Returns the DataViewInterface attached to this form
public getView ( ) : FOF30\View\DataView\DataViewInterface | ||
Результат | FOF30\View\DataView\DataViewInterface |
/** * Get the rendering of this field type for a repeatable (grid) display, * e.g. in a view listing many item (typically a "browse" task) * * @since 2.0 * * @return string The field HTML * * @throws DataModelRequired */ public function getRepeatable() { if (!$this->item instanceof DataModel) { throw new DataModelRequired(__CLASS__); } $class = isset($this->class) ? $this->class : 'input-mini'; $icon = isset($this->element['icon']) ? $this->element['icon'] : 'icon-menu'; $html = ''; $view = $this->form->getView(); $ordering = $view->getLists()->order == 'ordering'; if (!$view->hasAjaxOrderingSupport()) { // Ye olde Joomla! 2.5 method $disabled = $ordering ? '' : 'disabled="disabled"'; $html .= '<span>'; $html .= $view->getPagination()->orderUpIcon($this->rowid, true, 'orderup', 'Move Up', $ordering); $html .= '</span><span>'; $html .= $view->getPagination()->orderDownIcon($this->rowid, $view->getPagination()->total, true, 'orderdown', 'Move Down', $ordering); $html .= '</span>'; $html .= '<input type="text" name="order[]" size="5" value="' . $this->value . '" ' . $disabled; $html .= 'class="text-area-order" style="text-align: center" />'; } else { // The modern drag'n'drop method if ($view->getPerms()->editstate) { $disableClassName = ''; $disabledLabel = ''; $hasAjaxOrderingSupport = $view->hasAjaxOrderingSupport(); if (!$hasAjaxOrderingSupport['saveOrder']) { $disabledLabel = JText::_('JORDERINGDISABLED'); $disableClassName = 'inactive tip-top'; } $orderClass = $ordering ? 'order-enabled' : 'order-disabled'; $html .= '<div class="' . $orderClass . '">'; $html .= '<span class="sortable-handler ' . $disableClassName . '" title="' . $disabledLabel . '" rel="tooltip">'; $html .= '<i class="' . $icon . '"></i>'; $html .= '</span>'; if ($ordering) { $html .= '<input type="text" name="order[]" size="5" class="' . $class . ' text-area-order" value="' . $this->value . '" />'; } $html .= '</div>'; } else { $html .= '<span class="sortable-handler inactive" >'; $html .= '<i class="' . $icon . '"></i>'; $html .= '</span>'; } } return $html; }
/** * Method to get the field label. * * @return string The field label. * * @since 2.0 */ protected function getLabel() { // Get the label text from the XML element, defaulting to the element name. $title = $this->element['label'] ? (string) $this->element['label'] : ''; if (empty($title)) { $viewObject = $this->form->getView(); $viewName = $viewObject->getName(); $componentName = $viewObject->getContainer()->componentName; $title = $componentName . '_' . $this->form->getModel()->getContainer()->inflector->pluralize($viewName) . '_FIELD_' . (string) $this->element['name']; $title = strtoupper($title); $result = \JText::_($title); if ($result === $title) { $title = ucfirst((string) $this->element['name']); } } return $title; }
/** * Get the rendering of this field type for a repeatable (grid) display, * e.g. in a view listing many item (typically a "browse" task) * * @since 2.0 * * @return string The field HTML * * @throws DataModelRequired */ public function getRepeatable() { if (!$this->item instanceof DataModel) { throw new DataModelRequired(__CLASS__); } $class = isset($this->class) ? $this->class : 'input-mini'; $icon = isset($this->element['icon']) ? $this->element['icon'] : 'icon-menu'; $dnd = isset($this->element['dragndrop']) ? (string) $this->element['dragndrop'] : 'notbroken'; if (strtolower($dnd) == 'notbroken') { $dnd = !version_compare(JVERSION, '3.5.0', 'ge'); } else { $dnd = in_array(strtolower($dnd), array('1', 'true', 'yes', 'on', 'enabled'), true); } $html = ''; $view = $this->form->getView(); $ordering = $view->getLists()->order == $this->item->getFieldAlias('ordering'); if (!$view->hasAjaxOrderingSupport()) { // Ye olde Joomla! 2.5 method $disabled = $ordering ? '' : 'disabled="disabled"'; $html .= '<span>'; $html .= $view->getPagination()->orderUpIcon($this->rowid, true, 'orderup', 'Move Up', $ordering); $html .= '</span><span>'; $html .= $view->getPagination()->orderDownIcon($this->rowid, $view->getPagination()->total, true, 'orderdown', 'Move Down', $ordering); $html .= '</span>'; $html .= '<input type="text" name="order[]" size="5" value="' . $this->value . '" ' . $disabled; $html .= 'class="text-area-order" style="text-align: center" />'; } else { // The modern drag'n'drop method if ($view->getPerms()->editstate) { $disableClassName = ''; $disabledLabel = ''; $hasAjaxOrderingSupport = $view->hasAjaxOrderingSupport(); if (!$hasAjaxOrderingSupport['saveOrder']) { $disabledLabel = JText::_('JORDERINGDISABLED'); $disableClassName = 'inactive tip-top'; } $orderClass = $ordering ? 'order-enabled' : 'order-disabled'; $html .= '<div class="' . $orderClass . '">'; if ($dnd) { $html .= '<span class="sortable-handler ' . $disableClassName . '" title="' . $disabledLabel . '" rel="tooltip">'; $html .= '<span class="' . $icon . '"></span>'; $html .= '</span>'; } if ($ordering) { // Joomla! 3.5 and later: drag and drop reordering is broken when the ordering field is not hidden // because some idiot submitted that code and some moron committed it. I tried to file a PR to fix // it and got the reply "can't test, won't test". OK, then. You retarded bonobos blindly accepted // code which did the EXACT OPPOSITE of what it promised and broke b/c. However, you won't accept // the fix to that shit from someone who knows how Joomla! works and wasted 2 hours of his time to // track down your idiocy, fix it and explain why you retarded monkeys cocked it up. F*****g morons! $joomla35IsBroken = version_compare(JVERSION, '3.5.0', 'ge') ? 'style="display: none"' : ''; // When the developer has disabled Drag and Drop we will show the field regardless $joomla35IsBroken = $dnd ? $joomla35IsBroken : ''; $html .= '<input type="text" name="order[]" ' . $joomla35IsBroken . ' size="5" class="' . $class . ' text-area-order" value="' . $this->value . '" />'; } $html .= '</div>'; } else { $html .= '<span class="sortable-handler inactive" >'; $html .= '<i class="' . $icon . '"></i>'; $html .= '</span>'; } } return $html; }
/** * Renders a Form for a Browse view and returns the corresponding HTML * * @param Form &$form The form to render * @param DataModel $model The model providing our data * * @return string The HTML rendering of the form */ public function renderFormBrowse(Form &$form, DataModel $model) { $html = ''; \JHtml::_('behavior.multiselect'); \JHtml::_('bootstrap.tooltip'); \JHtml::_('dropdown.init'); $view = $form->getView(); $order = $view->escape($view->getLists()->order); $html .= <<<HTML <script type="text/javascript"> \tJoomla.orderTable = function() { \t\tvar table = document.getElementById("sortTable"); \t\tvar direction = document.getElementById("directionTable"); \t\tvar order = table.options[table.selectedIndex].value; \t\tvar dirn = 'asc'; \t\tif (order != '{$order}') \t\t{ \t\t\tdirn = 'asc'; \t\t} \t\telse { \t\t\tdirn = direction.options[direction.selectedIndex].value; \t\t} \t\tJoomla.tableOrdering(order, dirn); \t}; </script> HTML; // Getting all header row elements $headerFields = $form->getHeaderset(); // Get form parameters $show_header = $form->getAttribute('show_header', 1); $show_filters = $form->getAttribute('show_filters', 1); $show_pagination = $form->getAttribute('show_pagination', 1); $norows_placeholder = $form->getAttribute('norows_placeholder', ''); // Joomla! 3.x sidebar support $form_class = ''; if ($show_filters) { \JHtmlSidebar::setAction("index.php?option=" . $this->container->componentName . "&view=" . $this->container->inflector->pluralize($form->getView()->getName())); } // Reorder the fields with ordering first $tmpFields = array(); $i = 1; foreach ($headerFields as $tmpField) { if ($tmpField instanceof HeaderOrdering) { $tmpFields[0] = $tmpField; } else { $tmpFields[$i] = $tmpField; } $i++; } $headerFields = $tmpFields; ksort($headerFields, SORT_NUMERIC); // Pre-render the header and filter rows $header_html = ''; $filter_html = ''; $sortFields = array(); if ($show_header || $show_filters) { foreach ($headerFields as $headerField) { $header = $headerField->header; $filter = $headerField->filter; $buttons = $headerField->buttons; $options = $headerField->options; $sortable = $headerField->sortable; $tdwidth = $headerField->tdwidth; // If it's a sortable field, add to the list of sortable fields if ($sortable) { $sortFields[$headerField->name] = \JText::_($headerField->label); } // Get the table data width, if set if (!empty($tdwidth)) { $tdwidth = 'width="' . $tdwidth . '"'; } else { $tdwidth = ''; } if (!empty($header)) { $header_html .= "\t\t\t\t\t<th {$tdwidth}>" . "\n"; $header_html .= "\t\t\t\t\t\t" . $header; $header_html .= "\t\t\t\t\t</th>" . "\n"; } if (!empty($filter)) { $filter_html .= '<div class="filter-search btn-group pull-left">' . "\n"; $filter_html .= "\t" . '<label for="title" class="element-invisible">'; $filter_html .= \JText::_($headerField->label); $filter_html .= "</label>\n"; $filter_html .= "\t{$filter}\n"; $filter_html .= "</div>\n"; if (!empty($buttons)) { $filter_html .= '<div class="btn-group pull-left hidden-phone">' . "\n"; $filter_html .= "\t{$buttons}\n"; $filter_html .= '</div>' . "\n"; } } elseif (!empty($options)) { $label = $headerField->label; $filterName = $headerField->filterFieldName; $filterSource = $headerField->filterSource; \JHtmlSidebar::addFilter('- ' . \JText::_($label) . ' -', $filterName, \JHtml::_('select.options', $options, 'value', 'text', $model->getState($filterSource, ''), true)); } } } // Start the form $filter_order = $form->getView()->getLists()->order; $filter_order_Dir = $form->getView()->getLists()->order_Dir; $actionUrl = $this->container->platform->isBackend() ? 'index.php' : \JUri::root() . 'index.php'; if ($this->container->platform->isFrontend() && $this->container->input->getCmd('Itemid', 0) != 0) { $itemid = $this->container->input->getCmd('Itemid', 0); $uri = new \JUri($actionUrl); if ($itemid) { $uri->setVar('Itemid', $itemid); } $actionUrl = \JRoute::_($uri->toString()); } $html .= '<form action="' . $actionUrl . '" method="post" name="adminForm" id="adminForm" ' . $form_class . '>' . "\n"; // Get and output the sidebar, if present $sidebar = \JHtmlSidebar::render(); if ($show_filters && !empty($sidebar)) { $html .= '<div id="j-sidebar-container" class="span2">' . "\n"; $html .= "\t{$sidebar}\n"; $html .= "</div>\n"; $html .= '<div id="j-main-container" class="span10">' . "\n"; } else { $html .= '<div id="j-main-container">' . "\n"; } // Render header search fields, if the header is enabled $pagination = $form->getView()->getPagination(); if ($show_header) { $html .= "\t" . '<div id="filter-bar" class="btn-toolbar">' . "\n"; $html .= "{$filter_html}\n"; if ($show_pagination) { // Render the pagination rows per page selection box, if the pagination is enabled $html .= "\t" . '<div class="btn-group pull-right hidden-phone">' . "\n"; $html .= "\t\t" . '<label for="limit" class="element-invisible">' . \JText::_('JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC') . '</label>' . "\n"; $html .= "\t\t" . $pagination->getLimitBox() . "\n"; $html .= "\t" . '</div>' . "\n"; } if (!empty($sortFields)) { // Display the field sort order $asc_sel = $form->getView()->getLists()->order_Dir == 'asc' ? 'selected="selected"' : ''; $desc_sel = $form->getView()->getLists()->order_Dir == 'desc' ? 'selected="selected"' : ''; $html .= "\t" . '<div class="btn-group pull-right hidden-phone">' . "\n"; $html .= "\t\t" . '<label for="directionTable" class="element-invisible">' . \JText::_('JFIELD_ORDERING_DESC') . '</label>' . "\n"; $html .= "\t\t" . '<select name="directionTable" id="directionTable" class="input-medium" onchange="Joomla.orderTable()">' . "\n"; $html .= "\t\t\t" . '<option value="">' . \JText::_('JFIELD_ORDERING_DESC') . '</option>' . "\n"; $html .= "\t\t\t" . '<option value="asc" ' . $asc_sel . '>' . \JText::_('JGLOBAL_ORDER_ASCENDING') . '</option>' . "\n"; $html .= "\t\t\t" . '<option value="desc" ' . $desc_sel . '>' . \JText::_('JGLOBAL_ORDER_DESCENDING') . '</option>' . "\n"; $html .= "\t\t" . '</select>' . "\n"; $html .= "\t" . '</div>' . "\n\n"; // Display the sort fields $html .= "\t" . '<div class="btn-group pull-right">' . "\n"; $html .= "\t\t" . '<label for="sortTable" class="element-invisible">' . \JText::_('JGLOBAL_SORT_BY') . '</label>' . "\n"; $html .= "\t\t" . '<select name="sortTable" id="sortTable" class="input-medium" onchange="Joomla.orderTable()">' . "\n"; $html .= "\t\t\t" . '<option value="">' . \JText::_('JGLOBAL_SORT_BY') . '</option>' . "\n"; $html .= "\t\t\t" . \JHtml::_('select.options', $sortFields, 'value', 'text', $form->getView()->getLists()->order) . "\n"; $html .= "\t\t" . '</select>' . "\n"; $html .= "\t" . '</div>' . "\n"; } $html .= "\t</div>\n\n"; $html .= "\t" . '<div class="clearfix"> </div>' . "\n\n"; } // Start the table output $html .= "\t\t" . '<table class="table table-striped" id="itemsList">' . "\n"; // Open the table header region if required if ($show_header) { $html .= "\t\t\t<thead>" . "\n"; } // Render the header row, if enabled if ($show_header) { $html .= "\t\t\t\t<tr>" . "\n"; $html .= $header_html; $html .= "\t\t\t\t</tr>" . "\n"; } // Close the table header region if required if ($show_header) { $html .= "\t\t\t</thead>" . "\n"; } // Loop through rows and fields, or show placeholder for no rows $html .= "\t\t\t<tbody>" . "\n"; $fields = $form->getFieldset('items'); $num_columns = count($fields); $items = $model->get(); if ($count = count($items)) { $m = 1; foreach ($items as $i => $item) { $rowHtml = ''; $form->bind($item); $m = 1 - $m; $rowClass = 'row' . $m; $fields = $form->getFieldset('items'); // Reorder the fields to have ordering first $tmpFields = array(); $j = 1; foreach ($fields as $tmpField) { if ($tmpField instanceof FieldOrdering) { $tmpFields[0] = $tmpField; } else { $tmpFields[$j] = $tmpField; } $j++; } $fields = $tmpFields; ksort($fields, SORT_NUMERIC); /** @var FieldInterface $field */ foreach ($fields as $field) { $field->rowid = $i; $field->item = $item; $labelClass = $field->labelclass; $class = $labelClass ? 'class ="' . $labelClass . '"' : ''; if (!method_exists($field, 'getRepeatable')) { throw new \Exception('getRepeatable not found in class ' . get_class($field)); } // Let the fields change the row (tr element) class if (method_exists($field, 'getRepeatableRowClass')) { $rowClass = $field->getRepeatableRowClass($rowClass); } $rowHtml .= "\t\t\t\t\t<td {$class}>" . $field->getRepeatable() . '</td>' . "\n"; } $html .= "\t\t\t\t<tr class=\"{$rowClass}\">\n" . $rowHtml . "\t\t\t\t</tr>\n"; } } elseif ($norows_placeholder) { $html .= "\t\t\t\t<tr><td colspan=\"{$num_columns}\">"; $html .= \JText::_($norows_placeholder); $html .= "</td></tr>\n"; } $html .= "\t\t\t</tbody>" . "\n"; // End the table output $html .= "\t\t" . '</table>' . "\n"; // Render the pagination bar, if enabled, on J! 3.0+ $html .= $pagination->getListFooter(); // Close the wrapper element div on Joomla! 3.0+ $html .= "</div>\n"; $html .= "\t" . '<input type="hidden" name="option" value="' . $this->container->componentName . '" />' . "\n"; $html .= "\t" . '<input type="hidden" name="view" value="' . $this->container->inflector->pluralize($form->getView()->getName()) . '" />' . "\n"; $html .= "\t" . '<input type="hidden" name="task" value="' . $form->getView()->getTask() . '" />' . "\n"; $html .= "\t" . '<input type="hidden" name="layout" value="' . $form->getView()->getLayout() . '" />' . "\n"; // The id field is required in Joomla! 3 front-end to prevent the pagination limit box from screwing it up. if ($this->container->platform->isFrontend()) { $html .= "\t" . '<input type="hidden" name="id" value="" />' . "\n"; } $html .= "\t" . '<input type="hidden" name="boxchecked" value="" />' . "\n"; $html .= "\t" . '<input type="hidden" name="hidemainmenu" value="" />' . "\n"; $html .= "\t" . '<input type="hidden" name="filter_order" value="' . $filter_order . '" />' . "\n"; $html .= "\t" . '<input type="hidden" name="filter_order_Dir" value="' . $filter_order_Dir . '" />' . "\n"; $html .= "\t" . '<input type="hidden" name="' . \JFactory::getSession()->getFormToken() . '" value="1" />' . "\n"; // End the form $html .= '</form>' . "\n"; return $html; }