/**
  * @param $object    Translations
  * @param $text      string
  * @param $context   string
  * @param $joinpoint Around_Method
  * @return string
  */
 public function onTranslate(Translations $object, $text, $context, Around_Method $joinpoint)
 {
     $context = isset($context) ? $context : '';
     if (strpos($text, '¦') !== false) {
         $translations = $object;
         $elements = [];
         $number = 0;
         $i = 0;
         while (($i = strpos($text, '¦', $i)) !== false) {
             $i += 2;
             $j = strpos($text, '¦', $i);
             if ($j >= $i) {
                 $number++;
                 $elements['$' . $number] = $translations->translate(substr($text, $i, $j - $i), $context);
                 $text = substr($text, 0, $i - 2) . '$' . $number . substr($text, $j + 2);
                 $i += strlen($number) - 1;
             }
         }
         $i = 0;
         while (($i = strpos($text, '!', $i)) !== false) {
             $i++;
             $j = strpos($text, '!', $i);
             if ($j > $i && strpos(SP . TAB . CR . LF, $text[$i]) === false) {
                 $number++;
                 $elements['$' . $number] = substr($text, $i, $j - $i);
                 $text = substr($text, 0, $i - 1) . '$' . $number . substr($text, $j + 1);
             }
         }
         $translation = str_replace(array_keys($elements), $elements, $translations->translate($text, $context));
         return $translation;
     } else {
         return $joinpoint->process($text, $context);
     }
 }
Example #2
0
 /**
  * @param $var_name  string can be an unique var or path.of.vars
  * @param $joinpoint Around_Method
  * @return string var value after reading value / executing specs (can be an object)
  */
 public function noParseZone($var_name, Around_Method $joinpoint)
 {
     $is_include = substr($var_name, 0, 1) == SL;
     if (!$is_include) {
         $this->dont_parse_wiki++;
     }
     $result = $joinpoint->process();
     if (!$is_include) {
         $this->dont_parse_wiki--;
     }
     return $result;
 }
Example #3
0
 /**
  * @param $class_name    string
  * @param $feature_names string|string[]
  * @param $joinpoint     Around_Method
  * @return callable[]
  */
 public function getPossibleViewCalls($class_name, $feature_names, Around_Method $joinpoint)
 {
     if (is_array($feature_names)) {
         $feature_names = join(DOT, $feature_names);
     }
     if (isset($this->view_calls[$class_name][$feature_names])) {
         $view = $this->view_calls[$class_name][$feature_names];
         if (@method_exists($view[0], $view[1])) {
             return [$view];
         }
     }
     return $joinpoint->process();
 }