diff --git a/admin/compiler/joomla_3/JViewLegacy_list_site.php b/admin/compiler/joomla_3/JViewLegacy_list_site.php index 17aeb3b43..921980337 100644 --- a/admin/compiler/joomla_3/JViewLegacy_list_site.php +++ b/admin/compiler/joomla_3/JViewLegacy_list_site.php @@ -39,7 +39,7 @@ class ###Component###View###SViews### extends JViewLegacy protected function _prepareDocument() {###SITE_LIBRARIES_LOADER### ###SITE_UIKIT_LOADER### ###SITE_GOOGLECHART_LOADER### ###SITE_FOOTABLE_LOADER### ###SITE_DOCUMENT_METADATA### ###SITE_DOCUMENT_CUSTOM_PHP### // add the document default css file - $this->document->addStyleSheet(JURI::root(true) .'/components/com_###component###/assets/css/###sview###.css', (###Component###Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');###SITE_DOCUMENT_CUSTOM_CSS### ###SITE_DOCUMENT_CUSTOM_JS### + $this->document->addStyleSheet(JURI::root(true) .'/components/com_###component###/assets/css/###sview###.css', (###Component###Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');###SITE_DOCUMENT_CUSTOM_CSS### ###SITE_DOCUMENT_CUSTOM_JS### ###SITE_JAVASCRIPT_FOR_BUTTONS### } /** diff --git a/admin/compiler/joomla_3/JViewLegacy_site.php b/admin/compiler/joomla_3/JViewLegacy_site.php index e7bb300b9..7b6dedd65 100644 --- a/admin/compiler/joomla_3/JViewLegacy_site.php +++ b/admin/compiler/joomla_3/JViewLegacy_site.php @@ -39,7 +39,7 @@ class ###Component###View###SView### extends JViewLegacy protected function _prepareDocument() {###SITE_LIBRARIES_LOADER### ###SITE_UIKIT_LOADER### ###SITE_GOOGLECHART_LOADER### ###SITE_FOOTABLE_LOADER### ###SITE_DOCUMENT_METADATA### ###SITE_DOCUMENT_CUSTOM_PHP### // add the document default css file - $this->document->addStyleSheet(JURI::root(true) .'/components/com_###component###/assets/css/###sview###.css', (###Component###Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');###SITE_DOCUMENT_CUSTOM_CSS### ###SITE_DOCUMENT_CUSTOM_JS### + $this->document->addStyleSheet(JURI::root(true) .'/components/com_###component###/assets/css/###sview###.css', (###Component###Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');###SITE_DOCUMENT_CUSTOM_CSS### ###SITE_DOCUMENT_CUSTOM_JS### ###SITE_JAVASCRIPT_FOR_BUTTONS### } /** diff --git a/admin/compiler/joomla_3/default_list_site.php b/admin/compiler/joomla_3/default_list_site.php index 9be3504a7..72cd3f045 100644 --- a/admin/compiler/joomla_3/default_list_site.php +++ b/admin/compiler/joomla_3/default_list_site.php @@ -18,4 +18,4 @@ defined('_JEXEC') or die('Restricted access'); defined('_JEXEC') or die('Restricted access');###LICENSE_LOCKED_DEFINED### ###SITE_CODE_BODY### ?> -###SITE_TOP_BUTTON### ###SITE_BODY### ###SITE_BOTTOM_BUTTON### +###SITE_TOP_FORM### ###SITE_TOP_BUTTON### ###SITE_BODY### ###SITE_BOTTOM_BUTTON### ###SITE_BOTTOM_FORM### diff --git a/admin/compiler/joomla_3/default_site.php b/admin/compiler/joomla_3/default_site.php index d1cf7e463..72cd3f045 100644 --- a/admin/compiler/joomla_3/default_site.php +++ b/admin/compiler/joomla_3/default_site.php @@ -18,4 +18,4 @@ defined('_JEXEC') or die('Restricted access'); defined('_JEXEC') or die('Restricted access');###LICENSE_LOCKED_DEFINED### ###SITE_CODE_BODY### ?> -###SITE_TOP_BUTTON### ###SITE_BODY### ###SITE_BOTTOM_BUTTON### +###SITE_TOP_FORM### ###SITE_TOP_BUTTON### ###SITE_BODY### ###SITE_BOTTOM_BUTTON### ###SITE_BOTTOM_FORM### diff --git a/admin/helpers/compiler/e_Interpretation.php b/admin/helpers/compiler/e_Interpretation.php index e439ab1f4..0de4bafdb 100644 --- a/admin/helpers/compiler/e_Interpretation.php +++ b/admin/helpers/compiler/e_Interpretation.php @@ -144,6 +144,13 @@ class Interpretation extends Fields */ public $customAdminAdded = array(); + /** + * Switch to add form to site views + * + * @var array + */ + public $addSiteForm = array(); + /** * The extensions params * @@ -3307,16 +3314,12 @@ class Interpretation extends Fields // set custom css file VIEWCSS $this->fileContentDynamic[$view['settings']->code][$this->hhh . $TARGET . '_VIEWCSS' . $this->hhh] = $this->setCustomCSS($view); + // incase no buttons are found + $this->fileContentDynamic[$view['settings']->code][$this->hhh . 'SITE_JAVASCRIPT_FOR_BUTTONS' . $this->hhh] = ''; + // set the custom buttons CUSTOM_BUTTONS $this->fileContentDynamic[$view['settings']->code][$this->hhh . $TARGET . '_CUSTOM_BUTTONS' . $this->hhh] = $this->setCustomButtons($view); - // only set the custom get form method if site target - if ('site' === $this->target) - { - // set the custom get form method SITE_CUSTOM_GET_FORM_METHOD - $this->fileContentDynamic[$view['settings']->code][$this->hhh . 'SITE_CUSTOM_GET_FORM_METHOD' . $this->hhh] = $this->setCustomGetForm($view); - } - // see if we should add get modules to the view.html $this->fileContentDynamic[$view['settings']->code][$this->hhh . $TARGET . '_GET_MODULE' . $this->hhh] = $this->setGetModules($view, $TARGET); @@ -3400,11 +3403,6 @@ class Interpretation extends Fields return ''; } - public function setCustomGetForm(&$view) - { - return ''; - } - public function setDocumentCustomPHP(&$view) { if ($view['settings']->add_php_document == 1) @@ -3498,9 +3496,9 @@ class Interpretation extends Fields if (3 !== $type && ($custom_button['target'] != 2 || $this->target === 'site')) { // add cpanel button TODO does not work well on site with permissions - if ($custom_button['target'] == 2) + if ($custom_button['target'] == 2 || $this->target === 'site') { - $buttons[] = $this->_t(1) . $tab . $this->_t(1) . "if (\$this->user->authorise('" . $viewName . "." . $keyCode . "'))"; + $buttons[] = $this->_t(1) . $tab . $this->_t(1) . "if (\$this->user->authorise('" . $viewName . "." . $keyCode . "', 'com_" . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . "'))"; } else { @@ -3580,12 +3578,32 @@ class Interpretation extends Fields // return buttons if they were build if (ComponentbuilderHelper::checkArray($buttons)) { + // only for site views + if ('site' === $this->target) + { + // set the custom get form method SITE_JAVASCRIPT_FOR_BUTTONS + $this->fileContentDynamic[$view['settings']->code][$this->hhh . 'SITE_JAVASCRIPT_FOR_BUTTONS' . $this->hhh] = $this->setJavaScriptForButtons(); + // insure the form is added + $this->addSiteForm[$view['settings']->code] = true; + } return PHP_EOL . implode(PHP_EOL, $buttons); } } return ''; } + public function setJavaScriptForButtons() + { + // add behavior.framework to insure Joomla function is on the page + $script = array(); + $script[] = $this->_t(2) . "//" . $this->setLine(__LINE__) . " Add the needed Javascript to insure that the buttons work."; + $script[] = $this->_t(2) . "JHtml::_('behavior.framework', true);"; + $script[] = $this->_t(2) . "\$this->document->addScriptDeclaration(\"Joomla.submitbutton = function(task){if (task == ''){ return false; } else { Joomla.submitform(task); return true; }}\");"; + + // return the script + return PHP_EOL . implode(PHP_EOL, $script); + } + public function setFunctionOnlyButtons($viewName_list) { // return buttons if they were build @@ -4216,7 +4234,6 @@ class Interpretation extends Fields } $body[] = $this->setPlaceholders($view['settings']->default, $this->placeholders); $body[] = PHP_EOL . 'items) && isset($this->pagination) && isset($this->pagination->pagesTotal) && $this->pagination->pagesTotal > 1): ?>'; - $body[] = '
'; $body[] = ''; - + // insure the form is added + $this->addSiteForm[$view['settings']->code] = true; + // return the body return implode(PHP_EOL, $body); } else @@ -4243,6 +4261,25 @@ class Interpretation extends Fields } return ''; } + + public function setCustomViewForm(&$view, $type) + { + if (isset($this->addSiteForm[$view]) && $this->addSiteForm[$view]) + { + switch($type) + { + case 1: + // top + return ''; + break; + } + } + return ''; + } public function setCustomViewSubmitButtonScript(&$view) { diff --git a/admin/helpers/compiler/f_Infusion.php b/admin/helpers/compiler/f_Infusion.php index 7e9b286fc..79fef55a6 100644 --- a/admin/helpers/compiler/f_Infusion.php +++ b/admin/helpers/compiler/f_Infusion.php @@ -901,6 +901,10 @@ class Infusion extends Interpretation // setup the templates $this->setCustomViewTemplateBody($view); + + // set the site form if needed + $this->fileContentDynamic[$view['settings']->code][$this->hhh . 'SITE_TOP_FORM' . $this->hhh] = $this->setCustomViewForm($view['settings']->code, 1); + $this->fileContentDynamic[$view['settings']->code][$this->hhh . 'SITE_BOTTOM_FORM' . $this->hhh] = $this->setCustomViewForm($view['settings']->code, 2); } // setup the layouts $this->setCustomViewLayouts(); diff --git a/site/models/api.php b/site/models/api.php index a01d4d9f4..67033eb34 100644 --- a/site/models/api.php +++ b/site/models/api.php @@ -222,5 +222,5 @@ class ComponentbuilderModelApi extends JModelItem // set that the component was not found $this->messages[] = JText::_('COM_COMPONENTBUILDER_COMPONENT_WAS_NOT_FOUND'); return false; - } + } ###SITE_CUSTOM_GET_FORM_METHOD### } diff --git a/site/views/api/tmpl/default.php b/site/views/api/tmpl/default.php index 672f72a4b..529b4d713 100644 --- a/site/views/api/tmpl/default.php +++ b/site/views/api/tmpl/default.php @@ -13,7 +13,7 @@ defined('_JEXEC') or die('Restricted access'); ?> - +