本文整理汇总了PHP中cmsCore::getTemplates方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsCore::getTemplates方法的具体用法?PHP cmsCore::getTemplates怎么用?PHP cmsCore::getTemplates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cmsCore
的用法示例。
在下文中一共展示了cmsCore::getTemplates方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
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)))));
}
示例2: run
public function run($do = false)
{
// если нужно, передаем управление другому экшену
if ($do) {
$this->runAction('settings_' . $do, array_slice($this->params, 1));
return;
}
$values = $this->cms_config->getAll();
$values['time_zone'] = $values['cfg_time_zone'];
$form = $this->getForm('settings');
if ($this->request->has('submit')) {
$values = array_merge($values, $form->parse($this->request, true));
$errors = $form->validate($this, $values);
if (!$errors) {
if ($values['cache_method'] == 'memory') {
if (!class_exists('Memcache')) {
cmsUser::addSessionMessage(LANG_CP_MEMCACHE_NOT_AVAILABLE, 'error');
$values['cache_method'] = 'files';
}
}
if ($values['cache_method'] == 'memory') {
$memcache_tester = new Memcache();
$memcache_result = @$memcache_tester->connect($values['cache_host'], $values['cache_port']);
if (!$memcache_result) {
cmsUser::addSessionMessage(LANG_CP_MEMCACHE_CONNECT_ERROR, 'error');
$values['cache_method'] = 'files';
}
}
if (!$values['cache_enabled'] && $values['cache_method'] == 'files') {
files_clear_directory($this->cms_config->cache_path . 'data/');
}
$result = $this->cms_config->save($values);
if (!$result) {
$errors = array();
cmsUser::addSessionMessage(LANG_CP_SETTINGS_NOT_WRITABLE, 'error');
} else {
cmsUser::addSessionMessage(LANG_CP_SAVE_SUCCESS, 'success');
$this->redirectToAction('settings');
}
} else {
cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
}
}
$tpls = cmsCore::getTemplates();
foreach ($tpls as $tpl) {
if (file_exists($this->cms_config->root_path . 'templates/' . $tpl . '/options.form.php')) {
$templates_has_options[] = $tpl;
}
}
return $this->cms_template->render('settings', array('templates_has_options' => $templates_has_options, 'do' => 'edit', 'values' => $values, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
}
示例3: run
public function run()
{
if (!$this->request->isAjax()) {
cmsCore::error404();
}
$page_id = $this->request->get('page_id', 0);
$template = $this->request->get('template', '');
if (!is_numeric($page_id)) {
cmsCore::error404();
}
$tpls = cmsCore::getTemplates();
if (!$template || !in_array($template, $tpls)) {
$template = cmsConfig::get('template');
}
$widgets_model = cmsCore::getModel('widgets');
$scheme = $widgets_model->getWidgetBindingsScheme($page_id, $template);
cmsTemplate::getInstance()->renderJSON(array('is_exists' => $scheme !== false, 'scheme' => $scheme));
}
示例4: run
public function run($do = false)
{
// если нужно, передаем управление другому экшену
if ($do) {
$this->runAction('widgets_' . $do, array_slice($this->params, 1));
return;
}
cmsCore::loadAllControllersLanguages();
$widgets_model = cmsCore::getModel('widgets');
$controllers = $widgets_model->getPagesControllers();
$widgets_list = $widgets_model->getAvailableWidgets();
$tpls = cmsCore::getTemplates();
$template_name = $this->request->get('template_name', '');
if (!$template_name || !in_array($template_name, $tpls)) {
$template_name = cmsConfig::get('template');
}
foreach ($tpls as $tpl) {
$templates[$tpl] = $tpl;
}
$scheme_html = $this->getSchemeHTML($template_name);
return $this->cms_template->render('widgets', array('controllers' => $controllers, 'template_name' => $template_name, 'templates' => $templates, 'widgets_list' => $widgets_list, 'scheme_html' => $scheme_html));
}
示例5: run
public function run()
{
if (!$this->request->isAjax()) {
cmsCore::error404();
}
$widget_id = $this->request->get('widget_id', 0);
$page_id = $this->request->get('page_id', 0);
$position = $this->request->get('position', '');
$template = $this->request->get('template', '');
$tpls = cmsCore::getTemplates();
if (!$template || !in_array($template, $tpls)) {
$template = cmsConfig::get('template');
}
$widgets_model = cmsCore::getModel('widgets');
$widget = $widgets_model->getWidget($widget_id);
$binded_id = $widgets_model->addWidgetBinding($widget, $page_id, $position, $template);
$bind_widget = $widgets_model->getWidgetBinding($binded_id);
cmsCore::loadWidgetLanguage($bind_widget['name'], $bind_widget['controller']);
$form = cmsCore::getWidgetOptionsForm($bind_widget['name'], $bind_widget['controller'], false, $bind_widget['template']);
$data = $form->parse(new cmsRequest($bind_widget));
$widgets_model->updateWidgetBinding($binded_id, $data);
$this->cms_template->renderJSON(array('error' => !(bool) $binded_id, 'id' => $binded_id));
}