コード例 #1
0
 function eventOnDate($testDate, $multidayTreatment = 0)
 {
     if (!isset($this->_startday)) {
         $this->_startday = JevDate::mktime(0, 0, 0, $this->mup(), $this->dup(), $this->yup());
         $this->_endday = JevDate::mktime(0, 0, 0, $this->mdn(), $this->ddn(), $this->ydn());
         // if ends on midnight then testing day should ignore the second day since no one wants this event to show
         if ($this->hdn() + $this->mindn() + $this->sdn() == 0 && $this->_startday != $this->_endday) {
             $this->_endday -= 86400;
         }
     }
     if ($this->_startday <= $testDate && $this->_endday >= $testDate) {
         // if only show on first day
         if ($multidayTreatment == 2 && $testDate >= $this->_startday + 86400) {
             return false;
         }
         // don't show multiday suppressed events after the first day if multiday is not true
         if ($multidayTreatment == 0) {
             if (!$this->_multiday && $testDate >= $this->_startday + 86400) {
                 return false;
             }
         }
         return true;
     } else {
         return false;
     }
 }
コード例 #2
0
function DefaultdateFormattedDateRange($view)
{
    $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
    if ($params->get("daterangeformat", "") == "") {
        $return = JEventsHTML::getDateFormat($view->startyear, $view->startmonth, $view->startday, 1) . "&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;" . JEventsHTML::getDateFormat($view->endyear, $view->endmonth, $view->endday, 1);
    } else {
        $return = $params->get("daterangeformat", "");
        $startmatches = array();
        preg_match_all('|{START(.*?)}|', $return, $startmatches);
        if (count($startmatches) == 2 && count($startmatches[1]) == 1) {
            $replace = str_replace(array("(", ")"), "", $startmatches[1][0]);
            $datestp = JevDate::mktime(0, 0, 0, $view->startmonth, $view->startday, $view->startyear);
            $replace = JEV_CommonFunctions::jev_strftime($replace, $datestp);
            $return = str_replace($startmatches[0][0], $replace, $return);
        }
        $endmatches = array();
        preg_match_all('|{END(.*?)}|', $return, $endmatches);
        if (count($endmatches) == 2 && count($endmatches[1]) == 1) {
            $replace = str_replace(array("(", ")"), "", $endmatches[1][0]);
            $datestp = JevDate::mktime(0, 0, 0, $view->endmonth, $view->endday, $view->endyear);
            $replace = JEV_CommonFunctions::jev_strftime($replace, $datestp);
            $return = str_replace($endmatches[0][0], $replace, $return);
        }
        //$return = $params->get("daterangeformat", "");
    }
    return $return;
}
コード例 #3
0
ファイル: view.html.php プロジェクト: madcsaba/li-de
 function getAdjacentYear($year, $month, $day, $direction = 1)
 {
     $d1 = JevDate::mktime(0, 0, 0, $month, $day, $year + $direction);
     $day = JevDate::strftime("%d", $d1);
     $year = JevDate::strftime("%Y", $d1);
     $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
     $cfg = JEVConfig::getInstance();
     if (method_exists("JEVHelper", "getMinYear")) {
         $earliestyear = JEVHelper::getMinYear();
         $latestyear = JEVHelper::getMaxYear();
     } else {
         $earliestyear = $params->get("com_earliestyear", 1970);
         $latestyear = $params->get("com_latestyear", 2150);
     }
     if ($year > $latestyear || $year < $earliestyear) {
         return false;
     }
     $month = JevDate::strftime("%m", $d1);
     $task = JRequest::getString('jevtask');
     $Itemid = JEVHelper::getItemid();
     if (isset($Itemid)) {
         $item = "&Itemid={$Itemid}";
     } else {
         $item = "";
     }
     return JRoute::_("index.php?option=" . JEV_COM_COMPONENT . "&task={$task}{$item}&year={$year}&month={$month}&day={$day}");
 }
コード例 #4
0
    function editICalendar($icsid, $catid, $access = 0, $state = 1, $label = "")
    {
        $db =& JFactory::getDBO();
        $temp = new iCalICSFile($db);
        $temp->_setup($icsid, $catid, $access, $state);
        $temp->filename = "_from_scratch_";
        $temp->icaltype = 2;
        $temp->label = empty($label) ? 'Scratch-' . md5(JevDate::mktime()) : $label;
        $temp->srcURL = "";
        $rawText = <<<RAWTEXT

BEGIN:VCALENDAR
PRODID:-//JEvents Project//JEvents Calendar 1.5.0//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:{$label}
X-WR-TIMEZONE:Europe/London
BEGIN:VTIMEZONE
TZID:Europe/London
X-LIC-LOCATION:Europe/London
BEGIN:DAYLIGHT
TZOFFSETFROM:+0000
TZOFFSETTO:+0100
TZNAME:BST
DTSTART:19700329T010000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0100
TZOFFSETTO:+0000
TZNAME:GMT
DTSTART:19701025T020000
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
END:STANDARD
END:VTIMEZONE
END:VCALENDAR
\t\t
RAWTEXT;
        $temp->_icalInfo =& JEVHelper::iCalInstance("", $rawText);
        return $temp;
    }
コード例 #5
0
 function getAdjacentYear($year, $month, $day, $direction = 1)
 {
     $d1 = JevDate::mktime(0, 0, 0, $month, $day, $year + $direction);
     $day = JevDate::strftime("%d", $d1);
     $year = JevDate::strftime("%Y", $d1);
     $cfg =& JEVConfig::getInstance();
     $earliestyear = $cfg->get('com_earliestyear');
     $latestyear = $cfg->get('com_latestyear');
     if ($year > $latestyear || $year < $earliestyear) {
         return false;
     }
     $month = JevDate::strftime("%m", $d1);
     $task = JRequest::getString('jevtask');
     $Itemid = JEVHelper::getItemid();
     if (isset($Itemid)) {
         $item = "&Itemid={$Itemid}";
     } else {
         $item = "";
     }
     return JRoute::_("index.php?option=" . JEV_COM_COMPONENT . "&task={$task}{$item}&year={$year}&month={$month}&day={$day}");
 }
コード例 #6
0
ファイル: helper.php プロジェクト: madcsaba/li-de
 /**
  * Function that overwrites meta-tags in mainframe!!
  *
  * @static
  * @param string $name - metatag name
  * @param string $content - metatag value
  */
 public static function checkRobotsMetaTag($name = "robots", $content = "index,follow")
 {
     // force robots metatag
     $cfg = JEVConfig::getInstance();
     $document = JFactory::getDocument();
     // constrained in some way
     if ($cfg->get('com_blockRobots', 0) >= 1) {
         // Allow on detail  pages - block otherwise unless crawler!
         if ($cfg->get('com_blockRobots', 0) == 3) {
             if (strpos(JRequest::getString("jevtask", ""), ".detail") > 0) {
                 $document->setMetaData($name, "index,nofollow");
                 return;
             }
             if (strpos(JRequest::getString("jevtask", ""), "crawler") !== false || $content != "index,follow") {
                 $document->setMetaData($name, $content);
             } else {
                 $document->setMetaData($name, "noindex,nofollow");
             }
             return;
         }
         // Always block Robots
         if ($cfg->get('com_blockRobots', 0) == 1) {
             $document->setMetaData($name, "noindex,nofollow");
             return;
         }
         // conditional on date
         list($cyear, $cmonth, $cday) = JEVHelper::getYMD();
         $cdate = JevDate::mktime(0, 0, 0, $cmonth, $cday, $cyear);
         $prior = JevDate::strtotime($cfg->get('robotprior', "-1 day"));
         if ($cdate < $prior && $cfg->get('com_blockRobots', 0)) {
             $document->setMetaData($name, "noindex,nofollow");
             return;
         }
         $post = JevDate::strtotime($cfg->get('robotpost', "-1 day"));
         if ($cdate > $post && $cfg->get('com_blockRobots', 0)) {
             $document->setMetaData($name, "noindex,nofollow");
             return;
         }
         //If JEvents is not blocking robots we use menu item configuration
         $document->setMetaData($name, $cfg->get('robots', $content));
     } else {
         $document->setMetaData($name, $cfg->get('robots', $content));
     }
 }
コード例 #7
0
ファイル: calendar_cell.php プロジェクト: poorgeek/JEvents
 function calendarCell(&$currentDay, $year, $month, $i, $slot = "")
 {
     $cfg = JEVConfig::getInstance();
     $event = $currentDay["events"][$i];
     // Event publication infomation
     $event_up = new JEventDate($event->startDate());
     $event_down = new JEventDate($event->endDate());
     // BAR COLOR GENERATION
     $bgeventcolor = JEV_CommonFunctions::setColor($event);
     $start_publish = JevDate::mktime(0, 0, 0, $event->mup(), $event->dup(), $event->yup());
     $stop_publish = JevDate::mktime(0, 0, 0, $event->mdn(), $event->ddn(), $event->ydn());
     // this file controls the events component month calendar display cell output.  It is separated from the
     // showCalendar function in the events.php file to allow users to customize this portion of the code easier.
     // The event information to be displayed within a month day on the calendar can be modified, as well as any
     // overlay window information printed with a javascript mouseover event.  Each event prints as a separate table
     // row with a single column, within the month table's cell.
     // On mouse over date formats
     // Note that the date formats for the events can be easily changed by modifying the sprintf formatting
     // string below.  These are used for the default overlay window.  As well, the JevDate::strftime() function could
     // also be used instead to provide more powerful date formatting which supports locales if php function
     // set_locale() is being used.
     // define start and end
     $cellStart = '<div class="eventfull"><div class="eventstyle" ';
     $cellStyle = '';
     $cellEnd = '</div></div>' . "\n";
     // add the event color as the column background color
     include_once JPATH_ADMINISTRATOR . "/components/" . JEV_COM_COMPONENT . "/libraries/colorMap.php";
     //$colStyle .= $bgeventcolor ? ' background-color:' . $bgeventcolor . ';' : '';
     //$colStyle .= $bgeventcolor ? 'color:'.JevMapColor($bgeventcolor) . ';' : '';
     // MSIE ignores "inherit" color for links - stupid Microsoft!!!
     //$linkStyle = $bgeventcolor ? 'style="color:'.JevMapColor($bgeventcolor) . ';"' : '';
     $linkStyle = "";
     // The title is printed as a link to the event's detail page
     $link = $this->event->viewDetailLink($year, $month, $currentDay['d0'], false);
     $link = JRoute::_($link . $this->_datamodel->getCatidsOutLink());
     $title = $event->title();
     // [mic] if title is too long, cut 'em for display
     $tmpTitle = $title;
     // set truncated title
     if (!isset($this->event->truncatedtitle)) {
         if (JString::strlen($title) >= $cfg->get('com_calCutTitle', 50)) {
             $tmpTitle = JString::substr($title, 0, $cfg->get('com_calCutTitle', 50)) . ' ...';
         }
         $tmpTitle = JEventsHTML::special($tmpTitle);
         $this->event->truncatedtitle = $tmpTitle;
     } else {
         $tmpTitle = $this->event->truncatedtitle;
     }
     // [new mic] if amount of displaing events greater than defined, show only a scmall coloured icon
     // instead of full text - the image could also be "recurring dependig", which means
     // for each kind of event (one day, multi day, last day) another icon
     // in this case the dfinition must moved down to be more flexible!
     // [tstahl] add a graphic symbol for all day events?
     $tmp_start_time = $this->start_time == $this->stop_time && !$this->event->noendtime() || $this->event->alldayevent() ? '' : $this->start_time;
     $templatedcell = false;
     if ($currentDay['countDisplay'] < $cfg->get('com_calMaxDisplay', 5)) {
         ob_start();
         $templatedcell = $this->loadedFromTemplate('month.calendar_cell', $this->event, 0);
         $res = ob_get_clean();
         if ($templatedcell) {
             $templatedcell = $res;
         } else {
             if ($this->_view) {
                 $this->_view->assignRef("link", $link);
                 $this->_view->assignRef("linkStyle", $linkStyle);
                 $this->_view->assignRef("tmp_start_time", $tmp_start_time);
                 $this->_view->assignRef("tmpTitle", $tmpTitle);
             }
             $title_event_link = $this->loadOverride("cellcontent");
             // allow fallback to old method
             if ($title_event_link == "") {
                 $title_event_link = "\n" . '<a class="cal_titlelink" href="' . $link . '" ' . $linkStyle . '>' . ($cfg->get('com_calDisplayStarttime') ? $tmp_start_time : '') . ' ' . $tmpTitle . '</a>' . "\n";
             }
             $cellStyle .= "border-width:0px 0px 1px 8px;border-color:{$bgeventcolor};padding:0px 0px 1px 2px;";
         }
     } else {
         $eventIMG = '<img align="left" src="' . JURI::root() . 'components/' . JEV_COM_COMPONENT . '/images/event.png" alt="" style="height:12px;width:8px;border:1px solid white;background-color:' . $bgeventcolor . '" />';
         $title_event_link = "\n" . '<a class="cal_titlelink" href="' . $link . '">' . $eventIMG . '</a>' . "\n";
         $cellStyle .= ' float:left;width:10px;';
     }
     $cellString = '';
     // allow template overrides for cell popups
     // only try override if we have a view reference
     if ($this->_view) {
         $this->_view->assignRef("ecc", $this);
         $this->_view->assignRef("cellDate", $currentDay["cellDate"]);
     }
     if ($cfg->get("com_enableToolTip", 1)) {
         if ($cfg->get("tooltiptype", 'joomla') == 'overlib') {
             $tooltip = $this->loadOverride("overlib");
             // allow fallback to old method
             if ($tooltip == "") {
                 $tooltip = $this->calendarCell_popup($currentDay["cellDate"]);
             }
             $cellString .= $tooltip;
         } else {
             // TT background
             if ($cfg->get('com_calTTBackground', 1) == '1') {
                 $bground = $this->event->bgcolor();
                 $fground = $this->event->fgcolor();
             } else {
                 $bground = "#000000";
                 $fground = "#ffffff";
             }
             JevHtmlBootstrap::popover('.hasjevtip', array("trigger" => "hover focus", "placement" => "top", "container" => "#jevents_body", "delay" => array("hide" => 150)));
             //$toolTipArray = array('className'=>'jevtip');
             //JHTML::_('behavior.tooltip', '.hasjevtip', $toolTipArray);
             $tooltip = $this->loadOverride("tooltip");
             // allow fallback to old method
             if ($tooltip == "") {
                 $tooltip = $this->calendarCell_tooltip($currentDay["cellDate"]);
             }
             if (strpos($tooltip, "templated") === 0) {
                 $title = JString::substr($tooltip, 9);
                 $cellString = "";
             } else {
                 $cellString .= '<div class="jevtt_text" >' . $tooltip . '</div>';
                 $title = '<div class="jevtt_title" style = "color:' . $fground . ';background-color:' . $bground . '">' . $this->title . '</div>';
             }
             if ($templatedcell) {
                 $templatedcell = str_replace("[[TOOLTIP]]", htmlspecialchars($title . $cellString, ENT_QUOTES), $templatedcell);
                 $templatedcell = str_replace("[[TOOLTIPTITLE]]", htmlspecialchars($title, ENT_QUOTES), $templatedcell);
                 $templatedcell = str_replace("[[TOOLTIPCONTENT]]", htmlspecialchars($cellString, ENT_QUOTES), $templatedcell);
                 $time = $cfg->get('com_calDisplayStarttime') ? $tmp_start_time : "";
                 $templatedcell = str_replace("[[EVTTIME]]", $time, $templatedcell);
                 return $templatedcell;
             }
             $html = $cellStart . ' style="' . $cellStyle . '">' . $this->tooltip($title, $cellString, $title_event_link) . $cellEnd;
             return $html;
         }
     }
     if ($templatedcell) {
         $templatedcell = str_replace("[[TOOLTIP]]", htmlspecialchars($title . $cellString, ENT_QUOTES), $templatedcell);
         $templatedcell = str_replace("[[TOOLTIPTITLE]]", htmlspecialchars($title, ENT_QUOTES), $templatedcell);
         $templatedcell = str_replace("[[TOOLTIPCONTENT]]", htmlspecialchars($cellString, ENT_QUOTES), $templatedcell);
         $time = $cfg->get('com_calDisplayStarttime') ? $tmp_start_time : "";
         $templatedcell = str_replace("[[EVTTIME]]", $time, $templatedcell);
         return $templatedcell;
     }
     // return the whole thing
     return $cellStart . ' style="' . $cellStyle . '" ' . $cellString . ">\n" . $title_event_link . $cellEnd;
 }
コード例 #8
0
    function __construct($view, $today_date, $view_date, $dates, $alts, $option, $task, $Itemid)
    {
        global $catidsOut;
        if (JRequest::getInt('pop', 0)) {
            return;
        }
        $cfg = JEVConfig::getInstance();
        $compname = JEV_COM_COMPONENT;
        //Lets check if we should show the nav on event details
        if ($task == "icalrepeat.detail" && $cfg->get('shownavbar_detail', 1) == 0) {
            return;
        }
        $this->iconstoshow = $cfg->get('iconstoshow', array('byyear', 'bymonth', 'byweek', 'byday', 'search'));
        $viewimages = JURI::root() . "components/" . JEV_COM_COMPONENT . "/views/" . $view->getViewName() . "/assets/images";
        $cat = "";
        $hiddencat = "";
        if ($catidsOut != 0) {
            $cat = '&catids=' . $catidsOut;
            $hiddencat = '<input type="hidden" name="catids" value="' . $catidsOut . '"/>';
        }
        $link = 'index.php?option=' . $option . '&task=' . $task . $cat . '&Itemid=' . $Itemid . '&';
        $month_date = JevDate::mktime(0, 0, 0, $view_date->month, $view_date->day, $view_date->year);
        ?>
        <?php 
        if ($task == "month.calendar") {
            echo "<div class='month_date'><div class='month_title'>" . JEV_CommonFunctions::jev_strftime("%B", $month_date) . ", </div><div class='month_title_year'>  " . JEV_CommonFunctions::jev_strftime("%Y", $month_date) . "</div></div>";
        }
        ?>
        <div class="new-navigation">
            <div class="nav-items">
                <?php 
        if (in_array("byyear", $this->iconstoshow)) {
            ?>
                    <div  id="nav-year"<?php 
            if ($task == "year.listevents") {
                echo ' class="active"';
            }
            ?>
 >
                        <a href="<?php 
            echo JRoute::_('index.php?option=' . $option . $cat . '&task=year.listevents&' . $view_date->toDateURL() . '&Itemid=' . $Itemid);
            ?>
" title="<?php 
            echo JText::_('JEV_VIEWBYYEAR');
            ?>
"  >
                    <?php 
            echo JText::_('JEV_VIEWBYYEAR');
            ?>
</a>
                    </div>
                <?php 
        }
        ?>
                <?php 
        if (in_array("bymonth", $this->iconstoshow)) {
            ?>
                    <div  id="nav-month"<?php 
            if ($task == "month.calendar") {
                echo ' class="active"';
            }
            ?>
>
                        <a href="<?php 
            echo JRoute::_('index.php?option=' . $option . $cat . '&task=month.calendar&' . $view_date->toDateURL() . '&Itemid=' . $Itemid);
            ?>
" title="<?php 
            echo JText::_('JEV_VIEWBYMONTH');
            ?>
" >							<?php 
            echo JText::_('JEV_VIEWBYMONTH');
            ?>
</a>
                    </div>
                     <?php 
        }
        ?>
                        <?php 
        if (in_array("byweek", $this->iconstoshow)) {
            ?>
                    <div id="nav-week"<?php 
            if ($task == "week.listevents") {
                echo ' class="active"';
            }
            ?>
>
                        <a href="<?php 
            echo JRoute::_('index.php?option=' . $option . $cat . '&task=week.listevents&' . $view_date->toDateURL() . '&Itemid=' . $Itemid);
            ?>
" title="<?php 
            echo JText::_('JEV_VIEWBYWEEK');
            ?>
" >
                         <?php 
            echo JText::_('JEV_VIEWBYWEEK');
            ?>
</a>
                    </div>
                        <?php 
        }
        ?>
                <?php 
        if (in_array("byday", $this->iconstoshow)) {
            ?>
                    <div id="nav-today"<?php 
            if ($task == "day.listevents") {
                echo ' class="active"';
            }
            ?>
>
                        <a href="<?php 
            echo JRoute::_('index.php?option=' . $option . $cat . '&task=day.listevents&' . $today_date->toDateURL() . '&Itemid=' . $Itemid);
            ?>
" title="<?php 
            echo JText::_('JEV_VIEWTODAY');
            ?>
" >
                    <?php 
            echo JText::_('JEV_VIEWTODAY');
            ?>
</a>
                    </div>
                <?php 
        }
        ?>
                <?php 
        if (in_array("bymonth", $this->iconstoshow)) {
            ?>
                    <?php 
            echo $this->_viewJumptoIcon($view_date, $viewimages);
            ?>
                        <?php 
        }
        ?>
                        <?php 
        if ($cfg->get('com_hideshowbycats', 0) == '0') {
            ?>
                    <?php 
            if (in_array("bycat", $this->iconstoshow)) {
                ?>
                        <div id="nav-cat"<?php 
                if ($task == "cat.listevents") {
                    echo ' class="active"';
                }
                ?>
>
                            <a href="<?php 
                echo JRoute::_('index.php?option=' . $option . $cat . '&task=cat.listevents&' . $view_date->toDateURL() . '&Itemid=' . $Itemid);
                ?>
" title="<?php 
                echo JText::_('JEV_VIEWBYCAT');
                ?>
" >
                    <?php 
                echo JText::_('JEV_VIEWBYCAT');
                ?>
</a>
                        </div>
                <?php 
            }
            ?>
            <?php 
        }
        ?>
            </div>
        <?php 
        if (in_array("search", $this->iconstoshow)) {
            ?>
                <div  id="nav-search">
                    <a href="<?php 
            echo JRoute::_('index.php?option=' . $option . $cat . '&task=search.form&' . $view_date->toDateURL() . '&Itemid=' . $Itemid);
            ?>
" title="<?php 
            echo JText::_('JEV_SEARCH_TITLE');
            ?>
" >
                        <img src="<?php 
            echo $viewimages;
            ?>
/icon-search.gif" alt="Search" /></a>
                </div>
        <?php 
        }
        ?>
        <?php 
        if (in_array("bymonth", $this->iconstoshow)) {
            echo $this->_viewHiddenJumpto($view_date, $view, $Itemid);
        }
        ?>


        </div>
        <?php 
    }
コード例 #9
0
<div class="jev_toprow">
    <div class="jev_header2">
        <div class="previousmonth">
            <?php 
if ($precedingWeek) {
    echo "<a href='" . $precedingWeek . "' title='" . JText::_("PRECEEDING_Week") . "' >" . JText::_("PRECEEDING_Week") . "</a>";
}
?>
        </div>
        <div class="currentmonth">
            <?php 
$week_start = $data['days']['0'];
$week_end = $data['days']['6'];
$starttime = JevDate::mktime(0, 0, 0, $week_start['week_month'], $week_start['week_day'], $week_start['week_year']);
$endtime = JevDate::mktime(0, 0, 0, $week_end['week_month'], $week_end['week_day'], $week_end['week_year']);
if ($week_start['week_month'] == $week_end['week_month']) {
    $startformat = "%d";
    $endformat = "%d %B, %Y";
} else {
    if ($week_start['week_year'] == $week_end['week_year']) {
        $startformat = "%d %B";
        $endformat = "%d %B, %Y";
    } else {
        $startformat = "%d. %B  %Y";
        $endformat = "%d. %B %Y";
    }
}
echo JEV_CommonFunctions::jev_strftime($startformat, $starttime) . ' - ' . JEV_CommonFunctions::jev_strftime($endformat, $endtime);
?>
        </div>
コード例 #10
0
 /**
  * iCal spec represents date in ISO 8601 format followed by "T" then the time
  * a "Z at the end means the time is UTC and not local time zone
  *
  * TODO make sure if time is UTC we take account of system time offset properly
  *
  */
 function unixTime($ical_date, $tz = false)
 {
     jimport("joomla.utilities.date");
     static $offset = null;
     if (is_null($offset)) {
         $config =& JFactory::getConfig();
         $offset = $config->getValue('config.offset', 0);
     }
     if (!is_numeric($ical_date)) {
         $t = JevDate::strtotime($ical_date);
         if (JString::strpos($ical_date, "Z") > 0) {
             if (is_callable("date_default_timezone_set")) {
                 $timezone = date_default_timezone_get();
                 // See http://www.php.net/manual/en/timezones.php
                 $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
                 // server offset tiemzone
                 if ($params->get("icaltimezone", "") != "") {
                     date_default_timezone_set($params->get("icaltimezone", ""));
                 }
                 // server offset PARAMS
                 $serveroffset1 = (JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%S', $t)) - JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%SZ', $t))) / 3600;
                 // server offset SERVER
                 date_default_timezone_set($timezone);
                 $serveroffset2 = (JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%S', $t)) - JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%SZ', $t))) / 3600;
                 $t = new JevDate($ical_date, $serveroffset1 - $serveroffset2);
                 //$t = new JevDate($ical_date );
                 date_default_timezone_set($timezone);
                 echo "icaldate = " . $ical_date . " imported date=" . $t->toMySQL() . "<br/>";
             } else {
                 // Summer Time adjustment
                 list($y, $m, $d, $h, $min, $s) = explode(":", JevDate::strftime('%Y:%m:%d:%H:%M:%S', $t));
                 $dst = (JevDate::mktime($h, $min, $s, $m, $d, $y, 0) - JevDate::mktime($h, $min, $s, $m, $d, $y, -1)) / 3600;
                 // server offset including DST
                 $serveroffset = (JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%S', $t)) - JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%SZ', $t))) / 3600;
                 $serveroffset += $dst;
                 $t = new JevDate($ical_date, -($serveroffset + $offset));
             }
             /*
             echo "<h3>SET TIMEZONE</h3>";
             $timezone= date_default_timezone_get();
             date_default_timezone_set('America/New_York');
             
             $tempIcal  = "20091020T163000Z";
             echo $tempIcal."<br/>";
             $temp = JevDate::strtotime($tempIcal);
             list($y,$m,$d,$h,$min,$s) = explode(":", JevDate::strftime('%Y:%m:%d:%H:%M:%S',$temp));
             echo "$y,$m,$d,$h,$min,$s<br/>";
             $dst = (JevDate::mktime($h,$min,$s,$m,$d,$y,0)-JevDate::mktime($h,$min,$s,$m,$d,$y,-1))/3600;
             $so = (JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%S',$temp))-JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%SZ',$temp)))/3600;
             echo " dst=".$dst." serverforoffset=".$so."<br/>";
             $so += $dst;
             $t = new JevDate($tempIcal);
             echo $t->toMySQL()."<br><br/>";
             
             
             $tempIcal  = "20091029T163000Z";
             echo $tempIcal."<br/>";
             $temp = JevDate::strtotime($tempIcal);
             list($y,$m,$d,$h,$min,$s) = explode(":", JevDate::strftime('%Y:%m:%d:%H:%M:%S',$temp));
             echo "$y,$m,$d,$h,$min,$s<br/>";
             $dst = (JevDate::mktime($h,$min,$s,$m,$d,$y,0)-JevDate::mktime($h,$min,$s,$m,$d,$y,-1))/3600;
             $so = (JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%S',$temp))-JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%SZ',$temp)))/3600;
             echo " dst=".$dst." serverforoffset=".$so."<br/>";
             $so += $dst;
             $t = new JevDate($tempIcal );
             echo $t->toMySQL()."<br><br/>";
             
             $tempIcal  = "20091103T163000Z";
             echo $tempIcal."<br/>";
             $temp = JevDate::strtotime($tempIcal);
             list($y,$m,$d,$h,$min,$s) = explode(":", JevDate::strftime('%Y:%m:%d:%H:%M:%S',$temp));
             echo "$y,$m,$d,$h,$min,$s<br/>";
             $dst = (JevDate::mktime($h,$min,$s,$m,$d,$y,0)-JevDate::mktime($h,$min,$s,$m,$d,$y,-1))/3600;
             $so = (JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%S',$temp))-JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%SZ',$temp)))/3600;
             echo " dst=".$dst." serverforoffset=".$so."<br/>";
             $so += $dst;
             $t = new JevDate($tempIcal);
             echo $t->toMySQL()."<br>";
             */
         } else {
             if ($tz != false && $tz != "") {
                 // really should use the timezone of the inputted date
                 $tz = new DateTimeZone($tz);
                 $t = new JevDate($ical_date, $tz);
                 echo "icaldate = " . $ical_date . " imported date=" . $t->toMySQL() . "<br/>";
             } else {
                 $compparams = JComponentHelper::getParams(JEV_COM_COMPONENT);
                 $jtz = $compparams->get("icaltimezonelive", "");
                 if ($jtz) {
                     $t = new JevDate($ical_date, $jtz);
                 } else {
                     $t = new JevDate($ical_date);
                 }
             }
         }
         //$result = $t->toMySQL();
         $result = $t->toUnix();
         return $result;
     }
     $isUTC = false;
     if (JString::strpos($ical_date, "Z") !== false) {
         $isUTC = true;
     }
     // strip "T" and "Z" from the string
     $ical_date = str_replace('T', '', $ical_date);
     $ical_date = str_replace('Z', '', $ical_date);
     // split it out intyo YYYY MM DD HH MM SS
     preg_match("#([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})([0-9]{0,2})#", $ical_date, $date);
     list($temp, $y, $m, $d, $h, $min, $s) = $date;
     if (!$min) {
         $min = 0;
     }
     if (!$h) {
         $h = 0;
     }
     if (!$d) {
         $d = 0;
     }
     if (!$s) {
         $s = 0;
     }
     // Trap unix dated beofre 1970
     $y = max($y, 1970);
     if ($isUTC) {
         $t = gmJevDate::mktime($h, $min, $s, $m, $d, $y) + 3600 * $offset;
         $result = JevDate::strtotime(gmdate('Y-m-d H:i:s', $t));
     } else {
         $result = JevDate::mktime($h, $min, $s, $m, $d, $y);
     }
     // double check!!
     //list($y1,$m1,$d1,$h1,$min1,$s1)=explode(":",JevDate::strftime('%Y:%m:%d:%H:%M:%S',$result));
     return $result;
 }
コード例 #11
0
ファイル: calendar.php プロジェクト: affiliatelk/ecc
 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;
     }
     $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 = "";
     $mod = "";
     if (isset($this->_modid) && $this->_modid > 0) {
         $mod = 'id="modid_' . $this->_modid . '" ';
         $content .= "<span id='testspan" . $this->_modid . "' style='display:none'></span>\n";
     }
     $temptime = JevDate::mktime(12, 0, 0, $month, 15, $year);
     //$content .= $this->_displayCalendarMod($temptime,$this->com_starday, JText::_('JEV_THIS_MONTH'),$day_name, false);
     $thisDayOfMonth = date("j", $temptime);
     $daysLeftInMonth = date("t", $temptime) - date("j", $temptime) + 1;
     // calculate month offset from first of month
     $first_of_current_month = JevDate::strtotime(date('Y-m-01', $temptime));
     $base_year = date("Y", $temptime);
     $base_month = date("m", $temptime);
     $basefirst_of_month = JevDate::mktime(0, 0, 0, $base_month, 1, $base_year);
     if ($this->disp_lastMonth && (!$this->disp_lastMonthDays || $thisDayOfMonth <= $this->disp_lastMonthDays)) {
         $content .= $this->_displayCalendarMod(JevDate::strtotime("-1 month", $first_of_current_month), $this->com_starday, JText::_('JEV_LAST_MONTH'), $day_name, $this->disp_lastMonth == 2, $first_of_current_month);
     }
     $content .= $this->_displayCalendarMod($temptime, $this->com_starday, JText::_('JEV_THIS_MONTH'), $day_name, false, $first_of_current_month);
     if ($this->disp_nextMonth && (!$this->disp_nextMonthDays || $daysLeftInMonth <= $this->disp_nextMonthDays)) {
         $content .= $this->_displayCalendarMod(JevDate::strtotime("+1 month", $first_of_current_month), $this->com_starday, JText::_('JEV_NEXT_MONTH'), $day_name, $this->disp_nextMonth == 2, $first_of_current_month);
     }
     return $content;
 }
コード例 #12
0
 function edit()
 {
     // get the view
     $this->view =& $this->getView("icalevent", "html");
     $cid = JRequest::getVar('cid', array(0));
     JArrayHelper::toInteger($cid);
     if (is_array($cid) && count($cid) > 0) {
         $id = $cid[0];
     } else {
         $id = 0;
     }
     // front end passes the id as evid
     if ($id == 0) {
         $id = JRequest::getInt("evid", 0);
     }
     if (!JEVHelper::isEventCreator()) {
         JError::raiseError(403, JText::_('ALERTNOTAUTH'));
     }
     $repeatId = 0;
     $db = JFactory::getDBO();
     // iCal agid uses GUID or UUID as identifier
     if ($id > 0) {
         if ($repeatId == 0) {
             // this version gives us a repeat not an event so
             //$row = $this->queryModel->getEventById($id, true, "icaldb");
             $vevent = $this->dataModel->queryModel->getVEventById($id);
             if (!$vevent) {
                 $Itemid = JRequest::getInt("Itemid");
                 JFactory::getApplication()->redirect(JRoute::_("index.php?option=" . JEV_COM_COMPONENT . "&Itemid={$Itemid}", false), JText::_("JEV_SORRY_UPDATED"));
             }
             $row = new jIcalEventDB($vevent);
             $row->fixDtstart();
         } else {
             $row = $this->queryModel->listEventsById($repeatId, true, "icaldb");
         }
         if (!JEVHelper::canEditEvent($row)) {
             JError::raiseError(403, JText::_('ALERTNOTAUTH'));
         }
     } else {
         $vevent = new iCalEvent($db);
         $vevent->set("freq", "DAILY");
         $vevent->set("description", "");
         $vevent->set("summary", "");
         list($year, $month, $day) = JEVHelper::getYMD();
         $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
         $defaultstarttime = $params->get("defaultstarttime", "08:00");
         $defaultendtime = $params->get("defaultendtime", "17:00");
         list($starthour, $startmin) = explode(":", $defaultstarttime);
         list($endhour, $endmin) = explode(":", $defaultendtime);
         $vevent->set("dtstart", JevDate::mktime($starthour, $startmin, 0, $month, $day, $year));
         $vevent->set("dtend", JevDate::mktime($endhour, $endmin, 0, $month, $day, $year));
         $row = new jIcalEventDB($vevent);
         // TODO - move this to class!!
         // populate with meaningful initial values
         $row->starttime($defaultstarttime);
         $row->endtime($defaultendtime);
     }
     /*
     $db =& JFactory::getDBO();
     // get list of groups
     $query = "SELECT id AS value, name AS text"
     . "\n FROM #__groups"
     . "\n ORDER BY id"	;
     $db->setQuery( $query );
     $groups = $db->loadObjectList();
     
     // build the html select list
     $glist = JHTML::_('select.genericlist', $groups, 'access', 'class="inputbox" size="1"',	'value', 'text', intval( $row->access() ) );
     */
     $glist = JEventsHTML::buildAccessSelect(intval($row->access()), 'class="inputbox" size="1"');
     // get all the raw native calendars
     $nativeCals = $this->dataModel->queryModel->getNativeIcalendars();
     // Strip this list down based on user permissions
     $jevuser =& JEVHelper::getAuthorisedUser();
     if ($jevuser && $jevuser->calendars != "" && $jevuser->calendars != "all") {
         $cals = array_keys($nativeCals);
         $allowedcals = explode("|", $jevuser->calendars);
         foreach ($cals as $calid) {
             if (!in_array($calid, $allowedcals)) {
                 unset($nativeCals[$calid]);
             }
         }
     }
     // Are we allowed to edit events within a URL based iCal
     $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
     if ($params->get("allowedit", 0) && $row->icsid() > 0) {
         $calsql = 'SELECT * FROM #__jevents_icsfile WHERE ics_id=' . intval($row->icsid());
         $db->setQuery($calsql);
         $cal = $db->loadObject();
         if ($cal && $cal->icaltype == 0) {
             $nativeCals[$cal->ics_id] = $cal;
             $this->view->assign("offerlock", 1);
         }
     }
     $excats = "0";
     if ($jevuser && $jevuser->categories != "" && $jevuser->categories != "all") {
         // Find which categories to exclude
         if (JVersion::isCompatible("1.6.0")) {
             $catsql = 'SELECT id  FROM #__categories WHERE id NOT IN (' . str_replace("|", ",", $jevuser->categories) . ') AND extension="com_jevents"';
         } else {
             $catsql = 'SELECT id  FROM #__categories WHERE id NOT IN (' . str_replace("|", ",", $jevuser->categories) . ') AND section="com_jevents"';
         }
         $db->setQuery($catsql);
         $excats = implode(",", $db->loadResultArray());
     }
     // only offer a choice of native calendars if it exists!
     if (count($nativeCals) > 1) {
         $icalList = array();
         $icalList[] = JHTML::_('select.option', '0', JText::_('JEV_EVENT_CHOOSE_ICAL'), 'ics_id', 'label');
         $icalList = array_merge($icalList, $nativeCals);
         $clist = JHTML::_('select.genericlist', $icalList, 'ics_id', " onchange='preselectCategory(this);'", 'ics_id', 'label', $row->icsid());
         $this->view->assign('clistChoice', true);
         $this->view->assign('defaultCat', 0);
     } else {
         if (count($nativeCals) == 0 || !is_array($nativeCals)) {
             JError::raiseWarning(870, JText::_('INVALID_CALENDAR_STRUCTURE'));
         }
         $icsid = $row->icsid() > 0 ? $row->icsid() : current($nativeCals)->ics_id;
         $clist = '<input type="hidden" name="ics_id" value="' . $icsid . '" />';
         $this->view->assign('clistChoice', false);
         $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
         if ($params->get("defaultcat", false)) {
             $this->view->assign('defaultCat', current($nativeCals)->catid);
         } else {
             $this->view->assign('defaultCat', 0);
         }
     }
     // Set the layout
     $this->view->setLayout('edit');
     $this->view->assign('editCopy', $this->editCopy);
     $this->view->assign('id', $id);
     $this->view->assign('row', $row);
     $this->view->assign('excats', $excats);
     $this->view->assign('nativeCals', $nativeCals);
     $this->view->assign('clist', $clist);
     $this->view->assign('repeatId', $repeatId);
     $this->view->assign('glist', $glist);
     // only those who can publish globally can set priority field
     if (JEVHelper::isEventPublisher(true)) {
         $list = array();
         for ($i = 0; $i < 10; $i++) {
             $list[] = JHTML::_('select.option', $i, $i, 'val', 'text');
         }
         $priorities = JHTML::_('select.genericlist', $list, 'priority', "", 'val', 'text', $row->priority());
         $this->view->assign('setPriority', true);
         $this->view->assign('priority', $priorities);
     } else {
         $this->view->assign('setPriority', false);
     }
     $this->view->assignRef('dataModel', $this->dataModel);
     // for Admin interface only
     $this->view->assign('with_unpublished_cat', JFactory::getApplication()->isAdmin());
     $this->view->display();
 }
コード例 #13
0
ファイル: latest.php プロジェクト: pguilford/vcomcc
 protected function processMatch(&$content, $match, $dayEvent, $dateParm, $relDay)
 {
     $datenow = JEVHelper::getNow();
     $dispatcher = JDispatcher::getInstance();
     // get the title and start time
     $startDate = JevDate::strtotime($dayEvent->publish_up());
     if ($relDay > 0) {
         $eventDate = JevDate::strtotime($datenow->toFormat('%Y-%m-%d ') . JevDate::strftime('%H:%M', $startDate) . " +{$relDay} days");
     } else {
         $eventDate = JevDate::strtotime($datenow->toFormat('%Y-%m-%d ') . JevDate::strftime('%H:%M', $startDate) . " {$relDay} days");
     }
     $endDate = JevDate::strtotime($dayEvent->publish_down());
     list($st_year, $st_month, $st_day) = explode('-', JevDate::strftime('%Y-%m-%d', $startDate));
     list($ev_year, $ev_month, $ev_day) = explode('-', JevDate::strftime('%Y-%m-%d', $startDate));
     $task_events = 'icalrepeat.detail';
     switch ($match) {
         case 'endDate':
         case 'startDate':
         case 'eventDate':
             // Note we need to examine the date specifiers used to determine if language translation will be
             // necessary.  Do this later when script is debugged.
             if (!$this->disableDateStyle) {
                 $content .= '<span class="mod_events_latest_date">';
             }
             if (!$dayEvent->alldayevent() && $match == "endDate" && ($dayEvent->noendtime() && $dayEvent->getUnixStartDate() == $dayEvent->getUnixEndDate() || $dayEvent->getUnixStartTime() == $dayEvent->getUnixEndTime())) {
                 $time_fmt = "";
             } else {
                 if (!isset($dateParm) || $dateParm == '') {
                     if ($this->com_calUseStdTime) {
                         $time_fmt = $dayEvent->alldayevent() ? '' : IS_WIN ? ' @%I:%M%p' : ' @%l:%M%p';
                     } else {
                         $time_fmt = $dayEvent->alldayevent() ? '' : ' @%H:%M';
                     }
                     $dateFormat = $this->displayYear ? '%a %b %d, %Y' . $time_fmt : '%a %b %d' . $time_fmt;
                     $jmatch = new JevDate(${$match});
                     $content .= $jmatch->toFormat($dateFormat);
                     //$content .= JEV_CommonFunctions::jev_strftime($dateFormat, $$match);
                 } else {
                     // format endDate when midnight to show midnight!
                     if ($match == "endDate" && $dayEvent->sdn() == 59) {
                         $tempEndDate = $endDate + 1;
                         if ($dayEvent->alldayevent()) {
                             // if an all day event then we don't want to roll to the next day
                             $tempEndDate -= 86400;
                         }
                         $match = "tempEndDate";
                     }
                     // if a '%' sign detected in date format string, we assume JevDate::strftime() is to be used,
                     if (preg_match("/\\%/", $dateParm)) {
                         $jmatch = new JevDate(${$match});
                         $content .= $jmatch->toFormat($dateParm);
                     } else {
                         $content .= date($dateParm, ${$match});
                     }
                     if ($match == "tempDndDate") {
                         $match = "endDate";
                     }
                 }
             }
             if (!$this->disableDateStyle) {
                 $content .= "</span>";
             }
             break;
         case 'title':
             $title = $dayEvent->title();
             if (!empty($dateParm)) {
                 $parts = explode("|", $dateParm);
                 if (count($parts) > 0 && strlen($title) > intval($parts[0])) {
                     $title = substr($title, 0, intval($parts[0]));
                     if (count($parts) > 1) {
                         $title .= $parts[1];
                     }
                 }
             }
             if (!$this->disableTitleStyle) {
                 $content .= '<span class="mod_events_latest_content">';
             }
             if ($this->displayLinks) {
                 $link = $dayEvent->viewDetailLink($ev_year, $ev_month, $ev_day, false, $this->myItemid);
                 if ($this->modparams->get("ignorefiltermodule", 0)) {
                     $link = JRoute::_($link . $this->datamodel->getCatidsOutLink() . "&filter_reset=1");
                 } else {
                     $link = JRoute::_($link . $this->datamodel->getCatidsOutLink());
                 }
                 $content .= $this->_htmlLinkCloaking($link, JEventsHTML::special($title));
             } else {
                 $content .= JEventsHTML::special($title);
             }
             if (!$this->disableTitleStyle) {
                 $content .= '</span>';
             }
             break;
         case 'category':
             $catobj = $dayEvent->getCategoryName();
             $content .= JEventsHTML::special($catobj);
             break;
         case 'categoryimage':
             $catobj = $dayEvent->getCategoryImage();
             $content .= $catobj;
             break;
         case 'calendar':
             $catobj = $dayEvent->getCalendarName();
             $content .= JEventsHTML::special($catobj);
             break;
         case 'contact':
             // Also want to cloak contact details so
             $this->modparams->set("image", 1);
             $dayEvent->text = $dayEvent->contact_info();
             $dispatcher->trigger('onContentPrepare', array('com_jevents', &$dayEvent, &$this->modparams, 0));
             $dayEvent->contact_info($dayEvent->text);
             $content .= $dayEvent->contact_info();
             break;
         case 'content':
             // Added by Kaz McCoy 1-10-2004
             $this->modparams->set("image", 1);
             $dayEvent->data->text = $dayEvent->content();
             $dispatcher->trigger('onContentPrepare', array('com_jevents', &$dayEvent->data, &$this->modparams, 0));
             if (!empty($dateParm)) {
                 $parts = explode("|", $dateParm);
                 if (count($parts) > 0 && strlen(strip_tags($dayEvent->data->text)) > intval($parts[0])) {
                     $dayEvent->data->text = substr(strip_tags($dayEvent->data->text), 0, intval($parts[0]));
                     if (count($parts) > 1) {
                         $dayEvent->data->text .= $parts[1];
                     }
                 }
             }
             $dayEvent->content($dayEvent->data->text);
             //$content .= substr($dayEvent->content, 0, 150);
             $content .= $dayEvent->content();
             break;
         case 'addressInfo':
         case 'location':
             $this->modparams->set("image", 0);
             $dayEvent->data->text = $dayEvent->location();
             $dispatcher->trigger('onContentPrepare', array('com_jevents', &$dayEvent->data, &$this->modparams, 0));
             $dayEvent->location($dayEvent->data->text);
             $content .= $dayEvent->location();
             break;
         case 'duration':
             $timedelta = $dayEvent->noendtime() || $dayEvent->alldayevent() ? "" : $dayEvent->getUnixEndTime() - $dayEvent->getUnixStartTime();
             if ($timedelta == "") {
                 break;
             }
             $fieldval = isset($dateParm) && $dateParm != '' ? $dateParm : JText::_("JEV_DURATION_FORMAT");
             $shownsign = false;
             // whole days!
             if (stripos($fieldval, "%wd") !== false) {
                 $days = intval($timedelta / (60 * 60 * 24));
                 $timedelta -= $days * 60 * 60 * 24;
                 if ($timedelta > 3610) {
                     //if more than 1 hour and 10 seconds over a day then round up the day output
                     $days += 1;
                 }
                 $fieldval = str_ireplace("%wd", $days, $fieldval);
                 $shownsign = true;
             }
             if (stripos($fieldval, "%d") !== false) {
                 $days = intval($timedelta / (60 * 60 * 24));
                 $timedelta -= $days * 60 * 60 * 24;
                 /*
                  if ($timedelta>3610){
                  //if more than 1 hour and 10 seconds over a day then round up the day output
                  $days +=1;
                  }
                 */
                 $fieldval = str_ireplace("%d", $days, $fieldval);
                 $shownsign = true;
             }
             if (stripos($fieldval, "%h") !== false) {
                 $hours = intval($timedelta / (60 * 60));
                 $timedelta -= $hours * 60 * 60;
                 if ($shownsign) {
                     $hours = abs($hours);
                 }
                 $hours = sprintf("%02d", $hours);
                 $fieldval = str_ireplace("%h", $hours, $fieldval);
                 $shownsign = true;
             }
             if (stripos($fieldval, "%m") !== false) {
                 $mins = intval($timedelta / 60);
                 $timedelta -= $hours * 60;
                 if ($mins) {
                     $mins = abs($mins);
                 }
                 $mins = sprintf("%02d", $mins);
                 $fieldval = str_ireplace("%m", $mins, $fieldval);
             }
             $content .= $fieldval;
             break;
         case 'extraInfo':
             $this->modparams->set("image", 0);
             $dayEvent->data->text = $dayEvent->extra_info();
             $dispatcher->trigger('onContentPrepare', array('com_jevents', &$dayEvent->data, &$this->modparams, 0));
             $dayEvent->extra_info($dayEvent->data->text);
             $content .= $dayEvent->extra_info();
             break;
         case 'countdown':
             $timedelta = $dayEvent->getUnixStartTime() - JevDate::mktime();
             $eventPassed = !($timedelta >= 0);
             $fieldval = $dateParm;
             $shownsign = false;
             if (stripos($fieldval, "%nopast") !== false) {
                 if (!$eventPassed) {
                     $fieldval = str_ireplace("%nopast", "", $fieldval);
                 } else {
                     $fieldval = JText::_('JEV_EVENT_FINISHED');
                 }
             }
             if (stripos($fieldval, "%d") !== false) {
                 $days = intval($timedelta / (60 * 60 * 24));
                 $timedelta -= $days * 60 * 60 * 24;
                 $fieldval = str_ireplace("%d", $days, $fieldval);
                 $shownsign = true;
             }
             if (stripos($fieldval, "%h") !== false) {
                 $hours = intval($timedelta / (60 * 60));
                 $timedelta -= $hours * 60 * 60;
                 if ($shownsign) {
                     $hours = abs($hours);
                 }
                 $hours = sprintf("%02d", $hours);
                 $fieldval = str_ireplace("%h", $hours, $fieldval);
                 $shownsign = true;
             }
             if (stripos($fieldval, "%m") !== false) {
                 $mins = intval($timedelta / 60);
                 $timedelta -= $hours * 60;
                 if ($mins) {
                     $mins = abs($mins);
                 }
                 $mins = sprintf("%02d", $mins);
                 $fieldval = str_ireplace("%m", $mins, $fieldval);
             }
             $content .= $fieldval;
             break;
         case 'createdByAlias':
             $content .= $dayEvent->created_by_alias();
             break;
         case 'createdByUserName':
             $catobj = JEVHelper::getUser($dayEvent->created_by());
             $content .= isset($catobj->username) ? $catobj->username : "";
             break;
         case 'createdByUserEmail':
             // Note that users email address will NOT be available if they don't want to receive email
             $catobj = JEVHelper::getUser($dayEvent->created_by());
             $content .= $catobj->sendEmail ? $catobj->email : '';
             break;
         case 'createdByUserEmailLink':
             // Note that users email address will NOT be available if they don't want to receive email
             $content .= JRoute::_("index.php?option=" . $compname . "&task=" . $task_events . "&agid=" . $dayEvent->id() . "&year=" . $st_year . "&month=" . $st_month . "&day=" . $st_day . "&Itemid=" . $this->myItemid . $this->catout);
             break;
         case 'color':
             $content .= $dayEvent->bgcolor();
             break;
         case 'eventDetailLink':
             $link = $dayEvent->viewDetailLink($st_year, $st_month, $st_day, false, $this->myItemid);
             $link = JRoute::_($link . $this->datamodel->getCatidsOutLink());
             $content .= $link;
             /*
              $content .= JRoute::_("index.php?option="
              . $compname
              . "&task=".$task_events
              . "&agid=".$dayEvent->id()
              . "&year=".$st_year
              . "&month=".$st_month
              . "&day=".$st_day
              . "&Itemid=".$this->myItemid . $this->catout);
             */
             break;
         default:
             try {
                 if (strpos($match, '${') !== false) {
                     $parts = explode('${', $match);
                     $tempstr = "";
                     foreach ($parts as $part) {
                         if (strpos($part, "}") !== false) {
                             // limit to 2 because we may be using joomla content plugins
                             $subparts = explode("}", $part, 2);
                             if (strpos($subparts[0], "#") > 0) {
                                 $formattedparts = explode("#", $subparts[0]);
                                 $subparts[0] = $formattedparts[0];
                             } else {
                                 $formattedparts = array($subparts[0], "%s", "");
                             }
                             $subpart = "_" . $subparts[0];
                             if (isset($dayEvent->{$subpart})) {
                                 $temp = $dayEvent->{$subpart};
                                 if ($temp != "") {
                                     $tempstr .= str_replace("%s", $temp, $formattedparts[1]);
                                 } else {
                                     if (isset($formattedparts[2])) {
                                         $tempstr .= str_replace("%s", $temp, $formattedparts[2]);
                                     }
                                 }
                             } else {
                                 if (isset($dayEvent->customfields[$subparts[0]]['value'])) {
                                     $temp = $dayEvent->customfields[$subparts[0]]['value'];
                                     if ($temp != "") {
                                         $tempstr .= str_replace("%s", $temp, $formattedparts[1]);
                                     } else {
                                         if (isset($formattedparts[2])) {
                                             $tempstr .= str_replace("%s", $temp, $formattedparts[2]);
                                         }
                                     }
                                 } else {
                                     $matchedByPlugin = false;
                                     $layout = "list";
                                     static $fieldNameArrays = array();
                                     $jevplugins = JPluginHelper::getPlugin("jevents");
                                     foreach ($jevplugins as $jevplugin) {
                                         $classname = "plgJevents" . ucfirst($jevplugin->name);
                                         if (is_callable(array($classname, "substitutefield"))) {
                                             if (!isset($fieldNameArrays[$classname])) {
                                                 $fieldNameArrays[$classname] = call_user_func(array($classname, "fieldNameArray"), $layout);
                                             }
                                             if (isset($fieldNameArrays[$classname]["values"])) {
                                                 if (in_array($subparts[0], $fieldNameArrays[$classname]["values"])) {
                                                     $matchedByPlugin = true;
                                                     // is the event detail hidden - if so then hide any custom fields too!
                                                     if (!isset($event->_privateevent) || $event->_privateevent != 3) {
                                                         $temp = call_user_func(array($classname, "substitutefield"), $dayEvent, $subparts[0]);
                                                         if ($temp != "") {
                                                             $tempstr .= str_replace("%s", $temp, $formattedparts[1]);
                                                         } else {
                                                             if (isset($formattedparts[2])) {
                                                                 $tempstr .= str_replace("%s", $temp, $formattedparts[2]);
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                     if (!$matchedByPlugin) {
                                         // Layout editor code
                                         include_once JEV_PATH . "/views/default/helpers/defaultloadedfromtemplate.php";
                                         ob_start();
                                         // false at the end to stop it running through the plugins
                                         $part = "{{Dummy Label:" . implode("#", $formattedparts) . "}}";
                                         DefaultLoadedFromTemplate(false, false, $dayEvent, 0, $part, false);
                                         $newpart = ob_get_clean();
                                         if ($newpart != $part) {
                                             $tempstr .= $newpart;
                                             $matchedByPlugin = true;
                                         }
                                     }
                                     // none of the plugins has replaced the output so we now replace the blank formatted part!
                                     if (!$matchedByPlugin && isset($formattedparts[2])) {
                                         $tempstr .= str_replace("%s", "", $formattedparts[2]);
                                     }
                                     //$dispatcher->trigger( 'onLatestEventsField', array( &$dayEvent, $subparts[0], &$tempstr));
                                 }
                             }
                             $tempstr .= $subparts[1];
                         } else {
                             $tempstr .= $part;
                         }
                     }
                     $content .= $tempstr;
                 } else {
                     if ($match) {
                         $content .= $match;
                     }
                 }
             } catch (Exception $e) {
                 if ($match) {
                     $content .= $match;
                 }
             }
             break;
     }
     // end of switch
 }
コード例 #14
0
ファイル: calendar.php プロジェクト: poorgeek/JEvents
    function _displayCalendarMod($time, $startday, $linkString, &$day_name, $monthMustHaveEvent = false, $basedate = false)
    {
        $db = JFactory::getDBO();
        $cfg = JEVConfig::getInstance();
        $compname = JEV_COM_COMPONENT;
        $cal_day = date("d", $time);
        //$cal_year=date("Y",$time);
        //$cal_month=date("m",$time);
        //list($cal_year,$cal_month,$cal_day) = JEVHelper::getYMD();
        if (!$basedate) {
            $basedate = $time;
        }
        $base_year = date("Y", $basedate);
        $base_month = date("m", $basedate);
        $basefirst_of_month = JevDate::mktime(0, 0, 0, $base_month, 1, $base_year);
        $requestYear = JRequest::getInt("year", 0);
        $requestMonth = JRequest::getInt("month", 0);
        // special case when site link set the dates for the mini-calendar in the URL but not in the ajax request
        if ($requestMonth && $requestYear && JRequest::getString("task", "") != "modcal.ajax" && $this->modparams->get("minical_usedate", 0)) {
            $requestDay = JRequest::getInt("day", 1);
            $requestTime = JevDate::mktime(0, 0, 0, $requestMonth, $requestDay, $requestYear);
            if ($time - $basedate > 100000) {
                $requestTime = JevDate::strtotime("+1 month", $requestTime);
            } else {
                if ($time - $basedate < -100000) {
                    $requestTime = JevDate::strtotime("-1 month", $requestTime);
                }
            }
            $cal_year = date("Y", $requestTime);
            $cal_month = date("m", $requestTime);
            $base_year = $requestYear;
            $base_month = $requestMonth;
            $basefirst_of_month = JevDate::mktime(0, 0, 0, $requestMonth, $requestDay, $requestYear);
        } else {
            $cal_year = date("Y", $time);
            $cal_month = date("m", $time);
        }
        $base_prev_month = $base_month - 1;
        $base_next_month = $base_month + 1;
        $base_next_month_year = $base_year;
        $base_prev_month_year = $base_year;
        if ($base_prev_month == 0) {
            $base_prev_month = 12;
            $base_prev_month_year -= 1;
        }
        if ($base_next_month == 13) {
            $base_next_month = 1;
            $base_next_month_year += 1;
        }
        $reg = JFactory::getConfig();
        $reg->set("jev.modparams", $this->modparams);
        if ($this->modparams->get("showtooltips", 0)) {
            $data = $this->datamodel->getCalendarData($cal_year, $cal_month, 1, false, false);
            $this->hasTooltips = true;
        } else {
            $data = $this->datamodel->getCalendarData($cal_year, $cal_month, 1, true, $this->modparams->get("noeventcheck", 0));
        }
        $reg->set("jev.modparams", false);
        $width = $this->modparams->get("mod_cal_width", "135px");
        $height = $this->modparams->get("mod_cal_height", "auto");
        $rowheight = $this->modparams->get("mod_cal_rowheight", "auto");
        $month_name = JEVHelper::getMonthName($cal_month);
        $to_day = date("Y-m-d", $this->timeWithOffset);
        $today = JevDate::mktime(0, 0, 0, $cal_month, $cal_day, $cal_year);
        $cal_prev_month = $cal_month - 1;
        $cal_next_month = $cal_month + 1;
        $cal_next_month_year = $cal_year;
        $cal_prev_month_year = $cal_year;
        // additional EBS
        if ($cal_prev_month == 0) {
            $cal_prev_month = 12;
            $cal_prev_month_year -= 1;
        }
        if ($cal_next_month == 13) {
            $cal_next_month = 1;
            $cal_next_month_year += 1;
        }
        $viewname = $this->getTheme();
        $viewpath = JURI::root(true) . "/components/{$compname}/views/" . $viewname . "/assets";
        $viewimages = $viewpath . "/images";
        $linkpref = "index.php?option={$compname}&Itemid=" . $this->myItemid . $this->cat . "&task=";
        /*
        $linkprevious = $linkpref."month.calendar&day=$cal_day&month=$cal_prev_month&year=$cal_prev_month_year";
        $linkprevious = JRoute::_($linkprevious);
        $linkprevious = $this->htmlLinkCloaking($linkprevious, '<img border="0" title="' . JText::_("JEV_PREVIOUSMONTH") . '" alt="' . JText::_("JEV_PREVIOUSMONTH") . '" src="'.$viewimages.'/mini_arrowleft.gif"/>' );
        */
        $jev_component_name = JEV_COM_COMPONENT;
        $this->_navigationJS($this->_modid);
        $scriptlinks = "";
        if ($this->minical_prevmonth) {
            $linkprevious = htmlentities(JURI::base() . "index.php?option={$jev_component_name}&task=modcal.ajax&day=1&month={$base_prev_month}&year={$base_prev_month_year}&modid={$this->_modid}&tmpl=component" . $this->cat);
            $scriptlinks .= "linkprevious = '" . $linkprevious . "';\n";
            $linkprevious = '<img border="0" title="' . JText::_("JEV_PREVIOUSMONTH") . '" alt="' . JText::_("JEV_LAST_MONTH") . '" class="mod_events_link" src="' . $viewimages . '/mini_arrowleft.gif" onmousedown="callNavigation(\'' . $linkprevious . '\');" />';
        } else {
            $linkprevious = "";
        }
        if ($this->minical_actmonth == 1) {
            $linkcurrent = $linkpref . "month.calendar&day={$cal_day}&month={$cal_month}&year={$cal_year}";
            $linkcurrent = JRoute::_($linkcurrent);
            $linkcurrent = $this->htmlLinkCloaking($linkcurrent, $month_name . " " . $cal_year, array("style" => "text-decoration:none;color:inherit;"));
        } elseif ($this->minical_actmonth == 2) {
            $linkcurrent = $month_name . " " . $cal_year;
        } else {
            $linkcurrent = "";
        }
        /*
        $linknext = $linkpref."month.calendar&day=$cal_day&month=$cal_next_month&year=$cal_next_month_year";
        $linknext = JRoute::_($linknext);
        $linknext = $this->htmlLinkCloaking($linknext, '<img border="0" title="' . JText::_("JEV_NEXT_MONTH") . '" alt="' . JText::_("JEV_NEXT_MONTH") . '" src="'.$viewimages.'/mini_arrowright.gif"/>' );
        */
        $this->_navigationJS($this->_modid);
        if ($this->minical_nextmonth) {
            $linknext = htmlentities(JURI::base() . "index.php?option={$jev_component_name}&task=modcal.ajax&day=1&month={$base_next_month}&year={$base_next_month_year}&modid={$this->_modid}&tmpl=component" . $this->cat);
            $scriptlinks .= "linknext = '" . $linknext . "';\n";
            $linknext = '<img border="0" title="' . JText::_("JEV_NEXT_MONTH") . '" alt="' . JText::_("JEV_NEXT_MONTH") . '" class="mod_events_link" src="' . $viewimages . '/mini_arrowright.gif" onmousedown="callNavigation(\'' . $linknext . '\');" />';
        } else {
            $linknext = "";
        }
        $content = <<<START
<div id="extcal_minical">
\t<table cellspacing="1" cellpadding="0" style="width:{$width}; text-align:center;border: 1px solid rgb(190, 194, 195); background-color: rgb(255, 255, 255);">
\t\t<tr>
\t\t\t<td style="vertical-align: top;">
START;
        if ($this->minical_showlink) {
            $content .= <<<START

\t\t\t\t<table style="width:{$width};" cellspacing="0" cellpadding="2" border="0" class="extcal_navbar">
\t\t\t\t\t<tr>
\t\t\t\t\t\t<td valign="middle" height="18" align="center">
\t\t\t\t\t\t\t{$linkprevious}
                \t\t</td>
\t\t                <td width="98%" valign="middle" nowrap="nowrap" height="18" align="center" class="extcal_month_label">
\t\t\t\t\t\t\t{$linkcurrent}
\t\t                </td>
\t\t\t\t\t\t<td valign="middle" height="18" align="center" style="margin: 0 auto; min-width: 4px;">
\t\t                    {$linknext}
                \t\t</td>
\t\t\t\t\t</tr>
\t\t\t\t</table>
START;
        }
        $content .= <<<START
\t\t\t\t<table style="width:{$width};height:{$height}; " class="extcal_weekdays">
START;
        $lf = "\n";
        // Days name rows - with blank week no.
        $content .= "<tr>\n<td/>\n";
        for ($i = 0; $i < 7; $i++) {
            $content .= "<td  class='extcal_weekdays'>" . $day_name[($i + $startday) % 7] . "</td>" . $lf;
        }
        $content .= "</tr>\n";
        $datacount = count($data["dates"]);
        $dn = 0;
        for ($w = 0; $w < 6 && $dn < $datacount; $w++) {
            $content .= "<tr style='height:{$rowheight};'>\n";
            // the week column
            list($week, $link) = each($data['weeks']);
            $content .= '<td class="extcal_weekcell">';
            $content .= $this->htmlLinkCloaking($link, "<img width='5' height='20' border='0' alt='week " . $week . "' src='" . $viewimages . "/icon-mini-week.gif'/>");
            $content .= "</td>\n";
            for ($d = 0; $d < 7 && $dn < $datacount; $d++) {
                $currentDay = $data["dates"][$dn];
                switch ($currentDay["monthType"]) {
                    case "prior":
                    case "following":
                        $content .= "<td class='extcal_othermonth'/>\n";
                        break;
                    case "current":
                        $dayOfWeek = JevDate::strftime("%w", $currentDay["cellDate"]);
                        $class = $currentDay["today"] ? "extcal_todaycell" : "extcal_daycell";
                        $linkclass = "extcal_daylink";
                        if ($dayOfWeek == 0 && !$currentDay["today"]) {
                            $class = "extcal_sundaycell";
                            $linkclass = "extcal_sundaylink";
                        }
                        if ($currentDay["events"] || $this->modparams->get("noeventcheck", 0)) {
                            $linkclass = "extcal_busylink";
                        }
                        $content .= "<td class='" . $class . "'>\n";
                        $tooltip = $this->getTooltip($currentDay, array('class' => $linkclass));
                        if ($tooltip) {
                            $content .= $tooltip;
                        } else {
                            if ($this->modparams->get("emptydaylinks", 1) || $currentDay["events"] || $this->modparams->get("noeventcheck", 0)) {
                                $content .= $this->htmlLinkCloaking($currentDay["link"], $currentDay['d'], array('class' => $linkclass, 'title' => JText::_('JEV_CLICK_TOSWITCH_DAY')));
                            } else {
                                $content .= $currentDay['d'];
                            }
                        }
                        $content .= "</td>\n";
                        break;
                }
                $dn++;
            }
            $content .= "</tr>\n";
        }
        $content .= "</table>\n";
        $content .= "</td></tr></table></div>\n";
        if ($scriptlinks != "") {
            $content .= "<script style='text/javascript'>xyz=1;" . $scriptlinks . "zyx=1;</script>";
        }
        // Now check to see if this month needs to have at least 1 event in order to display
        //			if (!$monthMustHaveEvent || $monthHasEvent) return $content;
        //			else return '';
        return $content;
    }
コード例 #15
0
ファイル: datamodel.php プロジェクト: hriggs/cs-website
 function getAdjacentDay($year, $month, $day, $direction = 1)
 {
     $d1 = JevDate::mktime(0, 0, 0, $month, $day + $direction, $year);
     $day = JevDate::strftime("%d", $d1);
     $year = JevDate::strftime("%Y", $d1);
     $cfg = JEVConfig::getInstance();
     $earliestyear = JEVHelper::getMinYear();
     $latestyear = JEVHelper::getMaxYear();
     if ($year > $latestyear || $year < $earliestyear) {
         return false;
     }
     $month = JevDate::strftime("%m", $d1);
     $task = JRequest::getString('jevtask');
     $Itemid = JEVHelper::getItemid();
     if (isset($Itemid)) {
         $item = "&Itemid={$Itemid}";
     } else {
         $item = "";
     }
     // URL suffix to preserver catids!
     $cat = $this->getCatidsOutLink();
     return JRoute::_("index.php?option=" . JEV_COM_COMPONENT . "&task={$task}{$item}&year={$year}&month={$month}&day={$day}" . $cat);
 }
コード例 #16
0
ファイル: helper.php プロジェクト: madseller/coperio
 /**
  * Function that overwrites meta-tags in mainframe!!
  *
  * @static
  * @param string $name - metatag name
  * @param string $content - metatag value
  */
 function checkRobotsMetaTag($name = "robots", $content = "noindex, nofollow")
 {
     // force robots metatag
     $cfg =& JEVConfig::getInstance();
     if ($cfg->get('com_blockRobots', 0) >= 1) {
         $document =& JFactory::getDocument();
         // Allow on content pages
         if ($cfg->get('com_blockRobots', 0) == 3) {
             if (strpos(JRequest::getString("jevtask", ""), ".detail") > 0) {
                 $document->setMetaData($name, "nofollow");
                 return;
             }
             $document->setMetaData($name, $content);
             return;
         }
         if ($cfg->get('com_blockRobots', 0) == 1) {
             $document->setMetaData($name, $content);
             return;
         }
         list($cyear, $cmonth, $cday) = JEVHelper::getYMD();
         $cdate = JevDate::mktime(0, 0, 0, $cmonth, $cday, $cyear);
         $prior = JevDate::strtotime($cfg->get('robotprior', "-1 day"));
         if ($cdate < $prior) {
             $document->setMetaData($name, $content);
             return;
         }
         $post = JevDate::strtotime($cfg->get('robotpost', "-1 day"));
         if ($cdate > $post) {
             $document->setMetaData($name, $content);
             return;
         }
     }
 }
コード例 #17
0
 protected function processMatch(&$content, $match, $dayEvent, $dateParm, $relDay)
 {
     $datenow = JEVHelper::getNow();
     $dispatcher =& JDispatcher::getInstance();
     // get the title and start time
     $startDate = JevDate::strtotime($dayEvent->publish_up());
     if ($relDay > 0) {
         $eventDate = JevDate::strtotime($datenow->toFormat('%Y-%m-%d ') . JevDate::strftime('%H:%M', $startDate) . " +{$relDay} days");
     } else {
         $eventDate = JevDate::strtotime($datenow->toFormat('%Y-%m-%d ') . JevDate::strftime('%H:%M', $startDate) . " {$relDay} days");
     }
     $endDate = JevDate::strtotime($dayEvent->publish_down());
     list($st_year, $st_month, $st_day) = explode('-', JevDate::strftime('%Y-%m-%d', $startDate));
     list($ev_year, $ev_month, $ev_day) = explode('-', JevDate::strftime('%Y-%m-%d', $startDate));
     $task_events = 'icalrepeat.detail';
     switch ($match) {
         case 'endDate':
         case 'startDate':
         case 'eventDate':
             // Note we need to examine the date specifiers used to determine if language translation will be
             // necessary.  Do this later when script is debugged.
             if (!$this->disableDateStyle) {
                 $content .= '<span class="mod_events_latest_date">';
             }
             if (!$dayEvent->alldayevent() && $match == "endDate" && ($dayEvent->noendtime() || $dayEvent->getUnixStartTime() == $dayEvent->getUnixEndTime())) {
                 $time_fmt = "";
             } else {
                 if (!isset($dateParm) || $dateParm == '') {
                     if ($this->com_calUseStdTime) {
                         $time_fmt = $dayEvent->alldayevent() ? '' : ' @%l:%M%p';
                     } else {
                         $time_fmt = $dayEvent->alldayevent() ? '' : ' @%H:%M';
                     }
                     $dateFormat = $this->displayYear ? '%a %b %d, %Y' . $time_fmt : '<span class="eventDay">%a</span>  <span class="eventDate">%d<span class="eventMonth">%b</span></span>';
                     $jmatch = new JevDate(${$match});
                     $content .= $jmatch->toFormat($dateFormat);
                     //$content .= JEV_CommonFunctions::jev_strftime($dateFormat, $$match);
                 } else {
                     // format endDate when midnight to show midnight!
                     if ($match == "endDate" && $dayEvent->sdn() == 59) {
                         $tempEndDate = $endDate + 1;
                         if ($dayEvent->alldayevent()) {
                             // if an all day event then we don't want to roll to the next day
                             $tempEndDate -= 86400;
                         }
                         $match = "tempEndDate";
                     }
                     // if a '%' sign detected in date format string, we assume JevDate::strftime() is to be used,
                     if (preg_match("/\\%/", $dateParm)) {
                         $jmatch = new JevDate(${$match});
                         $content .= $jmatch->toFormat($dateParm);
                     } else {
                         $content .= date($dateParm, ${$match});
                     }
                     if ($match == "tempDndDate") {
                         $match = "endDate";
                     }
                 }
             }
             if (!$this->disableDateStyle) {
                 $content .= "</span>";
             }
             break;
         case 'title':
             $title = $dayEvent->title();
             if (!empty($dateParm)) {
                 $parts = explode("|", $dateParm);
                 if (count($parts) > 0 && strlen($title) > intval($parts[0])) {
                     $title = substr($title, 0, intval($parts[0]));
                     if (count($parts) > 1) {
                         $title .= $parts[1];
                     }
                 }
             }
             if (!$this->disableTitleStyle) {
                 $content .= '<span class="mod_events_latest_content">';
             }
             if ($this->displayLinks) {
                 $link = $dayEvent->viewDetailLink($ev_year, $ev_month, $ev_day, false, $this->myItemid);
                 $link = JRoute::_($link . $this->datamodel->getCatidsOutLink());
                 $content .= $this->_htmlLinkCloaking($link, JEventsHTML::special($title));
             } else {
                 $content .= JEventsHTML::special($title);
             }
             if (!$this->disableTitleStyle) {
                 $content .= '</span>';
             }
             break;
         case 'category':
             $catobj = $dayEvent->getCategoryName();
             $content .= JEventsHTML::special($catobj);
             break;
         case 'calendar':
             $catobj = $dayEvent->getCalendarName();
             $content .= JEventsHTML::special($catobj);
             break;
         case 'contact':
             // Also want to cloak contact details so
             $this->modparams->set("image", 1);
             $dayEvent->text = $dayEvent->contact_info();
             if (JVersion::isCompatible("1.6.0")) {
                 $dispatcher->trigger('onContentPrepare', array('com_jevents', &$dayEvent, &$this->modparams, 0));
             } else {
                 $dispatcher->trigger('onPrepareContent', array(&$dayEvent, &$this->modparams, 0), true);
             }
             $dayEvent->contact_info($dayEvent->text);
             $content .= $dayEvent->contact_info();
             break;
         case 'content':
             // Added by Kaz McCoy 1-10-2004
             $this->modparams->set("image", 1);
             $dayEvent->data->text = $dayEvent->content();
             if (JVersion::isCompatible("1.6.0")) {
                 $dispatcher->trigger('onContentPrepare', array('com_jevents', &$dayEvent->data, &$this->modparams, 0));
             } else {
                 $results = $dispatcher->trigger('onPrepareContent', array(&$dayEvent->data, &$this->modparams, 0), true);
             }
             if (!empty($dateParm)) {
                 $parts = explode("|", $dateParm);
                 if (count($parts) > 0 && strlen(strip_tags($dayEvent->data->text)) > intval($parts[0])) {
                     $dayEvent->data->text = substr(strip_tags($dayEvent->data->text), 0, intval($parts[0]));
                     if (count($parts) > 1) {
                         $dayEvent->data->text .= $parts[1];
                     }
                 }
             }
             $dayEvent->content($dayEvent->data->text);
             //$content .= substr($dayEvent->content, 0, 150);
             $content .= $dayEvent->content();
             break;
         case 'addressInfo':
         case 'location':
             $this->modparams->set("image", 0);
             $dayEvent->data->text = $dayEvent->location();
             if (JVersion::isCompatible("1.6.0")) {
                 $dispatcher->trigger('onContentPrepare', array('com_jevents', &$dayEvent->data, &$this->modparams, 0));
             } else {
                 $results = $dispatcher->trigger('onPrepareContent', array(&$dayEvent->data, &$this->modparams, 0), true);
             }
             $dayEvent->location($dayEvent->data->text);
             $content .= $dayEvent->location();
             break;
         case 'extraInfo':
             $this->modparams->set("image", 0);
             $dayEvent->data->text = $dayEvent->extra_info();
             if (JVersion::isCompatible("1.6.0")) {
                 $dispatcher->trigger('onContentPrepare', array('com_jevents', &$dayEvent->data, &$this->modparams, 0));
             } else {
                 $results = $dispatcher->trigger('onPrepareContent', array(&$dayEvent->data, &$this->modparams, 0), true);
             }
             $dayEvent->extra_info($dayEvent->data->text);
             $content .= $dayEvent->extra_info();
             break;
         case 'countdown':
             $timedelta = $dayEvent->getUnixStartTime() - JevDate::mktime();
             $fieldval = $dateParm;
             $shownsign = false;
             if (stripos($fieldval, "%d") !== false) {
                 $days = intval($timedelta / (60 * 60 * 24));
                 $timedelta -= $days * 60 * 60 * 24;
                 $fieldval = str_ireplace("%d", $days, $fieldval);
                 $shownsign = true;
             }
             if (stripos($fieldval, "%h") !== false) {
                 $hours = intval($timedelta / (60 * 60));
                 $timedelta -= $hours * 60 * 60;
                 if ($shownsign) {
                     $hours = abs($hours);
                 }
                 $hours = sprintf("%02d", $hours);
                 $fieldval = str_ireplace("%h", $hours, $fieldval);
                 $shownsign = true;
             }
             if (stripos($fieldval, "%m") !== false) {
                 $mins = intval($timedelta / 60);
                 $timedelta -= $hours * 60;
                 if ($mins) {
                     $mins = abs($mins);
                 }
                 $mins = sprintf("%02d", $mins);
                 $fieldval = str_ireplace("%m", $mins, $fieldval);
             }
             $content .= $fieldval;
             break;
         case 'createdByAlias':
             $content .= $dayEvent->created_by_alias();
             break;
         case 'createdByUserName':
             $catobj = JEVHelper::getUser($dayEvent->created_by());
             $content .= isset($catobj->username) ? $catobj->username : "";
             break;
         case 'createdByUserEmail':
             // Note that users email address will NOT be available if they don't want to receive email
             $catobj = JEVHelper::getUser($dayEvent->created_by());
             $content .= $catobj->sendEmail ? $catobj->email : '';
             break;
         case 'createdByUserEmailLink':
             // Note that users email address will NOT be available if they don't want to receive email
             $content .= JRoute::_("index.php?option=" . $compname . "&task=" . $task_events . "&agid=" . $dayEvent->id() . "&year=" . $st_year . "&month=" . $st_month . "&day=" . $st_day . "&Itemid=" . $this->myItemid . $this->catout);
             break;
         case 'color':
             $content .= $dayEvent->bgcolor();
             break;
         case 'eventDetailLink':
             $link = $dayEvent->viewDetailLink($st_year, $st_month, $st_day, false, $this->myItemid);
             $link = JRoute::_($link . $this->datamodel->getCatidsOutLink());
             $content .= $link;
             /*
              $content .= JRoute::_("index.php?option="
              . $compname
              . "&task=".$task_events
              . "&agid=".$dayEvent->id()
              . "&year=".$st_year
              . "&month=".$st_month
              . "&day=".$st_day
              . "&Itemid=".$this->myItemid . $this->catout);
             */
             break;
         default:
             try {
                 if (strpos($match, '${') !== false) {
                     $parts = explode('${', $match);
                     $tempstr = "";
                     foreach ($parts as $part) {
                         if (strpos($part, "}") !== false) {
                             $subparts = explode("}", $part);
                             //$part = str_replace("}","",$part);
                             $subpart = "_" . $subparts[0];
                             if (isset($dayEvent->{$subpart})) {
                                 $temp = $dayEvent->{$subpart};
                                 $tempstr .= $temp;
                             } else {
                                 if (isset($dayEvent->customfields[$subparts[0]]['value'])) {
                                     $temp = $dayEvent->customfields[$subparts[0]]['value'];
                                     $tempstr .= $temp;
                                 } else {
                                     $layout = "list";
                                     $jevplugins = JPluginHelper::getPlugin("jevents");
                                     foreach ($jevplugins as $jevplugin) {
                                         $classname = "plgJevents" . ucfirst($jevplugin->name);
                                         if (is_callable(array($classname, "substitutefield"))) {
                                             $fieldNameArray = call_user_func(array($classname, "fieldNameArray"), $layout);
                                             if (isset($fieldNameArray["values"])) {
                                                 if (in_array($subparts[0], $fieldNameArray["values"])) {
                                                     // is the event detail hidden - if so then hide any custom fields too!
                                                     if (!isset($event->_privateevent) || $event->_privateevent != 3) {
                                                         $tempstr .= call_user_func(array($classname, "substitutefield"), $dayEvent, $subparts[0]);
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                     //$dispatcher->trigger( 'onLatestEventsField', array( &$dayEvent, $subparts[0], &$tempstr));
                                 }
                             }
                             $tempstr .= $subparts[1];
                         } else {
                             $tempstr .= $part;
                         }
                     }
                     $content .= $tempstr;
                 } else {
                     if ($match) {
                         $content .= $match;
                     }
                 }
             } catch (Exception $e) {
                 if ($match) {
                     $content .= $match;
                 }
             }
             break;
     }
     // end of switch
 }
コード例 #18
0
function DefaultLoadedFromTemplate($view, $template_name, $event, $mask, $template_value = false, $runplugins = true)
{
    $db = JFactory::getDBO();
    // find published template
    static $templates;
    static $fieldNameArray;
    if (!isset($templates)) {
        $templates = array();
        $fieldNameArray = array();
        $rawtemplates = array();
    }
    $specialmodules = false;
    static $allcat_catids;
    $loadedFromFile = false;
    if (!$template_value) {
        if (!array_key_exists($template_name, $templates)) {
            $db->setQuery("SELECT * FROM #__jev_defaults WHERE state=1 AND name= " . $db->Quote($template_name) . " AND " . 'language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
            $rawtemplates = $db->loadObjectList();
            $templates[$template_name] = array();
            if ($rawtemplates) {
                foreach ($rawtemplates as $rt) {
                    if (!isset($templates[$template_name][$rt->language])) {
                        $templates[$template_name][$rt->language] = array();
                    }
                    $templates[$template_name][$rt->language][$rt->catid] = $rt;
                }
            }
            if (!isset($templates[$template_name]['*'][0])) {
                try {
                    $viewname = $view->getViewName();
                } catch (Exception $e) {
                    $viewname = "default";
                }
                $templatefile = JPATH_BASE . '/' . 'templates' . '/' . JFactory::getApplication()->getTemplate() . '/' . 'html' . '/' . JEV_COM_COMPONENT . "/{$viewname}/defaults/{$template_name}.html";
                if (!JFile::exists($templatefile)) {
                    $templatefile = JPATH_BASE . '/' . 'templates' . '/' . JFactory::getApplication()->getTemplate() . '/' . 'html' . '/' . JEV_COM_COMPONENT . "/defaults/{$template_name}.html";
                }
                if (!JFile::exists($templatefile)) {
                    $templatefile = JEV_VIEWS . "/{$viewname}/defaults/{$template_name}.html";
                }
                if (!JFile::exists($templatefile)) {
                    $templatefile = JEV_ADMINPATH . "views/defaults/tmpl/{$template_name}.html";
                }
                // Fall back to html version
                if (JFile::exists($templatefile)) {
                    $loadedFromFile = true;
                    $templates[$template_name]['*'] = array();
                    $templates[$template_name]['*'][0] = new stdClass();
                    $templates[$template_name]['*'][0]->value = file_get_contents($templatefile);
                    $templates[$template_name]['*'][0]->params = null;
                    $templates[$template_name]['*'][0]->fromfile = true;
                } else {
                    return false;
                }
            }
            if (isset($templates[$template_name][JFactory::getLanguage()->getTag()])) {
                $templateArray = $templates[$template_name][JFactory::getLanguage()->getTag()];
                // We have the most specific by language now fill in the gaps
                if (isset($templates[$template_name]["*"])) {
                    foreach ($templates[$template_name]["*"] as $cat => $cattemplates) {
                        if (!isset($templateArray[$cat])) {
                            $templateArray[$cat] = $cattemplates;
                        }
                    }
                }
                $templates[$template_name] = $templateArray;
            } else {
                if (isset($templates[$template_name]["*"])) {
                    $templates[$template_name] = $templates[$template_name]["*"];
                } else {
                    if (is_array($templates[$template_name]) && count($templates[$template_name]) == 0) {
                        $templates[$template_name] = null;
                    } else {
                        if (is_array($templates[$template_name]) && count($templates[$template_name]) > 0) {
                            $templates[$template_name] = current($templates[$template_name]);
                        } else {
                            $templates[$template_name] = null;
                        }
                    }
                }
            }
            $matched = false;
            foreach (array_keys($templates[$template_name]) as $catid) {
                if ($templates[$template_name][$catid]->value != "") {
                    if (isset($templates[$template_name][$catid]->params)) {
                        $templates[$template_name][$catid]->params = new JRegistry($templates[$template_name][$catid]->params);
                        $specialmodules = $templates[$template_name][$catid]->params;
                    }
                    // Adjust template_value to include dynamic module output then strip it out afterwards
                    if ($specialmodules) {
                        $modids = $specialmodules->get("modid", array());
                        if (count($modids) > 0) {
                            $modvals = $specialmodules->get("modval", array());
                            // not sure how this can arise :(
                            if (is_object($modvals)) {
                                $modvals = get_object_vars($modvals);
                            }
                            $modids = array_values($modids);
                            $modvals = array_values($modvals);
                            for ($count = 0; $count < count($modids) && $count < count($modvals) && trim($modids[$count]) != ""; $count++) {
                                $templates[$template_name][$catid]->value .= "{{module start:MODULESTART#" . $modids[$count] . "}}";
                                // cleaned later!
                                //$templates[$template_name][$catid]->value .= preg_replace_callback('|{{.*?}}|', 'cleanLabels', $modvals[$count]);
                                $templates[$template_name][$catid]->value .= $modvals[$count];
                                $templates[$template_name][$catid]->value .= "{{module end:MODULEEND}}";
                            }
                        }
                    }
                    // strip carriage returns other wise the preg replace doesn;y work - needed because wysiwyg editor may add the carriage return in the template field
                    $templates[$template_name][$catid]->value = str_replace("\r", '', $templates[$template_name][$catid]->value);
                    $templates[$template_name][$catid]->value = str_replace("\n", '', $templates[$template_name][$catid]->value);
                    // non greedy replacement - because of the ?
                    $templates[$template_name][$catid]->value = preg_replace_callback('|{{.*?}}|', 'cleanLabels', $templates[$template_name][$catid]->value);
                    $matchesarray = array();
                    preg_match_all('|{{.*?}}|', $templates[$template_name][$catid]->value, $matchesarray);
                    $templates[$template_name][$catid]->matchesarray = $matchesarray;
                }
            }
        }
        if (is_null($templates[$template_name])) {
            return false;
        }
        $catids = $event->catids() && count($event->catids()) ? $event->catids() : array($event->catid());
        $catids[] = 0;
        // find the overlap
        $catids = array_intersect($catids, array_keys($templates[$template_name]));
        // At present must be an EXACT category match - no inheriting allowed!
        if (count($catids) == 0) {
            if (!isset($templates[$template_name][0]) || $templates[$template_name][0]->value == "") {
                return false;
            }
        }
        $template = false;
        foreach ($catids as $catid) {
            // use the first matching non-empty layout
            if ($templates[$template_name][$catid]->value != "") {
                $template = $templates[$template_name][$catid];
                break;
            }
        }
        if (!$template) {
            return false;
        }
        $template_value = $template->value;
        $specialmodules = $template->params;
        $matchesarray = $template->matchesarray;
        $loadedFromFile = isset($template->fromfile);
    } else {
        if ($runplugins && JRequest::getString("option") != "com_jevents") {
            // This is a special scenario where we call this function externally e.g. from RSVP Pro messages
            // In this scenario we have not gone through the displaycustomfields plugin
            static $pluginscalled = array();
            if (!isset($pluginscalled[$event->rp_id()])) {
                $dispatcher = JEventDispatcher::getInstance();
                JPluginHelper::importPlugin("jevents");
                $customresults = $dispatcher->trigger('onDisplayCustomFields', array(&$event));
                $pluginscalled[$event->rp_id()] = $event;
            } else {
                $event = $pluginscalled[$event->rp_id()];
            }
        }
        // Adjust template_value to include dynamic module output then strip it out afterwards
        if ($specialmodules) {
            $modids = $specialmodules->get("modid", array());
            if (count($modids) > 0) {
                $modvals = $specialmodules->get("modval", array());
                // not sure how this can arise :(
                if (is_object($modvals)) {
                    $modvals = get_object_vars($modvals);
                }
                $modids = array_values($modids);
                $modvals = array_values($modvals);
                for ($count = 0; $count < count($modids) && $count < count($modvals) && trim($modids[$count]) != ""; $count++) {
                    $template_value .= "{{module start:MODULESTART#" . $modids[$count] . "}}";
                    // cleaned later!
                    //$template_value .= preg_replace_callback('|{{.*?}}|', 'cleanLabels', $modvals[$count]);
                    $template_value .= $modvals[$count];
                    $template_value .= "{{module end:MODULEEND}}";
                }
            }
        }
        // strip carriage returns other wise the preg replace doesn;y work - needed because wysiwyg editor may add the carriage return in the template field
        $template_value = str_replace("\r", '', $template_value);
        $template_value = str_replace("\n", '', $template_value);
        // non greedy replacement - because of the ?
        $template_value = preg_replace_callback('|{{.*?}}|', 'cleanLabels', $template_value);
        $matchesarray = array();
        preg_match_all('|{{.*?}}|', $template_value, $matchesarray);
    }
    if ($template_value == "") {
        return;
    }
    if (count($matchesarray) == 0) {
        return;
    }
    // now replace the fields
    $search = array();
    $replace = array();
    $blank = array();
    $rawreplace = array();
    $jevparams = JComponentHelper::getParams(JEV_COM_COMPONENT);
    for ($i = 0; $i < count($matchesarray[0]); $i++) {
        $strippedmatch = preg_replace('/(#|:|;)+[^}]*/', '', $matchesarray[0][$i]);
        if (in_array($strippedmatch, $search)) {
            continue;
        }
        // translation string
        if (JString::strpos($strippedmatch, "{{_") === 0 && JString::strpos($strippedmatch, " ") === false) {
            $search[] = $strippedmatch;
            $strippedmatch = JString::substr($strippedmatch, 3, JString::strlen($strippedmatch) - 5);
            $replace[] = JText::_($strippedmatch);
            $blank[] = "";
            continue;
        }
        // Built in fields
        switch ($strippedmatch) {
            case "{{TITLE}}":
                $search[] = "{{TITLE}}";
                $replace[] = $event->title();
                $blank[] = "";
                break;
            case "{{TRUNCATED_TITLE}}":
                $search[] = "{{TRUNCATED_TITLE:.*?}}";
                $replace[] = $event->title();
                $blank[] = "";
                break;
            case "{{PRIORITY}}":
                $search[] = "{{PRIORITY}}";
                $replace[] = $event->priority();
                $blank[] = "";
                break;
            case "{{LINK}}":
            case "{{LINKSTART}}":
            case "{{LINKEND}}":
            case "{{TITLE_LINK}}":
                // no need to repeat this for each of the matching 'case's
                if (!in_array("{{LINK}}", $search)) {
                    // Title link
                    $rowlink = $event->viewDetailLink($event->yup(), $event->mup(), $event->dup(), false);
                    if ($view) {
                        $rowlink = JRoute::_($rowlink . $view->datamodel->getCatidsOutLink());
                    }
                    ob_start();
                    ?>
						<a class="ev_link_row" href="<?php 
                    echo $rowlink;
                    ?>
" title="<?php 
                    echo JEventsHTML::special($event->title());
                    ?>
">
						<?php 
                    $linkstart = ob_get_clean();
                    $search[] = "{{LINK}}";
                    $replace[] = $rowlink;
                    $blank[] = "";
                    $search[] = "{{LINKSTART}}";
                    $replace[] = $linkstart;
                    $blank[] = "";
                    $search[] = "{{LINKEND}}";
                    $replace[] = "</a>";
                    $blank[] = "";
                    $fulllink = $linkstart . $event->title() . '</a>';
                    $search[] = "{{TITLE_LINK}}";
                    $replace[] = $fulllink;
                    $blank[] = "";
                }
                break;
            case "{{TRUNCTITLE}}":
                // for month calendar cell only
                if (isset($event->truncatedtitle)) {
                    $search[] = "{{TRUNCTITLE}}";
                    $replace[] = $event->truncatedtitle;
                    $blank[] = "";
                } else {
                    $search[] = "{{TRUNCTITLE}}";
                    $replace[] = $event->title();
                    $blank[] = "";
                }
                break;
            case "{{URL}}":
                $search[] = "{{URL}}";
                $replace[] = $event->url();
                $blank[] = "";
                break;
            case "{{TRUNCATED_DESC}}":
                $search[] = "{{TRUNCATED_DESC:.*?}}";
                $replace[] = $event->content();
                $blank[] = "";
                //	$search[]="|{{TRUNCATED_DESC:(.*)}}|";$replace[]=$event->content();
                break;
            case "{{DESCRIPTION}}":
                $search[] = "{{DESCRIPTION}}";
                $replace[] = $event->content();
                $blank[] = "";
                break;
            case "{{MANAGEMENT}}":
                $search[] = "{{MANAGEMENT}}";
                if ($view) {
                    ob_start();
                    $view->_viewNavAdminPanel();
                    $replace[] = ob_get_clean();
                } else {
                    $replace[] = "";
                }
                $blank[] = "";
                break;
            case "{{CATEGORY}}":
                $search[] = "{{CATEGORY}}";
                $replace[] = $event->catname();
                $blank[] = "";
                break;
            case "{{ALLCATEGORIES}}":
                $search[] = "{{ALLCATEGORIES}}";
                if (!isset($allcat_catids)) {
                    $db = JFactory::getDBO();
                    $arr_catids = array();
                    $catsql = "SELECT cat.id, cat.title as name FROM #__categories  as cat WHERE cat.extension='com_jevents' ";
                    $db->setQuery($catsql);
                    $allcat_catids = $db->loadObjectList('id');
                }
                $db = JFactory::getDbo();
                $db->setQuery("Select catid from #__jevents_catmap  WHERE evid = " . $event->ev_id());
                $allcat_eventcats = $db->loadColumn();
                $allcats = array();
                foreach ($allcat_eventcats as $catid) {
                    if (isset($allcat_catids[$catid])) {
                        $allcats[] = $allcat_catids[$catid]->name;
                    }
                }
                $replace[] = implode(", ", $allcats);
                $blank[] = "";
                break;
            case "{{CALENDAR}}":
                $search[] = "{{CALENDAR}}";
                $replace[] = $event->getCalendarName();
                $blank[] = "";
                break;
            case "{{COLOUR}}":
            case "{{colour}}":
                $bgcolor = $event->bgcolor();
                $search[] = $strippedmatch;
                $replace[] = $bgcolor == "" ? "#ffffff" : $bgcolor;
                $blank[] = "";
                break;
            case "{{FGCOLOUR}}":
                $search[] = "{{FGCOLOUR}}";
                $replace[] = $event->fgcolor();
                $blank[] = "";
                break;
            case "{{TTTIME}}":
                $search[] = "{{TTTIME}}";
                $replace[] = "[[TTTIME]]";
                $blank[] = "";
                break;
            case "{{EVTTIME}}":
                $search[] = "{{EVTTIME}}";
                $replace[] = "[[EVTTIME]]";
                $blank[] = "";
                break;
                // deprecated
            // deprecated
            case "{{TOOLTIP}}":
                $search[] = "{{TOOLTIP}}";
                $replace[] = "[[TOOLTIP]]";
                $blank[] = "";
                break;
                // new version for bootstrap
            // new version for bootstrap
            case "{{TOOLTIPTITLE}}":
                $search[] = "{{TOOLTIPTITLE}}";
                $replace[] = "[[TOOLTIPTITLE]]";
                $blank[] = "";
                break;
            case "{{TOOLTIPCONTENT}}":
                $search[] = "{{TOOLTIPCONTENT}}";
                $replace[] = "[[TOOLTIPCONTENT]]";
                $blank[] = "";
                break;
            case "{{CATEGORYLNK}}":
                $router = JRouter::getInstance("site");
                $catlinks = array();
                if ($jevparams->get("multicategory", 0)) {
                    $catids = $event->catids();
                    $catdata = $event->getCategoryData();
                } else {
                    $catids = array($event->catid());
                    $catdata = array($event->getCategoryData());
                }
                $vars = $router->getVars();
                foreach ($catids as $cat) {
                    $vars["catids"] = $cat;
                    $catname = "xxx";
                    foreach ($catdata as $cg) {
                        if ($cat == $cg->id) {
                            $catname = $cg->name;
                            break;
                        }
                    }
                    $eventlink = "index.php?";
                    foreach ($vars as $key => $val) {
                        // this is only used in the latest events module so do not perpetuate it here
                        if ($key == "filter_reset") {
                            continue;
                        }
                        if ($key == "task" && ($val == "icalrepeat.detail" || $val == "icalevent.detail")) {
                            $val = "week.listevents";
                        }
                        $eventlink .= $key . "=" . $val . "&";
                    }
                    $eventlink = JString::substr($eventlink, 0, JString::strlen($eventlink) - 1);
                    $eventlink = JRoute::_($eventlink);
                    $catlinks[] = '<a class="ev_link_cat" href="' . $eventlink . '"  title="' . JEventsHTML::special($catname) . '">' . $catname . '</a>';
                }
                $search[] = "{{CATEGORYLNK}}";
                $replace[] = implode(", ", $catlinks);
                $blank[] = "";
                break;
            case "{{CATEGORYIMG}}":
                $search[] = "{{CATEGORYIMG}}";
                $replace[] = $event->getCategoryImage();
                $blank[] = "";
                break;
            case "{{CATEGORYIMGS}}":
                $search[] = "{{CATEGORYIMGS}}";
                $replace[] = $event->getCategoryImage(true);
                $blank[] = "";
                break;
            case "{{ALLCATEGORYIMGS}}":
                $search[] = "{{ALLCATEGORYIMGS}}";
                if (!isset($allcat_catids)) {
                    $db = JFactory::getDBO();
                    $arr_catids = array();
                    $catsql = "SELECT cat.id, cat.title as name FROM #__categories  as cat WHERE cat.extension='com_jevents' ";
                    $db->setQuery($catsql);
                    $allcat_catids = $db->loadObjectList('id');
                }
                $db = JFactory::getDbo();
                $db->setQuery("Select params from #__jevents_catmap  WHERE evid = " . $event->ev_id());
                $data = $db->loadColumn();
                $output = "";
                if (is_array($data)) {
                    foreach ($data as $cat) {
                        $params = json_decode($cat->params);
                        if (isset($params->image) && $params->image != "") {
                            $output .= "<img src = '" . JURI::root() . $params->image . "' class='catimage'  alt='categoryimage' />";
                        }
                    }
                }
                $replace[] = $output;
                $blank[] = "";
                break;
            case "{{CATDESC}}":
                $search[] = "{{CATDESC}}";
                $replace[] = $event->getCategoryDescription();
                $blank[] = "";
                break;
            case "{{CATID}}":
                $search[] = "{{CATID}}";
                $replace[] = $event->catid();
                $blank[] = "";
                break;
            case "{{PARENT_CATEGORY}}":
                $search[] = "{{PARENT_CATEGORY}}";
                $replace[] = $event->getParentCategory();
                $blank[] = "";
                break;
            case "{{ICALDIALOG}}":
            case "{{ICALBUTTON}}":
            case "{{EDITDIALOG}}":
            case "{{EDITBUTTON}}":
                // no need to repeat this for each of the matching 'case's
                if (!in_array("{{EDITBUTTON}}", $search)) {
                    if ($jevparams->get("showicalicon", 0) && !$jevparams->get("disableicalexport", 0)) {
                        $cssloaded = true;
                        ob_start();
                        $view->eventIcalButton($event);
                        ?>
							<div class="jevdialogs" style="position:relative;">
							<?php 
                        $search[] = "{{ICALDIALOG}}";
                        if ($view) {
                            ob_start();
                            $view->eventIcalDialog($event, $mask, true);
                            $dialog = ob_get_clean();
                            $replace[] = $dialog;
                        } else {
                            $replace[] = "";
                        }
                        $blank[] = "";
                        echo $dialog;
                        ?>
							</div>

							<?php 
                        $search[] = "{{ICALBUTTON}}";
                        $replace[] = ob_get_clean();
                        $blank[] = "";
                    } else {
                        $search[] = "{{ICALBUTTON}}";
                        $replace[] = "";
                        $blank[] = "";
                        $search[] = "{{ICALDIALOG}}";
                        $replace[] = "";
                        $blank[] = "";
                    }
                    if (JEVHelper::canEditEvent($event) || JEVHelper::canPublishEvent($event) || JEVHelper::canDeleteEvent($event)) {
                        ob_start();
                        $view->eventManagementButton($event);
                        ?>
							<div class="jevdialogs">
							<?php 
                        $search[] = "{{EDITDIALOG}}";
                        if ($view) {
                            ob_start();
                            $view->eventManagementDialog($event, $mask, true);
                            $dialog = ob_get_clean();
                            $replace[] = $dialog;
                        } else {
                            $replace[] = "";
                        }
                        $blank[] = "";
                        echo $dialog;
                        ?>
							</div>

							<?php 
                        $search[] = "{{EDITBUTTON}}";
                        $replace[] = ob_get_clean();
                        $blank[] = "";
                    } else {
                        $search[] = "{{EDITBUTTON}}";
                        $replace[] = "";
                        $blank[] = "";
                        $search[] = "{{EDITDIALOG}}";
                        $replace[] = "";
                        $blank[] = "";
                    }
                }
                break;
            case "{{CREATED}}":
                $compparams = JComponentHelper::getParams(JEV_COM_COMPONENT);
                $jtz = $compparams->get("icaltimezonelive", "");
                if ($jtz == "") {
                    $jtz = null;
                }
                $created = JevDate::getDate($event->created(), $jtz);
                $search[] = "{{CREATED}}";
                $replace[] = $created->toFormat(JText::_("DATE_FORMAT_CREATED"));
                $blank[] = "";
                break;
            case "{{ACCESS}}":
                $search[] = "{{ACCESS}}";
                $replace[] = $event->getAccessName();
                $blank[] = "";
                break;
            case "{{JEVSTARTED}}":
            case "{{JEVENDED}}":
                // no need to repeat this for each of the matching 'case's
                if (!in_array("{{JEVSTARTED}}", $search)) {
                    $search[] = "{{JEVSTARTED}}";
                    $now = new JevDate("+0 seconds");
                    $now = $now->toFormat("%Y-%m-%d %H:%M:%S");
                    $replace[] = $event->publish_up() < $now ? JText::_("JEV_EVENT_STARTED") : "";
                    $blank[] = "";
                    $search[] = "{{JEVENDED}}";
                    $replace[] = $event->publish_down() < $now ? JText::_("JEV_EVENT_ENDED") : "";
                    $blank[] = "";
                }
                break;
            case "{{REPEATSUMMARY}}":
            case "{{STARTDATE}}":
            case "{{ENDDATE}}":
            case "{{STARTTIME}}":
            case "{{ENDTIME}}":
            case "{{STARTTZ}}":
            case "{{ENDTZ}}":
            case "{{ISOSTART}}":
            case "{{ISOEND}}":
            case "{{DURATION}}":
            case "{{COUNTDOWN}}":
            case "{{MULTIENDDATE}}":
                // no need to repeat this for each of the matching 'case's
                if (!in_array("{{COUNTDOWN}}", $search)) {
                    if ($template_name == "icalevent.detail_body") {
                        $search[] = "{{REPEATSUMMARY}}";
                        $repeatsummary = $view->repeatSummary($event);
                        if (!$repeatsummary) {
                            $repeatsummary = $event->repeatSummary();
                        }
                        if ($jevparams->get("com_repeatview", 1)) {
                            $replace[] = $repeatsummary;
                        } else {
                            $replace[] = "";
                        }
                        //$replace[] = $event->repeatSummary();
                        $blank[] = "";
                        $row = $event;
                        $start_date = JEventsHTML::getDateFormat($row->yup(), $row->mup(), $row->dup(), 0);
                        $start_time = JEVHelper::getTime($row->getUnixStartTime(), $row->hup(), $row->minup());
                        $stop_date = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn(), 0);
                        $stop_time = JEVHelper::getTime($row->getUnixEndTime(), $row->hdn(), $row->mindn());
                        $stop_time_midnightFix = $stop_time;
                        $stop_date_midnightFix = $stop_date;
                        if ($row->sdn() == 59 && $row->mindn() == 59) {
                            $stop_time_midnightFix = JEVHelper::getTime($row->getUnixEndTime() + 1, 0, 0);
                            $stop_date_midnightFix = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn() + 1, 0);
                        }
                        $search[] = "{{STARTDATE}}";
                        $replace[] = $start_date;
                        $blank[] = "";
                        $search[] = "{{ENDDATE}}";
                        $replace[] = $stop_date;
                        $blank[] = "";
                        $search[] = "{{STARTTIME}}";
                        $replace[] = $row->alldayevent() ? "" : $start_time;
                        $blank[] = "";
                        $search[] = "{{ENDTIME}}";
                        $replace[] = $row->noendtime() || $row->alldayevent() ? "" : $stop_time_midnightFix;
                        $blank[] = "";
                        $search[] = "{{MULTIENDDATE}}";
                        $replace[] = $row->endDate() > $row->startDate() ? $stop_date : "";
                        $blank[] = "";
                        $search[] = "{{STARTTZ}}";
                        $replace[] = $row->alldayevent() ? "" : $start_time;
                        $blank[] = "";
                        $search[] = "{{ENDTZ}}";
                        $replace[] = $row->noendtime() || $row->alldayevent() ? "" : $stop_time_midnightFix;
                        $blank[] = "";
                        $rawreplace["{{STARTDATE}}"] = $row->getUnixStartDate();
                        $rawreplace["{{ENDDATE}}"] = $row->getUnixEndDate();
                        $rawreplace["{{STARTTIME}}"] = $row->alldayevent() ? "" : $row->getUnixStartTime();
                        $rawreplace["{{ENDTIME}}"] = $row->noendtime() || $row->alldayevent() ? "" : $row->getUnixEndTime();
                        $rawreplace["{{STARTTZ}}"] = $row->yup() . "-" . $row->mup() . "-" . $row->dup() . " " . $row->hup() . ":" . $row->minup() . ":" . $row->sup();
                        $rawreplace["{{ENDTZ}}"] = $row->ydn() . "-" . $row->mdn() . "-" . $row->ddn() . " " . $row->hdn() . ":" . $row->mindn() . ":" . $row->sdn();
                        $rawreplace["{{MULTIENDDATE}}"] = $row->endDate() > $row->startDate() ? $row->getUnixEndDate() : "";
                        if (JString::strpos($template_value, "{{ISOSTART}}") !== false || JString::strpos($template_value, "{{ISOEND}}") !== false) {
                            $search[] = "{{ISOSTART}}";
                            $replace[] = JEventsHTML::getDateFormat($row->yup(), $row->mup(), $row->dup(), "%Y-%m-%d") . "T" . sprintf('%02d:%02d:00', $row->hup(), $row->minup());
                            $blank[] = "";
                            $search[] = "{{ISOEND}}";
                            $replace[] = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn(), "%Y-%m-%d") . "T" . sprintf('%02d:%02d:00', $row->hdn(), $row->mindn());
                            $blank[] = "";
                        }
                    } else {
                        $row = $event;
                        $start_date = JEventsHTML::getDateFormat($row->yup(), $row->mup(), $row->dup(), 0);
                        $start_time = JEVHelper::getTime($row->getUnixStartTime(), $row->hup(), $row->minup());
                        $stop_date = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn(), 0);
                        $stop_time = JEVHelper::getTime($row->getUnixEndTime(), $row->hdn(), $row->mindn());
                        $stop_time_midnightFix = $stop_time;
                        $stop_date_midnightFix = $stop_date;
                        if ($row->sdn() == 59 && $row->mindn() == 59) {
                            $stop_time_midnightFix = JEVHelper::getTime($row->getUnixEndTime() + 1, 0, 0);
                            $stop_date_midnightFix = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn() + 1, 0);
                        }
                        $search[] = "{{STARTDATE}}";
                        $replace[] = $start_date;
                        $blank[] = "";
                        $search[] = "{{ENDDATE}}";
                        $replace[] = $stop_date;
                        $blank[] = "";
                        $search[] = "{{STARTTIME}}";
                        $replace[] = $row->alldayevent() ? "" : $start_time;
                        $blank[] = "";
                        $search[] = "{{ENDTIME}}";
                        $replace[] = $row->noendtime() || $row->alldayevent() ? "" : $stop_time_midnightFix;
                        $blank[] = "";
                        $search[] = "{{MULTIENDDATE}}";
                        $replace[] = $row->endDate() > $row->startDate() ? $stop_date : "";
                        $blank[] = "";
                        $search[] = "{{STARTTZ}}";
                        $replace[] = $row->alldayevent() ? "" : $start_time;
                        $blank[] = "";
                        $search[] = "{{ENDTZ}}";
                        $replace[] = $row->noendtime() || $row->alldayevent() ? "" : $stop_time_midnightFix;
                        $blank[] = "";
                        $rawreplace["{{STARTDATE}}"] = $row->getUnixStartDate();
                        $rawreplace["{{ENDDATE}}"] = $row->getUnixEndDate();
                        $rawreplace["{{STARTTIME}}"] = $row->alldayevent() ? "" : $row->getUnixStartTime();
                        $rawreplace["{{ENDTIME}}"] = $row->noendtime() || $row->alldayevent() ? "" : $row->getUnixEndTime();
                        $rawreplace["{{STARTTZ}}"] = $row->yup() . "-" . $row->mup() . "-" . $row->dup() . " " . $row->hup() . ":" . $row->minup() . ":" . $row->sup();
                        $rawreplace["{{ENDTZ}}"] = $row->ydn() . "-" . $row->mdn() . "-" . $row->ddn() . " " . $row->hdn() . ":" . $row->mindn() . ":" . $row->sdn();
                        $rawreplace["{{MULTIENDDATE}}"] = $row->endDate() > $row->startDate() ? $row->getUnixEndDate() : "";
                        if (JString::strpos($template_value, "{{ISOSTART}}") !== false || JString::strpos($template_value, "{{ISOEND}}") !== false) {
                            $search[] = "{{ISOSTART}}";
                            $replace[] = JEventsHTML::getDateFormat($row->yup(), $row->mup(), $row->dup(), "%Y-%m-%d") . "T" . sprintf('%02d:%02d:00', $row->hup(), $row->minup());
                            $blank[] = "";
                            $search[] = "{{ISOEND}}";
                            $replace[] = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn(), "%Y-%m-%d") . "T" . sprintf('%02d:%02d:00', $row->hdn(), $row->mindn());
                            $blank[] = "";
                        }
                        // these would slow things down if not needed in the list
                        $dorepeatsummary = JString::strpos($template_value, "{{REPEATSUMMARY}}") !== false;
                        if ($dorepeatsummary) {
                            $cfg = JEVConfig::getInstance();
                            $jevtask = JRequest::getString("jevtask");
                            $jevtask = str_replace(".listevents", "", $jevtask);
                            $showyeardate = $cfg->get("showyeardate", 0);
                            $row = $event;
                            $times = "";
                            if ($showyeardate && $jevtask == "year" || $jevtask == "search.results" || $jevtask == "month.calendar" || $jevtask == "cat" || $jevtask == "range") {
                                $start_publish = $row->getUnixStartDate();
                                $stop_publish = $row->getUnixEndDate();
                                if ($stop_publish == $start_publish) {
                                    if ($row->noendtime()) {
                                        $times = $start_time;
                                    } else {
                                        if ($row->alldayevent()) {
                                            $times = "";
                                        } else {
                                            if ($start_time != $stop_time) {
                                                $times = $start_time . ' - ' . $stop_time_midnightFix;
                                            } else {
                                                $times = $start_time;
                                            }
                                        }
                                    }
                                    $times = $start_date . " " . $times . "<br/>";
                                } else {
                                    if ($row->noendtime()) {
                                        $times = $start_time;
                                    } else {
                                        if ($row->alldayevent()) {
                                            $times = "";
                                        } else {
                                            if ($start_time != $stop_time && !$row->alldayevent()) {
                                                $times = $start_time . '&nbsp;-&nbsp;' . $stop_time_midnightFix;
                                            }
                                        }
                                    }
                                    $times = $start_date . ' - ' . $stop_date . " " . $times . "<br/>";
                                }
                            } else {
                                if (($jevtask == "day" || $jevtask == "week") && $row->starttime() != $row->endtime() && !$row->alldayevent()) {
                                    if ($row->noendtime()) {
                                        if ($showyeardate && $jevtask == "year") {
                                            $times = $start_time . '&nbsp;-&nbsp;' . $stop_time_midnightFix . '&nbsp;';
                                        } else {
                                            $times = $start_time . '&nbsp;';
                                        }
                                    } else {
                                        if ($row->alldayevent()) {
                                            $times = "";
                                        } else {
                                            $times = $start_time . '&nbsp;-&nbsp;' . $stop_time_midnightFix . '&nbsp;';
                                        }
                                    }
                                }
                            }
                            $search[] = "{{REPEATSUMMARY}}";
                            $replace[] = $times;
                            $blank[] = "";
                        }
                    }
                    $search[] = "{{COUNTDOWN}}";
                    $timedelta = $row->getUnixStartTime() - JevDate::mktime();
                    $eventPassed = !($timedelta >= 0);
                    $fieldval = JText::_("JEV_COUNTDOWN_FORMAT");
                    $shownsign = false;
                    if (stripos($fieldval, "%nopast") !== false) {
                        if (!$eventPassed) {
                            $fieldval = str_ireplace("%nopast", "", $fieldval);
                        } else {
                            $fieldval = JText::_('JEV_EVENT_ALREADY_STARTED');
                        }
                    }
                    if (stripos($fieldval, "%d") !== false) {
                        $days = intval($timedelta / (60 * 60 * 24));
                        $timedelta -= $days * 60 * 60 * 24;
                        $fieldval = str_ireplace("%d", $days, $fieldval);
                        $shownsign = true;
                    }
                    if (stripos($fieldval, "%h") !== false) {
                        $hours = intval($timedelta / (60 * 60));
                        $timedelta -= $hours * 60 * 60;
                        if ($shownsign) {
                            $hours = abs($hours);
                        }
                        $hours = sprintf("%02d", $hours);
                        $fieldval = str_ireplace("%h", $hours, $fieldval);
                        $shownsign = true;
                    }
                    if (stripos($fieldval, "%m") !== false) {
                        $mins = intval($timedelta / 60);
                        $timedelta -= $hours * 60;
                        if ($mins) {
                            $mins = abs($mins);
                        }
                        $mins = sprintf("%02d", $mins);
                        $fieldval = str_ireplace("%m", $mins, $fieldval);
                    }
                    $replace[] = $fieldval;
                    $blank[] = "";
                    $search[] = "{{DURATION}}";
                    $timedelta = $row->noendtime() ? "" : $row->getUnixEndTime() - $row->getUnixStartTime();
                    if ($row->alldayevent()) {
                        $timedelta = $row->getUnixEndDate() - $row->getUnixStartDate() + 60 * 60 * 24;
                    }
                    $fieldval = JText::_("JEV_DURATION_FORMAT");
                    $shownsign = false;
                    // whole days!
                    if (stripos($fieldval, "%wd") !== false) {
                        $days = intval($timedelta / (60 * 60 * 24));
                        $timedelta -= $days * 60 * 60 * 24;
                        if ($timedelta > 3610) {
                            //if more than 1 hour and 10 seconds over a day then round up the day output
                            $days += 1;
                        }
                        $fieldval = str_ireplace("%d", $days, $fieldval);
                        $shownsign = true;
                    }
                    if (stripos($fieldval, "%d") !== false) {
                        $days = intval($timedelta / (60 * 60 * 24));
                        $timedelta -= $days * 60 * 60 * 24;
                        /*
                         if ($timedelta>3610){
                         //if more than 1 hour and 10 seconds over a day then round up the day output
                         $days +=1;
                         }
                        */
                        $fieldval = str_ireplace("%d", $days, $fieldval);
                        $shownsign = true;
                    }
                    if (stripos($fieldval, "%h") !== false) {
                        $hours = intval($timedelta / (60 * 60));
                        $timedelta -= $hours * 60 * 60;
                        if ($shownsign) {
                            $hours = abs($hours);
                        }
                        $hours = sprintf("%02d", $hours);
                        $fieldval = str_ireplace("%h", $hours, $fieldval);
                        $shownsign = true;
                    }
                    if (stripos($fieldval, "%m") !== false) {
                        $mins = intval($timedelta / 60);
                        $timedelta -= $hours * 60;
                        if ($mins) {
                            $mins = abs($mins);
                        }
                        $mins = sprintf("%02d", $mins);
                        $fieldval = str_ireplace("%m", $mins, $fieldval);
                    }
                    $replace[] = $fieldval;
                    $blank[] = "";
                }
                break;
            case "{{PREVIOUSNEXT}}":
                static $doprevnext;
                if (!isset($doprevnext)) {
                    $doprevnext = JString::strpos($template_value, "{{PREVIOUSNEXT}}") !== false;
                }
                if ($doprevnext) {
                    $search[] = "{{PREVIOUSNEXT}}";
                    $replace[] = $event->previousnextLinks();
                    $blank[] = "";
                }
                break;
            case "{{PREVIOUSNEXTEVENT}}":
                static $doprevnextevent;
                if (!isset($doprevnextevent)) {
                    $doprevnextevent = JString::strpos($template_value, "{{PREVIOUSNEXTEVENT}}") !== false;
                }
                if ($doprevnextevent) {
                    $search[] = "{{PREVIOUSNEXTEVENT}}";
                    $replace[] = $event->previousnextEventLinks();
                    $blank[] = "";
                }
                break;
            case "{{FIRSTREPEAT}}":
            case "{{FIRSTREPEATSTART}}":
            case "{{JEVAGE}}":
                // no need to repeat this for each of the matching 'case's
                if (!in_array("{{FIRSTREPEAT}}", $search)) {
                    static $dofirstrepeat;
                    if (!isset($dofirstrepeat)) {
                        $dofirstrepeat = JString::strpos($template_value, "{{FIRSTREPEAT") !== false || JString::strpos($template_value, "{{FIRSTREPEATSTART") !== false || JString::strpos($template_value, "{{JEVAGE") !== false;
                    }
                    if ($dofirstrepeat) {
                        $search[] = "{{FIRSTREPEAT}}";
                        $firstrepeat = $event->getFirstRepeat();
                        if ($firstrepeat->rp_id() == $event->rp_id()) {
                            $replace[] = "";
                        } else {
                            $replace[] = "<a class='ev_firstrepeat' href='" . $firstrepeat->viewDetailLink($firstrepeat->yup(), $firstrepeat->mup(), $firstrepeat->dup(), true) . "' title='" . JText::_('JEV_FIRSTREPEAT') . "' >" . JText::_('JEV_FIRSTREPEAT') . "</a>";
                        }
                        $blank[] = "";
                        $search[] = "{{FIRSTREPEATSTART}}";
                        if ($firstrepeat->rp_id() == $event->rp_id()) {
                            $replace[] = "";
                        } else {
                            $replace[] = JEventsHTML::getDateFormat($firstrepeat->yup(), $firstrepeat->mup(), $firstrepeat->dup(), 0);
                            $rawreplace["{{FIRSTREPEATSTART}}"] = $firstrepeat->yup() . "-" . $firstrepeat->mup() . "-" . $firstrepeat->dup() . " " . $firstrepeat->hup() . ":" . $firstrepeat->minup() . ":" . $firstrepeat->sup();
                        }
                        $blank[] = "";
                        $search[] = "{{JEVAGE}}";
                        if ($firstrepeat->rp_id() == $event->rp_id()) {
                            $replace[] = "";
                        } else {
                            $replace[] = $event->yup() > $firstrepeat->yup() && $event->mup() == $firstrepeat->mup() && $event->dup() == $firstrepeat->dup() ? $event->yup() - $firstrepeat->yup() : "";
                        }
                        $blank[] = "";
                    }
                }
                break;
            case "{{LASTREPEAT}}":
            case "{{LASTREPEATEND}}":
                // no need to repeat this for each of the matching 'case's
                if (!in_array("{{LASTREPEAT}}", $search)) {
                    static $dolastrepeat;
                    if (!isset($dolastrepeat)) {
                        $dolastrepeat = JString::strpos($template_value, "{{LASTREPEAT}}") !== false || JString::strpos($template_value, "{{LASTREPEATEND}}") !== false;
                    }
                    if ($dolastrepeat) {
                        $search[] = "{{LASTREPEAT}}";
                        $lastrepeat = $event->getLastRepeat();
                        if ($lastrepeat->rp_id() == $event->rp_id()) {
                            $replace[] = "";
                        } else {
                            $replace[] = "<a class='ev_lastrepeat' href='" . $lastrepeat->viewDetailLink($lastrepeat->yup(), $lastrepeat->mup(), $lastrepeat->dup(), true) . "' title='" . JText::_('JEV_LASTREPEAT') . "' >" . JText::_('JEV_LASTREPEAT') . "</a>";
                        }
                        $blank[] = "";
                        $search[] = "{{LASTREPEATEND}}";
                        if ($lastrepeat->rp_id() != $event->rp_id()) {
                            $replace[] = JEventsHTML::getDateFormat($lastrepeat->ydn(), $lastrepeat->mdn(), $lastrepeat->ddn(), 0);
                            $rawreplace["{{LASTREPEATEND}}"] = $lastrepeat->ydn() . "-" . $lastrepeat->mdn() . "-" . $lastrepeat->ddn() . " " . $lastrepeat->hdn() . ":" . $lastrepeat->mindn() . ":" . $lastrepeat->sdn();
                        } else {
                            $replace[] = "";
                        }
                        $blank[] = "";
                    }
                }
                break;
            case "{{CREATOR_LABEL}}":
                $search[] = "{{CREATOR_LABEL}}";
                if ($jevparams->get("com_byview", 1) || $template_name != "icalevent.detail_body") {
                    $replace[] = JText::_('JEV_BY');
                } else {
                    $replace[] = "";
                }
                $blank[] = "";
                break;
            case "{{CREATOR}}":
                $search[] = "{{CREATOR}}";
                if ($jevparams->get("com_byview", 1) || $template_name != "icalevent.detail_body") {
                    $replace[] = $event->contactlink();
                } else {
                    $replace[] = "";
                }
                $blank[] = "";
                break;
            case "{{HITS}}":
                $search[] = "{{HITS}}";
                if ($jevparams->get("com_hitsview", 1) || $template_name != "icalevent.detail_body") {
                    $replace[] = "<span class='hitslabel'>" . JText::_('JEV_EVENT_HITS') . '</span> : ' . $event->hits();
                } else {
                    $replace[] = "";
                }
                $blank[] = "";
                break;
            case "{{LOCATION_LABEL}}":
            case "{{LOCATION}}":
                // no need to repeat this for each of the matching 'case's
                if (!in_array("{{LOCATION}}", $search)) {
                    if ($event->hasLocation()) {
                        $search[] = "{{LOCATION_LABEL}}";
                        $replace[] = JText::_('JEV_EVENT_ADRESSE') . "&nbsp;";
                        $blank[] = "";
                        $search[] = "{{LOCATION}}";
                        $replace[] = $event->location();
                        $blank[] = "";
                    } else {
                        $search[] = "{{LOCATION_LABEL}}";
                        $replace[] = "";
                        $blank[] = "";
                        $search[] = "{{LOCATION}}";
                        $replace[] = "";
                        $blank[] = "";
                    }
                }
                break;
            case "{{CONTACT_LABEL}}":
            case "{{CONTACT}}":
                // no need to repeat this for each of the matching 'case's
                if (!in_array("{{CONTACT}}", $search)) {
                    if ($event->hasContactInfo()) {
                        if (JString::strpos($event->contact_info(), '<script') === false) {
                            $dispatcher = JEventDispatcher::getInstance();
                            JPluginHelper::importPlugin('content');
                            //Contact
                            $pattern = '[a-zA-Z0-9&?_.,=%\\-\\/]';
                            if (JString::strpos($event->contact_info(), '<a href=') === false && $event->contact_info() != "") {
                                $event->contact_info(preg_replace('@(https?://)(' . $pattern . '*)@i', '<a href="\\1\\2">\\1\\2</a>', $event->contact_info()));
                            }
                            // NO need to call conContentPrepate since its called on the template value below here
                        }
                        $search[] = "{{CONTACT_LABEL}}";
                        $replace[] = JText::_('JEV_EVENT_CONTACT') . "&nbsp;";
                        $blank[] = "";
                        $search[] = "{{CONTACT}}";
                        $replace[] = $event->contact_info();
                        $blank[] = "";
                    } else {
                        $search[] = "{{CONTACT_LABEL}}";
                        $replace[] = "";
                        $blank[] = "";
                        $search[] = "{{CONTACT}}";
                        $replace[] = "";
                        $blank[] = "";
                    }
                }
                break;
            case "{{EXTRAINFO}}":
                //Extra
                if (JString::strpos($event->extra_info(), '<script') === false && $event->extra_info() != "") {
                    $dispatcher = JEventDispatcher::getInstance();
                    JPluginHelper::importPlugin('content');
                    $pattern = '[a-zA-Z0-9&?_.,=%\\-\\/#]';
                    if (JString::strpos($event->extra_info(), '<a href=') === false) {
                        $event->extra_info(preg_replace('@(https?://)(' . $pattern . '*)@i', '<a href="\\1\\2">\\1\\2</a>', $event->extra_info()));
                    }
                    //$row->extra_info(eregi_replace('[^(href=|href="|href=\')](((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)','\\1', $row->extra_info()));
                    // NO need to call conContentPrepate since its called on the template value below here
                }
                $search[] = "{{EXTRAINFO}}";
                $replace[] = $event->extra_info();
                $blank[] = "";
                break;
            case "{{RPID}}":
                $search[] = "{{RPID}}";
                $replace[] = $event->rp_id();
                $blank[] = "";
                break;
            default:
                $strippedmatch = str_replace(array("{", "}"), "", $strippedmatch);
                if (is_callable(array($event, $strippedmatch))) {
                    $search[] = "{{" . $strippedmatch . "}}";
                    $replace[] = $event->{$strippedmatch}();
                    $blank[] = "";
                }
                break;
        }
    }
    // Now do the plugins
    // get list of enabled plugins
    $layout = $template_name == "icalevent.list_row" || $template_name == "month.calendar_cell" || $template_name == "month.calendar_tip" ? "list" : "detail";
    if ($runplugins) {
        $jevplugins = JPluginHelper::getPlugin("jevents");
        foreach ($jevplugins as $jevplugin) {
            $classname = "plgJevents" . ucfirst($jevplugin->name);
            if (is_callable(array($classname, "substitutefield"))) {
                if (!isset($fieldNameArray[$classname])) {
                    $fieldNameArray[$classname] = array();
                }
                if (!isset($fieldNameArray[$classname][$layout])) {
                    //list($usec, $sec) = explode(" ", microtime());
                    //$starttime = (float) $usec + (float) $sec;
                    $fieldNameArray[$classname][$layout] = call_user_func(array($classname, "fieldNameArray"), $layout);
                    //list ($usec, $sec) = explode(" ", microtime());
                    //$time_end = (float) $usec + (float) $sec;
                    //echo  "$classname::fieldNameArray = ".round($time_end - $starttime, 4)."<br/>";
                }
                if (isset($fieldNameArray[$classname][$layout]["values"])) {
                    foreach ($fieldNameArray[$classname][$layout]["values"] as $fieldname) {
                        if (!JString::strpos($template_value, $fieldname) !== false) {
                            continue;
                        }
                        $search[] = "{{" . $fieldname . "}}";
                        // is the event detail hidden - if so then hide any custom fields too!
                        if (!isset($event->_privateevent) || $event->_privateevent != 3) {
                            $replace[] = call_user_func(array($classname, "substitutefield"), $event, $fieldname);
                            if (is_callable(array($classname, "blankfield"))) {
                                $blank[] = call_user_func(array($classname, "blankfield"), $event, $fieldname);
                            } else {
                                $blank[] = "";
                            }
                        } else {
                            $blank[] = "";
                            $replace[] = "";
                        }
                    }
                }
            }
        }
    }
    // word counts etc.
    for ($s = 0; $s < count($search); $s++) {
        if (JString::strpos($search[$s], "TRUNCATED_DESC:") > 0 || JString::strpos($search[$s], "TRUNCATED_TITLE:") > 0) {
            global $tempreplace, $tempevent, $tempsearch;
            $tempreplace = $replace[$s];
            $tempsearch = $search[$s];
            $tempevent = $event;
            $template_value = preg_replace_callback("|{$tempsearch}|", 'jevSpecialHandling', $template_value);
        }
    }
    // Date/time formats etc.
    for ($s = 0; $s < count($search); $s++) {
        if (JString::strpos($search[$s], "STARTDATE") > 0 || JString::strpos($search[$s], "STARTTIME") > 0 || JString::strpos($search[$s], "ENDDATE") > 0 || JString::strpos($search[$s], "ENDTIME") > 0 || JString::strpos($search[$s], "ENDTZ") > 0 || JString::strpos($search[$s], "STARTTZ") > 0 || JString::strpos($search[$s], "MULTIENDDATE") > 0 || JString::strpos($search[$s], "FIRSTREPEATSTART") > 0 || JString::strpos($search[$s], "LASTREPEATEND") > 0) {
            if (!isset($rawreplace[$search[$s]]) || !$rawreplace[$search[$s]]) {
                continue;
            }
            global $tempreplace, $tempevent, $tempsearch, $tempblank;
            $tempreplace = $rawreplace[$search[$s]];
            $tempblank = $blank[$s];
            $tempsearch = str_replace("}}", ";.*?}}", $search[$s]);
            $tempevent = $event;
            $template_value = preg_replace_callback("~{$tempsearch}~", 'jevSpecialDateFormatting', $template_value);
        }
    }
    for ($s = 0; $s < count($search); $s++) {
        global $tempreplace, $tempevent, $tempsearch, $tempblank;
        $tempreplace = $replace[$s];
        $tempblank = $blank[$s];
        $tempsearch = str_replace("}}", "#", $search[$s]);
        $tempevent = $event;
        $template_value = preg_replace_callback("|{$tempsearch}(.+?)}}|", 'jevSpecialHandling2', $template_value);
    }
    // The universal search and replace to finish
    $template_value = str_replace($search, $replace, $template_value);
    if ($specialmodules) {
        $reg = JRegistry::getInstance("com_jevents");
        $parts = explode("{{MODULESTART#", $template_value);
        $dynamicmodules = array();
        foreach ($parts as $part) {
            $currentdynamicmodules = $reg->get("dynamicmodules", false);
            if (JString::strpos($part, "{{MODULEEND}}") === false) {
                // strip out BAD HTML tags left by WYSIWYG editors
                if (JString::substr($part, JString::strlen($part) - 3) == "<p>") {
                    $template_value = JString::substr($part, 0, JString::strlen($part) - 3);
                } else {
                    $template_value = $part;
                }
                continue;
            }
            // start with module name
            $modname = JString::substr($part, 0, JString::strpos($part, "}}"));
            $modulecontent = JString::substr($part, JString::strpos($part, "}}") + 2);
            $modulecontent = JString::substr($modulecontent, 0, JString::strpos($modulecontent, "{{MODULEEND}}"));
            // strip out BAD HTML tags left by WYSIWYG editors
            if (JString::strpos($modulecontent, "</p>") === 0) {
                $modulecontent = "<p>x@#" . $modulecontent;
            }
            if (JString::substr($modulecontent, JString::strlen($modulecontent) - 3) == "<p>") {
                $modulecontent .= "x@#</p>";
            }
            $modulecontent = str_replace("<p>x@#</p>", "", $modulecontent);
            if (isset($currentdynamicmodules[$modname])) {
                if (!is_array($currentdynamicmodules[$modname])) {
                    $currentdynamicmodules[$modname] = array($currentdynamicmodules[$modname]);
                }
                $currentdynamicmodules[$modname][] = $modulecontent;
                $dynamicmodules[$modname] = $currentdynamicmodules[$modname];
            } else {
                $dynamicmodules[$modname] = $modulecontent;
            }
        }
        $reg->set("dynamicmodules", $dynamicmodules);
    }
    // non greedy replacement - because of the ?
    $template_value = preg_replace_callback('|{{.*?}}|', 'cleanUnpublished', $template_value);
    // replace [[ with { to that other content plugins can work ok - but not for calendar cell or tooltip since we use [[ there already!
    if ($template_name != "month.calendar_cell" && $template_name != "month.calendar_tip") {
        $template_value = str_replace(array("[[", "]]"), array("{", "}"), $template_value);
    }
    //We add new line characters again to avoid being marked as SPAM when using tempalte in emails
    // do this before calling content plugins in case these add javascript etc. to layout
    $template_value = preg_replace("@(<\\s*(br)*\\s*\\/\\s*(p|td|tr|table|div|ul|li|ol|dd|dl|dt)*\\s*>)+?@i", "\$1\n", $template_value);
    // Call content plugins - BUT because emailcloak doesn't identify emails in input fields to a text substitution
    $template_value = str_replace("@", "@£@", $template_value);
    $params = new JRegistry(null);
    $tmprow = new stdClass();
    $tmprow->text = $template_value;
    $tmprow->event = $event;
    $dispatcher = JEventDispatcher::getInstance();
    JPluginHelper::importPlugin('content');
    $dispatcher->trigger('onContentPrepare', array('com_jevents', &$tmprow, &$params, 0));
    $template_value = $tmprow->text;
    $template_value = str_replace("@£@", "@", $template_value);
    echo $template_value;
    return !$loadedFromFile;
}
コード例 #19
0
 function addDays($n = 0)
 {
     $this->date = JevDate::mktime($this->hour, $this->minute, $this->second, $this->month, $this->day + $n, $this->year);
     $parts = explode(":", date("Y:m:j:G:i:s:t", $this->date));
     $this->year = intval($parts[0]);
     $this->month = intval($parts[1]);
     $this->day = intval($parts[2]);
     $this->dim = intval($parts[6]);
 }
コード例 #20
0
ファイル: jeventshtml.php プロジェクト: hriggs/cs-website
 public static function getDateFormat($year, $month, $day, $type)
 {
     // Transform to translation strings
     if (empty($year)) {
         $year = 0;
     }
     if (empty($month)) {
         $month = 0;
     }
     if (empty($day)) {
         $day = 1;
     }
     static $format_type;
     if (!isset($format_type)) {
         $cfg = JEVConfig::getInstance();
         $format_type = $cfg->get('com_dateformat');
     }
     $datestp = JevDate::mktime(0, 0, 0, $month, $day, $year);
     // if date format is from langauge file then do this first
     if ($format_type == 3 && is_numeric($type)) {
         return JEV_CommonFunctions::jev_strftime(JText::_("DATE_FORMAT_" . $type), $datestp);
     }
     switch ($type) {
         case '0':
             if ($format_type == 0) {
                 return JEV_CommonFunctions::jev_strftime("%A %d %B %Y", $datestp);
                 // Fr style : Monday 03 Juillet 2003
             } elseif ($format_type == 1) {
                 return JEV_CommonFunctions::jev_strftime("%A, %B %d, %Y", $datestp);
                 // Us style : Monday, July 03, 2003
             } else {
                 //return JevDate::strftime("%A, %e. %B %Y",$datestp);
                 // %e not supported by windows
                 return sprintf(JEV_CommonFunctions::jev_strftime("%A, %%s. %B %Y", $datestp), intval(JEV_CommonFunctions::jev_strftime('%d', $datestp)));
                 // De style : Montag, 3. Juli 2003
             }
             break;
         case '1':
             if ($format_type == 0) {
                 return JEV_CommonFunctions::jev_strftime("%d %B %Y", $datestp);
                 // Fr style : 23 Juillet 2003
             } elseif ($format_type == 1) {
                 return JEV_CommonFunctions::jev_strftime("%B %d, %Y", $datestp);
                 // Us style : July 23, 2003
             } else {
                 return JEV_CommonFunctions::jev_strftime("%d. %B %Y", $datestp);
                 // De style : 23. Juli 2003
             }
             break;
         case '2':
             if ($format_type == 0) {
                 return JEV_CommonFunctions::jev_strftime("%d %B", $datestp);
                 // Fr style : 23 Juillet
             } elseif ($format_type == 1) {
                 return JEV_CommonFunctions::jev_strftime("%B %d", $datestp);
                 // Us style : Juillet 23
             } else {
                 return JEV_CommonFunctions::jev_strftime("%d. %B", $datestp);
                 // De style : 23. Juli
             }
             break;
         case '3':
             if ($format_type == 0) {
                 return JEV_CommonFunctions::jev_strftime("%B %Y", $datestp);
                 // Fr style : Juillet 2003
             } elseif ($format_type == 1) {
                 return JEV_CommonFunctions::jev_strftime("%B, %Y", $datestp);
                 // Us style : Juillet, 2003
             } else {
                 return JEV_CommonFunctions::jev_strftime("%B %Y", $datestp);
                 // De style : Juli 2003
             }
             break;
         case '4':
             if ($format_type == 0) {
                 return JEV_CommonFunctions::jev_strftime("%d/%m/%Y", $datestp);
                 // Fr style : 23/07/2003
             } elseif ($format_type == 1) {
                 return JEV_CommonFunctions::jev_strftime("%m/%d/%Y", $datestp);
                 // Us style : 07/23/2003
             } else {
                 return JEV_CommonFunctions::jev_strftime("%d.%m.%Y", $datestp);
                 // De style : 23.07.2003
             }
             break;
         case '5':
             if ($format_type == 0) {
                 return JEV_CommonFunctions::jev_strftime("%d/%m", $datestp);
                 // Fr style : 23/07
             } elseif ($format_type == 1) {
                 return JEV_CommonFunctions::jev_strftime("%m/%d", $datestp);
                 // Us style : 07/23
             } else {
                 return JEV_CommonFunctions::jev_strftime("%d.%m.", $datestp);
                 // De style : 23.07.
             }
             break;
         case '6':
             if ($format_type == 0) {
                 return JEV_CommonFunctions::jev_strftime("%m/%Y", $datestp);
                 // Fr style : 07/2003
             } elseif ($format_type == 1) {
                 return JEV_CommonFunctions::jev_strftime("%m/%Y", $datestp);
                 // Us style : 07/2003
             } else {
                 return JEV_CommonFunctions::jev_strftime("%m/%Y", $datestp);
                 // De style : 07/2003
             }
             break;
         case '7':
             if ($format_type == 0) {
                 return JEV_CommonFunctions::jev_strftime("%A, %d", $datestp);
                 // Fr style : Monday 23
             } elseif ($format_type == 1) {
                 return JEV_CommonFunctions::jev_strftime("%A, %d", $datestp);
                 // Us style : Monday, 23
             } else {
                 return JEV_CommonFunctions::jev_strftime("%A, %d.", $datestp);
                 // De style : Montag, 23.
             }
             break;
         default:
             // in this case $type is a format!
             return JEV_CommonFunctions::jev_strftime($type, $datestp);
             break;
     }
     return $newdate;
 }
コード例 #21
0
ファイル: dbmodel.php プロジェクト: madseller/coperio
 function countIcalEventsByCat($catids, $showrepeats = false)
 {
     $db =& JFactory::getDBO();
     $user = JFactory::getUser();
     // Use catid in accessibleCategoryList to pick up offsping too!
     $aid = null;
     $catidlist = implode(",", $catids);
     // process the new plugins
     // get extra data and conditionality from plugins
     $extrafields = "";
     // must have comma prefix
     $extratables = "";
     // must have comma prefix
     $extrawhere = array();
     $extrajoin = array();
     $needsgroup = false;
     if (!$this->cfg->getValue("showyearpast", 1)) {
         list($year, $month, $day) = JEVHelper::getYMD();
         $startdate = JevDate::mktime(0, 0, 0, $month, $day, $year);
         $startdate = JevDate::strftime('%Y-%m-%d 00:00:00', $startdate);
         $extrawhere[] = "rpt.endrepeat >=  '{$startdate}'";
     }
     $filters = jevFilterProcessing::getInstance(array("published", "justmine", "category", "search"));
     $filters->setWhereJoin($extrawhere, $extrajoin);
     $needsgroup = $filters->needsGroupBy();
     $extrafields = "";
     // must have comma prefix
     $extratables = "";
     // must have comma prefix
     $dispatcher =& JDispatcher::getInstance();
     $dispatcher->trigger('onListIcalEvents', array(&$extrafields, &$extratables, &$extrawhere, &$extrajoin, &$needsgroup));
     $catwhere = "\n WHERE ev.catid IN(" . $this->accessibleCategoryList() . ")";
     $params = JComponentHelper::getParams("com_jevents");
     if ($params->get("multicategory", 0)) {
         $extrajoin[] = "\n #__jevents_catmap as catmap ON catmap.evid = rpt.eventid";
         $extrajoin[] = "\n #__categories AS catmapcat ON catmap.catid = catmapcat.id";
         $extrafields .= ", GROUP_CONCAT(DISTINCT catmap.catid SEPARATOR ',') as catids";
         $extrawhere[] = " catmapcat.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . JEVHelper::getAid($user) . ')' : ' <=  ' . JEVHelper::getAid($user));
         $extrawhere[] = " catmap.catid IN(" . $this->accessibleCategoryList() . ")";
         $needsgroup = true;
         $catwhere = "\n WHERE 1 ";
     }
     $extrajoin = count($extrajoin) ? " \n LEFT JOIN " . implode(" \n LEFT JOIN ", $extrajoin) : '';
     $extrawhere = count($extrawhere) ? ' AND ' . implode(' AND ', $extrawhere) : '';
     // Get the count
     if ($showrepeats) {
         $query = "SELECT count(DISTINCT rpt.rp_id) as cnt" . "\n FROM #__jevents_vevent as ev " . "\n LEFT JOIN #__jevents_icsfile as icsf ON icsf.ics_id=ev.icsid" . "\n LEFT JOIN #__jevents_repetition as rpt ON rpt.eventid = ev.ev_id" . "\n LEFT JOIN #__jevents_rrule as rr ON rr.eventid = ev.ev_id" . "\n LEFT JOIN #__jevents_vevdetail as det ON det.evdet_id = rpt.eventdetail_id" . $extrajoin . $catwhere . "\n AND icsf.state=1" . $extrawhere;
     } else {
         // TODO fine a single query way of doing this !!!
         $query = "SELECT MIN(rpt.rp_id) as rp_id FROM #__jevents_repetition as rpt " . "\n LEFT JOIN #__jevents_vevent as ev ON rpt.eventid = ev.ev_id" . "\n LEFT JOIN #__jevents_rrule as rr ON rr.eventid = ev.ev_id" . "\n LEFT JOIN #__jevents_vevdetail as det ON det.evdet_id = rpt.eventdetail_id" . "\n LEFT JOIN #__jevents_icsfile as icsf  ON icsf.ics_id=ev.icsid " . $extrajoin . $catwhere . $extrawhere . "\n AND icsf.state=1" . "\n GROUP BY ev.ev_id";
         $db->setQuery($query);
         $rplist = $db->loadResultArray();
         $rplist = implode(',', array_merge(array(-1), $rplist));
         $query = "SELECT count(DISTINCT det.evdet_id) as cnt" . "\n FROM #__jevents_vevent as ev " . "\n LEFT JOIN #__jevents_icsfile as icsf ON icsf.ics_id=ev.icsid" . "\n LEFT JOIN #__jevents_repetition as rpt ON rpt.eventid = ev.ev_id" . "\n AND rpt.rp_id IN({$rplist})" . "\n LEFT JOIN #__jevents_rrule as rr ON rr.eventid = ev.ev_id" . "\n LEFT JOIN #__jevents_vevdetail as det ON det.evdet_id = rpt.eventdetail_id" . $extrajoin . $catwhere . "\n AND icsf.state=1" . $extrawhere;
     }
     $db->setQuery($query);
     //echo $db->_sql;
     //echo $db->explain();
     $total = intval($db->loadResult());
     return $total;
 }
コード例 #22
0
ファイル: listevents_body.php プロジェクト: madcsaba/li-de
$hasevents = false;
echo '<fieldset><legend class="ev_fieldset">' . JText::_('JEV_EVENTSFOR') . '&nbsp;' . JText::_('JEV_WEEK') . ' : </legend><br />' . "\n";
echo '<table align="center" width="90%" cellspacing="0" cellpadding="5" class="ev_table">' . "\n";
?>
    <tr valign="top">
        <td colspan="2"  align="center" class="cal_td_daysnames">
           <!-- <div class="cal_daysnames"> -->
            <?php 
echo $data['startdate'] . ' - ' . $data['enddate'];
?>
            <!-- </div> -->
        </td>
    </tr>
<?php 
for ($d = 0; $d < 7; $d++) {
    $day_link = '<a class="ev_link_weekday" href="' . $data['days'][$d]['link'] . '" title="' . JText::_('JEV_CLICK_TOSWITCH_DAY') . '">' . JEV_CommonFunctions::jev_strftime("%A", JevDate::mktime(3, 0, 0, $data['days'][$d]['week_month'], $data['days'][$d]['week_day'], $data['days'][$d]['week_year'])) . "<br/>" . JEventsHTML::getDateFormat($data['days'][$d]['week_year'], $data['days'][$d]['week_month'], $data['days'][$d]['week_day'], 2) . '</a>' . "\n";
    if ($data['days'][$d]['today']) {
        $bg = 'class="ev_td_today"';
    } else {
        $bg = 'class="ev_td_left"';
    }
    echo '<tr><td ' . $bg . '>' . $day_link . '</td>' . "\n";
    echo '<td class="ev_td_right">' . "\n";
    $num_events = count($data['days'][$d]['rows']);
    if ($num_events > 0) {
        $hasevents = true;
        echo "<ul class='ev_ul'>\n";
        for ($r = 0; $r < $num_events; $r++) {
            $row = $data['days'][$d]['rows'][$r];
            $listyle = 'style="border-color:' . $row->bgcolor() . ';"';
            echo "<li class='ev_td_li' {$listyle}>\n";
コード例 #23
0
 function eventInPeriod($startDate, $endDate)
 {
     if (!isset($this->_start)) {
         $this->_start = JevDate::mktime(0, 0, 0, $this->mup, $this->dup, $this->yup);
         $this->_end = JevDate::mktime(0, 0, 0, $this->mdn, $this->ddn, $this->ydn);
     }
     if (!isset($this->rrule)) {
         if ($this->_start <= $endDate && $this->_end >= $startDate) {
             return true;
         } else {
             return false;
         }
     } else {
         if (isset($this->rrule)) {
             return $this->rrule->eventInPeriod($startDate, $endDate, $this->_start, $this->_end);
         }
     }
     return false;
 }
コード例 #24
0
ファイル: commonfunctions.php プロジェクト: madseller/coperio
 function mosEventRepeatArrayFlex($row = null, $flexStart = null, $flexEnd = null)
 {
     // builds and returns array
     if (is_null($row) || is_null($flexStart) || is_null($flexEnd)) {
         $eventDays = array();
         return $eventDays;
     }
     list($dayStart, $monthStart, $yearStart) = explode(":", date("d:m:Y", $flexStart));
     list($dayEnd, $monthEnd, $yearEnd) = explode(":", date("d:m:Y", $flexEnd));
     if ($monthStart == $monthEnd && $yearStart == $yearEnd) {
         $flexEndSecond = JevDate::mktime(23, 59, 59, $monthEnd, $dayEnd, $yearEnd);
         return mosEventRepeatArrayPeriod($row, $flexStart, $flexEnd, $flexEndSecond);
     } else {
         $eventDays = array();
         for ($y = $yearStart; $y <= $yearEnd; $y++) {
             $startMonth = 1;
             if ($y == $yearStart) {
                 $startMonth = $monthStart;
             }
             $endMonth = 12;
             if ($y == $yearEnd) {
                 $endMonth = $monthEnd;
             }
             for ($m = $startMonth; $m <= $endMonth; $m++) {
                 $dateStart = JevDate::mktime(0, 0, 0, $m, 1, $y);
                 $daysInMonth = intval(date("t", $dateStart));
                 $dateEnd = JevDate::mktime(0, 0, 0, $m, $daysInMonth, $y);
                 $dateEndSecond = JevDate::mktime(23, 59, 59, $m, $daysInMonth, $y);
                 $part = mosEventRepeatArrayPeriod($row, $dateStart, $dateEnd, $dateEndSecond);
                 foreach ($part as $key => $val) {
                     $eventDays[$key] = $val;
                 }
             }
         }
         return $eventDays;
     }
 }
コード例 #25
0
ファイル: iCalRRule.php プロジェクト: hriggs/cs-website
 /**
  * Generates repetition from vevent & rrule data from scratch
  * The result can then be saved to the database
  */
 function getRepetitions($dtstart, $dtend, $duration, $recreate = false, $exdate = array())
 {
     // put exdate into somewhere that I can get from _makerepeat
     $this->_exdate = $exdate;
     // TODO  "getRepetitions doesnt yet deal with Short months and 31st or leap years/week 53<br/>";
     if ($dtend == 0 && $duration > 0) {
         $dtend = $dtstart + $duration;
     }
     if (!$recreate && isset($this->_repetitions)) {
         return $this->_repetitions;
     }
     $this->_repetitions = array();
     if (!isset($this->eventid)) {
         echo "no eventid set in generateRepetitions<br/>";
         return $this->_repetitions;
     }
     if ($this->count == 1 && $this->freq != "IRREGULAR") {
         //echo "count=1 returing<br/>";
         $this->_makeRepeat($dtstart, $dtend);
         return $this->_repetitions;
     }
     //list ($h,$min,$s,$d,$m,$y) = explode(":",JevDate::strftime("%H:%M:%S:%d:%m:%Y",$end));
     list($startHour, $startMin, $startSecond, $startDay, $startMonth, $startYear, $startWD) = explode(":", JevDate::strftime("0%H:0%M:0%S:%d:%m:%Y:%w", $dtstart));
     //echo "$startHour,$startMin,$startSecond,$startDay,$startMonth,$startYear,$startWD,$dtstart<br/>";
     $dtstartMidnight = JevDate::mktime(0, 0, 0, $startMonth, $startDay, $startYear);
     list($endDay, $endMonth, $endYear, $endWD) = explode(":", JevDate::strftime("%d:%m:%Y:%w", $dtend));
     $duration = $dtend - $dtstart;
     static $weekdayMap = array("SU" => 0, "MO" => 1, "TU" => 2, "WE" => 3, "TH" => 4, "FR" => 5, "SA" => 6);
     static $weekdayReverseMap = array("SU", "MO", "TU", "WE", "TH", "FR", "SA");
     static $dailySecs = 86400;
     static $weeklySecs = 604800;
     // TODO implement byyearday
     // TODO do full leap year audit e.g. YEARLY repeats
     //echo "freq = ".$this->freq."<br/>";
     switch ($this->freq) {
         case "YEARLY":
             // TODO the code doesn't yet deal with multiple bymonths
             if ($this->bymonth == "") {
                 $this->bymonth = $startMonth;
             }
             //if ($this->byday=="") $this->byday=$weekdayReverseMap[$startWD];
             // If I have byday and bymonthday then the two considions must be met
             $weekdays = array();
             if ($this->byday != "") {
                 foreach (explode(",", $this->byday) as $bday) {
                     if (array_key_exists($bday, $weekdayMap)) {
                         $weekdays[] = $weekdayMap[$bday];
                     }
                 }
             }
             if ($this->byyearday != "") {
                 echo "byyearday <br/>";
                 $days = explode(",", $this->byyearday);
                 $start = $dtstart;
                 $end = $dtend;
                 $countRepeats = 0;
                 $currentYearStart = JevDate::mktime(0, 0, 0, 1, 1, $startYear);
                 // do the current month first
                 while ($countRepeats < $this->count && !$this->_afterUntil($currentYearStart)) {
                     $currentYear = JevDate::strftime("%Y", $currentYearStart);
                     $currentYearDays = date("L", $currentYearStart) ? 366 : 365;
                     foreach ($days as $day) {
                         if ($countRepeats >= $this->count || $this->_afterUntil($start)) {
                             return $this->_repetitions;
                         }
                         // TODO I am assuming all + or all -ve
                         $details = array();
                         preg_match("/(\\+|-?)(\\d*)/", $day, $details);
                         list($temp, $plusminus, $daynumber) = $details;
                         if (JString::strlen($plusminus) == 0) {
                             $plusminus = "+";
                         }
                         // do not go over year end
                         if ($daynumber > $currentYearDays) {
                             continue;
                         }
                         if ($plusminus == "+") {
                             $targetStart = JevDate::mktime($startHour, $startMin, $startSecond, 12, 31, $currentYear - 1);
                             $targetStart = JevDate::strtotime("+{$daynumber} days", $targetStart);
                         } else {
                             $targetStart = JevDate::mktime($startHour, $startMin, $startSecond, 1, 1, $currentYear + 1);
                             $targetStart = JevDate::strtotime("-{$daynumber} days", $targetStart);
                         }
                         $targetEnd = $targetStart + $duration;
                         if ($countRepeats >= $this->count) {
                             return $this->_repetitions;
                         }
                         if ($targetStart >= $dtstartMidnight && !$this->_afterUntil($targetStart)) {
                             // double check for byday constraints
                             if ($this->byday != "") {
                                 if (!in_array(JevDate::strftime("%w", $targetStart), $weekdays)) {
                                     continue;
                                 }
                             }
                             $countRepeats += $this->_makeRepeat($targetStart, $targetEnd);
                         }
                     }
                     // now ago to the start of next year
                     if ($currentYear + $this->rinterval > 2099) {
                         return $this->_repetitions;
                     }
                     $currentYearStart = JevDate::mktime(0, 0, 0, 1, 1, $currentYear + $this->rinterval);
                 }
             } else {
                 if ($this->bymonthday != "") {
                     echo "bymonthday" . $this->bymonthday . " <br/>";
                     $days = explode(",", $this->bymonthday);
                     $start = $dtstart;
                     $end = $dtend;
                     $countRepeats = 0;
                     $currentMonthStart = JevDate::mktime(0, 0, 0, $startMonth, 1, $startYear);
                     // do the current month first
                     while ($countRepeats < $this->count && !$this->_afterUntil($currentMonthStart)) {
                         list($currentMonth, $currentYear) = explode(":", JevDate::strftime("%m:%Y", $currentMonthStart));
                         $currentMonthDays = date("t", $currentMonthStart);
                         foreach ($days as $day) {
                             if ($countRepeats >= $this->count || $this->_afterUntil($start)) {
                                 return $this->_repetitions;
                             }
                             // Assume no negative bymonthday values
                             // TODO relax this assumption
                             // do not go over month end
                             if ($day > $currentMonthDays) {
                                 continue;
                             }
                             $targetStart = JevDate::mktime($startHour, $startMin, $startSecond, $currentMonth, $day, $currentYear);
                             $targetEnd = $targetStart + $duration;
                             if ($countRepeats >= $this->count) {
                                 return $this->_repetitions;
                             }
                             if ($targetStart >= $dtstartMidnight && !$this->_afterUntil($targetStart)) {
                                 // double check for byday constraints
                                 if ($this->byday != "") {
                                     if (!in_array(JevDate::strftime("%w", $targetStart), $weekdays)) {
                                         continue;
                                     }
                                 }
                                 $countRepeats += $this->_makeRepeat($targetStart, $targetEnd);
                             }
                         }
                         // now ago to the start of next month
                         if ($currentYear + $this->rinterval > 2099) {
                             return $this->_repetitions;
                         }
                         $currentMonthStart = JevDate::mktime(0, 0, 0, $currentMonth, 1, $currentYear + $this->rinterval);
                     }
                 } else {
                     if ($this->byday == "") {
                         $start = $dtstart;
                         $end = $dtend;
                         $countRepeats = 0;
                         while ($countRepeats < $this->count && !$this->_afterUntil($start)) {
                             $countRepeats += $this->_makeRepeat($start, $end);
                             $currentYear = JevDate::strftime("%Y", $start);
                             list($h, $min, $s, $d, $m, $y) = explode(":", JevDate::strftime("%H:%M:%S:%d:%m:%Y", $start));
                             $maxyear = PHP_INT_SIZE === 8 ? 2999 : 2037;
                             if ($currentYear + $this->rinterval >= $maxyear) {
                                 break;
                             }
                             $start = JevDate::strtotime("+" . $this->rinterval . " years", $start);
                             $end = JevDate::strtotime("+" . $this->rinterval . " years", $end);
                         }
                     } else {
                         $days = explode(",", $this->byday);
                         // duplicate where necessary
                         $extradays = array();
                         foreach ($days as $day) {
                             if (strpos($day, "+") === false && strpos($day, "-") === false) {
                                 for ($i = 2; $i <= 52; $i++) {
                                     $extradays[] = "+" . $i . $day;
                                 }
                             }
                         }
                         $days = array_merge($days, $extradays);
                         $start = $dtstart;
                         $end = $dtend;
                         $countRepeats = 0;
                         // do the current month first
                         while ($countRepeats < $this->count && !$this->_afterUntil($start)) {
                             $currentMonth = JevDate::strftime("%m", $start);
                             foreach ($days as $day) {
                                 if ($countRepeats >= $this->count || $this->_afterUntil($start)) {
                                     return $this->_repetitions;
                                 }
                                 $details = array();
                                 if (strpos($day, "+") === false && strpos($day, "-") === false) {
                                     $day = "+1" . $day;
                                 }
                                 preg_match("/(\\+|-?)(\\d+)(.{2})/", $day, $details);
                                 if (count($details) != 4) {
                                     echo "<br/><br/><b>PROBLEMS with {$day}</b><br/><br/>";
                                     return $this->_repetitions;
                                 } else {
                                     list($temp, $plusminus, $weeknumber, $dayname) = $details;
                                     if (JString::strlen($plusminus) == 0) {
                                         $plusminus = "+";
                                     }
                                     if (JString::strlen($weeknumber) == 0) {
                                         $weeknumber = 1;
                                     }
                                     // always check for dtstart (nothing is allowed earlier)
                                     if ($plusminus == "-") {
                                         //echo "count back $weeknumber weeks on $dayname<br/>";
                                         list($startDay, $startMonth, $startYear, $startWD) = explode(":", JevDate::strftime("%d:%m:%Y:%w", $start));
                                         $startLast = date("t", $start);
                                         $monthEnd = JevDate::mktime(0, 0, 0, $startMonth, $startLast, $startYear);
                                         $meWD = JevDate::strftime("%w", $monthEnd);
                                         $adjustment = $startLast - (7 + $meWD - $weekdayMap[$dayname]) % 7;
                                         $targetstartDay = $adjustment - ($weeknumber - 1) * 7;
                                         $targetendDay = $targetstartDay + $endDay - $startDay;
                                         list($h, $min, $s, $d, $m, $y) = explode(":", JevDate::strftime("%H:%M:%S:%d:%m:%Y", $start));
                                         $testStart = JevDate::mktime($h, $min, $s, $m, $targetstartDay, $y);
                                         if ($currentMonth == JevDate::strftime("%m", $testStart)) {
                                             $targetStart = $testStart;
                                             $targetEnd = $targetStart + $duration;
                                             if ($countRepeats >= $this->count) {
                                                 return $this->_repetitions;
                                             }
                                             if ($targetStart >= $dtstartMidnight && !$this->_afterUntil($targetStart)) {
                                                 $countRepeats += $this->_makeRepeat($targetStart, $targetEnd);
                                             }
                                         }
                                     } else {
                                         //echo "count forward $weeknumber weeks on $dayname<br/>";
                                         list($startDay, $startMonth, $startYear, $startWD) = explode(":", JevDate::strftime("%d:%m:%Y:%w", $start));
                                         $monthStart = JevDate::mktime(0, 0, 0, $startMonth, 1, $startYear);
                                         $msWD = JevDate::strftime("%w", $monthStart);
                                         if (!isset($weekdayMap[$dayname])) {
                                             $x = 1;
                                         }
                                         $adjustment = 1 + (7 + $weekdayMap[$dayname] - $msWD) % 7;
                                         $targetstartDay = $adjustment + ($weeknumber - 1) * 7;
                                         $targetendDay = $targetstartDay + $endDay - $startDay;
                                         list($h, $min, $s, $d, $m, $y) = explode(":", JevDate::strftime("%H:%M:%S:%d:%m:%Y", $start));
                                         $testStart = JevDate::mktime($h, $min, $s, $m, $targetstartDay, $y);
                                         if ($currentMonth == JevDate::strftime("%m", $testStart)) {
                                             $targetStart = $testStart;
                                             $targetEnd = $targetStart + $duration;
                                             if ($countRepeats >= $this->count) {
                                                 return $this->_repetitions;
                                             }
                                             if ($targetStart >= $dtstartMidnight && !$this->_afterUntil($targetStart)) {
                                                 $countRepeats += $this->_makeRepeat($targetStart, $targetEnd);
                                             }
                                         }
                                     }
                                 }
                             }
                             // now ago to the start of the next month
                             $start = $targetStart;
                             $end = $targetEnd;
                             list($h, $min, $s, $d, $m, $y) = explode(":", JevDate::strftime("%H:%M:%S:%d:%m:%Y", $start));
                             if ($y + $this->rinterval + $m / 12 > 2099) {
                                 return $this->_repetitions;
                             }
                             $start = JevDate::mktime($h, $min, $s, $m, 1, $y + $this->rinterval);
                             $end = $start + $duration;
                         }
                     }
                 }
             }
             return $this->_repetitions;
             break;
         case "MONTHLY":
             if ($this->bymonthday == "" && $this->byday == "") {
                 $this->bymonthday = $startDay;
             }
             if ($this->bymonthday != "") {
                 echo "bymonthday" . $this->bymonthday . " <br/>";
                 // if not byday then by monthday
                 $days = explode(",", $this->bymonthday);
                 // If I have byday and bymonthday then the two considions must be met
                 $weekdays = array();
                 if ($this->byday != "") {
                     foreach (explode(",", $this->byday) as $bday) {
                         $weekdays[] = $weekdayMap[$bday];
                     }
                 }
                 $start = $dtstart;
                 $end = $dtend;
                 $countRepeats = 0;
                 $currentMonthStart = JevDate::mktime(0, 0, 0, $startMonth, 1, $startYear);
                 // do the current month first
                 while ($countRepeats < $this->count && !$this->_afterUntil($currentMonthStart)) {
                     //echo $countRepeats ." ".$this->count." ".$currentMonthStart."<br/>";
                     list($currentMonth, $currentYear) = explode(":", JevDate::strftime("%m:%Y", $currentMonthStart));
                     $currentMonthDays = date("t", $currentMonthStart);
                     foreach ($days as $day) {
                         if ($countRepeats >= $this->count || $this->_afterUntil($start)) {
                             return $this->_repetitions;
                         }
                         $details = array();
                         preg_match("/(\\+|-?)(\\d+)/", $day, $details);
                         if (count($details) != 3) {
                             echo "<br/><br/><b>PROBLEMS with {$day}</b><br/><br/>";
                             return $this->_repetitions;
                         } else {
                             list($temp, $plusminus, $daynumber) = $details;
                             if (JString::strlen($plusminus) == 0) {
                                 $plusminus = "+";
                             }
                             if (JString::strlen($daynumber) == 0) {
                                 $daynumber = $startDay;
                             }
                             // always check for dtstart (nothing is allowed earlier)
                             if ($plusminus == "-") {
                                 // must not go before start of month etc.
                                 if ($daynumber > $currentMonthDays) {
                                     continue;
                                 }
                                 echo "I need to check negative bymonth days <br/>";
                                 $targetStart = JevDate::mktime($startHour, $startMin, $startSecond, $currentMonth, $currentMonthDays + 1 - $daynumber, $currentYear);
                                 $targetEnd = $targetStart + $duration;
                                 if ($countRepeats >= $this->count) {
                                     return $this->_repetitions;
                                 }
                                 if ($targetStart >= $dtstartMidnight && !$this->_afterUntil($targetStart)) {
                                     $countRepeats += $this->_makeRepeat($targetStart, $targetEnd);
                                 }
                             } else {
                                 //echo "$daynumber $currentMonthDays bd=".$this->byday." <br/>";
                                 // must not go over end month etc.
                                 if ($daynumber > $currentMonthDays) {
                                     continue;
                                 }
                                 //echo "$startHour,$startMin,$startSecond,$currentMonth,$daynumber,$currentYear<br/>";
                                 $targetStart = JevDate::mktime($startHour, $startMin, $startSecond, $currentMonth, $daynumber, $currentYear);
                                 $targetEnd = $targetStart + $duration;
                                 //echo "$targetStart $targetEnd $dtstartMidnight<br/>";
                                 if ($countRepeats >= $this->count) {
                                     return $this->_repetitions;
                                 }
                                 if ($targetStart >= $dtstartMidnight && !$this->_afterUntil($targetStart)) {
                                     // double check for byday constraints
                                     if ($this->byday != "") {
                                         if (!in_array(JevDate::strftime("%w", $targetStart), $weekdays)) {
                                             continue;
                                         }
                                     }
                                     $countRepeats += $this->_makeRepeat($targetStart, $targetEnd);
                                     //echo "countrepeats = $countRepeats<br/>";
                                 }
                             }
                         }
                     }
                     // now ago to the start of next month
                     if ($currentYear + ($currentMonth + $this->rinterval) / 12 > 2099) {
                         return $this->_repetitions;
                     }
                     $currentMonthStart = JevDate::mktime(0, 0, 0, $currentMonth + $this->rinterval, 1, $currentYear);
                 }
             } else {
                 $days = explode(",", $this->byday);
                 // TODO I should also iterate over week number if this is used
                 //$weeknumbers = explode(",",$this->byweekno);
                 if ($this->bysetpos != "") {
                     $newdays = array();
                     $setpositions = explode(",", $this->bysetpos);
                     foreach ($setpositions as $setposition) {
                         foreach ($days as $day) {
                             if (strpos($setposition, "+") === false && strpos($setposition, "-") === false) {
                                 $setposition = "+" . $setposition;
                             }
                             $newdays[] = $setposition . $day;
                         }
                     }
                     $days = $newdays;
                     $this->byday = implode(",", $days);
                 }
                 $start = $dtstart;
                 $end = $dtend;
                 $countRepeats = 0;
                 $currentMonthStart = JevDate::mktime(0, 0, 0, $startMonth, 1, $startYear);
                 // do the current month first
                 while ($countRepeats < $this->count && !$this->_afterUntil($currentMonthStart)) {
                     list($currentMonth, $currentYear, $currentMonthStartWD) = explode(":", JevDate::strftime("%m:%Y:%w", $currentMonthStart));
                     $currentMonthDays = date("t", $currentMonthStart);
                     $this->sortByDays($days, $currentMonthStart, $dtstart);
                     foreach ($days as $day) {
                         if ($countRepeats >= $this->count || $this->_afterUntil($start)) {
                             return $this->_repetitions;
                         }
                         $details = array();
                         preg_match("/(\\+|-?)(\\d?)(.+)/", $day, $details);
                         if (count($details) != 4) {
                             echo "<br/><br/><b>PROBLEMS with {$day}</b><br/><br/>";
                             return $this->_repetitions;
                         } else {
                             list($temp, $plusminus, $weeknumber, $dayname) = $details;
                             if (JString::strlen($plusminus) == 0) {
                                 $plusminus = "+";
                             }
                             if (JString::strlen($weeknumber) == 0) {
                                 $weeknumber = 1;
                             }
                             $multiplier = $plusminus == "+" ? 1 : -1;
                             // always check for dtstart (nothing is allowed earlier)
                             if ($plusminus == "-") {
                                 //echo "count back $weeknumber weeks on $dayname<br/>";
                                 $startLast = date("t", $currentMonthStart);
                                 $currentMonthEndWD = ($startLast - 1 + $currentMonthStartWD) % 7;
                                 $adjustment = $startLast - (7 + $currentMonthEndWD - $weekdayMap[$dayname]) % 7;
                                 $targetstartDay = $adjustment - ($weeknumber - 1) * 7;
                             } else {
                                 //echo "count forward $weeknumber weeks on $dayname<br/>";
                                 $adjustment = 1 + (7 + $weekdayMap[$dayname] - $currentMonthStartWD) % 7;
                                 $targetstartDay = $adjustment + ($weeknumber - 1) * 7;
                             }
                             $targetStart = JevDate::mktime($startHour, $startMin, $startSecond, $currentMonth, $targetstartDay, $currentYear);
                             if ($currentMonth == JevDate::strftime("%m", $targetStart)) {
                                 $targetEnd = $targetStart + $duration;
                                 if ($countRepeats >= $this->count) {
                                     return $this->_repetitions;
                                 }
                                 if ($targetStart >= $dtstartMidnight && !$this->_afterUntil($targetStart)) {
                                     $countRepeats += $this->_makeRepeat($targetStart, $targetEnd);
                                 }
                             }
                         }
                     }
                     // now go to the start of next month
                     if ($currentYear + ($currentMonth + $this->rinterval) / 12 > 2099) {
                         return $this->_repetitions;
                     }
                     $currentMonthStart = JevDate::mktime(0, 0, 0, $currentMonth + $this->rinterval, 1, $currentYear);
                 }
             }
             return $this->_repetitions;
             break;
         case "WEEKLY":
             $days = explode(",", $this->byday);
             $start = $dtstart;
             $end = $dtend;
             $countRepeats = 0;
             $currentWeekDay = JevDate::strftime("%w", $start);
             // Go to the zero day of the first week (even if this is in the past)
             // this will be the base from which we count the weeks and weekdays
             $currentWeekStart = JevDate::strtotime("-{$currentWeekDay} days", $start);
             // no BYDAY specified
             if ($this->byday == "") {
                 $daynames = array("SU", "MO", "TU", "WE", "TH", "FR", "SA", "SU");
                 $this->byday = "+" . $daynames[$currentWeekDay];
                 $days = array($this->byday);
             }
             while ($countRepeats < $this->count && !$this->_afterUntil($currentWeekStart)) {
                 list($currentDay, $currentMonth, $currentYear) = explode(":", JevDate::strftime("%d:%m:%Y", $currentWeekStart));
                 foreach ($days as $day) {
                     if ($countRepeats >= $this->count || $this->_afterUntil($start)) {
                         return $this->_repetitions;
                     }
                     $details = array();
                     preg_match("/(\\+|-?)(\\d?)(.+)/", $day, $details);
                     if (count($details) != 4) {
                         continue;
                         echo "<br/><br/><b>PROBLEMS with {$day}</b><br/><br/>";
                         return $this->_repetitions;
                     } else {
                         list($temp, $plusminus, $daynumber, $dayname) = $details;
                         if (JString::strlen($plusminus) == 0) {
                             $plusminus = "+";
                         }
                         // this is not relevant for weekly recurrence ?!?!?
                         //if (JString::strlen($daynumber)==0) $daynumber=1;
                         $multiplier = $plusminus == "+" ? 1 : -1;
                         if ($plusminus == "-") {
                             // TODO find out if I ever have this situation?
                             // It would seem meaningless
                         } else {
                             //echo "count forward $daynumber days on $dayname<br/>";
                             $targetstartDay = $currentDay + $weekdayMap[$dayname];
                         }
                         $targetStart = JevDate::mktime($startHour, $startMin, $startSecond, $currentMonth, $targetstartDay, $currentYear);
                         $targetEnd = $targetStart + $duration;
                         if ($countRepeats >= $this->count) {
                             return $this->_repetitions;
                         }
                         if ($targetStart >= $dtstartMidnight && !$this->_afterUntil($targetStart)) {
                             $countRepeats += $this->_makeRepeat($targetStart, $targetEnd);
                         }
                     }
                 }
                 // now go to the start of next week
                 if ($currentYear + $currentMonth / 12 > 2099) {
                     return $this->_repetitions;
                 }
                 $currentWeekStart = JevDate::strtotime("+" . $this->rinterval . " weeks", $currentWeekStart);
             }
             return $this->_repetitions;
             break;
         case "DAILY":
             $start = $dtstart;
             $end = $dtend;
             $countRepeats = 0;
             $startYear = JevDate::strftime("%Y", $start);
             while ($startYear < 2027 && $countRepeats < $this->count && !$this->_afterUntil($start)) {
                 //while ($startYear<5027 && $countRepeats < $this->count && !$this->_afterUntil($start)) {
                 $countRepeats += $this->_makeRepeat($start, $end);
                 $start = JevDate::strtotime("+" . $this->rinterval . " days", $start);
                 $end = JevDate::strtotime("+" . $this->rinterval . " days", $end);
                 $startYear = JevDate::strftime("%Y", $start);
             }
             return $this->_repetitions;
             break;
         case "IRREGULAR":
             $processedDates = array();
             // current date is ALWAYS a repeat
             $processedDates[] = $dtstart;
             $this->_makeRepeat($dtstart, $dtend);
             if (is_string($this->irregulardates) && $this->irregulardates != "") {
                 $this->irregulardates = @json_decode($this->irregulardates);
             }
             if (!is_array($this->irregulardates)) {
                 $this->irregulardates = array();
             }
             sort($this->irregulardates);
             foreach ($this->irregulardates as $irregulardate) {
                 // avoid duplicate values
                 if (in_array($irregulardate, $processedDates)) {
                     continue;
                 }
                 $processedDates[] = $irregulardate;
                 // find the start and end times of the initial event
                 $irregulardate += $dtstart - $dtstartMidnight;
                 $this->_makeRepeat($irregulardate, $irregulardate + $duration);
             }
             return $this->_repetitions;
             break;
         default:
             echo "UNKNOWN TYPE<br/>";
             return $this->_repetitions;
             break;
     }
 }
コード例 #26
0
ファイル: listevents_body.php プロジェクト: madcsaba/li-de
	</div>
</div>
<div class="jev_clear"></div>
<div id='jev_maincal' class='jev_listview'>

	<?php 
$num_events = count($data['rows']);
$chdate = "";
if ($num_events > 0) {
    $hasevents = true;
    for ($r = 0; $r < $num_events; $r++) {
        $row = $data['rows'][$r];
        $event_day_month_year = $row->dup() . $row->mup() . $row->yup();
        // Ensure we reflect multiday setting
        if (!$row->eventOnDate(JevDate::mktime(0, 0, 0, $row->mup(), $row->dup(), $row->yup()))) {
            continue;
        }
        $date = JEventsHTML::getDateFormat($row->yup(), $row->mup(), $row->dup(), 1);
        ?>
			<div class="jev_listrow">
		<ul class='ev_ul'>

					<?php 
        $listyle = 'style="border-color:' . $row->bgcolor() . ';"';
        echo "<li class='ev_td_li' {$listyle}>\n";
        if (!$this->loadedFromTemplate('icalevent.list_row', $row, 0)) {
            $this->viewEventRowNEW($row);
            echo "&nbsp;::&nbsp;";
            $this->viewEventCatRowNEW($row);
        }
コード例 #27
0
            } else {
                $cellclass = 'jev_dayoutofmonth' . ($d == 6 ? ' jev_lastday' : '');
            }
            if (array_key_exists($slot, $currentDay["slots"])) {
                $event = $currentDay["slots"][$slot][0];
                $blocks = $currentDay["slots"][$slot][1];
                $key = $currentDay["slots"][$slot][2];
                // reset class to include block count
                if ($currentDay["monthType"] == "current") {
                    $cellclass = $currentDay["today"] ? 'jev_today jevblocks1' : 'jev_daynoevents jevblocks1';
                } else {
                    $cellclass = 'jev_dayoutofmonth jevblocks1' . ($d == 6 ? ' jev_lastday' : '');
                }
                if ($blocks > 0) {
                    echo '<div class="' . $cellclass . ' jevstart_' . $event->getUnixStartTime() . '" >';
                    $datestp = JevDate::mktime(0, 0, 0, $event->mup(), $event->dup(), $event->yup());
                    $day_link = "<a href='" . $currentDay['link'] . "'>" . substr($event->_startrepeat, 11, 5) . "</a>";
                    echo "<span class='hiddentime'>{$day_link}</span>";
                    if ($cfg->get("flatscalabledayname", 1) && !in_array($datestp, $hiddendatearray) && (!isset($lastdatestp) || $datestp != $lastdatestp)) {
                        $lastdatestp = $datestp;
                        $hiddendatearray[] = $datestp;
                        ?>
										<div class="hiddendayname jev_daysnames" style="display:none">
											<span>
											<?php 
                        $weekday = JevDate::strftime("%w", $currentDay["cellDate"]);
                        // adjust day of week to reflect start day in config
                        $weekday -= $weekstartday;
                        if ($weekday < 0) {
                            $weekday += 7;
                        }
コード例 #28
0
ファイル: jeventcal.php プロジェクト: poorgeek/JEvents
 function getRepeatArray($startPeriod, $endPeriod, $periodEndSecond)
 {
     // NEED TO CHECK MONTH and week overlapping month end
     // builds and returns array
     $eventDays = array();
     // double check the SQL has given us valid events
     $event_start_date = JevDate::mktime(0, 0, 0, $this->_mup, $this->_dup, $this->_yup);
     $event_end_date = JevDate::mktime(0, 0, 0, $this->_mdn, $this->_ddn, $this->_ydn);
     if ($event_end_date < $startPeriod || $event_start_date > $periodEndSecond) {
         return $eventDays;
     }
     $daysInMonth = intval(date("t", $startPeriod));
     list($periodStartDay, $month, $year) = explode(":", date("d:m:Y", $startPeriod));
     $repeatingEvent = false;
     if ($this->_reccurtype != 0 || $this->_reccurday != "" || $this->_reccurweekdays != "" || $this->_reccurweeks != "") {
         $repeatingEvent = true;
     }
     // treat midnight as a special case
     $endsMidnight = false;
     if ($this->_hdn == 0 && $this->_mindn == 0 && $this->_sdn == 0) {
         $endsMidnight = true;
     }
     $multiDayEvent = false;
     if ($this->_dup != $this->_ddn || $this->_mup != $this->_mdn || $this->_yup != $this->_ydn) {
         // should test month/year too!
         $multiDayEvent = true;
     }
     if (!$repeatingEvent) {
         if (!$multiDayEvent) {
             // single day so populate the array and get on with things!
             $eventDays[$event_start_date] = true;
             return $eventDays;
         } else {
             // otherwise a multiday event
             // Find the first and last relevant days
             if ($startPeriod > $event_start_date) {
                 $firstDay = 1;
             } else {
                 $firstDay = intval(date("j", $event_start_date));
             }
             if ($event_end_date > $endPeriod) {
                 $lastDay = $daysInMonth;
             } else {
                 $lastDay = intval(date("j", $event_end_date));
             }
             for ($d = $firstDay; $d <= $lastDay; $d++) {
                 $eventDate = JevDate::mktime(0, 0, 0, $month, $d, $year);
                 // treat midnight as a special case - we don't mark following day as having the event
                 if ($d == $lastDay && $endsMidnight) {
                     continue;
                 }
                 $eventDays[$eventDate] = true;
             }
             return $eventDays;
         }
     }
     // All I'm left with are the repeated events
     //echo "row->reccurtype = $this->_reccurtype $this->_id<br/><br/>CHECK IT OUT - type 2 needs more work!!!<br/><hr/>";
     switch ($this->_reccurtype) {
         case 0:
             // All days
             $this->viewable = true;
             return $this->viewable;
             break;
         case 1:
             // By week - 1* by week
         // By week - 1* by week
         case 2:
             // By week - n* by week
             // This is multi-days per week
             if ($this->_reccurweekdays != "") {
                 $reccurweekdays = explode('|', $this->_reccurweekdays);
                 $countdays = count($reccurweekdays);
             } else {
                 if ($this->_reccurday != "") {
                     $reccurweekdays = array();
                     $tmp_weekday = intval($this->_reccurday);
                     if ($tmp_weekday == -1) {
                         $tmp_weekday = intval(date('w', $event_start_date));
                     }
                     $reccurweekdays[] = $tmp_weekday;
                     $countdays = count($reccurweekdays);
                 } else {
                     echo "Should not really be here <br/>";
                 }
             }
             if (strpos($this->_reccurweeks, "pair") === false) {
                 $repeatweeks = explode('|', $this->_reccurweeks);
             } else {
                 $repeatweeks = array();
             }
             for ($i = 0; $i < $countdays; $i++) {
                 // This is first, second week etc of the months
                 if (count($repeatweeks) > 0) {
                     $daynum_of_first_in_month = intval(date('w', JevDate::mktime(0, 0, 0, $month, 1, $year)));
                     $adjustment = 1 + (7 + $reccurweekdays[$i] - $daynum_of_first_in_month) % 7;
                     // Now find repeat weeks for the month
                     foreach ($repeatweeks as $weeknum) {
                         // first $reccurweekdays[$i] in the month is therefore
                         $next_recurweekday = $adjustment + ($weeknum - 1) * 7;
                         $nextDate = JevDate::mktime(0, 0, 0, $month, $next_recurweekday, $year);
                         if ($nextDate >= $event_start_date && $nextDate <= $event_end_date) {
                             $eventDays[$nextDate] = true;
                         }
                     }
                 } else {
                     // find corrected start date
                     $weekday_of_startdate = date('w', $event_start_date);
                     if ($reccurweekdays[$i] >= 0) {
                         $true_start_day_of_week_for_sequence = $reccurweekdays[$i];
                     } else {
                         $true_start_day_of_week_for_sequence = $weekday_of_startdate;
                     }
                     list($event_start_day, $event_start_month, $event_start_year) = explode(":", date("d:m:Y", $event_start_date));
                     $adjustedStartDay = $event_start_day + (7 + $true_start_day_of_week_for_sequence - $weekday_of_startdate) % 7;
                     $sequence_start_date = JevDate::mktime(0, 0, 0, $event_start_month, $adjustedStartDay, $event_start_year);
                     //echo "event start data : ".date("d:m:Y",$event_start_date)."<br/>";
                     //echo "adj sequence_start_date: ".date("d:m:Y",$sequence_start_date)."<br/>";
                     //echo "month start data : ".date("d:m:Y",$startPeriod)."<br/>";
                     if ($this->_reccurweeks == "pair") {
                         // every 2 weeks
                         // first of month day difference
                         // 60*60*24 = 86400
                         // 86400*14 = 1209600
                         $delta = (1209600 + $sequence_start_date - $startPeriod) % 1209600;
                         $deltadays = round($delta / 86400, 0);
                         for ($weeks = 0; $weeks < 6; $weeks++) {
                             $nextDate = JevDate::mktime(0, 0, 0, $month, $periodStartDay + $deltadays + 14 * $weeks, $year);
                             if ($nextDate <= $endPeriod) {
                                 if ($nextDate >= $event_start_date && $nextDate <= $event_end_date) {
                                     $eventDays[$nextDate] = true;
                                 }
                             } else {
                                 break;
                             }
                         }
                     } else {
                         if ($this->_reccurweeks == "impair") {
                             // every 3 weeks
                             // every 2 weeks
                             // first of month day difference
                             // 60*60*24 = 86400
                             // 86400*21 = 1814400
                             $delta = (1814400 + $sequence_start_date - $startPeriod) % 1814400;
                             $deltadays = round($delta / 86400, 0);
                             for ($weeks = 0; $weeks < 6; $weeks++) {
                                 $nextDate = JevDate::mktime(0, 0, 0, $month, $periodStartDay + $deltadays + 21 * $weeks, $year);
                                 if ($nextDate <= $endPeriod) {
                                     if ($nextDate >= $event_start_date && $nextDate <= $event_end_date) {
                                         $eventDays[$nextDate] = true;
                                     }
                                 } else {
                                     break;
                                 }
                             }
                         }
                     }
                 }
             }
             return $eventDays;
             break;
         case 3:
             // By month - 1* by month
             if ($this->_reccurday == -1) {
                 //by day number
                 list($event_start_day, $event_start_month, $event_start_year) = explode(":", date("d:m:Y", $event_start_date));
                 $nextDate = JevDate::mktime(0, 0, 0, $month, $event_start_day, $year);
                 if ($nextDate >= $event_start_date && $nextDate <= $event_end_date) {
                     $eventDays[$nextDate] = true;
                 }
             } else {
                 //by day name following the day number
                 list($event_start_day, $event_start_month, $event_start_year) = explode(":", date("d:m:Y", $event_start_date));
                 $equiv_day_of_month = JevDate::mktime(0, 0, 0, $month, $event_start_day, $year);
                 $weekday_of_equivalent = date('w', $equiv_day_of_month);
                 $temp = $event_start_day + (7 + $this->_reccurday - $weekday_of_equivalent) % 7;
                 $nextDate = JevDate::mktime(0, 0, 0, $month, $temp, $year);
                 if ($nextDate >= $event_start_date && $nextDate <= $event_end_date) {
                     $eventDays[$nextDate] = true;
                 }
             }
             return $eventDays;
             break;
         case 4:
             // By month - end of the month
             // get month end
             list($lastday, $month, $year) = explode(":", date("t:m:Y", $endPeriod));
             $monthEnd = JevDate::mktime(0, 0, 0, $month, $lastday, $year);
             if ($monthEnd >= $event_start_date && $monthEnd <= $event_end_date) {
                 $eventDays[$monthEnd] = true;
             }
             return $eventDays;
             break;
         case 5:
             // By year - 1* by year
             list($event_start_day, $event_start_month, $event_start_year) = explode(":", date("d:m:Y", $event_start_date));
             if ($month == $event_start_month) {
                 if ($this->_reccurday == -1) {
                     //by day number
                     $nextDate = JevDate::mktime(0, 0, 0, $month, $event_start_day, $year);
                     if ($nextDate >= $event_start_date && $nextDate <= $event_end_date) {
                         $eventDays[$nextDate] = true;
                     }
                 } else {
                     //by day name following the day number
                     list($event_start_day, $event_start_month, $event_start_year) = explode(":", date("d:m:Y", $event_start_date));
                     $equiv_day_of_month = JevDate::mktime(0, 0, 0, $month, $event_start_day, $year);
                     $weekday_of_equivalent = date('w', $equiv_day_of_month);
                     $temp = $event_start_day + (7 + $this->_reccurday - $weekday_of_equivalent) % 7;
                     $nextDate = JevDate::mktime(0, 0, 0, $month, $temp, $year);
                     if ($nextDate >= $event_start_date && $nextDate <= $event_end_date) {
                         $eventDays[$nextDate] = true;
                     }
                 }
             }
             return $eventDays;
             break;
         default:
             return $eventDays;
             break;
     }
 }
コード例 #29
0
 function fixDtstart()
 {
     // must only ever do this once!
     if (isset($this->dtfixed) && $this->dtfixed) {
         return;
     }
     $this->dtfixed = 1;
     $db =& JFactory::getDBO();
     // Now get the first repeat since dtstart may have been set in a different timezeone and since it is a unixdate it would then be wrong
     if (strtolower($this->freq()) == "none") {
         $repeat = $this->getFirstRepeat();
         $this->dtstart($repeat->getUnixStartTime());
         $this->dtend($repeat->getUnixEndTime());
     } else {
         $repeat = $this->getFirstRepeat();
         // Is this repeat an exception?
         $db->setQuery("SELECT * FROM #__jevents_exception WHERE rp_id=" . intval($repeat->rp_id()));
         $exception = $db->loadObject();
         if (!$exception) {
             $this->dtstart($repeat->getUnixStartTime());
             $this->dtend($repeat->getUnixEndTime());
         } else {
             // This is the scenario where the first repeat is an exception so check to see if we need to be worried
             $jregistry =& JRegistry::getInstance("jevents");
             // This is the server default timezone
             $jtimezone = $jregistry->getValue("jevents.timezone", false);
             if ($jtimezone) {
                 // This is the JEvents set timezone
                 $timezone = date_default_timezone_get();
                 // Only worry if the JEvents  set timezone is different to the server timezone
                 if ($timezone != $jtimezone) {
                     // look for repeats that are not exceptions
                     $repeat2 = $this->getFirstRepeat(false);
                     // if we have none then use the first repeat and give a warning
                     if (!$repeat2) {
                         $this->dtstart($repeat->getUnixStartTime());
                         $this->dtend($repeat->getUnixEndTime());
                         JFactory::getApplication()->enqueueMessage(JText::_('JEV_PLEASE_CHECK_START_AND_END_TIMES_FOR_THIS_EVENT'));
                     } else {
                         // Calculate the time adjustment (if any) then check against the non-exceptional repeat
                         // Convert dtstart using system timezone to date
                         date_default_timezone_set($jtimezone);
                         $truestarttime = JevDate::strftime("%H:%M:%S", $this->dtstart());
                         // if the system timezone version of dtstart is the same time as the first non-exceptional repeat
                         // then we are safe to use this adjustment mechanism to dtstart.  We use the real "date" and convert
                         // back into unix time using the  Jevents timezone
                         if ($truestarttime == JevDate::strftime("%H:%M:%S", JevDate::mktime($repeat2->hup(), $repeat2->minup(), $repeat2->sup(), 0, 0, 0))) {
                             $truedtstart = JevDate::strftime("%Y-%m-%d %H:%M:%S", $this->dtstart());
                             $truedtend = JevDate::strftime("%Y-%m-%d %H:%M:%S", $this->dtend());
                             // switch timezone back to Jevents timezone
                             date_default_timezone_set($timezone);
                             $this->dtstart(JevDate::strtotime($truedtstart));
                             $this->dtend(JevDate::strtotime($truedtend));
                         } else {
                             // In this scenario we have no idea what the time should be unfortunately
                             JFactory::getApplication()->enqueueMessage(JText::_('JEV_PLEASE_CHECK_START_AND_END_TIMES_FOR_THIS_EVENT'));
                             // switch timezone back
                             date_default_timezone_set($timezone);
                         }
                     }
                 }
             }
         }
     }
 }