Ejemplo n.º 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 (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);
 }
Ejemplo n.º 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 ($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);
 }
Ejemplo n.º 3
0
 public function actionEdit()
 {
     $this->validateToken();
     $this->validatePermission('smartslider_edit');
     if (N2Request::getInt('save')) {
         $slidersModel = new N2SmartsliderSlidersModel();
         $slider = $slidersModel->get(N2Request::getInt('sliderid'));
         $this->validateDatabase($slider);
         if ($sliderid = $slidersModel->save($slider['id'], N2Request::getVar('slider'))) {
             N2Message::success(n2_('Slider saved.'));
             $this->response->respond();
         }
     }
     $response = null;
     $id = N2Request::getCmd('id');
     $ajaxModel = new N2SmartSliderAjaxModel();
     ob_start();
     switch ($id) {
         case 'slidertype':
             $response = $ajaxModel->sliderType($this->appType);
             break;
         case 'sliderresponsivemode':
             $response = $ajaxModel->sliderResponsiveMode($this->appType);
             break;
         case 'sliderwidgetarrow':
             $response = $ajaxModel->sliderWidget($this->appType, 'arrow');
             break;
         case 'sliderwidgetbullet':
             $response = $ajaxModel->sliderWidget($this->appType, 'bullet');
             break;
         case 'sliderwidgetautoplay':
             $response = $ajaxModel->sliderWidget($this->appType, 'autoplay');
             break;
         case 'sliderwidgetindicator':
             $response = $ajaxModel->sliderWidget($this->appType, 'indicator');
             break;
         case 'sliderwidgetfullscreen':
             $response = $ajaxModel->sliderWidget($this->appType, 'fullscreen');
             break;
         case 'sliderwidgetbar':
             $response = $ajaxModel->sliderWidget($this->appType, 'bar');
             break;
         case 'sliderwidgetthumbnail':
             $response = $ajaxModel->sliderWidget($this->appType, 'thumbnail');
             break;
         case 'sliderwidgetshadow':
             $response = $ajaxModel->sliderWidget($this->appType, 'shadow');
             break;
         case 'sliderwidgethtml':
             $response = $ajaxModel->sliderWidget($this->appType, 'html');
             break;
     }
     if ($response == null) {
         $response = array('html' => '', 'script' => '');
     }
     $response['html'] .= ob_get_clean();
     $this->response->respond($response);
 }
Ejemplo n.º 4
0
 public function actionDuplicate()
 {
     if ($this->validateToken() && $this->validatePermission('smartslider_edit')) {
         $slidersModel = new N2SmartsliderSlidersModel();
         if (($sliderid = N2Request::getInt('sliderid')) && $slidersModel->get($sliderid)) {
             $newSliderId = $slidersModel->duplicate($sliderid);
             N2Message::success(n2_('Slider duplicated.'));
             $this->redirect(array("slider/edit", array("sliderid" => $newSliderId)));
         }
         $this->redirectToSliders();
     }
 }
Ejemplo n.º 5
0
 public function actionClearCache()
 {
     if ($this->validatePermission('smartslider_config')) {
         if ($this->validateToken()) {
             $slidersModel = new N2SmartsliderSlidersModel();
             foreach ($slidersModel->getAll() as $slider) {
                 $slidersModel->refreshCache($slider['id']);
             }
             N2Cache::clearGroup('n2-ss-0');
             N2Cache::clearGroup('combined');
             N2Message::success(n2_('Cache cleared.'));
         }
         $this->redirect(array("settings/default"));
     }
 }
Ejemplo n.º 6
0
 public function actionCreateSettings()
 {
     if ($this->validatePermission('smartslider_edit')) {
         $slidersModel = new N2SmartsliderSlidersModel();
         if (!($slider = $slidersModel->get(N2Request::getInt('sliderid')))) {
             $this->redirectToSliders();
         }
         if (N2Request::getInt('save')) {
             $generatorModel = new N2SmartsliderGeneratorModel();
             $result = $generatorModel->createGenerator($slider['id'], N2Request::getVar('generator'));
             N2Message::success(n2_('Generator created.'));
             $this->redirect(array("slides/edit", array("sliderid" => $slider['id'], "slideid" => $result['slideId'])), 302, true);
         }
         $this->addView("create_settings", array('slider' => $slider));
         $this->render();
     }
 }
Ejemplo n.º 7
0
 public function actionEdit()
 {
     if ($this->validatePermission('smartslider_edit')) {
         $slidersModel = new N2SmartsliderSlidersModel();
         $sliderId = N2Request::getInt('sliderid');
         $slider = $slidersModel->get($sliderId);
         if ($this->validateDatabase($slider)) {
             $slidesModel = new N2SmartsliderSlidesModel();
             if (!$slidesModel->get(N2Request::getInt('slideid'))) {
                 $this->redirect("sliders/index");
             }
             $this->initAdminSlider();
             $this->addView("../../inline/_sidebar_slide", array("appObj" => $this, "slider" => $slider), "sidebar");
             $this->addView("edit", array("slidesModel" => new N2SmartsliderSlidesModel(), "sliderId" => $sliderId));
             $this->render();
         }
     }
 }
Ejemplo n.º 8
0
 public function actionExportAll()
 {
     N2Loader::import('libraries.export', 'smartslider');
     $slidersModel = new N2SmartsliderSlidersModel();
     $sliders = $slidersModel->getAll();
     foreach ($sliders as $slider) {
         $export = new N2SmartSliderExport($slider['id']);
         $export->create(true);
     }
     $folder = N2Platform::getPublicDir();
     $folder .= '/export/';
     $zip = new N2ZipFile();
     foreach (N2Filesystem::files($folder) as $file) {
         $zip->addFile(file_get_contents($folder . $file), $file);
     }
     ob_end_clean();
     header('Content-disposition: attachment; filename=sliders_unzip_to_import.zip');
     header('Content-type: application/zip');
     echo $zip->file();
     n2_exit(true);
 }
Ejemplo n.º 9
0
 public function loadSlider()
 {
     $slidersModel = new N2SmartsliderSlidersModel();
     $slider = $slidersModel->get($this->sliderId);
     if (empty($slider)) {
         return false;
     }
     if (isset($this->parameters['extend']['sliderData']) && is_array($this->parameters['extend']['sliderData'])) {
         $sliderData = $this->parameters['extend']['sliderData'];
         $slider['title'] = $sliderData['title'];
         unset($sliderData['title']);
         $slider['type'] = $sliderData['type'];
         unset($sliderData['type']);
         $this->data = new N2Data($slider);
         $this->params = new N2Data($sliderData);
     } else {
         $this->data = new N2Data($slider);
         $this->params = new N2Data($slider['params'], true);
     }
     $this->sliderType = $this->getSliderTypeResource('type');
     $this->params->fillDefault($this->sliderType->getDefaults());
     $this->sliderType->limitParams($this->params);
     $this->features = new N2SmartSliderFeatures($this);
     $this->initSlides();
     return true;
 }
Ejemplo n.º 10
0
 public function renderRestoreFromServerForm()
 {
     N2SmartsliderSlidersModel::renderRestoreFromServerForm();
 }
Ejemplo n.º 11
0
 /**
  * @param array $data
  */
 private function editForm($data = array())
 {
     $this->simpleEditForm($data);
     $slidersModel = new N2SmartsliderSlidersModel();
     $slider = $slidersModel->get(N2Request::getInt('sliderid', 0));
     $slidersSliderXml = call_user_func(array('N2SSPluginType' . $slider['type'], "getPath")) . '/slide.xml';
     if ((!isset($data['static-slide']) || $data['static-slide'] != 1) && N2Filesystem::existsFile($slidersSliderXml)) {
         $form = new N2Form();
         $form->loadArray($data);
         $form->loadXMLFile($slidersSliderXml);
         echo $form->render('slide');
     }
     if (isset($data['generator_id']) && $data['generator_id'] > 0) {
         $form = new N2Form();
         $form->loadArray($data);
         $form->loadXMLFile(dirname(__FILE__) . '/forms/slide_generator.xml');
         echo $form->render('slide');
     }
     N2JS::addFirstCode("new NextendForm('smartslider-form','', {});");
 }
Ejemplo n.º 12
0
 public function createHTML($isZIP = true)
 {
     $this->files = array();
     ob_end_clean();
     N2AssetsManager::createStack();
     N2AssetsPredefined::frontend(true);
     ob_start();
     N2Base::getApplication("smartslider")->getApplicationType('widget')->render(array("controller" => 'home', "action" => N2Platform::getPlatform(), "useRequest" => false), array($this->sliderId, 'Export as HTML'));
     $slidersModel = new N2SmartsliderSlidersModel();
     $slider = $slidersModel->get($this->sliderId);
     $sliderHTML = ob_get_clean();
     $headHTML = '';
     $css = N2AssetsManager::getCSS(true);
     foreach ($css['url'] as $url) {
         $headHTML .= N2Html::style($url, true, array('media' => 'screen, print')) . "\n";
     }
     array_unshift($css['files'], N2LIBRARYASSETS . '/normalize.css');
     foreach ($css['files'] as $file) {
         $path = 'css/' . basename($file);
         $this->files[$path] = file_get_contents($file);
         $headHTML .= N2Html::style($path, true, array('media' => 'screen, print')) . "\n";
     }
     if ($css['inline'] != '') {
         $headHTML .= N2Html::style($css['inline']) . "\n";
     }
     $js = N2AssetsManager::getJs(true);
     if ($js['globalInline'] != '') {
         $headHTML .= N2Html::script($js['globalInline']) . "\n";
     }
     foreach ($js['url'] as $url) {
         $headHTML .= N2Html::script($url, true) . "\n";
     }
     foreach ($js['files'] as $file) {
         $path = 'js/' . basename($file);
         $this->files[$path] = file_get_contents($file);
         $headHTML .= N2Html::script($path, true) . "\n";
     }
     if ($js['inline'] != '') {
         $headHTML .= N2Html::script($js['inline']) . "\n";
     }
     $sliderHTML = preg_replace_callback('/(src|data-desktop|data-tablet|data-mobile)=["|\'](.*?)["|\']/i', array($this, 'replaceHTMLImage'), $sliderHTML);
     $sliderHTML = preg_replace_callback('/url\\(\\s*([\'"]|('))?(\\S*\\.(?:jpe?g|gif|png))([\'"]|('))?\\s*\\)[^;}]*?/i', array($this, 'replaceHTMLBGImage'), $sliderHTML);
     $sliderHTML = preg_replace_callback('/(n2-lightbox-urls)=["|\'](.*?)["|\']/i', array($this, 'replaceLightboxImages'), $sliderHTML);
     $headHTML = preg_replace_callback('/"([^"]*?\\.(jpg|png|gif|jpeg))"/i', array($this, 'replaceJSON'), $headHTML);
     $this->files['index.html'] = "<!doctype html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge, chrome=1\">\n<title>" . $slider['title'] . "</title>\n" . $headHTML . "</head>\n<body>\n" . $sliderHTML . "</body>\n</html>";
     if (!$isZIP) {
         return $this->files;
     }
     $zip = new N2ZipFile();
     foreach ($this->files as $path => $content) {
         $zip->addFile($content, $path);
     }
     ob_end_clean();
     header('Content-disposition: attachment; filename=' . preg_replace('/[^a-zA-Z0-9_-]/', '', $slider['title']) . '.zip');
     header('Content-type: application/zip');
     echo $zip->file();
     n2_exit(true);
 }
Ejemplo n.º 13
0
 public function import($filePathOrData, $imageImportMode = 'clone', $linkedVisuals = 1, $isFilePath = true)
 {
     $zip = new N2ZipRead();
     $importData = $zip->read_zip($filePathOrData, $isFilePath);
     if (!isset($importData['data'])) {
         if (array_key_exists("slider.ss2", $importData)) {
             N2Message::error(n2_('You can\'t import sliders from Smart Slider 2.'));
         }
         return false;
     }
     $this->backup = unserialize($importData['data']);
     $this->sectionTranslation = array();
     $this->importVisuals($this->backup->visuals, $linkedVisuals);
     $sliderModel = new N2SmartsliderSlidersModel();
     if ($this->restore) {
         $this->sliderId = $sliderModel->restore($this->backup->slider);
     } else {
         $this->sliderId = $sliderModel->import($this->backup->slider);
     }
     if (!$this->sliderId) {
         return false;
     }
     switch ($imageImportMode) {
         case 'clone':
             $images = $importData['images'];
             $imageStore = new N2StoreImage('slider' . $this->sliderId, true);
             foreach ($images as $file => $content) {
                 $localImage = $imageStore->makeCache($file, $content);
                 if ($localImage) {
                     $this->imageTranslation[$file] = N2ImageHelper::dynamic(N2Uri::pathToUri($localImage));
                 } else {
                     $this->imageTranslation[$file] = $file;
                 }
                 if (!$this->imageTranslation[$file]) {
                     $this->imageTranslation[$file] = array_search($file, $this->backup->imageTranslation);
                 }
             }
             break;
         case 'update':
             $keys = array_keys($this->backup->NextendImageHelper_Export);
             $values = array_values($this->backup->NextendImageHelper_Export);
             foreach ($this->backup->imageTranslation as $image => $value) {
                 $this->imageTranslation[$value] = str_replace($keys, $values, $image);
             }
             break;
         default:
             break;
     }
     foreach ($this->backup->NextendImageManager_ImageData as $image => $data) {
         $data['tablet']['image'] = $this->fixImage($data['tablet']['image']);
         $data['mobile']['image'] = $this->fixImage($data['mobile']['image']);
         N2ImageManager::addImageData($this->fixImage($image), $data);
     }
     unset($importData);
     if (empty($this->backup->slider['type'])) {
         $this->backup->slider['type'] = 'simple';
     }
     $class = 'N2SSPluginType' . $this->backup->slider['type'];
     N2Loader::importPath(call_user_func(array($class, "getPath")) . NDS . 'backup');
     $class = 'N2SmartSliderBackup' . $this->backup->slider['type'];
     call_user_func_array(array($class, 'import'), array($this, &$this->backup->slider));
     $enabledWidgets = array();
     $plugins = array();
     N2Plugin::callPlugin('sswidget', 'onWidgetList', array(&$plugins));
     $params = $this->backup->slider['params'];
     foreach ($plugins as $k => $v) {
         $widget = $params->get('widget' . $k);
         if ($widget && $widget != 'disabled') {
             $enabledWidgets[$k] = $widget;
         }
     }
     foreach ($enabledWidgets as $k => $v) {
         $class = 'N2SSPluginWidget' . $k . $v;
         if (class_exists($class, false)) {
             $params->fillDefault(call_user_func(array($class, 'getDefaults')));
             call_user_func_array(array($class, 'prepareImport'), array($this, $params));
         } else {
             unset($enabledWidgets);
         }
     }
     $sliderModel->importUpdate($this->sliderId, $params);
     $generatorTranslation = array();
     N2Loader::import("models.generator", "smartslider");
     $generatorModel = new N2SmartsliderGeneratorModel();
     foreach ($this->backup->generators as $generator) {
         $generatorTranslation[$generator['id']] = $generatorModel->import($generator);
     }
     $slidesModel = new N2SmartsliderSlidesModel();
     for ($i = 0; $i < count($this->backup->slides); $i++) {
         $slide = $this->backup->slides[$i];
         $slide['params'] = new N2Data($slide['params'], true);
         $slide['thumbnail'] = $this->fixImage($slide['thumbnail']);
         $slide['params']->set('backgroundImage', $this->fixImage($slide['params']->get('backgroundImage')));
         $slide['params']->set('link', $this->fixLightbox($slide['params']->get('link')));
         $slide['slide'] = N2SmartSliderLayer::prepareImport($this, $slide['slide']);
         if (isset($generatorTranslation[$slide['generator_id']])) {
             $slide['generator_id'] = $generatorTranslation[$slide['generator_id']];
         }
         $slidesModel->import($slide, $this->sliderId);
     }
     return $this->sliderId;
 }
Ejemplo n.º 14
0
 public function renderForm($slider)
 {
     $values = N2SmartsliderSlidersModel::renderEditForm($slider);
     // Used by AJAX widget subforms
     N2JS::addFirstCode("\r\n            new NextendForm(\r\n                'smartslider-form',\r\n                '" . $this->appType->router->createAjaxUrl(array('slider/edit', array('sliderid' => $slider['id']))) . "',\r\n                " . json_encode($values) . "\r\n            );\r\n        ");
 }
Ejemplo n.º 15
0
<div class="n2-sidebar-inner">
    <?php 
N2Loader::import('libraries.browse.browse');
$app = N2Base::getApplication('smartslider');
$accessEdit = N2Acl::canDo('smartslider_edit', $app->info);
$accessDelete = N2Acl::canDo('smartslider_delete', $app->info);
$sliderid = N2Request::getInt('sliderid', 0);
$generatorId = N2Request::getInt('generator_id', 0);
$controller = N2Request::getCmd('nextendcontroller');
$slidersModel = new N2SmartsliderSlidersModel();
$showSlideManager = false;
$dl = array();
if (!$sliderid) {
    $orderBy = N2SmartSliderSettings::get('slidersOrder', 'time');
    $orderByDirection = N2SmartSliderSettings::get('slidersOrderDirection', 'DESC');
    $actions = N2Html::tag('a', array("class" => 'n2-button n2-button-grey n2-button-medium' . ($orderBy == 'title' ? ' n2-active' : ''), "href" => $this->appType->router->createUrl(array('sliders/orderby', array('title' => $orderBy == 'title' ? $orderByDirection == 'ASC' ? 'DESC' : 'ASC' : 'ASC') + N2Form::tokenizeUrl()))), N2Html::tag('i', array('class' => 'n2-i n2-it n2-i-16' . ($orderBy == 'title' ? $orderByDirection == 'ASC' ? ' n2-i-sortalphabetic1' : ' n2-i-sortalphabetic2' : ' n2-i-sortalphabetic1')), ''));
    $actions .= N2Html::tag('a', array("class" => 'n2-button n2-button-grey n2-button-medium' . ($orderBy == 'time' ? ' n2-active' : ''), "href" => $this->appType->router->createUrl(array('sliders/orderby', array('time' => $orderBy == 'time' ? $orderByDirection == 'ASC' ? 'DESC' : 'ASC' : 'DESC') + N2Form::tokenizeUrl()))), N2Html::tag('i', array('class' => 'n2-i n2-it n2-i-16' . ($orderBy == 'time' ? $orderByDirection == 'ASC' ? ' n2-i-sortdate1' : ' n2-i-sortdate2' : ' n2-i-sortdate2')), ''));
    $dl[] = array('title' => '<span>' . n2_('SLIDER LIST') . '</span>', 'class' => 'n2-ss-slider-ordering n2-ss-slide2-list', 'tooltip' => null, 'actions' => $actions);
    $sliders = $slidersModel->getAll($orderBy, $orderByDirection);
} else {
    // Show only one sliders's sidebar in this context
    $sliders = array($slidersModel->get($sliderid));
}
if ($sliders) {
    foreach ($sliders as $slider) {
        $active = $sliderid == $slider['id'];
        $preUl = '';
        if ($active) {
            $showSlideManager = true;
            ob_start();
            $this->widget->init("buttonmenu", array("content" => N2Html::tag('div', array('class' => 'n2-button-menu'), N2Html::tag('div', array('class' => 'n2-button-menu-inner n2-border-radius'), N2Html::link(n2_('Add images'), '#', array('class' => 'n2-add-quick-image n2-h4')) . N2Html::link(n2_('Add video'), '#', array('class' => 'n2-add-quick-video n2-h4' . (N2Platform::$hasPosts ? '' : ' n2-separator'))) . (N2Platform::$hasPosts ? N2Html::link(n2_('Add post'), '#', array('class' => 'n2-add-quick-post n2-h4')) : '') . N2Html::link(n2_('Create empty slide'), $app->router->createUrl(array("slides/create", array("sliderid" => N2Request::getInt('sliderid'), "static" => 0))), array('class' => 'n2-h4 n2-separator')) . N2Html::link(n2_('Create static slide'), $app->router->createUrl(array("slides/create", array("sliderid" => N2Request::getInt('sliderid'), "static" => 1))), array('class' => 'n2-h4')) . N2Html::link(n2_('Create dynamic slides'), $app->router->createUrl(array("generator/create", array("sliderid" => N2Request::getInt('sliderid')))), array('class' => 'n2-h4'))))));
Ejemplo n.º 16
0
 public function renderImportFromServerForm()
 {
     N2SmartsliderSlidersModel::renderImportFromServerForm();
 }