Exemple #1
0
 private function __construct()
 {
     $this->tablesManager = TablesManager::getInstance();
     $this->fieldsManager = FieldsManager::getInstance();
     $this->metaManager = MetaManager::getInstance();
     $this->relationsManager = RelationsManager::getInstance();
     $this->itemsManager = ItemsManager::getInstance();
     $this->commentsManager = CommentsManager::getInstance();
     $this->tablesMeta = [];
 }
 /**
  * Функция по записи о типе контента собирает всю информацию о метаданных и  
  * формирует ассоциативный массив для создания MetaObject
  * @param type $data запись из таблицы _meta
  * @return array вся метаинформация о типе контента 
  */
 private function collectData($data)
 {
     $descriptor = [];
     $descriptor['table'] = $data['type'];
     $info = $this->decodeInfo($data['info']);
     $descriptor['title'] = isset($info['title']) ? $info['title'] : $data['type'];
     $descriptor['title_pl'] = isset($info['title_pl']) ? $info['title_pl'] : $data['type'];
     $descriptor['order'] = isset($data['order']) ? $data['order'] : '';
     $descriptor['my'] = isset($info['my']) ? $info['my'] : $data['type'];
     $descriptor['rows_count'] = TablesManager::getInstance()->getRowsCount($data['type']);
     $descriptor['items'] = explode(',', $data['items']);
     if (count($descriptor['items']) == 1 && $descriptor['items'][0] == '') {
         $descriptor['items'] = [];
     }
     $descriptor['has_items'] = count($descriptor['items']) > 0;
     $descriptor['items_limit'] = $data['items_limit'];
     $descriptor['settings'] = [];
     foreach ($this->settingFieldsNames as $name) {
         $descriptor['settings'][$name] = (bool) $data[$name];
     }
     if ($data['af_fields']) {
         $descriptor['fields'] = json_decode($data['af_fields'], true);
     } else {
         $descriptor['fields'] = FieldsManager::getInstance()->getFields($data['type']);
     }
     if ($data['relations']) {
         $descriptor['relations'] = json_decode($data['relations'], true);
     } else {
         $descriptor['relations'] = RelationsManager::getInstance()->getRelations($data['type']);
     }
     return $descriptor;
 }