/**
  * Returns the element definition list
  * Used to admin elements (elements_definition_list and element_definition views)
  *
  * XHR call
  *
  */
 function get_element_definition_list()
 {
     $elements = $this->element_definition_model->get_lang_list(array('order_by' => 'ordering ASC'), Settings::get_lang('default'));
     $elements_lang = $this->element_definition_model->get_all('element_definition_lang');
     // Elements
     foreach ($elements as &$element) {
         $element['languages'] = array();
         // Translated elements.
         foreach (Settings::get_languages() as $lang) {
             $element['languages'][$lang['lang']] = array('title' => '');
             foreach ($elements_lang as $ld) {
                 if ($ld['id_element_definition'] == $element['id_element_definition'] && $ld['lang'] == $lang['lang']) {
                     $element['languages'][$lang['lang']] = $ld;
                 }
             }
         }
         // Element's fields
         $element['fields'] = $this->extend_field_model->get_list(array('parent' => 'element', 'id_parent' => $element['id_element_definition']), Settings::get_lang('default'));
     }
     $this->template['elements'] = $elements;
     $this->output('element/definition/list');
 }
Exemple #2
0
 /**
  * Returns the element definition list
  * Used to admin elements (elements_definition_list and element_definition views)
  *
  * XHR call
  *
  */
 function get_element_definition_list()
 {
     $elements = $this->element_definition_model->get_lang_list(array('order_by' => 'ordering ASC'), Settings::get_lang('default'));
     $elements_lang = $this->element_definition_model->get_all('element_definition_lang');
     // Elements
     foreach ($elements as &$element) {
         $element['languages'] = array();
         // Translated elements.
         foreach (Settings::get_languages() as $lang) {
             $element['languages'][$lang['lang']] = array('title' => '');
             foreach ($elements_lang as $ld) {
                 if ($ld['id_element_definition'] == $element['id_element_definition'] && $ld['lang'] == $lang['lang']) {
                     $element['languages'][$lang['lang']] = $ld;
                 }
             }
         }
         // Element's fields
         $element['fields'] = $this->extend_field_model->get_list(array('parent' => 'element', 'id_parent' => $element['id_element_definition']), Settings::get_lang('default'));
         // Element usages on pages, articles
         $query = $this->db->where('id_element_definition = ' . $element['id_element_definition'])->from('element')->get();
         $usages = $query->result_array();
         foreach ($usages as $index => $usageElement) {
             if ($usageElement['parent'] === 'page') {
                 // get page: parent page of element
                 $usages[$index]['page'] = $this->page_model->get_by_id($usageElement['id_parent']);
                 $usages[$index]['article'] = null;
             } else {
                 // get page: parent page of article which is parent of element
                 $usages[$index]['article'] = $this->article_model->get_by_id($usageElement['id_parent']);
                 $usages[$index]['page'] = $this->page_model->get_by_id($usages[$index]['article']['id_page']);
             }
         }
         $element['usages'] = $usages;
     }
     $this->template['elements'] = $elements;
     $this->output('element/definition/list');
 }