You are here

function Config_File::_set_config_var in Quiz 6.6

Same name and namespace in other branches
  1. 6.5 includes/moodle/lib/smarty/Config_File.class.php \Config_File::_set_config_var()

Parameters

array &$container:

string $var_name:

mixed $var_value:

boolean $booleanize determines whether $var_value is converted to: to true/false

1 call to Config_File::_set_config_var()
Config_File::parse_contents in includes/moodle/lib/smarty/Config_File.class.php
parse the source of a configuration file manually.

File

includes/moodle/lib/smarty/Config_File.class.php, line 347

Class

Config_File
Config file reading class @package Smarty

Code

function _set_config_var(&$container, $var_name, $var_value, $booleanize) {
  if ($var_name[0] == '.') {
    if (!$this->read_hidden) {
      return;
    }
    else {
      $var_name = substr($var_name, 1);
    }
  }
  if (!preg_match("/^[a-zA-Z_]\\w*\$/", $var_name)) {
    $this
      ->_trigger_error_msg("Bad variable name '{$var_name}'");
    return;
  }
  if ($booleanize) {
    if (preg_match("/^(on|true|yes)\$/i", $var_value)) {
      $var_value = true;
    }
    else {
      if (preg_match("/^(off|false|no)\$/i", $var_value)) {
        $var_value = false;
      }
    }
  }
  if (!isset($container[$var_name]) || $this->overwrite) {
    $container[$var_name] = $var_value;
  }
  else {
    settype($container[$var_name], 'array');
    $container[$var_name][] = $var_value;
  }
}