Changeset 68
- Timestamp:
- Sep 7, 2003, 12:14:33 PM (21 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/cat_list.php
r57 r68 21 21 //----------------------------------------------------- template initialization 22 22 $sub = $vtp->Open( '../template/'.$user['template'].'/admin/cat_list.vtp' ); 23 // language 24 $vtp->setGlobalVar( $sub, 'cat_edit', $lang['cat_edit'] ); 25 $vtp->setGlobalVar( $sub, 'cat_up', $lang['cat_up'] ); 26 $vtp->setGlobalVar( $sub, 'cat_down', $lang['cat_down'] ); 27 $vtp->setGlobalVar( $sub, 'cat_image_info', $lang['cat_image_info'] ); 28 $vtp->setGlobalVar( $sub, 'cat_permission', $lang['cat_permission'] ); 29 $vtp->setGlobalVar( $sub, 'cat_update', $lang['cat_update'] ); 30 $vtp->setGlobalVar( $sub, 'user_template', $user['template'] ); 23 $tpl = array( 'cat_edit','cat_up','cat_down','cat_image_info', 24 'cat_permission','cat_update','cat_add','cat_parent','submit', 25 'cat_virtual','delete','cat_first','cat_last' ); 26 templatize_array( $tpl, 'lang', $sub ); 27 $vtp->setGlobalVar( $sub, 'user_template', $user['template'] ); 28 //--------------------------------------------------- adding a virtual category 29 $errors = array(); 30 if ( isset( $_POST['submit'] ) ) 31 { 32 if ( !preg_match( '/^\s*$/', $_POST['virtual_name'] ) ) 33 { 34 // we have then to add the virtual category 35 $query = 'INSERT INTO '.PREFIX_TABLE.'categories'; 36 $query.= ' (name,id_uppercat) VALUES '; 37 if ( $_POST['associate'] == -1 ) 38 { 39 $_POST['associate'] = 'NULL'; 40 } 41 $query.= " ('".$_POST['virtual_name']."',".$_POST['associate'].")"; 42 $query.= ';'; 43 echo $query; 44 mysql_query( $query ); 45 } 46 else 47 { 48 array_push( $errors, $lang['cat_error_name'] ); 49 } 50 } 31 51 //--------------------------------------------------------------- rank updates 32 if ( isset( $_GET['up'] ) &&is_numeric( $_GET['up'] ) )52 if ( isset( $_GET['up'] ) and is_numeric( $_GET['up'] ) ) 33 53 { 34 54 // 1. searching level (id_uppercat) … … 72 92 mysql_query( $query ); 73 93 } 74 if ( isset( $_GET['down'] ) &&is_numeric( $_GET['down'] ) )94 if ( isset( $_GET['down'] ) and is_numeric( $_GET['down'] ) ) 75 95 { 76 96 // 1. searching level (id_uppercat) … … 90 110 if ( $level == '' ) 91 111 { 92 $query.= ' AND id_uppercat is null';112 $query.= ' AND id_uppercat IS NULL'; 93 113 } 94 114 else … … 113 133 $query.= ';'; 114 134 mysql_query( $query ); 135 } 136 if ( isset( $_GET['last'] ) and is_numeric( $_GET['last'] ) ) 137 { 138 // 1. searching level (id_uppercat) of the category to move 139 $query = 'SELECT id_uppercat,rank'; 140 $query.= ' FROM '.PREFIX_TABLE.'categories'; 141 $query.= ' WHERE id = '.$_GET['last']; 142 $query.= ';'; 143 $row = mysql_fetch_array( mysql_query( $query ) ); 144 $level = $row['id_uppercat']; 145 // 2. searching the highest rank of the categories of the same parent 146 $query = 'SELECT MAX(rank) AS max_rank'; 147 $query.= ' FROM '.PREFIX_TABLE.'categories'; 148 $query.= ' WHERE id_uppercat'; 149 if ( $level == '' ) $query.= ' IS NULL'; 150 else $query.= ' = '.$level; 151 $query.= ';'; 152 $row = mysql_fetch_array( mysql_query( $query ) ); 153 $max_rank = $row['max_rank']; 154 // 3. updating the rank of our category to be after the previous max rank 155 $query = 'UPDATE '.PREFIX_TABLE.'categories'; 156 $query.= ' SET rank = '.($max_rank + 1); 157 $query.= ' WHERE id = '.$_GET['last']; 158 $query.= ';'; 159 mysql_query( $query ); 160 } 161 if ( isset( $_GET['first'] ) and is_numeric( $_GET['first'] ) ) 162 { 163 // to place our category as first, we simply say that is rank is 0, then 164 // reordering will move category ranks correctly (first rank should be 1 165 // and not 0) 166 $query = 'UPDATE '.PREFIX_TABLE.'categories'; 167 $query.= ' SET rank = 0'; 168 $query.= ' WHERE id = '.$_GET['first']; 169 $query.= ';'; 170 mysql_query( $query ); 171 } 172 if ( isset( $_GET['delete'] ) and is_numeric( $_GET['delete'] ) ) 173 { 174 delete_category( $_GET['delete'] ); 115 175 } 116 176 //------------------------------------------------------------------ reordering … … 143 203 } 144 204 } 145 146 205 ordering( 'NULL' ); 147 //----------------------------------------------------affichage de la page 206 //-------------------------------------------------------------- errors display 207 if ( count( $errors ) != 0 ) 208 { 209 $vtp->addSession( $sub, 'errors' ); 210 foreach ( $errors as $error ) { 211 $vtp->addSession( $sub, 'li' ); 212 $vtp->setVar( $sub, 'li.content', $error ); 213 $vtp->closeSession( $sub, 'li' ); 214 } 215 $vtp->closeSession( $sub, 'errors' ); 216 } 217 //---------------------------------------------------------------- page display 148 218 function display_cat_manager( $id_uppercat, $indent, 149 219 $uppercat_visible, $level ) 150 220 { 151 global $lang,$conf,$sub,$vtp ;221 global $lang,$conf,$sub,$vtp,$page; 152 222 153 223 // searching the min_rank and the max_rank of the category … … 171 241 $td = 'td'; 172 242 $class = ''; 173 if ( $level > 0 ) 174 { 175 $class = 'row'.$level; 176 } 177 else 178 { 179 $td = 'th'; 180 } 243 if ( $level > 0 ) $class = 'row'.$level; 244 else $td = 'th'; 181 245 182 246 $query = 'SELECT id,name,dir,nb_images,status,rank,site_id,visible'; … … 201 265 $vtp->setVar( $sub, 'cat.class', $class ); 202 266 $vtp->setVar( $sub, 'cat.indent', $indent ); 203 if ( $row['name'] == '' ) 204 { 205 $name = str_replace( '_', ' ', $row['dir'] ); 267 $vtp->setVar( $sub, 'cat.name', $row['name'] ); 268 if ( $row['dir'] != '' ) 269 { 270 $vtp->addSession( $sub, 'storage' ); 271 $vtp->setVar( $sub, 'storage.dir', $row['dir'] ); 272 $vtp->closeSession( $sub, 'storage' ); 273 // category can't be deleted 274 $vtp->addSession( $sub, 'no_delete' ); 275 $vtp->closeSession( $sub, 'no_delete' ); 206 276 } 207 277 else 208 278 { 209 $name = $row['name']; 210 } 211 $vtp->setVar( $sub, 'cat.name', $name ); 212 $vtp->setVar( $sub, 'cat.dir', $row['dir'] ); 279 $vtp->addSession( $sub, 'virtual' ); 280 $vtp->closeSession( $sub, 'virtual' ); 281 // category can be deleted 282 $vtp->addSession( $sub, 'delete' ); 283 $url = './admin.php?page=cat_list&delete='.$row['id']; 284 $vtp->setVar( $sub, 'delete.delete_url', add_session_id( $url ) ); 285 $vtp->closeSession( $sub, 'delete' ); 286 } 213 287 if ( $row['visible'] == 'false' or !$uppercat_visible ) 214 288 { … … 230 304 $vtp->closeSession( $sub, 'up' ); 231 305 } 232 else 306 else if ( $min_rank != $max_rank ) 233 307 { 234 308 $vtp->addSession( $sub, 'no_up' ); 309 $url = add_session_id( './admin.php?page=cat_list&last='.$row['id']); 310 $vtp->setVar( $sub, 'no_up.last_url', $url ); 235 311 $vtp->closeSession( $sub, 'no_up' ); 236 312 } … … 242 318 $vtp->closeSession( $sub, 'down' ); 243 319 } 244 else 320 else if ( $min_rank != $max_rank ) 245 321 { 246 322 $vtp->addSession( $sub, 'no_down' ); 323 $url = add_session_id('./admin.php?page=cat_list&first='.$row['id']); 324 $vtp->setVar( $sub, 'no_down.first_url', $url ); 247 325 $vtp->closeSession( $sub, 'no_down' ); 248 326 } … … 272 350 $vtp->closeSession( $sub, 'no_permission' ); 273 351 } 274 if ( $row['site_id'] == 1 ) 352 // you can individually update a category only if it is on the main site 353 // and if it's not a virtual category (a category is virtual if there is 354 // no directory associated) 355 if ( $row['site_id'] == 1 and $row['dir'] != '' ) 275 356 { 276 357 $vtp->addSession( $sub, 'update' ); … … 292 373 } 293 374 display_cat_manager( 'NULL', str_repeat( ' ', 4 ), true, 0 ); 375 // add a virtual category ? 376 $vtp->addSession( $sub, 'associate_cat' ); 377 $vtp->setVar( $sub, 'associate_cat.value', '-1' ); 378 $vtp->setVar( $sub, 'associate_cat.content', '' ); 379 $vtp->closeSession( $sub, 'associate_cat' ); 380 $page['plain_structure'] = get_plain_structure(); 381 $structure = create_structure( '', array() ); 382 display_categories( $structure, ' ' ); 294 383 //----------------------------------------------------------- sending html code 295 384 $vtp->Parse( $handle , 'sub', $sub ); -
trunk/admin/cat_modify.php
r57 r68 24 24 'editcat_name','editcat_comment','editcat_status', 25 25 'editcat_visible','editcat_visible_info', 'submit', 26 'editcat_uploadable' );26 'editcat_uploadable','cat_virtual','cat_parent' ); 27 27 templatize_array( $tpl, 'lang', $sub ); 28 28 //---------------------------------------------------------------- verification … … 72 72 $query.= ", status = '".$_POST['status']."'"; 73 73 $query.= ", visible = '".$_POST['visible']."'"; 74 $query.= ", uploadable = '".$_POST['uploadable']."'"; 74 75 if ( isset( $_POST['uploadable'] ) ) 76 $query.= ", uploadable = '".$_POST['uploadable']."'"; 77 78 if ( isset( $_POST['associate'] ) ) 79 { 80 $query.= ', id_uppercat = '; 81 if ( $_POST['associate'] == -1 ) $query.= 'NULL'; 82 else $query.= $_POST['associate']; 83 } 75 84 $query.= ' WHERE id = '.$_GET['cat']; 76 85 $query.= ';'; 86 echo $query; 77 87 mysql_query( $query ); 78 88 … … 107 117 $vtp->setVar( $sub, 'cat:name', $cat_name ); 108 118 // cat dir 109 $vtp->setVar( $sub, 'cat:dir', $row['dir'] ); 119 if ( $row['dir'] != '' ) 120 { 121 $vtp->addSession( $sub, 'storage' ); 122 $vtp->setVar( $sub, 'storage.dir', $row['dir'] ); 123 $vtp->closeSession( $sub, 'storage' ); 124 } 125 else 126 { 127 $vtp->addSession( $sub, 'virtual' ); 128 $vtp->closeSession( $sub, 'virtual' ); 129 } 110 130 // remote site ? 111 131 if ( $row['site_id'] != 1 ) … … 151 171 $vtp->closeSession( $sub, 'visible_option' ); 152 172 // uploadable : true or false 153 if ( $conf['upload_available'] ) 173 // a category can be uploadable if : 174 // 1. upload is authorized 175 // 2. category is not virtual 176 // 3. category is on the main site 177 if ( $conf['upload_available'] and $row['dir'] != '' and $row['site_id'] == 1 ) 154 178 { 155 179 $vtp->addSession( $sub, 'uploadable' ); … … 176 200 $vtp->closeSession( $sub, 'uploadable' ); 177 201 } 202 // can the parent category be changed ? (is the category virtual ?) 203 if ( $row['dir'] == '' ) 204 { 205 $vtp->addSession( $sub, 'parent' ); 206 $vtp->addSession( $sub, 'associate_cat' ); 207 $vtp->setVar( $sub, 'associate_cat.value', '-1' ); 208 $vtp->setVar( $sub, 'associate_cat.content', '' ); 209 $vtp->closeSession( $sub, 'associate_cat' ); 210 $structure = create_structure( '', array() ); 211 display_categories( $structure, ' ', $row['id_uppercat'], $row['id'] ); 212 $vtp->closeSession( $sub, 'parent' ); 213 } 178 214 //----------------------------------------------------------- sending html code 179 215 $vtp->Parse( $handle , 'sub', $sub ); -
trunk/admin/include/functions.php
r61 r68 386 386 } 387 387 388 function display_categories( $categories, $indent ) 388 function display_categories( $categories, $indent, 389 $selected = -1, $forbidden = -1 ) 389 390 { 390 391 global $vtp,$sub; 391 392 392 393 foreach ( $categories as $category ) { 393 $vtp->addSession( $sub, 'associate_cat' ); 394 $vtp->setVar( $sub, 'associate_cat.value', $category['id'] ); 395 $content = $indent.'- '.$category['name']; 396 $vtp->setVar( $sub, 'associate_cat.content', $content ); 397 $vtp->closeSession( $sub, 'associate_cat' ); 398 display_categories( $category['subcats'], $indent.str_repeat(' ',3) ); 394 if ( $category['id'] != $forbidden ) 395 { 396 $vtp->addSession( $sub, 'associate_cat' ); 397 $vtp->setVar( $sub, 'associate_cat.value', $category['id'] ); 398 $content = $indent.'- '.$category['name']; 399 $vtp->setVar( $sub, 'associate_cat.content', $content ); 400 if ( $category['id'] == $selected ) 401 $vtp->setVar( $sub, 'associate_cat.selected', ' selected="selected"' ); 402 $vtp->closeSession( $sub, 'associate_cat' ); 403 display_categories( $category['subcats'], $indent.str_repeat(' ',3), 404 $selected, $forbidden ); 405 } 399 406 } 400 407 } -
trunk/language/francais.php
r61 r68 493 493 $lang['cat_permission'] = 'permissions'; 494 494 $lang['cat_update'] = 'mis à jour'; 495 $lang['cat_add'] = 'Ajouter une catégorie virtuelle'; 496 $lang['cat_parent'] = 'catégorie parente'; 497 $lang['cat_error_name'] = 'Le nom d\'une catégorie ne doit pas être nul'; 498 $lang['cat_virtual'] = 'virtuelle'; 499 $lang['cat_first'] = 'Premier'; 500 $lang['cat_last'] = 'Dernier'; 495 501 // end version 1.3 496 502 … … 498 504 $lang['editcat_confirm'] = 'Informations enregistrées dans la base de données'; 499 505 $lang['editcat_back'] = 'catégories'; 500 $lang['editcat_title1'] = 'Options pour la ';506 $lang['editcat_title1'] = 'Options pour la catégorie'; 501 507 $lang['editcat_name'] = 'Nom'; 502 508 $lang['editcat_comment'] = 'Commentaire'; -
trunk/template/default/admin/cat_list.vtp
r30 r68 1 <!--VTP_errors--> 2 <div class="errors"> 3 <div class="errors_title">{#errors_title}</div> 4 <ul> 5 <!--VTP_li--> 6 <li>{#content}</li> 7 <!--/VTP_li--> 8 </ul> 9 </div> 10 <!--/VTP_errors--> 1 11 <table style="width:100%;"> 12 <tr> 13 <td colspan="8" style="text-align:center;padding-top:10px;padding-bottom:10px;"> 14 <form action="" method="post"> 15 {#cat_add} <input type="text" name="virtual_name" /> 16 {#cat_parent} 17 <select name="associate"> 18 <!--VTP_associate_cat--> 19 <option value="{#value}">{#content}</option> 20 <!--/VTP_associate_cat--> 21 </select> 22 <input type="submit" value="{#submit}" name="submit" /> 23 </form> 24 </td> 25 </tr> 2 26 <!--VTP_cat--> 3 27 <tr> 4 <{#td} style="width: 40%;text-align:left;">28 <{#td} style="width:50%;text-align:left;"> 5 29 {#indent}<img src="../template/{#user_template}/admin/images/puce.gif" alt=">" /> 6 {#name} [ dir : {#dir} ] 30 {#name} [ 31 <!--VTP_storage--> 32 dir : {#dir} 33 <!--/VTP_storage--> 34 <!--VTP_virtual--> 35 <span style="color:blue;">{#cat_virtual}</span> 36 <!--/VTP_virtual--> 37 ] 7 38 <span style="color:red;font-weight:normal;"> {#invisible} <span style="font-weight:bold;">{#private}</span></span> 8 39 </{#td}> 9 <{#td} style="text-align:center;"> 40 <{#td} class="{#class}" 41 style="width:1px;white-space:nowrap;text-align:center;"> 42 <!--VTP_up--> 43 <a href="{#up_url}"><img src="../template/{#user_template}/admin/images/arrow_up.gif" alt="{#cat_up}" title="{#cat_up}" style="border:none;" /></a> 44 <!--/VTP_up--> 45 <!--VTP_no_up--> 46 <a href="{#last_url}"><img src="../template/{#user_template}/admin/images/arrow_last.gif" alt="{#cat_last}" title="{#cat_last}" style="border:none;" /></a> 47 <!--/VTP_no_up--> 48 </{#td}> 49 <{#td} class="{#class}" 50 style="width:1px;white-space:nowrap;text-align:center;"> 51 <!--VTP_down--> 52 <a href="{#down_url}"><img src="../template/{#user_template}/admin/images/arrow_down.gif" alt="{#cat_down}" title="{#cat_down}" style="border:none;" /></a> 53 <!--/VTP_down--> 54 <!--VTP_no_down--> 55 <a href="{#first_url}"><img src="../template/{#user_template}/admin/images/arrow_first.gif" alt="{#cat_first}" title="{#cat_first}" style="border:none;" /></a> 56 <!--/VTP_no_down--> 57 </{#td}> 58 <{#td} class="{#class}" style="width:1px;text-align:center;"> 10 59 <div style="margin-left:3px;margin-right:3px;">{#nb_picture}</div> 11 60 </{#td}> … … 13 62 style="width:10%;white-space:nowrap;text-align:center;"> 14 63 <a href="{#edit_url}">{#cat_edit}</a> 15 </{#td}>16 <{#td} class="{#class}"17 style="width:10%;white-space:nowrap;text-align:center;">18 <!--VTP_up-->19 <a href="{#up_url}">{#cat_up}</a>20 <!--/VTP_up-->21 <!--VTP_no_up-->22 <span style="color:darkgray;">{#cat_up}</span>23 <!--/VTP_no_up-->24 </{#td}>25 <{#td} class="{#class}"26 style="width:10%;white-space:nowrap;text-align:center;">27 <!--VTP_down-->28 <a href="{#down_url}">{#cat_down}</a>29 <!--/VTP_down-->30 <!--VTP_no_down-->31 <span style="color:darkgray;">{#cat_down}</span>32 <!--/VTP_no_down-->33 64 </{#td}> 34 65 <{#td} class="{#class}" … … 59 90 <!--/VTP_no_update--> 60 91 </{#td}> 92 <{#td} class="{#class}" 93 style="width:10%;white-space:nowrap;text-align:center;"> 94 <!--VTP_delete--> 95 <a href="{#delete_url}">{#delete}</a> 96 <!--/VTP_delete--> 97 <!--VTP_no_delete--> 98 <span style="color:darkgray;">{#delete}</span> 99 <!--/VTP_no_delete--> 100 </{#td}> 61 101 <tr> 62 102 <!--/VTP_cat--> -
trunk/template/default/admin/cat_modify.vtp
r38 r68 6 6 <table style="width:100%;"> 7 7 <tr> 8 <th colspan="2">{#editcat_title1} "{#cat:name}" [ {#cat:dir} ]</th> 8 <th colspan="2">{#editcat_title1} "{#cat:name}" [ 9 <!--VTP_storage--> 10 dir : {#dir} 11 <!--/VTP_storage--> 12 <!--VTP_virtual--> 13 <span style="color:blue;">{#cat_virtual}</span> 14 <!--/VTP_virtual--> 15 ] 16 </th> 9 17 </tr> 10 18 <!--VTP_server--> … … 53 61 </tr> 54 62 <!--/VTP_uploadable--> 63 <!--VTP_parent--> 64 <tr> 65 <td>{#cat_parent}</td> 66 <td class="row2"> 67 <select name="associate"> 68 <!--VTP_associate_cat--> 69 <option value="{#value}"{#selected}>{#content}</option> 70 <!--/VTP_associate_cat--> 71 </select> 72 </td> 73 </tr> 74 <!--/VTP_parent--> 55 75 <tr> 56 76 <td colspan="2"> </td>
Note: See TracChangeset
for help on using the changeset viewer.