public function init($options, $template_name) { return array(array('type' => 'fieldset', 'title' => LANG_OPTIONS, 'childs' => array(new fieldList('options:menu', array('title' => LANG_MENU, 'generator' => function ($item) { $menu_model = cmsCore::getModel('menu'); $tree = $menu_model->getMenus(); $items = array(); if ($tree) { foreach ($tree as $item) { $items[$item['name']] = $item['title']; } } return $items; })), new fieldList('options:template', array('title' => LANG_WD_MENU_TEMPLATE, 'hint' => LANG_WD_MENU_TEMPLATE_HINT, 'generator' => function ($item) use($template_name) { $default_tpls = cmsCore::getFilesList('templates/default/assets/ui/', 'menu*.tpl.php'); $current_tpls = cmsCore::getFilesList('templates/' . $template_name . '/assets/ui/', 'menu*.tpl.php'); $tpls = array_unique(array_merge($current_tpls, $default_tpls)); $items = array(); if ($tpls) { foreach ($tpls as $tpl) { $items[str_replace('.tpl.php', '', $tpl)] = str_replace('.tpl.php', '', $tpl); } } return $items; })), new fieldCheckbox('options:is_detect', array('title' => LANG_WD_MENU_DETECT_ACTIVE, 'default' => 1)), new fieldNumber('options:max_items', array('title' => LANG_WD_MENU_MAX_ITEMS, 'hint' => LANG_WD_MENU_MAX_ITEMS_HINT, 'default' => 0))))); }
public function init() { $is_css_cache = cmsCore::getFilesList('cache/static/css', '*.css'); $is_js_cache = cmsCore::getFilesList('cache/static/js', '*.js'); return array(array('type' => 'fieldset', 'title' => LANG_CP_SETTINGS_SITE, 'childs' => array(new fieldCheckbox('is_site_on', array('title' => LANG_CP_SETTINGS_SITE_ENABLED)), new fieldString('off_reason', array('title' => LANG_CP_SETTINGS_SITE_REASON)), new fieldString('sitename', array('title' => LANG_CP_SETTINGS_SITENAME, 'rules' => array(array('required')))), new fieldString('hometitle', array('title' => LANG_CP_SETTINGS_HOMETITLE, 'rules' => array(array('required')))), new fieldList('frontpage', array('title' => LANG_CP_SETTINGS_FP_SHOW, 'generator' => function ($item) { $items = array('none' => LANG_CP_SETTINGS_FP_SHOW_NONE, 'profile' => LANG_CP_SETTINGS_FP_SHOW_PROFILE); $ctypes = cmsCore::getModel('content')->getContentTypes(); if ($ctypes) { foreach ($ctypes as $ctype) { if (!$ctype['options']['list_on']) { continue; } $items["content:{$ctype['name']}"] = sprintf(LANG_CP_SETTINGS_FP_SHOW_CONTENT, $ctype['title']); } } return $items; })), new fieldList('ctype_default', array('title' => LANG_CP_SETTINGS_CTYPE_DEF, 'hint' => LANG_CP_SETTINGS_CTYPE_DEF_HINT, 'generator' => function ($item) { $ctypes = cmsCore::getModel('content')->getContentTypes(); $items[''] = ''; if ($ctypes) { foreach ($ctypes as $ctype) { $items[$ctype['name']] = $ctype['title']; } } return $items; })), new fieldString('metakeys', array('title' => LANG_CP_SETTINGS_METAKEYS)), new fieldText('metadesc', array('title' => LANG_CP_SETTINGS_METADESC)), new fieldCheckbox('is_no_meta', array('title' => LANG_CP_SETTINGS_META_NO_DEFAULT)), new fieldCheckbox('is_sitename_in_title', array('title' => LANG_CP_SETTINGS_IS_SITENAME_IN_TITLE, 'default' => 1)), new fieldCheckbox('is_check_updates', array('title' => LANG_CP_SETTINGS_CHECK_UPDATES)), new fieldString('detect_ip_key', array('title' => LANG_CP_SETTINGS_DETECT_IP_KEY, 'hint' => LANG_CP_SETTINGS_DETECT_IP_KEY_HINT, 'default' => 'REMOTE_ADDR')))), array('type' => 'fieldset', 'title' => LANG_CP_SETTINGS_GUI, 'childs' => array(new fieldList('language', array('title' => LANG_CP_SETTINGS_LANGUAGE, 'generator' => function ($item) { $langs = cmsCore::getLanguages(); $items = array(); if ($langs) { foreach ($langs as $lang) { $items[$lang] = mb_strtoupper($lang); } } return $items; })), new fieldList('template', array('title' => LANG_CP_SETTINGS_TEMPLATE, 'hint' => '<a href="#" data-url="' . href_to('admin', 'settings', 'theme') . '">' . LANG_CP_SETTINGS_TEMPLATE_OPTIONS . '</a>', 'generator' => function ($item) { $tpls = cmsCore::getTemplates(); $items = array(); if ($tpls) { foreach ($tpls as $tpl) { $items[$tpl] = $tpl; } } return $items; })), new fieldList('default_editor', array('title' => LANG_CP_SETTINGS_EDITOR, 'default' => 'redactor', 'generator' => function ($item) { $items = array(); $editors = cmsCore::getWysiwygs(); foreach ($editors as $editor) { $items[$editor] = $editor; } return $items; })), new fieldCheckbox('show_breadcrumbs', array('title' => LANG_CP_SETTINGS_SHOW_BREADCRUMBS, 'default' => 1)), new fieldCheckbox('min_html', array('title' => LANG_CP_SETTINGS_HTML_MINIFY)), new fieldCheckbox('merge_css', array('title' => LANG_CP_SETTINGS_MERGE_CSS, 'hint' => $is_css_cache ? sprintf(LANG_CP_SETTINGS_CACHE_CLEAN_MERGED, href_to('admin', 'clear_cache', 'css')) : false)), new fieldCheckbox('merge_js', array('title' => LANG_CP_SETTINGS_MERGE_JS, 'hint' => $is_js_cache ? sprintf(LANG_CP_SETTINGS_CACHE_CLEAN_MERGED, href_to('admin', 'clear_cache', 'js')) : false)))), array('type' => 'fieldset', 'title' => LANG_CP_SETTINGS_DATE, 'childs' => array(new fieldList('time_zone', array('title' => LANG_CP_SETTINGS_TIMEZONE, 'generator' => function ($item) { return cmsCore::getTimeZones(); })), new fieldString('date_format', array('title' => LANG_CP_SETTINGS_DATE_FORMAT, 'rules' => array(array('required')))), new fieldString('date_format_js', array('title' => LANG_CP_SETTINGS_DATE_FORMAT_JS, 'rules' => array(array('required')))))), array('type' => 'fieldset', 'title' => LANG_CP_SETTINGS_MAIL, 'childs' => array(new fieldList('mail_transport', array('title' => LANG_CP_SETTINGS_MAIL_TRANSPORT, 'items' => array('mail' => 'PHP mail()', 'smtp' => 'SMTP', 'sendmail' => 'Sendmail'))), new fieldString('mail_from', array('title' => LANG_CP_SETTINGS_MAIL_FROM, 'rules' => array(array('required')))), new fieldString('mail_from_name', array('title' => LANG_CP_SETTINGS_MAIL_FROM_NAME)), new fieldString('mail_smtp_server', array('title' => LANG_CP_SETTINGS_MAIL_SMTP_HOST)), new fieldNumber('mail_smtp_port', array('title' => LANG_CP_SETTINGS_MAIL_SMTP_PORT)), new fieldCheckbox('mail_smtp_auth', array('title' => LANG_CP_SETTINGS_MAIL_SMTP_AUTH)), new fieldString('mail_smtp_user', array('title' => LANG_CP_SETTINGS_MAIL_SMTP_USER)), new fieldString('mail_smtp_pass', array('title' => LANG_CP_SETTINGS_MAIL_SMTP_PASS, 'is_password' => true)), new fieldList('mail_smtp_enc', array('title' => LANG_CP_SETTINGS_MAIL_SMTP_ENC, 'items' => array(0 => LANG_CP_SETTINGS_MAIL_SMTP_ENC_NO, 'ssl' => LANG_CP_SETTINGS_MAIL_SMTP_ENC_SSL, 'tls' => LANG_CP_SETTINGS_MAIL_SMTP_ENC_TLS))))), array('type' => 'fieldset', 'title' => LANG_CP_SETTINGS_CACHE, 'childs' => array(new fieldCheckbox('cache_enabled', array('title' => LANG_CP_SETTINGS_CACHE_ENABLED)), new fieldNumber('cache_ttl', array('title' => LANG_CP_SETTINGS_CACHE_TTL)), new fieldList('cache_method', array('title' => LANG_CP_SETTINGS_CACHE_METHOD, 'items' => array('files' => 'Files', 'memory' => 'Memcached' . (extension_loaded('memcache') ? '' : ' (' . LANG_CP_SETTINGS_CACHE_METHOD_NO . ')')))), new fieldString('cache_host', array('title' => LANG_CP_SETTINGS_CACHE_HOST)), new fieldNumber('cache_port', array('title' => LANG_CP_SETTINGS_CACHE_PORT)))), array('type' => 'fieldset', 'title' => LANG_CP_SETTINGS_DEBUG, 'childs' => array(new fieldCheckbox('debug', array('title' => LANG_CP_SETTINGS_DEBUG_MODE)), new fieldCheckbox('emulate_lag', array('title' => LANG_CP_SETTINGS_EMULATE_LAG)))), array('type' => 'fieldset', 'title' => LANG_CP_SETTINGS_SECURITY, 'childs' => array(new fieldText('allow_ips', array('title' => LANG_CP_SETTINGS_ALLOW_IPS, 'hint' => LANG_CP_SETTINGS_ALLOW_IPS_HINT))))); }
public function init() { return array('basic' => array('type' => 'fieldset', 'title' => LANG_RSS_FEED_BASIC, 'childs' => array(new fieldCheckbox('is_enabled', array('title' => LANG_RSS_FEED_ENABLED)), new fieldString('description', array('title' => LANG_RSS_FEED_DESC)), new fieldNumber('limit', array('title' => LANG_RSS_FEED_LIMIT, 'rules' => array(array('required'), array('digits'), array('min', 1), array('max', 50)))), new fieldList('template', array('title' => LANG_RSS_FEED_TEMPLATE, 'hint' => LANG_RSS_FEED_TEMPLATE_HINT, 'generator' => function ($item) { $tpls = cmsCore::getFilesList('templates/' . cmsConfig::get('template') . '/controllers/rss/', '*.tpl.php'); $items = array(); if ($tpls) { foreach ($tpls as $tpl) { $items[str_replace('.tpl.php', '', $tpl)] = $tpl; } } return $items; })))), 'image' => array('type' => 'fieldset', 'title' => LANG_RSS_FEED_IMAGE, 'childs' => array(new fieldImage('image', array()))), 'cache' => array('type' => 'fieldset', 'title' => LANG_RSS_FEED_CACHING, 'childs' => array(new fieldCheckbox('is_cache', array('title' => LANG_RSS_FEED_CACHE)), new fieldNumber('cache_interval', array('title' => LANG_RSS_FEED_CACHE_INT, 'rules' => array(array('digits'), array('min', 1))))))); }
/** * Возвращает все названия шаблонов для списка записей типов контента * @return array|boolean */ public function getAvailableContentListStyles() { $files = cmsCore::getFilesList('templates/' . $this->name . '/content', 'default_list*.tpl.php', true); if (!$files) { return false; } $styles = array(); foreach ($files as $file) { preg_match('/^default_list_([a-z0-9_\\-]*)\\.tpl$/i', $file, $matches); if (!$matches) { $styles[''] = 'default_list (' . LANG_CP_LISTVIEW_STYLE_BASIC . ')'; } else { $constant_name = 'LANG_CP_LISTVIEW_STYLE_' . mb_strtoupper($matches[1]); $title = defined($constant_name) ? '(' . constant($constant_name) . ')' : ''; $styles[$matches[1]] = pathinfo($file, PATHINFO_FILENAME) . $title; } } return $styles; }
public static function getWidgetOptionsForm($widget_name, $controller_name = false, $options = false, $template = false) { $template = $template ? $template : cmsConfig::get('template'); $widget_path = self::getWidgetPath($widget_name, $controller_name); $path = cmsConfig::get('system_path') . $widget_path; $form_file = $path . '/options.form.php'; $form_name = 'widget' . ($controller_name ? "_{$controller_name}_" : '_') . "{$widget_name}_options"; $form = cmsForm::getForm($form_file, $form_name, array($options, $template)); if (!$form) { $form = new cmsForm(); } $form->is_tabbed = true; // // Опции внешнего вида // $design_fieldset_id = $form->addFieldset(LANG_DESIGN); $form->addField($design_fieldset_id, new fieldString('class_wrap', array('title' => LANG_CSS_CLASS_WRAP))); $form->addField($design_fieldset_id, new fieldString('class_title', array('title' => LANG_CSS_CLASS_TITLE))); $form->addField($design_fieldset_id, new fieldString('class', array('title' => LANG_CSS_CLASS_BODY))); $form->addField($design_fieldset_id, new fieldList('tpl_wrap', array('title' => LANG_WIDGET_WRAPPER_TPL, 'hint' => LANG_WIDGET_WRAPPER_TPL_HINT, 'generator' => function ($item) use($template) { $current_tpls = cmsCore::getFilesList('templates/' . $template . '/widgets', '*.tpl.php'); $default_tpls = cmsCore::getFilesList('templates/default/widgets', '*.tpl.php'); $tpls = array_unique(array_merge($current_tpls, $default_tpls)); $items = array(); if ($tpls) { foreach ($tpls as $tpl) { $items[str_replace('.tpl.php', '', $tpl)] = str_replace('.tpl.php', '', $tpl); } } return $items; }))); $form->addField($design_fieldset_id, new fieldList('tpl_body', array('title' => LANG_WIDGET_BODY_TPL, 'hint' => sprintf(LANG_WIDGET_BODY_TPL_HINT, $widget_path), 'generator' => function ($item) use($template) { $w_path = cmsCore::getWidgetPath($item['name'], $item['controller']); $current_tpls = cmsCore::getFilesList('templates/' . $template . '/' . $w_path, '*.tpl.php'); $default_tpls = cmsCore::getFilesList('templates/default/' . $w_path, '*.tpl.php'); $tpls = array_unique(array_merge($current_tpls, $default_tpls)); $items = array(); if ($tpls) { foreach ($tpls as $tpl) { $items[str_replace('.tpl.php', '', $tpl)] = str_replace('.tpl.php', '', $tpl); } } return $items; }))); // // Опции доступа // $access_fieldset_id = $form->addFieldset(LANG_PERMISSIONS); // Показывать группам $form->addField($access_fieldset_id, new fieldListGroups('groups_view', array('title' => LANG_SHOW_TO_GROUPS, 'show_all' => true, 'show_guests' => true))); // Не показывать группам $form->addField($access_fieldset_id, new fieldListGroups('groups_hide', array('title' => LANG_HIDE_FOR_GROUPS, 'show_all' => false, 'show_guests' => true))); // // Опции заголовка // $title_fieldset_id = $form->addFieldsetToBeginning(LANG_BASIC_OPTIONS); // ID виджета $form->addField($title_fieldset_id, new fieldNumber('id', array('is_hidden' => true))); // Заголовок виджета $form->addField($title_fieldset_id, new fieldString('title', array('title' => LANG_TITLE, 'rules' => array(array('required'), array('min_length', 3), array('max_length', 128))))); // Флаг показа заголовка $form->addField($title_fieldset_id, new fieldCheckbox('is_title', array('title' => LANG_SHOW_TITLE, 'default' => true))); // Флаг объединения с предыдущим виджетом $form->addField($title_fieldset_id, new fieldCheckbox('is_tab_prev', array('title' => LANG_WIDGET_TAB_PREV, 'default' => false))); // Ссылки в заголовке $form->addField($title_fieldset_id, new fieldText('links', array('title' => LANG_WIDGET_TITLE_LINKS, 'hint' => LANG_WIDGET_TITLE_LINKS_HINT))); return $form; }
/** * Возвращает список всех имеющихся типов полей * @return array */ public static function getAvailableFormFields($only_public = true) { $fields_types = array(); $fields_files = cmsCore::getFilesList('system/fields', '*.php', true, true); foreach ($fields_files as $name) { $class = 'field' . string_to_camel('_', $name); $field = new $class(null, null); if ($only_public && !$field->is_public) { continue; } $fields_types[$name] = $field->getTitle(); } return $fields_types; }
/** * Возвращает все названия шаблонов для списка записей типов контента * @return array */ public function getAvailableContentListStyles() { $styles = $files = array(); $inherit_names = array('default'); if (file_exists($this->site_config->root_path . 'templates/' . $this->site_config->template . '/inherit.php')) { $names = (include $this->site_config->root_path . 'templates/' . $this->site_config->template . '/inherit.php'); if ($names) { foreach ($names as $name) { $inherit_names[] = $name; } } } if ($this->site_config->template !== 'default') { $inherit_names[] = $this->site_config->template; } $inherit_names = array_reverse($inherit_names); foreach ($inherit_names as $name) { $_files = cmsCore::getFilesList('templates/' . $name . '/content', 'default_list*.tpl.php', true); $files = array_merge($files, $_files); } $files = array_unique($files); if (!$files) { return $styles; } foreach ($files as $file) { preg_match('/^default_list_([a-z0-9_\\-]*)\\.tpl$/i', $file, $matches); if (!$matches) { $styles[''] = 'default_list (' . LANG_CP_LISTVIEW_STYLE_BASIC . ')'; } else { $constant_name = 'LANG_CP_LISTVIEW_STYLE_' . mb_strtoupper($matches[1]); $title = defined($constant_name) ? '(' . constant($constant_name) . ')' : ''; $styles[$matches[1]] = pathinfo($file, PATHINFO_FILENAME) . $title; } } return $styles; }