[SPIP][PLUGINS] v3.0-->v3.2
[lhc/web/www.git] / www / ecrire / inc / icone_renommer.php
index 97a873a..df61bd1 100644 (file)
@@ -3,39 +3,41 @@
 /***************************************************************************\
  *  SPIP, Systeme de publication pour l'internet                           *
  *                                                                         *
- *  Copyright (c) 2001-2016                                                *
+ *  Copyright (c) 2001-2017                                                *
  *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
  *                                                                         *
  *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
  *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
 \***************************************************************************/
 
-if (!defined('_ECRIRE_INC_VERSION')) return;
+if (!defined('_ECRIRE_INC_VERSION')) {
+       return;
+}
 
 include_spip('inc/boutons');
 include_spip('base/objets');
 
-function inc_icone_renommer_dist($fond,$fonction){
+function inc_icone_renommer_dist($fond, $fonction) {
        $size = 24;
-       if (preg_match("/(?:-([0-9]{1,3}))?([.](gif|png))?$/i",$fond,$match)
-               AND ((isset($match[0]) AND $match[0]) OR (isset($match[1]) AND $match[1]))) {
-               if (isset($match[1]) AND $match[1]) {
+       if (preg_match("/(?:-([0-9]{1,3}))?([.](gif|png))?$/i", $fond, $match)
+               and ((isset($match[0]) and $match[0]) or (isset($match[1]) and $match[1]))
+       ) {
+               if (isset($match[1]) and $match[1]) {
                        $size = $match[1];
                }
-               $type = substr($fond,0,-strlen($match[0]));
-               if (!isset($match[2]) OR !$match[2]) {
+               $type = substr($fond, 0, -strlen($match[0]));
+               if (!isset($match[2]) or !$match[2]) {
                        $fond .= ".png";
                }
-       }
-       else {
+       } else {
                $type = $fond;
                $fond .= ".png";
        }
 
        $rtl = false;
-       if (preg_match(',[-_]rtl$,i',$type,$match)){
+       if (preg_match(',[-_]rtl$,i', $type, $match)) {
                $rtl = true;
-               $type = substr($type,0,-strlen($match[0]));
+               $type = substr($type, 0, -strlen($match[0]));
        }
 
        // objet_type garde invariant tout ce qui ne commence par par id_, spip_
@@ -44,41 +46,42 @@ function inc_icone_renommer_dist($fond,$fonction){
 
        $dir = "images/";
        $f = "$type-$size.png";
-       if ($icone = find_in_theme($dir.$f)){
+       if ($icone = find_in_theme($dir . $f)) {
                $dir = dirname($icone);
                $fond = $icone;
 
                if ($rtl
-                       AND $fr = "$type-rtl-$size.png"
-                       AND file_exists($dir.'/'.$fr))
+                       and $fr = "$type-rtl-$size.png"
+                       and file_exists($dir . '/' . $fr)
+               ) {
                        $type = "$type-rtl";
+               }
 
                $action = $fonction;
-               if ($action=="supprimer.gif"){
+               if ($action == "supprimer.gif") {
                        $action = "del";
-               }
-               elseif ($action=="creer.gif"){
+               } elseif ($action == "creer.gif") {
                        $action = "new";
-               }
-               elseif ($action=="edit.gif"){
+               } elseif ($action == "edit.gif") {
                        $action = "edit";
                }
-               if (!in_array($action,array('del','new','edit')))
+               if (!in_array($action, array('del', 'new', 'edit'))) {
                        $action = "";
-               if ($action){
+               }
+               if ($action) {
                        if ($fa = "$type-$action-$size.png"
-                       AND file_exists($dir.'/'.$fa)){
-                               $fond = $dir .'/'. $fa;
+                               and file_exists($dir . '/' . $fa)
+                       ) {
+                               $fond = $dir . '/' . $fa;
                                $fonction = "";
-                       }
-                       else {
+                       } else {
                                $fonction = "$action-$size.png";
                        }
                }
+
                // c'est bon !
-               return array($fond,$fonction);
+               return array($fond, $fonction);
        }
 
-       return array($fond,$fonction);
+       return array($fond, $fonction);
 }
-?>