示例#1
0
 /**
  * Cache method to populate autocomplete options
  *
  * @param   plgFabrik_Element  $elementModel  element model
  * @param   string             $search        search string
  * @param   array              $opts          options, 'label' => field to use for label (db join)
  *
  * @since   3.0.7
  *
  * @return string  json encoded search results
  */
 public static function cacheAutoCompleteOptions($elementModel, $search, $opts = array())
 {
     $listModel = $elementModel->getListModel();
     $label = JArrayHelper::getValue($opts, 'label', '');
     $rows = $elementModel->filterValueList(true, '', $label);
     $v = addslashes(JRequest::getVar('value'));
     $start = count($rows) - 1;
     for ($i = $start; $i >= 0; $i--) {
         if (!preg_match("/{$v}(.*)/i", $rows[$i]->text)) {
             unset($rows[$i]);
         }
     }
     $rows = array_values($rows);
     echo json_encode($rows);
 }
示例#2
0
 /**
  * Cache method to populate autocomplete options
  *
  * @param   plgFabrik_Element  $elementModel  Element model
  * @param   string             $search        Search string
  * @param   array              $opts          Options, 'label' => field to use for label (db join)
  *
  * @since   3.0.7
  *
  * @return string  Json encoded search results
  */
 public static function cacheAutoCompleteOptions($elementModel, $search, $opts = array())
 {
     $app = JFactory::getApplication();
     $listModel = $elementModel->getListModel();
     $label = FArrayHelper::getValue($opts, 'label', '');
     $rows = $elementModel->filterValueList(true, '', $label);
     $v = $app->input->get('value', '', 'string');
     // Search for every word separately in the result rather than the single string (of multiple words)
     $regex = "/(?=.*" . implode(")(?=.*", array_filter(explode(" ", addslashes($v)))) . ").*/i";
     $start = count($rows) - 1;
     for ($i = $start; $i >= 0; $i--) {
         $rows[$i]->text = strip_tags($rows[$i]->text);
         // Check that search strings are not in the HTML we just stripped
         if (!preg_match($regex, $rows[$i]->text)) {
             unset($rows[$i]);
         }
     }
     $rows = array_values($rows);
     echo json_encode($rows);
 }
示例#3
0
 public function filterValueList($normal, $tableName = '', $label = '', $id = '', $incjoin = true)
 {
     $rows = parent::filterValueList($normal, $tableName, $label, $id, $incjoin);
     $this->unmergeFilterSplits($rows);
     $this->reapplyFilterLabels($rows);
     return $rows;
 }