Пример #1
0
 public static function backend($force = false)
 {
     static $once;
     if ($once != null && !$force) {
         return;
     }
     $once = true;
     $family = n2_x('Montserrat', 'Default Google font family for admin');
     foreach (explode(',', n2_x('latin', 'Default Google font charset for admin')) as $subset) {
         N2GoogleFonts::addSubset($subset);
     }
     N2GoogleFonts::addFont($family);
     N2CSS::addInline('.n2,html[dir="rtl"] .n2,.n2 td,.n2 th,.n2 select, .n2 textarea, .n2 input{font-family: "' . $family . '", Arial, sans-serif;}');
     N2CSS::addFiles(N2LIBRARYASSETS . "/css", array('nextend-font.css', 'font.css', 'admin.css', 'form.css', 'notificationcenter.css', 'spectrum.css', 'contextMenu.css'), 'nextend-backend');
     foreach (glob(N2LIBRARYASSETS . "/css/tabs/*.css") as $file) {
         N2CSS::addFile($file, 'nextend-backend');
     }
     foreach (glob(N2LIBRARYASSETS . "/css/jquery/*.css") as $file) {
         N2CSS::addFile($file, 'nextend-backend');
     }
     N2JS::addFiles(N2LIBRARYASSETS . "/js", array('json2.js', 'admin.js', 'color.js', 'query-string.js', 'md5.js', 'css.js', 'imagehelper.js', 'modal.js', 'notificationcenter.js', 'spectrum.js', 'expert.js'), 'nextend-backend');
     N2Localization::addJS(array('Cancel', 'Delete', 'Delete and never show again', 'Are you sure you want to delete?', 'Documentation'));
     self::form($force);
     N2JS::addFiles(N2LIBRARYASSETS . "/js/core/jquery", array("fixto.js", "jstorage.js", "jquery.datetimepicker.js", "jquery.tinyscrollbar.min.js", "jquery.unique-element-id.js", "vertical-pane.js"), "nextend-backend");
     wp_enqueue_script('nextend-ui', N2Uri::pathToUri(N2LIBRARYASSETS . "/js/core/jquery/ui/jquery-ui.nextend.js"), array('jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-autocomplete', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-resizable', 'jquery-ui-sortable', 'jquery-ui-slider'), '1.0', 1);
     wp_enqueue_script('nextend-ui-iframe-transport', N2Uri::pathToUri(N2LIBRARYASSETS . "/js/core/jquery/ui/jquery.iframe-transport.js"), array('jquery-ui-core', 'jquery-ui-widget'), '1.0', 1);
     wp_enqueue_script('nextend-ui-fileupload', N2Uri::pathToUri(N2LIBRARYASSETS . "/js/core/jquery/ui/jquery.fileupload.js"), array('jquery-ui-core', 'jquery-ui-widget'), '1.0', 1);
     N2JS::addFiles(N2LIBRARYASSETS . "/js/core/jquery/ui", array('jquery.contextMenu.js'), "nextend-backend");
     N2Base::getApplication('system')->info->assetsBackend();
     N2JS::addFirstCode("NextendAjaxHelper.addAjaxArray(" . json_encode(N2Form::tokenizeUrl()) . ");");
     N2Plugin::callPlugin('fontservices', 'onFontManagerLoadBackend');
 }
Пример #2
0
 function generateOptions(&$xml)
 {
     $this->values = array();
     $html = '';
     foreach ($xml->option as $option) {
         $v = N2XmlHelper::getAttribute($option, 'value');
         $image = N2Uri::pathToUri($v);
         $selected = $this->isSelected($v);
         if ($v != -1) {
             $value = $this->parseValue($image);
             $this->values[] = $value;
             $html .= N2Html::openTag("div", array("class" => "n2-radio-option n2-imagelist-option" . ($selected ? ' n2-active' : '')));
             $ext = pathinfo($image, PATHINFO_EXTENSION);
             if ($ext == 'svg') {
                 $image = 'data:image/svg+xml;base64,' . base64_encode(N2Filesystem::readFile(N2Filesystem::getBasePath() . $v));
             }
             $html .= N2Html::image($image, (string) $option, array('data-image' => $value));
             $html .= N2Html::closeTag("div");
         } else {
             $this->values[] = -1;
             $html .= N2Html::tag("div", array("class" => "n2-radio-option" . ($selected ? ' n2-active' : '')), (string) $option);
         }
     }
     return $html;
 }
Пример #3
0
 public static function getNextendElementUrlParameters()
 {
     $params = array('hasPosts' => N2Platform::$hasPosts);
     $params['imageUrl'] = N2Uri::pathToUri(N2LIBRARYASSETS . "/images");
     $params['url'] = N2Base::getApplication('system')->getApplicationType('backend')->router->createUrl("link/search");
     return json_encode(N2ElementUrlParams::extend($params));
 }
Пример #4
0
 static function render($slider, $id, $params)
 {
     $html = '';
     $previous = $params->get(self::$key . 'previous-image');
     $previousColor = $params->get(self::$key . 'previous-color');
     $previousHover = $params->get(self::$key . 'previous-hover');
     $previousHoverColor = $params->get(self::$key . 'previous-hover-color');
     if (empty($previous)) {
         $previous = $params->get(self::$key . 'previous');
         if ($previous == -1) {
             $previous = null;
         } elseif ($previous[0] != '$') {
             $previous = N2Uri::pathToUri(dirname(__FILE__) . '/image/previous/' . $previous);
         }
     }
     if ($params->get(self::$key . 'mirror')) {
         $next = str_replace('image/previous/', 'image/next/', $previous);
         $nextColor = $previousColor;
         $nextHover = $previousHover;
         $nextHoverColor = $previousHoverColor;
     } else {
         $next = $params->get(self::$key . 'next-image');
         $nextColor = $params->get(self::$key . 'next-color');
         $nextHover = $params->get(self::$key . 'next-hover');
         $nextHoverColor = $params->get(self::$key . 'next-hover-color');
         if (empty($next)) {
             $next = $params->get(self::$key . 'next');
             if ($next == -1) {
                 $next = null;
             } elseif ($next[0] != '$') {
                 $next = N2Uri::pathToUri(dirname(__FILE__) . '/image/next/' . $next);
             }
         }
     }
     if ($previous || $next) {
         N2LESS::addFile(N2Filesystem::translate(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'image' . DIRECTORY_SEPARATOR . 'style.less'), $slider->cacheId, array("sliderid" => $slider->elementId), NEXTEND_SMARTSLIDER_ASSETS . '/less' . NDS);
         N2JS::addFile(N2Filesystem::translate(dirname(__FILE__) . '/image/arrow.js'), $id);
         list($displayClass, $displayAttributes) = self::getDisplayAttributes($params, self::$key);
         $animation = $params->get(self::$key . 'animation');
         if ($animation == 'none' || $animation == 'fade') {
             $styleClass = N2StyleRenderer::render($params->get(self::$key . 'style'), 'heading', $slider->elementId, 'div#' . $slider->elementId . ' ');
         } else {
             $styleClass = N2StyleRenderer::render($params->get(self::$key . 'style'), 'heading-active', $slider->elementId, 'div#' . $slider->elementId . ' ');
         }
         if ($previous) {
             $html .= self::getHTML($id, $params, $animation, 'previous', $previous, $displayClass, $displayAttributes, $styleClass, $previousColor, $previousHover, $previousHoverColor);
         }
         if ($next) {
             $html .= self::getHTML($id, $params, $animation, 'next', $next, $displayClass, $displayAttributes, $styleClass, $nextColor, $nextHover, $nextHoverColor);
         }
         N2JS::addInline('new NextendSmartSliderWidgetArrowImage("' . $id . '", ' . floatval($params->get(self::$key . 'responsive-desktop')) . ', ' . floatval($params->get(self::$key . 'responsive-tablet')) . ', ' . floatval($params->get(self::$key . 'responsive-mobile')) . ');');
     }
     return $html;
 }
Пример #5
0
 static function render($slider, $id, $params)
 {
     $html = '';
     $play = $params->get(self::$key . 'play-image');
     $playColor = $params->get(self::$key . 'play-color');
     if (empty($play)) {
         $play = $params->get(self::$key . 'play');
         if ($play == -1) {
             $play = null;
         } elseif ($play[0] != '$') {
             $play = N2Uri::pathToUri(dirname(__FILE__) . '/image/play/' . $play);
         }
     }
     if ($params->get(self::$key . 'mirror')) {
         $pause = str_replace('image/play/', 'image/pause/', $play);
         $pauseColor = $playColor;
     } else {
         $pause = $params->get(self::$key . 'pause-image');
         $pauseColor = $params->get(self::$key . 'pause-color');
         if (empty($pause)) {
             $pause = $params->get(self::$key . 'pause');
             if ($pause == -1) {
                 $pause = null;
             } elseif ($pause[0] != '$') {
                 $pause = N2Uri::pathToUri(dirname(__FILE__) . '/image/pause/' . $pause);
             }
         }
     }
     $ext = pathinfo($play, PATHINFO_EXTENSION);
     if (substr($play, 0, 1) == '$' && $ext == 'svg') {
         list($color, $opacity) = N2Color::colorToSVG($playColor);
         $play = 'data:image/svg+xml;base64,' . base64_encode(str_replace(array('fill="#FFF"', 'opacity="1"'), array('fill="#' . $color . '"', 'opacity="' . $opacity . '"'), N2Filesystem::readFile(N2ImageHelper::fixed($play, true))));
     } else {
         $play = N2ImageHelper::fixed($play);
     }
     $ext = pathinfo($pause, PATHINFO_EXTENSION);
     if (substr($pause, 0, 1) == '$' && $ext == 'svg') {
         list($color, $opacity) = N2Color::colorToSVG($pauseColor);
         $pause = 'data:image/svg+xml;base64,' . base64_encode(str_replace(array('fill="#FFF"', 'opacity="1"'), array('fill="#' . $color . '"', 'opacity="' . $opacity . '"'), N2Filesystem::readFile(N2ImageHelper::fixed($pause, true))));
     } else {
         $pause = N2ImageHelper::fixed($pause);
     }
     if ($play && $pause) {
         N2CSS::addFile(N2Filesystem::translate(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'image' . DIRECTORY_SEPARATOR . 'style.css'), $id);
         N2JS::addFile(N2Filesystem::translate(dirname(__FILE__) . '/image/autoplay.js'), $id);
         list($displayClass, $displayAttributes) = self::getDisplayAttributes($params, self::$key);
         $styleClass = N2StyleRenderer::render($params->get(self::$key . 'style'), 'heading', $slider->elementId, 'div#' . $slider->elementId . ' ');
         list($style, $attributes) = self::getPosition($params, self::$key);
         N2JS::addInline('new NextendSmartSliderWidgetAutoplayImage("' . $id . '", ' . floatval($params->get(self::$key . 'responsive-desktop')) . ', ' . floatval($params->get(self::$key . 'responsive-tablet')) . ', ' . floatval($params->get(self::$key . 'responsive-mobile')) . ');');
         $html = N2Html::tag('div', $displayAttributes + $attributes + array('class' => $displayClass . $styleClass . 'nextend-autoplay nextend-autoplay-image', 'style' => $style), N2Html::image($play, '', array('class' => 'nextend-autoplay-play n2-ow')) . N2Html::image($pause, '', array('class' => 'nextend-autoplay-pause n2-ow')));
     }
     return $html;
 }
Пример #6
0
 public function getOutput()
 {
     N2GoogleFonts::build();
     N2LESS::build();
     $output = "";
     foreach ($this->urls as $url) {
         $output .= N2Html::style($url, true, array('media' => 'screen, print')) . "\n";
     }
     foreach ($this->getFiles() as $file) {
         $output .= N2Html::style(N2Uri::pathToUri($file) . '?' . filemtime($file), true, array('media' => 'screen, print')) . "\n";
     }
     $inline = implode("\n", $this->inline);
     if (!empty($inline)) {
         $output .= N2Html::style($inline);
     }
     return $output;
 }
 function generateOptions(&$xml)
 {
     $this->values = array();
     $html = '';
     foreach ($xml->option as $option) {
         $v = N2XmlHelper::getAttribute($option, 'value');
         $image = N2Uri::pathToUri($v);
         $selected = $this->isSelected($this->parseValue($v));
         if ($v != -1) {
             $this->values[] = $this->parseValue($image);
             $html .= N2Html::openTag("div", array("class" => "n2-radio-option n2-imagelist-option" . ($selected ? ' n2-active' : '')));
             $html .= N2Html::image($image, (string) $option);
             $html .= N2Html::closeTag("div");
         } else {
             $this->values[] = -1;
             $html .= N2Html::tag("div", array("class" => "n2-radio-option" . ($selected ? ' n2-active' : '')), (string) $option);
         }
     }
     return $html;
 }
Пример #8
0
 public function getOutput()
 {
     $output = "";
     $globalInline = $this->getGlobalInlineScripts();
     if (!empty($globalInline)) {
         $output .= N2Html::script($globalInline . "\n");
     }
     foreach ($this->urls as $url) {
         $output .= N2Html::script($url, true) . "\n";
     }
     if (!N2Platform::$isAdmin && N2Settings::get('async', '0')) {
         $jsCombined = new N2CacheCombine('js', N2Settings::get('minify-js', '0') ? 'N2MinifierJS::minify' : false);
         foreach ($this->getFiles() as $file) {
             if (basename($file) == 'n2.js') {
                 $output .= N2Html::script(N2Uri::pathToUri($file) . '?' . filemtime($file), true) . "\n";
             } else {
                 $jsCombined->add($file);
             }
         }
         $combinedFile = $jsCombined->make();
         $scripts = 'nextend.loadScript("' . N2Uri::pathToUri($combinedFile) . '?' . filemtime($combinedFile) . '");';
         $output .= N2Html::script($scripts . "\n");
     } else {
         if (!N2Platform::$isAdmin && N2Settings::get('combine-js', '0')) {
             $jsCombined = new N2CacheCombine('js', N2Settings::get('minify-js', '0') ? 'N2MinifierJS::minify' : false);
             foreach ($this->getFiles() as $file) {
                 $jsCombined->add($file);
             }
             $combinedFile = $jsCombined->make();
             $output .= N2Html::script(N2Uri::pathToUri($combinedFile) . '?' . filemtime($combinedFile), true) . "\n";
         } else {
             foreach ($this->getFiles() as $file) {
                 $output .= N2Html::script(N2Uri::pathToUri($file) . '?' . filemtime($file), true) . "\n";
             }
         }
     }
     $output .= N2Html::script(N2Localization::toJS() . "\n" . $this->getInlineScripts() . "\n");
     return $output;
 }
Пример #9
0
 public function getUri()
 {
     return N2Uri::pathToUri($this->getAssetsPath());
 }
Пример #10
0
 function getImage($path, $key)
 {
     return N2Uri::pathToUri(N2Filesystem::translate($path . $key . '.png'));
 }
Пример #11
0
 public function _renderGroupOption($group, $sources)
 {
     $options = array();
     foreach ($sources as $type => $info) {
         /**
          * @var $info N2GeneratorInfo
          */
         $options[$type] = $info->title;
         if ($info->hasConfiguration) {
             $button = N2Html::link("Next", $this->appType->router->createUrl(array("generator/checkConfiguration", array("sliderid" => N2Request::getInt('sliderid'), "group" => $group))), array("onclick" => "var el = n2(this); el.attr('href', el.attr('href') + '&type='+el.parents('.n2-box-placeholder').find('select').val());", "class" => "n2-button n2-button-small n2-button-blue"));
         } elseif (!$info->installed) {
             $button = N2Html::link("Check extension", $info->readMore, array("target" => "_blank", "class" => "n2-button n2-button-small n2-button-grey"));
         } else {
             $button = N2Html::link("Next", $this->appType->router->createUrl(array("generator/createSettings", array("sliderid" => N2Request::getInt('sliderid'), "group" => $group))), array("onclick" => "var el = n2(this); el.attr('href', el.attr('href') + '&type='+el.parents('.n2-box-placeholder').find('select').val());", "class" => "n2-button n2-button-small n2-button-blue"));
         }
     }
     $optionsHTML = '';
     foreach ($options as $k => $v) {
         $optionsHTML .= N2Html::tag('option', array('value' => $k), $v);
     }
     echo N2Html::tag('div', array('class' => 'n2-box'), N2Html::image(N2Uri::pathToUri(N2Filesystem::translate($info->path . '/../dynamic.png'))) . N2Html::tag("div", array('class' => 'n2-box-placeholder'), N2Html::tag("table", array(), N2Html::tag("tr", array(), N2Html::tag("td", array('class' => 'n2-box-label'), N2Html::tag('select', array('name' => 'generator-type'), $optionsHTML)) . N2Html::tag("td", array('class' => 'n2-box-button'), $button)))));
 }
Пример #12
0
 /**
  * @param $path
  *
  * @return mixed
  */
 public static function pathToAbsoluteURL($path)
 {
     return N2Uri::pathToUri($path);
 }
Пример #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;
 }