public static function api($posts) { if (class_exists('JHttp')) { $posts_default = array('platform' => N2Platform::getPlatform()); $client = new JHttp(); $response = $client->post(self::$api, $posts + $posts_default, array('Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8')); if ($response->code != '200') { N2Message::error(n2_('Unable to contact with the licensing server, please try again later!')); return array('status' => 'ERROR_HANDLED'); } if (isset($response->headers['Content-Type'])) { $contentType = $response->headers['Content-Type']; } $data = $response->body; } if (!isset($data)) { if (function_exists('curl_init')) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, self::$api); $posts_default = array('platform' => N2Platform::getPlatform()); curl_setopt($ch, CURLOPT_POSTFIELDS, $posts + $posts_default); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec($ch); $contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); $error = curl_error($ch); $curlErrorNumber = curl_errno($ch); curl_close($ch); if ($curlErrorNumber) { N2Message::error($curlErrorNumber . $error); return array('status' => 'ERROR_HANDLED'); } } else { $posts_default = array('platform' => N2Platform::getPlatform()); $opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => http_build_query($posts + $posts_default))); $context = stream_context_create($opts); $data = file_get_contents(self::$api, false, $context); if ($data === false) { N2Message::error(n2_('CURL disabled in your php.ini configuration. Please enable it!')); return array('status' => 'ERROR_HANDLED'); } $headers = self::parseHeaders($http_response_header); if ($headers['status'] != '200') { N2Message::error(n2_('Unable to contact with the licensing server, please try again later!')); return array('status' => 'ERROR_HANDLED'); } if (isset($headers['content-type'])) { $contentType = $headers['content-type']; } } } switch ($contentType) { case 'application/json': return json_decode($data, true); } return $data; }
public static function frontend($force = false) { static $once; if ($once != null && !$force) { return; } $once = true; N2AssetsManager::getInstance(); N2JS::addInline('window.N2PRO=' . N2PRO . ';', true); N2JS::addInline('window.N2GSAP=' . N2GSAP . ';', true); N2JS::addInline('window.N2PLATFORM="' . N2Platform::getPlatform() . '";', true); N2JS::addInline('window.nextend={localization: {}, deferreds:[], loadScript: function(url){n2jQuery.ready(function () {nextend.deferreds.push(n2.ajax({url:url,dataType:"script",cache:true,error:function(){console.log(arguments)}}))})}, ready: function(cb){n2.when.apply(n2, nextend.deferreds).done(function(){cb.call(window,n2)})}};', true); N2JS::jQuery($force); N2JS::addFiles(N2LIBRARYASSETS . "/js", array('consts.js', 'class.js', 'base64.js', 'mobile-detect.js'), 'nextend-frontend'); N2JS::addFiles(N2LIBRARYASSETS . "/js/core/jquery", array("jquery.imagesloaded.js", "litebox.js", "jquery.universalpointer.js", "jquery.mousewheel.js", "EventBurrito.js"), "nextend-frontend"); N2JS::modernizr(); N2CSS::addFiles(N2LIBRARYASSETS . "/css", array('litebox.css'), 'nextend-frontend'); self::animation($force); N2Loader::import('libraries.fonts.fonts'); N2Plugin::callPlugin('fontservices', 'onFontManagerLoad', array($force)); }
public function __construct() { N2Loader::addPath($this->getName(), $this->getPath()); $platformPath = N2Filesystem::realpath($this->getPath() . '/../' . N2Platform::getPlatform()); if ($platformPath) { N2Loader::addPath($this->getName() . '.platform', $platformPath); } $this->loadLocale(); $filterClass = 'N2' . ucfirst($this->getName()) . 'ApplicationInfoFilter'; N2Loader::import($filterClass, $this->getName() . '.platform'); $callable = $filterClass . '::filter'; if (is_callable($callable)) { call_user_func($filterClass . '::filter', $this); } if (N2Base::$isReady) { $this->onNextendBaseReady(); } else { N2Pluggable::addAction('nextendBaseReady', array($this, 'onNextendBaseReady')); } }
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); }