Changeset 1086 for trunk/picture.php


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/picture.php

    r1085 r1086  
    6464if ($page['current_rank'] != $page['first_rank'])
    6565{
    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
    8367  $page['previous_item'] = $page['items'][ $page['current_rank'] - 1 ];
     68  $page['first_item'] = $page['items'][ $page['first_rank'] ];
    8469}
    8570
    8671if ($page['current_rank'] != $page['last_rank'])
    8772{
    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
    10574  $page['next_item'] = $page['items'][ $page['current_rank'] + 1 ];
     75  $page['last_item'] = $page['items'][ $page['last_rank'] ];
    10676}
    10777
     
    145115
    146116      redirect($url_self);
    147      
     117
    148118      break;
    149119    }
     
    165135        redirect($url_self);
    166136      }
    167      
     137
    168138      break;
    169139    }
     
    179149        pwg_query($query);
    180150      }
    181      
     151
    182152      redirect($url_self);
    183  
     153
    184154      break;
    185155    }
     
    244214}
    245215usort($related_categories, 'global_rank_compare');
    246 //------------------------------------- prev, current & next picture management
     216//-------------------------first, prev, current, next & last picture management
    247217$picture = array();
    248218
     
    251221{
    252222  array_push($ids, $page['previous_item']);
     223  array_push($ids, $page['first_item']);
    253224}
    254225if (isset($page['next_item']))
    255226{
    256227  array_push($ids, $page['next_item']);
     228  array_push($ids, $page['last_item']);
    257229}
    258230
     
    269241  if (isset($page['previous_item']) and $row['id'] == $page['previous_item'])
    270242  {
    271     $i = 'prev';
     243    $i = 'previous';
    272244  }
    273245  else if (isset($page['next_item']) and $row['id'] == $page['next_item'])
    274246  {
    275247    $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';
    276256  }
    277257  else
     
    351331      )
    352332    );
     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  }
    353342}
    354343
     
    428417$page['body_id'] = 'thePicturePage';
    429418//------------------------------------------------------- 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     );
     419foreach ( 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  }
    454433}
    455434
     
    520499{
    521500  $uuid = uniqid(rand());
    522  
     501
    523502  $template->assign_block_vars(
    524503    'high',
     
    528507      )
    529508    );
    530  
     509
    531510  $template->assign_block_vars(
    532511    'download',
     
    572551  $result = pwg_query($query);
    573552  $row = mysql_fetch_array($result);
    574  
     553
    575554  if ($row['nb_fav'] == 0)
    576555  {
     
    642621{
    643622  $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>';
    647635}
    648636else
     
    653641// date of availability
    654642$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>';
    658655
    659656// size in pixels
Note: See TracChangeset for help on using the changeset viewer.