Пример #1
0
 /**
  * Get a collection of chronicles with same keywords
  * @param Array of String $keywords the keywords to search chronicle having one of them
  * @param int $numberOfChronicles number of maximum chronicle to get
  * @return Collection of chronicle
  */
 public function getChroniclesWithKeywords($keywords, $numberOfChronicles, $useCache = true)
 {
     try {
         $results = null;
         if ($useCache) {
             // Get cache key : sanitize keywords string and replace "-" by "_"
             $key = self::CHRONICLES_WITH_KEYWORDS . "_k_" . str_replace("-", "_", StringHelper::sanitize(implode("_", $keywords))) . "_m_" . $numberOfChronicles;
             $results = $this->getData($key);
         }
         if (!isset($results) || $results === false) {
             /* @var $dao ChronicleDao */
             $dao = $this->getDao();
             $criteria = array();
             // Add is_validated criteria
             $criteria["is_validated"] = array(false, "=", 1);
             // Add keywords criteria
             $criteria["keywords"] = array(false, "LIKE", $keywords);
             $orderBy = array("creation_date" => "DESC");
             $results = $dao->getList($criteria, $orderBy, $numberOfChronicles);
             if ($useCache) {
                 $this->setData($key, $results);
             }
         }
         return $results;
     } catch (\Exception $e) {
         $this->logException(get_class(), __FUNCTION__, $e);
     }
 }
Пример #2
0
 /**
  * Get detail page link for chronicle
  * @return string the detail page link
  */
 public function getDetailLink()
 {
     if ($this->getTitle()) {
         return HTTPHelper::Link("chronique/" . StringHelper::sanitize(StringHelper::cleanHTML($this->getTitle())) . "-" . $this->getId());
     } else {
         return HTTPHelper::Link("chronique/chronique-" . $this->getId());
     }
 }
Пример #3
0
 public function getLink()
 {
     $encodedTitle = StringHelper::sanitize($this->getTitle());
     return sprintf("livre/%s-%s", $encodedTitle, $this->getId());
 }