コード例 #1
0
ファイル: code_calendar.php プロジェクト: rair/yacs
 /**
  * render a calendar
  *
  * The provided anchor can reference:
  * - a section 'section:123'
  * - nothing
  *
  * @param string the anchor (e.g. 'section:123')
  * @return string the rendered text
  **/
 public function render($matches)
 {
     global $context;
     $anchor = count($matches) ? $matches[0] : '';
     // a list of dates
     include_once $context['path_to_root'] . 'dates/dates.php';
     // get records
     if ($anchor && strpos($anchor, 'section:') === 0) {
         $items = Dates::list_for_prefix(NULL, 'compact', trim($anchor));
     } else {
         $items = Dates::list_for_prefix(NULL, 'compact', NULL);
     }
     // build calendar for current month
     $text = Dates::build_months($items, FALSE, TRUE, FALSE, TRUE, gmstrftime('%Y'), gmstrftime('%m'), 'compact calendar');
     // job done
     return $text;
 }
コード例 #2
0
ファイル: dates.php プロジェクト: rair/yacs
 /**
  * list all dates for one month
  *
  * Provide an anchor reference to limit the scope of the list.
  *
  * @param int the year
  * @param int the month, from 1 to 12, or -1 for the full year
  * @param string the list variant, if any
  * @param string reference an target anchor (e.g., 'section:123'), if any
  * @return NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $type, $icon, $date)
  */
 public static function &list_for_month($year, $month, $variant = 'links', $anchor = NULL)
 {
     global $context;
     // check the year
     if ($year < 1970) {
         $year = (int) strftime('%Y');
     }
     // check the month
     if ($month >= 1 && $month <= 12) {
         $prefix = strftime('%Y-%m-', mktime(0, 0, 0, $month, 1, $year));
     } else {
         $prefix = strftime('%Y-', mktime(0, 0, 0, 1, 1, $year));
     }
     // the list of dates
     $output =& Dates::list_for_prefix($prefix, $variant, $anchor);
     return $output;
 }