本文整理匯總了PHP中FabrikHelperHTML::grid方法的典型用法代碼示例。如果您正苦於以下問題:PHP FabrikHelperHTML::grid方法的具體用法?PHP FabrikHelperHTML::grid怎麽用?PHP FabrikHelperHTML::grid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類FabrikHelperHTML
的用法示例。
在下文中一共展示了FabrikHelperHTML::grid方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: render
/**
* Draws the html form element
*
* @param array $data To pre-populate element with
* @param int $repeatCounter Repeat group counter
*
* @return string Elements html
*/
public function render($data, $repeatCounter = 0)
{
$name = $this->getHTMLName($repeatCounter);
$app = JFactory::getApplication();
$input = $app->input;
$id = $this->getHTMLId($repeatCounter);
$params = $this->getParams();
$values = $this->getSubOptionValues();
$labels = $this->getSubOptionLabels();
/**
* $$$ hugh -- working on issue with radio and checkbox, where extra blank subitem gets added
* if nothing selected. this fix assumes that 'value' cannot be empty string for sub-options,
* and I'm not sure if we enforce that. Problem being that if we just cast directly to
* an array, the array isn't "empty()", as it has a single, empty string entry. So then
* the array_diff() we're about to do sees that as a diff.
*
* $$$ rob - Need more logic that the previous test, as we weren't applying default value/label if set and data empty
*/
$selected = (array) $this->getValue($data, $repeatCounter);
if (FArrayHelper::emptyIsh($selected)) {
$selected = array();
// Nothing previously selected, and not editable, set selected to default value, which later on is replaced with default label
if (!$this->isEditable() && $params->get('sub_default_value', '') !== '') {
$selected[] = $params->get('sub_default_value');
}
}
// $$$ rob 06/10/2011 if front end add option on, but added option not saved we should add in the selected value to the
// values and labels.
$diff = array_diff($selected, $values);
if (!empty($diff)) {
$values = array_merge($values, $diff);
// Swap over the default value to the default label
if (!$this->isEditable()) {
foreach ($diff as &$di) {
if ($di === $params->get('sub_default_value')) {
$di = $params->get('sub_default_label');
}
}
}
$labels = array_merge($labels, $diff);
}
if (!$this->isEditable()) {
$aRoValues = array();
for ($i = 0; $i < count($values); $i++) {
if (in_array($values[$i], $selected)) {
$aRoValues[] = $this->getReadOnlyOutput($values[$i], $labels[$i]);
}
}
$splitter = $params->get('icon_folder') != -1 && $params->get('icon_folder') != '' ? ' ' : ', ';
if (empty($aRoValues)) {
return '';
}
return $this->isMultiple() && $this->renderWithHTML ? '<ul class="fabrikRepeatData"><li>' . implode('</li><li>', $aRoValues) . '</li></ul>' : implode($splitter, $aRoValues);
}
// Remove the default value
$key = array_search($params->get('sub_default_value'), $values);
if ($key) {
unset($values[$key]);
}
$optionsPerRow = (int) $this->getParams()->get('options_per_row', 4);
$elBeforeLabel = (bool) $this->getParams()->get('element_before_label', true);
// Element_before_label
if ($input->get('format') == 'raw') {
$optionsPerRow = 1;
}
$classes = $this->labelClasses();
$buttonGroup = $this->buttonGroup();
$grid = FabrikHelperHTML::grid($values, $labels, $selected, $name, $this->inputType, $elBeforeLabel, $optionsPerRow, $classes, $buttonGroup);
array_unshift($grid, '<div class="fabrikSubElementContainer" id="' . $id . '">');
$grid[] = '</div><!-- close subElementContainer -->';
if ($params->get('allow_frontend_addto', false)) {
$onlylabel = $params->get('allowadd-onlylabel');
$grid[] = $this->getAddOptionFields($repeatCounter, $onlylabel);
}
return implode("\n", $grid);
}
示例2: defined
<?php
defined('JPATH_BASE') or die;
$d = $displayData;
echo implode("\n", FabrikHelperHTML::grid($d->values, $d->labels, $d->default, $d->name, 'checkbox', false, 1, array('input' => array('fabrik_filter'))));
示例3: render
/**
* draws the form element
* @param array data
* @param int repeat group counter
* @return string returns element html
*/
public function render($data, $repeatCounter = 0)
{
$name = $this->getHTMLName($repeatCounter);
$id = $this->getHTMLId($repeatCounter);
$params = $this->getParams();
$values = $this->getSubOptionValues();
$labels = $this->getSubOptionLabels();
// $$$ hugh -- working on issue with radio and checkbox, where extra blank subitem gets added
// if nothing selected. this fix assumes that 'value' cannot be empty string for sub-options,
// and I'm not sure if we enforce that. Problem being that if we just cast directly to
// an array, the array isn't "empty()", as it has a single, empty string entry. So then
// the array_diff() we're about to do sees that as a diff.
// $selected = (array)$this->getValue($data, $repeatCounter);
$selected = $this->getValue($data, $repeatCounter);
if (is_string($selected)) {
if ($selected === '') {
$selected = array();
} else {
$selected = array($selected);
}
}
//$$$ rob 06/10/2011 if front end add option on, but added option not saved we should add in the selected value to the
// values and labels.
$diff = array_diff($selected, $values);
if (!empty($diff)) {
$values = array_merge($values, $diff);
$labels = array_merge($labels, $diff);
}
if (!$this->_editable) {
$aRoValues = array();
for ($i = 0; $i < count($values); $i++) {
if (in_array($values[$i], $selected)) {
$aRoValues[] = $this->getReadOnlyOutput($values[$i], $labels[$i]);
}
}
$splitter = $params->get('icon_folder') != -1 && $params->get('icon_folder') != '' ? ' ' : ', ';
return implode($splitter, $aRoValues);
}
$optionsPerRow = (int) $this->getParams()->get('options_per_row', 0);
$elBeforeLabel = (bool) $this->getParams()->get('element_before_label', true);
//element_before_label
if (JRequest::getVar('format') == 'raw') {
$optionsPerRow = 1;
}
$grid = FabrikHelperHTML::grid($values, $labels, $selected, $name, $this->inputType, $elBeforeLabel, $optionsPerRow);
array_unshift($grid, '<div class="fabrikSubElementContainer" id="' . $id . '">');
$grid[] = '</div>';
if ($params->get('allow_frontend_addto', false)) {
$onlylabel = $params->get('allowadd-onlylabel');
$grid[] = $this->getAddOptionFields($onlylabel, $repeatCounter);
}
return implode("\n", $grid);
}
示例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)
{
$name = $this->getHTMLName($repeatCounter);
$id = $this->getHTMLId($repeatCounter);
$params = $this->getParams();
$values = $this->getSubOptionValues();
$labels = $this->getSubOptionLabels();
/**
* $$$ hugh -- working on issue with radio and checkbox, where extra blank subitem gets added
* if nothing selected. this fix assumes that 'value' cannot be empty string for sub-options,
* and I'm not sure if we enforce that. Problem being that if we just cast directly to
* an array, the array isn't "empty()", as it has a single, empty string entry. So then
* the array_diff() we're about to do sees that as a diff.
*/
$selected = $this->getValue($data, $repeatCounter);
if (is_string($selected) || is_null($selected)) {
// $$$ hugh - ooops, '0' will count as empty.
// $selected = empty($selected) ? array() : array($selected);
$selected = $selected === '' ? array() : array($selected);
}
// $$$ rob 06/10/2011 if front end add option on, but added option not saved we should add in the selected value to the
// values and labels.
$diff = array_diff($selected, $values);
if (!empty($diff)) {
$values = array_merge($values, $diff);
// Swap over the default value to the default label
if (!$this->isEditable()) {
foreach ($diff as &$di) {
if ($di === $params->get('sub_default_value')) {
$di = $params->get('sub_default_label');
}
}
}
$labels = array_merge($labels, $diff);
}
if (!$this->isEditable()) {
$aRoValues = array();
for ($i = 0; $i < count($values); $i++) {
if (in_array($values[$i], $selected)) {
$aRoValues[] = $this->getReadOnlyOutput($values[$i], $labels[$i]);
}
}
$splitter = $params->get('icon_folder') != -1 && $params->get('icon_folder') != '' ? ' ' : ', ';
return $this->isMultiple() && $this->renderWithHTML ? '<ul class="fabrikRepeatData"><li>' . implode('</li><li>', $aRoValues) . '</li></ul>' : implode($splitter, $aRoValues);
}
// Remove the default value
$key = array_search($params->get('sub_default_value'), $values);
if ($key) {
unset($values[$key]);
}
$optionsPerRow = (int) $this->getParams()->get('options_per_row', 4);
$elBeforeLabel = (bool) $this->getParams()->get('element_before_label', true);
// Element_before_label
if (JRequest::getVar('format') == 'raw') {
$optionsPerRow = 1;
}
$grid = FabrikHelperHTML::grid($values, $labels, $selected, $name, $this->inputType, $elBeforeLabel, $optionsPerRow);
array_unshift($grid, '<div class="fabrikSubElementContainer" id="' . $id . '">');
$grid[] = '</div>';
if ($params->get('allow_frontend_addto', false)) {
$onlylabel = $params->get('allowadd-onlylabel');
$grid[] = $this->getAddOptionFields($repeatCounter, $onlylabel);
}
return implode("\n", $grid);
}
示例5: checkboxFilter
/**
* Checkbox filter
*
* @param array $rows Filter list options
* @param array $default Selected filter values
* @param string $v Filter name
*
* @since 3.0.7
*
* @return string Checkbox filter HTML
*/
protected function checkboxFilter($rows, $default, $v)
{
$values = array();
$labels = array();
foreach ($rows as $row) {
$values[] = $row->value;
$labels[] = $row->text;
}
$default = (array) $default;
return implode("\n", FabrikHelperHTML::grid($values, $labels, $default, $v, 'checkbox', false, 1, array('input' => array('fabrik_filter'))));
}