Changeset 25507 for trunk/include/calendar_weekly.class.php
- Timestamp:
- Nov 17, 2013, 4:03:32 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/calendar_weekly.class.php
r25018 r25507 22 22 // +-----------------------------------------------------------------------+ 23 23 24 /** 25 * @package functions\calendar 26 */ 27 24 28 include_once(PHPWG_ROOT_PATH.'include/calendar_base.class.php'); 25 29 26 define ('CYEAR', 0); 27 define ('CWEEK', 1); 28 define ('CDAY', 2); 30 /** level of year view */ 31 define('CYEAR', 0); 32 /** level of week view */ 33 define('CWEEK', 1); 34 /** level of day view */ 35 define('CDAY', 2); 36 29 37 30 38 /** … … 33 41 class Calendar extends CalendarBase 34 42 { 35 36 43 /** 37 44 * Initialize the calendar 38 * @param string inner_sql used for queries (INNER JOIN or normal)45 * @param string $inner_sql 39 46 */ 40 47 function initialize($inner_sql) … … 73 80 } 74 81 75 /** 76 * Generate navigation bars for category page 77 * @return boolean false to indicate that thumbnails where not included here 78 */ 79 function generate_category_content() 80 { 81 global $conf, $page; 82 /** 83 * Generate navigation bars for category page. 84 * 85 * @return boolean false indicates that thumbnails where not included 86 */ 87 function generate_category_content() 88 { 89 global $conf, $page; 82 90 83 if ( count($page['chronology_date'])==0 ) 84 { 85 $this->build_nav_bar(CYEAR); // years 86 } 87 if ( count($page['chronology_date'])==1 ) 88 { 89 $this->build_nav_bar(CWEEK, array()); // week nav bar 1-53 90 } 91 if ( count($page['chronology_date'])==2 ) 92 { 93 $this->build_nav_bar(CDAY); // days nav bar Mon-Sun 94 } 95 $this->build_next_prev(); 96 return false; 97 } 98 99 100 /** 101 * Returns a sql where subquery for the date field 102 * @param int max_levels return the where up to this level 103 * (e.g. 2=only year and week in year) 104 * @return string 105 */ 106 function get_date_where($max_levels=3) 107 { 108 global $page; 109 $date = $page['chronology_date']; 110 while (count($date)>$max_levels) 111 { 112 array_pop($date); 113 } 114 $res = ''; 115 if (isset($date[CYEAR]) and $date[CYEAR]!=='any') 116 { 117 $y = $date[CYEAR]; 118 $res = " AND $this->date_field BETWEEN '$y-01-01' AND '$y-12-31 23:59:59'"; 91 if ( count($page['chronology_date'])==0 ) 92 { 93 $this->build_nav_bar(CYEAR); // years 94 } 95 if ( count($page['chronology_date'])==1 ) 96 { 97 $this->build_nav_bar(CWEEK, array()); // week nav bar 1-53 98 } 99 if ( count($page['chronology_date'])==2 ) 100 { 101 $this->build_nav_bar(CDAY); // days nav bar Mon-Sun 102 } 103 $this->build_next_prev(); 104 return false; 119 105 } 120 106 121 if (isset($date[CWEEK]) and $date[CWEEK]!=='any') 107 /** 108 * Returns a sql WHERE subquery for the date field. 109 * 110 * @param int $max_levels (e.g. 2=only year and month) 111 * @return string 112 */ 113 function get_date_where($max_levels=3) 122 114 { 123 $res .= ' AND '.$this->calendar_levels[CWEEK]['sql'].'='.$date[CWEEK]; 115 global $page; 116 $date = $page['chronology_date']; 117 while (count($date)>$max_levels) 118 { 119 array_pop($date); 120 } 121 $res = ''; 122 if (isset($date[CYEAR]) and $date[CYEAR]!=='any') 123 { 124 $y = $date[CYEAR]; 125 $res = " AND $this->date_field BETWEEN '$y-01-01' AND '$y-12-31 23:59:59'"; 126 } 127 128 if (isset($date[CWEEK]) and $date[CWEEK]!=='any') 129 { 130 $res .= ' AND '.$this->calendar_levels[CWEEK]['sql'].'='.$date[CWEEK]; 131 } 132 if (isset($date[CDAY]) and $date[CDAY]!=='any') 133 { 134 $res .= ' AND '.$this->calendar_levels[CDAY]['sql'].'='.$date[CDAY]; 135 } 136 if (empty($res)) 137 { 138 $res = ' AND '.$this->date_field.' IS NOT NULL'; 139 } 140 return $res; 124 141 } 125 if (isset($date[CDAY]) and $date[CDAY]!=='any')126 {127 $res .= ' AND '.$this->calendar_levels[CDAY]['sql'].'='.$date[CDAY];128 }129 if (empty($res))130 {131 $res = ' AND '.$this->date_field.' IS NOT NULL';132 }133 return $res;134 }135 136 142 } 137 143
Note: See TracChangeset
for help on using the changeset viewer.