Esempio n. 1
0
 /**
  * Возвращает массив с пунктами меню, полученный из списка нодов с заданным pid
  * @param string $url
  * @param int $pid
  * @param string $base_slug
  * @return array
  */
 static function getMenus($url, $pid = 1, $base_slug = '/')
 {
     $htmlpage = \models\ContentList::getInstance('htmlpage');
     $pages = $htmlpage->getChilds($pid, false);
     $items = array();
     foreach ($pages as $v) {
         if ($v['af_inmenu'] == 0) {
             continue;
         }
         $item_url = $base_slug . $v['slug'];
         $items[$item_url]['id'] = $v['id'];
         // Выясняем slug родительской страницы:
         $tmp = explode('/', $url);
         array_shift($tmp);
         $parent_url = array_shift($tmp);
         if ($url == $item_url || $parent_url == $v['slug']) {
             // Либо если страница является дочерней
             $items[$item_url]['active'] = true;
         } else {
             $items[$item_url]['active'] = false;
         }
         $items[$item_url]['text'] = self::getMenuItemTitle($v);
         $items[$item_url]['childs'] = $v['childs'];
     }
     return $items;
 }
 public function __construct($table, $field, $searchTable, $defaults = [])
 {
     parent::__construct($table, $field);
     $this->searchTable = $searchTable;
     $search_model = \models\ContentList::getInstance($searchTable);
     $this->defaultValues = ['list' => []];
     $this->values = ['list' => []];
     $this->setDefaults($defaults);
     $this->setItems($search_model->get(0, 1000, false)['subset']);
 }
Esempio n. 3
0
 public function getLinksTinyMCE()
 {
     $this->setAJAXLayout();
     $model = \models\ContentList::getInstance('htmlpage');
     if ($model) {
         $result = $model->getLinksTree(1, false);
         //			echo '/*';
         //			\helpers\Debug::prePrintR($result);
         //			echo '*/';
     } else {
         $result = array('type' => 'error');
     }
     $this->fw->set('content', json_encode($result));
 }
Esempio n. 4
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);
 }
Esempio n. 5
0
 /**
  * Генерирует список нодов для ajax-подгрузки в select
  * при выборе элементов древовидных справочников в связях 1-N
  */
 public function listJSON()
 {
     $this->setAJAXLayout();
     if ($this->fw->exists('GET.pid') && $this->tableMeta->isTree()) {
         $pid = $this->fw->get('GET.pid');
         $list_model = \models\ContentList::getInstance($this->table);
         $cat = $list_model->getChilds($pid, false);
         $items = array();
         foreach ($cat as $v) {
             $items[] = array('id' => $v['id'], 'name' => $v['title']);
         }
         $result = array('items' => $items);
     } else {
         $result = array('type' => 'error');
     }
     $this->fw->set('content', json_encode($result));
 }
Esempio n. 6
0
 /**
  * Возвращает значения для выпадающих списка, который устанавливает связи с объектом
  * @todo Не работает, доделать!
  * @param string $object_slug - slug объекта для которого произовдится выборка значений для списка
  * @param id|null $user_id владелец объекта
  * @param id|null $depend_id ID объекта от которого зависит объект $object_slug
  * 
  * @return array
  */
 public function getSelectOptions__old__($object_slug, $user_id = null)
 {
     $res = array();
     if (is_null($user_id)) {
         $list_model = \models\ContentList::getInstance($this->table);
         if ($this->tableMeta->isTree()) {
             $tmp = $list_model->getChilds(1);
         } else {
             $tmp = $list_model->getAll('title');
         }
     } else {
         /* $meta = ContentMeta::getInstance()->getMetaAll();
         	  if (!empty($meta[$this->table]['cycle_relation'])) {
         	  //$cycle_relation = $meta[$this->table]['cycle_relation'];
         	  //$list = $this->getCycleRelatedList($cycle_relation, $object_slug, $user_id/* , $depend_id );
         	  } else */
         if (!is_null($user_id)) {
             $list = $this->mapper->find(['user_id=?', $user_id]);
         } else {
             $list = $this->mapper->find();
         }
         $tmp = array();
         foreach ($list as $k => $v) {
             $tmp[$v['id']] = $v;
         }
     }
     foreach ($tmp as $k => $v) {
         $res[$v['id']]['text'] = $v['title'];
     }
     return $res;
 }
 /**
  * Функция для получения связанных с разделом нодов
  * @param type $filter - массив в формате [0=>['field'=>'user_id', 'value'=>132, 'operation' => '>'], 1=>[...]]
  * @param type $options
  */
 private function getNodes($tree_node_id, $filter, $options)
 {
     if ($this->is_fko) {
         $filter[] = ['field' => $this->rel, 'value' => $tree_node_id];
         if (!isset($options['order'])) {
             if ($this->relatedMeta->isSortable()) {
                 $options['order'] = 'sort ASC';
             } elseif ($this->relatedMeta->isPriority()) {
                 $options['order'] = 'priority DESC';
             } else {
                 $options['order'] = 'created DESC';
             }
         }
         $model = \models\ContentList::getInstance($this->relatedMeta->get('table'));
         $nodes = $model->getFilter($filter, $options);
     } else {
         $nodes = $this->getRelatedObjects($tree_node_id, $this->rel, $options);
     }
     return $this->setNodesProperties($nodes);
 }
Esempio n. 8
0
 /**
  * 
  * @param type $node_id
  * @param type $rel_table
  * @param array $options Параметры для поиска (например сортировка или ограничение кол-ва)
  * @return type
  */
 function getRelatedObjects($node_id, $rel_table, $options = array())
 {
     $tmp = $this->getPluralSelected($node_id, $rel_table);
     if (count($tmp)) {
         $model = \models\ContentList::getInstance($rel_table['table']);
         return $model->getAllByIds($tmp, $options);
     } else {
         return [];
     }
 }
Esempio n. 9
0
 /**
  * @todo Доделать поиск
  * сделать умное перенаправление, получая адрес страницы по именованному маршруту
  * Искать объекты всех типов, для которых в _acl прописаны права на просмотр для обычных посетителей сайта
  */
 protected function makeSearch($types)
 {
     $q = $this->fw->get('GET.q');
     $res = array();
     foreach ($types as $type) {
         // Поиск по страницам сайта
         $model = \models\ContentList::getInstance($type);
         $r = $model->search($q);
         if ($r) {
             foreach ($r as $v) {
                 $v = $v->cast();
                 $res['/search/go/' . $type . '/' . $v['id']] = stripslashes(str_ireplace($q, '<strong>' . $q . '</strong>', htmlspecialchars($v['title'])));
             }
         }
     }
     $this->fw->set('html.search_query', $q);
     $this->fw->set('html.search_results', $res);
 }