コード例 #1
0
 public function actionItems($id, $type = null)
 {
     // Find Model
     $gallery = GalleryService::findById($id);
     // Update/Render if exist
     if (isset($gallery)) {
         $gallery->type = $type;
         return $this->render('@cmsgears/module-core/admin/views/gallery/items', ['gallery' => $gallery, 'items' => $gallery->files]);
     }
     // Model not found
     throw new NotFoundHttpException(Yii::$app->cmgCoreMessage->getMessage(CoreGlobal::ERROR_NOT_FOUND));
 }
コード例 #2
0
 public function actionUpdateItem($id)
 {
     // Find Model
     $item = FileService::findById($id);
     // Update/Render if exist
     if (isset($item)) {
         if ($item->load(Yii::$app->request->post(), "File") && GalleryService::updateItem($item)) {
             // Trigger Ajax Success
             return AjaxUtil::generateSuccess(Yii::$app->cmgCoreMessage->getMessage(CoreGlobal::MESSAGE_REQUEST));
         } else {
             // Generate Errors
             $errors = AjaxUtil::generateErrorMessage($item);
             // Trigger Ajax Success
             return AjaxUtil::generateFailure(Yii::$app->cmgCoreMessage->getMessage(CoreGlobal::ERROR_REQUEST), $errors);
         }
     }
 }