Author: rhari
Date: Tue Jun 5 13:42:49 2007
New Revision: 509
URL: http://svn.gna.org/viewcvs/phplinker?rev=509&view=rev
Log:
#232
Bug fix
Modified:
trunk/smarty/default/templates/admin/category.tpl
trunk/www/admin/category.php
trunk/www/lib/category.php
trunk/www/lib/general.php
Modified: trunk/smarty/default/templates/admin/category.tpl
URL:
http://svn.gna.org/viewcvs/phplinker/trunk/smarty/default/templates/admin/category.tpl?rev=509&r1=508&r2=509&view=diff
==============================================================================
--- trunk/smarty/default/templates/admin/category.tpl (original)
+++ trunk/smarty/default/templates/admin/category.tpl Tue Jun 5 13:42:49 2007
@@ -161,6 +161,7 @@
function addCateg (categname){
if (categname == '')return;
xajax_linker_add_category (0, categname);
+ xajax_linker_upd_htaccess();
document.getElementById('inputcateg').value = '';
}
@@ -198,6 +199,7 @@
// alert(document.forms[2].bt_save.value);
saveCateg();
saveTag();
+ xajax_linker_upd_htaccess();
xajax_linker_affiche_fin (modifExist);
document.forms[2].bt_save.value = "Enregistrer les modifications";
}
@@ -237,7 +239,6 @@
xajax_linker_upd_category(id, id_parent, tag, texte,
visibility, last);
}
}
-
// alert(count);
// alert(deleteIds);
// alert("Modifications enregistrées");
Modified: trunk/www/admin/category.php
URL:
http://svn.gna.org/viewcvs/phplinker/trunk/www/admin/category.php?rev=509&r1=508&r2=509&view=diff
==============================================================================
--- trunk/www/admin/category.php (original)
+++ trunk/www/admin/category.php Tue Jun 5 13:42:49 2007
@@ -43,6 +43,7 @@
$xajax->registerFunction("linker_upd_tag");
$xajax->registerFunction("linker_del_TagInIds");
$xajax->registerFunction("linker_affiche_fin");
+$xajax->registerFunction("linker_upd_htaccess");
// Utilisation de xajax pour traiter les requetes
Modified: trunk/www/lib/category.php
URL:
http://svn.gna.org/viewcvs/phplinker/trunk/www/lib/category.php?rev=509&r1=508&r2=509&view=diff
==============================================================================
--- trunk/www/lib/category.php (original)
+++ trunk/www/lib/category.php Tue Jun 5 13:42:49 2007
@@ -163,16 +163,21 @@
$objResponse = new xajaxResponse();
if (!linker_category_exist($id_parent, $name)){
- $qry = "INSERT INTO category (id_parent, name) VALUES (".$id_parent.",
'".utf8_decode($name)."')";
+ $qry = "INSERT INTO category (id_parent, name) VALUES (".$id_parent.",
'".addslashes(utf8_decode($name))."')";
$qry = sql_query('die',__FILE__,__LINE__,__FUNCTION__,$qry);
$id=mysql_insert_id();
linker_log("[".$_SESSION['login'] ."]Add category $name");
- linker_regenerate_htaccess();
$objResponse->addScriptCall("addCateg_step2", $id, $name);
}
else
$objResponse->addAlert("Cette catégorie existe déjà dans la branche
principale!!!");
+ return $objResponse->getXML();
+}
+
+function linker_upd_htaccess () {
+ $objResponse = new xajaxResponse();
+ linker_regenerate_htaccess();
return $objResponse->getXML();
}
@@ -188,12 +193,11 @@
id_parent = ".$id_parent.",
id_ad_tag = ".$id_ad_tag.",
".$visibilite."
- name = '".utf8_decode($name)."'
+ name = '".addslashes(utf8_decode($name))."'
WHERE id = ".$id;
$qry = sql_query('die',__FILE__,__LINE__,__FUNCTION__,$qry);
linker_log("[".$_SESSION['login'] ."]Update category $id set id_parent as
$id_parent,<br>set id_ad_tag as $id_ad_tag,<br>set name as $name $visibilite2");
- linker_regenerate_htaccess();
// }
// if ($last === 'true')
// $objResponse->addAlert("Modifications enregistrées");
@@ -214,16 +218,6 @@
return $objResponse->getXML();
}
-function linker_category_exist_in_session ($id_parent, $name){
- if (isset ($_SESSION['mng_categ']))
- foreach ($_SESSION['mng_categ'] as $categ)
- if (isset($categ['id_parent']) && isset($categ['name']))
- if ((string)$categ['id_parent'] == (string)$id_parent &&
strtoupper($categ['name']) == strtoupper($name))
- return true;
-
- return false;
-}
-
function linker_category_is_not_visible($id_categ){
if (linker_check_unsigned_int($id_categ) && $id_categ != 0) {
$qry = "SELECT visible FROM category WHERE id = ".$id_categ;
@@ -235,97 +229,6 @@
return false;
}
-function linker_save_category_into_session ($state, $visibility, $id,
$id_parent, $name){
- $reponse = new xajaxResponse();
-
- // edit : Editée ou Visibilité modifiée, drop : déplacée,del :
supprimée, new : nouvelle
-
- if ($state == 'del'){
-# si la categorie a supprimé est une nouvelle, on detruit la variable session
la contenant
-# si elle ne l'est pas, mettre son attribut " state" Ã del
- if (isset($_SESSION['mng_categ'][$id]['state']) &&
$_SESSION['mng_categ'][$id]['state'] == 'new'){
- unset($_SESSION['mng_categ'][$id]['state']);
- unset($_SESSION['mng_categ'][$id]['id']);
- }
- else {
- $_SESSION['mng_categ'][$id]['state'] = 'del';
- $_SESSION['mng_categ'][$id]['id'] = $id;
- }
-
- unset($_SESSION['mng_categ'][$id]['id_parent']);
- unset($_SESSION['mng_categ'][$id]['visibility']);
- unset($_SESSION['mng_categ'][$id]['name']);
-
- return $reponse;
- }
-
- if ($state == 'new'){
- if (!linker_category_exist(0, $name['categ_name']) &&
!linker_category_exist_in_session(0, $name['categ_name'])){
- $_SESSION['nb_new_categs'] =
(isset($_SESSION['nb_new_categs']))?$_SESSION['nb_new_categs']+1:1;
- $id = 'new_'.$_SESSION['nb_new_categs'];
-
- $_SESSION['mng_categ'][$id]['state'] = 'new';
- $_SESSION['mng_categ'][$id]['id'] = $id;
- $_SESSION['mng_categ'][$id]['id_parent'] = 0;
- $_SESSION['mng_categ'][$id]['visibility'] = '1';
- $_SESSION['mng_categ'][$id]['name'] = $name['categ_name'];
- }
- else{
- $reponse->addAlert("Ajout non éffectué!!!");
- }
-
- $reponse->addAssign("submitButton","value","Add");
- $reponse->addAssign("submitButton","disabled",false);
- $reponse->addRedirect("category");
-
- return $reponse;
- }
-
- if ($state == 'drop'){
- $oka = true;
- if (linker_category_exist($id_parent, $name))
- $oka = false;
-
- if (linker_category_exist_in_session($id_parent, $name))
- $oka = false;
-
- if ($oka) {
- ##### SI LA BRANCHE MODIFIE EST NOUVELLE L'ATTRIBUT STATE RESTE A NEW
- if (!isset($_SESSION['mng_categ'][$id]['state']) ||
(isset($_SESSION['mng_categ'][$id]['state']) &&
$_SESSION['mng_categ'][$id]['state'] != 'new'))
- $_SESSION['mng_categ'][$id]['state'] = 'drop';
-
- $_SESSION['mng_categ'][$id]['id'] = $id;
- $_SESSION['mng_categ'][$id]['id_parent'] = $id_parent;
-
- #### SI LE PARENT EST INVISIBLE L'ENFANT AUSSI LE SERA
- if (linker_category_is_not_visible($id_parent))
- $visibility = '0';
- # $reponse->addAlert($visibility);
- $_SESSION['mng_categ'][$id]['visibility'] = $visibility;
- $_SESSION['mng_categ'][$id]['name'] = $name;
- }
-
- return $reponse;
- }
-
- if ($state == 'edit'){
- ##### SI LA BRANCHE MODIFIE EST NOUVELLE L'ATTRIBUT STATE RESTE A NEW
- if (!isset($_SESSION['mng_categ'][$id]['state']) ||
(isset($_SESSION['mng_categ'][$id]['state']) &&
$_SESSION['mng_categ'][$id]['state'] != 'new'))
- $_SESSION['mng_categ'][$id]['state'] = 'edit';
-
- $_SESSION['mng_categ'][$id]['id'] = $id;
- $_SESSION['mng_categ'][$id]['id_parent'] = $id_parent;
-
- #### SI LE PARENT EST INVISIBLE L'ENFANT AUSSI LE SERA
- if (linker_category_is_not_visible($id_parent))
- $visibility = '0';
- # $reponse->addAlert($visibility);
- $_SESSION['mng_categ'][$id]['visibility'] = $visibility;
- $_SESSION['mng_categ'][$id]['name'] = $name;
-
- return $reponse;
- }
-}
function linker_del_CategInIds ($deleteIds) {
$objResponse = new xajaxResponse();
@@ -375,130 +278,6 @@
}
}
}
-}
-
-function linker_destroy_session_var_for ($id){
- unset($_SESSION['mng_categ'][$id]);
-}
-
-function linker_upd_idparent_in_session ($id){
- $qry = "SELECT id FROM category WHERE id_parent =
".$_SESSION['mng_categ'][$id]['id_parent']. " AND UPPER(name) LIKE
upper('".$_SESSION['mng_categ'][$id]['name']."')";
- $qry = sql_query('die',__FILE__,__LINE__,__FUNCTION__, $qry);
- while ($data = mysql_fetch_array($qry)){
- $new_id = $data['id'];
- }
-
- foreach ($_SESSION['mng_categ'] as $categ){
- if (isset($categ['id_parent']) && $categ['id_parent'] == $id)
- $_SESSION['mng_categ'][$categ['id']]['id_parent'] = $new_id;
- }
-}
-
-function linker_insert_new_categ ($id, $id_parent, $name, $visibility){
- $pos = strrpos((string)$id_parent, "new");
- if ($pos === false){
- $donothing = true;
- }
- else
- linker_insert_new_categ ($_SESSION['mng_categ'][$id_parent]['id'],
$_SESSION['mng_categ'][$id_parent]['id_parent'],
$_SESSION['mng_categ'][$id_parent]['name'],
$_SESSION['mng_categ'][$id_parent]['visibility']);
-
- if (isset($_SESSION['mng_categ'][$id]['id_parent']) &&
!linker_category_exist($_SESSION['mng_categ'][$id]['id_parent'], $name)){
- $qry = "INSERT INTO category (id_parent, name, visible)
- VALUES (".$_SESSION['mng_categ'][$id]['id_parent'].",
'".addslashes(utf8_decode($name))."', '".$visibility."')";
- sql_query('die',__FILE__,__LINE__,__FUNCTION__, $qry);
- linker_upd_idparent_in_session ($id);
- unset($_SESSION['mng_categ'][$id]);
- $_SESSION['nb_new_categs'] -= 1;
- }
-}
-
-function linker_save_session_category_to_database (){
- $reponse = new xajaxResponse();
-
-### ajouter d'abord toutes les nouvelles catégories afin qu'on puisse
rattacher leurs filles
-
- #######################INSERT
- foreach ($_SESSION['mng_categ'] as $categ){
- if ($categ['state'] == 'new') {
- linker_insert_new_categ ($categ['id'], $categ['id_parent'],
$categ['name'], $categ['visibility']);
- }
- }
-
- foreach ($_SESSION['mng_categ'] as $categ){
- switch ($categ['state']) {
-
- #######################APPLY UPDATE
-
- case 'edit' :
- $qry = "UPDATE category SET ";
- if ($categ['id_parent'] != -1)
- $qry .= "id_parent = ".$categ['id_parent'].",";
-
- if ($categ['name'] != "")
- $qry .= "name = '".addslashes(utf8_decode($categ['name']))."',";
-
- $qry .= "visible = '".$categ['visibility']."'
- WHERE id = ".$categ['id'];
- sql_query('die',__FILE__,__LINE__,__FUNCTION__, $qry);
- if ($categ['visibility'] == 0)
- linker_set_category_invisible ($categ['id'], true);
- // $reponse->addAlert($qry);
- break;
-
- case 'drop' :
- $qry = "UPDATE category SET ";
- if ($categ['id_parent'] != -1)
- $qry .= "id_parent = ".$categ['id_parent'].",";
-
- if ($categ['name'] != "")
- $qry .= "name = '".addslashes(utf8_decode($categ['name']))."',";
-
- $qry .= "visible = '".$categ['visibility']."'
- WHERE id = ".$categ['id'];
- sql_query('die',__FILE__,__LINE__,__FUNCTION__, $qry);
- if ($categ['visibility'] == 0)
- linker_set_category_invisible ($categ['id'], true);
- // $reponse->addAlert($qry);
- break;
-
- #######################APPLY DELETE
-
- case 'del' :
- linker_del_category ($categ['id'], true);
- break;
-
- #######################APPLY INSERT
-
- case 'new' :
- }
- }
- #######################DESTRUCTION DES VARIABLES SESSION
- unset($_SESSION['mng_categ']);
- unset($_SESSION['nb_new_categs']);
- $reponse->addRedirect("category");
-
- return $reponse;
-}
-
-function linker_init_session_mng_categ (){
- $reponse = new xajaxResponse();
-
- //unset($_SESSION['mng_categ']);
- $_SESSION['nb_new_categs'] = 0;
-
- return $reponse;
-}
-
-function linker_cancel_category_modifs(){
- $reponse = new xajaxResponse();
-
- unset($_SESSION['mng_categ']);
- unset($_SESSION['nb_new_categs']);
- linker_init_session_mng_categ();
- $reponse->addRedirect("category");
- //$objResponse->addAlert("Modifications annulées");
-
- return $reponse;
}
function linker_del_categ_in_url2category($id){
Modified: trunk/www/lib/general.php
URL:
http://svn.gna.org/viewcvs/phplinker/trunk/www/lib/general.php?rev=509&r1=508&r2=509&view=diff
==============================================================================
--- trunk/www/lib/general.php (original)
+++ trunk/www/lib/general.php Tue Jun 5 13:42:49 2007
@@ -107,6 +107,7 @@
function linker_remove_accents($char){
$char = utf8_encode($char);
+ $char = str_replace("ÃÂ ","_",$char);
$char = str_replace(" ","_",$char);
$char = str_replace("ï","i",$char);
$char = str_replace("ô","o",$char);
_______________________________________________
PHPLinker-commits mailing list
[email protected]
https://mail.gna.org/listinfo/phplinker-commits