本文整理汇总了PHP中cmsCore::isControllerExists方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsCore::isControllerExists方法的具体用法?PHP cmsCore::isControllerExists怎么用?PHP cmsCore::isControllerExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cmsCore
的用法示例。
在下文中一共展示了cmsCore::isControllerExists方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$form = $this->getForm('ctypes_basic', array('add'));
$form = cmsEventsManager::hook('ctype_basic_form', $form);
$is_submitted = $this->request->has('submit');
$ctype = $form->parse($this->request, $is_submitted);
if ($is_submitted) {
$errors = $form->validate($this, $ctype);
if (!$errors) {
if (cmsCore::isControllerExists($ctype['name'])) {
$errors['name'] = LANG_CP_CTYPE_ERROR_NAME;
}
}
if (!$errors) {
$content_model = cmsCore::getModel('content');
$ctype = cmsEventsManager::hook('ctype_before_add', $ctype);
$ctype = cmsEventsManager::hook("ctype_{$ctype['name']}_before_add", $ctype);
$ctype_id = $content_model->addContentType($ctype);
$ctype['id'] = $ctype_id;
cmsEventsManager::hook('ctype_after_add', $ctype);
cmsEventsManager::hook("ctype_{$ctype['name']}_after_add", $ctype);
if ($ctype_id) {
cmsCore::getController('content')->addWidgetsPages($ctype);
cmsUser::addSessionMessage(sprintf(LANG_CP_CTYPE_CREATED, $ctype['title']), 'success');
}
$this->redirectToAction('ctypes', array('labels', $ctype_id), array('wizard_mode' => true));
}
if ($errors) {
cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
}
}
return $this->cms_template->render('ctypes_basic', array('do' => 'add', 'ctype' => $ctype, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
}
示例2: run
public function run($id)
{
if (!$id) {
cmsCore::error404();
}
$content_model = cmsCore::getModel('content');
$ctype = $content_model->getContentType($id);
if (!$ctype) {
cmsCore::error404();
}
$form = $this->getForm('ctypes_basic', array('edit'));
$form = cmsEventsManager::hook('ctype_basic_form', $form);
$form = cmsEventsManager::hook('ctype_basic_' . $ctype['name'] . '_form', $form);
$form->hideField('titles', 'name');
$ctype = cmsEventsManager::hook('ctype_before_edit', $ctype);
// Если есть собственный шаблон для типа контента
// то удаляем поле выбора стиля
$tpl_file = $this->cms_template->getTemplateFileName('content/' . $ctype['name'] . '_list', true);
if ($tpl_file) {
$form->removeField('listview', 'options:list_style');
}
if ($this->request->has('submit')) {
$ctype = $form->parse($this->request, true);
$errors = $form->validate($this, $ctype);
if (!$errors) {
$ctype = cmsEventsManager::hook("ctype_before_update", $ctype);
$ctype = cmsEventsManager::hook("ctype_{$ctype['name']}_before_update", $ctype);
$content_model->updateContentType($id, $ctype);
$ctype['id'] = $id;
cmsEventsManager::hook("ctype_after_update", $ctype);
cmsEventsManager::hook("ctype_{$ctype['name']}_after_update", $ctype);
cmsUser::addSessionMessage(LANG_CP_SAVE_SUCCESS, 'success');
$this->redirectToAction('ctypes');
}
if ($errors) {
cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
}
}
// проверяем, есть ли нативный контроллер и есть ли у него опции
$is_controller = false;
if (cmsCore::isControllerExists($ctype['name'])) {
if (cmsCore::getController($ctype['name'])->options) {
$is_controller = true;
}
}
return $this->cms_template->render('ctypes_basic', array('is_controller' => $is_controller, 'id' => $id, 'do' => 'edit', 'ctype' => $ctype, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
}
示例3: install_package
/**
* 2.6.0 => 2.6.1
*/
function install_package()
{
$core = cmsCore::getInstance();
$content_model = cmsCore::getModel('content');
$ctypes = $content_model->getContentTypes();
foreach ($ctypes as $ctype) {
if ($ctype['name'] == 'video' && cmsCore::isControllerExists('video')) {
if (isFieldExists("{$content_model->table_prefix}video_cats", 'desc') && !isFieldExists("{$content_model->table_prefix}video_cats", 'description')) {
$content_model->db->query("ALTER TABLE `{#}{$content_model->table_prefix}video_cats` CHANGE `desc` `description` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL");
}
continue;
}
if (!isFieldExists("{$content_model->table_prefix}{$ctype['name']}_cats", 'description')) {
$content_model->db->query("ALTER TABLE `{#}{$content_model->table_prefix}{$ctype['name']}_cats` ADD `description` TEXT NULL DEFAULT NULL");
}
}
return true;
}
示例4: run
public function run($id = false)
{
if (!$id) {
cmsCore::error404();
}
$task = $this->model->getSchedulerTask($id);
// Проверяем существование контроллера
if (!cmsCore::isControllerExists($task['controller'])) {
cmsUser::addSessionMessage(sprintf(LANG_CP_SCHEDULER_TASK_RUN_FAIL, $task['title']), 'error');
$this->redirectBack();
}
$controller = cmsCore::getController($task['controller']);
// Выполняем хук
$controller->runHook("cron_{$task['hook']}");
// Обновляем время последнего запуска задачи
$this->model->updateSchedulerTaskDate($task['id']);
cmsUser::addSessionMessage(sprintf(LANG_CP_SCHEDULER_TASK_RAN, $task['title'], html_date_time()));
$this->redirectBack();
}
示例5: run
public function run($ctype_name = false)
{
if (!$ctype_name || $this->validate_sysname($ctype_name) !== true) {
cmsCore::error404();
}
$feed = $this->model->getFeedByCtypeName($ctype_name);
if (!$feed || !$feed['is_enabled']) {
cmsCore::error404();
}
if ($feed['is_cache']) {
$this->cache_file_path = cmsConfig::get('cache_path') . 'rss/' . md5($ctype_name . serialize($this->request->getData())) . '.rss';
if ($this->isDisplayCached($feed)) {
return $this->displayCached();
}
}
if ($this->model->isCtypeFeed($ctype_name)) {
$ctype_name = 'content';
}
if (!cmsCore::isControllerExists($ctype_name)) {
cmsCore::error404();
}
$controller = cmsCore::getController($ctype_name, $this->request);
if (!$controller->isEnabled()) {
cmsCore::error404();
}
$data = $controller->runHook('rss_feed_list', array($feed));
if ($data === $this->request) {
cmsCore::error404();
}
list($feed, $category, $author) = $data;
header('Content-type: application/rss+xml; charset=utf-8');
$rss = $this->cms_template->getRenderedChild($feed['template'], array('feed' => $feed, 'category' => $category, 'author' => $author));
if ($feed['is_cache']) {
$this->cacheRss($rss);
}
$this->halt($rss);
}
示例6: array
// Подключение модели
$model = cmsCore::getModel('admin');
// Получение списка задач для выполнения
$tasks = $model->getPendingSchedulerTasks();
// Если задач нет, выходим
if (!$tasks) {
exit;
}
// Коллекция контроллеров
$controllers = array();
//
// Выполняем задачи по списку
//
foreach ($tasks as $task) {
// Проверяем существование контроллера
if (!cmsCore::isControllerExists($task['controller'])) {
continue;
}
// Получаем контроллер из коллекции либо загружаем
// и сохраняем в коллекцию
if (isset($controllers[$task['controller']])) {
$controller = $controllers[$task['controller']];
} else {
$controller = cmsCore::getController($task['controller']);
$controllers[$task['controller']] = $controller;
}
// Выполняем хук
$controller->runHook("cron_{$task['hook']}");
// Обновляем время последнего запуска задачи
$model->updateSchedulerTaskDate($task['id']);
}
示例7: run
public function run()
{
if (!$this->request->isAjax()) {
cmsCore::error404();
}
$action = $this->request->get('action', '');
$csrf_token = $this->request->get('csrf_token', '');
$controller_name = $this->request->get('pc', '');
$profile_type = $this->request->get('pt', '');
$profile_id = $this->request->get('pi', '');
$parent_id = $this->request->get('parent_id', '');
$entry_id = $this->request->get('id', '');
$content = $this->request->get('content', '');
// Проверяем валидность
$is_valid = $controller_name && $profile_type && $action && $this->validate_sysname($controller_name) === true && $this->validate_sysname($profile_type) === true && is_numeric($profile_id) && is_numeric($parent_id) && (!$entry_id || is_numeric($entry_id)) && cmsForm::validateCSRFToken($csrf_token, false) && in_array($action, array('add', 'preview', 'update'));
if (!$is_valid) {
return $this->error();
}
if (!cmsCore::isControllerExists($controller_name)) {
return $this->error();
}
// какой контроллер обслуживаем
$controller = cmsCore::getController($controller_name);
//
// Получаем права доступа
//
$permissions = $controller->runHook('wall_permissions', array('profile_type' => $profile_type, 'profile_id' => $profile_id));
if (!$permissions || !is_array($permissions)) {
return $this->error();
}
// Типографируем текст
$content_html = cmsEventsManager::hook('html_filter', $content);
if ($this->validate_required($content_html) !== true) {
return $this->error(ERR_VALIDATE_REQUIRED);
}
//
// Превью записи
//
if ($action == 'preview') {
return $this->cms_template->renderJSON(array('error' => false, 'html' => cmsEventsManager::hook('parse_text', $content_html)));
}
//
// Редактирование записи
//
if ($action == 'update') {
$entry = $this->model->getEntry($entry_id);
if ($entry['user']['id'] != $this->cms_user->id && !$this->cms_user->is_admin) {
$this->error();
}
list($entry_id, $content, $content_html) = cmsEventsManager::hook('wall_before_update', array($entry_id, $content, $content_html));
$this->model->updateEntryContent($entry_id, $content, $content_html);
$entry_html = cmsEventsManager::hook('parse_text', $content_html);
}
//
// Добавление записи
//
if ($action == 'add') {
// проверяем права на добавление
if (!$permissions['add']) {
return $this->error();
}
// Собираем данные записи
$entry = array('user_id' => $this->cms_user->id, 'parent_id' => $parent_id, 'controller' => $controller_name, 'profile_type' => $profile_type, 'profile_id' => $profile_id, 'content' => $content, 'content_html' => $content_html);
// Сохраняем запись
$entry_id = $this->model->addEntry(cmsEventsManager::hook('wall_before_add', $entry));
if ($entry_id) {
// Получаем и рендерим добавленную запись
$entry = $this->model->getEntry($entry_id);
$entry['content_html'] = cmsEventsManager::hook('parse_text', $entry['content_html']);
$entry_html = $this->cms_template->renderInternal($this, 'entry', array('entries' => array($entry), 'user' => $this->cms_user, 'permissions' => $permissions));
// действия после добавления
$controller->runHook('wall_after_add', array('profile_type' => $profile_type, 'profile_id' => $profile_id, 'entry' => $entry, 'wall_model' => $this->model));
}
}
// Формируем и возвращаем результат
$result = array('error' => $entry_id ? false : true, 'message' => $entry_id ? LANG_WALL_ENTRY_SUCCESS : LANG_WALL_ENTRY_ERROR, 'id' => $entry_id, 'parent_id' => isset($entry['parent_id']) ? $entry['parent_id'] : 0, 'html' => isset($entry_html) ? $entry_html : false);
return $this->cms_template->renderJSON($result);
}
示例8: run
public function run()
{
if (!$this->request->isAjax()) {
cmsCore::error404();
}
$action = $this->request->get('action', '');
$is_guests_allowed = !empty($this->options['is_guests']);
$is_guest = $is_guests_allowed && !$this->cms_user->is_logged;
$is_user_allowed = $this->cms_user->is_logged && cmsUser::isAllowed('comments', 'add') || $is_guests_allowed;
$is_karma_allowed = $this->cms_user->is_logged && !cmsUser::isPermittedLimitHigher('comments', 'karma', $this->cms_user->karma) || $is_guests_allowed;
$is_add_allowed = $is_user_allowed && $is_karma_allowed;
if ($action == 'add' && !$is_add_allowed) {
cmsCore::error404();
}
if ($action == 'update' && !cmsUser::isAllowed('comments', 'edit')) {
cmsCore::error404();
}
$csrf_token = $this->request->get('csrf_token', '');
$target_controller = $this->request->get('tc', '');
$target_subject = $this->request->get('ts', '');
$target_id = $this->request->get('ti', '');
$target_user_id = $this->request->get('tud', '');
$parent_id = $this->request->get('parent_id', 0);
$comment_id = $this->request->get('id', 0);
$content = $this->request->get('content', '');
if ($is_guest) {
$author_name = $this->request->get('author_name', '');
$author_email = $this->request->get('author_email', '');
if (!$author_name) {
return $this->cms_template->renderJSON(array('error' => true, 'message' => LANG_COMMENT_ERROR_NAME, 'html' => false));
}
if ($author_email && !preg_match("/^([a-zA-Z0-9\\._-]+)@([a-zA-Z0-9\\._-]+)\\.([a-zA-Z]{2,4})\$/i", $author_email)) {
return $this->cms_template->renderJSON(array('error' => true, 'message' => LANG_COMMENT_ERROR_EMAIL, 'html' => false));
}
if (!empty($this->options['restricted_ips'])) {
if (string_in_mask_list($this->cms_user->ip, $this->options['restricted_ips'])) {
return $this->cms_template->renderJSON(array('error' => true, 'message' => LANG_COMMENT_ERROR_IP, 'html' => false));
}
}
if (!empty($this->options['guest_ip_delay'])) {
$last_comment_time = $this->model->getGuestLastCommentTime($this->cms_user->ip);
$now_time = time();
$minutes_passed = ($now_time - $last_comment_time) / 60;
if ($minutes_passed < $this->options['guest_ip_delay']) {
$spellcount = html_spellcount($this->options['guest_ip_delay'], LANG_MINUTE1, LANG_MINUTE2, LANG_MINUTE10);
return $this->cms_template->renderJSON(array('error' => true, 'message' => sprintf(LANG_COMMENT_ERROR_TIME, $spellcount), 'html' => false));
}
}
}
// Проверяем валидность
$is_valid = $target_controller && $target_subject && $target_id && $this->validate_sysname($target_controller) === true && $this->validate_sysname($target_subject) === true && is_numeric($target_id) && is_numeric($parent_id) && cmsCore::isControllerExists($target_controller) && cmsCore::isModelExists($target_controller) && (!$comment_id || is_numeric($comment_id)) && cmsForm::validateCSRFToken($csrf_token, false) && in_array($action, array('add', 'preview', 'update'), true);
if (!$is_valid) {
return $this->cms_template->renderJSON(array('error' => true, 'message' => LANG_COMMENT_ERROR));
}
// Типографируем текст
$content_html = cmsEventsManager::hook('html_filter', $content);
if (!$content_html) {
return $this->cms_template->renderJSON(array('error' => true, 'message' => ERR_VALIDATE_REQUIRED, 'html' => false));
}
//
// Превью комментария
//
if ($action == 'preview') {
return $this->cms_template->renderJSON(array('error' => false, 'html' => cmsEventsManager::hook('parse_text', $content_html)));
}
//
// Редактирование комментария
//
if ($action == 'update') {
$comment = $this->model->getComment($comment_id);
if (!cmsUser::isAllowed('comments', 'edit', 'all')) {
if (cmsUser::isAllowed('comments', 'edit', 'own') && $comment['user']['id'] != $this->cms_user->id) {
return $this->cms_template->renderJSON(array('error' => true, 'message' => LANG_COMMENT_ERROR));
}
}
list($comment_id, $content, $content_html) = cmsEventsManager::hook('comment_before_update', array($comment_id, $content, $content_html));
$this->model->updateCommentContent($comment_id, $content, $content_html);
$comment_html = cmsEventsManager::hook('parse_text', $content_html);
}
//
// Добавление комментария
//
if ($action == 'add') {
// Собираем данные комментария
$comment = array('user_id' => $this->cms_user->id, 'parent_id' => $parent_id, 'target_controller' => $target_controller, 'target_subject' => $target_subject, 'target_id' => $target_id, 'content' => $content, 'content_html' => $content_html, 'author_url' => $this->cms_user->ip);
if ($is_guest) {
$comment['author_name'] = $author_name;
$comment['author_email'] = $author_email;
}
// Получаем модель целевого контроллера
$target_model = cmsCore::getModel($target_controller);
// Получаем URL и заголовок комментируемой страницы
$target_info = $target_model->getTargetItemInfo($target_subject, $target_id);
if ($target_info) {
$comment['target_url'] = $target_info['url'];
$comment['target_title'] = $target_info['title'];
$comment['is_private'] = empty($target_info['is_private']) ? false : $target_info['is_private'];
// проверяем модерацию
$comment['is_approved'] = $this->isApproved($comment);
list($comment, $permissions) = cmsEventsManager::hook('comment_add_permissions', array($comment, array('error' => false, 'message' => '')));
//.........这里部分代码省略.........