prettyurls multiple 'backend'
This commit is contained in:
parent
fbbe7acc4e
commit
35bcf84f57
@ -7,14 +7,30 @@
|
|||||||
$lang['admin']['plugin']['submenu']['prettyurls'] = 'PrettyURLs Config';
|
$lang['admin']['plugin']['submenu']['prettyurls'] = 'PrettyURLs Config';
|
||||||
$lang['admin']['plugin']['prettyurls'] = array(
|
$lang['admin']['plugin']['prettyurls'] = array(
|
||||||
'head' => 'PrettyURLs Configuration',
|
'head' => 'PrettyURLs Configuration',
|
||||||
|
'htaccess' => '.htaccess',
|
||||||
'description'=>'This raw editor let you edit your '.
|
'description'=>'This raw editor let you edit your '.
|
||||||
'<code><a class="hint" href="http://wiki.flatpress.org/doc:plugins:prettyurls#htaccess">.htaccess</a></code>.',
|
'<code><a class="hint" href="http://wiki.flatpress.org/doc:plugins:prettyurls#htaccess">.htaccess</a></code>.',
|
||||||
'cantsave' => 'You can\'t edit this file, because it\'s not <strong>writable</strong>. You can give writing permission or copy and paste to a file and then upload as <a class="hint" href="http://wiki.flatpress.org/doc:plugins:prettyurls#manual_upload">described here</a>',
|
'cantsave' => 'You can\'t edit this file, because it\'s not <strong>writable</strong>. You can give writing permission or copy and paste to a file and then upload as <a class="hint" href="http://wiki.flatpress.org/doc:plugins:prettyurls#manual_upload">described here</a>',
|
||||||
'submit' => 'Save'
|
'mode' => 'Mode',
|
||||||
|
'auto' => 'Automatic',
|
||||||
|
'autodescr' => 'try to guess the best choice for me',
|
||||||
|
'pathinfo' => 'Path Info',
|
||||||
|
'pathinfodescr' => 'e.g. /index.php/2011/01/01/hello-world/',
|
||||||
|
'httpget' => 'HTTP Get',
|
||||||
|
'httpgetdescr'=> 'e.g. /?u=/2011/01/01/hello-world/',
|
||||||
|
'pretty' => 'Pretty',
|
||||||
|
'prettydescr'=> 'e.g. /2011/01/01/hello-world/',
|
||||||
|
|
||||||
|
'saveopt' => 'Save settings',
|
||||||
|
|
||||||
|
'submit' => 'Save .htaccess'
|
||||||
);
|
);
|
||||||
$lang['admin']['plugin']['prettyurls']['msgs'] = array(
|
$lang['admin']['plugin']['prettyurls']['msgs'] = array(
|
||||||
1 => '.htaccess saved successfully',
|
1 => '.htaccess saved successfully',
|
||||||
-1 => '.htaccess could not be saved (do you have writing permissions on <code>'. BLOG_ROOT .'</code>)?'
|
-1 => '.htaccess could not be saved (do you have writing permissions on <code>'. BLOG_ROOT .'</code>)?',
|
||||||
|
|
||||||
|
2 => 'Options saved successfully',
|
||||||
|
-2 => 'An error occurred attempting to save settings',
|
||||||
);
|
);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -230,6 +230,34 @@ class Plugin_PrettyURLs {
|
|||||||
$this->fp_params['feed'] = isset($matches[2])? $matches[2]:'rss2';
|
$this->fp_params['feed'] = isset($matches[2])? $matches[2]:'rss2';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function get_url() {
|
||||||
|
$baseurl = BLOG_BASEURL;
|
||||||
|
$opt = plugin_getoptions('prettyurls', 'mode');
|
||||||
|
$url = substr($_SERVER['REQUEST_URI'], strlen(BLOG_ROOT)-1);
|
||||||
|
|
||||||
|
switch($opt) {
|
||||||
|
case null:
|
||||||
|
case 0:
|
||||||
|
$opt = file_exists(ABS_PATH . '.htaccess') ? 3 : 1;
|
||||||
|
case 1:
|
||||||
|
$baseurl .= 'index.php/';
|
||||||
|
$url = $_SERVER['PATH_INFO'];
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
$baseurl .= '?u=/';
|
||||||
|
$url = @$_GET['u'];
|
||||||
|
/* case 3: do nothing, it's BLOG_BASEURL */
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->baseurl = $baseurl;
|
||||||
|
$this->mode = $opt;
|
||||||
|
|
||||||
|
return $url;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* here is where the real work is done.
|
* here is where the real work is done.
|
||||||
@ -251,7 +279,7 @@ class Plugin_PrettyURLs {
|
|||||||
global $fp_params;
|
global $fp_params;
|
||||||
|
|
||||||
$this->fp_params =& $fp_params;
|
$this->fp_params =& $fp_params;
|
||||||
$this->baseurl = PRETTYURLS_PATHINFO? BLOG_BASEURL . 'index.php/' : BLOG_BASEURL;
|
$url = $this->get_url();
|
||||||
|
|
||||||
if (PRETTYURLS_TITLES) {
|
if (PRETTYURLS_TITLES) {
|
||||||
#if ($f = io_load_file(PRETTYURLS_CACHE))
|
#if ($f = io_load_file(PRETTYURLS_CACHE))
|
||||||
@ -264,21 +292,21 @@ class Plugin_PrettyURLs {
|
|||||||
$this->categories(false);
|
$this->categories(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!defined('MOD_INDEX'))
|
if (!defined('MOD_INDEX'))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
# this is not working if you reach flatpress via symlink
|
|
||||||
# unless you don't edit manually defaults.php
|
|
||||||
if (strpos($_SERVER['REQUEST_URI'], BLOG_ROOT)!==false) {
|
|
||||||
$url = $_SERVER['REQUEST_URI'];
|
|
||||||
$del = BLOG_ROOT;
|
|
||||||
if (strpos($url, 'index.php')!==false)
|
|
||||||
$del = $del . 'index.php/';
|
|
||||||
$url = substr($url, strlen($del)-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
// # this is not working if you reach flatpress via symlink
|
||||||
|
// # unless you don't edit manually defaults.php
|
||||||
|
// if (strpos($_SERVER['REQUEST_URI'], BLOG_ROOT)!==false) {
|
||||||
|
// $url = $_SERVER['REQUEST_URI'];
|
||||||
|
// $del = BLOG_ROOT;
|
||||||
|
// if (strpos($url, 'index.php')!==false)
|
||||||
|
// $del = $del . 'index.php/';
|
||||||
|
// $url = substr($url, strlen($del)-1);
|
||||||
|
// }
|
||||||
|
|
||||||
// removes querystrings
|
// removes querystrings
|
||||||
if (false !== $i = strpos($url, '?'))
|
if (false !== $i = strpos($url, '?'))
|
||||||
$url = substr($url, 0, $i);
|
$url = substr($url, 0, $i);
|
||||||
@ -549,9 +577,12 @@ if (class_exists('AdminPanelAction')){
|
|||||||
class admin_plugin_prettyurls extends AdminPanelAction {
|
class admin_plugin_prettyurls extends AdminPanelAction {
|
||||||
|
|
||||||
var $langres = 'plugin:prettyurls';
|
var $langres = 'plugin:prettyurls';
|
||||||
|
var $_config = array('mode'=>0);
|
||||||
|
|
||||||
function setup() {
|
function setup() {
|
||||||
$this->smarty->assign('admin_resource', "plugin:prettyurls/admin.plugin.prettyurls");
|
$this->smarty->assign('admin_resource', "plugin:prettyurls/admin.plugin.prettyurls");
|
||||||
|
$this->_config['mode'] = plugin_getoptions('prettyurls', 'mode');
|
||||||
|
$this->smarty->assign('pconfig', $this->_config);
|
||||||
$blogroot = BLOG_ROOT;
|
$blogroot = BLOG_ROOT;
|
||||||
$f = ABS_PATH . '.htaccess';
|
$f = ABS_PATH . '.htaccess';
|
||||||
$txt = io_load_file($f);
|
$txt = io_load_file($f);
|
||||||
@ -582,11 +613,21 @@ STR;
|
|||||||
|
|
||||||
function onsubmit() {
|
function onsubmit() {
|
||||||
global $fp_config;
|
global $fp_config;
|
||||||
|
|
||||||
|
if (isset($_POST['saveopt'])) {
|
||||||
|
$this->_config['mode'] = (int) $_POST['mode'] ;
|
||||||
|
plugin_addoption('prettyurls', 'mode', $this->_config['mode']);
|
||||||
|
if( plugin_saveoptions() )
|
||||||
|
$this->smarty->assign('success', 2);
|
||||||
|
else $this->smarty->assign('success', -2);
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($_POST['htaccess']) && io_write_file(ABS_PATH.'.htaccess', $_POST['htaccess'])){
|
if (isset($_POST['htaccess-submit'])) {
|
||||||
$this->smarty->assign('success', 1);
|
if (!empty($_POST['htaccess']) && io_write_file(ABS_PATH.'.htaccess', $_POST['htaccess'])){
|
||||||
} else {
|
$this->smarty->assign('success', 1);
|
||||||
$this->smarty->assign('success', -1);
|
} else {
|
||||||
|
$this->smarty->assign('success', -1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 2;
|
return 2;
|
||||||
|
@ -1,11 +1,36 @@
|
|||||||
<h2>{$plang.head}</h2>
|
<h2>{$plang.head}</h2>
|
||||||
<p>{$plang.description}</p>
|
|
||||||
|
|
||||||
{include file=shared:errorlist.tpl}
|
{include file=shared:errorlist.tpl}
|
||||||
|
|
||||||
|
|
||||||
{html_form}
|
{html_form}
|
||||||
|
|
||||||
|
|
||||||
|
<h3>{$plang.mode} </h3>{debug}
|
||||||
|
<dl>
|
||||||
|
<dt><label><input type="radio" name="mode" value="0" {if $pconfig.mode == 0 }checked=checked{/if}>
|
||||||
|
{$plang.auto} </label> </dt>
|
||||||
|
<dd>{$plang.autodescr}</dd>
|
||||||
|
<dt><label><input type="radio" name="mode" value="1" {if $pconfig.mode==1}checked=checked{/if}>
|
||||||
|
{$plang.pathinfo} </label> </dt>
|
||||||
|
<dd>{$plang.pathinfodescr}</dd>
|
||||||
|
<dt><label><input type="radio" name="mode" value="2" {if $pconfig.mode==2}checked=checked{/if}>
|
||||||
|
{$plang.httpget} </label> </dt>
|
||||||
|
<dd>{$plang.httpgetdescr}</dd>
|
||||||
|
<dt><label><input type="radio" name="mode" value="3" {if $pconfig.mode==3}checked=checked{/if}>
|
||||||
|
{$plang.pretty} </label> </dt>
|
||||||
|
<dd>{$plang.prettydescr}</dd>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<div class="buttonbar">
|
||||||
|
<input type="submit" name="saveopt" value="{$plang.saveopt}" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3>{$plang.htaccess}</h3>
|
||||||
|
|
||||||
|
<p>{$plang.description}</p>
|
||||||
<p>
|
<p>
|
||||||
<textarea id="htaccess" name="htaccess"
|
<textarea id="htaccess" name="htaccess"
|
||||||
{if $cantsave}readonly="readonly" {/if}cols="70" rows="16">{$htaccess|escape:'html'}</textarea>
|
{if $cantsave}readonly="readonly" {/if}cols="70" rows="16">{$htaccess|escape:'html'}</textarea>
|
||||||
@ -15,8 +40,8 @@
|
|||||||
{if $cantsave}
|
{if $cantsave}
|
||||||
<p><em>{$plang.cantsave}</em></p>
|
<p><em>{$plang.cantsave}</em></p>
|
||||||
{else}
|
{else}
|
||||||
<input type="submit" value="{$plang.submit}"/>
|
<input type="submit" name="htaccess-submit" value="{$plang.submit}"/>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/html_form}
|
{/html_form}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user