当前位置: 首页>>代码示例>>PHP>>正文


PHP cmsTemplate类代码示例

本文整理汇总了PHP中cmsTemplate的典型用法代码示例。如果您正苦于以下问题:PHP cmsTemplate类的具体用法?PHP cmsTemplate怎么用?PHP cmsTemplate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了cmsTemplate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public function run($template_name)
 {
     $template = new cmsTemplate($template_name);
     if (!$template->hasOptions()) {
         cmsCore::error404();
     }
     $form = $template->getOptionsForm();
     // Форма отправлена?
     $is_submitted = $this->request->has('submit');
     $options = $template->getOptions();
     if ($is_submitted) {
         // Парсим форму и получаем поля записи
         $options = $form->parse($this->request, $is_submitted, $options);
         // Проверям правильность заполнения
         $errors = $form->validate($this, $options);
         if (!$errors) {
             $template->saveOptions($options);
             $this->redirectBack('settings');
         }
         if ($errors) {
             cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
         }
     }
     return cmsTemplate::getInstance()->render('settings_theme', array('template_name' => $template_name, 'options' => $options, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
 }
开发者ID:asphix,项目名称:icms2,代码行数:25,代码来源:settings_theme.php

示例2: run

 public function run($template_name)
 {
     $template = new cmsTemplate($template_name);
     if (!$template->hasOptions()) {
         cmsCore::error404();
     }
     $form = $template->getOptionsForm();
     $options = $template->getOptions();
     if ($this->request->has('submit')) {
         // Парсим форму и получаем поля записи
         $options = $form->parse($this->request, true, $options);
         // Проверям правильность заполнения
         $errors = $form->validate($this, $options);
         if (!$errors) {
             if ($template->saveOptions($options)) {
                 cmsUser::addSessionMessage(LANG_CP_SAVE_SUCCESS, 'success');
             } else {
                 cmsUser::addSessionMessage(LANG_CP_SETTINGS_TPL_NOT_WRITABLE, 'error');
             }
             $this->redirectToAction('settings');
         }
         if ($errors) {
             cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
         }
     }
     return $this->cms_template->render('settings_theme', array('template_name' => $template_name, 'options' => $options, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:27,代码来源:settings_theme.php

示例3: run

 public function run($id)
 {
     if (!$id) {
         cmsCore::error404();
     }
     $form = $this->getForm('preset', array('edit'));
     $is_submitted = $this->request->has('submit');
     $preset = $original_preset = $this->model->getPreset($id);
     if ($preset['is_internal']) {
         $form->removeFieldset('basic');
     }
     if ($is_submitted) {
         $preset = $form->parse($this->request, $is_submitted);
         $errors = $form->validate($this, $preset);
         if (!$errors) {
             $this->model->updatePreset($id, $preset);
             $this->createDefaultImages(array_merge($original_preset, $preset));
             $this->redirectToAction('presets');
         }
         if ($errors) {
             cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
         }
     }
     return cmsTemplate::getInstance()->render('backend/preset', array('do' => 'edit', 'preset' => $preset, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
 }
开发者ID:pin-git,项目名称:icms2,代码行数:25,代码来源:presets_edit.php

示例4: run

 public function run($tag_id)
 {
     if (!$tag_id) {
         cmsCore::error404();
     }
     $tags_model = cmsCore::getModel('tags');
     $form = $this->getForm('tag');
     $is_submitted = $this->request->has('submit');
     $tag = $tags_model->getTag($tag_id);
     $original_tag = $tag['tag'];
     if ($is_submitted) {
         $tag = $form->parse($this->request, $is_submitted);
         $errors = $form->validate($this, $tag);
         if ($original_tag == $tag['tag']) {
             $this->redirectToAction();
         }
         if (!$errors) {
             $duplicate_id = $tags_model->getTagId($tag['tag']);
             if (!$duplicate_id) {
                 $tags_model->updateTag($tag_id, $tag);
             }
             if ($duplicate_id) {
                 $tags_model->mergeTags($tag_id, $duplicate_id);
                 cmsUser::addSessionMessage(sprintf(LANG_TAGS_MERGED, $original_tag, $tag['tag']), 'success');
             }
             $this->redirectToAction();
         }
         if ($errors) {
             cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
         }
     }
     return cmsTemplate::getInstance()->render('backend/tag', array('do' => 'edit', 'tag' => $tag, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
 }
开发者ID:asphix,项目名称:icms2,代码行数:33,代码来源:edit.php

示例5: 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();
     }
     $form = $this->getForm('ctypes_dataset', array('add', $ctype['id']));
     $is_submitted = $this->request->has('submit');
     $fields = $content_model->getContentFields($ctype['name']);
     $dataset = array('sorting' => array(array('by' => 'date_pub', 'to' => 'desc')));
     if ($is_submitted) {
         $dataset = $form->parse($this->request, $is_submitted);
         $dataset['filters'] = $this->request->get('filters');
         $dataset['sorting'] = $this->request->get('sorting');
         $errors = $form->validate($this, $dataset);
         if (!$errors) {
             $dataset_id = $content_model->addContentDataset($dataset, $ctype);
             if ($dataset_id) {
                 cmsUser::addSessionMessage(sprintf(LANG_CP_DATASET_CREATED, $dataset['title']), 'success');
             }
             $this->redirectToAction('ctypes', array('datasets', $ctype['id']));
         }
         if ($errors) {
             cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
         }
     }
     return cmsTemplate::getInstance()->render('ctypes_dataset', array('do' => 'add', 'ctype' => $ctype, 'dataset' => $dataset, 'fields' => $fields, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
 }
开发者ID:pin-git,项目名称:icms2,代码行数:32,代码来源:ctypes_datasets_add.php

示例6: run

 public function run()
 {
     if (!$this->request->isAjax()) {
         cmsCore::error404();
     }
     $template = cmsTemplate::getInstance();
     $entry_id = $this->request->get('id');
     // Проверяем валидность
     $is_valid = is_numeric($entry_id);
     if (!$is_valid) {
         $result = array('error' => true, 'message' => LANG_ERROR);
         $template->renderJSON($result);
     }
     $user = cmsUser::getInstance();
     $entry = $this->model->getEntry($entry_id);
     $replies = $this->model->getReplies($entry_id);
     if (!$replies) {
         $result = array('error' => true, 'message' => LANG_ERROR);
         $template->renderJSON($result);
     }
     $permissions = array('add' => $user->is_logged, 'delete' => $user->is_admin || $user->id == $entry['profile_id']);
     $html = $template->renderInternal($this, 'entry', array('entries' => $replies, 'user' => $user, 'permissions' => $permissions));
     // Формируем и возвращаем результат
     $result = array('error' => false, 'html' => $html);
     $template->renderJSON($result);
 }
开发者ID:asphix,项目名称:icms2,代码行数:26,代码来源:get_replies.php

示例7: run

 public function run($id)
 {
     if (!$id) {
         cmsCore::error404();
     }
     $users_model = cmsCore::getModel('users');
     $group = $users_model->getGroup($id);
     if (!$group) {
         cmsCore::error404();
     }
     $controllers = cmsPermissions::getControllersWithRules();
     $owners = array();
     foreach ($controllers as $controller_name) {
         $controller = cmsCore::getController($controller_name);
         $subjects = $controller->getPermissionsSubjects();
         $rules = cmsPermissions::getRulesList($controller_name);
         $values = array();
         foreach ($subjects as $subject) {
             $values[$subject['name']] = cmsPermissions::getPermissions($subject['name']);
         }
         $owners[$controller_name] = array('subjects' => $subjects, 'rules' => $rules, 'values' => $values);
     }
     $template = cmsTemplate::getInstance();
     $template->setMenuItems('users_group', array(array('title' => LANG_CONFIG, 'url' => href_to($this->name, 'users', array('group_edit', $id))), array('title' => LANG_PERMISSIONS, 'url' => href_to($this->name, 'users', array('group_perms', $id)))));
     return $template->render('users_group_perms', array('group' => $group, 'owners' => $owners));
 }
开发者ID:asphix,项目名称:icms2,代码行数:26,代码来源:users_group_perms.php

示例8: run

 public function run($id = false)
 {
     if (!$id) {
         cmsCore::error404();
     }
     $widgets_model = cmsCore::getModel('widgets');
     cmsCore::loadAllControllersLanguages();
     $page = $widgets_model->getPage($id);
     if (!$page) {
         cmsCore::error404();
     }
     $form = $this->getForm('widgets_page');
     if (!$page['is_custom']) {
         $form->removeField('title', 'title');
     }
     $is_submitted = $this->request->has('submit');
     if ($is_submitted) {
         $page = $form->parse($this->request, $is_submitted);
         $errors = $form->validate($this, $page);
         if (!$errors) {
             $widgets_model->updatePage($id, $page);
             $this->redirectToAction('widgets');
         }
         if ($errors) {
             cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
         }
     }
     return cmsTemplate::getInstance()->render('widgets_page', array('do' => 'edit', 'page' => $page, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
 }
开发者ID:asphix,项目名称:icms2,代码行数:29,代码来源:widgets_page_edit.php

示例9: run

 public function run()
 {
     if (!$this->request->isAjax()) {
         cmsCore::error404();
     }
     if (!cmsUser::isAllowed('comments', 'edit')) {
         cmsCore::error404();
     }
     $comment_id = $this->request->get('id');
     // Проверяем валидность
     $is_valid = is_numeric($comment_id);
     if (!$is_valid) {
         $result = array('error' => true, 'message' => LANG_ERROR);
         cmsTemplate::getInstance()->renderJSON($result);
     }
     $user = cmsUser::getInstance();
     $comment = $this->model->getComment($comment_id);
     if (!cmsUser::isAllowed('comments', 'edit', 'all')) {
         if (cmsUser::isAllowed('comments', 'edit', 'own') && $comment['user']['id'] != $user->id) {
             $result = array('error' => true, 'message' => LANG_ERROR);
             cmsTemplate::getInstance()->renderJSON($result);
         }
     }
     // Формируем и возвращаем результат
     $result = array('error' => $comment ? false : true, 'id' => $comment_id, 'html' => $comment ? string_strip_br($comment['content']) : false);
     cmsTemplate::getInstance()->renderJSON($result);
 }
开发者ID:asphix,项目名称:icms2,代码行数:27,代码来源:get.php

示例10: run

 public function run($pass_token)
 {
     if (!$pass_token) {
         cmsCore::error404();
     }
     $users_model = cmsCore::getModel('users');
     $profile = $users_model->getUserByPassToken($pass_token);
     if (!$profile) {
         cmsCore::error404();
     }
     $form = $this->getForm('reset');
     $is_submitted = $this->request->has('submit');
     if ($is_submitted) {
         $profile = array_merge($profile, $form->parse($this->request, $is_submitted));
         $errors = $form->validate($this, $profile);
         if (!$errors) {
             $result = $users_model->updateUser($profile['id'], $profile);
             if ($result['success']) {
                 cmsUser::addSessionMessage(LANG_PASS_CHANGED, 'success');
                 $users_model->clearUserPassToken($profile['id']);
                 $this->redirectTo('users', $profile['id']);
             } else {
                 $errors = $result['errors'];
             }
         }
         if ($errors) {
             cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
         }
     }
     return cmsTemplate::getInstance()->render('reset', array('profile' => $profile, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
 }
开发者ID:asphix,项目名称:icms2,代码行数:31,代码来源:reset.php

示例11: run

 public function run($ctype_name = false)
 {
     $query = $this->request->get('q', false);
     $type = $this->request->get('type', 'words');
     $date = $this->request->get('date', 'all');
     $page = $this->request->get('page', 1);
     if (!in_array($type, array('words', 'exact'), true)) {
         cmsCore::error404();
     }
     if (!in_array($date, array('all', 'w', 'm', 'y'), true)) {
         cmsCore::error404();
     }
     if (!is_numeric($page)) {
         cmsCore::error404();
     }
     if ($this->request->has('q')) {
         if (!$query) {
             $this->redirectToAction('');
         }
         $results = $this->search($query, $type, $date, $ctype_name, $page);
         if ($results && !$ctype_name) {
             $ctype_name = $results[0]['name'];
             $page_url = href_to($this->name);
         } else {
             $page_url = href_to($this->name, 'index', $ctype_name);
         }
     }
     return cmsTemplate::getInstance()->render('index', array('query' => $query, 'type' => $type, 'date' => $date, 'ctype_name' => $ctype_name, 'page' => $page, 'perpage' => $this->options['perpage'], 'results' => isset($results) ? $results : false, 'page_url' => isset($page_url) ? $page_url : false));
 }
开发者ID:pin-git,项目名称:icms2,代码行数:29,代码来源:index.php

示例12: run

 public function run()
 {
     if (!$this->request->isAjax()) {
         cmsCore::error404();
     }
     $comment_id = $this->request->get('comment_id');
     $score = $this->request->get('score');
     // Проверяем валидность
     $is_valid = is_numeric($comment_id) && in_array($score, array(-1, 1));
     $template = cmsTemplate::getInstance();
     if (!$is_valid) {
         $template->renderJSON(array('error' => true));
     }
     $user = cmsUser::getInstance();
     $is_can_rate = cmsUser::isAllowed('comments', 'rate');
     if (!$is_can_rate) {
         $template->renderJSON(array('error' => true));
     }
     $is_voted = $this->model->isUserVoted($comment_id, $user->id);
     if ($is_voted) {
         $template->renderJSON(array('error' => true));
     }
     $comment = $this->model->getComment($comment_id);
     if ($comment['user_id'] == $user->id) {
         $template->renderJSON(array('error' => true));
     }
     $success = $this->model->rateComment($comment_id, $user->id, $score);
     $template->renderJSON(array('error' => !$success));
 }
开发者ID:asphix,项目名称:icms2,代码行数:29,代码来源:rate.php

示例13: run

 public function run($tab = 'all')
 {
     $user = cmsUser::getInstance();
     $dataset_name = false;
     $datasets = $this->getDatasets();
     if ($tab && isset($datasets[$tab])) {
         $dataset_name = $tab;
         $dataset = $datasets[$tab];
         if (isset($dataset['filter']) && is_callable($dataset['filter'])) {
             $this->model = $dataset['filter']($this->model, $dataset);
         }
     } else {
         if ($tab) {
             cmsCore::error404();
         }
     }
     // Сортировка
     if ($dataset_name) {
         $this->model->orderBy($datasets[$dataset_name]['order'][0], $datasets[$dataset_name]['order'][1]);
     }
     // Формируем базовые URL для страниц
     $page_url = array('base' => href_to($this->name, $dataset_name ? 'index/' . $dataset_name : ''), 'first' => href_to($this->name, $dataset_name ? 'index/' . $dataset_name : ''));
     // Получаем HTML списка записей
     $profiles_list_html = $this->renderProfilesList($page_url, $dataset_name);
     return cmsTemplate::getInstance()->render('index', array('datasets' => $datasets, 'dataset_name' => $dataset_name, 'dataset' => $dataset, 'user' => $user, 'profiles_list_html' => $profiles_list_html), $this->request);
 }
开发者ID:asphix,项目名称:icms2,代码行数:26,代码来源:index.php

示例14: run

 public function run()
 {
     if (!$this->getPackageContentsDir()) {
         $this->redirectToAction('install/finish');
     }
     $form = $this->getForm('ftp');
     $is_submitted = $this->request->has('submit');
     $account = cmsUser::isSessionSet('ftp_account') ? cmsUser::sessionGet('ftp_account') : array();
     if ($is_submitted) {
         $account = array_merge($account, $form->parse($this->request, $is_submitted, $account));
         cmsUser::sessionSet('ftp_account', $account);
         $errors = $form->validate($this, $account);
         if ($errors) {
             cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
         }
         if (!$errors) {
             $account['host'] = trim(str_replace('ftp://', '', $account['host']), '/');
             if ($account['path'] != '/') {
                 $account['path'] = '/' . trim($account['path'], '/') . '/';
             }
             $this->uploadPackageToFTP($account);
         }
     }
     return cmsTemplate::getInstance()->render('install_ftp', array('account' => $account, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
 }
开发者ID:asphix,项目名称:icms2,代码行数:25,代码来源:install_ftp.php

示例15: run

 public function run($feed_id)
 {
     if (!$feed_id) {
         cmsCore::error404();
     }
     $rss_model = cmsCore::getModel('rss');
     $feed = $rss_model->getFeed($feed_id);
     $ctype_id = $feed['ctype_id'];
     $content_model = cmsCore::getModel('content');
     $fields = $content_model->getContentFields($feed['ctype_name']);
     $fields = array('' => '') + array_collection_to_list($fields, 'name', 'title');
     $form = $this->getForm('feed', array($fields));
     $is_submitted = $this->request->has('submit');
     if ($is_submitted) {
         $feed = $form->parse($this->request, $is_submitted);
         $errors = $form->validate($this, $feed);
         if (!$errors) {
             $rss_model->updateFeed($feed_id, $feed);
             $ctype = $content_model->getContentType($ctype_id);
             $ctype['options']['is_rss'] = $feed['is_enabled'];
             $content_model->updateContentType($ctype_id, array('options' => $ctype['options']));
             $this->redirectToAction();
         }
         if ($errors) {
             cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
         }
     }
     return cmsTemplate::getInstance()->render('backend/edit', array('feed' => $feed, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
 }
开发者ID:asphix,项目名称:icms2,代码行数:29,代码来源:edit.php


注:本文中的cmsTemplate类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。