Exemplo n.º 1
0
 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');
         }
     }
 }
 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);
 }
Exemplo n.º 3
0
 /**
  * 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');
 }
 /**
  * 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);
 }
Exemplo n.º 5
0
	/**
	 * 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;
	}
 /**
  * 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());
         }
     }
 }
Exemplo n.º 7
0
 /**
  * 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());
 }
	/**
	 * 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;
	}
Exemplo n.º 9
0
 /**
  * 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;
 }
Exemplo n.º 10
0
 /**
  * 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);
 }
Exemplo n.º 11
0
 /**
  * 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;
         }
     }
 }
Exemplo n.º 12
0
	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;
	}
Exemplo n.º 13
0
 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));
 }
Exemplo n.º 14
0
 /**
  * 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;
 }
Exemplo n.º 15
0
 /**
  * @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();
 }
Exemplo n.º 16
0
 /**
  * Render comments and respond form html.
  *
  * @param AppView $view The view the comments are rendered on
  * @param Item $item The item whos comments are rendered
  *
  * @return string The html output
  *
  * @since 2.0
  */
 public function renderComments($view, $item)
 {
     if ($item->getApplication()->isCommentsEnabled()) {
         // get application params
         $params = $this->app->parameter->create($item->getApplication()->getParams()->get('global.comments.'));
         if ($params->get('twitter_enable') && !function_exists('curl_init')) {
             $this->app->error->raiseWarning(500, JText::_('To use Twitter, CURL needs to be enabled in your php settings.'));
             $params->set('twitter_enable', false);
         }
         // get active author
         $active_author = $this->activeAuthor();
         // filter author output
         JFilterOutput::objectHTMLSafe($active_author, ENT_QUOTES, array('app', 'application'));
         // get comment content from session
         $content = $this->app->system->session->get('com_zoo.comment.content');
         $params->set('content', $content);
         // get comments and build tree
         $approved = $item->canManageComments() ? Comment::STATE_UNAPPROVED : Comment::STATE_APPROVED;
         $comments = $item->getCommentTree($approved);
         // build captcha
         $captcha = false;
         if ($plugin = $params->get('captcha', false) and (!$params->get('captcha_guest_only', 0) or !$this->app->user->get()->id)) {
             $captcha = JCaptcha::getInstance($plugin);
         }
         // filter redirect url
         $view->set('redirect', htmlspecialchars(JUri::getInstance()->toString()));
         if ($item->isCommentsEnabled() || count($comments) - 1) {
             // create comments html
             return $view->partial('comments', compact('item', 'active_author', 'comments', 'params', 'captcha'));
         }
     }
     return null;
 }
Exemplo n.º 17
0
 /**
  * After a person replies a topic
  *
  * @since	1.3
  * @access	public
  * @param	string
  * @return
  */
 public function onAfterReply($message)
 {
     $length = JString::strlen($message->message);
     // Assign points for replying a thread
     if ($length > $this->params->get('activity_points_limit', 0)) {
         $this->assignPoints('thread.reply');
     }
     // Assign badge for replying to a thread
     if ($length > $this->params->get('activity_badge_limit', 0)) {
         $this->assignBadge('thread.reply', JText::_('PLG_KUNENA_EASYSOCIAL_BADGE_REPLY_TITLE'));
     }
     $stream = FD::stream();
     $tmpl = $stream->getTemplate();
     $tmpl->setActor($message->userid, SOCIAL_TYPE_USER);
     $tmpl->setContext($message->id, 'kunena');
     $tmpl->setVerb('reply');
     $tmpl->setAccess('core.view');
     // Add into stream
     $stream->add($tmpl);
     // Get a list of subscribers
     $recipients = $this->getSubscribers($message);
     if (!$recipients) {
         return;
     }
     $permalink = JUri::getInstance()->toString(array('scheme', 'host', 'port')) . $message->getPermaUrl(null);
     $options = array('uid' => $message->id, 'actor_id' => $message->userid, 'title' => '', 'type' => 'post', 'url' => $permalink, 'image' => '');
     // Add notifications in EasySocial
     FD::notify('post.reply', $recipients, array(), $options);
 }
Exemplo n.º 18
0
 public function display($tpl = null)
 {
     $this->version = new Itpmeta\Version();
     // Load Prism library version
     if (!class_exists("Prism\\Version")) {
         $this->prismVersion = JText::_("COM_ITPMETA_ITPRISM_LIBRARY_DOWNLOAD");
     } else {
         $prismVersion = new Prism\Version();
         $this->prismVersion = $prismVersion->getShortVersion();
         if (version_compare($this->prismVersion, $this->version->requiredPrismVersion, "<")) {
             $this->prismVersionLowerMessage = JText::_("COM_ITPMETA_PRISM_LIBRARY_LOWER_VERSION");
         }
     }
     $basic = new Itpmeta\Statistics\Basic(JFactory::getDbo());
     $this->totalUrls = $basic->getTotalUrls();
     $this->totalTags = $basic->getTotalTags();
     $this->totalGlobalTags = $basic->getTotalGlobalTags();
     // Get latest items.
     jimport("itpmeta.statistics.urls.latest");
     $this->latest = new Itpmeta\Statistics\Urls\Latest(JFactory::getDbo());
     $this->latest->load();
     // Get urls with scripts.
     jimport("itpmeta.statistics.urls.scripts");
     $this->urlsScripts = new Itpmeta\Statistics\Urls\Scripts(JFactory::getDbo());
     $this->urlsScripts->load(array("limit" => 10));
     $uri = JUri::getInstance();
     $this->domain = $uri->toString(array("scheme", "host"));
     // Add submenu
     ItpMetaHelper::addSubmenu($this->getName());
     $this->addToolbar();
     $this->addSidebar();
     $this->setDocument();
     parent::display($tpl);
 }
Exemplo n.º 19
0
 public function getInput()
 {
     $app = JFactory::getApplication();
     $heatmapforcecheck = JRequest::getInt('heatmapforcecheck', 0);
     if ($app->isAdmin() && $heatmapforcecheck) {
         $cache = JFactory::getCache();
         $result = $cache->clean('plg_system_heatmap:accountcheck');
         $refresh_uri = JUri::getInstance();
         $refresh_uri->delVar('heatmapforcecheck');
         $refresh_uri = $refresh_uri->toString();
         $app->redirect($refresh_uri);
     }
     $cache = JFactory::getCache('plg_system_heatmap:accountcheck');
     $cache->setCaching(true);
     $cache->setLifeTime(86400);
     //24h
     $domain = urlencode(JUri::root(false));
     //$accountCheck = HeatmapAccountChecker::check($domain);
     $accountCheck = $cache->call(array('HeatmapAccountChecker', 'check'), $domain);
     if ($accountCheck['valid']) {
         $msg .= '<span class="text-success">' . JText::_('PLG_HEATMAP_CHECK_ACCOUNT_VALID') . '</span>';
     } else {
         $msg .= '<span class="text-error">' . JText::_('PLG_HEATMAP_CHECK_ACCOUNT_NOT_FOUND') . '</span>';
     }
     $refresh_uri = JUri::getInstance();
     $refresh_uri->setVar('heatmapforcecheck', 1);
     $refresh_uri = $refresh_uri->toString();
     $msg .= '<br><a class="btn" href="' . $refresh_uri . '">' . JText::_('PLG_HEATMAP_CHECK_ACCOUNT') . '</a>';
     $lastcheck = isset($accountCheck['lastcheck']) ? $accountCheck['lastcheck'] : JText::_('PLG_HEATMAP_NEVER');
     $msg .= '<br>' . JText::_('PLG_HEATMAP_LAST_CHECK') . ' ' . $lastcheck;
     if (isset($accountCheck['error']) && $accountCheck['error']) {
         $msg .= '<br>' . JText::_('PLG_HEATMAP_ERROR_MSG') . ' <em>' . $accountCheck['error'] . '</em>';
     }
     return $msg;
 }
Exemplo n.º 20
0
 /**
  * route
  *
  * @return  void
  *
  * @throws \Exception
  */
 public static function quickRouting()
 {
     $app = \JFactory::getApplication();
     $input = $app->input;
     if ($app->isSite()) {
         $closure = function (\JRouterSite $router, \JUri $uri) use($input, $app) {
             $route = $uri->getPath();
             $route = trim($route, '/');
             // Admin
             if ($route == 'admin') {
                 $uri = \JUri::getInstance();
                 $target = new \JUri(\JUri::root() . 'administrator');
                 $target->setQuery($uri->getQuery());
                 $app->redirect($target);
             }
             return array();
         };
         $router = $app::getRouter();
         $router->attachParseRule($closure, JVERSION >= 3.4 ? $router::PROCESS_BEFORE : null);
     } else {
         if ($input->get('goezset') !== null) {
             $plugin = \JTable::getInstance('Extension');
             if ($plugin->load(array('name' => 'plg_system_ezset'))) {
                 $extId = $plugin->extension_id;
                 $app->redirect(\JRoute::_('index.php?option=com_plugins&task=plugin.edit&extension_id=' . $extId, false));
                 exit;
             }
         }
     }
 }
Exemplo n.º 21
0
 public function display($tpl = null)
 {
     $this->app = JFactory::getApplication();
     $this->option = JFactory::getApplication()->input->get('option');
     // Get model state.
     $this->state = $this->get('State');
     $this->item = $this->get('Item');
     // Get params
     $this->params = $this->state->get('params');
     /** @var  $this->params Joomla\Registry\Registry */
     $model = $this->getModel();
     $userId = JFactory::getUser()->get('id');
     if (!$this->item or $model->isRestricted($this->item, $userId)) {
         $this->app->enqueueMessage(JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'), 'notice');
         $this->app->redirect(JRoute::_('index.php?option=com_crowdfunding&view=discover', false));
         return;
     }
     $this->container = Prism\Container::getContainer();
     $this->prepareMoneyFormatter($this->container, $this->params);
     // Get the path to the images.
     $this->imageFolder = $this->params->get('images_directory', 'images/crowdfunding');
     $this->defaultAvatar = JUri::base() . $this->params->get('integration_avatars_default');
     $this->avatarsSize = $this->params->get('integration_avatars_size', 'small');
     // Prepare the link that points to project page.
     $host = JUri::getInstance()->toString(array('scheme', 'host'));
     $this->item->link = $host . JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($this->item->slug, $this->item->catslug));
     // Prepare the link that points to project image.
     $this->item->link_image = $host . '/' . $this->imageFolder . '/' . $this->item->image;
     // Get the current screen.
     $this->screen = $this->app->input->getCmd('screen', 'home');
     $this->prepareDocument();
     // Import content plugins
     JPluginHelper::importPlugin('content');
     switch ($this->screen) {
         case 'updates':
             $this->prepareUpdatesScreen();
             break;
         case 'comments':
             $this->prepareCommentsScreen();
             break;
         case 'funders':
             $this->prepareFundersScreen();
             break;
         default:
             // Home
             break;
     }
     // Events
     $dispatcher = JEventDispatcher::getInstance();
     $this->item->event = new stdClass();
     $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_crowdfunding.details', &$this->item, &$this->params));
     $this->item->event->beforeDisplayContent = trim(implode("\n", $results));
     $results = $dispatcher->trigger('onContentAfterDisplayMedia', array('com_crowdfunding.details', &$this->item, &$this->params));
     $this->item->event->onContentAfterDisplayMedia = trim(implode("\n", $results));
     $results = $dispatcher->trigger('onContentAfterDisplay', array('com_crowdfunding.details', &$this->item, &$this->params));
     $this->item->event->onContentAfterDisplay = trim(implode("\n", $results));
     // Count hits
     $model->hit($this->item->id);
     parent::display($tpl);
 }
Exemplo n.º 22
0
 /**
  * Detect is this page are frontpage?
  *
  * @return  boolean Is frontpage?
  */
 public static function isHome()
 {
     $langPath = null;
     $tag = null;
     $lang = \JFactory::getLanguage();
     // For multi language
     if (\JPluginHelper::isEnabled('system', 'languagefilter')) {
         $tag = $lang->getTag();
         $langCodes = \JLanguageHelper::getLanguages('lang_code');
         $langPath = $langCodes[$tag]->sef;
     }
     $uri = \JUri::getInstance();
     $root = $uri::root(true);
     // Get site route
     $route = StringHelper::substr($uri->getPath(), StringHelper::strlen($root));
     // Remove index.php
     $route = str_replace('index.php', '', $route);
     // If Multiple language enabled, we check first part of URI is language code or not.
     if ($langPath) {
         $params = ExtensionHelper::getParams('plg_system_languagefilter');
         if ($tag == $lang->getDefault() && $params->get('remove_default_prefix', 0)) {
             $langPath = '';
         }
         // If route equals lang path, means it is home route.
         if (trim($route, '/') == $langPath && !$uri->getVar('option')) {
             return true;
         }
     } else {
         if (!trim($route, '/') && !$uri->getVar('option')) {
             return true;
         }
     }
     return false;
 }
Exemplo n.º 23
0
 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 .= '&lt;br /&gt;';
     $overlib .= $date;
     $overlib .= '&lt;br /&gt;';
     $overlib .= htmlspecialchars($author, ENT_COMPAT, 'UTF-8');
     $button = JHtml::_('link', JRoute::_($url), $text);
     $output = '<span class="hasTooltip" title="' . JHtml::tooltipText('COM_WEBLINKS_EDIT') . ' :: ' . $overlib . '">' . $button . '</span>';
     return $output;
 }
Exemplo n.º 24
0
 /**
  * Get Uri
  *
  * @param   string  $url  URL
  *
  * @return  JUri
  */
 public function getUri($url = 'SERVER')
 {
     static $uriArray = array();
     if (!array_key_exists($url, $uriArray)) {
         // This will enable both SEF and non-SEF URI to be parsed properly
         $router = clone JRouter::getInstance('site');
         $uri = clone JUri::getInstance($url);
         $langCode = JLanguageHelper::detectLanguage();
         $lang = $uri->getVar('lang', $langCode);
         $uri->setVar('lang', $lang);
         $sefs = JLanguageHelper::getLanguages('lang_code');
         if (isset($sefs[$lang])) {
             $lang = $sefs[$lang]->sef;
             $uri->setVar('lang', $lang);
         }
         $router->setVars(array(), false);
         $query = $router->parse($uri);
         $query = array_merge($query, $uri->getQuery(true));
         $uri->setQuery($query);
         // We are removing format because of default value is csv if present and if not set
         // and we are never going to remember csv page in a browser history anyway
         $uri->delVar('format');
         $uriArray[$url] = $uri;
     }
     return $uriArray[$url];
 }
Exemplo n.º 25
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     // Get model state.
     $this->state = $this->get('State');
     $this->item = $this->get("Item");
     // Get params
     /** @var  $params Joomla\Registry\Registry */
     $params = $this->state->get("params");
     $this->params = $params;
     $model = $this->getModel();
     $userId = JFactory::getUser()->get("id");
     if (!$this->item or $model->isRestricted($this->item, $userId)) {
         $app->enqueueMessage(JText::_("COM_CROWDFUNDING_ERROR_INVALID_PROJECT"), "notice");
         $app->redirect(JRoute::_('index.php?option=com_crowdfunding&view=discover', false));
         return;
     }
     // Get rewards of the project
     $this->imageFolder = $this->params->get("images_directory", "images/crowdfunding");
     // Prepare the link that points to project page
     $host = JUri::getInstance()->toString(array("scheme", "host"));
     $this->item->link = $host . JRoute::_(CrowdFundingHelperRoute::getDetailsRoute($this->item->slug, $this->item->catslug));
     // Prepare the link that points to project image
     $this->item->link_image = $host . "/" . $this->imageFolder . "/" . $this->item->image;
     // Get the current screen
     $this->screen = $app->input->getCmd("screen", "home");
     $this->prepareDocument();
     // Import content plugins
     JPluginHelper::importPlugin('content');
     switch ($this->screen) {
         case "updates":
             $this->prepareUpdatesScreen();
             break;
         case "comments":
             $this->prepareCommentsScreen();
             break;
         case "funders":
             $this->prepareFundersScreen();
             break;
         default:
             // Home
             break;
     }
     // Events
     $dispatcher = JEventDispatcher::getInstance();
     $this->item->event = new stdClass();
     $offset = 0;
     $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_crowdfunding.details', &$this->item, &$this->params, $offset));
     $this->item->event->beforeDisplayContent = trim(implode("\n", $results));
     $results = $dispatcher->trigger('onContentAfterDisplayMedia', array('com_crowdfunding.details', &$this->item, &$this->params, $offset));
     $this->item->event->onContentAfterDisplayMedia = trim(implode("\n", $results));
     $results = $dispatcher->trigger('onContentAfterDisplay', array('com_crowdfunding.details', &$this->item, &$this->params, $offset));
     $this->item->event->onContentAfterDisplay = trim(implode("\n", $results));
     // Count hits
     $model->hit($this->item->id);
     $this->version = new CrowdFundingVersion();
     parent::display($tpl);
 }
Exemplo n.º 26
0
 /**
  * Tests the JHttp::connect method.
  *
  * @param   string  $url  The url to test.
  * @param   string  $key  The hash of the internally stored connection.
  *
  * @return  void
  *
  * @dataProvider  getTestConnectData
  * @since   11.3
  */
 public function testConnect($url, $key)
 {
     $http = new JHttpInspector();
     $res = $http->connect(JUri::getInstance($url));
     $this->assertThat($res, $this->equalTo($http->connections[$key]), 'Tests that the internally set connection is what was returned.');
     // We can't test a bad address because the connector throws a PHP error.
     $this->assertThat(is_resource($res), $this->isTrue(), 'Tests that the return value for a case that should connect is a resource.');
 }
Exemplo n.º 27
0
 /**
  * Constructor.
  *
  * @param   object  &$subject  The object to observe.
  * @param   array   $config    An optional associative array of configuration settings.
  *
  * @since   1.5
  */
 public function __construct(&$subject, $config)
 {
     parent::__construct($subject, $config);
     // Set the language in the class.
     $options = array('defaultgroup' => 'page', 'browsercache' => $this->params->get('browsercache', false), 'caching' => false);
     $this->_cache = JCache::getInstance('page', $options);
     $this->_cache_key = JUri::getInstance()->toString();
 }
Exemplo n.º 28
0
 /**
  * Get full current URL with simple optimization
  */
 public function getCurrentUrl()
 {
     static $url;
     if (!isset($url)) {
         $url = JUri::getInstance()->toString();
     }
     return $url;
 }
Exemplo n.º 29
0
 static function GetSefHrefLink($link, $name, $title = '', $rel = 'nofollow', $class = '', $anker = '', $attr = '')
 {
     $uri = $link instanceof JUri ? $link : JUri::getInstance($link);
     if ($anker) {
         $uri->setFragment($anker);
     }
     return JHtml::_('kunenaforum.link', $uri, $name, $title, $class, $rel, $attr);
 }
Exemplo n.º 30
0
 public function url(array $args = [])
 {
     $url = \JUri::getInstance();
     foreach ($args as $key => $val) {
         $url->setVar($key, $val);
     }
     return $url->toString();
 }