- Timestamp:
- Mar 6, 2007, 3:07:15 AM (18 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/functions_permalinks.php
r1866 r1873 103 103 $sanitized_permalink = preg_replace( '#[^a-zA-Z0-9_-]#', '' ,$permalink); 104 104 if ( $sanitized_permalink != $permalink 105 or preg_match( '#^(\d)+ -?#', $permalink) )105 or preg_match( '#^(\d)+(-.*)?$#', $permalink) ) 106 106 { 107 107 $page['errors'][] = l10n('Permalink_name_rule'); … … 109 109 } 110 110 111 // check if the new permalink is actively used 111 112 $existing_cat_id = get_cat_id_from_permalink( $permalink ); 112 113 if ( isset($existing_cat_id) ) … … 127 128 } 128 129 129 if ($save) 130 // check if the new permalink was historically used 131 $old_cat_id = get_cat_id_from_old_permalink($permalink, false); 132 if ( isset($old_cat_id) and $old_cat_id!=$cat_id ) 130 133 { 131 $old_cat_id = get_cat_id_from_old_permalink($permalink, false); 132 if ( isset($old_cat_id) ) 133 { 134 if ( $old_cat_id!=$cat_id ) 135 { 136 $page['errors'][] = 137 sprintf( 138 l10n('Permalink_%s_histo_used_by_%s'), 139 $permalink, $old_cat_id 140 ); 141 return false; 142 } 143 else 144 { 145 $query = ' 146 DELETE FROM '.OLD_PERMALINKS_TABLE.' 147 WHERE cat_id='.$cat_id.' AND permalink="'.$permalink.'"'; 148 pwg_query($query); 149 } 150 } 134 $page['errors'][] = 135 sprintf( 136 l10n('Permalink_%s_histo_used_by_%s'), 137 $permalink, $old_cat_id 138 ); 139 return false; 151 140 } 152 141 153 142 if ( !delete_cat_permalink($cat_id, $save ) ) 154 143 { … … 156 145 } 157 146 147 if ( isset($old_cat_id) ) 148 {// the new permalink must not be active and old at the same time 149 assert( $old_cat_id==$cat_id ); 150 $query = ' 151 DELETE FROM '.OLD_PERMALINKS_TABLE.' 152 WHERE cat_id='.$old_cat_id.' AND permalink="'.$permalink.'"'; 153 pwg_query($query); 154 } 155 158 156 $query = ' 159 157 UPDATE '.CATEGORIES_TABLE.' -
trunk/admin/permalinks.php
r1866 r1873 23 23 // | USA. | 24 24 // +-----------------------------------------------------------------------+ 25 26 function parse_sort_variables( 27 $sortable_by, $default_field, 28 $get_param, $get_rejects, 29 $template_var ) 30 { 31 global $template; 32 33 $url_components = parse_url( $_SERVER['REQUEST_URI'] ); 34 35 $base_url = $url_components['path']; 36 37 parse_str($url_components['query'], $vars); 38 $is_first = true; 39 foreach ($vars as $key => $value) 40 { 41 if (!in_array($key, $get_rejects) and $key!=$get_param) 42 { 43 $base_url .= $is_first ? '?' : '&'; 44 $is_first = false; 45 $base_url .= $key.'='.urlencode($value); 46 } 47 } 48 49 $ret = array(); 50 foreach( $sortable_by as $field) 51 { 52 $url = $base_url; 53 if ( $field !== @$_GET[$get_param] ) 54 { 55 if ( !isset($default_field) or $default_field!=$field ) 56 { // the first should be the default 57 $url = add_url_params($url, array($get_param=>$field) ); 58 } 59 $disp = '⇓'; // TODO: an small image is better 60 } 61 else 62 { 63 array_push($ret, $field); 64 $disp = '<em>⇓</em>'; // TODO: an small image is better 65 } 66 if ( isset($template_var) ) 67 { 68 $template->assign_var( $template_var.strtoupper($field), 69 '<a href="'.$url.'" title="'.l10n('Sort order').'">'.$disp.'</a>' 70 ); 71 } 72 } 73 return $ret; 74 } 25 75 26 76 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); … … 49 99 } 50 100 101 51 102 $template->set_filename('permalinks', 'admin/permalinks.tpl' ); 52 103 … … 60 111 display_select_cat_wrapper( $query, $selected_cat, 'categories', false ); 61 112 113 114 // --- generate display of active permalinks ----------------------------------- 115 $sort_by = parse_sort_variables( 116 array('id', 'name', 'permalink'), 'name', 117 'psf', 118 array('delete_permanent'), 119 'SORT_' ); 120 62 121 $query = ' 63 SELECT id, name, permalink122 SELECT id, permalink, uppercats, global_rank 64 123 FROM '.CATEGORIES_TABLE.' 65 WHERE permalink IS NOT NULL'; 124 WHERE permalink IS NOT NULL 125 '; 126 if ( count($sort_by) and 127 ($sort_by[0]=='id' or $sort_by[0]=='permalink') 128 ) 129 { 130 $query .= ' ORDER BY '.$sort_by[0]; 131 } 132 $categories=array(); 66 133 $result=pwg_query($query); 67 134 while ( $row=mysql_fetch_assoc($result) ) 68 135 { 69 $display_name = get_cat_display_name( array($row) ); 70 $template->assign_block_vars( 'permalink', 71 array( 72 'CAT_ID' => $row['id'], 73 'CAT' => $display_name, 74 'PERMALINK' => $row['permalink'], 75 ) 76 ); 136 $row['name'] = get_cat_display_name_cache( $row['uppercats'] ); 137 $categories[] = $row; 77 138 } 78 139 140 if ( !count($sort_by) or $sort_by[0]='name') 141 { 142 usort($categories, 'global_rank_compare'); 143 } 144 foreach ($categories as $cat) 145 { 146 $template->assign_block_vars( 'permalink', $cat ); 147 } 148 149 150 // --- generate display of old permalinks -------------------------------------- 151 152 $sort_by = parse_sort_variables( 153 array('cat_id','permalink','date_deleted','last_hit','hit'), null, 154 'dpsf', 155 array('delete_permanent'), 156 'SORT_OLD_' ); 157 79 158 $url_del_base = get_root_url().'admin.php?page=permalinks'; 80 81 159 $query = 'SELECT * FROM '.OLD_PERMALINKS_TABLE; 160 if ( count($sort_by) ) 161 { 162 $query .= ' ORDER BY '.$sort_by[0]; 163 } 82 164 $result = pwg_query($query); 83 165 while ( $row=mysql_fetch_assoc($result) ) 84 166 { 85 $row[' display_name'] = get_cat_display_name_cache($row['cat_id']);167 $row['name'] = get_cat_display_name_cache($row['cat_id']); 86 168 $row['U_DELETE'] = 87 169 add_url_params( -
trunk/include/category_cats.inc.php
r1869 r1873 178 178 update_cats_with_filtered_data($categories); 179 179 } 180 180 trigger_action('loc_begin_index_categories'); 181 181 if ($conf['subcatify']) 182 182 { -
trunk/template/yoga/admin/permalinks.tpl
r1866 r1873 6 6 </div> 7 7 8 <form method="post" >8 <form method="post" action="{F_ACTION}"> 9 9 <fieldset><legend>{lang:Add/delete a permalink}</legend> 10 10 <label>Category: … … 34 34 <table class="table2"> 35 35 <tr class="throw"> 36 <td>Id </td>37 <td>{lang:Category} </td>38 <td>{lang:Permalink} </td>36 <td>Id {SORT_ID}</td> 37 <td>{lang:Category} {SORT_NAME}</td> 38 <td>{lang:Permalink} {SORT_PERMALINK}</td> 39 39 </tr> 40 40 <!-- BEGIN permalink --> 41 41 <tr> 42 <td>{permalink. CAT_ID}</td>43 <td>{permalink. CAT}</td>44 <td>{permalink. PERMALINK}</td>42 <td>{permalink.id}</td> 43 <td>{permalink.name}</td> 44 <td>{permalink.permalink}</td> 45 45 </tr> 46 46 <!-- END permalink --> … … 50 50 <table class="table2"> 51 51 <tr class="throw"> 52 <td>Id </td>52 <td>Id {SORT_OLD_CAT_ID}</td> 53 53 <td>{lang:Category}</td> 54 <td>{lang:Permalink} </td>55 <td>Deleted on </td>56 <td>Last hit </td>57 <td>Hit </td>54 <td>{lang:Permalink} {SORT_OLD_PERMALINK}</td> 55 <td>Deleted on {SORT_OLD_DATE_DELETED}</td> 56 <td>Last hit {SORT_OLD_LAST_HIT}</td> 57 <td>Hit {SORT_OLD_HIT}</td> 58 58 <td></td> 59 59 </tr> … … 61 61 <tr> 62 62 <td>{deleted_permalink.cat_id}</td> 63 <td>{deleted_permalink. display_name}</td>63 <td>{deleted_permalink.name}</td> 64 64 <td>{deleted_permalink.permalink}</td> 65 65 <td>{deleted_permalink.date_deleted}</td>
Note: See TracChangeset
for help on using the changeset viewer.