diff --git a/lib/plugins/pluginutil.inc.php b/lib/plugins/pluginutil.inc.php index cda4af5..ed70a97 100644 --- a/lib/plugins/pluginutil.inc.php +++ b/lib/plugins/pluginutil.inc.php @@ -214,9 +214,14 @@ class KTPluginUtil { KTPluginUtil::load($aPluginList); - // Load the template locations - $query = "SELECT * FROM plugin_helper h WHERE h.classtype='locations'"; + // Load the template locations - ignore disabled plugins + // Allow for templates that don't correctly link to the plugin + $query = "SELECT * FROM plugin_helper h + LEFT JOIN plugins p ON (p.namespace = h.plugin) + WHERE h.classtype='locations' AND (disabled = 0 OR disabled IS NULL)"; + $aLocations = DBUtil::getResultArray($query); + if(!empty($aLocations)){ $oTemplating =& KTTemplating::getSingleton(); foreach ($aLocations as $location){ diff --git a/lib/templating/templating.inc.php b/lib/templating/templating.inc.php index 56ccc76..1f8020d 100644 --- a/lib/templating/templating.inc.php +++ b/lib/templating/templating.inc.php @@ -127,12 +127,64 @@ class KTTemplating { * @param unknown_type $descr * @param unknown_type $loc */ - function addLocation ($descr, $loc) { + function addLocation ($descr, $loc, $sPluginNamespace = NULL) { $this->aLocationRegistry[$descr] = $loc; - KTPlugin::registerPluginHelper($descr, $descr, $loc, $descr.'|'.$loc, 'general', 'locations'); + + if(!empty($sPluginNamespace)){ + $sPlugin = $sPluginNamespace; + }else{ + $sPlugin = $this->getPluginName(); + $sPlugin = (!empty($sPlugin)) ? $sPlugin : $descr; + } + + KTPlugin::registerPluginHelper($sPlugin, $sPlugin, $loc, $descr.'|'.$loc, 'general', 'locations'); } // }}} + function getPluginName(){ + $class = 'kttemplating'; + $function = 'addlocation'; + $function2 = 'setup'; + $bIsPlugin = false; + $file = false; + $plugin = false; + + $trace = debug_backtrace(); + + if(empty($trace)){ + return ''; + } + + foreach($trace as $call){ + if(strtolower($call['class']) == $class && strtolower($call['function']) == $function){ + $file = $call['file']; + } + if($file && strtolower($call['function']) == $function2){ + $plugin = $call['class']; + } + if(strtolower($call['class']) == 'ktplugin' && strtolower($call['function']) == 'register'){ + $bIsPlugin = true; + break; + } + if(strtolower($call['class']) == 'ktplugindispatcher' && strtolower($call['function']) == 'do_update'){ + $bIsPlugin = true; + break; + } + } + + if($bIsPlugin && $file !== false && $plugin !== false){ + include_once($file); + $oPlugin = new $plugin; + $sPluginName = $oPlugin->sNamespace; + + if(!empty($sPluginName)){ + return $sPluginName; + } + } + + return ''; + } + /** * Add the template location to the location registry *