/**
  * Manages all models.
  */
 public function actionManage()
 {
     $category = new BannerCategory('search');
     $category->unsetAttributes();
     // clear any default values
     if (isset($_GET['BannerCategory'])) {
         $category->attributes = $_GET['BannerCategory'];
     }
     $columnTemp = array();
     if (isset($_GET['GridColumn'])) {
         foreach ($_GET['GridColumn'] as $key => $val) {
             if ($_GET['GridColumn'][$key] == 1) {
                 $columnTemp[] = $key;
             }
         }
     }
     $columns = $category->getGridColumn($columnTemp);
     $model = $this->loadModel(1);
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['BannerSetting'])) {
         $model->attributes = $_POST['BannerSetting'];
         $jsonError = CActiveForm::validate($model);
         if (strlen($jsonError) > 2) {
             $errors = $model->getErrors();
             $summary['msg'] = "<div class='errorSummary'><strong>" . Yii::t('phrase', 'Please fix the following input errors:') . "</strong>";
             $summary['msg'] .= "<ul>";
             foreach ($errors as $key => $value) {
                 $summary['msg'] .= "<li>{$value[0]}</li>";
             }
             $summary['msg'] .= "</ul></div>";
             $message = json_decode($jsonError, true);
             $merge = array_merge_recursive($summary, $message);
             $encode = json_encode($merge);
             echo $encode;
         } else {
             if (isset($_GET['enablesave']) && $_GET['enablesave'] == 1) {
                 if ($model->save()) {
                     echo CJSON::encode(array('type' => 0, 'msg' => '<div class="errorSummary success"><strong>' . Yii::t('phrase', 'Banner setting success updated.') . '</strong></div>'));
                 } else {
                     print_r($model->getErrors());
                 }
             }
         }
     } else {
         $this->pageTitle = Yii::t('phrase', 'Banner Settings');
         $this->pageDescription = '';
         $this->pageMeta = '';
         $this->render('admin_manage', array('model' => $model, 'category' => $category, 'columns' => $columns));
     }
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = BannerCategory::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 /**
  * Set default columns to display
  */
 protected function afterConstruct()
 {
     if (count($this->defaultColumns) == 0) {
         /*
         $this->defaultColumns[] = array(
         	'class' => 'CCheckBoxColumn',
         	'name' => 'id',
         	'selectableRows' => 2,
         	'checkBoxHtmlOptions' => array('name' => 'trash_id[]')
         );
         */
         $this->defaultColumns[] = array('header' => 'No', 'value' => '$this->grid->dataProvider->pagination->currentPage*$this->grid->dataProvider->pagination->pageSize + $row+1');
         $this->defaultColumns[] = array('name' => 'title', 'value' => '$data->url != "-" ? CHtml::link($data->title, $data->url, array(\'target\' => \'_blank\')) : $data->title', 'type' => 'raw');
         if (!isset($_GET['category'])) {
             $this->defaultColumns[] = array('name' => 'cat_id', 'value' => 'Phrase::trans($data->category_relation->name, 2)', 'filter' => BannerCategory::getCategory(), 'type' => 'raw');
         }
         /*
         $this->defaultColumns[] = array(
         	'name' => 'media',
         	'value' => '$data->media != "" ? CHtml::link($data->media, Yii::app()->request->baseUrl.\'/public/banner/\'.$data->media, array(\'target\' => \'_blank\')) : "-"',
         	'type' => 'raw',
         );
         */
         $this->defaultColumns[] = array('name' => 'click', 'value' => '$data->url != "-" ? $data->click : "-"', 'htmlOptions' => array('class' => 'center'));
         $this->defaultColumns[] = array('name' => 'published_date', 'value' => 'Utility::dateFormat($data->published_date)', 'htmlOptions' => array('class' => 'center'), 'filter' => Yii::app()->controller->widget('zii.widgets.jui.CJuiDatePicker', array('model' => $this, 'attribute' => 'published_date', 'language' => 'ja', 'i18nScriptFile' => 'jquery.ui.datepicker-en.js', 'htmlOptions' => array('id' => 'published_date_filter'), 'options' => array('showOn' => 'focus', 'dateFormat' => 'dd-mm-yy', 'showOtherMonths' => true, 'selectOtherMonths' => true, 'changeMonth' => true, 'changeYear' => true, 'showButtonPanel' => true)), true));
         $this->defaultColumns[] = array('name' => 'expired_date', 'value' => '!in_array($data->expired_date, array("0000-00-00","1970-01-01")) ? Utility::dateFormat($data->expired_date) : "Permanent"', 'htmlOptions' => array('class' => 'center'), 'filter' => Yii::app()->controller->widget('zii.widgets.jui.CJuiDatePicker', array('model' => $this, 'attribute' => 'expired_date', 'language' => 'ja', 'i18nScriptFile' => 'jquery.ui.datepicker-en.js', 'htmlOptions' => array('id' => 'expired_date_filter'), 'options' => array('showOn' => 'focus', 'dateFormat' => 'dd-mm-yy', 'showOtherMonths' => true, 'selectOtherMonths' => true, 'changeMonth' => true, 'changeYear' => true, 'showButtonPanel' => true)), true));
         /* $this->defaultColumns[] = array(
         				'name' => 'creation_search',
         				'value' => '$data->creation_relation->displayname',
         			);
         			$this->defaultColumns[] = array(
         				'name' => 'creation_date',
         				'value' => 'Utility::dateFormat($data->creation_date)',
         				'htmlOptions' => array(
         					'class' => 'center',
         				),
         				'filter' => Yii::app()->controller->widget('zii.widgets.jui.CJuiDatePicker', array(
         					'model'=>$this,
         					'attribute'=>'creation_date',
         					'language' => 'ja',
         					'i18nScriptFile' => 'jquery.ui.datepicker-en.js',
         					//'mode'=>'datetime',
         					'htmlOptions' => array(
         						'id' => 'creation_date_filter',
         					),
         					'options'=>array(
         						'showOn' => 'focus',
         						'dateFormat' => 'dd-mm-yy',
         						'showOtherMonths' => true,
         						'selectOtherMonths' => true,
         						'changeMonth' => true,
         						'changeYear' => true,
         						'showButtonPanel' => true,
         					),
         				), true),
         			); */
         if (!isset($_GET['type'])) {
             $this->defaultColumns[] = array('name' => 'publish', 'value' => 'Utility::getPublish(Yii::app()->controller->createUrl("publish",array("id"=>$data->banner_id)), $data->publish, 1)', 'htmlOptions' => array('class' => 'center'), 'filter' => array(1 => Yii::t('phrase', 'Yes'), 0 => Yii::t('phrase', 'No')), 'type' => 'raw');
         }
     }
     parent::afterConstruct();
 }
示例#4
0
<?php

$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'content-category-form', 'enableAjaxValidation' => false));
?>
<p class="help-block">Fields with <span class="required">*</span> are required.</p>
<?php 
echo $form->errorSummary($model);
?>
<div class="row-fluid">
    <div class="span12">
        <?php 
if ($model->isNewRecord) {
    echo BannerCategory::get_category_new('BannerCategory', 'parent_id');
} else {
    echo BannerCategory::get_category_update('BannerCategory', 'parent_id', $model->parent_id);
}
?>
    </div>
</div>
<?php 
echo $form->textFieldControlGroup($model, 'title', array('class' => 'span5', 'maxlength' => 255));
echo $form->labelEx($model, 'description');
$this->widget('application.extensions.xheditor.JXHEditor', array('model' => $model, 'attribute' => 'description', 'htmlOptions' => array('class' => 'xheditor', 'style' => 'width: 100%; height: 150px;')));
echo $form->dropDownListControlGroup($model, 'published', array('1' => 'Yes', '0' => 'No'));
?>
<div class="form-actions">
    <?php 
echo TbHtml::submitButton($model->isNewRecord ? 'Create' : 'Save', array('color' => TbHtml::BUTTON_COLOR_PRIMARY));
?>
    <?php 
echo TbHtml::resetButton('Reset', array('color' => TbHtml::BUTTON_COLOR_INFO));
示例#5
0
        </div>
        <div class="widget-toolbar">
            <?php 
echo CHtml::link('<i class="icon-search"></i>', '#', array('class' => 'search-button', 'data-rel' => 'tooltip', 'title' => 'Search', 'data-placement' => 'bottom'));
?>
        </div>
    </div><!--/.widget-header -->
    <div class="widget-body">
        <div class="widget-main">
            <div class="search-form" style="display:none">
                <?php 
$this->renderPartial('_search', array('model' => $model));
?>
            </div><!-- search-form -->
            <?php 
$this->widget('bootstrap.widgets.TbGridView', array('type' => TbHtml::GRID_TYPE_HOVER, 'id' => 'banner-category-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('name' => 'parent_id', 'type' => 'raw', 'value' => 'getCategoryName($data->parent_id)', 'filter' => BannerCategory::get_category_new('BannerCategory', 'parent_id'), 'htmlOptions' => array('style' => "text-align:left;", 'title' => 'Parent Category')), 'title', array('name' => 'description', 'type' => 'raw', 'value' => '$data->description', 'htmlOptions' => array('style' => "text-align:left;", 'title' => 'Description')), array('name' => 'published', 'header' => "Status", 'value' => '$data->published?Yii::t(\'app\',\'Active\'):Yii::t(\'app\', \'Inactive\')', 'filter' => array('' => Yii::t('app', 'All'), '0' => Yii::t('app', 'Inactive'), '1' => Yii::t('app', 'Active')), 'htmlOptions' => array('style' => "text-align:center;")), array('header' => 'Actions', 'class' => 'bootstrap.widgets.TbButtonColumn'))));
/**
 * Retrieves Category name by ID.
 * @return string.
 */
function getCategoryName($id)
{
    $returnValue = Yii::app()->db->createCommand()->select('title')->from('{{banner_category}}')->where('id=:id', array(':id' => $id))->queryScalar();
    if ($returnValue <= '0') {
        $returnValue = 'No parent!';
    } else {
        $returnValue = $returnValue;
    }
    return $returnValue;
}
?>
示例#6
0
<?php

$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('action' => Yii::app()->createUrl($this->route), 'method' => 'get'));
echo $form->dropDownListControlGroup($model, 'parent_id', CHtml::listData(BannerCategory::model()->findAll(array('condition' => 'parent_id=0', "order" => "title")), 'id', 'title'), array('empty' => '--please select--', 'class' => 'span5'));
echo $form->textFieldControlGroup($model, 'title', array('class' => 'span5', 'maxlength' => 255));
?>
<div class="form-actions">
    <?php 
echo TbHtml::submitButton('Search', array('color' => TbHtml::BUTTON_COLOR_PRIMARY));
?>
    <?php 
echo TbHtml::resetButton('Reset', array('color' => TbHtml::BUTTON_COLOR_INFO));
?>
</div>

<?php 
$this->endWidget();
示例#7
0
        <div class="widget-toolbar">
            <a data-action="settings" href="#"><i class="icon-cog"></i></a>
            <a data-action="reload" href="#"><i class="icon-refresh"></i></a>
            <a data-action="collapse" href="#"><i class="icon-chevron-up"></i></a>
            <a data-action="close" href="#"><i class="icon-remove"></i></a>
        </div>
        <div class="widget-toolbar">
            <?php 
echo CHtml::link('<i class="icon-plus"></i>', array('create'), array('data-rel' => 'tooltip', 'title' => 'Add', 'data-placement' => 'bottom'));
?>
        </div>
        <div class="widget-toolbar">
            <?php 
echo CHtml::link('<i class="icon-search"></i>', '#', array('class' => 'search-button', 'data-rel' => 'tooltip', 'title' => 'Search', 'data-placement' => 'bottom'));
?>
        </div>
    </div><!--/.widget-header -->
    <div class="widget-body">
        <div class="widget-main">
            <div class="search-form" style="display:none">
                <?php 
$this->renderPartial('_search', array('model' => $model));
?>
            </div><!-- search-form -->
            <?php 
$this->widget('bootstrap.widgets.TbGridView', array('id' => 'banner-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('name' => 'catid', 'type' => 'raw', 'value' => 'DocumentCategory::getCategoryName($data->catid)', 'filter' => BannerCategory::get_category_new('Banner', 'catid'), 'htmlOptions' => array('style' => "text-align:left;", 'title' => 'Banner Category')), 'name', 'clickurl', array('name' => 'ordering', 'type' => 'raw', 'value' => '$data->ordering', 'htmlOptions' => array('style' => "text-align:center; width:50px;", 'title' => 'Ordering')), array('header' => 'Actions', 'class' => 'bootstrap.widgets.TbButtonColumn'))));
?>
        </div>
    </div><!--/.widget-body -->
</div><!--/.widget-box -->
echo $form->errorSummary($model);
?>
</div>
<?php 
//begin.Messages
?>

<fieldset>

	<div class="clearfix">
		<?php 
echo $form->labelEx($model, 'cat_id');
?>
		<div class="desc">
			<?php 
$category = BannerCategory::getCategory(1);
if ($category != null) {
    echo $form->dropDownList($model, 'cat_id', $category);
} else {
    echo $form->dropDownList($model, 'cat_id', array('prompt' => 'No Parent'));
}
echo $form->error($model, 'cat_id');
?>
			<?php 
/*<div class="small-px silent"></div>*/
?>
		</div>
	</div>

	<div class="clearfix">
		<?php 
示例#9
0
<?php

$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'banner-form', 'enableAjaxValidation' => false, 'htmlOptions' => array('enctype' => 'multipart/form-data')));
?>
<p class="help-block">Fields with <span class="required">*</span> are required.</p>

<?php 
echo $form->errorSummary($model);
?>
<div class="row-fluid">
    <div class="span12">
        <?php 
if ($model->isNewRecord) {
    echo BannerCategory::get_category_new('Banner', 'catid');
} else {
    echo BannerCategory::get_category_update('Banner', 'catid', $model->catid);
}
?>
    </div>
</div>
<?php 
echo $form->textFieldControlGroup($model, 'name', array('class' => 'span5', 'maxlength' => 255));
?>
<div class="row-fluid">
    <div class="span5">
        <?php 
echo $form->fileFieldControlGroup($model, 'banner', array('maxlength' => 255, 'class' => 'span12'));
?>
    </div>
</div>
<?php