本文整理匯總了PHP中FabrikHelperHTML::autoComplete方法的典型用法代碼示例。如果您正苦於以下問題:PHP FabrikHelperHTML::autoComplete方法的具體用法?PHP FabrikHelperHTML::autoComplete怎麽用?PHP FabrikHelperHTML::autoComplete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類FabrikHelperHTML
的用法示例。
在下文中一共展示了FabrikHelperHTML::autoComplete方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: elementJavascript
/**
* Returns javascript which creates an instance of the class defined in formJavascriptClass()
*
* @param int $repeatCounter repeat group counter
*
* @return string
*/
public function elementJavascript($repeatCounter)
{
$app = JFactory::getApplication();
$input = $app->input;
$id = $this->getHTMLId($repeatCounter);
$params = $this->getParams();
if ($params->get('cdd_display_type') == 'auto-complete') {
FabrikHelperHTML::autoComplete($id, $this->getElement()->id, 'fabrikcascadingdropdown');
}
FabrikHelperHTML::script('media/com_fabrik/js/lib/Event.mock.js');
$opts = $this->getElementJSOptions($repeatCounter);
$opts->showPleaseSelect = $this->showPleaseSelect();
$opts->watch = $this->_getWatchId($repeatCounter);
$opts->id = $this->_id;
// This bizarre chunk of code handles the case of setting a CDD value on the QS on a new form
$rowid = $input->getInt('rowid', 0);
$fullName = $this->getFullName(false, true, true);
$watchName = $this->getWatchFullName();
$qsValue = $input->get($fullName, '');
$qsWatchValue = $input->get($watchName, '');
// $$$ hugh - Rob, is there a better way of finding out if validation has failed than looking at _arErrors?
$opts->def = empty($this->getFormModel()->_arErrors) && $this->isEditable() && $rowid == 0 && !empty($qsValue) && !empty($qsWatchValue) ? $qsValue : $this->getValue(array(), $repeatCounter);
// $$$ hugh - for reasons utterly beyond me, after failed validation, getValue() is returning an array.
if (is_array($opts->def)) {
$opts->def = $opts->def[0];
}
$watchGroup = $this->getWatchElement()->getGroup()->getGroup();
$group = $this->getGroup()->getGroup();
$opts->watchInSameGroup = $watchGroup->id === $group->id;
$opts->editing = $this->isEditable() && JRequest::getInt('rowid', 0) != 0;
$opts->showDesc = $params->get('cdd_desc_column', '') === '' ? false : true;
$opts = json_encode($opts);
return "new FbCascadingdropdown('{$id}', {$opts})";
}
示例2: elementJavascript
/**
* Returns javascript which creates an instance of the class defined in formJavascriptClass()
*
* @param int $repeatCounter Repeat group counter
*
* @return array
*/
public function elementJavascript($repeatCounter)
{
$input = $this->app->input;
$id = $this->getHTMLId($repeatCounter);
$params = $this->getParams();
if ($this->getDisplayType() === 'auto-complete') {
$autoOpts = array();
$autoOpts['observerid'] = $this->getWatchId($repeatCounter);
$autoOpts['formRef'] = $this->getFormModel()->jsKey();
$autoOpts['storeMatchedResultsOnly'] = true;
FabrikHelperHTML::autoComplete($id, $this->getElement()->id, $this->getFormModel()->getId(), 'cascadingdropdown', $autoOpts);
}
$opts = $this->getElementJSOptions($repeatCounter);
$opts->showPleaseSelect = $this->showPleaseSelect();
$opts->watch = $this->getWatchId($repeatCounter);
$watchElementModel = $this->getWatchElement();
$opts->watchChangeEvent = $watchElementModel->getChangeEvent();
$opts->displayType = $params->get('cdd_display_type', 'dropdown');
$opts->id = $this->getId();
$opts->listName = $this->getListModel()->getTable()->db_table_name;
$opts->lang = FabrikWorker::getMultiLangURLCode();
// This bizarre chunk of code handles the case of setting a CDD value on the QS on a new form
$rowId = $input->get('rowid', '', 'string');
$fullName = $this->getFullName();
$watchName = $this->getWatchFullName();
// If returning from failed posted validation data can be in an array
$qsValue = $input->get($fullName, array(), 'array');
$qsValue = FArrayHelper::getValue($qsValue, 0, null);
$qsWatchValue = $input->get($watchName, array(), 'array');
$qsWatchValue = FArrayHelper::getValue($qsWatchValue, 0, null);
$useQsValue = $this->getFormModel()->hasErrors() && $this->isEditable() && $rowId === '' && !empty($qsValue) && !empty($qsWatchValue);
$opts->def = $useQsValue ? $qsValue : $this->getValue(array(), $repeatCounter);
// $$$ hugh - for reasons utterly beyond me, after failed validation, getValue() is returning an array.
if (is_array($opts->def) && !empty($opts->def)) {
$opts->def = $opts->def[0];
}
$watchGroup = $this->getWatchElement()->getGroup()->getGroup();
$group = $this->getGroup()->getGroup();
$opts->watchInSameGroup = $watchGroup->id === $group->id;
$opts->editing = $this->isEditable() && $rowId !== '';
$opts->showDesc = $params->get('cdd_desc_column', '') === '' ? false : true;
$opts->advanced = $this->getAdvancedSelectClass() != '';
$formId = $this->getFormModel()->getId();
$opts->autoCompleteOpts = $opts->displayType == 'auto-complete' ? FabrikHelperHTML::autoCompleteOptions($opts->id, $this->getElement()->id, $formId, 'cascadingdropdown') : null;
$this->elementJavascriptJoinOpts($opts);
$data = $this->getFormModel()->data;
// Was otherwise using the none-raw value.
$opts->value = $this->getValue($data, $repeatCounter, array('raw' => true));
$opts->optsPerRow = (int) $params->get('dbjoin_options_per_row', 1);
if (is_array($opts->value) && count($opts->value) > 0) {
$opts->value = ArrayHelper::getValue($opts->value, 0);
}
return array('FbCascadingdropdown', $id, $opts);
}
示例3: elementJavascript
/**
* return tehe javascript to create an instance of the class defined in formJavascriptClass
* @return string javascript to create instance. Instance name must be 'el'
*/
function elementJavascript($repeatCounter)
{
$id = $this->getHTMLId($repeatCounter);
$params = $this->getParams();
if ($params->get('cdd_display_type') == 'auto-complete') {
FabrikHelperHTML::autoComplete($id, $this->getElement()->id, 'fabrikcascadingdropdown');
}
FabrikHelperHTML::script('media/com_fabrik/js/lib/Event.mock.js');
$opts = $this->getElementJSOptions($repeatCounter);
$opts->showPleaseSelect = $params->get('cascadingdropdown_showpleaseselect', true);
$opts->watch = $this->_getWatchId($repeatCounter);
$opts->id = $this->_id;
$opts->def = $this->getValue(array(), $repeatCounter);
$watchGroup = $this->_getWatchElement()->getGroup()->getGroup();
$group = $this->getGroup()->getGroup();
$opts->watchInSameGroup = $watchGroup->id === $group->id;
$opts->editing = ($this->_editable && JRequest::getInt('rowid', 0) != 0) ? '1' : '0';
$opts->showDesc = $params->get('cdd_desc_column') === '' ? false : true;
$opts = json_encode($opts);
return "new FbCascadingdropdown('$id', $opts)";
}
示例4: elementJavascript
/**
* return tehe javascript to create an instance of the class defined in formJavascriptClass
* @return string javascript to create instance. Instance name must be 'el'
*/
function elementJavascript($repeatCounter)
{
$id = $this->getHTMLId($repeatCounter);
$params =& $this->getParams();
if ($params->get('cdd_display_type') == 'auto-complete') {
FabrikHelperHTML::autoComplete($id, $this->getElement()->id, 'fabrikcascadingdropdown');
}
$opts =& $this->getElementJSOptions($repeatCounter);
$opts->showPleaseSelect = $params->get('cascadingdropdown_showpleaseselect', true);
$opts->watch = $this->_getWatchId($repeatCounter);
$opts->id = $this->_id;
$opts->liveSite = COM_FABRIK_LIVESITE;
$opts->def = $this->getValue(array(), $repeatCounter);
$watchGroup = $this->_getWatchElement()->getGroup()->getGroup();
$group = $this->getGroup()->getGroup();
$opts->watchInSameGroup = $watchGroup->id === $group->id;
$opts->editing = $this->_editable && JRequest::getInt('rowid', 0) != 0 ? '1' : '0';
$opts->showDesc = $params->get('cdd_desc_column') === '' ? false : true;
$opts->lang = FabrikWorker::getJoomfishLang();
$opts = json_encode($opts);
return "new fbCascadingdropdown('{$id}', {$opts})";
}
示例5: getFilter
/**
* Get the table filter for the element
* @param bol do we render as a normal filter or as an advanced searc filter
* if normal include the hidden fields as well (default true, use false for advanced filter rendering)
* @return string filter html
*/
function getFilter($counter = 0, $normal = true)
{
$listModel =& $this->getlistModel();
$formModel =& $listModel->getFormModel();
$elName2 = $this->getFullName(false, false, false);
if (!$formModel->hasElement($elName2)) {
return '';
}
$table =& $listModel->getTable();
$element = $this->getElement();
$params =& $this->getParams();
$elName = $this->getFullName(false, true, false);
$htmlid = $this->getHTMLId() . 'value';
$v = 'fabrik___filter[list_' . $table->id . '][value]';
$v .= $normal ? '[' . $counter . ']' : '[]';
//corect default got
$default = $this->getDefaultFilterVal($normal, $counter);
$tabletype = $params->get('my_table_data', 'username');
$join =& $this->getJoin();
$joinTableName = FabrikString::safeColName($join->table_join_alias);
// if filter type isn't set was blowing up in switch below 'cos no $rows
// so added '' to this test. Should probably set $element->filter_type to a default somewhere.
if (in_array($element->filter_type, array('range', 'dropdown', ''))) {
$rows = $this->filterValueList($normal, '', $joinTableName . '.' . $tabletype, '', false);
$rows = (array) $rows;
array_unshift($rows, JHTML::_('select.option', '', $this->filterSelectLabel()));
}
switch ($element->filter_type) {
case "range":
$attribs = 'class="inputbox fabrik_filter" size="1" ';
$default1 = is_array($default) ? $default[0] : '';
$return = JHTML::_('select.genericlist', $rows, $v . '[]', $attribs, 'value', 'text', $default1, $element->name . "_filter_range_0");
$default1 = is_array($default) ? $default[1] : '';
$return .= JHTML::_('select.genericlist', $rows, $v . '[]', $attribs, 'value', 'text', $default1, $element->name . "_filter_range_1");
break;
case "dropdown":
default:
$return = JHTML::_('select.genericlist', $rows, $v, 'class="inputbox fabrik_filter" size="1" ', 'value', 'text', $default, $htmlid);
break;
case "field":
if (get_magic_quotes_gpc()) {
$default = stripslashes($default);
}
$default = htmlspecialchars($default);
$return = "<input type=\"text\" name=\"{$v}\" class=\"inputbox fabrik_filter\" value=\"{$default}\" id=\"{$htmlid}\" />";
break;
case "auto-complete":
if (get_magic_quotes_gpc()) {
$default = stripslashes($default);
}
$default = htmlspecialchars($default);
$return = "<input type=\"hidden\" name=\"{$v}\" class=\"inputbox fabrik_filter\" value=\"{$default}\" id=\"{$htmlid}\" />\n";
$return .= "<input type=\"text\" name=\"{$v}-auto-complete\" class=\"inputbox fabrik_filter autocomplete-trigger\" value=\"{$default}\" id=\"{$htmlid}-auto-complete\" />";
FabrikHelperHTML::autoComplete($htmlid, $this->getElement()->id, 'user');
break;
}
if ($normal) {
$return .= $this->getFilterHiddenFields($counter, $elName);
} else {
$return .= $this->getAdvancedFilterHiddenFields();
}
return $return;
}
示例6: elementJavascript
/**
* create an instance of the elements js class
* @param int group repeat counter
* @return string js call
*/
function elementJavascript($repeatCounter)
{
$id = $this->getHTMLId($repeatCounter);
if ($this->getParams()->get('database_join_display_type') == 'auto-complete') {
FabrikHelperHTML::autoComplete($id, $this->getElement()->id, 'databasejoin');
}
$opts = $this->elementJavascriptOpts($repeatCounter);
return "new FbDatabasejoin('{$id}', {$opts})";
}
示例7: elementJavascript
/**
* Returns javascript which creates an instance of the class defined in formJavascriptClass()
*
* @param int $repeatCounter Repeat group counter
*
* @return array
*/
public function elementJavascript($repeatCounter)
{
$params = $this->getParams();
$id = $this->getHTMLId($repeatCounter);
$opts = $this->getElementJSOptions($repeatCounter);
$inputMask = trim($params->get('text_input_mask', ''));
if (!empty($inputMask)) {
$opts->use_input_mask = true;
$opts->input_mask = $inputMask;
$opts->input_mask_definitions = $params->get('text_input_mask_definitions', '{}');
} else {
$opts->use_input_mask = false;
$opts->input_mask = '';
}
$opts->geocomplete = $params->get('autocomplete', '0') === '3';
$config = JComponentHelper::getParams('com_fabrik');
$apiKey = $config->get('google_api_key', '');
$opts->mapKey = empty($apiKey) ? false : $apiKey;
if ($this->getParams()->get('autocomplete', '0') == '2') {
$autoOpts = array();
$autoOpts['max'] = $this->getParams()->get('autocomplete_rows', '10');
$autoOpts['storeMatchedResultsOnly'] = false;
FabrikHelperHTML::autoComplete($id, $this->getElement()->id, $this->getFormModel()->getId(), 'field', $autoOpts);
}
return array('FbField', $id, $opts);
}
示例8: loadJavascriptClass
/**
* Load the javascript class that manages plugin interaction
* should only be called once
*
* @return string Javascript class file
*/
public function loadJavascriptClass()
{
$params = $this->getParams();
$model = $this->getModel();
$mapElement = $this->getMapElement();
if (!is_object($mapElement)) {
throw new RuntimeException('Radius search plug-in active but map element unpublished');
return;
}
$opts = array();
$opts['container'] = 'radius_search_place_container';
// Increase z-index with advanced class
$opts['menuclass'] = 'auto-complete-container advanced';
$formId = $model->getFormModel()->get('id');
if ($params->get('place', 1) == 1) {
$el = $this->getPlaceElement();
FabrikHelperHTML::autoComplete("radius_search_place{$this->renderOrder}", $el->getElement()->id, $formId, $el->getElement()->plugin, $opts);
}
if ($params->get('myloc', 1) == 1) {
$ext = FabrikHelperHTML::isDebug() ? '.js' : '-min.js';
FabrikHelperHTML::script('media/com_fabrik/js/lib/geo-location/geo' . $ext);
}
parent::loadJavascriptClass();
}
示例9: getFilter
/**
* Get the table filter for the element
* @param int counter
* @param bol do we render as a normal filter or as an advanced search filter
* if normal include the hidden fields as well (default true, use false for advanced filter rendering)
* @return string filter html
*/
function getFilter($counter = 0, $normal = true)
{
$element = $this->getElement();
$values = $this->getSubOptionValues();
$default = $this->getDefaultFilterVal($normal, $counter);
$elName = $this->getFullName(false, true, false);
$htmlid = $this->getHTMLId() . 'value';
$table =& $this->getlistModel()->getTable();
$params =& $this->getParams();
$v = 'fabrik___filter[list_' . $table->id . '][value]';
$v .= $normal ? '[' . $counter . ']' : '[]';
if (in_array($element->filter_type, array('range', 'dropdown', ''))) {
$rows = $this->filterValueList($normal);
JArrayHelper::sortObjects($rows, $params->get('filter_groupby', 'text'));
if (!in_array('', $values)) {
array_unshift($rows, JHTML::_('select.option', '', $this->filterSelectLabel()));
}
}
$attribs = 'class="inputbox fabrik_filter" size="1" ';
$size = $params->get('filter_length', 20);
switch ($element->filter_type) {
case "range":
$default1 = is_array($default) ? $default[0] : '';
$return = JHTML::_('select.genericlist', $rows, $v . '[]', $attribs, 'value', 'text', $default1, $element->name . "_filter_range_0");
$default1 = is_array($default) ? $default[1] : '';
$return .= JHTML::_('select.genericlist', $rows, $v . '[]', $attribs, 'value', 'text', $default1, $element->name . "_filter_range_1");
break;
case "dropdown":
default:
$return = JHTML::_('select.genericlist', $rows, $v, $attribs, 'value', 'text', $default, $htmlid);
break;
case "field":
if (get_magic_quotes_gpc()) {
$default = stripslashes($default);
}
$default = htmlspecialchars($default);
$return = "<input type=\"text\" name=\"{$v}\" class=\"inputbox fabrik_filter\" size=\"{$size}\" value=\"{$default}\" id=\"{$htmlid}\" />";
break;
case 'auto-complete':
if (get_magic_quotes_gpc()) {
$default = stripslashes($default);
}
$default = htmlspecialchars($default);
$return = "<input type=\"hidden\" name=\"{$v}\" class=\"inputbox fabrik_filter\" value=\"{$default}\" id=\"{$htmlid}\" />";
$return .= "<input type=\"text\" name=\"{$v}-auto-complete\" class=\"inputbox fabrik_filter autocomplete-trigger\" size=\"{$size}\" value=\"{$default}\" id=\"{$htmlid}-auto-complete\" />";
FabrikHelperHTML::autoComplete($htmlid, $this->getElement()->id, $element->plugin);
break;
}
if ($normal) {
$return .= $this->getFilterHiddenFields($counter, $elName);
} else {
$return .= $this->getAdvancedFilterHiddenFields();
}
return $return;
}
示例10: foreach
//.........這裏部分代碼省略.........
$default = $this->getDefaultFilterVal($normal, $counter);
$format = $params->get('date_table_format', '%Y-%m-%d');
$fromTable = $origTable;
$joinStr = '';
// $$$ hugh - in advanced search, _aJoins wasn't getting set
$joins = $listModel->getJoins();
foreach ($joins as $aJoin) {
// not sure why the group id key wasnt found - but put here to remove error
if (array_key_exists('group_id', $aJoin)) {
if ($aJoin->group_id == $element->group_id && $aJoin->element_id == 0) {
$fromTable = $aJoin->table_join;
$joinStr = " LEFT JOIN {$fromTable} ON " . $aJoin->table_join . "." . $aJoin->table_join_key . " = " . $aJoin->join_from_table . "." . $aJoin->table_key;
$elName = str_replace($origTable . '.', $fromTable . '.', $elName);
}
}
}
$where = $listModel->_buildQueryPrefilterWhere($this);
$elName = FabrikString::safeColName($elName);
//dont format here as the format string is different between mysql and php's calendar strftime
$sql = "SELECT DISTINCT({$elName}) AS text, {$elName} AS value FROM `{$origTable}` {$joinStr}" . "\n WHERE {$elName} IN ('" . implode("','", $ids) . "')" . "\n AND TRIM({$elName}) <> '' {$where} GROUP BY text ASC";
$requestName = $elName . "___filter";
if (array_key_exists($elName, $_REQUEST)) {
if (is_array($_REQUEST[$elName]) && array_key_exists('value', $_REQUEST[$elName])) {
$_REQUEST[$requestName] = $_REQUEST[$elName]['value'];
}
}
$htmlid = $this->getHTMLId();
$tzoffset = new DateTimeZone(JFactory::getConfig()->get('offset'));
if (in_array($element->filter_type, array('dropdown'))) {
$rows = $this->filterValueList($normal);
}
$calOpts = array('class' => 'inputbox fabrik_filter', 'maxlength' => '19', 'size' => 16);
switch ($element->filter_type) {
case "range":
FabrikHelperHTML::loadcalendar();
//@TODO: this messes up if the table date format is different to the form date format
if (empty($default)) {
$default = array('', '');
}
$v = 'fabrik___filter[table_' . $table->id . '][value][' . $counter . ']';
$return = JText::_('COM_FABRIK_DATE_RANGE_BETWEEN') . $this->calendar($default[0], $v . '[0]', $this->getHTMLId() . "_filter_range_0_" . JRequest::getVar('task'), $format, $calOpts);
$return .= "<br />" . JText::_('COM_FABRIK_DATE_RANGE_AND') . $this->calendar($default[1], $v . '[1]', $this->getHTMLId() . "_filter_range_1" . JRequest::getVar('task'), $format, $calOpts);
break;
case "dropdown":
// cant do the format in the MySQL query as its not the same formatting
// e.g. M in mysql is month and J's date code its minute
jimport('joomla.utilities.date');
$ddData = array();
foreach ($rows as $k => $o) {
if ($fabrikDb->getNullDate() === $o->text) {
$o->text = '';
$o->value = '';
} else {
$d = new JDate($o->text);
//@TODO add an option as to whether we format values or not (if records as timestamps we don't want to format the filter value as running
// the filter will result in no records found. see http://fabrikar.com/forums/showthread.php?t=10964
$o->value = $d->toFormat($format);
//if we have a table format like %m-%d then we want to remove duplicate full times
$o->text = $d->toFormat($format);
}
if (!array_key_exists($o->value, $ddData)) {
$ddData[$o->value] = $o;
}
}
array_unshift($ddData, JHTML::_('select.option', '', $this->filterSelectLabel()));
$return = JHTML::_('select.genericlist', $ddData, $v, 'class="inputbox fabrik_filter" size="1" maxlength="19"', 'value', 'text', $default, $htmlid . "_filter_range_0");
break;
default:
case "field":
FabrikHelperHTML::loadcalendar();
if (is_array($default)) {
$default = array_shift($default);
}
if (get_magic_quotes_gpc()) {
$default = stripslashes($default);
}
$default = htmlspecialchars($default);
$return = $this->calendar($default, $v, $htmlid . "_filter_range_0_" . JRequest::getVar('task'), $format, $calOpts);
break;
case 'auto-complete':
if (get_magic_quotes_gpc()) {
$default = stripslashes($default);
}
$default = htmlspecialchars($default);
$return = "<input type=\"hidden\" name=\"{$v}\" class=\"inputbox fabrik_filter\" value=\"{$default}\" id=\"{$htmlid}\" />";
$return .= "<input type=\"text\" name=\"{$v}-auto-complete\" class=\"inputbox fabrik_filter autocomplete-trigger\" value=\"{$default}\" id=\"{$htmlid}-auto-complete\" />";
$autoId = $htmlid;
if (!$normal) {
$autoId = '#advanced-search-table .autocomplete-trigger';
}
FabrikHelperHTML::autoComplete($autoId, $this->getElement()->id, 'date');
break;
}
if ($normal) {
$return .= $this->getFilterHiddenFields($counter, $elName);
} else {
$return .= $this->getAdvancedFilterHiddenFields();
}
return $return;
}
示例11: loadJavascriptClass
/**
* load the javascript class that manages interaction with the form element
* should only be called once
* @return string javascript class file
*/
function loadJavascriptClass()
{
$el = $this->getPlaceElement();
$mapelement = $this->getMapElement();
if (!is_object($mapelement)) {
return;
}
$opts = array();
$opts['container'] = 'radius_search_place_container';
$tableid = $this->model->_id;
$formid = $this->model->getForm()->_id;
$shortkey = $el->getElement()->name;
if (!is_object($mapelement)) {
JError::raiseNotice(500, JText::_('Radius search plug-in active but map element unpublished'));
return;
}
$mapfullkey = $mapelement->getFullName(false, true, false);
FabrikHelperHTML::autoComplete("radius_search_place{$this->_counter}", $el->getElement()->id, $el->_pluginName, $opts);
FabrikHelperHTML::script('geo.js', 'components/com_fabrik/libs/geo-location/');
FabrikHelperHTML::script('javascript.js', 'components/com_fabrik/plugins/table/radius_search/', false);
}
示例12: getFilter
/**
* Get the table filter for the element
* @param bol do we render as a normal filter or as an advanced searc filter
* if normal include the hidden fields as well (default true, use false for advanced filter rendering)
* @return string filter html
*/
function getFilter($counter = 0, $normal = true)
{
$listModel = $this->getlistModel();
$formModel = $listModel->getFormModel();
$elName2 = $this->getFullName(false, false, false);
if (!$formModel->hasElement($elName2)) {
return '';
}
$table = $listModel->getTable();
$element = $this->getElement();
$params = $this->getParams();
$elName = $this->getFullName(false, true, false);
$htmlid = $this->getHTMLId() . 'value';
$v = $this->filterName($counter, $normal);
//corect default got
$default = $this->getDefaultFilterVal($normal, $counter);
$return = array();
$tabletype = $this->_getValColumn();
$join = $this->getJoin();
$joinTableName = FabrikString::safeColName($join->table_join_alias);
// if filter type isn't set was blowing up in switch below 'cos no $rows
// so added '' to this test. Should probably set $element->filter_type to a default somewhere.
if (in_array($element->filter_type, array('range', 'dropdown', ''))) {
$rows = $this->filterValueList($normal, '', $joinTableName . '.' . $tabletype, '', false);
$rows = (array) $rows;
array_unshift($rows, JHTML::_('select.option', '', $this->filterSelectLabel()));
}
switch ($element->filter_type) {
case "range":
$attribs = 'class="inputbox fabrik_filter" size="1" ';
$default1 = is_array($default) ? $default[0] : '';
$return[] = JHTML::_('select.genericlist', $rows, $v . '[]', $attribs, 'value', 'text', $default1, $element->name . "_filter_range_0");
$default1 = is_array($default) ? $default[1] : '';
$return[] = JHTML::_('select.genericlist', $rows, $v . '[]', $attribs, 'value', 'text', $default1, $element->name . "_filter_range_1");
break;
case "dropdown":
default:
$return[] = JHTML::_('select.genericlist', $rows, $v, 'class="inputbox fabrik_filter" size="1" ', 'value', 'text', $default, $htmlid);
break;
case "field":
if (get_magic_quotes_gpc()) {
$default = stripslashes($default);
}
$default = htmlspecialchars($default);
$return[] = '<input type="text" name="' . $v . '" class="inputbox fabrik_filter" value="' . $default . '" id="' . $htmlid . '" />';
break;
case "hidden":
if (get_magic_quotes_gpc()) {
$default = stripslashes($default);
}
$default = htmlspecialchars($default);
$return[] = '<input type="hidden" name="' . $v . '" class="inputbox fabrik_filter" value="' . $default . '" id="' . $htmlid . '" />';
break;
case "auto-complete":
if (get_magic_quotes_gpc()) {
$default = stripslashes($default);
}
$default = htmlspecialchars($default);
$return[] = '<input type="hidden" name="' . $v . '" class="inputbox fabrik_filter" value="' . $default . '" id="' . $htmlid . '" />';
$return[] = '<input type="text" name="' . $v . '-auto-complete" class="inputbox fabrik_filter autocomplete-trigger" value="' . $default . '" id="' . $htmlid . '-auto-complete" />';
$selector = '#listform_' . $listModel->getRenderContext() . ' .' . $id;
FabrikHelperHTML::autoComplete($selector, $this->getElement()->id, 'user');
break;
}
if ($normal) {
$return[] = $this->getFilterHiddenFields($counter, $elName);
} else {
$return[] = $this->getAdvancedFilterHiddenFields();
}
return implode("\n", $return);
}
示例13: getFilter
//.........這裏部分代碼省略.........
if (array_key_exists('group_id', $aJoin)) {
if ($aJoin->group_id == $element->group_id && $aJoin->element_id == 0) {
$fromTable = $aJoin->table_join;
$joinStr = " LEFT JOIN {$fromTable} ON " . $aJoin->table_join . "." . $aJoin->table_join_key . " = " . $aJoin->join_from_table . "." . $aJoin->table_key;
$elName = str_replace($origTable . '.', $fromTable . '.', $elName);
}
}
}
$where = $listModel->_buildQueryPrefilterWhere($this);
$elName = FabrikString::safeColName($elName);
//dont format here as the format string is different between mysql and php's calendar strftime
$sql = "SELECT DISTINCT({$elName}) AS text, {$elName} AS value FROM `{$origTable}` {$joinStr}" . "\n WHERE {$elName} IN ('" . implode("','", $ids) . "')" . "\n AND TRIM({$elName}) <> '' {$where} GROUP BY text ASC";
$requestName = $elName . "___filter";
if (array_key_exists($elName, $_REQUEST)) {
if (is_array($_REQUEST[$elName]) && array_key_exists('value', $_REQUEST[$elName])) {
$_REQUEST[$requestName] = $_REQUEST[$elName]['value'];
}
}
$htmlid = $this->getHTMLId();
$timeZone = new DateTimeZone(JFactory::getConfig()->get('offset'));
if (in_array($element->filter_type, array('dropdown'))) {
$rows = $this->filterValueList($normal);
}
$calOpts = $this->filterCalendarOpts();
$return = array();
switch ($element->filter_type) {
case "range":
FabrikHelperHTML::loadcalendar();
if (empty($default)) {
$default = array('', '');
} else {
$default[0] = JFactory::getDate($default[0])->toFormat($format);
$default[1] = JFactory::getDate($default[1])->toFormat($format);
}
$return[] = JText::_('COM_FABRIK_DATE_RANGE_BETWEEN') . $this->calendar($default[0], $v . '[0]', $this->getHTMLId() . "_filter_range_0_" . JRequest::getVar('task'), $format, $calOpts);
$return[] = '<br />' . JText::_('COM_FABRIK_DATE_RANGE_AND') . $this->calendar($default[1], $v . '[1]', $this->getHTMLId() . "_filter_range_1_" . JRequest::getVar('task'), $format, $calOpts);
break;
case "dropdown":
// cant do the format in the MySQL query as its not the same formatting
// e.g. M in mysql is month and J's date code its minute
jimport('joomla.utilities.date');
$ddData = array();
foreach ($rows as $k => $o) {
if ($fabrikDb->getNullDate() === $o->text) {
$o->text = '';
$o->value = '';
} else {
$d = new FabDate($o->text);
$o->value = $d->toSql();
$o->text = $d->toFormat($format);
}
if (!array_key_exists($o->value, $ddData)) {
$ddData[$o->value] = $o;
}
}
array_unshift($ddData, JHTML::_('select.option', '', $this->filterSelectLabel()));
$return[] = JHTML::_('select.genericlist', $ddData, $v, 'class="inputbox fabrik_filter" size="1" maxlength="19"', 'value', 'text', $default, $htmlid . "_filter_range_0");
break;
default:
case "field":
FabrikHelperHTML::loadcalendar();
if (is_array($default)) {
$default = array_shift($default);
}
if ($default !== '') {
$default = JFactory::getDate($default)->toFormat($format);
}
$return[] = $this->calendar($default, $v, $htmlid . '_filter_range_0_' . JRequest::getVar('task'), $format, $calOpts);
break;
case 'hidden':
if (is_array($default)) {
$default = array_shift($default);
}
if (get_magic_quotes_gpc()) {
$default = stripslashes($default);
}
$default = htmlspecialchars($default);
$return[] = '<input type="hidden" name="' . $v . '" class="inputbox fabrik_filter" value="' . $default . '" id="' . $htmlid . '" />';
break;
case 'auto-complete':
if (get_magic_quotes_gpc()) {
$default = stripslashes($default);
}
$default = htmlspecialchars($default);
$return[] = '<input type="hidden" name="' . $v . '" class="inputbox fabrik_filter" value="' . $default . '" id="' . $htmlid . '" />';
$return[] = '<input type="text" name="' . $v . '-auto-complete" class="inputbox fabrik_filter autocomplete-trigger" value="' . $default . '" id="' . $htmlid . '-auto-complete" />';
$autoId = '#' . $htmlid . '-auto-complete';
if (!$normal) {
$autoId = '#advanced-search-table .autocomplete-trigger';
}
FabrikHelperHTML::autoComplete($autoId, $this->getElement()->id, 'date');
break;
}
if ($normal) {
$return[] = $this->getFilterHiddenFields($counter, $elName);
} else {
$return[] = $this->getAdvancedFilterHiddenFields();
}
return implode("\n", $return);
}
示例14: getFilter
/**
* can be overwritten by plugin class
* Get the table filter for the element
* @param int filter order
* @param bool do we render as a normal filter or as an advanced search filter
* if normal include the hidden fields as well (default true, use false for advanced filter rendering)
* @return string filter html
*/
public function getFilter($counter = 0, $normal = true)
{
$listModel = $this->getListModel();
$formModel = $listModel->getFormModel();
$dbElName = $this->getFullName(false, false, false);
if (!$formModel->hasElement($dbElName)) {
return '';
}
$table = $listModel->getTable();
$element = $this->getElement();
$elName = $this->getFullName(false, true, false);
$id = $this->getHTMLId() . 'value';
$v = $this->filterName($counter, $normal);
//corect default got
$default = $this->getDefaultFilterVal($normal, $counter);
$return = array();
if (in_array($element->filter_type, array('range', 'dropdown'))) {
$rows = $this->filterValueList($normal);
$this->unmergeFilterSplits($rows);
array_unshift($rows, JHTML::_('select.option', '', $this->filterSelectLabel()));
}
$size = (int) $this->getParams()->get('filter_length', 20);
switch ($element->filter_type) {
case "range":
$attribs = 'class="inputbox fabrik_filter" size="1" ';
$default1 = is_array($default) ? $default['value'][0] : '';
$return[] = JText::_('COM_FABRIK_BETWEEN') . JHTML::_('select.genericlist', $rows, $v . '[]', $attribs, 'value', 'text', $default1, $element->name . "_filter_range_0");
$default1 = is_array($default) ? $default['value'][1] : '';
$return[] = '<br /> ' . JText::_('COM_FABRIK_AND') . ' ' . JHTML::_('select.genericlist', $rows, $v . '[]', $attribs, 'value', 'text', $default1, $element->name . "_filter_range_1");
break;
case "dropdown":
$return[] = JHTML::_('select.genericlist', $rows, $v, 'class="inputbox fabrik_filter" size="1" ', 'value', 'text', $default, $id);
break;
case "field":
default:
// $$$ rob - if searching on "O'Fallon" from querystring filter the string has slashes added regardless
//if (get_magic_quotes_gpc()) {
$default = stripslashes($default);
//}
$default = htmlspecialchars($default);
$return[] = '<input type="text" name="' . $v . '" class="inputbox fabrik_filter" size="' . $size . '" value="' . $default . '" id="' . $id . '" />';
break;
case "hidden":
$default = stripslashes($default);
$default = htmlspecialchars($default);
$return[] = '<input type="hidden" name="' . $v . '" class="inputbox fabrik_filter" value="' . $default . '" id="' . $id . '" />';
break;
case "auto-complete":
$default = stripslashes($default);
$default = htmlspecialchars($default);
// $$$ rob 28/10/2011 using selector rather than element id so we can have n modules with the same filters showing and not produce invald html & duplicate js calls
$return[] = '<input type="hidden" name="' . $v . '" class="inputbox fabrik_filter ' . $id . '" value="' . $default . '" />';
$return[] = '<input type="text" name="' . $v . '-auto-complete" class="inputbox fabrik_filter autocomplete-trigger ' . $id . '-auto-complete" size="' . $size . '" value="' . $default . '" />';
$selector = '#listform_' . $listModel->getRenderContext() . ' .' . $id;
FabrikHelperHTML::autoComplete($selector, $this->getElement()->id);
break;
}
if ($normal) {
$return[] = $this->getFilterHiddenFields($counter, $elName);
} else {
$return[] = $this->getAdvancedFilterHiddenFields();
}
return implode("\n", $return);
}
示例15: autoCompleteFilter
/**
* Build the HTML for the auto-complete filter
*
* @param string $default label
* @param string $v field name
* @param string $labelValue label value
* @param bool $normal do we render as a normal filter or as an advanced search filter
* if normal include the hidden fields as well (default true, use false for advanced filter rendering)
*
* @return array html bits
*/
protected function autoCompleteFilter($default, $v, $labelValue = null, $normal = true)
{
$listModel = $this->getListModel();
if (is_null($labelValue)) {
$labelValue = $default;
}
$default = stripslashes($default);
$default = htmlspecialchars($default);
$id = $this->getHTMLId() . 'value';
$size = (int) $this->getParams()->get('filter_length', 20);
/**
* $$$ rob 28/10/2011 using selector rather than element id so we can have n modules with the same filters
* showing and not produce invald html & duplicate js calls
*/
$return = array();
$return[] = '<input type="hidden" name="' . $v . '" class="inputbox fabrik_filter ' . $id . '" value="' . $default . '" />';
$return[] = '<input type="text" name="' . 'auto-complete' . $this->getElement()->id . '" class="inputbox fabrik_filter autocomplete-trigger ' . $id . '-auto-complete" size="' . $size . '" value="' . $labelValue . '" />';
$opts = array();
if ($normal) {
$opts['menuclass'] = 'auto-complete-container';
$selector = '#listform_' . $listModel->getRenderContext() . ' .' . $id;
} else {
$selector = '.advancedSeach_' . $listModel->getRenderContext() . ' .' . $id;
$opts['menuclass'] = 'auto-complete-container advanced';
}
$element = $this->getElement();
FabrikHelperHTML::autoComplete($selector, $element->id, $element->plugin, $opts);
return $return;
}