本文整理汇总了PHP中cmsCore::loadControllerLanguage方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsCore::loadControllerLanguage方法的具体用法?PHP cmsCore::loadControllerLanguage怎么用?PHP cmsCore::loadControllerLanguage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cmsCore
的用法示例。
在下文中一共展示了cmsCore::loadControllerLanguage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run($profile)
{
// проверяем наличие доступа
if ($profile['id'] != $this->cms_user->id && !$this->cms_user->is_admin) {
cmsCore::error404();
}
$form = $this->getForm('password');
$is_submitted = $this->request->has('submit');
$data = array();
if ($is_submitted) {
cmsCore::loadControllerLanguage('auth');
$data = $form->parse($this->request, $is_submitted);
$errors = $form->validate($this, $data);
if (!$errors) {
$password_hash = md5(md5($data['password']) . $this->cms_user->password_salt);
if ($password_hash != $this->cms_user->password) {
$errors = array('password' => LANG_OLD_PASS_INCORRECT);
}
}
if (!$errors) {
$profile = array_merge($profile, $data);
$result = $this->model->updateUser($profile['id'], $profile);
if ($result['success']) {
cmsUser::addSessionMessage(LANG_PASS_CHANGED, 'success');
$this->redirectTo('users', $profile['id']);
} else {
$errors = $result['errors'];
}
}
if ($errors) {
cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
}
}
return $this->cms_template->render('profile_edit_password', array('id' => $profile['id'], 'profile' => $profile, 'data' => $data, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
}
示例2: run
public function run($controller_name)
{
if (!$controller_name) {
cmsCore::error404();
}
$controller_info = $this->model->getControllerInfo($controller_name);
if (!$controller_info) {
// если компонент имеет несколько контроллеров и один из них использует опции другого
$controller_info = cmsEventsManager::hook("admin_{$controller_name}_controller_info", false);
if (!$controller_info) {
cmsCore::error404();
}
}
cmsCore::loadControllerLanguage($controller_info['name']);
$controller_title = string_lang($controller_info['name'] . '_CONTROLLER', $controller_info['title']);
if (!$controller_info['is_backend']) {
return $this->cms_template->render('controllers_edit', array('is_backend' => false, 'ctype' => false, 'controller_name' => $controller_info['name'], 'controller_title' => $controller_title));
}
//
// Загружаем бакенд выбранного контроллера
//
$backend_context = $this->request->isAjax() ? cmsRequest::CTX_AJAX : cmsRequest::CTX_INTERNAL;
$backend_request = new cmsRequest($this->request->getData(), $backend_context);
$backend_controller = $this->loadControllerBackend($controller_info['name'], $backend_request);
// Определяем текущий экшен бакенда
$action_name = sizeof($this->params) > 1 ? $this->params[1] : 'index';
//
// Удаляем из массива параметров название контроллера и экшен
//
if (sizeof($this->params) <= 2) {
$params = array();
} else {
$params = $this->params;
unset($params[0]);
unset($params[1]);
}
// Если запрос пришел по AJAX, то выполняем экшен бакенда сразу же
// иначе он будет выполнен позже, в шаблоне, чтобы тулбары и pathwey бакенда
// вывелись позже, чем админки
if ($this->request->isAjax()) {
$backend_controller->runAction($action_name, $params);
$this->halt();
}
// Подключаем CSS бакенда если он есть
$css_file = $this->cms_template->getStylesFileName($controller_info['name'], 'backend');
if ($css_file) {
$this->cms_template->addCSS($css_file);
}
$this->cms_template->setMenuItems('backend', $backend_controller->getBackendMenu());
return $this->cms_template->render('controllers_edit', array('is_backend' => true, 'ctype' => cmsCore::getModel('content')->getContentTypeByName($backend_controller->maintained_ctype ? $backend_controller->maintained_ctype : $controller_name), 'controller_name' => $controller_info['name'], 'controller_title' => $controller_title, 'params' => $params, 'action_name' => $action_name, 'backend_controller' => $backend_controller));
}
示例3: init
public function init()
{
cmsCore::loadControllerLanguage('tags');
return array(array('type' => 'fieldset', 'title' => LANG_OPTIONS, 'childs' => array(new fieldListMultiple('options:subjects', array('title' => LANG_WD_TAGS_SUBJECTS, 'show_all' => true, 'generator' => function ($item) {
$cts = cmsCore::getModel('content')->getContentTypes();
$items = array();
if ($cts) {
foreach ($cts as $item) {
$items[$item['name']] = $item['title'];
}
}
return $items;
})), new fieldList('options:ordering', array('title' => LANG_WD_TAGS_CLOUD_ORDERING, 'items' => array('tag' => LANG_WD_TAGS_CLOUD_ORDER_BY_TAG, 'frequency' => LANG_WD_TAGS_CLOUD_ORDER_BY_FREQ))), new fieldList('options:style', array('title' => LANG_WD_TAGS_CLOUD_STYLE, 'items' => array('cloud' => LANG_WD_TAGS_CLOUD_STYLE_CLOUD, 'list' => LANG_WD_TAGS_CLOUD_STYLE_LIST))), new fieldNumber('options:max_fs', array('title' => LANG_WD_TAGS_CLOUD_MAX_FS, 'default' => 22)), new fieldNumber('options:min_fs', array('title' => LANG_WD_TAGS_CLOUD_MIN_FS, 'default' => 12)), new fieldNumber('options:min_freq', array('title' => LANG_WD_TAGS_MIN_FREQ, 'default' => 0)), new fieldNumber('options:min_len', array('title' => LANG_WD_TAGS_MIN_LEN, 'units' => LANG_WD_TAGS_MIN_LEN_UNITS, 'default' => 0)), new fieldNumber('options:limit', array('title' => LANG_WD_TAGS_CLOUD_LIMIT, 'default' => 10)), new fieldString('options:colors', array('title' => LANG_WD_TAGS_COLORS, 'hint' => LANG_WD_TAGS_COLORS_HINT, 'default' => '')), new fieldCheckbox('options:shuffle', array('title' => LANG_WD_TAGS_SHUFFLE)))));
}
示例4: run
public function run($controller_name)
{
if (!$controller_name) {
cmsCore::error404();
}
$controller_info = $this->model->getControllerInfo($controller_name);
if (!$controller_info) {
cmsCore::error404();
}
cmsCore::loadControllerLanguage($controller_name);
$controller_title = constant('LANG_' . mb_strtoupper($controller_name) . '_CONTROLLER');
$template = cmsTemplate::getInstance();
if (!$controller_info['is_backend']) {
return $template->render('controllers_edit', array('is_backend' => false, 'controller_name' => $controller_name, 'controller_title' => $controller_title));
}
//
// Загружаем бакенд выбранного контроллера
//
$backend_context = $this->request->isAjax() ? cmsRequest::CTX_AJAX : cmsRequest::CTX_INTERNAL;
$backend_request = new cmsRequest($this->request->getData(), $backend_context);
$backend_controller = $this->loadControllerBackend($controller_name, $backend_request);
// Определяем текущий экшен бакенда
$action_name = sizeof($this->params) > 1 ? $this->params[1] : 'index';
//
// Удаляем из массива параметров название контроллера и экшен
//
if (sizeof($this->params) <= 2) {
$params = array();
} else {
$params = $this->params;
unset($params[0]);
unset($params[1]);
}
// Устанавливаем корень для URL внутри бакенда
$backend_controller->setRootURL($this->name . '/controllers/edit/' . $controller_name);
// Если запрос пришел по AJAX, то выполняем экшен бакенда сразу же
// иначе он будет выполнен позже, в шаблоне, чтобы тулбары и pathwey бакенда
// вывелись позже, чем админки
if ($this->request->isAjax()) {
$backend_controller->runAction($action_name, $params);
$this->halt();
}
// Подключаем CSS бакенда если он есть
$css_file = $template->getStylesFileName($controller_name, 'backend');
if ($css_file) {
$template->addCSS($css_file);
}
$template->setMenuItems('backend', $backend_controller->getBackendMenu());
return $template->render('controllers_edit', array('is_backend' => true, 'controller_name' => $controller_name, 'controller_title' => $controller_title, 'params' => $params, 'action_name' => $action_name, 'backend_controller' => $backend_controller));
}
示例5: save_controller_options
function save_controller_options($controllers)
{
foreach ($controllers as $controller) {
$controller_root_path = cmsConfig::get('root_path') . 'system/controllers/' . $controller . '/';
$form_file = $controller_root_path . 'backend/forms/form_options.php';
$form_name = $controller . 'options';
cmsCore::loadControllerLanguage($controller);
$form = cmsForm::getForm($form_file, $form_name, false);
if ($form) {
$options = $form->parse(new cmsRequest(cmsController::loadOptions($controller)));
cmsCore::getModel('content')->filterEqual('name', $controller)->updateFiltered('controllers', array('options' => $options));
}
}
}
示例6: init
public function init()
{
cmsCore::loadControllerLanguage('users');
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 fieldCheckbox('options:is_detect', array('title' => LANG_WD_AVATAR_DETECT_ACTIVE, 'default' => 1)), new fieldNumber('options:max_items', array('title' => LANG_WD_AVATAR_MAX_ITEMS, 'hint' => LANG_WD_AVATAR_MAX_ITEMS_HINT, 'default' => 0)))));
}
示例7: componentUpdate
private function componentUpdate($manifest)
{
$model = new cmsModel();
$controller_root_path = $this->cms_config->root_path . 'system/controllers/' . $manifest['package']['name'] . '/';
$form_file = $controller_root_path . 'backend/forms/form_options.php';
$form_name = $manifest['package']['name'] . 'options';
cmsCore::loadControllerLanguage($manifest['package']['name']);
$form = cmsForm::getForm($form_file, $form_name, false);
if ($form) {
$options = $form->parse(new cmsRequest(cmsController::loadOptions($manifest['package']['name'])));
} else {
$options = null;
}
$model->filterEqual('name', $manifest['package']['name'])->updateFiltered('controllers', array('title' => $manifest['info']['title'], 'options' => $options, 'author' => isset($manifest['author']['name']) ? $manifest['author']['name'] : LANG_CP_PACKAGE_NONAME, 'url' => isset($manifest['author']['url']) ? $manifest['author']['url'] : null, 'version' => $manifest['version']['major'] . '.' . $manifest['version']['minor'] . '.' . $manifest['version']['build'], 'is_backend' => file_exists($controller_root_path . 'backend.php')));
return 'controllers';
}
示例8: __construct
function __construct($request)
{
$config = cmsConfig::getInstance();
$this->name = mb_strtolower(get_called_class());
$this->root_url = $this->name;
$this->root_path = $config->root_path . 'system/controllers/' . $this->name . '/';
$this->request = $request;
cmsCore::loadControllerLanguage($this->name);
$title_constant = 'LANG_' . strtoupper($this->name) . '_CONTROLLER';
$this->title = defined($title_constant) ? constant($title_constant) : $this->name;
if (cmsCore::isModelExists($this->name)) {
$this->model = cmsCore::getModel($this->name);
}
if ($this->useOptions) {
$this->options = $this->getOptions();
}
}
示例9: run
public function run($ctype_id)
{
if (!$ctype_id) {
cmsCore::error404();
}
$content_model = cmsCore::getModel('content');
$ctype = $content_model->getContentType($ctype_id);
if (!$ctype) {
cmsCore::error404();
}
cmsCore::loadControllerLanguage('content');
$rules = cmsPermissions::getRulesList('content');
$values = cmsPermissions::getPermissions($ctype['name']);
list($ctype, $rules, $values) = cmsEventsManager::hook('content_perms', array($ctype, $rules, $values));
list($ctype, $rules, $values) = cmsEventsManager::hook("content_{$ctype['name']}_perms", array($ctype, $rules, $values));
$users_model = cmsCore::getModel('users');
$groups = $users_model->getGroups(false);
return cmsTemplate::getInstance()->render('ctypes_perms', array('ctype' => $ctype, 'rules' => $rules, 'values' => $values, 'groups' => $groups));
}
示例10: getRulesList
/**
* Возвращает список доступных правил доступа для указанного компонента
* @param string $controller
* @return array
*/
static function getRulesList($controller)
{
$model = new cmsModel();
$model->filterEqual('controller', $controller);
cmsCore::loadControllerLanguage($controller);
$rules = $model->orderBy('name')->get('perms_rules', function ($rule, $model) {
$rule['title'] = constant('LANG_RULE_' . mb_strtoupper($rule['controller']) . '_' . mb_strtoupper($rule['name']));
if ($rule['type'] == 'list' && $rule['options']) {
$rule['options'] = explode(',', $rule['options']);
$options = array();
$options[0] = LANG_PERM_OPTION_NULL;
foreach ($rule['options'] as $id => $option) {
$options[trim($option)] = constant("LANG_PERM_OPTION_" . mb_strtoupper(trim($option)));
}
$rule['options'] = $options;
}
return $rule;
});
return $rules;
}
示例11: run
public function run()
{
if (!$this->request->isAjax()) {
cmsCore::error404();
}
$controller_name = $this->request->get('controller_name');
if (!$controller_name) {
cmsCore::error404();
}
$widgets_model = cmsCore::getModel('widgets');
cmsCore::loadControllerLanguage($controller_name);
$pages = $widgets_model->getControllerPages($controller_name);
$tree_nodes = array();
if ($pages) {
foreach ($pages as $page) {
$tree_nodes[] = array('title' => $page['title'], 'key' => "{$page['controller']}.{$page['id']}", 'isLazy' => false);
}
}
cmsTemplate::getInstance()->renderJSON($tree_nodes);
}
示例12: run
public function run($id)
{
if (!$id) {
cmsCore::error404();
}
$users_model = cmsCore::getModel('users');
$user = $users_model->getUser($id);
if (!$user) {
cmsCore::error404();
}
$form = $this->getForm('user', array('edit'));
$is_submitted = $this->request->has('submit');
if ($is_submitted) {
cmsCore::loadControllerLanguage('auth');
$user = $form->parse($this->request, $is_submitted);
if (!$user['is_locked']) {
$user['lock_until'] = null;
$user['lock_reason'] = null;
}
$errors = $form->validate($this, $user);
if (!$errors) {
$result = $users_model->updateUser($id, $user);
if ($result['success']) {
$back_url = $this->request->get('back');
if ($back_url) {
$this->redirect($back_url);
} else {
$this->redirectToAction('users');
}
} else {
$errors = $result['errors'];
}
}
if ($errors) {
cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
}
}
return cmsTemplate::getInstance()->render('user', array('do' => 'edit', 'user' => $user, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
}
示例13: run
public function run($id)
{
if (!$id) {
cmsCore::error404();
}
$wizard_mode = $this->request->get('wizard_mode');
$form = $this->getForm('ctypes_labels');
$is_submitted = $this->request->has('submit');
$content_model = cmsCore::getModel('content');
$ctype = $content_model->getContentType($id);
if (!$ctype) {
cmsCore::error404();
}
cmsCore::loadControllerLanguage('content');
if ($is_submitted) {
$ctype = array_merge($ctype, $form->parse($this->request, $is_submitted));
$errors = $form->validate($this, $ctype);
if (!$errors) {
$content_model->updateContentType($id, $ctype);
$activity_controller = cmsCore::getController('activity');
if ($activity_controller->isTypeExists('content', "add.{$ctype['name']}")) {
$activity_controller->updateType('content', "add.{$ctype['name']}", array('title' => sprintf(LANG_CONTENT_ACTIVITY_ADD, $ctype['labels']['many']), 'description' => sprintf(LANG_CONTENT_ACTIVITY_ADD_DESC, $ctype['labels']['create'], '%s')));
} else {
$activity_controller->addType(array('controller' => 'content', 'name' => "add.{$ctype['name']}", 'title' => sprintf(LANG_CONTENT_ACTIVITY_ADD, $ctype['labels']['many']), 'description' => sprintf(LANG_CONTENT_ACTIVITY_ADD_DESC, $ctype['labels']['create'], '%s')));
}
if ($wizard_mode) {
$this->redirectToAction('ctypes', array('fields', $id), array('wizard_mode' => true));
} else {
$this->redirectToAction('ctypes');
}
}
if ($errors) {
cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
}
}
return cmsTemplate::getInstance()->render('ctypes_labels', array('id' => $id, 'ctype' => $ctype, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
}
示例14: __construct
public function __construct($controller, $params = array())
{
parent::__construct($controller, $params);
cmsCore::loadControllerLanguage('content');
}
示例15: install_package
//.........这里部分代码省略.........
$core->db->dropIndex($table, $index_name);
}
}
// добавляем нужные
foreach ($add_table_indexes as $table => $indexes) {
foreach ($indexes as $index_name => $fields) {
$core->db->addIndex($table, $fields, $index_name);
}
}
//************************************************************************//
// типы контента
$ctypes = $content_model->getContentTypes();
$varchar_fields = array('seo_keys', 'seo_desc', 'seo_title');
$remove_ctype_indexes = array('_cats' => array('ns_left', 'ns_right', 'ns_differ', 'ns_ignore', 'parent_id'), '_props_bind' => array('cat_id', 'ordering'), '' => array('date_pub', 'user_id', 'parent_id', 'parent_type', 'is_comments_on', 'is_approved', 'date_approved', 'comments', 'rating', 'is_private', 'is_parent_hidden', 'photos_count', 'date_pub_end', 'date_last_modified', 'title'));
$add_ctype_indexes = array('_cats' => array('ns_left' => array('ns_level', 'ns_right', 'ns_left'), 'parent_id' => array('parent_id', 'ns_left')), '_props_bind' => array('ordering' => array('cat_id', 'ordering')), '' => array('date_pub' => array('is_pub', 'is_parent_hidden', 'is_approved', 'date_pub'), 'parent_id' => array('parent_id', 'parent_type', 'date_pub'), 'user_id' => array('user_id', 'date_pub'), 'date_pub_end' => array('date_pub_end')));
$add_ctype_fulltext_indexes = array('' => array('title' => array('title')));
foreach ($ctypes as $ctype) {
// меняем типы сео полям
foreach ($varchar_fields as $varchar_field) {
$core->db->query("ALTER TABLE `{#}{$content_model->table_prefix}{$ctype['name']}` CHANGE `{$varchar_field}` `{$varchar_field}` VARCHAR( 256 ) NULL DEFAULT NULL;");
$core->db->query("ALTER TABLE `{#}{$content_model->table_prefix}{$ctype['name']}_cats` CHANGE `{$varchar_field}` `{$varchar_field}` VARCHAR( 256 ) NULL DEFAULT NULL;");
}
// комментарии по умолчанию включены
$core->db->query("ALTER TABLE `{#}{$content_model->table_prefix}{$ctype['name']}` CHANGE `is_comments_on` `is_comments_on` TINYINT( 1 ) UNSIGNED NULL DEFAULT '1'");
// для текущих записей включаем их
$core->db->query("UPDATE `{#}{$content_model->table_prefix}{$ctype['name']}` SET `is_comments_on` = '1'");
// удаляем ненужные индексы
foreach ($remove_ctype_indexes as $table_postfix => $rcci) {
foreach ($rcci as $index_name) {
$core->db->dropIndex($content_model->table_prefix . $ctype['name'] . $table_postfix, $index_name);
}
}
// добавляем нужные обычные индексы
foreach ($add_ctype_indexes as $table_postfix => $indexes) {
foreach ($indexes as $index_name => $fields) {
$core->db->addIndex($content_model->table_prefix . $ctype['name'] . $table_postfix, $fields, $index_name);
}
}
// добавляем FULLTEXT индексы только для поля title. остальные поля включаются в индекс в настройках
foreach ($add_ctype_fulltext_indexes as $table_postfix => $fulltext_indexes) {
foreach ($fulltext_indexes as $index_name => $fields) {
$core->db->addIndex($content_model->table_prefix . $ctype['name'] . $table_postfix, $fields, $index_name, 'FULLTEXT');
}
}
}
if (!$core->db->isFieldExists('content_datasets', 'index')) {
$core->db->query("ALTER TABLE `{#}content_datasets` ADD `index` VARCHAR(40) NULL DEFAULT NULL COMMENT 'Название используемого индекса' AFTER `sorting`, ADD INDEX (`index`);");
}
if (!$core->db->isFieldExists('controllers', 'is_external')) {
$core->db->query("ALTER TABLE `{#}controllers` ADD `is_external` TINYINT(1) UNSIGNED NULL DEFAULT NULL COMMENT 'Сторонний компонент' AFTER `is_backend`");
}
if (!$core->db->isFieldExists('rss_feeds', 'template')) {
$core->db->query("ALTER TABLE `{#}rss_feeds` ADD `template` VARCHAR(30) NOT NULL DEFAULT 'feed' COMMENT 'Шаблон ленты';");
}
if (!$core->db->isFieldExists('images_presets', 'quality')) {
$core->db->query("ALTER TABLE `{#}images_presets` ADD `quality` TINYINT(1) NOT NULL DEFAULT '90';");
}
if (!$core->db->getRowsCount('perms_rules', "controller = 'content' AND name = 'disable_comments'", 1)) {
$core->db->query("INSERT INTO `{#}perms_rules` (`controller`,`name`,`type`,`options`) VALUES ('content','disable_comments','flag', NULL)");
}
$core->db->query("UPDATE `{#}perms_rules` SET `options` = 'own,all,full_delete' WHERE controller = 'comments' AND name = 'delete'");
// для всех датасетов создаем индексы, если нужно
$datasets = $content_model->select('ct.name', 'ctype_name')->joinInner('content_types', 'ct', 'ct.id = i.ctype_id')->get('content_datasets', function ($item, $model) {
$item['filters'] = cmsModel::yamlToArray($item['filters']);
$item['sorting'] = cmsModel::yamlToArray($item['sorting']);
return $item;
});
if ($datasets) {
foreach ($datasets as $dataset) {
$index = $content_model->addContentDatasetIndex($dataset, $dataset['ctype_name']);
$content_model->update('content_datasets', $dataset['id'], array('index' => $index), true);
}
}
$config = cmsConfig::getInstance();
$values = $config->getAll();
$values['db_engine'] = 'InnoDB';
if (!$config->save($values)) {
cmsUser::addSessionMessage('Не могу записать файл конфигурации сайта. Добавьте в него строку <b>"db_engine" => "InnoDB",</b>', 'info');
}
// если вдруг для каких то компонентов нет конфига в таблице cms_controllers
// пропускаем компонент карты сайта, т.к. там конфиг динамический
// будем надеяться, что опции в нем хоть раз сохранялись =)
$controllers = $content_model->filterNotEqual('name', 'sitemap')->get('controllers', function ($item, $model) {
$item['options'] = cmsModel::yamlToArray($item['options']);
return $item;
}, 'name');
foreach ($controllers as $controller) {
$controller_root_path = cmsConfig::get('root_path') . 'system/controllers/' . $controller['name'] . '/';
$form_file = $controller_root_path . 'backend/forms/form_options.php';
$form_name = $controller['name'] . 'options';
cmsCore::loadControllerLanguage($controller['name']);
$form = cmsForm::getForm($form_file, $form_name, false);
if ($form) {
$options = $form->parse(new cmsRequest(cmsController::loadOptions($controller['name'])));
} else {
$options = null;
}
$content_model->filterEqual('name', $controller['name'])->updateFiltered('controllers', array('options' => $options));
}
}