Exemplo n.º 1
0
 /**
  * Retrieves alias for the category
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function getAlias()
 {
     $config = EB::config();
     $alias = $this->alias;
     if ($config->get('main_sef_unicode') || !EBR::isSefEnabled()) {
         $alias = $this->id . ':' . $this->alias;
     }
     return $alias;
 }
Exemplo n.º 2
0
 /**
  * Retrieves the external url
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public static function getRoutedURL($url, $xhtml = false, $external = false, $isCanonical = false)
 {
     // If this is not an external link, just pass it to joomla's router
     if (!$external) {
         return EBR::_($url, $xhtml, null, false, $isCanonical);
     }
     $app = JFactory::getApplication();
     $uri = JURI::getInstance();
     $dashboard = false;
     // Check if the current menu view is pointing to the dashboard view
     if (!$app->isAdmin()) {
         $menu = JFactory::getApplication()->getMenu()->getActive();
         if (isset($menu->link) && $menu->link) {
             $pos = strpos($menu->link, 'view=dashboard');
             if ($pos !== false) {
                 $dashboard = true;
             }
         }
     }
     // Address issues with JRoute as it will include the /administrator/ portion in the url if this link
     // is being generated from the back end.
     if ($app->isAdmin() && EBR::isSefEnabled()) {
         $oriURL = $url;
         // We need to render our own router file.
         require_once JPATH_ROOT . '/components/com_easyblog/router.php';
         if (!EB::isJoomla30()) {
             // below is required for joomla 2.5
             require_once JPATH_ROOT . '/includes/router.php';
             require_once JPATH_ROOT . '/includes/application.php';
         }
         // Here we are tricking Joomla to assume that we are on the front end now.
         JFactory::$application = JApplication::getInstance('site');
         $router = new JRouterSite(array('mode' => JROUTER_MODE_SEF));
         $url = str_replace('/administrator', '/', EBR::_($oriURL, $xhtml, null, $dashboard, $isCanonical));
         $url = rtrim(JURI::root(), '/') . '/' . ltrim(str_replace('/administrator/', '/', $url), '/');
         $container = explode('/', $url);
         $container = array_unique($container);
         $url = implode('/', $container);
         // Update the "application" back so that it knows it's in the administrator area.
         JFactory::$application = JApplication::getInstance('administrator');
         return $url;
     }
     $url = EBR::_($url, $xhtml, null, $dashboard, $isCanonical);
     $url = str_replace('/administrator/', '/', $url);
     $url = ltrim($url, '/');
     // var_dump($url);
     // We need to use $uri->toString() because JURI::root() may contain a subfolder which will be duplicated
     // since $url already has the subfolder.
     return $uri->toString(array('scheme', 'host', 'port')) . '/' . $url;
 }
Exemplo n.º 3
0
 /**
  * Retrieves the alias for this author
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function getAlias()
 {
     static $permalinks = array();
     if (!isset($permalinks[$this->id])) {
         $config = EB::config();
         if (!$this->user && $this->id) {
             $this->user = JFactory::getuser($this->id);
         }
         // If the username is invalid
         if (!$this->user->username) {
             return JText::_('COM_EASYBLOG_INVALID_PERMALINK_BLOGGER');
         }
         // If user doesn't have a permalink, generate it for them
         if (!$this->permalink) {
             $this->permalink = EBR::normalizePermalink($this->user->username);
             $this->store();
         }
         $permalink = $this->permalink;
         if ($config->get('main_sef_unicode') || !EBR::isSefEnabled()) {
             $permalink = $this->id . '-' . $this->permalink;
         }
         $permalinks[$this->id] = $permalink;
     }
     return $permalinks[$this->id];
 }
Exemplo n.º 4
0
 /**
  * Retrieves the print link for a post
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function getPrintLink()
 {
     $url = 'index.php?option=com_easyblog&view=entry&id=' . $this->id;
     $url = EBR::_($url, false);
     if (EBR::isSefEnabled()) {
         $url .= '?tmpl=component&print=1&format=print';
     } else {
         $url .= '&tmpl=component&print=1&format=print';
     }
     return $url;
 }
Exemplo n.º 5
0
 /**
  * Retrieves the alias of a post
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function getAlias()
 {
     static $permalinks = array();
     if (!isset($permalinks[$this->id])) {
         $date = EB::date($this->created);
         // Default permalink
         $permalink = $this->permalink;
         // Ensure that the permalink is valid.
         $permalink = EBR::normalizePermalink($permalink);
         if ($this->config->get('main_sef_unicode') || !EBR::isSefEnabled()) {
             $permalink = $this->id . '-' . $permalink;
         }
         // Date based permalink
         $datePermalink = $date->format('Y') . '/' . $date->format('m') . '/' . $date->format('d');
         // Date based SEF settings
         if ($this->config->get('main_sef') == 'date') {
             $permalink = $datePermalink . '/' . $permalink;
         }
         // Category based permalink type
         if ($this->config->get('main_sef') == 'datecategory' || $this->config->get('main_sef') == 'category') {
             // Get the current primary category
             $category = $this->getPrimaryCategory();
             $categoryPermalink = $category->getAlias();
             // Date and category based permalink type
             if ($this->config->get('main_sef') == 'datecategory') {
                 $permalink = $categoryPermalink . '/' . $datePermalink . '/' . $permalink;
             } else {
                 $permalink = $categoryPermalink . '/' . $permalink;
             }
         }
         // Custom based permalink type
         if ($this->config->get('main_sef') == 'custom') {
             $permalink = EBR::getCustomPermalink($this);
         }
         $permalinks[$this->id] = $permalink;
     }
     return $permalinks[$this->id];
 }