コード例 #1
0
 /**
  * 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.
  */
 public function loadModel()
 {
     if ($this->_model === null) {
         if (isset($_GET['id'])) {
             $this->_model = ArtistType::model()->findbyPk($_GET['id']);
         }
         if ($this->_model === null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
     }
     return $this->_model;
 }
コード例 #2
0
ファイル: IndexAction.php プロジェクト: robebeye/MusicDream
 public function run($region = 1, $type = 2)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = 'proved=:proved';
     $criteria->params = array(':proved' => Artist::STATUS_PROVED);
     $criteria->order = "sort ASC,add_time DESC";
     $criteria->group = 'sort,id';
     $region = (int) $region;
     $type = (int) $type;
     $criteria->addSearchCondition('area_id', $region);
     $criteria->addSearchCondition('type_id', $type);
     $rawData = Artist::model()->findAll($criteria);
     $value = Yii::app()->cache->get('ARTISTS_' . $region . '_' . $type);
     if ($value === false) {
         $dataProvider = new CArrayDataProvider($rawData, array('id' => 'artist', 'pagination' => array('pageSize' => 500)));
         Yii::app()->cache->set('ARTISTS_' . $region . '_' . $type, $dataProvider, 10);
     } else {
         $dataProvider = $value;
     }
     $regionData = ArtistArea::model()->findByPk($region);
     $typeData = ArtistType::model()->findByPk($type);
     $this->render('index', array('dataProvider' => $dataProvider, 'region' => $region, 'type' => $type, 'regionData' => $regionData, 'typeData' => $typeData));
 }
コード例 #3
0
ファイル: _create.php プロジェクト: robebeye/MusicDream
$form = $this->beginWidget('CActiveForm', array('id' => 'artist-form', 'enableAjaxValidation' => true, 'htmlOptions' => array('enctype' => 'multipart/form-data')));
?>

	<p class="note">字段 <span class="required">*</span> 是必填的。</p>

	<?php 
echo $form->errorSummary($model);
?>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'type_id');
?>
		<?php 
//echo $form->textField($model,'type_id');
echo $form->dropDownList($model, 'type_id', ArtistType::getAll());
?>
		<?php 
echo $form->error($model, 'type_id');
?>
	</div>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'area_id');
?>
		<?php 
//echo $form->textField($model,'area_id');
echo $form->dropDownList($model, 'area_id', ArtistArea::getAll());
?>
		<?php 
コード例 #4
0
ファイル: admin.php プロジェクト: robebeye/MusicDream
<?php

$this->breadcrumbs = array('艺术家' => array('index'), '管理');
$this->menu = array(array('label' => '列出艺术家', 'url' => array('index')), array('label' => '增加艺术家', 'url' => array('create')));
Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('artist-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n");
?>

<h1>管理艺术家</h1>

<p>
你可以在每个搜索值之前输入一个对比符 (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
或 <b>=</b>) ,以指定对比如何完成。
</p>

<?php 
echo CHtml::link('高级搜索', '#', array('class' => 'search-button'));
?>
<div class="search-form" style="display:none">
<?php 
$this->renderPartial('_search', array('model' => $model));
?>
</div><!-- search-form -->

<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'artist-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'summaryText' => '这是 {start} 到 {end} 共 {count} 条记录', 'columns' => array(array('name' => 'type_id', 'value' => 'ArtistType::item($data->type_id)', 'filter' => ArtistType::items()), array('name' => 'area_id', 'value' => 'ArtistArea::item($data->area_id)', 'filter' => ArtistArea::items()), array('name' => 'name', 'type' => 'raw', 'value' => 'CHtml::link(CHtml::encode($data->name), $data->url)'), array('name' => 'proved', 'value' => 'Lookup::item("PROVED",$data->proved)', 'filter' => Lookup::items('PROVED')), array('name' => 'add_time', 'type' => 'datetime', 'filter' => false), array('class' => 'CButtonColumn'))));
コード例 #5
0
ファイル: ArtistType.php プロジェクト: robebeye/MusicDream
 /**
  * Loads the lookup items for the specified type from the database.
  * @param string the item type
  */
 private static function loadItems()
 {
     self::$_itemsLookup = array();
     $models = self::model()->findAll();
     foreach ($models as $model) {
         self::$_itemsLookup[$model->id] = $model->name;
     }
 }