mirror of
https://github.com/e107inc/e107.git
synced 2025-08-16 03:24:20 +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:
1
e107_core/bbcodes/_br.bb
Normal file
1
e107_core/bbcodes/_br.bb
Normal file
@@ -0,0 +1 @@
|
||||
return '<br />';
|
62
e107_core/bbcodes/bb_block.php
Normal file
62
e107_core/bbcodes/bb_block.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
|
||||
* $Id$
|
||||
*
|
||||
* DIV block bbcode
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
/**
|
||||
* Div HTML blocks handling
|
||||
*
|
||||
* [block=class=xxx&style=xxx&id=xxx]$content[/block]
|
||||
* [block=xxx]$content[/block] equals to [block=class=xxx]$content[/block]
|
||||
* If $content is missing, HTML comment will be used - '<!-- -->'
|
||||
*/
|
||||
class bb_block extends e_bb_base
|
||||
{
|
||||
/**
|
||||
* Called prior to save
|
||||
*
|
||||
*/
|
||||
function toDB($code_text, $parm)
|
||||
{
|
||||
// just for now
|
||||
if(!ADMIN) return $code_text; // TODO - pref
|
||||
|
||||
// transform to class, equal sign at 0 position is not well formed parm string
|
||||
if($parm && !strpos($parm, '=')) $parm = 'class='.$parm;
|
||||
$parms = eHelper::scParams($parm);
|
||||
$safe = array();
|
||||
|
||||
if(varsettrue($parms['class'])) $safe['class'] = eHelper::secureClassAttr($parms['class']);
|
||||
if(varsettrue($parms['id'])) $safe['id'] = eHelper::secureIdAttr($parms['id']);
|
||||
if(varsettrue($parms['style'])) $safe['style'] = eHelper::secureStyleAttr($parms['style']);
|
||||
if($safe)
|
||||
{
|
||||
return '[block='.eHelper::buildAttr($safe).']'.$code_text.'[/block]';
|
||||
}
|
||||
return '[block]'.$code_text.'[/block]';
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate youtube bbcode into the appropriate HTML
|
||||
*/
|
||||
function toHTML($code_text, $parm)
|
||||
{
|
||||
// transform to class, equal sign at 0 position is not well formed parm string
|
||||
if($parm && !strpos($parm, '=')) $parm = 'class='.$parm;
|
||||
$parms = eHelper::scParams($parm);
|
||||
|
||||
$class = varsettrue($parms['class']) ? ' class="'.eHelper::secureClassAttr($parms['class']).'"' : '';
|
||||
if(!$class) $class = ' class="bbcode"';
|
||||
|
||||
$id = varsettrue($parms['id']) ? ' id='.eHelper::secureIdAttr($parms['id']) : '';
|
||||
$style = varsettrue($parms['style']) ? ' style="'.eHelper::secureStyleAttr($parms['style']).'"' : '';
|
||||
|
||||
if(empty($code_text)) $code_text = '<!-- -->';
|
||||
return '<div'.$id.$class.$style.'>'.$code_text.'</div>';
|
||||
}
|
||||
}
|
76
e107_core/bbcodes/bb_h.php
Normal file
76
e107_core/bbcodes/bb_h.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
|
||||
* $Id$
|
||||
*
|
||||
* Heading bb code
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
/**
|
||||
* Basic usage [h=2]text[/h]
|
||||
* The same [h]text[/h] as heading number defaults to '2'
|
||||
* Advanced usage [h=2|class=className&id=element-id&style=some: style; and: moresStyle]text[/h]
|
||||
* 'class' defaults to 'bbcode' (if left empty)
|
||||
*/
|
||||
class bb_h extends e_bb_base
|
||||
{
|
||||
/**
|
||||
* Called prior to save
|
||||
* Sanitize and re-assemble the bbcode
|
||||
*/
|
||||
function toDB($code_text, $parm)
|
||||
{
|
||||
$code_text = trim($code_text);
|
||||
if(empty($code_text)) return '';
|
||||
|
||||
$bparms = eHelper::scDualParams($parm);
|
||||
|
||||
$h = $bparms[1] ? intval($bparms[1]) : 2;
|
||||
$parms = $bparms[2];
|
||||
unset($bparms);
|
||||
|
||||
if(vartrue($parms['class']))
|
||||
{
|
||||
$safe['class'] = eHelper::secureClassAttr($parms['class']);
|
||||
}
|
||||
if(vartrue($parms['id']))
|
||||
{
|
||||
$safe['id'] = eHelper::secureIdAttr($parms['id']);
|
||||
}
|
||||
if(vartrue($parms['style']))
|
||||
{
|
||||
$safe['style'] = eHelper::secureStyleAttr($parms['style']);
|
||||
}
|
||||
if($safe)
|
||||
{
|
||||
return '[h='.$h.'|'.eHelper::buildAttr($safe).']'.$code_text.'[/h]';
|
||||
}
|
||||
return '[h='.$h.']'.$code_text.'[/h]';
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Translate to <h*> tag
|
||||
*/
|
||||
function toHTML($code_text, $parm)
|
||||
{
|
||||
$code_text = trim($code_text);
|
||||
if(empty($code_text)) return '';
|
||||
$bparms = eHelper::scDualParams($parm);
|
||||
|
||||
$h = 'h'.($bparms[1] ? intval($bparms[1]) : 2);
|
||||
$parms = $bparms[2];
|
||||
unset($bparms);
|
||||
|
||||
$class = varsettrue($parms['class']) ? ' class="'.eHelper::secureClassAttr($parms['class']).'"' : '';
|
||||
if(!$class) $class = ' class="bbcode"';
|
||||
|
||||
$id = varsettrue($parms['id']) ? ' id='.eHelper::secureIdAttr($parms['id']) : '';
|
||||
$style = varsettrue($parms['style']) ? ' style="'.eHelper::secureStyleAttr($parms['style']).'"' : '';
|
||||
|
||||
return "<{$h}{$id}{$class}{$style}>".$code_text."</{$h}>";
|
||||
}
|
||||
}
|
35
e107_core/bbcodes/bb_nobr.php
Normal file
35
e107_core/bbcodes/bb_nobr.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
|
||||
* $Id$
|
||||
*
|
||||
* Strip HTML new lines bbcode
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
/**
|
||||
* Does nothing when saving in DB
|
||||
* Removes new lines produced by nl2br when translating to HTML
|
||||
*/
|
||||
class bb_nobr extends e_bb_base
|
||||
{
|
||||
private $_nobrRegEx = '#[^\w\s\-]#';
|
||||
|
||||
/**
|
||||
* Called prior to save
|
||||
* Re-assemble the bbcode
|
||||
*/
|
||||
function toDB($code_text, $parm)
|
||||
{
|
||||
return '[nobr]'.$code_text.'[/nobr]';
|
||||
}
|
||||
|
||||
/**
|
||||
* Strip new lines
|
||||
*/
|
||||
function toHTML($code_text, $parm)
|
||||
{
|
||||
return str_replace(E_NL, "\n", trim($code_text));
|
||||
}
|
||||
}
|
71
e107_core/bbcodes/bb_p.php
Normal file
71
e107_core/bbcodes/bb_p.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
|
||||
* $Id$
|
||||
*
|
||||
* Paragraph bbcode
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
/**
|
||||
* Basic usage [p=CSS-className]text[/p]
|
||||
* Advanced usage [p=class=className&id=element-id&style=some: style; and: moresStyle]text[/p]
|
||||
* 'class' defaults to 'bbcode' (if left empty)
|
||||
*/
|
||||
class bb_p extends e_bb_base
|
||||
{
|
||||
/**
|
||||
* Called prior to save
|
||||
* Sanitize and re-assemble the bbcode
|
||||
*/
|
||||
function toDB($code_text, $parm)
|
||||
{
|
||||
$code_text = trim($code_text);
|
||||
if(empty($code_text)) return '';
|
||||
|
||||
if($parm && !strpos($parm, '=')) $parm = 'class='.$parm;
|
||||
|
||||
$parms = eHelper::scParams($parm);
|
||||
$safe = array();
|
||||
|
||||
if(vartrue($parms['class']))
|
||||
{
|
||||
$safe['class'] = eHelper::secureClassAttr($parms['class']);
|
||||
}
|
||||
if(vartrue($parms['id']))
|
||||
{
|
||||
$safe['id'] = eHelper::secureIdAttr($parms['id']);
|
||||
}
|
||||
if(vartrue($parms['style']))
|
||||
{
|
||||
$safe['style'] = eHelper::secureStyleAttr($parms['style']);
|
||||
}
|
||||
if($safe)
|
||||
{
|
||||
return '[p='.eHelper::buildAttr($safe).']'.$code_text.'[/p]';
|
||||
}
|
||||
return '[p]'.$code_text.'[/p]';
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Translate to <p> tag
|
||||
*/
|
||||
function toHTML($code_text, $parm)
|
||||
{
|
||||
if($parm && !strpos($parm, '=')) $parm = 'class='.$parm;
|
||||
$code_text = trim($code_text);
|
||||
|
||||
$parms = eHelper::scParams($parm);
|
||||
|
||||
$class = varsettrue($parms['class']) ? ' class="'.eHelper::secureClassAttr($parms['class']).'"' : '';
|
||||
if(!$class) $class = ' class="bbcode"';
|
||||
|
||||
$id = varsettrue($parms['id']) ? ' id="'.eHelper::secureIdAttr($parms['id']).'"' : '';
|
||||
$style = varsettrue($parms['style']) ? ' style="'.eHelper::secureStyleAttr($parms['style']).'"' : '';
|
||||
|
||||
return "<p{$id}{$class}{$style}>".$code_text.'</p>';
|
||||
}
|
||||
}
|
@@ -17,7 +17,8 @@
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
include_once(e_HANDLER.'shortcode_handler.php');
|
||||
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_ren_help.php');
|
||||
//include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_ren_help.php');
|
||||
e107::coreLan('ren_help');
|
||||
|
||||
$codes = array('bb', 'bb_help', 'bb_preimagedir');
|
||||
register_shortcode('bbcode_shortcodes', $codes);
|
||||
@@ -54,9 +55,12 @@ class bbcode_shortcodes
|
||||
|
||||
$bbcode['newpage'] = array($bbcode_func,"[newpage]", LANHELP_34, "newpage.png");
|
||||
$bbcode['link'] = array('addinput',"[link=".LANHELP_35."][/link]", LANHELP_23,"link.png");
|
||||
$bbcode['h'] = array($bbcode_func,"[h][/h]", LANHELP_50,"heading.png"); // FIXME bbcode icon
|
||||
$bbcode['p'] = array($bbcode_func,"[p][/p]", LANHELP_49,"paragraph.png"); // FIXME bbcode icon
|
||||
$bbcode['b'] = array($bbcode_func,"[b][/b]", LANHELP_24,"bold.png");
|
||||
$bbcode['i'] = array($bbcode_func,"[i][/i]", LANHELP_25,"italic.png");
|
||||
$bbcode['u'] = array($bbcode_func,"[u][/u]", LANHELP_26,"underline.png");
|
||||
$bbcode['justify'] = array($bbcode_func,"[justify][/justify]", LANHELP_53,"center.png"); // FIXME bbcode icon
|
||||
$bbcode['center'] = array($bbcode_func,"[center][/center]", LANHELP_28,"center.png");
|
||||
$bbcode['left'] = array($bbcode_func,"[left][/left]", LANHELP_29,"left.png");
|
||||
$bbcode['right'] = array($bbcode_func,"[right][/right]", LANHELP_30,"right.png");
|
||||
@@ -67,6 +71,10 @@ class bbcode_shortcodes
|
||||
$bbcode['flash'] = array($bbcode_func,"[flash=width,height][/flash]", LANHELP_47,"flash.png");
|
||||
$bbcode['youtube'] = array($bbcode_func,"[youtube][/youtube]", LANHELP_48,"youtube.png");
|
||||
$bbcode['sanitised'] = array('', '', '');
|
||||
|
||||
$bbcode['nobr'] = array($bbcode_func,"[nobr][/nobr]", LANHELP_51, "nobr.png"); // FIXME bbcode icon
|
||||
$bbcode['br'] = array($bbcode_func,"[br]", LANHELP_52, "br.png"); // FIXME bbcode icon
|
||||
$bbcode['block'] = array($bbcode_func,"[block][/block]", LANHELP_54,"block.png"); // FIXME bbcode icon, interactive interface, theme hooks
|
||||
|
||||
$bbcode['fontsize'] = array("expandit","size_selector_".$rand, LANHELP_22,"fontsize.png","Size_Select",'size_selector_'.$rand);
|
||||
$bbcode['fontcol'] = array("expandit","col_selector_".$rand, LANHELP_21,"fontcol.png","Color_Select",'col_selector_'.$rand);
|
||||
|
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