/**
  * @ignore
  */
 public static function renderview($uObject)
 {
     $tInputFile = $uObject['templatePath'] . $uObject['templateFile'];
     $tOutputFile = Io::translatePath('{writable}cache/md/' . $uObject['compiledFile']);
     if (Framework::$disableCaches || !Io::isReadableAndNewer($tOutputFile, filemtime($tInputFile))) {
         if (self::$engine === null) {
             self::$engine = new MarkdownExtra();
         }
         $tInput = Io::read($tInputFile);
         $tOutput = self::$engine->transform($tInput);
         Io::writeSerialize($tOutputFile, $tOutput);
         echo $tOutput;
     } else {
         echo Io::readSerialize($tOutputFile);
     }
 }
Example #2
0
 /**
  * @ignore
  *
  * @throws \Exception
  */
 public static function renderview($uObject)
 {
     $tInputFile = $uObject['templatePath'] . $uObject['templateFile'];
     $tOutputFile = Io::translatePath('{writable}cache/cshtml/' . $uObject['compiledFile']);
     if (Framework::$disableCaches || !Io::isReadableAndNewer($tOutputFile, filemtime($tInputFile))) {
         if (self::$engine === null) {
             self::$engine = new RazorViewRenderer();
         }
         if (Framework::$readonly) {
             throw new \Exception('Framework runs in read only mode.');
         }
         self::$engine->generateViewFile($tInputFile, $tOutputFile);
     }
     // variable extraction
     $model = $uObject['model'];
     if (is_array($model)) {
         extract($model, EXTR_SKIP | EXTR_REFS);
     }
     extract(Framework::$variables, EXTR_SKIP | EXTR_REFS);
     require $tOutputFile;
 }
Example #3
0
 /**
  * Loads the default configuration for the current application.
  *
  * @uses Config::loadFile()
  * @throws \Exception if any extension is not found
  * @return array loaded configuration
  */
 public static function load()
 {
     $tConfigFiles = array(Framework::$corepath . 'config.json');
     if (Framework::$application !== null) {
         Io::glob(Framework::$application->path . 'config/', '*.json', Io::GLOB_RECURSIVE | Io::GLOB_FILES, "", $tConfigFiles);
     }
     $tLastModified = Io::getLastModified($tConfigFiles);
     $tOutputFile = Io::translatePath('{writable}cache/config');
     if (!Framework::$disableCaches && Io::isReadableAndNewer($tOutputFile, $tLastModified)) {
         self::$loadedFromCache = true;
         return Io::readSerialize($tOutputFile);
     }
     $tConfig = array();
     foreach ($tConfigFiles as $tFile) {
         self::loadFile($tConfig, $tFile, true);
     }
     if (isset($tConfig['extensionList'])) {
         foreach ($tConfig['extensionList'] as $tExtension) {
             $tFile = Framework::$corepath . 'src/Scabbia/Extensions/' . $tExtension . '/config.json';
             if (file_exists($tFile)) {
                 self::loadFile($tConfig, $tFile, false);
                 continue;
             }
             if (Framework::$application !== null) {
                 $tFile = Framework::$application->path . 'Extensions/' . $tExtension . '/config.json';
                 if (file_exists($tFile)) {
                     self::loadFile($tConfig, $tFile, false);
                     continue;
                 }
             }
             throw new \Exception('extension not found - ' . $tExtension);
         }
     }
     self::$loadedFromCache = false;
     if (!Framework::$readonly) {
         Io::writeSerialize($tOutputFile, $tConfig);
     }
     return $tConfig;
 }
Example #4
0
 /**
  * @ignore
  */
 public static function setLanguage($uLanguage, $uLastChoice = false)
 {
     self::load();
     if (isset(self::$languages[$uLanguage])) {
         self::$language = self::$languages[$uLanguage];
     } else {
         if ($uLastChoice) {
             $tExploded = explode('-', $uLanguage, 2);
             if (isset(self::$languages[$tExploded[0]])) {
                 self::$language = self::$languages[$tExploded[0]];
             }
         }
     }
     if (self::$language !== null) {
         // if (DIRECTORY_SEPARATOR === '\\') {
         //     $tLocale = explode('.', self::$language['localewin'], 2);
         // }
         // else {
         $tLocale = explode('.', self::$language['locale'], 2);
         // }
         $tLocale['all'] = implode('.', $tLocale);
         // mb_internal_encoding(self::$language['internalEncoding']);
         mb_http_output(self::$language['internalEncoding']);
         putenv('LANG=' . $tLocale[0]);
         setlocale(LC_ALL, $tLocale[0]);
         // @todo path confusion
         if (Framework::$application !== null) {
             $tLocalePath = Framework::$application->path . 'locale';
             $tMoFile = $tLocalePath . '/' . $tLocale[0] . '/LC_MESSAGES/application.mo';
             $tPoFile = $tLocalePath . '/' . $tLocale[0] . '/LC_MESSAGES/application.po';
             if (!Framework::$readonly && (!Io::isReadable($tMoFile) || Io::isReadableAndNewer($tPoFile, filemtime($tMoFile)))) {
                 $tCompiler = new \TrekkSoft\Potomoco\Compiler();
                 $tCompiler->compile($tPoFile, $tMoFile);
             }
             if (self::$gettextType === self::GETTEXT_EXTENSION) {
                 // bindtextdomain('core', Framework::$corepath . 'locale');
                 // bind_textdomain_codeset('core', self::$language['internalEncoding']);
                 bindtextdomain('application', $tLocalePath);
                 bind_textdomain_codeset('application', self::$language['internalEncoding']);
                 textdomain('application');
             } else {
                 self::$gettextInstance = new Gettext($tMoFile);
             }
         }
         Framework::$variables['lang'] = self::$language['key'];
         return true;
     }
     return false;
 }