From 5e79df84d95d46c31e9436bab7a3ce1ee9ad7de0 Mon Sep 17 00:00:00 2001 From: Jerry Christiansen Date: Sat, 31 May 2014 18:09:15 +0200 Subject: [PATCH 1/2] [imp] Move Highlights to layout --- layouts/plugins/system/highlight/default.php | 45 ++++++++++++ plugins/system/highlight/highlight.php | 72 ++++++++------------ 2 files changed, 73 insertions(+), 44 deletions(-) create mode 100644 layouts/plugins/system/highlight/default.php diff --git a/layouts/plugins/system/highlight/default.php b/layouts/plugins/system/highlight/default.php new file mode 100644 index 0000000000..7273819eda --- /dev/null +++ b/layouts/plugins/system/highlight/default.php @@ -0,0 +1,45 @@ +clean($term, 'string')); +} + +// Activate the highlighter. +JHtml::_('behavior.highlighter', $cleanTerms); + +// Adjust the component buffer. +$doc = JFactory::getDocument(); +$buf = $doc->getBuffer('component'); +$buf = '
' . $buf . '
'; +$doc->setBuffer($buf, 'component'); + +return true; \ No newline at end of file diff --git a/plugins/system/highlight/highlight.php b/plugins/system/highlight/highlight.php index e973c77475..bb01065821 100644 --- a/plugins/system/highlight/highlight.php +++ b/plugins/system/highlight/highlight.php @@ -31,57 +31,41 @@ class PlgSystemHighlight extends JPlugin */ public function onAfterDispatch() { - // Check that we are in the site application. - if (JFactory::getApplication()->isAdmin()) - { - return true; - } + // Check that we are in the site application. + if (JFactory::getApplication()->isAdmin()) + { + return true; + } - // Set the variables. - $input = JFactory::getApplication()->input; - $extension = $input->get('option', '', 'cmd'); + // Set the variables. + $input = JFactory::getApplication()->input; + $extension = $input->get('option', '', 'cmd'); - // Check if the highlighter is enabled. - if (!JComponentHelper::getParams($extension)->get('highlight_terms', 1)) - { - return true; - } + // Check if the highlighter is enabled. + if (!JComponentHelper::getParams($extension)->get('highlight_terms', 1)) + { + return true; + } - // Check if the highlighter should be activated in this environment. - if (JFactory::getDocument()->getType() !== 'html' || $input->get('tmpl', '', 'cmd') === 'component') - { - return true; - } + // Check if the highlighter should be activated in this environment. + if (JFactory::getDocument()->getType() !== 'html' || $input->get('tmpl', '', 'cmd') === 'component') + { + return true; + } - // Get the terms to highlight from the request. - $terms = $input->request->get('highlight', null, 'base64'); - $terms = $terms ? json_decode(base64_decode($terms)) : null; + // Get the terms to highlight from the request. + $terms = $input->request->get('highlight', null, 'base64'); + $terms = $terms ? json_decode(base64_decode($terms)) : null; - // Check the terms. - if (empty($terms)) - { - return true; - } + // Check the terms. + if (empty($terms)) + { + return true; + } - // Clean the terms array. - $filter = JFilterInput::getInstance(); - $cleanTerms = array(); + JLayoutHelper::render('plugins.system.highlight.default', array("terms" => $terms)); - foreach ($terms as $term) - { - $cleanTerms[] = htmlspecialchars($filter->clean($term, 'string')); - } - - // Activate the highlighter. - JHtml::_('behavior.highlighter', $cleanTerms); - - // Adjust the component buffer. - $doc = JFactory::getDocument(); - $buf = $doc->getBuffer('component'); - $buf = '
' . $buf . '
'; - $doc->setBuffer($buf, 'component'); - - return true; + return true; } } From 3f01a0c27a18215cf82bd42ef2e38cd310fa5f61 Mon Sep 17 00:00:00 2001 From: Jerry Christiansen Date: Sat, 31 May 2014 18:16:05 +0200 Subject: [PATCH 2/2] [imp] Moved batch to layout --- layouts/libraries/cms/html/batch/access.php | 43 ++++ layouts/libraries/cms/html/batch/item.php | 42 ++++ layouts/libraries/cms/html/batch/language.php | 38 ++++ layouts/libraries/cms/html/batch/tag.php | 36 ++++ layouts/libraries/cms/html/batch/user.php | 43 ++++ libraries/cms/html/batch.php | 192 ++++++------------ 6 files changed, 261 insertions(+), 133 deletions(-) create mode 100644 layouts/libraries/cms/html/batch/access.php create mode 100644 layouts/libraries/cms/html/batch/item.php create mode 100644 layouts/libraries/cms/html/batch/language.php create mode 100644 layouts/libraries/cms/html/batch/tag.php create mode 100644 layouts/libraries/cms/html/batch/user.php diff --git a/layouts/libraries/cms/html/batch/access.php b/layouts/libraries/cms/html/batch/access.php new file mode 100644 index 0000000000..599656c575 --- /dev/null +++ b/layouts/libraries/cms/html/batch/access.php @@ -0,0 +1,43 @@ + '.modal-body')); + +// Create the batch selector to change an access level on a selection list. +echo + '' + . JHtml::_( + 'access.assetgrouplist', + 'batch[assetgroup_id]', '', + 'class="inputbox"', + array( + 'title' => JText::_('JLIB_HTML_BATCH_NOCHANGE'), + 'id' => 'batch-access' + ) + ); + + diff --git a/layouts/libraries/cms/html/batch/item.php b/layouts/libraries/cms/html/batch/item.php new file mode 100644 index 0000000000..e4b7bfb770 --- /dev/null +++ b/layouts/libraries/cms/html/batch/item.php @@ -0,0 +1,42 @@ +' . JText::_('JLIB_HTML_BATCH_MENU_LABEL') . '' + . '
' + . '' + . '
' + . '
' + . JHtml::_('select.radiolist', $options, 'batch[move_copy]', '', 'value', 'text', 'm') + . '
'; \ No newline at end of file diff --git a/layouts/libraries/cms/html/batch/language.php b/layouts/libraries/cms/html/batch/language.php new file mode 100644 index 0000000000..54320e548c --- /dev/null +++ b/layouts/libraries/cms/html/batch/language.php @@ -0,0 +1,38 @@ + '.modal-body')); + +// Create the batch selector to change the language on a selection list. +return +'' +. ''; + + diff --git a/layouts/libraries/cms/html/batch/tag.php b/layouts/libraries/cms/html/batch/tag.php new file mode 100644 index 0000000000..c6513277e3 --- /dev/null +++ b/layouts/libraries/cms/html/batch/tag.php @@ -0,0 +1,36 @@ + '.modal-body')); + +// Create the batch selector to tag items on a selection list. +return + '' + . ''; \ No newline at end of file diff --git a/layouts/libraries/cms/html/batch/user.php b/layouts/libraries/cms/html/batch/user.php new file mode 100644 index 0000000000..3cb00adaac --- /dev/null +++ b/layouts/libraries/cms/html/batch/user.php @@ -0,0 +1,43 @@ + '.modal-body')); + +$optionNo = ''; + +if ($noUser) +{ +$optionNo = ''; +} + +// Create the batch selector to select a user on a selection list. +return +'' +. ''; \ No newline at end of file diff --git a/libraries/cms/html/batch.php b/libraries/cms/html/batch.php index ec48ebfcb7..c25cfc974e 100644 --- a/libraries/cms/html/batch.php +++ b/libraries/cms/html/batch.php @@ -18,141 +18,67 @@ */ abstract class JHtmlBatch { - /** - * Display a batch widget for the access level selector. - * - * @return string The necessary HTML for the widget. - * - * @since 1.7 - */ - public static function access() - { - JHtml::_('bootstrap.tooltip', '.modalTooltip', array('container' => '.modal-body')); + /** + * Display a batch widget for the access level selector. + * + * @return string The necessary HTML for the widget. + * + * @since 1.7 + */ + public static function access() + { + return JLayoutHelper::render('libraries.cms.html.batch.access', array()); + } - // Create the batch selector to change an access level on a selection list. - return - '' - . JHtml::_( - 'access.assetgrouplist', - 'batch[assetgroup_id]', '', - 'class="inputbox"', - array( - 'title' => JText::_('JLIB_HTML_BATCH_NOCHANGE'), - 'id' => 'batch-access' - ) - ); - } + /** + * Displays a batch widget for moving or copying items. + * + * @param string $extension The extension that owns the category. + * + * @return string The necessary HTML for the widget. + * + * @since 1.7 + */ + public static function item($extension) + { + return JLayoutHelper::render('libraries.cms.html.batch.item', array("extension" => $extension)); + } - /** - * Displays a batch widget for moving or copying items. - * - * @param string $extension The extension that owns the category. - * - * @return string The necessary HTML for the widget. - * - * @since 1.7 - */ - public static function item($extension) - { - // Create the copy/move options. - $options = array( - JHtml::_('select.option', 'c', JText::_('JLIB_HTML_BATCH_COPY')), - JHtml::_('select.option', 'm', JText::_('JLIB_HTML_BATCH_MOVE')) - ); + /** + * Display a batch widget for the language selector. + * + * @return string The necessary HTML for the widget. + * + * @since 2.5 + */ + public static function language() + { + return JLayoutHelper::render('libraries.cms.html.batch.language', array()); + } - // Create the batch selector to change select the category by which to move or copy. - return - '' - . '
' - . '' - . '
' - . '
' - . JHtml::_('select.radiolist', $options, 'batch[move_copy]', '', 'value', 'text', 'm') - . '
'; - } + /** + * Display a batch widget for the user selector. + * + * @param boolean $noUser Choose to display a "no user" option + * + * @return string The necessary HTML for the widget. + * + * @since 2.5 + */ + public static function user($noUser = true) + { + return JLayoutHelper::render('libraries.cms.html.batch.user', array("noUser" => $noUser)); + } - /** - * Display a batch widget for the language selector. - * - * @return string The necessary HTML for the widget. - * - * @since 2.5 - */ - public static function language() - { - JHtml::_('bootstrap.tooltip', '.modalTooltip', array('container' => '.modal-body')); - - // Create the batch selector to change the language on a selection list. - return - '' - . ''; - } - - /** - * Display a batch widget for the user selector. - * - * @param boolean $noUser Choose to display a "no user" option - * - * @return string The necessary HTML for the widget. - * - * @since 2.5 - */ - public static function user($noUser = true) - { - JHtml::_('bootstrap.tooltip', '.modalTooltip', array('container' => '.modal-body')); - - $optionNo = ''; - - if ($noUser) - { - $optionNo = ''; - } - - // Create the batch selector to select a user on a selection list. - return - '' - . ''; - } - - /** - * Display a batch widget for the tag selector. - * - * @return string The necessary HTML for the widget. - * - * @since 3.1 - */ - public static function tag() - { - JHtml::_('bootstrap.tooltip', '.modalTooltip', array('container' => '.modal-body')); - - // Create the batch selector to tag items on a selection list. - return - '' - . ''; - } + /** + * Display a batch widget for the tag selector. + * + * @return string The necessary HTML for the widget. + * + * @since 3.1 + */ + public static function tag() + { + return JLayoutHelper::render('libraries.cms.html.batch.tag', array()); + } }