- md5
- 598a126984e5eecf7cd68824858e9c1f
- sha1
- 9b28dd5e9e563e061eaed41abe16109da81d25d0
- sha256
- 0c02b4b6628d363daba1e1cd274646a1fae246540cedbbb07f8288f99ea24610
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
<?php
/**
* @package FrameworkOnFramework
* @subpackage config
* @copyright Copyright (c)2010-2012 Nicholas K. Dionysopoulos
* @license GNU General Public License version 2, or later
*/
defined('FOF_INCLUDED') or die();
/**
* Configuration parser for the tables-specific settings
*
* @package FrameworkOnFramework
* @since 2.1
*/
class FOFConfigDomainTables implements FOFConfigDomainInterface
{
/**
* Parse the XML data, adding them to the $ret array
*
* @param SimpleXMLElement $xml The XML data of the component's configuration area
* @param array &$ret The parsed data, in the form of a hash array
*
* @return void
*/
public function parseDomain(SimpleXMLElement $xml, array &$ret)
{
// Initialise
$ret['tables'] = array();
// Parse table configuration
$tableData = $xml->xpath('table');
// Sanity check
if (empty($tableData))
{
return;
}
foreach ($tableData as $aTable)
{
$key = (string) $aTable['name'];
$ret['tables'][$key]['behaviors'] = (string) $aTable->behaviors;
$ret['tables'][$key]['tablealias'] = $aTable->xpath('tablealias');
$ret['tables'][$key]['fields'] = array();
$fieldData = $aTable->xpath('field');
if (!empty($fieldData))
{
foreach ($fieldData as $field)
{
$k = (string) $field['name'];
$ret['tables'][$key]['fields'][$k] = (string) $field;
}
}
}
}
/**
* Return a configuration variable
*
* @param string &$configuration Configuration variables (hashed array)
* @param string $var The variable we want to fetch
* @param mixed $default Default value
*
* @return mixed The variable's value
*/
public function get(&$configuration, $var, $default)
{
$parts = explode('.', $var);
$view = $parts[0];
$method = 'get' . ucfirst($parts[1]);
if (!method_exists($this, $method))
{
return $default;
}
array_shift($parts);
array_shift($parts);
$ret = $this->$method($view, $configuration, $parts, $default);
return $ret;
}
/**
* Internal method to return the magic field mapping
*
* @param string $table The table for which we will be fetching a field map
* @param array &$configuration The configuration parameters hash array
* @param array $params Extra options; key 0 defines the table we want to fetch
* @param string $default Default magic field mapping; empty if not defined
*
* @return array Field map
*/
protected function getField($table, &$configuration, $params, $default = '')
{
$fieldmap = array();
if (isset($configuration['tables']['*']) && isset($configuration['tables']['*']['fields']))
{
$fieldmap = $configuration['tables']['*']['fields'];
}
if (isset($configuration['tables'][$table]) && isset($configuration['tables'][$table]['fields']))
{
$fieldmap = array_merge($fieldmap, $configuration['tables'][$table]['fields']);
}
$map = $default;
if (empty($params[0]))
{
$map = $fieldmap;
}
elseif (isset($fieldmap[$params[0]]))
{
$map = $fieldmap[$params[0]];
}
return $map;
}
/**
* Internal method to get table alias
*
* @param string $table The table for which we will be fetching table alias
* @param array &$configuration The configuration parameters hash array
* @param array $params Extra options; key 0 defines the table we want to fetch
* @param string $default Default table alias
*
* @return string Table alias
*/
protected function getTablealias($table, &$configuration, $params, $default = '')
{
$tablealias = $default;
if (isset($configuration['tables']['*'])
&& isset($configuration['tables']['*']['tablealias'])
&& isset($configuration['tables']['*']['tablealias'][0]))
{
$tablealias = (string) $configuration['tables']['*']['tablealias'][0];
}
if (isset($configuration['tables'][$table])
&& isset($configuration['tables'][$table]['tablealias'])
&& isset($configuration['tables'][$table]['tablealias'][0]))
{
$tablealias = (string) $configuration['tables'][$table]['tablealias'][0];
}
return $tablealias;
}
/**
* Internal method to get table alias
*
* @param string $table The table for which we will be fetching table alias
* @param array &$configuration The configuration parameters hash array
* @param array $params Extra options; key 0 defines the table we want to fetch
* @param string $default Default table alias
*
* @return string Table alias
*/
protected function getBehaviors($table, &$configuration, $params, $default = '')
{
$behaviors = $default;
if (isset($configuration['tables']['*'])
&& isset($configuration['tables']['*']['behaviors'])
&& isset($configuration['tables']['*']['behaviors']))
{
$behaviors = (string) $configuration['tables']['*']['behaviors'];
}
if (isset($configuration['tables'][$table])
&& isset($configuration['tables'][$table]['behaviors'])
&& isset($configuration['tables'][$table]['behaviors']))
{
$behaviors = (string) $configuration['tables'][$table]['behaviors'];
}
return $behaviors;
}
}
The same content is in 4 releases, Joomla 3.2.0 to 3.2.3. See them all, or every version of this file.