aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--admin/cat_list.php149
-rw-r--r--admin/cat_modify.php44
-rw-r--r--admin/include/functions.php21
-rw-r--r--language/francais.php8
-rw-r--r--template/default/admin/cat_list.vtp70
-rw-r--r--template/default/admin/cat_modify.vtp22
6 files changed, 256 insertions, 58 deletions
diff --git a/admin/cat_list.php b/admin/cat_list.php
index 97816b088..812a95cd2 100644
--- a/admin/cat_list.php
+++ b/admin/cat_list.php
@@ -20,16 +20,36 @@
include_once( './include/isadmin.inc.php' );
//----------------------------------------------------- template initialization
$sub = $vtp->Open( '../template/'.$user['template'].'/admin/cat_list.vtp' );
-// language
-$vtp->setGlobalVar( $sub, 'cat_edit', $lang['cat_edit'] );
-$vtp->setGlobalVar( $sub, 'cat_up', $lang['cat_up'] );
-$vtp->setGlobalVar( $sub, 'cat_down', $lang['cat_down'] );
-$vtp->setGlobalVar( $sub, 'cat_image_info', $lang['cat_image_info'] );
-$vtp->setGlobalVar( $sub, 'cat_permission', $lang['cat_permission'] );
-$vtp->setGlobalVar( $sub, 'cat_update', $lang['cat_update'] );
-$vtp->setGlobalVar( $sub, 'user_template', $user['template'] );
+$tpl = array( 'cat_edit','cat_up','cat_down','cat_image_info',
+ 'cat_permission','cat_update','cat_add','cat_parent','submit',
+ 'cat_virtual','delete','cat_first','cat_last' );
+templatize_array( $tpl, 'lang', $sub );
+$vtp->setGlobalVar( $sub, 'user_template', $user['template'] );
+//--------------------------------------------------- adding a virtual category
+$errors = array();
+if ( isset( $_POST['submit'] ) )
+{
+ if ( !preg_match( '/^\s*$/', $_POST['virtual_name'] ) )
+ {
+ // we have then to add the virtual category
+ $query = 'INSERT INTO '.PREFIX_TABLE.'categories';
+ $query.= ' (name,id_uppercat) VALUES ';
+ if ( $_POST['associate'] == -1 )
+ {
+ $_POST['associate'] = 'NULL';
+ }
+ $query.= " ('".$_POST['virtual_name']."',".$_POST['associate'].")";
+ $query.= ';';
+ echo $query;
+ mysql_query( $query );
+ }
+ else
+ {
+ array_push( $errors, $lang['cat_error_name'] );
+ }
+}
//--------------------------------------------------------------- rank updates
-if ( isset( $_GET['up'] ) && is_numeric( $_GET['up'] ) )
+if ( isset( $_GET['up'] ) and is_numeric( $_GET['up'] ) )
{
// 1. searching level (id_uppercat)
// and rank of the category to move
@@ -71,7 +91,7 @@ if ( isset( $_GET['up'] ) && is_numeric( $_GET['up'] ) )
$query.= ';';
mysql_query( $query );
}
-if ( isset( $_GET['down'] ) && is_numeric( $_GET['down'] ) )
+if ( isset( $_GET['down'] ) and is_numeric( $_GET['down'] ) )
{
// 1. searching level (id_uppercat)
// and rank of the category to move
@@ -89,7 +109,7 @@ if ( isset( $_GET['down'] ) && is_numeric( $_GET['down'] ) )
$query.= ' WHERE rank > '.$rank;
if ( $level == '' )
{
- $query.= ' AND id_uppercat is null';
+ $query.= ' AND id_uppercat IS NULL';
}
else
{
@@ -113,6 +133,46 @@ if ( isset( $_GET['down'] ) && is_numeric( $_GET['down'] ) )
$query.= ';';
mysql_query( $query );
}
+if ( isset( $_GET['last'] ) and is_numeric( $_GET['last'] ) )
+{
+ // 1. searching level (id_uppercat) of the category to move
+ $query = 'SELECT id_uppercat,rank';
+ $query.= ' FROM '.PREFIX_TABLE.'categories';
+ $query.= ' WHERE id = '.$_GET['last'];
+ $query.= ';';
+ $row = mysql_fetch_array( mysql_query( $query ) );
+ $level = $row['id_uppercat'];
+ // 2. searching the highest rank of the categories of the same parent
+ $query = 'SELECT MAX(rank) AS max_rank';
+ $query.= ' FROM '.PREFIX_TABLE.'categories';
+ $query.= ' WHERE id_uppercat';
+ if ( $level == '' ) $query.= ' IS NULL';
+ else $query.= ' = '.$level;
+ $query.= ';';
+ $row = mysql_fetch_array( mysql_query( $query ) );
+ $max_rank = $row['max_rank'];
+ // 3. updating the rank of our category to be after the previous max rank
+ $query = 'UPDATE '.PREFIX_TABLE.'categories';
+ $query.= ' SET rank = '.($max_rank + 1);
+ $query.= ' WHERE id = '.$_GET['last'];
+ $query.= ';';
+ mysql_query( $query );
+}
+if ( isset( $_GET['first'] ) and is_numeric( $_GET['first'] ) )
+{
+ // to place our category as first, we simply say that is rank is 0, then
+ // reordering will move category ranks correctly (first rank should be 1
+ // and not 0)
+ $query = 'UPDATE '.PREFIX_TABLE.'categories';
+ $query.= ' SET rank = 0';
+ $query.= ' WHERE id = '.$_GET['first'];
+ $query.= ';';
+ mysql_query( $query );
+}
+if ( isset( $_GET['delete'] ) and is_numeric( $_GET['delete'] ) )
+{
+ delete_category( $_GET['delete'] );
+}
//------------------------------------------------------------------ reordering
function ordering( $id_uppercat )
{
@@ -142,13 +202,23 @@ function ordering( $id_uppercat )
ordering( $row['id'] );
}
}
-
ordering( 'NULL' );
-//----------------------------------------------------affichage de la page
+//-------------------------------------------------------------- errors display
+if ( count( $errors ) != 0 )
+{
+ $vtp->addSession( $sub, 'errors' );
+ foreach ( $errors as $error ) {
+ $vtp->addSession( $sub, 'li' );
+ $vtp->setVar( $sub, 'li.content', $error );
+ $vtp->closeSession( $sub, 'li' );
+ }
+ $vtp->closeSession( $sub, 'errors' );
+}
+//---------------------------------------------------------------- page display
function display_cat_manager( $id_uppercat, $indent,
$uppercat_visible, $level )
{
- global $lang,$conf,$sub,$vtp;
+ global $lang,$conf,$sub,$vtp,$page;
// searching the min_rank and the max_rank of the category
$query = 'SELECT MIN(rank) AS min, MAX(rank) AS max';
@@ -170,14 +240,8 @@ function display_cat_manager( $id_uppercat, $indent,
// will we use <th> or <td> lines ?
$td = 'td';
$class = '';
- if ( $level > 0 )
- {
- $class = 'row'.$level;
- }
- else
- {
- $td = 'th';
- }
+ if ( $level > 0 ) $class = 'row'.$level;
+ else $td = 'th';
$query = 'SELECT id,name,dir,nb_images,status,rank,site_id,visible';
$query.= ' FROM '.PREFIX_TABLE.'categories';
@@ -200,16 +264,26 @@ function display_cat_manager( $id_uppercat, $indent,
$vtp->setVar( $sub, 'cat.td', $td );
$vtp->setVar( $sub, 'cat.class', $class );
$vtp->setVar( $sub, 'cat.indent', $indent );
- if ( $row['name'] == '' )
+ $vtp->setVar( $sub, 'cat.name', $row['name'] );
+ if ( $row['dir'] != '' )
{
- $name = str_replace( '_', ' ', $row['dir'] );
+ $vtp->addSession( $sub, 'storage' );
+ $vtp->setVar( $sub, 'storage.dir', $row['dir'] );
+ $vtp->closeSession( $sub, 'storage' );
+ // category can't be deleted
+ $vtp->addSession( $sub, 'no_delete' );
+ $vtp->closeSession( $sub, 'no_delete' );
}
else
{
- $name = $row['name'];
+ $vtp->addSession( $sub, 'virtual' );
+ $vtp->closeSession( $sub, 'virtual' );
+ // category can be deleted
+ $vtp->addSession( $sub, 'delete' );
+ $url = './admin.php?page=cat_list&amp;delete='.$row['id'];
+ $vtp->setVar( $sub, 'delete.delete_url', add_session_id( $url ) );
+ $vtp->closeSession( $sub, 'delete' );
}
- $vtp->setVar( $sub, 'cat.name', $name );
- $vtp->setVar( $sub, 'cat.dir', $row['dir'] );
if ( $row['visible'] == 'false' or !$uppercat_visible )
{
$subcat_visible = false;
@@ -229,9 +303,11 @@ function display_cat_manager( $id_uppercat, $indent,
$vtp->setVar( $sub, 'up.up_url', $url );
$vtp->closeSession( $sub, 'up' );
}
- else
+ else if ( $min_rank != $max_rank )
{
$vtp->addSession( $sub, 'no_up' );
+ $url = add_session_id( './admin.php?page=cat_list&amp;last='.$row['id']);
+ $vtp->setVar( $sub, 'no_up.last_url', $url );
$vtp->closeSession( $sub, 'no_up' );
}
if ( $row['rank'] != $max_rank )
@@ -241,9 +317,11 @@ function display_cat_manager( $id_uppercat, $indent,
$vtp->setVar( $sub, 'down.down_url', $url );
$vtp->closeSession( $sub, 'down' );
}
- else
+ else if ( $min_rank != $max_rank )
{
$vtp->addSession( $sub, 'no_down' );
+ $url = add_session_id('./admin.php?page=cat_list&amp;first='.$row['id']);
+ $vtp->setVar( $sub, 'no_down.first_url', $url );
$vtp->closeSession( $sub, 'no_down' );
}
if ( $row['nb_images'] > 0 )
@@ -271,7 +349,10 @@ function display_cat_manager( $id_uppercat, $indent,
$vtp->addSession( $sub, 'no_permission' );
$vtp->closeSession( $sub, 'no_permission' );
}
- if ( $row['site_id'] == 1 )
+ // you can individually update a category only if it is on the main site
+ // and if it's not a virtual category (a category is virtual if there is
+ // no directory associated)
+ if ( $row['site_id'] == 1 and $row['dir'] != '' )
{
$vtp->addSession( $sub, 'update' );
$url = add_session_id('./admin.php?page=update&amp;update='.$row['id']);
@@ -291,6 +372,14 @@ function display_cat_manager( $id_uppercat, $indent,
}
}
display_cat_manager( 'NULL', str_repeat( '&nbsp', 4 ), true, 0 );
+// add a virtual category ?
+$vtp->addSession( $sub, 'associate_cat' );
+$vtp->setVar( $sub, 'associate_cat.value', '-1' );
+$vtp->setVar( $sub, 'associate_cat.content', '' );
+$vtp->closeSession( $sub, 'associate_cat' );
+$page['plain_structure'] = get_plain_structure();
+$structure = create_structure( '', array() );
+display_categories( $structure, '&nbsp;' );
//----------------------------------------------------------- sending html code
$vtp->Parse( $handle , 'sub', $sub );
?> \ No newline at end of file
diff --git a/admin/cat_modify.php b/admin/cat_modify.php
index 90b3cac48..594504a63 100644
--- a/admin/cat_modify.php
+++ b/admin/cat_modify.php
@@ -23,7 +23,7 @@ $sub = $vtp->Open( '../template/'.$user['template'].'/admin/cat_modify.vtp' );
$tpl = array( 'remote_site','editcat_confirm','editcat_back','editcat_title1',
'editcat_name','editcat_comment','editcat_status',
'editcat_visible','editcat_visible_info', 'submit',
- 'editcat_uploadable' );
+ 'editcat_uploadable','cat_virtual','cat_parent' );
templatize_array( $tpl, 'lang', $sub );
//---------------------------------------------------------------- verification
if ( !is_numeric( $_GET['cat'] ) )
@@ -71,9 +71,19 @@ if ( isset( $_POST['submit'] ) )
$query.= ", status = '".$_POST['status']."'";
$query.= ", visible = '".$_POST['visible']."'";
- $query.= ", uploadable = '".$_POST['uploadable']."'";
+
+ if ( isset( $_POST['uploadable'] ) )
+ $query.= ", uploadable = '".$_POST['uploadable']."'";
+
+ if ( isset( $_POST['associate'] ) )
+ {
+ $query.= ', id_uppercat = ';
+ if ( $_POST['associate'] == -1 ) $query.= 'NULL';
+ else $query.= $_POST['associate'];
+ }
$query.= ' WHERE id = '.$_GET['cat'];
$query.= ';';
+ echo $query;
mysql_query( $query );
$query = 'SELECT id';
@@ -106,7 +116,17 @@ $result = get_cat_info( $row['id'] );
$cat_name = get_cat_display_name( $result['name'], ' - ', '' );
$vtp->setVar( $sub, 'cat:name', $cat_name );
// cat dir
-$vtp->setVar( $sub, 'cat:dir', $row['dir'] );
+if ( $row['dir'] != '' )
+{
+ $vtp->addSession( $sub, 'storage' );
+ $vtp->setVar( $sub, 'storage.dir', $row['dir'] );
+ $vtp->closeSession( $sub, 'storage' );
+}
+else
+{
+ $vtp->addSession( $sub, 'virtual' );
+ $vtp->closeSession( $sub, 'virtual' );
+}
// remote site ?
if ( $row['site_id'] != 1 )
{
@@ -150,7 +170,11 @@ if ( $row['visible'] == 'false' )
$vtp->setVar( $sub, 'visible_option.checked', $checked );
$vtp->closeSession( $sub, 'visible_option' );
// uploadable : true or false
-if ( $conf['upload_available'] )
+// a category can be uploadable if :
+// 1. upload is authorized
+// 2. category is not virtual
+// 3. category is on the main site
+if ( $conf['upload_available'] and $row['dir'] != '' and $row['site_id'] == 1 )
{
$vtp->addSession( $sub, 'uploadable' );
$vtp->addSession( $sub, 'uploadable_option' );
@@ -175,6 +199,18 @@ if ( $conf['upload_available'] )
$vtp->closeSession( $sub, 'uploadable_option' );
$vtp->closeSession( $sub, 'uploadable' );
}
+// can the parent category be changed ? (is the category virtual ?)
+if ( $row['dir'] == '' )
+{
+ $vtp->addSession( $sub, 'parent' );
+ $vtp->addSession( $sub, 'associate_cat' );
+ $vtp->setVar( $sub, 'associate_cat.value', '-1' );
+ $vtp->setVar( $sub, 'associate_cat.content', '' );
+ $vtp->closeSession( $sub, 'associate_cat' );
+ $structure = create_structure( '', array() );
+ display_categories( $structure, '&nbsp;', $row['id_uppercat'], $row['id'] );
+ $vtp->closeSession( $sub, 'parent' );
+}
//----------------------------------------------------------- sending html code
$vtp->Parse( $handle , 'sub', $sub );
?> \ No newline at end of file
diff --git a/admin/include/functions.php b/admin/include/functions.php
index 7115f163b..2763c890e 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -385,17 +385,24 @@ function get_keywords( $keywords_string )
return array_unique( $keywords );
}
-function display_categories( $categories, $indent )
+function display_categories( $categories, $indent,
+ $selected = -1, $forbidden = -1 )
{
global $vtp,$sub;
foreach ( $categories as $category ) {
- $vtp->addSession( $sub, 'associate_cat' );
- $vtp->setVar( $sub, 'associate_cat.value', $category['id'] );
- $content = $indent.'- '.$category['name'];
- $vtp->setVar( $sub, 'associate_cat.content', $content );
- $vtp->closeSession( $sub, 'associate_cat' );
- display_categories( $category['subcats'], $indent.str_repeat('&nbsp;',3) );
+ if ( $category['id'] != $forbidden )
+ {
+ $vtp->addSession( $sub, 'associate_cat' );
+ $vtp->setVar( $sub, 'associate_cat.value', $category['id'] );
+ $content = $indent.'- '.$category['name'];
+ $vtp->setVar( $sub, 'associate_cat.content', $content );
+ if ( $category['id'] == $selected )
+ $vtp->setVar( $sub, 'associate_cat.selected', ' selected="selected"' );
+ $vtp->closeSession( $sub, 'associate_cat' );
+ display_categories( $category['subcats'], $indent.str_repeat('&nbsp;',3),
+ $selected, $forbidden );
+ }
}
}
?> \ No newline at end of file
diff --git a/language/francais.php b/language/francais.php
index 5c7307b05..1059e3b0b 100644
--- a/language/francais.php
+++ b/language/francais.php
@@ -492,12 +492,18 @@ if ( $isadmin )
// start version 1.3
$lang['cat_permission'] = 'permissions';
$lang['cat_update'] = 'mis à jour';
+ $lang['cat_add'] = 'Ajouter une catégorie virtuelle';
+ $lang['cat_parent'] = 'catégorie parente';
+ $lang['cat_error_name'] = 'Le nom d\'une catégorie ne doit pas être nul';
+ $lang['cat_virtual'] = 'virtuelle';
+ $lang['cat_first'] = 'Premier';
+ $lang['cat_last'] = 'Dernier';
// end version 1.3
// page édition d\'une catégorie
$lang['editcat_confirm'] = 'Informations enregistrées dans la base de données';
$lang['editcat_back'] = 'catégories';
- $lang['editcat_title1'] = 'Options pour la';
+ $lang['editcat_title1'] = 'Options pour la catégorie';
$lang['editcat_name'] = 'Nom';
$lang['editcat_comment'] = 'Commentaire';
$lang['editcat_status'] = 'Status';
diff --git a/template/default/admin/cat_list.vtp b/template/default/admin/cat_list.vtp
index 12fe855a0..74e09c211 100644
--- a/template/default/admin/cat_list.vtp
+++ b/template/default/admin/cat_list.vtp
@@ -1,36 +1,67 @@
+<!--VTP_errors-->
+<div class="errors">
+ <div class="errors_title">{#errors_title}</div>
+ <ul>
+ <!--VTP_li-->
+ <li>{#content}</li>
+ <!--/VTP_li-->
+ </ul>
+</div>
+<!--/VTP_errors-->
<table style="width:100%;">
+<tr>
+ <td colspan="8" style="text-align:center;padding-top:10px;padding-bottom:10px;">
+ <form action="" method="post">
+ {#cat_add} <input type="text" name="virtual_name" />
+ {#cat_parent}
+ <select name="associate">
+ <!--VTP_associate_cat-->
+ <option value="{#value}">{#content}</option>
+ <!--/VTP_associate_cat-->
+ </select>
+ <input type="submit" value="{#submit}" name="submit" />
+ </form>
+ </td>
+</tr>
<!--VTP_cat-->
<tr>
- <{#td} style="width:40%;text-align:left;">
+ <{#td} style="width:50%;text-align:left;">
{#indent}<img src="../template/{#user_template}/admin/images/puce.gif" alt="&gt;" />
- &nbsp;{#name} [ dir : {#dir} ]
+ &nbsp;{#name} [
+ <!--VTP_storage-->
+ dir : {#dir}
+ <!--/VTP_storage-->
+ <!--VTP_virtual-->
+ <span style="color:blue;">{#cat_virtual}</span>
+ <!--/VTP_virtual-->
+ ]
<span style="color:red;font-weight:normal;"> {#invisible} <span style="font-weight:bold;">{#private}</span></span>
</{#td}>
- <{#td} style="text-align:center;">
- <div style="margin-left:3px;margin-right:3px;">{#nb_picture}</div>
- </{#td}>
<{#td} class="{#class}"
- style="width:10%;white-space:nowrap;text-align:center;">
- <a href="{#edit_url}">{#cat_edit}</a>
- </{#td}>
- <{#td} class="{#class}"
- style="width:10%;white-space:nowrap;text-align:center;">
+ style="width:1px;white-space:nowrap;text-align:center;">
<!--VTP_up-->
- <a href="{#up_url}">{#cat_up}</a>
+ <a href="{#up_url}"><img src="../template/{#user_template}/admin/images/arrow_up.gif" alt="{#cat_up}" title="{#cat_up}" style="border:none;" /></a>
<!--/VTP_up-->
<!--VTP_no_up-->
- <span style="color:darkgray;">{#cat_up}</span>
+ <a href="{#last_url}"><img src="../template/{#user_template}/admin/images/arrow_last.gif" alt="{#cat_last}" title="{#cat_last}" style="border:none;" /></a>
<!--/VTP_no_up-->
</{#td}>
<{#td} class="{#class}"
- style="width:10%;white-space:nowrap;text-align:center;">
+ style="width:1px;white-space:nowrap;text-align:center;">
<!--VTP_down-->
- <a href="{#down_url}">{#cat_down}</a>
+ <a href="{#down_url}"><img src="../template/{#user_template}/admin/images/arrow_down.gif" alt="{#cat_down}" title="{#cat_down}" style="border:none;" /></a>
<!--/VTP_down-->
<!--VTP_no_down-->
- <span style="color:darkgray;">{#cat_down}</span>
+ <a href="{#first_url}"><img src="../template/{#user_template}/admin/images/arrow_first.gif" alt="{#cat_first}" title="{#cat_first}" style="border:none;" /></a>
<!--/VTP_no_down-->
</{#td}>
+ <{#td} class="{#class}" style="width:1px;text-align:center;">
+ <div style="margin-left:3px;margin-right:3px;">{#nb_picture}</div>
+ </{#td}>
+ <{#td} class="{#class}"
+ style="width:10%;white-space:nowrap;text-align:center;">
+ <a href="{#edit_url}">{#cat_edit}</a>
+ </{#td}>
<{#td} class="{#class}"
style="width:10%;white-space:nowrap;text-align:center;">
<!--VTP_image_info-->
@@ -58,6 +89,15 @@
<span style="color:darkgray;">{#cat_update}</span>
<!--/VTP_no_update-->
</{#td}>
+ <{#td} class="{#class}"
+ style="width:10%;white-space:nowrap;text-align:center;">
+ <!--VTP_delete-->
+ <a href="{#delete_url}">{#delete}</a>
+ <!--/VTP_delete-->
+ <!--VTP_no_delete-->
+ <span style="color:darkgray;">{#delete}</span>
+ <!--/VTP_no_delete-->
+ </{#td}>
<tr>
<!--/VTP_cat-->
</table> \ No newline at end of file
diff --git a/template/default/admin/cat_modify.vtp b/template/default/admin/cat_modify.vtp
index 392919bf6..6293871a0 100644
--- a/template/default/admin/cat_modify.vtp
+++ b/template/default/admin/cat_modify.vtp
@@ -5,7 +5,15 @@
<form action="{#form_action}" method="post">
<table style="width:100%;">
<tr>
- <th colspan="2">{#editcat_title1} "{#cat:name}" [ {#cat:dir} ]</th>
+ <th colspan="2">{#editcat_title1} "{#cat:name}" [
+ <!--VTP_storage-->
+ dir : {#dir}
+ <!--/VTP_storage-->
+ <!--VTP_virtual-->
+ <span style="color:blue;">{#cat_virtual}</span>
+ <!--/VTP_virtual-->
+ ]
+ </th>
</tr>
<!--VTP_server-->
<tr>
@@ -52,6 +60,18 @@
</td>
</tr>
<!--/VTP_uploadable-->
+ <!--VTP_parent-->
+ <tr>
+ <td>{#cat_parent}</td>
+ <td class="row2">
+ <select name="associate">
+ <!--VTP_associate_cat-->
+ <option value="{#value}"{#selected}>{#content}</option>
+ <!--/VTP_associate_cat-->
+ </select>
+ </td>
+ </tr>
+ <!--/VTP_parent-->
<tr>
<td colspan="2">&nbsp;</td>
</tr>