本文整理汇总了PHP中Registry::loadArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Registry::loadArray方法的具体用法?PHP Registry::loadArray怎么用?PHP Registry::loadArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Registry
的用法示例。
在下文中一共展示了Registry::loadArray方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Stores a publisher.
*
* @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 (isset($this->params) && is_array($this->params)) {
$registry = new Registry();
$registry->loadArray($this->params);
$this->params = (string) $registry;
}
// Get date and user
$date = JFactory::getDate();
$user = JFactory::getUser();
if ($this->id) {
// Existing item
$this->modified_by = $user->get('username');
$this->modified = $date->toSql();
} else {
// New item
$this->created_by = $user->get('username');
$this->created = $date->toSql();
}
// Question 7: from array to comma separated string
if (is_array($this->question_7)) {
if (count($this->question_7) > 0) {
$this->question_7 = implode(',', $this->question_7);
} else {
$this->question_7 = '';
}
} else {
$this->question_7 = '';
}
return parent::store($updateNulls);
}
示例2: store
/**
* Stores an Identifier Range.
*
* @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 (isset($this->params) && is_array($this->params)) {
$registry = new Registry();
$registry->loadArray($this->params);
$this->params = (string) $registry;
}
// Get date and user
$date = JFactory::getDate();
$user = JFactory::getUser();
if ($this->id) {
// Existing item
$this->modified_by = $user->get('username');
$this->modified = $date->toSql();
} else {
// New item
$this->created_by = $user->get('username');
$this->created = $date->toSql();
$this->category = strlen($this->range_begin);
$this->free = $this->range_end - $this->range_begin + 1;
$this->next = $this->range_begin;
}
return parent::store($updateNulls);
}
示例3: store
/**
* Stores an identifier.
*
* @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 (isset($this->params) && is_array($this->params)) {
$registry = new Registry();
$registry->loadArray($this->params);
$this->params = (string) $registry;
}
return parent::store($updateNulls);
}
示例4: store
/**
* Stores a canceled identifier.
*
* @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 (isset($this->params) && is_array($this->params)) {
$registry = new Registry();
$registry->loadArray($this->params);
$this->params = (string) $registry;
}
if (!$this->id) {
// Get date and user
$date = JFactory::getDate();
$user = JFactory::getUser();
// New item
$this->canceled_by = $user->get('username');
$this->canceled = $date->toSql();
}
return parent::store($updateNulls);
}
示例5: store
/**
* Stores a group message.
*
* @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 (isset($this->params) && is_array($this->params)) {
$registry = new Registry();
$registry->loadArray($this->params);
$this->params = (string) $registry;
}
// Get date and user
$date = JFactory::getDate();
$user = JFactory::getUser();
$this->created_by = $user->get('username');
$this->created = $date->toSql();
// From array to comma separated string
$this->isbn_categories = $this->fromArrayToStr($this->isbn_categories);
$this->ismn_categories = $this->fromArrayToStr($this->ismn_categories);
return parent::store($updateNulls);
}
示例6: store
/**
* Stores an ISSN Range.
*
* @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 (isset($this->params) && is_array($this->params)) {
$registry = new Registry();
$registry->loadArray($this->params);
$this->params = (string) $registry;
}
// Get date and user
$date = JFactory::getDate();
$user = JFactory::getUser();
if ($this->id) {
// Existing item
$this->modified_by = $user->get('username');
$this->modified = $date->toSql();
// If this object is active, disactivate all the others
if (!$this->is_closed && $this->is_active) {
self::disactivateOther($this->id);
}
} else {
// New item
$this->created_by = $user->get('username');
$this->created = $date->toSql();
$this->free = $this->range_end - $this->range_begin + 1;
// Add ISSN range helper file
require_once JPATH_COMPONENT . '/helpers/issnrange.php';
// Get range begin check digit
$rangeBeginCheckDigit = IssnrangeHelper::countIssnCheckDigit($this->block . $this->range_begin);
// Set range begin check digit
$this->range_begin .= $rangeBeginCheckDigit;
// Set next pointer
$this->next = $this->range_begin;
// Get range end check digit
$rangeEndCheckDigit = IssnrangeHelper::countIssnCheckDigit($this->block . $this->range_end);
// Set range end check digit
$this->range_end .= $rangeEndCheckDigit;
// If this object is active, disactivate all the others
if ($this->is_active) {
self::disactivateOther(0);
}
}
return parent::store($updateNulls);
}
示例7: store
/**
* Stores a publication.
*
* @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 (isset($this->params) && is_array($this->params)) {
$registry = new Registry();
$registry->loadArray($this->params);
$this->params = (string) $registry;
}
// Get date and user
$date = JFactory::getDate();
$user = JFactory::getUser();
if ($this->id) {
// Is this the first modification?
if (empty($this->modified_by)) {
// Set on_process to true
$this->on_process = true;
}
// Is no_identifier_granted set to true
if ($this->no_identifier_granted) {
// Set on_process to false
$this->on_process = false;
}
// Existing item
$this->modified_by = $user->get('username');
$this->modified = $date->toSql();
} else {
// New item
$this->created_by = $user->get('username');
$this->created = $date->toSql();
}
// From array to comma separated string
$this->role_1 = $this->fromArrayToStr($this->role_1);
$this->role_2 = $this->fromArrayToStr($this->role_2);
$this->role_3 = $this->fromArrayToStr($this->role_3);
$this->role_4 = $this->fromArrayToStr($this->role_4);
$this->type = $this->fromArrayToStr($this->type);
$this->fileformat = $this->fromArrayToStr($this->fileformat);
return parent::store($updateNulls);
}
示例8: getArticleContent
//.........这里部分代码省略.........
$input = JFactory::getApplication()->input;
// Get the global params
$globalParams = JComponentHelper::getParams('com_content', true);
// Convert the parameter fields into objects.
foreach ($result as &$item) {
$articleParams = new \Joomla\Registry\Registry();
$articleParams->loadString($item->attribs);
// Unpack readmore and layout params
$item->alternative_readmore = $articleParams->get('alternative_readmore');
$item->layout = $articleParams->get('layout');
$item->params = clone $model->getState('params');
/*For blogs, article params override menu item params only if menu param = 'use_article'
Otherwise, menu item params control the layout
If menu item is 'use_article' and there is no article param, use global*/
if ($input->getString('layout') == 'blog' || $input->getString('view') == 'featured' || $model->getState('params')->get('layout_type') == 'blog') {
// Create an array of just the params set to 'use_article'
$menuParamsArray = $model->getState('params')->toArray();
$articleArray = array();
foreach ($menuParamsArray as $key => $value) {
if ($value === 'use_article') {
// If the article has a value, use it
if ($articleParams->get($key) != '') {
// Get the value from the article
$articleArray[$key] = $articleParams->get($key);
} else {
// Otherwise, use the global value
$articleArray[$key] = $globalParams->get($key);
}
}
}
// Merge the selected article params
if (count($articleArray) > 0) {
$articleParams = new Registry();
$articleParams->loadArray($articleArray);
$item->params->merge($articleParams);
}
} else {
// For non-blog layouts, merge all of the article params
$item->params->merge($articleParams);
}
// Get display date
switch ($item->params->get('list_show_date')) {
case 'modified':
$item->displayDate = $item->modified;
break;
case 'published':
$item->displayDate = $item->publish_up == 0 ? $item->created : $item->publish_up;
break;
default:
case 'created':
$item->displayDate = $item->created;
break;
}
// Compute the asset access permissions.
// Technically guest could edit an article, but lets not check that to improve performance a little.
if (!$guest) {
$asset = 'com_content.article.' . $item->id;
// Check general edit permission first.
if ($user->authorise('core.edit', $asset)) {
$item->params->set('access-edit', true);
} elseif (!empty($userId) && $user->authorise('core.edit.own', $asset)) {
// Check for a valid user and that they are the owner.
if ($userId == $item->created_by) {
$item->params->set('access-edit', true);
}
}
示例9: store
/**
* Stores a message type.
*
* @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 (isset($this->params) && is_array($this->params)) {
$registry = new Registry();
$registry->loadArray($this->params);
$this->params = (string) $registry;
}
// Get date and user
$date = JFactory::getDate();
$user = JFactory::getUser();
if ($this->id) {
// Existing item
$this->modified_by = $user->get('username');
$this->modified = $date->toSql();
} else {
// New item
$this->created_by = $user->get('username');
$this->created = $date->toSql();
// If publisher name, email and contact person are empty, and
// publisher has been selected from the db, copy publisher name,
// email and contact person from publisher.
if (empty($this->publisher) && empty($this->email) && empty($this->contact_person) && $this->publisher_id > 0) {
// Load publisher model
$publisherModel = JModelLegacy::getInstance('publisher', 'IssnregistryModel');
// Load publisher
$publisher = $publisherModel->getItem($this->publisher_id);
// Get publisher name
$this->publisher = $publisher->official_name;
// Get email
$email = $publisher->email_common;
// Contact person
$contactPerson = '';
// Get contact persons as JSON
$json = json_decode($publisher->contact_person);
// Check that we have a JSON object
if (!empty($json)) {
// Get the last contact person
$contactPerson = $json->{'name'}[sizeof($json->{'name'}) - 1];
// Get the last email
$emailTemp = $json->{'email'}[sizeof($json->{'email'}) - 1];
// If the email is not empty, let's use it
if (!empty($emailTemp)) {
$email = $emailTemp;
}
}
// Set contact person and email
$this->email = $email;
$this->contact_person = $contactPerson;
}
}
if (parent::store($updateNulls)) {
// Check form status, if "REJECTED", update publications status
if (strcmp($this->status, "REJECTED") == 0) {
// Load publication model
$publicationModel = JModelLegacy::getInstance('publication', 'IssnregistryModel');
// Update publications status
$publicationModel->setStatusToNoISSNGranted($this->id);
}
return true;
}
return false;
}