本文整理汇总了PHP中Joomla\Registry\Registry::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Registry::get方法的具体用法?PHP Registry::get怎么用?PHP Registry::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Joomla\Registry\Registry
的用法示例。
在下文中一共展示了Registry::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: prepareSorting
/**
* Prepare sortable fields, sort values and filters.
*/
protected function prepareSorting()
{
$this->listOrder = $this->escape($this->state->get('list.ordering'));
$this->listDirn = $this->escape($this->state->get('list.direction'));
$this->saveOrder = strcmp($this->listOrder, 'a.ordering') != 0 ? false : true;
$this->filterForm = $this->get('FilterForm');
}
示例3: 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);
}
示例4: execute
/**
* Execute the command.
*
* @return void
*
* @since 1.0
* @throws AbortException
* @throws \RuntimeException
* @throws \UnexpectedValueException
*/
public function execute()
{
try {
// Check if the database "exists"
$tables = $this->db->getTableList();
if (!$this->app->input->get('reinstall')) {
$this->app->out('<fg=black;bg=yellow>WARNING: A database has been found !!</fg=black;bg=yellow>')->out('Do you want to reinstall ? [y]es / [[n]]o :', false);
$in = trim($this->app->in());
if (!in_array($in, ['yes', 'y'])) {
throw new AbortException();
}
}
$this->cleanDatabase($tables);
$this->app->out("\nFinished!");
} catch (\RuntimeException $e) {
// Check if the message is "Could not connect to database." Odds are, this means the DB isn't there or the server is down.
if (strpos($e->getMessage(), 'Could not connect to database.') !== false) {
// ? really..
$this->app->out('No database found.')->out('Creating the database...', false);
$this->db->setQuery('CREATE DATABASE ' . $this->db->quoteName($this->config->get('database.name')))->execute();
$this->db->select($this->config->get('database.name'));
$this->app->out("\nFinished!");
} else {
throw $e;
}
}
// Perform the installation
$this->processSql();
$this->app->out('Installer has terminated successfully.');
}
示例5: check
/**
* Method to perform sanity checks on the JTable instance properties to ensure
* they are safe to store in the database. Child classes should override this
* method to make sure the data they are storing in the database is safe and
* as expected before storage.
*
* @return boolean True if the instance is sane and able to be stored in the database.
*
* @since 2.5
*/
public function check()
{
try {
parent::check();
} catch (\Exception $e) {
$this->setError($e->getMessage());
return false;
}
if (trim($this->alias) == '') {
$this->alias = $this->title;
}
$this->alias = JApplicationHelper::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '') {
$this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
}
$params = new Registry($this->params);
$nullDate = $this->_db->getNullDate();
$d1 = $params->get('d1', $nullDate);
$d2 = $params->get('d2', $nullDate);
// Check the end date is not earlier than the start date.
if ($d2 > $nullDate && $d2 < $d1) {
// Swap the dates.
$params->set('d1', $d2);
$params->set('d2', $d1);
$this->params = (string) $params;
}
return true;
}
示例6: prepareSorting
/**
* Prepare sortable fields, sort values and filters.
*/
protected function prepareSorting()
{
$this->listOrder = $this->escape($this->state->get('list.ordering'));
$this->listDirn = $this->escape($this->state->get('list.direction'));
$this->saveOrder = strcmp($this->listOrder, 'a.ordering') === 0;
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
}
示例7: upload
/**
* upload
*
* @param \JInput $input
*/
public static function upload(\JInput $input)
{
try {
$editorPlugin = \JPluginHelper::getPlugin('editors', 'akmarkdown');
if (!$editorPlugin) {
throw new \Exception('Editor Akmarkdown not exists');
}
$params = new Registry($editorPlugin->params);
$files = $input->files;
$field = $input->get('field', 'file');
$type = $input->get('type', 'post');
$allows = $params->get('Upload_AllowExtension', '');
$allows = array_map('strtolower', array_map('trim', explode(',', $allows)));
$file = $files->getVar($field);
$src = $file['tmp_name'];
$name = $file['name'];
$tmp = new \SplFileInfo(JPATH_ROOT . '/tmp/ak-upload/' . $name);
if (empty($file['tmp_name'])) {
throw new \Exception('File not upload');
}
$ext = pathinfo($name, PATHINFO_EXTENSION);
if (!in_array($ext, $allows)) {
throw new \Exception('File extension now allowed.');
}
// Move file to tmp
if (!is_dir($tmp->getPath())) {
\JFolder::create($tmp->getPath());
}
if (is_file($tmp->getPathname())) {
\JFile::delete($tmp->getPathname());
}
\JFile::upload($src, $tmp->getPathname());
$src = $tmp;
$dest = static::getDest($name, $params->get('Upload_S3_Subfolder', 'ak-upload'));
$s3 = new \S3($params->get('Upload_S3_Key'), $params->get('Upload_S3_SecretKey'));
$bucket = $params->get('Upload_S3_Bucket');
$result = $s3::putObject(\S3::inputFile($src->getPathname(), false), $bucket, $dest, \S3::ACL_PUBLIC_READ);
if (is_file($tmp->getPathname())) {
\JFile::delete($tmp->getPathname());
}
if (!$result) {
throw new \Exception('Upload fail.');
}
} catch (\Exception $e) {
$response = new Response();
$response->setBody(json_encode(['error' => $e->getMessage()]));
$response->setMimeType('text/json');
$response->respond();
exit;
}
$return = new \JRegistry();
$return['filename'] = 'https://' . $bucket . '.s3.amazonaws.com/' . $dest;
$return['file'] = 'https://' . $bucket . '.s3.amazonaws.com/' . $dest;
$response = new Response();
$response->setBody((string) $return);
$response->setMimeType('text/json');
$response->respond();
}
示例8: render
/**
* Renders a module script and returns the results as a string
*
* @param mixed $module The name of the module to render
* @param array $attribs Associative array of values
* @param string $content If present, module information from the buffer will be used
*
* @return string The output of the script
*
* @since 11.1
*/
public function render($module, $attribs = array(), $content = null)
{
if (!is_object($module)) {
$title = isset($attribs['title']) ? $attribs['title'] : null;
$module = JModuleHelper::getModule($module, $title);
if (!is_object($module)) {
if (is_null($content)) {
return '';
} else {
/**
* If module isn't found in the database but data has been pushed in the buffer
* we want to render it
*/
$tmp = $module;
$module = new stdClass();
$module->params = null;
$module->module = $tmp;
$module->id = 0;
$module->user = 0;
}
}
}
// Get the user and configuration object
// $user = JFactory::getUser();
$conf = Factory::getConfig();
// Set the module content
if (!is_null($content)) {
$module->content = $content;
}
// Get module parameters
$params = new Registry();
$params->loadString($module->params);
// Use parameters from template
if (isset($attribs['params'])) {
$template_params = new Registry();
$template_params->loadString(html_entity_decode($attribs['params'], ENT_COMPAT, 'UTF-8'));
$params->merge($template_params);
$module = clone $module;
$module->params = (string) $params;
}
$contents = '';
// Default for compatibility purposes. Set cachemode parameter or use JModuleHelper::moduleCache from within the
// module instead
$cachemode = $params->get('cachemode', 'oldstatic');
if ($params->get('cache', 0) == 1 && $conf->get('caching') >= 1 && $cachemode != 'id' && $cachemode != 'safeuri') {
// Default to itemid creating method and workarounds on
$cacheparams = new stdClass();
$cacheparams->cachemode = $cachemode;
$cacheparams->class = 'JModuleHelper';
$cacheparams->method = 'renderModule';
$cacheparams->methodparams = array($module, $attribs);
$contents = JModuleHelper::ModuleCache($module, $params, $cacheparams);
} else {
$contents = JModuleHelper::renderModule($module, $attribs);
}
return $contents;
}
示例9: __get
/**
* Get a global template var.
*
* @param string $key The template var key.
*
* @return mixed
*
* @since 1.0
*/
public function __get($key)
{
if ($this->globals->exists($key)) {
return $this->globals->get($key);
}
if ($this->debug) {
trigger_error('No template var: ' . $key);
}
return '';
}
示例10: getGroups
/**
* Get Mailchimp email groups
*
* @param \Joomla\Registry\Registry $params Params
*
* @throws RuntimeException
*
* @return array groups
*/
protected function getGroups($params)
{
$listId = $params->get('mailchimp_listid');
$apiKey = $params->get('mailchimp_apikey');
if ($apiKey == '') {
throw new RuntimeException('Mailchimp: no api key specified');
}
if ($listId == '') {
throw new RuntimeException('Mailchimp: no list id specified');
}
$api = new MCAPI($params->get('mailchimp_apikey'));
$groups = $api->listInterestGroupings($listId);
return $groups;
}
示例11: display
public function display($tpl = null)
{
$this->option = JFactory::getApplication()->input->get('option');
$this->state = $this->get('State');
$this->item = $this->get('Item');
$this->form = $this->get('Form');
// Load the component parameters.
$params = $this->state->get('params');
$filesystemHelper = new Prism\Filesystem\Helper($params);
$this->mediaFolder = $filesystemHelper->getMediaFolder();
// Prepare actions, behaviors, scripts and document
$this->addToolbar();
$this->setDocument();
parent::display($tpl);
}
示例12: getUsers
/**
* Get users sorted by activation date
*
* @param \Joomla\Registry\Registry $params module parameters
*
* @return array The array of users
*
* @since 1.6
*/
public static function getUsers($params)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)->select($db->quoteName(array('a.id', 'a.name', 'a.username', 'a.registerDate')))->order($db->quoteName('a.registerDate') . ' DESC')->from('#__users AS a');
$user = JFactory::getUser();
if (!$user->authorise('core.admin') && $params->get('filter_groups', 0) == 1) {
$groups = $user->getAuthorisedGroups();
if (empty($groups)) {
return array();
}
$query->join('LEFT', '#__user_usergroup_map AS m ON m.user_id = a.id')->join('LEFT', '#__usergroups AS ug ON ug.id = m.group_id')->where('ug.id in (' . implode(',', $groups) . ')')->where('ug.id <> 1');
}
$db->setQuery($query, 0, $params->get('shownumber'));
$result = $db->loadObjectList();
return (array) $result;
}
示例13: getMoneyFormatter
/**
* Return money formatter.
*
* <code>
* $this->prepareMoneyFormatter($container, $params);
* $money = $this->getMoneyFormatter($container, $params);
* </code>
*
* @param Registry $params
*
* @throws \RuntimeException
* @throws \InvalidArgumentException
* @throws \OutOfBoundsException
*
* @return Money
*/
protected function getMoneyFormatter($params)
{
$currencyId = $params->get('project_currency');
// Get the currency.
$currency = $this->getCurrency($currencyId);
// Prepare decimal pattern.
$fractionDigits = (int) $params->get('fraction_digits', 2);
$pattern = '#,##0';
if ($fractionDigits > 0) {
$pattern .= '.' . str_repeat('0', $fractionDigits);
}
$formatter = LocaleHelper::getNumberFormatter($pattern);
$money = new Money($formatter);
$money->setCurrency($currency);
return $money;
}
示例14: edit
/**
* Create a link to edit an existing weblink
*
* @param object $weblink Weblink data
* @param \Joomla\Registry\Registry $params Item params
* @param array $attribs Unused
*
* @return string
*/
public static function edit($weblink, $params, $attribs = array())
{
$uri = JUri::getInstance();
if ($params && $params->get('popup')) {
return;
}
if ($weblink->state < 0) {
return;
}
JHtml::_('bootstrap.tooltip');
$url = WeblinksHelperRoute::getFormRoute($weblink->id, base64_encode($uri));
$icon = $weblink->state ? 'edit.png' : 'edit_unpublished.png';
$text = JHtml::_('image', 'system/' . $icon, JText::_('JGLOBAL_EDIT'), null, true);
if ($weblink->state == 0) {
$overlib = JText::_('JUNPUBLISHED');
} else {
$overlib = JText::_('JPUBLISHED');
}
$date = JHtml::_('date', $weblink->created);
$author = $weblink->created_by_alias ? $weblink->created_by_alias : $weblink->author;
$overlib .= '<br />';
$overlib .= $date;
$overlib .= '<br />';
$overlib .= htmlspecialchars($author, ENT_COMPAT, 'UTF-8');
$button = JHtml::_('link', JRoute::_($url), $text);
return '<span class="hasTooltip" title="' . JHtml::tooltipText('COM_WEBLINKS_EDIT') . ' :: ' . $overlib . '">' . $button . '</span>';
}
示例15: 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');
}