Changeset 2218 for trunk/picture.php


Ignore:
Timestamp:
Feb 27, 2008, 9:25:18 PM (16 years ago)
Author:
rub
Message:

Resolved issue 0000807: New slideshow features

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/picture.php

    r2204 r2218  
    33// | PhpWebGallery - a PHP based picture gallery                           |
    44// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
    5 // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
     5// | Copyright (C) 2003-2008 PhpWebGallery Team - http://phpwebgallery.net |
    66// +-----------------------------------------------------------------------+
    77// | file          : $Id$
     
    7979    );
    8080
    81   if ( !isset($page['slideshow']) and isset($element_info['high_url']) )
     81  if ( !$page['slideshow'] and isset($element_info['high_url']) )
    8282  {
    8383    $uuid = uniqid(rand());
     
    425425;
    426426
    427 $url_slide = add_url_params(
    428   $picture['current']['url'],
    429   array( 'slideshow'=>$conf['slideshow_period'] )
    430   );
    431 
    432 
    433 $template->set_filename('picture', 'picture.tpl');
    434 if ( isset( $_GET['slideshow'] ) )
    435 {
    436   $page['meta_robots']=array('noindex'=>1, 'nofollow'=>1);
     427$slideshow_params = array();
     428$slideshow_url_params = array();
     429
     430if (isset($_GET['slideshow']))
     431{
    437432  $page['slideshow'] = true;
    438   if ( $conf['light_slideshow'] )
    439   { // Change template file
    440     // Add local-slideshow.css file if exists
    441     $template->set_filename('picture', 'slideshow.tpl');
    442     $css = get_root_url() . get_themeconf('template_dir') . '/theme/'
    443          . get_themeconf('theme') . '/local-slideshow.css';
    444     if (file_exists($css))
    445     {
    446       $template->assign_block_vars('slideshow', array());
    447     }
    448   }
    449   if ( isset($page['next_item']) )
    450   {
    451     // $redirect_msg, $refresh, $url_link and $title are required for creating
    452     // an automated refresh page in header.tpl
    453     $refresh= $_GET['slideshow'];
    454     $url_link = add_url_params(
    455         $picture['next']['url'],
    456         array('slideshow'=>$refresh)
    457       );
    458     $redirect_msg = nl2br(l10n('redirect_msg'));
     433  $page['meta_robots'] = array('noindex'=>1, 'nofollow'=>1);
     434
     435  $slideshow_params = decode_slideshow_params($_GET['slideshow']);
     436  $slideshow_url_params['slideshow'] = encode_slideshow_params($slideshow_params);
     437
     438  if ($slideshow_params['play'])
     439  {
     440    $id_pict_redirect = '';
     441    if (isset($page['next_item']))
     442    {
     443      $id_pict_redirect = 'next';
     444    }
     445    else
     446    {
     447      if ($slideshow_params['repeat'] and isset($page['first_item']))
     448      {
     449        $id_pict_redirect = 'first';
     450      }
     451    }
     452
     453    if (!empty($id_pict_redirect))
     454    {
     455      // $redirect_msg, $refresh, $url_link and $title are required for creating
     456      // an automated refresh page in header.tpl
     457      $refresh = $slideshow_params['period'];
     458      $url_link = add_url_params(
     459          $picture[$id_pict_redirect]['url'],
     460          $slideshow_url_params
     461        );
     462      $redirect_msg = nl2br(l10n('redirect_msg'));
     463    }
     464  }
     465}
     466else
     467{
     468  $page['slideshow'] = false;
     469}
     470
     471$template->set_filenames(
     472  array(
     473    'picture' =>
     474      (($page['slideshow'] and $conf['light_slideshow']) ? 'slideshow.tpl' : 'picture.tpl'),
     475    'nav_buttons' => 'picture_nav_buttons.tpl'));
     476
     477if ($page['slideshow'])
     478{
     479  // Add local-slideshow.css file if exists
     480  // Not only for ligth
     481  $css = get_root_url() . get_themeconf('template_dir') . '/theme/'
     482       . get_themeconf('theme') . '/local-slideshow.css';
     483  if (file_exists($css))
     484  {
     485    $template->assign_block_vars('slideshow', array());
    459486  }
    460487}
     
    515542        'TITLE_IMG' => $picture[$which_image]['name'],
    516543        'IMG' => $picture[$which_image]['thumbnail'],
    517         'U_IMG' => $picture[$which_image]['url'],
     544        // Params slideshow was transmit to navigation buttons
     545        'U_IMG' =>
     546          add_url_params(
     547            $picture[$which_image]['url'], $slideshow_url_params)
    518548        )
    519549      );
     
    526556      );
    527557  }
     558}
     559
     560
     561if ($page['slideshow'])
     562{
     563  //slideshow end
     564  $template->assign_block_vars(
     565    'stop_slideshow',
     566    array(
     567      'U_SLIDESHOW' => $picture['current']['url'],
     568      )
     569    );
     570
     571  foreach (array('repeat', 'play') as $p)
     572  {
     573    $template->assign_block_vars(
     574      ($slideshow_params[$p] ? 'stop' : 'start').'_'.$p,
     575      array(
     576        // Params slideshow was transmit to navigation buttons
     577        'U_IMG' =>
     578          add_url_params(
     579            $picture['current']['url'],
     580            array('slideshow' =>
     581              encode_slideshow_params(
     582                array_merge($slideshow_params,
     583                  array($p => ! $slideshow_params[$p]))
     584                  )
     585                )
     586              )
     587          )
     588      );
     589  }
     590
     591  foreach (array('dec', 'inc') as $op)
     592  {
     593    $new_period = $slideshow_params['period'] + ((($op == 'dec') ? -1 : 1) * $conf['slideshow_period_step']);
     594    $new_slideshow_params =
     595      correct_slideshow_params(
     596        array_merge($slideshow_params,
     597                  array('period' => $new_period)));
     598    $block_period = $op.'_period';
     599
     600    if ($new_slideshow_params['period'] === $new_period)
     601    {
     602      $template->assign_block_vars(
     603        $block_period,
     604        array(
     605          // Params slideshow was transmit to navigation buttons
     606          'U_IMG' =>
     607            add_url_params(
     608              $picture['current']['url'],
     609              array('slideshow' => encode_slideshow_params($new_slideshow_params)
     610                  )
     611                )
     612              )
     613          );
     614    }
     615    else
     616    {
     617      $template->assign_block_vars(
     618        $block_period.'_unactive',
     619        array()
     620        );
     621    }
     622  }
     623}
     624else
     625{
     626  $template->assign_block_vars(
     627    'start_slideshow',
     628    array(
     629      'U_SLIDESHOW' =>
     630        add_url_params(
     631          $picture['current']['url'],
     632          array( 'slideshow'=>''))
     633      )
     634    );
     635  $template->assign_block_vars(
     636    'thumbnails',array('U_UP' => $url_up));
    528637}
    529638
     
    538647
    539648    'U_HOME' => make_index_url(),
    540     'U_UP' => $url_up,
    541649    'U_METADATA' => $url_metadata,
    542650    'U_ADMIN' => $url_admin,
    543     'U_SLIDESHOW'=> $url_slide,
    544651    'U_ADD_COMMENT' => $url_self,
    545652    )
     
    643750
    644751//--------------------------------------------------------- picture information
    645 $header_infos = array();        //for html header use
     752$header_infos = array(); //for html header use
    646753// legend
    647754if (isset($picture['current']['comment'])
     
    790897}
    791898
    792 //slideshow end
    793 if (isset($_GET['slideshow']))
    794 {
    795   if (!is_numeric($_GET['slideshow']))
    796   {
    797     $_GET['slideshow'] = $conf['slideshow_period'];
    798   }
    799 
    800   $template->assign_block_vars(
    801     'stop_slideshow',
    802     array(
    803       'U_SLIDESHOW' => $picture['current']['url'],
    804       )
    805     );
    806 }
     899// assign tpl picture_nav_buttons
     900$template->assign_var_from_handle('NAV_BUTTONS', 'nav_buttons');
    807901
    808902// maybe someone wants a special display (call it before page_header so that
Note: See TracChangeset for help on using the changeset viewer.