示例#1
0
 /**
  * Assign page's data to smarty
  * @access private
  */
 private function getData($idPage, $idParent = false)
 {
     $ModelCms = new frontend_model_cms();
     $data = parent::s_page_data($idPage);
     $dataClean = $ModelCms->setItemData($data, 0);
     $dataClean['seoTitle'] = $data['seo_title_page'];
     $dataClean['seoDescr'] = $data['seo_desc_page'];
     $this->template->assign('page', $dataClean, true);
     // ** Assign parent page data
     if (isset($idParent)) {
         $parent = parent::s_page_data($idParent);
         $parentClean = $ModelCms->setItemData($parent, 0);
         $this->template->assign('parent', $parentClean);
     }
 }
示例#2
0
 /**
  * Retourne les données sql sur base des paramètres passés en paramète
  * @param array $data
  * @param array $current
  * @return array|null
  *
  */
 public static function getData($custom, $current)
 {
     if (!is_array($custom)) {
         return null;
     }
     if (!array_key_exists('cms', $current)) {
         return null;
     }
     $conf = array('id' => null, 'type' => null, 'limit' => null, 'lang' => $current['lang']['iso'], 'context' => array(1 => 'parent'));
     $current = $current['cms'];
     // custom values: data_sort
     if (isset($custom['select'])) {
         if ($custom['select'] == 'current') {
             $conf['id'] = isset($current['parent']['id']) ? $current['parent']['id'] : $current['record']['id'];
         } elseif (is_array($custom['select'])) {
             if (array_key_exists($conf['lang'], $custom['select'])) {
                 $conf['id'] = $custom['select'][$conf['lang']];
             }
         }
     } elseif (isset($custom['exclude'])) {
         if (is_array($custom['exclude'])) {
             if (array_key_exists($conf['lang'], $custom['exclude'])) {
                 $conf['id'] = $custom['exclude'][$conf['lang']];
                 $conf['type'] = 'exclude';
             }
         }
     }
     // custom values: display
     if (isset($custom['context'])) {
         if (is_array($custom['context'])) {
             foreach ($custom['context'] as $k => $v) {
                 $conf['context'][1] = $k;
                 $conf['context'][2] = $v;
             }
         } else {
             $allowed = array('', 'all', 'parent', 'child');
             if (array_search($custom['context'], $allowed)) {
                 $conf['context'][1] = $custom['context'];
             }
         }
     }
     // *** Load SQL data
     if ($conf['context'][1] == 'parent' or $conf['context'][1] == 'all') {
         $data = parent::s_page($conf['lang'], $conf['id'], $conf['type'], $conf['limit']);
         if ($data != null and ($conf['context'][2] == 'child' or $conf['context'][1] == 'all')) {
             foreach ($data as $k1 => $v1) {
                 $data_2 = parent::s_page_child($conf['lang'], $v1['idpage']);
                 if ($data_2 != null) {
                     $data[$k1]['subdata'] = $data_2;
                 }
             }
             $data_2 = null;
         }
     } elseif ($conf['context'][1] == 'child') {
         $data = parent::s_page_child($conf['lang'], $conf['id'], $conf['type'], $conf['limit']);
     }
     return $data;
 }