Ejemplo n.º 1
0
 /**
  * @access private
  * Rechercher une news et retourne sous forme JSON
  */
 private function json_url_news()
 {
     if ($this->news_search != '') {
         if (parent::s_search_news($this->news_search) != null) {
             foreach (parent::s_search_news($this->news_search) as $key) {
                 $dateformat = new magixglobal_model_dateformat();
                 $url_news = magixglobal_model_rewrite::filter_news_url($key['iso'], $dateformat->date_europeen_format($key['date_register']), $key['n_uri'], $key['keynews'], true);
                 $json[] = '{"idnews":' . json_encode($key['idnews']) . ',"n_title":' . json_encode($key['n_title']) . ',"iso":' . json_encode(magixcjquery_string_convert::upTextCase($key['iso'])) . ',"url_news":' . json_encode($url_news) . ',"date_register":' . json_encode($key['date_register']) . '}';
             }
             print '[' . implode(',', $json) . ']';
         }
     } else {
         print '{}';
     }
 }
Ejemplo n.º 2
0
 /**
  * @access private
  * Requête JSON pour les statistiques du CMS
  */
 private function json_graph()
 {
     if (parent::s_stats_rewrite() != null) {
         foreach (parent::s_stats_rewrite() as $key) {
             $stat[] = array('x' => magixcjquery_string_convert::upTextCase($key['iso']), 'y' => $key['REWRITE']);
         }
         print json_encode($stat);
     }
 }
Ejemplo n.º 3
0
 /**
  * @access private
  * Requête JSON pour les statistiques du catalogue
  */
 private function json_graph()
 {
     if (parent::s_stats_catalog() != null) {
         foreach (parent::s_stats_catalog() as $key) {
             $stat[] = array('x' => magixcjquery_string_convert::upTextCase($key['iso']), 'y' => $key['CATEGORY'], 'z' => $key['SUBCATEGORY'], 'a' => $key['CATALOG']);
         }
         print json_encode($stat);
     }
 }
Ejemplo n.º 4
0
 /**
 * @access private
 * Construction de la liste des plugins suivant des paramètres prédéfinis
      * @example:
      *
      * Icons :
      *
         public function setConfig(){
             return array(
                 'url'=> array(
                     'lang'  => 'none',
                     'action'=>''
                 ),
                 'icon'=> array(
                     'type'=>'font',
                     'name'=>'fa fa-flag'
                 )
             );
         }
      * URL et Langues :
      *
         public function setConfig(){
             return array(
                 'url'=> array(
                     'lang'  =>'list',
                     'action'=>'list'
                 )
             );
     }
      * Renommer le plugin :
      *
     public function setConfig(){
         return array(
             'url'=> array(
                 'lang'  =>'none',
                 'action'=>'',
                 'name'=>'mon plugin'
             )
         );
     }
 */
 public function set_html_item($debug = false)
 {
     $firebug = new magixcjquery_debug_magixfire();
     /**
      * Si le dossier est accessible en lecture
      */
     if (!is_readable($this->directory_plugins())) {
         throw new exception('Plugin dir is not minimal permission');
     }
     $makefiles = new magixcjquery_files_makefiles();
     $dir = $makefiles->scanRecursiveDir($this->directory_plugins());
     if ($dir != null) {
         plugins_Autoloader::register();
         $list = '';
         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) {
                     //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')) {
                         $access = $this->allow_access_config($d);
                         $role = new backend_model_role();
                         $data_role = $role->data();
                         // Si la methode setConfig existe on charge les éléments
                         if (method_exists($class, 'setConfig')) {
                             $class_name = $this->execute_plugins($class);
                             $setConfig = $class_name->setConfig();
                         } else {
                             if ($this->pathImgIcon($d, 'icon.png')) {
                                 $setConfig = array('icon' => array('type' => 'image', 'name' => 'icon.png'));
                             } else {
                                 $setConfig = array('icon' => array('type' => 'font', 'name' => 'fa-folder'));
                             }
                         }
                         // setConfig doit être un tableau
                         if (is_array($setConfig)) {
                             if ($setConfig['icon']['type'] == 'image') {
                                 $icon = '<img src="' . $this->pathImgIcon($d, $setConfig['icon']['name']) . '" width="16" height="16" alt="icon ' . $d . '" />';
                             } elseif ($setConfig['icon']['type'] == 'font') {
                                 $icon = '<span class="' . $setConfig['icon']['name'] . '"></span>';
                             }
                             if (isset($this->nameplugin)) {
                                 if ($this->nameplugin == $d) {
                                     $class_active = ' class="active"';
                                     $class_open = ' open';
                                     $class_on = ' on';
                                 } else {
                                     $class_active = '';
                                     $class_open = '';
                                     $class_on = '';
                                 }
                             } else {
                                 $class_active = '';
                                 $class_open = '';
                                 $class_on = '';
                             }
                             $array_lang = self::getTemplateVars('array_lang');
                             // Vérifie si URL est disponible dans le tableau
                             if (array_key_exists('url', $setConfig)) {
                                 if (isset($setConfig['url']['lang'])) {
                                     $lang = $setConfig['url']['lang'];
                                 } else {
                                     $lang = 'none';
                                 }
                                 if (isset($setConfig['url']['action'])) {
                                     if ($setConfig['url']['action'] != '') {
                                         $action = '&amp;action=' . $setConfig['url']['action'];
                                     } else {
                                         $action = '';
                                     }
                                 } else {
                                     $action = '';
                                 }
                                 if (isset($setConfig['url']['name'])) {
                                     if ($setConfig['url']['name'] != '') {
                                         $name = magixcjquery_string_convert::ucFirst($setConfig['url']['name']);
                                     } else {
                                         $name = magixcjquery_string_convert::ucFirst($d);
                                     }
                                 } else {
                                     $name = magixcjquery_string_convert::ucFirst($d);
                                 }
                             } else {
                                 $lang = 'none';
                                 $action = '';
                                 $name = magixcjquery_string_convert::ucFirst($d);
                             }
                             //Si le fichier d'accès est disponible, on retourne les permissions
                             if ($access != null or $access != '') {
                                 if ($access >= $data_role['id']) {
                                     //Si mode multi langue
                                     if ($lang === 'list') {
                                         $list .= '<li>';
                                         $list .= '<a href="#plugin-' . $d . '" class="showit' . $class_open . '">';
                                         $list .= '<span class="fa fa-plus-square-o"></span> ' . $name;
                                         $list .= '</a>';
                                         $list .= '<div class="collapse-item' . $class_on . '" id="plugin-' . $d . '">';
                                         $list .= '<div class="lang-group">';
                                         foreach ($array_lang as $key => $value) {
                                             //Ajoute la class active à la langue courante
                                             if ($this->nameplugin === $d and $this->getlang === $key) {
                                                 $lang_active = ' active';
                                             } else {
                                                 $lang_active = '';
                                             }
                                             $list .= '<a class="badge' . $lang_active . '" href="/' . PATHADMIN . '/plugins.php?name=' . $d . '&amp;getlang=' . $key . $action . '">';
                                             $list .= magixcjquery_string_convert::upTextCase($value) . '</a>';
                                         }
                                         $list .= '</div>';
                                         $list .= '</div>';
                                         $list .= '</li>';
                                     } else {
                                         $list .= '<li>';
                                         $list .= '<a' . $class_active . ' href="/' . PATHADMIN . '/plugins.php?name=' . $d . $action . '">' . $icon . ' ';
                                         $list .= $name;
                                         $list .= '</a>';
                                         $list .= '</li>';
                                     }
                                 } elseif ($access == '*') {
                                     //Si mode multi langue
                                     if ($lang === 'list') {
                                         $list .= '<li>';
                                         $list .= '<a href="#plugin-' . $d . '" class="showit' . $class_open . '">';
                                         $list .= '<span class="fa fa-plus-square-o"></span> ';
                                         $list .= $name;
                                         $list .= '</a>';
                                         $list .= '<div class="collapse-item' . $class_on . '" id="plugin-' . $d . '">';
                                         $list .= '<div class="lang-group">';
                                         foreach ($array_lang as $key => $value) {
                                             //Ajoute la class active à la langue courante
                                             if ($this->nameplugin === $d and $this->getlang === $key) {
                                                 $lang_active = ' active';
                                             } else {
                                                 $lang_active = '';
                                             }
                                             $list .= '<a class="badge' . $lang_active . '" href="/' . PATHADMIN . '/plugins.php?name=' . $d . '&amp;getlang=' . $key . $action . '">';
                                             $list .= magixcjquery_string_convert::upTextCase($value) . '</a>';
                                         }
                                         $list .= '</div>';
                                         $list .= '</div>';
                                         $list .= '</li>';
                                     } else {
                                         $list .= '<li>';
                                         $list .= '<a' . $class_active . ' href="/' . PATHADMIN . '/plugins.php?name=' . $d . $action . '">' . $icon . ' ';
                                         $list .= $name;
                                         $list .= '</a>';
                                         $list .= '</li>';
                                     }
                                 }
                             } else {
                                 $list .= '<li>';
                                 $list .= '<a' . $class_active . ' href="/' . PATHADMIN . '/plugins.php?name=' . $d . $action . '">' . $icon . ' ';
                                 $list .= $name;
                                 $list .= '</a>';
                                 $list .= '</li>';
                             }
                         } else {
                             throw new Exception('setConfig is not array');
                         }
                         //Si on demande un debug
                         if ($debug) {
                             $firebug->magixFireLog($d . ' pluginPath: ' . $pluginPath);
                             $firebug->magixFireLog($d . ' access: ' . $access);
                             $firebug->magixFireLog($d . ' icon type: ' . $setConfig['icon']['type']);
                             $firebug->magixFireLog($d . ' icon name: ' . $setConfig['icon']['name']);
                             $firebug->magixFireLog($d . ' URL: ' . $setConfig['url']);
                         }
                     }
                 }
             }
         }
     }
     return $list;
 }
Ejemplo n.º 5
0
 /**
  * Retourne les statistiques des contacts au format JSON
  */
 private function json_graph()
 {
     if (parent::select(array('type' => 'statistics')) != null) {
         foreach (parent::select(array('type' => 'statistics')) as $key) {
             $stat[] = array('x' => magixcjquery_string_convert::upTextCase($key['iso']), 'y' => $key['CONTACT']);
         }
         print json_encode($stat);
     }
 }
Ejemplo n.º 6
0
 /**
  * @access private
  * Requête JSON pour les statistiques des langues
  */
 private function json_graph()
 {
     if (parent::s_stats_user() != null) {
         foreach (parent::s_stats_user() as $key) {
             $stat[] = array('x' => magixcjquery_string_convert::upTextCase($key['pseudo_admin']), 'y' => $key['HOME'], 'z' => $key['NEWS'], 'a' => $key['PAGES'], 'b' => $key['PRODUCT']);
         }
         print json_encode($stat);
     }
 }
Ejemplo n.º 7
0
 /**
  * class pagination FirstString
  *
  * @param first letters $firstlt
  * @param sql $request
  * @param $key
  * @param string $url
  * @return void
  */
 function pagerString($firstlt, $request, $key, $rewrite = 'current', $url = false)
 {
     $lt_tampon = -1;
     $lt = null;
     //$rewrite = $url ? $url.$key.'/' : '?'.$key.'=';
     if ($rewrite == 'rewrite') {
         $urlreq = $_SERVER['PHP_SELF'];
         $point = strpos($urlreq, '.');
         $subst = substr($urlreq, 0, $point);
         $rewrite = $subst . '/' . $url . '/' . $key . '/';
     } elseif ($rewrite == 'current') {
         $rewrite = $_SERVER['PHP_SELF'] . '?' . $url . '=';
     }
     foreach ($request as $l) {
         $let = $l[$key];
         if ($let == $firstlt) {
             $lt .= '<div class="current">' . magixcjquery_string_convert::upTextCase($firstlt) . '</div>';
         } else {
             $lt .= '<a href="' . magixcjquery_html_helpersHtml::getUrl() . $rewrite . $let . '">' . magixcjquery_string_convert::upTextCase($l[$key]) . '</a>';
         }
         //letters prev diff letters next
         if ($lt != $lt_tampon) {
             // Save new letters
             $lt_tampon .= $lt;
         }
     }
     return $lt;
 }
Ejemplo n.º 8
0
 /**
  * Retourne au format JSON les liens des pages
  */
 public function json_url_page()
 {
     if ($this->page_search != '') {
         if (parent::s_page_url($this->page_search) != null) {
             foreach (parent::s_page_url($this->page_search) as $key) {
                 if ($key['idcat_p'] != 0) {
                     $url_cms = magixglobal_model_rewrite::filter_cms_url($key['iso'], $key['idcat_p'], $key['url_category'], $key['idpage'], $key['url_page'], true);
                 } else {
                     $url_cms = magixglobal_model_rewrite::filter_cms_url($key['iso'], null, null, $key['idpage'], $key['url_page'], true);
                 }
                 $json[] = '{"idpage":' . json_encode($key['idpage']) . ',"title_page":' . json_encode($key['title_page']) . ',"idcat_p":' . json_encode($key['idcat_p']) . ',"iso":' . json_encode(magixcjquery_string_convert::upTextCase($key['iso'])) . ',"url_cms":' . json_encode($url_cms) . ',"page_category":' . json_encode($key['page_category']) . '}';
             }
             print '[' . implode(',', $json) . ']';
         }
     } else {
         print '{}';
     }
 }
Ejemplo n.º 9
0
 /**
  * Construction du menu select
  * @param array $default_array
  * @param $options
  * @return string
  * @throws Exception
  */
 public static function select_static_row(array $default_array, $options)
 {
     if (is_array($default_array)) {
         if (array_key_exists('attr_name', $options)) {
             $attr_name = $options['attr_name'];
         } else {
             $attr_name = 'name_field';
         }
         if (array_key_exists('empty_value', $options)) {
             $empty_value = $options['empty_value'];
         } else {
             $empty_value = '';
         }
         if (array_key_exists('class', $options)) {
             $class = ' class="' . $options['class'] . '"';
         } else {
             $class = '';
         }
         if (array_key_exists('attr_id', $options)) {
             $attr_id = ' id="' . $options['attr_id'] . '"';
         } else {
             $attr_id = '';
         }
         if (array_key_exists('attr_multiple', $options)) {
             if ($options['attr_multiple'] === true) {
                 $attr_multiple = ' multiple="multiple"';
             } else {
                 $attr_multiple = '';
             }
         } else {
             $attr_multiple = '';
         }
         if (array_key_exists('upper_case', $options)) {
             if ($options['upper_case'] === true) {
                 $upper_case = true;
             } else {
                 $upper_case = false;
             }
         } else {
             $upper_case = false;
         }
         $mselect = '<select' . $attr_id . ' name="' . $attr_name . '"' . $class . $attr_multiple . '>';
         if (array_key_exists('attr_multiple', $options)) {
             if ($options['attr_multiple'] === true) {
                 $multiple = true;
             } else {
                 $multiple = false;
             }
         } else {
             $multiple = false;
         }
         if ($multiple != false) {
             if (array_key_exists('default_value', $options)) {
                 if (is_array($options['default_value'])) {
                     foreach ($options['default_value'] as $key => $value) {
                         $mselect .= '<option selected="selected" value="' . $key . '">' . $value . '</option>';
                     }
                 }
             }
             foreach ($default_array as $row => $val) {
                 $row_value = $row;
                 $row_name = $upper_case ? magixcjquery_string_convert::upTextCase($val) : $val;
                 $mselect .= '<option value="' . $row_value . '">' . $row_name . '</option>';
             }
         } else {
             if (array_key_exists('default_value', $options)) {
                 if ($options['default_value'] != null || $options['default_value'] != '') {
                     if (is_array($options['default_value'])) {
                         foreach ($options['default_value'] as $key => $value) {
                             $mselect .= '<option selected="selected" value="' . $key . '">' . $value . '</option>';
                         }
                     } else {
                         $default_value = $upper_case ? magixcjquery_string_convert::upTextCase($options['default_value']) : $options['default_value'];
                         $mselect .= '<option selected="selected" value="' . $options['default_value'] . '">' . $default_value . '</option>';
                     }
                     if ($empty_value != '') {
                         $mselect .= '<option value="">---------------------</option>';
                     }
                 } else {
                     if ($empty_value != '') {
                         $mselect .= '<option value="">' . $empty_value . '</option>';
                     }
                 }
             } else {
                 if ($empty_value != '') {
                     $mselect .= '<option value="">' . $empty_value . '</option>';
                 }
             }
             foreach ($default_array as $row => $val) {
                 $row_value = $row;
                 $row_name = $upper_case ? magixcjquery_string_convert::upTextCase($val) : $val;
                 $mselect .= '<option value="' . $row_value . '">' . $row_name . '</option>';
             }
         }
         $mselect .= '</select>';
         return $mselect;
     } else {
         throw new Exception('Params default_array is not array');
     }
 }