Example #1
0
 public function actionEdit()
 {
     $this->validateToken();
     $this->validatePermission('smartslider_edit');
     $slidersModel = new N2SmartsliderSlidersModel();
     $sliderId = N2Request::getInt('sliderid');
     $slider = $slidersModel->get($sliderId);
     $this->validateDatabase($slider);
     $slidesModel = new N2SmartsliderSlidesModel();
     $this->validateDatabase($slidesModel->get(N2Request::getInt('slideid')));
     $response = array();
     if (N2Request::getInt('save')) {
         if ($slideId = $slidesModel->save(N2Request::getInt('slideid'), N2Request::getVar('slide'))) {
             N2Message::success(n2_('Slide saved.'));
             if (N2Request::getInt('static') == 1) {
                 $slideCount = $slidesModel->makeStatic(N2Request::getInt('slideid'));
                 if ($slideCount) {
                     N2Message::success(sprintf(n2_('%d static slides generated.'), $slideCount));
                     $this->response->redirect(array("slider/edit", array("sliderid" => $sliderId)));
                 }
             }
         }
     }
     $this->response->respond($response);
 }
Example #2
0
 public function actionEdit()
 {
     $this->validateToken();
     $this->validatePermission('smartslider_edit');
     $slidersModel = new N2SmartsliderSlidersModel();
     $sliderId = N2Request::getInt('sliderid');
     $slider = $slidersModel->get($sliderId);
     $this->validateDatabase($slider);
     $slidesModel = new N2SmartsliderSlidesModel();
     $this->validateDatabase($slidesModel->get(N2Request::getInt('slideid')));
     $response = array();
     if (N2Request::getInt('save')) {
         if (N2SmartSliderSettings::get('slide-as-file', 0) && isset($_FILES['slide']) && isset(N2Request::$storage['slide'])) {
             N2Request::$storage['slide']['slide'] = N2Filesystem::readFile($_FILES['slide']['tmp_name']);
         }
         if ($slideId = $slidesModel->save(N2Request::getInt('slideid'), N2Request::getVar('slide'))) {
             N2Message::success(n2_('Slide saved.'));
             if (N2Request::getInt('static') == 1) {
                 $slideCount = $slidesModel->makeStatic(N2Request::getInt('slideid'));
                 if ($slideCount) {
                     N2Message::success(sprintf(n2_('%d static slides generated.'), $slideCount));
                     $this->response->redirect(array("slider/edit", array("sliderid" => $sliderId)));
                 }
             }
         }
     }
     $this->response->respond($response);
 }