Exemplo n.º 1
0
 private static function getLangvarsByPrefix($prefix, $lang_code = CART_LANGUAGE)
 {
     if (class_exists('Tygh\\Languages\\Values')) {
         return LanguageValues::getLangVarsByPrefix($prefix, $lang_code);
     } else {
         return fn_get_lang_vars_by_prefix($prefix, $lang_code);
     }
 }
Exemplo n.º 2
0
 /**
  * Prefilter: form tooltip
  * @param  string                    $content  template content
  * @param  \Smarty_Internal_Template $template template instance
  * @return string                    template content
  */
 public static function preFormTooltip($content, \Smarty_Internal_Template $template)
 {
     $pattern = '/\\<label[^>]*\\>.*(\\{__\\("([^\\}]+)"\\)\\}[^:\\<]*).*\\<\\/label\\>/';
     if (preg_match_all($pattern, $content, $matches)) {
         $cur_templ = $template->template_resource;
         $template_pattern = '/([^\\/\\.]+)/';
         $template_name = '';
         $ignored_names = array('tpl');
         if (preg_match_all($template_pattern, $cur_templ, $template_matches)) {
             foreach ($template_matches[0] as $k => $m) {
                 if (!in_array($template_matches[1][$k], $ignored_names)) {
                     $template_name .= $template_matches[1][$k] . '_';
                 }
             }
         }
         $template_pref = 'tt_' . $template_name;
         $template_tooltips = fn_get_lang_vars_by_prefix($template_pref);
         foreach ($matches[0] as $k => $m) {
             $field_name = $matches[2][$k];
             preg_match("/(^[a-zA-z0-9][\\.a-zA-Z0-9_]*)/", $field_name, $name_matches);
             if (@strlen($name_matches[0]) != strlen($field_name)) {
                 continue;
             }
             $label = $matches[1][$k];
             $template_lang_var = $template_pref . $field_name;
             $common_lang_var = 'ttc_' . $field_name;
             if (isset($_REQUEST['stt'])) {
                 $template_text = isset($template_tooltips[$template_lang_var]) ? '{__("' . $template_lang_var . '")}' : '';
                 $common_tip = __($common_lang_var);
                 $common_text = '';
                 if ($common_tip != '_' . $common_lang_var) {
                     $common_text = '{__("' . $common_lang_var . '")}';
                 }
                 $tooltip_text = sprintf("%s: %s <br/> %s: %s", $common_lang_var, $common_text, $template_lang_var, $template_text);
                 $tooltip = '{capture name="tooltip"}' . $tooltip_text . '{/capture}{include file="common/tooltip.tpl" tooltip=$smarty.capture.tooltip}';
             } else {
                 if (isset($template_tooltips[$template_lang_var])) {
                     $tooltip_text = '__("' . $template_lang_var . '")';
                 } else {
                     $tooltip = __($common_lang_var);
                     if ($tooltip == '_' . $common_lang_var || empty($tooltip)) {
                         continue;
                     }
                     $tooltip_text = '__("' . $common_lang_var . '")';
                 }
                 $tooltip = '{include file="common/tooltip.tpl" tooltip=' . $tooltip_text . '}';
             }
             $tooltip_added = str_replace($label, $label . $tooltip, $matches[0][$k]);
             $content = str_replace($matches[0][$k], $tooltip_added, $content);
         }
     }
     return $content;
 }
Exemplo n.º 3
0
 function prefilter_form_tooltip($content, &$compiler)
 {
     $pattern = '/\\<label[^>]*\\>.*(\\{\\$lang\\.([^\\}]+)\\}[^:\\<]*).*\\<\\/label\\>/';
     if (preg_match_all($pattern, $content, $matches)) {
         $cur_templ = $compiler->_current_file;
         $template_pattern = '/([^\\/\\.]+)/';
         $template_name = '';
         $ignored_names = array('tpl');
         if (preg_match_all($template_pattern, $cur_templ, $template_matches)) {
             foreach ($template_matches[0] as $k => $m) {
                 if (!in_array($template_matches[1][$k], $ignored_names)) {
                     $template_name .= $template_matches[1][$k] . '_';
                 }
             }
         }
         $template_pref = 'tt_' . $template_name;
         $template_tooltips = fn_get_lang_vars_by_prefix($template_pref);
         foreach ($matches[0] as $k => $m) {
             $field_name = $matches[2][$k];
             preg_match("/(^[a-zA-z0-9][a-zA-Z0-9_]*)/", $field_name, $name_matches);
             if (@strlen($name_matches[0]) != strlen($field_name)) {
                 continue;
             }
             $label = $matches[1][$k];
             $template_lang_var = $template_pref . $field_name;
             $common_lang_var = 'ttc_' . $field_name;
             if (isset($_REQUEST['stt'])) {
                 $template_text = isset($template_tooltips[$template_lang_var]) ? '{$lang.' . $template_lang_var . '}' : '';
                 $common_tip = fn_get_lang_var($common_lang_var);
                 $common_text = '';
                 if ($common_tip != '_' . $common_lang_var) {
                     $common_text = '{$lang.' . $common_lang_var . '}';
                 }
                 $tooltip_text = sprintf("%s: %s <br/> %s: %s", $common_lang_var, $common_text, $template_lang_var, $template_text);
                 $tooltip = '{capture name="tooltip"}' . $tooltip_text . '{/capture}{include file="common_templates/tooltip.tpl" params="cm-tooltip-focus" tooltip=$smarty.capture.tooltip"}';
             } else {
                 if (isset($template_tooltips[$template_lang_var])) {
                     $tooltip_text = '$lang.' . $template_lang_var;
                 } else {
                     $tooltip = fn_get_lang_var($common_lang_var);
                     if ($tooltip == '_' . $common_lang_var || empty($tooltip_text)) {
                         continue;
                     }
                     $tooltip_text = '$lang.' . $common_lang_var;
                 }
                 $tooltip = '{include file="common_templates/tooltip.tpl" tooltip=' . $tooltip_text . '}';
             }
             $tooltip_added = str_replace($label, $label . $tooltip, $matches[0][$k]);
             $content = str_replace($matches[0][$k], $tooltip_added, $content);
         }
         $content .= '{script src="js/jquery.simpletip-1.3.1.js"}';
     }
     return $content;
 }