/**
  * @see parent::getAutocompleteList()
  */
 function getAutocompleteList($keywords, $where = null, $limit = null, $ljoin = null, $order = null)
 {
     /** @var self[] $list */
     $list = $this->loadList($where, null, null, null, $ljoin);
     $real_list = array();
     $re = preg_quote($keywords);
     $re = CMbString::allowDiacriticsInRegexp($re);
     $re = str_replace("/", "\\/", $re);
     $re = "/({$re})/i";
     foreach ($list as $_ex_field) {
         if ($keywords == "%" || $keywords == "" || preg_match($re, $_ex_field->_view)) {
             $_ex_field->updateTranslation();
             $_group = $_ex_field->loadRefExGroup();
             $_ex_field->_view = "{$_group->_view} - {$_ex_field->_view}";
             $real_list[$_ex_field->_id] = $_ex_field;
         }
     }
     return $real_list;
 }
 function getAutocompleteList($keywords, $where = null, $limit = null, $ljoin = null, $order = null)
 {
     $list = $this->loadList($where, null, null, null, $ljoin);
     /** @var self[] $real_list */
     $real_list = array();
     $re = preg_quote($keywords);
     $re = CMbString::allowDiacriticsInRegexp($re);
     $re = str_replace("/", "\\/", $re);
     $re = "/({$re})/i";
     foreach ($list as $_match) {
         if ($keywords == "%" || $keywords == "" || preg_match($re, $_match->_view)) {
             $_match->loadView();
             $real_list[$_match->_id] = $_match;
         }
     }
     $views = CMbArray::pluck($real_list, "_view");
     array_multisort($views, $real_list);
     $empty = new self();
     $empty->_id = null;
     $empty->_guid = "{$this->_class}-{$this->_id}";
     // FIXME
     $empty->_view = " -- ";
     array_unshift($real_list, $empty);
     return $real_list;
 }
 * @package    Mediboard
 * @subpackage forms
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 17759 $
 */
CCanDo::checkEdit();
$ex_class_event_id = CValue::get("ex_class_event_id");
$keywords = CValue::get("_host_field_view");
$ex_class_event = new CExClassEvent();
$ex_class_event->load($ex_class_event_id);
$list = $ex_class_event->buildHostFieldsList();
$show_views = false;
// filtrage
if ($keywords) {
    $show_views = true;
    $re = preg_quote($keywords);
    $re = CMbString::allowDiacriticsInRegexp($re);
    $re = str_replace("/", "\\/", $re);
    $re = "/({$re})/i";
    foreach ($list as $_key => $element) {
        if (!preg_match($re, $element["title"])) {
            unset($list[$_key]);
        }
    }
}
$smarty = new CSmartyDP();
$smarty->assign("ex_class_event", $ex_class_event);
$smarty->assign("host_fields", $list);
$smarty->assign("show_views", $show_views);
$smarty->display("inc_autocomplete_hostfields.tpl");
Ejemplo n.º 4
0
 /**
  * Emphasize a text, putting <em> nodes around found tokens
  * Example:  {$text|emphasize:$tokens}
  *
  * @param string       $text   The text subject
  * @param array|string $tokens The string tokens to emphasize, space seperated if string
  * @param string       $tag    The HTML tag to use to emphasize
  *
  * @return string
  */
 function emphasize($text, $tokens, $tag = "em")
 {
     if (!is_array($tokens)) {
         $tokens = explode(" ", $tokens);
     }
     CMbArray::removeValue("", $tokens);
     if (count($tokens) == 0) {
         return $text;
     }
     foreach ($tokens as &$token) {
         $token = preg_quote($token);
         $token = CMbString::allowDiacriticsInRegexp($token);
     }
     $regexp = str_replace("/", "\\/", implode("|", $tokens));
     return preg_replace("/({$regexp})/i", "<{$tag}>\$1</{$tag}>", $text);
 }