1
0
mirror of https://github.com/e107inc/e107.git synced 2025-03-14 17:39:46 +01:00

Change shortcode handler so you can use a non-registered shortcode class or array, without the shortcodes getting registered, and without having to permit other registered shortcodes. Modify event calendar to use this method (gets rid of callScFunc() )

This commit is contained in:
e107steved 2011-03-24 21:29:45 +00:00
parent b8f183f46b
commit 13f51c79c3
7 changed files with 153 additions and 99 deletions

View File

@ -45,7 +45,7 @@ function setScVar($className, $scVarName, $value)
} }
/** /**
* FIXME: to be removed * FIXME: to be removed (once event calendar changed)
*/ */
function callScFunc($className, $scFuncName, $param = '') function callScFunc($className, $scFuncName, $param = '')
{ {
@ -64,7 +64,7 @@ class e_parse_shortcode
{ {
protected $scList = array(); // The actual code - added by parsing files or when plugin codes encountered. Array key is the shortcode name. 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 protected $parseSCFiles; // True if individual shortcode files are to be used
protected $addedCodes; // Apparently not used protected $addedCodes = NULL; // Pointer to a class or array to be used on a single call
protected $registered_codes = array(); // Shortcodes added by plugins TODO make it private protected $registered_codes = array(); // Shortcodes added by plugins TODO make it private
protected $scClasses = array(); // Batch shortcode classes - TODO make it private protected $scClasses = array(); // Batch shortcode classes - TODO make it private
protected $scOverride = array(); // Array of codes found in override/ dir protected $scOverride = array(); // Array of codes found in override/ dir
@ -487,43 +487,71 @@ class e_parse_shortcode
return in_array($code, $this->scOverride); return in_array($code, $this->scOverride);
} }
/**
* 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
*/
function parseCodes($text, $useSCFiles = true, $extraCodes = null, $eVars = null) function parseCodes($text, $useSCFiles = true, $extraCodes = null, $eVars = null)
{ {
$saveParseSCFiles = $this->parseSCFiles; // In case of nested call $saveParseSCFiles = $this->parseSCFiles; // In case of nested call
$this->parseSCFiles = $useSCFiles; $this->parseSCFiles = $useSCFiles;
$saveVars = $this->eVars; // In case of nested call $saveVars = $this->eVars; // In case of nested call
$saveCodes = $this->addedCodes;
$this->eVars = $eVars; $this->eVars = $eVars;
$this->addedCodes = NULL;
//object support //object support
if (is_object($extraCodes)) if (is_object($extraCodes))
{ {
$this->addedCodes = &$extraCodes;
/*
$classname = get_class($extraCodes); $classname = get_class($extraCodes);
//register once //register once
if (!$this->isScClass($classname)) if (!$this->isScClass($classname))
{ {
$this->registerShortcode($extraCodes, true); $this->registerShortcode($extraCodes, true); // Register class if not already registered
} }
//always overwrite object //always overwrite object
$this->scClasses[$classname] = $extraCodes; $this->scClasses[$classname] = $extraCodes;
*/
// auto-register eVars if possible - call it manually? // auto-register eVars if possible - call it manually?
// $this->callScFunc($classname, 'setParserVars', $this->eVars); // $this->callScFunc($classname, 'setParserVars', $this->eVars);
} }
elseif (is_array($extraCodes)) elseif (is_array($extraCodes))
{ {
$this->addedCodes = &$extraCodes;
/*
foreach ($extraCodes as $sc => $code) foreach ($extraCodes as $sc => $code)
{ {
$this->scList[$sc] = $code; $this->scList[$sc] = $code;
} }
*/
} }
$ret = preg_replace_callback('#\{(\S[^\x02]*?\S)\}#', array(&$this, 'doCode'), $text); $ret = preg_replace_callback('#\{(\S[^\x02]*?\S)\}#', array(&$this, 'doCode'), $text);
$this->parseSCFiles = $saveParseSCFiles; // Restore previous value $this->parseSCFiles = $saveParseSCFiles; // Restore previous value
$this->addedCodes = $saveCodes;
$this->eVars = $saveVars; // restore eVars $this->eVars = $saveVars; // restore eVars
return $ret; return $ret;
} }
/**
* Callback looks up and substitutes a shortcode
*/
function doCode($matches) function doCode($matches)
{ {
global $pref, $e107cache, $menu_pref, $sc_style, $parm, $sql; global $pref, $e107cache, $menu_pref, $sc_style, $parm, $sql;
@ -583,8 +611,20 @@ class e_parse_shortcode
$scCode = ''; $scCode = '';
$scFile = ''; $scFile = '';
$ret = '';
$_method = 'sc_'.strtolower($code);
if (is_object($this->addedCodes) && method_exists($this->addedCodes, $_method))
{
//It is class-based batch shortcode. Class already loaded; call the method
$ret = $this->addedCodes->$_method($parm, $sc_mode);
}
elseif (is_array($this->addedCodes) && array_key_exists($code, $this->addedCodes))
{
// Its array-based shortcode. Load the code for evaluation later.
$scCode = $this->addedCodes[$code];
}
// Check to see if we've already loaded the .sc file contents // Check to see if we've already loaded the .sc file contents
if (array_key_exists($code, $this->scList)) elseif (array_key_exists($code, $this->scList))
{ {
$scCode = $this->scList[$code]; $scCode = $this->scList[$code];
} }
@ -717,7 +757,7 @@ class e_parse_shortcode
{ {
// echo (isset($scFile)) ? "<br />sc_file= ".str_replace(e_CORE.'shortcodes/single/', '', $scFile).'<br />' : ''; // echo (isset($scFile)) ? "<br />sc_file= ".str_replace(e_CORE.'shortcodes/single/', '', $scFile).'<br />' : '';
// echo "<br />sc= <b>$code</b>"; // echo "<br />sc= <b>$code</b>";
} }
} }
if ($scCode) if ($scCode)

View File

@ -47,8 +47,9 @@ if (isset($_POST['printlists']))
exit(); exit();
} }
e107::getScParser(); //e107::getScParser();
require_once(e_PLUGIN.'calendar_menu/calendar_shortcodes.php'); require_once(e_PLUGIN.'calendar_menu/calendar_shortcodes.php');
$calSc = new event_calendar_shortcodes();
include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'.php'); include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'.php');
define('PAGE_NAME', EC_LAN_121); define('PAGE_NAME', EC_LAN_121);
@ -96,9 +97,14 @@ $nowday = $ecal_class->cal_date['mday'];
$monthstart = mktime(0, 0, 0, $month, 1, $year); // Start of month to be shown $monthstart = mktime(0, 0, 0, $month, 1, $year); // Start of month to be shown
$monthend = mktime(0, 0, 0, $month + 1, 1, $year) - 1; // End of month to be shown $monthend = mktime(0, 0, 0, $month + 1, 1, $year) - 1; // End of month to be shown
setScVar('event_calendar_shortcodes', 'ecalClass', &$ecal_class); // Give shortcodes a pointer to calendar class
callScFunc('event_calendar_shortcodes','setCalDate', $dateArray); // Tell shortcodes the date to display $calSc->ecalClass = &$ecal_class;
setScVar('event_calendar_shortcodes', 'catFilter', $cat_filter); // Category filter $calSc->setCalDate($dateArray);
$calSc->catFilter = $cat_filter;
//setScVar('event_calendar_shortcodes', 'ecalClass', &$ecal_class); // Give shortcodes a pointer to calendar class
//callScFunc('event_calendar_shortcodes','setCalDate', $dateArray); // Tell shortcodes the date to display
//setScVar('event_calendar_shortcodes', 'catFilter', $cat_filter); // Category filter
//------------------------------------------------- //-------------------------------------------------
@ -106,10 +112,10 @@ setScVar('event_calendar_shortcodes', 'catFilter', $cat_filter); // Category f
//------------------------------------------------- //-------------------------------------------------
// time switch buttons // time switch buttons
$cal_text = $e107->tp->parseTemplate($CALENDAR_TIME_TABLE, TRUE); $cal_text = $e107->tp->parseTemplate($CALENDAR_TIME_TABLE, FALSE, $calSc);
// navigation buttons // navigation buttons
$nav_text = $e107->tp->parseTemplate($CALENDAR_NAVIGATION_TABLE, TRUE); $nav_text = $e107->tp->parseTemplate($CALENDAR_NAVIGATION_TABLE, FALSE, $calSc);
// We'll need virtually all of the event-related fields, so get them regardless. Just cut back on category fields // We'll need virtually all of the event-related fields, so get them regardless. Just cut back on category fields
$ev_list = $ecal_class->get_events($monthstart, $monthend, FALSE, $cat_filter, TRUE, '*', 'event_cat_name,event_cat_icon'); $ev_list = $ecal_class->get_events($monthstart, $monthend, FALSE, $cat_filter, TRUE, '*', 'event_cat_name,event_cat_icon');
@ -172,16 +178,17 @@ $start = $monthstart;
$numberdays = date('t', $start); // number of days in this month $numberdays = date('t', $start); // number of days in this month
$text = ""; $text = "";
$text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_START, TRUE); $text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_START, FALSE, $calSc);
$text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_HEADER_START, TRUE); $text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_HEADER_START, FALSE, $calSc);
// Display the column headers // Display the column headers
for ($i = 0; $i < 7; $i++) for ($i = 0; $i < 7; $i++)
{ {
setScVar('event_calendar_shortcodes', 'headerDay', $ecal_class->day_offset_string($i)); $calSc->headerDay = $ecal_class->day_offset_string($i);
$text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_HEADER, TRUE); //setScVar('event_calendar_shortcodes', 'headerDay', $ecal_class->day_offset_string($i));
$text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_HEADER, FALSE, $calSc);
} }
$text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_HEADER_END, TRUE); $text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_HEADER_END, FALSE, $calSc);
// Calculate number of days to skip before 'real' days on first line of calendar // Calculate number of days to skip before 'real' days on first line of calendar
@ -190,30 +197,32 @@ if ($firstdayoffset < 0) $firstdayoffset+= 7;
for ($i=0; $i<$firstdayoffset; $i++) for ($i=0; $i<$firstdayoffset; $i++)
{ {
$text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_DAY_NON, TRUE); $text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_DAY_NON, FALSE, $calSc);
} }
$loop = $firstdayoffset; $loop = $firstdayoffset;
for ($c = 1; $c <= $numberdays; $c++) for ($c = 1; $c <= $numberdays; $c++)
{ // Loop through the number of days in this month { // Loop through the number of days in this month
setScVar('event_calendar_shortcodes', 'todayStart', $start); // Start of current day $calSc->todayStart = $start; // Start of current day
setScVar('event_calendar_shortcodes', 'curDay', $c); // Current day of month $calSc->curDay = $c; // Current day of month
//setScVar('event_calendar_shortcodes', 'todayStart', $start); // Start of current day
//setScVar('event_calendar_shortcodes', 'curDay', $c); // Current day of month
$got_ev = array_key_exists($c, $events) && is_array($events[$c]) && count($events[$c]) > 0; // Flag set if events on this day $got_ev = array_key_exists($c, $events) && is_array($events[$c]) && count($events[$c]) > 0; // Flag set if events on this day
// Highlight the current day. // Highlight the current day.
if ($nowday == $c && $month == $nowmonth && $year == $nowyear) if ($nowday == $c && $month == $nowmonth && $year == $nowyear)
{ //today { //today
$text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_DAY_TODAY, TRUE); $text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_DAY_TODAY, FALSE, $calSc);
} }
elseif ($got_ev) elseif ($got_ev)
{ //day has events { //day has events
$text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_DAY_EVENT, TRUE); $text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_DAY_EVENT, FALSE, $calSc);
} }
else else
{ // no events and not today { // no events and not today
$text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_DAY_EMPTY, TRUE); $text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_DAY_EMPTY, FALSE, $calSc);
} }
if ($got_ev) if ($got_ev)
{ {
@ -231,11 +240,12 @@ for ($c = 1; $c <= $numberdays; $c++)
$ev['imagesize'] = '4'; $ev['imagesize'] = '4';
$ev['fulltopic'] = FALSE; $ev['fulltopic'] = FALSE;
} }
setScVar('event_calendar_shortcodes', 'event', $ev); // Give shortcodes the event data //setScVar('event_calendar_shortcodes', 'event', $ev); // Give shortcodes the event data
$text .= $e107->tp->parseTemplate($CALENDAR_SHOWEVENT, TRUE); $calSc->event = $ev;
$text .= $e107->tp->parseTemplate($CALENDAR_SHOWEVENT, FALSE, $calSc);
} }
} }
$text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_DAY_END, TRUE); $text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_DAY_END, FALSE, $calSc);
$loop++; $loop++;
if ($loop == 7) if ($loop == 7)
@ -243,7 +253,7 @@ for ($c = 1; $c <= $numberdays; $c++)
$loop = 0; $loop = 0;
if($c != $numberdays) if($c != $numberdays)
{ {
$text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_WEEKSWITCH, TRUE); $text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_WEEKSWITCH, FALSE, $calSc);
} }
} }
$start += 86400; $start += 86400;
@ -254,10 +264,10 @@ if($loop!=0)
{ {
for ($c=$loop; $c<7; $c++) for ($c=$loop; $c<7; $c++)
{ {
$text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_DAY_NON, TRUE); $text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_DAY_NON, FALSE, $calSc);
} }
} }
$text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_END, TRUE); $text .= $e107->tp->parseTemplate($CALENDAR_CALENDAR_END, FALSE, $calSc);
$e107->ns->tablerender(EC_LAN_79, $cal_text . $nav_text . $text); $e107->ns->tablerender(EC_LAN_79, $cal_text . $nav_text . $text);

View File

@ -28,13 +28,14 @@ TODO:
1. Good way of reading categories 1. Good way of reading categories
2. Have 'currentMonth' flag (means 'current day' if $ds == 'one') ? 2. Have 'currentMonth' flag (means 'current day' if $ds == 'one') ?
3. Check whether $prop should be calculated better 3. Check whether $prop should be calculated better
4. Get rid of global on $pref
*/ */
if (!defined('e107_INIT')) { exit; } if (!defined('e107_INIT')) { exit; }
include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'.php'); include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'.php');
register_shortcode('event_calendar_shortcodes', true); //register_shortcode('event_calendar_shortcodes', true);
initShortcodeClass('event_calendar_shortcodes'); //initShortcodeClass('event_calendar_shortcodes');
/* /*
Navigation Shortcodes Navigation Shortcodes
@ -157,17 +158,17 @@ class event_calendar_shortcodes
{ {
protected $e107; protected $e107;
public $event; // Current event being displayed public $event; // Current event being displayed
public $ecalClass; // Pointer to event calendar class public $ecalClass; // Pointer to event calendar class
public $headerDay = 0; // Day number for header public $headerDay = 0; // Day number for header
public $todayStart; // Start of current day public $todayStart; // Start of current day
public $curDay; // Current day of month (1..31) public $curDay; // Current day of month (1..31)
public $numEvents = 0; // Number of events to be expected in certain list formats public $numEvents = 0; // Number of events to be expected in certain list formats
public $catFilter = '*'; // Event category filter public $catFilter = '*'; // Event category filter
public $eventDisplayCodes = ''; // Set to be an array of options public $eventDisplayCodes = ''; // Set to be an array of options
public $ecOutputType = ''; // Used by printing routines public $ecOutputType = ''; // Used by printing routines
public $changeFlags = array(); // Used by printing routines public $changeFlags = array(); // Used by printing routines
public $printVars = array(); // USed by printing routine public $printVars = array(); // USed by printing routine
private $months = array(EC_LAN_0, EC_LAN_1, EC_LAN_2, EC_LAN_3, EC_LAN_4, EC_LAN_5, EC_LAN_6, private $months = array(EC_LAN_0, EC_LAN_1, EC_LAN_2, EC_LAN_3, EC_LAN_4, EC_LAN_5, EC_LAN_6,
EC_LAN_7, EC_LAN_8, EC_LAN_9, EC_LAN_10, EC_LAN_11); // 'Long' month names EC_LAN_7, EC_LAN_8, EC_LAN_9, EC_LAN_10, EC_LAN_11); // 'Long' month names
@ -371,7 +372,7 @@ class event_calendar_shortcodes
global $pref; global $pref;
if ($this->ourDB == NULL) if ($this->ourDB == NULL)
{ {
$this->ourDB = new db; $this->ourDB = new db; // @todo use new method
} }
($parm == 'nosubmit') ? $insert = '' : $insert = "onchange='this.form.submit()'"; ($parm == 'nosubmit') ? $insert = '' : $insert = "onchange='this.form.submit()'";
$ret = "<select name='event_cat_ids' class='tbox' style='width:140px;' {$insert} >\n<option value='all'>".EC_LAN_97."</option>\n"; $ret = "<select name='event_cat_ids' class='tbox' style='width:140px;' {$insert} >\n<option value='all'>".EC_LAN_97."</option>\n";
@ -409,14 +410,14 @@ class event_calendar_shortcodes
{ {
if (!$this->event['event_allday']) return ''; if (!$this->event['event_allday']) return '';
if (trim($parm) == '') return ''; if (trim($parm) == '') return '';
return $this->e107->tp->parseTemplate('{'.$parm.'}'); return $this->e107->tp->parseTemplate('{'.$parm.'}', FALSE, $this);
} }
public function sc_ec_ifnot_allday($parm= '') public function sc_ec_ifnot_allday($parm= '')
{ {
if ($this->event['event_allday']) return ''; if ($this->event['event_allday']) return '';
if (trim($parm) == '') return ''; if (trim($parm) == '') return '';
return $this->e107->tp->parseTemplate('{'.$parm.'}'); return $this->e107->tp->parseTemplate('{'.$parm.'}', FALSE, $this);
} }
public function sc_ec_ifnot_sameday($parm= '') public function sc_ec_ifnot_sameday($parm= '')
@ -424,7 +425,7 @@ class event_calendar_shortcodes
if (intval($this->event['event_end']/86400) == intval($this->event['event_start']/86400)) return ''; if (intval($this->event['event_end']/86400) == intval($this->event['event_start']/86400)) return '';
if (!$this->event['event_allday']) return ''; if (!$this->event['event_allday']) return '';
if (trim($parm) == '') return; if (trim($parm) == '') return;
return $this->e107->tp->parseTemplate('{'.$parm.'}'); return $this->e107->tp->parseTemplate('{'.$parm.'}', FALSE, $this);
} }
public function sc_ec_if_sameday($parm= '') public function sc_ec_if_sameday($parm= '')
@ -432,7 +433,7 @@ class event_calendar_shortcodes
if (intval($this->event['event_end']/86400) != intval($this->event['event_start']/86400)) return ''; if (intval($this->event['event_end']/86400) != intval($this->event['event_start']/86400)) return '';
if (!$this->event['event_allday']) return ''; if (!$this->event['event_allday']) return '';
if (trim($parm) == '') return; if (trim($parm) == '') return;
return $this->e107->tp->parseTemplate('{'.$parm.'}'); return $this->e107->tp->parseTemplate('{'.$parm.'}', FALSE, $this);
} }
@ -845,7 +846,7 @@ class event_calendar_shortcodes
if ($this->event['event_allday']) $et += 2; if ($this->event['event_allday']) $et += 2;
if (is_array($this->eventDisplayCodes)) if (is_array($this->eventDisplayCodes))
{ {
return $this->e107->tp->parseTemplate($this->eventDisplayCodes[$et]); return $this->e107->tp->parseTemplate($this->eventDisplayCodes[$et], FALSE, $this);
} }
return '--** No template set **--'; return '--** No template set **--';
} }
@ -1063,42 +1064,42 @@ class event_calendar_shortcodes
{ {
if ($this->printVars['ot'] != 'print') return; if ($this->printVars['ot'] != 'print') return;
if (trim($parm) == '') return; if (trim($parm) == '') return;
return $this->e107->tp->parseTemplate('{'.$parm.'}'); return $this->e107->tp->parseTemplate('{'.$parm.'}', FALSE, $this);
} }
public function sc_ec_ifnot_print($parm = '') public function sc_ec_ifnot_print($parm = '')
{ {
if ($this->printVars['ot'] == 'print') return; if ($this->printVars['ot'] == 'print') return;
if (trim($parm) == '') return; if (trim($parm) == '') return;
return $this->e107->tp->parseTemplate('{'.$parm.'}'); return $this->e107->tp->parseTemplate('{'.$parm.'}', FALSE, $this);
} }
public function sc_ec_if_display($parm = '') public function sc_ec_if_display($parm = '')
{ {
if ($this->printVars['ot'] != 'display') return; if ($this->printVars['ot'] != 'display') return;
if (trim($parm) == '') return; if (trim($parm) == '') return;
return $this->e107->tp->parseTemplate('{'.$parm.'}'); return $this->e107->tp->parseTemplate('{'.$parm.'}', FALSE, $this);
} }
public function sc_ec_ifnot_display($parm = '') public function sc_ec_ifnot_display($parm = '')
{ {
if ($this->printVars['ot'] == 'display') return; if ($this->printVars['ot'] == 'display') return;
if (trim($parm) == '') return; if (trim($parm) == '') return;
return $this->e107->tp->parseTemplate('{'.$parm.'}'); return $this->e107->tp->parseTemplate('{'.$parm.'}', FALSE, $this);
} }
public function sc_ec_if_pdf($parm = '') public function sc_ec_if_pdf($parm = '')
{ {
if ($this->printVars['ot'] != 'pdf') return; if ($this->printVars['ot'] != 'pdf') return;
if (trim($parm) == '') return; if (trim($parm) == '') return;
return $this->e107->tp->parseTemplate('{'.$parm.'}'); return $this->e107->tp->parseTemplate('{'.$parm.'}', FALSE, $this);
} }
public function sc_ec_ifnot_pdf($parm = '') public function sc_ec_ifnot_pdf($parm = '')
{ {
if ($this->printVars['ot'] == 'pdf') return; if ($this->printVars['ot'] == 'pdf') return;
if (trim($parm) == '') return; if (trim($parm) == '') return;
return $this->e107->tp->parseTemplate('{'.$parm.'}'); return $this->e107->tp->parseTemplate('{'.$parm.'}', FALSE, $this);
} }
} // END - shortcode class } // END - shortcode class

View File

@ -145,20 +145,20 @@ $sc_style['EC_EVENT_THREAD']['post'] = "</span></td></tr>\n";
$sc_style['EC_EVENT_CATEGORY']['pre'] = "<b>".EC_LAN_30."</b> "; $sc_style['EC_EVENT_CATEGORY']['pre'] = "<b>".EC_LAN_30."</b> ";
$sc_style['EC_EVENT_CATEGORY']['post'] = "&nbsp;"; $sc_style['EC_EVENT_CATEGORY']['post'] = "&nbsp;";
$sc_style['EC_EVENT_DATE_START']['pre'] = ""; $sc_style['EC_EVENT_DATE_START']['pre'] = '';
$sc_style['EC_EVENT_DATE_START']['post'] = ""; $sc_style['EC_EVENT_DATE_START']['post'] = '';
$sc_style['EC_EVENT_TIME_START']['pre'] = ""; $sc_style['EC_EVENT_TIME_START']['pre'] = '';
$sc_style['EC_EVENT_TIME_START']['post'] = ""; $sc_style['EC_EVENT_TIME_START']['post'] = '';
$sc_style['EC_EVENT_DATE_END']['pre'] = ""; $sc_style['EC_EVENT_DATE_END']['pre'] = '';
$sc_style['EC_EVENT_DATE_END']['post'] = ""; $sc_style['EC_EVENT_DATE_END']['post'] = '';
$sc_style['EC_EVENT_TIME_END']['pre'] = ""; $sc_style['EC_EVENT_TIME_END']['pre'] = '';
$sc_style['EC_EVENT_TIME_END']['post'] = ""; $sc_style['EC_EVENT_TIME_END']['post'] = '';
$sc_style['EC_EVENT_EVENT_DATE_TIME']['pre'] = "<b>".EC_LAN_29."</b> "; $sc_style['EC_EVENT_EVENT_DATE_TIME']['pre'] = "<b>".EC_LAN_29."</b> ";
$sc_style['EC_EVENT_EVENT_DATE_TIME']['post'] = ""; $sc_style['EC_EVENT_EVENT_DATE_TIME']['post'] = '';
$sc_style['EC_IFNOT_ALLDAY']['pre'] = EC_LAN_144; $sc_style['EC_IFNOT_ALLDAY']['pre'] = EC_LAN_144;
$sc_style['EC_IFNOT_ALLDAY']['post'] = ""; $sc_style['EC_IFNOT_ALLDAY']['post'] = "";

View File

@ -62,8 +62,11 @@ global $ecal_class;
if (!is_object($ecal_class)) $ecal_class = new ecal_class; if (!is_object($ecal_class)) $ecal_class = new ecal_class;
$cal_super = $ecal_class->cal_super; $cal_super = $ecal_class->cal_super;
e107::getScParser();
//e107::getScParser();
require_once(e_PLUGIN.'calendar_menu/calendar_shortcodes.php'); require_once(e_PLUGIN.'calendar_menu/calendar_shortcodes.php');
$calSc = new event_calendar_shortcodes();
require_once(e_HANDLER.'calendar/calendar_class.php'); require_once(e_HANDLER.'calendar/calendar_class.php');
$cal = new DHTML_Calendar(true); $cal = new DHTML_Calendar(true);
@ -72,8 +75,6 @@ if ($cat_filter == -1) $cat_filter = '*';
$mult_count = 0; $mult_count = 0;
// $e_wysiwyg = $pref['eventpost_editmode'] == 2 ? 'ne_event' : '';
// Array links db field names to internal variables // Array links db field names to internal variables
$ev_fields = array( $ev_fields = array(
@ -759,7 +760,7 @@ if ($action == 'ne' || $action == 'ed')
} }
else else
{ {
header("location:".e_PLUGIN."calendar_menu/event.php"); header('location:'.e_PLUGIN.'calendar_menu/event.php');
exit; exit;
} }
} // End of "Enter New Event" } // End of "Enter New Event"
@ -771,17 +772,17 @@ if ($action == 'ne' || $action == 'ed')
//----------------------------------------------- //-----------------------------------------------
if (is_readable(THEME.'calendar_template.php')) if (is_readable(THEME.'calendar_template.php'))
{ // Has to be require { // Has to be require
require(THEME.'calendar_template.php'); require(THEME.'calendar_template.php');
} }
else else
{ {
require(e_PLUGIN.'calendar_menu/calendar_template.php'); require(e_PLUGIN.'calendar_menu/calendar_template.php');
} }
setScVar('event_calendar_shortcodes', 'ecalClass', &$ecal_class); // Give shortcodes a pointer to calendar class $calSc->ecalClass = &$ecal_class; // Give shortcodes a pointer to calendar class
callScFunc('event_calendar_shortcodes','setCalDate', $dateArray); // Tell shortcodes the date to display $calSc->setCalDate($dateArray); // Tell shortcodes the date to display
setScVar('event_calendar_shortcodes', 'catFilter', $cat_filter); // Category filter $calSc->catFilter = $cat_filter; // Category filter
setScVar('event_calendar_shortcodes', 'eventDisplayCodes', $EVENT_EVENT_DATETIME); // Templates for different event types $calSc->eventDisplayCodes = $EVENT_EVENT_DATETIME; // Templates for different event types
$monthstart = mktime(0, 0, 0, $month, 1, $year); $monthstart = mktime(0, 0, 0, $month, 1, $year);
$monthend = mktime(0, 0, 0, $month + 1, 1, $year) -1 ; $monthend = mktime(0, 0, 0, $month + 1, 1, $year) -1 ;
@ -792,10 +793,10 @@ $nowyear = $ecal_class->cal_date['year'];
$text2 = ""; $text2 = "";
// time switch buttons // time switch buttons
$text2 .= $e107->tp->parseTemplate($CALENDAR_TIME_TABLE, TRUE); $text2 .= $e107->tp->parseTemplate($CALENDAR_TIME_TABLE, FALSE, $calSc);
// navigation buttons // navigation buttons
$text2 .= $e107->tp->parseTemplate($CALENDAR_NAVIGATION_TABLE, TRUE); $text2 .= $e107->tp->parseTemplate($CALENDAR_NAVIGATION_TABLE, FALSE, $calSc);
// ****** CAUTION - the category dropdown also used $sql object - take care to avoid interference! // ****** CAUTION - the category dropdown also used $sql object - take care to avoid interference!
@ -830,10 +831,10 @@ if ($ds == 'event')
} }
} }
$next10_start = $thisEvent['event_start'] +1; $next10_start = $thisEvent['event_start'] +1;
setScVar('event_calendar_shortcodes', 'event', $thisEvent); // Give shortcodes the event data $calSc->event = $thisEvent; // Give shortcodes the event data
$text2 .= $e107->tp->parseTemplate($EVENT_EVENT_TABLE_START, TRUE); $text2 .= $e107->tp->parseTemplate($EVENT_EVENT_TABLE_START, FALSE, $calSc);
if ($ec_err) $text2.= "Software Error<br />"; else $text2 .= $e107->tp->parseTemplate($EVENT_EVENT_TABLE, TRUE); if ($ec_err) $text2.= "Software Error<br />"; else $text2 .= $e107->tp->parseTemplate($EVENT_EVENT_TABLE, FALSE, $calSc);
$text2 .= $e107->tp->parseTemplate($EVENT_EVENT_TABLE_END, TRUE); $text2 .= $e107->tp->parseTemplate($EVENT_EVENT_TABLE_END, FALSE, $calSc);
} }
else else
{ {
@ -881,16 +882,14 @@ else
// display event list for current month // display event list for current month
if(count($tim_arr)) if(count($tim_arr))
{ {
$text2 .= $e107->tp->parseTemplate($EVENT_EVENTLIST_TABLE_START, TRUE); $text2 .= $e107->tp->parseTemplate($EVENT_EVENTLIST_TABLE_START, FALSE, $calSc);
foreach ($tim_arr as $tim => $ptr) foreach ($tim_arr as $tim => $ptr)
{ {
$ev_list[$ptr]['event_start'] = $tim; $ev_list[$ptr]['event_start'] = $tim;
// $text2 .= show_event($ev_list[$ptr]); $calSc->event = $ev_list[$ptr]; // Give shortcodes the event data
//$thisevent = $ev_list[$ptr]; $text2 .= $e107->tp->parseTemplate($EVENT_EVENT_TABLE, FALSE, $calSc);
setScVar('event_calendar_shortcodes', 'event', $ev_list[$ptr]); // Give shortcodes the event data
$text2 .= $e107->tp->parseTemplate($EVENT_EVENT_TABLE, TRUE);
} }
$text2 .= $e107->tp->parseTemplate($EVENT_EVENTLIST_TABLE_END, TRUE); $text2 .= $e107->tp->parseTemplate($EVENT_EVENTLIST_TABLE_END, FALSE, $calSc);
} }
} }
@ -904,25 +903,25 @@ $ev_list = $ecal_class->get_n_events(10, $next10_start, $next10_start+86400000,
$num = count($ev_list); $num = count($ev_list);
if ($num != 0) if ($num != 0)
{ {
setScVar('event_calendar_shortcodes', 'numEvents', $num); // Give shortcodes the number of events to expect $calSc->numEvents = $num; // Give shortcodes the number of events to expect
$archive_events = ''; $archive_events = '';
foreach ($ev_list as $thisEvent) foreach ($ev_list as $thisEvent)
{ {
setScVar('event_calendar_shortcodes', 'event', $thisEvent); // Give shortcodes the event data $calSc->event = $thisEvent; // Give shortcodes the event data
$archive_events .= $e107->tp->parseTemplate($EVENT_ARCHIVE_TABLE, TRUE); $archive_events .= $e107->tp->parseTemplate($EVENT_ARCHIVE_TABLE, FALSE, $calSc);
} }
} }
else else
{ {
$archive_events = $e107->tp->parseTemplate($EVENT_ARCHIVE_TABLE_EMPTY, TRUE); $archive_events = $e107->tp->parseTemplate($EVENT_ARCHIVE_TABLE_EMPTY, FALSE, $calSc);
} }
$text2 .= $e107->tp->parseTemplate($EVENT_ARCHIVE_TABLE_START, TRUE); $text2 .= $e107->tp->parseTemplate($EVENT_ARCHIVE_TABLE_START, FALSE, $calSc);
$text2 .= $archive_events; $text2 .= $archive_events;
$text2 .= $e107->tp->parseTemplate($EVENT_ARCHIVE_TABLE_END, TRUE); $text2 .= $e107->tp->parseTemplate($EVENT_ARCHIVE_TABLE_END, FALSE, $calSc);
$e107->ns->tablerender($e107->tp->ParseTemplate('{EC_EVENT_PAGE_TITLE}'), $text2); $e107->ns->tablerender($e107->tp->ParseTemplate('{EC_EVENT_PAGE_TITLE}', FALSE, $calSc), $text2);
// Claim back memory no longer required // Claim back memory no longer required
unset($ev_list); unset($ev_list);

View File

@ -28,7 +28,7 @@ $e107 = e107::getInstance();
if (!$e107->isInstalled('calendar_menu')) return ''; if (!$e107->isInstalled('calendar_menu')) return '';
if (!isset($scal_class) || !is_object($ecal_class)) if (!isset($ecal_class) || !is_object($ecal_class))
{ {
require_once(e_PLUGIN.'calendar_menu/ecal_class.php'); require_once(e_PLUGIN.'calendar_menu/ecal_class.php');
$ecal_class = new ecal_class; $ecal_class = new ecal_class;
@ -45,8 +45,9 @@ if($cacheData = $e107->ecache->retrieve($cache_tag, $ecal_class->max_cache_time)
include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'.php'); include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'.php');
e107::getScParser();
require_once(e_PLUGIN.'calendar_menu/calendar_shortcodes.php'); require_once(e_PLUGIN.'calendar_menu/calendar_shortcodes.php');
$calSc = new event_calendar_shortcodes();
if (is_readable(THEME.'calendar_template.php')) if (is_readable(THEME.'calendar_template.php'))
{ // Has to be require { // Has to be require
require(THEME.'calendar_template.php'); require(THEME.'calendar_template.php');
@ -72,9 +73,7 @@ $end_time = $start_time + (86400 * $days_ahead) - 1;
$cal_text = ''; $cal_text = '';
setScVar('event_calendar_shortcodes', 'ecalClass', &$ecal_class); // Give shortcodes a pointer to calendar class $calSc->ecalClass = &$ecal_class; // Give shortcodes a pointer to calendar class
//callScFunc('event_calendar_shortcodes','setCalDate', $dateArray); // Tell shortcodes the date to display
//setScVar('event_calendar_shortcodes', 'catFilter', $cat_filter); // Category filter
$ev_list = $ecal_class->get_n_events($show_count, $start_time, $end_time, varset($pref['eventpost_fe_set'],FALSE), $show_recurring, $ev_list = $ecal_class->get_n_events($show_count, $start_time, $end_time, varset($pref['eventpost_fe_set'],FALSE), $show_recurring,
'event_id,event_start, event_thread, event_title, event_recurring, event_allday, event_category', 'event_cat_icon'); 'event_id,event_start, event_thread, event_title, event_recurring, event_allday, event_category', 'event_cat_icon');
@ -85,9 +84,9 @@ if ($cal_totev > 0)
foreach ($ev_list as $thisEvent) foreach ($ev_list as $thisEvent)
{ {
$cal_totev --; // Can use this to modify inter-event gap $cal_totev --; // Can use this to modify inter-event gap
setScVar('event_calendar_shortcodes', 'numEvents', $cal_totev); // Number of events to display $calSc->numEvents = $cal_totev; // Number of events to display
setScVar('event_calendar_shortcodes', 'event', $thisEvent); // Give shortcodes the event data $calSc->event = $thisEvent; // Give shortcodes the event data
$cal_text .= $e107->tp->parseTemplate($EVENT_CAL_FE_LINE,TRUE); $cal_text .= $e107->tp->parseTemplate($EVENT_CAL_FE_LINE,FALSE, $calSc);
} }
} }
else else

View File

@ -25,7 +25,12 @@
require_once('../../class2.php'); require_once('../../class2.php');
$e107 = e107::getInstance(); $e107 = e107::getInstance();
if (!$e107->isInstalled('calendar_menu')) header('Location: '.e_BASE.'index.php'); if (!$e107->isInstalled('calendar_menu'))
{
header('Location: '.e_BASE.'index.php');
exit();
}
include_lan(e_PLUGIN .'calendar_menu/languages/'.e_LANGUAGE.'.php'); include_lan(e_PLUGIN .'calendar_menu/languages/'.e_LANGUAGE.'.php');
global $pref; global $pref;
define('PAGE_NAME', EC_LAN_80); define('PAGE_NAME', EC_LAN_80);