public static function init() { self::$isJoomla = JVERSION; if (JFactory::getApplication()->isAdmin()) { self::$isAdmin = true; } }
public static function init() { self::$isWordpress = get_bloginfo('version'); if (basename($_SERVER['PHP_SELF']) == 'admin.php') { self::$isAdmin = true; } }
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 function update() { $posts = array('action' => 'update'); $response = N2SS3::api($posts); if (is_string($response)) { if (N2Platform::updateFromZip($response, N2SS3::getUpdateInfo())) { return 'OK'; } return 'UPDATE_ERROR'; } return $response['status']; }
protected function isCacheValid(&$manifestData) { if (N2SmartSliderHelper::getInstance()->isSliderChanged($this->parameters['slider']->sliderId, 1)) { $this->clearCurrentGroup(); N2SmartSliderHelper::getInstance()->setSliderChanged($this->parameters['slider']->sliderId, 0); return false; } $time = N2Platform::getTime(); if ($manifestData['nextCacheRefresh'] < $time) { return false; } return true; }
function fetchElement() { $dir = N2Platform::getPublicDir(); $extension = N2XmlHelper::getAttribute($this->_xml, 'extension'); $files = scandir($dir); $validated_files = array(); foreach ($files as $file) { if (strtolower(pathinfo($file, PATHINFO_EXTENSION)) == $extension) { $validated_files[] = $file; } } $this->_xml->addChild('option', n2_('Choose a file to import'))->addAttribute('value', ''); foreach ($validated_files as $f) { $this->_xml->addChild('option', $f)->addAttribute('value', $f); } return parent::fetchElement(); }
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 static function hasApiError($status, $data = array()) { extract($data); switch ($status) { case 'OK': return false; case 'PRODUCT_ASSET_NOT_AVAILABLE': N2Message::error(sprintf(n2_('Demo slider is not available with the following ID: %s'), $key)); case 'ASSET_PREMIUM': N2Message::error('Premium sliders are available in PRO version only!'); break; case 'LICENSE_EXPIRED': N2Message::error('Your license key expired!'); break; case 'DOMAIN_REGISTER_FAILED': N2Message::error('Your license key authorized on a different domain!'); break; case 'LICENSE_INVALID': N2Message::error('Your license key invalid, please enter again!'); N2SmartsliderLicenseModel::getInstance()->setKey(''); return array("sliders/index"); break; case 'UPDATE_ERROR': N2Message::error('Update error, please update manually!'); break; case 'PLATFORM_NOT_ALLOWED': N2Message::error(sprintf('Your license key is not valid for Smart Slider3 - %s!', N2Platform::getPlatformName())); break; case 'ERROR_HANDLED': break; case null: N2Message::error('Licensing server not reachable, try again later!'); break; default: N2Message::error('Debug: ' . $status); N2Message::error('Licensing server not reachable, try again later!'); break; } return true; }
protected function addManifestData(&$manifestData) { $manifestData['cacheTime'] = N2Platform::getTime(); $this->generator->setNextCacheRefresh($manifestData['cacheTime'] + max(0, $this->generator->currentGenerator['params']->get('cache-expiration', 1)) * 60 * 60); }
<?php $this->widget->init('topbar', array("actions" => array(N2Html::tag('a', array('href' => $this->appType->router->createUrl(array('sliders/index')), 'class' => 'n2-button n2-button-red n2-button-big n2-h4 n2-b n2-uc'), n2_('Cancel')), N2Html::tag('a', array('href' => '#', 'class' => 'n2-button n2-button-green n2-button-big n2-h4 n2-b n2-uc', 'onclick' => 'return NextendForm.submit("#smartslider-form");'), n2_('Import'))))); ?> <form id="smartslider-form" action="" method="post"> <?php $_class->renderImportFromServerForm(); ?> <input name="save" value="1" type="hidden"/> </form> <div class="n2-form "> <div class="n2-form-tab "> <div class="n2-h2 n2-content-box-title-bg"><?php n2_e('Instructions'); ?> </div> <div class="n2-description"> <p><?php printf(n2_('Smart Slider export files are listed from the directory only with <i>ss3</i> extension: %s'), N2Platform::getPublicDir()); ?> </p> </div> </div> </div> <?php N2SS3::showBeacon('Import slider');
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); }
function duplicate($id) { $slider = $this->get($id); unset($slider['id']); $slider['title'] .= ' - copy'; $slider['time'] = date('Y-m-d H:i:s', N2Platform::getTime()); try { $this->db->insert($slider); $newSliderId = $this->db->insertId(); } catch (Exception $e) { throw new Exception($e->getMessage()); } if (!$newSliderId) { return false; } $slidesModel = new N2SmartsliderSlidesModel(); foreach ($slidesModel->getAll($id) as $slide) { $slidesModel->copy($slide['id'], $newSliderId); } return $newSliderId; }
#n2-admin { margin: 0 !important; } .n2-form-tab { margin: 0; border: 0; } body, .n2-form-tab { background-color: #e9edf0; } <?php N2Platform::adminHideCSS(); ?> </style> <?php N2JS::addFirstCode("\n if(window.parent != window){\n parentDocument = window.parent.n2(window.parent.document);\n \$(window).on('keydown keyup keypress', function(e){\n if(e.keyCode == 27){\n parentDocument.trigger(e);\n }\n });\n }\n\n var container = n2('.n2-ss-container-device'),\n autoHeight = function(){\n var minHeight = n2(window).height() - container.offset().top ;\n container.css('height', 'auto');\n if(container.height() < minHeight){\n container.height(minHeight);\n }\n };\n\n autoHeight();\n n2(window).on('resize', autoHeight);\n n2('.n2-ss-slider').on('SliderResize', autoHeight);\n window[n2('.n2-ss-slider').attr('id')].startedDeferred.done(function(slider){\n slider.ready(autoHeight);\n });\n"); ?> <div class="n2-form-tab " style="display: block;"> <div class="n2-heading-controls n2-content-box-title-bg"> <div class="n2-table"> <div class="n2-tr"> <div class="n2-td n2-h2"> <?php echo n2_('Preview');
protected function slidesWhereQuery() { $date = N2Platform::getDate(); return " AND ((published = 1 AND (publish_up = '0000-00-00 00:00:00' OR publish_up < '{$date}')\n AND (publish_down = '0000-00-00 00:00:00' OR publish_down > '{$date}'))\n OR id = " . N2Request::getInt('slideid') . ") "; }
public static function getImagesFolder() { return N2Platform::getPublicDir(); }
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html **/ defined('_JEXEC') or die('Restricted access'); ?> <div></div> <div class="n2-form"> <div class="n2-form-tab " id="n2-tab-general"><div class="n2-h2 n2-content-box-title-bg">Help</div> <table> <colgroup> <col class="n2-label-col"> <col class="n2-element-col"> </colgroup> <tbody> <tr> <td class="n2-label"><label>Nextend Framework version</label></td> <td class="n2-element"><div class="n2-element-plain"><?php echo N2::$version; ?> </div></td> </tr> <tr> <td class="n2-label"><label>Platform</label></td> <td class="n2-element"><div class="n2-element-plain"><?php echo N2Platform::getPlatformName(); ?> </div></td> </tr> </tbody> </table> </div> </div>
public function isVisible() { if (!$this->visible) { return false; } $time = N2Platform::getTime(); $publish_up = strtotime($this->publish_up); $publish_down = strtotime($this->publish_down); if ($publish_down) { if ($publish_down > $time) { $this->setNextCacheRefresh($publish_down); } else { return false; } } if ($publish_up) { if ($publish_up > $time) { $this->setNextCacheRefresh($publish_up); return false; } } return true; }
public function actionImportFromServer() { if ($this->validatePermission('smartslider_edit')) { if (N2Request::getInt('save')) { if ($this->validateToken()) { $data = new N2Data(N2Request::getVar('slider')); $file = $data->get('import-file'); if (empty($file)) { N2Message::error(n2_('Please select a file!')); $this->refresh(); } else { $dir = N2Platform::getPublicDir(); if (N2Filesystem::fileexists($dir . '/' . $file)) { N2Loader::import('libraries.import', 'smartslider'); $import = new N2SmartSliderImport(); $sliderId = $import->import($dir . '/' . $file, $data->get('image-mode', 'clone'), $data->get('linked-visuals', 0)); if ($sliderId !== false) { if ($data->get('delete')) { @unlink($dir . '/' . $file); } N2Message::success(n2_('Slider imported.')); $this->redirect(array("slider/edit", array("sliderid" => $sliderId))); } else { N2Message::error(n2_('Import error!')); $this->refresh(); } } else { N2Message::error(n2_('The chosen file is missing!')); $this->refresh(); } } } else { $this->refresh(); } } $this->addView('importFromServer'); $this->render(); } }