本文整理汇总了PHP中JRegistry::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP JRegistry::toArray方法的具体用法?PHP JRegistry::toArray怎么用?PHP JRegistry::toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JRegistry
的用法示例。
在下文中一共展示了JRegistry::toArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTrans
/**
* Get language items and store them in an array
*
*/
function getTrans($lang, $item)
{
$app = JFactory::getApplication();
$option = 'com_osmembership';
$registry = new JRegistry();
$languages = array();
if (strpos($item, 'admin.') !== false) {
$isAdmin = true;
$item = substr($item, 6);
} else {
$isAdmin = false;
}
if ($isAdmin) {
$path = JPATH_ROOT . '/administrator/language/en-GB/en-GB.' . $item . '.ini';
} else {
$path = JPATH_ROOT . '/language/en-GB/en-GB.' . $item . '.ini';
}
$registry->loadFile($path, 'INI');
$languages['en-GB'][$item] = $registry->toArray();
if ($isAdmin) {
$path = JPATH_ROOT . '/administrator/language/' . $lang . '/' . $lang . '.' . $item . '.ini';
} else {
$path = JPATH_ROOT . '/language/' . $lang . '/' . $lang . '.' . $item . '.ini';
}
$search = $app->getUserStateFromRequest($option . 'search', 'search', '', 'string');
$search = JString::strtolower($search);
if (JFile::exists($path)) {
$registry->loadFile($path, 'INI');
$languages[$lang][$item] = $registry->toArray();
} else {
$languages[$lang][$item] = array();
}
return $languages;
}
示例2: postflight
/**
* Method to run after installing the component
*/
function postflight($type, $parent)
{
//Restore the modified language strings by merging to language files
$registry = new JRegistry();
foreach (self::$languageFiles as $languageFile) {
$backupFile = JPATH_ROOT . '/language/en-GB/bak.' . $languageFile;
$currentFile = JPATH_ROOT . '/language/en-GB/' . $languageFile;
if (JFile::exists($currentFile) && JFile::exists($backupFile)) {
$registry->loadFile($currentFile, 'INI');
$currentItems = $registry->toArray();
$registry->loadFile($backupFile, 'INI');
$backupItems = $registry->toArray();
$items = array_merge($currentItems, $backupItems);
$content = "";
foreach ($items as $key => $value) {
$content .= "{$key}=\"{$value}\"\n";
}
JFile::write($currentFile, $content);
}
}
// Restore custom modified css file
if (JFile::exists(JPATH_ROOT . '/components/com_osmembership/assets/css/bak.custom.css')) {
JFile::copy(JPATH_ROOT . '/components/com_osmembership/assets/css/bak.custom.css', JPATH_ROOT . '/components/com_osmembership/assets/css/custom.css');
JFile::delete(JPATH_ROOT . '/components/com_osmembership/assets/css/bak.custom.css');
}
}
示例3: getUpdates
public function getUpdates()
{
$updates = array();
$all_plugins = $this->folder('j2store')->getList();
$json = $this->sendRequest();
$update_data = array();
if (!empty($json)) {
$registry = new JRegistry($json);
$update_data = $registry->toArray();
} else {
return $updates;
}
//get plugins that have updates
foreach ($all_plugins as $plugin) {
if (isset($update_data[$plugin->element])) {
//load manifest cache to get the version
$manifest = json_decode($plugin->manifest_cache);
if ($manifest) {
$version = (string) $manifest->version;
if (version_compare($update_data[$plugin->element], $version, 'gt')) {
$plugin->current_version = $version;
$plugin->new_version = $update_data[$plugin->element];
$updates[] = $plugin;
}
}
}
}
return $updates;
}
示例4: getItem
/**
* Method to get a category.
*
* @param integer An optional id of the object to get, otherwise the id from the model state is used.
* @return mixed Category data object on success, false on failure.
* @since 1.6
*/
public function getItem($pk = null)
{
if ($result = parent::getItem($pk)) {
// Prime required properties.
if (empty($result->id)) {
$result->parent_id = $this->getState('category.parent_id');
$result->extension = $this->getState('category.extension');
}
// Convert the metadata field to an array.
$registry = new JRegistry();
$registry->loadJSON($result->metadata);
$result->metadata = $registry->toArray();
// Convert the created and modified dates to local user time for display in the form.
jimport('joomla.utilities.date');
$tz = new DateTimeZone(JFactory::getApplication()->getCfg('offset'));
if (intval($result->created_time)) {
$date = new JDate($result->created_time);
$date->setTimezone($tz);
$result->created_time = $date->toMySQL(true);
} else {
$result->created_time = null;
}
if (intval($result->modified_time)) {
$date = new JDate($result->modified_time);
$date->setTimezone($tz);
$result->modified_time = $date->toMySQL(true);
} else {
$result->modified_time = null;
}
}
return $result;
}
示例5: getOptions
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 11.1
*/
protected function getOptions()
{
$options = array();
$compositions_id = $this->form->getValue('id') ? $this->form->getValue('id') : 0;
$db = JFactory::getDbo();
$query = $db->getQuery(true)->select("id AS `value`, title AS `text`, print_title")->from('#__sibdiet_compositions AS a')->order('a.title')->where("TRIM(IFNULL(a.compositions,'')) = '' AND a.id <> " . $compositions_id);
// Get the options.
$db->setQuery($query);
try {
$options = $db->loadObjectList();
} catch (RuntimeException $e) {
JError::raiseWarning(500, $e->getMessage());
}
$lang_tag = JFactory::getLanguage()->get('tag');
foreach ($options as $key => $option) {
// Convert the print_title field to an array.
$registry = new JRegistry();
$registry->loadString($option->print_title);
$print_title = $registry->toArray();
if (array_key_exists($lang_tag, $print_title)) {
$options[$key]->text .= ' { ' . $print_title[$lang_tag] . ' }';
}
// Disable selected values
if (array_key_exists($options[$key]->value, $this->value)) {
$options[$key]->disable = 1;
}
}
array_unshift($options, JHtml::_('select.option', '', ''));
return $options;
}
示例6: before
/**
* Load user form.
*
* @return void
*/
protected function before()
{
parent::before();
$userParams = JComponentHelper::getParams('com_users');
// Check if user is allowed to change his name.
$this->changeUsername = $userParams->get('change_login_name', 1);
// Check to see if Frontend User Params have been enabled.
if ($userParams->get('frontend_userparams', 0))
{
JFactory::getLanguage()->load('com_users', JPATH_ADMINISTRATOR);
JForm::addFormPath(JPATH_ROOT . '/components/com_users/models/forms');
JForm::addFieldPath(JPATH_ROOT . '/components/com_users/models/fields');
JPluginHelper::importPlugin('user');
$registry = new JRegistry($this->user->params);
$form = JForm::getInstance('com_users.profile', 'frontend');
$data = new StdClass;
$data->params = $registry->toArray();
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('onContentPrepareForm', array($form, $data));
$form->bind($data);
$this->frontendForm = $form->getFieldset('params');
}
$this->headerText = JText::_('COM_KUNENA_PROFILE_EDIT_USER_TITLE');
}
示例7: display
/**
* Execute and display a template script.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise a Error object.
*/
public function display($tpl = null)
{
$app = JFactory::getApplication();
$user = JFactory::getUser();
$this->item = $this->get('Item');
$this->print = $app->input->getBool('print');
$this->secretkey = $app->input->getString('secretkey');
$this->state = $this->get('State');
$this->user = $user;
$this->params = $this->state->get('params');
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseWarning(500, implode("\n", $errors));
return false;
}
// Check the view access to the request print.
if ($user->get('guest')) {
if (!empty($this->secretkey) && $this->secretkey == $this->item->secretkey) {
// User requested diet print by secret key
} else {
JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
return;
}
}
// Convert body field to array.
$registry = new JRegistry();
$registry->loadString($this->item->body);
$this->item->body = $registry->toArray();
$this->item = (object) array_merge((array) $this->item, $this->item->body);
$this->item = SibdietHelper::calculate($this->item);
//Escape strings for HTML output
$this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx'));
$this->_prepareDocument();
parent::display($tpl);
}
示例8: display
/**
* Display the view
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return void
*/
public function display($tpl = null)
{
SibdietHelper::addSubmenu('requestschecks');
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
$this->permissions = SibdietHelper::getUserPermissions();
// Calculate profile refer No.
foreach ($this->items as $item) {
$item->referNo = SibdietHelper::getReferNo($item->profiles_id);
// Convert the payment field to an array.
$registry = new JRegistry();
$registry->loadString($item->payment);
$item->payment = $registry->toArray();
}
$this->addToolbar();
$this->sidebar = JHtmlSidebar::render();
if (in_array('requestschecks', $this->permissions)) {
parent::display($tpl);
}
}
示例9: getInput
public function getInput()
{
$objectID = JRequest::getInt('id', 0);
// Create a new query object.
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select('a.*');
$query->from('`#__autofilter_regions` AS a');
$db->setQuery($query);
$regions = $db->loadObjectList();
$loadedObject = array();
if ($objectID != 0) {
// Select the required fields from the table.
$query = $db->getQuery(true);
$query->select('a.regions_covered_ids');
$query->from('`#__autofilter_repairmans` AS a');
$query->where('(a.id = ' . $objectID . ')');
$db->setQuery($query);
$loadedObject = $db->loadObject();
$registry = new JRegistry();
$registry->loadString($loadedObject->regions_covered_ids);
$loadedObject = array_values($registry->toArray());
}
$html = '<select id="' . $this->id . '" name="' . $this->name . '" multiple="multiple">';
foreach ($regions as $region) {
$selected = in_array($region->id, $loadedObject) ? 'selected' : '';
$html .= '<option value="' . $region->id . '" ' . $selected . '>' . $region->name . '</option>';
}
$html .= '</select>';
return $html;
}
示例10: getItem
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
$pk = !empty($pk) ? $pk : (int) $this->getState($this->getName() . '.id');
$table = $this->getTable();
if ($pk > 0) {
// Attempt to load the row.
$return = $table->load($pk);
// Check for a table object error.
if ($return === false && $table->getError()) {
$this->setError($table->getError());
return false;
}
}
// Convert to the JObject before adding other data.
$properties = $table->getProperties(1);
$item = JArrayHelper::toObject($properties, 'JObject');
if (property_exists($item, 'params')) {
$registry = new JRegistry();
$registry->loadString($item->params);
$item->params = $registry->toArray();
}
if (property_exists($item, 'order_params')) {
$registry = new JRegistry();
$registry->loadString($item->order_params);
$item->order_params = $registry->toArray();
}
return $item;
}
示例11: getItem
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 12.2
*/
public function getItem($pk = null)
{
$item = parent::getItem($pk);
$db = JFactory::getDbo();
$model_table = JModelLegacy::getInstance("Table", "JDeveloperModel");
if ($item->table) {
$table = JModelLegacy::getInstance("Table", "JDeveloperModel")->getItem($item->table);
$item->component_name = "com_" . JModelLegacy::getInstance("Component", "JDeveloperModel")->getItem($table->component)->name;
}
// Exists field in database?
if ($model_table->isInstalled($item->table)) {
$item->isInstalled = $this->dbColumnExists($item, "", true);
} else {
$item->isInstalled = false;
}
// Add formfield id
$query = $db->getQuery(true)->select("id")->from("#__jdeveloper_formfields as ff")->where("ff.name = " . $db->quote($item->type));
$item->formfield_id = (int) $db->setQuery($query)->loadResult();
// Add formrule id
$query = $db->getQuery(true)->select("id")->from("#__jdeveloper_formrules as fr")->where("fr.name = " . $db->quote($item->rule));
$item->formrule_id = (int) $db->setQuery($query)->loadResult();
// Load options
$registry = new JRegistry();
$registry->loadString($item->options);
$item->options = $registry->toArray();
// Load attributes
$registry = new JRegistry();
$registry->loadString($item->attributes);
$item->attributes = $registry->toArray();
return $item;
}
示例12: getItem
public function getItem($pk = null)
{
$storeId = md5(__METHOD__);
if (!isset($this->cache[$storeId])) {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('config_params');
$query->from('#__judownload_categories');
$query->where('parent_id = 0');
$query->where('level = 0');
$db->setQuery($query);
$config_params = $db->loadResult();
$registry = new JRegistry();
$registry->loadString($config_params);
$globalConfig = $registry->toObject();
foreach ($globalConfig as $key => $value) {
if (is_object($value)) {
$registry = new JRegistry();
$registry->loadObject($value);
$globalConfig->{$key} = $registry->toArray();
}
}
$this->cache[$storeId] = $globalConfig;
}
return $this->cache[$storeId];
}
示例13: _getURL
public function _getURL($user, $sizex, $sizey)
{
if (!$user->userid == 0) {
$user = KunenaFactory::getUser($user->userid);
$user = JsnHelper::getUser($user->userid);
if ($sizex <= 50) {
$avatar = JURI::root(true) . '/' . $user->getValue('avatar_mini');
} else {
$avatar = JURI::root(true) . '/' . $user->getValue('avatar');
}
} elseif ($this->params->get('guestavatar', "easyprofile") == "easyprofile") {
$avatar = JUri::root(true) . '/components/com_jsn/assets/img/default.jpg';
} else {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('params')->from('#__jsn_fields')->where('alias=\'avatar\'');
$db->setQuery($query);
$params = $db->loadResult();
$registry = new JRegistry();
$registry->loadString($params);
$params = $registry->toArray();
if ($params['image_defaultvalue'] != "") {
$avatar = JUri::root(true) . '/' . $params['image_defaultvalue'];
} else {
$avatar = JUri::root(true) . '/components/com_jsn/assets/img/default.jpg';
}
}
return $avatar;
}
示例14: getItem
public function getItem($pk = null)
{
$pk = !empty($pk) ? $pk : (int) $this->getState($this->getName() . '.id');
$table = $this->getTable();
if ($pk > 0) {
// Attempt to load the row.
$return = $table->load($pk);
// Check for a table object error.
if ($return === false && $table->getError()) {
$this->setError($table->getError());
return false;
}
}
// Convert to the JObject before adding other data.
$properties = $table->getProperties(1);
$item = JArrayHelper::toObject($properties, 'JObject');
if (!is_array($item->items)) {
if (isset($item->id)) {
$this->_db->setQuery('SELECT * FROM #__djc2_order_items WHERE order_id=\'' . $item->id . '\'');
$item->items = $this->_db->loadObjectList();
} else {
$item->items = array();
}
}
if (property_exists($item, 'params')) {
$registry = new JRegistry();
$registry->loadString($item->params);
$item->params = $registry->toArray();
}
return $item;
}
示例15: getData
/**
* Loading the table data
*/
public function getData()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select(array('*'));
$query->from('#__jem_settings');
$query->where(array('id = 1 '));
$db->setQuery($query);
$data = $db->loadObject();
// Convert the params field to an array.
$registry = new JRegistry;
$registry->loadString($data->globalattribs);
$data->globalattribs = $registry->toArray();
// Convert Css settings to an array
$registryCss = new JRegistry;
$registryCss->loadString($data->css);
$data->css = $registryCss->toArray();
return $data;
}