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


PHP cmsCore::getModel方法代码示例

本文整理汇总了PHP中cmsCore::getModel方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsCore::getModel方法的具体用法?PHP cmsCore::getModel怎么用?PHP cmsCore::getModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cmsCore的用法示例。


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

示例1: run

 public function run($ctype_name = false)
 {
     if (!$ctype_name) {
         cmsCore::error404();
     }
     $feed = $this->model->getFeedByCtypeName($ctype_name);
     if (!$feed || !$feed['is_enabled']) {
         cmsCore::error404();
     }
     $category_id = $this->request->get('category', false);
     $user_id = $this->request->get('user', false);
     $content_model = cmsCore::getModel('content');
     if ($category_id) {
         $category = $content_model->getCategory($ctype_name, $category_id);
     }
     if ($user_id) {
         $author = cmsCore::getModel('users')->getUser($user_id);
     }
     if (!empty($category)) {
         $content_model->filterCategory($ctype_name, $category, true);
     }
     if (!empty($author)) {
         $content_model->filterEqual('user_id', $user_id);
     }
     $content_model->orderBy('id', 'desc')->limit($feed['limit']);
     $feed['items'] = $content_model->getContentItems($ctype_name);
     $feed = cmsEventsManager::hook('before_render_' . $ctype_name . '_feed_list', $feed);
     header('Content-type: application/rss+xml; charset=utf-8');
     return cmsTemplate::getInstance()->renderPlain('feed', array('feed' => $feed, 'category' => isset($category) ? $category : false, 'author' => isset($author) ? $author : false));
 }
开发者ID:asphix,项目名称:icms2,代码行数:30,代码来源:feed.php

示例2: 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

示例3: 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

示例4: 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

示例5: run

 public function run()
 {
     $camera = urldecode($this->request->get('name', ''));
     if (!$camera) {
         cmsCore::error404();
     }
     if (cmsUser::isAllowed('albums', 'view_all')) {
         $this->model->disablePrivacyFilter();
     }
     $this->model->filterEqual('camera', $camera);
     $page = $this->request->get('photo_page', 1);
     $perpage = empty($this->options['limit']) ? 16 : $this->options['limit'];
     $this->model->limitPagePlus($page, $perpage);
     $this->model->orderBy($this->options['ordering'], 'desc');
     $photos = $this->getPhotosList();
     if (!$photos) {
         cmsCore::error404();
     }
     if ($photos && count($photos) > $perpage) {
         $has_next = true;
         array_pop($photos);
     } else {
         $has_next = false;
     }
     $ctype = cmsCore::getModel('content')->getContentTypeByName('albums');
     $this->cms_template->render('camera', array('page_title' => sprintf(LANG_PHOTOS_CAMERA_TITLE, $camera), 'ctype' => $ctype, 'page' => $page, 'row_height' => $this->getRowHeight(), 'user' => $this->cms_user, 'item' => array('id' => 0, 'user_id' => 0, 'url_params' => array('camera' => $camera), 'base_url' => href_to('photos', 'camera-' . urlencode($camera))), 'item_type' => 'camera', 'photos' => $photos, 'is_owner' => cmsUser::isAllowed('albums', 'delete', 'all'), 'has_next' => $has_next, 'hooks_html' => cmsEventsManager::hookAll('photo_camera_html', $camera), 'preset_small' => $this->options['preset_small']));
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:27,代码来源:camera.php

示例6: store

 public function store($value, $is_submitted, $old_value = null)
 {
     $config = cmsConfig::getInstance();
     $files_model = cmsCore::getModel('files');
     if ($value) {
         $file = cmsModel::yamlToArray($old_value);
         $path = $config->upload_path . $file['path'];
         @unlink($path);
         $files_model->deleteFile($file['id']);
         $old_value = null;
     }
     $uploader = new cmsUploader();
     if (!$uploader->isUploaded($this->name)) {
         return $old_value;
     }
     $allowed_extensions = $this->getOption('extensions');
     $max_size_mb = $this->getOption('max_size_mb');
     if (!trim($allowed_extensions)) {
         $allowed_extensions = false;
     }
     if (!$max_size_mb) {
         $max_size_mb = 0;
     }
     $result = $uploader->upload($this->name, $allowed_extensions, $max_size_mb * 1048576);
     if (!$result['success']) {
         if (!empty($result['path'])) {
             $uploader->remove($result['path']);
         }
         cmsUser::addSessionMessage($result['error'], 'error');
         return null;
     }
     $file = $files_model->registerFile($result['url'], $result['name']);
     return array('id' => $file['id'], 'url_key' => $file['url_key'], 'name' => $result['name'], 'size' => $result['size'], 'path' => $result['url']);
 }
开发者ID:asphix,项目名称:icms2,代码行数:34,代码来源:file.php

示例7: run

 public function run($data)
 {
     if (empty($this->options['is_hash_tag'])) {
         return $data;
     }
     list($ctype, $items) = $data;
     if (empty($items)) {
         return $data;
     }
     $fields = cmsCore::getModel('content')->filterIn('type', array('text', 'html'))->getContentFields($ctype['name']);
     if (!$fields) {
         return $data;
     }
     foreach ($items as $item) {
         foreach ($fields as $field) {
             if (!$field['is_in_list'] || empty($field['options']['in_fulltext_search'])) {
                 continue;
             }
             if (!empty($item[$field['name']])) {
                 $items[$item['id']][$field['name']] = $this->parseHashTag($item[$field['name']]);
             }
         }
     }
     return array($ctype, $items);
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:25,代码来源:content_before_list.php

示例8: init

 public function init()
 {
     return array(array('type' => 'fieldset', 'title' => LANG_ACTIVITY_OPT_TYPES, 'childs' => array(new fieldList('types', array('is_multiple' => true, 'generator' => function () {
         $types = cmsCore::getModel('activity')->getTypes();
         return array_collection_to_list($types, 'id', 'title');
     })))), array('type' => 'fieldset', 'title' => LANG_LIST_LIMIT, 'childs' => array(new fieldNumber('limit', array('default' => 15, 'rules' => array(array('required')))))));
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:7,代码来源:form_options.php

示例9: run

 public function run()
 {
     $taxonomy_model = cmsCore::getModel('taxonomy');
     $vocabularies = $taxonomy_model->getVocabularies();
     $grid = $this->loadDataGrid('terms');
     return cmsTemplate::getInstance()->render('backend/vocabularies', array('vocabularies' => $vocabularies, 'grid' => $grid));
 }
开发者ID:softsolution,项目名称:taxonomyic20,代码行数:7,代码来源:vocabularies.php

示例10: run

 public function run($ctype_id, $parent_id)
 {
     if (!$this->request->isAjax()) {
         cmsCore::error404();
     }
     $content_model = cmsCore::getModel('content');
     $ctype = $content_model->getContentType($ctype_id);
     $category = $content_model->getCategory($ctype['name'], $parent_id);
     $grid = $this->loadDataGrid('content_items', $ctype['name']);
     $content_model->setPerPage(admin::perpage);
     $filter = array();
     $filter_str = $this->request->get('filter');
     if ($filter_str) {
         parse_str($filter_str, $filter);
         $content_model->applyGridFilter($grid, $filter);
         if (!empty($filter['advanced_filter'])) {
             parse_str($filter['advanced_filter'], $dataset_filters);
             if (!empty($dataset_filters['dataset'])) {
                 $dataset_id = $dataset_filters['dataset'];
                 $dataset = $content_model->getContentDataset($dataset_id);
                 $content_model->applyDatasetFilters($dataset, true);
             }
             $content_model->applyDatasetFilters($dataset_filters);
         }
     }
     $content_model->filterCategory($ctype['name'], $category, $ctype['is_cats_recursive']);
     $content_model->disableApprovedFilter();
     $content_model->disablePubFilter();
     $total = $content_model->getContentItemsCount($ctype['name']);
     $perpage = isset($filter['perpage']) ? $filter['perpage'] : admin::perpage;
     $pages = ceil($total / $perpage);
     $items = $content_model->getContentItems($ctype['name']);
     cmsTemplate::getInstance()->renderGridRowsJSON($grid, $items, $total, $pages);
     $this->halt();
 }
开发者ID:rookees,项目名称:icms2,代码行数:35,代码来源:content_items_ajax.php

示例11: init

 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)))));
 }
开发者ID:Val-Git,项目名称:icms2,代码行数:25,代码来源:options.form.php

示例12: run

 public function run($controller_name)
 {
     if (!$controller_name) {
         cmsCore::error404();
     }
     $controller_info = $this->model->getControllerInfo($controller_name);
     if (!$controller_info || !$controller_info['is_external']) {
         cmsCore::error404();
     }
     if ($controller_info['is_backend']) {
         $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);
         // смотрим специальный экшен
         if ($backend_controller->isActionExists('delete_component')) {
             $backend_controller->redirectToAction('delete_component');
         }
     }
     // нет бэкэенда или экшена, удаляем через метод модели контроллера
     // если в модели контроллера нет метода deleteController
     // будет использоваться из основной модели
     // который просто удалит запись в cms_controllers
     if (cmsCore::isModelExists($controller_info['name'])) {
         cmsCore::getModel($controller_info['name'])->deleteController($controller_info['id']);
     } else {
         $model = new cmsModel();
         $model->deleteController($controller_info['id']);
     }
     cmsUser::addSessionMessage(sprintf(LANG_CP_COMPONENT_IS_DELETED, $controller_info['title']), 'success');
     $this->redirectToAction('controllers');
 }
开发者ID:pin-git,项目名称:icms2,代码行数:31,代码来源:controllers_delete.php

示例13: run

 public function run()
 {
     if (!$this->request->isAjax()) {
         cmsCore::error404();
     }
     if (preg_match('/^\\/[0-9a-zA-Zа-яёА-ЯЁ\\-\\_\\.\\/\\*?&=]+$/u', $this->request->get('link_from'))) {
         if (preg_match('/[\\/\\*]+$/u', $this->request->get('link_from'))) {
             $type = '2';
         } elseif (preg_match('/^\\/[0-9a-zA-Zа-яёА-ЯЁ\\-\\_\\.\\/?&=]+$/u', $this->request->get('link_from'))) {
             $type = '1';
         } else {
             $res['error']['incorrect_link_from'] = 1;
         }
     } else {
         $res['error']['incorrect_link_from'] = 1;
     }
     if (!preg_match('/^\\/[0-9a-zA-Zа-яёА-ЯЁ\\-\\_\\.\\/?&=]+$/u', $this->request->get('link_to')) and $this->request->get('header') != '410') {
         $res['error']['incorrect_link_to'] = 1;
     }
     $link_to = $this->request->get('link_to');
     if ($this->request->get('header') === '410') {
         $link_to = '--//--';
     }
     if (!isset($res['error'])) {
         $model = cmsCore::getModel('shredirect');
         $data = array('link_from' => $this->request->get('link_from'), 'type' => $type, 'link_to' => $link_to, 'header' => $this->request->get('header'));
         if ($model->addShredirect($data)) {
             $res['reply'] = LANG_SHREDIRECT_SUCCESS_ADD;
         } else {
             $res['error']['bd'] = LANG_SHREDIRECT_ERROR_BD;
         }
     }
     echo json_encode($res);
     die;
 }
开发者ID:regvo,项目名称:instant,代码行数:35,代码来源:add.php

示例14: run

 public function run()
 {
     if (cmsUser::isLogged()) {
         $this->redirectToHome();
     }
     $users_model = cmsCore::getModel('users');
     $form = $this->getForm('restore');
     $data = array();
     $is_submitted = $this->request->has('submit');
     if ($is_submitted) {
         $data = $form->parse($this->request, $is_submitted);
         $errors = $form->validate($this, $data);
         if ($errors) {
             cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
         }
         if (!$errors) {
             $user = $users_model->getUserByEmail($data['email']);
             if (!$user) {
                 cmsUser::addSessionMessage(LANG_EMAIL_NOT_FOUND, 'error');
             } else {
                 $pass_token = string_random(32, $user['email']);
                 $users_model->updateUserPassToken($user['id'], $pass_token);
                 $messenger = cmsCore::getController('messages');
                 $to = array('email' => $user['email'], 'name' => $user['nickname']);
                 $letter = array('name' => 'reg_restore');
                 $messenger->sendEmail($to, $letter, array('nickname' => $user['nickname'], 'page_url' => href_to_abs('auth', 'reset', $pass_token), 'valid_until' => html_date(date('d.m.Y H:i', time() + 24 * 3600), true)));
                 cmsUser::addSessionMessage(LANG_TOKEN_SENDED, 'success');
             }
         }
     }
     return cmsTemplate::getInstance()->render('restore', array('data' => $data, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
 }
开发者ID:asphix,项目名称:icms2,代码行数:32,代码来源:restore.php

示例15: run

 public function run($id)
 {
     if (!$id) {
         cmsCore::error404();
     }
     $images_model = cmsCore::getModel('images');
     $form = $this->getForm('preset', array('edit'));
     $is_submitted = $this->request->has('submit');
     $preset = $images_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) {
             $images_model->updatePreset($id, $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:asphix,项目名称:icms2,代码行数:25,代码来源:presets_edit.php


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