Exemplo n.º 1
0
 public static function getLang($value = '')
 {
     static $array = array();
     static $set;
     static $current;
     if ($value == 'array' && count($array)) {
         return $array;
     }
     if ($value == 'set' && !is_null($set)) {
         return $set;
     }
     if (in_array($value, array('locale', 'name', 'segment', 'index', 'dateformat')) && !is_null($current)) {
         return $current[$value];
     }
     if ($value == '' && !is_null($current)) {
         return $current;
     }
     //no static cache?  so cycle languages and uri and fill static vars
     $segments = array();
     foreach (rpd::config("languages") as $lang) {
         if ($lang['segment'] == '') {
             $default = $lang;
             continue;
         }
         $segments[$lang['segment']] = $lang;
     }
     $current = $default;
     if (count($segments) > 0) {
         //piu' di una lingua
         $set = '(' . implode('|', array_keys($segments)) . ')';
         if (preg_match('@^' . $set . '/?@i', url_helper::get_uri(), $match)) {
             $current = $segments[$match[1]];
         }
     }
     $array = array_merge(array('default' => $default), $segments);
     $curr = array_search($current, $array);
     $array[$curr]['is_current'] = true;
     if ($value == 'array') {
         return $array;
     }
     if ($value == 'set') {
         return $set;
     }
     if (in_array($value, array('locale', 'name', 'segment', 'index'))) {
         return $current[$value];
     }
     return $current;
 }
Exemplo n.º 2
0
 /**
  * internal, add a submit button
  *
  * @param array $config
  */
 public function save_button($config = null)
 {
     $caption = isset($config['caption']) ? $config['caption'] : rpd::lang('btn.save');
     $this->submit("btn_submit", $caption, "BL");
 }