From 6d0aa7cdd972a8dc9fc00049626e81e3787c0744 Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 6 Apr 2016 19:43:31 -0700 Subject: [PATCH] New e_event.php v2.x specification. (e_module is no longer required for registering events.) Example added to e107_plugins/_blank --- e107_handlers/e107_class.php | 12 +++++-- e107_handlers/event_class.php | 20 +++++++++++ e107_plugins/_blank/e_event.php | 51 +++++++++++++++++++++++++++++ e107_plugins/social/e_shortcode.php | 4 +-- 4 files changed, 82 insertions(+), 5 deletions(-) create mode 100644 e107_plugins/_blank/e_event.php diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index 5279d154c..0695eba02 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -2064,7 +2064,7 @@ class e107 $elist = self::getPref($filename.'_list'); - if($elist) + if(!empty($elist)) { foreach(array_keys($elist) as $key) { @@ -2117,6 +2117,7 @@ class e107 { if(E107_DBG_INCLUDES) { + //$debug_backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 6); $mes->addDebug('Executing '.$class_name.' :: '.$method_name.'()'); } return call_user_func(array($obj, $method_name),$param, $param2); @@ -2856,7 +2857,12 @@ class e107 $key = $tmp[1]; } - $tmp = e107::getAddonConfig('e_url'); + if(!$tmp = self::getRegistry('core/e107/addons/e_url')) + { + $tmp = e107::getAddonConfig('e_url'); + self::setRegistry('core/e107/addons/e_url',$tmp); + } + $tp = e107::getParser(); $pref = self::getPref('e_url_alias'); @@ -3866,7 +3872,7 @@ class e107 { define('e_LOGIN', SITEURL.(file_exists(e_BASE.'customlogin.php') ? 'customlogin.php' : 'login.php')); } - + return $this; } diff --git a/e107_handlers/event_class.php b/e107_handlers/event_class.php index 1c609a2d0..841f06c16 100644 --- a/e107_handlers/event_class.php +++ b/e107_handlers/event_class.php @@ -36,6 +36,26 @@ class e107_event function __construct() { + $temp = e107::getAddonConfig('e_event'); + + if(!empty($temp)) + { + foreach($temp as $plug=>$data) + { + foreach($data as $event) + { + $name = $event['name']; + $class = array($plug."_event", $event['function']); + + if(!empty($name) && !empty($event['function'])) + { + $this->register($name, $class); + } + } + + } + + } } diff --git a/e107_plugins/_blank/e_event.php b/e107_plugins/_blank/e_event.php new file mode 100644 index 000000000..92b61530f --- /dev/null +++ b/e107_plugins/_blank/e_event.php @@ -0,0 +1,51 @@ +trigger('plugin_event',$array); + * Where 'plugin' is the folder of their plugin and 'event' is a unique name of the event. + * $array is data which is sent to the triggered function. eg. myfunction($array) in the example below. + * + * @return array + */ + function config() + { + + $event = array(); + + $event[] = array( + 'name' => "login", // when this is triggered... (see http://e107.org/developer-manual/classes-and-methods#events) + 'function' => "myfunction", // ..run this function (see below). + ); + + return $event; + + } + + + function myfunction($data) // the method to run. + { + print_a($data); + } + + + + + +} //end class + diff --git a/e107_plugins/social/e_shortcode.php b/e107_plugins/social/e_shortcode.php index 1d220c94e..0e4a11735 100644 --- a/e107_plugins/social/e_shortcode.php +++ b/e107_plugins/social/e_shortcode.php @@ -107,7 +107,7 @@ class social_shortcodes extends e_shortcode if($data['href'] != '') { - $text .= ''; + $text .= ''; $text .= "\n"; } } @@ -288,7 +288,7 @@ class social_shortcodes extends e_shortcode - $opt[$k] = "".$tp->toIcon($val["icon"]).""; + $opt[$k] = "".$tp->toIcon($val["icon"], array('fw'=>1)).""; } // Show only Email, Facebook, Twitter and Google.