| Server IP : 180.180.241.3 / Your IP : 216.73.216.35 Web Server : Microsoft-IIS/7.5 System : Windows NT NETWORK-NHRC 6.1 build 7601 (Windows Server 2008 R2 Standard Edition Service Pack 1) i586 User : IUSR ( 0) PHP Version : 5.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/AppServ/www/news/modules/mod_jevents_cal/tmpl/default/ |
Upload File : |
<?php
/**
* copyright (C) 2008 GWE Systems Ltd - All rights reserved
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die();
/**
* HTML View class for the component frontend
*
* @static
*/
class DefaultModCalView
{
var $_modid = null;
/* parameters form module or component */
var $displayLastMonth = null;
var $disp_lastMonthDays = null;
var $disp_lastMonth = null;
var $displayNextMonth = null;
var $disp_nextMonthDays = null;
var $disp_nextMonth = null;
var $linkCloaking = null;
/* component only parameter */
var $com_starday = null;
/* module only parameters */
var $inc_ec_css = null;
var $minical_showlink = null;
var $minical_prevyear = null;
var $minical_prevmonth = null;
var $minical_actmonth = null;
var $minical_actyear = null;
var $minical_nextmonth = null;
var $minical_nextyear = null;
/* class variables */
var $catidsOut = null;
var $modcatids = null;
var $catidList = "";
var $aid = null;
var $lang = null;
var $myItemid = 0;
var $cat = "";
/* modules parameter object */
var $modparams = null;
// data model for module
var $datamodel = null;
function DefaultModCalView($params, $modid){
$this->_modid = $modid;
global $mainframe;
$user =& JFactory::getUser();
$cfg = & JEVConfig::getInstance();
$jev_component_name = JEV_COM_COMPONENT;
$db =& JFactory::getDBO();
$this->datamodel =& new JEventsDataModel();
// component config object
$jevents_config = & JEVConfig::getInstance();
$this->modparams = & $params;
$this->aid = $user->aid;
$tmplang =& JFactory::getLanguage();
// get params exclusive to module
$this->inc_ec_css = $this->modparams->get('inc_ec_css', 1);
$this->minical_showlink = $this->modparams->get('minical_showlink', 1);;
$this->minical_prevyear = $this->modparams->get('minical_prevyear', 1);;
$this->minical_prevmonth = $this->modparams->get('minical_prevmonth', 1);;
$this->minical_actmonth = $this->modparams->get('minical_actmonth', 1);;
$this->minical_actmonth = $this->modparams->get('minical_actmonth', 1);;
$this->minical_actyear = $this->modparams->get('minical_actyear', 1);;
$this->minical_nextmonth = $this->modparams->get('minical_nextmonth', 1);;
$this->minical_nextyear = $this->modparams->get('minical_nextyear', 1);;
// get params exclusive to component
$this->com_starday = intval($jevents_config->get('com_starday',0));
// make config object (module or component) current
if (intval($this->modparams->get('modcal_useLocalParam', 0)) == 1) {
$myparam = & $this->modparams;
} else {
$myparam = & $jevents_config;
}
// get com_event config parameters for this module
$this->displayLastMonth = $myparam->get('modcal_DispLastMonth', 'NO');
$this->disp_lastMonthDays = $myparam->get('modcal_DispLastMonthDays', 0);
$this->linkCloaking = $myparam->get('modcal_LinkCloaking', 0);
$t_datenow = JEVHelper::getNow();
$this->timeWithOffset = $t_datenow->toUnix(true);
switch($this->displayLastMonth) {
case 'YES_stop':
$this->disp_lastMonth = 1;
break;
case 'YES_stop_events':
$this->disp_lastMonth = 2;
break;
case 'ALWAYS':
$this->disp_lastMonthDays = 0;
$this->disp_lastMonth = 1;
break;
case 'ALWAYS_events':
$this->disp_lastMonthDays = 0;
$this->disp_lastMonth = 2;
break;
case 'NO':
default:
$this->disp_lastMonthDays = 0;
$this->disp_lastMonth = 0;
break;
}
$this->displayNextMonth = $myparam->get('modcal_DispNextMonth', 'NO');
$this->disp_nextMonthDays = $myparam->get('modcal_DispNextMonthDays', 0);
switch($this->displayNextMonth) {
case 'YES_stop':
$this->disp_nextMonth = 1;
break;
case 'YES_stop_events':
$this->disp_nextMonth = 2;
break;
case 'ALWAYS':
$this->disp_nextMonthDays = 0;
$this->disp_nextMonth = 1;
break;
case 'ALWAYS_events':
$this->disp_nextMonthDays = 0;
$this->disp_nextMonth = 2;
break;
case 'NO':
default:
$this->disp_nextMonthDays = 0;
$this->disp_nextMonth = 0;
break;
}
// find appropriate Itemid and setup catids for datamodel
$this->myItemid = $this->datamodel->setupModuleCatids($this->modparams);
$this->cat = $this->datamodel->getCatidsOutLink(true);
$this->linkpref = 'index.php?option='.$jev_component_name.'&Itemid='.$this->myItemid.$this->cat.'&task=';
}
function getTheme(){
$theme = JEV_CommonFunctions::getJEventsViewName();
return $theme;
}
/**
* Cloaks html link whith javascript
*
* @param string The cloaking URL
* @param string The link text
* @return string HTML
*/
protected function htmlLinkCloaking($url='', $text='', $attribs=array()) {
$link = JRoute::_($url);
if ($this->linkCloaking) {
$attribs['onclick'] = 'window.location.href=\''. $link . '\';return false;';
$href = '"#"';
} else {
$href = '"' . $link . '"';
}
$attrstr = '';
foreach ($attribs as $key => $value) {
$attrstr .= ' '.$key.' = "'.$value.'"';
}
return '<a href=' . $href . $attrstr . '>' . $text . '</a>';
}
function _navigationJS($modid){
static $included = false;
if ($included) return;
$included = true;
?>
<script language="javascript" type="text/javascript" ><!--
function navLoaded(elem, modid){
myspan = document.getElementById("testspan"+modid);
modbody = myspan.parentNode;
modbody.innerHTML=elem.innerHTML;
}
function callNavigation(link){
body = document.getElementsByTagName('body')[0];
if (!document.getElementById('calnav')){
iframe = document.createElement('iframe');
iframe.setAttribute("name","calnav");
iframe.setAttribute("id","calnav");
iframe.style.display = "none";
}
body.appendChild(iframe);
iframe.setAttribute("src",link);
}
//--></script>
<?php }
function monthYearNavigation($cal_today,$adj,$symbol, $label,$action="month.calendar"){
$cfg = & JEVConfig::getInstance();
$jev_component_name = JEV_COM_COMPONENT;
$adjDate = strtotime($adj,$cal_today);
list($year,$month) = explode(":",strftime("%Y:%m",$adjDate));
$link = JRoute::_($this->linkpref.$action."&day=1&month=$month&year=$year".$this->cat);
$content ="";
if (isset($this->_modid) && $this->_modid>0){
$this->_navigationJS($this->_modid);
$link = htmlentities("index.php?option=$jev_component_name&task=modcal.ajax&day=1&month=$month&year=$year&modid=$this->_modid&tmpl=component".$this->cat);
$content = '<td>';
$content .= '<div class="mod_events_link" onmousedown="callNavigation(\''.$link.'\');">'.$symbol."</div>\n";
$content .= '</td>';
}
return $content;
}
function _displayCalendarMod($time, $startday, $linkString, $day_name, $monthMustHaveEvent=false){
$db =& JFactory::getDBO();
$cfg = & JEVConfig::getInstance();
$option = JEV_COM_COMPONENT;
$cal_year=date("Y",$time);
$cal_month=date("m",$time);
// do not use $cal_day since it's not reliable due to month offset calculation
//$cal_day=date("d",$time);
$data = $this->datamodel->getCalendarData($cal_year,$cal_month,1,true);
$month_name = JEVHelper::getMonthName($cal_month);
$first_of_month = mktime(0,0,0,$cal_month, 1, $cal_year);
//$today = mktime(0,0,0,$cal_month, $cal_day, $cal_year);
$today = strtotime(date('Y-m-d', $this->timeWithOffset));
$content = '<div style="margin:0px;padding:0px;border-width:0px;">';
$mod ="";
if (isset($this->_modid) && $this->_modid>0){
$mod = 'id="modid_'.$this->_modid.'" ';
$content .= "<span id='testspan".$this->_modid."' style='display:none'></span>\n";
}
if( $this->minical_showlink ){
$content .= "\n".'<table cellpadding="0" cellspacing="0" align="center" class="mod_events_monthyear" >' . "\n"
. '<tr >' . "\n";
if( $this->minical_showlink == 1 ){
if( $this->minical_prevyear ){
$content .= $this->monthYearNavigation($first_of_month,"-1 year",'«',JText::_('JEV_CLICK_TOSWITCH_PY'));
}
if( $this->minical_prevmonth ){
$content .= $this->monthYearNavigation($first_of_month,"-1 month",'<',JText::_('JEV_CLICK_TOSWITCH_PM'));
}
if( $this->minical_actmonth == 1 ){
// combination of actual month and year: view month
$seflinkActMonth = JRoute::_( $this->linkpref.'month.calendar&month='.$cal_month.'&year='.$cal_year);
$content .= '<td align="center">';
$content .= $this->htmlLinkCloaking($seflinkActMonth, $month_name, array('class'=>"mod_events_link",'title'=> JText::_('JEV_CLICK_TOSWITCH_MON')))." ";
if( $this->minical_actyear < 1 ) $content .= '</td>';
}elseif( $this->minical_actmonth == 2 ){
$content .= '<td align="center">';
$content .= $month_name . "\n";
if( $this->minical_actyear < 1 ) $content .= '</td>';
}
if( $this->minical_actyear == 1 ){
// combination of actual month and year: view year
$seflinkActYear = JRoute::_( $this->linkpref . 'year.listevents' . '&month=' . $cal_month
. '&year=' . $cal_year );
if( $this->minical_actmonth < 1 )$content .= '<td align="center">';
$content .= $this->htmlLinkCloaking($seflinkActYear, $cal_year, array('class'=>"mod_events_link",'title'=> JText::_('JEV_CLICK_TOSWITCH_YEAR')))." ";
$content .= '</td>';
}elseif( $this->minical_actyear == 2 ){
if( $this->minical_actmonth < 1 ) $content .= '<td align="center">';
$content .= $cal_year . "\n";
$content .= '</td>';
}
if( $this->minical_nextmonth ){
$content .= $this->monthYearNavigation($first_of_month,"+1 month",'>',JText::_('JEV_CLICK_TOSWITCH_NM'));
}
if( $this->minical_nextyear ){
$content .= $this->monthYearNavigation($first_of_month,"+1 year",'»',JText::_('JEV_CLICK_TOSWITCH_NY'));
}
// combination of actual month and year: view year & month [ mic: not used here ]
// $seflinkActYM = JRoute::_( $link . 'month.calendar' . '&month=' . $cal_month
// . '&year=' . $cal_year );
}else{
// show only text
$content .= '<td>';
$content .= $month_name . ' ' . $cal_year;
$content .= '</td>';
}
$content .= "</tr>\n"
. "</table>\n";
}
$lf = "\n";
$content .= '<table align="center" class="mod_events_table" cellspacing="0" cellpadding="2" >'.$lf
. '<tr class="mod_events_dayname">'.$lf;
// Days name rows
for ($i=0;$i<7;$i++) {
$content.="<td class=\"mod_events_td_dayname\">".$day_name[($i+$startday)%7]."</td>".$lf ;
}
$content.='</tr>'.$lf;
$datacount = count($data["dates"]);
$dn=0;
for ($w=0;$w<6 && $dn<$datacount;$w++){
$content .="<tr>\n";
/*
echo "<td width='2%' class='cal_td_weeklink'>";
list($week,$link) = each($data['weeks']);
echo "<a href='".$link."'>$week</a></td>\n";
*/
for ($d=0;$d<7 && $dn<$datacount;$d++){
$currentDay = $data["dates"][$dn];
switch ($currentDay["monthType"]){
case "prior":
case "following":
$content .= '<td class="mod_events_td_dayoutofmonth">'.$currentDay["d"]."</td>\n";
break;
case "current":
if ($currentDay["events"]){
$class = ($currentDay["cellDate"] == $today) ? "mod_events_td_todaywithevents" : "mod_events_td_daywithevents";
}
else {
$class = ($currentDay["cellDate"] == $today) ? "mod_events_td_todaynoevents" : "mod_events_td_daynoevents";
}
$content .= "<td class='".$class."'>\n";
$content .= $this->htmlLinkCloaking($currentDay["link"], $currentDay['d'], array('class'=>"mod_events_daylink",'title'=> JText::_('JEV_CLICK_TOSWITCH_DAY')));
$content .="</td>\n";
break;
}
$dn++;
}
$content .= "</tr>\n";
}
$content .= '</table>'.$lf;
$content .= '</div>'.$lf;
return $content;
}
function getCal($modid=0) {
// capture module id so that we can use it for ajax type navigation
if ($modid!=0) {
$this->_modid=$modid;
}
global $mainframe;
$user =& JFactory::getUser();
$db =& JFactory::getDBO();
// this will get the viewname based on which classes have been implemented
$viewname = $this->getTheme();
$cfg = & JEVConfig::getInstance();
$compname = JEV_COM_COMPONENT;
$viewpath = "components/".JEV_COM_COMPONENT."/views/".$viewname."/assets/css/";
// get array
$day_name = JEVHelper::getWeekdayLetter(null, 1);
$day_name[0] = '<span class="sunday">' . $day_name[0] . '</span>';
$day_name[6] = '<span class="saturday">' . $day_name[6] . '</span>';
$content="";
if ($this->inc_ec_css){
JHTML::stylesheet( "modstyle.css", $viewpath);
}
$thisDayOfMonth = date("j", $this->timeWithOffset);
$daysLeftInMonth = date("t", $this->timeWithOffset) - date("j", $this->timeWithOffset) + 1;
// calculate month offset from first of month
$first_of_current_month = strtotime(date('Y-m-01',$this->timeWithOffset));
if($this->disp_lastMonth && (!$this->disp_lastMonthDays || $thisDayOfMonth <= $this->disp_lastMonthDays))
$content .= $this->_displayCalendarMod(strtotime("-1 month", $first_of_current_month),
$this->com_starday, JText::_('JEV_LAST_MONTH'), $day_name, $this->disp_lastMonth == 2);
$content .= $this->_displayCalendarMod($this->timeWithOffset,
$this->com_starday, JText::_('JEV_THIS_MONTH'),$day_name, false);
if($this->disp_nextMonth && (!$this->disp_nextMonthDays || $daysLeftInMonth <= $this->disp_nextMonthDays))
$content .= $this->_displayCalendarMod(strtotime("+1 month", $first_of_current_month),
$this->com_starday, JText::_('JEV_NEXT_MONTH'),$day_name, $this->disp_nextMonth == 2);
return $content;
} // function getCal
function getAjaxCal($modid=0, $month, $year){
// capture module id so that we can use it for ajax type navigation
if ($modid!=0) {
$this->_modid=$modid;
}
global $mainframe;
$user =& JFactory::getUser();
$db =& JFactory::getDBO();
static $isloaded_css = false;
// this will get the viewname based on which classes have been implemented
$cfg = & JEVConfig::getInstance();
$viewname = ucfirst($cfg->get('com_calViewName',"default"));
$cfg = & JEVConfig::getInstance();
// get array
$day_name = JEVHelper::getWeekdayLetter(null, 1);
$day_name[0] = '<span class="sunday">' . $day_name[0] . '</span>';
$day_name[6] = '<span class="saturday">' . $day_name[6] . '</span>';
$content="";
$temptime = mktime(12,0,0,$month,15,$year);
$content .= $this->_displayCalendarMod($temptime,$this->com_starday, JText::_('JEV_THIS_MONTH'),$day_name, false);
return $content;
} // function getSpecificCal
}