Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
Référence de la classe JRegistryFormatINI
+ Graphe d'héritage de JRegistryFormatINI:
+ Graphe de collaboration de JRegistryFormatINI:

Liste de tous les membres

Fonctions membres publiques

 objectToString ($object, $options=array())
 stringToObject ($data, array $options=array())

Fonctions membres protégées

 getValueAsINI ($value)

Attributs protégés statiques

static $cache = array()
- Attributs protégés statiques inherited from JRegistryFormat
static $instances = array()

Additional Inherited Members

- Fonctions membres publiques statiques inherited from JRegistryFormat
static getInstance ($type)

Description détaillée

Définition à la ligne 19 du fichier ini.php.


Documentation des fonctions membres

JRegistryFormatINI::getValueAsINI (   $value)
protected

Method to get a value in an INI format.

Paramètres:
mixed$valueThe value to convert to INI format.
Renvoie:
string The value in INI format.
Depuis:
11.1

Définition à la ligne 215 du fichier ini.php.

{
$string = '';
switch (gettype($value))
{
case 'integer':
case 'double':
$string = $value;
break;
case 'boolean':
$string = $value ? 'true' : 'false';
break;
case 'string':
// Sanitize any CRLF characters..
$string = '"' . str_replace(array("\r\n", "\n"), '\\n', $value) . '"';
break;
}
return $string;
}
JRegistryFormatINI::objectToString (   $object,
  $options = array() 
)

Converts an object into an INI formatted string

  • Unfortunately, there is no way to have ini values nested further than two levels deep. Therefore we will only go through the first two levels of the object.
Paramètres:
object$objectData source object.
array$optionsOptions used by the formatter.
Renvoie:
string INI formatted string.
Depuis:
11.1

Réimplémentée à partir de JRegistryFormat.

Définition à la ligne 42 du fichier ini.php.

{
$local = array();
$global = array();
// Iterate over the object to set the properties.
foreach (get_object_vars($object) as $key => $value)
{
// If the value is an object then we need to put it in a local section.
if (is_object($value))
{
// Add the section line.
$local[] = '';
$local[] = '[' . $key . ']';
// Add the properties for this section.
foreach (get_object_vars($value) as $k => $v)
{
$local[] = $k . '=' . $this->getValueAsINI($v);
}
}
else
{
// Not in a section so add the property to the global array.
$global[] = $key . '=' . $this->getValueAsINI($value);
}
}
return implode("\n", array_merge($global, $local));
}
JRegistryFormatINI::stringToObject (   $data,
array  $options = array() 
)

Parse an INI formatted string and convert it into an object.

Paramètres:
string$dataINI formatted string to convert.
mixed$optionsAn array of options used by the formatter, or a boolean setting to process sections.
Renvoie:
object Data object.
Depuis:
11.1

Réimplémentée à partir de JRegistryFormat.

Définition à la ligne 83 du fichier ini.php.

{
$sections = (isset($options['processSections'])) ? $options['processSections'] : false;
// Check the memory cache for already processed strings.
$hash = md5($data . ':' . (int) $sections);
if (isset(self::$cache[$hash]))
{
return self::$cache[$hash];
}
// If no lines present just return the object.
if (empty($data))
{
return new stdClass;
}
$obj = new stdClass;
$section = false;
$lines = explode("\n", $data);
// Process the lines.
foreach ($lines as $line)
{
// Trim any unnecessary whitespace.
$line = trim($line);
// Ignore empty lines and comments.
if (empty($line) || ($line{0} == ';'))
{
continue;
}
if ($sections)
{
$length = strlen($line);
// If we are processing sections and the line is a section add the object and continue.
if (($line[0] == '[') && ($line[$length - 1] == ']'))
{
$section = substr($line, 1, $length - 2);
$obj->$section = new stdClass;
continue;
}
}
elseif ($line{0} == '[')
{
continue;
}
// Check that an equal sign exists and is not the first character of the line.
if (!strpos($line, '='))
{
// Maybe throw exception?
continue;
}
// Get the key and value for the line.
list ($key, $value) = explode('=', $line, 2);
// Validate the key.
if (preg_match('/[^A-Z0-9_]/i', $key))
{
// Maybe throw exception?
continue;
}
// If the value is quoted then we assume it is a string.
$length = strlen($value);
if ($length && ($value[0] == '"') && ($value[$length - 1] == '"'))
{
// Strip the quotes and Convert the new line characters.
$value = stripcslashes(substr($value, 1, ($length - 2)));
$value = str_replace('\n', "\n", $value);
}
else
{
// If the value is not quoted, we assume it is not a string.
// If the value is 'false' assume boolean false.
if ($value == 'false')
{
$value = false;
}
// If the value is 'true' assume boolean true.
elseif ($value == 'true')
{
$value = true;
}
// If the value is numeric than it is either a float or int.
elseif (is_numeric($value))
{
// If there is a period then we assume a float.
if (strpos($value, '.') !== false)
{
$value = (float) $value;
}
else
{
$value = (int) $value;
}
}
}
// If a section is set add the key/value to the section, otherwise top level.
if ($section)
{
$obj->$section->$key = $value;
}
else
{
$obj->$key = $value;
}
}
// Cache the string to save cpu cycles -- thus the world :)
self::$cache[$hash] = clone ($obj);
return $obj;
}

Documentation des données membres

JRegistryFormatINI::$cache = array()
staticprotected

Définition à la ligne 27 du fichier ini.php.


La documentation de cette classe a été générée à partir du fichier suivant :