diff options
author | rvelices <rv-github@modusoptimus.com> | 2008-02-28 02:41:48 +0000 |
---|---|---|
committer | rvelices <rv-github@modusoptimus.com> | 2008-02-28 02:41:48 +0000 |
commit | c73923204927f406d492491398980d3aa429c4eb (patch) | |
tree | 717f79ecab01b8d97c359c27406be6dd26ff8193 /admin | |
parent | 618158aca4d99fe522b0f54d547442f17a5db148 (diff) |
- migrate many templates to smarty
git-svn-id: http://piwigo.org/svn/trunk@2223 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r-- | admin/advanced_feature.php | 17 | ||||
-rw-r--r-- | admin/cat_list.php | 63 | ||||
-rw-r--r-- | admin/cat_modify.php | 264 | ||||
-rw-r--r-- | admin/cat_move.php | 26 | ||||
-rw-r--r-- | admin/cat_options.php | 53 | ||||
-rw-r--r-- | admin/cat_perm.php | 95 | ||||
-rw-r--r-- | admin/include/functions_tabsheet.inc.php | 36 | ||||
-rw-r--r-- | admin/permalinks.php | 17 | ||||
-rw-r--r-- | admin/rating.php | 81 |
9 files changed, 202 insertions, 450 deletions
diff --git a/admin/advanced_feature.php b/admin/advanced_feature.php index aab295b38..e5104e8a6 100644 --- a/admin/advanced_feature.php +++ b/admin/advanced_feature.php @@ -2,10 +2,9 @@ // +-----------------------------------------------------------------------+ // | 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 | // +-----------------------------------------------------------------------+ -// | branch : BSF (Best So Far) -// | file : $RCSfile$ +// | file : $Id$ // | last update : $Date$ // | last modifier : $Author$ // | revision : $Revision$ @@ -89,24 +88,18 @@ $advanced_features = // | Template init | // +-----------------------------------------------------------------------+ -$template->set_filenames(array('advanced_feature'=>'admin/advanced_feature.tpl')); +$template->set_filename('advanced_feature', 'admin/advanced_feature.tpl'); $start_url = get_root_url().'admin.php?page=advanced_feature&action='; -$template->assign_vars( +$template->assign( array ( 'U_HELP' => get_root_url().'popuphelp.php?page=advanced_feature' )); // advanced_features -if (count($advanced_features) > 0) -{ - foreach ($advanced_features as $advanced_feature) - { - $template->assign_block_vars('advanced_features.advanced_feature', $advanced_feature); - } -} +$template->assign('advanced_features', $advanced_features); // +-----------------------------------------------------------------------+ // | Sending html code | diff --git a/admin/cat_list.php b/admin/cat_list.php index aac736a21..d1f590257 100644 --- a/admin/cat_list.php +++ b/admin/cat_list.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$ @@ -154,7 +154,7 @@ if (isset($_GET['parent_id'])) // +-----------------------------------------------------------------------+ // | template initialization | // +-----------------------------------------------------------------------+ -$template->set_filenames(array('categories'=>'admin/cat_list.tpl')); +$template->set_filename('categories', 'admin/cat_list.tpl'); $form_action = PHPWG_ROOT_PATH.'admin.php?page=cat_list'; if (isset($_GET['parent_id'])) @@ -162,20 +162,11 @@ if (isset($_GET['parent_id'])) $form_action.= '&parent_id='.$_GET['parent_id']; } -$template->assign_vars(array( +$template->assign(array( 'CATEGORIES_NAV'=>$navigation, 'F_ACTION'=>$form_action, - - 'L_ADD_VIRTUAL'=>l10n('cat_add'), - 'L_SUBMIT'=>l10n('submit'), - 'L_STORAGE'=>l10n('storage'), - 'L_NB_IMG'=>l10n('pictures'), - 'L_MOVE_UP'=>l10n('up'), - 'L_EDIT'=>l10n('edit'), - 'L_DELETE'=>l10n('delete'), )); -$tpl = array('cat_first','cat_last'); // +-----------------------------------------------------------------------+ // | Categories display | // +-----------------------------------------------------------------------+ @@ -220,16 +211,11 @@ SELECT id_uppercat, COUNT(*) AS nb_subcats { $categories[$row['id_uppercat']]['nb_subcats'] = $row['nb_subcats']; } - - $template->assign_block_vars('categories', array()); } +$template->assign('categories', array()); foreach ($categories as $category) { - // TODO : not used anymore ? - //$images_folder = PHPWG_ROOT_PATH.'template/'; - //$images_folder.= $user['template'].'/admin/images'; - $base_url = PHPWG_ROOT_PATH.'admin.php?page='; $cat_list_url = $base_url.'cat_list'; @@ -239,8 +225,7 @@ foreach ($categories as $category) $self_url.= '&parent_id='.$_GET['parent_id']; } - $template->assign_block_vars( - 'categories.category', + $tpl_cat = array( 'NAME' => $category['name'], 'ID' => $category['id'], @@ -254,49 +239,27 @@ foreach ($categories as $category) 'U_CHILDREN' => $cat_list_url.'&parent_id='.$category['id'], 'U_EDIT' => $base_url.'cat_modify&cat_id='.$category['id'], - ) + + 'IS_VIRTUAL' => empty($category['dir']) ); if (empty($category['dir'])) { - $template->assign_block_vars( - 'categories.category.delete', - array( - 'URL'=>$self_url.'&delete='.$category['id'] - ) - ); - $template->assign_block_vars( - 'categories.category.virtual', - array( - 'CLASS' => 'virtual_cat', - ) - ); + $tpl_cat['U_DELETE'] = $self_url.'&delete='.$category['id']; } if ($category['nb_images'] > 0) { - $template->assign_block_vars( - 'categories.category.elements', - array( - 'URL'=>$base_url.'element_set&cat='.$category['id'] - ) - ); + $tpl_cat['U_MANAGE_ELEMENTS']= + $base_url.'element_set&cat='.$category['id']; } if ('private' == $category['status']) { - $template->assign_block_vars( - 'categories.category.permissions', - array( - 'URL'=>$base_url.'cat_perm&cat='.$category['id'] - ) - ); + $tpl_cat['U_MANAGE_PERMISSIONS']= + $base_url.'cat_perm&cat='.$category['id']; } -} -// Add a link to Page bottom only if needed (10 or more categories) -if ( isset($category['rank']) and $category['rank'] > 9 ) -{ - $template->assign_block_vars('eop_link', array('ICON'=>'Displayed')); + $template->append('categories', $tpl_cat); } // +-----------------------------------------------------------------------+ // | sending html code | diff --git a/admin/cat_modify.php b/admin/cat_modify.php index 6f3c4b075..7492633b1 100644 --- a/admin/cat_modify.php +++ b/admin/cat_modify.php @@ -43,8 +43,6 @@ if ( !isset( $_GET['cat_id'] ) || !is_numeric( $_GET['cat_id'] ) ) $_GET['cat_id'] = '-1'; } -$template->set_filenames( array('categories'=>'admin/cat_modify.tpl') ); - //--------------------------------------------------------- form criteria check if (isset($_POST['submit'])) { @@ -208,6 +206,7 @@ foreach (array('comment','dir','site_id', 'id_uppercat') as $nullable) $category['is_virtual'] = empty($category['dir']) ? true : false; + // Navigation path $url = PHPWG_ROOT_PATH.'admin.php?page=cat_modify&cat_id='; @@ -217,27 +216,9 @@ $navigation = get_cat_display_name_cache( ); $form_action = PHPWG_ROOT_PATH.'admin.php?page=cat_modify&cat_id='.$_GET['cat_id']; -$status = ($category['status']=='public')?'STATUS_PUBLIC':'STATUS_PRIVATE'; -$lock = ($category['visible']=='true')?'UNLOCKED':'LOCKED'; - -if ($category['commentable'] == 'true') -{ - $commentable = 'COMMENTABLE_TRUE'; -} -else -{ - $commentable = 'COMMENTABLE_FALSE'; -} -if ($category['uploadable'] == 'true') -{ - $uploadable = 'UPLOADABLE_TRUE'; -} -else -{ - $uploadable = 'UPLOADABLE_FALSE'; -} //----------------------------------------------------- template initialization +$template->set_filename( 'categories', 'admin/cat_modify.tpl'); $base_url = PHPWG_ROOT_PATH.'admin.php?page='; $cat_list_url = $base_url.'cat_list'; @@ -248,35 +229,24 @@ if (!empty($category['id_uppercat'])) $self_url.= '&parent_id='.$category['id_uppercat']; } -$template->assign_vars( +$template->assign( array( 'CATEGORIES_NAV' => $navigation, - 'CAT_NAME' => $category['name'], - 'CAT_COMMENT' => $category['comment'], + 'CAT_NAME' => @htmlspecialchars($category['name']), + 'CAT_COMMENT' => @htmlspecialchars($category['comment']), + + 'status_values' => array('public','private'), + 'false_true' => array('false', 'true'), + 'no_yes' => array('no','yes'), - $status => 'checked="checked"', - $lock => 'checked="checked"', - $commentable => 'checked="checked"', - $uploadable => 'checked="checked"', + 'CAT_STATUS' => $category['status'], + 'CAT_VISIBLE' => $category['visible'], + 'CAT_COMMENTABLE' => $category['commentable'], + 'CAT_UPLOADABLE' => $category['uploadable'], 'IMG_ORDER_DEFAULT' => empty($category['image_order']) ? 'checked="checked"' : '', - 'L_EDIT_NAME' => l10n('name'), - 'L_STORAGE' => l10n('storage'), - 'L_REMOTE_SITE' => l10n('remote_site'), - 'L_EDIT_COMMENT' => l10n('description'), - 'L_EDIT_STATUS' => l10n('conf_access'), - 'L_STATUS_PUBLIC' => l10n('public'), - 'L_STATUS_PRIVATE' => l10n('private'), - 'L_EDIT_LOCK' => l10n('lock'), - 'L_EDIT_UPLOADABLE' => l10n('editcat_uploadable'), - 'L_EDIT_COMMENTABLE' => l10n('comments'), - 'L_YES' => l10n('yes'), - 'L_NO' => l10n('no'), - 'L_SUBMIT' => l10n('submit'), - 'L_SET_RANDOM_REPRESENTANT'=>l10n('cat_representant'), - 'U_JUMPTO' => make_index_url( array( 'category' => $category @@ -295,33 +265,45 @@ $template->assign_vars( if ('private' == $category['status']) { - $template->assign_block_vars( - 'permissions', - array( - 'URL'=>$base_url.'cat_perm&cat='.$category['id'] - ) + $template->assign( 'U_MANAGE_PERMISSIONS', + $base_url.'cat_perm&cat='.$category['id'] ); } // manage category elements link if ($category['nb_images'] > 0) { - $template->assign_block_vars( - 'elements', + $template->assign( 'U_MANAGE_ELEMENTS', + $base_url.'element_set&cat='.$category['id'] + ); +} + +if ($category['is_virtual']) +{ + $template->assign( array( - 'URL'=>$base_url.'element_set&cat='.$category['id'] + 'U_DELETE' => $self_url.'&delete='.$category['id'], ) ); } - -// image order management -$matches = array(); -if ( !empty( $category['image_order'] ) ) +else { - preg_match_all('/([a-z_]+) *(?:(asc|desc)(?:ending)?)? *(?:, *|$)/i', - $category['image_order'], $matches); + $category['cat_full_dir'] = get_complete_dir($_GET['cat_id']); + $template->assign( + array( + 'CAT_FULL_DIR' => preg_replace('/\/$/', + '', + $category['cat_full_dir'] ) + ) + ); + if (!url_is_remote($category['cat_full_dir']) ) + { + $template->assign('SHOW_UPLOADABLE', true); + } } +// image order management + $sort_fields = array( '' => '', 'date_creation' => l10n('Creation date'), @@ -332,49 +314,39 @@ $sort_fields = array( 'id' => 'Id', ); -for ($i=0; $i<3; $i++) // 3 fields -{ - $template->assign_block_vars('image_order', array('NUMBER'=>$i+1) ); - foreach ($sort_fields as $sort_field => $name) - { - $selected=''; - if ( isset($matches[1][$i]) and $matches[1][$i]==$sort_field ) - { - $selected='selected="selected"'; - } - elseif ( empty($sort_field) ) - { - $selected='selected="selected"'; - } +$sort_directions = array( + 'ASC' => l10n('ascending'), + 'DESC' => l10n('descending'), + ); - $template->assign_block_vars('image_order.field', - array( - 'SELECTED' => $selected, - 'VALUE' => $sort_field, - 'OPTION' => $name - ) - ); - } +$template->assign( 'image_order_field_options', $sort_fields); +$template->assign( 'image_order_direction_options', $sort_directions); - $template->assign_block_vars('image_order.order', - array( - 'SELECTED' => - ( empty($matches[2][$i]) or strcasecmp($matches[2][$i],'ASC')==0 ) - ? 'selected="selected"' : '', - 'VALUE' => 'ASC', - 'OPTION' => 'Ascending' - ) - ); +$matches = array(); +if ( !empty( $category['image_order'] ) ) +{ + preg_match_all('/([a-z_]+) *(?:(asc|desc)(?:ending)?)? *(?:, *|$)/i', + $category['image_order'], $matches); +} - $template->assign_block_vars('image_order.order', - array( - 'SELECTED' => - ( isset($matches[2][$i]) and strcasecmp($matches[2][$i],'DESC')==0 ) - ? 'selected="selected"' : '', - 'VALUE' => 'DESC', - 'OPTION' => 'Descending' - ) +for ($i=0; $i<3; $i++) // 3 fields +{ + $tpl_image_order_select = array( + 'ID' => $i+1, + 'FIELD' => array(''), + 'DIRECTION' => array('ASC'), ); + + if ( isset($matches[1][$i]) ) + { + $tpl_image_order_select['FIELD'] = array($matches[1][$i]); + } + + if (isset($matches[2][$i]) and strcasecmp($matches[2][$i],'DESC')==0) + { + $tpl_image_order_select['DIRECTION'] = array('DESC'); + } + $template->append( 'image_orders', $tpl_image_order_select); } @@ -382,7 +354,7 @@ for ($i=0; $i<3; $i++) // 3 fields if ($category['nb_images'] > 0 or !empty($category['representative_picture_id'])) { - $template->assign_block_vars('representant', array()); + $tpl_representant = array(); // picture to display : the identified representant or the generic random // representant ? @@ -398,24 +370,15 @@ SELECT id,tn_ext,path $url = PHPWG_ROOT_PATH.'admin.php?page=picture_modify'; $url.= '&image_id='.$category['representative_picture_id']; - $template->assign_block_vars( - 'representant.picture', + $tpl_representant['picture'] = array( 'SRC' => $src, 'URL' => $url - ) ); } - else // $category['nb_images'] > 0 - { - $template->assign_block_vars('representant.random', array()); - } // can the admin choose to set a new random representant ? - if ($category['nb_images'] > 0) - { - $template->assign_block_vars('representant.set_random', array()); - } + $tpl_representant['ALLOW_SET_RANDOM'] = ($category['nb_images']>0) ? true : false; // can the admin delete the current representant ? if ( @@ -425,45 +388,17 @@ SELECT id,tn_ext,path ($category['nb_images'] == 0 and !empty($category['representative_picture_id']))) { - $template->assign_block_vars('representant.delete_representant', array()); + $tpl_representant['ALLOW_DELETE'] = true; } + $template->assign('representant', $tpl_representant); } -if (!$category['is_virtual']) -{ - $template->assign_block_vars( - 'storage', - array('CATEGORY_DIR'=>preg_replace('/\/$/', - '', - get_complete_dir($category['id'])))); -} -else +if ($category['is_virtual']) { - $template->assign_block_vars( - 'delete', - array( - 'URL'=>$self_url.'&delete='.$category['id'] - ) - ); - - $template->assign_block_vars('move', array()); - // the category can be moved in any category but in itself, in any // sub-category $unmovables = get_subcat_ids(array($category['id'])); - $blockname = 'move.parent_option'; - - $template->assign_block_vars( - $blockname, - array( - 'SELECTED' - => empty($category['id_uppercat']) ? 'selected="selected"' : '', - 'VALUE'=> 0, - 'OPTION' => '------------' - ) - ); - $query = ' SELECT id,name,uppercats,global_rank FROM '.CATEGORIES_TABLE.' @@ -473,59 +408,33 @@ SELECT id,name,uppercats,global_rank display_select_cat_wrapper( $query, empty($category['id_uppercat']) ? array() : array($category['id_uppercat']), - $blockname + 'move_cat_options' ); } -$category['cat_dir'] = get_complete_dir($_GET['cat_id']); -if (is_numeric($category['site_id']) and url_is_remote($category['cat_dir']) ) -{ - $query = ' -SELECT galleries_url - FROM '.SITES_TABLE.' - WHERE id = '.$category['site_id'].' -;'; - list($galleries_url) = mysql_fetch_array(pwg_query($query)); - $template->assign_block_vars('server', array('SITE_URL' => $galleries_url)); -} - -if (!$category['is_virtual'] and !url_is_remote($category['cat_dir']) ) -{ - $template->assign_block_vars('upload' ,array()); -} - -$blockname = 'category_option_parent'; - -$template->assign_block_vars( - $blockname, - array( - 'VALUE'=> 0, - 'OPTION' => '------------' - ) - ); +// create virtual in parent and link $query = ' SELECT id,name,uppercats,global_rank FROM '.CATEGORIES_TABLE.' ;'; - display_select_cat_wrapper( $query, array(), - $blockname + 'create_new_parent_options' ); + // destination categories $query = ' SELECT id,name,uppercats,global_rank FROM '.CATEGORIES_TABLE.' WHERE id != '.$category['id'].' ;'; - display_select_cat_wrapper( $query, array(), - 'category_option_destination' + 'category_destination_options' ); // info by email to an access granted group of category informations @@ -635,18 +544,9 @@ SELECT WHERE id IN ('.implode(',', $group_ids).') ORDER BY name ASC ;'; - $result = pwg_query($query); - - while ($row = mysql_fetch_array($result)) - { - $template->assign_block_vars( - 'group_mail.group_option', - array( - 'VALUE' => $row['id'], - 'OPTION' => $row['name'], - ) - ); - } + $template->assign('group_mail_options', + simple_hash_from_query($query, 'id', 'name') + ); } //----------------------------------------------------------- sending html code diff --git a/admin/cat_move.php b/admin/cat_move.php index 1532641d1..72aa6b6c9 100644 --- a/admin/cat_move.php +++ b/admin/cat_move.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$ @@ -64,14 +64,9 @@ if (isset($_POST['submit'])) // +-----------------------------------------------------------------------+ // | template initialization | // +-----------------------------------------------------------------------+ +$template->set_filename('cat_move', 'admin/cat_move.tpl'); -$template->set_filenames( - array( - 'cat_move' => 'admin/cat_move.tpl' - ) - ); - -$template->assign_vars( +$template->assign( array( 'U_HELP' => PHPWG_ROOT_PATH.'popuphelp.php?page=cat_move', 'F_ACTION' => PHPWG_ROOT_PATH.'admin.php?page=cat_move', @@ -87,21 +82,10 @@ SELECT id,name,uppercats,global_rank FROM '.CATEGORIES_TABLE.' WHERE dir IS NULL ;'; - display_select_cat_wrapper( $query, array(), - 'category_option_selection' - ); - -$blockname = 'category_option_parent'; - -$template->assign_block_vars( - $blockname, - array( - 'VALUE'=> 0, - 'OPTION' => '------------' - ) + 'category_to_move_options' ); $query = ' @@ -112,7 +96,7 @@ SELECT id,name,uppercats,global_rank display_select_cat_wrapper( $query, array(), - $blockname + 'category_parent_options' ); // +-----------------------------------------------------------------------+ diff --git a/admin/cat_options.php b/admin/cat_options.php index 0a9b93e8f..210427eea 100644 --- a/admin/cat_options.php +++ b/admin/cat_options.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$ @@ -149,24 +149,30 @@ $template->set_filenames( ) ); -$page['section'] = isset($_GET['section']) ? $_GET['section'] : 'upload'; +$page['section'] = isset($_GET['section']) ? $_GET['section'] : 'status'; $base_url = PHPWG_ROOT_PATH.'admin.php?page=cat_options&section='; -$template->assign_vars( +$template->assign( array( - 'L_SUBMIT'=>l10n('submit'), - 'L_RESET'=>l10n('reset'), - 'U_HELP' => PHPWG_ROOT_PATH.'/popuphelp.php?page=cat_options', - 'F_ACTION'=>$base_url.$page['section'] ) ); // TabSheet initialization $opt_link = $link_start.'cat_options&section='; -$page['tabsheet'] = array +$tabsheet = array ( + 'status' => array + ( + 'caption' => l10n('cat_security'), + 'url' => $opt_link.'status' + ), + 'visible' => array + ( + 'caption' => l10n('lock'), + 'url' => $opt_link.'visible' + ), 'upload' => array ( 'caption' => l10n('upload'), @@ -177,31 +183,26 @@ $page['tabsheet'] = array 'caption' => l10n('comments'), 'url' => $opt_link.'comments' ), - 'visible' => array - ( - 'caption' => l10n('lock'), - 'url' => $opt_link.'visible' - ), - 'status' => array - ( - 'caption' => l10n('cat_security'), - 'url' => $opt_link.'status' - ) ); if ($conf['allow_random_representative']) { - $page['tabsheet']['representative'] = + $tabsheet['representative'] = array ( 'caption' => l10n('Representative'), 'url' => $opt_link.'representative' ); } -$page['tabsheet'][$page['section']]['selected'] = true; +$tabsheet[$page['section']]['selected'] = true; // Assign tabsheet to template -template_assign_tabsheet(); +$template->assign( + array( + 'tabsheet' => $tabsheet, + 'TABSHEET_TITLE' => $tabsheet[$page['section']]['caption'] + ) + ); // +-----------------------------------------------------------------------+ // | form display | @@ -236,7 +237,7 @@ SELECT id,name,uppercats,global_rank AND dir IS NOT NULL AND site_id = 1 ;'; - $template->assign_vars( + $template->assign( array( 'L_SECTION' => l10n('cat_upload_title'), 'L_CAT_OPTIONS_TRUE' => l10n('authorized'), @@ -257,7 +258,7 @@ SELECT id,name,uppercats,global_rank FROM '.CATEGORIES_TABLE.' WHERE commentable = \'false\' ;'; - $template->assign_vars( + $template->assign( array( 'L_SECTION' => l10n('cat_comments_title'), 'L_CAT_OPTIONS_TRUE' => l10n('authorized'), @@ -278,7 +279,7 @@ SELECT id,name,uppercats,global_rank FROM '.CATEGORIES_TABLE.' WHERE visible = \'false\' ;'; - $template->assign_vars( + $template->assign( array( 'L_SECTION' => l10n('cat_lock_title'), 'L_CAT_OPTIONS_TRUE' => l10n('unlocked'), @@ -299,7 +300,7 @@ SELECT id,name,uppercats,global_rank FROM '.CATEGORIES_TABLE.' WHERE status = \'private\' ;'; - $template->assign_vars( + $template->assign( array( 'L_SECTION' => l10n('cat_status_title'), 'L_CAT_OPTIONS_TRUE' => l10n('cat_public'), @@ -321,7 +322,7 @@ SELECT id,name,uppercats,global_rank WHERE nb_images != 0 AND representative_picture_id IS NULL ;'; - $template->assign_vars( + $template->assign( array( 'L_SECTION' => l10n('Representative'), 'L_CAT_OPTIONS_TRUE' => l10n('singly represented'), diff --git a/admin/cat_perm.php b/admin/cat_perm.php index eb0efa3cd..bca45faa0 100644 --- a/admin/cat_perm.php +++ b/admin/cat_perm.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$ @@ -72,12 +72,6 @@ SELECT id // | form submission | // +-----------------------------------------------------------------------+ -if (isset($_POST) and false) -{ - echo '<pre>'; - print_r($_POST); - echo '</pre>'; -} if (isset($_POST['deny_groups_submit']) and isset($_POST['deny_groups']) @@ -202,7 +196,7 @@ SELECT user_id, cat_id // | template initialization | // +-----------------------------------------------------------------------+ -$template->set_filenames(array('cat_perm'=>'admin/cat_perm.tpl')); +$template->set_filename('cat_perm', 'admin/cat_perm.tpl'); $template->assign_vars( array( @@ -230,43 +224,23 @@ SELECT id, name FROM '.GROUPS_TABLE.' ORDER BY name ASC ;'; -$result = pwg_query($query); - -while ($row = mysql_fetch_array($result)) -{ - $groups[$row['id']] = $row['name']; -} +$groups = simple_hash_from_query($query, 'id', 'name'); +$template->assign('all_groups', $groups); +// groups granted to access the category $query = ' SELECT group_id FROM '.GROUP_ACCESS_TABLE.' WHERE cat_id = '.$page['cat'].' ;'; $group_granted_ids = array_from_query($query, 'group_id'); +$template->assign('group_granted_ids', $group_granted_ids); -// groups granted to access the category -foreach ($group_granted_ids as $group_id) -{ - $template->assign_block_vars( - 'group_granted', - array( - 'NAME'=>$groups[$group_id], - 'ID'=>$group_id - ) - ); -} // groups denied -foreach (array_diff(array_keys($groups), $group_granted_ids) as $group_id) -{ - $template->assign_block_vars( - 'group_denied', - array( - 'NAME'=>$groups[$group_id], - 'ID'=>$group_id - ) - ); -} +$template->assign('group_denied_ids', + array_diff(array_keys($groups), $group_granted_ids) + ); // users... $users = array(); @@ -276,11 +250,9 @@ SELECT '.$conf['user_fields']['id'].' AS id, '.$conf['user_fields']['username'].' AS username FROM '.USERS_TABLE.' ;'; -$result = pwg_query($query); -while($row = mysql_fetch_array($result)) -{ - $users[$row['id']] = $row['username']; -} +$users = simple_hash_from_query($query, 'id', 'username'); +$template->assign('all_users', $users); + $query = ' SELECT user_id @@ -289,16 +261,9 @@ SELECT user_id ;'; $user_granted_direct_ids = array_from_query($query, 'user_id'); -foreach ($user_granted_direct_ids as $user_id) -{ - $template->assign_block_vars( - 'user_granted', - array( - 'NAME'=>$users[$user_id], - 'ID'=>$user_id - ) - ); -} +$template->assign('user_granted_direct_ids', $user_granted_direct_ids); + + $user_granted_indirect_ids = array(); if (count($group_granted_ids) > 0) @@ -335,41 +300,27 @@ SELECT user_id, group_id foreach ($user_granted_indirect_ids as $user_id) { - $group = ''; - foreach ($granted_groups as $group_id => $group_users) { if (in_array($user_id, $group_users)) { - $group = $groups[$group_id]; + $template->append( + 'user_granted_indirects', + array( + 'USER'=>$users[$user_id], + 'GROUP'=>$groups[$group_id] + ) + ); break; } } - - $template->assign_block_vars( - 'user_granted_indirect', - array( - 'NAME'=>$users[$user_id], - 'GROUP'=>$group - ) - ); } } $user_denied_ids = array_diff(array_keys($users), $user_granted_indirect_ids, $user_granted_direct_ids); - -foreach ($user_denied_ids as $user_id) -{ - $template->assign_block_vars( - 'user_denied', - array( - 'NAME'=>$users[$user_id], - 'ID'=>$user_id - ) - ); -} +$template->assign('user_denied_ids', $user_denied_ids); // +-----------------------------------------------------------------------+ diff --git a/admin/include/functions_tabsheet.inc.php b/admin/include/functions_tabsheet.inc.php index e8a5704d7..9bb57322d 100644 --- a/admin/include/functions_tabsheet.inc.php +++ b/admin/include/functions_tabsheet.inc.php @@ -41,34 +41,24 @@ function template_assign_tabsheet() { global $page, $template; +//THIS SHOULD BE DEPRECATED ? + + $template->set_filename('tabsheet', 'admin/tabsheet.tpl'); + $template->assign('tabsheet', $page['tabsheet']); - if (count($page['tabsheet']) > 0) + foreach ($page['tabsheet'] as $tab_name => $tab) { - $template->set_filename('tabsheet', 'admin/tabsheet.tpl'); - - foreach ($page['tabsheet'] as $tab_name => $tab) + $is_selected = isset($tab['selected']) and $tab['selected'] === true; + if ($is_selected) { - $is_selected = isset($tab['selected']) and $tab['selected'] === true; - $template->assign_block_vars - ( - 'tab', - array - ( - 'CLASSNAME' => ($is_selected ? 'selected_tab' : 'normal_tab'), - 'URL' => $tab['url'], - 'CAPTION' => $tab['caption'] - ) - ); - - if ($is_selected) - { - $template->assign_vars( - array('TABSHEET_TITLE' => '['.$tab['caption'].']')); - } + $template->assign_vars( + array('TABSHEET_TITLE' => '['.$tab['caption'].']')); + break; } - - $template->assign_var_from_handle('TABSHEET', 'tabsheet'); } + + $template->assign_var_from_handle('TABSHEET', 'tabsheet'); + $template->clear_assign('tabsheet'); } ?> diff --git a/admin/permalinks.php b/admin/permalinks.php index 77becf76f..20a83f246 100644 --- a/admin/permalinks.php +++ b/admin/permalinks.php @@ -1,7 +1,7 @@ <?php // +-----------------------------------------------------------------------+ // | PhpWebGallery - a PHP based picture gallery | -// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | +// | Copyright (C) 2003-2008 PhpWebGallery Team - http://phpwebgallery.net | // +-----------------------------------------------------------------------+ // | file : $Id$ // | last update : $Date$ @@ -72,7 +72,7 @@ function parse_sort_variables( } if ( isset($template_var) ) { - $template->assign_var( $template_var.strtoupper($field), + $template->assign( $template_var.strtoupper($field), '<a href="'.$url.$anchor.'" title="'.l10n('Sort order').'">'.$disp.'</a>' ); } @@ -146,11 +146,7 @@ if ( $sort_by[0]=='name') { usort($categories, 'global_rank_compare'); } -foreach ($categories as $cat) -{ - $template->assign_block_vars( 'permalink', $cat ); -} - +$template->assign( 'permalinks', $categories ); // --- generate display of old permalinks -------------------------------------- @@ -167,6 +163,7 @@ if ( count($sort_by) ) $query .= ' ORDER BY '.$sort_by[0]; } $result = pwg_query($query); +$deleted_permalinks=array(); while ( $row=mysql_fetch_assoc($result) ) { $row['name'] = get_cat_display_name_cache($row['cat_id']); @@ -175,10 +172,10 @@ while ( $row=mysql_fetch_assoc($result) ) $url_del_base, array( 'delete_permanent'=> $row['permalink'] ) ); - $template->assign_block_vars( 'deleted_permalink', $row ); + $deleted_permalinks[] = $row; } - -$template->assign_var('U_HELP', get_root_url().'popuphelp.php?page=permalinks'); +$template->assign('deleted_permalinks', $deleted_permalinks); +$template->assign('U_HELP', get_root_url().'popuphelp.php?page=permalinks'); $template->assign_var_from_handle('ADMIN_CONTENT', 'permalinks'); ?> diff --git a/admin/rating.php b/admin/rating.php index d9cb4eef6..f7a2216ec 100644 --- a/admin/rating.php +++ b/admin/rating.php @@ -2,10 +2,9 @@ // +-----------------------------------------------------------------------+ // | 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 | // +-----------------------------------------------------------------------+ -// | branch : BSF (Best So Far) -// | file : $RCSfile$ +// | file : $Id$ // | last update : $Date$ // | last modifier : $Author$ // | revision : $Revision$ @@ -115,28 +114,24 @@ list($nb_images) = mysql_fetch_row(pwg_query($query)); // | template init | // +-----------------------------------------------------------------------+ -$template->set_filenames(array('rating'=>'admin/rating.tpl')); +$template->set_filename('rating', 'admin/rating.tpl'); -$template->assign_vars( +$template->assign( array( 'NAVBAR' => create_navigation_bar( PHPWG_ROOT_PATH.'admin.php'.get_query_string_diff(array('start','del')), $nb_images, $start, $elements_per_page - ) - ) - ); - - -$template->assign_vars( - array( + ), 'F_ACTION' => PHPWG_ROOT_PATH.'admin.php', 'DISPLAY' => $elements_per_page, - 'NB_ELEMENTS' => $nb_images + 'NB_ELEMENTS' => $nb_images, ) ); + + $available_order_by= array( array(l10n('Rate date'), 'recently_rated DESC'), array(l10n('Average rate'), 'average_rate DESC'), @@ -151,45 +146,23 @@ $available_order_by= array( for ($i=0; $i<count($available_order_by); $i++) { - $template->assign_block_vars( - 'order_by', - array( - 'VALUE' => $i, - 'CONTENT' => $available_order_by[$i][0], - 'SELECTED' => $i==$order_by_index ? 'SELECTED' : '' - ) + $template->append( + 'order_by_options', + $available_order_by[$i][0] ); } +$template->assign('order_by_options_selected', array($order_by_index) ); + $user_options = array( - array( - 'value' => 'all', - 'content' => l10n('all'), - ), - array( - 'value' => 'user', - 'content' => l10n('Users'), - ), - array( - 'value' => 'guest', - 'content' => l10n('Guests'), - ), + 'all' => l10n('all'), + 'user' => l10n('Users'), + 'guest' => l10n('Guests'), ); -foreach ($user_options as $user_option) -{ - $template->assign_block_vars( - 'user_option', - array( - 'VALUE' => $user_option['value'], - 'CONTENT' => $user_option['content'], - 'SELECTED' => - (isset($_GET['users']) and $_GET['users'] == $user_option['value']) - ? 'selected="selected"' - : '', - ) - ); -} +$template->assign('user_options', $user_options ); +$template->assign('user_options_selected', array(@$_GET['users']) ); + $query = ' SELECT i.id, @@ -217,6 +190,7 @@ while ($row = mysql_fetch_assoc($result)) array_push($images, $row); } +$template->assign( 'images', array() ); foreach ($images as $image) { $thumbnail_src = get_thumbnail_url($image); @@ -231,18 +205,17 @@ ORDER BY date DESC;'; $result = pwg_query($query); $nb_rates = mysql_num_rows($result); - $template->assign_block_vars('image', + $tpl_image = array( 'U_THUMB' => $thumbnail_src, 'U_URL' => $image_url, 'AVG_RATE' => $image['average_rate'], 'STD_RATE' => $image['std_rates'], 'SUM_RATE' => $image['sum_rates'], - 'NB_RATES' => $image['nb_rates'], - 'NB_RATES_TOTAL' => $nb_rates, + 'NB_RATES' => (int)$image['nb_rates'], + 'NB_RATES_TOTAL' => (int)$nb_rates, 'FILE' => $image['file'], - 'NB_RATES_PLUS1' => $nb_rates+1, - ) + 'rates' => array() ); while ($row = mysql_fetch_array($result)) @@ -270,17 +243,17 @@ ORDER BY date DESC;'; $user .= '('.$row['anonymous_id'].')'; } - $template->assign_block_vars('image.rate', + $tpl_image['rates'][] = array( 'DATE' => format_date($row['date']), 'RATE' => $row['rate'], 'USER' => $user, 'U_DELETE' => $url_del - ) ); } + $template->append( 'images', $tpl_image ); } -//print_r($template->_tpldata); + // +-----------------------------------------------------------------------+ // | sending html code | // +-----------------------------------------------------------------------+ |