maj site_name si seul plugin
authordj3c1t <dj3c1t@free.fr>
Fri, 20 Dec 2013 16:32:10 +0000 (17:32 +0100)
committerdj3c1t <dj3c1t@free.fr>
Fri, 20 Dec 2013 16:32:10 +0000 (17:32 +0100)
mw_sourceml.php

index 301f9ca..740a25a 100644 (file)
     }
 
     function enable($env){
+      $data = $env->data();
+      if(
+            ($data->config("site_name") == "mtweb")
+        &&  (($plugins = $env->plugins()) !== false)
+        &&  (count($plugins) == 1)
+      ){
+        $data->set_config("site_name", "SourceML");
+      }
       return true;
     }
 
     function disable($env){
+      $data = $env->data();
+      if(
+            ($data->config("site_name") == "SourceML")
+        &&  (($plugins = $env->plugins()) !== false)
+        &&  (count($plugins) == 1)
+      ){
+        $data->set_config("site_name", "mtweb");
+      }
       return true;
     }
 
     function install($env){
       $data = $env->data();
-
+      $res = true;
       if(
             $env->bdd("sgbd") == "mysql"
         ||  $env->bdd("sgbd") == "pdo_mysql"
       ){
         $data->load_modules($env->path("mw_dir")."plugins/mw_sourceml/app/", "data/modules/sql/");
-        return $data->mw_sourceml_install_mysql($this, $env);
+        $res = $data->mw_sourceml_install_mysql($this, $env);
       }
       elseif(
             $env->bdd("sgbd") == "pdo_sqlite"
       ){
         $data->load_modules($env->path("mw_dir")."plugins/mw_sourceml/app/", "data/modules/sql/");
-        return $data->mw_sourceml_install_sqlite($this, $env);
+        $res = $data->mw_sourceml_install_sqlite($this, $env);
       }
       elseif(
             $env->bdd("sgbd") == "xml"
       ){
         $data->load_modules($env->path("mw_dir")."plugins/mw_sourceml/app/", "data/modules/xml/");
-        return $data->mw_sourceml_install_xml($this, $env);
+        $res = $data->mw_sourceml_install_xml($this, $env);
+      }
+      else{
+        $res = "Mode de stockage pour Mtweb (".$env->bdd("sgbd").") non supporté par SourceML";
       }
-      return "Mode de stockage pour Mtweb (".$env->bdd("sgbd").") non supporté par SourceML";
+      return $res;
     }
 
     function uninstall($env){
       $data = $env->data();
+      $res = true;
       if(
             $env->bdd("sgbd") == "mysql"
         ||  $env->bdd("sgbd") == "pdo_mysql"
         ||  $env->bdd("sgbd") == "pdo_sqlite"
       ){
         $data->load_modules($env->path("mw_dir")."plugins/mw_sourceml/app/", "data/modules/sql/");
-        return $data->mw_sourceml_uninstall_sql($this, $env);
+        $res = $data->mw_sourceml_uninstall_sql($this, $env);
       }
-      if(
+      elseif(
             $env->bdd("sgbd") == "xml"
       ){
         $data->load_modules($env->path("mw_dir")."plugins/mw_sourceml/app/", "data/modules/xml/");
-        return $data->mw_sourceml_uninstall_xml($this, $env);
+        $res = $data->mw_sourceml_uninstall_xml($this, $env);
+      }
+      else{
+        $res = "Mode de stockage pour Mtweb (".$env->bdd("sgbd").") non supporté par SourceML";
       }
-      return "Mode de stockage pour Mtweb (".$env->bdd("sgbd").") non supporté par SourceML";
+      return $res;
     }
 
   }