mirror of
https://github.com/e107inc/e107.git
synced 2025-08-11 09:04:38 +02:00
- Custom Pages: new fields for SEF string and meta data, admin validation and data control, front-end SEO (meta data), additional 'safe' URL config (for migrated installs); some new useful helper methods;
- More typography and layout control: new class based paragraph, heading, nobr, br and block bbcodes (awaiting new icons) - Overall improvements and stability fixes
This commit is contained in:
87
e107_core/url/page/sef_noid_url.php
Normal file
87
e107_core/url/page/sef_noid_url.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
|
||||
* $Id$
|
||||
*
|
||||
* Custom page routing config
|
||||
*/
|
||||
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)
|
||||
|
||||
'mapVars' => array(
|
||||
'page_id' => 'id',
|
||||
'page_sef' => 'name',
|
||||
),
|
||||
|
||||
'allowVars' => array(
|
||||
'page',
|
||||
),
|
||||
),
|
||||
|
||||
'rules' => array(
|
||||
|
||||
### using only title for pages is risky enough (empty sef for old DB's)
|
||||
'<name:{secure}>' => array('view/index', 'allowVars' => false, 'legacyQuery' => '{name}.{page}', 'parseCallback' => 'itemIdByTitle'),
|
||||
|
||||
### 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_SEFNOID_LABEL, // Current profile name
|
||||
'description' => LAN_EURL_PAGE_SEFNOID_DESCR, //
|
||||
),
|
||||
'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');
|
||||
if(($id = $request->getRequestParam('id')))
|
||||
{
|
||||
$request->setRequestParam('name', $id);
|
||||
return;
|
||||
}
|
||||
elseif(!$name || is_numeric($name)) return;
|
||||
|
||||
$sql = e107::getDb('url');
|
||||
$name = e107::getParser()->toDB($name);
|
||||
if($sql->db_Select('page', 'page_id', "page_theme='' AND page_sef='{$name}'"))
|
||||
{
|
||||
$name = $sql->db_Fetch();
|
||||
$request->setRequestParam('name', $name['page_id']);
|
||||
}
|
||||
else $request->setRequestParam('name', 0);
|
||||
}
|
||||
}
|
@@ -3,7 +3,7 @@
|
||||
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
|
||||
* $Id$
|
||||
*
|
||||
* User routing config
|
||||
* Custom page routing config
|
||||
*/
|
||||
class core_page_sef_url extends eUrlConfig
|
||||
{
|
||||
@@ -13,35 +13,26 @@ class core_page_sef_url extends eUrlConfig
|
||||
|
||||
'config' => array(
|
||||
'allowMain' => true,
|
||||
'noSingleEntry' => false, // [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' => 'path', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
|
||||
'selfParse' => false, // [optional] default false; use only this->parse() method, no core routine URL parsing
|
||||
'selfCreate' => false, // [optional] default false; use only this->create() method, no core routine URL creating
|
||||
'defaultRoute' => 'view/index',// [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(
|
||||
'page_id' => 'id',
|
||||
'page_title' => 'name',
|
||||
'page_sef' => 'name',
|
||||
),
|
||||
|
||||
'allowVars' => array(
|
||||
'page', 'id',
|
||||
'page',
|
||||
),
|
||||
),
|
||||
|
||||
'rules' => array(
|
||||
### using only title for pages is risky enough (non-unique title, possible bad characters)
|
||||
//'<name:{secure}>' => array('view/index', 'allowVars' => array('name'),'legacyQuery' => '{name}.{page}', 'parseCallback' => 'itemIdByTitle'),
|
||||
'<id:{number}>/<name:{secure}>' => array('view/index', 'legacyQuery' => '{id}.{page}', ),
|
||||
|
||||
### fallback when assembling method don't know the title of the page - build by ID only
|
||||
'<id:{number}>' => array('view/index', 'legacyQuery' => '{id}.{page}', ),
|
||||
'<id:{number}>/<name:{sefsecureOptional}>' => array('view/index', 'legacyQuery' => '{id}.{page}', ),
|
||||
|
||||
### page list
|
||||
'list' => array('list/index', 'legacyQuery' => '', ),
|
||||
'/' => array('list/index', 'legacyQuery' => '', ),
|
||||
) // rule set array
|
||||
);
|
||||
@@ -66,34 +57,4 @@ class core_page_sef_url extends eUrlConfig
|
||||
|
||||
return $admin;
|
||||
}
|
||||
|
||||
### CUSTOM METHODS ###
|
||||
|
||||
/**
|
||||
* view/item by name callback
|
||||
* @param eRequest $request
|
||||
*/
|
||||
public function itemIdByTitle(eRequest $request)
|
||||
{
|
||||
$name = $request->getRequestParam('name');
|
||||
if(($id = $request->getRequestParam('id')))
|
||||
{
|
||||
$request->setRequestParam('name', $id);
|
||||
return;
|
||||
}
|
||||
elseif(!$name) return;
|
||||
elseif(is_numeric($name))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$sql = e107::getDb('url');
|
||||
$name = e107::getParser()->toDB($name);var_dump($name);
|
||||
if($sql->db_Select('page', 'page_id', "page_theme='' AND page_title='{$name}'")) // TODO - it'll be page_sef (new) field
|
||||
{
|
||||
$name = $sql->db_Fetch();
|
||||
$request->setRequestParam('name', $name['page_id']);
|
||||
}
|
||||
else $request->setRequestParam('name', 0);
|
||||
}
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@
|
||||
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
|
||||
* $Id$
|
||||
*
|
||||
* Page routing config
|
||||
* Custom page routing config
|
||||
*/
|
||||
class core_page_url extends eUrlConfig
|
||||
{
|
||||
|
Reference in New Issue
Block a user