2006-12-02 04:36:16 +00:00
< ? php
/*
2009-08-20 16:41:29 +00:00
* e107 website system
*
2010-04-23 15:54:11 +00:00
* Copyright ( C ) 2008 - 2010 e107 Inc ( e107 . org )
2009-08-20 16:41:29 +00:00
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
* e107 Shortcode handler
*
2010-04-23 15:54:11 +00:00
* $URL $
* $Id $
2010-04-25 13:52:14 +00:00
*/
2006-12-02 04:36:16 +00:00
2010-04-25 13:52:14 +00:00
if ( ! defined ( 'e107_INIT' ))
{
exit ;
}
2006-12-02 04:36:16 +00:00
2010-04-24 11:39:14 +00:00
/**
*
* @ package e107
* @ subpackage e107_handlers
* @ version $Id $
* @ author e107inc
*
* e_parse_shortcode - shortcode parser / manager , former e_shortcode
* e_shortcode - abstract batch class
*/
2009-08-20 16:41:29 +00:00
/**
2010-04-23 15:54:11 +00:00
* FIXME : to be removed
2009-08-20 16:41:29 +00:00
*/
2010-04-25 13:52:14 +00:00
function register_shortcode ( $classFunc , $codes , $path = '' , $force = false )
2007-06-13 02:53:21 +00:00
{
2010-04-23 15:54:11 +00:00
return e107 :: getScParser () -> registerShortcode ( $classFunc , $codes , $path , $force );
2009-01-15 22:04:45 +00:00
}
2009-08-20 16:41:29 +00:00
/**
2010-04-23 15:54:11 +00:00
* FIXME : to be removed
2009-08-20 16:41:29 +00:00
*/
function setScVar ( $className , $scVarName , $value )
2009-01-25 17:44:13 +00:00
{
2010-04-23 15:54:11 +00:00
return e107 :: getScParser () -> setScVar ( $className , $scVarName , $value );
2009-01-25 17:44:13 +00:00
}
2009-11-20 22:23:02 +00:00
/**
2011-03-24 21:29:45 +00:00
* FIXME : to be removed ( once event calendar changed )
2009-11-20 22:23:02 +00:00
*/
2010-04-23 15:54:11 +00:00
function callScFunc ( $className , $scFuncName , $param = '' )
2009-11-20 22:23:02 +00:00
{
2010-04-23 15:54:11 +00:00
return e107 :: getScParser () -> callScFunc ( $className , $scFuncName , $param );
2009-11-20 22:23:02 +00:00
}
2009-08-20 16:41:29 +00:00
/**
2010-04-23 15:54:11 +00:00
* FIXME : to be removed
2009-08-20 16:41:29 +00:00
*/
2010-04-23 15:54:11 +00:00
function initShortcodeClass ( $class , $force = false , $eVars = null )
2009-01-15 22:04:45 +00:00
{
2010-04-23 15:54:11 +00:00
return e107 :: getScParser () -> initShortcodeClass ( $class , $eVars , $force );
2006-12-02 04:36:16 +00:00
}
2010-04-23 15:54:11 +00:00
class e_parse_shortcode
2008-02-13 02:57:17 +00:00
{
2010-04-25 13:52:14 +00:00
protected $scList = array (); // The actual code - added by parsing files or when plugin codes encountered. Array key is the shortcode name.
protected $parseSCFiles ; // True if individual shortcode files are to be used
2011-03-24 21:29:45 +00:00
protected $addedCodes = NULL ; // Pointer to a class or array to be used on a single call
2010-04-25 13:52:14 +00:00
protected $registered_codes = array (); // Shortcodes added by plugins TODO make it private
protected $scClasses = array (); // Batch shortcode classes - TODO make it private
2013-02-08 16:49:57 +02:00
protected $scOverride = array (); // Array of codes found in override/shortcodes dir
protected $scBatchOverride = array (); // Array of codes found in override/shortcodes/batch dir
2014-08-18 22:57:18 -07:00
protected $ignoreCodes = array (); // Shortcodes to be ignored and remain unchanged. (ie. {THEME}, {e_PLUGIN} etc. )
2010-04-25 13:52:14 +00:00
/**
* @ var e_vars
*/
protected $eVars = null ;
2013-04-28 19:14:14 +03:00
/**
* Wrappers array for the current parsing cycle , see contact_template . php and $CONTACT_WRAPPER variable
* @ var array
*/
protected $wrappers = array ();
/**
* Former $sc_style global variable . Internally used - performance reasons
* @ var array
*/
protected $sc_style = array ();
2010-04-23 15:54:11 +00:00
function __construct ()
2006-12-02 04:36:16 +00:00
{
2010-04-25 13:52:14 +00:00
$this -> parseSCFiles = true ; // Default probably never used, but make sure its defined.
2014-08-18 22:57:18 -07:00
$this -> ignoreCodes = e107 :: getParser () -> getUrlConstants (); // ignore all URL shortcodes. ie. {e_PLUGIN}
2009-09-19 17:43:19 +00:00
$this -> loadOverrideShortcodes ();
$this -> loadThemeShortcodes ();
$this -> loadPluginShortcodes ();
$this -> loadPluginSCFiles ();
2013-02-08 16:49:57 +02:00
//$this->loadCoreShortcodes(); DEPRECATED
2012-04-23 01:21:06 +00:00
2010-04-23 15:54:11 +00:00
}
2010-04-25 13:52:14 +00:00
2010-04-23 15:54:11 +00:00
/**
* Register shortcode
* $classFunc could be function name , class name or object
* $code could be 'true' when class name / object is passed to automate the
* registration of shortcode methods
*
* @ param mixed $classFunc
* @ param mixed $codes
* @ param string $path
* @ param boolean $force override
* @ return e_parse_shortcode
*/
function registerShortcode ( $classFunc , $codes , $path = '' , $force = false )
{
//If codes is set to true, let's go get a list of shortcode methods
2010-04-25 13:52:14 +00:00
if ( $codes === true )
2010-04-23 15:54:11 +00:00
{
$codes = array ();
$tmp = get_class_methods ( $classFunc );
2010-04-25 13:52:14 +00:00
foreach ( $tmp as $c )
2010-04-23 15:54:11 +00:00
{
2010-04-25 13:52:14 +00:00
if ( strpos ( $c , 'sc_' ) === 0 )
2010-04-23 15:54:11 +00:00
{
$codes [] = substr ( $c , 3 );
}
}
unset ( $tmp );
}
2010-04-25 13:52:14 +00:00
2010-04-23 15:54:11 +00:00
//Register object feature
$classObj = null ;
2010-04-25 13:52:14 +00:00
if ( is_object ( $classFunc ))
2010-04-23 15:54:11 +00:00
{
$classObj = $classFunc ;
$classFunc = get_class ( $classObj );
2010-04-25 13:52:14 +00:00
2010-04-23 15:54:11 +00:00
}
2010-04-25 13:52:14 +00:00
2010-04-23 15:54:11 +00:00
//We only register these shortcodes if they have not already been registered in some manner
//ie theme or other plugin .sc files
2010-04-25 13:52:14 +00:00
if ( is_array ( $codes ))
2010-04-23 15:54:11 +00:00
{
2010-04-25 13:52:14 +00:00
foreach ( $codes as $code )
2010-04-23 15:54:11 +00:00
{
$code = strtoupper ( $code );
2010-04-25 13:52:14 +00:00
if (( ! $this -> isRegistered ( $code ) || $force == true ) && ! $this -> isOverride ( $code ))
2010-04-23 15:54:11 +00:00
{
$this -> registered_codes [ $code ] = array ( 'type' => 'class' , 'path' => $path , 'class' => $classFunc );
}
}
2010-04-25 13:52:14 +00:00
2010-04-23 15:54:11 +00:00
//register object if required
2010-04-25 13:52:14 +00:00
if ( null !== $classObj && ( ! $this -> isScClass ( $classFunc ) || $force == true ))
2010-04-23 15:54:11 +00:00
{
$this -> scClasses [ $classFunc ] = $classObj ;
}
}
else
{
$codes = strtoupper ( $codes );
2010-04-25 13:52:14 +00:00
if (( ! $this -> isRegistered ( $code ) || $force == true ) && ! $this -> isOverride ( $code ))
2010-04-23 15:54:11 +00:00
{
$this -> registered_codes [ $codes ] = array ( 'type' => 'func' , 'path' => $path , 'function' => $classFunc );
}
}
return $this ;
}
2010-04-25 13:52:14 +00:00
2010-04-23 15:54:11 +00:00
/**
* Add value to already registered SC object
*
* @ param string $className
* @ param string $scVarName
* @ param mixed $value
* @ return e_parse_shortcode
*/
public function setScVar ( $className , $scVarName , $value )
{
2010-04-25 13:52:14 +00:00
if ( $this -> isScClass ( $className ))
2010-04-23 15:54:11 +00:00
{
2010-04-24 09:58:02 +00:00
// new way - batch should extend e_shortcode class
2010-04-25 13:52:14 +00:00
if ( method_exists ( $this -> scClasses [ $className ], 'setScVar' ))
2010-04-24 09:58:02 +00:00
{
$this -> scClasses [ $className ] -> setScVar ( $scVarName , $value );
}
else // Old - DEPRECATED
2010-04-26 15:05:59 +00:00
2010-04-24 09:58:02 +00:00
{
$this -> scClasses [ $className ] -> $scVarName = $value ;
}
2010-04-23 15:54:11 +00:00
}
return $this ;
}
2010-04-25 13:52:14 +00:00
2010-04-23 15:54:11 +00:00
/**
* Call function on an already registered SC object
*
* @ param string $className
* @ param string $scFuncName
* @ param mixed $param - passed to function
*
2010-04-25 13:52:14 +00:00
* @ return mixed | boolean - NULL if class / method doesn ' t exist ; otherwise whatever the function returns .
2010-04-23 15:54:11 +00:00
*/
public function callScFunc ( $className , $scFuncName , $param = '' )
{
2010-04-25 13:52:14 +00:00
if ( $this -> isScClass ( $className ))
2010-04-23 15:54:11 +00:00
{
2010-04-25 13:52:14 +00:00
return method_exists ( $this -> scClasses [ $className ], $scFuncName ) ? call_user_func ( array ( $this -> scClasses [ $className ], $scFuncName ), $param ) : null ;
2010-04-23 15:54:11 +00:00
}
2010-04-24 09:58:02 +00:00
return null ;
2010-04-23 15:54:11 +00:00
}
2010-04-26 15:05:59 +00:00
2010-04-25 13:52:14 +00:00
/**
2010-04-26 15:05:59 +00:00
* same as e_parse_shortcode :: callScFunc (), but passes the last argument ( array )
2010-04-25 13:52:14 +00:00
* to the called method as multiple arguments
*
* @ param string $className
* @ param string $scFuncName
* @ param array $param - arguments passed to function
*
* @ return mixed | boolean - NULL if class / method doesn ' t exist ; otherwise whatever the function returns .
*/
protected function callScFuncA ( $className , $scFuncName , $args = array ())
{
if ( $this -> isScClass ( $className ))
{
// avoid warnings
return method_exists ( $this -> scClasses [ $className ], $scFuncName ) ? call_user_func_array ( array ( $this -> scClasses [ $className ], $scFuncName ), $args ) : null ;
}
return null ;
}
2010-04-23 15:54:11 +00:00
/**
* Create shortcode object - don ' t forget you still can use e_shortcode . php
*
* @ param string $class
* @ param boolean $force
* @ return e_shortcode
*/
2010-04-25 13:52:14 +00:00
public function initShortcodeClass ( $class , $force = false )
2010-04-23 15:54:11 +00:00
{
2011-11-22 12:52:34 +00:00
if ( class_exists ( $class , false ) && ( $force || ! $this -> isScClass ( $class )))
2010-04-23 15:54:11 +00:00
{
2010-04-25 13:52:14 +00:00
$this -> scClasses [ $class ] = new $class ();
2012-08-23 11:42:54 +00:00
if ( method_exists ( $this -> scClasses [ $class ], 'init' ))
{
$this -> scClasses [ $class ] -> init ();
}
2010-04-23 15:54:11 +00:00
return $this -> scClasses [ $class ];
}
return null ;
}
2010-04-25 13:52:14 +00:00
2010-04-23 15:54:11 +00:00
/**
* Get registered SC object
2010-04-25 13:52:14 +00:00
* Normally you would use the proxy of this method - e107 :: getScBatch ()
2013-02-09 19:05:51 +02:00
* Global File Override ClassName / Path examples :
* 1. Core signup shortcodes
* - Origin ClassName : signup_shortcodes
* - Origin Location : core / shortcodes / batch / signup_shortcodes . php
* - File Override ClassName : override_signup_shortcodes
* - File Override Location : core / override / shortcodes / batch / signup_shortcodes . php
*
2013-02-22 21:30:14 -08:00
* 2. Plugin 'gallery' global shortcode batch ( e_shortcode . php )
* - Origin ClassName : gallery_shortcodes //FIXME Should be gallery_shortcode? (more below)
2013-02-09 19:05:51 +02:00
* - Origin Location : plugins / gallery / e_shortcode . php
* - File Override ClassName : override_gallery_shortcodes
* - File Override Location : core / override / shortcodes / batch / gallery_shortcodes . php
*
* 3. Plugin 'forum' regular shortcode batch
2013-02-22 21:30:14 -08:00
* - Origin ClassName : plugin_forum_view_shortcodes //FIXME Should be forum_shortcodes? (more below)
2013-02-09 19:05:51 +02:00
* - Origin Location : plugins / forum / shortcodes / batch / view_shortcodes . php
* - File Override ClassName : override_plugin_forum_view_shortcodes
* - File Override Location : core / override / shortcodes / batch / forum_view_shortcodes . php
2010-04-26 15:05:59 +00:00
*
* < code >< ? php
2010-04-25 13:52:14 +00:00
* // simple use
2012-04-23 01:21:06 +00:00
* e107 :: getScParser () -> getScObject ( 'news_shortcodes' ); // For Globally Registered shortcodes, including plugins using e_shortcode.php
2010-04-26 15:05:59 +00:00
*
2012-01-06 10:05:32 +00:00
* // plugin override - e107_plugins/myplug/shortcodes/batch/news_shortcodes.php -> class plugin_myplug_news_shortcodes
2010-04-25 13:52:14 +00:00
* e107 :: getScParser () -> getScObject ( 'news_shortcodes' , 'myplug' , true );
2010-04-26 15:05:59 +00:00
*
2010-04-25 13:52:14 +00:00
* // more complex plugin override
2012-01-06 10:05:32 +00:00
* // e107_plugins/myplug/shortcodes/batch/news2_shortcodes.php -> class plugin_myplug_news2_shortcodes
2010-04-25 13:52:14 +00:00
* e107 :: getScParser () -> getScObject ( 'news_shortcodes' , 'myplug' , 'news2_shortcodes' );
* </ code >
2010-04-23 15:54:11 +00:00
* @ param string $className
2012-04-23 01:21:06 +00:00
* @ param string $plugName if true className is used . , if string , string value is used .
2010-04-25 13:52:14 +00:00
* @ param string $overrideClass if true , $className is used
2010-04-23 15:54:11 +00:00
* @ return e_shortcode
*/
2010-04-25 13:52:14 +00:00
public function getScObject ( $className , $pluginName = null , $overrideClass = null )
2010-04-23 15:54:11 +00:00
{
2013-02-22 21:30:14 -08:00
/* FIXME Discuss Generic plugin Class naming . ( excluding specific calls with $overrideClass .
// Defaults should be:
e_shortcode . php = { plugin } _shortcode
{ plugin } _shortcodes . php = { plugin } _shortcodes
*/
2012-04-23 01:21:06 +00:00
if ( trim ( $className ) == " " ){ return ; }
2013-02-09 19:05:51 +02:00
2010-04-26 15:05:59 +00:00
$_class_fname = $className ;
2013-02-22 21:30:14 -08:00
if ( $pluginName === TRUE ) //XXX When called manually by a plugin, not e_shortcode.php eg. $sc = e107::getScBatch('faqs',TRUE); for faqs_shortcode.php with class faqs_shortcode
2013-02-09 19:05:51 +02:00
{
2013-02-22 21:30:14 -08:00
$pluginName = str_replace ( " _shortcodes " , " " , $className );
$manualCall = true ;
2013-02-09 19:05:51 +02:00
}
elseif ( is_string ( $pluginName ))
2013-02-08 16:49:57 +02:00
{
2013-02-22 21:30:14 -08:00
// FIXME "plugin_ " should NOT be used or be necessary.
// FIXME Core classes should use special naming to avoid comflicts, not plugins.
$className = 'plugin_' . $pluginName . '_' . str_replace ( '/' , '_' , $className );
2013-02-08 16:49:57 +02:00
}
2013-02-11 15:12:30 +02:00
$globalOverride = $this -> isBatchOverride ( str_replace ( 'plugin_' , '' , $className ));
2013-02-08 16:49:57 +02:00
// forced override
2010-04-25 13:52:14 +00:00
if ( $overrideClass )
{
if ( true === $overrideClass )
{
$overrideClass = $className ;
2010-04-26 15:05:59 +00:00
}
2010-04-25 13:52:14 +00:00
// e.g. class plugin_myplug_news_shortcodes
2013-02-01 17:35:56 -08:00
if ( $pluginName != null )
{
$_class_fname = $overrideClass ;
$className = 'plugin_' . $pluginName . '_' . str_replace ( '/' , '_' , $overrideClass );
}
else
{
$className = $overrideClass ;
}
2010-04-25 13:52:14 +00:00
}
2012-11-02 00:23:59 +00:00
2013-06-19 22:50:51 -07:00
if ( $className == '_theme__shortcodes' ) // Check for theme shortcode batch. - @see header_default.php //XXX Discuss.
{
$className = 'theme_shortcodes' ;
$path = THEME . 'theme_shortcodes.php' ;
}
elseif ( ! $pluginName )
2012-11-02 00:23:59 +00:00
{
2013-02-09 19:05:51 +02:00
if ( ! $globalOverride )
{
$path = e_CORE . 'shortcodes/batch/' . $_class_fname . '.php' ;
}
else
{
$path = e_CORE . 'override/shortcodes/batch/' . $_class_fname . '.php' ;
$className = 'override_' . $className ;
}
2013-02-08 16:49:57 +02:00
}
else
{
2013-02-22 21:30:14 -08:00
2013-02-09 19:05:51 +02:00
if ( ! $globalOverride )
2013-02-22 21:30:14 -08:00
{
2013-02-09 19:05:51 +02:00
// do nothing if it's e_shortcode batch global
2013-02-22 21:30:14 -08:00
if ( $pluginName . '_shortcodes' !== $className || $manualCall == true ) // manual call by plugin, not e_shortcode.php
{
2013-02-09 19:05:51 +02:00
// BC - required.
$pathBC = e_PLUGIN . $pluginName . '/' ;
$path = ( is_readable ( $pathBC . $_class_fname . '.php' ) ? $pathBC : e_PLUGIN . $pluginName . '/shortcodes/batch/' ) . $_class_fname . '.php' ;
}
}
else
{
2013-02-11 15:12:30 +02:00
$path = e_CORE . 'override/shortcodes/batch/' . $pluginName . '_' . $_class_fname . '.php' ;
2013-02-09 19:05:51 +02:00
$className = 'override_' . $className ;
}
}
2013-06-19 22:50:51 -07:00
2013-02-09 19:05:51 +02:00
// Includes global Shortcode Classes (e_shortcode.php) or already loaded batch
if ( $this -> isScClass ( $className ))
{
return $this -> scClasses [ $className ];
2013-02-08 16:49:57 +02:00
}
2012-04-23 01:21:06 +00:00
2012-12-11 15:08:29 -08:00
// If it already exists - don't include it again.
if ( class_exists ( $className , false )) // don't allow __autoload()
{
2013-05-31 18:40:56 -07:00
// $this->registerClassMethods($className, $path); // XXX Global registration should happen separately - here we want only the object.
2013-06-19 22:50:51 -07:00
$this -> scClasses [ $className ] = new $className ();
2012-12-11 15:08:29 -08:00
return $this -> scClasses [ $className ];
}
2010-04-25 13:52:14 +00:00
if ( is_readable ( $path ))
{
2010-04-26 15:05:59 +00:00
require_once ( $path );
if ( class_exists ( $className , false )) // don't allow __autoload()
2010-04-25 13:52:14 +00:00
{
// register instance directly to allow override
2013-06-19 22:50:51 -07:00
$this -> scClasses [ $className ] = new $className ();
2013-06-01 14:08:42 -07:00
// $this->registerClassMethods($className, $path); // XXX Global registration should happen separately - here we want only the object.
2010-04-25 13:52:14 +00:00
return $this -> scClasses [ $className ];
}
2012-04-23 01:21:06 +00:00
elseif ( E107_DBG_BBSC || E107_DBG_SC )
{
2013-02-01 17:35:56 -08:00
echo " <h3>Couldn't Find Class ' " . $className . " ' in <b> " . $path . " </b></h3> " ;
2012-04-23 01:21:06 +00:00
}
}
elseif ( E107_DBG_BBSC || E107_DBG_SC )
{
2013-02-22 21:30:14 -08:00
echo " <h3>Couldn't Load: <b> " . $path . " with class-name: { $className } and pluginName { $pluginName } </b></h3> " ;
2013-02-01 17:35:56 -08:00
2010-04-25 13:52:14 +00:00
}
2010-04-23 15:54:11 +00:00
// TODO - throw exception?
2010-04-24 09:58:02 +00:00
return null ;
2009-09-19 17:43:19 +00:00
}
2010-02-10 21:53:56 +00:00
2009-09-19 17:43:19 +00:00
/**
2010-02-10 22:18:57 +00:00
* Register any shortcode from the override / shortcodes / directory
2009-11-17 15:29:33 +00:00
*
2010-04-24 09:58:02 +00:00
* @ return e_parse_shortcode
2009-09-19 17:43:19 +00:00
*/
protected function loadOverrideShortcodes ()
{
2010-04-25 13:52:14 +00:00
if ( e107 :: getPref ( 'sc_override' ))
2009-01-16 01:02:41 +00:00
{
2010-04-23 15:54:11 +00:00
$tmp = explode ( ',' , e107 :: getPref ( 'sc_override' ));
2010-04-25 13:52:14 +00:00
foreach ( $tmp as $code )
2009-01-16 01:02:41 +00:00
{
$code = strtoupper ( trim ( $code ));
$this -> registered_codes [ $code ][ 'type' ] = 'override' ;
2013-02-08 16:49:57 +02:00
$this -> registered_codes [ $code ][ 'path' ] = e_CORE . 'override/shortcodes/single/' ;
$this -> registered_codes [ $code ][ 'function' ] = 'override_' . strtolower ( $code ) . '_shortcode' ;
2009-01-16 01:02:41 +00:00
$this -> scOverride [] = $code ;
}
2010-01-23 16:41:56 +00:00
}
2013-02-08 16:49:57 +02:00
if ( e107 :: getPref ( 'sc_batch_override' ))
{
$tmp = explode ( ',' , e107 :: getPref ( 'sc_batch_override' ));
foreach ( $tmp as $code )
{
//$code = strtoupper(trim($code));
//$this->registered_codes[$code]['type'] = 'override';
$this -> scBatchOverride [] = $code ;
}
}
2010-04-24 09:58:02 +00:00
return $this ;
2009-09-19 17:43:19 +00:00
}
2010-02-10 21:53:56 +00:00
2009-09-19 17:43:19 +00:00
/**
* Register any shortcodes that were registered by the theme
* $register_sc [] = 'MY_THEME_CODE'
2009-11-17 15:29:33 +00:00
*
2010-04-24 09:58:02 +00:00
* @ return e_parse_shortcode
2009-09-19 17:43:19 +00:00
*/
2013-06-19 22:50:51 -07:00
protected function loadThemeShortcodes ()
2009-09-19 17:43:19 +00:00
{
global $register_sc ;
2013-06-19 22:50:51 -07:00
// $this->registered_codes[$code]['type'] = 'plugin';
// $this->registered_codes[$code]['function'] = strtolower($code).'_shortcode';
// $this->registered_codes[$code]['path'] = e_PLUGIN.$path.'/shortcodes/single/';
2015-05-31 09:25:59 -07:00
// $this->registered_codes[$code]['perms'] = $uclass;
if ( deftrue ( 'e_DEVELOPER' )) // experimental, could break something. - use theme shortcodes in other templates.
{
if ( file_exists ( THEME . " theme_shortcodes.php " ))
{
$classFunc = 'theme_shortcodes' ;
$path = THEME . " theme_shortcodes.php " ;
include_once ( $path );
$this -> registerClassMethods ( $classFunc , $path , false );
}
}
2013-06-19 22:50:51 -07:00
2010-04-25 13:52:14 +00:00
if ( isset ( $register_sc ) && is_array ( $register_sc ))
2006-12-02 04:36:16 +00:00
{
2010-04-25 13:52:14 +00:00
foreach ( $register_sc as $code )
2006-12-02 04:36:16 +00:00
{
2010-04-25 13:52:14 +00:00
if ( ! $this -> isRegistered ( $code ))
2009-01-16 01:02:41 +00:00
{
$code = strtoupper ( $code );
$this -> registered_codes [ $code ][ 'type' ] = 'theme' ;
}
2009-01-08 17:23:13 +00:00
}
2010-01-23 16:41:56 +00:00
}
2013-06-19 22:50:51 -07:00
2010-04-24 09:58:02 +00:00
return $this ;
2009-09-19 17:43:19 +00:00
}
2010-02-10 21:53:56 +00:00
2009-09-19 17:43:19 +00:00
/**
* Register all . sc files found in plugin directories ( via pref )
2009-11-17 15:29:33 +00:00
*
2010-04-24 09:58:02 +00:00
* @ return e_parse_shortcode
2009-09-19 17:43:19 +00:00
*/
protected function loadPluginSCFiles ()
2010-01-23 16:41:56 +00:00
{
2010-04-24 09:58:02 +00:00
$pref = e107 :: getPref ( 'shortcode_list' );
2013-02-11 14:25:59 +02:00
$prefl = e107 :: getPref ( 'shortcode_legacy_list' );
2010-02-10 21:53:56 +00:00
2013-02-11 14:25:59 +02:00
// new shortcodes - functions, shortcode/single/*.php
2010-04-25 13:52:14 +00:00
if ( $pref )
2009-01-08 17:23:13 +00:00
{
2010-04-25 13:52:14 +00:00
foreach ( $pref as $path => $namearray )
2009-01-08 17:23:13 +00:00
{
2010-04-25 13:52:14 +00:00
foreach ( $namearray as $code => $uclass )
2006-12-02 04:36:16 +00:00
{
2013-02-11 14:25:59 +02:00
$code = strtoupper ( $code );
if ( ! $this -> isRegistered ( $code ))
{
if ( $this -> isOverride ( $code ))
{
$this -> registered_codes [ $code ][ 'type' ] = 'override' ;
$this -> registered_codes [ $code ][ 'function' ] = 'override_' . strtolower ( $code ) . '_shortcode' ;
$this -> registered_codes [ $code ][ 'path' ] = e_CORE . 'override/shortcodes/single/' ;
$this -> registered_codes [ $code ][ 'perms' ] = $uclass ;
continue ;
}
$this -> registered_codes [ $code ][ 'type' ] = 'plugin' ;
$this -> registered_codes [ $code ][ 'function' ] = strtolower ( $code ) . '_shortcode' ;
$this -> registered_codes [ $code ][ 'path' ] = e_PLUGIN . $path . '/shortcodes/single/' ;
$this -> registered_codes [ $code ][ 'perms' ] = $uclass ;
}
}
}
}
// legacy .sc - plugin root
if ( $prefl )
{
foreach ( $prefl as $path => $namearray )
{
foreach ( $namearray as $code => $uclass )
{
// XXX old? investigate
2010-04-25 13:52:14 +00:00
if ( $code == 'shortcode_config' )
2007-06-13 02:53:21 +00:00
{
include_once ( e_PLUGIN . $path . '/shortcode_config.php' );
}
else
{
2013-02-11 14:25:59 +02:00
$code = strtoupper ( $code );
2010-04-25 13:52:14 +00:00
if ( ! $this -> isRegistered ( $code ))
2009-01-08 17:23:13 +00:00
{
2013-02-11 14:25:59 +02:00
$this -> registered_codes [ $code ][ 'type' ] = 'plugin_legacy' ;
2009-01-08 17:23:13 +00:00
$this -> registered_codes [ $code ][ 'path' ] = $path ;
2013-02-11 14:25:59 +02:00
$this -> registered_codes [ $code ][ 'perms' ] = $uclass ;
2009-01-08 17:23:13 +00:00
}
2007-06-13 02:53:21 +00:00
}
2006-12-02 04:36:16 +00:00
}
}
2010-01-23 16:41:56 +00:00
}
2013-02-11 14:25:59 +02:00
2010-04-24 09:58:02 +00:00
return $this ;
2009-01-08 21:47:44 +00:00
}
2009-10-20 16:00:38 +00:00
2009-09-18 22:20:40 +00:00
/**
2010-01-23 16:41:56 +00:00
* Register Plugin Shortcode Batch files ( e_shortcode . php ) for use site - wide .
* Equivalent to multiple . sc files in the plugin ' s folder .
2009-11-17 15:29:33 +00:00
*
2010-04-24 09:58:02 +00:00
* @ return e_parse_shortcode
2009-09-18 22:20:40 +00:00
*/
2009-09-19 17:43:19 +00:00
protected function loadPluginShortcodes ()
2009-09-18 22:20:40 +00:00
{
2010-04-24 09:58:02 +00:00
$pref = e107 :: getPref ( 'e_shortcode_list' );
2010-02-10 21:53:56 +00:00
2010-04-25 13:52:14 +00:00
if ( ! $pref )
2009-09-18 22:20:40 +00:00
{
2010-04-24 09:58:02 +00:00
return $this ;
2009-09-18 22:20:40 +00:00
}
2013-02-09 19:05:51 +02:00
2010-04-25 13:52:14 +00:00
foreach ( $pref as $key => $val )
2009-09-18 22:20:40 +00:00
{
2013-02-09 19:05:51 +02:00
$globalOverride = $this -> isBatchOverride ( $key . '_shortcodes' );
if ( $globalOverride )
{
$path = e_CORE . 'override/shortcodes/batch/' . $key . '_shortcodes.php' ;
$classFunc = 'override_' . $key . '_shortcodes' ;
}
else
{
$path = e_PLUGIN . $key . '/e_shortcode.php' ;
$classFunc = $key . '_shortcodes' ;
}
2010-04-25 13:52:14 +00:00
if ( ! include_once ( $path ))
2009-09-18 22:20:40 +00:00
{
2013-02-09 19:05:51 +02:00
// try to switch back to the batch origin in case it's an override
if ( $globalOverride )
{
$path = e_PLUGIN . $key . '/e_shortcode.php' ;
$classFunc = $key . '_shortcodes' ;
if ( ! include_once ( $path ))
{
continue ;
}
}
else continue ;
2009-09-18 22:20:40 +00:00
}
2012-04-23 01:21:06 +00:00
2013-02-09 19:05:51 +02:00
$this -> registerClassMethods ( $classFunc , $path , false );
2010-02-10 23:11:54 +00:00
}
2010-04-24 09:58:02 +00:00
return $this ;
2010-02-10 23:11:54 +00:00
}
/**
* Common Auto - Register function for class methods .
2010-04-25 13:52:14 +00:00
* @ return e_parse_shortcode
2010-02-10 23:11:54 +00:00
*/
2010-04-25 13:52:14 +00:00
protected function registerClassMethods ( $class , $path , $force = false )
2010-02-10 23:11:54 +00:00
{
2010-04-25 13:52:14 +00:00
$tmp = get_class_methods ( $class );
$className = is_object ( $class ) ? get_class ( $class ) : $class ;
2010-04-26 15:05:59 +00:00
2010-04-25 13:52:14 +00:00
foreach ( $tmp as $c )
2010-04-23 15:54:11 +00:00
{
2010-04-25 13:52:14 +00:00
if ( strpos ( $c , 'sc_' ) === 0 )
2010-01-23 16:41:56 +00:00
{
2010-04-23 15:54:11 +00:00
$sc_func = substr ( $c , 3 );
$code = strtoupper ( $sc_func );
2010-04-25 13:52:14 +00:00
if ( $force || ! $this -> isRegistered ( $code ))
2009-09-18 22:20:40 +00:00
{
2010-04-25 13:52:14 +00:00
$this -> registered_codes [ $code ] = array ( 'type' => 'class' , 'path' => $path , 'class' => $className );
2012-08-24 09:05:32 +00:00
$this -> initShortcodeClass ( $className );
// if (class_exists($className, false))
// {
// $this->scClasses[$className] = new $className(); // Required. Test with e107::getScBatch($className)
// echo "CLASS=:".$className;
// }
2009-09-18 22:20:40 +00:00
}
2010-01-23 16:41:56 +00:00
}
2010-04-23 15:54:11 +00:00
}
2012-04-23 01:21:06 +00:00
2010-04-25 13:52:14 +00:00
return $this ;
2009-09-18 22:20:40 +00:00
}
2009-01-08 21:47:44 +00:00
2013-02-08 16:49:57 +02:00
/**
* DEPRECATED admin_shortcodes now loaded inside admin parse function ( see boot . php )
2010-01-23 16:41:56 +00:00
* Register Core Shortcode Batches .
2010-04-25 13:52:14 +00:00
* FIXME - make it smarter - currently loaded all the time ( even on front - end )
2013-02-08 16:49:57 +02:00
*
2010-04-24 11:39:14 +00:00
* @ return e_parse_shortcode
2009-09-19 17:43:19 +00:00
*/
2013-02-08 16:49:57 +02:00
// function loadCoreShortcodes()
// {
// $coreBatchList = array('admin_shortcodes');
//
// foreach ($coreBatchList as $cb)
// {
// $path = e_CORE.'shortcodes/batch/'.$cb.".php";
// if (include_once($path))
// {
// $this->registerClassMethods($cb, $path);
// }
// }
// return $this;
// }
2006-12-02 04:36:16 +00:00
2009-01-08 17:23:13 +00:00
function isRegistered ( $code )
{
2013-02-11 14:25:59 +02:00
return array_key_exists ( $code , $this -> registered_codes );
2009-01-08 17:23:13 +00:00
}
2010-02-10 21:53:56 +00:00
2009-12-12 16:40:41 +00:00
public function resetScClass ( $className , $object )
{
2010-04-25 13:52:14 +00:00
if ( null === $object )
{
unset ( $this -> scClasses [ $className ]);
}
elseif ( $this -> isScClass ( $className ))
2009-12-12 16:40:41 +00:00
{
$this -> scClasses [ $className ] = $object ;
}
2010-04-25 13:52:14 +00:00
return $this ;
2009-12-12 16:40:41 +00:00
}
2010-02-10 21:53:56 +00:00
2009-08-20 16:41:29 +00:00
function isScClass ( $className )
{
return isset ( $this -> scClasses [ $className ]);
}
2007-06-13 02:53:21 +00:00
2009-01-16 01:02:41 +00:00
function isOverride ( $code )
{
return in_array ( $code , $this -> scOverride );
}
2013-02-09 19:05:51 +02:00
function isBatchOverride ( $name )
{
return in_array ( $name , $this -> scBatchOverride );
}
2011-03-24 21:29:45 +00:00
/**
* Parse the shortcodes in some text
*
* @ param string $text - the text containing the shortcodes
* @ param boolean $useSCFiles - if TRUE , all currently registered shortcodes can be used .
* - if FALSE , only those passed are used .
* @ param array | object | null $extraCodes - if passed , defines additional shortcodes :
* - if an object or an array , the shortcodes defined by the class of the object are available for this parsing only .
* @ param array | null $eVars - if defined , details values to be substituted for shortcodes . Array key ( lower case ) is shortcode name ( upper case )
*
* @ return string with shortcodes substituted
*/
2010-04-25 15:04:53 +00:00
function parseCodes ( $text , $useSCFiles = true , $extraCodes = null , $eVars = null )
2008-02-13 02:57:17 +00:00
{
2013-04-28 19:14:14 +03:00
global $sc_style ; //legacy, will be removed soon, use the non-global $SC_STYLE instead
2010-04-25 13:52:14 +00:00
$saveParseSCFiles = $this -> parseSCFiles ; // In case of nested call
2006-12-02 04:36:16 +00:00
$this -> parseSCFiles = $useSCFiles ;
2010-04-25 13:52:14 +00:00
$saveVars = $this -> eVars ; // In case of nested call
2011-03-24 21:29:45 +00:00
$saveCodes = $this -> addedCodes ;
2010-04-25 13:52:14 +00:00
$this -> eVars = $eVars ;
2011-03-24 21:29:45 +00:00
$this -> addedCodes = NULL ;
2013-04-18 12:41:32 -07:00
2013-04-28 19:14:14 +03:00
// former $sc_style - do it once here and not on every doCode loop - performance
2015-07-20 12:11:49 -07:00
$this -> sc_style = e107 :: scStyle (); //FIXME - BC Problems and conflicts.
2013-05-07 18:30:02 -07:00
/* --------- BUG TEST Scenario --------------
* Front - end Theme : Bootstrap
* MENU - 1 contains '{NAVIGATION=side}' on top and chatbox_menu below
* URL to use : / usersettings . php - 'Signature' input should be enabled .
* Expected Result :
* 1 ) { NAVIGATION = side } wrapped with $SC_WRAPPER ie . enclosed in box .
* 2 ) Internal styling of chatbox_class not to be damaged by what happens globally ie . the text 'Display name' should not appear in the chatbox
* 3 ) Usersettings Signature box to appear wrapped in BC $sc_style pre / post - ie . should appear at the bottom of the html table . ( not at the top )
* 4 ) Existing Chatbox Styling ( v1 . x ) not broken ( ie . test with v1 theme ) .
* - All of the above to occur without changes to usersetting_template . php - since its logic is that of v1 . x templates .
*
* Things that may help :
* Modify e107 :: getScBatch () so that it never registers shortcodes globally ; ie . no overriding of existing shortcodes with it , as it is a replacement for non - global shortcode declaration in v1
* ONLY globally register shortcodes when they are declared in e_shortcode . php - this is consistent with the logic of e_xxxx which affect e107 Outside of the plugin / sript . ( gallery plugin follows this logic )
*
*/
2013-04-28 19:14:14 +03:00
if ( isset ( $sc_style ) && is_array ( $sc_style ))
{
2013-05-07 18:30:02 -07:00
$this -> sc_style = array_merge ( $sc_style , $this -> sc_style ); // XXX Commenting this out will fix #2 above.
2013-04-28 19:14:14 +03:00
}
2010-01-23 16:41:56 +00:00
2009-08-20 16:41:29 +00:00
//object support
2013-05-07 18:30:02 -07:00
2010-04-25 13:52:14 +00:00
if ( is_object ( $extraCodes ))
2009-08-20 16:41:29 +00:00
{
2016-02-29 15:13:32 -08:00
2013-05-07 18:30:02 -07:00
2011-03-24 21:29:45 +00:00
$this -> addedCodes = & $extraCodes ;
2013-04-28 19:14:14 +03:00
// TEMPLATEID_WRAPPER support - see contact template
// must be registered in e_shortcode object (batch) via wrapper() method before parsing
// Do it only once per parsing cylcle and not on every doCode() loop - performance
if ( method_exists ( $this -> addedCodes , 'wrapper' ))
{
2015-08-22 00:17:07 -07:00
// $cname = get_class($this->addedCodes);
2015-07-20 12:11:49 -07:00
$tmpWrap = e107 :: templateWrapper ( $this -> addedCodes -> wrapper ());
if ( ! empty ( $tmpWrap )) // FIX for #3 above.
{
$this -> wrappers = array_merge ( $this -> wrappers , $tmpWrap );
}
2015-08-22 00:17:07 -07:00
2013-04-28 19:14:14 +03:00
}
2015-07-20 12:11:49 -07:00
2011-03-24 21:29:45 +00:00
/*
2009-09-25 20:15:19 +00:00
$classname = get_class ( $extraCodes );
2010-02-10 21:53:56 +00:00
2009-09-25 20:15:19 +00:00
//register once
2010-04-25 13:52:14 +00:00
if ( ! $this -> isScClass ( $classname ))
2009-09-25 20:15:19 +00:00
{
2011-03-24 21:29:45 +00:00
$this -> registerShortcode ( $extraCodes , true ); // Register class if not already registered
2009-09-25 20:15:19 +00:00
}
2010-02-10 21:53:56 +00:00
2009-09-25 20:15:19 +00:00
//always overwrite object
$this -> scClasses [ $classname ] = $extraCodes ;
2011-03-24 21:29:45 +00:00
*/
2010-04-26 15:05:59 +00:00
2010-04-25 13:52:14 +00:00
// auto-register eVars if possible - call it manually?
2010-04-25 15:04:53 +00:00
// $this->callScFunc($classname, 'setParserVars', $this->eVars);
2009-08-20 16:41:29 +00:00
}
2014-08-17 20:53:44 -07:00
elseif ( is_array ( $extraCodes )) // Array value contains the contents of a .sc file which is then parsed. ie. return " whatever ";
2008-02-13 02:57:17 +00:00
{
2015-08-22 00:17:07 -07:00
$this -> addedCodes = & $extraCodes ;
2011-03-24 21:29:45 +00:00
/*
2010-04-25 13:52:14 +00:00
foreach ( $extraCodes as $sc => $code )
2008-02-13 02:57:17 +00:00
{
2006-12-02 04:36:16 +00:00
$this -> scList [ $sc ] = $code ;
}
2011-03-24 21:29:45 +00:00
*/
2014-08-17 20:53:44 -07:00
// print_a($this);
2006-12-02 04:36:16 +00:00
}
2015-08-22 00:17:07 -07:00
2016-01-24 20:08:47 -08:00
$ret = preg_replace_callback ( '#\{([A-Z][^\x02]*?\S)\}#' , array ( & $this , 'doCode' ), $text ); // must always start with uppercase letter
// $ret = preg_replace_callback('#\{(\S[^\x02]*?\S)\}#', array(&$this, 'doCode'), $text);
2010-04-25 13:52:14 +00:00
$this -> parseSCFiles = $saveParseSCFiles ; // Restore previous value
2011-03-24 21:29:45 +00:00
$this -> addedCodes = $saveCodes ;
2010-04-25 13:52:14 +00:00
$this -> eVars = $saveVars ; // restore eVars
2013-04-18 12:41:32 -07:00
$this -> debug_legacy = null ;
2013-05-07 18:30:02 -07:00
2014-08-17 20:53:44 -07:00
// $this->sc_style = array(); //XXX Adding this will also fix #2 above.
2013-05-07 18:30:02 -07:00
2006-12-02 04:36:16 +00:00
return $ret ;
}
2011-03-24 21:29:45 +00:00
/**
* Callback looks up and substitutes a shortcode
*/
2006-12-02 04:36:16 +00:00
function doCode ( $matches )
{
2014-08-18 22:57:18 -07:00
// print_a($matches);
if ( in_array ( $matches [ 0 ], $this -> ignoreCodes )) // Ignore all {e_PLUGIN}, {THEME} etc. otherwise it will just return blank for these items.
{
return $matches [ 0 ];
}
2013-04-28 19:14:14 +03:00
// XXX remove all globals, $sc_style removed
global $pref , $e107cache , $menu_pref , $parm , $sql ;
2013-03-11 05:11:58 -07:00
$parmArray = false ;
2015-08-22 00:17:07 -07:00
$fullShortcodeKey = null ;
2006-12-02 04:36:16 +00:00
2010-04-25 13:52:14 +00:00
if ( $this -> eVars )
{
if ( $this -> eVars -> isVar ( $matches [ 1 ]))
{
2016-02-15 19:59:47 -08:00
$match1 = $matches [ 1 ]; // php7 fix.
return $this -> eVars -> $match1 ;
2010-01-23 16:41:56 +00:00
}
}
2010-04-25 13:52:14 +00:00
if ( strpos ( $matches [ 1 ], E_NL ) !== false )
{
return $matches [ 0 ];
}
2013-03-11 02:41:48 -07:00
2016-01-24 20:08:47 -08:00
2013-05-29 15:33:39 -07:00
if ( preg_match ( '/^([A-Z_]*):(.*)/' , $matches [ 1 ], $newMatch ))
2013-03-11 05:11:58 -07:00
{
2015-08-22 00:17:07 -07:00
$fullShortcodeKey = $newMatch [ 0 ];
2013-03-11 05:11:58 -07:00
$code = $newMatch [ 1 ];
$parmStr = trim ( $newMatch [ 2 ]);
2013-04-29 19:38:26 -07:00
$debugParm = $parmStr ;
2013-03-11 05:11:58 -07:00
parse_str ( $parmStr , $parm );
$parmArray = true ;
}
elseif ( strpos ( $matches [ 1 ], '=' ))
2006-12-02 04:36:16 +00:00
{
2013-03-11 02:41:48 -07:00
list ( $code , $parm ) = explode ( '=' , $matches [ 1 ], 2 );
2006-12-02 04:36:16 +00:00
}
else
{
2013-03-11 02:41:48 -07:00
$code = $matches [ 1 ];
$parm = '' ;
2006-12-02 04:36:16 +00:00
}
2013-03-11 02:41:48 -07:00
//look for the $sc_mode
if ( strpos ( $code , '|' ))
2007-06-13 02:53:21 +00:00
{
2013-03-11 02:41:48 -07:00
list ( $code , $sc_mode ) = explode ( " | " , $code , 2 );
$code = trim ( $code );
$sc_mode = trim ( $sc_mode );
2007-06-13 02:53:21 +00:00
}
else
{
2013-03-11 02:41:48 -07:00
$sc_mode = '' ;
2007-03-30 13:33:29 +00:00
}
2013-03-11 05:11:58 -07:00
if ( $parmArray == false )
{
$parm = trim ( $parm );
$parm = str_replace ( array ( '[[' , ']]' ), array ( '{' , '}' ), $parm );
}
2010-09-10 01:00:36 +00:00
if ( E107_DBG_BBSC || E107_DBG_SC || E107_DBG_TIMEDETAILS )
2006-12-02 04:36:16 +00:00
{
2006-12-05 09:15:08 +00:00
$sql -> db_Mark_Time ( " SC $code " );
2006-12-02 04:36:16 +00:00
}
2010-04-25 13:52:14 +00:00
if ( E107_DBG_SC )
2006-12-02 04:36:16 +00:00
{
2013-04-18 12:41:32 -07:00
$dbg = " <strong> " ;
$dbg .= '{' ;
$dbg .= $code ;
$dbg .= ( $parm ) ? '=' . htmlentities ( $parm ) : " " ;
$dbg .= '}' ;
$dbg .= " </strong> " ;
// echo $dbg;
return $dbg ;
2010-04-25 13:52:14 +00:00
// trigger_error('starting shortcode {'.$code.'}', E_USER_ERROR); // no longer useful - use ?[debug=bbsc]
2013-04-18 12:41:32 -07:00
}
2009-01-08 17:23:13 +00:00
$scCode = '' ;
$scFile = '' ;
2015-07-02 14:15:17 -07:00
$_path = '' ;
2011-03-24 21:29:45 +00:00
$ret = '' ;
$_method = 'sc_' . strtolower ( $code );
2013-04-29 19:38:26 -07:00
if ( is_object ( $this -> addedCodes ) && method_exists ( $this -> addedCodes , $_method )) //It is class-based batch shortcode. Class already loaded; call the method
2011-03-24 21:29:45 +00:00
{
2013-04-18 12:41:32 -07:00
2013-04-29 19:38:26 -07:00
$ret = $this -> addedCodes -> $_method ( $parm , $sc_mode );
if ( E107_DBG_BBSC || E107_DBG_SC || E107_DBG_TIMEDETAILS )
{
$_class = get_class ( $this -> addedCodes ); // "(class loaded)"; // debug.
$_function = $_method ;
$_path = " (already loaded) " ;
}
2011-03-24 21:29:45 +00:00
}
2013-04-29 19:38:26 -07:00
elseif ( is_array ( $this -> addedCodes ) && array_key_exists ( $code , $this -> addedCodes )) // Its array-based shortcode. Load the code for evaluation later.
2011-03-24 21:29:45 +00:00
{
2013-04-29 19:38:26 -07:00
2011-03-24 21:29:45 +00:00
$scCode = $this -> addedCodes [ $code ];
2013-04-18 12:41:32 -07:00
// $_path = print_a($this->backTrace,true);
//XXX $_path = print_a($this,true);
2011-03-24 21:29:45 +00:00
}
2013-04-29 19:38:26 -07:00
elseif ( array_key_exists ( $code , $this -> scList )) // Check to see if we've already loaded the .sc file contents
2009-01-08 17:23:13 +00:00
{
2013-04-18 12:41:32 -07:00
2009-01-08 17:23:13 +00:00
$scCode = $this -> scList [ $code ];
2013-04-18 12:41:32 -07:00
$_path = " (loaded earlier) " ; // debug.
2006-12-02 04:36:16 +00:00
}
else
{
2009-01-08 17:23:13 +00:00
//.sc file not yet loaded, or shortcode is new function type
if ( $this -> parseSCFiles == true )
2007-06-13 02:53:21 +00:00
{
2013-04-18 12:41:32 -07:00
2009-01-08 17:23:13 +00:00
if ( array_key_exists ( $code , $this -> registered_codes ))
2006-12-02 04:36:16 +00:00
{
2009-01-08 20:16:47 +00:00
//shortcode is registered, let's proceed.
2010-04-25 13:52:14 +00:00
if ( isset ( $this -> registered_codes [ $code ][ 'perms' ]))
2009-01-08 20:16:47 +00:00
{
2010-04-25 13:52:14 +00:00
if ( ! check_class ( $this -> registered_codes [ $code ][ 'perms' ]))
{
return '' ;
}
2009-01-08 20:16:47 +00:00
}
2010-04-25 13:52:14 +00:00
switch ( $this -> registered_codes [ $code ][ 'type' ])
2006-12-02 04:36:16 +00:00
{
2009-01-08 17:23:13 +00:00
case 'class' :
2009-01-08 20:16:47 +00:00
//It is batch shortcode. Load the class and call the method
2013-04-18 12:41:32 -07:00
$_class = $this -> registered_codes [ $code ][ 'class' ];
$_method = 'sc_' . strtolower ( $code );
2010-04-25 13:52:14 +00:00
if ( ! $this -> isScClass ( $_class ))
2009-01-08 17:23:13 +00:00
{
2010-04-25 13:52:14 +00:00
if ( ! class_exists ( $_class ) && $this -> registered_codes [ $code ][ 'path' ])
2009-01-08 17:23:13 +00:00
{
2009-01-09 01:12:18 +00:00
include_once ( $this -> registered_codes [ $code ][ 'path' ]);
2009-01-08 17:23:13 +00:00
}
2010-04-25 13:52:14 +00:00
$this -> initShortcodeClass ( $_class , false );
if ( ! $this -> isScClass ( $_class ))
{
return '' ;
}
2010-04-26 15:05:59 +00:00
2010-04-25 13:52:14 +00:00
// egister passed eVars object on init - call it manually?
2012-04-24 11:22:07 +00:00
// $this->callScFunc($_class, 'setVars', $this->var);
2009-01-08 17:23:13 +00:00
}
2010-04-26 15:05:59 +00:00
2010-04-25 13:52:14 +00:00
// FIXME - register passed eVars object - BAD solution - called on EVERY sc method call
// XXX - removal candidate - I really think it should be done manually (outside the parser)
2010-04-25 15:04:53 +00:00
// via e107::getScBatch(name)->setParserVars($eVars);
// $this->callScFunc($_class, 'setParserVars', $this->eVars);
2013-04-28 19:14:14 +03:00
$wrapper = $this -> callScFunc ( $_class , 'wrapper' , null );
2015-08-22 00:17:07 -07:00
2010-04-25 13:52:14 +00:00
$ret = $this -> callScFuncA ( $_class , $_method , array ( $parm , $sc_mode ));
2013-04-18 12:41:32 -07:00
2010-04-25 13:52:14 +00:00
/* if ( method_exists ( $this -> scClasses [ $_class ], $_method ))
2009-01-08 17:23:13 +00:00
{
2009-01-15 20:18:46 +00:00
$ret = $this -> scClasses [ $_class ] -> $_method ( $parm , $sc_mode );
2009-01-08 17:23:13 +00:00
}
2009-01-25 17:44:13 +00:00
else
{
echo $_class . '::' . $_method . ' NOT FOUND!<br />' ;
2010-04-25 13:52:14 +00:00
} */
2010-02-10 21:53:56 +00:00
2009-01-08 17:23:13 +00:00
break ;
2013-02-08 16:49:57 +02:00
case 'override' :
2009-01-08 17:23:13 +00:00
case 'func' :
2013-02-11 14:25:59 +02:00
case 'plugin' :
2009-01-08 17:23:13 +00:00
//It is a function, so include the file and call the function
$_function = $this -> registered_codes [ $code ][ 'function' ];
2013-02-08 16:49:57 +02:00
if ( ! function_exists ( $_function ) && $this -> registered_codes [ $code ][ 'path' ])
2009-01-08 17:23:13 +00:00
{
include_once ( $this -> registered_codes [ $code ][ 'path' ] . strtolower ( $code ) . '.php' );
2009-11-23 10:27:43 +00:00
2009-01-08 17:23:13 +00:00
}
2013-02-11 14:25:59 +02:00
2010-04-25 13:52:14 +00:00
if ( function_exists ( $_function ))
2009-01-08 17:23:13 +00:00
{
2009-01-15 20:18:46 +00:00
$ret = call_user_func ( $_function , $parm , $sc_mode );
2009-01-08 17:23:13 +00:00
}
break ;
2013-02-11 14:25:59 +02:00
case 'plugin_legacy' :
2007-06-13 02:53:21 +00:00
$scFile = e_PLUGIN . strtolower ( $this -> registered_codes [ $code ][ 'path' ]) . '/' . strtolower ( $code ) . '.sc' ;
2009-01-08 17:23:13 +00:00
break ;
2013-02-08 16:49:57 +02:00
// case 'override':
// $scFile = e_CORE.'override/shortcodes/'.strtolower($code).'.sc';
// break;
2009-01-16 01:02:41 +00:00
2009-01-08 17:23:13 +00:00
case 'theme' :
$scFile = THEME . strtolower ( $code ) . '.sc' ;
break ;
}
2008-03-02 21:08:31 +00:00
}
2009-01-08 17:23:13 +00:00
else
{
// Code is not registered, let's look for .sc or .php file
// .php file takes precedence over .sc file
2010-04-25 13:52:14 +00:00
if ( is_readable ( e_CORE . 'shortcodes/single/' . strtolower ( $code ) . '.php' ))
2009-01-08 17:23:13 +00:00
{
$_function = strtolower ( $code ) . '_shortcode' ;
2009-11-23 10:27:43 +00:00
$_class = strtolower ( $code );
2013-04-18 12:41:32 -07:00
$_path = e_CORE . 'shortcodes/single/' . strtolower ( $code ) . '.php' ;
2010-02-10 21:53:56 +00:00
include_once ( e_CORE . 'shortcodes/single/' . strtolower ( $code ) . '.php' );
2010-04-25 13:52:14 +00:00
if ( class_exists ( $_class , false )) // prevent __autoload - performance
2009-11-23 10:27:43 +00:00
{
2013-08-27 13:56:36 +03:00
// SecretR - fix array(parm, sc_mode) causing parm to become an array, see issue 424
$ret = call_user_func ( array ( $_class , $_function ), $parm , $sc_mode );
2009-11-23 10:27:43 +00:00
}
2010-04-25 13:52:14 +00:00
elseif ( function_exists ( $_function ))
2007-06-13 02:53:21 +00:00
{
2013-03-11 05:11:58 -07:00
$ret = call_user_func ( $_function , $parm , $sc_mode );
2007-06-13 02:53:21 +00:00
}
2006-12-02 04:36:16 +00:00
}
else
{
2010-02-10 21:53:56 +00:00
$scFile = e_CORE . 'shortcodes/single/' . strtolower ( $code ) . '.sc' ;
2013-04-18 12:41:32 -07:00
$_path = $scFile ;
2006-12-02 04:36:16 +00:00
}
}
2009-01-08 17:23:13 +00:00
if ( $scFile && file_exists ( $scFile ))
{
$scCode = file_get_contents ( $scFile );
$this -> scList [ $code ] = $scCode ;
2013-04-18 12:41:32 -07:00
$_path = $scFile ;
2014-08-18 22:57:18 -07:00
}
else
{
// $ret = 'Missing!';
$_path .= " MISSING! " ;
2009-01-08 17:23:13 +00:00
}
2006-12-02 04:36:16 +00:00
}
2008-02-13 02:57:17 +00:00
2009-01-08 17:23:13 +00:00
if ( ! isset ( $scCode ))
2007-06-13 02:53:21 +00:00
{
2010-04-25 13:52:14 +00:00
if ( E107_DBG_BBSC )
{
trigger_error ( 'shortcode not found:{' . $code . '}' , E_USER_ERROR );
}
2008-02-13 02:57:17 +00:00
return $matches [ 0 ];
2007-06-13 02:53:21 +00:00
}
2007-03-05 21:24:47 +00:00
2010-04-25 13:52:14 +00:00
if ( E107_DBG_SC && $scFile )
2007-06-13 02:53:21 +00:00
{
2010-04-25 13:52:14 +00:00
// echo (isset($scFile)) ? "<br />sc_file= ".str_replace(e_CORE.'shortcodes/single/', '', $scFile).'<br />' : '';
// echo "<br />sc= <b>$code</b>";
2011-03-24 21:29:45 +00:00
}
2009-01-08 17:23:13 +00:00
}
2006-12-02 04:36:16 +00:00
2010-04-25 13:52:14 +00:00
if ( $scCode )
2009-01-08 17:23:13 +00:00
{
2014-10-03 20:59:05 -07:00
$ret = @ eval ( $scCode );
if ( $ret === false && E107_DEBUG_LEVEL > 0 ) // Error in Code.
{
$string = print_a ( $scCode , true );
e107 :: getMessage () -> addDebug ( 'Could not parse Shortcode ' . $scFile . ' :: {' . $code . '} ' . $string );
}
2006-12-02 04:36:16 +00:00
}
2015-08-22 00:17:07 -07:00
2010-04-25 13:52:14 +00:00
if ( isset ( $ret ) && ( $ret != '' || is_numeric ( $ret )))
2006-12-02 04:36:16 +00:00
{
2013-04-28 19:14:14 +03:00
// Wrapper support - see contact_template.php
2015-08-22 00:17:07 -07:00
if ( isset ( $this -> wrappers [ $code ]) && ! empty ( $this -> wrappers [ $code ])) // eg: $NEWS_WRAPPER['view']['item']['NEWSIMAGE']
2008-02-13 02:57:17 +00:00
{
2013-04-28 19:14:14 +03:00
list ( $pre , $post ) = explode ( " { ---} " , $this -> wrappers [ $code ], 2 );
$ret = $pre . $ret . $post ;
2015-08-22 00:17:07 -07:00
}
elseif ( ! empty ( $fullShortcodeKey ) && ! empty ( $this -> wrappers [ $fullShortcodeKey ]) ) // eg: $NEWS_WRAPPER['view']['item']['NEWSIMAGE: item=1']
{
list ( $pre , $post ) = explode ( " { ---} " , $this -> wrappers [ $fullShortcodeKey ], 2 );
$ret = $pre . $ret . $post ;
2007-03-30 13:33:29 +00:00
}
2013-04-28 19:14:14 +03:00
else
2006-12-02 04:36:16 +00:00
{
2013-04-28 19:14:14 +03:00
//if $sc_mode exists, we need it to parse $sc_style
if ( $sc_mode )
2006-12-02 04:36:16 +00:00
{
2013-04-28 19:14:14 +03:00
$code = $code . '|' . $sc_mode ;
2006-12-02 04:36:16 +00:00
}
2013-04-28 19:14:14 +03:00
if ( is_array ( $this -> sc_style ) && array_key_exists ( $code , $this -> sc_style ))
2006-12-02 04:36:16 +00:00
{
2013-04-28 19:14:14 +03:00
$pre = $post = '' ;
// old way - pre/post keys
if ( is_array ( $this -> sc_style [ $code ]))
{
if ( isset ( $this -> sc_style [ $code ][ 'pre' ]))
{
$pre = $this -> sc_style [ $code ][ 'pre' ];
}
if ( isset ( $this -> sc_style [ $code ][ 'post' ]))
{
2013-04-29 13:31:21 +03:00
$post = $this -> sc_style [ $code ][ 'post' ];
2013-04-28 19:14:14 +03:00
}
}
// new way - same format as wrapper
else
{
list ( $pre , $post ) = explode ( " { ---} " , $this -> sc_style [ $code ], 2 );
}
$ret = $pre . $ret . $post ;
2006-12-02 04:36:16 +00:00
}
}
}
2010-09-10 01:00:36 +00:00
if ( E107_DBG_SC || E107_DBG_TIMEDETAILS )
2008-02-13 02:57:17 +00:00
{
2010-09-10 01:00:36 +00:00
$sql -> db_Mark_Time ( " (After SC { $code } ) " );
2006-12-05 09:15:08 +00:00
}
2013-04-18 12:41:32 -07:00
if ( E107_DBG_BBSC || E107_DBG_SC || E107_DBG_TIMEDETAILS )
{
global $db_debug ;
$other = array ();
2013-04-29 19:38:26 -07:00
2013-04-18 12:41:32 -07:00
if ( $_class )
{
$other [ 'class' ] = $_class ;
}
2013-05-24 18:11:14 +02:00
if ( vartrue ( $_function ))
2013-04-18 12:41:32 -07:00
{
$other [ 'function' ] = $_function ;
}
2013-05-24 18:11:14 +02:00
if ( vartrue ( $_path ))
2013-04-18 12:41:32 -07:00
{
$other [ 'path' ] = str_replace ( '../' , '' , $_path );
}
if ( $this -> debug_legacy )
{
2013-04-29 19:38:26 -07:00
$other = $this -> debug_legacy ;
2013-04-18 12:41:32 -07:00
}
2015-08-22 00:17:07 -07:00
if ( ! empty ( $this -> wrappers [ $code ]))
{
$other [ 'wrapper' ] = $this -> wrappers [ $code ];
}
elseif ( ! empty ( $this -> wrappers [ $fullShortcodeKey ]) )
{
$other [ 'wrapper' ] = $this -> wrappers [ $fullShortcodeKey ];
}
2013-04-18 12:41:32 -07:00
$info = ( isset ( $this -> registered_codes [ $code ])) ? print_a ( $this -> registered_codes [ $code ], true ) : print_a ( $other , true );
2013-04-29 19:38:26 -07:00
$tmp = isset ( $debugParm ) ? $debugParm : $parm ;
$db_debug -> logCode ( 2 , $code , $tmp , $info );
2015-08-22 00:17:07 -07:00
2013-04-18 12:41:32 -07:00
}
2009-12-17 22:47:20 +00:00
return isset ( $ret ) ? $ret : '' ;
2006-12-02 04:36:16 +00:00
}
2006-12-03 07:03:22 +00:00
function parse_scbatch ( $fname , $type = 'file' )
{
global $e107cache , $eArrayStorage ;
2006-12-05 09:15:08 +00:00
$cur_shortcodes = array ();
2010-04-25 13:52:14 +00:00
if ( $type == 'file' )
2006-12-02 04:36:16 +00:00
{
2009-01-08 17:23:13 +00:00
$batch_cachefile = 'nomd5_scbatch_' . md5 ( $fname );
2008-02-13 02:57:17 +00:00
// $cache_filename = $e107cache->cache_fname("nomd5_{$batchfile_md5}");
2007-02-04 17:36:16 +00:00
$sc_cache = $e107cache -> retrieve_sys ( $batch_cachefile );
2010-04-25 13:52:14 +00:00
if ( ! $sc_cache )
2006-12-03 07:03:22 +00:00
{
$sc_batch = file ( $fname );
}
else
{
2015-02-14 23:34:15 -08:00
$cur_shortcodes = e107 :: unserialize ( $sc_cache );
2006-12-03 07:03:22 +00:00
$sc_batch = " " ;
}
2006-12-02 04:36:16 +00:00
}
else
{
$sc_batch = $fname ;
}
2013-04-18 12:41:32 -07:00
$this -> debug_legacy = array ( 'type' => $type , 'path' => str_replace ( e_ROOT , " " , $fname ));
2006-12-03 07:03:22 +00:00
2010-04-25 13:52:14 +00:00
if ( $sc_batch )
2006-12-03 07:03:22 +00:00
{
2006-12-05 09:15:08 +00:00
$cur_sc = '' ;
2010-04-25 13:52:14 +00:00
foreach ( $sc_batch as $line )
2006-12-03 07:03:22 +00:00
{
if ( trim ( $line ) == 'SC_END' )
{
$cur_sc = '' ;
}
if ( $cur_sc )
{
$cur_shortcodes [ $cur_sc ] .= $line ;
}
2009-08-20 16:41:29 +00:00
if ( preg_match ( '#^SC_BEGIN (\w*).*#' , $line , $matches ))
2006-12-03 07:03:22 +00:00
{
$cur_sc = $matches [ 1 ];
2010-04-25 13:52:14 +00:00
$cur_shortcodes [ $cur_sc ] = varset ( $cur_shortcodes [ $cur_sc ], '' );
2006-12-03 07:03:22 +00:00
}
2006-12-02 04:36:16 +00:00
}
2010-04-25 13:52:14 +00:00
if ( $type == 'file' )
2006-12-03 07:03:22 +00:00
{
$sc_cache = $eArrayStorage -> WriteArray ( $cur_shortcodes , false );
2007-02-04 17:36:16 +00:00
$e107cache -> set_sys ( $batch_cachefile , $sc_cache );
2006-12-02 04:36:16 +00:00
}
2006-12-03 07:03:22 +00:00
}
2010-04-25 13:52:14 +00:00
foreach ( array_keys ( $cur_shortcodes ) as $cur_sc )
2006-12-03 07:03:22 +00:00
{
2010-04-25 13:52:14 +00:00
if ( array_key_exists ( $cur_sc , $this -> registered_codes ))
2008-02-13 02:57:17 +00:00
{
2010-04-25 13:52:14 +00:00
if ( $this -> registered_codes [ $cur_sc ][ 'type' ] == 'plugin' )
2008-02-13 02:57:17 +00:00
{
2010-04-25 13:52:14 +00:00
$scFile = e_PLUGIN . strtolower ( $this -> registered_codes [ $cur_sc ][ 'path' ]) . '/' . strtolower ( $cur_sc ) . '.sc' ;
2008-02-13 02:57:17 +00:00
}
else
{
2006-12-03 07:03:22 +00:00
$scFile = THEME . strtolower ( $cur_sc ) . '.sc' ;
}
2008-02-13 02:57:17 +00:00
if ( is_readable ( $scFile ))
{
2006-12-03 07:03:22 +00:00
$cur_shortcodes [ $cur_sc ] = file_get_contents ( $scFile );
2006-12-02 04:36:16 +00:00
}
}
}
2006-12-03 07:03:22 +00:00
return $cur_shortcodes ;
2006-12-02 04:36:16 +00:00
}
}
2010-04-23 15:54:11 +00:00
class e_shortcode
{
/**
2012-08-23 11:42:54 +00:00
* Stores passed to shortcode handler array data
* Usage : $this -> var [ 'someKey' ]
* Assigned via setVars () and addVars () methods
* @ var array
2010-04-23 15:54:11 +00:00
*/
2012-08-23 11:42:54 +00:00
protected $var = array (); // value available to each shortcode.
2012-06-17 10:51:13 +00:00
protected $mode = 'view' ; // or edit. Used within shortcodes for form elements vs values only.
2010-04-25 13:52:14 +00:00
2013-04-28 19:14:14 +03:00
protected $wrapper = null ; // holds template/key value of the currently used wrapper (if any) - see contact_template.php for an example.
2013-04-26 13:49:57 -07:00
2010-04-23 15:54:11 +00:00
/**
2010-04-24 11:39:14 +00:00
* Storage for shortcode values
2010-04-23 15:54:11 +00:00
* @ var e_vars
*/
protected $scVars = null ;
2010-04-25 13:52:14 +00:00
public function __construct ()
2010-04-23 15:54:11 +00:00
{
$this -> scVars = new e_vars ();
}
2012-08-23 11:42:54 +00:00
/**
* Startup code for child class
*/
public function init () {}
2013-04-28 19:14:14 +03:00
/**
* Sets wrapper id ( to be retrieved from the registry while parsing )
* Example e107 :: getScBatch ( 'contact' ) -> wrapper ( 'contact/form' );
* which results in using the $CONTACT_WRAPPER [ 'form' ] wrapper in the parsing phase
2016-02-29 15:13:32 -08:00
* Template cannot be loaded via include , only by getTemplate or getCoreTemplate
* e107 :: getScBatch () must be used also .
2013-04-28 19:14:14 +03:00
*/
public function wrapper ( $id = null )
{
if ( null === $id ) return $this -> wrapper ;
if ( false === $id ) $id = null ;
$this -> wrapper = $id ;
2015-08-22 00:17:07 -07:00
2013-04-28 19:14:14 +03:00
return $this ;
}
2010-04-25 13:52:14 +00:00
2010-04-24 11:39:14 +00:00
/**
2012-08-23 11:42:54 +00:00
* Set external array data to be used in the batch
2012-11-02 00:23:59 +00:00
* Use setVars () - preferred .
2013-06-23 19:06:46 -07:00
* //XXX will soon become private. Use setVars() instead.
2012-08-23 11:42:54 +00:00
* @ param array $eVars
2010-04-24 11:39:14 +00:00
* @ return e_shortcode
*/
2013-06-23 19:06:46 -07:00
public function setParserVars ( $eVars )
2010-04-24 11:39:14 +00:00
{
2012-04-24 11:22:07 +00:00
$this -> var = $eVars ;
2010-04-24 11:39:14 +00:00
return $this ;
}
2012-06-17 10:51:13 +00:00
2012-11-02 00:23:59 +00:00
/**
* Alias of setParserVars - Preferred use by Plugins .
*/
2012-06-19 09:08:41 +00:00
public function setVars ( $eVars ) // Alias of setParserVars();
{
return $this -> setParserVars ( $eVars );
}
2012-08-23 11:42:54 +00:00
/**
* Add array to current parser array data
* @ param array $array
* @ return e_shortcode
*/
public function addParserVars ( $array )
2012-06-17 10:51:13 +00:00
{
2012-08-23 13:06:01 +00:00
if ( ! is_array ( $array )) return $this ;
2012-08-23 11:42:54 +00:00
$this -> var = array_merge ( $this -> var , $array );
return $this ;
}
/**
* Alias of addParserVars ()
* @ param array $array
* @ return e_shortcode
*/
public function addVars ( $array )
{
return $this -> addParserVars ( $array );
2012-06-17 10:51:13 +00:00
}
2010-04-25 13:52:14 +00:00
2010-04-24 11:39:14 +00:00
/**
* Get external simple parser object
2010-04-25 13:52:14 +00:00
*
2012-08-23 11:42:54 +00:00
* @ return array
2010-04-24 11:39:14 +00:00
*/
2010-04-25 15:04:53 +00:00
public function getParserVars ()
2010-04-24 11:39:14 +00:00
{
2012-04-24 11:22:07 +00:00
return $this -> var ;
2010-04-24 11:39:14 +00:00
}
2010-04-25 13:52:14 +00:00
2012-08-23 11:42:54 +00:00
/**
* Alias of getParserVars ()
*
* @ return array
*/
public function getVars ()
{
return $this -> getParserVars ();
}
/**
* Batch mod
* @ param string mod
* @ return e_shortcode
*/
public function setMode ( $mode )
{
$this -> mode = ( $mode == 'edit' ) ? 'edit' : 'view' ;
return $this ;
}
2010-04-23 15:54:11 +00:00
/**
* Add shortcode value
2010-12-07 13:30:22 +00:00
* < code > e107 :: getScBatch ( 'class_name' ) -> setScVar ( 'some_property' , $some_value ); </ code >
2010-04-23 15:54:11 +00:00
*
* @ param string $name
* @ param mixed $value
2010-04-24 11:39:14 +00:00
* @ return e_shortcode
2010-04-23 15:54:11 +00:00
*/
public function setScVar ( $name , $value )
{
$this -> scVars -> $name = $value ;
return $this ;
}
2010-12-07 13:30:22 +00:00
/**
* Add shortcode values
* < code > e107 :: getScBatch ( 'class_name' ) -> addScVars ( array ( 'some_property' , $some_value )); </ code >
*
* @ param array $vars
* @ return e_shortcode
*/
public function addScVars ( $vars )
{
$this -> scVars -> addVars ( $vars );
return $this ;
}
2010-04-25 13:52:14 +00:00
2010-04-23 15:54:11 +00:00
/**
* Retrieve shortcode value
2010-12-07 13:30:22 +00:00
* < code > $some_value = e107 :: getScBatch ( 'class_name' ) -> getScVar ( 'some_property' ); </ code >
2010-04-23 15:54:11 +00:00
*
* @ param string $name
* @ return mixed
*/
public function getScVar ( $name )
{
return $this -> scVars -> $name ;
}
2010-12-07 13:30:22 +00:00
/**
* Retrieve all shortcode values
* < code > $some_value = e107 :: getScBatch ( 'class_name' ) -> getScVars (); </ code >
*
* @ return mixed
*/
public function getScVars ()
{
return $this -> scVars -> getVars ();
}
2010-04-25 13:52:14 +00:00
2010-04-24 11:39:14 +00:00
/**
* Check if shortcode variable is set
2010-12-07 13:30:22 +00:00
* < code > if ( e107 :: getScBatch ( 'class_name' ) -> issetScVar ( 'some_property' ))
2010-04-25 13:52:14 +00:00
* {
2010-04-24 11:39:14 +00:00
* //do something
* } </ code >
*
* @ param string $name
* @ return boolean
*/
public function issetScVar ( $name )
{
return isset ( $this -> scVars -> $name );
}
2010-04-25 13:52:14 +00:00
2010-04-24 11:39:14 +00:00
/**
* Unset shortcode value
2010-12-07 13:30:22 +00:00
* < code > e107 :: getScBatch ( 'class_name' ) -> unsetScVar ( 'some_property' ); </ code >
2010-04-24 11:39:14 +00:00
*
* @ param string $name
2010-12-07 13:30:22 +00:00
* @ return e_shortcode
2010-04-24 11:39:14 +00:00
*/
public function unsetScVar ( $name )
{
$this -> scVars -> $name = null ;
2010-04-25 13:52:14 +00:00
unset ( $this -> scVars -> $name );
2010-12-07 13:30:22 +00:00
return $this ;
}
/**
* Empty scvar object data
* @ return e_shortcode
*/
public function emptyScVars ()
{
$this -> scVars -> emptyVars ();
return $this ;
2010-04-24 11:39:14 +00:00
}
2010-04-25 13:52:14 +00:00
2010-04-24 11:39:14 +00:00
/**
* Magic setter - bind to eVars object
*
* @ param string $name
* @ param mixed $value
*/
public function __set ( $name , $value )
{
$this -> setScVar ( $name , $value );
}
/**
* Magic getter - bind to eVars object
*
* @ param string $name
* @ return mixed value or null if key not found
*/
public function __get ( $name )
{
return $this -> getScVar ( $name );
}
2010-04-25 13:52:14 +00:00
2010-04-24 11:39:14 +00:00
/**
* Magic method - bind to eVars object
* NOTE : works on PHP 5.1 . 0 +
*
* @ param string $name
* @ return boolean
*/
public function __isset ( $name )
{
return $this -> issetScVar ( $name );
}
2010-04-25 13:52:14 +00:00
2010-04-24 11:39:14 +00:00
/**
* Magic method - bind to eVars object
* NOTE : works on PHP 5.1 . 0 +
*
* @ param string $name
*/
public function __unset ( $name )
{
$this -> unsetScVar ( $name );
}
2010-04-25 13:52:14 +00:00
}