From 6f05df319804397985e39b961d1e3f47888b1433 Mon Sep 17 00:00:00 2001 From: pollen8 Date: Wed, 13 Nov 2013 11:06:42 +0100 Subject: [PATCH] fixes #1073 - joomla 3.2 changes the way bootstrap grouped inputs need to be rendered --- components/com_fabrik/helpers/html.php | 69 ++++++++++++++++++++------ plugins/fabrik_element/yesno/yesno.php | 2 +- 2 files changed, 56 insertions(+), 15 deletions(-) diff --git a/components/com_fabrik/helpers/html.php b/components/com_fabrik/helpers/html.php index 47d7c567b26..d93c55dcc15 100644 --- a/components/com_fabrik/helpers/html.php +++ b/components/com_fabrik/helpers/html.php @@ -1945,7 +1945,7 @@ protected static function propertiesFromArray($properties) } /** - * Make a grid of items + * Build array of items for use in grid() * * @param array $values Option values * @param array $labels Option labels @@ -1953,28 +1953,26 @@ protected static function propertiesFromArray($properties) * @param string $name Input name * @param string $type Checkbox/radio etc * @param bool $elementBeforeLabel Element before or after the label - deprecated - not used in Joomla 3 - * @param int $optionsPerRow Number of suboptions to show per row * @param array $classes Label classes * @param bool $buttonGroup Should it be rendered as a bootstrap button group (radio only) * - * @return string grid + * @return array Grid items */ - public static function grid($values, $labels, $selected, $name, $type = "checkbox", - $elementBeforeLabel = true, $optionsPerRow = 4, $classes = array(), $buttonGroup = false) + public static function gridItems($values, $labels, $selected, $name, $type = 'checkbox', + $elementBeforeLabel = true, $classes = array(), $buttonGroup = false) { - $items = array(); + $j3 = FabrikWorker::j3(); + $version = new JVersion; - if (FabrikWorker::j3()) - { - $elementBeforeLabel = true; - } + // Button group rendering seems to have changed in J3.2 + $j32ButtonGroup = version_compare($version->RELEASE, 3.2, '>=') && $buttonGroup; for ($i = 0; $i < count($values); $i++) { $item = array(); $thisname = $type === 'checkbox' ? FabrikString::rtrimword($name, '[]') . '[' . $i . ']' : $name; - $label = '' . $labels[$i] . ''; + $label = $j32ButtonGroup? $labels[$i] : '' . $labels[$i] . ''; // For values like '1"' $value = htmlspecialchars($values[$i], ENT_QUOTES); @@ -1985,16 +1983,59 @@ public static function grid($values, $labels, $selected, $name, $type = "checkbo $inputClass .= ' ' . implode(' ', $classes['input']); } + preg_match('/[\w\s]+/', $name, $id); + $id = $id[0] . '_' . $i; $chx = '' : ' />'; $labelClass = FabrikWorker::j3() && !$buttonGroup ? $type : ''; - $item[] = ''; + + if ($j32ButtonGroup) + { + $item[] = $chx; + $item[] = ''; + } + else + { + $item[] = ''; + } $items[] = implode("\n", $item); } + return $items; + } + + /** + * Make a grid of items + * + * @param array $values Option values + * @param array $labels Option labels + * @param array $selected Selected options + * @param string $name Input name + * @param string $type Checkbox/radio etc + * @param bool $elementBeforeLabel Element before or after the label - deprecated - not used in Joomla 3 + * @param int $optionsPerRow Number of suboptions to show per row + * @param array $classes Label classes + * @param bool $buttonGroup Should it be rendered as a bootstrap button group (radio only) + * + * @return string grid + */ + + public static function grid($values, $labels, $selected, $name, $type = 'checkbox', + $elementBeforeLabel = true, $optionsPerRow = 4, $classes = array(), $buttonGroup = false) + { + $items = array(); + + if (FabrikWorker::j3()) + { + $elementBeforeLabel = true; + } + + $items = self::gridItems($values, $labels, $selected, $name, $type, $elementBeforeLabel, $classes, $buttonGroup); + $grid = array(); $optionsPerRow = empty($optionsPerRow) ? 4 : $optionsPerRow; $w = floor(100 / $optionsPerRow); diff --git a/plugins/fabrik_element/yesno/yesno.php b/plugins/fabrik_element/yesno/yesno.php index 151355db0ef..ff62d223ba1 100644 --- a/plugins/fabrik_element/yesno/yesno.php +++ b/plugins/fabrik_element/yesno/yesno.php @@ -116,7 +116,7 @@ public function renderListData_pdf($data, $thisRow) } else { - $icon = $j3 ? 'checkmark.png' : '0_8bit.png'; + $icon = $j3 ? 'remove.png' : '0_8bit.png'; return FabrikHelperHTML::image($icon, 'list', $this->tmpl, array('alt' => JText::_('JNO'))); }