1<?php 2/** 3 * @package FrameworkOnFramework 4 * @subpackage render 5 * @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved. 6 * @license GNU General Public License version 2 or later; see LICENSE.txt 7 * @note This file has been modified by the Joomla! Project and no longer reflects the original work of its author. 8 */ 9defined('FOF_INCLUDED') or die; 10 11/** 12 * Default Joomla! 1.5, 1.7, 2.5 view renderer class 13 * 14 * @package FrameworkOnFramework 15 * @since 2.0 16 */ 17class FOFRenderJoomla extends FOFRenderAbstract 18{ 19 /** 20 * Public constructor. Determines the priority of this class and if it should be enabled 21 */ 22 public function __construct() 23 { 24 $this->priority = 50; 25 $this->enabled = true; 26 } 27 28 /** 29 * Echoes any HTML to show before the view template 30 * 31 * @param string $view The current view 32 * @param string $task The current task 33 * @param FOFInput $input The input array (request parameters) 34 * @param array $config The view configuration array 35 * 36 * @return void 37 */ 38 public function preRender($view, $task, $input, $config = array()) 39 { 40 $format = $input->getCmd('format', 'html'); 41 42 if (empty($format)) 43 { 44 $format = 'html'; 45 } 46 47 if ($format != 'html') 48 { 49 return; 50 } 51 52 $platform = FOFPlatform::getInstance(); 53 54 if ($platform->isCli()) 55 { 56 return; 57 } 58 59 if (version_compare(JVERSION, '3.0.0', 'lt')) 60 { 61 JHtml::_('behavior.framework'); 62 } 63 else 64 { 65 if (version_compare(JVERSION, '3.3.0', 'ge')) 66 { 67 JHtml::_('behavior.core'); 68 } 69 else 70 { 71 JHtml::_('behavior.framework', true); 72 } 73 74 JHtml::_('jquery.framework'); 75 } 76 77 // Wrap output in various classes 78 $version = new JVersion; 79 $versionParts = explode('.', $version->RELEASE); 80 $minorVersion = str_replace('.', '', $version->RELEASE); 81 $majorVersion = array_shift($versionParts); 82 83 if ($platform->isBackend()) 84 { 85 $area = $platform->isBackend() ? 'admin' : 'site'; 86 $option = $input->getCmd('option', ''); 87 $view = $input->getCmd('view', ''); 88 $layout = $input->getCmd('layout', ''); 89 $task = $input->getCmd('task', ''); 90 91 $classes = array( 92 'joomla-version-' . $majorVersion, 93 'joomla-version-' . $minorVersion, 94 $area, 95 $option, 96 'view-' . $view, 97 'layout-' . $layout, 98 'task-' . $task, 99 ); 100 } 101 elseif ($platform->isFrontend()) 102 { 103 // @TODO: Remove the frontend Joomla! version classes in FOF 3 104 $classes = array( 105 'joomla-version-' . $majorVersion, 106 'joomla-version-' . $minorVersion, 107 ); 108 } 109 110 echo '<div id="akeeba-renderjoomla" class="' . implode(' ', $classes) . "\">\n"; 111 112 // Render submenu and toolbar (only if asked to) 113 if ($input->getBool('render_toolbar', true)) 114 { 115 $this->renderButtons($view, $task, $input, $config); 116 $this->renderLinkbar($view, $task, $input, $config); 117 } 118 } 119 120 /** 121 * Echoes any HTML to show after the view template 122 * 123 * @param string $view The current view 124 * @param string $task The current task 125 * @param FOFInput $input The input array (request parameters) 126 * @param array $config The view configuration array 127 * 128 * @return void 129 */ 130 public function postRender($view, $task, $input, $config = array()) 131 { 132 $format = $input->getCmd('format', 'html'); 133 134 if (empty($format)) 135 { 136 $format = 'html'; 137 } 138 139 if ($format != 'html') 140 { 141 return; 142 } 143 144 // Closing tag only if we're not in CLI 145 if (FOFPlatform::getInstance()->isCli()) 146 { 147 return; 148 } 149 150 echo "</div>\n"; // Closes akeeba-renderjoomla div 151 } 152 153 /** 154 * Renders a FOFForm for a Browse view and returns the corresponding HTML 155 * 156 * @param FOFForm &$form The form to render 157 * @param FOFModel $model The model providing our data 158 * @param FOFInput $input The input object 159 * 160 * @return string The HTML rendering of the form 161 */ 162 protected function renderFormBrowse(FOFForm &$form, FOFModel $model, FOFInput $input) 163 { 164 JHtml::_('behavior.multiselect'); 165 166 // Getting all header row elements 167 $headerFields = $form->getHeaderset(); 168 169 // Start the form 170 $html = ''; 171 $filter_order = $form->getView()->getLists()->order; 172 $filter_order_Dir = $form->getView()->getLists()->order_Dir; 173 $actionUrl = FOFPlatform::getInstance()->isBackend() ? 'index.php' : JUri::root().'index.php'; 174 175 if (FOFPlatform::getInstance()->isFrontend() && ($input->getCmd('Itemid', 0) != 0)) 176 { 177 $itemid = $input->getCmd('Itemid', 0); 178 $uri = new JUri($actionUrl); 179 180 if ($itemid) 181 { 182 $uri->setVar('Itemid', $itemid); 183 } 184 185 $actionUrl = JRoute::_($uri->toString()); 186 } 187 188 $html .= '<form action="'.$actionUrl.'" method="post" name="adminForm" id="adminForm">' . PHP_EOL; 189 $html .= "\t" . '<input type="hidden" name="option" value="' . $input->getCmd('option') . '" />' . PHP_EOL; 190 $html .= "\t" . '<input type="hidden" name="view" value="' . FOFInflector::pluralize($input->getCmd('view')) . '" />' . PHP_EOL; 191 $html .= "\t" . '<input type="hidden" name="task" value="" />' . PHP_EOL; 192 $html .= "\t" . '<input type="hidden" name="layout" value="' . $input->getCmd('layout', '') . '" />' . PHP_EOL; 193 $html .= "\t" . '<input type="hidden" name="boxchecked" value="" />' . PHP_EOL; 194 $html .= "\t" . '<input type="hidden" name="hidemainmenu" value="" />' . PHP_EOL; 195 $html .= "\t" . '<input type="hidden" name="filter_order" value="' . $filter_order . '" />' . PHP_EOL; 196 $html .= "\t" . '<input type="hidden" name="filter_order_Dir" value="' . $filter_order_Dir . '" />' . PHP_EOL; 197 198 $html .= "\t" . '<input type="hidden" name="' . JFactory::getSession()->getFormToken() . '" value="1" />' . PHP_EOL; 199 200 // Start the table output 201 $html .= "\t\t" . '<table class="adminlist" id="adminList">' . PHP_EOL; 202 203 // Get form parameters 204 $show_header = $form->getAttribute('show_header', 1); 205 $show_filters = $form->getAttribute('show_filters', 1); 206 $show_pagination = $form->getAttribute('show_pagination', 1); 207 $norows_placeholder = $form->getAttribute('norows_placeholder', ''); 208 209 // Open the table header region if required 210 if ($show_header || $show_filters) 211 { 212 $html .= "\t\t\t<thead>" . PHP_EOL; 213 } 214 215 // Pre-render the header and filter rows 216 if ($show_header || $show_filters) 217 { 218 $header_html = ''; 219 $filter_html = ''; 220 221 foreach ($headerFields as $header) 222 { 223 // Make sure we have a header field. Under Joomla! 2.5 we cannot 224 // render filter-only fields. 225 $tmpHeader = $header->header; 226 227 if (empty($tmpHeader)) 228 { 229 continue; 230 } 231 232 $tdwidth = $header->tdwidth; 233 234 if (!empty($tdwidth)) 235 { 236 $tdwidth = 'width="' . $tdwidth . '"'; 237 } 238 else 239 { 240 $tdwidth = ''; 241 } 242 243 $header_html .= "\t\t\t\t\t<th $tdwidth>" . PHP_EOL; 244 $header_html .= "\t\t\t\t\t\t" . $tmpHeader; 245 $header_html .= "\t\t\t\t\t</th>" . PHP_EOL; 246 247 $filter = $header->filter; 248 $buttons = $header->buttons; 249 $options = $header->options; 250 251 $filter_html .= "\t\t\t\t\t<td>" . PHP_EOL; 252 253 if (!empty($filter)) 254 { 255 $filter_html .= "\t\t\t\t\t\t$filter" . PHP_EOL; 256 257 if (!empty($buttons)) 258 { 259 $filter_html .= "\t\t\t\t\t\t<nobr>$buttons</nobr>" . PHP_EOL; 260 } 261 } 262 elseif (!empty($options)) 263 { 264 $label = $header->label; 265 $emptyOption = JHtml::_('select.option', '', '- ' . JText::_($label) . ' -'); 266 array_unshift($options, $emptyOption); 267 $attribs = array( 268 'onchange' => 'document.adminForm.submit();' 269 ); 270 $filter = JHtml::_('select.genericlist', $options, $header->name, $attribs, 'value', 'text', $header->value, false, true); 271 $filter_html .= "\t\t\t\t\t\t$filter" . PHP_EOL; 272 } 273 274 $filter_html .= "\t\t\t\t\t</td>" . PHP_EOL; 275 } 276 } 277 278 // Render header if enabled 279 if ($show_header) 280 { 281 $html .= "\t\t\t\t<tr>" . PHP_EOL; 282 $html .= $header_html; 283 $html .= "\t\t\t\t</tr>" . PHP_EOL; 284 } 285 286 // Render filter row if enabled 287 if ($show_filters) 288 { 289 $html .= "\t\t\t\t<tr>"; 290 $html .= $filter_html; 291 $html .= "\t\t\t\t</tr>"; 292 } 293 294 // Close the table header region if required 295 if ($show_header || $show_filters) 296 { 297 $html .= "\t\t\t</thead>" . PHP_EOL; 298 } 299 300 // Loop through rows and fields, or show placeholder for no rows 301 $html .= "\t\t\t<tbody>" . PHP_EOL; 302 $fields = $form->getFieldset('items'); 303 $num_columns = count($fields); 304 $items = $form->getModel()->getItemList(); 305 306 if ($count = count($items)) 307 { 308 $m = 1; 309 310 foreach ($items as $i => $item) 311 { 312 $table_item = $form->getModel()->getTable(); 313 $table_item->reset(); 314 $table_item->bind($item); 315 316 $form->bind($item); 317 318 $m = 1 - $m; 319 $class = 'row' . $m; 320 321 $html .= "\t\t\t\t<tr class=\"$class\">" . PHP_EOL; 322 323 $fields = $form->getFieldset('items'); 324 325 foreach ($fields as $field) 326 { 327 $field->rowid = $i; 328 $field->item = $table_item; 329 $labelClass = $field->labelClass ? $field->labelClass : $field->labelclass; // Joomla! 2.5/3.x use different case for the same name 330 $class = $labelClass ? 'class ="' . $labelClass . '"' : ''; 331 $html .= "\t\t\t\t\t<td $class>" . $field->getRepeatable() . '</td>' . PHP_EOL; 332 } 333 334 $html .= "\t\t\t\t</tr>" . PHP_EOL; 335 } 336 } 337 elseif ($norows_placeholder) 338 { 339 $html .= "\t\t\t\t<tr><td colspan=\"$num_columns\">"; 340 $html .= JText::_($norows_placeholder); 341 $html .= "</td></tr>\n"; 342 } 343 344 $html .= "\t\t\t</tbody>" . PHP_EOL; 345 346 // Render the pagination bar, if enabled 347 348 if ($show_pagination) 349 { 350 $pagination = $form->getModel()->getPagination(); 351 $html .= "\t\t\t<tfoot>" . PHP_EOL; 352 $html .= "\t\t\t\t<tr><td colspan=\"$num_columns\">"; 353 354 if (($pagination->total > 0)) 355 { 356 $html .= $pagination->getListFooter(); 357 } 358 359 $html .= "</td></tr>\n"; 360 $html .= "\t\t\t</tfoot>" . PHP_EOL; 361 } 362 363 // End the table output 364 $html .= "\t\t" . '</table>' . PHP_EOL; 365 366 // End the form 367 $html .= '</form>' . PHP_EOL; 368 369 return $html; 370 } 371 372 /** 373 * Renders a FOFForm for a Read view and returns the corresponding HTML 374 * 375 * @param FOFForm &$form The form to render 376 * @param FOFModel $model The model providing our data 377 * @param FOFInput $input The input object 378 * 379 * @return string The HTML rendering of the form 380 */ 381 protected function renderFormRead(FOFForm &$form, FOFModel $model, FOFInput $input) 382 { 383 $html = $this->renderFormRaw($form, $model, $input, 'read'); 384 385 return $html; 386 } 387 388 /** 389 * Renders a FOFForm for an Edit view and returns the corresponding HTML 390 * 391 * @param FOFForm &$form The form to render 392 * @param FOFModel $model The model providing our data 393 * @param FOFInput $input The input object 394 * 395 * @return string The HTML rendering of the form 396 */ 397 protected function renderFormEdit(FOFForm &$form, FOFModel $model, FOFInput $input) 398 { 399 // Get the key for this model's table 400 $key = $model->getTable()->getKeyName(); 401 $keyValue = $model->getId(); 402 403 JHTML::_('behavior.tooltip'); 404 405 $html = ''; 406 407 $validate = strtolower($form->getAttribute('validate')); 408 $class = ''; 409 410 if (in_array($validate, array('true', 'yes', '1', 'on'))) 411 { 412 JHtml::_('behavior.formvalidation'); 413 $class = 'form-validate '; 414 $this->loadValidationScript($form); 415 } 416 417 // Check form enctype. Use enctype="multipart/form-data" to upload binary files in your form. 418 $template_form_enctype = $form->getAttribute('enctype'); 419 420 if (!empty($template_form_enctype)) 421 { 422 $enctype = ' enctype="' . $form->getAttribute('enctype') . '" '; 423 } 424 else 425 { 426 $enctype = ''; 427 } 428 429 // Check form name. Use name="yourformname" to modify the name of your form. 430 $formname = $form->getAttribute('name'); 431 432 if (empty($formname)) 433 { 434 $formname = 'adminForm'; 435 } 436 437 // Check form ID. Use id="yourformname" to modify the id of your form. 438 $formid = $form->getAttribute('name'); 439 440 if (empty($formid)) 441 { 442 $formid = 'adminForm'; 443 } 444 445 // Check if we have a custom task 446 $customTask = $form->getAttribute('customTask'); 447 448 if (empty($customTask)) 449 { 450 $customTask = ''; 451 } 452 453 // Get the form action URL 454 $actionUrl = FOFPlatform::getInstance()->isBackend() ? 'index.php' : JUri::root().'index.php'; 455 456 if (FOFPlatform::getInstance()->isFrontend() && ($input->getCmd('Itemid', 0) != 0)) 457 { 458 $itemid = $input->getCmd('Itemid', 0); 459 $uri = new JUri($actionUrl); 460 461 if ($itemid) 462 { 463 $uri->setVar('Itemid', $itemid); 464 } 465 466 $actionUrl = JRoute::_($uri->toString()); 467 } 468 469 $html .= '<form action="'.$actionUrl.'" method="post" name="' . $formname . 470 '" id="' . $formid . '"' . $enctype . ' class="' . $class . 471 '">' . PHP_EOL; 472 $html .= "\t" . '<input type="hidden" name="option" value="' . $input->getCmd('option') . '" />' . PHP_EOL; 473 $html .= "\t" . '<input type="hidden" name="view" value="' . $input->getCmd('view', 'edit') . '" />' . PHP_EOL; 474 $html .= "\t" . '<input type="hidden" name="task" value="' . $customTask . '" />' . PHP_EOL; 475 $html .= "\t" . '<input type="hidden" name="' . $key . '" value="' . $keyValue . '" />' . PHP_EOL; 476 477 $html .= "\t" . '<input type="hidden" name="' . JFactory::getSession()->getFormToken() . '" value="1" />' . PHP_EOL; 478 479 $html .= $this->renderFormRaw($form, $model, $input, 'edit'); 480 $html .= '</form>'; 481 482 return $html; 483 } 484 485 /** 486 * Renders a raw FOFForm and returns the corresponding HTML 487 * 488 * @param FOFForm &$form The form to render 489 * @param FOFModel $model The model providing our data 490 * @param FOFInput $input The input object 491 * @param string $formType The form type e.g. 'edit' or 'read' 492 * 493 * @return string The HTML rendering of the form 494 */ 495 protected function renderFormRaw(FOFForm &$form, FOFModel $model, FOFInput $input, $formType) 496 { 497 $html = ''; 498 499 foreach ($form->getFieldsets() as $fieldset) 500 { 501 $html .= $this->renderFieldset($fieldset, $form, $model, $input, $formType, false); 502 } 503 504 return $html; 505 } 506 507 /** 508 * Renders a raw fieldset of a FOFForm and returns the corresponding HTML 509 * 510 * @param stdClass &$fieldset The fieldset to render 511 * @param FOFForm &$form The form to render 512 * @param FOFModel $model The model providing our data 513 * @param FOFInput $input The input object 514 * @param string $formType The form type e.g. 'edit' or 'read' 515 * @param boolean $showHeader Should I render the fieldset's header? 516 * 517 * @return string The HTML rendering of the fieldset 518 */ 519 protected function renderFieldset(stdClass &$fieldset, FOFForm &$form, FOFModel $model, FOFInput $input, $formType, $showHeader = true) 520 { 521 $html = ''; 522 523 $fields = $form->getFieldset($fieldset->name); 524 525 if (isset($fieldset->class)) 526 { 527 $class = 'class="' . $fieldset->class . '"'; 528 } 529 else 530 { 531 $class = ''; 532 } 533 534 $element = empty($fields) ? 'div' : 'fieldset'; 535 $html .= "\t" . '<' . $element . ' id="' . $fieldset->name . '" ' . $class . '>' . PHP_EOL; 536 537 $isTabbedFieldset = $this->isTabFieldset($fieldset); 538 539 if (isset($fieldset->label) && !empty($fieldset->label) && !$isTabbedFieldset) 540 { 541 $html .= "\t\t" . '<h3>' . JText::_($fieldset->label) . '</h3>' . PHP_EOL; 542 } 543 544 foreach ($fields as $field) 545 { 546 $groupClass = $form->getFieldAttribute($field->fieldname, 'groupclass', '', $field->group); 547 548 // Auto-generate label and description if needed 549 // Field label 550 $title = $form->getFieldAttribute($field->fieldname, 'label', '', $field->group); 551 $emptylabel = $form->getFieldAttribute($field->fieldname, 'emptylabel', false, $field->group); 552 553 if (empty($title) && !$emptylabel) 554 { 555 $model->getName(); 556 $title = strtoupper($input->get('option') . '_' . $model->getName() . '_' . $field->id . '_LABEL'); 557 } 558 559 // Field description 560 $description = $form->getFieldAttribute($field->fieldname, 'description', '', $field->group); 561 562 /** 563 * The following code is backwards incompatible. Most forms don't require a description in their form 564 * fields. Having to use emptydescription="1" on each one of them is an overkill. Removed. 565 */ 566 /* 567 $emptydescription = $form->getFieldAttribute($field->fieldname, 'emptydescription', false, $field->group); 568 if (empty($description) && !$emptydescription) 569 { 570 $description = strtoupper($input->get('option') . '_' . $model->getName() . '_' . $field->id . '_DESC'); 571 } 572 */ 573 574 if ($formType == 'read') 575 { 576 $inputField = $field->static; 577 } 578 elseif ($formType == 'edit') 579 { 580 $inputField = $field->input; 581 } 582 583 if (empty($title)) 584 { 585 $html .= "\t\t\t" . $inputField . PHP_EOL; 586 587 if (!empty($description) && $formType == 'edit') 588 { 589 $html .= "\t\t\t\t" . '<span class="help-block">'; 590 $html .= JText::_($description) . '</span>' . PHP_EOL; 591 } 592 } 593 else 594 { 595 $html .= "\t\t\t" . '<div class="fof-row ' . $groupClass . '">' . PHP_EOL; 596 $html .= $this->renderFieldsetLabel($field, $form, $title); 597 $html .= "\t\t\t\t" . $inputField . PHP_EOL; 598 599 if (!empty($description)) 600 { 601 $html .= "\t\t\t\t" . '<span class="help-block">'; 602 $html .= JText::_($description) . '</span>' . PHP_EOL; 603 } 604 605 $html .= "\t\t\t" . '</div>' . PHP_EOL; 606 } 607 } 608 609 $element = empty($fields) ? 'div' : 'fieldset'; 610 $html .= "\t" . '</' . $element . '>' . PHP_EOL; 611 612 return $html; 613 } 614 615 /** 616 * Renders a label for a fieldset. 617 * 618 * @param object $field The field of the label to render 619 * @param FOFForm &$form The form to render 620 * @param string $title The title of the label 621 * 622 * @return string The rendered label 623 */ 624 protected function renderFieldsetLabel($field, FOFForm &$form, $title) 625 { 626 $html = ''; 627 628 $labelClass = $field->labelClass ? $field->labelClass : $field->labelclass; // Joomla! 2.5/3.x use different case for the same name 629 $required = $field->required; 630 631 if ($required) 632 { 633 $labelClass .= ' required'; 634 } 635 636 $tooltip = $form->getFieldAttribute($field->fieldname, 'tooltip', '', $field->group); 637 638 if (!empty($tooltip)) 639 { 640 JHtml::_('behavior.tooltip'); 641 642 $tooltipText = JText::_($title) . '::' . JText::_($tooltip); 643 644 $labelClass .= ' hasTip'; 645 646 $html .= "\t\t\t\t" . '<label id="' . $field->id . '-lbl" class="' . $labelClass . '" for="' . $field->id . '" title="' . $tooltipText . '" rel="tooltip">'; 647 } 648 else 649 { 650 $html .= "\t\t\t\t" . '<label class="' . $labelClass . '" for="' . $field->id . '">'; 651 } 652 653 $html .= JText::_($title); 654 655 if ($required) 656 { 657 $html .= '<span class="star"> *</span>'; 658 } 659 660 $html .= "\t\t\t\t" . '</label>' . PHP_EOL; 661 662 return $html; 663 } 664 665 /** 666 * Loads the validation script for an edit form 667 * 668 * @param FOFForm &$form The form we are rendering 669 * 670 * @return void 671 */ 672 protected function loadValidationScript(FOFForm &$form) 673 { 674 $message = $form->getView()->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED')); 675 676 $js = <<<JS 677Joomla.submitbutton = function(task) 678{ 679 if (task == 'cancel' || document.formvalidator.isValid(document.id('adminForm'))) 680 { 681 Joomla.submitform(task, document.getElementById('adminForm')); 682 } 683 else { 684 alert('$message'); 685 } 686}; 687JS; 688 689 $document = FOFPlatform::getInstance()->getDocument(); 690 691 if ($document instanceof JDocument) 692 { 693 $document->addScriptDeclaration($js); 694 } 695 } 696 697 /** 698 * Renders the submenu (link bar) 699 * 700 * @param string $view The active view name 701 * @param string $task The current task 702 * @param FOFInput $input The input object 703 * @param array $config Extra configuration variables for the toolbar 704 * 705 * @return void 706 */ 707 protected function renderLinkbar($view, $task, $input, $config = array()) 708 { 709 // On command line don't do anything 710 711 if (FOFPlatform::getInstance()->isCli()) 712 { 713 return; 714 } 715 716 // Do not render a submenu unless we are in the the admin area 717 $toolbar = FOFToolbar::getAnInstance($input->getCmd('option', 'com_foobar'), $config); 718 $renderFrontendSubmenu = $toolbar->getRenderFrontendSubmenu(); 719 720 if (!FOFPlatform::getInstance()->isBackend() && !$renderFrontendSubmenu) 721 { 722 return; 723 } 724 725 $this->renderLinkbarItems($toolbar); 726 } 727 728 /** 729 * do the rendering job for the linkbar 730 * 731 * @param FOFToolbar $toolbar A toolbar object 732 * 733 * @return void 734 */ 735 protected function renderLinkbarItems($toolbar) 736 { 737 $links = $toolbar->getLinks(); 738 739 if (!empty($links)) 740 { 741 foreach ($links as $link) 742 { 743 JSubMenuHelper::addEntry($link['name'], $link['link'], $link['active']); 744 } 745 } 746 } 747 748 /** 749 * Renders the toolbar buttons 750 * 751 * @param string $view The active view name 752 * @param string $task The current task 753 * @param FOFInput $input The input object 754 * @param array $config Extra configuration variables for the toolbar 755 * 756 * @return void 757 */ 758 protected function renderButtons($view, $task, $input, $config = array()) 759 { 760 // On command line don't do anything 761 762 if (FOFPlatform::getInstance()->isCli()) 763 { 764 return; 765 } 766 767 // Do not render buttons unless we are in the the frontend area and we are asked to do so 768 $toolbar = FOFToolbar::getAnInstance($input->getCmd('option', 'com_foobar'), $config); 769 $renderFrontendButtons = $toolbar->getRenderFrontendButtons(); 770 771 if (FOFPlatform::getInstance()->isBackend() || !$renderFrontendButtons) 772 { 773 return; 774 } 775 776 // Load main backend language, in order to display toolbar strings 777 // (JTOOLBAR_BACK, JTOOLBAR_PUBLISH etc etc) 778 FOFPlatform::getInstance()->loadTranslations('joomla'); 779 780 $title = JFactory::getApplication()->get('JComponentTitle'); 781 $bar = JToolbar::getInstance('toolbar'); 782 783 // Delete faux links, since if SEF is on, Joomla will follow the link instead of submitting the form 784 $bar_content = str_replace('href="#"', '', $bar->render()); 785 786 echo '<div id="FOFHeaderHolder">', $bar_content, $title, '<div style="clear:both"></div>', '</div>'; 787 } 788} 789