Пример #1
0
 /**
  * Returns all relevant articles for a FAQ record with the same language
  *
  * @param integer $record_id FAQ ID
  * @param string  $thema     FAQ title
  * 
  * @return string
  */
 public function getAllRelatedById($record_id, $article_name, $keywords)
 {
     global $sids;
     $relevantslisting = '';
     $begriffe = str_replace('-', ' ', $article_name) . $keywords;
     $search = PMF_Search_Factory::create($this->language, array('database' => PMF_Db::getType()));
     $i = $last_id = 0;
     $search->setDatabaseHandle($this->db)->setTable(SQLPREFIX . 'faqdata AS fd')->setResultColumns(array('fd.id AS id', 'fd.lang AS lang', 'fcr.category_id AS category_id', 'fd.thema AS thema', 'fd.content AS content'))->setJoinedTable(SQLPREFIX . 'faqcategoryrelations AS fcr')->setJoinedColumns(array('fd.id = fcr.record_id', 'fd.lang = fcr.record_lang'))->setConditions(array('fd.active' => "'yes'", 'fd.lang' => "'" . $this->language->getLanguage() . "'"))->setMatchingColumns(array('fd.thema', 'fd.content', 'fd.keywords'));
     $result = $search->search($begriffe);
     while (($row = $this->db->fetchObject($result)) && $i < PMF_Configuration::getInstance()->get('records.numberOfRelatedArticles')) {
         if ($row->id == $record_id || $row->id == $last_id) {
             continue;
         }
         $relevantslisting .= '' == $relevantslisting ? '<ul>' : '';
         $relevantslisting .= '<li>';
         $url = sprintf('%saction=artikel&amp;cat=%d&amp;id=%d&amp;artlang=%s', $sids, $row->category_id, $row->id, $row->lang);
         $oLink = new PMF_Link(PMF_Link::getSystemRelativeUri() . '?' . $url);
         $oLink->itemTitle = $row->thema;
         $oLink->text = $row->thema;
         $oLink->tooltip = $row->thema;
         $relevantslisting .= $oLink->toHtmlAnchor() . '</li>';
         $i++;
         $last_id = $row->id;
     }
     $relevantslisting .= $i > 0 ? '</ul>' : '';
     return '' == $relevantslisting ? '-' : $relevantslisting;
 }
Пример #2
0
 /**
  * Returns all relevant articles for a FAQ record with the same language
  *
  * @param integer $recordId FAQ ID
  * @param string  $question FAQ title
  * @param string  $keywords FAQ keywords
  *
  * @return array
  */
 public function getAllRelatedById($recordId, $question, $keywords)
 {
     $terms = str_replace('-', ' ', $question) . $keywords;
     $search = PMF_Search_Factory::create($this->_config, array('database' => PMF_Db::getType()));
     $search->setTable(PMF_Db::getTablePrefix() . 'faqdata AS fd')->setResultColumns(array('fd.id AS id', 'fd.lang AS lang', 'fcr.category_id AS category_id', 'fd.thema AS question', 'fd.content AS answer'))->setJoinedTable(PMF_Db::getTablePrefix() . 'faqcategoryrelations AS fcr')->setJoinedColumns(array('fd.id = fcr.record_id', 'fd.lang = fcr.record_lang'))->setConditions(array('fd.active' => "'yes'", 'fd.lang' => "'" . $this->_config->getLanguage()->getLanguage() . "'"))->setMatchingColumns(array('fd.thema', 'fd.content', 'fd.keywords'));
     $result = $search->search($terms);
     return $this->_config->getDb()->fetchAll($result);
 }
Пример #3
0
     }
 }
 if ($action == 'view' && is_null($searchterm)) {
     $faq->getAllRecords($orderby, null, $sortby);
     $laction = 'view';
     $internalSearch = '';
     foreach ($faq->faqRecords as $record) {
         if (!isset($numActiveByCat[$record['category_id']])) {
             $numActiveByCat[$record['category_id']] = 0;
         }
         $numActiveByCat[$record['category_id']] += $record['active'] == 'yes' ? 1 : 0;
     }
 } elseif ($action == "view" && !is_null($searchterm)) {
     $fdTable = SQLPREFIX . 'faqdata';
     $fcrTable = SQLPREFIX . 'faqcategoryrelations';
     $search = PMF_Search_Factory::create($Language, array('database' => PMF_Db::getType()));
     $search->setDatabaseHandle($db)->setTable($fdTable)->setResultColumns(array($fdTable . '.id AS id', $fdTable . '.lang AS lang', $fdTable . '.solution_id AS solution_id', $fcrTable . '.category_id AS category_id', $fdTable . '.sticky AS sticky', $fdTable . '.active AS active', $fdTable . '.thema AS thema', $fdTable . '.content AS content', $fdTable . '.datum AS date'))->setJoinedTable($fcrTable)->setJoinedColumns(array($fdTable . '.id = ' . $fcrTable . '.record_id', $fdTable . '.lang = ' . $fcrTable . '.record_lang'));
     if (is_numeric($searchterm)) {
         $search->setMatchingColumns(array($fdTable . '.solution_id'));
     } else {
         $search->setMatchingColumns(array($fdTable . '.thema', $fdTable . '.content', $fdTable . '.keywords'));
     }
     $result = $search->search($searchterm);
     // @todo add missing ordering!
     $laction = 'view';
     $internalSearch = '&amp;search=' . $searchterm;
     $wasSearch = true;
     while ($row = $db->fetchObject($result)) {
         if ($searchcat != 0 && $searchcat != (int) $row->category_id) {
             continue;
         }
Пример #4
0
 /**
  * The main search function for the full text search
  *
  * @param string  $searchTerm   Text/Number (solution id)
  * @param boolean $allLanguages true to search over all languages
  *
  * @return  array
  */
 public function search($searchTerm, $allLanguages = true)
 {
     $fdTable = PMF_Db::getTablePrefix() . 'faqdata';
     $fcrTable = PMF_Db::getTablePrefix() . 'faqcategoryrelations';
     $condition = array($fdTable . '.active' => "'yes'");
     $search = PMF_Search_Factory::create($this->_config, array('database' => PMF_Db::getType()));
     if (!is_null($this->getCategoryId()) && 0 < $this->getCategoryId()) {
         if ($this->getCategory() instanceof PMF_Category) {
             $children = $this->getCategory()->getChildNodes($this->getCategoryId());
             $selectedCategory = array($fcrTable . '.category_id' => array_merge((array) $this->getCategoryId(), $children));
         } else {
             $selectedCategory = array($fcrTable . '.category_id' => $this->getCategoryId());
         }
         $condition = array_merge($selectedCategory, $condition);
     }
     if (!$allLanguages && !is_numeric($searchTerm)) {
         $selectedLanguage = array($fdTable . '.lang' => "'" . $this->_config->getLanguage()->getLanguage() . "'");
         $condition = array_merge($selectedLanguage, $condition);
     }
     $search->setTable($fdTable)->setResultColumns(array($fdTable . '.id AS id', $fdTable . '.lang AS lang', $fdTable . '.solution_id AS solution_id', $fcrTable . '.category_id AS category_id', $fdTable . '.thema AS question', $fdTable . '.content AS answer'))->setJoinedTable($fcrTable)->setJoinedColumns(array($fdTable . '.id = ' . $fcrTable . '.record_id', $fdTable . '.lang = ' . $fcrTable . '.record_lang'))->setConditions($condition);
     if (is_numeric($searchTerm)) {
         $search->setMatchingColumns(array($fdTable . '.solution_id'));
     } else {
         $search->setMatchingColumns(array($fdTable . '.thema', $fdTable . '.content', $fdTable . '.keywords'));
     }
     $result = $search->search($searchTerm);
     if (!$this->_config->getDb()->numRows($result)) {
         return [];
     } else {
         return $this->_config->getDb()->fetchAll($result);
     }
 }
Пример #5
0
 /**
  * The main search function for the full text search
  *
  * @param string  $searchterm   Text/Number (solution id)
  * @param boolean $allLanguages true to search over all languages
  * 
  * @return  array
  */
 public function search($searchterm, $allLanguages = true)
 {
     $fdTable = SQLPREFIX . 'faqdata';
     $fcrTable = SQLPREFIX . 'faqcategoryrelations';
     $condition = array($fdTable . '.active' => "'yes'");
     $search = PMF_Search_Factory::create($this->language, array('database' => PMF_Db::getType()));
     // Search in all or one category?
     if (!is_null($this->categoryId) && 0 < $this->categoryId) {
         $selectedCategory = array($fcrTable . '.category_id' => $this->categoryId);
         $condition = array_merge($selectedCategory, $condition);
     }
     if (!$allLanguages && !is_numeric($searchterm)) {
         $selectedLanguage = array($fdTable . '.lang' => "'" . $this->language->getLanguage() . "'");
         $condition = array_merge($selectedLanguage, $condition);
     }
     $search->setDatabaseHandle($this->db)->setTable($fdTable)->setResultColumns(array($fdTable . '.id AS id', $fdTable . '.lang AS lang', $fdTable . '.solution_id AS solution_id', $fcrTable . '.category_id AS category_id', $fdTable . '.thema AS question', $fdTable . '.content AS answer'))->setJoinedTable($fcrTable)->setJoinedColumns(array($fdTable . '.id = ' . $fcrTable . '.record_id', $fdTable . '.lang = ' . $fcrTable . '.record_lang'))->setConditions($condition);
     if (is_numeric($searchterm)) {
         $search->setMatchingColumns(array($fdTable . '.solution_id'));
     } else {
         $search->setMatchingColumns(array($fdTable . '.thema', $fdTable . '.content', $fdTable . '.keywords'));
     }
     $result = $search->search($searchterm);
     if (!$this->db->num_rows($result)) {
         return array();
     } else {
         return $this->db->fetchAll($result);
     }
 }
             $numCommentsByCat[$catkey] += $numCommentsByFaq[$faqkey];
         }
     }
 }
 if (is_null($searchTerm)) {
     $faq->getAllRecords($orderBy, null, $sortBy);
     foreach ($faq->faqRecords as $record) {
         if (!isset($numActiveByCat[$record['category_id']])) {
             $numActiveByCat[$record['category_id']] = 0;
         }
         $numActiveByCat[$record['category_id']] += $record['active'] == 'yes' ? 1 : 0;
     }
 } else {
     $fdTable = PMF_Db::getTablePrefix() . 'faqdata';
     $fcrTable = PMF_Db::getTablePrefix() . 'faqcategoryrelations';
     $search = PMF_Search_Factory::create($faqConfig, array('database' => PMF_Db::getType()));
     $search->setTable($fdTable)->setResultColumns(array($fdTable . '.id AS id', $fdTable . '.lang AS lang', $fdTable . '.solution_id AS solution_id', $fcrTable . '.category_id AS category_id', $fdTable . '.sticky AS sticky', $fdTable . '.active AS active', $fdTable . '.thema AS thema', $fdTable . '.content AS content', $fdTable . '.datum AS date'))->setJoinedTable($fcrTable)->setJoinedColumns(array($fdTable . '.id = ' . $fcrTable . '.record_id', $fdTable . '.lang = ' . $fcrTable . '.record_lang'));
     if (is_numeric($searchTerm)) {
         $search->setMatchingColumns(array($fdTable . '.solution_id'));
     } else {
         $search->setMatchingColumns(array($fdTable . '.thema', $fdTable . '.content', $fdTable . '.keywords'));
     }
     $result = $search->search($searchTerm);
     $laction = 'view';
     $internalSearch = '&amp;search=' . $searchTerm;
     $wasSearch = true;
     $idsFound = array();
     $faqsFound = array();
     while ($row = $faqConfig->getDb()->fetchObject($result)) {
         if ($searchCat != 0 && $searchCat != (int) $row->category_id) {
             continue;