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

Shortcode handler was failing to load classes under some conditions. Also added some debug info. (use e107 debugger for Firefox in SC mode)

This commit is contained in:
CaMer0n 2012-04-23 01:21:06 +00:00
parent 0733253516
commit 62e92a2621
3 changed files with 40 additions and 131 deletions

View File

@ -1567,7 +1567,7 @@ class e107
/**
* Get plugin template. Use this method for plugin templates, which are following the
* new template standards:
* - template variables naming conventions
* - template variables naming conventions ie. ${NAME IN CAPS}_TEMPLATE['{ID}'] = "<div>...</div>";
* - one array variable per template only
* - theme override is made now by current_theme/templates/plugin_name/ folder
*
@ -1590,12 +1590,16 @@ class e107
* @param boolean $info retrieve template info only
* @return string|array
*/
public static function getTemplate($plug_name, $id, $key = null, $override = true, $merge = false, $info = false)
public static function getTemplate($plug_name, $id = null, $key = null, $override = true, $merge = false, $info = false)
{
if(null === $plug_name)
{
return self::getCoreTemplate($id, $key, $override, $merge, $info);
}
if(null == $id) // loads {$plug_name}/templates/{$plug_name}_template.php and an array ${PLUG_NAME}_TEMPLATE
{
$id = $plug_name;
}
$reg_path = 'plugin/'.$plug_name.'/templates/'.$id.($override ? '/ext' : '');
$path = self::templatePath($plug_name, $id, $override);
$id = str_replace('/', '_', $id);

View File

@ -76,12 +76,13 @@ class e_parse_shortcode
function __construct()
{
$this->parseSCFiles = true; // Default probably never used, but make sure its defined.
$this->loadOverrideShortcodes();
$this->loadThemeShortcodes();
$this->loadPluginShortcodes();
$this->loadPluginSCFiles();
$this->loadCoreShortcodes();
}
/**
@ -250,7 +251,7 @@ class e_parse_shortcode
*
* <code><?php
* // simple use
* e107::getScParser()->getScObject('news_shortcodes');
* e107::getScParser()->getScObject('news_shortcodes'); // For Globally Registered shortcodes, including plugins using e_shortcode.php
*
* // plugin override - e107_plugins/myplug/shortcodes/batch/news_shortcodes.php -> class plugin_myplug_news_shortcodes
* e107::getScParser()->getScObject('news_shortcodes', 'myplug', true);
@ -260,14 +261,16 @@ class e_parse_shortcode
* e107::getScParser()->getScObject('news_shortcodes', 'myplug', 'news2_shortcodes');
* </code>
* @param string $className
* @param string $plugName
* @param string $plugName if true className is used., if string, string value is used.
* @param string $overrideClass if true, $className is used
* @return e_shortcode
*/
public function getScObject($className, $pluginName = null, $overrideClass = null)
{
if(trim($className)==""){ return; }
$_class_fname = $className;
// plugin override
if($overrideClass)
{
@ -279,27 +282,41 @@ class e_parse_shortcode
$_class_fname = $overrideClass;
$className = 'plugin_'.$pluginName.'_'.str_replace('/', '_', $overrideClass);
}
elseif($pluginName)
elseif(is_string($pluginName))
{
$className = 'plugin_'.$pluginName.'_'.str_replace('/', '_', $className);
}
if ($this->isScClass($className))
elseif($pluginName === TRUE)
{
$pluginName = str_replace("_shortcodes","",$className);
}
if ($this->isScClass($className)) // Includes global Shortcode Classes. ie. e_shortcode.php
{
return $this->scClasses[$className];
}
$path = ($pluginName ? e_PLUGIN.$pluginName.'/shortcodes/batch/' : e_CORE.'shortcodes/batch/').$_class_fname.'.php';
if (is_readable($path))
{
require_once($path);
if (class_exists($className, false)) // don't allow __autoload()
{
// register instance directly to allow override
$this->scClasses[$className] = new $className();
// $this->scClasses[$className] = new $className(); // located inside registerClassMethods()
$this->registerClassMethods($className, $path);
return $this->scClasses[$className];
}
elseif(E107_DBG_BBSC || E107_DBG_SC)
{
echo "Couldn't Find Class '".$className."' in <b>".$path."</b>";
}
}
elseif(E107_DBG_BBSC || E107_DBG_SC)
{
echo "Couldn't Load: <b>".$path."</b>";
}
// TODO - throw exception?
@ -410,6 +427,8 @@ class e_parse_shortcode
}
$this->registerClassMethods($classFunc, $path, false);
}
return $this;
}
@ -432,9 +451,16 @@ class e_parse_shortcode
if ($force || !$this->isRegistered($code))
{
$this->registered_codes[$code] = array('type' => 'class', 'path' => $path, 'class' => $className);
if (class_exists($className, false))
{
$this->scClasses[$className] = new $className(); // Required. Test with e107::getScBatch($className)
}
}
}
}
return $this;
}

View File

@ -1,121 +0,0 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2012 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Cron Administration
*
* $URL: https://e107.svn.sourceforge.net/svnroot/e107/trunk/e107_0.8/e107_admin/cron.php $
* $Id: cron.php 12492 2011-12-30 16:09:10Z e107steved $
*
*/
/**
*
* @package e107
* @subpackage frontend
* @version $Id: cron.php 12492 2011-12-30 16:09:10Z e107steved $
* Ultra-simple Image-Gallery
*/
/*
* THIS SCRIPT IS HIGHLY EXPERIMENTAL. USE AT OWN RISK.
*
*/
require_once("class2.php");
if (!getperms('0'))
{
header('location:'.e_BASE.'index.php');
exit;
}
require_once(HEADERF);
class gallery
{
private $catList = array();
function __construct()
{
$this->catList = e107::getMedia()->getCategories('gallery');
if(($_GET['cat']) && isset($this->catList[$_GET['cat']]))
{
$this->showImages($_GET['cat']);
}
else
{
$this->listCategories();
}
}
function listCategories()
{
foreach($this->catList as $val)
{
$thumb = "<img src='".e107::getParser()->thumbUrl($val['media_cat_image'],'aw=190&ah=150')."' alt='' />";
$text .= "<div style='width:190px;height:180px;float:left;margin:3px;border:1px solid black;background-color:black'>
<a href='".e_SELF."?cat=".$val['media_cat_category']."'>
".$thumb ."
<div style='text-align:center'><h3>".$val['media_cat_title']."</h2></a></div>
</div>";
}
e107::getRender()->tablerender("Gallery",$text);
}
function showImages($cat)
{
$GALLERY_LIST_START = "<div class='gallery-list-start' style='clear:both'>";
$GALLERY_LIST_ITEM = "<div class='gallery-list-item'>
{MEDIA_THUMB}
{MEDIA_CAPTION}
</div>";
$list = e107::getMedia()->getImages($cat);
foreach($list as $row)
{
$thumb = "<img src='".e107::getParser()->thumbUrl($row['media_url'],'aw=190&ah=150')."' alt='' />";
$text .= "<div style='width:190px;height:180px;float:left;margin:3px;border:1px solid black;background-color:black'>
<div>".$thumb."</div>
<div style='display:block;text-align:center;color:white;'>".$row['media_caption']."</div>
</div>";
//TODO GET TEMPLATING TO WORK WITHOUT THE USE OF A SHORTCODE FILE.
//TODO Shadowbox/Popup support.
// $sc = array("MEDIA_CAPTION" => $row['media_caption'],"MEDIA_THUMB"=> $thumb);
// $text .= e107::getParser()->simpleParse($GALLERY_LIST_ITEM, $sc); // NOT WORKING?
}
$GALLERY_LIST_END = "</div>
<div class='gallery-list-end' style='text-align:center;clear:both'><a href='".e_SELF."'>Back to Categories</a></div>";
$text = $GALLERY_LIST_START.$text.$GALLERY_LIST_END;
e107::getRender()->tablerender("Gallery :: ".str_replace("_"," ",$cat),$text);
}
}
new gallery;
require_once(FOOTERF);
exit;
?>