function drawSetLang($currentLang = "ko", $curPosition = 'Norm') { $locale = Locales::getInstance(); if ($locale->setDirectory(ROOT . '/resources/locale/setup')) { $availableLanguages = $locale->getSupportedLocales(); } else { return false; } ?> Select Default Language : <select name="Lang" id = "Lang" onchange= "current();" > <?php foreach ($availableLanguages as $key => $value) { print ' <option value="' . $key . '" ' . ($key == $currentLang ? ' selected="selected" ' : '') . '>' . $value . '</option>' . CRLF; } ?> </select> <?php return true; }
$context->setProperty('plugin.uri.access', $pluginAccessURL); $context->setProperty('plugin.uri.menu', $pluginMenuURL); $context->setProperty('plugin.uri.handler', $pluginHandlerURL); $context->setProperty('plugin.uri.self', $pluginSelfURL); $context->setProperty('plugin.parameter.access', $pluginAccessParam); $context->setProperty('plugin.parameter.self', $pluginSelfParam); $context->setProperty('plugin.uri', $context->getProperty('service.path') . "/plugins/{$plugin}"); $context->setProperty('plugin.path', ROOT . "/plugins/{$plugin}"); $context->setProperty('plugin.name', $plugin); $pluginURL = $context->getProperty('plugin.uri'); $pluginPath = $context->getProperty('plugin.path'); $pluginName = $context->getProperty('plugin.name'); // Loading locale resource $languageDomain = null; if (is_dir($pluginPath . '/locale/')) { $locale = Locales::getInstance(); $languageDomain = $locale->domain; if (file_exists($pluginPath . '/locale/' . $locale->defaultLanguage . '.php')) { $locale->setDirectory($pluginPath . '/locale'); $locale->set($locale->defaultLanguage, $pluginName); $locale->domain = $pluginName; } } include_once ROOT . "/plugins/{$plugin}/index.php"; if (function_exists($handler)) { if (!empty($configMappings[$plugin]['config'])) { $configVal = getCurrentSetting($plugin); $context->setProperty('plugin.config', Setting::fetchConfigVal($configVal)); } else { $configVal = ''; $context->setProperty('plugin.config', array());
function _text($t) { $locale = Locales::getInstance(); if (isset($locale->resource[$locale->domain]) && isset($locale->resource[$locale->domain][$t])) { return $locale->resource[$locale->domain][$t]; } else { return $t; } }
function handleDataSet($plugin, $DATA) { global $configMappings, $activePlugins, $service, $pluginURL, $pluginPath, $pluginName, $configMapping, $configVal; $context = Model_Context::getInstance(); $xmls = new XMLStruct(); if (!$xmls->open($DATA)) { unset($xmls); return array('error' => '3', 'customError' => ''); } unset($xmls); if (!in_array($plugin, $activePlugins)) { return array('error' => '9', 'customError' => _f('%1 : 플러그인이 활성화되어 있지 않아 설정을 저장하지 못했습니다.', $plugin)); } $reSetting = true; if (!empty($configMappings[$plugin]['dataValHandler'])) { $context->setProperty('plugin.uri', $context->getProperty('service.path') . "/plugins/{$plugin}"); $context->setProperty('plugin.path', ROOT . "/plugins/{$plugin}"); $context->setProperty('plugin.name', $plugin); $pluginURL = $context->getProperty('plugin.uri'); // Legacy plugin support. $pluginPath = $context->getProperty('plugin.path'); $pluginName = $context->getProperty('plugin.name'); include_once ROOT . "/plugins/{$plugin}/index.php"; if (function_exists($configMappings[$plugin]['dataValHandler'])) { if (!empty($configMappings[$plugin]['config'])) { $configVal = getCurrentSetting($plugin); $context->setProperty('plugin.config', Setting::fetchConfigVal($configVal)); } else { $configVal = ''; $context->setProperty('plugin.config', array()); } // Loading locale resource $languageDomain = null; if (is_dir($pluginPath . '/locale/')) { $locale = Locales::getInstance(); $languageDomain = $locale->domain; if (file_exists($pluginPath . '/locale/' . $locale->defaultLanguage . '.php')) { $locale->setDirectory($pluginPath . '/locale'); $locale->set($locale->defaultLanguage, $pluginName); $locale->domain = $pluginName; } } $reSetting = call_user_func($configMappings[$plugin]['dataValHandler'], serialize(fetchConfigXML($DATA))); $pluginURL = $pluginPath = $pluginName = ""; $context->unsetProperty('plugin.uri'); $context->unsetProperty('plugin.path'); $context->unsetProperty('plugin.name'); $context->unsetProperty('plugin.config', array()); if (!is_null($languageDomain)) { $locale->domain = $languageDomain; } } if (true !== $reSetting) { return array('error' => '9', 'customError' => $reSetting); } } $result = updatePluginConfig($plugin, $DATA); return array('error' => $result, 'customError' => ''); }
function &selectNode($path, $lang = null) { $path = explode('/', $path); if (array_shift($path) != '') { $null = null; return $null; } $cursor =& $this->struct; while (is_array($cursor) && ($step = array_shift($path))) { $step = $this->expandNS($step); if (!preg_match('/^([^[]+)(\\[(\\d+|lang\\(\\))\\])?$/', $step, $matches)) { $null = null; return $null; } $name = $matches[1]; if (!isset($cursor[$name][0])) { $null = null; return $null; } if (count($matches) != 4) { // Node name only. if (isset($cursor[$name][0])) { $cursor =& $cursor[$name][0]; } else { $null = null; return $null; } } else { if ($matches[3] != 'lang()') { // Position. /* see http://dev.textcube.org/ticket/430 */ $index = $matches[3]; $index -= $this->baseindex; if (isset($cursor[$name][$index])) { $cursor =& $cursor[$name][$index]; } else { $null = null; return $null; } } else { // lang() expression. for ($i = 0; $i < count($cursor[$name]); $i++) { if (isset($cursor[$name][$i]['.attributes']['xml:lang'])) { $lang = $cursor[$name][$i]['.attributes']['xml:lang']; } else { $lang = ""; } $locale = Locales::getInstance(); switch ($locale->match($lang)) { case 3: $cursor =& $cursor[$name][$i]; return $cursor; case 2: $secondBest =& $cursor[$name][$i]; break; case 1: $thirdBest =& $cursor[$name][$i]; break; case 0: if (!isset($thirdBest)) { $thirdBest =& $cursor[$name][$i]; } break; } } if (isset($secondBest)) { $cursor =& $secondBest; } else { if (isset($thirdBest)) { $cursor =& $thirdBest; } else { $null = null; return $null; } } } } } return $cursor; }