Exemple #1
0
 protected function getOptions($data)
 {
     if ($this->dictionary) {
         $options = Node::getSortedList($this->dictionary, $this->field ? $this->field : 'name');
     } else {
         $options = $this->options;
     }
     return $options;
 }
 public function onGet(array $options)
 {
     $sections = array_intersect_key(Node::getSortedList('tag'), array_flip(Node::create('subscription')->getEnabledSections()));
     $output = html::simpleOptions($sections, 'section', 'sections');
     if ($this->description) {
         $output .= html::em('description', html::cdata($this->description));
     }
     return $output;
 }
Exemple #3
0
 protected function getData($data)
 {
     if (isset($this->dictionary)) {
         return Node::getSortedList($this->dictionary);
     }
     if (!is_array($result = $this->options)) {
         $result = array();
     }
     return $result;
 }
 private function getData()
 {
     $list = array();
     if (!$this->required) {
         $list[''] = $this->default_label;
     }
     if (isset($this->dictionary)) {
         $list = array_merge($list, Node::getSortedList($this->dictionary));
     } elseif (is_array($this->options)) {
         $list = array_merge($list, $this->options);
     }
     return $list;
 }
Exemple #5
0
 /**
  * Возвращает форму для настройки виджета.
  *
  * @return Form вкладка для настройки виджета.
  */
 public static function getConfigOptions(Context $ctx)
 {
     $fields = array();
     $schema = Schema::load($ctx->db, 'tag');
     foreach ($schema as $k => $v) {
         if ($v instanceof URLControl) {
             $fields[$k] = $v->label;
         }
     }
     asort($fields);
     $tags = array('anything' => t('Текущий, если в нём пусто — родительский'), 'parent' => t('Родительский (соседние разделы)'), 'root' => t('Из настроек страницы'));
     foreach (Node::getSortedList('tag') as $k => $v) {
         $tags[$k] = $v;
     }
     return array('fixed' => array('type' => 'EnumControl', 'label' => t('Всегда возвращать раздел'), 'description' => t("По умолчанию виджет возвращает информацию о текущем разделе.  Вы можете настроить его на фиксированный раздел.  Подсветка текущего раздела при этом сохранится."), 'options' => $tags, 'default' => t('Текущий (его подразделы)')), 'depth' => array('type' => 'NumberControl', 'label' => t('Глубина'), 'description' => t("Меню будет содержать столько уровней вложенности.")));
 }
 /**
  * Возвращает информацию о правах на разделы.
  * @route GET//api/taxonomy/access.xml
  */
 public static function on_get_access(Context $ctx)
 {
     if (!$ctx->user->hasAccess(ACL::UPDATE, 'tag')) {
         throw new ForbiddenException();
     }
     $data = $ctx->db->getResults("SELECT n.id, n.parent_id, n.name, (SELECT MIN(uid) FROM {node__access} WHERE nid = n.id AND p = 1) AS `publishers`, (SELECT MIN(uid) FROM {node__access} WHERE nid = n.id AND u = 1) AS `owners` FROM {node} n WHERE n.class = 'tag' AND n.deleted = 0 ORDER BY n.left");
     $result = self::recurse($data, null);
     return new Response(html::em('sections', $result), 'text/xml');
     $perms = $ctx->db->getResultsKV("nid", "gid", "SELECT a.nid AS nid, MIN(a.uid) AS gid FROM node__access a INNER JOIN node n ON n.id = a.nid INNER JOIN node g ON g.id = a.uid WHERE n.class = 'tag' AND g.class = 'group' AND a.p = 1 GROUP BY a.nid");
     $data = Node::getSortedList('tag');
     $tmp = '';
     foreach ($data as $k => $v) {
         $gid = array_key_exists($k, $perms) ? $perms[$k] : null;
         $tmp .= html::em('section', array('id' => $k, 'group' => $gid, 'level' => 1 + (strlen($v) - strlen(ltrim($v))) / 2), html::cdata(trim($v)));
     }
     $result .= html::wrap('sections', $tmp);
     return new Response($result, 'text/xml');
 }
 /**
  * Вывод поисковой формы.
  */
 public static function on_get_search_form(Context $ctx)
 {
     $output = '';
     $url = new url($ctx->get('destination', $ctx->get('from')));
     if (null === $url->arg('preset')) {
         $types = Node::find(array('class' => 'type', 'published' => 1, 'deleted' => 0, 'name' => $ctx->user->getAccess(ACL::READ)), $ctx->db);
         $list = array();
         foreach ($types as $type) {
             if (!$type->isdictionary) {
                 $list[$type->name] = $type->title;
             }
         }
         asort($list);
         if ('file' == ($type = $ctx->get('type')) and array_key_exists($type, $list)) {
             $list = array($type => $type);
         }
         $tmp = '';
         foreach ($list as $k => $v) {
             $tmp .= html::em('type', array('name' => $k, 'title' => $v));
         }
         $output .= html::em('types', $tmp);
     }
     $tmp = '';
     foreach (Node::getSortedList('user', 'fullname', 'id') as $k => $v) {
         $tmp .= html::em('user', array('id' => $k, 'name' => $v));
     }
     $output .= html::em('users', $tmp);
     if (null === $url->arg('preset')) {
         $tmp = '';
         foreach (Node::getSortedList('tag', 'id', 'name') as $k => $v) {
             $tmp .= html::em('section', array('id' => $k, 'name' => $v));
         }
         $output .= html::em('sections', $tmp);
     }
     return html::em('content', array('name' => 'search', 'query' => self::get_clean_query($url->arg('search')), 'from' => urlencode($ctx->get('from'))), $output);
 }
 /**
  * Возвращает форму для настройки виджета.
  *
  * Форма позволяет выбрать типы документов, используемые для формирования
  * облака.
  *
  * @return Form вкладка с настройками виджета.
  */
 public static function getConfigOptions(Context $ctx)
 {
     $types = Node::getSortedList('type', 'title', 'name');
     return array('linktpl' => array('type' => 'TextLineControl', 'label' => t('Шаблон ссылки'), 'default' => 'section/$id'), 'type' => array('type' => 'EnumControl', 'label' => t('Тип выводимых объектов'), 'options' => $types, 'default' => 'tag', 'required' => true), 'classes' => array('type' => 'SetControl', 'label' => t('Типы документов'), 'options' => $types));
 }
 /**
  * @mcms_message ru.molinos.cms.module.settings.admin
  */
 public static function on_get_settings(Context $ctx)
 {
     return new Schema(array('admin' => array('type' => 'NodeLinkControl', 'label' => t('Администратор сервера'), 'dictionary' => 'user', 'required' => false, 'description' => t('Выберите пользователя, который занимается администрированием этого сайта. На его почтовый адрес будут приходить сообщения о состоянии системы.'), 'nonew' => true), 'debuggers' => array('type' => 'ListControl', 'label' => t('IP адреса разработчиков'), 'description' => t('Пользователям с этими адресами будут доступны отладочные функции (?debug=). Можно использовать маски, вроде 192.168.1.*'), 'default' => array('127.0.0.1', $_SERVER['REMOTE_ADDR'])), 'requiregroup' => array('type' => 'EnumControl', 'label' => t('Доступ к админке'), 'required' => false, 'default_label' => t('разрешить всем'), 'options' => Node::getSortedList('group'))));
 }
 public function testGetSortedLis()
 {
     $list = Node::getSortedList('type');
     $this->assertTrue(is_array($list));
     $this->assertFalse(empty($list));
     $list = Node::getSortedList('dummy');
     $this->assertTrue(is_array($list));
     $this->assertTrue(empty($list));
 }
 /**
  * @mcms_message ru.molinos.cms.module.settings.search
  */
 public static function on_get_settings(Context $ctx)
 {
     return new Schema(array('engine' => array('type' => 'EnumControl', 'options' => array('gas' => t('Google Ajax Search'), 'mg' => t('mnoGoSearch')), 'group' => t('Технология поиска'), 'weight' => 10, 'required' => true), 'gas_key' => array('type' => 'TextLineControl', 'label' => t('Ключ Google API'), 'description' => t('Для работы Google Ajax Search нужно <a href=\'@url\'>получить ключ</a>, уникальный для вашего сайта (это делается бесплатно и быстро).', array('@url' => 'http://code.google.com/apis/ajaxsearch/signup.html')), 'group' => 'Google Ajax Search', 'weight' => 20), 'mg_dsn' => array('type' => 'TextLineControl', 'label' => t('Параметры подключения к БД'), 'description' => t('Строка формата mysql://mnogouser:pass@server/mnogodb/?dbmode=multi'), 'group' => 'mnoGoSearch', 'weight' => 30), 'mg_ispell' => array('type' => 'TextLineControl', 'label' => t('Путь к словарям'), 'description' => t('Введите полный путь к папке ispell.'), 'group' => 'mnoGoSearch', 'weight' => 30), 'mg_indexer' => array('type' => 'TextLineControl', 'label' => t('Путь к индексатору'), 'description' => t('Введите полный путь к исполняемому файлу индексатора (что-то вроде /usr/local/bin/indexer).'), 'group' => 'mnoGoSearch', 'weight' => 30), 'mg_indexmode' => array('type' => 'EnumControl', 'label' => t('Режим индексирования'), 'required' => true, 'options' => array('web' => t('Обход сайта (медленно)'), 'db' => t('По базе данных (быстро)')), 'group' => 'mnoGoSearch', 'weight' => 30), 'mg_results' => array('type' => 'EnumControl', 'label' => t('Страница для результатов'), 'required' => true, 'options' => Node::getSortedList('domain'), 'description' => t('Используется только в режиме индексирования базы данных.  На эту страницу будут вести ссылки, отображаемые в результатах поиска.  При индексировании в режиме обхода сайта этот параметр не используется.'))));
 }
 /**
  * @mcms_message ru.molinos.cms.module.settings.captcha
  */
 public static function on_get_settings(Context $ctx)
 {
     return new Schema(array('types' => array('type' => 'SetControl', 'label' => t('Защищаемые типы'), 'options' => Node::getSortedList('type', 'title', 'name'))));
 }
Exemple #13
0
 /**
  * Возвращает форму для настройки виджета.
  *
  * @return Form вкладка для настройки виджета.
  */
 public static function getConfigOptions(Context $ctx)
 {
     return array('fixed' => array('type' => 'EnumControl', 'label' => t('Раздел по умолчанию'), 'description' => t('Здесь можно выбрать раздел, который будет использован, если из адреса текущего запроса вытащить код раздела не удалось.'), 'options' => array('page' => 'Из настроек страницы') + Node::getSortedList('tag'), 'default' => t('не используется')), 'forcefixed' => array('type' => 'BoolControl', 'label' => t('Всегда использовать этот раздел'), 'description' => t('Всегда возвращать информацию о выбранном разделе, независимо от того, в каком разделе находится посетитель.')), 'illcache' => array('type' => 'BoolControl', 'label' => t('Используется для формирования меню')));
 }
 /**
  * @mcms_message ru.molinos.cms.module.settings.taxonomy
  */
 public static function on_get_settings(Context $ctx)
 {
     return new Schema(array('multitagtypes' => array('type' => 'SetControl', 'label' => t('Помещать в несколько разделов можно'), 'options' => Node::getSortedList('type', 'title', 'name'))));
 }
 /**
  * @mcms_message ru.molinos.cms.module.settings.pridetypograph
  */
 public static function on_get_settings(Context $ctx)
 {
     return new Schema(array('fields' => array('type' => 'SetControl', 'label' => t('Обрабатываемые поля'), 'options' => Node::getSortedList('field', 'label', 'name'))));
 }
 /**
  * Возвращает схему для редактирования маршрута.
  */
 private static function getSchema(Context $ctx)
 {
     $widgets = array();
     if (class_exists('Widget')) {
         foreach (Widget::loadWidgets($ctx) as $k => $v) {
             $widgets[$k] = sprintf("%s (%s)", $v['title'], $v['classname']);
         }
         asort($widgets);
     }
     $themes = array();
     foreach (glob(os::path(MCMS_SITE_FOLDER, 'themes', '*'), GLOB_ONLYDIR) as $dir) {
         $themes[] = basename($dir);
     }
     return new Schema(array('host' => array('type' => 'TextLineControl', 'label' => t('Домен'), 'weight' => 1, 'required' => true, 'description' => t('Имя «localhost» используется как домен по умолчанию.'), 'group' => t('Адрес'), 'default' => 'localhost'), 'path' => array('type' => 'TextLineControl', 'label' => t('Путь'), 'weight' => 2, 'description' => t('Звёздочка используется для передачи произвольного параметра. Она может быть только одна. Пустой путь означает главную страницу домена.'), 'group' => t('Адрес')), 'title' => array('type' => 'TextLineControl', 'label' => t('Заголовок'), 'weight' => 3, 'group' => t('Внешний вид')), 'language' => array('type' => 'TextLineControl', 'label' => t('Язык по умолчанию'), 'weight' => 4, 'required' => true, 'default' => 'ru', 'group' => t('Внешний вид')), 'content_type' => array('type' => 'TextLineControl', 'label' => t('Тип содержимого'), 'required' => true, 'default' => 'text/html', 'group' => t('Внешний вид'), 'weight' => 5, 'description' => t('Обычно используют text/html, реже — text/xml.')), 'theme' => array('type' => 'TextLineControl', 'label' => t('Шкура'), 'group' => t('Внешний вид'), 'weight' => 6, 'description' => t('Доступные шкуры: %list.', array('%list' => join(', ', $themes))), 'default' => empty($themes) ? null : $themes[0]), 'optional' => array('type' => 'BoolControl', 'label' => t('Параметры не обязательны'), 'group' => t('Параметризация'), 'weight' => 7), 'defaultsection' => array('type' => 'EnumControl', 'label' => t('Раздел по умолчанию'), 'options' => Node::getSortedList('tag'), 'group' => t('Параметризация'), 'weight' => 8), 'widgets' => array('type' => 'SetControl', 'options' => $widgets, 'group' => t('Виджеты'), 'label' => t('Виджеты'), 'weight' => 9), 'cache' => array('type' => 'NumberControl', 'group' => t('Производительность'), 'weight' => 10, 'label' => t('Время жизни страницы в кэше'), 'description' => t('Указывается в секундах, по умолчанию кэш отключен.'))));
 }
Exemple #17
0
 /**
  * Возвращает форму для настройки виджета.
  *
  * @return Form вкладка с настройками виджета.
  */
 public static function getConfigOptions(Context $ctx)
 {
     $schema = array('fixed' => array('type' => 'SectionControl', 'label' => t('Показывать документы из раздела'), 'prepend' => array('root' => t('Основного для страницы (или домена)')), 'description' => t('В большинстве случаев нужен текущий раздел. Фиксированный используется только если список работает в отрыве от контекста запроса, например -- всегда показывает баннеры из фиксированного раздела.'), 'required' => false, 'default_label' => t('Текущего (из пути или свойств страницы)'), 'store' => true), 'fallbackmode' => array('type' => 'EnumControl', 'label' => t('Режим использования фиксированного раздела'), 'options' => array('always' => t('Всегда'), 'empty' => t('Если в запрошенном ничего не найдено'))), 'recurse' => array('type' => 'BoolControl', 'label' => t('Включить документы из подразделов')), 'showpath' => array('type' => 'BoolControl', 'label' => t('Возвращать информацию о разделе'), 'description' => t('Снижает производительность.')), 'limit' => array('type' => 'NumberControl', 'label' => t('Количество элементов на странице')), 'onlyiflast' => array('type' => 'BoolControl', 'label' => t('Возвращать список только если не запрошен документ')), 'onlyathome' => array('type' => 'BoolControl', 'label' => t('Возвращать список только если не запрошен конкретный раздел')), 'skipcurrent' => array('type' => 'BoolControl', 'label' => t('Не возвращать текущий документ')), 'count_comments' => array('type' => 'BoolControl', 'label' => t('Возвращать количество комментариев'), 'ifmodule' => 'comment'), 'pager' => array('type' => 'BoolControl', 'label' => t('Использовать постраничную листалку'), 'description' => t('Если эта опция выключена, массив $pager возвращаться не будет, и параметр .page=N обрабатываться не будет.')), 'allowoverride' => array('type' => 'BoolControl', 'label' => t('Разрешить переопределять раздел'), 'description' => t('При включении можно будет использовать ?виджет.section=123 для изменения раздела, с которым работает виджет.')), 'sort' => array('type' => 'TextLineControl', 'label' => t('Сортировка'), 'description' => t('Правило сортировки описывается как список полей, разделённых пробелами. Обратная сортировка задаётся префиксом "-" перед именем поля.')), 'types' => array('type' => 'SetControl', 'group' => t('Типы выводимых документов'), 'label' => t('Типы документов'), 'options' => Node::getSortedList('type', 'title', 'name')));
     return $schema;
 }
 /**
  * @mcms_message ru.molinos.cms.module.settings.auth
  */
 public static function on_get_settings(Context $ctx)
 {
     return new Schema(array('new_user_groups' => array('type' => 'SetControl', 'label' => t('Группы для регистрирующихся пользователей'), 'options' => Node::getSortedList('group'), 'store' => true), 'special_profile_fields' => array('type' => 'SetControl', 'label' => t('Запретить пользователям редактировать поля'), 'options' => self::getProfileFields(), 'store' => true), 'check_pw_on_profile_edit' => array('type' => 'BoolControl', 'label' => t('Проверять пароль при изменении профиля')), 'login_theme' => array('type' => 'TextLineControl', 'label' => t('Шкура для формы входа'), 'description' => t('Используется шаблон login.xsl, если такого нет или в нём ошибка — используется встроенный.')), 'allow_anonymous' => array('type' => 'SetControl', 'label' => t('Разрешить пользователям анонимно создавать'), 'options' => Node::getSortedList('type', 'title', 'name'), 'group' => t('Информация об авторстве'), 'weight' => 50), 'uid_weight' => array('type' => 'NumberControl', 'label' => t('Вес контрола'), 'group' => t('Информация об авторстве'), 'weight' => 51), 'uid_label' => array('type' => 'TextLineControl', 'label' => t('Подпись контрола'), 'default' => t('Ваше имя'), 'group' => t('Информация об авторстве'), 'weight' => 52), 'uid_group' => array('type' => 'TextLineControl', 'label' => t('Имя группы'), 'group' => t('Информация об авторстве'), 'weight' => 53)));
 }
 /**
  * Возвращает информацию о правах на объект.
  */
 public static function on_get_access(Context $ctx)
 {
     if (!$ctx->get('type')) {
         throw new BadRequestException();
     }
     $type = Node::load(array('class' => 'type', 'deleted' => 0, 'name' => $ctx->get('type')));
     if (empty($type)) {
         throw new PageNotFoundException();
     } elseif (!$type->checkPermission(ACL::UPDATE)) {
         throw new ForbiddenException();
     }
     $groups = Node::getSortedList('group', 'title');
     $groups[0] = t('Анонимные пользователи');
     $perms = $ctx->db->getResultsK("uid", "SELECT * FROM `node__access` WHERE `nid` = ?", array($type->id));
     $result = '';
     foreach ($groups as $gid => $groupName) {
         $result .= html::em('perm', array('gid' => $gid ? $gid : 'none', 'name' => $groupName, 'create' => !empty($perms[$gid]['c']), 'read' => !empty($perms[$gid]['r']), 'update' => !empty($perms[$gid]['u']), 'delete' => !empty($perms[$gid]['d']), 'publish' => !empty($perms[$gid]['p']), 'own' => !empty($perms[$gid]['o'])));
     }
     return html::em('content', array('id' => $type->id, 'name' => $type->name, 'title' => $type->title, 'next' => $ctx->get('destination'), 'own' => !empty($type->fields['uid'])), $result);
 }
 /**
  * Подтверждение удаления объектов.
  */
 public static function on_get_delete(Context $ctx)
 {
     $types = Node::getSortedList('type', 'title', 'name', 'name', 'name', 'name');
     $nodes = Node::find(array('id' => explode(' ', $ctx->get('node')), 'deleted' => 0), $ctx->db);
     if (empty($nodes)) {
         throw new PageNotFoundException();
     }
     $result = '';
     foreach ($nodes as $node) {
         if ($node->checkPermission(ACL::DELETE)) {
             $result .= html::em('node', array('id' => $node->id, 'name' => $node->getName(), 'type' => $types[$node->class]));
         }
     }
     if (empty($result)) {
         throw new ForbiddenException();
     }
     return html::em('content', array('name' => 'confirmdelete', 'title' => t('Подтвердите удаление объектов')), $result);
 }
 /**
  * @mcms_message ru.molinos.cms.module.settings.moderator
  */
 public static function on_get_settings(Context $ctx)
 {
     return new Schema(array('from' => array('type' => 'EmailControl', 'label' => t('Отправитель сообщений'), 'description' => t('С этого адреса будут приходить сообщения на тему модерации.'), 'default' => 'no-reply@' . MCMS_HOST_NAME), 'super' => array('type' => 'EmailControl', 'label' => t('Супервизоры'), 'description' => t('Список почтовых адресов, на которые всегда приходят все сообщения о модерации, независимо от привязки пользователя к выпускающему редактору.')), 'skip_types' => array('type' => 'SetControl', 'label' => t('Немодерируемые документы'), 'options' => Node::getSortedList('type', 'title', 'name'))));
 }
Exemple #22
0
 public static function getConfigOptions(Context $ctx)
 {
     $types = array('*' => 'Предлагать выбор') + Node::getSortedList('type', 'title', 'name');
     return array('section_default' => array('type' => 'EnumControl', 'label' => t('Раздел по умолчанию'), 'options' => Node::getSortedList('tag'), 'default' => t('Не используется')), 'type' => array('type' => 'EnumControl', 'label' => t('Тип данных по умолчанию'), 'options' => $types, 'default' => t('Не используется'), 'description' => "<p>Если пользователь попадает в раздел, в который он может добавить документы нескольких типов, ему будет предложен список этих типов в виде ссылок, ведущих на разные формы.&nbsp; Если вы укажете тип по умолчанию, и этот тип будет в списке возможных, вместо списка ссылок пользователю автоматически покажут нужную форму.</p>" . "<p>Однако <strong>имейте в виду</strong>, что этот параметр виджетом рассматривается как рекоммендация, а не как условие; если вы выберете здесь, скажем, &laquo;обратную связь&raquo;, а пользователь может создавать только &laquo;вакансии&raquo;, ему всё равно покажут форму с вакансией.</p>"), 'stripped' => array('type' => 'BoolControl', 'label' => t('Только базовые свойства'), 'description' => t("При установке этого флага форма будет содержать только основные поля создаваемого документа, без дополнительных вкладок (вроде настроек доступа и файловых приложений).&nbsp; Это полезно для форм с обратной связью.")), 'publish' => array('type' => 'BoolControl', 'label' => t('Публиковать при создании')), 'createlabel' => array('type' => 'TextLineControl', 'label' => t('Шаблон ссылки на форму'), 'description' => t("Шаблон, по которому формируется текст ссылки на форму создания документа нужного типа.&nbsp; Используется только в случаях, когда конкретный тип не указан, и возможно создание нескольких разных документов.")), 'anonymous' => array('type' => 'BoolControl', 'label' => t('Не работать с типами, недоступными анонимному пользователю')), 'next' => array('type' => 'TextLineControl', 'label' => t('После сохранения переходить на'), 'description' => t('Это значение используется если адрес перехода не указан явно через <tt>?destination</tt>.')));
 }
 /**
  * Возвращает форму для настройки виджета.
  *
  * Форма позволяет выбрать типы документов, используемые для формирования
  * облака.
  *
  * @return Form вкладка с настройками виджета.
  */
 public static function getConfigOptions(Context $ctx)
 {
     $types = Node::getSortedList('type', 'title', 'name');
     return array('hosts' => array('type' => 'SetControl', 'label' => t('Возвращать только для'), 'options' => $types), 'classes' => array('type' => 'SetControl', 'label' => t('Возвращать только следующие типы'), 'options' => $types), 'field' => array('type' => 'TextLineControl', 'label' => t('Привязка к полю')), 'sort' => array('type' => 'EnumControl', 'label' => t('Сортировка'), 'options' => array('name' => t('По имени'), 'created' => t('По дате добавления (сначала старые)'), '-created' => t('По дате добавления (сначала новые)'), '-id' => t('По идентификатору'))));
 }