mirror of
https://github.com/e107inc/e107.git
synced 2025-08-18 12:21:45 +02:00
Renormalized all text file line endings
This commit is contained in:
@@ -1,151 +1,151 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
|
||||
* $Id$
|
||||
*
|
||||
* Custom page routing config
|
||||
*/
|
||||
if (!defined('e107_INIT')){ exit; }
|
||||
|
||||
class core_page_sef_noid_url extends eUrlConfig
|
||||
{
|
||||
public function config()
|
||||
{
|
||||
return array(
|
||||
|
||||
'config' => array(
|
||||
'allowMain' => true,
|
||||
'legacy' => '{e_BASE}page.php', // [optional] default empty; if it's a legacy module (no single entry point support) - URL to the entry point script
|
||||
'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/
|
||||
'urlSuffix' => '', // [optional] default empty; string to append to the URL (e.g. .html)
|
||||
|
||||
'allowVars' => array(
|
||||
'page',
|
||||
),
|
||||
),
|
||||
|
||||
'rules' => array(
|
||||
'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'),
|
||||
'<name:{secure}>' => array('view/index', 'mapVars' => array('page_id'=>'id', 'page_sef'=>'name'), 'legacyQuery' => '{id}.{page}', 'parseCallback' => 'itemIdByTitle'),
|
||||
### 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
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin callback
|
||||
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
|
||||
*/
|
||||
public function admin()
|
||||
{
|
||||
// static may be used for performance
|
||||
static $admin = array(
|
||||
'labels' => array(
|
||||
'name' => LAN_EURL_CORE_PAGE, // Module name
|
||||
'label' => LAN_EURL_PAGE_SEFNOID_LABEL, // Current profile name
|
||||
'description' => LAN_EURL_PAGE_SEFNOID_DESCR, //
|
||||
'examples' => array("{SITEURL}page/page-title")
|
||||
),
|
||||
'generate' => array('table'=> 'page', 'primary'=>'page_id', 'input'=>'page_title', 'output'=>'page_sef'),
|
||||
'form' => array(), // Under construction - additional configuration options
|
||||
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
|
||||
);
|
||||
|
||||
return $admin;
|
||||
}
|
||||
|
||||
### CUSTOM METHODS ###
|
||||
|
||||
/**
|
||||
* view/item by name callback
|
||||
* @param eRequest $request
|
||||
*/
|
||||
public function itemIdByTitle(eRequest $request)
|
||||
{
|
||||
$name = $request->getRequestParam('name');
|
||||
|
||||
// e107::getMessage()->addDebug('name = '.$name);
|
||||
// e107::getMessage()->addDebug(print_r($request,true));
|
||||
// e107::getAdminLog()->toFile('page_sef_noid_url');
|
||||
|
||||
if(($id = $request->getRequestParam('id')))
|
||||
{
|
||||
$request->setRequestParam('name', $id);
|
||||
return;
|
||||
}
|
||||
elseif(!$name || is_numeric($name))
|
||||
{
|
||||
if(ADMIN)
|
||||
{
|
||||
e107::getMessage()->addError("One of your pages is missing a SEF URL value");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$sql = e107::getDb('url');
|
||||
$name = e107::getParser()->toDB($name);
|
||||
|
||||
if($sql->select('page', 'page_id', "page_sef='{$name}'"))
|
||||
{
|
||||
$name = $sql->fetch();
|
||||
$request->setRequestParam('name', $name['page_id'])
|
||||
->setRequestParam('id', $name['page_id']);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ADMIN)
|
||||
{
|
||||
e107::getMessage()->addError("Couldn't find a page with a SEF URL value of '".$name."'");
|
||||
}
|
||||
$request->setRequestParam('name', 0)
|
||||
->setRequestParam('id', 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* chapter/index and book/index by name callback
|
||||
* @param eRequest $request
|
||||
*/
|
||||
public function chapterIdByTitle(eRequest $request)
|
||||
{
|
||||
$name = $request->getRequestParam('name');
|
||||
|
||||
if(($id = $request->getRequestParam('id')))
|
||||
{
|
||||
$request->setRequestParam('name', $id);
|
||||
return;
|
||||
}
|
||||
elseif(!$name || is_numeric($name))
|
||||
{
|
||||
if(ADMIN)
|
||||
{
|
||||
e107::getMessage()->addError("One of your page-chapters is missing a SEF URL value");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$sql = e107::getDb('url');
|
||||
$name = e107::getParser()->toDB($name);
|
||||
|
||||
if($sql->select('page_chapters', 'chapter_id', "chapter_sef='{$name}'"))
|
||||
{
|
||||
$name = $sql->fetch();
|
||||
$request->setRequestParam('id', $name['chapter_id'])
|
||||
->setRequestParam('name', $name['chapter_id']);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ADMIN)
|
||||
{
|
||||
e107::getMessage()->addError("Couldn't find a book or chapter with a SEF URL value of '".$name."'");
|
||||
}
|
||||
$request->setRequestParam('id', 0)
|
||||
->setRequestParam('name', 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
|
||||
* $Id$
|
||||
*
|
||||
* Custom page routing config
|
||||
*/
|
||||
if (!defined('e107_INIT')){ exit; }
|
||||
|
||||
class core_page_sef_noid_url extends eUrlConfig
|
||||
{
|
||||
public function config()
|
||||
{
|
||||
return array(
|
||||
|
||||
'config' => array(
|
||||
'allowMain' => true,
|
||||
'legacy' => '{e_BASE}page.php', // [optional] default empty; if it's a legacy module (no single entry point support) - URL to the entry point script
|
||||
'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/
|
||||
'urlSuffix' => '', // [optional] default empty; string to append to the URL (e.g. .html)
|
||||
|
||||
'allowVars' => array(
|
||||
'page',
|
||||
),
|
||||
),
|
||||
|
||||
'rules' => array(
|
||||
'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'),
|
||||
'<name:{secure}>' => array('view/index', 'mapVars' => array('page_id'=>'id', 'page_sef'=>'name'), 'legacyQuery' => '{id}.{page}', 'parseCallback' => 'itemIdByTitle'),
|
||||
### 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
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin callback
|
||||
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
|
||||
*/
|
||||
public function admin()
|
||||
{
|
||||
// static may be used for performance
|
||||
static $admin = array(
|
||||
'labels' => array(
|
||||
'name' => LAN_EURL_CORE_PAGE, // Module name
|
||||
'label' => LAN_EURL_PAGE_SEFNOID_LABEL, // Current profile name
|
||||
'description' => LAN_EURL_PAGE_SEFNOID_DESCR, //
|
||||
'examples' => array("{SITEURL}page/page-title")
|
||||
),
|
||||
'generate' => array('table'=> 'page', 'primary'=>'page_id', 'input'=>'page_title', 'output'=>'page_sef'),
|
||||
'form' => array(), // Under construction - additional configuration options
|
||||
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
|
||||
);
|
||||
|
||||
return $admin;
|
||||
}
|
||||
|
||||
### CUSTOM METHODS ###
|
||||
|
||||
/**
|
||||
* view/item by name callback
|
||||
* @param eRequest $request
|
||||
*/
|
||||
public function itemIdByTitle(eRequest $request)
|
||||
{
|
||||
$name = $request->getRequestParam('name');
|
||||
|
||||
// e107::getMessage()->addDebug('name = '.$name);
|
||||
// e107::getMessage()->addDebug(print_r($request,true));
|
||||
// e107::getAdminLog()->toFile('page_sef_noid_url');
|
||||
|
||||
if(($id = $request->getRequestParam('id')))
|
||||
{
|
||||
$request->setRequestParam('name', $id);
|
||||
return;
|
||||
}
|
||||
elseif(!$name || is_numeric($name))
|
||||
{
|
||||
if(ADMIN)
|
||||
{
|
||||
e107::getMessage()->addError("One of your pages is missing a SEF URL value");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$sql = e107::getDb('url');
|
||||
$name = e107::getParser()->toDB($name);
|
||||
|
||||
if($sql->select('page', 'page_id', "page_sef='{$name}'"))
|
||||
{
|
||||
$name = $sql->fetch();
|
||||
$request->setRequestParam('name', $name['page_id'])
|
||||
->setRequestParam('id', $name['page_id']);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ADMIN)
|
||||
{
|
||||
e107::getMessage()->addError("Couldn't find a page with a SEF URL value of '".$name."'");
|
||||
}
|
||||
$request->setRequestParam('name', 0)
|
||||
->setRequestParam('id', 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* chapter/index and book/index by name callback
|
||||
* @param eRequest $request
|
||||
*/
|
||||
public function chapterIdByTitle(eRequest $request)
|
||||
{
|
||||
$name = $request->getRequestParam('name');
|
||||
|
||||
if(($id = $request->getRequestParam('id')))
|
||||
{
|
||||
$request->setRequestParam('name', $id);
|
||||
return;
|
||||
}
|
||||
elseif(!$name || is_numeric($name))
|
||||
{
|
||||
if(ADMIN)
|
||||
{
|
||||
e107::getMessage()->addError("One of your page-chapters is missing a SEF URL value");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$sql = e107::getDb('url');
|
||||
$name = e107::getParser()->toDB($name);
|
||||
|
||||
if($sql->select('page_chapters', 'chapter_id', "chapter_sef='{$name}'"))
|
||||
{
|
||||
$name = $sql->fetch();
|
||||
$request->setRequestParam('id', $name['chapter_id'])
|
||||
->setRequestParam('name', $name['chapter_id']);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ADMIN)
|
||||
{
|
||||
e107::getMessage()->addError("Couldn't find a book or chapter with a SEF URL value of '".$name."'");
|
||||
}
|
||||
$request->setRequestParam('id', 0)
|
||||
->setRequestParam('name', 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,67 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
|
||||
* $Id$
|
||||
*
|
||||
* Custom page routing config
|
||||
*/
|
||||
if (!defined('e107_INIT')){ exit; }
|
||||
|
||||
class core_page_sef_url extends eUrlConfig
|
||||
{
|
||||
public function config()
|
||||
{
|
||||
return array(
|
||||
|
||||
'config' => array(
|
||||
'allowMain' => true,
|
||||
'legacy' => '{e_BASE}page.php', // [optional] default empty; if it's a legacy module (no single entry point support) - URL to the entry point script
|
||||
'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/
|
||||
'urlSuffix' => '', // [optional] default empty; string to append to the URL (e.g. .html)
|
||||
|
||||
'mapVars' => array(
|
||||
'page_id' => 'id',
|
||||
'page_sef' => 'name',
|
||||
),
|
||||
|
||||
'allowVars' => array(
|
||||
'page',
|
||||
),
|
||||
),
|
||||
|
||||
'rules' => array(
|
||||
'<id:{number}>/<name:{sefsecureOptional}>' => array('view/index', 'legacyQuery' => '{id}.{page}', ),
|
||||
### Used for assembling only
|
||||
'<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
|
||||
'/' => array('list/index', 'legacyQuery' => '', ),
|
||||
) // rule set array
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin callback
|
||||
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
|
||||
*/
|
||||
public function admin()
|
||||
{
|
||||
// static may be used for performance
|
||||
static $admin = array(
|
||||
'labels' => array(
|
||||
'name' => LAN_EURL_CORE_PAGE, // Module name
|
||||
'label' => LAN_EURL_PAGE_SEF_LABEL, // Current profile name
|
||||
'description' => LAN_EURL_PAGE_SEF_DESCR, //
|
||||
'examples' => array("{SITEURL}page/1/page-name")
|
||||
),
|
||||
'generate' => array('table'=> 'page', 'primary'=>'page_id', 'input'=>'page_title', 'output'=>'page_sef'),
|
||||
'form' => array(), // Under construction - additional configuration options
|
||||
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
|
||||
);
|
||||
|
||||
return $admin;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
|
||||
* $Id$
|
||||
*
|
||||
* Custom page routing config
|
||||
*/
|
||||
if (!defined('e107_INIT')){ exit; }
|
||||
|
||||
class core_page_sef_url extends eUrlConfig
|
||||
{
|
||||
public function config()
|
||||
{
|
||||
return array(
|
||||
|
||||
'config' => array(
|
||||
'allowMain' => true,
|
||||
'legacy' => '{e_BASE}page.php', // [optional] default empty; if it's a legacy module (no single entry point support) - URL to the entry point script
|
||||
'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/
|
||||
'urlSuffix' => '', // [optional] default empty; string to append to the URL (e.g. .html)
|
||||
|
||||
'mapVars' => array(
|
||||
'page_id' => 'id',
|
||||
'page_sef' => 'name',
|
||||
),
|
||||
|
||||
'allowVars' => array(
|
||||
'page',
|
||||
),
|
||||
),
|
||||
|
||||
'rules' => array(
|
||||
'<id:{number}>/<name:{sefsecureOptional}>' => array('view/index', 'legacyQuery' => '{id}.{page}', ),
|
||||
### Used for assembling only
|
||||
'<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
|
||||
'/' => array('list/index', 'legacyQuery' => '', ),
|
||||
) // rule set array
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin callback
|
||||
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
|
||||
*/
|
||||
public function admin()
|
||||
{
|
||||
// static may be used for performance
|
||||
static $admin = array(
|
||||
'labels' => array(
|
||||
'name' => LAN_EURL_CORE_PAGE, // Module name
|
||||
'label' => LAN_EURL_PAGE_SEF_LABEL, // Current profile name
|
||||
'description' => LAN_EURL_PAGE_SEF_DESCR, //
|
||||
'examples' => array("{SITEURL}page/1/page-name")
|
||||
),
|
||||
'generate' => array('table'=> 'page', 'primary'=>'page_id', 'input'=>'page_title', 'output'=>'page_sef'),
|
||||
'form' => array(), // Under construction - additional configuration options
|
||||
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
|
||||
);
|
||||
|
||||
return $admin;
|
||||
}
|
||||
}
|
||||
|
@@ -1,131 +1,131 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
|
||||
* $Id$
|
||||
*
|
||||
* Custom page routing config
|
||||
*/
|
||||
if (!defined('e107_INIT')){ exit; }
|
||||
|
||||
class core_page_url extends eUrlConfig
|
||||
{
|
||||
public function config()
|
||||
{
|
||||
return array(
|
||||
|
||||
'config' => array(
|
||||
'noSingleEntry' => true, // [optional] default false; disallow this module to be shown via single entry point when this config is used
|
||||
'legacy' => '{e_BASE}page.php', // [optional] default empty; if it's a legacy module (no single entry point support) - URL to the entry point script
|
||||
'format' => 'get', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
|
||||
'selfParse' => true, // [optional] default false; use only this->parse() method, no core routine URL parsing
|
||||
'selfCreate' => true, // [optional] default false; use only this->create() method, no core routine URL creating
|
||||
'defaultRoute' => '', // [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
|
||||
'errorRoute' => '', // [optional] default empty; route (no leading module) used when module is found but no inner route is matched, leave empty to force error 404 page
|
||||
'urlSuffix' => '', // [optional] default empty; string to append to the URL (e.g. .html)
|
||||
'mapVars' => array(),
|
||||
'allowVars' => array(),
|
||||
),
|
||||
|
||||
'rules' => array() // rule set array
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function create($route, $params = array(), $options = array())
|
||||
{
|
||||
if(!$params) return 'page.php';
|
||||
|
||||
if(is_string($route))
|
||||
{
|
||||
$route = explode('/', $route, 2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(!varset($route[1])) $route[1] = 'index';
|
||||
|
||||
$url = 'page.php?';
|
||||
|
||||
if(isset($params['chapter_id']) && !empty($params['chapter_id']))
|
||||
{
|
||||
$params['id'] = $params['chapter_id'];
|
||||
}
|
||||
|
||||
switch ($route[0])
|
||||
{
|
||||
case 'book':
|
||||
|
||||
if(!empty($params['book_id']))
|
||||
{
|
||||
$params['id'] = $params['book_id'];
|
||||
}
|
||||
|
||||
$url .= "bk=".intval($params['id']);
|
||||
break;
|
||||
|
||||
case 'chapter':
|
||||
$url .= "ch=".intval($params['id']);
|
||||
break;
|
||||
|
||||
case 'view':
|
||||
default:
|
||||
## aliases as retrieved from the DB, map vars to proper values
|
||||
if(isset($params['page_title']) && !empty($params['page_title']))
|
||||
{
|
||||
$params['name'] = $params['page_title'];
|
||||
}
|
||||
|
||||
if(isset($params['page_id']) && !empty($params['page_id']))
|
||||
{
|
||||
$params['id'] = $params['page_id'];
|
||||
}
|
||||
|
||||
if('--FROM--' != vartrue($params['page']))
|
||||
{
|
||||
$page = varset($params['page']) ? intval($params['page']) : '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
$page = '--FROM--';
|
||||
}
|
||||
|
||||
$url .= "id=".intval($params['id']).($page ? '.'.$page : '');
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin callback
|
||||
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
|
||||
*/
|
||||
public function admin()
|
||||
{
|
||||
// static may be used for performance
|
||||
static $admin = array(
|
||||
'labels' => array(
|
||||
'name' => LAN_EURL_CORE_PAGE, // Module name
|
||||
'label' => LAN_EURL_DEFAULT, // Current profile name
|
||||
'description' => LAN_EURL_LEGACY, //
|
||||
'examples' => array("{SITEURL}page.php?1","{SITEURL}page.php?id=1")
|
||||
),
|
||||
'form' => array(), // Under construction - additional configuration options
|
||||
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
|
||||
);
|
||||
|
||||
return $admin;
|
||||
}
|
||||
|
||||
public function parse($pathInfo, $params = array(), eRequest $request = null, eRouter $router = null, $config = array())
|
||||
{
|
||||
// this config doesn't support parsing, it's done by the module entry script (news.php)
|
||||
// this means News are not available via single entry point if this config is currently active
|
||||
return false;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
|
||||
* $Id$
|
||||
*
|
||||
* Custom page routing config
|
||||
*/
|
||||
if (!defined('e107_INIT')){ exit; }
|
||||
|
||||
class core_page_url extends eUrlConfig
|
||||
{
|
||||
public function config()
|
||||
{
|
||||
return array(
|
||||
|
||||
'config' => array(
|
||||
'noSingleEntry' => true, // [optional] default false; disallow this module to be shown via single entry point when this config is used
|
||||
'legacy' => '{e_BASE}page.php', // [optional] default empty; if it's a legacy module (no single entry point support) - URL to the entry point script
|
||||
'format' => 'get', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
|
||||
'selfParse' => true, // [optional] default false; use only this->parse() method, no core routine URL parsing
|
||||
'selfCreate' => true, // [optional] default false; use only this->create() method, no core routine URL creating
|
||||
'defaultRoute' => '', // [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
|
||||
'errorRoute' => '', // [optional] default empty; route (no leading module) used when module is found but no inner route is matched, leave empty to force error 404 page
|
||||
'urlSuffix' => '', // [optional] default empty; string to append to the URL (e.g. .html)
|
||||
'mapVars' => array(),
|
||||
'allowVars' => array(),
|
||||
),
|
||||
|
||||
'rules' => array() // rule set array
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function create($route, $params = array(), $options = array())
|
||||
{
|
||||
if(!$params) return 'page.php';
|
||||
|
||||
if(is_string($route))
|
||||
{
|
||||
$route = explode('/', $route, 2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(!varset($route[1])) $route[1] = 'index';
|
||||
|
||||
$url = 'page.php?';
|
||||
|
||||
if(isset($params['chapter_id']) && !empty($params['chapter_id']))
|
||||
{
|
||||
$params['id'] = $params['chapter_id'];
|
||||
}
|
||||
|
||||
switch ($route[0])
|
||||
{
|
||||
case 'book':
|
||||
|
||||
if(!empty($params['book_id']))
|
||||
{
|
||||
$params['id'] = $params['book_id'];
|
||||
}
|
||||
|
||||
$url .= "bk=".intval($params['id']);
|
||||
break;
|
||||
|
||||
case 'chapter':
|
||||
$url .= "ch=".intval($params['id']);
|
||||
break;
|
||||
|
||||
case 'view':
|
||||
default:
|
||||
## aliases as retrieved from the DB, map vars to proper values
|
||||
if(isset($params['page_title']) && !empty($params['page_title']))
|
||||
{
|
||||
$params['name'] = $params['page_title'];
|
||||
}
|
||||
|
||||
if(isset($params['page_id']) && !empty($params['page_id']))
|
||||
{
|
||||
$params['id'] = $params['page_id'];
|
||||
}
|
||||
|
||||
if('--FROM--' != vartrue($params['page']))
|
||||
{
|
||||
$page = varset($params['page']) ? intval($params['page']) : '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
$page = '--FROM--';
|
||||
}
|
||||
|
||||
$url .= "id=".intval($params['id']).($page ? '.'.$page : '');
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin callback
|
||||
* Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
|
||||
*/
|
||||
public function admin()
|
||||
{
|
||||
// static may be used for performance
|
||||
static $admin = array(
|
||||
'labels' => array(
|
||||
'name' => LAN_EURL_CORE_PAGE, // Module name
|
||||
'label' => LAN_EURL_DEFAULT, // Current profile name
|
||||
'description' => LAN_EURL_LEGACY, //
|
||||
'examples' => array("{SITEURL}page.php?1","{SITEURL}page.php?id=1")
|
||||
),
|
||||
'form' => array(), // Under construction - additional configuration options
|
||||
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
|
||||
);
|
||||
|
||||
return $admin;
|
||||
}
|
||||
|
||||
public function parse($pathInfo, $params = array(), eRequest $request = null, eRouter $router = null, $config = array())
|
||||
{
|
||||
// this config doesn't support parsing, it's done by the module entry script (news.php)
|
||||
// this means News are not available via single entry point if this config is currently active
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user