Ignore:
Timestamp:
Mar 22, 2006, 2:01:47 AM (18 years ago)
Author:
rvelices
Message:

URL rewriting: capable of fully working with urls without ?

URL rewriting: works with image file instead of image id (change
make_picture_url to generate urls with file name instead of image id)

URL rewriting: completely works with category/best_rated and
picture/best_rated/534 (change 'category.php?' to 'category' in make_index_url
and 'picture.php?' to 'picture' in make_picture_url to see it)

fix: picture category display in upper bar

fix: function rate_picture variables and use of the new user type

fix: caddie icon appears now on category page

fix: admin element_set sql query was using storage_category_id column
(column has moved to #image_categories)

fix: replaced some old $_GET[xxx] with $page[xxx]

fix: pictures have metadata url (use ? parameter - might change later)

File:
1 edited

Legend:

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

    • Property svn:keywords set to Author Date Id Revision
    r1090 r1092  
    77// | branch        : BSF (Best So Far)
    88// | file          : $RCSfile$
    9 // | last update   : $Date: 2006-01-27 02:11:43 +0100 (ven, 27 jan 2006) $
    10 // | last modifier : $Author: rvelices $
    11 // | revision      : $Revision: 1014 $
     9// | last update   : $Date$
     10// | last modifier : $Author$
     11// | revision      : $Revision$
    1212// +-----------------------------------------------------------------------+
    1313// | This program is free software; you can redistribute it and/or modify  |
     
    8585$next_token = 0;
    8686if (basename($_SERVER['SCRIPT_NAME']) == 'picture.php')
    87 {
    88 
    89   // the first token must be the numeric identifier of the picture
    90   preg_match('/(\d+)/', $tokens[$next_token], $matches);
    91   if (!isset($matches[1]))
    92   {
    93     die('Fatal: picture identifier is missing');
    94   }
    95   $page['image_id'] = $matches[1];
    96 
    97   $next_token++;
     87{ // the last token must be the identifier for the picture
     88  $token = array_pop($tokens);
     89  if ( is_numeric($token) )
     90  {
     91    $page['image_id'] = $token;
     92  }
     93  else
     94  {
     95    preg_match('/^(\d+-)?((.*)[_\.]html?)?$/', $token, $matches);
     96    if ( isset($matches[1]) and is_numeric($matches[1]) )
     97    {
     98      $page['image_id'] = $matches[1];
     99      if ( !empty($matches[3]) )
     100      {
     101        $page['image_file'] = $matches[3];
     102      }
     103    }
     104    else
     105    {
     106      if ( !empty($matches[3]) )
     107      {
     108        $page['image_file'] = $matches[3];
     109      }
     110      else
     111      {
     112        die('Fatal: picture identifier is missing');
     113      }
     114    }
     115  }
    98116}
    99117
     
    274292        'uppercats'        => $result['uppercats'],
    275293
    276         'title' => get_cat_display_name($result['name'], '', false),
    277         )
    278       );
    279 
    280     if (!isset($_GET['calendar']))
     294        'title' => get_cat_display_name($result['name'], null, false),
     295        )
     296      );
     297
     298    if (!isset($page['chronology_field']))
    281299    {
    282300      $query = '
     
    322340  FROM '.IMAGES_TABLE.'
    323341    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
    324   WHERE '.get_sql_search_clause($_GET['search']).'
     342  WHERE '.get_sql_search_clause($page['search']).'
    325343    AND '.$forbidden.'
    326344  '.$conf['order_by'].'
     
    490508}
    491509
     510if (basename($_SERVER['SCRIPT_NAME']) == 'picture.php'
     511    and !isset($page['image_id']) )
     512{
     513  $query = '
     514SELECT id,file
     515  FROM '.IMAGES_TABLE .'
     516  WHERE id IN ('.implode(',',$page['items']).')
     517  AND file LIKE "' . $page['image_file'] . '.%" ESCAPE "|"'
     518;
     519  $result = pwg_query($query);
     520  if (mysql_num_rows($result)>0)
     521  {
     522    list($page['image_id'], $page['image_file']) = mysql_fetch_row($result);
     523  }
     524}
    492525?>
Note: See TracChangeset for help on using the changeset viewer.