/** * @ignore */ public function storageGet($uKey, $uDirect = false) { // path $tPath = Io::translatePath($this->path . $uKey, true); if (!Io::isReadable($tPath)) { return false; } if ($uDirect) { return Io::read($tPath); } return Io::readSerialize($tPath, $this->keyphase); }
/** * Outputs all parts in single output. * * @returns string Output */ public function output() { $tOutputFile = Io::translatePath('{writable}cache/assets/' . $this->outputName); foreach ($this->classes as $tClassName) { $tOutputFile .= '_' . $tClassName; } $tOutputFile .= '.' . $this->outputType; if (!Framework::$disableCaches && Io::isReadable($tOutputFile, $this->cacheTtl)) { return Io::read($tOutputFile); } $tContent = ""; foreach ($this->parts as $tPart) { if ($tPart['class'] !== null && !in_array($tPart['class'], $this->classes, true)) { continue; } if ($tPart['bindtype'] === 'function') { $tValue = call_user_func($tPart['value'], $tPart); $tDescription = 'function ' . $tPart['value']; } elseif ($tPart['bindtype'] === 'string') { $tValue = $tPart['value']; $tDescription = 'string'; } else { $tValue = Io::read(Io::translatePath($tPart['value'])); $tDescription = 'file ' . $tPart['value']; } if (array_key_exists($tPart['parttype'], self::$fileProcessors)) { $tContent .= call_user_func(self::$fileProcessors[$tPart['parttype']], $tValue, $tDescription); } else { $tContent .= $tValue; } } if (array_key_exists($this->outputType, self::$packProcessors)) { $tContent = call_user_func(self::$packProcessors[$this->outputType], $tContent); } if (!Framework::$readonly) { Io::write($tOutputFile, $tContent); } return $tContent; }
/** * @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; }