function index() { global $viewhelper; require CACHE_COMMON_PATH . "cache_type.php"; $title = L("industry_info", "tpl"); //cal require CLASS_PATH . "calendar.class.php"; $cal = new Calendar(); $cal->setMonthNames(explode(",", L("month_unit", "tpl"))); $cal->setDayNames(explode(",", L("week_unit", "tpl"))); $d = getdate(time()); $day = $_GET['day']; if ($day == "") { $day = $d['mday']; } $month = $_GET['month']; if ($month == "") { $month = $d["mon"]; } $year = $_GET['year']; if ($year == "") { $year = $d["year"]; } if (isset($_GET['year']) && isset($_GET['month']) && isset($_GET['day'])) { $title .= L("journal", "tpl", $year . $month . $day); setvar("date_line", $year . "-" . $month . "-" . $day); } $viewhelper->setTitle($title); setvar("Calendar", $cal->getMonthView($month, $year)); $cache_id = $year . $month . $day; //end cal render("news/index"); }
/** * возвращает календарь. хтмл. */ public function calendar() { $this->__loadLib("calendar.php"); $this->__implement("calendar"); $year = getRequest('year') ? (int) getRequest('year') : date('Y'); $month = getRequest('month') ? (int) getRequest('month') : date('m'); $calendar = new Calendar(); $lang_id = cmsController::getInstance()->getCurrentLang()->getId(); $lang = langsCollection::getInstance()->getLang($lang_id); if ($lang->getPrefix() == "ru") { $calendar->setMonthNames(array("Январь", "Февраль", "Март", "Апрель", "Май", "Июнь", "Июль", "Август", "Сентябрь", "Октябрь", "Ноябрь", "Декабрь")); $calendar->setDayNames(array("Вс", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб")); $calendar->setStartDay(1); } $result = $calendar->getMonthView($month, $year); return $result; }
function display_page_content() { $event_types = EventTypes::FindAll(); $year = getRequestVarAtIndex(2); $month = getRequestVarAtIndex(3); $day = getRequestVarAtIndex(4); $event_id = getRequestVarAtIndex(5); ?> <script language="javascript" type="text/javascript"> //<![CDATA[ $().ready(function() { $("#eventtype").change(function() { var selected = $("#eventtype").val(); if(selected == "All") { $("table.calendarTable td a").show(); } else { $("table.calendarTable td a:not(." + selected + ")").hide(); $("." + selected).show(); } }); }); //]]> </script> <?php if ($event_id != "") { $event = Events::FindById($event_id); $cal = new Calendar(); echo $cal->getMiniMonthView("events", "calendar", $month, $year, $day, $event_id); ?> <div class="event_details"> <h1><?php echo $event->title; ?> </h1> <h3><?php echo $event->getDateRangeString(); ?> </h3> <div class="event_description"> <?php echo $event->getDescription(); ?> </div> </div> <?php } else { if ($day != "") { $event = Events::FindAllForDate($day, $month, $year); $cal = new Calendar(); echo $cal->getMiniMonthView("events", "calendar", $month, $year, $day, $event_id); if (substr($day, 0, 1) == "0") { $properday = substr($day, 1, 1); } else { $properday = $day; } echo "\t\t\t<h2>Events for " . getFullMonthName($month) . " " . $properday . ", " . $year . "</h2>\n"; foreach ($event as $theevent) { ?> <div class="event_details"> <h1><?php echo $theevent->title; ?> </h1> <h3><?php echo $theevent->getDateRangeString(); ?> </h3> <div class="event_description"> <?php echo chopText($theevent->getDescription(true), 100); ?> </div> <a href="<?php echo get_link("/events/calendar/{$year}/{$month}/{$day}/{$theevent->id}"); ?> ">Read More</a> </div> <?php } } else { ?> <p>Below is our Event Calendar engine, which displays all the past and future events for your website. Use the double arrows to go back or forward in time and view previous or upcoming months. Click on any event to find out more about it. Notice how we can handle recurring events – repetitive events every week, every first day, second, third, or last. </p> <select name="eventtype" id="eventtype"> <?php echo "<option value='All' selected>All Events</option>"; foreach ($event_types as $event_type) { echo "<option value='{$event_type->slug()}' "; echo ">{$event_type->name}</option>\r\n"; } ?> </select> <p> </p> <?php $cal = new Calendar(); if ($month != "" && $year != "") { echo $cal->getMonthView($month, $year); } else { echo $cal->getCurrentMonthView(); } } } // end the if statement }
uses("news", "newstype"); $news = new Newses(); $newstype = new Newstypes(); $title = L("industry_info", "tpl"); //cal require "../libraries/calendar.class.php"; $cal = new Calendar(); $cal->setMonthNames(explode(",", L("month_unit", "tpl"))); $cal->setDayNames(explode(",", L("week_unit", "tpl"))); $d = getdate(time()); $day = $_GET['day']; if ($day == "") { $day = $d['mday']; } $month = $_GET['month']; if ($month == "") { $month = $d["mon"]; } $year = $_GET['year']; if ($year == "") { $year = $d["year"]; } if (isset($_GET['year']) && isset($_GET['month']) && isset($_GET['day'])) { $title .= L("journal", "tpl", $year . $month . $day); setvar("date_line", $year . "-" . $month . "-" . $day); } $viewhelper->setTitle($title); setvar("Calendar", $cal->getMonthView($month, $year)); $cache_id = $year . $month . $day; //end cal render("news/index");
private function getDayList(array $options, array $query) { $result = ''; $instance = $this->host; $taglist = $this->getTagList($query); $root = $options['root']; $year = $options['year']; $month = $options['month']; $url = bebop_split_url(); $sql = "SELECT DAY(`n`.`created`) AS `day`, COUNT(*) AS `count` " . "FROM `node` `n` WHERE `n`.`id` IN " . "(SELECT `nid` FROM `node__rel` WHERE `tid` IN ({$taglist})) " . "AND YEAR(`n`.`created`) = :year AND MONTH(`n`.`created`) = :month " . "AND `n`.`published` = 1 " . "AND `n`.`deleted` = 0 " . "GROUP BY `day` ORDER BY `day`"; // Список задействованных дней. // FIXME: publishing $days = $this->ctx->db->getResultsKV("day", "count", $sql, array(':year' => $year, ':month' => $month)); // Список месяцев. $months = array('Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'); // Получаем карту этого месяца. $cal = new Calendar(); $map = $cal->getMonthView($month, $year); $result = "<table class='calendar' id='{$instance}-calendar'><tr>"; // Предыдущий месяц. $tmp = $url; if (--$tmp['args'][$instance]['month'] == 0) { $tmp['args'][$instance]['year']--; $tmp['args'][$instance]['month'] = 12; } $result .= "<th class='prev'><a href='" . bebop_combine_url($tmp) . "' title='{$months[$tmp['args'][$instance]['month'] - 1]}'><span>←</span></a></th>"; // Текущий месяц. $result .= "<th colspan='5' class='current'><span>{$months[$month - 1]}</span></th>"; // Следующий месяц. $tmp = $url; if (++$tmp['args'][$instance]['month'] == 13) { $tmp['args'][$instance]['year']++; $tmp['args'][$instance]['month'] = 1; } $result .= "<th class='next'><a href='" . bebop_combine_url($tmp) . "' title='{$months[$tmp['args'][$instance]['month'] - 1]}'><span>→</span></a></th></tr>"; // Недели. foreach ($map as $week) { $result .= "<tr>"; foreach ($week as $day) { $result .= "<td>"; if (empty($day)) { $result .= " "; } elseif (empty($days[$day])) { $result .= $day; } else { $url['args'][$instance]['day'] = $day; $url['args'][$instance]['page'] = null; $result .= "<a href='" . bebop_combine_url($url) . "'>{$day}</a>"; } $result .= "</td>"; } $result .= "</tr>"; } $result .= "</table>"; return $result; }