Beispiel #1
0
 /**
  * Manages all models.
  */
 public function actionAdmin()
 {
     $model = new Ad('search');
     $adverlist = Adver::getDropList();
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['Ad'])) {
         $model->attributes = $_GET['Ad'];
     }
     if ($model->pid == 0) {
         $model->pid = '';
     }
     if ($model->is_show == 0) {
         $model->is_show = '';
     }
     $this->render('admin', array('model' => $model, 'adverlist' => $adverlist));
 }
Beispiel #2
0
<?php

/* @var $this AdController */
/* @var $model Ad */
$this->breadcrumbs = array('Ads' => array('index'), $model->name);
?>

<h3 class="title">查看 广告 <?php 
echo $model->name;
?>
</h3>

<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('id', array('name' => 'pid', 'value' => Adver::getName($model->pid)), 'name', 'brief', array('name' => 'img', 'value' => CHtml::link(CHtml::image($model->img, '图片', array('width' => '150px')), $model->img, array("target" => "_blank")), 'type' => 'raw'), 'link', 'orderid', array('name' => 'is_show', 'value' => $model->is_show == 1 ? "是" : "否"), array('name' => 'create_uid', 'value' => User::getName($model->create_uid)), 'create_time', array('name' => 'update_uid', 'value' => User::getName($model->update_uid)), 'update_time')));
Beispiel #3
0
 public static function getName($id = '')
 {
     $condition = array('condition' => 'id=:id', 'params' => array('id' => $id));
     $dataRs = Adver::model()->find($condition);
     if ($dataRs) {
         return $dataRs['name'];
     } else {
         return '';
     }
 }
Beispiel #4
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.
  * @param integer $id the ID of the model to be loaded
  * @return Adver the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Adver::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }