@@ -558,15 +558,33 @@ public function nextIdCategory() {
558
558
* @param content tableau multidimensionnel des catégories
559
559
* @param action permet de forcer la mise àjour du fichier
560
560
* @return string
561
- * @author Stephane F
561
+ * @author Stephane F, Pedro "P3ter" CADETE
562
562
**/
563
563
public function editCategories ($ content , $ action =false ) {
564
-
564
+
565
565
$ save = $ this ->aCats ;
566
-
566
+
567
567
# suppression
568
568
if (!empty ($ content ['selection ' ]) AND $ content ['selection ' ]=='delete ' AND isset ($ content ['idCategory ' ]) AND empty ($ content ['update ' ])) {
569
569
foreach ($ content ['idCategory ' ] as $ cat_id ) {
570
+ // change article category to the default category id
571
+ foreach ($ this ->plxGlob_arts ->aFiles as $ numart => $ filename ) {
572
+ $ filenameArray = explode (". " , $ filename );
573
+ $ filenameArrayCat = explode (", " , $ filenameArray [1 ]);
574
+ if (in_array ($ cat_id , $ filenameArrayCat )) {
575
+ $ key = array_search ($ cat_id , $ filenameArrayCat );
576
+ if (count (preg_grep ('[0-9]{3} ' , $ filenameArrayCat )) > 1 ) {
577
+ // this article has more than one category
578
+ unset($ filenameArrayCat [$ key ]);
579
+ }
580
+ else {
581
+ $ filenameArrayCat [$ key ] = '000 ' ;
582
+ }
583
+ $ filenameArray [1 ] = implode (", " , $ filenameArrayCat );
584
+ $ filenameNew = implode (". " , $ filenameArray );
585
+ rename (PLX_ROOT .$ this ->aConf ['racine_articles ' ].$ filename , PLX_ROOT .$ this ->aConf ['racine_articles ' ].$ filenameNew );
586
+ }
587
+ }
570
588
unset($ this ->aCats [$ cat_id ]);
571
589
$ action = true ;
572
590
}
0 commit comments