示例#1
0
 public function run()
 {
     Yii::import('application.models.*');
     $path = Yii::app()->request->getParam('path');
     $id = Yii::app()->request->getParam('id');
     $widget = Yii::app()->request->getParam('widget');
     $data = AdminWidget::getWidgetDataByPath($widget);
     $modelName = $data['model'];
     $tableName = ActiveRecord::model($modelName)->tableName();
     $d = Yii::app()->db->createCommand('select MAX(sort),MIN(sort) FROM ' . $tableName . ' where active = 1')->queryRow(false);
     $max = intval($d[0]);
     $min = intval($d[1]);
     $pk = ActiveRecord::model($modelName)->tableSchema->primaryKey;
     $model = ActiveRecord::model($modelName)->findByPk($id);
     if ($model->sort != $max && $path == 'down' || $model->sort != $min && $path == 'up') {
         if ($path == 'down') {
             $s = $model->sort + 1;
             $c = Yii::app()->db->createCommand("update {$tableName} set sort = sort-1 where sort = {$s}")->execute();
             $r = Yii::app()->db->createCommand("update {$tableName} set sort = sort+1 where {$pk} = {$id}")->execute();
         } else {
             $s = $model->sort - 1;
             $c = Yii::app()->db->createCommand("update {$tableName} set sort = sort+1 where sort = {$s}")->execute();
             $r = Yii::app()->db->createCommand("update {$tableName} set sort = sort-1 where {$pk} = {$id}")->execute();
         }
     }
 }
 public function init()
 {
     //		var_dump($this->params);
     $this->modelName = !is_array($this->params['model']) ? $this->params['model'] : $this->params['model']['class'];
     if ($this->params['importPath']) {
         Yii::import($this->params['importPath']);
     }
     return parent::init();
 }
示例#3
0
 public function init()
 {
     $this->modelName = !is_array($this->params['model']) ? $this->params['model'] : $this->params['model']['class'];
     $this->id = Yii::app()->request->getParam('id', null);
     if ($this->params['importPath']) {
         Yii::import($this->params['importPath']);
     }
     return parent::init();
 }
示例#4
0
 public function init()
 {
     if ($this->params['importPath']) {
         Yii::import($this->params['importPath']);
     }
     $this->modelName = !is_array($this->params['model']) ? $this->params['model'] : $this->params['model']['class'];
     $this->returnUrl = "/admin/" . $this->params['path'];
     return parent::init();
 }
示例#5
0
 /**
  * This action uses to show widgets by name
  * @param $widget widget name from $panelSettings
  */
 public function actionShow($widget, $action = '', $id = '')
 {
     // var_dump($_REQUEST);
     // exit();
     $data = AdminWidget::getWidgetDataByPath($widget);
     if (!$data) {
         throw new CHttpException(404, 'Page not found');
     }
     if (!$action) {
         $this->render('show', array('widgetClass' => ucfirst($data['class']), 'data' => $data));
     } else {
         $widgetClass = AdminWidget::getWidgetNameByAction($action);
         // var_dump($wi)
         if ($widgetClass) {
             $this->render('show', array('widgetClass' => ucfirst($widgetClass), 'data' => $data));
         } else {
             throw new CHttpException(404, Yii::t('app', 'Page not found'));
         }
     }
 }