コード例 #1
0
 /**
  * Generates the HTML markup for the calendar grid
  * @access public
  * @return string The HTML markup of the calendar
  */
 function get_calendar_markup()
 {
     $calendar_data = get_calendar_data_for_month($this->view_year, $this->view_month);
     $now_year = date('Y');
     $now_month = date('m');
     $now_day = date('j');
     if ($this->view_year == $now_year && $this->view_month == $now_month) {
         $this->date_classes[$now_day][] = 'today';
     }
     if (empty($this->date_classes[$this->view_day]) || !in_array('currentlyViewing', $this->date_classes[$this->view_day])) {
         $this->date_classes[$this->view_day][] = 'currentlyViewing';
     }
     $calendar_markup = '<div class="' . $this->wrapper_class . '">' . "\n";
     // previous month link
     if (!empty($this->previous_month_query_string)) {
         $calendar_markup .= '<a href="' . $this->previous_month_query_string . '" title="' . $this->get_previous_month_name() . '" class="previous">«</a>';
     }
     // month and year we are currently viewing
     $calendar_markup .= '<' . $this->heading_tag . '>' . date('F Y', mktime(0, 0, 0, $this->view_month, 1, $this->view_year)) . '</' . $this->heading_tag . '>';
     // next month link
     if (!empty($this->next_month_query_string)) {
         $calendar_markup .= '<a href="' . $this->next_month_query_string . '" title="' . $this->get_next_month_name() . '" class="next">»</a>';
     }
     //set up table (without data)
     $calendar_markup .= '<table summary="' . htmlspecialchars($this->table_summary) . '">' . "\n";
     $calendar_markup .= '<tr>' . "\n";
     foreach ($this->weekdays as $weekday => $abbreviation) {
         $calendar_markup .= '<th>' . $abbreviation . '</th>' . "\n";
     }
     $calendar_markup .= '</tr>' . "\n";
     //add data
     foreach ($calendar_data as $week_num => $week_values) {
         $calendar_markup .= '<tr>' . "\n";
         foreach ($this->weekdays as $weekday => $abbreviation) {
             if (!empty($week_values[$weekday])) {
                 $day = $week_values[$weekday];
                 if (!empty($this->date_classes[$day])) {
                     $calendar_markup .= '<td class="' . implode(' ', $this->date_classes[$day]) . '">';
                 } else {
                     $calendar_markup .= '<td>';
                 }
                 if (!empty($this->linked_dates[$day])) {
                     $link = $this->linked_dates[$day];
                     $title = 'View ' . date('j F Y', mktime(0, 0, 0, $this->view_month, $day, $this->view_year));
                     $calendar_markup .= '<a href="' . $link . '" title="' . $title . '">' . $day . '</a>';
                 } else {
                     $calendar_markup .= $day;
                 }
                 $calendar_markup .= '</td>' . "\n";
             } else {
                 $calendar_markup .= '<td></td>' . "\n";
             }
         }
         $calendar_markup .= '</tr>' . "\n";
     }
     $calendar_markup .= '</table>' . "\n";
     $calendar_markup .= '</div>' . "\n";
     return $calendar_markup;
 }
コード例 #2
0
ファイル: events.php プロジェクト: natepixel/reason_package
	/**
	 * Get the calendar grid links for a given month
	 *
	 * @param string $year e.g. 2014
	 * @param string $month e.g. 07
	 * @return array('YYYY-MM-DD' => 'link-to-view', 'YYYY-MM-DD' => 'linko-to-view', ...)
	 */
	function get_calendar_grid_links($year, $month)
	{
		$links = array();
		$weeks = get_calendar_data_for_month( $year, $month );
		if(!empty($this->request['view']) && $this->request['view'] != 'all')
			$pass_view_val = $this->request['view'];
		else
			$pass_view_val = '';
		foreach($weeks as $week)
		{
			foreach($week as $day)
			{
				$date = $year.'-'.$month.'-'.str_pad($day,2,'0',STR_PAD_LEFT);
				$links[$day] =  $this->construct_link(array('start_date'=>$date,'view'=>$pass_view_val,'no_search'=>'1'));
			}
		}
		return $links;
	}