Example #1
0
 /**
  * @return string
  */
 public function run()
 {
     $this->model->setAttributes($this->attributes);
     return $this->render('manage', ['model' => $this->model, 'attribute' => $this->attribute, 'list' => ArrayHelper::map(Magic::find()->where($this->attributes)->orderBy(['position' => SORT_ASC, 'id' => SORT_ASC])->all(), 'id', function ($row) {
         return $this->render('_item', ['row' => $row]);
     })]);
 }
Example #2
0
 /**
  * @param int $id
  * @return \app\modules\magic\models\Magic
  * @throws \yii\web\NotFoundHttpException
  */
 protected function findModel($id)
 {
     if (($model = Magic::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #3
0
 public function init()
 {
     /* @var $row Magic */
     $model = Magic::find()->where($this->options)->orderBy(['position' => SORT_ASC, 'id' => SORT_ASC])->all();
     foreach ($model as $row) {
         $type = $row->getType();
         $this->list = ArrayHelper::merge($this->list, [$type => [$row]]);
     }
     parent::init();
 }
Example #4
0
File: Magic.php Project: apurey/cmf
 /**
  * @return string
  */
 public function getPreviewUrl()
 {
     return DIRECTORY_SEPARATOR . Magic::getUploadDir() . DIRECTORY_SEPARATOR . $this->preview;
 }
Example #5
0
File: Page.php Project: apurey/cmf
 public function delete()
 {
     $images = Magic::find()->where(['module' => $this->formName(), 'group_id' => 0, 'record_id' => $this->id])->all();
     if ($images) {
         foreach ($images as $image) {
             $image->delete();
         }
     }
     parent::delete();
 }
Example #6
0
 /**
  * @param \app\modules\magic\models\Magic $model
  * @return string
  */
 protected function display(Magic $model)
 {
     $model->scenario = 'many';
     return $this->renderAjax('@app/modules/magic/widgets/views/manage', ['model' => $model, 'attribute' => $model::ATTRIBUTE, 'list' => ArrayHelper::map(Magic::find()->where(['module' => $model->module, 'group_id' => $model->group_id, 'record_id' => $model->record_id])->orderBy(['position' => SORT_ASC, 'id' => SORT_ASC])->all(), 'id', function ($row) {
         return $this->renderPartial('@app/modules/magic/widgets/views/_item', ['row' => $row]);
     })]);
 }