Ejemplo n.º 1
0
 public function beforeroute()
 {
     $this->table = $this->fw->get('PARAMS.table');
     if (!\models\meta\Meta::getInstance()->exists($this->table)) {
         $this->fw->error(404);
     }
     $this->tableMeta = \models\meta\Meta::getInstance()->getTableMeta($this->table);
     //		Для типов контента, которые завияст от других, должен быть передан ID родительского объекта
     //		$this->meta_all = \models\ContentMeta::getMetaAll();
     //		$this->meta = $this->meta_all[$this->table];
     //		foreach ($this->meta_all as $meta) {
     //			if ($meta['depend'] == $this->table) {
     //				$this->dependants[] = $meta['type'];
     //			}
     //		}
     $class = $this->modelClass;
     $this->model = $class::getInstance($this->table);
     if ($this->tableMeta->isTree()) {
         $this->setPid();
     }
     if ($this->fw->get('use_app_routes')) {
         $this->fw->mset(array('ctrl_base' => $this->fw->get('app_backend_base.content'), 'core_ctrl_base' => $this->fw->get('app_backend_base.content_core')));
     } else {
         $this->fw->mset(array('ctrl_base' => $this->fw->get('backend_base.content'), 'core_ctrl_base' => $this->fw->get('backend_base.content_core')));
     }
     $this->fw->set('valid_items', $this->tableMeta->get('items'));
     parent::beforeroute();
     $this->setOwnerId();
 }
Ejemplo n.º 2
0
 /**
  * Возвращает список родительских объектов
  * @param string $table Имя таблицы, для которой ищем родителей
  * @return type
  */
 function getParents($table)
 {
     //		$relations = $this->db->exec('SHOW FULL columns from `' . $table . '` LIKE "fko\_%"');
     $relations = CacheQuery::getInstance()->get('cached.parents.' . $table, 'SHOW FULL columns from `' . $table . '` LIKE "fko\\_%"', null, 'getFull');
     $list = array();
     foreach ($relations as $k => $v) {
         $table = preg_replace('/^fko_/', '', current($v));
         $relTableMeta = Meta::getInstance()->getTableMeta($table);
         /*$relTable = $table;
         			$res = CacheQuery::getInstance()->get(
         				'cached.comment.' . $relTable,
         				'SELECT table_comment FROM information_schema.tables WHERE table_name = "' . $relTable . '"',
         				null,
         				'getFirstRow'
         			);
         //			$res = $this->db->exec('SELECT table_comment 
         //                        FROM
         //                            information_schema.tables
         //                        WHERE 
         //                            table_name = "' . $relTable . '"');*/
         $list[$k]['table'] = $table;
         $list[$k]['name'] = 'fko_' . $table;
         $list[$k]['comment'] = $relTableMeta->get('comment');
         $list[$k]['title'] = $relTableMeta->get('title');
     }
     return $list;
 }
Ejemplo n.º 3
0
 /** Поиск и перенаправление на объект с заданным id
  * @return type
  */
 public function go()
 {
     $id = $this->fw->get('PARAMS.id');
     $type = $this->fw->get('PARAMS.type');
     if (!\models\meta\Meta::getInstance()->exists($type)) {
         $this->fw->error(404);
     }
     $tableMeta = \models\meta\Meta::getInstance()->getTableMeta($type);
     $model = \models\Content::getInstance($type);
     if ($this->fw->exists('ALIASES.frontend_' . $type . '_node')) {
         $alias = 'frontend_' . $type . '_node';
     } elseif ($this->fw->exists('ALIASES.frontend_' . $type . '_razdel')) {
         // TODO: перейти к использованию только английских имён для маршрутов: @frontend_type_category
         $alias = 'frontend_content_razdel';
     } else {
         $alias = 'frontend_content_node';
     }
     if ($tableMeta->isTree()) {
         $path = $model->getPath($id);
         if (empty($path)) {
             $path = ' ';
             // Чтобы корректно сформировался маршрут
         }
         $route = $this->fw->alias($alias, '1=' . $path);
     } else {
         $path = $model->getSlug($id);
         $route = $this->fw->alias($alias, 'slug=' . $path);
     }
     $this->fw->reroute($route);
 }
Ejemplo n.º 4
0
 public function beforeroute()
 {
     $this->table = $this->fw->get('PARAMS.type');
     if (!\models\meta\Meta::getInstance()->exists($this->table)) {
         $this->fw->error(404);
     }
     $this->tableMeta = \models\meta\Meta::getInstance()->getTableMeta($this->table);
 }
Ejemplo n.º 5
0
 public function beforeroute()
 {
     parent::beforeroute();
     $this->setAJAXLayout();
     $tableMetaObj = \models\meta\Meta::getInstance()->getTableMeta($this->table);
     $this->has_items = $tableMetaObj->hasItems();
     if ($this->has_items) {
         $this->item_model = \models\ContentItem::getInstance($this->table);
     }
     $this->is_moderated = $tableMetaObj->isModerated();
 }
Ejemplo n.º 6
0
 protected function __construct($table)
 {
     $f3 = \Base::instance();
     $this->db = $f3->get('db');
     if (!empty($table) && \models\meta\Meta::getInstance()->exists($table)) {
         $this->mapper = new \DB\SQL\Mapper($this->db, $table, null, $f3->get('application.db.ttl'));
         $this->table = $table;
     } else {
         echo 'construct error: ' . $table;
         $f3->error(500);
     }
 }
Ejemplo n.º 7
0
 public function getObjectNamesList()
 {
     $f3 = \Base::instance();
     $objects = \models\meta\Meta::getInstance()->getList();
     $list = [];
     foreach ($objects as $o) {
         $list[] = $o->get('table');
     }
     foreach (self::$spec_objects as $o) {
         $list[] = $o;
     }
     return $list;
 }
Ejemplo n.º 8
0
 /**
  * Получаем мета-данные связанной таблицы с нодами
  * @param type $rel
  */
 private function setRalatedMeta($rel)
 {
     if (is_string($rel)) {
         // Определяем тип связи
         $rel_table = $rel;
         $this->rel = 'fko_' . $this->table;
         $this->is_fko = true;
     } else {
         $this->rel = $rel;
         $rel_table = $rel['table'];
         $this->is_fko = false;
     }
     $this->relatedMeta = \models\meta\Meta::getInstance()->getTableMeta($rel_table);
     $this->relatedHasItems = $this->relatedMeta->hasItems();
     if ($this->relatedHasItems) {
         $this->relatedItemModel = \models\ContentItem::getInstance($rel_table);
     }
 }
Ejemplo n.º 9
0
 /**
  * Эта функция пока не перенесена
  */
 static function getCountWaiting($table = null)
 {
     if (is_null($table)) {
         $tables = \models\meta\Meta::getInstance()->getListBySetting('is_commentable', true);
     } else {
         $tableMeta = models\meta\Meta::getInstance()->getTableMeta($table);
         if ($tableMeta && $tableMeta->is_commentable()) {
             $tables = [$tableMeta];
         }
     }
     $result = [];
     foreach ($tables as $t) {
         $res = \Base::instance()->get('db')->exec('SELECT count(*) AS cnt ' . 'FROM `comments_' . $t->get('table') . '` ' . 'WHERE moderation = "waiting"');
         //			\helpers\Debug::prePrintR($res);
         $result[$t->get('table')] = $res[0]['cnt'];
     }
     return $result;
 }
Ejemplo n.º 10
0
 /** Конструктор
  * @param $table название таблицы, для которой создаются фильтры
  * @param $saveInSession сохранять ли фильтр в сессии, используйте для админки; если необходимо передавать фильтр через URL, не устанавливайт это поле 	
  */
 public function __construct($table, $saveInSession = true)
 {
     $this->saveInSession = $saveInSession;
     $this->table = $table;
     if ($this->saveInSession) {
         $f3 = \Base::instance();
         if (!$f3->get('SESSION.filters')) {
             $f3->set('SESSION.filters', []);
         }
         if (!$f3->get('SESSION.filters.' . $this->table)) {
             $f3->set('SESSION.filters.' . $this->table, []);
         }
     }
     $fields = \models\meta\Meta::getInstance()->getTableMeta($table)->get('fields');
     foreach ($fields as $f) {
         $type = $f['type'];
         //\models\content::getInputType($f['Type']);
         /** Если есть фильтр по имени поля, то берем его */
         if (isset($this->config[$f['name']])) {
             if (!$this->config[$f['name']]) {
                 continue;
             }
             $this->filters[$f['fullname']] = new $this->config[$f['name']]($this->table, $f);
         } elseif (isset($this->config[$type])) {
             if (!$this->config[$type]) {
                 continue;
             }
             $this->filters[$f['fullname']] = new $this->config[$type]($this->table, $f);
         } elseif ($f['foreign_key']) {
             $constructor = $this->config['foreign_key'];
             $this->filters[$f['fullname']] = new $constructor($this->table, $f, substr($f['fullname'], 4));
         } elseif (strpos($f['data_type'], 'enum') === 0) {
             $constructor = $this->config['enum'];
             $this->filters[$f['fullname']] = new $constructor($this->table, $f, substr($f['data_type'], 5, -1));
         } elseif (strpos($f['data_type'], 'set') === 0) {
             $constructor = $this->config['set'];
             $this->filters[$f['fullname']] = new $constructor($this->table, $f, substr($f['data_type'], 4, -1));
         }
         /** Если мы сохраняли в сессии, то загружаем фильтры из сессии */
         if ($this->saveInSession && $this->filters[$f['fullname']]) {
             $this->filters[$f['fullname']]->loadFromSession();
         }
     }
 }
Ejemplo n.º 11
0
 /**
  * Создаёт таблицу для хранения элементов типа контента
  * @param type $table
  * @return boolean
  */
 public function createItemsTable($table)
 {
     if (Meta::getInstance()->exists($table)) {
         $items_table = $table . '__items';
         if (!$this->tableExists($items_table)) {
             $q = $this->getCreateItemTableQuery($table);
             if ($this->db->exec($q) !== false) {
                 //$this->metaWriter->setHasItems($table,true);
                 \helpers\Msg::success('tables.created');
                 return TRUE;
             }
         } else {
             return TRUE;
             //     \helpers\Msg::info('tables.already_exists', array($items_table, $title));
         }
     } else {
         \helpers\Msg::info('tables.content_doesnt_exist', array($table, $title));
         return false;
     }
 }
Ejemplo n.º 12
0
 public function create()
 {
     $this->setAJAXLayout();
     if ($this->fw->exists('POST.obj')) {
         $post = $this->fw->get('POST');
         if (empty($post['obj'])) {
             $this->fw->error(406);
             return;
         }
         $tableMeta = \models\meta\Meta::getInstance()->exists($post['obj']);
         if ($tableMeta && $tableMeta->is_commentable()) {
             $this->model = \models\Comment::getInstance($post['obj']);
             if ($this->model->create($post)) {
                 $this->obj_id = $post['id'];
                 $this->printList();
                 $this->fw->set('inc', 'default/comment/list.html');
                 return;
             }
         }
     }
     $this->fw->error(406);
 }
Ejemplo n.º 13
0
 /**
  * Редактирование профиля пользователя
  */
 public function index()
 {
     \helpers\Layout::setTitles($this->fw->get('i18n.user.profile.title'));
     $model_profile = \models\UserProfile::getInstance();
     $model_profile_meta = \models\meta\Meta::getInstance()->getTableMeta('_user_profile');
     $profile = $model_profile->getByUserID($this->user_id);
     if (!is_null($profile)) {
         $this->fw->set('profile', $profile);
     } else {
         $user = $this->user_model->getOne($this->user_id);
         $title = $user->email;
         $model_profile->create($this->user_id, ['id' => $this->user_id, 'title' => $title]);
     }
     \models\UserProfile::setAjaxFields('_user_profile', $this->user_id);
     $this->fw->set('PARAMS.id', $this->user_id);
     $this->fw->set('upload_field_action_url', $this->fw->alias('backend_content_imagefield', 'table=' . $this->table . ',id=' . $this->user_id));
     foreach ($model_profile_meta->getPlural() as $k => $v) {
         $res = $this->model->getPluralSelected($this->node->id, $v);
         $this->fw->set("ajax_fields.{$v['full_table_name']}.selected", $res);
     }
     $this->fw->set('inc', 'user/profile.html');
     $this->clear_messages_after = true;
 }
Ejemplo n.º 14
0
 /**
  * Устанавливает массив с данными для генерации AJAX-полей
  */
 protected function setAJAXFields()
 {
     $mapper = new \DB\SQL\Mapper($this->db, '_group');
     $groups = [];
     foreach ($mapper->find() as $g) {
         $groups[$g->id] = $g->name;
     }
     $ajax_fields = array(array('name' => 'ref', 'type' => 'hidden', 'value' => $this->user_id), array('name' => 'group_id', 'table' => 'user', 'type' => 'select_list', 'placeHolder' => $this->fw->get('i18n.user.group.placeholder'), 'label' => $this->fw->get('i18n.user.group.label'), 'options' => $groups), array('name' => 'email', 'type' => 'text', 'placeHolder' => $this->fw->get('i18n.user.email.placeholder'), 'label' => $this->fw->get('i18n.user.email.label')));
     $additional_fields = array();
     $pofileMeta = \models\meta\Meta::getInstance()->getTableMeta('_user_profile');
     foreach ($pofileMeta->getAdditionalFields() as $v) {
         $type = $v['input_type'];
         $additional_fields[] = array('name' => 'af_' . $v['name'], 'table' => 'content/_user_profile', 'type' => $type, 'placeHolder' => $v['comment'], 'label' => $v['title']);
     }
     $this->fw->set('ajax_fields', array_merge($ajax_fields, $additional_fields));
     $this->setAjaxFieldsPost();
 }
Ejemplo n.º 15
0
 public function beforeroute()
 {
     parent::beforeroute();
     $this->metaManager = \models\meta\Meta::getInstance();
     $this->tableMeta = $this->metaManager->getTableMeta($this->fw->get('PARAMS.table'));
 }
Ejemplo n.º 16
0
 /**
  * Заменяет в тексте [link=<type>-<id>]
  * на html-код <a href="..." target="_blank">...</a>
  * @param string $text
  */
 public function makeLinks($text)
 {
     static $pattern = null;
     if (is_null($pattern)) {
         $types = \models\meta\Meta::getInstance()->getTypesNames();
         $pattern = '/\\[link=(' . implode('|', $types) . ')-(\\d+)\\]/';
     }
     if (preg_match_all($pattern, $text, $matches)) {
         if (count($matches) == 3) {
             $text = strip_tags($text);
             //			\helpers\Debug::prePrintR($matches);
             foreach ($matches[0] as $k => $v) {
                 $type = $matches[1][$k];
                 $id = $matches[2][$k];
                 $model = \models\Content::getInstance($type);
                 if ($node = $model->getOne($id)) {
                     $route = $model->getNamedRoute($type);
                     $link = '<a href="' . \Base::instance()->alias($route, 'table=' . $type . ',slug=' . $node->slug) . '">' . $node->title . '</a>';
                     $text = str_replace($v, $link, $text);
                 }
             }
         }
     }
     return $text;
 }
Ejemplo n.º 17
0
 /**
  * Формирует массив для генерации полей, отвечающих для связей много-ко-многим 
  * с другими объектами
  * @param type $table
  * @param int $user_id ID пользователя, для выборки доступных ему для выбора объектов
  * @return array Массив с параметрами полей для связей много-ко-многим
  */
 static function getAjaxRelationsPluralFields($table, $user_id = null, $rules = null)
 {
     $ajax_fields = [];
     $tableMeta = \models\meta\Meta::getInstance()->getTableMeta($table);
     foreach ($tableMeta->getPlural() as $k => $v) {
         $related = $v['table'];
         $content_model = self::getInstance($related);
         $options = $content_model->getSelectOptions($table, $user_id, $rules[$related]);
         if (!empty($options)) {
             $ajax_fields[$v['full_table_name']] = array('name' => $v['full_table_name'], 'type' => 'select_plural', 'multiselect' => true, 'placeHolder' => $v['comment'], 'label' => $v['label'], 'options' => $options);
         }
     }
     return $ajax_fields;
 }
Ejemplo n.º 18
0
 /**
  * Устанвливает пользовательское меню
  */
 protected function setAccountMenu()
 {
     $menu = [];
     $rules = ACLdata::getInstance()->getRules($this->user_group_id);
     // Модерирование комментариев
     if (in_array('comment', $rules[ACLdata::RELATION_NO][ACLdata::ACTION_MODERATION])) {
         $has_comments = \models\meta\Meta::getInstance()->getListBySetting('is_commentable', true);
         if (!empty($has_comments)) {
             array_push($menu, ['type' => 'header', 'title' => $this->fw->get('i18n.user.menu.moderation')]);
             $count_comments = \models\Comments::getCountWaiting();
             array_push($menu, ['object' => 'comments', 'action' => 'moderation', 'icon' => 'fui-checkbox-checked', 'title' => $this->fw->get('i18n.user.menu.comments.title'), 'count' => array_sum($count_comments)]);
             array_push($menu, ['type' => 'divider']);
         }
     }
     $read_rules = array_merge($rules[ACLdata::RELATION_NO][ACLdata::ACTION_READ], $rules[ACLdata::RELATION_OWN][ACLdata::ACTION_READ], $rules[ACLdata::RELATION_REF][ACLdata::ACTION_READ], $rules[ACLdata::RELATION_PARENT][ACLdata::ACTION_READ]);
     $read_admin = $rules[ACLdata::RELATION_NO][ACLdata::ACTION_READ];
     if (in_array('_user', $read_rules)) {
         array_push($menu, array('object' => 'user', 'href' => '/account/user', 'icon' => 'fui-user', 'title' => $this->fw->get('i18n.user.menu.users.title')));
     }
     // TODO: проверить
     //			if ($this->fw->exists('importer')) {
     //				$this->fw->config($this->fw->get('ROOT') . '/../' . APP_FOLDER . '/cfg/importer.ini');
     //				$menu = array_merge($menu, Importer::getMenu());
     //			}
     $content = array();
     $tmp = \models\meta\Meta::getInstance()->getList();
     foreach ($tmp as $v) {
         $table = $v->get('table');
         if ($table != '_user_profile' && in_array($table, $read_rules)) {
             $model = \models\ContentList::getInstance($table);
             $content[$v->get('title')] = array('object' => 'content', 'params' => 'table=' . $table, 'icon' => 'fui-list', 'title' => !is_null($v->get('title_pl')) ? $v->get('title_pl') : $v->get('title'), 'count_own' => $model->getCount(['user_id=?', $this->user_id]), 'count' => $read_admin ? $model->getCount() : '');
         }
     }
     if (!empty($content)) {
         ksort($content);
         array_unshift($content, ['type' => 'header', 'title' => $this->fw->get('i18n.user.menu.content.list')]);
         $menu = array_merge($menu, $content);
     }
     if (in_array('_group', $read_rules) || in_array('_acl', $read_rules)) {
         $menu = array_merge($menu, array(['type' => 'divider'], ['type' => 'header', 'title' => $this->fw->get('i18n.user.menu.rights.title')]));
         if (in_array('_group', $read_rules)) {
             $menu = array_merge($menu, array(array('object' => 'group', 'icon' => 'fui-list-thumbnailed', 'title' => $this->fw->get('i18n.user.menu.groups.title'))));
         }
         if (in_array('_acl', $read_rules)) {
             $menu = array_merge($menu, array(array('object' => 'acl', 'icon' => 'fui-list-thumbnailed', 'title' => $this->fw->get('i18n.user.menu.acl.title'))));
         }
     }
     if (in_array('_service', $read_rules)) {
         $menu = array_merge($menu, array(['type' => 'divider'], ['type' => 'header', 'title' => $this->fw->get('i18n.user.menu.service.title')], array('object' => 'static_blocks', 'icon' => 'fui-list-thumbnailed', 'title' => $this->fw->get('i18n.user.menu.static.title')), array('object' => 'static_places', 'icon' => 'fui-list-small-thumbnails', 'title' => $this->fw->get('i18n.user.menu.static.places.title')), array('object' => 'service', 'action' => 'resetcache', 'icon' => 'glyphicon glyphicon-refresh', 'title' => $this->fw->get('i18n.cache.reset.title')), array('object' => 'service', 'action' => 'phpinfo', 'icon' => 'fui-info', 'title' => 'PHPINFO'), array('object' => 'meta', 'icon' => 'fui-gear', 'title' => $this->fw->get('i18n.user.menu.contentmeta.title')), array('object' => 'comments', 'icon' => 'fui-gear', 'title' => $this->fw->get('i18n.user.menu.comments.title'))));
     }
     //\helpers\Debug::prePrintR($this->fw->get('PARAMS'));
     for ($i = 0; $i < count($menu); $i++) {
         if (isset($menu[$i]['href']) && $menu[$i]['href'] == $this->fw->get('PARAMS.0')) {
             $menu[$i]['class'] = 'active';
         }
     }
     $this->fw->set('MENUS.account', $menu);
     $this->fw->set('html.account_js', true);
 }
Ejemplo n.º 19
0
 public function settings()
 {
     if ($this->checkAccess(\models\ACL::ACTION_UPDATE)) {
         $this->setAJAXLayout();
         if ($this->fw->exists('POST.table') && $this->fw->exists('POST.setting')) {
             if (\models\meta\Meta::getInstance()->switchSetting($this->fw->get('POST.table'), $this->fw->get('POST.setting'))) {
                 \helpers\Msg::error('saved');
                 \Cache::instance()->reset();
                 echo "1";
                 return;
             } else {
                 \helpers\Msg::error('error');
                 \helpers\Msg::error('switches_error');
             }
         }
     } else {
         // Нет прав на редактирования этого нода
         \helpers\Msg::warning('update_no_rights');
         $this->fw->error(401);
     }
     \Cache::instance()->reset();
     echo "0";
 }
Ejemplo n.º 20
0
 protected function __construct($table)
 {
     parent::__construct($table);
     $this->tableMeta = \models\meta\Meta::getInstance()->getTableMeta($table);
 }
Ejemplo n.º 21
0
 /**
  * Формирует необходимую информацию для полей фильтрации
  * Пример фильтра много-ко-много:
  * если надо выбрать все объекты типа контента `objects`, связанные с другим объектом типа контента `categories`,
  * через расшивочную таблицу `or_categories_objects`
  * где <cat_id> - ID записи в таблице <categories>, фильтр будет иметь такой вид:
  * ['field' => <categories>, 'value' => <cat_id>]
  * @param array $filter одно поле для фильтрации в формате array ['field' => 'название поля', 'value' => 'значение']
  * @param string $slug название типа контента для формирования имени таблицы
  * @param boolean $for_admin для админа или нет 
  * @return array дополненный массив одного поля для фильтрации (null, если название поля некорректно)
  * 	[
  * 		'field' => 'название поля', 
  * 		'value' => 'значение'
  * 		'menu'  => 'что писать в меню', 
  * 		'clear_field' => 'Реальное имя поля в таблице', 
  * 		'table' => 'Название таблицы для связи много-ко-многим',
  * 	]
  */
 static function clearFilterFieldName($filter, $slug, $for_admin = false)
 {
     //		\helpers\Debug::prePrintR($filter);
     if (isset($filter['clear_field'])) {
         return $filter;
     }
     $filter['clear_field'] = null;
     $list_base_fields = array('priority', 'created', 'published', 'user_id', 'pid');
     if ($for_admin) {
         $list_base_fields[] = 'moderation';
         $list_base_fields[] = 'deleted';
         $list_base_fields[] = 'edited';
     }
     $list = array();
     $list_obj = array();
     $field_data = array();
     $tableMeta = \models\meta\Meta::getInstance()->getTableMeta($slug);
     foreach ($tableMeta->getFields() as $v) {
         $field_data[$v['name']] = $v;
         if ($v['is_additional']) {
             $list[] = $v['fullname'];
         } elseif (preg_match('/^fko_(.+)$/', $v['fullname'], $m)) {
             $list_obj['po_' . $m[1]] = $m[1];
         } elseif (in_array($v['name'], $list_base_fields)) {
             $list[] = $v['name'];
         }
     }
     // простые поля
     if (in_array($filter['field'], $list) || in_array(preg_replace('/^' . $slug . '\\./', '', $filter['field']), $list)) {
         $filter['clear_field'] = $filter['field'];
         if ($field_data[$filter['field']]['type'] == "enum('0','1')") {
             list($title, $comment) = explode(';', $field_data[$filter['field']]['comment']);
             $filter['menu'] = $title . ' : ' . ($filter['value'] ? 'да' : 'нет');
         } else {
             $filter['menu'] = $filter['value'];
         }
         return $filter;
     }
     // Категории один-ко-много
     if (isset($list_obj[$filter['field']])) {
         $node_manager = \models\Content::getInstance($list_obj[$filter['field']]);
         $node = $node_manager->get($filter['value']);
         $filter['menu'] = $node['title'];
         $filter['clear_field'] = 'fko_' . $list_obj[$filter['field']];
         return $filter;
     }
     //Категории много-ко-много
     $tables = $tableMeta->getPlural();
     foreach ($tables as $t) {
         //$plural_name = RelationsManager::getPluralName($filter['table'], $filter['field']);
         if ($filter['field'] == $t['table']) {
             $filter['clear_field'] = $t['full_table_name'] . '.' . $filter['field'] . '_id';
             $filter['menu'] = $t['comment'];
             $filter['table'] = $t;
             return $filter;
         }
     }
     return null;
 }
Ejemplo n.º 22
0
 /**
  * Список объектов, которые можно комментировать, или добавить возможность комментирования
  * ПЕРЕНЕСЕНА ИЗ КОНТРОЛЛЕРА Settings - ПРОВЕРИТЬ РАБОТОСПОСОБНОСТЬ
  * @param type $this->fw
  * @return type
  */
 public function getCommentsObjectsList()
 {
     $this->fw->set('list.subset', \models\meta\Meta::getInstance()->getListBySetting('is_commentable', true));
     $this->fw->set('list.is_sortable', true);
     // Чтобы не было постраничного выводв
     $this->fw->set('tpl', 'comments/objects');
     $this->fw->set('inc', 'comments/objects/list.html');
 }
Ejemplo n.º 23
0
 public function indexNN()
 {
     $this->show();
     $this->fw->set('html.inc', $this->tpldir . '/' . $this->table . '/index.html');
     $cache = \Cache::instance();
     if (!$cache->exists($this->table . '_index', $res)) {
         $model = $this->getListRelatedModel();
         $meta = \models\meta\Meta::getInstance()->getTableMeta($this->table_cat);
         $rel = $meta->getPluralRelation($this->table);
         $res = $model->getTreeWithRelatedNodes(0, $rel, [['field' => 'published', 'value' => '1']], ['limit' => $this->table_cat_nodes_limit, 'order' => $this->table_cat_nodes_order]);
         $cache->set($this->table . '_index', $res, $this->fw->get('application.cache.ttl'));
     }
     //		$this->print_r($res);
     $this->fw->set('html.index', $res);
 }