From e610a1e553c05a80ebd50552785377c9c05c1d3a Mon Sep 17 00:00:00 2001 From: Tazzios <23451105+Tazzios@users.noreply.github.com> Date: Sun, 10 Oct 2021 11:12:24 +0200 Subject: [PATCH] button check if jdownloads exists --- editor_button/tmpl/default.php | 136 ++++++++++++++++++--------------- 1 file changed, 75 insertions(+), 61 deletions(-) diff --git a/editor_button/tmpl/default.php b/editor_button/tmpl/default.php index 9652c13..9e69d26 100644 --- a/editor_button/tmpl/default.php +++ b/editor_button/tmpl/default.php @@ -19,22 +19,34 @@ $document->addScript( JUri::root() .'/plugins/editors-xtd/pdfviewer/assets/pdfviewer.js'); -//$document->setTitle('pdf viewer'); - -// get all published jdownloads files -$db = JFactory::getDbo(); -$query = "SELECT id, title FROM #__jdownloads_files WHERE published = 1 ORDER BY publish_up desc"; -$db->setQuery($query); -$fields = $db->loadAssocList(); - -// create an one row array with paramtofind to use for the while check +//check if jdownloads is installed +$path= JPATH_ROOT . '/administrator/components/com_jdownloads'; $dropdown = ''; -foreach ($fields as $field) { +$radiojdownload = ''; +$radioexternalpdf = ''; +if (file_exists( $path )) { + // get all published jdownloads files + $db = JFactory::getDbo(); + $query = "SELECT id, title FROM #__jdownloads_files WHERE published = 1 ORDER BY publish_up desc"; + $db->setQuery($query); + $fields = $db->loadAssocList(); + + // create dropdown with jdownloads files + $dropdown = '
+ +
'; + $radiojdownload = 'checked'; - $dropdown .= ''; +} else { + $radioexternalpdf = 'checked'; + $radiojdownload = 'disabled' ; } -$dropdown .= ''; // Get plugin 'my_plugin' of plugin type 'my_plugin_type' @@ -47,7 +59,6 @@ // Get plugin params $pluginParams = new JRegistry($plugin->params); - //select default in viewer dropdown $paramviewer = $pluginParams->get('viewer'); $selectpdfjs = ''; @@ -68,7 +79,7 @@ } - //select default in style dropdown + //set default from config in style dropdown $paramstyle = $pluginParams->get('style'); $selectembed = ''; $selectpopup = ''; @@ -82,49 +93,43 @@ $selectembed = 'selected'; $setwidth = 'value="'. $pluginParams->get('embedwidth') .'"'; $setheight = 'value="'. $pluginParams->get('embedheight') .'"'; - break; - + break; case "popup": $selectpopup = 'selected'; $setwidth = 'value="'. $pluginParams->get('popupwidth') .'"'; $setheight = 'value="'. $pluginParams->get('popupheight') .'"'; - break; - + break; + case "new": $selectnew = 'selected'; - break; - - default: - + break; + default: $selectpopup = 'selected'; - break; + break; } } ?> +
- + >
- + > - -
- - - - +
+ +