예제 #1
0
 public function __construct($categories = null)
 {
     if ($categories === null) {
         $this->categories = PageCategory::model()->findAll();
     } else {
         $this->categories = $categories;
     }
 }
예제 #2
0
 public function testCategoryUrlUnique()
 {
     // Create new category with existing url
     $category = new PageCategory();
     $category->attributes = array('name' => 'Тест тест 2', 'description' => 'Category test desc', 'parent_id' => $this->PageCategory['PageCategory_2']['parent_id'], 'url' => $this->PageCategory['PageCategory_2']['url']);
     $this->assertTrue($category->save());
     $category = PageCategory::model()->findByPk($category->id);
     $this->assertTrue($category instanceof PageCategory);
     $this->assertEquals('fantastika-' . date('YmdHis'), $category->url);
 }
예제 #3
0
 /**
  * Delete category by Pk
  */
 public function actionDelete()
 {
     if (Yii::app()->request->isPostRequest) {
         $model = PageCategory::model()->findAllByPk($_REQUEST['id']);
         if (!empty($model)) {
             foreach ($model as $category) {
                 $category->delete();
             }
         }
         if (!Yii::app()->request->isAjaxRequest) {
             $this->redirect('index');
         }
     }
 }
예제 #4
0
 /**
  * Filter pages by category
  */
 public function actionList()
 {
     // Remove "pages/" from beginning
     $url = substr(Yii::app()->request->getPathInfo(), 6);
     $model = PageCategory::model()->withFullUrl($url)->find();
     if (!$model) {
         throw new CHttpException(404, Yii::t('PagesModule.core', 'Категория не найдена.'));
     }
     $criteria = Page::model()->published()->filterByCategory($model)->getDbCriteria();
     $count = Page::model()->count($criteria);
     $pagination = new CPagination($count);
     $pagination->pageSize = $model->page_size > 0 ? $model->page_size : $model->defaultPageSize;
     $pagination->applyLimit($criteria);
     $pages = Page::model()->findAll($criteria);
     $view = $this->setDesign($model, 'list');
     $this->render($view, array('model' => $model, 'pages' => $pages, 'pagination' => $pagination));
 }
예제 #5
0
 /**
  * `On after create new language` event.
  * Create default translation for each page object.
  * @param $event
  */
 public function insertTranslations($event)
 {
     Yii::import('application.modules.banners.models.Page');
     if (!$event->sender->isNewRecord) {
         return;
     }
     // Find all pages on default language and
     // make copy on new lang.
     $pages = Page::model()->language(Yii::app()->languageManager->default->id)->findAll();
     if ($pages) {
         foreach ($pages as $p) {
             $p->createTranslation($event->sender->getPrimaryKey());
         }
     }
     // Categories
     $categories = PageCategory::model()->language(Yii::app()->languageManager->default->id)->findAll();
     if ($categories) {
         foreach ($categories as $c) {
             $c->createTranslation($event->sender->getPrimaryKey());
         }
     }
 }
예제 #6
0
파일: updater.php 프로젝트: nazo/phpcondo
                break;
            case 'BlogPost':
                $type = 'ブログ';
                break;
            default:
                $type = '';
        }
        $content['Content']['type'] = $type;
        $Content->set($content);
        if (!$Content->save()) {
            $result = false;
        }
    }
    if ($result) {
        $this->setMessage('contents テーブルのデータ更新に成功しました。');
    } else {
        $this->setMessage('contents テーブルのデータ更新に失敗しました。', true);
    }
}
/**
 * page_categories データ更新
 */
App::import('Model', 'PageCategory');
$PageCategory = new PageCategory();
$data = array('PageCategory' => array('name' => 'smartphone', 'title' => 'スマートフォン', 'created' => date('Y-m-d H:i:s')));
$PageCategory->create($data);
if ($PageCategory->save()) {
    $this->setMessage('page_categories テーブルのデータ更新に成功しました。');
} else {
    $this->setMessage('page_categories テーブルのデータ更新に失敗しました。', true);
}
                </ul>
            </div>

            <div class="row">
                <div class="box col-md-12">
                    <div class="box-inner">
                        <div class="box-header well" data-original-title="">
                            <h2><i class="glyphicon glyphicon-edit"></i> Add / Edit Page Category</h2>


                        </div>
                        <div class="box-content">
                            <?php 
$id = Request::get("id");
if (is_numeric($id) && $id > 0) {
    $pagecategoryObj = new PageCategory();
    $pagecategoryObj->set("pagecategory_id", $id);
    $result = $pagecategoryObj->getName();
    if (count($result)) {
        $row = $result[0];
        $pagecategory_id = $row['id'];
        $pagecategory_name = $row['name'];
        $pagecategory_url = $row['url'];
        $pagecategory_status = $row['active'];
    }
}
?>
                            <div class="error"><?php 
echo Error::displayError();
?>
</div>
                            <div class="control-group">
                                <div class="error"><?php 
echo Error::displayError();
?>
</div>
                                <form action="" method="POST" enctype="multipart/form-data">
                                    <table class="table table-striped table-bordered bootstrap-datatable datatable responsive" >
                                        <tr>
                                            <td><label class="control-label" for="selectError">Category </label></td>
                                            <td>
                                                <div class="input-group" style="width: 50%">
                                                    <span class="input-group-addon"></span>
                                                    <select required="" name="category_id" class="form-control">
                                                        <option value="">--Select Category--</option>
                                                        <?php 
$pagecategoryObj = new PageCategory();
$rows = $pagecategoryObj->getAll();
foreach ($rows as $row) {
    $selected = "";
    if ($row['id'] == $category_id) {
        $selected = 'selected="selected"';
    }
    ?>
                                                            <option value="<?php 
    echo $row['id'];
    ?>
" <?php 
    echo $selected;
    ?>
><?php 
    echo $row['name'];
예제 #9
0
<?php

/** Display pages list **/
$this->pageHeader = Yii::t('PagesModule.core', 'Страницы');
$this->breadcrumbs = array('Home' => $this->createUrl('/admin'), Yii::t('PagesModule.core', 'Страницы'));
$this->topButtons = $this->widget('application.modules.admin.widgets.SAdminTopButtons', array('template' => array('create'), 'elements' => array('create' => array('link' => $this->createUrl('create'), 'title' => Yii::t('PagesModule.core', 'Создать страницу'), 'options' => array('icons' => array('primary' => 'ui-icon-plus'))))));
$this->widget('ext.sgridview.SGridView', array('dataProvider' => $dataProvider, 'id' => 'pagesListGrid', 'afterAjaxUpdate' => "function(){registerFilterDatePickers()}", 'filter' => $model, 'columns' => array(array('class' => 'CCheckBoxColumn'), array('class' => 'SGridIdColumn', 'name' => 'id'), array('name' => 'title', 'type' => 'raw', 'value' => 'CHtml::link(CHtml::encode($data->title), array("update", "id"=>$data->id))'), array('name' => 'url', 'type' => 'raw', 'value' => 'CHtml::link(CHtml::encode($data->url), $data->getViewUrl(), array("target"=>"_blank"))'), array('name' => 'category_id', 'type' => 'raw', 'value' => strtr('$data->category ? $data->category->getUpdateLink(): "{no}"', array('{no}' => Yii::t('PagesModule.core', 'Нет'))), 'filter' => PageCategory::keyValueList()), array('name' => 'user_id', 'type' => 'raw', 'value' => '$data->author->getUpdateLink()'), array('name' => 'status', 'value' => 'CHtml::encode($data->statusLabel)', 'filter' => Page::statuses()), 'publish_date', array('class' => 'CButtonColumn', 'template' => '{update}{delete}'))));
Yii::app()->clientScript->registerScript("pageDatepickers", "\n\t\tfunction registerFilterDatePickers(id, data){\n\t\t\tjQuery('input[name=\"Page[publish_date]\"]').datepicker({\n\t\t\t\tdateFormat:'yy-mm-dd',\n\t\t\t\tconstrainInput: false\n\t\t\t});\n\t\t}\n\t\tregisterFilterDatePickers();\n\t");
예제 #10
0
<?php

/*** Create/update page form ***/
Yii::import('zii.widgets.jui.CJuiDatePicker');
return array('id' => 'pageUpdateForm', 'showErrorSummary' => true, 'elements' => array('content' => array('type' => 'form', 'title' => Yii::t('PagesModule.core', 'Содержимое'), 'elements' => array('title' => array('type' => 'text'), 'url' => array('type' => 'text'), 'category_id' => array('type' => 'dropdownlist', 'items' => PageCategory::keyValueList(), 'empty' => '---'), 'short_description' => array('type' => 'SRichTextarea'), 'full_description' => array('type' => 'SRichTextarea'))), 'seo' => array('type' => 'form', 'title' => Yii::t('PagesModule.core', 'Мета данные'), 'elements' => array('meta_title' => array('type' => 'text'), 'meta_keywords' => array('type' => 'textarea'), 'meta_description' => array('type' => 'textarea'))), 'additional' => array('type' => 'form', 'title' => Yii::t('PagesModule.core', 'Дополнительно'), 'elements' => array('status' => array('type' => 'dropdownlist', 'items' => Page::statuses()), 'publish_date' => array('type' => 'CJuiDatePicker', 'options' => array('dateFormat' => 'yy-mm-dd ' . date('H:i:s'))), 'layout' => array('type' => 'text'), 'view' => array('type' => 'text')))));
예제 #11
0
 /**
  * Count and cache categories by url
  *
  * @param $pathInfo
  * @return int|mixed
  */
 public static function countByPath($pathInfo)
 {
     $count = Yii::app()->cache->get(__CLASS__ . $pathInfo);
     if ($count === false) {
         $model = PageCategory::model()->withFullUrl($pathInfo)->find();
         if ($model) {
             $count = 1;
         } else {
             $count = 0;
         }
     }
     Yii::app()->cache->set('page_category_' . $pathInfo, $count, 3600);
     return $count;
 }
                        <i class="glyphicon glyphicon-edit icon-white"></i>
                        Add 
                    </a><br/><br/>
                    <table class="table table-striped table-bordered bootstrap-datatable datatable responsive">
                        <thead>
                            <tr>
                                <th>Id</th>
                                <th>Name </th>
                                <th>URL</th>
                                <th>Status</th>
                                <th>Actions</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php 
$pageObj = new PageCategory();
$rows = $pageObj->getAll();
foreach ($rows as $row) {
    ?>
 
                                <tr>
                                    <td><?php 
    echo $row['id'];
    ?>
</td>
                                    <td class="center"><?php 
    echo $row['name'];
    ?>
</td>
                                    <td class="center"><?php 
    echo $row['url'];
예제 #13
0
 public function getCategory($id)
 {
     return PageCategory::model()->findByPk($id);
 }
예제 #14
0
<?php

/*** Create/update page form ***/
return array('id' => 'pageUpdateForm', 'showErrorSummary' => true, 'elements' => array('content' => array('type' => 'form', 'title' => Yii::t('PagesModule.core', 'Параметры'), 'elements' => array('name' => array('type' => 'text'), 'url' => array('type' => 'text'), 'parent_id' => array('type' => 'dropdownlist', 'items' => PageCategory::keyValueList(), 'empty' => '---', 'options' => array($this->model->id => array('disabled' => true))), 'description' => array('type' => 'SRichTextarea'))), 'seo' => array('type' => 'form', 'title' => Yii::t('PagesModule.core', 'Мета данные'), 'elements' => array('meta_title' => array('type' => 'text'), 'meta_keywords' => array('type' => 'textarea'), 'meta_description' => array('type' => 'textarea'))), 'design' => array('type' => 'form', 'title' => Yii::t('PagesModule.core', 'Внешний вид'), 'elements' => array('page_size' => array('type' => 'text'), 'layout' => array('type' => 'text'), 'view' => array('type' => 'text')))));