1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 12:48:24 +01:00

Shortcode fixes and introduction of new format. {SC: get-string} eg. {MYSHORTCODE:w=100&h=50}

This is returned to the shortcode as an array('w'=>100, 'h'=>50);  Use {SETIMAGE:w=100} to set the default thumbnail width.
This commit is contained in:
Cameron 2013-03-11 05:11:58 -07:00
parent 58ef32c990
commit 5436e861f5
3 changed files with 32 additions and 10 deletions

View File

@ -1,10 +1,9 @@
<?php
// Aloow theme templates to set the default Image Resizing of thumb.php
function setimage_shortcode($parm, $mode)
function setimage_shortcode($parm, $mode='')
{
parse_str($mode,$options);
e107::getParser()->thumbWidth = vartrue($options['w'],100);
e107::getParser()->thumbWidth = vartrue($parm['w'],100);
}
?>

View File

@ -96,6 +96,15 @@ class _system_cron
// Very basic and needs improvement. (for large DBs)
function dbBackup()
{
$sql = e107::getDb();
$sql->backup('*');
return;
require(e_BASE."e107_config.php");
$sql = e107::getDb();

View File

@ -715,7 +715,10 @@ class e_parse_shortcode
*/
function doCode($matches)
{
global $pref, $e107cache, $menu_pref, $sc_style, $parm, $sql;
$parmArray = false;
if ($this->eVars)
{
@ -729,7 +732,14 @@ class e_parse_shortcode
return $matches[0];
}
if (strpos($matches[1], '='))
if(preg_match('/^([A-Z]*):(.*)/', $matches[1], $newMatch))
{
$code = $newMatch[1];
$parmStr = trim($newMatch[2]);
parse_str($parmStr,$parm);
$parmArray = true;
}
elseif (strpos($matches[1], '='))
{
list($code, $parm) = explode('=', $matches[1], 2);
}
@ -749,9 +759,14 @@ class e_parse_shortcode
{
$sc_mode = '';
}
$parm = trim($parm);
$parm = str_replace(array('[[', ']]'), array('{', '}'), $parm);
if($parmArray == false)
{
$parm = trim($parm);
$parm = str_replace(array('[[', ']]'), array('{', '}'), $parm);
}
if (E107_DBG_BBSC || E107_DBG_SC || E107_DBG_TIMEDETAILS)
{
global $db_debug;
@ -887,13 +902,12 @@ class e_parse_shortcode
include_once(e_CORE.'shortcodes/single/'.strtolower($code).'.php');
if (class_exists($_class, false)) // prevent __autoload - performance
{
$ret = call_user_func(array($_class, $_function), $parm);
$ret = call_user_func(array($_class, $_function), array($parm, $sc_mode));
}
elseif (function_exists($_function))
{
$ret = call_user_func($_function, $parm);
$ret = call_user_func($_function, $parm, $sc_mode);
}
}
else