public static function indexationSearch($searchParams)
 {
     Zend_Search_Lucene::setDefaultSearchField('contents');
     $directory = Zend_Registry::get('lucene_index');
     $index = new Zend_Search_Lucene($directory);
     $words = strtolower(Cible_FunctionsGeneral::removeAccents(Cible_FunctionsGeneral::html2text(utf8_decode($searchParams['words']))));
     $wordsArray = explode(' ', $words);
     if (count($wordsArray) > 1) {
         $query = new Zend_Search_Lucene_Search_Query_Phrase($wordsArray);
     } else {
         if (strlen($words) >= 3) {
             $pattern = new Zend_Search_Lucene_Index_Term("{$words}*");
             $query = new Zend_Search_Lucene_Search_Query_Wildcard($pattern);
         } else {
             $term = new Zend_Search_Lucene_Index_Term($words);
             $query = new Zend_Search_Lucene_Search_Query_Term($term);
         }
     }
     $hits = $index->find($query);
     //echo($query);
     $i = 0;
     $result = array();
     foreach ($hits as $hit) {
         $result[$i]['moduleID'] = $hit->moduleID;
         $result[$i]['pageID'] = $hit->pageID;
         $result[$i]['contentID'] = $hit->contentID;
         $result[$i]['languageID'] = $hit->languageID;
         $result[$i]['title'] = $hit->title;
         $result[$i]['text'] = $hit->text;
         $result[$i]['link'] = $hit->link;
         $i++;
     }
     return $result;
 }
Beispiel #2
0
 protected function generateList($tree, $level = 1)
 {
     $content = '';
     foreach ($tree as $object) {
         $link = !empty($object['Link']) ? $object['Link'] : 'javascript:void(0);';
         $tmp = '';
         $title = $this->_stripHtml ? Cible_FunctionsGeneral::html2text($object['Title']) : $object['Title'];
         $tmp .= "<a id='menuTitle_{$object['ID']}' href='{$link}'>{$title}</a>";
         if (!empty($object['child'])) {
             $tmp .= "<ul class='{$this->_class}'>";
             $tmp .= $this->generateList($object['child'], $level + 1);
             $tmp .= '</ul>';
         }
         $attr['liClass'] = !empty($this->_customLiClass) ? $this->_customLiClass : '';
         if ($object['Placeholder'] == 2 && $level > 1) {
             $this->_showActions = false;
         } else {
             $this->_showActions = true;
         }
         $content .= str_replace(array('%OBJECT_ID%', '%LI_CLASS%'), array($object['ID'], $attr['liClass']), $this->_li_template) . $tmp . $this->showActions($object['ID']) . "</li>";
     }
     return $content;
 }
Beispiel #3
0
 /**
  * Truncate a string to the max number of characters given and allows to
  * associate a class for the three final dots.
  *
  * @param string $string The string to truncate
  * @param int    $max    <OPTIONAL> Default = 150. Limit to cut the string.
  * @param array  $option <OPTIONAL> Array for parameters (ie class attrib).
  *
  * @return string $string The formatted string
  */
 public static function truncateString($string, $max = 150, $option = array())
 {
     $string = Cible_FunctionsGeneral::html2text($string);
     if (strlen($string) > $max) {
         $string = substr($string, 0, $max);
         $i = strrpos($string, " ");
         $string = substr($string, 0, $i);
         $dot = "...";
         if (!empty($option["dotStyle"])) {
             $dot = "<span class='" . $option["dotStyle"] . "'>...</span>";
         }
         $string = $string . $dot;
     }
     return $string;
 }
Beispiel #4
0
 public function editInfoAction()
 {
     // web page title
     $this->view->title = "Modification d'une infolettre";
     if ($this->view->aclIsAllowed('newsletter', 'manage', true)) {
         // variables
         $pageID = $this->_getParam('pageID');
         $blockID = $this->_getParam('blockID');
         $newsletterID = $this->_getParam('newsletterID');
         $baseDir = $this->view->baseUrl();
         $newsletterSelect = new NewsletterReleases();
         $select = $newsletterSelect->select();
         $select->where('NR_ID = ?', $newsletterID);
         $newsletterData = $newsletterSelect->fetchRow($select);
         // generate the form
         $cancelUrl = "/newsletter/index/edit/blockID/{$blockID}/pageID/{$pageID}/newsletterID/{$newsletterID}";
         $form = new FormNewsletter(array('baseDir' => $baseDir, 'cancelUrl' => $baseDir . $cancelUrl));
         if ($this->_request->isPost()) {
             $formData = $this->_request->getPost();
             if ($form->isValid($formData)) {
                 $newsletterData['NR_LanguageID'] = $form->getValue('NR_LanguageID');
                 $newsletterData['NR_CategoryID'] = $form->getValue('NR_CategoryID');
                 $newsletterData['NR_ModelID'] = $form->getValue('NR_ModelID');
                 $newsletterData['NR_Title'] = $form->getValue('NR_Title');
                 $newsletterData['NR_AdminEmail'] = $form->getValue('NR_AdminEmail');
                 $newsletterData['NR_ValUrl'] = Cible_FunctionsGeneral::formatValueForUrl($form->getValue('NR_Title'));
                 $newsletterData['NR_Date'] = $form->getValue('NR_Date');
                 $newsletterData['NR_TextIntro'] = $form->getValue('NR_TextIntro');
                 $newsletterData['NR_Online'] = $formData['NR_Online'] == 0 ? 2 : 1;
                 $newsletterData['NR_AfficherTitre'] = $form->getValue('NR_AfficherTitre');
                 $newsletterData->save();
                 $blockData = Cible_FunctionsBlocks::getBlockDetails($blockID);
                 $status = $blockData['B_Online'];
                 if ($newsletterData['NR_Online'] == 1 && $status == 1 || $newsletterData['NR_Online'] == 0) {
                     // get all article in the release
                     $articlesSelect = new NewsletterArticles();
                     $select = $articlesSelect->select()->where('NA_ReleaseID = ?', $newsletterID);
                     $articlesData = $articlesSelect->fetchAll($select);
                     $indexData['pageID'] = $pageID;
                     $indexData['moduleID'] = 8;
                     $indexData['languageID'] = $newsletterData['NR_LanguageID'];
                     foreach ($articlesData as $article) {
                         $indexData['contentID'] = $article['NA_ID'];
                         if ($newsletterData['NR_Online'] == 1) {
                             $indexData['title'] = $article['NA_Title'];
                             $indexData['text'] = Cible_FunctionsGeneral::stripTextWords(Cible_FunctionsGeneral::html2text($article['NA_Resume']));
                             $indexData['link'] = '';
                             $indexData['contents'] = Cible_FunctionsGeneral::html2text($article['NA_Resume'] . "<br/>" . $article['NA_Text']);
                             $indexData['action'] = 'update';
                         } elseif ($newsletterData['NR_Online'] == 0) {
                             $indexData['action'] = 'delete';
                         }
                         Cible_FunctionsIndexation::indexation($indexData);
                     }
                 }
             }
             $this->_redirect($cancelUrl);
         } else {
             $data = $newsletterData->toArray();
             if ($data['NR_Online'] == 2) {
                 $data['NR_Online'] = 0;
             }
             $form->populate($data);
             $this->view->form = $form;
         }
     }
 }