- Timestamp:
- Mar 17, 2006, 5:13:19 AM (19 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/category.php
r1084 r1086 132 132 $icon_recent = get_icon(date('Y-m-d')); 133 133 134 $calendar_view_link = duplicate_index_URL( 135 array(), // nothing to redefine 136 array('chronology_type', 'start') // what to remove ? 137 ); 138 139 if (!isset($page['chronology_type'])) 140 { 141 $calendar_view_link.= '/calendar-'; 142 134 if (!isset($page['chronology'])) 135 { 136 $chronology = 137 array( 138 'chronology' => 139 array( 140 'field' => 'created', 141 'style' => 'monthly', 142 'view' => 'list', 143 ) 144 ); 143 145 $template->assign_block_vars( 144 146 'mode_created', 145 147 array( 146 'URL' => $calendar_view_link.'created' 147 ) 148 ); 149 148 'URL' => duplicate_index_URL( $chronology, array('start') ) 149 ) 150 ); 151 152 $chronology['chronology']['field'] = 'posted'; 150 153 $template->assign_block_vars( 151 154 'mode_posted', 152 155 array( 153 'URL' => $calendar_view_link.'posted'156 'URL' => duplicate_index_URL( $chronology, array('start') ) 154 157 ) 155 158 ); … … 160 163 'mode_normal', 161 164 array( 162 'URL' => $calendar_view_link 163 ) 164 ); 165 166 $calendar_view_link .= '/calendar-'; 167 if ($page['chronology_type'] == 'created') 168 { 169 $template->assign_block_vars( 170 'mode_posted', 171 array( 172 'URL' => $calendar_view_link.'posted' 173 ) 174 ); 165 'URL' => duplicate_index_URL( array(), array('chronology','start') ) 166 ) 167 ); 168 169 $chronology = $page['chronology']; 170 if ($chronology['field'] == 'created') 171 { 172 $chronology['field'] = 'posted'; 175 173 } 176 174 else 177 175 { 178 $template->assign_block_vars( 179 'mode_created', 180 array( 181 'URL' => $calendar_view_link.'created' 182 ) 183 ); 184 } 176 $chronology['field'] = 'created'; 177 } 178 $url = duplicate_index_URL( 179 array( 180 'chronology'=>$chronology 181 ), 182 array('chronology_date', 'start') 183 ); 184 $template->assign_block_vars( 185 'mode_'.$chronology['field'], 186 array('URL' => $url ) 187 ); 185 188 } 186 189 … … 294 297 array( 295 298 'URL' => 296 make_index_URL() 297 .'/calendar-' 298 .($conf['calendar_datefield'] == 'date_available' ? 'posted' : 'created') 299 .'-monthly-c', 299 make_index_URL( 300 array( 301 'chronology'=> 302 array( 303 'field' => ($conf['calendar_datefield']=='date_available' ? 'posted' : 'created'), 304 'style' => 'monthly', 305 'view' => 'calendar' 306 ) 307 ) 308 ), 300 309 'TITLE' => $lang['calendar_hint'], 301 310 'NAME' => $lang['calendar'] -
trunk/include/calendar_base.class.php
r1069 r1086 34 34 // used for queries (INNER JOIN or normal) 35 35 var $inner_sql; 36 // base url used when generating html links37 var $url_base;38 // array of date components e.g. (2005,10,12) ...39 var $date_components;40 36 // 41 37 var $calendar_levels; … … 45 41 /** 46 42 * Initialize the calendar 47 * @param string date_field db column on which this calendar works48 43 * @param string inner_sql used for queries (INNER JOIN or normal) 49 * @param array date_components 50 */ 51 function initialize($date_field, $inner_sql, $date_components) 52 { 53 $this->date_field = $date_field; 44 */ 45 function initialize($inner_sql) 46 { 47 global $page; 48 if ($page['chronology']['field']=='posted') 49 { 50 $this->date_field = 'date_available'; 51 } 52 else 53 { 54 $this->date_field = 'date_creation'; 55 } 54 56 $this->inner_sql = $inner_sql; 55 $this->date_components = $date_components;56 57 $this->has_nav_bar = false; 57 58 } … … 59 60 function get_display_name() 60 61 { 61 global $conf ;62 global $conf, $page; 62 63 $res = ''; 63 $url = $this->url_base; 64 65 for ($i=0; $i<count($this->date_components); $i++) 64 65 for ($i=0; $i<count($page['chronology_date']); $i++) 66 66 { 67 67 $res .= $conf['level_separator']; 68 if ( $i>0)69 { 70 $ url .= '-';71 }72 $url .= $this->date_components[$i];73 if ( isset($this->date_components[$i+1]))74 {68 if ( isset($page['chronology_date'][$i+1]) ) 69 { 70 $chronology_date = array_slice($page['chronology_date'],0, $i+1); 71 $url = duplicate_index_url( 72 array( 'chronology_date'=>$chronology_date ), 73 array( 'start' ) 74 ); 75 75 $res .= 76 76 '<a href="'.$url.'">' 77 .$this->get_date_component_label($i, $ this->date_components[$i])77 .$this->get_date_component_label($i, $page['chronology_date'][$i]) 78 78 .'</a>'; 79 79 } … … 82 82 $res .= 83 83 '<span class="calInHere">' 84 .$this->get_date_component_label($i, $ this->date_components[$i])84 .$this->get_date_component_label($i, $page['chronology_date'][$i]) 85 85 .'</span>'; 86 86 } … … 132 132 * Creates a calendar navigation bar. 133 133 * 134 * @param string url_base - links start with this root134 * @param array date_components 135 135 * @param array items - hash of items to put in the bar (e.g. 2005,2006) 136 136 * @param array selected_item - item currently selected (e.g. 2005) … … 141 141 * @return string the navigation bar 142 142 */ 143 function get_nav_bar_from_items($ url_base, $items, $selected_item,143 function get_nav_bar_from_items($date_components, $items, $selected_item, 144 144 $class_prefix, $show_any, 145 145 $show_empty=false, $labels=null) 146 146 { 147 global $conf ;147 global $conf, $page; 148 148 149 149 $nav_bar = ''; … … 181 181 { 182 182 $nav_bar .= '<span class="'.$class_prefix.'">'; 183 $url = $url_base . $item; 183 $url = duplicate_index_url( 184 array('chronology_date'=>array_merge($date_components,$item)), 185 array( 'start' ) 186 ); 184 187 $nav_bar .= '<a href="'.$url.'">'; 185 188 $nav_bar .= $label; … … 204 207 { 205 208 $nav_bar .= '<span class="'.$class_prefix.'">'; 206 $url = $url_base . 'any'; 209 $url = duplicate_index_url( 210 array('chronology_date'=>array_merge($date_components,'any')), 211 array( 'start' ) 212 ); 207 213 $nav_bar .= '<a href="'.$url.'">'; 208 214 $nav_bar .= $label; … … 222 228 function build_nav_bar($level, $labels=null) 223 229 { 224 global $template, $conf ;230 global $template, $conf, $page; 225 231 226 232 $query = ' … … 241 247 242 248 if ( count($level_items)==1 and 243 count($ this->date_components)<count($this->calendar_levels)-1)244 { 245 if ( ! isset($ this->date_components[$level]) )249 count($page['chronology_date'])<count($this->calendar_levels)-1) 250 { 251 if ( ! isset($page['chronology_date'][$level]) ) 246 252 { 247 253 list($key) = array_keys($level_items); 248 $ this->date_components[$level] = (int)$key;249 250 if ( $level<count($ this->date_components) and254 $page['chronology_date'][$level] = (int)$key; 255 256 if ( $level<count($page['chronology_date']) and 251 257 $level!=count($this->calendar_levels)-1 ) 252 258 { … … 256 262 } 257 263 258 $url_base = $this->url_base;259 for ($i=0; $i<$level; $i++)260 {261 if (isset($this->date_components[$i]))262 {263 $url_base .= $this->date_components[$i].'-';264 }265 }266 264 $nav_bar = $this->get_nav_bar_from_items( 267 $ url_base,265 $page['chronology_date'], 268 266 $level_items, 269 267 null, … … 289 287 function build_next_prev() 290 288 { 291 global $template ;289 global $template, $page; 292 290 $prev = $next =null; 293 if ( empty($ this->date_components) )291 if ( empty($page['chronology_date']) ) 294 292 return; 295 293 $query = 'SELECT CONCAT_WS("-"'; 296 for ($i=0; $i<count($ this->date_components); $i++)297 { 298 if ( 'any' === $ this->date_components[$i] )294 for ($i=0; $i<count($page['chronology_date']); $i++) 295 { 296 if ( 'any' === $page['chronology_date'] ) 299 297 { 300 298 $query .= ','.'"any"'; … … 305 303 } 306 304 } 307 $current = implode('-', $ this->date_components);305 $current = implode('-', $page['chronology_date'] ); 308 306 309 307 $query.=') as period' . $this->inner_sql .' … … 328 326 $template->assign_block_vars( 'calendar.navbar', array() ); 329 327 } 328 330 329 if ( $current_rank>0 ) 331 330 { // has previous 332 331 $prev = $upper_items[$current_rank-1]; 332 $chronology_date = explode('-', $prev); 333 333 $template->assign_block_vars( 334 334 'calendar.navbar.prev', 335 335 array( 336 336 'LABEL' => $this->get_date_nice_name($prev), 337 'URL' => $this->url_base . $prev, 337 'URL' => duplicate_index_url( 338 array('chronology_date'=>$chronology_date), array('start') 339 ) 338 340 ) 339 341 ); 340 342 } 341 343 if ( $current_rank < count($upper_items)-1 ) 342 { 343 // has next 344 { // has next 344 345 $next = $upper_items[$current_rank+1]; 346 $chronology_date = explode('-', $next); 345 347 $template->assign_block_vars( 346 348 'calendar.navbar.next', 347 349 array( 348 350 'LABEL' => $this->get_date_nice_name($next), 349 'URL' => $this->url_base . $next, 351 'URL' => duplicate_index_url( 352 array('chronology_date'=>$chronology_date), array('start') 353 ) 350 354 ) 351 355 ); -
trunk/include/calendar_monthly.class.php
r1069 r1086 1 <?php1 <?php 2 2 // +-----------------------------------------------------------------------+ 3 3 // | PhpWebGallery - a PHP based picture gallery | … … 39 39 /** 40 40 * Initialize the calendar 41 * @param string date_field db column on which this calendar works42 41 * @param string inner_sql used for queries (INNER JOIN or normal) 43 * @param array date_components44 42 */ 45 function initialize($ date_field, $inner_sql, $date_components)46 { 47 parent::initialize($ date_field, $inner_sql, $date_components);43 function initialize($inner_sql) 44 { 45 parent::initialize($inner_sql); 48 46 global $lang; 49 47 $this->calendar_levels = array( … … 68 66 * where not included here, true otherwise 69 67 */ 70 function generate_category_content($url_base, $view_type) 71 { 72 global $conf; 73 74 $this->url_base = $url_base; 75 68 function generate_category_content() 69 { 70 global $conf, $page; 71 72 $view_type = $page['chronology']['view']; 76 73 if ($view_type==CAL_VIEW_CALENDAR) 77 74 { 78 if ( count($ this->date_components)==0 )75 if ( count($page['chronology_date'])==0 ) 79 76 {//case A: no year given - display all years+months 80 77 if ($this->build_global_calendar()) … … 82 79 } 83 80 84 if ( count($ this->date_components)==1 )81 if ( count($page['chronology_date'])==1 ) 85 82 {//case B: year given - display all days in given year 86 83 if ($this->build_year_calendar()) … … 91 88 } 92 89 93 if ( count($ this->date_components)==2 )90 if ( count($page['chronology_date'])==2 ) 94 91 {//case C: year+month given - display a nice month calendar 95 92 $this->build_month_calendar(); … … 101 98 } 102 99 103 if ($view_type==CAL_VIEW_LIST or count($ this->date_components)==3)100 if ($view_type==CAL_VIEW_LIST or count($page['chronology_date'])==3) 104 101 { 105 102 $has_nav_bar = false; 106 if ( count($ this->date_components)==0 )103 if ( count($page['chronology_date'])==0 ) 107 104 { 108 105 $this->build_nav_bar(CYEAR); // years 109 106 } 110 if ( count($ this->date_components)==1)107 if ( count($page['chronology_date'])==1) 111 108 { 112 109 $this->build_nav_bar(CMONTH); // month 113 110 } 114 if ( count($ this->date_components)==2 )111 if ( count($page['chronology_date'])==2 ) 115 112 { 116 113 $day_labels = range( 1, $this->get_all_days_in_month( 117 $ this->date_components[CYEAR] ,$this->date_components[CMONTH] ) );114 $page['chronology_date'][CYEAR] ,$page['chronology_date'][CMONTH] ) ); 118 115 array_unshift($day_labels, 0); 119 116 unset( $day_labels[0] ); … … 134 131 function get_date_where($max_levels=3) 135 132 { 136 $date = $this->date_components; 133 global $page; 134 $date = $page['chronology_date']; 137 135 while (count($date)>$max_levels) 138 136 { … … 219 217 function build_global_calendar() 220 218 { 221 assert( count($this->date_components) == 0 ); 219 global $page; 220 assert( count($page['chronology_date']) == 0 ); 222 221 $query='SELECT DISTINCT(DATE_FORMAT('.$this->date_field.',"%Y%m")) as period, 223 222 COUNT( DISTINCT(id) ) as count'; … … 245 244 {// only one year exists so bail out to year view 246 245 list($y) = array_keys($items); 247 $ this->date_components[CYEAR] = $y;246 $page['chronology_date'][CYEAR] = $y; 248 247 return false; 249 248 } … … 252 251 foreach ( $items as $year=>$year_data) 253 252 { 254 $url_base = $this->url_base.$year; 255 256 $nav_bar = '<span class="calCalHead"><a href="'.$url_base.'">'.$year.'</a>'; 253 $chronology_date = array( $year ); 254 $url = duplicate_index_url( array('chronology_date'=>$chronology_date) ); 255 256 $nav_bar = '<span class="calCalHead"><a href="'.$url.'">'.$year.'</a>'; 257 257 $nav_bar .= ' ('.$year_data['nb_images'].')'; 258 258 $nav_bar .= '</span><br>'; 259 259 260 $url_base .= '-'; 261 $nav_bar .= $this->get_nav_bar_from_items( $url_base, 260 $nav_bar .= $this->get_nav_bar_from_items( $chronology_date, 262 261 $year_data['children'], null, 'calCal', false, false, $lang['month'] ); 263 262 … … 271 270 function build_year_calendar() 272 271 { 273 assert( count($this->date_components) == 1 ); 272 global $page; 273 assert( count($page['chronology_date']) == 1 ); 274 274 $query='SELECT DISTINCT(DATE_FORMAT('.$this->date_field.',"%m%d")) as period, 275 275 COUNT( DISTINCT(id) ) as count'; … … 295 295 { // only one month exists so bail out to month view 296 296 list($m) = array_keys($items); 297 $ this->date_components[CMONTH] = $m;297 $page['chronology_date'][CMONTH] = $m; 298 298 return false; 299 299 } … … 301 301 foreach ( $items as $month=>$month_data) 302 302 { 303 $url_base = $this->url_base.$this->date_components[CYEAR].'-'.$month; 304 305 $nav_bar = '<span class="calCalHead"><a href="'.$url_base.'">'; 303 $chronology_date = array( $page['chronology_date'][CYEAR], $month ); 304 $url = duplicate_index_url( array('chronology_date'=>$chronology_date) ); 305 306 $nav_bar = '<span class="calCalHead"><a href="'.$url.'">'; 306 307 $nav_bar .= $lang['month'][$month].'</a>'; 307 308 $nav_bar .= ' ('.$month_data['nb_images'].')'; 308 309 $nav_bar .= '</span><br>'; 309 310 310 $url_base .= '-'; 311 $nav_bar .= $this->get_nav_bar_from_items( $url_base, 311 $nav_bar .= $this->get_nav_bar_from_items( $chronology_date, 312 312 $month_data['children'], null, 'calCal', false ); 313 313 … … 322 322 function build_month_calendar() 323 323 { 324 global $page; 324 325 $query='SELECT DISTINCT(DAYOFMONTH('.$this->date_field.')) as period, 325 326 COUNT( DISTINCT(id) ) as count'; 326 327 $query.= $this->inner_sql; 327 $query.= $this->get_date_where( $this->date_components);328 $query.= $this->get_date_where(); 328 329 $query.= ' 329 330 GROUP BY period'; … … 338 339 foreach ( $items as $day=>$data) 339 340 { 340 $ this->date_components[CDAY]=$day;341 $page['chronology_date'][CDAY]=$day; 341 342 $query = ' 342 343 SELECT file,tn_ext,path, width, height, DAYOFWEEK('.$this->date_field.')-1 as dow'; … … 346 347 ORDER BY RAND() 347 348 LIMIT 0,1'; 348 unset ( $ this->date_components[CDAY] );349 unset ( $page['chronology_date'][CDAY] ); 349 350 350 351 $row = mysql_fetch_array(pwg_query($query)); … … 417 418 $template->assign_block_vars('calendar.thumbnails.row.col.blank', array()); 418 419 } 419 for ($day=1; $day<=$this->get_all_days_in_month( 420 $this->date_components[CYEAR] ,$this->date_components[CMONTH]); $day++) 420 for ( $day = 1; 421 $day <= $this->get_all_days_in_month( 422 $page['chronology_date'][CYEAR], $page['chronology_date'][CMONTH] 423 ); 424 $day++) 421 425 { 422 426 $dow = ($first_day_dow + $day-1)%7; … … 487 491 $css_style.='top:'.round(-$pos_top).'px;'; 488 492 } 489 $url = $this->url_base. 490 $this->date_components[CYEAR].'-'. 491 $this->date_components[CMONTH].'-'.$day; 493 $url = duplicate_index_url( 494 array( 495 'chronology_date' => 496 array( 497 $page['chronology_date'][CYEAR], 498 $page['chronology_date'][CMONTH], 499 $day 500 ) 501 ) 502 ); 492 503 $alt = $wday_labels[$dow] . ' ' . $day. 493 504 ' ('.$items[$day]['nb_images'].')'; … … 520 531 foreach ( $items as $day=>$data) 521 532 { 522 $url = $this->url_base. 523 $this->date_components[CYEAR].'-'. 524 $this->date_components[CMONTH].'-'.$day; 533 $url = duplicate_index_url( 534 array( 535 'chronology_date' => 536 array( 537 $page['chronology_date'][CYEAR], 538 $page['chronology_date'][CMONTH], 539 $day 540 ) 541 ) 542 ); 525 543 526 544 $thumbnail_title = $lang['day'][$data['dow']] . ' ' . $day; -
trunk/include/calendar_weekly.class.php
r1069 r1086 39 39 /** 40 40 * Initialize the calendar 41 * @param string date_field db column on which this calendar works42 41 * @param string inner_sql used for queries (INNER JOIN or normal) 43 * @param array date_components44 42 */ 45 function initialize($ date_field, $inner_sql, $date_components)43 function initialize($inner_sql) 46 44 { 47 parent::initialize($ date_field, $inner_sql, $date_components);45 parent::initialize($inner_sql); 48 46 global $lang; 49 47 $week_no_labels=array(); … … 80 78 * @return boolean false to indicate that thumbnails where not included here 81 79 */ 82 function generate_category_content( $url_base, $view_type)80 function generate_category_content() 83 81 { 84 global $conf ;82 global $conf, $page; 85 83 86 $this->url_base = $url_base; 87 88 assert($view_type==CAL_VIEW_LIST); 89 90 if ( count($this->date_components)==0 ) 84 if ( count($page['chronology_date'])==0 ) 91 85 { 92 86 $this->build_nav_bar(CYEAR); // years 93 87 } 94 if ( count($ this->date_components)==1 )88 if ( count($page['chronology_date'])==1 ) 95 89 { 96 90 $this->build_nav_bar(CWEEK, array()); // week nav bar 1-53 97 91 } 98 if ( count($ this->date_components)==2 )92 if ( count($page['chronology_date'])==2 ) 99 93 { 100 94 $this->build_nav_bar(CDAY); // days nav bar Mon-Sun … … 113 107 function get_date_where($max_levels=3) 114 108 { 115 $date = $this->date_components; 109 global $page; 110 $date = $page['chronology_date']; 116 111 while (count($date)>$max_levels) 117 112 { -
trunk/include/functions.inc.php
r1084 r1086 224 224 $height = $original_height; 225 225 $is_original_size = true; 226 226 227 227 if ( $max_width != "" ) 228 228 { … … 250 250 { 251 251 if ( $ratioWidth < $ratioHeight ) 252 { 252 { 253 253 $width = floor( $original_width / $ratioHeight ); 254 254 $height = $max_height; 255 255 } 256 256 else 257 { 258 $width = $max_width; 257 { 258 $width = $max_width; 259 259 $height = floor( $original_height / $ratioWidth ); 260 260 } … … 331 331 $remaining ); 332 332 $return_string.= $treatment; 333 333 334 334 return $return_string; 335 335 } … … 341 341 // FIXME : with new advanced search, this function needs a rewrite 342 342 return $string; 343 343 344 344 $words = explode( ',', $search ); 345 345 $style = 'background-color:white;color:red;'; … … 360 360 $login = ($user['id'] == $conf['guest_id']) 361 361 ? 'guest' : addslashes($user['username']); 362 362 363 363 $query = ' 364 364 INSERT INTO '.HISTORY_TABLE.' … … 388 388 389 389 list($year,$month,$day,$hour,$minute,$second) = array(0,0,0,0,0,0); 390 390 391 391 switch ( $type ) 392 392 { … … 433 433 { 434 434 global $conf,$page,$debug,$t2; 435 435 436 436 $start = get_moment(); 437 437 $result = mysql_query($query) or my_error($query."\n"); 438 438 439 439 $time = get_moment() - $start; 440 440 … … 444 444 $page['queries_time'] = 0; 445 445 } 446 446 447 447 $page['count_queries']++; 448 448 $page['queries_time']+= $time; 449 449 450 450 if ($conf['show_queries']) 451 451 { … … 460 460 $output.= number_format( ($time+$start-$t2), 3, '.', ' ').' s)'; 461 461 $output.= "</pre>\n"; 462 462 463 463 $debug .= $output; 464 464 } 465 465 466 466 return $result; 467 467 } … … 501 501 502 502 include( PHPWG_ROOT_PATH.'include/page_header.php' ); 503 503 504 504 $template->set_filenames( array( 'redirect' => 'redirect.tpl' ) ); 505 505 $template->parse('redirect'); 506 506 507 507 include( PHPWG_ROOT_PATH.'include/page_tail.php' ); 508 508 … … 519 519 { 520 520 $query_string = ''; 521 521 522 522 $str = $_SERVER['QUERY_STRING']; 523 523 parse_str($str, $vars); 524 524 525 525 $is_first = true; 526 526 foreach ($vars as $key => $value) … … 554 554 555 555 $template_dir = PHPWG_ROOT_PATH.'template'; 556 556 557 557 foreach (get_dirs($template_dir) as $template) 558 558 { … … 596 596 $src.= strtolower(get_extension($path)).'.png'; 597 597 } 598 598 599 599 return $src; 600 600 } … … 623 623 { 624 624 $array = array(); 625 625 626 626 $result = pwg_query($query); 627 627 while ($row = mysql_fetch_array($result)) … … 642 642 { 643 643 global $template; 644 644 645 645 $template->assign_block_vars( 646 646 $blockname, array('SELECTED' => '', 'VALUE' => 0, 'OPTION' => '--')); 647 647 648 648 for ($i = 1; $i <= 31; $i++) 649 649 { … … 669 669 { 670 670 global $template, $lang; 671 671 672 672 $template->assign_block_vars( 673 673 $blockname, array('SELECTED' => '', … … 698 698 { 699 699 global $user; 700 700 701 701 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 702 702 703 703 $query = ' 704 704 SELECT element_id … … 750 750 echo '[l10n] language key "'.$key.'" is not defined<br />'; 751 751 } 752 752 753 753 return isset($lang[$key]) ? $lang[$key] : $key; 754 754 } … … 798 798 die('Search id must be an integer'); 799 799 } 800 800 801 801 $query = ' 802 802 SELECT rules … … 805 805 ;'; 806 806 list($serialized_rules) = mysql_fetch_row(pwg_query($query)); 807 807 808 808 return unserialize($serialized_rules); 809 809 } … … 821 821 { 822 822 $search = get_search_array($search_id); 823 823 824 824 // SQL where clauses are stored in $clauses array during query 825 825 // construction 826 826 $clauses = array(); 827 827 828 828 foreach (array('file','name','comment','keywords','author') as $textfield) 829 829 { … … 848 848 } 849 849 } 850 850 851 851 if (isset($search['fields']['allwords'])) 852 852 { … … 876 876 ); 877 877 } 878 878 879 879 array_walk( 880 880 $word_clauses, 881 881 create_function('&$s','$s="(".$s.")";') 882 882 ); 883 883 884 884 array_push( 885 885 $clauses, … … 893 893 ); 894 894 } 895 895 896 896 foreach (array('date_available', 'date_creation') as $datefield) 897 897 { … … 903 903 ); 904 904 } 905 905 906 906 foreach (array('after','before') as $suffix) 907 907 { 908 908 $key = $datefield.'-'.$suffix; 909 909 910 910 if (isset($search['fields'][$key])) 911 911 { 912 912 array_push( 913 913 $clauses, 914 914 915 915 $datefield. 916 916 ($suffix == 'after' ? ' >' : ' <'). 917 917 ($search['fields'][$key]['inc'] ? '=' : ''). 918 918 " '".$search['fields'][$key]['date']."'" 919 919 920 920 ); 921 921 } 922 922 } 923 923 } 924 924 925 925 if (isset($search['fields']['cat'])) 926 926 { … … 934 934 $cat_ids = $search['fields']['cat']['words']; 935 935 } 936 936 937 937 $local_clause = 'category_id IN ('.implode(',', $cat_ids).')'; 938 938 array_push($clauses, $local_clause); 939 939 } 940 940 941 941 // adds brackets around where clauses 942 942 $clauses = prepend_append_array_items($clauses, '(', ')'); 943 943 944 944 $where_separator = 945 945 implode( … … 947 947 $clauses 948 948 ); 949 949 950 950 $search_clause = $where_separator; 951 951 952 952 if (isset($forbidden)) 953 953 { … … 987 987 988 988 $available_upgrade_ids = array(); 989 989 990 990 if ($contents = opendir($upgrades_path)) 991 991 { … … 1016 1016 .'/'.make_section_in_URL($params) 1017 1017 ; 1018 1019 if (isset($params['start']) and $params['start'] > 0) 1020 { 1021 $url.= '/start-'.$params['start']; 1022 } 1018 1019 $url = add_well_known_params_in_url($url, $params); 1023 1020 1024 1021 return $url; … … 1107 1104 die('make_picture_URL: image_id is a required parameter'); 1108 1105 } 1109 1106 1110 1107 $url = 1111 1108 PHPWG_ROOT_PATH.'picture.php?' … … 1114 1111 ; 1115 1112 1116 // first comment to start on 1113 $url = add_well_known_params_in_url($url, $params); 1114 return $url; 1115 } 1116 1117 /** 1118 *adds to the url the chronology and start parameters 1119 */ 1120 function add_well_known_params_in_url($url, $params) 1121 { 1122 if ( isset($params['chronology']) ) 1123 { 1124 $url .= '/'. $params['chronology']['field']; 1125 $url .= '-'. $params['chronology']['style']; 1126 if ( isset($params['chronology']['view']) ) 1127 { 1128 $url .= '-'. $params['chronology']['view']; 1129 } 1130 if ( isset($params['chronology_date']) ) 1131 { 1132 $url .= '-'. implode('-', $params['chronology_date'] ); 1133 } 1134 } 1135 1117 1136 if (isset($params['start']) and $params['start'] > 0) 1118 1137 { 1119 1138 $url.= '/start-'.$params['start']; 1120 1139 } 1121 1122 1140 return $url; 1123 1141 } … … 1135 1153 { 1136 1154 $section_string = ''; 1137 1155 1138 1156 if (!isset($params['section'])) 1139 1157 { … … 1160 1178 $params['section'] = 'categories'; 1161 1179 } 1162 1180 1163 1181 switch($params['section']) 1164 1182 { … … 1173 1191 $section_string.= 'category/'.$params['category']; 1174 1192 } 1175 1193 1176 1194 break; 1177 1195 } … … 1189 1207 $section_string.= '/'.$tag; 1190 1208 } 1191 1209 1192 1210 break; 1193 1211 } … … 1198 1216 die('make_section_in_URL: require a search identifier'); 1199 1217 } 1200 1218 1201 1219 $section_string.= 'search/'.$params['search']; 1202 1220 … … 1211 1229 1212 1230 $section_string.= 'list/'.implode(',', $params['list']); 1213 1231 1214 1232 break; 1215 1233 } -
trunk/include/functions_calendar.inc.php
r1062 r1086 25 25 // +-----------------------------------------------------------------------+ 26 26 27 define('CAL_VIEW_LIST', 'l'); 28 define('CAL_VIEW_CALENDAR', 'c'); 29 30 function get_calendar_parameter($options, &$parameters ) 31 { 32 if ( count($parameters) and isset($options[$parameters[0]]) ) 33 { 34 return array_shift($parameters); 35 } 36 else 37 { 38 foreach ($options as $option => $data) 39 { 40 if ( empty( $data['default_link'] ) ) 41 { 42 break; 43 } 44 } 45 return $option; 46 } 47 } 27 define('CAL_VIEW_LIST', 'list'); 28 define('CAL_VIEW_CALENDAR', 'calendar'); 48 29 49 30 function initialize_calendar() … … 54 35 $inner_sql = ' FROM ' . IMAGES_TABLE; 55 36 56 if (!isset($page['cat ']) or is_numeric($page['cat']))37 if (!isset($page['category']) or is_numeric($page['category'])) 57 38 { // we will regenerate the items by including subcats elements 58 39 $page['cat_nb_images'] = 0; … … 61 42 INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id'; 62 43 63 if (isset($page['cat ']) and is_numeric($page['cat']))44 if (isset($page['category']) and is_numeric($page['category'])) 64 45 { 65 46 $sub_ids = array_diff( 66 get_subcat_ids(array($page['cat '])),47 get_subcat_ids(array($page['category'])), 67 48 explode(',', $user['forbidden_categories']) 68 49 ); … … 93 74 //-------------------------------------- initialize the calendar parameters --- 94 75 pwg_debug('start initialize_calendar'); 95 // the parameters look like (FIELD)?(STYLE)?(VIEW)?(DATE COMPONENTS)?96 // FIELD = (created-|posted-)97 // STYLE = (m-|w-)98 // VIEW = (l-|c-)99 // DATE COMPONENTS= YEAR(-MONTH/WEEK)?(-DAY)?100 76 101 77 $fields = array( 102 78 // Created 103 79 'created' => array( 104 'default_link' => 'created-',105 80 'label' => l10n('Creation date'), 106 'db_field' => 'date_creation',107 81 ), 108 82 // Posted 109 83 'posted' => array( 110 'default_link' => 'posted-',111 84 'label' => l10n('Post date'), 112 'db_field' => 'date_available',113 85 ), 114 86 ); … … 117 89 // Monthly style 118 90 'monthly' => array( 119 'default_link' => '',120 91 'include' => 'calendar_monthly.class.php', 121 92 'view_calendar' => true, … … 123 94 // Weekly style 124 95 'weekly' => array( 125 'default_link' => 'weekly-',126 96 'include' => 'calendar_weekly.class.php', 127 97 'view_calendar' => false, … … 129 99 ); 130 100 131 $views = array( 132 // list view 133 CAL_VIEW_LIST => array( 134 'default_link' => '', 135 ), 136 // calendar view 137 CAL_VIEW_CALENDAR => array( 138 'default_link' => CAL_VIEW_CALENDAR.'-', 139 ), 140 ); 141 142 $requested = explode('-', $_GET['calendar']); 101 $views = array(CAL_VIEW_LIST,CAL_VIEW_CALENDAR); 143 102 144 103 // Retrieve calendar field 145 $cal_field = get_calendar_parameter($fields, $requested); 104 if ( !isset( $fields[ $page['chronology']['field'] ] ) ) 105 { 106 die('bad field'); 107 } 146 108 147 109 // Retrieve style 148 $cal_style = get_calendar_parameter($styles, $requested); 110 if ( !isset( $styles[ $page['chronology']['style'] ] ) ) 111 { 112 $page['chronology']['style'] = 'monthly'; 113 } 114 $cal_style = $page['chronology']['style']; 149 115 include(PHPWG_ROOT_PATH.'include/'. $styles[$cal_style]['include']); 150 116 $calendar = new Calendar(); 151 117 152 118 // Retrieve view 153 $cal_view = get_calendar_parameter($views, $requested); 154 if ( CAL_VIEW_CALENDAR==$cal_view and !$styles[$cal_style]['view_calendar'] ) 155 { 156 $cal_view=CAL_VIEW_LIST; 157 } 119 120 if ( !isset($page['chronology']['view']) or 121 !in_array( $page['chronology']['view'], $views ) ) 122 { 123 $page['chronology']['view'] = CAL_VIEW_LIST; 124 } 125 126 if ( CAL_VIEW_CALENDAR==$page['chronology']['view'] and 127 !$styles[$cal_style]['view_calendar'] ) 128 { 129 130 $page['chronology']['view'] = CAL_VIEW_LIST; 131 } 132 $cal_view = $page['chronology']['view']; 158 133 159 134 // perform a sanity check on $requested 160 while (count($requested) > 3) 161 { 162 array_pop($requested); 135 if (!isset($page['chronology_date'])) 136 { 137 $page['chronology_date'] = array(); 138 } 139 while ( count($page['chronology_date']) > 3) 140 { 141 array_pop($page['chronology_date']); 163 142 } 164 143 165 144 $any_count = 0; 166 for ($i = 0; $i < count($ requested); $i++)167 { 168 if ($ requested[$i] == 'any')145 for ($i = 0; $i < count($page['chronology_date']); $i++) 146 { 147 if ($page['chronology_date'][$i] == 'any') 169 148 { 170 149 if ($cal_view == CAL_VIEW_CALENDAR) 171 150 {// we dont allow any in calendar view 172 while ($i < count($ requested))151 while ($i < count($page['chronology_date'])) 173 152 { 174 array_pop($ requested);153 array_pop($page['chronology_date']); 175 154 } 176 155 break; … … 178 157 $any_count++; 179 158 } 180 elseif ($ requested[$i] == '')181 { 182 while ($i < count($ requested))159 elseif ($page['chronology_date'][$i] == '') 160 { 161 while ($i < count($page['chronology_date'])) 183 162 { 184 array_pop($ requested);163 array_pop($page['chronology_date']); 185 164 } 186 165 } 187 166 else 188 167 { 189 $ requested[$i] = (int)$requested[$i];168 $page['chronology_date'][$i] = (int)$page['chronology_date'][$i]; 190 169 } 191 170 } 192 171 if ($any_count == 3) 193 172 { 194 array_pop($ requested);195 } 196 197 $calendar->initialize($ fields[$cal_field]['db_field'], $inner_sql, $requested);173 array_pop($page['chronology_date']); 174 } 175 176 $calendar->initialize($inner_sql); 198 177 199 178 //echo ('<pre>'. var_export($calendar, true) . '</pre>'); 200 179 201 $url_base = get_query_string_diff(array('start', 'calendar'));180 /* $url_base = get_query_string_diff(array('start', 'calendar')); 202 181 $url_base = 203 182 PHPWG_ROOT_PATH.'category.php' … … 205 184 .(empty($url_base) ? '?' : '&') 206 185 .'calendar='.$cal_field.'-' 207 ; 186 ;*/ 208 187 $must_show_list = true; // true until calendar generates its own display 209 188 if (basename($_SERVER["PHP_SELF"]) == 'category.php') … … 211 190 $template->assign_block_vars('calendar', array()); 212 191 213 if ($calendar->generate_category_content( 214 $url_base.$cal_style.'-'.$cal_view.'-', 215 $cal_view 216 ) 217 ) 192 if ($calendar->generate_category_content()) 218 193 { 219 194 unset( … … 229 204 foreach ($styles as $style => $style_data) 230 205 { 231 foreach ($views as $view => $view_data)206 foreach ($views as $view) 232 207 { 233 208 if ( $style_data['view_calendar'] or $view != CAL_VIEW_CALENDAR) 234 209 { 235 210 $selected = ''; 236 $url = $url_base.$style.'-'.$view; 237 if ($style==$cal_style) 211 $chronology = $page['chronology']; 212 $chronology['style'] = $style; 213 $chronology['view'] = $view; 214 215 if ($style!=$cal_style) 238 216 { 239 $ url .= '-'.implode('-', $calendar->date_components);240 if ( $view==$cal_view)217 $chronology_date = array(); 218 if ( isset($page['chronology_date'][0]) ) 241 219 { 242 $selected = 'SELECTED';220 array_push($chronology_date, $page['chronology_date'][0]); 243 221 } 244 222 } 245 223 else 246 224 { 247 if (isset($calendar->date_components[0])) 248 { 249 $url .= '-' . $calendar->date_components[0]; 250 } 225 $chronology_date = $page['chronology_date']; 251 226 } 227 $url = duplicate_index_url( 228 array( 229 'chronology' => $chronology, 230 'chronology_date' => $chronology_date, 231 ) 232 ); 233 234 if ($style==$cal_style and $view==$cal_view ) 235 { 236 $selected = 'SELECTED'; 237 } 238 252 239 $template->assign_block_vars( 253 240 'calendar.views.view', … … 261 248 } 262 249 } 263 $calendar_title = 264 '<a href="'.$url_base.$cal_style.'-'.$cal_view.'">' 265 .$fields[$cal_field]['label'].'</a>'; 250 $url = duplicate_index_url( 251 array('chronology_date'=>array()), array('start') 252 ); 253 $calendar_title = '<a href="'.$url.'">' 254 .$fields[$chronology['field']]['label'].'</a>'; 266 255 $calendar_title.= $calendar->get_display_name(); 267 256 //this should be an assign_block_vars, but I need to assign 'calendar' -
trunk/include/section_init.inc.php
r1082 r1086 79 79 } 80 80 $page['image_id'] = $matches[1]; 81 82 $next_token++; 83 } 84 81 82 $next_token++; 83 } 84 85 85 if (0 === strpos($tokens[$next_token], 'cat')) 86 86 { 87 87 $page['section'] = 'categories'; 88 88 $next_token++; 89 89 90 90 if (isset($tokens[$next_token]) 91 and preg_match('/ (\d+)/', $tokens[$next_token], $matches))91 and preg_match('/^(\d+)/', $tokens[$next_token], $matches)) 92 92 { 93 93 $page['category'] = $matches[1]; … … 99 99 $page['section'] = 'tags'; 100 100 $page['tags'] = array(); 101 102 $next_token++; 103 101 102 $next_token++; 103 104 104 for ($i = $next_token; ; $i++) 105 105 { … … 108 108 break; 109 109 } 110 110 111 111 preg_match('/^(\d+)/', $tokens[$i], $matches); 112 112 if (!isset($matches[1])) … … 123 123 array_push($page['tags'], $matches[1]); 124 124 } 125 125 126 126 $next_token = $i; 127 127 } … … 155 155 $page['section'] = 'search'; 156 156 $next_token++; 157 157 158 158 preg_match('/(\d+)/', $tokens[$next_token], $matches); 159 159 if (!isset($matches[1])) … … 185 185 $next_token++; 186 186 } 187 187 188 188 for ($i = $next_token; ; $i++) 189 189 { … … 192 192 break; 193 193 } 194 194 195 195 if (preg_match('/^start-(\d+)/', $tokens[$i], $matches)) 196 196 { … … 198 198 } 199 199 200 if (preg_match('/^calendar-(.+)$/', $tokens[$i], $matches)) 201 { 202 // TODO: decide with rvelices how we name calendar/chronology is the 203 // URL 204 $_GET['calendar'] = $matches[1]; 200 if (preg_match('/^posted|created/', $tokens[$i] )) 201 { 202 $chronology_tokens = explode('-', $tokens[$i] ); 203 $page['chronology']['field'] = $chronology_tokens[0]; 204 array_shift($chronology_tokens); 205 $page['chronology']['style'] = $chronology_tokens[0]; 206 array_shift($chronology_tokens); 207 if ( count($chronology_tokens)>0 ) 208 { 209 if ('list'==$chronology_tokens[0] or 210 'calendar'==$chronology_tokens[0]) 211 { 212 $page['chronology']['view'] = $chronology_tokens[0]; 213 array_shift($chronology_tokens); 214 } 215 $page['chronology_date'] = $chronology_tokens; 216 } 205 217 } 206 218 } … … 220 232 $conf['order_by'] = str_replace( 221 233 'ORDER BY ', 222 'ORDER BY '.$orders[ $_COOKIE['pwg_image_order'] ][1].',', 234 'ORDER BY '.$orders[ $_COOKIE['pwg_image_order'] ][1].',', 223 235 $conf['order_by'] 224 236 ); … … 234 246 { 235 247 $result = get_cat_info($page['category']); 236 248 237 249 $page = array_merge( 238 250 $page, … … 247 259 'cat_id_uppercat' => $result['id_uppercat'], 248 260 'uppercats' => $result['uppercats'], 249 261 250 262 'title' => get_cat_display_name($result['name'], '', false), 251 263 ) 252 264 ); 253 265 254 266 if (!isset($_GET['calendar'])) 255 267 { … … 262 274 ;'; 263 275 $page['items'] = array_from_query($query, 'image_id'); 264 276 265 277 $page['thumbnails_include'] = 266 278 $result['nb_images'] > 0 … … 388 400 LIMIT 0, '.$conf['top_number'].' 389 401 ;'; 390 402 391 403 $page = array_merge( 392 404 $page, … … 405 417 $page['super_order_by'] = true; 406 418 $conf['order_by'] = ' ORDER BY average_rate DESC, id ASC'; 407 419 408 420 $query =' 409 421 SELECT DISTINCT(id) … … 437 449 '.$conf['order_by'].' 438 450 ;'; 439 451 440 452 $page = array_merge( 441 453 $page, … … 447 459 ); 448 460 } 449 461 450 462 if (!isset($page['cat_nb_images'])) 451 463 { … … 458 470 // +-----------------------------------------------------------------------+ 459 471 460 if (isset($ _GET['calendar']))472 if (isset($page['chronology'])) 461 473 { 462 474 include_once( PHPWG_ROOT_PATH.'include/functions_calendar.inc.php' ); -
trunk/picture.php
r1085 r1086 64 64 if ($page['current_rank'] != $page['first_rank']) 65 65 { 66 // "go to first picture of this section" link is displayed only if the 67 // displayed item is not the first. 68 $template->assign_block_vars( 69 'first', 70 array( 71 'U_IMG' => duplicate_picture_URL( 72 // redefinitions 73 array( 74 'image_id' => $page['items'][ $page['first_rank'] ], 75 ), 76 // removes 77 array() 78 ) 79 ) 80 ); 81 82 // caching previous item : readability purpose 66 // caching first & previous item : readability purpose 83 67 $page['previous_item'] = $page['items'][ $page['current_rank'] - 1 ]; 68 $page['first_item'] = $page['items'][ $page['first_rank'] ]; 84 69 } 85 70 86 71 if ($page['current_rank'] != $page['last_rank']) 87 72 { 88 // "go to last picture of this section" link is displayed only if the 89 // displayed item is not the last. 90 $template->assign_block_vars( 91 'last', 92 array( 93 'U_IMG' => duplicate_picture_URL( 94 // redefinitions 95 array( 96 'image_id' => $page['items'][ $page['last_rank'] ], 97 ), 98 // removes 99 array() 100 ) 101 ) 102 ); 103 104 // caching next item : readability purpose 73 // caching next & last item : readability purpose 105 74 $page['next_item'] = $page['items'][ $page['current_rank'] + 1 ]; 75 $page['last_item'] = $page['items'][ $page['last_rank'] ]; 106 76 } 107 77 … … 145 115 146 116 redirect($url_self); 147 117 148 118 break; 149 119 } … … 165 135 redirect($url_self); 166 136 } 167 137 168 138 break; 169 139 } … … 179 149 pwg_query($query); 180 150 } 181 151 182 152 redirect($url_self); 183 153 184 154 break; 185 155 } … … 244 214 } 245 215 usort($related_categories, 'global_rank_compare'); 246 //------------------------- ------------ prev, current & next picture management216 //-------------------------first, prev, current, next & last picture management 247 217 $picture = array(); 248 218 … … 251 221 { 252 222 array_push($ids, $page['previous_item']); 223 array_push($ids, $page['first_item']); 253 224 } 254 225 if (isset($page['next_item'])) 255 226 { 256 227 array_push($ids, $page['next_item']); 228 array_push($ids, $page['last_item']); 257 229 } 258 230 … … 269 241 if (isset($page['previous_item']) and $row['id'] == $page['previous_item']) 270 242 { 271 $i = 'prev ';243 $i = 'previous'; 272 244 } 273 245 else if (isset($page['next_item']) and $row['id'] == $page['next_item']) 274 246 { 275 247 $i = 'next'; 248 } 249 else if (isset($page['first_item']) and $row['id'] == $page['first_item']) 250 { 251 $i = 'first'; 252 } 253 else if (isset($page['last_item']) and $row['id'] == $page['last_item']) 254 { 255 $i = 'last'; 276 256 } 277 257 else … … 351 331 ) 352 332 ); 333 334 if ('previous'==$i and $page['previous_item']==$page['first_item']) 335 { 336 $picture['first'] = $picture[$i]; 337 } 338 if ('next'==$i and $page['next_item']==$page['last_item']) 339 { 340 $picture['last'] = $picture[$i]; 341 } 353 342 } 354 343 … … 428 417 $page['body_id'] = 'thePicturePage'; 429 418 //------------------------------------------------------- navigation management 430 if (isset($page['previous_item'])) 431 { 432 $template->assign_block_vars( 433 'previous', 434 array( 435 'TITLE_IMG' => $picture['prev']['name'], 436 'IMG' => $picture['prev']['thumbnail'], 437 'U_IMG' => $picture['prev']['url'], 438 'U_IMG_SRC' => $picture['prev']['src'] 439 ) 440 ); 441 } 442 443 if (isset($page['next_item'])) 444 { 445 $template->assign_block_vars( 446 'next', 447 array( 448 'TITLE_IMG' => $picture['next']['name'], 449 'IMG' => $picture['next']['thumbnail'], 450 'U_IMG' => $picture['next']['url'], 451 'U_IMG_SRC' => $picture['next']['src'] // allow navigator to preload 452 ) 453 ); 419 foreach ( array('first','previous','next','last') as $which_image ) 420 { 421 if (isset($picture[$which_image])) 422 { 423 $template->assign_block_vars( 424 $which_image, 425 array( 426 'TITLE_IMG' => $picture[$which_image]['name'], 427 'IMG' => $picture[$which_image]['thumbnail'], 428 'U_IMG' => $picture[$which_image]['url'], 429 'U_IMG_SRC' => $picture[$which_image]['src'] 430 ) 431 ); 432 } 454 433 } 455 434 … … 520 499 { 521 500 $uuid = uniqid(rand()); 522 501 523 502 $template->assign_block_vars( 524 503 'high', … … 528 507 ) 529 508 ); 530 509 531 510 $template->assign_block_vars( 532 511 'download', … … 572 551 $result = pwg_query($query); 573 552 $row = mysql_fetch_array($result); 574 553 575 554 if ($row['nb_fav'] == 0) 576 555 { … … 642 621 { 643 622 $val = format_date($picture['current']['date_creation']); 644 $infos['INFO_CREATION_DATE'] = '<a href="'. 645 PHPWG_ROOT_PATH.'category.php?calendar=created-c-'. 646 $picture['current']['date_creation'].'">'.$val.'</a>'; 623 $url = make_index_URL( 624 array( 625 'chronology' => 626 array( 627 'field'=>'created', 628 'style'=>'monthly', 629 'view'=>'list', 630 ), 631 'chronology_date' => explode('-', $picture['current']['date_creation']) 632 ) 633 ); 634 $infos['INFO_CREATION_DATE'] = '<a href="'.$url.'">'.$val.'</a>'; 647 635 } 648 636 else … … 653 641 // date of availability 654 642 $val = format_date($picture['current']['date_available'], 'mysql_datetime'); 655 $infos['INFO_POSTED_DATE'] = '<a href="'. 656 PHPWG_ROOT_PATH.'category.php?calendar=posted-c-'. 657 substr($picture['current']['date_available'],0,10).'">'.$val.'</a>'; 643 $url = make_index_URL( 644 array( 645 'chronology' => 646 array( 647 'field'=>'posted', 648 'style'=>'monthly', 649 'view'=>'list', 650 ), 651 'chronology_date' => explode('-', substr($picture['current']['date_available'],0,10)) 652 ) 653 ); 654 $infos['INFO_POSTED_DATE'] = '<a href="'.$url.'">'.$val.'</a>'; 658 655 659 656 // size in pixels
Note: See TracChangeset
for help on using the changeset viewer.