* @license PHP License * @package WB * @subpackage content */ /** * Load base class */ WBClass::load('WBContent'); /** * Content component: Static * * @version 0.1.0 * @package WB * @subpackage content */ class WBContent_Locale_LanguageSwitch extends WBContent { /** * my parameter list * @var array */ protected $config = array( 'tmpl' => 'switch', ); /** * locale config * @var WBConfig */ protected $locale; /** * current language * @var string */ protected $lang; /** * language dictionary * @var WBDictionary_Language */ protected $dict; /** * constructor * * */ public function __construct() { parent::__construct(); $this->locale = WBClass::create('WBConfig'); $this->locale->load('locale'); $this->dict = WBClass::create('WBDictionary_Language'); $this->lang = $this->locale->get('locale/langauges/default'); if (class_exists('patI18n', false)) { $this->lang = patI18n::getLocale(patI18n::LOCALE_TYPE_COMPLETE); } } /** * run * * run component * * @return array parameter list */ public function run() { $this->loadTemplates($this->config['tmpl']); $this->tmpl->addGlobalVars($this->config); $this->dict->load($this->lang); $this->tmpl->addGlobalVars($this->dict->get(), 'LANG_SELECTED_'); $available = $this->locale->get('locale/languages/available'); $request = $this->locale->get('locale/languages/requestpath', array()); $this->tmpl->addGlobalVar('LANG_AVAILABLE', count($available)); if ($this->tmpl->exists('lang_available_list_entry')) { $list = array(); foreach ($available as $a) { $this->dict->load($a); $data = $this->dict->get(); if (isset($request[$a])) { $data['langpath'] = $request[$a]; if ('__default' == $data['langpath']) { $data['langpath'] = ''; } } $list[] = $data; } $this->tmpl->addRows('lang_available_list_entry', $list); } return $this->config; } /** * receive output * * fetch output of this content component * * @return string */ public function getString() { return $this->tmpl->getParsedTemplate('snippet'); } } ?>