本文整理匯總了PHP中FabrikHelperHTML::aList方法的典型用法代碼示例。如果您正苦於以下問題:PHP FabrikHelperHTML::aList方法的具體用法?PHP FabrikHelperHTML::aList怎麽用?PHP FabrikHelperHTML::aList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類FabrikHelperHTML
的用法示例。
在下文中一共展示了FabrikHelperHTML::aList方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: render
/**
* draws the form element
* @param array data to preopulate element with
* @param int repeat group counter
* @return string returns field element
*/
function render($data, $repeatCounter = 0)
{
if ($this->isJoin()) {
$this->hasSubElements = true;
}
$params =& $this->getParams();
$formModel =& $this->getForm();
$groupModel =& $this->getGroup();
$element = $this->getElement();
$aGroupRepeats[$element->group_id] = $groupModel->canRepeat();
$displayType = $params->get('database_join_display_type', 'dropdown');
$db = $this->getDb();
if (!$db) {
JError::raiseWarning(JText::sprintf('PLG_ELEMENT_DBJOIN_DB_CONN_ERR', $element->name));
return '';
}
if (isset($formModel->_aJoinGroupIds[$groupModel->_id])) {
$joinId = $formModel->_aJoinGroupIds[$groupModel->_id];
$joinGroupId = $groupModel->_id;
} else {
$joinId = '';
$joinGroupId = '';
}
// $$$ rob dont load in all options for autocomplete as slows loading on large data sets
$tmp = $displayType == 'auto-complete' && $this->_editable ? array() : $this->_getOptions($data, $repeatCounter);
/*get the default value */
$w = new FabrikWorker();
$default = (array) $this->getValue($data, $repeatCounter);
foreach ($default as &$d) {
$d = $w->parseMessageForPlaceHolder($d);
}
$thisElName = $this->getHTMLName($repeatCounter);
//get the default label for the drop down (use in read only templates)
$defaultLabel = '';
$defaultValue = '';
foreach ($tmp as $obj) {
if ($obj->value == JArrayHelper::getValue($default, 0, '')) {
$defaultValue = $obj->value;
$defaultLabel = $obj->text;
}
}
$id = $this->getHTMLId($repeatCounter);
//$$$rob should be canUse() otherwise if user set to view but not use the dd was shown
//if ($this->canView()) {
if ($this->canUse()) {
$str = '';
/*if user can access the drop down*/
switch ($displayType) {
case 'dropdown':
default:
$str .= JHTML::_('select.genericlist', $tmp, $thisElName, 'class="fabrikinput inputbox" size="1"', 'value', 'text', $default, $id);
break;
case 'radio':
// $$$ rob 24/05/2011 - always set one value as selected for radio button if none already set
if ($defaultValue == '' && !empty($tmp)) {
$defaultValue = $tmp[0]->value;
}
// $$$ rob 24/05/2011 - add options per row
$options_per_row = intval($params->get('dbjoin_options_per_row', 0));
$str .= "<div class=\"fabrikSubElementContainer\" id=\"{$id}\">";
$str .= FabrikHelperHTML::aList($displayType, $tmp, $thisElName, 'class="fabrikinput inputbox" size="1" id="' . $id . '"', $defaultValue, 'value', 'text', $options_per_row);
break;
case 'checkbox':
$idname = $this->getFullName(false, true, false) . "_id";
$defaults = explode(GROUPSPLITTER, JArrayHelper::getValue($data, $idname));
// $$$ rob 24/05/2011 - add options per row
$options_per_row = intval($params->get('dbjoin_options_per_row', 0));
$str .= "<div class=\"fabrikSubElementContainer\" id=\"{$id}\">";
//$joinids = $default == '' ? array() : explode(GROUPSPLITTER, $default);
$joinids = $default;
$str .= FabrikHelperHTML::aList($displayType, $tmp, $thisElName, 'class="fabrikinput inputbox" size="1" id="' . $id . '"', $defaults, 'value', 'text', $options_per_row, $this->_editable);
if ($this->isJoin() && $this->_editable) {
$join =& $this->getJoin();
$joinidsName = 'join[' . $join->id . '][' . $join->table_join . '___id][]';
$tmpids = array();
foreach ($tmp as $obj) {
$o = new stdClass();
$o->text = $obj->text;
if (in_array($obj->value, $defaults)) {
$index = array_search($obj->value, $defaults);
$o->value = $joinids[$index];
} else {
$o->value = 0;
}
$tmpids[] = $o;
}
$str .= "<div class=\"fabrikHide\">";
$str .= FabrikHelperHTML::aList($displayType, $tmpids, $joinidsName, 'class="fabrikinput inputbox" size="1" id="' . $id . '"', $joinids, 'value', 'text', $options_per_row, $this->_editable);
$str .= "</div>";
}
$defaultLabel = $str;
break;
case 'auto-complete':
$autoCompleteName = str_replace('[]', '', $thisElName) . '-auto-complete';
//.........這裏部分代碼省略.........
示例2: radioList
/**
* Generates an HTML radio list
* @param array An array of objects
* @param string The value of the HTML name attribute
* @param string Additional HTML attributes for the <select> tag
* @param mixed The key that is selected
* @param string The name of the object variable for the option value
* @param string The name of the object variable for the option text
* @param int number of options to show per row @since 2.0.5
* @returns string HTML for the select list
*/
function radioList(&$arr, $tag_name, $tag_attribs, $selected = null, $key = 'value', $text = 'text', $options_per_row = 0)
{
return FabrikHelperHTML::aList('radio', $arr, $tag_name, $tag_attribs, $selected, $key, $text, $options_per_row);
}
示例3: renderCheckBoxList
/**
* Render checkbox list in form
*
* @param array $data Form data
* @param int $repeatCounter Repeat group counter
* @param array &$html HTML to assign output to
* @param array $tmp List of value/label objects
* @param array $default Default values - the lookup table's primary key values
*
* @since 3.0.7
*
* @return void
*/
protected function renderCheckBoxList($data, $repeatCounter, &$html, $tmp, $default)
{
$id = $this->getHTMLId($repeatCounter);
$name = $this->getHTMLName($repeatCounter);
$params = $this->getParams();
$optsPerRow = (int) $params->get('dbjoin_options_per_row', 0);
$html[] = '<div class="fabrikSubElementContainer" id="' . $id . '">';
$editable = $this->isEditable();
$attribs = 'class="fabrikinput inputbox" id="' . $id . '"';
$name = FabrikString::rtrimword($name, '[]');
$targetIds = $this->multiOptionTargetIds($data, $repeatCounter);
if ($targetIds !== false) {
$default = $targetIds;
}
$html[] = FabrikHelperHTML::aList('checkbox', $tmp, $name, $attribs, $default, 'value', 'text', $optsPerRow, $editable);
if (empty($tmp)) {
$tmpids = array();
$o = new stdClass();
$o->text = 'dummy';
$o->value = 'dummy';
$tmpids[] = $o;
$tmp = $tmpids;
$dummy = FabrikHelperHTML::aList('checkbox', $tmp, $name, $attribs, $default, 'value', 'text', 1, true);
$html[] = '<div class="chxTmplNode">' . $dummy . '</div>';
}
$html[] = '</div>';
}
示例4: render
/**
* Draws the html form element
*
* @param array $data to preopulate element with
* @param int $repeatCounter repeat group counter
*
* @return string elements html
*/
public function render($data, $repeatCounter = 0)
{
// For repetaing groups we need to unset this where each time the element is rendered
unset($this->_autocomplete_where);
if ($this->isJoin()) {
$this->hasSubElements = true;
}
$params = $this->getParams();
$formModel = $this->getForm();
$groupModel = $this->getGroup();
$element = $this->getElement();
$aGroupRepeats[$element->group_id] = $groupModel->canRepeat();
$displayType = $params->get('database_join_display_type', 'dropdown');
$db = $this->getDb();
if (!$db) {
JError::raiseWarning(JText::sprintf('PLG_ELEMENT_DBJOIN_DB_CONN_ERR', $element->name));
return '';
}
if (isset($formModel->_aJoinGroupIds[$groupModel->getId()])) {
$joinId = $formModel->_aJoinGroupIds[$groupModel->getId()];
$joinGroupId = $groupModel->getId();
} else {
$joinId = '';
$joinGroupId = '';
}
$default = (array) $this->getValue($data, $repeatCounter);
$tmp = $this->_getOptions($data, $repeatCounter);
$w = new FabrikWorker();
foreach ($default as &$d) {
$d = $w->parseMessageForPlaceHolder($d);
}
$thisElName = $this->getHTMLName($repeatCounter);
// Get the default label for the drop down (use in read only templates)
$defaultLabel = '';
$defaultValue = '';
foreach ($tmp as $obj) {
if ($obj->value == JArrayHelper::getValue($default, 0, '')) {
$defaultValue = $obj->value;
$defaultLabel = $obj->text;
break;
}
}
$id = $this->getHTMLId($repeatCounter);
// $$$ rob 24/05/2011 - add options per row
$options_per_row = intval($params->get('dbjoin_options_per_row', 0));
$html = array();
// $$$ hugh - still need to check $this->isEditable(), as content plugin sets it to false,
// as no point rendering editable view for {fabrik view=element ...} in an article.
if (!$formModel->isEditable() || !$this->isEditable()) {
// $$$ rob 19/03/2012 uncommented line below - needed for checkbox rendering
$obj = JArrayHelper::toObject($data);
$defaultLabel = $this->renderListData($default, $obj);
if ($defaultLabel === $params->get('database_join_noselectionlabel', JText::_('COM_FABRIK_PLEASE_SELECT'))) {
// No point showing 'please select' for read only
$defaultLabel = '';
}
if ($params->get('databasejoin_readonly_link') == 1) {
$popupformid = (int) $params->get('databasejoin_popupform');
if ($popupformid !== 0) {
$query = $db->getQuery(true);
$query->select('id')->from('#__{package}_lists')->where('form_id =' . $popupformid);
$db->setQuery($query);
$listid = $db->loadResult();
$url = 'index.php?option=com_fabrik&view=details&formid=' . $popupformid . '&listid =' . $listid . '&rowid=' . $defaultValue;
$defaultLabel = '<a href="' . JRoute::_($url) . '">' . $defaultLabel . '</a>';
}
}
$html[] = $defaultLabel;
} else {
// $$$rob should be canUse() otherwise if user set to view but not use the dd was shown
if ($this->canUse()) {
$idname = $this->getFullName(false, true, false) . '_id';
$attribs = 'class="fabrikinput inputbox" size="1"';
/*if user can access the drop down*/
switch ($displayType) {
case 'dropdown':
default:
$html[] = JHTML::_('select.genericlist', $tmp, $thisElName, $attribs, 'value', 'text', $default, $id);
break;
case 'radio':
// $$$ rob 24/05/2011 - always set one value as selected for radio button if none already set
if ($defaultValue == '' && !empty($tmp)) {
$defaultValue = $tmp[0]->value;
}
// $$$ rob 24/05/2011 - add options per row
$options_per_row = intval($params->get('dbjoin_options_per_row', 0));
$html[] = '<div class="fabrikSubElementContainer" id="' . $id . '">';
$html[] = FabrikHelperHTML::aList($displayType, $tmp, $thisElName, $attribs . ' id="' . $id . '"', $defaultValue, 'value', 'text', $options_per_row);
break;
case 'checkbox':
$defaults = $formModel->failedValidation() ? $default : explode(GROUPSPLITTER, JArrayHelper::getValue($data, $idname));
$html[] = '<div class="fabrikSubElementContainer" id="' . $id . '">';
//.........這裏部分代碼省略.........
示例5: render
/**
* draws the form element
* @param array data to preopulate element with
* @param int repeat group counter
* @return string returns field element
*/
function render($data, $repeatCounter = 0)
{
if ($this->isJoin()) {
$this->hasSubElements = true;
}
$params =& $this->getParams();
$formModel =& $this->getForm();
$groupModel =& $this->getGroup();
$element =& $this->getElement();
$aGroupRepeats[$element->group_id] = $groupModel->canRepeat();
$displayType = $params->get('database_join_display_type', 'dropdown');
$db =& $this->getDb();
if (!$db) {
JError::raiseWarning(JText::sprintf('Could not make join to %s', $element->name));
return '';
}
if (isset($formModel->_aJoinGroupIds[$groupModel->_id])) {
$joinId = $formModel->_aJoinGroupIds[$groupModel->_id];
$joinGroupId = $groupModel->_id;
} else {
$joinId = '';
$joinGroupId = '';
}
/*get the default value */
$w = new FabrikWorker();
$default = $this->getValue($data, $repeatCounter);
$default = $w->parseMessageForPlaceHolder($default);
// $$$ rob dont load in all options for autocomplete as slows loading on large data sets
// $tmp = ($displayType == 'auto-complete' && $this->_editable) ? array() : $this->_getOptions($data, $repeatCounter);
// $$$ hugh - doesn't matter if editable, otherwise it just failsd on _getROElement(). Don't load for auto-complete, period.
//$tmp = $this->_getOptions($data, $repeatCounter);
// $$$ rob - huh? (^^ above line + comment ^^) how can it not matter for editable?
// If you have repeat auto-completes in a form then we must get the correct label/value to show in the field
$tmp = $displayType == 'auto-complete' ? $this->getOneOption($default, $data, $repeatCounter) : $this->_getOptions($data, $repeatCounter);
$default = $this->getValue($data, $repeatCounter);
$default = $w->parseMessageForPlaceHolder($default);
$thisElName = $this->getHTMLName($repeatCounter);
//weird situation in http://gb.inetis.ch/ where lots of inner joins and repeating groups meant deafult was a csv list?????
if (is_string($default) && strpos($default, ',')) {
$default = explode(',', $default);
$default = $default[$repeatCounter];
}
//get the default label for the drop down (use in read only templates)
$defaultLabel = '';
$defaultValue = '';
foreach ($tmp as $obj) {
if ($obj->value == $default) {
$defaultValue = $obj->value;
$defaultLabel = $obj->text;
}
}
$id = $this->getHTMLId($repeatCounter);
//$$$rob should be canUse() otherwise if user set to view but not use the dd was shown
//if ($this->canView()) {
if ($this->canUse()) {
$str = '';
/*if user can access the drop down*/
switch ($displayType) {
case 'dropdown':
default:
$str .= JHTML::_('select.genericlist', $tmp, $thisElName, 'class="fabrikinput inputbox" size="1"', 'value', 'text', $default, $id);
break;
case 'radio':
// $$$ rob 24/05/2011 - always set one value as selected for radio button if none already set
if ($defaultValue == '' && !empty($tmp)) {
$defaultValue = $tmp[0]->value;
}
// $$$ rob 24/05/2011 - add options per row
$options_per_row = intval($params->get('dbjoin_options_per_row', 0));
$str .= "<div class=\"fabrikSubElementContainer\" id=\"{$id}\">";
$str .= FabrikHelperHTML::aList($displayType, $tmp, $thisElName, 'class="fabrikinput inputbox" size="1" id="' . $id . '"', $defaultValue, 'value', 'text', $options_per_row);
break;
case 'checkbox':
$idname = $this->getFullName(false, true, false) . "_id";
$join =& $this->getJoin();
$repeatnumName = $join->table_join . "___repeatnum";
$defaults = explode(GROUPSPLITTER, JArrayHelper::getValue($data, $idname));
if ($groupModel->canRepeat() && $groupModel->isJoin()) {
//$$$ rob 21/07/2011 if checkbox is in repeat group then we want to filter the defaults to only show those selected in this repeat group
$fk = $groupModel->getJoinModel()->getPrimaryKey() . '_raw';
$fkeyvals = JArrayHelper::getValue($data['join'][$this->getGroup()->getGroup()->join_id], $fk);
$repeatNums = JArrayHelper::getValue($data['join'][$this->getGroup()->getGroup()->join_id], $repeatnumName);
$currentFkVal = $fkeyvals[$repeatCounter];
$repeatNums = explode(GROUPSPLITTER, $repeatNums[0]);
$allDefaults = $defaults;
$defaults = array();
foreach ($repeatNums as $rk => $v) {
if ($v == $currentFkVal) {
$defaults[] = $allDefaults[$rk];
} else {
$defaults[] = '';
}
}
}
//.........這裏部分代碼省略.........
示例6: renderCheckBoxList
/**
* Render checkbox list in form
*
* @param array $data Form data
* @param int $repeatCounter Repeat group counter
* @param array &$html HTML to assign output to
* @param array $tmp List of value/label objects
* @param array $default Default values - the lookup table's primary key values
*
* @since 3.0.7
*
* @return void
*/
protected function renderCheckBoxList($data, $repeatCounter, &$html, $tmp, $default)
{
$id = $this->getHTMLId($repeatCounter);
$name = $this->getHTMLName($repeatCounter);
$params = $this->getParams();
$html[] = '<div class="fabrikSubElementContainer" id="' . $id . '">';
$attributes = 'class="fabrikinput inputbox" id="' . $id . '"';
$name = FabrikString::rtrimword($name, '[]');
if (!$this->getFormModel()->isNewRecord()) {
// If its a new record we don't want to look up defaults in the look up table as they will not exist
$targetIds = $this->multiOptionTargetIds($data, $repeatCounter);
if ($targetIds !== false) {
$default = $targetIds;
}
}
$this->renderReadOnlyTrimOptions($tmp, $default);
$layout = $this->getLayout('form-checkboxlist');
$displayData = new stdClass();
$displayData->options = $tmp;
$displayData->default = (array) $default;
$displayData->optsPerRow = (int) $params->get('dbjoin_options_per_row', 1);
$displayData->name = $name;
$displayData->editable = $this->isEditable();
$displayData->optionLayout = $this->getLayout('form-checkbox');
$html[] = '<div class="fabrikSubElementContainer" id="' . $id . '">';
$singleLayout = 'fabrik-element-' . $this->getPluginName() . '-form-checkbox';
FabrikHelperHTML::jLayoutJs($singleLayout, $singleLayout, $displayData, array($this->layoutBasePath()));
if (FabrikWorker::j3()) {
$html[] = $layout->render($displayData);
} else {
$html[] = FabrikHelperHTML::aList('checkbox', $tmp, $name, $attributes, $default, 'value', 'text', $displayData->optsPerRow, $displayData->editable);
}
if (empty($tmp) && !FabrikWorker::j3()) {
$tmpIds = array();
$o = new stdClass();
$o->text = 'dummy';
$o->value = 'dummy';
$tmpIds[] = $o;
$tmp = $tmpIds;
$dummy = FabrikHelperHTML::aList('checkbox', $tmp, $name, $attributes, $default, 'value', 'text', 1, true);
$html[] = '<div class="chxTmplNode">' . $dummy . '</div>';
}
$html[] = '</div>';
}