function _getValue() { parent::_getValue(); if (count($this->parsed_fields) > 0) { if (isset($this->data) && $this->data->loaded) { $data = $this->data->get_all(); foreach ($this->parsed_fields as $field_name) { $field_rel_regex = '#^(.+)\\[(.+)\\]$#'; if (preg_match($field_rel_regex, $field_name, $match)) { if (isset($data[$match[1]][$match[2]])) { $replace = $data[$match[1]][$match[2]]; } else { $replace = RAPYD_FIELD_SYMBOL_NULL; } $this->content_pattern = str_replace("<#{$field_name}#>", $replace, $this->content_pattern); } if (isset($data[$field_name])) { $this->content_pattern = str_replace("<#{$field_name}#>", $data[$field_name], $this->content_pattern); } } } } $this->value = replaceFunctions($this->content_pattern); }
/** * it return the column output. * if the column pattern is a field object it build() the field first. * * @access public * @return string column output */ function getValue() { switch ($this->patternType) { case "fieldObject": $this->field->requestRefill = false; //$this->field->status = "show"; $this->field->build(); return $this->field->output; break; case "pattern": if ($this->rpattern == "") { $this->rpattern = " "; } $this->rpattern = replaceFunctions($this->rpattern); return $this->rpattern; break; case "fieldName": $this->rpattern = nl2br(htmlspecialchars($this->rpattern)); if ($this->rpattern == "") { $this->rpattern = " "; } return $this->rpattern; break; } }
/** * it return the column output. * if the column pattern is a field object it build() the field first. * * @access public * @return string column output */ function getValue() { switch ($this->patternType) { case 'fieldObject': $this->field->requestRefill = false; //$this->field->status = "show"; //$this->field->name = replaceFunctions($this->field->name); $this->field->build(); return $this->field->output; break; case 'pattern': if ($this->rpattern == '') { $this->rpattern = ' '; } $this->rpattern = replaceFunctions($this->rpattern); return $this->rpattern; break; case 'fieldName': $this->rpattern = nl2br(htmlspecialchars($this->rpattern)); if ($this->rpattern == '') { $this->rpattern = ' '; } return $this->rpattern; break; } }
/** * it return the cell output. * * @access public * @return string cell output */ function getValue() { $this->pattern = replaceFunctions($this->pattern); return $this->pattern; }
/** * Questa funzione consente di utilizzare una stringa per effettuare chiamate a funzioni php. * La ricorsivita' consente anche funzioni innestate. * * E' utilizzabile nei casi in cui si vuole fare e si puo' fare a meno di eval * * Consente una formattazione veloce dei campi di rapyd * * <code> * $pattern = 'e si... <strtolower><substr>Io Sono fesso|0|8</substr>Bravo</strtolower> <strtoupper>Davvero!</strtoupper>'; * echo htmlspecialchars(replaceFunctions($pattern)); * </code> */ function replaceFunctions($content) { $ci =& get_instance(); $rapyd =& $ci->rapyd; //allowed function $functions = $rapyd->config->item("replace_functions"); //parameter separator $arg_sep = $rapyd->config->item("argument_separator"); foreach ($functions as $function) { $tagName = $function; $beginTag = "<" . $tagName . ">"; $beginLen = strlen($beginTag); $endTag = "</" . $tagName . ">"; $endLen = strlen($endTag); $beginPos = strpos($content, $beginTag); $endPos = strpos($content, $endTag); $subcontent = ""; if ($endPos > 0) { $subcontent = substr($content, $beginPos + $beginLen, $endPos - $beginPos - $beginLen); foreach ($functions as $nestedfunction) { $nestedTag = "</" . $nestedfunction . ">"; if (strpos($subcontent, $nestedTag) > 0) { $subcontent = replaceFunctions($subcontent); } } //???double barre a repercuter dans code ou faire une synthax identique pour les noms de fonctions if (strpos($subcontent, $arg_sep) === false) { if (substr($function, 0, 9) == "callback_") { $method = substr($function, 9); $result = $ci->{$method}($subcontent); } else { $result = $function($subcontent); } } else { //???double barre $arguments = explode($arg_sep, $subcontent); for ($i = 0; $i < count($arguments); $i++) { if (defined($arguments[$i])) { $arguments[$i] = constant($arguments[$i]); } } //print_r($arguments); if (substr($function, 0, 9) == "callback_") { $method = substr($function, 9); $result = call_user_func_array(array(&$ci, $method), $arguments); } else { //if($function == "htmlspecialchars")echo print_r($arguments,true); //print_r($arguments); $result = call_user_func_array($function, $arguments); } } $content = substr($content, 0, $beginPos) . $result . substr($content, $endPos + $endLen); $endPos = strpos($content, $endTag); if ($endPos > 0) { $content = replaceFunctions($content); } } } return $content; }