本文整理汇总了PHP中plgFabrik_Element::getListModel方法的典型用法代码示例。如果您正苦于以下问题:PHP plgFabrik_Element::getListModel方法的具体用法?PHP plgFabrik_Element::getListModel怎么用?PHP plgFabrik_Element::getListModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plgFabrik_Element
的用法示例。
在下文中一共展示了plgFabrik_Element::getListModel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cacheAutoCompleteOptions
/**
* 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);
}
示例2: cacheAutoCompleteOptions
/**
* 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);
}
示例3: cacheAutoCompleteOptions
/**
* Cache method to populate auto-complete 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();
$table = $listModel->getTable();
$db = $listModel->getDb();
$name = $elementModel->getFullName(false, false);
$query = $db->getQuery(true);
$params = $elementModel->getParams();
$format = $params->get('date_table_format');
$elementModel->strftimeTFormatToMySQL($format);
$search = $db->quote('%' . addslashes($search) . '%');
$query->select('DISTINCT(' . $name . ') AS value, ' . $name . ' AS text')->from($table->db_table_name)->where($name . ' LIKE ' . $search . ' OR DATE_FORMAT(' . $name . ', "' . $format . '" ) LIKE ' . $search);
$db->setQuery($query);
$tmp = $db->loadObjectList();
$ddData = array();
foreach ($tmp as &$t) {
$elementModel->toLabel($t->text);
if (!array_key_exists($t->text, $ddData)) {
$ddData[$t->text] = $t;
}
}
$ddData = array_values($ddData);
echo json_encode($ddData);
}
示例4: cacheAutoCompleteOptions
/**
* Cache method to populate autocomplete options
*
* @param plgFabrik_Element $elementModel element model
* @param string $search serch string
*
* @since 3.0.7
*
* @return string json encoded search results
*/
public static function cacheAutoCompleteOptions($elementModel, $search)
{
$name = $elementModel->getFullName(false, false, false);
$elementModel->encryptFieldName($name);
$listModel = $elementModel->getListModel();
$db = $listModel->getDb();
$query = $db->getQuery(true);
$tableName = $listModel->getTable()->db_table_name;
$query->select('DISTINCT(' . $name . ') AS value, ' . $name . ' AS text')->from($tableName);
$query->where($name . ' LIKE ' . $db->quote(addslashes('%' . $search . '%')));
$query = $listModel->_buildQueryJoin($query);
$query = $listModel->_buildQueryWhere(false, $query);
$query = $listModel->pluginQuery($query);
$db->setQuery($query);
$tmp = $db->loadObjectList();
foreach ($tmp as &$t) {
$elementModel->toLabel($t->text);
}
return json_encode($tmp);
}