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


PHP Page::model方法代码示例

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


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

示例1: actionIndex

 public function actionIndex()
 {
     // Загружаем страницу "Наши работы"
     Yii::import("application.modules.page.models.Page");
     $page = Page::model()->with(array('slides' => array('scopes' => 'published', 'order' => 'slides.sort ASC')))->findByPath("portfolio");
     $this->render('index', array('page' => $page));
 }
开发者ID:kuzmina-mariya,项目名称:unizaro-stone,代码行数:7,代码来源:PortfolioController.php

示例2: renderContent

 protected function renderContent()
 {
     $model = new Page();
     //If it has guid, it means this is a translated version
     $guid = isset($_GET['guid']) ? strtolower(trim($_GET['guid'])) : '';
     //List of language that should exclude not to translate
     $lang_exclude = array();
     //List of translated versions
     $versions = array();
     // If the guid is not empty, it means we are creating a translated version of a content
     // We will exclude the translated language and include the name of the translated content to $versions
     if ($guid != '') {
         $page_object = Page::model()->findAll('guid=:gid', array(':gid' => $guid));
         if (count($page_object) > 0) {
             $langs = GxcHelpers::getAvailableLanguages();
             foreach ($page_object as $obj) {
                 $lang_exclude[] = $obj->lang;
                 $versions[] = $obj->name . ' - ' . $langs[$obj->lang]['name'];
             }
         }
         $model->guid = $guid;
     }
     // if it is ajax validation request
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'page-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     //Define Blocks in Regions
     $regions_blocks = array();
     // collect user input data
     if (isset($_POST['Page'])) {
         $regions_blocks = isset($_POST['Page']['regions']) ? $_POST['Page']['regions'] : array();
         $model->attributes = $_POST['Page'];
         if ($model->save()) {
             if (!empty($regions_blocks)) {
                 //Delete All Page Block Before
                 PageBlock::model()->deleteAll('page_id = :id', array(':id' => $model->page_id));
                 foreach ($regions_blocks as $key => $blocks) {
                     $order = 1;
                     for ($i = 0; $i < count($blocks['id']); $i++) {
                         $block = $blocks['id'][$i];
                         $temp_page_block = new PageBlock();
                         $temp_page_block->page_id = $model->page_id;
                         $temp_page_block->block_id = $block;
                         $temp_page_block->region = $key;
                         $temp_page_block->block_order = $order;
                         $temp_page_block->status = $blocks['status'][$i];
                         $temp_page_block->save();
                         $order++;
                     }
                 }
             }
             //Start to save the Page Block
             user()->setFlash('success', t('cms', 'Create new Page Successfully!'));
             $model = new Page();
             Yii::app()->controller->redirect(array('create'));
         }
     }
     $this->render('cmswidgets.views.page.page_form_widget', array('model' => $model, 'lang_exclude' => $lang_exclude, 'versions' => $versions, 'regions_blocks' => $regions_blocks));
 }
开发者ID:pramana08,项目名称:GXC-CMS-2,代码行数:60,代码来源:PageCreateWidget.php

示例3: loadModel

 public function loadModel($id)
 {
     if (($model = Page::model()->findByPk($id)) === null) {
         throw new CHttpException(404, 'Страница не найдена');
     }
     return $model;
 }
开发者ID:kuzmina-mariya,项目名称:happy-end,代码行数:7,代码来源:PageBackendController.php

示例4: run

 public function run()
 {
     $ids = Yii::app()->request->getParam('id');
     $command = Yii::app()->request->getParam('command');
     empty($ids) && $this->controller->message('error', Yii::t('admin', 'No Select'));
     if (!is_array($ids)) {
         $ids = array($ids);
     }
     $criteria = new CDbCriteria();
     $criteria->addInCondition('id', $ids);
     switch ($command) {
         case 'delete':
             //删除
             Page::model()->deleteAll($criteria);
             break;
         case 'show':
             //显示
             Page::model()->updateAll(['status' => 'Y'], $criteria);
             break;
         case 'hidden':
             //隐藏
             Page::model()->updateAll(['status' => 'N'], $criteria);
             break;
         default:
             $this->controller->message('error', Yii::t('admin', 'Error Operation'));
     }
     $this->controller->message('success', Yii::t('admin', 'Batch Operate Success'));
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:28,代码来源:BatchAction.php

示例5: actionPaths

 /**
  * Set paths for all models.
  *
  * @return void
  */
 public function actionPaths()
 {
     $models = Page::model()->resetScope()->findAll();
     foreach ($models as $model) {
         $model->save(true, array('path'));
     }
 }
开发者ID:kuzmina-mariya,项目名称:gallery,代码行数:12,代码来源:PageBackendController.php

示例6: parsePosts

 public function parsePosts()
 {
     $content = $this->getContent($this->web_url);
     if (!$content) {
         return;
     }
     $doc = new DOMDocument();
     @$doc->loadHTML($content);
     $path = new DOMXPath($doc);
     $links = $path->query('//div[@class="newsItem"]/h2/a');
     $images = $path->query('//div[@class="newsItem"]/a/img');
     foreach ($links as $i => $link) {
         $href = $source_url = $this->prepareHref($link->getAttribute('href'));
         $page = Page::model()->findByAttributes(array('source' => $this->source, 'source_url' => $source_url));
         if ($page) {
             $this->log("Пост #{$page->id} уже был спарсен, пропускаем");
             continue;
         }
         $image = $images->item($i);
         if ($image) {
             $image = $this->web_url . $image->getAttribute('src');
         }
         $this->parsePost($this->web_url . $href, $image, $source_url);
     }
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:25,代码来源:MixfightParser.php

示例7: loadModel

 public function loadModel($id)
 {
     if (($model = Page::model()->findByPk($id)) === null) {
         throw new CHttpException(404, Yii::t('PageModule.page', 'Page was not found!'));
     }
     return $model;
 }
开发者ID:kuzmina-mariya,项目名称:4seasons,代码行数:7,代码来源:PageBackendController.php

示例8: actionFaq

 /**
  * FAQ
  */
 public function actionFaq()
 {
     // Загружаем страницу "FAQ"
     Yii::import("application.modules.page.models.Page");
     $page = Page::model()->with(array('slides' => array('scopes' => 'published', 'order' => 'slides.sort ASC')))->findByPath("faq");
     // Список групп
     $groups = FaqGroup::model()->published()->with(array('slides' => array('scopes' => 'published', 'order' => 'slides.sort ASC'), 'questions' => array('scopes' => array('answered', 'faq'), 'order' => 'questions.sort ASC')))->findAll(array('order' => 't.sort ASC'));
     /*
             $dataProvider = new CActiveDataProvider('Feedback', array('criteria'  => array(
        'condition' => 'type_id = :type_id AND (status = :sended OR status = :finished)',
        'params'    => array(
            ':type_id'  => $type->id,
            ':sended'   => Feedback::STATUS_ANSWER_SENDED,
            ':finished' => Feedback::STATUS_FINISHED,
        ),
        'order'     => 't.sort ASC',
             )));
     * 
     */
     $type = DictionaryData::model()->findByCode('feedback-faq');
     if (!$type) {
         throw new CHttpException(404);
     }
     $form = $this->_processForm($type);
     $this->render('faq', array('model' => $form, 'page' => $page, 'groups' => $groups));
 }
开发者ID:kuzmina-mariya,项目名称:unizaro-spa,代码行数:29,代码来源:ContactController.php

示例9: getModel

 /**
  * Возвращает объект запрашиваемой страницы
  * 
  * @return Page модель страницы
  */
 public function getModel()
 {
     if ($this->_model === null) {
         if (!isset($_GET['pageId'])) {
             $lang = Yii::app()->language;
             if (!empty($_GET['alias'])) {
                 $page = Page::model()->find("`{$lang}_alias` = :alias", array(':alias' => $_GET['alias']));
                 if ($page && (!Yii::app()->params['strictFind'] || $page[$lang . '_alias'] == $_GET['alias'])) {
                     $_GET['pageId'] = $page->id;
                     $this->_model = $page;
                 }
             } elseif (!empty($_GET['url'])) {
                 $page = Page::model()->find("`{$lang}_url` = :url", array(':url' => '/' . $_GET['url']));
                 if ($page && (!Yii::app()->params['strictFind'] || $page[$lang . '_url'] == '/' . $_GET['url'])) {
                     $_GET['pageId'] = $page->id;
                     $this->_model = $page;
                 }
             } else {
                 $_GET['pageId'] = 1;
                 $this->_model = Page::model()->findByPk(1);
             }
         } else {
             if (isset($_GET['pageId'])) {
                 $this->_model = Page::model()->findbyPk($_GET['pageId']);
             }
             if ($this->_model && $this->_model->language) {
                 Yii::app()->language = $this->_model->language;
             }
         }
     }
     return $this->_model;
 }
开发者ID:rosko,项目名称:Tempo-CMS,代码行数:37,代码来源:PageComponent.php

示例10: run

 public function run()
 {
     $pages = Page::model()->getRecentPages();
     ?>
 <ul>
 <?php 
     foreach ($pages as $page) {
         ?>
     <li>
         <?php 
         $title = CHtml::encode($page->title);
         echo CHtml::link($title, $page->url);
         ?>
     </li>
 <?php 
     }
     ?>
 <?php 
     if (!$pages) {
         echo Yii::t('app', 'Sorry, no recent pages!');
     }
     ?>
 </ul>
 <?php 
     parent::run();
 }
开发者ID:awecode,项目名称:awecms,代码行数:26,代码来源:RecentPages.php

示例11: actionIndex

 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     // renders the view file 'protected/views/site/index.php'
     // using the default layout 'protected/views/layouts/main.php'
     $model = Page::model()->find('name=:name', array(':name' => 'home_page'));
     $this->render('index', array('model' => $model));
 }
开发者ID:robertgunze,项目名称:eams,代码行数:11,代码来源:SiteController.php

示例12: run

 public function run()
 {
     // 主菜单
     $menuId = Yii::app()->controller->menuId;
     $rootId = Page::model()->getRootIdByPk($menuId);
     if ($rootId == false) {
         $rootId = $menuId;
     }
     $items = array();
     $criteria = new CDbCriteria();
     $criteria->compare('parent_id', '0');
     $criteria->compare('is_indexable', '1');
     $criteria->order = 'sort_order ASC';
     $pages = Page::model()->localized()->findAll($criteria);
     foreach ($pages as $i => $page) {
         $items[$i] = array('template' => '{menu}', 'label' => $page->title, 'url' => $page->getPermalink());
         if ($i == 0) {
             $items[$i]['itemOptions'] = array('class' => $page->primaryKey == $rootId ? 'line active' : 'line');
         } else {
             if ($page->primaryKey == $rootId) {
                 $items[$i]['itemOptions'] = array('class' => 'active');
             }
         }
     }
     if ($menuId == 0) {
         $items = array_merge(array(array('label' => Yii::t('common', '首页'), 'url' => array('site/index'), 'itemOptions' => array('class' => 'cur'))), $items);
     } else {
         $items = array_merge(array(array('label' => Yii::t('common', '首页'), 'url' => array('site/index'))), $items);
     }
     $this->render('menu', array('items' => $items));
 }
开发者ID:kinghinds,项目名称:kingtest2,代码行数:31,代码来源:Menu.php

示例13: actionIndex

 /**
  * Index action:
  *
  * @return void
  */
 public function actionIndex()
 {
     $module = Yii::app()->getModule('homepage');
     $view = $data = null;
     if ($module->mode == HomepageModule::MODE_PAGE) {
         $target = Page::model()->findByPk($module->target);
         if (null === $target) {
             throw new CHttpException('404', Yii::t('HomepageModule.page', 'Page was not found'));
         }
         $page = Page::model()->published()->find('slug = :slug AND lang = :lang', [':slug' => $target->slug, ':lang' => Yii::app()->getLanguage()]);
         $page = $page ?: $target;
         $view = $page->view ?: 'page';
         $data = ['page' => $page];
     }
     if ($module->mode == HomepageModule::MODE_POSTS) {
         $view = 'posts';
         $dataProvider = new CActiveDataProvider('Post', ['criteria' => new CDbCriteria(['condition' => 't.status = :status', 'params' => [':status' => Post::STATUS_PUBLISHED], 'limit' => $module->limit, 'order' => 't.publish_time DESC', 'with' => ['createUser', 'blog', 'commentsCount']])]);
         $data = ['dataProvider' => $dataProvider];
     }
     if ($module->mode == HomepageModule::MODE_STORE) {
         $view = 'store';
         Yii::import('application.modules.store.components.ProductRepository');
         $data = ['dataProvider' => (new ProductRepository())->getListForIndexPage()];
     }
     $this->render($view, $data);
 }
开发者ID:RonLab1987,项目名称:43berega,代码行数:31,代码来源:HpController.php

示例14: actionSitemapxml

 /**
  * Generate sitemap.
  */
 public function actionSitemapxml()
 {
     $posts = Post::model()->findAll(array('order' => 'createTime DESC', 'condition' => 'status=' . Post::STATUS_PUBLISHED));
     $pages = Page::model()->findAll(array('order' => 'createTime DESC', 'condition' => 'status=' . Page::STATUS_PUBLISHED));
     header('Content-Type: application/xml');
     $this->renderPartial('../site/sitemapxml', array('posts' => $posts, 'pages' => $pages));
 }
开发者ID:Greka163,项目名称:Yii-blog-new,代码行数:10,代码来源:SiteController.php

示例15: actionUpdate

 /**
  * Create or update new page
  * @param boolean $new
  */
 public function actionUpdate($new = false)
 {
     if ($new === true) {
         $model = new Page();
     } else {
         $model = Page::model()->cache($this->cacheTime)->language(Yii::app()->language->active)->findByPk($_GET['id']);
     }
     $this->breadcrumbs = array(Yii::t('PagesModule.default', 'MODULE_NAME') => $this->createUrl('index'), $model->isNewRecord ? $model->t('PAGE_TITLE', 0) : CHtml::encode($model->title));
     $this->pageName = $model->isNewRecord ? $model->t('PAGE_TITLE', 0) : $model->t('PAGE_TITLE', 1);
     if (!$model) {
         throw new CHttpException(404);
     }
     if (Yii::app()->request->isPostRequest) {
         $model->attributes = $_POST['Page'];
         if ($model->validate()) {
             $model->save();
             if ($model->in_menu == 1) {
                 $isset = MenuModel::model()->findByAttributes(array('url' => '/page/' . $model->seo_alias));
                 if (!isset($isset)) {
                     $menu = new MenuModel();
                     $menu->label = $model->title;
                     $menu->url = '/page/' . $model->seo_alias;
                     if ($menu->validate()) {
                         $menu->save(false, false);
                     }
                 }
             }
             $this->redirect(array('index'));
         }
     }
     $this->render('update', array('model' => $model));
 }
开发者ID:buildshop,项目名称:bs-common,代码行数:36,代码来源:DefaultController.php


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