From 77fd1f51a3c5f5a52f72ef8a299fe368228e2285 Mon Sep 17 00:00:00 2001 From: vdigital Date: Fri, 23 May 2008 21:05:41 +0000 Subject: git-svn-id: http://piwigo.org/svn/trunk@2357 68402e56-0260-453c-a942-63ccdbb3a9ee --- BSF/admin/permalinks.php | 179 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 BSF/admin/permalinks.php (limited to 'BSF/admin/permalinks.php') diff --git a/BSF/admin/permalinks.php b/BSF/admin/permalinks.php new file mode 100644 index 000000000..ecae18965 --- /dev/null +++ b/BSF/admin/permalinks.php @@ -0,0 +1,179 @@ + $value) + { + if (!in_array($key, $get_rejects) and $key!=$get_param) + { + $base_url .= $is_first ? '?' : '&'; + $is_first = false; + $base_url .= $key.'='.urlencode($value); + } + } + + $ret = array(); + foreach( $sortable_by as $field) + { + $url = $base_url; + $disp = '⇓'; // TODO: an small image is better + + if ( $field !== @$_GET[$get_param] ) + { + if ( !isset($default_field) or $default_field!=$field ) + { // the first should be the default + $url = add_url_params($url, array($get_param=>$field) ); + } + elseif (isset($default_field) and !isset($_GET[$get_param]) ) + { + array_push($ret, $field); + $disp = ''.$disp.''; + } + } + else + { + array_push($ret, $field); + $disp = ''.$disp.''; + } + if ( isset($template_var) ) + { + $template->assign( $template_var.strtoupper($field), + ''.$disp.'' + ); + } + } + return $ret; +} + +if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); + +include_once(PHPWG_ROOT_PATH.'admin/include/functions_permalinks.php'); + +$selected_cat = array(); +if ( isset($_POST['set_permalink']) and $_POST['cat_id']>0 and !is_adviser() ) +{ + $permalink = $_POST['permalink']; + if ( empty($permalink) ) + delete_cat_permalink($_POST['cat_id'], isset($_POST['save']) ); + else + set_cat_permalink($_POST['cat_id'], $permalink, isset($_POST['save']) ); + $selected_cat = array( $_POST['cat_id'] ); +} +elseif ( isset($_GET['delete_permanent']) and !is_adviser() ) +{ + $query = ' +DELETE FROM '.OLD_PERMALINKS_TABLE.' + WHERE permalink="'.$_GET['delete_permanent'].'" + LIMIT 1'; + pwg_query($query); + if (mysql_affected_rows()==0) + array_push($page['errors'], 'Cannot delete the old permalink !'); +} + + +$template->set_filename('permalinks', 'admin/permalinks.tpl' ); + +$query = ' +SELECT + id, + CONCAT(id, " - ", name, IF(permalink IS NULL, "", " √") ) AS name, + uppercats, global_rank +FROM '.CATEGORIES_TABLE; + +display_select_cat_wrapper( $query, $selected_cat, 'categories', false ); + + +// --- generate display of active permalinks ----------------------------------- +$sort_by = parse_sort_variables( + array('id', 'name', 'permalink'), 'name', + 'psf', + array('delete_permanent'), + 'SORT_' ); + +$query = ' +SELECT id, permalink, uppercats, global_rank + FROM '.CATEGORIES_TABLE.' + WHERE permalink IS NOT NULL +'; +if ( $sort_by[0]=='id' or $sort_by[0]=='permalink' ) +{ + $query .= ' ORDER BY '.$sort_by[0]; +} +$categories=array(); +$result=pwg_query($query); +while ( $row=mysql_fetch_assoc($result) ) +{ + $row['name'] = get_cat_display_name_cache( $row['uppercats'] ); + $categories[] = $row; +} + +if ( $sort_by[0]=='name') +{ + usort($categories, 'global_rank_compare'); +} +$template->assign( 'permalinks', $categories ); + +// --- generate display of old permalinks -------------------------------------- + +$sort_by = parse_sort_variables( + array('cat_id','permalink','date_deleted','last_hit','hit'), null, + 'dpsf', + array('delete_permanent'), + 'SORT_OLD_', '#old_permalinks' ); + +$url_del_base = get_root_url().'admin.php?page=permalinks'; +$query = 'SELECT * FROM '.OLD_PERMALINKS_TABLE; +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']); + $row['U_DELETE'] = + add_url_params( + $url_del_base, + array( 'delete_permanent'=> $row['permalink'] ) + ); + $deleted_permalinks[] = $row; +} +$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'); +?> -- cgit v1.2.3