mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 20:30:39 +02:00
Fixed #694, rewrite of URL configurations, admin linking fixed
This commit is contained in:
@@ -435,7 +435,7 @@ class page_admin_ui extends e_admin_ui
|
|||||||
protected $sortField = 'page_order';
|
protected $sortField = 'page_order';
|
||||||
protected $orderStep = 10;
|
protected $orderStep = 10;
|
||||||
//protected $url = array('profile'=>'page/view', 'name' => 'page_title', 'description' => '', 'link'=>'{e_BASE}page.php?id=[id]'); // 'link' only needed if profile not provided.
|
//protected $url = array('profile'=>'page/view', 'name' => 'page_title', 'description' => '', 'link'=>'{e_BASE}page.php?id=[id]'); // 'link' only needed if profile not provided.
|
||||||
protected $url = array('route'=>'page/view/index', 'vars' => array('id' => 'page_id', 'name' => 'page_sef', 'chapter' => 'chapter_sef', 'book' => 'book_sef'), 'name' => 'page_title', 'description' => ''); // 'link' only needed if profile not provided.
|
protected $url = array('route'=>'page/view/index', 'vars' => array('id' => 'page_id', 'name' => 'page_sef', 'other' => 'page_sef', 'chapter' => 'chapter_sef', 'book' => 'book_sef'), 'name' => 'page_title', 'description' => ''); // 'link' only needed if profile not provided.
|
||||||
protected $tabs = array("Page","Page Options","Menu", "Menu Options");
|
protected $tabs = array("Page","Page Options","Menu", "Menu Options");
|
||||||
protected $featurebox = array('name'=>'page_title', 'description'=>'page_text', 'image' => 'menu_image', 'visibility' => 'page_class', 'url' => true);
|
protected $featurebox = array('name'=>'page_title', 'description'=>'page_text', 'image' => 'menu_image', 'visibility' => 'page_class', 'url' => true);
|
||||||
|
|
||||||
|
@@ -326,7 +326,8 @@ class cpage_shortcodes extends e_shortcode
|
|||||||
$urldata = array_merge($this->var, $chapter);
|
$urldata = array_merge($this->var, $chapter);
|
||||||
$urldata['book_sef'] = $this->chapterData[$chapter['chapter_parent']]['chapter_sef'];
|
$urldata['book_sef'] = $this->chapterData[$chapter['chapter_parent']]['chapter_sef'];
|
||||||
}
|
}
|
||||||
return e107::getUrl()->create($route, $urldata, array('allow' => 'page_sef,page_title,page_id,chapter_sef,book_sef'));
|
|
||||||
|
return e107::getUrl()->create($route, $urldata, array('allow' => 'page_sef,page_id,chapter_sef,book_sef'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function sc_cpagemetadiz()
|
function sc_cpagemetadiz()
|
||||||
|
@@ -19,24 +19,19 @@ class core_page_sef_chapters_url extends eUrlConfig
|
|||||||
'format' => 'path', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
|
'format' => 'path', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
|
||||||
'defaultRoute' => 'view/index',// [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
|
'defaultRoute' => 'view/index',// [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
|
||||||
'urlSuffix' => '', // [optional] default empty; string to append to the URL (e.g. .html)
|
'urlSuffix' => '', // [optional] default empty; string to append to the URL (e.g. .html)
|
||||||
|
|
||||||
'mapVars' => array(
|
|
||||||
'page_id' => 'id',
|
|
||||||
'page_sef' => 'name',
|
|
||||||
),
|
|
||||||
|
|
||||||
'allowVars' => array(
|
'allowVars' => array(
|
||||||
'page',
|
'page',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
### using only title for pages is risky enough (empty sef for old DB's)
|
'rules' => array(
|
||||||
'rules' => array(
|
### match page view with no assigned chapter first to avoid namespace collisions
|
||||||
'<book:{sefsecure}>/<chapter:{sefsecure}>/<name:{secure}>' => array('view/index', 'allowVars' => false, 'mapVars' => array('page_id'=>'id', 'page_sef'=>'name', 'chapter_sef'=>'chapter', 'book_sef'=>'book'), 'legacyQuery' => '{name}.{page}', 'parseCallback' => 'itemIdByTitle'),
|
'item/<name:{secure}>' => array('view/other', 'mapVars' => array('page_id'=>'id', 'page_sef'=>'name'),'legacyQuery' => '{id}.{page}', 'parseCallback' => 'itemIdByTitle'),
|
||||||
'<book:{sefsecure}>/<name:{sefsecure}>' => array('chapter/index', 'allowVars' => false, 'mapVars' => array('chapter_id'=>'id', 'chapter_sef'=>'name', 'book_sef'=>'book'), 'legacyQuery' => 'ch={id}', 'parseCallback' => 'chapterIdByTitle'),
|
'<book:{sefsecure}>/<chapter:{sefsecure}>/<name:{secure}>' => array('view/index', 'mapVars' => array('page_id'=>'id', 'page_sef'=>'name', 'chapter_sef'=>'chapter', 'book_sef'=>'book'), 'legacyQuery' => '{id}.{page}', 'parseCallback' => 'itemIdByTitle'),
|
||||||
'<name:{sefsecure}>' => array('book/index', 'allowVars' => false, 'mapVars' => array('chapter_id'=>'id', 'chapter_sef'=>'name'), 'legacyQuery' => '{type}={id}', 'parseCallback' => 'chapterIdByTitle'),
|
'<book:{sefsecure}>/<name:{sefsecure}>' => array('chapter/index', 'allowVars' => false, 'mapVars' => array('chapter_id'=>'id', 'chapter_sef'=>'name', 'book_sef'=>'book'), 'legacyQuery' => 'ch={id}', 'parseCallback' => 'chapterIdByTitle'),
|
||||||
'<name:{secure}>' => array('view/other', 'allowVars' => false, 'legacyQuery' => '{type}={id}', 'parseCallback' => 'chapterIdByTitle'),
|
'<book:{sefsecure}>' => array('book/index', 'allowVars' => false, 'mapVars' => array('chapter_id'=>'id', 'chapter_sef'=>'book'), 'legacyQuery' => 'bk={id}', 'parseCallback' => 'chapterIdByTitle'),
|
||||||
'/' => array('list/index', 'legacyQuery' => '', ), // page list
|
'/' => array('list/index', 'allowVars' => false, 'legacyQuery' => '', ), // page list
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -98,7 +93,8 @@ class core_page_sef_chapters_url extends eUrlConfig
|
|||||||
{
|
{
|
||||||
$name = $sql->fetch();
|
$name = $sql->fetch();
|
||||||
//$request->setRequestParam('legacyQuery','{name}.{page}');
|
//$request->setRequestParam('legacyQuery','{name}.{page}');
|
||||||
$request->setRequestParam('name', $name['page_id']);
|
$request->setRequestParam('name', $name['page_id'])
|
||||||
|
->setRequestParam('id', $name['page_id']);
|
||||||
e107::getMessage()->addDebug("Set PAGE ID = '".$name['page_id']."'");
|
e107::getMessage()->addDebug("Set PAGE ID = '".$name['page_id']."'");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,7 +128,12 @@ class core_page_sef_chapters_url extends eUrlConfig
|
|||||||
public function chapterIdByTitle(eRequest $request)
|
public function chapterIdByTitle(eRequest $request)
|
||||||
{
|
{
|
||||||
$name = $request->getRequestParam('name');
|
$name = $request->getRequestParam('name');
|
||||||
|
if(null == $name)
|
||||||
|
{
|
||||||
|
// Book view
|
||||||
|
$name = $request->getRequestParam('book');
|
||||||
|
}
|
||||||
|
|
||||||
if(($id = $request->getRequestParam('id')))
|
if(($id = $request->getRequestParam('id')))
|
||||||
{
|
{
|
||||||
$request->setRequestParam('name', $id);
|
$request->setRequestParam('name', $id);
|
||||||
@@ -153,17 +154,19 @@ class core_page_sef_chapters_url extends eUrlConfig
|
|||||||
if($sql->select('page_chapters', 'chapter_id', "chapter_sef='{$name}'")) // First check books and chapters.
|
if($sql->select('page_chapters', 'chapter_id', "chapter_sef='{$name}'")) // First check books and chapters.
|
||||||
{
|
{
|
||||||
$name = $sql->fetch();
|
$name = $sql->fetch();
|
||||||
$request->setRequestParam('id', $name['chapter_id']);
|
$request->setRequestParam('id', $name['chapter_id'])
|
||||||
$request->setRequestParam('type', 'bk');
|
->setRequestParam('name', $name['chapter_id']);
|
||||||
|
|
||||||
|
//$request->setRequestParam('type', 'bk');
|
||||||
e107::getMessage()->addDebug("Set CHAPTER ID = '".$name['chapter_id']."'");
|
e107::getMessage()->addDebug("Set CHAPTER ID = '".$name['chapter_id']."'");
|
||||||
}
|
}
|
||||||
elseif($sql->select('page', 'page_id', "page_sef='{$name}'")) // fall back to pages.
|
/*elseif($sql->select('page', 'page_id', "page_sef='{$name}'")) // fall back to pages.
|
||||||
{
|
{
|
||||||
$name = $sql->fetch();
|
$name = $sql->fetch();
|
||||||
$request->setRequestParam('id', $name['page_id']);
|
$request->setRequestParam('id', $name['page_id']);
|
||||||
$request->setRequestParam('type', 'id');
|
$request->setRequestParam('type', 'id');
|
||||||
e107::getMessage()->addDebug("Set PAGE ID = '".$name['page_id']."'");
|
e107::getMessage()->addDebug("Set PAGE ID = '".$name['page_id']."'");
|
||||||
}
|
}*/
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(ADMIN)
|
if(ADMIN)
|
||||||
|
@@ -19,23 +19,19 @@ class core_page_sef_noid_url extends eUrlConfig
|
|||||||
'format' => 'path', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
|
'format' => 'path', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
|
||||||
'defaultRoute' => 'view/index',// [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
|
'defaultRoute' => 'view/index',// [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
|
||||||
'urlSuffix' => '', // [optional] default empty; string to append to the URL (e.g. .html)
|
'urlSuffix' => '', // [optional] default empty; string to append to the URL (e.g. .html)
|
||||||
|
|
||||||
'mapVars' => array(
|
|
||||||
'page_id' => 'id',
|
|
||||||
'page_sef' => 'name',
|
|
||||||
),
|
|
||||||
|
|
||||||
'allowVars' => array(
|
'allowVars' => array(
|
||||||
'page',
|
'page',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
### using only title for pages is risky enough (empty sef for old DB's)
|
'rules' => array(
|
||||||
'rules' => array(
|
|
||||||
'chapter/<name:{sefsecureOptional}>' => array('chapter/index', 'allowVars' => false, 'mapVars' => array('chapter_id'=>'id', 'chapter_sef'=>'name'), 'legacyQuery' => 'ch={id}', 'parseCallback' => 'chapterIdByTitle'),
|
'chapter/<name:{sefsecureOptional}>' => array('chapter/index', 'allowVars' => false, 'mapVars' => array('chapter_id'=>'id', 'chapter_sef'=>'name'), 'legacyQuery' => 'ch={id}', 'parseCallback' => 'chapterIdByTitle'),
|
||||||
'book/<name:{sefsecureOptional}>' => array('book/index', 'allowVars' => false, 'mapVars' => array('chapter_id'=>'id', 'chapter_sef'=>'name'), 'legacyQuery' => 'bk={id}', 'parseCallback' => 'chapterIdByTitle'),
|
'book/<name:{sefsecureOptional}>' => array('book/index', 'allowVars' => false, 'mapVars' => array('chapter_id'=>'id', 'chapter_sef'=>'name'), 'legacyQuery' => 'bk={id}', 'parseCallback' => 'chapterIdByTitle'),
|
||||||
'<name:{secure}>' => array('view/index', 'allowVars' => false, 'legacyQuery' => '{name}.{page}', 'parseCallback' => 'itemIdByTitle'),
|
'<name:{secure}>' => array('view/index', 'mapVars' => array('page_id'=>'id', 'page_sef'=>'name'), 'legacyQuery' => '{id}.{page}', 'parseCallback' => 'itemIdByTitle'),
|
||||||
'/' => array('list/index', 'legacyQuery' => '', ), // page list
|
### Used for assembling only
|
||||||
|
'<other:{secure}>' => array('view/other', 'mapVars' => array('page_id'=>'id', 'page_sef'=>'other'), 'legacyQuery' => '{id}.{page}', 'parseCallback' => 'itemIdByTitle'),
|
||||||
|
'/' => array('list/index', 'allowVars' => false, 'legacyQuery' => '', ), // page list
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -71,7 +67,7 @@ class core_page_sef_noid_url extends eUrlConfig
|
|||||||
public function itemIdByTitle(eRequest $request)
|
public function itemIdByTitle(eRequest $request)
|
||||||
{
|
{
|
||||||
$name = $request->getRequestParam('name');
|
$name = $request->getRequestParam('name');
|
||||||
|
|
||||||
// e107::getMessage()->addDebug('name = '.$name);
|
// e107::getMessage()->addDebug('name = '.$name);
|
||||||
// e107::getMessage()->addDebug(print_r($request,true));
|
// e107::getMessage()->addDebug(print_r($request,true));
|
||||||
// e107::getAdminLog()->toFile('page_sef_noid_url');
|
// e107::getAdminLog()->toFile('page_sef_noid_url');
|
||||||
@@ -96,7 +92,8 @@ class core_page_sef_noid_url extends eUrlConfig
|
|||||||
if($sql->select('page', 'page_id', "page_sef='{$name}'"))
|
if($sql->select('page', 'page_id', "page_sef='{$name}'"))
|
||||||
{
|
{
|
||||||
$name = $sql->fetch();
|
$name = $sql->fetch();
|
||||||
$request->setRequestParam('name', $name['page_id']);
|
$request->setRequestParam('name', $name['page_id'])
|
||||||
|
->setRequestParam('id', $name['page_id']);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -104,7 +101,8 @@ class core_page_sef_noid_url extends eUrlConfig
|
|||||||
{
|
{
|
||||||
e107::getMessage()->addError("Couldn't find a page with a SEF URL value of '".$name."'");
|
e107::getMessage()->addError("Couldn't find a page with a SEF URL value of '".$name."'");
|
||||||
}
|
}
|
||||||
$request->setRequestParam('name', 0);
|
$request->setRequestParam('name', 0)
|
||||||
|
->setRequestParam('id', 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +134,8 @@ class core_page_sef_noid_url extends eUrlConfig
|
|||||||
if($sql->select('page_chapters', 'chapter_id', "chapter_sef='{$name}'"))
|
if($sql->select('page_chapters', 'chapter_id', "chapter_sef='{$name}'"))
|
||||||
{
|
{
|
||||||
$name = $sql->fetch();
|
$name = $sql->fetch();
|
||||||
$request->setRequestParam('id', $name['chapter_id']);
|
$request->setRequestParam('id', $name['chapter_id'])
|
||||||
|
->setRequestParam('name', $name['chapter_id']);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -144,7 +143,8 @@ class core_page_sef_noid_url extends eUrlConfig
|
|||||||
{
|
{
|
||||||
e107::getMessage()->addError("Couldn't find a book or chapter with a SEF URL value of '".$name."'");
|
e107::getMessage()->addError("Couldn't find a book or chapter with a SEF URL value of '".$name."'");
|
||||||
}
|
}
|
||||||
$request->setRequestParam('id', 0);
|
$request->setRequestParam('id', 0)
|
||||||
|
->setRequestParam('name', 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -31,10 +31,11 @@ class core_page_sef_url extends eUrlConfig
|
|||||||
),
|
),
|
||||||
|
|
||||||
'rules' => array(
|
'rules' => array(
|
||||||
### using only title for pages is risky enough (non-unique title, possible bad characters)
|
|
||||||
'<id:{number}>/<name:{sefsecureOptional}>' => array('view/index', 'legacyQuery' => '{id}.{page}', ),
|
'<id:{number}>/<name:{sefsecureOptional}>' => array('view/index', 'legacyQuery' => '{id}.{page}', ),
|
||||||
'chapter/<id:{number}>/<name:{sefsecureOptional}>' => array('chapter/index', 'mapVars' => array('chapter_id'=>'id','chapter_sef'=>'name'), 'legacyQuery' => 'ch={id}' ),
|
### Used for assembling only
|
||||||
'book/<id:{number}>/<name:{sefsecureOptional}>' => array('book/index', 'mapVars' => array('chapter_id'=>'id','chapter_sef'=>'name'), 'legacyQuery' => 'bk={id}' ),
|
'<id:{number}>/<other:{sefsecureOptional}>' => array('view/other', 'mapVars' => array('page_id'=>'id', 'page_sef'=>'other'), 'legacyQuery' => '{id}.{page}', ),
|
||||||
|
'chapter/<id:{number}>/<name:{sefsecureOptional}>' => array('chapter/index', 'allowVars' => false, 'mapVars' => array('chapter_id'=>'id','chapter_sef'=>'name'), 'legacyQuery' => 'ch={id}' ),
|
||||||
|
'book/<id:{number}>/<name:{sefsecureOptional}>' => array('book/index', 'allowVars' => false, 'mapVars' => array('chapter_id'=>'id','chapter_sef'=>'name'), 'legacyQuery' => 'bk={id}' ),
|
||||||
|
|
||||||
### page list
|
### page list
|
||||||
'/' => array('list/index', 'legacyQuery' => '', ),
|
'/' => array('list/index', 'legacyQuery' => '', ),
|
||||||
|
Reference in New Issue
Block a user