1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-02 20:57:26 +02:00

Converting related core shortcodes to use batch class->method functionality.

This commit is contained in:
mcfly
2009-01-08 21:47:44 +00:00
parent d7b8b858cc
commit feed586bcb
9 changed files with 121 additions and 72 deletions

View File

@@ -0,0 +1,46 @@
<?php
/*
* Copyright e107 Inc e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id: siteinfo_shortcodes.php,v 1.1 2009-01-08 21:47:44 mcfly_e107 Exp $
*
* News shortcode batch
*/
if (!defined('e107_INIT')) { exit; }
//include_once(e_HANDLER.'shortcode_handler.php');
$codes = array('sitebutton', 'sitedisclaimer', 'sitename', 'sitedescription', 'sitetag');
register_shortcode('siteinfo_shortcodes', $codes);
class siteinfo_shortcodes
{
function get_sitebutton()
{
$e107 = e107::getInstance();
$path = ($_POST['sitebutton'] && $_POST['ajax_used']) ? $e107->tp->replaceConstants($_POST['sitebutton']) : (strstr(SITEBUTTON, 'http:') ? SITEBUTTON : e_IMAGE.SITEBUTTON);
return "<a href='".SITEURL."'><img src='".$path."' alt=\"".SITENAME."\" style='border: 0px; width: 88px; height: 31px' /></a>";
}
function get_sitedisclaimer()
{
$e107 = e107::getInstance();
return $e107->tp->toHtml(SITEDISCLAIMER, true, 'constants defs');
}
function get_sitename($parm)
{
return ($parm == 'link') ? "<a href='".SITEURL."' title=\"".SITENAME."\">".SITENAME."</a>" : SITENAME;
}
function get_sitedescription()
{
global $pref;
return SITEDESCRIPTION.(defined('THEME_DESCRIPTION') && $pref['displaythemeinfo'] ? THEME_DESCRIPTION : '');
}
function get_sitetag()
{
return SITETAG;
}
}
?>

View File

@@ -1,3 +0,0 @@
global $tp;
$path = ($_POST['sitebutton'] && $_POST['ajax_used']) ? $tp->replaceConstants($_POST['sitebutton']) : (strstr(SITEBUTTON, "http:") ? SITEBUTTON : e_IMAGE.SITEBUTTON);
return "<a href='".SITEURL."'><img src='".$path."' alt=\"".SITENAME."\" style='border: 0px; width: 88px; height: 31px' /></a>";

View File

@@ -1 +0,0 @@
return SITECONTACTINFO;

View File

@@ -1 +0,0 @@
return SITEDESCRIPTION.(defined("THEME_DESCRIPTION") && $pref['displaythemeinfo'] ? THEME_DESCRIPTION : "");

View File

@@ -1,3 +0,0 @@
global $tp;
$ret = $tp->toHtml(SITEDISCLAIMER,TRUE,"constants defs");
return $ret;

View File

@@ -1,2 +0,0 @@
return ($parm == "link") ? "<a href='".SITEURL."' title=\"".SITENAME."\">".SITENAME."</a>" : SITENAME;

View File

@@ -1 +0,0 @@
return SITETAG;

View File

@@ -9,9 +9,9 @@
* Text processing and parsing functions
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/e_parse_class.php,v $
* $Revision: 1.48 $
* $Date: 2009-01-03 22:32:54 $
* $Author: e107steved $
* $Revision: 1.49 $
* $Date: 2009-01-08 21:47:44 $
* $Author: mcfly_e107 $
*
*/
if (!defined('e107_INIT')) { exit; }
@@ -270,12 +270,16 @@ class e_parse
// Initialise the shortcode handler - has to be done when $prefs valid, so can't be done in constructor ATM
function sch_load()
function sch_load($noCore=false)
{
if (!is_object($this->e_sc))
{
require_once(e_HANDLER."shortcode_handler.php");
$this->e_sc = new e_shortcode;
if(!$noCore)
{
$this->e_sc->loadCoreShortcodes();
}
}
}

View File

@@ -12,8 +12,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/shortcode_handler.php,v $
| $Revision: 1.17 $
| $Date: 2009-01-08 20:16:47 $
| $Revision: 1.18 $
| $Date: 2009-01-08 21:47:44 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -56,7 +56,7 @@ class e_shortcode
var $registered_codes = array(); // Shortcodes added by plugins
var $scClasses = array(); // Batch shortcode classes
function e_shortcode()
function e_shortcode($noload=false)
{
global $pref, $register_sc;
@@ -97,6 +97,16 @@ class e_shortcode
}
}
}
}
function loadCoreShortcodes()
{
$coreBatchList = array('siteinfo_shortcodes.php');
foreach($coreBatchList as $cb)
{
include_once(e_FILE.'shortcode/batch/'.$cb);
}
}
function isRegistered($code)