Пример #1
0
 public function actionUpdate()
 {
     if ($this->validateToken()) {
         $status = N2SmartsliderUpdateModel::getInstance()->update();
         $hasError = N2SS3::hasApiError($status);
         if (is_array($hasError)) {
             $this->redirect($hasError);
         } else {
             if ($hasError === false) {
                 N2Message::success(n2_('Smart Slider 3 updated to the latest version!'));
             }
         }
         $this->redirectToSliders();
     } else {
         $this->refresh();
     }
 }
Пример #2
0
 public function actionImportDemo()
 {
     $this->validateToken();
     $this->validatePermission('smartslider_edit');
     $key = 'http:' . base64_decode(N2Request::getVar('key'));
     if (strpos($key, 'http://smartslider3.com/') !== 0) {
         N2Message::error(sprintf(n2_('Import url is not valid: %s'), $key));
         $this->response->error();
     }
     $posts = array('action' => 'asset', 'asset' => $key);
     $result = N2SS3::api($posts);
     if (!is_string($result)) {
         $hasError = N2SS3::hasApiError($result['status'], array('key' => $key));
         if (is_array($hasError)) {
             $this->redirect($hasError);
         } else {
             if ($hasError !== false) {
                 $this->response->error();
             }
         }
     } else {
         N2Loader::import(array('models.Sliders', 'models.Slides'), 'smartslider');
         N2Loader::import('libraries.import', 'smartslider');
         $import = new N2SmartSliderImport();
         $sliderId = $import->import($result, 'clone', 1, false);
         if ($sliderId !== false) {
             N2Message::success(n2_('Slider imported.'));
             $this->response->redirect(array("slider/edit", array("sliderid" => $sliderId)));
         } else {
             N2Message::error(n2_('Import error!'));
             $this->response->error();
         }
     }
     $this->response->respond();
 }