示例#1
0
 protected static function get_lang_swap(FTL_Binding $tag, $swap)
 {
     // $swap = $tag->getAttribute('swap');
     if (!is_null($swap)) {
         $swap = explode(',', $swap);
         $swap = array_map('trim', $swap);
         // Try to get internal swap values
         foreach ($swap as &$str) {
             if (strpos($str, '::') !== FALSE) {
                 $seg = explode('::', $str);
                 // The asked key must be set
                 if (!empty($seg[1])) {
                     // Get from global value
                     if ($seg[0] == 'global') {
                         $str = self::$context->get_global($seg[1]);
                     } else {
                         $parent = NULL;
                         // Parent not set : current parent
                         if ($seg[0] == '') {
                             $parent = $tag->getDataParent();
                         } else {
                             $parent = $tag->getParent($seg[0]);
                         }
                         if (!is_null($parent)) {
                             $str = $parent->getValue($seg[1], $parent->name);
                         } else {
                             $str = '';
                         }
                     }
                 }
             }
         }
     }
     return $swap;
 }