Example #1
0
 /**
  */
 public function execute()
 {
     SPFactory::mainframe()->cleanBuffer()->customHeader();
     if (SPFs::exists($this->file)) {
         echo SPFs::read($this->file);
     } else {
         echo json_encode(array('progress' => 0, 'message' => '', 'interval' => 100, 'type' => ''));
     }
     exit;
 }
Example #2
0
 public function loadFile($file)
 {
     $sql = SPFs::read($file);
     $sql = explode("\n", $sql);
     $log = array();
     if (count($sql)) {
         foreach ($sql as $query) {
             if (strlen($query)) {
                 $this->exec(str_replace('spdb_', $this->prefix . 'sobipro_', $query));
                 $log[] = $query;
             }
         }
     }
     return $log;
 }
Example #3
0
 /**
  * @return array
  */
 public function struct()
 {
     if (!$this->dependency) {
         return parent::struct(true);
     }
     $selected = $this->getRaw();
     if (isset($this->_fData->options)) {
         $path = SPConfig::unserialize($this->_fData->options);
     } else {
         return null;
     }
     $selectedPath = array();
     $options = json_decode(SPFs::read(SOBI_PATH . '/etc/fields/select-list/definitions/' . str_replace('.xml', '.json', $this->dependencyDefinition)), true);
     if (isset($options['translation'])) {
         SPLang::load($options['translation']);
         $selected = Sobi::Txt(strtoupper($options['prefix']) . '.' . strtoupper($selected));
     }
     if (count($path) && isset($options['translation'])) {
         foreach ($path as $step) {
             $selectedPath[$step] = $selected = Sobi::Txt(strtoupper($options['prefix']) . '.' . strtoupper($step));
         }
     }
     $this->cleanCss();
     return array('_complex' => 1, '_data' => $selected, '_attributes' => array('class' => $this->cssClass), '_options' => array('path' => count($selectedPath) ? $selectedPath : $path));
 }
Example #4
0
 private function getNews()
 {
     $out = array();
     $path = SPLoader::path('etc.news', 'front', false, 'xml');
     if (SPFs::exists($path) && time() - filemtime($path) < 60 * 60 * 12) {
         $content = SPFs::read(SPLoader::path('etc.news', 'front', false, 'xml'));
     } else {
         try {
             $connection = SPFactory::Instance('services.remote');
             $news = 'http://rss.sigsiu.net';
             $connection->setOptions(array('url' => $news, 'connecttimeout' => 10, 'header' => false, 'returntransfer' => true));
             $file = SPFactory::Instance('base.fs.file', $path);
             $content = $connection->exec();
             $cinf = $connection->info();
             if (isset($cinf['http_code']) && $cinf['http_code'] != 200) {
                 return Sobi::Error('about', sprintf('CANNOT_GET_NEWS', $news, $cinf['http_code']), SPC::WARNING, 0, __LINE__, __FILE__);
             }
             $file->content($content);
             $file->save();
         } catch (SPException $x) {
             return Sobi::Error('about', SPLang::e('CANNOT_LOAD_NEWS', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
         }
     }
     try {
         if (strlen($content)) {
             $news = new DOMXPath(DOMDocument::loadXML($content));
             $atom = false;
             if ($atom) {
                 //Atom
                 $news->registerNamespace('atom', 'http://www.w3.org/2005/Atom');
                 $out['title'] = $news->query('/atom:feed/atom:title')->item(0)->nodeValue;
                 $items = $news->query('/atom:feed/atom:entry[*]');
                 $c = 5;
                 $open = false;
                 foreach ($items as $item) {
                     $date = $item->getElementsByTagName('updated')->item(0)->nodeValue;
                     if (!$open && time() - strtotime($date) < 60 * 60 * 24) {
                         $open = true;
                     }
                     $feed = array('url' => $item->getElementsByTagName('link')->item(0)->nodeValue, 'title' => $item->getElementsByTagName('title')->item(0)->nodeValue, 'content' => $item->getElementsByTagName('content')->item(0)->nodeValue);
                     if (!$c--) {
                         break;
                     }
                     $out['feeds'][] = $feed;
                 }
             } else {
                 //RSS
                 $out['title'] = $news->query('/rss/channel/title')->item(0)->nodeValue;
                 $items = $news->query('/rss/channel/item[*]');
                 $c = 5;
                 $open = false;
                 foreach ($items as $item) {
                     $date = $item->getElementsByTagName('pubDate')->item(0)->nodeValue;
                     if (!$open && time() - strtotime($date) < 60 * 60 * 24) {
                         $open = true;
                     }
                     $feed = array('url' => $item->getElementsByTagName('link')->item(0)->nodeValue, 'title' => $item->getElementsByTagName('title')->item(0)->nodeValue, 'content' => $item->getElementsByTagName('description')->item(0)->nodeValue, 'image' => $item->getElementsByTagName('enclosure')->item(0)->attributes->getNamedItem('url')->nodeValue);
                     if (!$c--) {
                         break;
                     }
                     $out['feeds'][] = $feed;
                 }
             }
         }
         if ($open) {
             SPFactory::header()->addJsCode('SobiPro.jQuery( document ).ready( function () { SobiPro.jQuery( \'#SobiProNews\' ).trigger(\'click\'); } );');
         }
     } catch (DOMException $x) {
         return Sobi::Error('about', SPLang::e('CANNOT_LOAD_NEWS', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
     }
     return $out;
 }
Example #5
0
 /**
  * @param string $name variable name
  * @param string $property
  * @param string $request request method
  * @return string
  */
 public static function file($name, $property = null, $request = 'files')
 {
     if ($request == 'files') {
         /** check for Ajax uploaded files */
         $check = self::string($name);
         if ($check) {
             $secret = md5(Sobi::Cfg('secret'));
             $fileName = str_replace('file://', null, $check);
             $path = SPLoader::dirPath("tmp.files.{$secret}", 'front', false) . '/' . $fileName;
             if (file_exists("{$path}.var")) {
                 $cfg = SPFs::read("{$path}.var");
                 $data = SPConfig::unserialize($cfg);
                 $_FILES[$name] = $data;
             }
         }
     }
     self::init($name, $request);
     self::$val = isset(self::$request[self::$name]) ? self::$request[self::$name] : null;
     return $property && isset(self::$val[$property]) ? self::$val[$property] : self::$val;
 }
Example #6
0
 private function _jsFiles()
 {
     if (Sobi::Cfg('cache.include_js_files', false) && !defined('SOBIPRO_ADM')) {
         if (count($this->_cache['js'])) {
             $compression = Sobi::Cfg('cache.compress_js', false);
             $comprLevel = Sobi::Cfg('cache.compress_level', 0);
             $check = array('section' => Sobi::Section(), 'compress_level' => $comprLevel, 'compress_js' => $compression);
             foreach ($this->_cache['js'] as $file) {
                 $check[$file] = filemtime($file);
             }
             $check = md5(serialize($check));
             if (!SPFs::exists(SOBI_PATH . "/var/js/{$check}.js")) {
                 $noCompress = explode(',', Sobi::Cfg('cache.js_compress_exceptions'));
                 $jsContent = "\n/* Created at: " . date(SPFactory::config()->key('date.log_format', 'D M j G:i:s T Y')) . " */\n";
                 foreach ($this->_cache['js'] as $file) {
                     $fName = str_replace(SOBI_ROOT, null, $file);
                     $jsContent .= "\n// ========\n// File: {$fName}\n// ========\n\n";
                     if ($compression && !in_array(basename($file), $noCompress)) {
                         $compressor = SPFactory::Instance('env.jspacker', SPFs::read($file), $comprLevel, false, true);
                         $jsContent .= $compressor->pack();
                     } else {
                         $jsContent .= SPFs::read($file);
                     }
                     $jsContent .= ";\n";
                 }
                 SPFs::write(SOBI_PATH . "/var/js/{$check}.js", $jsContent);
             }
             $cfile = SPLoader::JsFile('front.var.js.' . $check, false, true, true);
             $this->jsFiles[++$this->count] = "\n<script type=\"text/javascript\" src=\"{$cfile}\"></script>";
         }
     }
     return $this->jsFiles;
 }
Example #7
0
 protected function xmlFile($node, &$element)
 {
     $type = $node->attributes->getNamedItem('type')->nodeValue;
     $translatable = $node->attributes->getNamedItem('translatable') ? $node->attributes->getNamedItem('translatable')->nodeValue : false;
     $admin = $node->attributes->getNamedItem('start-path') ? $node->attributes->getNamedItem('start-path')->nodeValue : 'front';
     $filename = $node->attributes->getNamedItem('filename')->nodeValue;
     $path = explode('.', $filename);
     $filename = array_pop($path);
     $dirPath = implode('.', $path);
     $element['type'] = 'text';
     if ($translatable) {
         $file = SPLoader::path($dirPath . '.' . Sobi::Lang() . '.' . $filename, $admin, true, $type);
         if (!$file) {
             $file = SPLoader::path($dirPath . '.en-GB.' . $filename, $admin, true, $type);
         }
         if ($file) {
             $element['content'] = SPFs::read($file);
         } else {
             $element['content'] = SPLoader::path($dirPath . '.' . Sobi::Lang() . '.' . $filename, $admin, false, $type);
         }
     }
 }
Example #8
0
 /**
  * @return void
  */
 protected function templateSettings()
 {
     if (!(isset($this->_attr['config']) && count($this->_attr['config'])) && SPLoader::translatePath("{$this->_templatePath}.config", 'absolute', true, 'json')) {
         $config = json_decode(SPFs::read(SPLoader::translatePath("{$this->_templatePath}.config", 'absolute', true, 'json')), true);
         $task = SPRequest::task() == 'entry.add' ? 'entry.edit' : SPRequest::task();
         $settings = array();
         foreach ($config as $section => $setting) {
             $settings[str_replace('-', '.', $section)] = $setting;
         }
         if (SPLoader::translatePath("{$this->_templatePath}.{$task}", 'absolute', true, 'json')) {
             $subConfig = json_decode(SPFs::read(SPLoader::translatePath("{$this->_templatePath}.{$task}", 'absolute', true, 'json')), true);
             if (count($subConfig)) {
                 foreach ($subConfig as $section => $subSettings) {
                     foreach ($subSettings as $k => $v) {
                         $settings[str_replace('-', '.', $section)][$k] = $v;
                     }
                 }
             }
         }
         if (isset($settings['general'])) {
             foreach ($settings['general'] as $k => $v) {
                 $this->_attr['config'][$k] = array('_complex' => 1, '_attributes' => array('value' => $v));
             }
         }
         if (isset($settings[$task])) {
             foreach ($settings[$task] as $k => $v) {
                 $this->_attr['config'][$k] = array('_complex' => 1, '_attributes' => array('value' => $v));
             }
         }
     }
 }
Example #9
0
 /**
  * Reads file and returns the content of it
  * @return string
  */
 public function &read()
 {
     $this->_content = SPFs::read($this->_filename);
     return $this->_content;
 }
Example #10
0
 private function payment()
 {
     $sid = SPRequest::sid();
     $data = SPFactory::cache()->getObj('payment', $sid, Sobi::Section(), true);
     if (!$data) {
         $tsId = SPRequest::string('tsid');
         $tfile = SPLoader::path('tmp.edit.' . $tsId . '.payment', 'front', false, 'var');
         if (SPFs::exists($tfile)) {
             $data = SPConfig::unserialize(SPFs::read($tfile));
         }
     }
     if (!$data) {
         Sobi::Error('payment', SPLang::e('Session expired'), SPC::ERROR, 500, __LINE__, __FILE__);
     }
     /*
      * It doesn't make sense because this has been already checked for the edit function. Right?
      * Or do I miss something?
      */
     //		if( Sobi::My( 'id' ) && Sobi::My( 'id' ) == $this->_model->get( 'owner' ) ) {
     //			$this->authorise( 'edit', 'own' );
     //		}
     //		else {
     //			$this->authorise( 'edit', '*' );
     //		}
     if ($data['ident'] != SPRequest::string('payment_' . $sid, null, false, 'cookie')) {
         Sobi::Error('payment', SPLang::e('UNAUTHORIZED_ACCESS'), SPC::ERROR, 403, __LINE__, __FILE__);
     }
     $this->paymentView(null, $data['data']);
 }
Example #11
0
 /**
  * This method is adding new tasks to the XML files used for Joomla! menu definition
  * @param $tasks - list of tasks to add
  * @param $controlString - a single string to check for if it has not been already added
  * @param $languageFile - language file where the translation for tasks can be found
  * @param array $additionalStrings - optional list of additional strings to add to the sys ini files
  * @param bool $force - force even if it has been already done - forcing only language files redefinition
  * @return void
  */
 public function updateXMLDefinition($tasks, $controlString, $languageFile, $additionalStrings = array(), $force = false)
 {
     $file = SPLoader::translatePath('metadata', 'front', true, 'xml');
     $run = false;
     $strings = array();
     foreach ($tasks as $label) {
         $strings[] = $label;
         $strings[] = $label . '_EXPL';
     }
     if (count($additionalStrings)) {
         foreach ($additionalStrings as $additionalString) {
             $strings[] = $additionalString;
         }
     }
     /** check if it hasn't been already added */
     if (!strstr(SPFs::read($file), $controlString)) {
         $run = true;
         $doc = new DOMDocument();
         $doc->load($file);
         $options = $doc->getElementsByTagName('options')->item(0);
         foreach ($tasks as $task => $label) {
             $node = $doc->createElement('option');
             $attribute = $doc->createAttribute('value');
             $attribute->value = $task;
             $node->appendChild($attribute);
             $attribute = $doc->createAttribute('name');
             $attribute->value = 'SP.' . $label;
             $node->appendChild($attribute);
             $attribute = $doc->createAttribute('msg');
             $attribute->value = 'SP.' . $label . '_EXPL';
             $node->appendChild($attribute);
             $options->appendChild($node);
         }
         $doc->save($file);
     }
     if ($run || $force) {
         $dirPath = SPLoader::dirPath('administrator.language', 'root');
         /** @var SPDirectory $dir */
         $dir = SPFactory::Instance('base.fs.directory', $dirPath);
         $files = $dir->searchFile('com_sobipro.sys.ini', false, 2);
         $default = array();
         $defaultLangDir = SPLoader::dirPath("language.en-GB", 'root', true);
         $defaultLang = parse_ini_file($defaultLangDir . 'en-GB.' . $languageFile . '.ini');
         foreach ($strings as $string) {
             $default['SP.' . $string] = $defaultLang['SP.' . $string];
         }
         /** @var SPFile $file */
         $file = null;
         foreach ($files as $file) {
             $fileName = $file->getFileName();
             list($language) = explode('.', $fileName);
             $nativeLangDir = SPLoader::dirPath("language.{$language}", 'root', true);
             $nativeStrings = array();
             if ($nativeLangDir) {
                 $nativeLangFile = $nativeLangDir . $language . '.' . $languageFile . '.ini';
                 if (file_exists($nativeLangFile)) {
                     $nativeLang = @parse_ini_file($nativeLangFile);
                     foreach ($strings as $string) {
                         if (isset($nativeLang['SP.' . $string])) {
                             $nativeStrings['SP.' . $string] = $nativeLang['SP.' . $string];
                         }
                     }
                 }
             }
             $add = null;
             foreach ($strings as $string) {
                 if (isset($nativeStrings['SP.' . $string])) {
                     $add .= "\nSP.{$string}=\"{$nativeStrings['SP.' . $string]}\"";
                 } else {
                     $add .= "\nSP.{$string}=\"{$default['SP.' . $string]}\"";
                 }
             }
             $add .= "\n";
             $content = SPFs::read($file->getPathname());
             $add = $content . $add;
             SPFs::write($file->getPathname(), $add);
         }
     }
 }
Example #12
0
 /**
  */
 protected function tplCfg($path, $task = null)
 {
     $file = explode('.', $path);
     $files = array();
     if (strstr($file[0], 'cms:')) {
         $file[0] = str_replace('cms:', null, $file[0]);
         $file = SPFactory::mainframe()->path(implode('.', $file));
         $path = SPLoader::dirPath($file, 'root', true);
         $this->_tCfg = SPLoader::loadIniFile("{$path}.config", true, false, false, true);
         $files[] = SPLoader::iniStorage();
     } else {
         $this->_tCfg = SPLoader::loadIniFile("usr.templates.{$path}.config");
         $files[] = SPLoader::iniStorage();
         $path = SPLoader::dirPath('usr.templates.' . $path, 'front', true);
     }
     if (!$task) {
         $task = $this->_task == 'add' || $this->_task == 'submit' ? 'edit' : $this->template;
     }
     if (SPLoader::translatePath("{$path}.{$this->templateType}.{$task}", 'absolute', true, 'ini')) {
         $taskCfg = SPLoader::loadIniFile("{$path}.{$this->templateType}.{$task}", true, false, false, true);
         $files[] = SPLoader::iniStorage();
         foreach ($taskCfg as $section => $keys) {
             if (isset($this->_tCfg[$section])) {
                 $this->_tCfg[$section] = array_merge($this->_tCfg[$section], $keys);
             } else {
                 $this->_tCfg[$section] = $keys;
             }
         }
     }
     if (count($files)) {
         foreach ($files as $i => $file) {
             $files[$i] = array('file' => str_replace(SPLoader::translateDirPath(Sobi::Cfg('section.template'), 'templates'), null, $file), 'checksum' => md5_file($file));
         }
         SPFactory::registry()->set('template_config', $files);
     }
     if (SPLoader::translatePath("{$path}.config", 'absolute', true, 'json')) {
         $config = json_decode(SPFs::read(SPLoader::translatePath("{$path}.config", 'absolute', true, 'json')), true);
         $settings = array();
         foreach ($config as $section => $setting) {
             $settings[str_replace('-', '.', $section)] = $setting;
         }
         if (SPLoader::translatePath("{$path}.{$this->templateType}.{$task}", 'absolute', true, 'json')) {
             $subConfig = json_decode(SPFs::read(SPLoader::translatePath("{$path}.{$this->templateType}.{$task}", 'absolute', true, 'json')), true);
             if (count($subConfig)) {
                 foreach ($subConfig as $section => $subSettings) {
                     foreach ($subSettings as $k => $v) {
                         $settings[str_replace('-', '.', $section)][$k] = $v;
                     }
                 }
             }
         }
         if (isset($settings['general'])) {
             foreach ($settings['general'] as $k => $v) {
                 $this->_tCfg['general'][$k] = $v;
             }
         }
         $task = SPRequest::task() == 'entry.add' ? 'entry.edit' : SPRequest::task();
         if (isset($settings[$task])) {
             foreach ($settings[$task] as $k => $v) {
                 $this->_tCfg['general'][$k] = $v;
             }
         }
     }
     Sobi::Trigger($this->name(), __FUNCTION__, array(&$this->_tCfg));
     SPFactory::registry()->set('current_template', $path);
 }
Example #13
0
 protected function iconFont()
 {
     $font = SPRequest::cmd('font');
     if (strstr($font, 'font-')) {
         SPFactory::mainframe()->cleanBuffer()->customHeader();
         exit(SPFs::read(SPLoader::translatePath('etc.fonts.' . $font, 'front', true, 'json')));
     }
 }
Example #14
0
 private static function createLangFile()
 {
     static $loaded = false;
     if (!$loaded) {
         $lang = array('months' => Sobi::Txt('JS_CALENDAR_MONTHS'), 'monthsShort' => Sobi::Txt('JS_CALENDAR_MONTHS_SHORT'), 'days' => Sobi::Txt('JS_CALENDAR_DAYS'), 'daysShort' => Sobi::Txt('JS_CALENDAR_DAYS_SHORT'), 'daysMin' => Sobi::Txt('JS_CALENDAR_DAYS_MINI'), 'today' => Sobi::Txt('JS_CALENDAR_TODAY'));
         $check = md5(serialize($lang));
         if (!SPLoader::JsFile('locale.' . Sobi::Lang(false) . '_date_picker', false, true, false) || !stripos(SPFs::read(SPLoader::JsFile('locale.' . Sobi::Lang(false) . '_date_picker', false, false, false)), $check)) {
             foreach ($lang as $k => $v) {
                 $lang[$k] = explode(',', $v);
             }
             $lang = json_encode($lang);
             $c = "\nvar spDatePickerLang={$lang}";
             $c .= "\n//{$check}";
             SPFs::write(SPLoader::JsFile('locale.' . Sobi::Lang(false) . '_date_picker', false, false, false), $c);
         }
     }
     $loaded = true;
 }
Example #15
0
 private function download()
 {
     $Error = new DOMDocument('1.0', 'utf-8');
     $Error->formatOutput = true;
     $Root = $Error->createElement('errorLog');
     $Date = $Error->createAttribute('createdAt');
     $Date->appendChild($Error->createTextNode(date(DATE_RFC822)));
     $Root->appendChild($Date);
     $Site = $Error->createAttribute('site');
     $Site->appendChild($Error->createTextNode(Sobi::Cfg('live_site')));
     $Root->appendChild($Site);
     $Error->appendChild($Root);
     $levels = $this->levels();
     try {
         $errors = SPFactory::db()->select('*', 'spdb_errors', null, 'eid.desc')->loadAssocList();
     } catch (SPException $x) {
     }
     $c = 0;
     if (count($errors)) {
         foreach ($errors as $i => $err) {
             $c++;
             if ($c > Sobi::Cfg('err_log.limit', 50)) {
                 break;
             }
             $err['errNum'] = $levels[$err['errNum']];
             $Err = $Error->createElement('error');
             $Date = $Error->createAttribute('date');
             $Date->appendChild($Error->createTextNode($err['date']));
             $Err->appendChild($Date);
             $Level = $Error->createAttribute('level');
             $Level->appendChild($Error->createTextNode($err['errNum']));
             $Err->appendChild($Level);
             $Code = $Error->createAttribute('returnCode');
             $Code->appendChild($Error->createTextNode($err['errCode']));
             $Err->appendChild($Code);
             $Section = $Error->createAttribute('section');
             $Section->appendChild($Error->createTextNode($err['errSect']));
             $Err->appendChild($Section);
             $err['errBacktrace'] = unserialize(gzuncompress(base64_decode($err['errBacktrace'])));
             $err['errBacktrace'] = str_replace(SOBI_ROOT, null, $err['errBacktrace']);
             $err['errMsg'] = str_replace(SOBI_ROOT, null, $err['errMsg']);
             $err['errCont'] = unserialize(gzuncompress(base64_decode($err['errCont'])));
             $err['errCont'] = str_replace(SOBI_ROOT, null, $err['errCont']);
             $ErrMsg = $Error->createElement('message', $err['errMsg']);
             $Err->appendChild($ErrMsg);
             $ErrMsg = $Error->createElement('file', $err['errFile'] . ':' . $err['errLine']);
             $Err->appendChild($ErrMsg);
             $ErrUser = $Error->createElement('user');
             $Uid = $Error->createAttribute('uid');
             $Uid->appendChild($Error->createTextNode($err['errUid']));
             $ErrUser->appendChild($Uid);
             $UsrIp = $Error->createElement('ip', $err['errIp']);
             $ErrUser->appendChild($UsrIp);
             $UsrA = $Error->createElement('userAgent', $err['errUa']);
             $ErrUser->appendChild($UsrA);
             $UsrReq = $Error->createElement('requestedUri', htmlentities($err['errReq']));
             $ErrUser->appendChild($UsrReq);
             $UsrRef = $Error->createElement('referrerUri', str_replace(Sobi::Cfg('live_site'), null, htmlentities($err['errRef'])));
             $ErrUser->appendChild($UsrRef);
             $Err->appendChild($ErrUser);
             $ErrStack = $Error->createElement('callStack');
             $ErrStack->appendChild($Error->createCDATASection("\n" . stripslashes(var_export($err['errCont'], true)) . "\n"));
             $Err->appendChild($ErrStack);
             $ErrTrace = $Error->createElement('callTrace');
             $ErrTrace->appendChild($Error->createCDATASection("\n" . stripslashes(var_export($err['errBacktrace'], true)) . "\n"));
             $Err->appendChild($ErrTrace);
             $Root->appendChild($Err);
         }
     }
     $file = SPLoader::path('var.log.errors', 'front', false, 'xml');
     SPFs::write($file, $Error->saveXML());
     $fp = SPFs::read($file);
     SPFactory::mainframe()->cleanBuffer();
     header("Content-type: application/xml");
     header('Content-Disposition: attachment; filename=error.xml');
     echo $fp;
     flush();
     exit;
 }
Example #16
0
 private function editFile()
 {
     if (Sobi::Section() && Sobi::Cfg('section.template') == SPC::DEFAULT_TEMPLATE) {
         SPFactory::message()->warning(Sobi::Txt('TP.DEFAULT_WARN', 'https://www.sigsiu.net/help_screen/template.info'), false)->setSystemMessage();
     }
     $file = SPRequest::cmd('file');
     $file = $this->file($file);
     $ext = SPFs::getExt($file);
     $fileContent = SPFs::read($file);
     $path = str_replace('\\', '/', SOBI_PATH);
     if (strstr($file, $path)) {
         $filename = str_replace($path . '/usr/templates/', null, $file);
     } else {
         $filename = str_replace(SOBI_ROOT, null, $file);
     }
     $menu = $this->createMenu();
     if (Sobi::Section()) {
         $menu->setOpen('AMN.APPS_SECTION_TPL');
     } else {
         $menu->setOpen('GB.CFG.GLOBAL_TEMPLATES');
     }
     /** @var $view SPAdmTemplateView */
     $view = SPFactory::View('template', true)->assign($fileContent, 'file_content')->assign($filename, 'file_name')->assign($ext, 'file_ext')->assign($menu, 'menu')->assign($this->_task, 'task')->assign(Sobi::Section(), 'sid')->addHidden(SPRequest::cmd('file'), 'fileName')->addHidden($filename, 'filePath')->determineTemplate('template', 'edit');
     Sobi::Trigger('Edit', $this->name(), array(&$file, &$view));
     $view->display();
 }
Example #17
0
 protected function initIcons()
 {
     if (!count($this->_icons)) {
         if (Sobi::Reg('current_template') && SPFs::exists(Sobi::Reg('current_template') . '/js/icons.json')) {
             $this->_icons = json_decode(Sobi::Reg('current_template') . '/js/icons.json', true);
         } else {
             $this->_icons = json_decode(SPFs::read(SOBI_PATH . '/etc/icons.json'), true);
         }
     }
 }