| Server IP : 195.130.67.5 / Your IP : 216.73.217.154 Web Server : Microsoft-IIS/10.0 System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586 User : IUSR ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/Old Sites/Libteiser - Ojs/ojs2/classes/core/ |
Upload File : |
<?php
/**
* @file classes/core/DataObject.inc.php
*
* Copyright (c) 2003-2009 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class DataObject
* @ingroup core
* @see Core
*
* @brief Any class with an associated DAO should extend this class.
*/
// $Id: DataObject.inc.php,v 1.12.2.1 2009/04/08 19:42:47 asmecher Exp $
class DataObject {
/** Array of object data */
var $_data;
/**
* Constructor.
*/
function DataObject($callHooks = true) {
$this->_data = array();
}
function &getLocalizedData($key) {
$localePrecedence = Locale::getLocalePrecedence();
foreach ($localePrecedence as $locale) {
$value =& $this->getData($key, $locale);
if (!empty($value)) return $value;
unset($value);
}
// Fallback: Get the first available piece of data.
$data =& $this->getData($key, null);
if (!empty($data)) return $data[array_shift(array_keys($data))];
// No data available; return null.
unset($data);
$data = null;
return $data;
}
/**
* Get the value of a data variable.
* @param $key string
* @param $locale string optional
* @return mixed
*/
function &getData($key, $locale = null) {
if ($locale !== null) {
if (isset($this->_data[$key][$locale])) {
return $this->_data[$key][$locale];
}
} else {
if (isset($this->_data[$key])) {
return $this->_data[$key];
}
}
$nullVar = null;
return $nullVar;
}
/**
* Set the value of a new or existing data variable.
* @param $key string
* @param $locale optional
* @param $value mixed
*/
function setData($key, $value, $locale = null) {
if ($locale !== null) {
$this->_data[$key][$locale] = $value;
} else {
$this->_data[$key] = $value;
}
}
}
?>