Example #1
0
 public function redirect($url)
 {
     self::fix_output_buffer();
     $this->response['redirect'] = $this->appType->router->createUrl($url);
     echo json_encode($this->response);
     n2_exit(true);
 }
Example #2
0
 function loadXMLFile($file)
 {
     if (!N2Filesystem::existsFile($file)) {
         echo "xml file not found ('{$file}')! <br /><strong>" . __FILE__ . ":" . __LINE__ . "</strong>";
         n2_exit(true);
         //throw new Exception("xml file not found ('{$file}')! <br /><strong>" . __FILE__ . ":" . __LINE__."</strong>");
     }
     // @fix Warning: simplexml_load_file(): I/O warning : failed to load external entity
     $this->_xml = simplexml_load_string(file_get_contents($file));
     $this->_xmlfile = $file;
     $this->xmlFolder = dirname($file);
 }
Example #3
0
 /**
  * @param bool $error error message
  * @param int  $limit
  */
 public static function getDebugTrace($error = false, $limit = 5)
 {
     $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
     $outrace = array();
     if ($trace) {
         foreach ($trace as $k => $trow) {
             if ($k > 0 && $k <= $limit + 1) {
                 $outrace[] = $trow;
             }
         }
     }
     if ($error) {
         echo "<p><strong>{$error}</strong></p>";
     }
     echo N2Html::openTag("pre");
     print_r($outrace);
     echo N2Html::closeTag("pre");
     n2_exit(true);
 }
Example #4
0
 function initElements()
 {
     $this->_elements = array();
     foreach ($this->_xml->param as $element) {
         $test = N2XmlHelper::getAttribute($element, 'test');
         if ($this->_form->makeTest($test)) {
             $class = N2Form::importElement(N2XmlHelper::getAttribute($element, 'type'));
             if (!class_exists($class, false)) {
                 throw new Exception($class . ' missing in ' . $this->_form->_xmlfile);
                 n2_exit(true);
             }
             $field = new $class($this->_form, $this, $element);
             if ($field->_name) {
                 $this->_elements[$field->_name] = $field;
             } else {
                 $this->_elements[] = $field;
             }
         }
     }
 }
Example #5
0
 public function actionExportAll()
 {
     N2Loader::import('libraries.export', 'smartslider');
     $slidersModel = new N2SmartsliderSlidersModel();
     $sliders = $slidersModel->getAll();
     foreach ($sliders as $slider) {
         $export = new N2SmartSliderExport($slider['id']);
         $export->create(true);
     }
     $folder = N2Platform::getPublicDir();
     $folder .= '/export/';
     $zip = new N2ZipFile();
     foreach (N2Filesystem::files($folder) as $file) {
         $zip->addFile(file_get_contents($folder . $file), $file);
     }
     ob_end_clean();
     header('Content-disposition: attachment; filename=sliders_unzip_to_import.zip');
     header('Content-type: application/zip');
     echo $zip->file();
     n2_exit(true);
 }
Example #6
0
 public static function removeStack()
 {
     if (count(self::$cssStack) > 0) {
         /**
          * @var $previousCSS          N2AssetsCss
          * @var $previousLESS         N2AssetsLess
          * @var $previousJS           N2AssetsJs
          * @var $previousGoogleFons   N2AssetsGoogleFonts
          */
         $previousCSS = array_shift(self::$cssStack);
         self::$css = self::$cssStack[0];
         $previousLESS = array_shift(self::$lessStack);
         self::$less = self::$lessStack[0];
         $previousJS = array_shift(self::$jsStack);
         self::$js = self::$jsStack[0];
         $previousGoogleFons = array_shift(self::$googleFontsStack);
         self::$googleFonts = self::$googleFontsStack[0];
         return array('css' => $previousCSS->serialize(), 'less' => $previousLESS->serialize(), 'js' => $previousJS->serialize(), 'googleFonts' => $previousGoogleFons->serialize());
     } else {
         echo "Too much remove stack on the asset manager...";
         n2_exit(true);
     }
 }
Example #7
0
<?php

/**
* @author    Roland Soos
* @copyright (C) 2015 Nextendweb.com
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
**/
defined('_JEXEC') or die('Restricted access');
if (JFactory::getUser()->authorise('core.manage', 'com_nextend2')) {
    jimport("nextend2.nextend.joomla.library");
    N2Base::getApplication("system")->getApplicationType('backend')->render(array("controller" => "dashboard", "action" => "index"));
    n2_exit();
} else {
    return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
}
Example #8
0
 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*([\'"]|(&#039;))?(\\S*\\.(?:jpe?g|gif|png))([\'"]|(&#039;))?\\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);
 }
Example #9
0
 public static function nextendApplication()
 {
     N2Base::getApplication("system")->getApplicationType('backend')->setCurrent()->render(array("controller" => "dashboard", "action" => "index"));
     n2_exit();
 }
Example #10
0
 public function actionFinishAuth()
 {
     if ($this->validatePermission('smartslider_config')) {
         $generatorModel = new N2SmartsliderGeneratorModel();
         $group = N2Request::getVar('group');
         $type = N2Request::getVar('type');
         $info = $generatorModel->getGeneratorInfo($group, $type);
         $configuration = $info->getConfiguration();
         $result = $configuration->finishAuth();
         if ($result === true) {
             N2Message::success(n2_('Authentication successful.'));
             echo '<script>window.opener.location.reload();self.close();</script>';
         } else {
             if ($result instanceof Exception) {
                 $message = $result->getMessage();
             } else {
                 $message = 'Something wrong with the credentials';
             }
             echo '<script>window.opener.nextend.notificationCenter.error("' . htmlspecialchars($message) . '");self.close();</script>';
         }
         n2_exit(true);
     }
 }
Example #11
0
 /**
  * @param array|string $url
  * @param integer      $statusCode
  * @param bool         $terminate
  */
 public static function redirect($url, $statusCode = 302, $terminate = true)
 {
     header('Location: ' . $url, true, $statusCode);
     if ($terminate) {
         n2_exit(true);
     }
 }
 public static function application($dummy, $controller = 'sliders', $action = 'index')
 {
     N2Base::getApplication("smartslider")->getApplicationType('backend')->setCurrent()->render(array("controller" => $controller, "action" => $action));
     n2_exit();
 }