Ignore:
Timestamp:
Mar 17, 2006, 5:13:19 AM (18 years ago)
Author:
rvelices
Message:

URL rewrite for chronology: uses $pagechronology and
$pagechronology_date. $pagechronology is an array with 'field',
'style' and 'view' keys. This is step 1.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/section_init.inc.php

    r1082 r1086  
    7979      }
    8080      $page['image_id'] = $matches[1];
    81      
    82       $next_token++;
    83     }
    84    
     81
     82      $next_token++;
     83    }
     84
    8585    if (0 === strpos($tokens[$next_token], 'cat'))
    8686    {
    8787      $page['section'] = 'categories';
    8888      $next_token++;
    89      
     89
    9090      if (isset($tokens[$next_token])
    91           and preg_match('/(\d+)/', $tokens[$next_token], $matches))
     91          and preg_match('/^(\d+)/', $tokens[$next_token], $matches))
    9292      {
    9393        $page['category'] = $matches[1];
     
    9999      $page['section'] = 'tags';
    100100      $page['tags'] = array();
    101      
    102       $next_token++;
    103      
     101
     102      $next_token++;
     103
    104104      for ($i = $next_token; ; $i++)
    105105      {
     
    108108          break;
    109109        }
    110        
     110
    111111        preg_match('/^(\d+)/', $tokens[$i], $matches);
    112112        if (!isset($matches[1]))
     
    123123        array_push($page['tags'], $matches[1]);
    124124      }
    125      
     125
    126126      $next_token = $i;
    127127    }
     
    155155      $page['section'] = 'search';
    156156      $next_token++;
    157      
     157
    158158      preg_match('/(\d+)/', $tokens[$next_token], $matches);
    159159      if (!isset($matches[1]))
     
    185185      $next_token++;
    186186    }
    187    
     187
    188188    for ($i = $next_token; ; $i++)
    189189    {
     
    192192        break;
    193193      }
    194      
     194
    195195      if (preg_match('/^start-(\d+)/', $tokens[$i], $matches))
    196196      {
     
    198198      }
    199199
    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        }
    205217      }
    206218    }
     
    220232  $conf['order_by'] = str_replace(
    221233    'ORDER BY ',
    222     'ORDER BY '.$orders[ $_COOKIE['pwg_image_order'] ][1].',', 
     234    'ORDER BY '.$orders[ $_COOKIE['pwg_image_order'] ][1].',',
    223235    $conf['order_by']
    224236    );
     
    234246  {
    235247    $result = get_cat_info($page['category']);
    236    
     248
    237249    $page = array_merge(
    238250      $page,
     
    247259        'cat_id_uppercat'  => $result['id_uppercat'],
    248260        'uppercats'        => $result['uppercats'],
    249        
     261
    250262        'title' => get_cat_display_name($result['name'], '', false),
    251263        )
    252264      );
    253    
     265
    254266    if (!isset($_GET['calendar']))
    255267    {
     
    262274;';
    263275      $page['items'] = array_from_query($query, 'image_id');
    264      
     276
    265277      $page['thumbnails_include'] =
    266278        $result['nb_images'] > 0
     
    388400  LIMIT 0, '.$conf['top_number'].'
    389401;';
    390    
     402
    391403    $page = array_merge(
    392404      $page,
     
    405417    $page['super_order_by'] = true;
    406418    $conf['order_by'] = ' ORDER BY average_rate DESC, id ASC';
    407    
     419
    408420    $query ='
    409421SELECT DISTINCT(id)
     
    437449  '.$conf['order_by'].'
    438450;';
    439      
     451
    440452    $page = array_merge(
    441453      $page,
     
    447459      );
    448460  }
    449  
     461
    450462  if (!isset($page['cat_nb_images']))
    451463  {
     
    458470// +-----------------------------------------------------------------------+
    459471
    460 if (isset($_GET['calendar']))
     472if (isset($page['chronology']))
    461473{
    462474  include_once( PHPWG_ROOT_PATH.'include/functions_calendar.inc.php' );
Note: See TracChangeset for help on using the changeset viewer.