You are here

function Config_File::get in Quiz 6.6

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

Retrieves config info based on the file, section, and variable name.

Parameters

string $file_name config file to get info for:

string $section_name (optional) section to get info for:

string $var_name (optional) variable to get info for:

Return value

string|array a value or array of values

1 call to Config_File::get()
Config_File::get_key in includes/moodle/lib/smarty/Config_File.class.php
Retrieves config info based on the key.

File

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

Class

Config_File
Config file reading class @package Smarty

Code

function &get($file_name, $section_name = NULL, $var_name = NULL) {
  if (empty($file_name)) {
    $this
      ->_trigger_error_msg('Empty config file name');
    return;
  }
  else {
    $file_name = $this->_config_path . $file_name;
    if (!isset($this->_config_data[$file_name])) {
      $this
        ->load_file($file_name, false);
    }
  }
  if (!empty($var_name)) {
    if (empty($section_name)) {
      return $this->_config_data[$file_name]["vars"][$var_name];
    }
    else {
      if (isset($this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name])) {
        return $this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name];
      }
      else {
        return array();
      }
    }
  }
  else {
    if (empty($section_name)) {
      return (array) $this->_config_data[$file_name]["vars"];
    }
    else {
      if (isset($this->_config_data[$file_name]["sections"][$section_name]["vars"])) {
        return (array) $this->_config_data[$file_name]["sections"][$section_name]["vars"];
      }
      else {
        return array();
      }
    }
  }
}