本文整理汇总了PHP中JRegistry::loadArray方法的典型用法代码示例。如果您正苦于以下问题:PHP JRegistry::loadArray方法的具体用法?PHP JRegistry::loadArray怎么用?PHP JRegistry::loadArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JRegistry
的用法示例。
在下文中一共展示了JRegistry::loadArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
/**
* Saves the system configuration
*
* @return boolean If successfull return TRUE, otherwise FALSE
*/
public function save()
{
if (!empty($this->_modified)) {
$config = new JRegistry('config');
$config->loadArray(JFactory::getConfig()->toArray());
$config->loadArray($this->_data);
if (file_put_contents($this->getPath(), $config->toString('PHP', 'config', array('class' => 'JConfig'))) === false) {
$this->setStatusMessage(JText::_('ERRORCONFIGFILE'));
$this->setStatus(KDatabase::STATUS_FAILED);
return false;
}
$this->setStatus(KDatabase::STATUS_UPDATED);
}
return true;
}
示例2: 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.
*
* @link http://docs.joomla.org/JTable/bind
* @since 11.1
* @throws InvalidArgumentException
*/
public function bind($src, $ignore = array())
{
if (is_object($src)) {
$src = get_object_vars($src);
}
if (isset($src['params']) && is_array($src['params'])) {
$registry = new JRegistry();
$registry->loadArray($src['params']);
$src['params'] = $registry->toString();
}
if (isset($src['plugins']) && is_array($src['plugins'])) {
$registry = new JRegistry();
$registry->loadArray($src['plugins']);
$src['plugins'] = $registry->toString();
}
if (isset($src['rules']) && is_array($src['rules'])) {
$rules = array();
foreach ((array) $src['rules'] as $action => $ids) {
$rules[$action] = array();
foreach ($ids as $id => $p) {
if ($p !== '') {
$rules[$action][$id] = $p == '1' || $p == 'true' ? true : false;
}
}
}
$this->setRules(new JAccessRules($rules));
}
return parent::bind($src, $ignore);
}
示例3: bind
/**
* Overloaded bind function to pre-process the params.
*
* @param array Named array
*
* @return null|string null is operation was satisfactory, otherwise returns an error
* @see JTable:bind
* @since 1.5
*/
public function bind($array, $ignore = '')
{
$input = JFactory::getApplication()->input;
$task = $input->getString('task', '');
if (($task == 'save' || $task == 'apply') && (!JFactory::getUser()->authorise('core.edit.state', 'com_somosmaestros') && $array['state'] == 1)) {
$array['state'] = 0;
}
if ($array['id'] == 0) {
$array['created_by'] = JFactory::getUser()->id;
}
if (isset($array['params']) && is_array($array['params'])) {
$registry = new JRegistry();
$registry->loadArray($array['params']);
$array['params'] = (string) $registry;
}
if (isset($array['metadata']) && is_array($array['metadata'])) {
$registry = new JRegistry();
$registry->loadArray($array['metadata']);
$array['metadata'] = (string) $registry;
}
if (!JFactory::getUser()->authorise('core.admin', 'com_somosmaestros.video.' . $array['id'])) {
$actions = JFactory::getACL()->getActions('com_somosmaestros', 'video');
$default_actions = JFactory::getACL()->getAssetRules('com_somosmaestros.video.' . $array['id'])->getData();
$array_jaccess = array();
foreach ($actions as $action) {
$array_jaccess[$action->name] = $default_actions[$action->name];
}
$array['rules'] = $this->JAccessRulestoArray($array_jaccess);
}
//Bind the rules for ACL where supported.
if (isset($array['rules']) && is_array($array['rules'])) {
$this->setRules($array['rules']);
}
return parent::bind($array, $ignore);
}
示例4: bind
/**
* Overloaded bind function to pre-process the params.
*
* @param array Named array
* @return null|string null is operation was satisfactory, otherwise returns an error
* @see JTable:bind
* @since 1.5
*/
public function bind($array, $ignore = '')
{
if (!JFactory::getUser()->authorise('core.edit.state', 'com_einsatzkomponente.einsatzbilderbearbeiten.' . $array['id']) && $array['state'] == 1) {
$array['state'] = 0;
}
if (!isset($array['created_by']) || $array['created_by'] == 0) {
$array['created_by'] = JFactory::getUser()->id;
}
if (isset($array['params']) && is_array($array['params'])) {
$registry = new JRegistry();
$registry->loadArray($array['params']);
$array['params'] = (string) $registry;
}
if (isset($array['metadata']) && is_array($array['metadata'])) {
$registry = new JRegistry();
$registry->loadArray($array['metadata']);
$array['metadata'] = (string) $registry;
}
if (!JFactory::getUser()->authorise('core.admin', 'com_einsatzkomponente.einsatzbilderbearbeiten.' . $array['id'])) {
$actions = JFactory::getACL()->getActions('com_einsatzkomponente', 'einsatzbilderbearbeiten');
$default_actions = JFactory::getACL()->getAssetRules('com_einsatzkomponente.einsatzbilderbearbeiten.' . $array['id'])->getData();
$array_jaccess = array();
foreach ($actions as $action) {
$array_jaccess[$action->name] = $default_actions[$action->name];
}
$array['rules'] = $this->JAccessRulestoArray($array_jaccess);
}
//Bind the rules for ACL where supported.
if (isset($array['rules']) && is_array($array['rules'])) {
$this->setRules($array['rules']);
}
return parent::bind($array, $ignore);
}
示例5: bind
/**
* Overloaded bind function to pre-process the params.
*
* @param array Named array
*
* @return null|string null is operation was satisfactory, otherwise returns an error
* @see JTable::bind
*/
public function bind($array, $ignore = '')
{
// For Fields group
// Convert jform[fields_group][field] to jform[field] or JTable cannot bind data.
// ==========================================================================================
$data = array();
$array = AKHelper::_('array.pivotFromTwoDimension', $array);
// Set field['param_xxx'] to params
// ==========================================================================================
if (empty($array['params'])) {
$array['params'] = AKHelper::_('array.pivotFromPrefix', 'param_', $array, JArrayHelper::getValue($array, 'params', array()));
}
// Set params to JRegistry
// ==========================================================================================
if (isset($array['params']) && is_array($array['params'])) {
$registry = new JRegistry();
$registry->loadArray($array['params']);
$array['params'] = (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);
}
示例6: 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 = '')
{
if (isset($array['params']) && is_array($array['params'])) {
$registry = new JRegistry();
$registry->loadArray($array['params']);
$array['params'] = (string) $registry;
}
if (isset($array['metadata']) && is_array($array['metadata'])) {
$registry = new JRegistry();
$registry->loadArray($array['metadata']);
$array['metadata'] = (string) $registry;
}
if (!JFactory::getUser()->authorise('core.admin', 'com_quick2cart.region.' . $array['id'])) {
$actions = JFactory::getACL()->getActions('com_quick2cart', 'region');
$default_actions = JFactory::getACL()->getAssetRules('com_quick2cart.region.' . $array['id'])->getData();
$array_jaccess = array();
foreach ($actions as $action) {
$array_jaccess[$action->name] = $default_actions[$action->name];
}
$array['rules'] = $this->JAccessRulestoArray($array_jaccess);
}
// Bind the rules for ACL where supported.
if (isset($array['rules']) && is_array($array['rules'])) {
$this->setRules($array['rules']);
}
return parent::bind($array, $ignore);
}
示例7: preprocessForm
protected function preprocessForm(\JForm $form, $data, $group = 'content')
{
// if no data, grab the posted form data.
if (!$data instanceof JObject) {
$data = JFactory::getApplication()->input->get('jform', $data, 'array');
$data = JArrayHelper::toObject($data);
}
$params = new JRegistry();
$params->loadArray($data->params);
if ($params->get('discovery.url')) {
$plugin = $params->get('discovery.type');
$language = JFactory::getLanguage();
$language->load('plg_harvest_' . $plugin);
$path = JPATH_ROOT . '/plugins/harvest/' . $plugin . '/forms/harvest.xml';
$form->loadFile($path, false);
foreach (JPluginHelper::getPlugin('ingest') as $plugin) {
$language->load('plg_ingest_' . $plugin->name);
$path = JPATH_ROOT . '/plugins/ingest/' . $plugin->name . '/forms/ingest.xml';
$form->loadFile($path, false);
}
$form->removeField('originating_url');
$form->removeField('harvester');
// hide the run_once value (users cannot set it after discovery)
$form->setFieldAttribute("run_once", 'type', 'hidden');
$form->setFieldAttribute("run_once", 'class', '');
} else {
$form->removeField('state');
$form->removeField('harvested');
$form->removeField('url', 'params.discovery');
$form->removeField('type', 'params.discovery');
}
parent::preprocessForm($form, $data, $group);
}
示例8: bind
/**
* Overloaded bind function to pre-process the params.
*
* @param array Named array
* @return null|string null is operation was satisfactory, otherwise returns an error
* @see JTable:bind
*/
public function bind($array, $ignore = '')
{
if (isset($array['body']) && is_array($array['body'])) {
$registry = new JRegistry();
$registry->loadArray($array['body']);
$array['body'] = (string) $registry;
}
if (isset($array['special']) && is_array($array['special'])) {
$registry = new JRegistry();
$registry->loadArray($array['special']);
$array['special'] = (string) $registry;
}
if (isset($array['laboratory']) && is_array($array['laboratory'])) {
$registry = new JRegistry();
$registry->loadArray($array['laboratory']);
$array['laboratory'] = (string) $registry;
}
if (isset($array['payment']) && is_array($array['payment'])) {
$registry = new JRegistry();
$registry->loadArray($array['payment']);
$array['payment'] = (string) $registry;
}
if (isset($array['ctags']) && is_array($array['ctags'])) {
$array['ctags'] = implode(',', $array['ctags']);
} else {
$data['ctags'] = '';
}
return parent::bind($array, $ignore);
}
示例9: store
/**
* Extend store
*/
public function store($updateNulls = false)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
// created & modified
if (!$this->created) {
$this->created = $date->toSql();
}
if (!$this->created_by) {
$this->created_by = $user->get('id');
}
$this->modified = $date->toSql();
$this->modified_by = $user->get('id');
// ordering
if (!$this->id) {
$where = "catid = " . $this->catid;
$this->ordering = $this->getNextOrder($where);
}
// params
// Transform the params field
if (is_array($this->params)) {
$registry = new JRegistry();
$registry->loadArray($this->params);
$this->params = (string) $registry;
}
return parent::store($updateNulls);
}
示例10: bind
/**
* Overloaded bind function to pre-process the params.
*
* @param array Named array
* @return null|string null is operation was satisfactory, otherwise returns an error
* @see JTable:bind
* @since 1.5
*/
public function bind($array, $ignore = '')
{
$input = JFactory::getApplication()->input;
$task = $input->getString('task', '');
if (($task == 'save' || $task == 'apply') && (!JFactory::getUser()->authorise('core.edit.state', 'com_dzproduct') && $array['state'] == 1)) {
$array['state'] = 0;
}
//Support for multiple or not foreign key field: itemid
if (isset($array['itemid'])) {
if (is_array($array['itemid'])) {
$array['itemid'] = implode(',', $array['itemid']);
} else {
if (strrpos($array['itemid'], ',') != false) {
$array['itemid'] = explode(',', $array['itemid']);
} else {
if (empty($array['itemid'])) {
$array['itemid'] = '';
}
}
}
}
//Support for multiple or not foreign key field: fieldid
if (isset($array['fieldid'])) {
if (is_array($array['fieldid'])) {
$array['fieldid'] = implode(',', $array['fieldid']);
} else {
if (strrpos($array['fieldid'], ',') != false) {
$array['fieldid'] = explode(',', $array['fieldid']);
} else {
if (empty($array['fieldid'])) {
$array['fieldid'] = '';
}
}
}
}
if (isset($array['params']) && is_array($array['params'])) {
$registry = new JRegistry();
$registry->loadArray($array['params']);
$array['params'] = (string) $registry;
}
if (isset($array['metadata']) && is_array($array['metadata'])) {
$registry = new JRegistry();
$registry->loadArray($array['metadata']);
$array['metadata'] = (string) $registry;
}
if (!JFactory::getUser()->authorise('core.admin', 'com_dzproduct.fielddata.' . $array['id'])) {
$actions = JFactory::getACL()->getActions('com_dzproduct', 'fielddata');
$default_actions = JFactory::getACL()->getAssetRules('com_dzproduct.fielddata.' . $array['id'])->getData();
$array_jaccess = array();
foreach ($actions as $action) {
$array_jaccess[$action->name] = $default_actions[$action->name];
}
$array['rules'] = $this->JAccessRulestoArray($array_jaccess);
}
//Bind the rules for ACL where supported.
if (isset($array['rules']) && is_array($array['rules'])) {
$this->setRules($array['rules']);
}
return parent::bind($array, $ignore);
}
示例11: apply
function apply()
{
$app = JFactory::getApplication();
$configs = JRequest::get('POST');
$model = JFBCFactory::config();
JPluginHelper::importPlugin('socialprofiles');
$profilePlugins = $app->triggerEvent('socialProfilesGetPlugins');
foreach ($profilePlugins as $plugin) {
$pluginName = $plugin->getName();
$settings = new JRegistry();
$search = "profiles_" . $pluginName . "_";
$stdFields = JRequest::getVar('profiles_' . $pluginName);
$settings->loadArray($stdFields);
foreach ($configs as $key => $value) {
$pos = strpos($key, $search);
if ($pos === 0) {
$key = str_replace($search, "", $key);
if (strpos($key, "field_map") != false) {
$key = str_replace("_field_map", ".", $key);
$settings->set('field_map.' . $key, $value);
}
}
}
$model->update("profile_" . $pluginName, $settings->toString());
}
JFBCFactory::log(JText::_('COM_JFBCONNECT_MSG_SETTINGS_UPDATED'));
$this->display();
}
示例12: saveParams
/**
* TuiyoParameter::saveParams()
*
* @param mixed $postParams
* @param mixed $key
* @param string $type
* @return
*/
public function saveParams($postParams, $key, $type = "system")
{
jimport('joomla.filesystem.file');
jimport('joomla.client.helper');
// Set FTP credentials, if given
JClientHelper::setCredentialsFromRequest('ftp');
$ftp = JClientHelper::getCredentials('ftp');
$file = TUIYO_CONFIG . DS . strtolower($key) . ".ini";
if (JFile::exists($file)) {
JFile::write($file);
}
if (count($postParams)) {
$registry = new JRegistry();
$registry->loadArray($postParams);
$iniTxt = $registry->toString();
// Try to make the params file writeable
if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0755')) {
JError::raiseNotice('SOME_ERROR_CODE', _('Could not make the template parameter file writable'));
return false;
}
//Write the file
$return = JFile::write($file, $iniTxt);
// Try to make the params file unwriteable
if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0555')) {
JError::raiseNotice('SOME_ERROR_CODE', _('Could not make the template parameter file unwritable'));
return false;
}
if (!$return) {
JError::raiseError(TUIYO_SERVER_ERROR, _("Could not save the template parameters"));
return false;
}
return $return;
}
}
示例13: savepositions
public function savepositions($cachable = false, $urlparams = false)
{
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
$jinput = JFactory::getApplication()->input;
$layout = $jinput->get('layout', 'default', 'STRING');
$print_config = $jinput->get('print_config', array(), 'ARRAY');
$direction = $jinput->get('direction', '', 'STRING');
$modified = JFactory::getDate()->toSql();
$db = JFactory::getDBO();
$registry = new JRegistry();
$registry->loadArray($print_config);
$print_config = (string) $registry;
// get component params
$params = JComponentHelper::getParams('com_sibdiet');
if ($layout == 'addresses') {
$params->set('print_config_addresses', $print_config);
// Save to component params
$query = $db->getQuery(true)->update("#__extensions")->set('`params` = ' . $db->quote((string) $params))->where("`element` = 'com_sibdiet'");
} else {
$params->set('print_config_' . $direction, $print_config);
// Save to user settings
$query = "INSERT INTO #__sibdiet_settings (id,modified,print_config_" . $direction . ") VALUES (" . JFactory::getUser()->id . ",'" . $modified . "','" . $print_config . "') ON DUPLICATE KEY UPDATE modified = '" . $modified . "', print_config_" . $direction . " = '" . $print_config . "'";
}
$db->setQuery($query);
//execute db object
try {
// Execute the query in Joomla 3.0.
$result = $db->execute();
} catch (Exception $e) {
//print the errors
print_r($e);
}
return self::display();
}
示例14: save
public function save()
{
$task = $this->getTask();
// get the Application Object
$app = JFactory::getApplication();
// get the payment id
$payment_id = $app->input->getInt('extension_id');
// if payment id exists
if ($payment_id) {
$data = $app->input->getArray($_POST);
$paymentdata = array();
$paymentdata['extension_id'] = $payment_id;
$registry = new JRegistry();
$registry->loadArray($data);
$paymentdata['params'] = $registry->toString('JSON');
try {
F0FTable::getAnInstance('Payment', 'J2StoreTable')->save($paymentdata);
} catch (Exception $e) {
$msg = $e->getMessage();
}
switch ($task) {
case 'apply':
parent::apply();
break;
case 'save':
parent::save();
break;
case 'savenew':
parent::savenew();
break;
}
}
}
示例15: display
function display($cachable = false, $urlparams = array())
{
$app = JFactory::getApplication();
$user = JFactory::getUser();
if (empty(JFactory::getUser()->id)) {
$url = JRoute::_("index.php?option=com_j2store&view=downloads");
$redirect = "index.php?option=com_users&view=login&return=" . base64_encode($url);
$redirect = JRoute::_($redirect, false);
JFactory::getApplication()->redirect($redirect);
return;
}
$params = JComponentHelper::getParams('com_j2store');
$model = $this->getModel('downloads');
$ns = 'com_j2store.downloads';
$files = $model->getItems();
$registry = new JRegistry();
$registry->loadArray($files);
$files = $registry->toObject();
//print_r($files);
//exit;
//$freefiles=$model->getFreeFiles();
//$files=$this->process($files,$freefiles);
$view = $this->getView('downloads', 'html');
$view->set('_controller', 'downloads');
$view->set('_view', 'downloads');
$view->set('_doTask', true);
$view->set('hidemenu', false);
$view->setModel($model, true);
$view->assign('files', $files);
$view->assign('params', $params);
$view->setLayout('default');
// $view->display();
parent::display();
}