e107 = e107::getInstance();
}
/**
* Set the current date for calendar display
*
* Routine then calculates various values needed for shortcodes
*
* @param array $curDate - As returned by getdate()
*
* @return BOOLEAN TRUE
*/
public function setCalDate($curDate)
{
$this->ds = varset($curDate['ds'],'');
$this->day = varset($curDate['mday'], 0); // Day number being shown - rarely relevant
$this->month = $curDate['mon']; // Number of month being shown
$this->year = $curDate['year']; // Number of year being shown
$this->monthStart = gmmktime(0, 0, 0, $curDate['mon'], 1, $curDate['year']); // Start of month to be shown
$this->monthEnd = gmmktime(0, 0, 0, $curDate['mon'] + 1, 1, $curDate['year']) - 1; // End of month to be shown
// Calculate date code for previous month
$this->prevMonth = $curDate['mon']-1;
$prevYear = $curDate['year'];
if ($this->prevMonth == 0)
{
$this->prevMonth = 12;
$prevYear--;
}
$this->previous = gmmktime(0, 0, 0, $this->prevMonth, 1, $prevYear); // Previous month - Used by nav
// Calculate date code for next month
$this->nextMonth = $curDate['mon'] + 1;
$nextYear = $curDate['year'];
if ($this->nextMonth == 13)
{
$this->nextMonth = 1;
$nextYear++;
}
$this->next = gmmktime(0, 0, 0, $this->nextMonth, 1, $nextYear); // Next month - used by nav
$this->py = $curDate['year']-1; // Number of previous year for nav
$this->prevLink = gmmktime(0, 0, 0, $curDate['mon'], 1, $this->py);
$this->ny = $curDate['year'] + 1; // Number of next year for nav
$this->nextLink = gmmktime(0, 0, 0, $curDate['mon'], 1, $this->ny);
$this->prop = gmmktime(0, 0, 0, $curDate['mon'], $curDate['mday'], $curDate['year']); // Sets start date for new event entry
$this->nowMonth = $this->ecalClass->cal_date['mon'];
$this->nowYear = $this->ecalClass->cal_date['year'];
$this->nowDay = $this->ecalClass->cal_date['mday'];
return TRUE;
}
// Navigation shortcodes
public function sc_ec_prev_month($parm = '')
{
return "<< ".$this->months[($this->prevMonth-1)]."";
}
public function sc_ec_next_month($parm = '')
{
return " ".$this->months[($this->nextMonth-1)]." >>";
}
public function sc_ec_current_month($parm = '')
{
if($this->ecalClass->pref['eventpost_dateformat'] == 'my')
{
return $this->months[($this->month-1)].' '.$this->year;
}
return $this->year.' '.$this->months[($this->month-1)];
}
public function sc_ec_prev_year($parm = '')
{
return "<< ".$this->py."";
}
public function sc_ec_next_year($parm = '')
{
return "".$this->ny." >>";
}
public function sc_ec_month_list($parm = '')
{
$ret = '';
for ($ii = 0; $ii < 12; $ii++)
{
$monthJump = gmmktime(0, 0, 0, $ii+1, 1, $this->year);
$ret .= "".$this->monthabb[$ii]." ";
}
return $ret;
}
// Navigation buttons
public function sc_ec_nav_but_allevents($parm = '')
{
$allevents = (e_PAGE == "event.php" ? EC_LAN_96 : EC_LAN_93);
return "";
}
public function sc_ec_nav_but_viewcat($parm = '')
{
return "";
}
public function sc_ec_nav_but_subscription($parm = '')
{
if (isset($this->ecalClass->pref['eventpost_asubs']) && ($this->ecalClass->pref['eventpost_asubs']>0) && USER)
{
return "";
}
return '';
}
public function sc_ec_nav_but_enterevent($parm = '')
{
$ret = "";
if ($this->ecalClass->cal_super || check_class($this->ecalClass->pref['eventpost_admin']))
{
$ret .= "";
}
return $ret;
}
public function sc_ec_nav_linkcurrentmonth($parm = '')
{
$ret = '';
if ($this->month != $this->nowMonth || $this->year != $this->nowYear || $this->ds == 'one')
{ // Just jump to current page without a query part - that will default to today
$ret = "";
}
return $ret;
}
public function sc_ec_nav_but_printlists($parm = '')
{
if (isset($this->ecalClass->pref['eventpost_printlists']) && ($this->ecalClass->pref['eventpost_printlists']>0) && USER)
{
return "";
}
else
{
return '';
return 'Cant print lists';
}
}
// Categories listing
public function sc_ec_nav_categories($parm = '')
{
if ($this->ourDB == NULL)
{
$this->ourDB = new db; // @todo use new method
}
($parm == 'nosubmit') ? $insert = '' : $insert = "onchange='this.form.submit()'";
$ret = "\n";
return $ret;
}
// Event information shortcodes
//-----------------------------
public function sc_ec_event_location($parm = '')
{
return $this->event['event_location'];
}
public function sc_ec_event_recent_icon()
{
return $this->sc_ec_calendar_calendar_recent_icon();
}
public function sc_ec_if_allday($parm= '')
{
if (!$this->event['event_allday']) return '';
if (trim($parm) == '') return '';
return e107::getParser()->parseTemplate('{'.$parm.'}', FALSE, $this);
}
public function sc_ec_ifnot_allday($parm= '')
{
if ($this->event['event_allday']) return '';
if (trim($parm) == '') return '';
return e107::getParser()->parseTemplate('{'.$parm.'}', FALSE, $this);
}
public function sc_ec_ifnot_sameday($parm= '')
{
if (intval($this->event['event_end']/86400) == intval($this->event['event_start']/86400)) return '';
if (!$this->event['event_allday']) return '';
if (trim($parm) == '') return;
return e107::getParser()->parseTemplate('{'.$parm.'}', FALSE, $this);
}
public function sc_ec_if_sameday($parm= '')
{
if (intval($this->event['event_end']/86400) != intval($this->event['event_start']/86400)) return '';
if (!$this->event['event_allday']) return '';
if (trim($parm) == '') return;
return e107::getParser()->parseTemplate('{'.$parm.'}', FALSE, $this);
}
// Event mailout shortcodes
//--------------------------
public function sc_ec_mail_heading_date($parm)
{
if (isset($parm) && ($parm !== ""))
{
return strftime($parm,$this->event['event_start']);
}
else
{
return $this->ecalClass->event_date_string($this->event['event_start']);
}
}
public function sc_ec_mail_date_start($parm)
{
return $this->sc_ec_mail_heading_date($parm);
}
public function sc_ec_mail_date_start_allday($parm)
{
if ($this->event['event_allday'] != 1) return '';
return $this->sc_ec_mail_heading_date($parm);
}
public function sc_ec_mail_date_start_timed($parm)
{
if ($this->event['event_allday'] == 1) return '';
return $this->sc_ec_mail_heading_date($parm);
}
public function sc_ec_mail_time_start($parm)
{
if ($this->event['event_allday'] == 1) return '';
return $this->ecalClass->time_string($this->event['event_start']);
}
public function sc_ec_mail_date_end($parm = '')
{
if ($this->event['event_allday'] ||($this->event['event_end'] == $this->event['event_start'])) return '';
if ($parm !== '')
{
return strftime($parm,$this->event['event_end']);
}
return $this->ecalClass->event_date_string($this->event['event_end']);
}
public function sc_ec_mail_time_end($parm = '')
{
if ($this->event['event_allday'] ||($this->event['event_end'] == $this->event['event_start'])) return '';
$endds = $ecal_class->time_string($this->event['event_end']);
return $endds;
}
public function sc_ec_mail_title($parm = '')
{
return $this->event['event_title'];
}
public function sc_ec_mail_id($parm = '')
{
return 'calevent'.$this->event['event_id'];
}
public function sc_ec_mail_details($parm = '')
{
return e107::getParser()->toHTML($this->event['event_details'], TRUE,'E_BODY');
}
public function sc_ec_mail_category($parm = '')
{
return $this->event['event_cat_name'];
}
public function sc_ec_mail_contact($parm = '')
{
if ($this->event['event_contact'] == '') return '';
return e107::getParser()->toHTML($this->event['event_contact'],TRUE,'LINKTEXT');
}
public function sc_ec_mail_thread($parm = '')
{
return $this->event['event_thread'];
}
public function sc_ec_mail_link($parm = '')
{
$cal_dayarray = getdate($this->event['event_start']);
$cal_linkut = gmmktime(0 , 0 , 0 , $cal_dayarray['mon'], $cal_dayarray['mday'], $cal_dayarray['year']).".one"; // ALways need "one"
return ' '.SITEURLBASE.e_PLUGIN_ABS.'calendar_menu/event.php?'.$cal_linkut.' ';
}
public function sc_ec_mail_short_date($parm = '')
{
return $this->ecalClass->next_date_string($this->event['event_start']);
}
// Codes can be used to return a LAN to help with multi-language
public function sc_ec_mail_subject($parm = '')
{
return EC_MAILOUT_SUBJECT;
}
//------------------------------------------
// CALENDAR CALENDAR - 'Big' calendar
//------------------------------------------
public function sc_ec_calendar_calendar_header_day($parm = '')
{
if(isset($this->ecalClass->pref['eventpost_lenday']) && $this->ecalClass->pref['eventpost_lenday'])
{
return "".e107::getParser()->text_truncate($this->headerDay,$this->ecalClass->pref['eventpost_lenday'],'')."";
}
else
{
return "".$this->headerDay."";
}
}
public function sc_ec_calendar_calendar_day_today_heading()
{
return "".$this->days[($this->curDay-1)]."[".EC_LAN_TODAY."]";
}
public function sc_ec_calendar_calendar_day_event_heading()
{
return "".$this->days[($this->curDay-1)]."";
}
public function sc_ec_calendar_calendar_day_empty_heading()
{
return "".$this->days[($this->curDay-1)]."";
}
public function sc_ec_calendar_calendar_recent_icon()
{
if (!isset($this->event['is_recent'])) return '';
if (!$this->event['startofevent']) return ''; // Only display on first day of multi-day events
if (is_readable(EC_RECENT_ICON))
{
return " ";
}
return "R";
}
public function sc_ec_event_page_title()
{
switch ($this->ds)
{
case 'one' : return EC_LAN_80.': '.$this->day.' '.$this->months[$this->month-1];
// case 'event' : return EC_LAN_122.': '.$this->day.' '.$this->months[$this->month-1];
case 'event' : return EC_LAN_122;
default : return EC_LAN_80;
}
}
public function sc_ec_showevent_image()
{
//TODO review bullet
$img = '';
if($this->event['event_cat_icon'] && file_exists(e_PLUGIN.'calendar_menu/images/'.$this->event['event_cat_icon']))
{
$img = "event['event_cat_icon']."' alt='' height='".$this->event['imagesize']."' width='".$this->event['imagesize']."' />";
}
elseif(defined('BULLET'))
{
$img = '';
}
elseif(file_exists(THEME.'images/bullet2.gif'))
{
$img = '';
}
return $img;
}
public function sc_ec_showevent_indicat()
{
return $this->event['indicat'];
}
public function sc_ec_showevent_heading()
{
$linkut = mktime(0 , 0 , 0 , $this->month, $this->curDay, $this->year);
$show_title = e107::getParser()->toHTML($this->event['event_title'],FALSE,'TITLE'); // Remove entities in case need to truncate
if(isset($this->event['fulltopic']) && !$this->event['fulltopic'])
{
$show_title = e107::getParser()->text_truncate($show_title, 10, '...');
}
if($this->event['startofevent'])
{
$eTitle = $this->event['event_title'];
if ($this->event['event_allday'] == 0)
{
$eTitle .= ' ('.$this->ecalClass->time_string($this->event['event_start']).')';
}
return "event['event_id']."'>".$show_title."";
}
else
{
return "event['event_id']."'>".$show_title."";
}
}
public function sc_ec_eventlist_caption()
{
$ret = '';
if ($this->ds == 'one')
{
$ret = EC_LAN_111.$this->months[$this->month-1].' '.$this->day;
}
elseif ($this->ds != 'event')
{
$ret = EC_LAN_112.$this->months[$this->month-1];
}
return $ret;
}
//---------------------------------------------------
// EVENT SHOWEVENT (Detail of individual events)
//---------------------------------------------------
public function sc_ec_event_heading_date()
{
return $this->ecalClass->event_date_string($this->event['event_start']);
}
// Same code as previous
public function sc_ec_event_date_start()
{
return $this->ecalClass->event_date_string($this->event['event_start']);
}
public function sc_ec_event_time_start()
{
if ($this->event['event_allday'] == 1) return '';
return $this->ecalClass->time_string($this->event['event_start']);
}
public function sc_ec_event_date_end()
{
if ($this->event['event_end'] == $this->event['event_start']) return '';
return $this->ecalClass->event_date_string($this->event['event_end']);
}
public function sc_ec_event_time_end()
{
if ($this->event['event_allday'] ||($this->event['event_end'] == $this->event['event_start'])) return '';
return $this->ecalClass->time_string($this->event['event_end']);
}
public function sc_ec_event_title()
{
return $this->event['event_title'];
}
public function sc_ec_event_cat_icon()
{
if ($this->event['event_cat_icon'] && is_readable(e_PLUGIN.'calendar_menu/images/'.$this->event['event_cat_icon']))
{
return " ";
}
return '';
}
public function sc_ec_event_id()
{
return 'calevent'.$this->event['event_id'];
}
public function sc_ec_event_displaystyle()
{ // Returns initial state of expandable blocks
if (($this->ds=='event') || ($this->ds=='one'))
{
return ''; // Let block display
}
return 'display: none; ';
}
/**
* Display class for event display block - to manage expansion/contraction
* When displaying a single event, or a single day's events, block to be expanded
* For event lists, block to be contracted
*
* @param int $param - optional supplementary list of classes to apply
*
* @return string -
*/
public function sc_ec_event_displayclass($parm='')
{
if (($this->ds=='event') || ($this->ds=='one'))
{ // Single event or one day's events - block expanded
return " class='{$parm}'";
}
return " class='e-show-if-js e-hideme {$parm}'"; // Block contracted
// return " class='e-hide-if-js e-showme {$parm}'"; // Block contracted
}
public function sc_ec_event_details()
{
return e107::getParser()->toHTML($this->event['event_details'], TRUE, 'BODY');
}
public function sc_ec_event_category()
{
return $this->event['event_cat_name'];
}
public function sc_ec_event_author()
{
$lp = explode(".", $this->event['event_author'],2); // Split into userid.username
if (preg_match("/[0-9]+/", $lp[0]))
{
$event_author_id = $lp[0];
$event_author_name = $lp[1];
}
if(USER)
{
return "".$event_author_name."";
}
return $event_author_name;
}
public function sc_ec_event_contact()
{
if ($this->event['event_contact'] == '') return '';
$tm = $this->event['event_contact'];
if (strpos($tm,'[') === FALSE)
{ // Add a bbcode if none exists
$tm = '[link=mailto:'.trim($tm).']'.substr($tm,0,strpos($tm,'@')).'[/link]';
}
return e107::getParser()->toHTML($tm,TRUE,'LINKTEXT'); // Return obfuscated email link
}
public function sc_ec_event_thread()
{
if (isset($this->event['event_thread']) && ($this->event['event_thread'] != ''))
{
return "".EC_LAN_39."";
}
return '';
}
public function sc_ec_event_options()
{
$event_author_name = strstr(varset($this->event['event_author'],'0.??'),'.');
if (USERNAME == $event_author_name || $this->ecalClass->cal_super || check_class($this->ecalClass->pref['eventpost_admin']))
{
return "event['event_id']."'>";
}
}
public function sc_ec_ec_event_link()
{
$cal_dayarray = getdate($this->event['event_start']);
$cal_linkut = mktime(0 , 0 , 0 , $cal_dayarray['mon'], $cal_dayarray['mday'], $cal_dayarray['year']).'.one'; // ALways need "one"
return ' '.e_PLUGIN_ABS.'calendar_menu/event.php?'.$cal_linkut.' ';
}
public function sc_ec_event_event_date_time()
{
$et = 0;
if (intval($this->event['event_end']/86400) == intval($this->event['event_start']/86400)) $et += 1;
if ($this->event['event_allday']) $et += 2;
if (is_array($this->eventDisplayCodes))
{
return e107::getParser()->parseTemplate($this->eventDisplayCodes[$et], FALSE, $this);
}
return '--** No template set **--';
}
public function sc_ec_event_short_date()
{
return $this->ecalClass->next_date_string($this->event['event_start']);
}
//------------------------------------------
// EVENT ARCHIVE (list of next events at bottom of event list)
//------------------------------------------
public function sc_ec_eventarchive_caption()
{
if ($this->numEvents == 0)
{
return EC_LAN_137;
}
return str_replace('-NUM-', $this->numEvents, EC_LAN_62);
}
public function sc_ec_eventarchive_date()
{
$startds = $this->ecalClass->event_date_string($this->event['event_start']);
return "event['event_id']."'>".$startds."";
}
public function sc_ec_eventarchive_details()
{
$number = 40;
$rowtext = e107::getParser()->toHTML($this->event['event_details'], TRUE, 'BODY');
$rowtext = strip_tags($rowtext);
$words = explode(' ', $rowtext);
$ret = implode(' ', array_slice($words, 0, $number));
if(count($words) > $number)
{
$ret .= ' '.EC_LAN_133.' ';
}
return $ret;
}
public function sc_ec_eventarchive_empty()
{
return EC_LAN_37;
}
public function sc_ec_eventarchive_heading()
{
return $this->event['event_title'];
}
// FORTHCOMING EVENTS MENU
//---------------------------
function sc_ec_next_event_recent_icon()
{
if (!$this->ecalClass->pref['eventpost_fe_showrecent']) return;
if (!isset($this->event['is_recent'])) return;
if (is_readable(EC_RECENT_ICON))
{
return " ";
}
return '';
}
public function sc_ec_next_event_time()
{
if ($this->event['event_allday'] != 1)
{
return $this->ecalClass->time_string($this->event['event_start']);
}
return '';
}
public function sc_ec_next_event_date()
{
return $this->ecalClass->next_date_string($this->event['event_start']);
}
public function sc_ec_next_event_title()
{
if (isset($this->ecalClass->pref['eventpost_namelink']) && ($this->ecalClass->pref['eventpost_namelink'] == '2') && (isset($this->event['event_thread']) && ($this->event['event_thread'] != '')))
{
$fe_event_title = "";
}
else
{
$fe_event_title = "event['event_id']."'>";
}
$fe_event_title .= $this->event['event_title']."";
return $fe_event_title;
}
public function sc_ec_next_event_icon()
{
$fe_icon_file = '';
if ($this->ecalClass->pref['eventpost_showcaticon'] == 1)
{
if($this->event['event_cat_icon'] && is_readable(e_PLUGIN.'calendar_menu/images/'.$this->event['event_cat_icon']))
{
$fe_icon_file = e_PLUGIN_ABS.'calendar_menu/images/'.$this->event['event_cat_icon'];
}
elseif(defined('BULLET'))
{
$fe_icon_file = THEME_ABS.'images/'.BULLET;
}
elseif(file_exists(THEME.'images/bullet2.gif'))
{
$fe_icon_file = THEME_ABS.'images/bullet2.gif';
}
}
return $fe_icon_file;
}
public function sc_ec_next_event_gap()
{
if ($this->numEvents) return '
'; // Return a newline as a gap on all but last item
return '';
}
// Specific to the 'listings' page
//--------------------------------
public function sc_ec_pr_list_title()
{
return $this->printVars['lt'];
}
public function sc_ec_pr_cat_list()
{
if (is_array($this->printVars['cat']))
{
return implode(', ',$this->printVars['cat']);
}
return $this->printVars['cat'];
}
public function sc_ec_pr_change_year()
{
if (!$this->changeFlags['yc']) return '';
$thisevent_start_date = $this->ecalClass->gmgetdate($this->event['event_start']);
return $thisevent_start_date['year'];
}
public function sc_ec_pr_change_month()
{
if (!$this->changeFlags['mc']) return '';
$thisevent_start_date = $this->ecalClass->gmgetdate($this->event['event_start']);
return $thisevent_start_date['month'];
}
public function sc_ec_pr_list_start($parm = '')
{
if ($parm)
{
return $this->ecalClass->event_date_string($this->printVars['sd']);
}
return strftime($parm,$this->printVars['sd']);
}
public function sc_ec_pr_list_end($parm = '')
{
if ($parm)
{
return $this->ecalClass->event_date_string($this->printVars['ed']);
}
return strftime($parm,$this->printVars['ed']);
}
public function sc_ec_now_date($parm = '')
{
if ($parm == '') return $this->ecalClass->event_date_string(time());
return strftime($parm,time());
}
public function sc_ec_now_time($parm = '')
{
if ($parm == '') return $this->ecalClass->time_string(time());
return strftime($parm,time());
}
public function sc_ec_print_button()
{
if ($this->printVars['ot'] != 'print') return;
return "";
}
public function sc_ec_if_print($parm = '')
{
if ($this->printVars['ot'] != 'print') return;
if (trim($parm) == '') return;
return e107::getParser()->parseTemplate('{'.$parm.'}', FALSE, $this);
}
public function sc_ec_ifnot_print($parm = '')
{
if ($this->printVars['ot'] == 'print') return;
if (trim($parm) == '') return;
return e107::getParser()->parseTemplate('{'.$parm.'}', FALSE, $this);
}
public function sc_ec_if_display($parm = '')
{
if ($this->printVars['ot'] != 'display') return;
if (trim($parm) == '') return;
return e107::getParser()->parseTemplate('{'.$parm.'}', FALSE, $this);
}
public function sc_ec_ifnot_display($parm = '')
{
if ($this->printVars['ot'] == 'display') return;
if (trim($parm) == '') return;
return e107::getParser()->parseTemplate('{'.$parm.'}', FALSE, $this);
}
public function sc_ec_if_pdf($parm = '')
{
if ($this->printVars['ot'] != 'pdf') return;
if (trim($parm) == '') return;
return e107::getParser()->parseTemplate('{'.$parm.'}', FALSE, $this);
}
public function sc_ec_ifnot_pdf($parm = '')
{
if ($this->printVars['ot'] == 'pdf') return;
if (trim($parm) == '') return;
return e107::getParser()->parseTemplate('{'.$parm.'}', FALSE, $this);
}
} // END - shortcode class
?>