public function __buildPageXML($page, $page_types, $qf)
 {
     $lang_code = FLang::getLangCode();
     $oPage = new XMLElement('page');
     $oPage->setAttribute('handle', $page['handle']);
     $oPage->setAttribute('id', $page['id']);
     // keep current first
     $oPage->appendChild(new XMLElement('item', General::sanitize($page['plh_t-' . $lang_code]), array('lang' => $lang_code, 'handle' => $page['plh_h-' . $lang_code])));
     // add others
     foreach (FLang::getLangs() as $lc) {
         if ($lang_code != $lc) {
             $oPage->appendChild(new XMLElement('item', General::sanitize($page['plh_t-' . $lc]), array('lang' => $lc, 'handle' => $page['plh_h-' . $lc])));
         }
     }
     if (in_array($page['id'], array_keys($page_types))) {
         $xTypes = new XMLElement('types');
         foreach ($page_types[$page['id']] as $type) {
             $xTypes->appendChild(new XMLElement('type', $type));
         }
         $oPage->appendChild($xTypes);
     }
     if ($page['children'] != '0') {
         if ($children = PageManager::fetch(false, array($qf . 'id, handle, title'), array(sprintf('`parent` = %d', $page['id'])))) {
             foreach ($children as $c) {
                 $oPage->appendChild($this->__buildPageXML($c, $page_types, $qf));
             }
         }
     }
     return $oPage;
 }
 /**
  * Frontend
  */
 public function dFrontendInitialised()
 {
     if (!$this->meetDependencies(true)) {
         return;
     }
     $this->_initFLang();
     Lang::set(FLang::getLangCode());
 }
 public function execute(array &$param_pool = null)
 {
     $result = new XMLElement('fl-languages');
     $main_lang = FLang::getMainLang();
     $crt_lc = FLang::getLangCode();
     $lang_names = Languages::all()->listAll();
     $langs = FLang::getLangs();
     $current_language_xml = new XMLElement('current-language', $lang_names[$crt_lc] ? $lang_names[$crt_lc]['name'] : $crt_lc);
     $current_language_xml->setAttribute('handle', $crt_lc);
     $current_language_xml->setAttribute('language', FLang::getLang());
     $current_language_xml->setAttribute('region', FLang::getReg());
     $result->appendChild($current_language_xml);
     $supported_languages_xml = new XMLElement('supported-languages');
     foreach ($langs as $lc) {
         $lang_xml = new XMLElement('item', $lang_names[$lc] ? $lang_names[$lc]['name'] : $lc);
         $lang_xml->setAttribute('handle', $lc);
         if ($lc === $main_lang) {
             $lang_xml->setAttribute('main', 'yes');
         }
         $supported_languages_xml->appendChild($lang_xml);
     }
     $result->appendChild($supported_languages_xml);
     return $result;
 }