Changeset 2227 for trunk/picture.php


Ignore:
Timestamp:
Feb 29, 2008, 2:25:13 AM (17 years ago)
Author:
rvelices
Message:

picture, footer and picture modify template migration

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/picture.php

    r2224 r2227  
    8282  {
    8383    $uuid = uniqid(rand());
    84     $template->assign_block_vars(
     84    $template->assign(
    8585      'high',
    8686      array(
     
    9090      );
    9191  }
    92   $template->assign_vars( array(
     92  $template->assign( array(
    9393      'SRC_IMG' => $element_info['image_url'],
    9494      'ALT_IMG' => $element_info['file'],
     
    473473    'picture' =>
    474474      (($page['slideshow'] and $conf['light_slideshow']) ? 'slideshow.tpl' : 'picture.tpl'),
    475     'nav_buttons' => 'picture_nav_buttons.tpl'));
    476 
    477 if ($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());
    486   }
    487 }
     475    ));
     476
    488477
    489478$title =  $picture['current']['name'];
     
    524513    and $picture['next']['is_picture'] )
    525514{
    526   $template->assign_block_vars(
    527     'prefetch',
    528     array (
    529       'URL' => $picture['next']['image_url']
    530       )
    531     );
     515  $template->assign('U_PREFETCH', $picture['next']['image_url'] );
    532516}
    533517
    534518//------------------------------------------------------- navigation management
    535 foreach (array('first','previous','next','last') as $which_image)
     519foreach (array('first','previous','next','last', 'current') as $which_image)
    536520{
    537521  if (isset($picture[$which_image]))
    538522  {
    539     $template->assign_block_vars(
     523    $template->assign(
    540524      $which_image,
    541525      array(
    542         'TITLE_IMG' => $picture[$which_image]['name'],
    543         'IMG' => $picture[$which_image]['thumbnail'],
     526        'TITLE' => $picture[$which_image]['name'],
     527        'THUMB_SRC' => $picture[$which_image]['thumbnail'],
    544528        // Params slideshow was transmit to navigation buttons
    545529        'U_IMG' =>
    546530          add_url_params(
    547             $picture[$which_image]['url'], $slideshow_url_params)
     531            $picture[$which_image]['url'], $slideshow_url_params),
     532        'U_DOWNLOAD' => @$picture['current']['download_url'],
    548533        )
    549534      );
    550535  }
    551   else
    552   {
    553     $template->assign_block_vars(
    554       $which_image.'_unactive',
    555       array()
    556       );
    557   }
    558536}
    559537
     
    561539if ($page['slideshow'])
    562540{
     541  // Add local-slideshow.css file if exists
     542  // Not only for ligth
     543  $css = PHPWG_ROOT_PATH . get_themeconf('template_dir') . '/theme/'
     544       . get_themeconf('theme') . '/local-slideshow.css';
     545  if (file_exists($css))
     546  {
     547    //TODO CORRECT THIS $template->assign_block_vars('slideshow', array());
     548  }
     549
     550  $tpl_slideshow = array();
     551
    563552  //slideshow end
    564   $template->assign_block_vars(
    565     'stop_slideshow',
     553  $template->assign(
    566554    array(
    567       'U_SLIDESHOW' => $picture['current']['url'],
     555      'U_SLIDESHOW_STOP' => $picture['current']['url'],
    568556      )
    569557    );
     
    571559  foreach (array('repeat', 'play') as $p)
    572560  {
    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' =>
     561    $var_name =
     562      'U_'
     563      .($slideshow_params[$p] ? 'STOP_' : 'START_')
     564      .strtoupper($p);
     565
     566    $tpl_slideshow[$var_name] =
    578567          add_url_params(
    579568            $picture['current']['url'],
    580569            array('slideshow' =>
    581570              encode_slideshow_params(
    582                 array_merge($slideshow_params, 
     571                array_merge($slideshow_params,
    583572                  array($p => ! $slideshow_params[$p]))
    584                   )
    585573                )
    586574              )
    587           )
    588       );
     575          );
    589576  }
    590577
     
    594581    $new_slideshow_params =
    595582      correct_slideshow_params(
    596         array_merge($slideshow_params, 
     583        array_merge($slideshow_params,
    597584                  array('period' => $new_period)));
    598     $block_period = $op.'_period';
    599585
    600586    if ($new_slideshow_params['period'] === $new_period)
    601587    {
    602       $template->assign_block_vars(
    603         $block_period,
    604         array(
    605           // Params slideshow was transmit to navigation buttons
    606           'U_IMG' =>
     588      $var_name = 'U_'.strtoupper($op).'_PERIOD';
     589      $tpl_slideshow[$var_name] =
    607590            add_url_params(
    608591              $picture['current']['url'],
    609592              array('slideshow' => encode_slideshow_params($new_slideshow_params)
    610593                  )
    611                 )
    612               )
    613594          );
    614595    }
    615     else
    616     {
    617       $template->assign_block_vars(
    618         $block_period.'_unactive',
    619         array()
    620         );
    621     }
    622   }
     596  }
     597  $template->assign('slideshow', $tpl_slideshow );
    623598}
    624599else
    625600{
    626   $template->assign_block_vars(
    627     'start_slideshow',
     601  $template->assign(
    628602    array(
    629       'U_SLIDESHOW' =>
     603      'U_SLIDESHOW_START' =>
    630604        add_url_params(
    631605          $picture['current']['url'],
     
    633607      )
    634608    );
    635   $template->assign_block_vars(
    636     'up',array('U_URL' => $url_up));
    637 }
    638 
    639 $template->assign_vars(
     609}
     610
     611$template->assign(
    640612  array(
    641613    'SECTION_TITLE' => $page['title'],
    642     'PICTURE_TITLE' => $picture['current']['name'],
    643614    'PHOTO' => $title_nb,
    644     'TITLE' => $picture['current']['name'],
     615    'SHOW_PICTURE_NAME_ON_TITLE' => $conf['show_picture_name_on_title'],
    645616
    646617    'LEVEL_SEPARATOR' => $conf['level_separator'],
     618   
     619    'FILE_PICTURE_NAV_BUTTONS' => 'picture_nav_buttons.tpl',
    647620
    648621    'U_HOME' => make_index_url(),
     622    'U_UP' => $url_up,
    649623    'U_METADATA' => $url_metadata,
    650     'U_ADMIN' => $url_admin,
    651     'U_ADD_COMMENT' => $url_self,
    652624    )
    653625  );
    654626
    655 if ($conf['show_picture_name_on_title'])
    656 {
    657   $template->assign_block_vars('title', array());
    658 }
    659627
    660628//------------------------------------------------------- upper menu management
    661629
    662 // download link
    663 if ( isset($picture['current']['download_url']) )
    664 {
    665   $template->assign_block_vars(
    666     'download',
     630// admin links
     631if (is_admin())
     632{
     633  if (isset($page['category']))
     634  {
     635    $template->assign(
     636      array(
     637        'U_SET_AS_REPRESENTATIVE' => add_url_params($url_self,
     638                    array('action'=>'set_as_representative')
     639                 )
     640        )
     641      );
     642  }
     643 
     644  $template->assign(
    667645    array(
    668       'U_DOWNLOAD' => $picture['current']['download_url']
    669       )
    670     );
    671 }
    672 
    673 // button to set the current picture as representative
    674 if (is_admin() and isset($page['category']))
    675 {
    676   $template->assign_block_vars(
    677     'representative',
    678     array(
    679       'URL' => add_url_params($url_self,
    680                   array('action'=>'set_as_representative')
    681                )
    682       )
    683     );
    684 }
    685 
    686 // caddie button
    687 if (is_admin())
    688 {
    689   $template->assign_block_vars(
    690     'caddie',
    691     array(
    692       'URL' => add_url_params($url_self,
     646      'U_CADDIE' => add_url_params($url_self,
    693647                  array('action'=>'add_to_caddie')
    694                )
     648               ),
     649      'U_ADMIN' => $url_admin,
    695650      )
    696651    );
     
    712667  if ($row['nb_fav'] == 0)
    713668  {
    714     $template->assign_block_vars(
     669    $template->assign(
    715670      'favorite',
    716671      array(
     
    728683  else
    729684  {
    730     $template->assign_block_vars(
     685    $template->assign(
    731686      'favorite',
    732687      array(
     
    743698  }
    744699}
    745 //------------------------------------ admin link for information modifications
    746 if ( is_admin() )
    747 {
    748   $template->assign_block_vars('admin', array());
    749 }
    750700
    751701//--------------------------------------------------------- picture information
     
    755705    and !empty($picture['current']['comment']))
    756706{
    757   $template->assign_block_vars(
    758     'legend',
    759     array(
    760       'COMMENT_IMG' =>
     707  $template->assign(
     708      'COMMENT_IMG',
    761709        trigger_event('render_element_description',
    762710          $picture['current']['comment'])
    763       ));
     711      );
    764712  $header_infos['COMMENT'] = strip_tags($picture['current']['comment']);
    765713}
     
    781729  $header_infos['INFO_AUTHOR'] = $picture['current']['author'];
    782730}
    783 else
    784 {
    785   $infos['INFO_AUTHOR'] = l10n('N/A');
    786 }
    787731
    788732// creation date
     
    800744  $infos['INFO_CREATION_DATE'] =
    801745    '<a href="'.$url.'" rel="nofollow">'.$val.'</a>';
    802 }
    803 else
    804 {
    805   $infos['INFO_CREATION_DATE'] = l10n('N/A');
    806746}
    807747
     
    837777  }
    838778}
    839 else
    840 {
    841   $infos['INFO_DIMENSIONS'] = l10n('N/A');
    842 }
    843779
    844780// filesize
     
    848784    sprintf(l10n('%d Kb'), $picture['current']['filesize']);
    849785}
    850 else
    851 {
    852   $infos['INFO_FILESIZE'] = l10n('N/A');
    853 }
    854786
    855787// number of visits
     
    859791$infos['INFO_FILE'] = $picture['current']['file'];
    860792
    861 // tags
     793$template->assign($infos);
     794
     795// related tags
    862796$tags = get_common_tags( array($page['image_id']), -1);
    863797if ( count($tags) )
    864798{
    865   $infos['INFO_TAGS'] = '';
    866   foreach ($tags as $num => $tag)
    867   {
    868     $infos['INFO_TAGS'] .= $num ? ', ' : '';
    869     $infos['INFO_TAGS'] .= '<a href="'
    870       .make_index_url(
     799  foreach ($tags as $tag)
     800  {
     801    $template->append(
     802        'related_tags',
    871803        array(
    872           'tags' => array($tag)
     804          'ID'    => $tag['id'],
     805          'NAME'  => $tag['name'],
     806          'U_TAG' => make_index_url(
     807                      array(
     808                        'tags' => array($tag)
     809                        )
     810                      ),
     811          'U_TAG_IMAGE' => duplicate_picture_url(
     812                      array(
     813                        'section' => 'tags',
     814                        'tags' => array($tag)
     815                        )
     816                    )
    873817          )
    874         )
    875       .'">'.$tag['name'].'</a>';
    876   }
    877   $header_infos['INFO_TAGS'] = strip_tags($infos['INFO_TAGS']);
    878 }
    879 else
    880 {
    881   $infos['INFO_TAGS'] = l10n('N/A');
    882 }
    883 
    884 $template->assign_vars($infos);
     818      );
     819  }
     820}
    885821
    886822// related categories
    887823foreach ($related_categories as $category)
    888824{
    889   $template->assign_block_vars(
    890     'category',
    891     array(
    892       'LINE' => count($related_categories) > 3
     825  $template->append(
     826    'related_categories',
     827      count($related_categories) > 3
    893828        ? get_cat_display_name_cache($category['uppercats'])
    894829        : get_cat_display_name_from_id($category['category_id'])
    895       )
    896     );
    897 }
    898 
    899 // assign tpl picture_nav_buttons
    900 $template->assign_var_from_handle('NAV_BUTTONS', 'nav_buttons');
     830    );
     831}
    901832
    902833// maybe someone wants a special display (call it before page_header so that
     
    907838  $picture['current']
    908839  );
    909 $template->assign_var( 'ELEMENT_CONTENT', $element_content );
     840$template->assign( 'ELEMENT_CONTENT', $element_content );
    910841
    911842// +-----------------------------------------------------------------------+
     
    924855include(PHPWG_ROOT_PATH.'include/page_header.php');
    925856trigger_action('loc_end_picture');
    926 $template->parse('picture');
     857$template->pparse('picture');
    927858include(PHPWG_ROOT_PATH.'include/page_tail.php');
    928859?>
Note: See TracChangeset for help on using the changeset viewer.