Beispiel #1
0
 protected function prepare()
 {
     if (PATCHWORK_I18N) {
         $this->lang = Patchwork::__LANG__();
         if (!isset($this->alt)) {
             $a = array();
             $base = preg_quote($_SERVER['PATCHWORK_BASE'], "'");
             $base = explode('__', $base, 2);
             $base[1] = '/' === $base[1] ? '[^?/]+(/?)' : ".+?({$base[1]})";
             $base = "'^({$base[0]}){$base[1]}(.*)\$'D";
             if (preg_match($base, Patchwork::__URI__(), $base)) {
                 unset($base[0]);
                 foreach ($GLOBALS['CONFIG']['i18n.lang_list'] as $k => $v) {
                     if ('' === $k) {
                         continue;
                     }
                     $v = $base[1] . $v . $base[2] . ($this->lang === $k ? $base[3] : Patchwork::translateRequest($base[3], $k));
                     $a[] = (object) array('lang' => $k, 'title' => isset(self::$nativeLang[$k]) ? self::$nativeLang[$k] : $k, 'href' => $v);
                 }
             } else {
                 user_error('Something is wrong between Patchwork::__URI__() and PATCHWORK_BASE');
             }
             $this->alt =& $a;
         }
         return count($this->alt);
     } else {
         return 0;
     }
 }