Exemplo n.º 1
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];
 }