Exemple #1
0
 public function listPlugins()
 {
     $pathplugins = new backend_controller_plugins();
     /**
      * Si le dossier est accessible en lecture
      */
     if (!is_readable($pathplugins->directory_plugins())) {
         throw new exception('Plugin dir is not minimal permission');
     }
     $makefiles = new magixcjquery_files_makefiles();
     $dir = $makefiles->scanRecursiveDir($pathplugins->directory_plugins());
     if ($dir != null) {
         plugins_Autoloader::register();
         $list = '';
         foreach ($dir as $d) {
             if (file_exists($pathplugins->directory_plugins() . $d . DIRECTORY_SEPARATOR . 'admin.php')) {
                 $pluginPath = $pathplugins->directory_plugins() . $d;
                 if ($makefiles->scanDir($pluginPath) != null) {
                     //Nom de la classe pour le test de la méthode
                     $class = 'plugins_' . $d . '_admin';
                     //Si la méthode run existe on ajoute le plugin dans le menu
                     if (method_exists($class, 'run')) {
                         $plugin[$class] = $d;
                     }
                 }
             }
         }
         return $plugin;
     }
 }
Exemple #2
0
 /**
  * @access private
  * @param $dir
  */
 private function cacheDir($dir)
 {
     $makefile = new magixcjquery_files_makefiles();
     $pathDir = $this->pathCacheDir($dir);
     if (file_exists($pathDir)) {
         $scandir = $makefile->scanDir($pathDir, array('.htaccess', '.gitignore'));
         $clean = '';
         if ($scandir != null) {
             foreach ($scandir as $file) {
                 $clean .= $makefile->removeFile($pathDir, $file);
             }
         }
     } else {
         $magixfire = new magixcjquery_debug_magixfire();
         $magixfire->magixFireError(new Exception('Error: var is not exist'));
     }
 }
Exemple #3
0
 /**
  * moves the file
  * @param $files
  * @param $dest
  * @return void
  */
 public static function move_files($file, $source, $dest)
 {
     //if file exist with magixcjquery function
     if (!magixcjquery_files_makefiles::recursiveFileExists($file, $source)) {
         //Checks if a stream is a local stream
         if (stream_is_local($dest)) {
             if (copy($source . $file, $dest . $file)) {
                 unlink($source . $file);
             } else {
                 throw new Exception('Error copy file');
             }
         }
     } else {
         throw new Exception('is not file exists');
     }
 }
Exemple #4
0
 /**
  * Suppression d'image
  */
 private function remove_image()
 {
     if (isset($this->delete_image)) {
         $makeFiles = new magixcjquery_files_makefiles();
         $vimage = parent::s_n_image_news($this->delete_image);
         if (file_exists(self::dir_img_news() . $vimage['n_image'])) {
             $makeFiles->removeFile(self::dir_img_news(), $vimage['n_image']);
             $makeFiles->removeFile(self::dir_img_news(), 's_' . $vimage['n_image']);
         }
         $img = null;
         parent::u_news_image($img, $this->delete_image);
     }
 }
Exemple #5
0
 /**
  * Scanne les plugins et vérifie si la fonction d'execution exist afin de l'intégrer dans le module
  * @access private
  * @param string $methodName
  * @return array|null
  */
 public function menu_item_plugin($methodName)
 {
     try {
         plugins_Autoloader::register();
         // Si le dossier est accessible en lecture
         if (!is_readable($this->directory_plugins())) {
             throw new exception('Error in load plugin: Plugin is not minimal permission');
         }
         $makefiles = new magixcjquery_files_makefiles();
         $dir = $makefiles->scanRecursiveDir($this->directory_plugins());
         if ($dir != null) {
             $data = '';
             $arrData = '';
             foreach ($dir as $d) {
                 if (file_exists($this->directory_plugins() . $d . DIRECTORY_SEPARATOR . 'admin.php')) {
                     $pluginPath = $this->directory_plugins() . $d;
                     if ($makefiles->scanDir($pluginPath) != null) {
                         if (class_exists('plugins_' . $d . '_admin')) {
                             if (method_exists('plugins_' . $d . '_admin', $methodName)) {
                                 if (method_exists('plugins_' . $d . '_admin', 'setConfig')) {
                                     $class_name = $this->execute_plugins('plugins_' . $d . '_admin');
                                     $setConfig = $class_name->setConfig();
                                     if (array_key_exists('url', $setConfig)) {
                                         if (isset($setConfig['url']['name'])) {
                                             $data['name'] = $setConfig['url']['name'];
                                         } else {
                                             $data['name'] = $d;
                                         }
                                     }
                                     $data['url'] = $d;
                                 } else {
                                     $data['url'] = $d;
                                     $data['name'] = null;
                                 }
                                 $arrData[] = $data;
                             }
                         }
                     }
                 }
             }
             if (is_array($arrData)) {
                 $arr_item = $arrData;
             } else {
                 $arr_item = null;
             }
             return $arr_item;
         }
     } catch (Exception $e) {
         magixglobal_model_system::magixlog('An error has occured :', $e);
     }
 }
Exemple #6
0
 /**
  * Scanne les plugins et vérifie si la fonction createSitemap 
  * exist afin de l'intégrer dans le sitemap
  * @access private
  */
 private function writeplugin($idlang)
 {
     try {
         plugins_Autoloader::register();
         // Si le dossier est accessible en lecture
         if (!is_readable($this->directory_plugins())) {
             throw new exception('Error in writeplugin: Plugin is not minimal permission');
         }
         $makefiles = new magixcjquery_files_makefiles();
         $dir = $makefiles->scanRecursiveDir($this->directory_plugins());
         if ($dir != null) {
             foreach ($dir as $d) {
                 if (file_exists($this->directory_plugins() . $d . DIRECTORY_SEPARATOR . 'admin.php')) {
                     $pluginPath = $this->directory_plugins() . $d;
                     if ($makefiles->scanDir($pluginPath) != null) {
                         if (class_exists('plugins_' . $d . '_admin')) {
                             $this->loadConfigPlugins('plugins_' . $d . '_admin', $idlang);
                         }
                     }
                 }
             }
         }
     } catch (Exception $e) {
         magixglobal_model_system::magixlog('An error has occured :', $e);
     }
 }
Exemple #7
0
 /**
  * @access public
  * Retourne un tableau avec les images sélectionné
  * @param string $directory
  * @param string $exclude
  * @param array $option
  * @return array|null
  * @throws Exception
  */
 public function scanImage($directory, $exclude, array $option = array('imgsize' => 'mini', 'reverse' => false))
 {
     $makeFiles = new magixcjquery_files_makefiles();
     if (file_exists($directory)) {
         $array_dir = $makeFiles->scanDir($directory, $exclude);
         if (is_array($option)) {
             switch ($option['imgsize']) {
                 case 'mini':
                     $imgsize = '/s_/';
                     break;
                 case 'medium':
                     $imgsize = '/m_/';
                     break;
                 default:
                     $imgsize = '/s_/';
                     break;
             }
             if ($array_dir != null) {
                 if (is_array($array_dir)) {
                     if ($option['reverse']) {
                         $tabs_files = preg_grep($imgsize, $array_dir, PREG_GREP_INVERT);
                     } else {
                         $tabs_files = preg_grep($imgsize, $array_dir);
                     }
                     return $tabs_files;
                 } else {
                     throw new Exception('Error scanImage :array_dir is not array');
                 }
             }
         } else {
             throw new Exception('Error scanImage :option is not array');
         }
     } else {
         return null;
     }
 }
Exemple #8
0
 /**
  * Création du fichier de configuration
  * @throws Exception
  */
 private function create_config_file()
 {
     if (isset($this->M_DBHOST) && isset($this->M_DBUSER) && isset($this->M_DBPASSWORD) && isset($this->M_DBNAME)) {
         if (!is_writable(dirname(self::$configfile))) {
             throw new Exception(sprintf('Cannot write %s file.', self::$configfile));
         }
         self::config_file_exist();
         try {
             # Creates config.php file
             $full_conf = file_get_contents(self::$config_in);
             $writeconst = new magixcjquery_files_makefiles();
             /**
              * create constante define in config file
              */
             $writeconst->writeConstValue('M_DBDRIVER', $this->M_DBDRIVER, $full_conf);
             $writeconst->writeConstValue('M_DBHOST', $this->M_DBHOST, $full_conf);
             $writeconst->writeConstValue('M_DBUSER', $this->M_DBUSER, $full_conf);
             $writeconst->writeConstValue('M_DBPASSWORD', $this->M_DBPASSWORD, $full_conf);
             $writeconst->writeConstValue('M_DBNAME', $this->M_DBNAME, $full_conf);
             switch ($this->M_LOG) {
                 case 'debug':
                     $writeconst->writeConstValue('M_LOG', $this->M_LOG, $full_conf);
                     break;
                 case 'log':
                     $writeconst->writeConstValue('M_LOG', $this->M_LOG, $full_conf);
                     break;
                 case 'false':
                     $writeconst->writeConstValue('M_LOG', $this->M_LOG, $full_conf, false);
             }
             $writeconst->writeConstValue('M_TMP_DIR', magixglobal_model_system::base_path() . 'var' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . 'errors.log', $full_conf);
             $writeconst->writeConstValue('M_FIREPHP', $this->M_FIREPHP, $full_conf, false);
             $fp = fopen(self::$configfile, 'wb');
             if ($fp === false) {
                 throw new Exception(sprintf('Cannot write %s file.', self::$configfile));
             }
             fwrite($fp, $full_conf);
             fclose($fp);
             //chmod(self::$configfile, 0666);
             app_model_smarty::getInstance()->display('config/request/success_add.tpl');
         } catch (Exception $e) {
             magixcjquery_debug_magixfire::magixFireError($e);
         }
     }
 }
Exemple #9
0
 /**
  * Retourne un tableau de la liste des plugins
  * @param $create
  * @return array
  */
 private function list_plugin($create)
 {
     $makefiles = new magixcjquery_files_makefiles();
     $dir = $makefiles->scanRecursiveDir($create->directory_plugins());
     $iso = backend_db_block_lang::s_data_iso($this->getlang);
     if ($dir != null) {
         foreach ($dir as $d) {
             if (file_exists($create->directory_plugins() . $d . DIRECTORY_SEPARATOR . 'i18n')) {
                 if (file_exists($create->directory_plugins() . $d . DIRECTORY_SEPARATOR . 'i18n' . DIRECTORY_SEPARATOR . 'public_local_' . $iso['iso'] . '.conf')) {
                     $array_plugin[] = $d;
                 }
             }
         }
         return $array_plugin;
     }
 }
Exemple #10
0
 /**
  * @access private
  * Suppression des images de galerie produit
  */
 private function remove_product_galery()
 {
     if (isset($this->delete_galery)) {
         $makeFiles = new magixcjquery_files_makefiles();
         $data = parent::s_product_galery_data($this->delete_galery);
         if (file_exists(self::dirImgProductGalery() . 'maxi' . DIRECTORY_SEPARATOR . $data['imgcatalog'])) {
             $makeFiles->removeFile(self::dirImgProductGalery() . 'maxi' . DIRECTORY_SEPARATOR, $data['imgcatalog']);
             $makeFiles->removeFile(self::dirImgProductGalery() . 'mini' . DIRECTORY_SEPARATOR, $data['imgcatalog']);
             parent::d_product_galery($this->delete_galery);
         }
     }
 }
Exemple #11
0
 /**
  * @access private
  * Scanne le dossier skin (public) et retourne les images ou capture des thèmes
  */
 private function scanTemplateDir($create)
 {
     $create->configLoad('local_' . backend_model_language::current_Language() . '.conf');
     $skin = $this->directory_skin();
     if (!is_readable($skin)) {
         throw new exception('skin is not minimal permission');
     }
     $makefiles = new magixcjquery_files_makefiles();
     $dir = $makefiles->scanRecursiveDir($skin, '.svn');
     $count = count($dir);
     if ($count == 0) {
         throw new exception('skin is not found');
     }
     if (!is_array($dir)) {
         throw new exception('skin is not array');
     }
     $template = null;
     foreach ($dir as $d) {
         if ($d == $this->load_theme()) {
             $btn_class = ' btn-primary';
             $btn_title = $create->getConfigVars('select');
         } else {
             $ctpl = '';
             $btn_class = ' btn-default';
             $btn_title = $create->getConfigVars('choose');
         }
         $themePath = self::directory_skin() . $d;
         if ($makefiles->scanDir($themePath) != null) {
             if (file_exists($themePath . '/screenshot.png')) {
                 $img = 'src="' . magixcjquery_html_helpersHtml::getUrl() . '/skin/' . $d . '/screenshot.png"';
                 $srcData = '';
             } else {
                 $img = 'src="' . magixcjquery_html_helpersHtml::getUrl() . '/skin/default/screenshot.png"';
                 $srcData = ' data-src="holder.js/260x180"';
             }
             $template .= '<li class="col-sm-4">';
             $template .= '<div class="thumbnail">';
             $template .= '<img ' . $img . $srcData . ' alt="' . $btn_title . '">';
             $template .= '<div class="caption">';
             $template .= '<h3>' . $d . '</h3>';
             $template .= '<p><a data-skin="' . $d . '" class="skin-tpl btn btn-large btn-block' . $btn_class . '" href="#">' . $btn_title . '</a></p>';
             $template .= '</div>';
             $template .= '</div>';
             $template .= '</li>';
         }
     }
     return $template;
 }