You are here

function Smarty_Compiler::_expand_quoted_text in Quiz 6.5

Same name and namespace in other branches
  1. 6.6 includes/moodle/lib/smarty/Smarty_Compiler.class.php \Smarty_Compiler::_expand_quoted_text()

expand quoted text with embedded variables

Parameters

string $var_expr:

Return value

string

1 call to Smarty_Compiler::_expand_quoted_text()
Smarty_Compiler::_parse_var_props in includes/moodle/lib/smarty/Smarty_Compiler.class.php
compile single variable and section properties token into PHP code

File

includes/moodle/lib/smarty/Smarty_Compiler.class.php, line 1656

Class

Smarty_Compiler
Template compiling class @package Smarty

Code

function _expand_quoted_text($var_expr) {

  // if contains unescaped $, expand it
  if (preg_match_all('~(?:\\`(?<!\\\\)\\$' . $this->_dvar_guts_regexp . '(?:' . $this->_obj_ext_regexp . ')*\\`)|(?:(?<!\\\\)\\$\\w+(\\[[a-zA-Z0-9]+\\])*)~', $var_expr, $_match)) {
    $_match = $_match[0];
    rsort($_match);
    reset($_match);
    foreach ($_match as $_var) {
      $var_expr = str_replace($_var, '".(' . $this
        ->_parse_var(str_replace('`', '', $_var)) . ')."', $var_expr);
    }
    $_return = preg_replace('~\\.""|(?<!\\\\)""\\.~', '', $var_expr);
  }
  else {
    $_return = $var_expr;
  }

  // replace double quoted literal string with single quotes
  $_return = preg_replace('~^"([\\s\\w]+)"$~', "'\\1'", $_return);
  return $_return;
}