private static function load() { if (!self::$storage) { N2Loader::import("libraries.session.storage"); self::$storage = new N2SessionStorage(); } }
public function install() { foreach (self::$sql as $query) { $this->db->query($this->db->parsePrefix($query)); } N2Loader::import('install', 'platform'); }
public function actionSearch() { $this->validateToken(); N2Loader::import('libraries.models.content', 'platform'); $keyword = N2Request::getVar('keyword', ''); $this->response->respond(N2ModelsContent::search($keyword)); }
protected function renderType(&$context) { $params = $this->slider->params; N2Loader::import('libraries.image.color'); $width = intval($context['width']); $height = intval($context['height']); $context['backgroundSize'] = $params->get('background-size'); $context['backgroundAttachment'] = $params->get('background-fixed') ? 'fixed' : 'scroll'; $borderWidth = $params->get('border-width'); $borderColor = $params->get('border-color'); $context['borderRadius'] = $params->get('border-radius') . 'px'; $padding = N2Parse::parse($params->get('padding')); $context['paddingt'] = $padding[0] . 'px'; $context['paddingr'] = $padding[1] . 'px'; $context['paddingb'] = $padding[2] . 'px'; $context['paddingl'] = $padding[3] . 'px'; if ($context['canvas']) { $width += 2 * $borderWidth + $padding[1] + $padding[3]; $height += 2 * $borderWidth + $padding[0] + $padding[2]; $context['width'] = $width . "px"; $context['height'] = $height . "px"; } $context['border'] = $borderWidth . 'px'; $rgba = N2Color::hex2rgba($borderColor); $context['borderrgba'] = 'RGBA(' . $rgba[0] . ',' . $rgba[1] . ',' . $rgba[2] . ',' . round($rgba[3] / 127, 2) . ')'; $context['borderhex'] = '#' . substr($borderColor, 0, 6); $width = $width - ($padding[1] + $padding[3]) - $borderWidth * 2; $height = $height - ($padding[0] + $padding[2]) - $borderWidth * 2; $context['inner1height'] = $height . 'px'; $context['canvaswidth'] = $width . "px"; $context['canvasheight'] = $height . "px"; N2LESS::addFile(N2Filesystem::translate(dirname(__FILE__) . NDS . 'style.less'), $this->slider->cacheId, $context, NEXTEND_SMARTSLIDER_ASSETS . '/less' . NDS); }
public function subform($appType, $configurationXmlFile, $values, $control_name, $name) { if (N2Filesystem::fileexists($configurationXmlFile)) { N2Loader::import('libraries.form.form'); $form = new N2Form($appType); $form->loadArray($values); //$subformValue = array(); //$subformValue[N2Post::getVar('name')] = N2Post::getVar('value'); //$form->loadArray($subformValue); $form->loadXMLFile($configurationXmlFile); ob_end_clean(); // To clear the output of the platform ob_start(); $subform = $form->getSubFormAjax(N2Post::getVar('tab'), $name); $subform->initAjax($control_name); echo $subform->renderForm(); //echo N2AssetsManager::generateAjaxCSS(); $scripts = N2AssetsManager::generateAjaxJS(); $html = ob_get_clean(); $response = array('html' => $html, 'scripts' => $scripts); } else { $response = array('error' => 'Configuration file not found: ' . $configurationXmlFile); } return $response; }
public function renderSetsForm() { $configurationXmlFile = $this->getPath() . '/forms/' . $this->type . '/sets.xml'; N2Loader::import('libraries.form.form'); $form = new N2Form(); $form->loadXMLFile($configurationXmlFile); echo $form->render($this->type . 'set'); }
public function actionExportHTML() { if ($this->validateToken() && $this->validatePermission('smartslider_edit')) { N2Loader::import('libraries.export', 'smartslider'); $export = new N2SmartSliderExport($this->sliderId); $export->createHTML(); } }
public function render($cache = false) { if (!$cache) { return $this->slider->render(); } N2Loader::import("libraries.slider.cache.slider", "smartslider"); return $this->slider->addCMSFunctions($this->cacheSlider()); }
public function actionIndex($secured = false) { if ($secured) { N2Loader::import('models.Install', 'system'); $installModel = new N2SystemInstallModel(); $installModel->install(); } }
public function getSliderTypeResource($resourceName) { $type = $this->data->get('type', 'simple'); $class = 'N2SSPluginType' . $type; N2Loader::importPath(call_user_func(array($class, "getPath")) . NDS . $resourceName); $class = 'N2SmartSlider' . $resourceName . $type; return new $class($this); }
public static function renderRestoreFromServerForm() { $configurationXmlFile = dirname(__FILE__) . '/forms/import/restorefromserver.xml'; N2Loader::import('libraries.form.form'); $form = new N2Form(N2Base::getApplication('smartslider')->getApplicationType('backend')); $form->loadXMLFile($configurationXmlFile); echo $form->render('slider'); }
public static function renderForm() { $configurationXmlFile = dirname(__FILE__) . '/forms/login.xml'; N2Loader::import('libraries.form.form'); $form = new N2Form(N2Base::getApplication('system')->getApplicationType('backend')); $form->loadXMLFile($configurationXmlFile); return $form->render('login'); }
function renderForm($data = array()) { N2Loader::import('libraries.animations.manager'); $configurationXmlFile = dirname(__FILE__) . '/forms/layer.xml'; N2Loader::import('libraries.form.form'); $form = new N2Form(); $form->loadArray($data); $form->loadXMLFile($configurationXmlFile); echo $form->render('layer'); }
protected function autoload() { N2Loader::import("libraries.slider.helper", "smartslider"); N2Loader::import("libraries.slider.manager", "smartslider"); N2Form::$importPaths[] = dirname(__FILE__) . '/form'; N2Filesystem::registerTranslate(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'plugins', $this->info->getAssetsPath() . '/plugins'); require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'loadplugin.php'; N2Loader::import('plugins.loadplugin', 'smartslider.platform'); N2Loader::import('libraries.link', 'smartslider'); }
/** * @param $slide N2SmartSliderSlide * * @return string */ public function make($slide) { $dynamicHeight = intval($this->slider->params->get('dynamic-height', 0)); $backgroundImageOpacity = min(100, max(0, $slide->parameters->get('backgroundImageOpacity', 100))) / 100; if ($slide->hasGenerator()) { $rawBackgroundImage = $slide->parameters->get('backgroundImage', ''); $backgroundImage = $slide->fill($rawBackgroundImage); $imageData = N2ImageManager::getImageData($rawBackgroundImage); $imageData['desktop-retina']['image'] = $slide->fill($imageData['desktop-retina']['image']); $imageData['tablet']['image'] = $slide->fill($imageData['tablet']['image']); $imageData['tablet-retina']['image'] = $slide->fill($imageData['tablet-retina']['image']); $imageData['mobile']['image'] = $slide->fill($imageData['mobile']['image']); $imageData['mobile-retina']['image'] = $slide->fill($imageData['mobile-retina']['image']); } else { $backgroundImage = $slide->fill($slide->parameters->get('backgroundImage', '')); $imageData = N2ImageManager::getImageData($backgroundImage); } $sizes = $this->slider->assets->sizes; $backgroundColor = ''; $color = $slide->parameters->get('backgroundColor', ''); if (strlen($color) == 8 && substr($color, 6, 2) != '00') { $backgroundColor = 'background-color: #' . substr($color, 0, 6) . ';'; if (!class_exists('N2Color')) { N2Loader::import("libraries.image.color"); } $rgba = N2Color::hex2rgba($color); $rgba[3] = round($rgba[3] / 127, 2); $backgroundColor .= "background-color: RGBA({$rgba[0]}, {$rgba[1]}, {$rgba[2]}, {$rgba[3]});"; } if (empty($backgroundImage)) { $src = N2Image::base64Transparent(); } else { $src = $backgroundImage; } $alt = $slide->parameters->get('backgroundAlt', ''); $title = $slide->parameters->get('backgroundTitle', ''); $fillMode = $slide->parameters->get('backgroundMode', 'default'); if ($fillMode == 'default') { $fillMode = $this->slider->params->get('backgroundMode', 'fill'); } if ($dynamicHeight) { return $this->simple($backgroundColor, $backgroundImageOpacity, $src, $imageData, $alt, $title, $sizes); } switch ($fillMode) { case 'fit': return $this->fit($backgroundColor, $backgroundImageOpacity, $src, $imageData, $alt, $title, $sizes); case 'stretch': return $this->stretch($backgroundColor, $backgroundImageOpacity, $src, $imageData, $alt, $title); case 'center': return $this->center($backgroundColor, $backgroundImageOpacity, $src, $imageData); case 'tile': return $this->tile($backgroundColor, $backgroundImageOpacity, $src, $imageData); } return $this->fill($backgroundColor, $backgroundImageOpacity, $src, $imageData, $alt, $title, $sizes); }
public function renderFontsConfigurationForm() { $values = N2Fonts::loadSettings(); $form = new N2Form($this->appType); $form->loadArray($values); $form->loadArray($values['plugins']->toArray()); $form->loadXMLFile(N2Loader::getPath('models', 'system') . '/forms/fonts.xml'); echo N2Html::openTag("form", array("id" => "nextend-config", "method" => "post", "action" => N2Request::getRequestUri())); $form->render('fonts'); echo N2Html::closeTag("form"); }
public function render($xmlpath, $data) { N2Loader::import('libraries.form.form'); $form = new N2Form(N2Base::getApplication('smartslider')->getApplicationType('backend')); $form->loadArray($data); $form->loadXMLFile($xmlpath); echo $form->render('settings'); N2JS::addFirstCode(' new NextendForm("smartslider-form", ' . json_encode($form->_data) . ', null, "' . N2Filesystem::toLinux(N2Filesystem::pathToRelativePath($xmlpath)) . '", "settings", "' . N2Uri::ajaxUri('nextend', 'smartslider') . '"); '); }
public function actionGenerateImage() { $this->validateToken(); $device = N2Request::getVar('device'); $this->validateVariable($device == 'tablet' || $device == 'mobile', 'device'); $image = N2Request::getVar('image'); $this->validateVariable(!empty($image), 'image'); N2Loader::import('libraries.image.image'); $scale = array('tablet' => 0.5, 'mobile' => 0.3); $newImage = N2Image::scaleImage('image', $image, $scale[$device], true); $this->response->respond(array('image' => N2ImageHelper::fixed($newImage))); }
public function install() { foreach (self::$sql as $query) { $this->db->query($this->db->parsePrefix($query)); } N2Loader::import('install', 'smartslider.platform'); $sliders = $this->db->queryAll($this->db->parsePrefix('SELECT * FROM #__nextend2_smartslider3_sliders LIMIT 1')); if (empty($sliders)) { foreach (self::$sampleSlider as $query) { $this->db->query($this->db->parsePrefix($query)); } } }
/** * @param $slide N2SmartSliderSlide * @param $slider * @param $extend */ public function __construct($slide, $slider, $extend) { N2Loader::import("libraries.slider.cache.generator", "smartslider"); N2Loader::import("models.generator", "smartslider"); $this->slide = $slide; $this->slider = $slider; $this->generatorModel = new N2SmartsliderGeneratorModel(); $this->currentGenerator = $this->generatorModel->get($this->slide->generator_id); $this->currentGenerator['params'] = new N2Data($this->currentGenerator['params'], true); if (isset($extend[$this->slide->generator_id])) { $extend = new N2Data($extend[$this->slide->generator_id]); $slide->parameters->set('record-slides', $extend->get('record-slides', 1)); $extend->un_set('record-slides'); $this->currentGenerator['params']->loadArray($extend->toArray()); } }
function initTabs() { if (count($this->_tabs) == 0) { foreach ($this->_xml->params as $tab) { $test = N2XmlHelper::getAttribute($tab, 'test'); if ($test == '' || $this->_form->makeTest($test)) { $type = N2XmlHelper::getAttribute($tab, 'type'); if ($type == '') { $type = 'default'; } N2Loader::import('libraries.form.tabs.' . $type); $class = 'N2Tab' . ucfirst($type); $this->_tabs[N2XmlHelper::getAttribute($tab, 'name')] = new $class($this->_form, $tab); } } } }
public function actionAviary() { if ($this->canDo('nextend_config')) { N2Loader::import('libraries.image.aviary'); $aviary = N2Request::getVar('aviary', false); if ($aviary) { if ($this->validateToken()) { N2ImageAviary::storeSettings($aviary); N2Message::success(n2_('Saved.')); N2Request::redirect($this->appType->router->createUrl(array("settings/aviary", array('layout' => N2Request::getCmd('layout', ''))))); } else { $this->refresh(); } } $this->addView("../../inline/sidebar/settings", array("appObj" => $this), "sidebar"); $this->addView("aviary"); $this->render(); } }
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 actionSaveImage() { $this->validateToken(); N2Loader::import('libraries.image.aviary'); $image = N2Request::getVar('aviaryUrl'); $this->validateVariable(!empty($image), 'image'); require_once dirname(__FILE__) . '/Browse.php'; $root = N2Filesystem::getImagesFolder(); $folder = 'aviary'; $path = N2Filesystem::realpath($root . '/' . $folder); if ($path === false || $path == '') { N2Filesystem::createFolder($root . '/' . $folder); $path = N2Filesystem::realpath($root . '/' . $folder); } $tmp = tempnam(sys_get_temp_dir(), 'image-'); file_put_contents($tmp, file_get_contents($image)); $src = null; // Set variables for storage // fix file filename for query strings preg_match('/([^\\?]+)\\.(jpe?g|gif|png)\\b/i', $image, $matches); $file_array['name'] = basename($matches[1]); $file_array['tmp_name'] = $tmp; $file_array['size'] = filesize($tmp); $file_array['error'] = 0; try { $fileName = preg_replace('/[^a-zA-Z0-9_-]/', '', $file_array['name']); $upload = new N2BulletProof(); $file = $upload->uploadDir($path)->upload($file_array, $fileName); $src = N2ImageHelper::dynamic(N2Filesystem::pathToAbsoluteURL($file)); } catch (Exception $e) { N2Message::error($e->getMessage()); $this->response->error(); } if ($src) { $this->response->respond(array('image' => $src)); } else { N2Message::error(sprintf(n2_('Unexpected error: %s'), $image)); $this->response->error(); } }
public function run($parameters = array(), $arguments = array()) { $useRequest = true; if (isset($parameters['useRequest'])) { $useRequest = $parameters['useRequest']; } if (isset($parameters["controller"])) { $this->getController($parameters["controller"], $useRequest); } else { $this->getController(); } $class = 'N2' . $this->app->name . $this->type . $this->controllerName . 'Controller'; if ($this->isAjaxCall()) { //sleep(10); $class = $class . 'Ajax'; N2Loader::import('controllers.ajax.' . $this->controllerName, $this->identifier); } else { N2Loader::import('controllers.' . $this->controllerName, $this->identifier); } $method = 'action'; if (isset($parameters["action"])) { $method .= $this->getAction($parameters["action"], $useRequest); } else { $method .= $this->getAction(); } $callable = $this->createControllerObject($class, $method); if (is_callable($callable)) { call_user_func_array($callable, $arguments); } else { $callable[1] = 'magicMethod'; if (is_callable($callable)) { array_unshift($arguments, $method); call_user_func_array($callable, $arguments); } else { throw new Exception("Method not exists: " . get_class($callable[0]) . '->' . $method); } } }
public static function updateFromZip($fileRaw, $updateInfo) { N2Loader::import('libraries.zip.zip_read'); $tmpHandle = tmpfile(); fwrite($tmpHandle, $fileRaw); $metaData = stream_get_meta_data($tmpHandle); $tmpFilename = $metaData['uri']; $_GET['plugins'] = $updateInfo['plugin']; include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; $upgrader = new Plugin_Upgrader(new Plugin_Upgrader_Skin(compact('title', 'nonce', 'url', 'plugin'))); $upgrader->init(); $upgrader->upgrade_strings(); add_filter('upgrader_pre_install', array($upgrader, 'deactivate_plugin_before_upgrade'), 10, 2); add_filter('upgrader_clear_destination', array($upgrader, 'delete_old_plugin'), 10, 4); $upgrader->run(array('package' => $tmpFilename, 'destination' => WP_PLUGIN_DIR, 'clear_destination' => true, 'clear_working' => true, 'hook_extra' => array('plugin' => $updateInfo['plugin'], 'type' => 'plugin', 'action' => 'update'))); // Cleanup our hooks, in case something else does a upgrade on this connection. remove_filter('upgrader_pre_install', array($upgrader, 'deactivate_plugin_before_upgrade')); remove_filter('upgrader_clear_destination', array($upgrader, 'delete_old_plugin')); // Force refresh of plugin update information wp_clean_plugins_cache(true); fclose($tmpHandle); include ABSPATH . 'wp-admin/admin-footer.php'; return true; }
<?php N2Loader::import('libraries.form.tab'); class N2TabRaw extends N2Tab { function decorateGroupStart() { } function decorateGroupEnd() { echo "</div>"; } function decorateElement(&$el, $out, $i) { echo $out[1]; } }
protected function addSlideLink() { list($url, $target) = (array) N2Parse::parse($this->parameters->getIfEmpty('link', '|*|')); if (!empty($url) && $url != '#') { if (empty($target)) { $target = '_self'; } $url = $this->fill($url); $this->containerAttributes['onclick'] = ''; if (strpos($url, 'javascript:') === 0) { $this->containerAttributes['onclick'] = $url; } else { N2Loader::import('libraries.link.link'); $url = N2LinkParser::parse($url, $this->containerAttributes); $this->containerAttributes['data-href'] = N2Platform::$isJoomla ? JRoute::_($url, false) : $url; if (empty($this->containerAttributes['onclick'])) { if ($target == '_blank') { $this->containerAttributes['n2click'] = "window.open(this.getAttribute('data-href'),'_blank');"; } else { $this->containerAttributes['n2click'] = "window.location=this.getAttribute('data-href')"; } $this->containerAttributes['n2middleclick'] = "window.open(this.getAttribute('data-href'),'_blank');"; } } $this->containerAttributes['style'] .= 'cursor:pointer;'; } }
<?php abstract class N2AclAbstract { public static $aclKey; public static function getInstance() { static $instance = null; if (null === $instance) { $instance = new N2Acl(); } return $instance; } /** * @param $action * @param N2ApplicationInfo $info * * @return bool */ public function authorise($action, $info) { return true; } public static function canDo($action, $info) { return self::getInstance()->authorise($action, $info); } } N2Loader::import('libraries.acl.acl', 'platform');
public function initialize() { parent::initialize(); N2Loader::import(array('models.Sliders', 'models.Slides'), 'smartslider'); }