Esempio n. 1
0
 public function run()
 {
     $ads = Ads::model()->find(array('condition' => 'block_id=:block_id and status=1', 'params' => array(':block_id' => $this->block_id)));
     if ($ads && !YII_DEBUG) {
         echo '<div class="clearfix"></div>';
         echo '<div id="ads' . $ads->block_id . '">';
         echo $ads->content;
         echo '</div>';
         echo '<div class="clearfix"></div>';
     } else {
         if ($ads && YII_DEBUG) {
             echo '<div class="clearfix"></div>';
             echo '<div id="ads' . $ads->block_id . '" class="debug" style="width:200px;height:200px;background-color: #cdc;">';
             echo '</div>';
             echo '<div class="clearfix"></div>';
         }
     }
     /*if($ads && $this->block_id == 2){
                $content = str_replace(array("\n","\r"), '', $ads->content);
                $js = "$(document).ready(function(){
                     var els = $('.org_item').length;
                     var randomEls = Math.floor((Math.random() * els) + 1);
                     console.log(randomEls)
                     $('.org_item').eq(randomEls-1).after('<div id=\"ads2\" class=\"ads2\"></div>');
                });";
                Yii::app()->getClientScript()->registerScript('ads_' . $this->block_id, $js, CClientScript::POS_END);
     
             }*/
 }
Esempio n. 2
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 Ads the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Ads::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Esempio n. 3
0
 public function getOne($keyid, $return = '')
 {
     if (!$keyid) {
         return false;
     }
     $item = Ads::model()->findByPk($keyid);
     if ($return != '') {
         return $item[$return];
     }
     return $item;
 }
 public function actionCheckAsRead()
 {
     $id = Yii::app()->request->getParam('id');
     $status = 'Error';
     $ads = Ads::model()->findByPk($id);
     if ($ads) {
         $ads->read_status = 1;
         if ($ads->save()) {
             $status = 'Ok';
         }
     }
     echo json_encode(array('status' => $status));
 }