mirror of
https://github.com/e107inc/e107.git
synced 2025-04-20 20:51:53 +02:00
New {SETIMAGE} shortcode for theme developers. Using this prior to a media-manager image being called will allow one to set the default size for the image (ie. when not specified otherwise). eg. {SETIMAGE|w=293} will set the width of the images to 293px.
This commit is contained in:
parent
452aa5d539
commit
3430c31048
10
e107_core/shortcodes/single/setimage.php
Normal file
10
e107_core/shortcodes/single/setimage.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
// Aloow theme templates to set the default Image Resizing of thumb.php
|
||||
|
||||
function setimage_shortcode($parm, $mode)
|
||||
{
|
||||
parse_str($mode,$options);
|
||||
e107::getParser()->thumbWidth = vartrue($options['w'],100);
|
||||
}
|
||||
|
||||
?>
|
@ -65,6 +65,8 @@ class e_parse extends e_parser
|
||||
|
||||
// Highlight query
|
||||
var $e_query;
|
||||
|
||||
public $thumbWidth = 100;
|
||||
|
||||
// Set up the defaults
|
||||
var $e_optDefault = array(
|
||||
@ -1833,7 +1835,7 @@ class e_parse extends e_parser
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!vartrue($options['w']) && !vartrue($options['h'])) $options['w'] = 100;
|
||||
if(!vartrue($options['w']) && !vartrue($options['h'])) $options['w'] = $this->thumbWidth;
|
||||
$thurl .= 'w='.((integer) vartrue($options['w'], 0)).'&h='.((integer) vartrue($options['h'], 0));
|
||||
}
|
||||
|
||||
@ -2445,6 +2447,13 @@ class e_parser
|
||||
|
||||
|
||||
|
||||
// Parse i_xxxx to bootstrap glyph format.
|
||||
public function glyph($text)
|
||||
{
|
||||
$text = preg_replace('/\[(i_[\w]*)\]/',"<i class='$1'></i>", $text);
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Perform and render XSS Test Comparison
|
||||
|
@ -2331,6 +2331,7 @@ class e_form
|
||||
if($link) $value = "<a class='e-tip{$dialog}' {$ext} href='".$link."' {$modal} title='Quick View'>".$value."</a>";
|
||||
}
|
||||
|
||||
|
||||
if(!vartrue($attributes['noedit']) && vartrue($parms['editable']) && !vartrue($parms['link'])) // avoid bad markup, better solution coming up
|
||||
{
|
||||
$mode = preg_replace('/[^\w]/', '', vartrue($_GET['mode'], ''));
|
||||
|
@ -715,7 +715,10 @@ class e_parse_shortcode
|
||||
*/
|
||||
function doCode($matches)
|
||||
{
|
||||
global $pref, $e107cache, $menu_pref, $sc_style, $parm, $sql;
|
||||
global $pref, $e107cache, $menu_pref, $sc_style;
|
||||
// global $parm, $sql; XXX Why Global $parm?
|
||||
|
||||
$sql = e107::getDb();
|
||||
|
||||
if ($this->eVars)
|
||||
{
|
||||
@ -728,27 +731,38 @@ class e_parse_shortcode
|
||||
{
|
||||
return $matches[0];
|
||||
}
|
||||
|
||||
if (strpos($matches[1], '='))
|
||||
|
||||
// look for the $sc_mode FIRST to avoid issues with '=' eg. {SETIMAGE=something|w=200}
|
||||
// Shortcode Layout {CODE=PARM|MODE} XXX @Miro - do you also require support for the other way around? ie. {CODE|MODE=PARM} ?
|
||||
|
||||
if (strpos($matches[1], '|'))
|
||||
{
|
||||
list($code, $parm) = explode('=', $matches[1], 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
$code = $matches[1];
|
||||
$parm = '';
|
||||
}
|
||||
//look for the $sc_mode
|
||||
if (strpos($code, '|'))
|
||||
{
|
||||
list($code, $sc_mode) = explode("|", $code, 2);
|
||||
$code = trim($code);
|
||||
list($rawcode, $sc_mode) = explode("|", $matches[1], 2);
|
||||
$rawcode = trim($rawcode);
|
||||
$sc_mode = trim($sc_mode);
|
||||
//
|
||||
// print_a("{".$matches[1]."} RAWCODE: ".$rawcode." MODE: ".$sc_mode." ");
|
||||
}
|
||||
else
|
||||
{
|
||||
$sc_mode = '';
|
||||
$rawcode = $matches[1];
|
||||
}
|
||||
|
||||
if (strpos($rawcode, '='))
|
||||
{
|
||||
list($code, $parm) = explode('=', $rawcode, 2);
|
||||
// print_a("{".$matches[1]."} CODE: ".code." PARM: ".$parm." MODE: ".$sc_mode." ");
|
||||
}
|
||||
else
|
||||
{
|
||||
$code = $rawcode;
|
||||
$parm = '';
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
|
||||
$parm = trim($parm);
|
||||
$parm = str_replace(array('[[', ']]'), array('{', '}'), $parm);
|
||||
|
||||
@ -893,7 +907,15 @@ class e_parse_shortcode
|
||||
}
|
||||
elseif (function_exists($_function))
|
||||
{
|
||||
$ret = call_user_func($_function, $parm);
|
||||
if($sc_mode)
|
||||
{
|
||||
$ret = call_user_func($_function, $parm, $sc_mode); // v2.x
|
||||
}
|
||||
else
|
||||
{
|
||||
$ret = call_user_func($_function, $parm);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user