示例#1
0
 public function installPlugin($name, $activate = false)
 {
     // Effacement du cache plugins lors d'une installation
     $this->intiPluginsCache(array(), true);
     // Création du dossier data
     @mkdir(DATA_PLUGIN . $name . '/', 0777);
     @chmod(DATA_PLUGIN . $name . '/', 0777);
     // Lecture du fichier config usine
     $config = util::readJsonFile(PLUGINS . $name . '/param/config.json');
     // Par défaut le plugin est inactif
     if ($activate) {
         $config['activate'] = "1";
     } else {
         $config['activate'] = "0";
     }
     // Création du fichier config
     @util::writeJsonFile(DATA_PLUGIN . $name . '/config.json', $config);
     @chmod(DATA_PLUGIN . $name . '/config.json', 0666);
     // Appel de la fonction d'installation du plugin
     if (function_exists($name . 'Install')) {
         call_user_func($name . 'Install');
     }
     // Check du fichier config
     if (!file_exists(DATA_PLUGIN . $name . '/config.json')) {
         return false;
     }
     return true;
 }
示例#2
0
 public function saveConfig($val, $append = array())
 {
     $config = util::readJsonFile(DATA . 'config.json', true);
     $config = array_merge($config, $append);
     foreach ($config as $k => $v) {
         if (isset($val[$k])) {
             $config[$k] = $val[$k];
         }
     }
     if (util::writeJsonFile(DATA . 'config.json', $config)) {
         $this->config = util::readJsonFile(DATA . 'config.json', true);
         return true;
     } else {
         return false;
     }
 }
示例#3
0
文件: page.php 项目: hellojo84/99ko
 public function del($obj)
 {
     if ($obj->getIsHomepage() < 1 && $this->count() > 1) {
         foreach ($this->items as $k => $v) {
             if ($v->getId() == $obj->getId()) {
                 unset($this->items[$k]);
             }
         }
         $pages = util::readJsonFile($this->pagesFile, true);
         foreach ($pages as $k => $v) {
             if ($v['id'] == $obj->getId()) {
                 unset($pages[$k]);
             }
         }
         if (util::writeJsonFile($this->pagesFile, $pages)) {
             $this->repairPositions($obj);
             return true;
         }
         return false;
     }
     return false;
 }