From 35076ee1b9e32618d3c92bdd8aee20f2c4abb694 Mon Sep 17 00:00:00 2001 From: rvelices Date: Sat, 1 Mar 2008 13:12:07 +0000 Subject: - index.tpl, menubar.tpl, mainpage_categories.tpl and month_calendar.tpl go smarty - better template debugging tweak (the smarty console is shown only once at the end) git-svn-id: http://piwigo.org/svn/trunk@2231 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/calendar_base.class.php | 43 +++--- include/calendar_monthly.class.php | 195 +++++++++--------------- include/category_cats.inc.php | 25 ++- include/functions_calendar.inc.php | 13 +- include/menubar.inc.php | 162 ++++++++------------ include/page_tail.php | 19 +-- include/smarty/libs/Smarty.class.php | 22 ++- include/template.class.php | 64 +++++--- index.php | 110 +++++--------- template/yoga/footer.tpl | 2 +- template/yoga/index.tpl | 181 +++++++++++----------- template/yoga/mainpage_categories.tpl | 29 ++-- template/yoga/menubar.tpl | 279 ++++++++++++++++++---------------- template/yoga/month_calendar.tpl | 92 +++++++---- 14 files changed, 586 insertions(+), 650 deletions(-) diff --git a/include/calendar_base.class.php b/include/calendar_base.class.php index 67282190c..aff910253 100644 --- a/include/calendar_base.class.php +++ b/include/calendar_base.class.php @@ -1,7 +1,7 @@ date_field = 'date_creation'; } $this->inner_sql = $inner_sql; - $this->has_nav_bar = false; } function get_display_name() @@ -262,13 +259,12 @@ SELECT DISTINCT('.$this->calendar_levels[$level]['sql'] isset($labels) ? $labels : $this->calendar_levels[$level]['labels'] ); - $template->assign_block_vars( - 'calendar.navbar', + $template->append( + 'chronology_navigation_bars', array( - 'BAR' => $nav_bar, + 'CONTENT' => $nav_bar, ) ); - $this->has_nav_bar = true; } /** @@ -311,40 +307,47 @@ GROUP BY period'; } $current_rank = $upper_items_rank[$current]; - if (!$this->has_nav_bar and - ($current_rank>0 or $current_rank < count($upper_items)-1 ) ) - { - $template->assign_block_vars( 'calendar.navbar', array() ); - } - + $tpl_var = array(); + if ( $current_rank>0 ) { // has previous $prev = $upper_items[$current_rank-1]; $chronology_date = explode('-', $prev); - $template->assign_block_vars( - 'calendar.navbar.prev', + $tpl_var['previous'] = array( 'LABEL' => $this->get_date_nice_name($prev), 'URL' => duplicate_index_url( array('chronology_date'=>$chronology_date), array('start') ) - ) ); } + if ( $current_rank < count($upper_items)-1 ) { // has next $next = $upper_items[$current_rank+1]; $chronology_date = explode('-', $next); - $template->assign_block_vars( - 'calendar.navbar.next', + $tpl_var['next'] = array( 'LABEL' => $this->get_date_nice_name($next), 'URL' => duplicate_index_url( array('chronology_date'=>$chronology_date), array('start') ) - ) ); } + + if ( !empty($tpl_var) ) + { + $existing = & $template->get_template_vars('chronology_navigation_bars'); + if ( !empty($existing) ) + { + $existing[ sizeof($existing)-1 ] = + array_merge( $existing[ sizeof($existing)-1 ], $tpl_var); + } + else + { + $template->append( 'chronology_navigation_bars', $tpl_var ); + } + } } } ?> diff --git a/include/calendar_monthly.class.php b/include/calendar_monthly.class.php index 7200dff09..ec3a656bc 100644 --- a/include/calendar_monthly.class.php +++ b/include/calendar_monthly.class.php @@ -71,16 +71,22 @@ function generate_category_content() $view_type = $page['chronology_view']; if ($view_type==CAL_VIEW_CALENDAR) { + global $template; + $tpl_var = array(); if ( count($page['chronology_date'])==0 ) {//case A: no year given - display all years+months - if ($this->build_global_calendar()) + if ($this->build_global_calendar($tpl_var)) + { + $template->assign('chronology_calendar', $tpl_var); return true; + } } if ( count($page['chronology_date'])==1 ) {//case B: year given - display all days in given year - if ($this->build_year_calendar()) + if ($this->build_year_calendar($tpl_var)) { + $template->assign('chronology_calendar', $tpl_var); $this->build_nav_bar(CYEAR); // years return true; } @@ -88,9 +94,10 @@ function generate_category_content() if ( count($page['chronology_date'])==2 ) {//case C: year+month given - display a nice month calendar - $this->build_month_calendar(); - //$this->build_nav_bar(CYEAR); // years - //$this->build_nav_bar(CMONTH); // month + if ( $this->build_month_calendar($tpl_var) ) + { + $template->assign('chronology_calendar', $tpl_var); + } $this->build_next_prev(); return true; } @@ -98,7 +105,6 @@ function generate_category_content() if ($view_type==CAL_VIEW_LIST or count($page['chronology_date'])==3) { - $has_nav_bar = false; if ( count($page['chronology_date'])==0 ) { $this->build_nav_bar(CYEAR); // years @@ -213,7 +219,7 @@ function get_all_days_in_month($year, $month) return $nb_days; } -function build_global_calendar() +function build_global_calendar(&$tpl_var) { global $page; assert( count($page['chronology_date']) == 0 ); @@ -246,27 +252,27 @@ function build_global_calendar() return false; } - global $lang, $template; + global $lang; foreach ( $items as $year=>$year_data) { $chronology_date = array( $year ); $url = duplicate_index_url( array('chronology_date'=>$chronology_date) ); - $nav_bar = ''.$year.''; - $nav_bar .= ' ('.$year_data['nb_images'].')'; - $nav_bar .= '
'; - - $nav_bar .= $this->get_nav_bar_from_items( $chronology_date, + $nav_bar = $this->get_nav_bar_from_items( $chronology_date, $year_data['children'], 'calCal', false, false, $lang['month'] ); - $template->assign_block_vars( 'calendar.calbar', - array( 'BAR' => $nav_bar) - ); + $tpl_var['calendar_bars'][] = + array( + 'U_HEAD' => $url, + 'NB_IMAGES' => $year_data['nb_images'], + 'HEAD_LABEL' => $year, + 'NAV_BAR' => $nav_bar, + ); } return true; } -function build_year_calendar() +function build_year_calendar(&$tpl_var) { global $page; assert( count($page['chronology_date']) == 1 ); @@ -296,29 +302,28 @@ function build_year_calendar() $page['chronology_date'][CMONTH] = $m; return false; } - global $lang, $template; + global $lang; foreach ( $items as $month=>$month_data) { $chronology_date = array( $page['chronology_date'][CYEAR], $month ); $url = duplicate_index_url( array('chronology_date'=>$chronology_date) ); - $nav_bar = ''; - $nav_bar .= $lang['month'][$month].''; - $nav_bar .= ' ('.$month_data['nb_images'].')'; - $nav_bar .= '
'; - - $nav_bar .= $this->get_nav_bar_from_items( $chronology_date, + $nav_bar = $this->get_nav_bar_from_items( $chronology_date, $month_data['children'], 'calCal', false ); - $template->assign_block_vars( 'calendar.calbar', - array( 'BAR' => $nav_bar) - ); + $tpl_var['calendar_bars'][] = + array( + 'U_HEAD' => $url, + 'NB_IMAGES' => $month_data['nb_images'], + 'HEAD_LABEL' => $lang['month'][$month], + 'NAV_BAR' => $nav_bar, + ); } return true; } -function build_month_calendar() +function build_month_calendar(&$tpl_var) { global $page; $query='SELECT DISTINCT(DAYOFMONTH('.$this->date_field.')) as period, @@ -358,7 +363,7 @@ SELECT id, file,tn_ext,path, width, height, DAYOFWEEK('.$this->date_field.')-1 a $items[$day]['dow'] = $row['dow']; } - global $lang, $template, $conf; + global $lang, $conf; if ( !empty($items) and $conf['calendar_month_cell_width']>0 @@ -389,36 +394,15 @@ SELECT id, file,tn_ext,path, width, height, DAYOFWEEK('.$this->date_field.')-1 a $cell_width = $conf['calendar_month_cell_width']; $cell_height = $conf['calendar_month_cell_height']; - $template->set_filenames( - array( - 'month_calendar'=>'month_calendar.tpl', - ) - ); - - $template->assign_block_vars('calendar.thumbnails', - array( - 'WIDTH'=>$cell_width, - 'HEIGHT'=>$cell_height, - ) - ); - - //fill the heading with day names - $template->assign_block_vars('calendar.thumbnails.head', array()); - foreach( $wday_labels as $d => $label) - { - $template->assign_block_vars('calendar.thumbnails.head.col', - array('LABEL'=>$label) - ); - } - - $template->assign_block_vars('calendar.thumbnails.row', array()); + $tpl_weeks = array(); + $tpl_crt_week = array(); //fill the empty days in the week before first day of this month for ($i=0; $i<$first_day_dow; $i++) { - $template->assign_block_vars('calendar.thumbnails.row.col', array()); - $template->assign_block_vars('calendar.thumbnails.row.col.blank', array()); + $tpl_crt_week[] = array(); } + for ( $day = 1; $day <= $this->get_all_days_in_month( $page['chronology_date'][CYEAR], $page['chronology_date'][CMONTH] @@ -428,28 +412,22 @@ SELECT id, file,tn_ext,path, width, height, DAYOFWEEK('.$this->date_field.')-1 a $dow = ($first_day_dow + $day-1)%7; if ($dow==0 and $day!=1) { - $template->assign_block_vars('calendar.thumbnails.row', array()); + $tpl_weeks[] = $tpl_crt_week; // add finished week to week list + $tpl_crt_week = array(); // start new week } - $template->assign_block_vars('calendar.thumbnails.row.col', array()); + if ( !isset($items[$day]) ) - { - $template->assign_block_vars('calendar.thumbnails.row.col.empty', - array('LABEL'=>$day)); + {// empty day + $tpl_crt_week[] = + array( + 'DAY' => $day + ); } else { -/* // first try to guess thumbnail size - if ( !empty($items[$day]['width']) ) - { - $tn_size = get_picture_size( - $items[$day]['width'], $items[$day]['height'], - $conf['tn_width'], $conf['tn_height'] ); - } - else*/ - {// item not an image (tn is either mime type or an image) - $thumb = get_thumbnail_path($items[$day]); - $tn_size = @getimagesize($thumb); - } + $thumb = get_thumbnail_path($items[$day]); + $tn_size = @getimagesize($thumb); + $tn_width = $tn_size[0]; $tn_height = $tn_size[1]; @@ -459,21 +437,21 @@ SELECT id, file,tn_ext,path, width, height, DAYOFWEEK('.$this->date_field.')-1 a $ratio_w = $tn_width/$cell_width; $ratio_h = $tn_height/$cell_height; - $pos_top=$pos_left=0; - $img_width=$img_height=''; + $css_style = ''; + if ( $ratio_w>1 and $ratio_h>1) {// cell completely smaller than the thumbnail so we will let the browser // resize the thumbnail if ($ratio_w > $ratio_h ) {// thumbnail ratio compared to cell -> wide format - $img_height = 'height="'.$cell_height.'"'; + $css_style = 'height:'.$cell_height.'px;'; $browser_img_width = $cell_height*$tn_width/$tn_height; $pos_left = ($browser_img_width-$cell_width)/2; } else { - $img_width = 'width="'.$cell_width.'"'; + $css_style = 'width:'.$cell_width.'px;'; $browser_img_height = $cell_width*$tn_height/$tn_width; $pos_top = ($browser_img_height-$cell_height)/2; } @@ -484,7 +462,6 @@ SELECT id, file,tn_ext,path, width, height, DAYOFWEEK('.$this->date_field.')-1 a $pos_top = ($tn_height-$cell_height)/2; } - $css_style = ''; if ( round($pos_left)!=0) { $css_style.='left:'.round(-$pos_left).'px;'; @@ -505,64 +482,32 @@ SELECT id, file,tn_ext,path, width, height, DAYOFWEEK('.$this->date_field.')-1 a ); $alt = $wday_labels[$dow] . ' ' . $day. ' ('.sprintf("%d ".l10n('pictures'), $items[$day]['nb_images']).')'; - $template->assign_block_vars('calendar.thumbnails.row.col.full', - array( - 'LABEL' => $day, - 'IMAGE' => $items[$day]['tn_url'], - 'U_IMG_LINK'=> $url, - 'STYLE' => $css_style, - 'IMG_WIDTH' => $img_width, - 'IMG_HEIGHT'=> $img_height, - 'IMAGE_ALT' => $alt, - ) + + $tpl_crt_week[] = + array( + 'DAY' => $day, + 'IMAGE' => $items[$day]['tn_url'], + 'U_IMG_LINK'=> $url, + 'IMAGE_STYLE' => $css_style, + 'IMAGE_ALT' => $alt, ); } } //fill the empty days in the week after the last day of this month while ( $dow<6 ) { - $template->assign_block_vars('calendar.thumbnails.row.col', array()); - $template->assign_block_vars('calendar.thumbnails.row.col.blank', array()); + $tpl_crt_week[] = array(); $dow++; } - $template->assign_var_from_handle('MONTH_CALENDAR', 'month_calendar'); - } - else - { - $template->assign_block_vars('thumbnails', array()); - $template->assign_block_vars('thumbnails.line', array()); - foreach ( $items as $day=>$data) - { - $url = duplicate_index_url( - array( - 'chronology_date' => - array( - $page['chronology_date'][CYEAR], - $page['chronology_date'][CMONTH], - $day - ) - ) - ); - - $thumbnail_title = $lang['day'][$data['dow']] . ' ' . $day; - $name = $thumbnail_title .' ('.$data['nb_images'].')'; - - $template->assign_block_vars( - 'thumbnails.line.thumbnail', - array( - 'IMAGE'=>$data['tn_url'], - 'IMAGE_ALT'=>$data['file'], - 'IMAGE_TITLE'=>$thumbnail_title, - 'U_IMG_LINK'=>$url - ) - ); - $template->assign_block_vars( - 'thumbnails.line.thumbnail.category_name', - array( - 'NAME' => $name - ) + $tpl_weeks[] = $tpl_crt_week; + + $tpl_var['month_view'] = + array( + 'CELL_WIDTH' => $cell_width, + 'CELL_HEIGHT' => $cell_height, + 'wday_labels' => $wday_labels, + 'weeks' => $tpl_weeks, ); - } } return true; diff --git a/include/category_cats.inc.php b/include/category_cats.inc.php index 894990885..e969b475b 100644 --- a/include/category_cats.inc.php +++ b/include/category_cats.inc.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | PhpWebGallery - a PHP based picture gallery | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | -// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | +// | Copyright (C) 2003-2008 PhpWebGallery Team - http://phpwebgallery.net | // +-----------------------------------------------------------------------+ // | file : $Id$ // | last update : $Date$ @@ -233,12 +233,11 @@ if (count($categories) > 0) $icon_ts = get_icon($category['max_date_last'], $category['is_child_date_last']); - $template->assign_block_vars( - 'categories.category', + $tpl_var = array( - 'SRC' => $thumbnail_src_of[$category['representative_picture_id']], + 'ID' => $category['id'], + 'TN_SRC' => $thumbnail_src_of[$category['representative_picture_id']], 'ALT' => $category['name'], - 'TITLE' => l10n('hint_category'), 'ICON' => $icon_ts, 'URL' => make_index_url( @@ -260,8 +259,7 @@ if (count($categories) > 0) @$category['comment'], 'subcatify_category_description')), 'NAME' => $name, - ) - ); + ); if ($conf['display_fromto']) { @@ -286,16 +284,13 @@ if (count($categories) > 0) format_date($to) ); } - - $template->assign_block_vars( - 'categories.category.dates', - array( - 'INFO' => $info, - ) - ); + $tpl_var['INFO_DATES'] = $info; } } - } + }//fromto + + $template->append( 'category_thumbnails', $tpl_var); + //plugins need to add/modify sth in this loop ? trigger_action('loc_index_category_thumbnail', diff --git a/include/functions_calendar.inc.php b/include/functions_calendar.inc.php index 86ef40837..74055f39d 100644 --- a/include/functions_calendar.inc.php +++ b/include/functions_calendar.inc.php @@ -200,6 +200,9 @@ WHERE id IN (' . implode(',',$page['items']) .')'; $page['items'] = array(); $must_show_list = false; } + + $page['comment'] = ''; + $template->assign('FILE_CHRONOLOGY_VIEW', 'month_calendar.tpl'); foreach ($styles as $style => $style_data) { @@ -207,7 +210,7 @@ WHERE id IN (' . implode(',',$page['items']) .')'; { if ( $style_data['view_calendar'] or $view != CAL_VIEW_CALENDAR) { - $selected = ''; + $selected = false; if ($style!=$cal_style) { @@ -231,11 +234,11 @@ WHERE id IN (' . implode(',',$page['items']) .')'; if ($style==$cal_style and $view==$page['chronology_view'] ) { - $selected = 'SELECTED'; + $selected = true; } - $template->assign_block_vars( - 'calendar.views.view', + $template->append( + 'chronology_views', array( 'VALUE' => $url, 'CONTENT' => l10n('chronology_'.$style.'_'.$view), @@ -251,7 +254,7 @@ WHERE id IN (' . implode(',',$page['items']) .')'; $calendar_title = '' .$fields[$page['chronology_field']]['label'].''; $calendar_title.= $calendar->get_display_name(); - $template->merge_block_vars('calendar', + $template->assign('chronology', array( 'TITLE' => $calendar_title ) diff --git a/include/menubar.inc.php b/include/menubar.inc.php index 9729f2f47..38c0b3fd0 100644 --- a/include/menubar.inc.php +++ b/include/menubar.inc.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | PhpWebGallery - a PHP based picture gallery | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | -// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | +// | Copyright (C) 2003-2008 PhpWebGallery Team - http://phpwebgallery.net | // +-----------------------------------------------------------------------+ // | file : $Id$ // | last update : $Date$ @@ -36,18 +36,12 @@ $template->set_filenames( trigger_action('loc_begin_menubar'); -$template->assign_vars( +$template->assign( array( 'NB_PICTURE' => $user['nb_total_images'], - 'USERNAME' => $user['username'], 'MENU_CATEGORIES_CONTENT' => get_categories_menu(), - 'F_IDENTIFY' => get_root_url().'identification.php', 'U_CATEGORIES' => make_index_url(array('section' => 'categories')), - 'U_REGISTER' => get_root_url().'register.php', 'U_LOST_PASSWORD' => get_root_url().'password.php', - 'U_LOGOUT' => get_root_url().'?act=logout', - 'U_ADMIN'=> get_root_url().'admin.php', - 'U_PROFILE'=> get_root_url().'profile.php', ) ); @@ -59,30 +53,27 @@ foreach ($conf['links'] as $url => $url_data) $url_data = array('label' => $url_data); } - if + if ( (!isset($url_data['eval_visible'])) or (eval($url_data['eval_visible'])) ) { - $template->assign_block_vars( - 'links.link', - array( + $tpl_var = array( 'URL' => $url, 'LABEL' => $url_data['label'] - ) ); + if (!isset($url_data['new_window']) or $url_data['new_window']) { - $template->assign_block_vars( - 'links.link.new_window', + $tpl_var['new_window'] = array( - 'name' => (isset($url_data['nw_name']) ? $url_data['nw_name'] : ''), - 'features' => (isset($url_data['nw_features']) ? $url_data['nw_features'] : '') - ) + 'NAME' => (isset($url_data['nw_name']) ? $url_data['nw_name'] : ''), + 'FEATURES' => (isset($url_data['nw_features']) ? $url_data['nw_features'] : '') ); } + $template->append('links', $tpl_var); } } @@ -91,26 +82,22 @@ if (!empty($conf['filter_pages']) and get_filter_page_value('used')) { if ($filter['enabled']) { - $template->assign_block_vars( - 'stop_filter', - array( - 'URL' => add_url_params(make_index_url(array()), array('filter' => 'stop')) - ) + $template->assign( + 'U_STOP_FILTER', + add_url_params(make_index_url(array()), array('filter' => 'stop')) ); } else { - $template->assign_block_vars( - 'start_filter', - array( - 'URL' => add_url_params(make_index_url(array()), array('filter' => 'start-recent-'.$user['recent_period'])) - ) + $template->assign( + 'U_START_FILTER', + add_url_params(make_index_url(array()), array('filter' => 'start-recent-'.$user['recent_period'])) ); } } //------------------------------------------------------------------------ tags -if ('tags' == $page['section']) +if ('tags' == @$page['section']) { // display tags associated to currently tagged items, less current tags $tags = array(); @@ -124,10 +111,10 @@ if ('tags' == $page['section']) foreach ($tags as $tag) { - $template->assign_block_vars( - 'tags.tag', + $template->append( + 'related_tags', array( - 'URL' => make_index_url( + 'U_TAG' => make_index_url( array( 'tags' => array($tag) ) @@ -135,40 +122,30 @@ if ('tags' == $page['section']) 'NAME' => $tag['name'], - 'TITLE' => l10n('See pictures linked to this tag only'), + 'CLASS' => 'tagLevel'.$tag['level'], - 'CLASS' => 'tagLevel'.$tag['level'] - ) - ); + 'add' => array( - $template->assign_block_vars( - 'tags.tag.add', - array( - 'URL' => make_index_url( - array( - 'tags' => array_merge( - $page['tags'], - array($tag) - ) + 'URL' => make_index_url( + array( + 'tags' => array_merge( + $page['tags'], + array($tag) + ) + ) + ), + 'COUNTER' => $tag['counter'], ) - ), - 'TITLE' => l10n_dec( - '%d picture are also linked to current tags', - '%d pictures are also linked to current tags', - $tag['counter']), ) ); - } } //---------------------------------------------------------- special categories // favorites categories if ( !is_a_guest() ) { - $template->assign_block_vars('username', array()); - - $template->assign_block_vars( - 'special_cat', + $template->append( + 'special_categories', array( 'URL' => make_index_url(array('section' => 'favorites')), 'TITLE' => l10n('favorite_cat_hint'), @@ -176,8 +153,8 @@ if ( !is_a_guest() ) )); } // most visited -$template->assign_block_vars( - 'special_cat', +$template->append( + 'special_categories', array( 'URL' => make_index_url(array('section' => 'most_visited')), 'TITLE' => l10n('most_visited_cat_hint'), @@ -186,8 +163,8 @@ $template->assign_block_vars( // best rated if ($conf['rate']) { - $template->assign_block_vars( - 'special_cat', + $template->append( + 'special_categories', array( 'URL' => make_index_url(array('section' => 'best_rated')), 'TITLE' => l10n('best_rated_cat_hint'), @@ -196,8 +173,8 @@ if ($conf['rate']) ); } // random -$template->assign_block_vars( - 'special_cat', +$template->append( + 'special_categories', array( 'URL' => get_root_url().'random.php', 'TITLE' => l10n('random_cat_hint'), @@ -206,16 +183,16 @@ $template->assign_block_vars( )); // recent pics -$template->assign_block_vars( - 'special_cat', +$template->append( + 'special_categories', array( 'URL' => make_index_url(array('section' => 'recent_pics')), 'TITLE' => l10n('recent_pics_cat_hint'), 'NAME' => l10n('recent_pics_cat'), )); // recent cats -$template->assign_block_vars( - 'special_cat', +$template->append( + 'special_categories', array( 'URL' => make_index_url(array('section' => 'recent_cats')), 'TITLE' => l10n('recent_cats_cat_hint'), @@ -223,8 +200,8 @@ $template->assign_block_vars( )); // calendar -$template->assign_block_vars( - 'special_cat', +$template->append( + 'special_categories', array( 'URL' => make_index_url( @@ -244,44 +221,43 @@ $template->assign_block_vars( if (is_a_guest()) { - $template->assign_block_vars('login', array()); + $template->assign( + array( + 'U_IDENTIFY' => get_root_url().'identification.php', + 'AUTHORIZE_REMEMBERING' => $conf['authorize_remembering'] + ) + ); - $template->assign_block_vars('quickconnect', array()); - if ($conf['authorize_remembering']) - { - $template->assign_block_vars('quickconnect.remember_me', array()); - } if ($conf['allow_user_registration']) { - $template->assign_block_vars('register', array()); - $template->assign_block_vars('quickconnect.register', array()); + $template->assign( 'U_REGISTER', get_root_url().'register.php'); } } else { - $template->assign_block_vars('hello', array()); + $template->assign('USERNAME', $user['username']); if (is_autorize_status(ACCESS_CLASSIC)) { - $template->assign_block_vars('profile', array()); + $template->assign('U_PROFILE', get_root_url().'profile.php'); } // the logout link has no meaning with Apache authentication : it is not // possible to logout with this kind of authentication. if (!$conf['apache_authentication']) { - $template->assign_block_vars('logout', array()); + $template->assign('U_LOGOUT', get_root_url().'?act=logout'); } if (is_admin()) { - $template->assign_block_vars('admin', array()); + $template->assign('U_ADMIN', get_root_url().'admin.php'); } } // tags link -$template->assign_block_vars( - 'summary', +$template->append( + 'summaries', array( 'TITLE' => l10n('See available tags'), 'NAME' => l10n('Tags'), @@ -290,8 +266,8 @@ $template->assign_block_vars( ); // search link -$template->assign_block_vars( - 'summary', +$template->append( + 'summaries', array( 'TITLE'=>l10n('hint_search'), 'NAME'=>l10n('search'), @@ -299,11 +275,10 @@ $template->assign_block_vars( 'REL'=> 'rel="search"' ) ); -$template->assign_block_vars( 'summary.quick_search', array() ); // comments link -$template->assign_block_vars( - 'summary', +$template->append( + 'summaries', array( 'TITLE'=>l10n('hint_comments'), 'NAME'=>l10n('comments'), @@ -312,8 +287,8 @@ $template->assign_block_vars( ); // about link -$template->assign_block_vars( - 'summary', +$template->append( + 'summaries', array( 'TITLE' => l10n('about_page_title'), 'NAME' => l10n('About'), @@ -322,8 +297,8 @@ $template->assign_block_vars( ); // notification -$template->assign_block_vars( - 'summary', +$template->append( + 'summaries', array( 'TITLE'=>l10n('RSS feed'), 'NAME'=>l10n('Notification'), @@ -335,12 +310,7 @@ $template->assign_block_vars( if (isset($page['category']) and $page['category']['uploadable'] ) { // upload a picture in the category $url = get_root_url().'upload.php?cat='.$page['category']['id']; - $template->assign_block_vars( - 'upload', - array( - 'U_UPLOAD'=> $url - ) - ); + $template->assign('U_UPLOAD', $url); } trigger_action('loc_end_menubar'); diff --git a/include/page_tail.php b/include/page_tail.php index dcb9155a3..4e5f88074 100644 --- a/include/page_tail.php +++ b/include/page_tail.php @@ -44,15 +44,20 @@ if (!is_a_guest()) //------------------------------------------------------------- generation time $debug_vars = array(); -if ($conf['show_gt']) + +if ($conf['show_queries']) { - $time = get_elapsed_time($t2, get_moment()); + $debug_vars = array_merge($debug_vars, array('QUERIES_LIST' => $debug) ); +} +if ($conf['show_gt']) +{ if (!isset($page['count_queries'])) { $page['count_queries'] = 0; $page['queries_time'] = 0; } + $time = get_elapsed_time($t2, get_moment()); $debug_vars = array_merge($debug_vars, array('TIME' => $time, @@ -61,16 +66,12 @@ if ($conf['show_gt']) ); } -if ($conf['show_queries']) -{ - $debug_vars = array_merge($debug_vars, array('QUERIES_LIST' => $debug) ); -} - $template->assign('debug', $debug_vars ); trigger_action('loc_end_page_tail'); // // Generate the page // -$template->pparse('tail'); -?> +$template->parse('tail'); +$template->p(); +?> \ No newline at end of file diff --git a/include/smarty/libs/Smarty.class.php b/include/smarty/libs/Smarty.class.php index c79874606..6b893dec8 100644 --- a/include/smarty/libs/Smarty.class.php +++ b/include/smarty/libs/Smarty.class.php @@ -1057,7 +1057,7 @@ class Smarty } else { // var non-existant, return valid reference $_tmp = null; - return $_tmp; + return $_tmp; } } @@ -1116,7 +1116,7 @@ class Smarty function fetch($resource_name, $cache_id = null, $compile_id = null, $display = false) { static $_cache_info = array(); - + $_smarty_old_error_level = $this->debugging ? error_reporting() : error_reporting(isset($this->error_reporting) ? $this->error_reporting : error_reporting() & ~E_NOTICE); @@ -1292,11 +1292,19 @@ class Smarty if ($display) { if (isset($_smarty_results)) { echo $_smarty_results; } + } + + if ($this->debugging) { + // capture time for debugging info + $_params = array(); + require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); + $this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = (smarty_core_get_microtime($_params, $this) - $_debug_start_time); + } + + if ($display) { if ($this->debugging) { // capture time for debugging info $_params = array(); - require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); - $this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = (smarty_core_get_microtime($_params, $this) - $_debug_start_time); require_once(SMARTY_CORE_DIR . 'core.display_debug_console.php'); echo smarty_core_display_debug_console($_params, $this); } @@ -1932,10 +1940,10 @@ class Smarty { return eval($code); } - + /** * Extracts the filter name from the given callback - * + * * @param callback $function * @return string */ @@ -1950,7 +1958,7 @@ class Smarty return $function; } } - + /**#@-*/ } diff --git a/include/template.class.php b/include/template.class.php index da4b69034..1afdb655c 100644 --- a/include/template.class.php +++ b/include/template.class.php @@ -222,21 +222,6 @@ class Template { * is true. */ function parse($handle, $return=false) - { - return $this->_pparse_or_parse($handle, $return, false); - } - - /** - * Load the file for the handle, eventually compile the file and run the compiled - * code. This will print out the results of executing the template. - */ - function pparse($handle) - { - $this->_pparse_or_parse($handle, false, true); - } - - - /*private*/ function _pparse_or_parse($handle, $return, $immediate_display) { if ( !isset($this->files[$handle]) ) { @@ -253,31 +238,54 @@ class Template { if ($is_new) { - $this->smarty->assign( 'pwg_root', get_root_url() ); //deprecated $this->smarty->assign( 'ROOT_URL', get_root_url() ); - if ($immediate_display) - $this->p(); - $v = $this->smarty->fetch($this->files[$handle], null, null, $immediate_display ? true : false); - if ($immediate_display) - return; + $v = $this->smarty->fetch($this->files[$handle], null, null, false); } else { $this->_old->set_filename( $handle, $this->files[$handle] ); $v = $this->_old->parse($handle, true); } - if ($return==false) + if ($return) { - $this->output .= $v; + return $v; } - return $v; + $this->output .= $v; } - /** flushes current output */ + /** + * Load the file for the handle, eventually compile the file and run the compiled + * code. This will print out the results of executing the template. + */ + function pparse($handle) + { + $this->parse($handle, false); + echo $this->output; + $this->output=''; + + } + + + /** flushes the output */ function p() { + $start = get_moment(); + echo $this->output; $this->output=''; + + if ($this->smarty->debugging) + { + global $t2; + $this->smarty->assign( + array( + 'AAAA_DEBUG_OUTPUT_TIME__' => get_elapsed_time($start, get_moment()), + 'AAAA_DEBUG_TOTAL_TIME__' => get_elapsed_time($t2, get_moment()) + ) + ); + require_once(SMARTY_CORE_DIR . 'core.display_debug_console.php'); + echo smarty_core_display_debug_console(null, $this->smarty); + } } /** @@ -315,6 +323,12 @@ class Template { $this->smarty->append( $tpl_var, $value, $merge ); } + /** see smarty get_template_vars http://www.smarty.net/manual/en/api.get_template_vars.php */ + function &get_template_vars($name=null) + { + return $this->smarty->get_template_vars( $name ); + } + /** see smarty append http://www.smarty.net/manual/en/api.clear_assign.php */ function clear_assign($tpl_var) { diff --git a/index.php b/index.php index 815b9376c..5ebc91083 100644 --- a/index.php +++ b/index.php @@ -103,25 +103,21 @@ if (count($page['items']) > 0) { $template_title.= ' ['.count($page['items']).']'; } -$template->assign_var('TITLE', $template_title); +$template->assign('TITLE', $template_title); if (isset($page['flat']) or isset($page['chronology_field'])) { - $template->assign_block_vars( - 'mode_normal', - array( - 'URL' => duplicate_index_url( array(), array('chronology_field', 'start', 'flat') ) - ) + $template->assign( + 'U_MODE_NORMAL', + duplicate_index_url( array(), array('chronology_field', 'start', 'flat') ) ); } if (!isset($page['flat']) and 'categories' == $page['section']) { - $template->assign_block_vars( - 'flat', - array( - 'URL' => duplicate_index_url(array('flat' => ''), array('start', 'chronology_field')) - ) + $template->assign( + 'U_MODE_FLAT', + duplicate_index_url(array('flat' => ''), array('start', 'chronology_field')) ); } @@ -133,19 +129,15 @@ if (!isset($page['chronology_field'])) 'chronology_style' => 'monthly', 'chronology_view' => 'list', ); - $template->assign_block_vars( - 'mode_created', - array( - 'URL' => duplicate_index_url( $chronology_params, array('start', 'flat') ) - ) + $template->assign( + 'U_MODE_CREATED', + duplicate_index_url( $chronology_params, array('start', 'flat') ) ); $chronology_params['chronology_field'] = 'posted'; - $template->assign_block_vars( - 'mode_posted', - array( - 'URL' => duplicate_index_url( $chronology_params, array('start', 'flat') ) - ) + $template->assign( + 'U_MODE_POSTED', + duplicate_index_url( $chronology_params, array('start', 'flat') ) ); } else @@ -162,9 +154,9 @@ else array('chronology_field'=>$chronology_field ), array('chronology_date', 'start', 'flat') ); - $template->assign_block_vars( - 'mode_'.$chronology_field, - array('URL' => $url ) + $template->assign( + 'U_MODE_'.strtoupper($chronology_field), + $url ); } // include menubar @@ -172,41 +164,33 @@ include(PHPWG_ROOT_PATH.'include/menubar.inc.php'); if ('search' == $page['section']) { - $template->assign_block_vars( - 'search_rules', - array( - 'URL' => get_root_url().'search_rules.php?search_id='.$page['search'], - ) + $template->assign( + 'U_SEARCH_RULES', + get_root_url().'search_rules.php?search_id='.$page['search'] ); } if (isset($page['category']) and is_admin()) { - $template->assign_block_vars( - 'edit', - array( - 'URL' => - get_root_url().'admin.php?page=cat_modify' + $template->assign( + 'U_EDIT', + get_root_url().'admin.php?page=cat_modify' .'&cat_id='.$page['category']['id'] - ) ); } if (is_admin() and !empty($page['items'])) { - $template->assign_block_vars( - 'caddie', - array( - 'URL' => - add_url_params(duplicate_index_url(), array('caddie'=>1) ) - ) + $template->assign( + 'U_CADDIE', + add_url_params(duplicate_index_url(), array('caddie'=>1) ) ); } if ( $page['section']=='search' and $page['start']==0 and !isset($page['chronology_field']) and isset($page['qsearch_details']) ) { - $template->assign_var('QUERY_SEARCH', + $template->assign('QUERY_SEARCH', htmlspecialchars($page['qsearch_details']['q']) ); $cats = array_merge( @@ -220,11 +204,7 @@ if ( $page['section']=='search' and $page['start']==0 and { $hints[] = get_cat_display_name( array($cat) ); } - $template->assign_block_vars( 'category_search_results', - array( - 'CONTENT' => implode(' — ', $hints) - ) - ); + $template->assign( 'category_search_results', $hints); } $tags = (array)@$page['qsearch_details']['matching_tags']; @@ -239,11 +219,7 @@ if ( $page['section']=='search' and $page['start']==0 and .$tag['name'] .''; } - $template->assign_block_vars( 'tag_search_results', - array( - 'CONTENT' => implode(' — ', $hints) - ) - ); + $template->assign( 'tag_search_results', $hints); } } @@ -272,29 +248,18 @@ if (!empty($page['cat_slideshow_url'])) } else { - $template->assign_block_vars( - 'slideshow', array('URL' => $page['cat_slideshow_url'])); + $template->assign('U_SLIDESHOW', $page['cat_slideshow_url']); } } // navigation bar -if ($page['navigation_bar'] != '') -{ - $template->assign_block_vars( - 'cat_infos.navigation', - array( - 'NAV_BAR' => $page['navigation_bar'], - ) - ); -} +$template->assign( 'NAV_BAR', $page['navigation_bar'] ); if ( count($page['items']) > 0 and $page['section'] != 'most_visited' and $page['section'] != 'best_rated') { // image order - $template->assign_block_vars( 'preferred_image_order', array() ); - $order_idx = pwg_get_session_var( 'image_order', 0 ); $orders = get_category_preferred_image_orders(); @@ -302,12 +267,12 @@ if ( count($page['items']) > 0 { if ($orders[$i][2]) { - $template->assign_block_vars( - 'preferred_image_order.order', + $template->append( + 'image_orders', array( 'DISPLAY' => $orders[$i][0], 'URL' => add_url_params( duplicate_index_url(), array('image_order'=>$i) ), - 'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : ''), + 'SELECTED' => ($order_idx==$i ? true:false), ) ); } @@ -317,18 +282,13 @@ if ( count($page['items']) > 0 // category comment if (isset($page['comment']) and $page['comment'] != '') { - $template->assign_block_vars( - 'cat_infos.comment', - array( - 'COMMENTS' => $page['comment'] - ) - ); + $template->assign('CONTENT_DESCRIPTION', $page['comment'] ); } //------------------------------------------------------------ log informations pwg_log(); include(PHPWG_ROOT_PATH.'include/page_header.php'); trigger_action('loc_end_index'); -$template->parse('index'); +$template->pparse('index'); include(PHPWG_ROOT_PATH.'include/page_tail.php'); ?> diff --git a/template/yoga/footer.tpl b/template/yoga/footer.tpl index 37aab1fba..68abea4fb 100644 --- a/template/yoga/footer.tpl +++ b/template/yoga/footer.tpl @@ -29,4 +29,4 @@ {if isset($debug.QUERIES_LIST)}{$debug.QUERIES_LIST}{/if} - + \ No newline at end of file diff --git a/template/yoga/index.tpl b/template/yoga/index.tpl index 48c4a7df3..944c5153e 100644 --- a/template/yoga/index.tpl +++ b/template/yoga/index.tpl @@ -1,116 +1,117 @@ - - -{MENUBAR} +{* $Id$ *} +{$MENUBAR}
  •  
  • - + {if !empty($image_orders) }
  • - {lang:Sort order}: + {'Sort order'|@translate}:
  • - - - -
  • {lang:caddie}
  • - - - -
  • {lang:edit}
  • - - - -
  • (?)
  • - - - -
  • {lang:slideshow}
  • - - - -
  • {lang:mode_normal_hint}
  • - - - -
  • {lang:mode_flat_hint}
  • - - - -
  • {lang:mode_posted_hint}
  • - - -
  • {lang:mode_created_hint}
  • - - {PLUGIN_INDEX_ACTIONS} + {/if} + + {if isset($U_CADDIE) } +
  • {'caddie'|@translate}
  • + {/if} + + {if isset($U_EDIT) } +
  • {'edit'|@translate}
  • + {/if} + + {if isset($U_SEARCH_RULES) } +
  • (?)
  • + {/if} + + {if isset($U_SLIDESHOW) } +
  • {'slideshow'|@translate}
  • + {/if} + + {if isset($U_MODE_FLAT) } +
  • {'mode_flat_hint'|@translate}
  • + {/if} + + {if isset($U_MODE_NORMAL) } +
  • {'mode_normal_hint'|@translate}
  • + {/if} + + {if isset($U_MODE_POSTED) } +
  • {'mode_posted_hint'|@translate}
  • + {/if} + + {if isset($U_MODE_CREATED) } +
  • {'mode_created_hint'|@translate}
  • + {/if} + + {if !empty($PLUGIN_INDEX_ACTIONS)}{$PLUGIN_INDEX_ACTIONS}{/if}
-

{TITLE}

- - -
{lang:calendar_view}: +

{$TITLE}

+ + {if isset($chronology_views) } +
{'calendar_view'|@translate}:
- - + {/if} - -

{calendar.TITLE}

- + {if isset($chronology.TITLE) } +

{$chronology.TITLE}

+ {/if}
-{PLUGIN_INDEX_CONTENT_BEGIN} - - -
{lang:Category results for} {QUERY_SEARCH} : {category_search_results.CONTENT}
- - -
{lang:Tag results for} {QUERY_SEARCH} : {tag_search_results.CONTENT}
- - - - - -
- -
« {calendar.navbar.prev.LABEL}
- - -
{calendar.navbar.next.LABEL} »
- - {calendar.navbar.BAR}  +{if !empty($PLUGIN_INDEX_CONTENT_END)}{$PLUGIN_INDEX_CONTENT_BEGIN}{/if} + +{if !empty($category_search_results) } +
{'Category results for'|@translate} {$QUERY_SEARCH} : + + {foreach from=$category_search_results item=res name=res_loop} + {if !$smarty.foreach.res_loop.first} — {/if} + {$res} + {/foreach} + +
+{/if} + +{if !empty($tag_search_results) } +
{'Tag results for'|@translate} {$QUERY_SEARCH} : + + {foreach from=$tag_search_results item=res name=res_loop} + {if !$smarty.foreach.res_loop.first} — {/if} + {$res} + {/foreach} +
- +{/if} - -
{calendar.calbar.BAR}
- - +{if isset($FILE_CHRONOLOGY_VIEW) } +{include file=$FILE_CHRONOLOGY_VIEW} +{/if} -{MONTH_CALENDAR} -{CATEGORIES} -{THUMBNAILS} +{if !empty($CATEGORIES) }{$CATEGORIES}{/if} +{if !empty($THUMBNAILS) }{$THUMBNAILS}{/if} - - + +{if !empty($NAV_BAR) } +{/if} + +{if !empty($CONTENT_DESCRIPTION) } +
+ {$CONTENT_DESCRIPTION}
- - -
{cat_infos.comment.COMMENTS}
- - +{/if} -{PLUGIN_INDEX_CONTENT_END} +{if !empty($PLUGIN_INDEX_CONTENT_END) }{$PLUGIN_INDEX_CONTENT_END}{/if}
diff --git a/template/yoga/mainpage_categories.tpl b/template/yoga/mainpage_categories.tpl index dcf589b51..b28c619fb 100644 --- a/template/yoga/mainpage_categories.tpl +++ b/template/yoga/mainpage_categories.tpl @@ -1,28 +1,27 @@ - - - +{* $Id$ *} +
    - + {foreach from=$category_thumbnails item=cat}
  • - {categories.category.NAME} - {categories.category.ICON} + {$cat.NAME} + {$cat.ICON}

    - -

    {categories.category.dates.INFO}

    - -

    {categories.category.CAPTION_NB_IMAGES} 

    -

    {categories.category.DESCRIPTION} 

    + {if isset($cat.INFO_DATES) } +

    {$cat.INFO_DATES}

    + {/if} +

    {$cat.CAPTION_NB_IMAGES}

    +

    {$cat.DESCRIPTION}

  • - + {/foreach}
- + diff --git a/template/yoga/menubar.tpl b/template/yoga/menubar.tpl index 3fe8ded73..a7e01fcad 100644 --- a/template/yoga/menubar.tpl +++ b/template/yoga/menubar.tpl @@ -1,155 +1,164 @@ - - +{* $Id$ *} +