当前位置: 首页>>代码示例>>PHP>>正文


PHP JUri::getInstance方法代码示例

本文整理汇总了PHP中JUri::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP JUri::getInstance方法的具体用法?PHP JUri::getInstance怎么用?PHP JUri::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JUri的用法示例。


在下文中一共展示了JUri::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setCanonical

 public static function setCanonical($canonicalLink)
 {
     $homPage = false;
     $language = JFactory::getLanguage();
     $languageTagArr = explode('-', $language->getTag());
     $currentUrl = trim(str_replace(array('index.php/', 'index.php'), '', JUri::getInstance()->toString()), '/');
     $currentUrl = str_replace('?lang=' . $languageTagArr[0], '', $currentUrl);
     $homeUrl = JUri::base();
     $homeUrlWithLang = $homeUrl . $languageTagArr[0];
     if ($currentUrl == $homeUrl || $currentUrl == $homeUrlWithLang) {
         $homPage = true;
     }
     if (!$homPage) {
         $document = JFactory::getDocument();
         $canonicalTagExisted = false;
         $listingHeadData = $document->getHeadData();
         $listingHeadDataLink = $listingHeadData['links'];
         if (!empty($listingHeadDataLink)) {
             foreach ($listingHeadDataLink as $listingHeadDataLinkKey => $listingHeadDataLinkItem) {
                 if (is_array($listingHeadDataLinkItem) && isset($listingHeadDataLinkItem['relation']) && $listingHeadDataLinkItem['relation'] == 'canonical') {
                     $canonicalTagExisted = true;
                     unset($listingHeadDataLink[$listingHeadDataLinkKey]);
                     $listingHeadDataLink[$canonicalLink] = $listingHeadDataLinkItem;
                 }
             }
             $listingHeadData['links'] = $listingHeadDataLink;
             $document->setHeadData($listingHeadData);
         }
         if (!$canonicalTagExisted) {
             $document->addHeadLink(htmlspecialchars($canonicalLink), 'canonical');
         }
     }
 }
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:33,代码来源:helper.php

示例2: display

 public function display($tpl = null)
 {
     $this->app = JFactory::getApplication();
     /** @var $this->app JApplicationSite */
     $this->option = JFactory::getApplication()->input->get('option');
     $this->state = $this->get('State');
     $this->item = $this->get('Item');
     // Get params
     $this->params = $this->state->get('params');
     /** @var  $this->params Joomla\Registry\Registry */
     $this->imageFolder = $this->params->get('images_directory', 'images/crowdfunding');
     if (!$this->item) {
         $this->app->enqueueMessage(JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'), 'notice');
         $this->app->redirect(JRoute::_(CrowdfundingHelperRoute::getDiscoverRoute(), false));
         return;
     }
     $container = Prism\Container::getContainer();
     $this->money = $this->getMoneyFormatter($container, $this->params);
     // Integrate with social profile.
     $this->displayCreator = $this->params->get('integration_display_creator', true);
     // Prepare integration. Load avatars and profiles.
     if ($this->displayCreator and (is_object($this->item) and $this->item->user_id > 0)) {
         $socialProfile = CrowdfundingHelper::prepareIntegration($this->params->get('integration_social_platform'), $this->item->user_id);
         $this->socialProfileLink = !$socialProfile ? null : $socialProfile->getLink();
     }
     // Set a link to project page
     $uri = JUri::getInstance();
     $host = $uri->toString(array('scheme', 'host'));
     $this->item->link = $host . JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($this->item->slug, $this->item->catslug), false);
     // Set a link to image
     $this->item->link_image = $host . '/' . $this->imageFolder . '/' . $this->item->image;
     $this->embedCode = $this->prepareEmbedCode($this->item, $host);
     $this->prepareDocument();
     parent::display($tpl);
 }
开发者ID:ITPrism,项目名称:CrowdfundingDistribution,代码行数:35,代码来源:view.html.php

示例3: onAfterDispatch

 /**
  * Add the canonical uri to the head.
  *
  * @return  void
  *
  * @since   3.5
  */
 public function onAfterDispatch()
 {
     $doc = $this->app->getDocument();
     if (!$this->app->isSite() || $doc->getType() !== 'html') {
         return;
     }
     $sefDomain = $this->params->get('domain', '');
     // Don't add a canonical html tag if no alternative domain has added in SEF plugin domain field.
     if (empty($sefDomain)) {
         return;
     }
     // Check if a canonical html tag already exists (for instance, added by a component).
     $canonical = '';
     foreach ($doc->_links as $linkUrl => $link) {
         if (isset($link['relation']) && $link['relation'] === 'canonical') {
             $canonical = $linkUrl;
             break;
         }
     }
     // If a canonical html tag already exists get the canonical and change it to use the SEF plugin domain field.
     if (!empty($canonical)) {
         // Remove current canonical link.
         unset($doc->_links[$canonical]);
         // Set the current canonical link but use the SEF system plugin domain field.
         $canonical = $sefDomain . JUri::getInstance($canonical)->toString(array('path', 'query', 'fragment'));
     } else {
         $canonical = $sefDomain . JUri::getInstance()->toString(array('path', 'query', 'fragment'));
     }
     // Add the canonical link.
     $doc->addHeadLink(htmlspecialchars($canonical), 'canonical');
 }
开发者ID:brenot,项目名称:forumdesenvolvimento,代码行数:38,代码来源:sef.php

示例4: onUserTwofactorShowConfiguration

 /**
  * Shows the configuration page for this two factor authentication method.
  *
  * @param   object   $otpConfig  The two factor auth configuration object
  * @param   integer  $user_id    The numeric user ID of the user whose form we'll display
  *
  * @return  boolean|string  False if the method is not ours, the HTML of the configuration page otherwise
  *
  * @see     UsersModelUser::getOtpConfig
  * @since   3.2
  */
 public function onUserTwofactorShowConfiguration($otpConfig, $user_id = null)
 {
     // Create a new TOTP class with Google Authenticator compatible settings
     $totp = new FOFEncryptTotp(30, 6, 10);
     if ($otpConfig->method == $this->methodName) {
         // This method is already activated. Reuse the same secret key.
         $secret = $otpConfig->config['code'];
     } else {
         // This methods is not activated yet. Create a new secret key.
         $secret = $totp->generateSecret();
     }
     // These are used by Google Authenticator to tell accounts apart
     $username = JFactory::getUser($user_id)->username;
     $hostname = JUri::getInstance()->getHost();
     // This is the URL to the QR code for Google Authenticator
     $url = $totp->getUrl($username, $hostname, $secret);
     // Is this a new TOTP setup? If so, we'll have to show the code validation field.
     $new_totp = $otpConfig->method != 'totp';
     // Start output buffering
     @ob_start();
     // Include the form.php from a template override. If none is found use the default.
     $path = FOFPlatform::getInstance()->getTemplateOverridePath('plg_twofactorauth_totp', true);
     JLoader::import('joomla.filesystem.file');
     if (JFile::exists($path . '/form.php')) {
         include_once $path . '/form.php';
     } else {
         include_once __DIR__ . '/tmpl/form.php';
     }
     // Stop output buffering and get the form contents
     $html = @ob_get_clean();
     // Return the form contents
     return array('method' => $this->methodName, 'form' => $html);
 }
开发者ID:joomla-projects,项目名称:media-manager-improvement,代码行数:44,代码来源:totp.php

示例5: getGetFields

	/**
	 * Method to get hidden input fields for a get form so that control variables
	 * are not lost upon form submission.
	 *
	 * @param   string  $route  The route to the page. [optional]
	 *
	 * @return  string  A string of hidden input form fields
	 *
	 * @since   2.5
	 */
	public static function getGetFields($route = null)
	{
		$fields = null;
		$uri = JUri::getInstance(JRoute::_($route));
		$uri->delVar('q');
		$elements = $uri->getQuery(true);

		// Create hidden input elements for each part of the URI.
		// Add the current menu id if it doesn't have one
		$needId = true;
		foreach ($elements as $n => $v)
		{
			$fields .= '<input type="hidden" name="' . $n . '" value="' . $v . '" />';
			if ($n == 'Itemid')
			{
				$needId = false;
			}
		}
		if ($needId)
		{
			$fields .= '<input type="hidden" name="Itemid" value="' . JFactory::getApplication()->input->get('Itemid', '0', 'int') . '" />';
		}

		return $fields;
	}
开发者ID:GitIPFire,项目名称:Homeworks,代码行数:35,代码来源:helper.php

示例6: onAfterRender

 /**
  * The backup process via a cronjob is executed in the trigger onAfterRender
  */
 public function onAfterRender()
 {
     // Is the a token provided via the URL?
     $token_request = JFactory::getApplication()->input->get('ejbtoken', NULL, 'STRING');
     if (!empty($token_request)) {
         $token = $this->params->get('token');
         // Compare the provided token from the GET request with the saved one from the settings
         if ($token_request == $token) {
             // Which type of backup is requested?
             $type_request = JFactory::getApplication()->input->get('ejbtype', NULL, 'INTEGER');
             if (empty($type_request) or !in_array($type_request, array(1, 2, 3))) {
                 $type = (int) $this->params->get('type');
             } else {
                 $type = $type_request;
             }
             // Set the correct type name how it is used in the component
             if ($type == 1) {
                 $type = 'fullbackup';
             } elseif ($type == 2) {
                 $type = 'databasebackup';
             } elseif ($type == 3) {
                 $type = 'filebackup';
             }
             // Okay, we have everything to start the backup process - let's do it!
             $this->backup_create($type);
             // Redirect without the query to remove the cronjob parameters
             JFactory::getApplication()->redirect(JUri::getInstance()->current());
         }
     }
 }
开发者ID:richardgarcia7,项目名称:apc-softdev-gd121mi122-06,代码行数:33,代码来源:easyjoomlabackupcronjob.php

示例7: testGetURI

 /**
  * Test JRequest::getUri
  *
  * @return  void
  */
 public function testGetURI()
 {
     $uri = JUri::getInstance();
     $uri->setPath('/foo/bar');
     $uri->setQuery(array('baz' => 'buz'));
     $this->assertEquals('/foo/bar?baz=buz', JRequest::getUri());
 }
开发者ID:rdiaztushman,项目名称:joomla-platform,代码行数:12,代码来源:JRequestTest.php

示例8: email

	/**
	 * Icon for email
	 *
	 * @param   object     $member   Member info
	 * @param   JRegistry  $params   HTML Params
	 * @param   array      $attribs  Member attribs
	 *
	 * @return string
	 *
	 * @since    1.5
	 */
	public static function email($member, $params, $attribs = [])
	{
		require_once JPATH_SITE . '/components/com_mailto/helpers/mailto.php';
		$uri  = JUri::getInstance();
		$base = $uri->toString(['scheme', 'host', 'port']);
		$link = $base . JRoute::_(ContentHelperRoute::getArticleRoute($member->slug, $member->catid), false);
		$url  = 'index.php?option=com_mailto&tmpl=component&link=' . MailtoHelper::addLink($link);

		$status = 'width=400,height=350,menubar=yes,resizable=yes';

		if ($params->get('show_icons'))
		{
			$text = JHtml::_('image', 'system/emailButton.png', JText::_('JGLOBAL_EMAIL'), null, true);
		}
		else
		{
			$text = '&#160;' . JText::_('JGLOBAL_EMAIL');
		}

		$attribs['title']   = JText::_('JGLOBAL_EMAIL');
		$attribs['onclick'] = "window.open(this.href,'win2','" . $status . "'); return false;";

		$output = JHtml::_('link', JRoute::_($url), $text, $attribs);

		return $output;
	}
开发者ID:Joomla-Bible-Study,项目名称:joomla_churchdirectory,代码行数:37,代码来源:icon.php

示例9: execute

 /**
  * Execute the controller.
  *
  * @return  boolean  True if controller finished execution, false if the controller did not
  *                   finish execution. A controller might return false if some precondition for
  *                   the controller to run has not been satisfied.
  *
  * @since   12.1
  * @throws  LogicException
  * @throws  RuntimeException
  */
 public function execute()
 {
     $model = new MonitorModelIssue();
     $id = $this->input->getInt('id');
     $user = JFactory::getUser();
     // Get the params
     // TODO: may be removed when new MVC is implemented completely
     $this->app = JFactory::getApplication();
     if ($this->app instanceof JApplicationSite) {
         $params = $this->app->getParams();
     }
     if (!$model->canEdit($user, $id)) {
         if ($user->guest && isset($params) && $params->get('redirect_login', 1)) {
             $this->app->enqueueMessage(JText::_('JGLOBAL_YOU_MUST_LOGIN_FIRST'), 'error');
             $this->app->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . base64_encode(JUri::getInstance()->toString()), '403'));
         } else {
             throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403);
         }
     }
     if ($id) {
         $model->setIssueId($id);
     }
     $model->loadForm();
     $view = new MonitorViewIssueHtml($model);
     $view->setLayout('edit');
     $view->loadForm();
     echo $view->render();
     return true;
 }
开发者ID:Harmageddon,项目名称:com_monitor,代码行数:40,代码来源:edit.php

示例10: display

 /**
  * Display the view
  */
 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');
     $this->params = $this->state->get('params');
     // Get rewards images URI.
     if (!empty($this->item->id)) {
         $userId = CrowdfundingHelper::getUserIdByRewardId($this->item->id);
         $uri = JUri::getInstance();
         $this->rewardsImagesUri = $uri->toString(array('scheme', 'host')) . '/' . CrowdfundingHelper::getImagesFolderUri($userId);
     }
     $app = JFactory::getApplication();
     /** @var  $app JApplicationAdministrator */
     // Get project title.
     $projectId = $app->getUserState('com_crowdfunding.rewards.pid');
     $this->projectTitle = CrowdfundingHelper::getProjectTitle($projectId);
     // Get a property that give us ability to upload images.
     $this->allowedImages = $this->params->get('rewards_images', 0);
     $this->layout = $this->getLayout();
     if (strcmp('default', $this->layout) === 0) {
         $this->prepareDefaultLayout();
     }
     // Prepare actions, behaviors, scripts and document.
     $this->addToolbar();
     $this->setDocument();
     parent::display($tpl);
 }
开发者ID:ITPrism,项目名称:CrowdfundingDistribution,代码行数:32,代码来源:view.html.php

示例11: __construct

 /**
  * Class constructor
  *
  * @param   array  $options  Associative array of options
  *
  * @since  11.1
  */
 public function __construct($options = array())
 {
     parent::__construct($options);
     // Set document type
     $this->_type = 'opensearch';
     // Set mime type
     $this->_mime = 'application/opensearchdescription+xml';
     // Add the URL for self updating
     $update = new JOpenSearchUrl();
     $update->type = 'application/opensearchdescription+xml';
     $update->rel = 'self';
     $update->template = JRoute::_(JUri::getInstance());
     $this->addUrl($update);
     // Add the favicon as the default image
     // Try to find a favicon by checking the template and root folder
     $app = JFactory::getApplication();
     $dirs = array(JPATH_THEMES . '/' . $app->getTemplate(), JPATH_BASE);
     foreach ($dirs as $dir) {
         if (file_exists($dir . '/favicon.ico')) {
             $path = str_replace(JPATH_BASE . '/', '', $dir);
             $path = str_replace('\\', '/', $path);
             $favicon = new JOpenSearchImage();
             $favicon->data = JUri::base() . $path . '/favicon.ico';
             $favicon->height = '16';
             $favicon->width = '16';
             $favicon->type = 'image/vnd.microsoft.icon';
             $this->addImage($favicon);
             break;
         }
     }
 }
开发者ID:WineWorld,项目名称:joomlatrialcmbg,代码行数:38,代码来源:opensearch.php

示例12: getDefaultCanonical

	static function getDefaultCanonical()
	{
		$app = JFactory::getApplication();
		$doc = JFactory::getDocument();

		if ($app->getName() != 'site' || $doc->getType() !== 'html')
		{
			return;
		}

		$router = $app->getRouter();
		
		$uri = clone JUri::getInstance();
		// Get configuration from plugin
		$plugin = JPluginHelper::getPlugin('system', 'sef');
		$domain = null;
		if (!empty($plugin)) {
			$pluginParams = FLEXI_J16GE ? new JRegistry($plugin->params) : new JParameter($plugin->params);
			$domain = $pluginParams->get('domain');
		}

		if ($domain === null || $domain === '')
		{
			$domain = $uri->toString(array('scheme', 'host', 'port'));
		}

		$parsed = $router->parse($uri);
		$fakelink = 'index.php?' . http_build_query($parsed);
		$link = $domain . JRoute::_($fakelink, false);

		return ($uri !== $link) ? htmlspecialchars($link) : false;
	}
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:32,代码来源:flexicontent.helper.php

示例13: search

 public function search()
 {
     $app = JFactory::getApplication();
     $post['id'] = $this->input->getInt('id');
     $searchTags = $this->input->get('searchTags', array(), 'ARRAY');
     $post['searchTags'] = $searchTags;
     $tagSearchOption = $this->input->getString('tagSearchOption', null, 'post');
     $post['tagSearchOption'] = $tagSearchOption;
     $post['ordering'] = $this->input->getWord('ordering', null, 'post');
     //        $post['searchphrase'] = $this->input->getWord('searchphrase', 'all', 'post');
     $post['limit'] = $this->input->getUInt('limit', null, 'post');
     if ($post['limit'] === null) {
         unset($post['limit']);
     }
     // set Itemid id for links from menu
     $app = JFactory::getApplication();
     $menu = $app->getMenu();
     $items = $menu->getItems('link', 'index.php?option=com_search&view=search');
     //$app->enqueueMessage('Task = search', 'error');
     if (isset($items[0])) {
         $post['Itemid'] = $items[0]->id;
     } elseif ($this->input->getInt('Itemid') > 0) {
         //use Itemid from requesting page only if there is no existing menu
         $post['Itemid'] = $this->input->getInt('Itemid');
     }
     unset($post['task']);
     unset($post['submit']);
     $uri = JUri::getInstance();
     $session =& JFactory::getSession();
     $session->set('TagSearchPost', $post);
     //$uri->setQuery($post);
     $uri->setVar('option', 'com_tagsearch');
     $this->setRedirect(JRoute::_('index.php' . $uri->toString(array('query', 'fragment')), false));
 }
开发者ID:ShogunWeb,项目名称:Tag-search,代码行数:34,代码来源:controller.php

示例14: onInstallerBeforePackageDownload

 /**
  * Handle adding credentials to package download request
  *
  * @param   string  $url        url from which package is going to be downloaded
  * @param   array   $headers    headers to be sent along the download request (key => value format)
  *
  * @return  boolean true if credentials have been added to request or not our business, false otherwise (credentials not set by user)
  *
  * @since   2.5
  */
 public function onInstallerBeforePackageDownload(&$url, &$headers)
 {
     $uri = JUri::getInstance($url);
     // I don't care about download URLs not coming from our site
     // Note: as the Download ID is common for all extensions, this plugin will be triggered for all
     // extensions with a download URL on our site
     $host = $uri->getHost();
     if (!in_array($host, array('www.akeebabackup.com', 'www.akeeba.com'))) {
         return true;
     }
     // Get the download ID
     JLoader::import('joomla.application.component.helper');
     $component = JComponentHelper::getComponent($this->extension);
     $dlid = $component->params->get('update_dlid', '');
     // If the download ID is invalid, return without any further action
     if (!preg_match('/^([0-9]{1,}:)?[0-9a-f]{32}$/i', $dlid)) {
         return true;
     }
     // Appent the Download ID to the download URL
     if (!empty($dlid)) {
         $uri->setVar('dlid', $dlid);
         $url = $uri->toString();
     }
     return true;
 }
开发者ID:sillysachin,项目名称:teamtogether,代码行数:35,代码来源:akeebabackup.php

示例15: run

 /**
  * @return string
  */
 public function run()
 {
     $config = CRM_Core_Config::singleton();
     switch ($config->userFramework) {
         case 'Drupal':
             $this->assign('ufAccessURL', url('admin/people/permissions'));
             break;
         case 'Drupal6':
             $this->assign('ufAccessURL', url('admin/user/permissions'));
             break;
         case 'Joomla':
             //condition based on Joomla version; <= 2.5 uses modal window; >= 3.0 uses full page with return value
             if (version_compare(JVERSION, '3.0', 'lt')) {
                 JHTML::_('behavior.modal');
                 $url = $config->userFrameworkBaseURL . 'index.php?option=com_config&view=component&component=com_civicrm&tmpl=component';
                 $jparams = 'rel="{handler: \'iframe\', size: {x: 875, y: 550}, onClose: function() {}}" class="modal"';
                 $this->assign('ufAccessURL', $url);
                 $this->assign('jAccessParams', $jparams);
             } else {
                 $uri = (string) JUri::getInstance();
                 $return = urlencode(base64_encode($uri));
                 $url = $config->userFrameworkBaseURL . 'index.php?option=com_config&view=component&component=com_civicrm&return=' . $return;
                 $this->assign('ufAccessURL', $url);
                 $this->assign('jAccessParams', '');
             }
             break;
         case 'WordPress':
             $this->assign('ufAccessURL', CRM_Utils_System::url('civicrm/admin/access/wp-permissions', 'reset=1'));
             break;
     }
     return parent::run();
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:35,代码来源:Access.php


注:本文中的JUri::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。