Example #1
0
 public static function addKeyword($keyword, $path, $url)
 {
     array_unshift(self::$siteKeywords, $keyword);
     array_unshift(self::$imagePaths, $path);
     if (N2Settings::get('protocol-relative', '1')) {
         $url = self::protocolRelative($url);
     }
     array_unshift(self::$imageUrls, $url);
 }
Example #2
0
 public function renderGlobalConfigurationForm()
 {
     $values = N2Settings::getAll();
     $form = new N2Form($this->appType);
     $form->loadArray($values);
     $form->loadXMLFile(N2Loader::getPath('models', 'system') . '/forms/globalconfig.xml');
     echo N2Html::openTag("form", array("id" => "nextend-config", "method" => "post", "action" => N2Request::getRequestUri()));
     $form->render('global');
     echo N2Html::closeTag("form");
     N2JS::addFirstCode("\n            new NextendForm(\n                'nextend-config',\n                '" . $this->appType->router->createAjaxUrl(array('settings/index')) . "',\n                " . json_encode($values) . "\n            );\n        ");
 }
Example #3
0
 public static function init()
 {
     $config = array('jquery' => 1, 'gsap' => 1, 'async' => 0, 'combine-js' => 0, 'minify-js' => 0, 'protocol-relative' => 1);
     if (!defined('NEXTEND_INSTALL')) {
         foreach (N2StorageSectionAdmin::getAll('system', 'global') as $data) {
             $config[$data['referencekey']] = $data['value'];
         }
     }
     self::$data = new N2Data();
     self::$data->loadArray($config);
 }
Example #4
0
 public static function jQuery($force = false)
 {
     if (N2Settings::get('jquery') || N2Platform::$isAdmin || $force) {
         self::addFiles(N2LIBRARYASSETS . '/js/core/jquery', array("jQuery.min.js", "njQuery.js"), "n2");
     } else {
         if (N2Settings::get('async', '0')) {
             self::addInline(file_get_contents(N2LIBRARYASSETS . '/js/core/jquery/njQuery.js'), true);
         } else {
             self::addFiles(N2LIBRARYASSETS . '/js/core/jquery', array("njQuery.js"), "n2");
         }
     }
     self::addFiles(N2LIBRARYASSETS . '/js', array("console.js"), "nextend-frontend");
 }
Example #5
0
 public static function jQuery($force = false)
 {
     if ($force) {
         self::addFiles(ABSPATH . '/wp-includes/js/jquery/', array("jquery.js", "jquery-migrate.min.js"), "n2");
         self::addFiles(N2LIBRARYASSETS . '/js/core/jquery', array("njQuery.js"), "n2");
     } else {
         wp_enqueue_script('jquery');
         if (N2Settings::get('async', '0')) {
             self::addInline(file_get_contents(N2LIBRARYASSETS . '/js/core/jquery/njQuery.js'), true);
         } else {
             self::addFiles(N2LIBRARYASSETS . '/js/core/jquery', array("njQuery.js"), "n2");
         }
     }
     self::addFiles(N2LIBRARYASSETS . '/js', array("console.js"), "nextend-frontend");
 }
Example #6
0
 public static function api($posts)
 {
     if (!isset($data)) {
         if (function_exists('curl_init') && N2Settings::get('curl', 1)) {
             $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);
             curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
             curl_setopt($ch, CURLOPT_TIMEOUT, 30);
             if (N2Settings::get('curl-clean-proxy', 0)) {
                 curl_setopt($ch, CURLOPT_PROXY, '');
             }
             $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;
 }
Example #7
0
 public static function init()
 {
     $config = array('jquery' => 1, 'gsap' => 1, 'async' => 0, 'combine-js' => 0, 'minify-js' => 0, 'protocol-relative' => 1);
     if (!defined('NEXTEND_INSTALL')) {
         global $wpdb;
         if ($wpdb->get_var("SHOW TABLES LIKE '" . $wpdb->prefix . "nextend2_section_storage'") != $wpdb->prefix . 'nextend2_section_storage') {
             define('NEXTEND_INSTALL', 1);
         }
     }
     if (!defined('NEXTEND_INSTALL')) {
         foreach (N2StorageSectionAdmin::getAll('system', 'global') as $data) {
             $config[$data['referencekey']] = $data['value'];
         }
     }
     self::$data = new N2Data();
     self::$data->loadArray($config);
 }
Example #8
0
 public function actionIndex()
 {
     if ($this->canDo('nextend_config')) {
         $data = N2Post::getVar('global');
         if (is_array($data)) {
             if ($this->validateToken()) {
                 N2Settings::setAll($data);
             } else {
                 $this->refresh();
             }
         }
         $this->addView("../../inline/sidebar/settings", array("appObj" => $this), "sidebar");
         $this->addView("index");
         $this->render();
     } else {
         $this->noAccess();
     }
 }
Example #9
0
 private static function animation($force = false)
 {
     static $once;
     if ($once != null && !$force) {
         return;
     }
     $once = true;
     if (N2Pluggable::hasAction('animationFramework')) {
         N2Pluggable::doAction('animationFramework');
     } else {
         if (N2Settings::get('gsap')) {
             N2JS::addFiles(N2LIBRARYASSETS . "/js/core/gsap", array("gsap.js"), "nextend-frontend");
         } else {
             if (N2Platform::$isAdmin) {
                 N2JS::addFiles(N2LIBRARYASSETS . "/js/core/gsap", array("gsap.js"), "nextend-gsap");
             } else {
                 N2JS::addFiles(N2LIBRARYASSETS . "/js/core/gsap", array("NextendTimeline.js"), "nextend-gsap");
             }
         }
     }
 }
Example #10
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;
 }
Example #11
0
 public static function afterOutputEnd()
 {
     self::$nextend_wp_footer = true;
     if (defined('N2LIBRARY')) {
         ob_start();
         do_action('nextend_css');
         do_action('nextend_js');
         if (class_exists('N2AssetsManager')) {
             echo N2AssetsManager::getCSS();
             echo N2AssetsManager::getJs();
         }
         self::$nextend_head = ob_get_clean();
     }
     if (N2Settings::get('safemode') == 1) {
         echo self::$nextend_head;
     }
     return true;
 }