Commits

Alexey Badenkov  committed 2c007ef

Несколько исправлений по новостям

  • Participants
  • Parent commits 32ee33a

Comments (0)

Files changed (5)

File www/protected/config/_urles.php

         '/catalog' => 'catalog/default/index',
 
         array(
-            'class' => 'application.modules.components.PaymentsRoute',
+            'class' => 'application.modules.shop.components.PaymentsRoute',
         ),
         '/order/<_a>/*' => 'shop/order/<_a>',
         '/cart' => 'shop/cart/index',

File www/protected/modules/news/controllers/AdminController.php

                 }
             } else {
                 Yii::app()->user->setFlash('error', CHtml::errorSummary($model)); 
-                    $this->setFlash('news', array('type'=>'error',
-                                              'message'=>CHtml::errorSummary($model)));
             }
         }
 
         if (isset($_POST['NewsItem'])) {
             $model->attributes = $_POST['NewsItem'];
             if ($model->save()) {
-                    
+                    Yii::app()->user->setFlash('success', 'Изменения успешно сохранены.');
 					if ($this->module->withCategories) {
-						$this->setFlash('news', array('type'=>'success',
-                                              'message'=>'Изменения успешно сохранены.'));
 						$this->redirect(array('index', 'category_id'=>$model->category_id));
                     } else {
-						$this->setFlash('news', array('type'=>'success',
-                                              'message'=>'Изменения успешно сохранены.'));
 						$this->redirect(array('index'));
                     }
 	
 				}
                 else {
-                    $this->setFlash('news', array('type'=>'error',
-                                              'message'=>CHtml::errorSummary($model)));
+                    Yii::app()->user->setFlash('error', CHtml::errorSummary($model));
 					//$this->redirect(array('index'));
                 }
             
         $model->delete();
 
         if (!Yii::app()->request->isAjaxRequest) {
+            Yii::app()->user->setFlash('success', 'Новость удалена успешно.');
             if ($this->module->withCategories) {
-			    $this->setFlash('news', array('type'=>'success',
-                                              'message'=>'Новость удалена успешно.'));
                 $this->redirect(array('index', 'category_id'=>$category_id));
             } else {
-			    $this->setFlash('news', array('type'=>'success',
-                                              'message'=>'Новость удалена успешно.'));
                 $this->redirect(array('index'));
             }
         }
             $model->attributes = $_POST['NewsCategory'];
 
             if ($model->save()) {
-			    $this->setFlash('news', array('type'=>'success',
-                                              'message'=>'Категория создана успешно.'));
+                Yii::app()->user->setFlash('success', 'Категория создана успешно.');
                 $this->redirect(array('index', 'category_id'=>$model->id));
             }
         }
             $model->attributes = $_POST['NewsCategory'];
 
             if ($model->save()) {
-			    $this->setFlash('news', array('type'=>'success',
-                                              'message'=>'Категория изменена успешно.'));
+                Yii::app()->user->setFlash('success', 'Категория изменена успешно.');
                 $this->redirect(array('index', 'category_id'=>$model->id));
             }
         }
         $model->delete();
 
         if (!Yii::app()->request->isAjaxRequest) {
-		    $this->setFlash('news', array('type'=>'success',
-                                              'message'=>'Категория удалена успешно.'));
+            Yii::app()->user->setFlash('success', 'Категория удалена успешно.');
             $this->redirect(array('index'));
         }
     }
 
         return $model;
     }
-
 }

File www/protected/modules/news/controllers/DefaultController.php

         $criteria = new CDbCriteria();
         $criteria->addCondition('status = :status');
         $criteria->addCondition('create_time <= :time');
-        $criteria->addCondition('expire_time >= :time');
+        $criteria->addCondition('expire_time >= :time OR expire_time IS NULL OR expire_time=0');
         $criteria->order = 'create_time DESC';
         $criteria->params = array(':status' => NewsItem::STATUS_PUBLISHED,
                                   ':time' => time());
         $criteria = new CDbCriteria();
         $criteria->addCondition('id = :id');
         $criteria->addCondition('create_time <= :time');
-        $criteria->addCondition('expire_time >= :time');
+        $criteria->addCondition('expire_time >= :time OR expire_time IS NULL OR expire_time=0');
         $criteria->addCondition('status = :status');
         $criteria->params = array(':id' => $id,
                                   ':time' => time(),

File www/protected/modules/news/models/NewsItem.php

     const RSS_INVISIBLE = 0;
     const RSS_VISIBLE = 1;
 
-
     /**
      * Returns the static model of the specified AR class.
      * @return news the static model class
     {
 
         return array(
-            array('category_id, createTime, expireTime, title, annotation, content, visible_in_rss, status', 'required'),
+            array('category_id, createTime,title, annotation, content, visible_in_rss, status', 'required'),
             array('logo_url, update_time, create_time, expire_time, author_id', 'safe')
         );
     }
     protected function afterFind()
     {
         $this->createTime = Yii::app()->dateFormatter->format('dd.MM.yyyy', $this->create_time);
-        $this->expireTime = Yii::app()->dateFormatter->format('dd.MM.yyyy', $this->expire_time);
+        if (!empty($this->expire_time)) {
+            $this->expireTime = Yii::app()->dateFormatter->format('dd.MM.yyyy', $this->expire_time);
+        }
     }
 
     public function beforeValidate()
             return false;
         }
         $this->create_time = CDateTimeParser::parse($this->createTime,'dd.MM.yyyy');
-        $this->expire_time = CDateTimeParser::parse($this->expireTime,'dd.MM.yyyy');
+        if (!empty($this->expireTime)) {
+            $this->expire_time = CDateTimeParser::parse($this->expireTime,'dd.MM.yyyy');
+        }
 
         return true;
     }

File www/protected/modules/news/views/admin/_form.php

 			<?php endif; ?>
 		<?php endif; ?>
 
-        <?php $form->textFieldRow($model, 'title', array('class' => 'span12')); ?>
+        <?php echo $form->textFieldRow($model, 'title', array('class' => 'span12')); ?>
 
 		<div class="control-group">
 			<?php echo CHtml::activeLabelEx($model, 'create_time'); ?>