本文整理汇总了PHP中Joomla\Registry\Registry类的典型用法代码示例。如果您正苦于以下问题:PHP Registry类的具体用法?PHP Registry怎么用?PHP Registry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Registry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getComponent
/**
* Get the component information.
*
* @param string $option The component option.
* @param boolean $strict If set and the component does not exist, the enabled attribute will be set to false.
*
* @return stdClass An object with the information for the component.
*
* @since 1.5
*/
public static function getComponent($option, $strict = false)
{
if (!isset(static::$components[$option]))
{
if (static::load($option))
{
$result = static::$components[$option];
}
else
{
$result = new stdClass;
$result->enabled = $strict ? false : true;
$result->params = new Registry;
}
}
else
{
$result = static::$components[$option];
}
if (is_string($result->params))
{
$temp = new Registry;
$temp->loadString(static::$components[$option]->params);
static::$components[$option]->params = $temp;
}
return $result;
}
示例2: 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)
{
if ($item = parent::getItem($pk)) {
if (!empty($item->params)) {
// Convert the params field to an array.
$registry = new Registry();
$registry->loadString($item->params);
$item->params = $registry->toArray();
}
if (!empty($item->metadata)) {
// Convert the metadata field to an array.
$registry = new Registry();
$registry->loadString($item->metadata);
$item->metadata = $registry->toArray();
}
if (!empty($item->template)) {
// base64 Decode template.
$item->template = base64_decode($item->template);
}
if (!empty($item->php_view)) {
// base64 Decode php_view.
$item->php_view = base64_decode($item->php_view);
}
if (!empty($item->id)) {
$item->tags = new JHelperTags();
$item->tags->getTagIds($item->id, 'com_componentbuilder.template');
}
}
return $item;
}
示例3: 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)
{
if ($item = parent::getItem($pk)) {
if (!empty($item->params)) {
// Convert the params field to an array.
$registry = new Registry();
$registry->loadString($item->params);
$item->params = $registry->toArray();
}
if (!empty($item->metadata)) {
// Convert the metadata field to an array.
$registry = new Registry();
$registry->loadString($item->metadata);
$item->metadata = $registry->toArray();
}
if (!empty($item->interventions)) {
// JSON Decode interventions.
$item->interventions = json_decode($item->interventions);
}
if (!empty($item->id)) {
$item->tags = new JHelperTags();
$item->tags->getTagIds($item->id, 'com_costbenefitprojection.intervention');
}
}
return $item;
}
示例4: populateState
/**
* Method to auto-populate the model state.
*
* @param string $ordering Field used for order by clause
* @param string $direction Direction of order
*
* Note. Calling getState in this method will result in recursion.
*
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
$this->setState('filter.extension', $this->_extension);
// Get the parent id if defined.
$parent_id = $app->input->getInt('id');
$this->setState('filter.parentId', $parent_id);
// Load the parameters. Merge Global and Menu Item params into new object
$params = $app->getParams();
$menu_params = new Registry();
if ($menu = $app->getMenu()->getActive()) {
$menu_params->loadString($menu->params);
}
$merged_params = clone $menu_params;
$merged_params->merge($params);
$this->setState('params', $merged_params);
$params = $merged_params;
$this->setState('filter.published', 1);
$this->setState('filter.language', $app->getLanguageFilter());
// process show_category_noauth parameter
if (!$params->get('show_category_noauth')) {
$this->setState('filter.access', true);
} else {
$this->setState('filter.access', false);
}
}
示例5: create
/**
* Build a social profile object.
*
* <code>
* $options = new Joomla\Registry\Registry(array(
* 'platform' => 'socialcommunity',
* 'user_id' => 1,
* 'title' => 'Title...',
* 'image' => "http://mydomain.com/image.png",
* 'url' => "http://mydomain.com",
* 'app' => 'my_app'
* ));
*
* $factory = new Prism\Integration\Activity\Factory($options);
* $activity = $factory->create();
* </code>
*/
public function create()
{
$activity = null;
switch ($this->options->get('platform')) {
case 'socialcommunity':
$activity = new Socialcommunity($this->options->get('user_id'));
$activity->setUrl($this->options->get('url'));
$activity->setImage($this->options->get('image'));
break;
case 'gamification':
$activity = new Gamification($this->options->get('user_id'));
$activity->setTitle($this->options->get('title'));
$activity->setUrl($this->options->get('url'));
$activity->setImage($this->options->get('image'));
break;
case 'jomsocial':
// Register JomSocial Router
if (!class_exists('CRoute')) {
\JLoader::register('CRoute', JPATH_SITE . '/components/com_community/libraries/core.php');
}
$activity = new JomSocial($this->options->get('user_id'));
$activity->setApp($this->options->get('app'));
break;
case 'easysocial':
$activity = new EasySocial($this->options->get('user_id'));
$activity->setContextId($this->options->get('user_id'));
break;
}
if ($activity !== null) {
$activity->setDb(\JFactory::getDbo());
}
return $activity;
}
示例6: handle
/**
* Execute the middleware. Don't call this method directly; it is used by the `Application` internally.
*
* @internal
*
* @param ServerRequestInterface $request The request object
* @param ResponseInterface $response The response object
* @param callable $next The next middleware handler
*
* @return ResponseInterface
*/
public function handle(ServerRequestInterface $request, ResponseInterface $response, callable $next = null)
{
$attributes = $request->getAttributes();
if (!isset($attributes['command'])) {
switch (strtoupper($request->getMethod())) {
case 'GET':
$params = new Registry($request->getQueryParams());
break;
case 'POST':
default:
$params = new Registry($request->getAttributes());
break;
}
$extension = ucfirst(strtolower($params->get('option', 'Article')));
$action = ucfirst(strtolower($params->get('task', 'display')));
$entity = $params->get('entity', 'error');
$id = $params->get('id', null);
$commandClass = "\\Joomla\\Extension\\{$extension}\\Command\\{$action}Command";
if (class_exists($commandClass)) {
$command = new $commandClass($entity, $id, $response->getBody());
$request = $request->withAttribute('command', $command);
}
// @todo Emit afterRouting event
}
return $next($request, $response);
}
示例7: onExtensionAfterSave
public function onExtensionAfterSave($context, $table, $isNew)
{
if (!($context == 'com_plugins.plugin' && $table->element == 'giftd')) {
return true;
}
$app = JFactory::getApplication();
$code = $app->getUserState('plugins.system.giftd.code', '');
$token_prefix = $app->getUserState('plugins.system.giftd.token_prefix', '');
$app->setUserState('plugins.system.giftd.code', '');
$app->setUserState('plugins.system.giftd.token_prefix', '');
if (!empty($code) || !empty($token_prefix)) {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName('params'))->from($db->quoteName('#__extensions'))->where($db->quoteName('element') . ' = ' . $db->quote('giftd'))->where($db->quoteName('type') . ' = ' . $db->quote('plugin'));
$params = new Registry($db->setQuery($query, 0, 1)->loadResult());
if (!empty($code)) {
$params->set('partner_code', $code);
}
if (!empty($token_prefix)) {
$params->set('partner_token_prefix', $token_prefix);
}
$query->clear()->update($db->quoteName('#__extensions'));
$query->set($db->quoteName('params') . '= ' . $db->quote((string) $params));
$query->where($db->quoteName('element') . ' = ' . $db->quote('giftd'));
$query->where($db->quoteName('type') . ' = ' . $db->quote('plugin'));
$db->setQuery($query);
$db->execute();
}
return true;
}
示例8: handle
/**
* Prepare the statuses of the items.
*
* @param array $data
* @param array $options
*/
public function handle(&$data, array $options = array())
{
foreach ($data as $key => $item) {
// Calculate funding end date
if (is_numeric($item->funding_days) and $item->funding_days > 0) {
$fundingStartDate = new Crowdfunding\Date($item->funding_start);
$endDate = $fundingStartDate->calculateEndDate($item->funding_days);
$item->funding_end = $endDate->format(Prism\Constants::DATE_FORMAT_SQL_DATE);
}
// Calculate funded percentage.
$item->funded_percents = (string) MathHelper::calculatePercentage($item->funded, $item->goal, 0);
// Calculate days left
$today = new Crowdfunding\Date();
$item->days_left = $today->calculateDaysLeft($item->funding_days, $item->funding_start, $item->funding_end);
// Decode parameters.
if ($item->params === null) {
$item->params = '{}';
}
if (is_string($item->params) and $item->params !== '') {
$params = new Registry();
$params->loadString($item->params);
$item->params = $params;
}
}
}
示例9: 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);
}
示例10: getConfig
/**
* Get config
*/
static function getConfig($var = false)
{
// check if config is already loaded
$app = self::getApp();
if (isset($app->chclient->config)) {
return $var ? $app->chclient->config->{$var} : $app->chclient->config;
}
// default config
$config = (object) [];
$registry = new Registry();
$config_fields = $registry->loadFile(JPATH_ROOT . '/components/com_chclient/config.yml', 'yaml');
foreach ($config_fields as $field => $properties) {
$config->{$field} = $properties->value;
}
// get site config
$site_config = json_decode(JFactory::getDbo()->setQuery('SELECT config FROM #__chclient_config AS a WHERE a.id = 1')->loadResult());
foreach ($config as $field => $p) {
if (isset($site_config->{$field})) {
$config->{$field} = $site_config->{$field};
}
}
// datepicker options
$config->datepicker_min_date = CHLibDate::getDate()->format(CHLibDate::dateLocale());
$config->datepicker_format = str_replace('Y', 'YYYY', str_replace('m', 'MM', str_replace('d', 'DD', CHLibDate::dateLocale())));
// store config for later use
$app->chclient->config = $config;
return $var ? $app->chclient->config->{$var} : $app->chclient->config;
}
示例11: 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'));
}
}
示例12: execute
public function execute()
{
if ($this->state->get('children', false) && count($this->state->get('children', 0) > 1)) {
foreach ($this->state->get('children') as $child_id) {
$cartItemData['child_id'] = $child_id;
$cartItemData['start_date'] = $this->state->get('startdates.' . $child_id);
$cartItemData['dates'] = $this->state->get('dates.' . $child_id);
$cartItemData['product_id'] = $this->state->get('product_id', false);
$cartApp = Sp4kAppsCartApp::getInstance(new Registry($cartItemData));
/** @var Registry $cartItem */
$cartItem = new Registry($cartApp->getItem());
$cartItems[$cartItem->get('cart_key')] = $cartItem;
}
} else {
$cartApp = Sp4kAppsCartApp::getInstance($this->state);
$cartItem = $cartApp->getItem();
$cartItems[$cartItem->cartkey] = $cartItem;
}
/** @var JSession $cartSession */
$cartSession = JFactory::getSession();
$cartSessionData = $cartSession->get('cart', [], 'Sp4k');
foreach ($cartItems as $cartKey => $cartItem) {
$cartSessionData['items'][$cartKey] = $cartItem->toObject();
}
//$cartItemData['totals'] = $this->getCartTotals($cart);
$cartSession->set('cart', $cartSessionData, 'Sp4k');
}
示例13: __construct
/**
* Overrides JGithub constructor to initialise the api property.
*
* @param mixed $input An optional argument to provide dependency injection for the application's
* input object. If the argument is a JInputCli object that object will become
* the application's input object, otherwise a default input object is created.
* @param mixed $config An optional argument to provide dependency injection for the application's
* config object. If the argument is a JRegistry object that object will become
* the application's config object, otherwise a default config object is created.
* @param mixed $dispatcher An optional argument to provide dependency injection for the application's
* event dispatcher. If the argument is a JDispatcher object that object will become
* the application's event dispatcher, if it is null then the default event dispatcher
* will be created based on the application's loadDispatcher() method.
*
* @see loadDispatcher()
* @since 11.1
*/
public function __construct()
{
parent::__construct();
$options = new Registry();
$options->set('headers.Accept', 'application/vnd.github.html+json');
$this->api = new Github($options);
}
示例14: 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)
{
if ($item = parent::getItem($pk)) {
if (!empty($item->params)) {
// Convert the params field to an array.
$registry = new Registry();
$registry->loadString($item->params);
$item->params = $registry->toArray();
}
if (!empty($item->metadata)) {
// Convert the metadata field to an array.
$registry = new Registry();
$registry->loadString($item->metadata);
$item->metadata = $registry->toArray();
}
if (!empty($item->testcompanies)) {
// JSON Decode testcompanies.
$item->testcompanies = json_decode($item->testcompanies);
}
if (!empty($item->id)) {
$item->tags = new JHelperTags();
$item->tags->getTagIds($item->id, 'com_costbenefitprojection.service_provider');
}
}
$this->service_providervvvx = $item->id;
return $item;
}
示例15: 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)
{
if ($item = parent::getItem($pk)) {
if (!empty($item->params)) {
// Convert the params field to an array.
$registry = new Registry();
$registry->loadString($item->params);
$item->params = $registry->toArray();
}
if (!empty($item->metadata)) {
// Convert the metadata field to an array.
$registry = new Registry();
$registry->loadString($item->metadata);
$item->metadata = $registry->toArray();
}
if (!empty($item->causesrisks)) {
// JSON Decode causesrisks.
$item->causesrisks = json_decode($item->causesrisks);
}
if (!empty($item->id)) {
$item->tags = new JHelperTags();
$item->tags->getTagIds($item->id, 'com_costbenefitprojection.country');
}
}
$this->countryvvvy = $item->id;
$this->countryvvvz = $item->id;
$this->countryvvwa = $item->id;
return $item;
}