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/functions.inc.php

    r1084 r1086  
    224224  $height = $original_height;
    225225  $is_original_size = true;
    226                
     226
    227227  if ( $max_width != "" )
    228228  {
     
    250250    {
    251251      if ( $ratioWidth < $ratioHeight )
    252       { 
     252      {
    253253        $width = floor( $original_width / $ratioHeight );
    254254        $height = $max_height;
    255255      }
    256256      else
    257       { 
    258         $width = $max_width; 
     257      {
     258        $width = $max_width;
    259259        $height = floor( $original_height / $ratioWidth );
    260260      }
     
    331331                             $remaining );
    332332  $return_string.= $treatment;
    333                
     333
    334334  return $return_string;
    335335}
     
    341341  // FIXME : with new advanced search, this function needs a rewrite
    342342  return $string;
    343  
     343
    344344  $words = explode( ',', $search );
    345345  $style = 'background-color:white;color:red;';
     
    360360    $login = ($user['id'] == $conf['guest_id'])
    361361      ? 'guest' : addslashes($user['username']);
    362    
     362
    363363    $query = '
    364364INSERT INTO '.HISTORY_TABLE.'
     
    388388
    389389  list($year,$month,$day,$hour,$minute,$second) = array(0,0,0,0,0,0);
    390  
     390
    391391  switch ( $type )
    392392  {
     
    433433{
    434434  global $conf,$page,$debug,$t2;
    435  
     435
    436436  $start = get_moment();
    437437  $result = mysql_query($query) or my_error($query."\n");
    438  
     438
    439439  $time = get_moment() - $start;
    440440
     
    444444    $page['queries_time'] = 0;
    445445  }
    446  
     446
    447447  $page['count_queries']++;
    448448  $page['queries_time']+= $time;
    449  
     449
    450450  if ($conf['show_queries'])
    451451  {
     
    460460    $output.= number_format( ($time+$start-$t2), 3, '.', ' ').' s)';
    461461    $output.= "</pre>\n";
    462    
     462
    463463    $debug .= $output;
    464464  }
    465  
     465
    466466  return $result;
    467467}
     
    501501
    502502  include( PHPWG_ROOT_PATH.'include/page_header.php' );
    503  
     503
    504504  $template->set_filenames( array( 'redirect' => 'redirect.tpl' ) );
    505505  $template->parse('redirect');
    506  
     506
    507507  include( PHPWG_ROOT_PATH.'include/page_tail.php' );
    508508
     
    519519{
    520520  $query_string = '';
    521  
     521
    522522  $str = $_SERVER['QUERY_STRING'];
    523523  parse_str($str, $vars);
    524  
     524
    525525  $is_first = true;
    526526  foreach ($vars as $key => $value)
     
    554554
    555555  $template_dir = PHPWG_ROOT_PATH.'template';
    556  
     556
    557557  foreach (get_dirs($template_dir) as $template)
    558558  {
     
    596596    $src.= strtolower(get_extension($path)).'.png';
    597597  }
    598  
     598
    599599  return $src;
    600600}
     
    623623{
    624624  $array = array();
    625  
     625
    626626  $result = pwg_query($query);
    627627  while ($row = mysql_fetch_array($result))
     
    642642{
    643643  global $template;
    644  
     644
    645645  $template->assign_block_vars(
    646646    $blockname, array('SELECTED' => '', 'VALUE' => 0, 'OPTION' => '--'));
    647  
     647
    648648  for ($i = 1; $i <= 31; $i++)
    649649  {
     
    669669{
    670670  global $template, $lang;
    671  
     671
    672672  $template->assign_block_vars(
    673673    $blockname, array('SELECTED' => '',
     
    698698{
    699699  global $user;
    700  
     700
    701701  include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
    702  
     702
    703703  $query = '
    704704SELECT element_id
     
    750750    echo '[l10n] language key "'.$key.'" is not defined<br />';
    751751  }
    752  
     752
    753753  return isset($lang[$key]) ? $lang[$key] : $key;
    754754}
     
    798798    die('Search id must be an integer');
    799799  }
    800  
     800
    801801  $query = '
    802802SELECT rules
     
    805805;';
    806806  list($serialized_rules) = mysql_fetch_row(pwg_query($query));
    807  
     807
    808808  return unserialize($serialized_rules);
    809809}
     
    821821{
    822822  $search = get_search_array($search_id);
    823  
     823
    824824  // SQL where clauses are stored in $clauses array during query
    825825  // construction
    826826  $clauses = array();
    827  
     827
    828828  foreach (array('file','name','comment','keywords','author') as $textfield)
    829829  {
     
    848848    }
    849849  }
    850  
     850
    851851  if (isset($search['fields']['allwords']))
    852852  {
     
    876876        );
    877877    }
    878    
     878
    879879    array_walk(
    880880      $word_clauses,
    881881      create_function('&$s','$s="(".$s.")";')
    882882      );
    883    
     883
    884884    array_push(
    885885      $clauses,
     
    893893      );
    894894  }
    895  
     895
    896896  foreach (array('date_available', 'date_creation') as $datefield)
    897897  {
     
    903903        );
    904904    }
    905    
     905
    906906    foreach (array('after','before') as $suffix)
    907907    {
    908908      $key = $datefield.'-'.$suffix;
    909      
     909
    910910      if (isset($search['fields'][$key]))
    911911      {
    912912        array_push(
    913913          $clauses,
    914          
     914
    915915          $datefield.
    916916          ($suffix == 'after'             ? ' >' : ' <').
    917917          ($search['fields'][$key]['inc'] ? '='  : '').
    918918          " '".$search['fields'][$key]['date']."'"
    919          
     919
    920920          );
    921921      }
    922922    }
    923923  }
    924  
     924
    925925  if (isset($search['fields']['cat']))
    926926  {
     
    934934      $cat_ids = $search['fields']['cat']['words'];
    935935    }
    936    
     936
    937937    $local_clause = 'category_id IN ('.implode(',', $cat_ids).')';
    938938    array_push($clauses, $local_clause);
    939939  }
    940  
     940
    941941  // adds brackets around where clauses
    942942  $clauses = prepend_append_array_items($clauses, '(', ')');
    943  
     943
    944944  $where_separator =
    945945    implode(
     
    947947      $clauses
    948948      );
    949  
     949
    950950  $search_clause = $where_separator;
    951  
     951
    952952  if (isset($forbidden))
    953953  {
     
    987987
    988988  $available_upgrade_ids = array();
    989  
     989
    990990  if ($contents = opendir($upgrades_path))
    991991  {
     
    10161016    .'/'.make_section_in_URL($params)
    10171017    ;
    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);
    10231020
    10241021  return $url;
     
    11071104    die('make_picture_URL: image_id is a required parameter');
    11081105  }
    1109  
     1106
    11101107  $url =
    11111108    PHPWG_ROOT_PATH.'picture.php?'
     
    11141111    ;
    11151112
    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*/
     1120function 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
    11171136  if (isset($params['start']) and $params['start'] > 0)
    11181137  {
    11191138    $url.= '/start-'.$params['start'];
    11201139  }
    1121 
    11221140  return $url;
    11231141}
     
    11351153{
    11361154  $section_string = '';
    1137  
     1155
    11381156  if (!isset($params['section']))
    11391157  {
     
    11601178    $params['section'] = 'categories';
    11611179  }
    1162  
     1180
    11631181  switch($params['section'])
    11641182  {
     
    11731191        $section_string.= 'category/'.$params['category'];
    11741192      }
    1175      
     1193
    11761194      break;
    11771195    }
     
    11891207        $section_string.= '/'.$tag;
    11901208      }
    1191      
     1209
    11921210      break;
    11931211    }
     
    11981216        die('make_section_in_URL: require a search identifier');
    11991217      }
    1200      
     1218
    12011219      $section_string.= 'search/'.$params['search'];
    12021220
     
    12111229
    12121230      $section_string.= 'list/'.implode(',', $params['list']);
    1213      
     1231
    12141232      break;
    12151233    }
Note: See TracChangeset for help on using the changeset viewer.