예제 #1
0
 /**
  * Method to get the field input markup.
  *
  * @return	string	The field input markup.
  * @since	1.6
  */
 protected function getInput()
 {
     $readonly = (string) $this->element['readonly'] == 'true' ? ' readonly="readonly"' : '';
     $class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
     $router = new JRouterSite(array('mode' => 1));
     $route = $router->build('index.php?option=com_slogin&task=check&plugin=' . (string) $this->element['value']);
     $CallbackUrl = JURI::root() . str_replace('/administrator/', '', $route);
     $html = '<input type="text" name="' . $this->name . '" id="' . $this->id . '"' . ' value="' . $CallbackUrl . '" size="70%" ' . $class . $readonly . ' />';
     return $html;
 }
예제 #2
0
 /**
  * Translates an internal Joomla URL to a humanly readable URL.
  *
  * @param   string   $url    Absolute or Relative URI to Joomla resource.
  * @param   boolean  $xhtml  Replace & by &amp; for XML compliance.
  * @param   integer  $ssl    Secure state for the resolved URI.
  *                             0: (default) No change, use the protocol currently used in the request
  *                             1: Make URI secure using global secure site URI.
  *                             2: Make URI unsecure using the global unsecure site URI.
  *
  * @return string The translated humanly readable URL.
  */
 public static function jroute($url, $xhtml = true, $ssl = null)
 {
     if (!static::$router) {
         static::$router = static::getRouter();
     }
     if (!is_array($url) && strpos($url, '&') !== 0 && strpos($url, 'index.php') !== 0) {
         return $url;
     }
     // Backup base with frontend root
     $base = TestHelper::getValue('JUri', 'base');
     TestHelper::setValue('JUri', 'base', TestHelper::getValue('JUri', 'root'));
     // Build route.
     /** @var Uri $uri */
     $uri = static::$router->build($url);
     // Restore base
     TestHelper::setValue('JUri', 'base', $base);
     $scheme = array('path', 'query', 'fragment');
     /*
      * Get the secure/unsecure URLs.
      *
      * If the first 5 characters of the BASE are 'https', then we are on an ssl connection over
      * https and need to set our secure URL to the current request URL, if not, and the scheme is
      * 'http', then we need to do a quick string manipulation to switch schemes.
      */
     if ((int) $ssl || $uri->isSSL()) {
         static $host_port;
         if (!is_array($host_port)) {
             $uri2 = \JUri::getInstance();
             $host_port = array($uri2->getHost(), $uri2->getPort());
         }
         // Determine which scheme we want.
         $uri->setScheme((int) $ssl === 1 || $uri->isSSL() ? 'https' : 'http');
         $uri->setHost($host_port[0]);
         $uri->setPort($host_port[1]);
         $scheme = array_merge($scheme, array('host', 'port', 'scheme'));
     }
     $url = $uri->toString($scheme);
     // Replace spaces.
     $url = preg_replace('/\\s/u', '%20', $url);
     if ($xhtml) {
         $url = htmlspecialchars($url);
     }
     return $url;
 }
예제 #3
0
 /**
  * convert from normal format to sef format
  *
  * @param unknown_type $matches
  * @return unknown
  */
 function convertUrl($originalPath, $pathonly = false)
 {
     jimport('joomla.application.router');
     // Get the router
     $router = new JRouterSite(array('mode' => JROUTER_MODE_SEF));
     // Make sure that we have our router
     if (!$router) {
         if ($pathonly) {
             return $originalPath;
         } else {
             return $this->getRootUrl() . $originalPath;
         }
     }
     // Build route
     $path = str_replace(JURI::root(true), '', $originalPath);
     $uri = $router->build($path);
     $path = $uri->toString(array('path', 'query', 'fragment'));
     if (!preg_match('/^\\/+/', $path)) {
         $path = "/{$path}";
     }
     //
     if ($pathonly) {
         return $path;
     } else {
         $url = $this->getRootUrl();
         return $url . $path;
     }
 }
예제 #4
0
 /**
  * Create Joomla SEF URLs
  *
  * @copyright
  * @author 		RolandD
  * @todo
  * @see 		http://www.joomla.org/
  * @see			_getSiteRoute()
  * @access 		private
  * @param 		string	$url	the original URL to turn into SEF
  * @return 		string SEF URL
  * @since 		3.0
  */
 private function _joomlaSef($url)
 {
     // Load Joomla core files for SEF
     jimport('joomla.application.router');
     require_once JPATH_ROOT . '/includes/application.php';
     require_once JPATH_ROOT . '/includes/router.php';
     $router = new JRouterSite(array('mode' => 1));
     $uri = $router->build($url);
     return $uri->toString();
 }
예제 #5
0
 /**
  * testBuild().
  *
  * @param   string  $url      The URL
  * @param   integer $mode     JROUTER_MODE_RAW or JROUTER_MODE_SEF
  * @param   array   $vars     An associative array with global variables
  * @param   array   $map      Valuemap for JApplication::get() Mock
  * @param   array   $server   Values for $_SERVER
  * @param   array   $expected Expected value
  *
  * @dataProvider casesBuild
  *
  * @return void
  * @testdox      Variables are transformed into proper URLs
  * @since        3.4
  */
 public function testBuild($url, $mode, $vars, $map, $server, $expected)
 {
     $_SERVER = array_merge($_SERVER, $server);
     $app = $this->getMockCmsApp();
     $app->expects($this->any())->method('get')->will($this->returnValueMap($map));
     $object = new JRouterSite(array(), $app, TestMockMenu::create($this));
     $object->setMode($mode);
     // Check the expected values
     $this->assertEquals($expected, (string) $object->build($url));
 }
예제 #6
0
// adding to com_awdwall
if(file_exists(JPATH_SITE . '/components/com_awdwall/awdwall.php'))
{
$websitename=$mainframe->getCfg('fromname');
$user 			= &JFactory::getUser($userId);
$db->setQuery('SELECT cat.id FROM #__categories cat RIGHT JOIN #__content cont ON cat.id = cont.catid WHERE cont.id='.$contentid);
$category_id = $db->loadResult();
$db->setQuery('SELECT alias FROM #__content WHERE id='.$contentid);
$alias = $db->loadResult();
//$articlelink='index.php?option=com_content&view=article&id='.$contentid.'&Itemid='.$ItemId;
// $url = ' '.JURI::root().ContentHelperRoute::getArticleRoute($article->id, $article->catid); 
//$articlelink=ContentHelperRoute::getArticleRoute($contentid, $category_id, 0);
$mode=$mainframe->getCfg('sef');
$newUrl = ContentHelperRoute::getArticleRoute($contentid.':'.$alias, $category_id);
$router = new JRouterSite(array('mode'=>$mode));
$newUrl = $router->build($newUrl)->toString(array('path', 'query', 'fragment'));
$newUrl = str_replace('/administrator/', '', $newUrl);
$newUrl = str_replace('component/content/article/', '', $newUrl);
$newUrl = str_replace('plugins/content/loadjomwall/', '', $newUrl);
$articlelink=$newUrl;

	$query 	= "SELECT title FROM #__content where id = " . (int)$contentid;
	$db->setQuery($query);
	$articletitle = $db->loadResult();
$message_wall=' '.JText::_('has comment on').' <a href="'.$articlelink.'" >'.$articletitle.'</a>&nbsp;'.JText::_('article').'<br>'.nl2br($message_wall);
	$query = "INSERT INTO #__awd_wall (user_id, type, commenter_id, message,wall_date) VALUES ('".intval($user->id)."','text', '".intval($user->id)."', '".nl2br($message_wall)."', '".time()."') ";
	$db->setQuery($query);			
	if (!@$db->query()) {
		$error = 1;
		$message = $db->stderr();
	}
예제 #7
0
 /**
  * Create Joomla SEF URLs
  *
  * In the backend, the languagefilter plugin is not triggered, so we need
  * to add our own language tag to the URL
  *
  * @copyright
  * @author 		RolandD
  * @todo
  * @see 		http://www.joomla.org/
  * @see			_getSiteRoute()
  * @access 		private
  * @param 		string	$url	the original URL to turn into SEF
  * @return 		string SEF URL
  * @since 		3.0
  */
 private function _joomlaSef($url)
 {
     $jinput = JFactory::getApplication()->input;
     $template = $jinput->get('template', null, null);
     // Load Joomla core files for SEF
     jimport('joomla.application.router');
     require_once JPATH_ROOT . '/includes/application.php';
     require_once JPATH_ROOT . '/includes/router.php';
     $router = new JRouterSite(array('mode' => 1));
     $uri = $router->build($url);
     // Add the language tag since we can't use the languagefilter
     $jconfig = JFactory::getConfig();
     $path = str_ireplace(JURI::root(true), '', $uri->getPath());
     $adminpos = strpos($path, '/administrator/');
     // Check if the language filter is being used
     if (JPluginHelper::isEnabled('system', 'languagefilter')) {
         if ($jconfig->get('sef_rewrite')) {
             // Using SEF Rewrite
             if ($adminpos !== false) {
                 $path = substr($template->get('language', 'general'), 0, 2) . '/' . substr($path, $adminpos + 15);
             }
         } else {
             //  Not using SEF Rewrite
             if ($adminpos !== false) {
                 $path = 'index.php/' . substr($template->get('language', 'general'), 0, 2) . '/' . substr($path, $adminpos + 24);
             }
         }
     } else {
         if ($adminpos !== false) {
             $path = substr($path, $adminpos + 15);
         }
     }
     $uri->setPath($path);
     return $uri->toString();
 }
예제 #8
0
 public static function getRoutedURL($url, $xhtml = false, $external = false)
 {
     if (!$external) {
         return DiscussRouter::_($url, $xhtml);
     }
     $mainframe = JFactory::getApplication();
     $uri = JURI::getInstance(JURI::base());
     //To fix 1.6 Jroute issue as it will include the administrator into the url path.
     $url = str_replace('/administrator/', '/', DiscussRouter::_($url, $xhtml));
     if ($mainframe->isAdmin() && DiscussRouter::isSefEnabled()) {
         if (DiscussHelper::getJoomlaVersion() >= '1.6') {
             JFactory::$application = JApplication::getInstance('site');
         }
         if (DiscussHelper::getJoomlaVersion() >= '3.0') {
             jimport('joomla.libraries.cms.router');
         } else {
             jimport('joomla.application.router');
             require_once JPATH_ROOT . '/includes/router.php';
             require_once JPATH_ROOT . '/includes/application.php';
         }
         $router = new JRouterSite(array('mode' => JROUTER_MODE_SEF));
         $urls = $router->build($url)->toString(array('path', 'query', 'fragment'));
         $urls = DISCUSS_JURIROOT . '/' . ltrim(str_replace('/administrator/', '/', $urls), '/');
         $container = explode('/', $urls);
         $container = array_unique($container);
         $urls = implode('/', $container);
         if (DiscussHelper::getJoomlaVersion() >= '1.6') {
             JFactory::$application = JApplication::getInstance('administrator');
         }
         return $urls;
     } else {
         $url = rtrim($uri->toString(array('scheme', 'host', 'port')), '/') . '/' . ltrim($url, '/');
         $url = str_replace('/administrator/', '/', $url);
         if (DiscussRouter::isSefEnabled()) {
             $container = explode('/', $url);
             $container = array_unique($container);
             $url = implode('/', $container);
         }
         return $url;
     }
 }