本文整理汇总了PHP中Joomla\Registry\Registry::loadArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Registry::loadArray方法的具体用法?PHP Registry::loadArray怎么用?PHP Registry::loadArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Joomla\Registry\Registry
的用法示例。
在下文中一共展示了Registry::loadArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: admin_postinstall_eaccelerator_action
/**
* Disables the unsupported eAccelerator caching method, replacing it with the
* "file" caching method.
*
* @return void
*
* @since 3.2
*/
function admin_postinstall_eaccelerator_action()
{
$prev = new JConfig();
$prev = JArrayHelper::fromObject($prev);
$data = array('cacheHandler' => 'file');
$data = array_merge($prev, $data);
$config = new Registry('config');
$config->loadArray($data);
jimport('joomla.filesystem.path');
jimport('joomla.filesystem.file');
// Set the configuration file path.
$file = JPATH_CONFIGURATION . '/configuration.php';
// Get the new FTP credentials.
$ftp = JClientHelper::getCredentials('ftp', true);
// Attempt to make the file writeable if using FTP.
if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0644')) {
JError::raiseNotice('SOME_ERROR_CODE', JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTWRITABLE'));
}
// Attempt to write the configuration file as a PHP class named JConfig.
$configuration = $config->toString('PHP', array('class' => 'JConfig', 'closingtag' => false));
if (!JFile::write($file, $configuration)) {
JFactory::getApplication()->enqueueMessage(JText::_('COM_CONFIG_ERROR_WRITE_FAILED'), 'error');
return;
}
// Attempt to make the file unwriteable if using FTP.
if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0444')) {
JError::raiseNotice('SOME_ERROR_CODE', JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTUNWRITABLE'));
}
}
示例2: bind
public function bind($array, $ignore = '')
{
// Search for the {readmore} tag and split the text up accordingly.
if (isset($array['value']) && is_array($array['value'])) {
$registry = new Registry();
$registry->loadArray($array['value']);
$array['value'] = (string) $registry;
}
// if (isset($array['media']) && is_array($array['media']))
// {
// $registry = new Registry;
// $registry->loadArray($array['media']);
// $array['media'] = (string) $registry;
// }
//
// if (isset($array['metadata']) && is_array($array['metadata']))
// {
// $registry = new Registry;
// $registry->loadArray($array['metadata']);
// $array['metadata'] = (string) $registry;
// }
//
// // Bind the rules.
// if (isset($array['rules']) && is_array($array['rules']))
// {
// $rules = new JAccessRules($array['rules']);
// $this->setRules($rules);
// }
return parent::bind($array, $ignore);
}
示例3: bind
/**
* Overloaded bind function
*
* @param array $array Named array
* @param mixed $ignore An optional array or space separated list of properties
* to ignore while binding.
*
* @return mixed Null if operation was satisfactory, otherwise returns an error string
*
* @see JTable::bind()
* @since 3.1
*/
public function bind($array, $ignore = '')
{
if (isset($array['core_params']) && is_array($array['core_params'])) {
$registry = new Registry();
$registry->loadArray($array['core_params']);
$array['core_params'] = (string) $registry;
}
if (isset($array['core_metadata']) && is_array($array['core_metadata'])) {
$registry = new Registry();
$registry->loadArray($array['core_metadata']);
$array['core_metadata'] = (string) $registry;
}
if (isset($array['core_images']) && is_array($array['core_images'])) {
$registry = new Registry();
$registry->loadArray($array['core_images']);
$array['core_images'] = (string) $registry;
}
if (isset($array['core_urls']) && is_array($array['core_urls'])) {
$registry = new Registry();
$registry->loadArray($array['core_urls']);
$array['core_urls'] = (string) $registry;
}
if (isset($array['core_body']) && is_array($array['core_body'])) {
$registry = new Registry();
$registry->loadArray($array['core_body']);
$array['core_body'] = (string) $registry;
}
return parent::bind($array, $ignore);
}
示例4: store
/**
* Stores a FamilyUnit
*
* @param boolean $updateNulls True to update fields even if they are null.
*
* @return boolean True on success, false on failure.
*
* @since 1.7.0
*/
public function store($updateNulls = false)
{
// Transform the params field
if (is_array($this->params)) {
$registry = new Registry();
$registry->loadArray($this->params);
$this->params = (string) $registry;
}
$date = JFactory::getDate();
$user = JFactory::getUser();
if ($this->id) {
// Existing item
$this->modified = $date->toSql();
$this->modified_by = $user->get('id');
} else {
// New newsfeed. A feed created and created_by field can be set by the user,
// so we don't touch either of these if they are set.
if (!intval($this->created)) {
$this->created = $date->toSql();
}
if (empty($this->created_by)) {
$this->created_by = $user->get('id');
}
}
// Attempt to store the data.
return parent::store($updateNulls);
}
示例5: bind
/**
* Method to bind an associative array or object to the JTable instance. This
* method only binds properties that are publicly accessible and optionally
* takes an array of properties to ignore when binding.
*
* @param array $array Named array
* @param mixed $ignore An optional array or space separated list of properties
* to ignore while binding. [optional]
*
* @return mixed Null if operation was satisfactory, otherwise returns an error string
*
* @since 2.5
*/
public function bind($array, $ignore = '')
{
if (isset($array['params']) && is_array($array['params'])) {
$registry = new Registry();
$registry->loadArray($array['params']);
$array['params'] = (string) $registry;
}
return parent::bind($array, $ignore);
}
示例6: bind
/**
* Method to bind an associative array or object to the JTable instance.This
* method only binds properties that are publicly accessible and optionally
* takes an array of properties to ignore when binding.
*
* @param mixed $src An associative array or object to bind to the JTable instance.
* @param mixed $ignore An optional array or space separated list of properties to ignore while binding.
*
* @return boolean True on success.
*/
public function bind($src, $ignore = array())
{
if (isset($src['params']) && is_array($src['params'])) {
$registry = new Registry();
$registry->loadArray($src['params']);
$src['params'] = (string) $registry;
}
parent::bind($src, $ignore);
return true;
}
示例7: prepareExecute
/**
* prepareExecute
*
* @return void
*/
protected function prepareExecute()
{
parent::prepareExecute();
$this->app->setUserState("com_userxtd.edit.field.data", $this->input->getVar('jform'));
$attrs = $this->app->getUserState("com_userxtd.edit.field.attrs", array());
$postAttrs = $this->input->getVar('attrs', array());
$attrs = new Registry($attrs);
$attrs->loadArray($postAttrs);
$this->app->setUserState("com_userxtd.edit.field.attrs", $attrs->toArray());
}
示例8: bind
/**
* Overloaded bind function to pre-process the params.
*
* @param array $array Named array
* @param mixed $ignore An optional array or space separated list of properties to ignore while binding.
*
* @return null|string null if operation was satisfactory, otherwise returns an error
*
* @since 1.6
*/
public function bind($array, $ignore = '')
{
if (isset($array['params']) && is_array($array['params'])) {
$registry = new Registry();
$registry->loadArray($array['params']);
$array['params'] = (string) $registry;
}
// Verify that the default style is not unset
if ($array['home'] == '0' && $this->home == '1') {
$this->setError(JText::_('COM_TEMPLATES_ERROR_CANNOT_UNSET_DEFAULT_STYLE'));
return false;
}
return parent::bind($array, $ignore);
}
示例9: bind
/**
* Overloaded bind function
*
* @param array $array hash named array
* @param array $ignore An optional array or space separated list of properties to ignore while binding.
*
* @return null|string null is operation was satisfactory, otherwise returns an error
*/
public function bind($array, $ignore = array())
{
// Bind the rules.
if (isset($array['rules']) && is_array($array['rules'])) {
$rules = new JAccessRules($array['rules']);
$this->setRules($rules);
}
if (isset($array['params']) && is_array($array['params'])) {
$registry = new Registry();
$registry->loadArray($array['params']);
$array['params'] = (string) $registry;
}
return parent::bind($array, $ignore);
}
示例10: bind
/**
* Method to bind an associative array or object to the JTable instance.This
* method only binds properties that are publicly accessible and optionally
* takes an array of properties to ignore when binding.
*
* @param mixed $src An associative array or object to bind to the JTable instance.
* @param mixed $ignore An optional array or space separated list of properties to ignore while binding.
*
* @return boolean True on success.
*/
public function bind($src, $ignore = array())
{
// Bind the rules.
if (isset($src['rules']) && is_array($src['rules'])) {
$rules = new JAccessRules($src['rules']);
$this->setRules($rules);
}
// Covert the params to a json object if its set as an array
if (isset($src['params']) && is_array($src['params'])) {
$registry = new Registry();
$registry->loadArray($src['params']);
$src['params'] = (string) $registry;
}
return parent::bind($src, $ignore);
}
示例11: store
/**
* Stores a proveedor.
*
* @param boolean $updateNulls True to update fields even if they are null.
*
* @return boolean True on success, false on failure.
*
* @since 1.6
*/
public function store($updateNulls = false)
{
// Transform the params field
if (is_array($this->params)) {
$registry = new Registry();
$registry->loadArray($this->params);
$this->params = (string) $registry;
}
$date = JFactory::getDate();
$user = JFactory::getUser();
$this->modified = $date->toSql();
if ($this->id) {
// Existing item
$this->modified_by = $user->get('id');
} else {
// New proveedor. A proveedor created and created_by field can be set by the user,
// so we don't touch either of these if they are set.
if (!(int) $this->created) {
$this->created = $date->toSql();
}
if (empty($this->created_by)) {
$this->created_by = $user->get('id');
}
}
// Set publish_up to null date if not set
if (!$this->publish_up) {
$this->publish_up = $this->_db->getNullDate();
}
// Set publish_down to null date if not set
if (!$this->publish_down) {
$this->publish_down = $this->_db->getNullDate();
}
// Set xreference to empty string if not set
if (!$this->xreference) {
$this->xreference = '';
}
// Store utf8 email as punycode
$this->email_to = JStringPunycode::emailToPunycode($this->email_to);
// Convert IDN urls to punycode
$this->webpage = JStringPunycode::urlToPunycode($this->webpage);
// Verify that the alias is unique
$table = JTable::getInstance('Proveedor', 'ProveedorTable');
if ($table->load(array('alias' => $this->alias, 'catid' => $this->catid)) && ($table->id != $this->id || $this->id == 0)) {
$this->setError(JText::_('COM_PROVEEDOR_ERROR_UNIQUE_ALIAS'));
return false;
}
return parent::store($updateNulls);
}
示例12: bind
/**
* Method to bind an associative array or object to the JTable instance.This
* method only binds properties that are publicly accessible and optionally
* takes an array of properties to ignore when binding.
*
* @param mixed $src An associative array or object to bind to the JTable instance.
* @param mixed $ignore An optional array or space separated list of properties to ignore while binding.
*
* @return boolean True on success.
*/
public function bind($src, $ignore = array())
{
if (isset($src['params']) && is_array($src['params'])) {
$registry = new Registry();
$registry->loadArray($src['params']);
$src['params'] = (string) $registry;
}
// Needed for form edit view where we see the database table anme and connection id
if (array_key_exists('db_table_name', $src)) {
$this->db_table_name = $src['db_table_name'];
}
if (array_key_exists('connection_id', $src)) {
$this->connection_id = $src['connection_id'];
}
return parent::bind($src, $ignore);
}
示例13: bind
/**
* Overloaded bind function
*
* @param array $array Named array
* @param mixed $ignore An optional array or space separated list of properties to ignore while binding.
*
* @return mixed Null if operation was satisfactory, otherwise returns an error
*
* @see JTable::bind()
* @since 11.1
*/
public function bind($array, $ignore = '')
{
// Verify that the default home menu is not unset
if ($this->home == '1' && $this->language == '*' && $array['home'] == '0') {
$this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_CANNOT_UNSET_DEFAULT_DEFAULT'));
return false;
}
// Verify that the default home menu set to "all" languages" is not unset
if ($this->home == '1' && $this->language == '*' && $array['language'] != '*') {
$this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_CANNOT_UNSET_DEFAULT'));
return false;
}
// Verify that the default home menu is not unpublished
if ($this->home == '1' && $this->language == '*' && $array['published'] != '1') {
$this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_UNPUBLISH_DEFAULT_HOME'));
return false;
}
if (isset($array['params']) && is_array($array['params'])) {
$registry = new Registry();
$registry->loadArray($array['params']);
$array['params'] = (string) $registry;
}
return parent::bind($array, $ignore);
}
示例14: save
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
$input = JFactory::getApplication()->input;
$filter = JFilterInput::getInstance();
if (isset($data['metadata']) && isset($data['metadata']['author'])) {
$data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM');
}
if (isset($data['created_by_alias'])) {
$data['created_by_alias'] = $filter->clean($data['created_by_alias'], 'TRIM');
}
if (isset($data['images']) && is_array($data['images'])) {
$registry = new Registry();
$registry->loadArray($data['images']);
$data['images'] = (string) $registry;
}
if (isset($data['urls']) && is_array($data['urls'])) {
$check = $input->post->get('jform', array(), 'array');
foreach ($data['urls'] as $i => $url) {
if ($url != false && ($i == 'urla' || $i == 'urlb' || $i == 'urlc')) {
if (preg_match('~^#[a-zA-Z]{1}[a-zA-Z0-9-_:.]*$~', $check['urls'][$i]) == 1) {
$data['urls'][$i] = $check['urls'][$i];
} else {
$data['urls'][$i] = JStringPunycode::urlToPunycode($url);
}
}
}
unset($check);
$registry = new Registry();
$registry->loadArray($data['urls']);
$data['urls'] = (string) $registry;
}
// Alter the title for save as copy
if ($input->get('task') == 'save2copy') {
$origTable = clone $this->getTable();
$origTable->load($input->getInt('id'));
if ($data['title'] == $origTable->title) {
list($title, $alias) = $this->generateNewTitle($data['catid'], $data['alias'], $data['title']);
$data['title'] = $title;
$data['alias'] = $alias;
} else {
if ($data['alias'] == $origTable->alias) {
$data['alias'] = '';
}
}
$data['state'] = 0;
}
// Automatic handling of alias for empty fields
if (in_array($input->get('task'), array('apply', 'save', 'save2new')) && (!isset($data['id']) || (int) $data['id'] == 0)) {
if ($data['alias'] == null) {
if (JFactory::getConfig()->get('unicodeslugs') == 1) {
$data['alias'] = JFilterOutput::stringURLUnicodeSlug($data['title']);
} else {
$data['alias'] = JFilterOutput::stringURLSafe($data['title']);
}
$table = JTable::getInstance('Content', 'JTable');
if ($table->load(array('alias' => $data['alias'], 'catid' => $data['catid']))) {
$msg = JText::_('COM_CONTENT_SAVE_WARNING');
}
list($title, $alias) = $this->generateNewTitle($data['catid'], $data['alias'], $data['title']);
$data['alias'] = $alias;
if (isset($msg)) {
JFactory::getApplication()->enqueueMessage($msg, 'warning');
}
}
}
if (parent::save($data)) {
if (isset($data['featured'])) {
$this->featured($this->getState($this->getName() . '.id'), $data['featured']);
}
return true;
}
return false;
}
示例15: bind
/**
* Overloaded bind function
*
* @param array $array Named array to bind
* @param mixed $ignore An optional array or space separated list of properties to ignore while binding.
*
* @return mixed Null if operation was satisfactory, otherwise returns an error
*
* @since 1.5
*/
public function bind($array, $ignore = array())
{
if (isset($array['params']) && is_array($array['params'])) {
$registry = new Registry();
$registry->loadArray($array['params']);
if ((int) $registry->get('width', 0) < 0) {
$this->setError(JText::sprintf('JLIB_DATABASE_ERROR_NEGATIVE_NOT_PERMITTED', JText::_('COM_BANNERS_FIELD_WIDTH_LABEL')));
return false;
}
if ((int) $registry->get('height', 0) < 0) {
$this->setError(JText::sprintf('JLIB_DATABASE_ERROR_NEGATIVE_NOT_PERMITTED', JText::_('COM_BANNERS_FIELD_HEIGHT_LABEL')));
return false;
}
// Converts the width and height to an absolute numeric value:
$width = abs((int) $registry->get('width', 0));
$height = abs((int) $registry->get('height', 0));
// Sets the width and height to an empty string if = 0
$registry->set('width', $width ? $width : '');
$registry->set('height', $height ? $height : '');
$array['params'] = (string) $registry;
}
if (isset($array['imptotal'])) {
$array['imptotal'] = abs((int) $array['imptotal']);
}
return parent::bind($array, $ignore);
}