From a62712e85433083ddcfd2822ae0d2bce680431f0 Mon Sep 17 00:00:00 2001 From: Olivier Buisard Date: Sun, 12 Feb 2023 21:14:58 -0500 Subject: [PATCH] Misc fixes (#59) * CategoriesList is wrongly named * Added buttons for options Removed return for display * Replaced generic icon for page Removed return for display * Better comments signatures * Full list of buttons to remove in editor 'hide' * Fix to show images properly * Fix to show images properly Removed useless publish function * Removed scrap class * Format of title column tag to fix tooltip oddity * URL is required * Missing JEXEC or die * Added column selection * Removed break word on title * Sanitized the description (removed html and truncation) * Review of some key translations * Rename of keys * Add/edit step/tour are not using language keys * Removed toolbar instance * Missing search label * Removed image path replacement * Added image path replacement to ensure images show in the tour * Steps should show only if published * New/Edit tabs are not properly translated * Changed the name of the com_guidedtours asset * Changed translation to N_ITEMS * How to create smart search filters * Update step.xml use VALUE rather than OPTION * Update step.xml --- .../com_guidedtours/forms/filter_steps.xml | 4 +- .../components/com_guidedtours/forms/step.xml | 28 ++-- .../components/com_guidedtours/forms/tour.xml | 3 +- .../com_guidedtours/services/provider.php | 4 + .../src/Controller/DisplayController.php | 4 + .../src/Controller/StepController.php | 4 + .../src/Controller/StepsController.php | 6 + .../src/Controller/TourController.php | 4 + .../src/Controller/ToursController.php | 4 + .../src/Extension/GuidedtoursComponent.php | 4 + .../src/Helper/GuidedtoursHelper.php | 4 + .../com_guidedtours/src/Helper/StepHelper.php | 4 + .../com_guidedtours/src/Model/StepModel.php | 5 +- .../com_guidedtours/src/Model/StepsModel.php | 4 + .../com_guidedtours/src/Model/TourModel.php | 37 +---- .../com_guidedtours/src/Model/ToursModel.php | 4 + .../Service/HTML/oldAdministratorService.php | 131 ------------------ .../com_guidedtours/src/Table/StepTable.php | 6 +- .../com_guidedtours/src/Table/TourTable.php | 8 +- .../src/View/Step/HtmlView.php | 20 +-- .../src/View/Steps/HtmlView.php | 25 +++- .../src/View/Tour/HtmlView.php | 16 ++- .../src/View/Tours/HtmlView.php | 20 ++- .../com_guidedtours/tmpl/step/edit.php | 9 +- .../com_guidedtours/tmpl/steps/default.php | 21 +-- .../com_guidedtours/tmpl/tour/edit.php | 13 +- .../com_guidedtours/tmpl/tours/default.php | 16 ++- .../language/en-GB/com_guidedtours.ini | 59 ++++---- .../language/en-GB/com_guidedtours.sys.ini | 4 +- installation/sql/mysql/base.sql | 2 +- installation/sql/postgresql/base.sql | 2 +- plugins/system/tour/tour.php | 17 ++- 32 files changed, 226 insertions(+), 266 deletions(-) delete mode 100644 administrator/components/com_guidedtours/src/Service/HTML/oldAdministratorService.php diff --git a/administrator/components/com_guidedtours/forms/filter_steps.xml b/administrator/components/com_guidedtours/forms/filter_steps.xml index a7d0eb04fbc73..816e3ce03c6e1 100644 --- a/administrator/components/com_guidedtours/forms/filter_steps.xml +++ b/administrator/components/com_guidedtours/forms/filter_steps.xml @@ -4,14 +4,14 @@ diff --git a/administrator/components/com_guidedtours/forms/step.xml b/administrator/components/com_guidedtours/forms/step.xml index 77d7b7abba9e6..10f277e48762a 100644 --- a/administrator/components/com_guidedtours/forms/step.xml +++ b/administrator/components/com_guidedtours/forms/step.xml @@ -17,22 +17,22 @@ - - - - - + > + + + + + @@ -111,7 +111,7 @@ > - + getTable(); - $pks = (array) $pks; - - $date = Factory::getDate()->toSql(); - - // Clean the cache. - $this->cleanCache(); - - // Ensure that previous checks don't empty the array. - if (empty($pks)) { - return true; - } - - $table->load($pk); - $table->modified = $date; - $table->store(); - - return parent::publish($pks, $value); - } - /** * Method to get a single record. * diff --git a/administrator/components/com_guidedtours/src/Model/ToursModel.php b/administrator/components/com_guidedtours/src/Model/ToursModel.php index 4646f090be990..3c28890542207 100644 --- a/administrator/components/com_guidedtours/src/Model/ToursModel.php +++ b/administrator/components/com_guidedtours/src/Model/ToursModel.php @@ -17,6 +17,10 @@ use Joomla\Database\DatabaseQuery; use Joomla\Database\ParameterType; +// phpcs:disable PSR1.Files.SideEffects +\defined('_JEXEC') or die; +// phpcs:enable PSR1.Files.SideEffects + /** * Model class for Tours * diff --git a/administrator/components/com_guidedtours/src/Service/HTML/oldAdministratorService.php b/administrator/components/com_guidedtours/src/Service/HTML/oldAdministratorService.php deleted file mode 100644 index 5726a5aa190af..0000000000000 --- a/administrator/components/com_guidedtours/src/Service/HTML/oldAdministratorService.php +++ /dev/null @@ -1,131 +0,0 @@ - - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -namespace Joomla\Component\Guidedtours\Administrator\Service\HTML; - -use Joomla\CMS\Factory; -use Joomla\CMS\HTML\HTMLHelper; -use Joomla\CMS\Language\Associations; -use Joomla\CMS\Language\Text; -use Joomla\CMS\Layout\LayoutHelper; -use Joomla\CMS\Router\Route; -use Joomla\Utilities\ArrayHelper; - -/** - * guidedtours HTML helper - * - * @since __DEPLOY_VERSION__ - */ -class AdministratorService -{ - /** - * Render the list of associated items - * - * @param integer $articleid The article item id - * - * @return string The language HTML - * - * @throws \Exception - */ - public function association($articleid) - { - // Defaults - $html = ''; - - // Get the associations - if ( - $associations = Associations::getAssociations( - 'com_guidedtours', - '#__guidedtours', - 'com_guidedtours.item', - $articleid - ) - ) { - foreach ($associations as $tag => $associated) { - $associations[$tag] = (int) $associated->id; - } - - // Get the associated menu items - $db = Factory::getDbo(); - $query = $db->getQuery(true) - ->select('c.*') - ->select('l.sef as lang_sef') - ->select('l.lang_code') - ->from('#__guidedtours as c') - ->select('cat.title as category_title') - ->join('LEFT', '#__categories as cat ON cat.id=c.catid') - ->where('c.id IN (' . implode(',', array_values($associations)) . ')') - ->where('c.id != ' . $articleid) - ->join('LEFT', '#__languages as l ON c.language=l.lang_code') - ->select('l.image') - ->select('l.title as language_title'); - $db->setQuery($query); - - try { - $items = $db->loadObjectList('id'); - } catch (\RuntimeException $e) { - throw new \Exception($e->getMessage(), 500, $e); - } - - if ($items) { - foreach ($items as &$item) { - $text = $item->lang_sef ? strtoupper($item->lang_sef) : 'XX'; - $url = Route::_('index.php?option=com_content&task=article.edit&id=' . (int) $item->id); - $tooltip = '' . htmlspecialchars($item->language_title, ENT_QUOTES, 'UTF-8') . - '
' - . htmlspecialchars($item->title, ENT_QUOTES, 'UTF-8') . '
' . - Text::sprintf('JCATEGORY_SPRINTF', $item->category_title); - $classes = 'badge badge-secondary'; - - $item->link = '' . $text . '' - . ''; - } - } - - $html = LayoutHelper::render('joomla.content.associations', $items); - } - - return $html; - } - - /** - * Show the feature/unfeature links - * - * @param integer $i Row number - * @param boolean $canChange Is user allowed to change? - * @param integer $value The state value - * - * @return string HTML code - */ - public function featured($i, $canChange = true, $value = 0) - { - // Array of image, task, title, action - $states = array( - 0 => array('unfeatured', 'articles.featured', 'COM_CONTENT_UNFEATURED', 'JGLOBAL_TOGGLE_FEATURED'), - 1 => array('featured', 'articles.unfeatured', 'COM_CONTENT_FEATURED', 'JGLOBAL_TOGGLE_FEATURED'), - ); - $state = ArrayHelper::getValue($states, (int) $value, $states[1]); - $icon = $state[0]; - - if ($canChange) { - $html = ''; - } else { - $html = ''; - } - - return $html; - } -} diff --git a/administrator/components/com_guidedtours/src/Table/StepTable.php b/administrator/components/com_guidedtours/src/Table/StepTable.php index 30fd9b067af68..a91ecf65e271c 100644 --- a/administrator/components/com_guidedtours/src/Table/StepTable.php +++ b/administrator/components/com_guidedtours/src/Table/StepTable.php @@ -14,6 +14,10 @@ use Joomla\CMS\Table\Table; use Joomla\Database\DatabaseDriver; +// phpcs:disable PSR1.Files.SideEffects +\defined('_JEXEC') or die; +// phpcs:enable PSR1.Files.SideEffects + /** * Guidedtour_steps table * @@ -28,7 +32,7 @@ class StepTable extends Table * @since __DEPLOY_VERSION__ */ - // phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore + // phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore protected $_supportNullValue = true; /** diff --git a/administrator/components/com_guidedtours/src/Table/TourTable.php b/administrator/components/com_guidedtours/src/Table/TourTable.php index df114b041e781..db8fedcdde6ef 100644 --- a/administrator/components/com_guidedtours/src/Table/TourTable.php +++ b/administrator/components/com_guidedtours/src/Table/TourTable.php @@ -14,6 +14,10 @@ use Joomla\CMS\Table\Table; use Joomla\Database\DatabaseDriver; +// phpcs:disable PSR1.Files.SideEffects +\defined('_JEXEC') or die; +// phpcs:enable PSR1.Files.SideEffects + /** * Guidedtours table * @@ -28,7 +32,7 @@ class TourTable extends Table * @since __DEPLOY_VERSION__ */ - // phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore + // phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore protected $_supportNullValue = true; /** @@ -38,7 +42,7 @@ class TourTable extends Table * @since __DEPLOY_VERSION__ */ - // phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore + // phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore protected $_jsonEncode = array('extensions'); /** diff --git a/administrator/components/com_guidedtours/src/View/Step/HtmlView.php b/administrator/components/com_guidedtours/src/View/Step/HtmlView.php index 4ca44cd2d8420..a09b31ee4d04a 100644 --- a/administrator/components/com_guidedtours/src/View/Step/HtmlView.php +++ b/administrator/components/com_guidedtours/src/View/Step/HtmlView.php @@ -18,6 +18,10 @@ use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Toolbar\ToolbarHelper; +// phpcs:disable PSR1.Files.SideEffects +\defined('_JEXEC') or die; +// phpcs:enable PSR1.Files.SideEffects + /** * View to edit an Step * @@ -28,7 +32,7 @@ class HtmlView extends BaseHtmlView /** * The \JForm object * - * @var \JForm + * @var \Joomla\CMS\Form\Form */ protected $form; @@ -49,7 +53,7 @@ class HtmlView extends BaseHtmlView /** * The actions the user is authorised to perform * - * @var \JObject + * @var \Joomla\CMS\Object\CMSObject */ protected $canDo; @@ -58,7 +62,7 @@ class HtmlView extends BaseHtmlView * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * - * @return mixed A string if successful, otherwise an Error object. + * @return void * * @throws \Exception * @since __DEPLOY_VERSION__ @@ -75,7 +79,7 @@ public function display($tpl = null) $this->addToolbar(); - return parent::display($tpl); + parent::display($tpl); } /** @@ -90,17 +94,13 @@ protected function addToolbar() { Factory::getApplication()->input->set('hidemainmenu', true); - $user = Factory::getUser(); + $user = $this->getCurrentUser(); $userId = $user->id; $isNew = empty($this->item->id); $canDo = ContentHelper::getActions('com_guidedtours'); - $toolbar = Toolbar::getInstance(); - - ToolbarHelper::title( - Text::_('COM_GUIDEDTOURS') . ' - ' . ($isNew ? 'Add Step' : 'Edit Step') - ); + ToolbarHelper::title(Text::_('COM_GUIDEDTOURS') . ' - ' . ($isNew ? Text::_('COM_GUIDEDTOURS_MANAGER_STEP_NEW') : Text::_('COM_GUIDEDTOURS_MANAGER_STEP_EDIT')), 'map-signs'); $toolbarButtons = []; diff --git a/administrator/components/com_guidedtours/src/View/Steps/HtmlView.php b/administrator/components/com_guidedtours/src/View/Steps/HtmlView.php index c78d1647e90be..402822e46e1a5 100644 --- a/administrator/components/com_guidedtours/src/View/Steps/HtmlView.php +++ b/administrator/components/com_guidedtours/src/View/Steps/HtmlView.php @@ -20,6 +20,10 @@ use Joomla\CMS\Router\Route; use Joomla\Component\Guidedtours\Administrator\Helper\GuidedtoursHelper; +// phpcs:disable PSR1.Files.SideEffects +\defined('_JEXEC') or die; +// phpcs:enable PSR1.Files.SideEffects + /** * View class for a list of guidedtour_steps. * @@ -37,21 +41,21 @@ class HtmlView extends BaseHtmlView /** * The pagination object * - * @var \JPagination + * @var \Joomla\CMS\Pagination\Pagination */ protected $pagination; /** * The model state * - * @var \JObject + * @var \Joomla\CMS\Object\CMSObject */ protected $state; /** * Form object for search filters * - * @var \JForm + * @var \Joomla\CMS\Form\Form */ public $filterForm; @@ -76,7 +80,7 @@ class HtmlView extends BaseHtmlView * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * - * @return mixed A string if successful, otherwise an Error object. + * @return void */ public function display($tpl = null) { @@ -97,7 +101,7 @@ public function display($tpl = null) $this->addToolbar(); - return parent::display($tpl); + parent::display($tpl); } /** @@ -109,11 +113,14 @@ public function display($tpl = null) */ protected function addToolbar() { + // Get the toolbar object instance + $toolbar = Toolbar::getInstance('toolbar'); + $canDo = ContentHelper::getActions('com_guidedtours'); - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); - $toolbar = Toolbar::getInstance('toolbar'); $tour_id = $this->state->get('tour_id'); + $title = GuidedtoursHelper::getTourTitle($this->state->get('filter.tour_id'))->title; ToolbarHelper::title(Text::sprintf('COM_GUIDEDTOURS_STEPS_LIST', Text::_($title)), 'map-signs'); $arrow = Factory::getLanguage()->isRtl() ? 'arrow-right' : 'arrow-left'; @@ -155,6 +162,10 @@ protected function addToolbar() ->message('JGLOBAL_CONFIRM_DELETE') ->listCheck(true); } + + if ($user->authorise('core.admin', 'com_guidedtours') || $user->authorise('core.options', 'com_guidedtours')) { + $toolbar->preferences('com_guidedtours'); + } } /** diff --git a/administrator/components/com_guidedtours/src/View/Tour/HtmlView.php b/administrator/components/com_guidedtours/src/View/Tour/HtmlView.php index 44cbf8389f1cd..41597d4c5d7e6 100644 --- a/administrator/components/com_guidedtours/src/View/Tour/HtmlView.php +++ b/administrator/components/com_guidedtours/src/View/Tour/HtmlView.php @@ -18,6 +18,10 @@ use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Toolbar\ToolbarHelper; +// phpcs:disable PSR1.Files.SideEffects +\defined('_JEXEC') or die; +// phpcs:enable PSR1.Files.SideEffects + /** * View to edit an tour. * @@ -28,7 +32,7 @@ class HtmlView extends BaseHtmlView /** * The \JForm object * - * @var \JForm + * @var \Joomla\CMS\Form\Form */ protected $form; @@ -49,7 +53,7 @@ class HtmlView extends BaseHtmlView /** * The actions the user is authorised to perform * - * @var \JObject + * @var \Joomla\CMS\Object\CMSObject */ protected $canDo; @@ -58,7 +62,7 @@ class HtmlView extends BaseHtmlView * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * - * @return mixed A string if successful, otherwise an Error object. + * @return void * * @throws \Exception * @since __DEPLOY_VERSION__ @@ -75,7 +79,7 @@ public function display($tpl = null) $this->addToolbar(); - return parent::display($tpl); + parent::display($tpl); } /** @@ -98,9 +102,7 @@ protected function addToolbar() $toolbar = Toolbar::getInstance(); - ToolbarHelper::title( - Text::_('COM_GUIDEDTOURS') . ' - ' . ($isNew ? 'Add Tour' : 'Edit Tour') - ); + ToolbarHelper::title(Text::_('COM_GUIDEDTOURS') . ' - ' . ($isNew ? Text::_('COM_GUIDEDTOURS_MANAGER_TOUR_NEW') : Text::_('COM_GUIDEDTOURS_MANAGER_TOUR_EDIT')), 'map-signs'); $toolbarButtons = []; diff --git a/administrator/components/com_guidedtours/src/View/Tours/HtmlView.php b/administrator/components/com_guidedtours/src/View/Tours/HtmlView.php index d84e532e961c9..a42020580ab68 100644 --- a/administrator/components/com_guidedtours/src/View/Tours/HtmlView.php +++ b/administrator/components/com_guidedtours/src/View/Tours/HtmlView.php @@ -10,6 +10,7 @@ namespace Joomla\Component\Guidedtours\Administrator\View\Tours; +use Joomla\CMS\Factory; use Joomla\CMS\Helper\ContentHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\View\GenericDataException; @@ -17,6 +18,10 @@ use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Toolbar\ToolbarHelper; +// phpcs:disable PSR1.Files.SideEffects +\defined('_JEXEC') or die; +// phpcs:enable PSR1.Files.SideEffects + /** * View class for a list of guidedtours. * @@ -34,21 +39,21 @@ class HtmlView extends BaseHtmlView /** * The pagination object * - * @var \JPagination + * @var \Joomla\CMS\Pagination\Pagination */ protected $pagination; /** * The model state * - * @var \JObject + * @var \Joomla\CMS\Object\CMSObject */ protected $state; /** * Form object for search filters * - * @var \JForm + * @var \Joomla\CMS\Form\Form */ public $filterForm; @@ -73,7 +78,7 @@ class HtmlView extends BaseHtmlView * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * - * @return mixed A string if successful, otherwise an Error object. + * @return void */ public function display($tpl = null) { @@ -94,7 +99,7 @@ public function display($tpl = null) $this->addToolbar(); - return parent::display($tpl); + parent::display($tpl); } /** @@ -112,6 +117,7 @@ protected function addToolbar() ToolbarHelper::title(Text::_('COM_GUIDEDTOURS_TOURS_LIST'), 'map-signs'); $canDo = ContentHelper::getActions('com_guidedtours'); + $user = Factory::getApplication()->getIdentity(); if ($canDo->get('core.create')) { $toolbar->addNew('tour.add'); @@ -144,5 +150,9 @@ protected function addToolbar() ->message('JGLOBAL_CONFIRM_DELETE') ->listCheck(true); } + + if ($user->authorise('core.admin', 'com_guidedtours') || $user->authorise('core.options', 'com_guidedtours')) { + $toolbar->preferences('com_guidedtours'); + } } } diff --git a/administrator/components/com_guidedtours/tmpl/step/edit.php b/administrator/components/com_guidedtours/tmpl/step/edit.php index 269d8309f0254..eca5b792957e2 100644 --- a/administrator/components/com_guidedtours/tmpl/step/edit.php +++ b/administrator/components/com_guidedtours/tmpl/step/edit.php @@ -12,14 +12,15 @@ use Joomla\CMS\Factory; use Joomla\CMS\HTML\HTMLHelper; -use Joomla\CMS\Language\Associations; use Joomla\CMS\Language\Text; use Joomla\CMS\Layout\LayoutHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\MVC\View\GenericDataException; -HTMLHelper::_('behavior.formvalidator'); -HTMLHelper::_('behavior.keepalive'); +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->document->getWebAssetManager(); +$wa->useScript('keepalive') + ->useScript('form.validate'); $app = Factory::getApplication(); $tour_id = $app->getUserState('com_guidedtours.tour_id'); @@ -40,7 +41,7 @@
'details')); ?> - + item->id) ? Text::_('COM_GUIDEDTOURS_STEP_NEW_STEP') : Text::_('COM_GUIDEDTOURS_STEP_EDIT_STEP')); ?>
diff --git a/administrator/components/com_guidedtours/tmpl/steps/default.php b/administrator/components/com_guidedtours/tmpl/steps/default.php index 493f1350c24b2..a256714f94b77 100644 --- a/administrator/components/com_guidedtours/tmpl/steps/default.php +++ b/administrator/components/com_guidedtours/tmpl/steps/default.php @@ -8,7 +8,10 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +defined('_JEXEC') or die; + use Joomla\CMS\Factory; +use Joomla\CMS\HTML\Helpers\StringHelper; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\Layout\LayoutHelper; @@ -16,9 +19,12 @@ use Joomla\CMS\Session\Session; use Joomla\Component\Guidedtours\Administrator\View\Steps\HtmlView; -/** @var HtmlView $this*/ +/** @var HtmlView $this */ -HTMLHelper::_('behavior.multiselect'); +/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->document->getWebAssetManager(); +$wa->useScript('table.columns') + ->useScript('multiselect'); try { $app = Factory::getApplication(); @@ -65,7 +71,7 @@ items)) : ?> - +
diff --git a/administrator/components/com_guidedtours/tmpl/tour/edit.php b/administrator/components/com_guidedtours/tmpl/tour/edit.php index 9a7c2402728df..c1b5801e21f9b 100644 --- a/administrator/components/com_guidedtours/tmpl/tour/edit.php +++ b/administrator/components/com_guidedtours/tmpl/tour/edit.php @@ -8,6 +8,8 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +defined('_JEXEC') or die; + use Joomla\CMS\Factory; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; @@ -18,20 +20,21 @@ $user = $app->getIdentity(); $input = $app->input; -HTMLHelper::_('behavior.formvalidator'); -HTMLHelper::_('behavior.keepalive'); - +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->document->getWebAssetManager(); +$wa->useScript('keepalive') + ->useScript('form.validate'); ?> + (int) $this->item->id); ?>" method="post" name="adminForm" id="guidedtours-form" class="form-validate">
'details')); ?> - + item->id) ? Text::_('COM_GUIDEDTOURS_NEW_TOUR') : Text::_('COM_GUIDEDTOURS_EDIT_TOUR')); ?>
form->renderField('description'); ?> diff --git a/administrator/components/com_guidedtours/tmpl/tours/default.php b/administrator/components/com_guidedtours/tmpl/tours/default.php index 95038ed2b69e0..8f4bb7644e00e 100644 --- a/administrator/components/com_guidedtours/tmpl/tours/default.php +++ b/administrator/components/com_guidedtours/tmpl/tours/default.php @@ -8,7 +8,10 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +defined('_JEXEC') or die; + use Joomla\CMS\Factory; +use Joomla\CMS\HTML\Helpers\StringHelper; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\Language\Multilanguage; @@ -18,9 +21,12 @@ use Joomla\Component\Guidedtours\Administrator\View\Tours\HtmlView; use Joomla\String\Inflector; -/** @var HtmlView $this*/ +/** @var HtmlView $this */ -HTMLHelper::_('behavior.multiselect'); +/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->document->getWebAssetManager(); +$wa->useScript('table.columns') + ->useScript('multiselect'); try { $app = Factory::getApplication(); @@ -67,7 +73,7 @@ items)) : ?> -
, @@ -186,10 +192,9 @@
- - escape($item->title); ?> + + escape($item->title); ?> + escape($item->title); ?> @@ -202,7 +207,7 @@ - description; ?> + description, 200, true, false); ?>
+
diff --git a/administrator/language/en-GB/com_guidedtours.ini b/administrator/language/en-GB/com_guidedtours.ini index 4ef690c87bc3c..722ecd7f106e8 100644 --- a/administrator/language/en-GB/com_guidedtours.ini +++ b/administrator/language/en-GB/com_guidedtours.ini @@ -13,18 +13,19 @@ COM_GUIDEDTOURS_BASIC_STEP="Basic Step" COM_GUIDEDTOURS_DESCRIPTION="Description" COM_GUIDEDTOURS_DESCRIPTION_ASC="Description ascending"  COM_GUIDEDTOURS_DESCRIPTION_DESC="Description descending" +COM_GUIDEDTOURS_EDIT_TOUR="Edit Tour" COM_GUIDEDTOURS_ERROR_TOUR_NOT_FOUND="Tour not found!" -COM_GUIDEDTOURS_EXTENSIONS_DESC="Will show the tour only for selected extensions. If used tours won't be displayed at other extensions." +COM_GUIDEDTOURS_EXTENSIONS_DESC="Will show the tour for the selected extensions in priority." COM_GUIDEDTOURS_EXTENSIONS_LABEL="Component Selector" COM_GUIDEDTOURS_FIELD_NOTE_LABEL="Note" -COM_GUIDEDTOURS_FIELD_OPTION_BOTTOM="Bottom" -COM_GUIDEDTOURS_FIELD_OPTION_CENTER="Center" -COM_GUIDEDTOURS_FIELD_OPTION_LEFT="Left" -COM_GUIDEDTOURS_FIELD_OPTION_RIGHT="Right" -COM_GUIDEDTOURS_FIELD_OPTION_TOP="Top" +COM_GUIDEDTOURS_FIELD_VALUE_BOTTOM="Bottom" +COM_GUIDEDTOURS_FIELD_VALUE_CENTER="Center" COM_GUIDEDTOURS_FIELD_VALUE_INTERACTIVE_STEP="Interactive" +COM_GUIDEDTOURS_FIELD_VALUE_LEFT="Left" COM_GUIDEDTOURS_FIELD_VALUE_NEXT_STEP="Next" COM_GUIDEDTOURS_FIELD_VALUE_REDIRECT="Redirect" +COM_GUIDEDTOURS_FIELD_VALUE_RIGHT="Right" +COM_GUIDEDTOURS_FIELD_VALUE_TOP="Top" COM_GUIDEDTOURS_FILTER_SEARCH_DESC="Search in id, title and description. Prefix with ID: to search for tour ID or DESCRIPTION: to search only description text." COM_GUIDEDTOURS_GUIDEDTOUR_STEPS_PAGE_TITLE="Guided Tour - List of Steps" COM_GUIDEDTOURS_GUIDEDTOURS_LABEL_DESCRIPTION="Description" @@ -34,30 +35,42 @@ COM_GUIDEDTOURS_INTERACTIVE_STEP_DESC="Click on the type of interactive step whi COM_GUIDEDTOURS_LANGUAGE="Language" COM_GUIDEDTOURS_LANGUAGE_ASC="Language ascending" COM_GUIDEDTOURS_LANGUAGE_DESC="Language descending" -COM_GUIDEDTOURS_N_ITEMS_DELETED_1="Tour deleted." -COM_GUIDEDTOURS_N_ITEMS_DELETED="%s tours deleted." -COM_GUIDEDTOURS_N_ITEMS_PUBLISHED_1="Tour published." -COM_GUIDEDTOURS_N_ITEMS_PUBLISHED="%s tours published." -COM_GUIDEDTOURS_N_ITEMS_TRASHED_1="Tour trashed." -COM_GUIDEDTOURS_N_ITEMS_TRASHED="%s tours trashed." -COM_GUIDEDTOURS_N_ITEMS_UNPUBLISHED_1="Tour unpublished." -COM_GUIDEDTOURS_N_ITEMS_UNPUBLISHED="%s tours unpublished." -COM_GUIDEDTOURS_N_ITEMS_ARCHIVED_1="Tour archived." -COM_GUIDEDTOURS_N_ITEMS_ARCHIVED="%s Tours archived." +COM_GUIDEDTOURS_MANAGER_STEP_EDIT="Edit step" +COM_GUIDEDTOURS_MANAGER_STEP_NEW="New step" +COM_GUIDEDTOURS_MANAGER_TOUR_EDIT="Edit tour" +COM_GUIDEDTOURS_MANAGER_TOUR_NEW="New tour" +COM_GUIDEDTOURS_N_ITEMS_DELETED_1="Item deleted." +COM_GUIDEDTOURS_N_ITEMS_DELETED="%s items deleted." +COM_GUIDEDTOURS_N_ITEMS_PUBLISHED_1="Item published." +COM_GUIDEDTOURS_N_ITEMS_PUBLISHED="%s items published." +COM_GUIDEDTOURS_N_ITEMS_TRASHED_1="Item trashed." +COM_GUIDEDTOURS_N_ITEMS_TRASHED="%s items trashed." +COM_GUIDEDTOURS_N_ITEMS_UNPUBLISHED_1="Item unpublished." +COM_GUIDEDTOURS_N_ITEMS_UNPUBLISHED="%s items unpublished." +COM_GUIDEDTOURS_N_ITEMS_ARCHIVED_1="Item archived." +COM_GUIDEDTOURS_N_ITEMS_ARCHIVED="%s items archived." +COM_GUIDEDTOURS_NEW_TOUR="New Tour" COM_GUIDEDTOURS_ORDER_DESCRIPTION_ASC="Description ascending" COM_GUIDEDTOURS_ORDER_DESCRIPTION_DESC="Description descending" COM_GUIDEDTOURS_ORDER_TYPE_ASC="Type ascending" COM_GUIDEDTOURS_ORDER_TYPE_DESC="Type descending" -COM_GUIDEDTOURS_POSITION_DESC="Add the Position where you want to display your step. e.g. Bottom, Center, Left, Right, Top" -COM_GUIDEDTOURS_POSITION_LABEL="Position" COM_GUIDEDTOURS_RULES_TAB="Permissions" COM_GUIDEDTOURS_STATUS="Status" COM_GUIDEDTOURS_STEP_ASC="Step ascending" COM_GUIDEDTOURS_STEP_DESC="Step descending" +COM_GUIDEDTOURS_STEP_EDIT_STEP="Edit Step" COM_GUIDEDTOURS_STEP_FILTER_SEARCH_DESC="Search in id, title and description. Prefix with ID: to search for step ID or DESCRIPTION: to search only description text." +COM_GUIDEDTOURS_STEP_FILTER_SEARCH_LABEL="Search" COM_GUIDEDTOURS_STEP_ID="ID" +COM_GUIDEDTOURS_STEP_NEW_STEP="New Step" +COM_GUIDEDTOURS_STEP_POSITION_DESC="Select the position of the step popup, relative to the element it points to." +COM_GUIDEDTOURS_STEP_POSITION_LABEL="Position" COM_GUIDEDTOURS_STEP_TITLE="Title" +COM_GUIDEDTOURS_STEP_TARGET_DESC="Add the target element the step will be attached to. Options: .classname, #id, any selector following the CSS syntax (make sure it is a focusable element if the step is interactive), or leave blank for a centered step." +COM_GUIDEDTOURS_STEP_TARGET_LABEL="Target" COM_GUIDEDTOURS_STEP_TYPE="Type" +COM_GUIDEDTOURS_STEP_TYPE_LABEL="Type" +COM_GUIDEDTOURS_STEP_TYPE_DESC="Select the type which you want to select for the tour." COM_GUIDEDTOURS_STEP_TYPE_NEXT_STEP="Next" COM_GUIDEDTOURS_STEP_TYPE_REDIRECT="Redirect" COM_GUIDEDTOURS_STEP_TYPE_INTERACTIVE_STEP="Interactive" @@ -66,8 +79,6 @@ COM_GUIDEDTOURS_STEPS_EMPTYSTATE_CONTENT="A tour can only be functional if steps COM_GUIDEDTOURS_STEPS_EMPTYSTATE_TITLE="No steps for this tour have been created yet." COM_GUIDEDTOURS_STEPS_EMPTYSTATE_BUTTON_ADD="Add your first step" COM_GUIDEDTOURS_STEPS_LIST="Guided Tour: %s" -COM_GUIDEDTOURS_TARGET_DESC="Add the target item to attach your step element to. Options: .classname, #id or leave blank for a centered step." -COM_GUIDEDTOURS_TARGET_LABEL="Target" COM_GUIDEDTOURS_TITLE="Guided Tours" COM_GUIDEDTOURS_TOUR_ID="ID" COM_GUIDEDTOURS_TOUR_TITLE="Title" @@ -75,15 +86,13 @@ COM_GUIDEDTOURS_TOURS_LIST="Guided Tours" COM_GUIDEDTOURS_TOURS_LIST_EMPTYSTATE_BUTTON_ADD="Add your first tour" COM_GUIDEDTOURS_TOURS_LIST_EMPTYSTATE_CONTENT="Create a tour to make it functional." COM_GUIDEDTOURS_TOURS_LIST_EMPTYSTATE_TITLE="No tours have been created yet." -COM_GUIDEDTOURS_TYPE_LABEL="Type" -COM_GUIDEDTOURS_TYPE_DESC="Select the type which you want to select for the tour." COM_GUIDEDTOURS_TYPE_INTERACTIVE_STEP_BUTTON_LABEL="Button" COM_GUIDEDTOURS_TYPE_INTERACTIVE_STEP_LABEL="Interactive Step" -COM_GUIDEDTOURS_TYPE_INTERACTIVE_STEP_OTHERS_LABEL="Others" +COM_GUIDEDTOURS_TYPE_INTERACTIVE_STEP_OTHER_LABEL="Other" COM_GUIDEDTOURS_TYPE_INTERACTIVE_STEP_TEXT_FIELD_LABEL="Text Field" -COM_GUIDEDTOURS_TYPE_REDIRECT_URL_DESC="Enter the Relative URL of the page you want to Start the Tour from eg administrator/index.php?option=com_guidedtours&view=tours for guided tour relative URL." +COM_GUIDEDTOURS_TYPE_REDIRECT_URL_DESC="Enter the relative URL of the page you want the step to redirect to, eg administrator/index.php?option=com_guidedtours&view=tours for the tours' list page." COM_GUIDEDTOURS_TYPE_REDIRECT_URL_LABEL="URL" COM_GUIDEDTOURS_URL_LABEL="URL" -COM_GUIDEDTOURS_URL_DESC="Enter the Relative URL of the page from where you want to Start the Tour e.g administrator/index.php?option=com_guidedtours&view=tours for guided tour relative URL." +COM_GUIDEDTOURS_URL_DESC="Enter the relative URL of the page from where you want to Start the tour, e.g administrator/index.php?option=com_guidedtours&view=tours for the tours' list page." COM_GUIDEDTOURS_XML_DESCRIPTION="Component for managing Guided Tours functionality" diff --git a/administrator/language/en-GB/com_guidedtours.sys.ini b/administrator/language/en-GB/com_guidedtours.sys.ini index 4a8879b566643..0defc3fecfcb0 100644 --- a/administrator/language/en-GB/com_guidedtours.sys.ini +++ b/administrator/language/en-GB/com_guidedtours.sys.ini @@ -23,7 +23,7 @@ COM_GUIDEDTOURS_TOUR_GUIDEDTOURS_STEP_CONTENT_TITLE="Add content" COM_GUIDEDTOURS_TOUR_GUIDEDTOURS_STEP_CONTENT_DESCRIPTION="

Enter content describing the tour.

" COM_GUIDEDTOURS_TOUR_GUIDEDTOURS_STEP_COMPONENT_TITLE="Select a component" -COM_GUIDEDTOURS_TOUR_GUIDEDTOURS_STEP_COMPONENT_DESCRIPTION="

Select the extension(s) where you want to show your tour. For instance, If you are creating a tour for the 'Users' extension, then select 'Users'.

" +COM_GUIDEDTOURS_TOUR_GUIDEDTOURS_STEP_COMPONENT_DESCRIPTION="

Select the extension(s) where you want to show your tour in priority in the list of possible tours to run. For instance, If you are creating a tour for the 'Users' extension, then select 'Users'.

" COM_GUIDEDTOURS_TOUR_GUIDEDTOURS_STEP_URL_TITLE="Add a URL" COM_GUIDEDTOURS_TOUR_GUIDEDTOURS_STEP_URL_DESCRIPTION="

Add the relative URL of the page where the tour must start.

" @@ -316,7 +316,7 @@ COM_GUIDEDTOURS_TOUR_NEWSFEEDS_STEP_SAVECLOSE_DESCRIPTION="

Save and close the COM_GUIDEDTOURS_TOUR_NEWSFEEDS_STEP_CONGRATULATIONS_TITLE="Congratulations!" COM_GUIDEDTOURS_TOUR_NEWSFEEDS_STEP_CONGRATULATIONS_DESCRIPTION="

You have successfully created a news feed!

" -COM_GUIDEDTOURS_TOUR_SMARTSEARCH_TITLE="How to create a smart search filter?" +COM_GUIDEDTOURS_TOUR_SMARTSEARCH_TITLE="How to create smart search filters?" COM_GUIDEDTOURS_TOUR_SMARTSEARCH_DESCRIPTION="

This tour will show you how you can create a smart search filter in Joomla.

" COM_GUIDEDTOURS_TOUR_SMARTSEARCH_STEP_NEW_TITLE="Select the 'New' button" diff --git a/installation/sql/mysql/base.sql b/installation/sql/mysql/base.sql index c9b352d2ef789..1333b2c87af7c 100644 --- a/installation/sql/mysql/base.sql +++ b/installation/sql/mysql/base.sql @@ -108,7 +108,7 @@ INSERT INTO `#__assets` (`id`, `parent_id`, `lft`, `rgt`, `level`, `name`, `titl (88, 18, 126, 127, 2, 'com_modules.module.98', 'Logged-in Users', '{}'), (89, 18, 128, 129, 2, 'com_modules.module.90', 'Login Support', '{}'), (90, 1, 165, 166, 1, 'com_scheduler', 'com_scheduler', '{}'), -(91, 1, 167, 168, 1, 'com_guidedtours.guidedtours.1', 'com_guidedtours', '{}'), +(91, 1, 167, 168, 1, 'com_guidedtours', 'com_guidedtours', '{}'), (92, 18, 130, 131, 2, 'com_modules.module.109', 'Guided Tours', '{}'); -- -------------------------------------------------------- diff --git a/installation/sql/postgresql/base.sql b/installation/sql/postgresql/base.sql index 100ad22531846..cd6dfe2b51ff0 100644 --- a/installation/sql/postgresql/base.sql +++ b/installation/sql/postgresql/base.sql @@ -114,7 +114,7 @@ INSERT INTO "#__assets" ("id", "parent_id", "lft", "rgt", "level", "name", "titl (88, 18, 126, 127, 2, 'com_modules.module.98', 'Logged-in Users', '{}'), (89, 18, 128, 129, 2, 'com_modules.module.90', 'Login Support', '{}'), (90, 1, 165, 166, 1, 'com_scheduler', 'com_scheduler', '{}'), -(91, 1, 167, 168, 1, 'com_guidedtours.guidedtours.1', 'com_guidedtours', '{}'), +(91, 1, 167, 168, 1, 'com_guidedtours', 'com_guidedtours', '{}'), (92, 18, 130, 131, 2, 'com_modules.module.109', 'Guided Tours', '{}'); SELECT setval('#__assets_id_seq', 93, false); diff --git a/plugins/system/tour/tour.php b/plugins/system/tour/tour.php index b61fa63fce9cd..dcf4388c12a2e 100644 --- a/plugins/system/tour/tour.php +++ b/plugins/system/tour/tour.php @@ -14,6 +14,10 @@ use Joomla\CMS\Plugin\CMSPlugin; use Joomla\Event\SubscriberInterface; +// phpcs:disable PSR1.Files.SideEffects +\defined('_JEXEC') or die; +// phpcs:enable PSR1.Files.SideEffects + /** * PlgSystemTour * @@ -129,6 +133,9 @@ protected function getJsonTour($tour_id) $tour = $myTour->getItem($tour_id); + // Replace 'images/' to '../images/' when using an image from /images in backend. + $tour->description = preg_replace('*src\=\"(?!administrator\/)images/*', 'src="../images/', $tour->description); + $mySteps = $factory->createModel( 'Steps', 'Administrator', @@ -136,8 +143,16 @@ protected function getJsonTour($tour_id) ); $mySteps->setState('filter.tour_id', $tour_id); + $mySteps->setState('filter.published', 1); + + $tour_steps = $mySteps->getItems(); + + foreach ($tour_steps as $step) { + // Replace 'images/' to '../images/' when using an image from /images in backend. + $step->description = preg_replace('*src\=\"(?!administrator\/)images/*', 'src="../images/', $step->description); + } - $tour->steps = $mySteps->getItems(); + $tour->steps = $tour_steps; return json_encode($tour); }
, @@ -191,7 +197,7 @@
- - description; ?> + description, 200, true, false); ?>