From d007d1d29d3dd99fa08ebc88e26117c6b8920ee5 Mon Sep 17 00:00:00 2001 From: Tuan Pham Ngoc Date: Sat, 28 Aug 2021 23:25:11 +0700 Subject: [PATCH 1/2] CS --- .../com_weblinks/helpers/weblinks.php | 3 +++ .../models/fields/modal/weblink.php | 11 ++++++++++- .../components/com_weblinks/script.php | 18 ++++++++++++------ .../components/com_weblinks/tables/weblink.php | 3 ++- .../com_weblinks/views/weblinks/view.html.php | 1 + .../com_weblinks/models/category.php | 2 +- src/components/com_weblinks/router.php | 4 ++-- .../views/categories/view.html.php | 1 + .../views/category/tmpl/default_children.php | 4 ++-- .../com_weblinks/views/category/view.html.php | 2 +- src/plugins/finder/weblinks/weblinks.php | 2 +- src/plugins/search/weblinks/weblinks.php | 12 ++++++------ 12 files changed, 42 insertions(+), 21 deletions(-) diff --git a/src/administrator/components/com_weblinks/helpers/weblinks.php b/src/administrator/components/com_weblinks/helpers/weblinks.php index 4fee7153380..987dc21c5a6 100644 --- a/src/administrator/components/com_weblinks/helpers/weblinks.php +++ b/src/administrator/components/com_weblinks/helpers/weblinks.php @@ -146,14 +146,17 @@ public static function countTagItems(&$items, $extension) { $item->count_published = $weblink->count; } + if ($weblink->state == 0) { $item->count_unpublished = $weblink->count; } + if ($weblink->state == 2) { $item->count_archived = $weblink->count; } + if ($weblink->state == -2) { $item->count_trashed = $weblink->count; diff --git a/src/administrator/components/com_weblinks/models/fields/modal/weblink.php b/src/administrator/components/com_weblinks/models/fields/modal/weblink.php index 1a94c60e56b..df393f754a6 100644 --- a/src/administrator/components/com_weblinks/models/fields/modal/weblink.php +++ b/src/administrator/components/com_weblinks/models/fields/modal/weblink.php @@ -65,7 +65,8 @@ protected function getInput() function jSelectWeblink_" . $this->id . "(id, title, catid, object, url, language) { window.processModalSelect('Weblink', '" . $this->id . "', id, title, catid, object, url, language); } - "); + " + ); $scriptSelect[$this->id] = true; } } @@ -94,6 +95,7 @@ function jSelectWeblink_" . $this->id . "(id, title, catid, object, url, languag ->from($db->quoteName('#__weblinks')) ->where($db->quoteName('id') . ' = ' . (int) $value); $db->setQuery($query); + try { $title = $db->loadResult(); @@ -103,6 +105,7 @@ function jSelectWeblink_" . $this->id . "(id, title, catid, object, url, languag JError::raiseWarning(500, $e->getMessage()); } } + $title = empty($title) ? JText::_('COM_WEBLINKS_SELECT_A_WEBLINK') : htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); // The current weblink display field. @@ -122,6 +125,7 @@ function jSelectWeblink_" . $this->id . "(id, title, catid, object, url, languag . ' ' . JText::_('JSELECT') . ''; } + // New weblink button if ($allowNew) { @@ -135,6 +139,7 @@ function jSelectWeblink_" . $this->id . "(id, title, catid, object, url, languag . ' ' . JText::_('JACTION_CREATE') . ''; } + // Edit weblink button if ($allowEdit) { @@ -148,6 +153,7 @@ function jSelectWeblink_" . $this->id . "(id, title, catid, object, url, languag . ' ' . JText::_('JACTION_EDIT') . ''; } + // Clear weblink button if ($allowClear) { @@ -159,6 +165,7 @@ function jSelectWeblink_" . $this->id . "(id, title, catid, object, url, languag . '' . JText::_('JCLEAR') . ''; } + $html .= ''; // Select weblink modal @@ -236,10 +243,12 @@ function jSelectWeblink_" . $this->id . "(id, title, catid, object, url, languag ) ); } + // Note: class='required' for client side validation. $class = $this->required ? ' class="required modal-value"' : ''; $html .= ''; + return $html; } diff --git a/src/administrator/components/com_weblinks/script.php b/src/administrator/components/com_weblinks/script.php index b43cae4d815..8e8e1210099 100644 --- a/src/administrator/components/com_weblinks/script.php +++ b/src/administrator/components/com_weblinks/script.php @@ -153,7 +153,8 @@ private function insertMissingUcmRecords() . $db->quote('com_weblinks.weblink') . ', ' . $db->quote( '{"special":{"dbtable":"#__weblinks","key":"id","type":"Weblink","prefix":"WeblinksTable","config":"array()"}, - "common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}') . ', ' + "common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}' + ) . ', ' . $db->quote('') . ', ' . $db->quote( '{"common":{"core_content_item_id":"id","core_title":"title","core_state":"state","core_alias":"alias", @@ -161,7 +162,8 @@ private function insertMissingUcmRecords() "core_publish_up":"publish_up","core_publish_down":"publish_down","core_access":"access", "core_params":"params", "core_featured":"featured", "core_metadata":"metadata", "core_language":"language", "core_images":"images", "core_urls":"url", "core_version":"version", "core_ordering":"ordering", "core_metakey":"metakey", "core_metadesc":"metadesc", - "core_catid":"catid", "core_xreference":"xreference", "asset_id":"null"}, "special":{}}') . ', ' + "core_catid":"catid", "core_xreference":"xreference", "asset_id":"null"}, "special":{}}' + ) . ', ' . $db->quote('WeblinksHelperRoute::getWeblinkRoute') . ', ' . $db->quote( '{"formFile":"administrator\\/components\\/com_weblinks\\/models\\/forms\\/weblink.xml", @@ -170,7 +172,8 @@ private function insertMissingUcmRecords() "ordering"], "displayLookup":[{"sourceColumn":"catid","targetTable":"#__categories","targetColumn":"id","displayColumn":"title"}, {"sourceColumn":"created_by","targetTable":"#__users","targetColumn":"id","displayColumn":"name"}, {"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id","displayColumn":"title"}, - {"sourceColumn":"modified_by","targetTable":"#__users","targetColumn":"id","displayColumn":"name"} ]}') + {"sourceColumn":"modified_by","targetTable":"#__users","targetColumn":"id","displayColumn":"name"} ]}' + ) ); $db->setQuery($query); @@ -189,7 +192,8 @@ private function insertMissingUcmRecords() . $db->quote('com_weblinks.category') . ', ' . $db->quote(' {"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"}, - "common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}') . ', ' + "common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}' + ) . ', ' . $db->quote('') . ', ' . $db->quote(' {"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias", @@ -198,7 +202,8 @@ private function insertMissingUcmRecords() "core_params":"params", "core_featured":"null", "core_metadata":"metadata", "core_language":"language", "core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey", "core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"}, - "special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}') . ', ' + "special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}' + ) . ', ' . $db->quote('WeblinksHelperRoute::getCategoryRoute') . ', ' . $db->quote(' {"formFile":"administrator\\/components\\/com_categories\\/models\\/forms\\/category.xml", @@ -209,7 +214,8 @@ private function insertMissingUcmRecords() "displayColumn":"name"},{"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id", "displayColumn":"title"},{"sourceColumn":"modified_user_id","targetTable":"#__users","targetColumn":"id", "displayColumn":"name"},{"sourceColumn":"parent_id","targetTable":"#__categories","targetColumn":"id", - "displayColumn":"title"}]}') + "displayColumn":"title"}]}' + ) ); $db->setQuery($query); diff --git a/src/administrator/components/com_weblinks/tables/weblink.php b/src/administrator/components/com_weblinks/tables/weblink.php index 0346630ae8c..d46c86305b3 100644 --- a/src/administrator/components/com_weblinks/tables/weblink.php +++ b/src/administrator/components/com_weblinks/tables/weblink.php @@ -38,7 +38,7 @@ public function __construct(&$db) // Set the published column alias $this->setColumnAlias('published', 'state'); - if (version_compare(JVERSION, '4.0', '<' ) == 1) + if (version_compare(JVERSION, '4.0', '<') == 1) { JTableObserverTags::createObserver($this, array('typeAlias' => 'com_weblinks.weblink')); JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_weblinks.weblink')); @@ -130,6 +130,7 @@ public function check() if (trim($this->title) == '') { $this->setError(JText::_('COM_WEBLINKS_ERR_TABLES_TITLE')); + return false; } diff --git a/src/administrator/components/com_weblinks/views/weblinks/view.html.php b/src/administrator/components/com_weblinks/views/weblinks/view.html.php index f97955f1f5a..dd95828e8f2 100644 --- a/src/administrator/components/com_weblinks/views/weblinks/view.html.php +++ b/src/administrator/components/com_weblinks/views/weblinks/view.html.php @@ -47,6 +47,7 @@ public function display($tpl = null) if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); + return false; } diff --git a/src/components/com_weblinks/models/category.php b/src/components/com_weblinks/models/category.php index 9378226616b..7f01801689a 100644 --- a/src/components/com_weblinks/models/category.php +++ b/src/components/com_weblinks/models/category.php @@ -186,7 +186,7 @@ protected function getListQuery() $search = $db->quote('%' . $db->escape($search, true) . '%'); $query->where('(a.title LIKE ' . $search . ')'); } - + // If grouping by subcategory, add the subcategory list ordering clause. if ($this->getState('category.group', 0)) { diff --git a/src/components/com_weblinks/router.php b/src/components/com_weblinks/router.php index ee5253dfb5b..419434e0a2e 100644 --- a/src/components/com_weblinks/router.php +++ b/src/components/com_weblinks/router.php @@ -65,7 +65,7 @@ public function build(&$query) } // Are we dealing with an weblink that is attached to a menu item? - if (isset($query['view']) && ($mView == $query['view']) and (isset($query['id'])) and ($mId == (int) $query['id'])) + if (isset($query['view']) && ($mView == $query['view']) && (isset($query['id'])) && ($mId == (int) $query['id'])) { unset($query['view']); unset($query['catid']); @@ -74,7 +74,7 @@ public function build(&$query) return $segments; } - if (isset($view) and ($view == 'category' or $view == 'weblink')) + if (isset($view) && ($view == 'category' || $view == 'weblink')) { if ($mId != (int) $query['id'] || $mView != $view) { diff --git a/src/components/com_weblinks/views/categories/view.html.php b/src/components/com_weblinks/views/categories/view.html.php index 25311050cb1..ced41e039e4 100644 --- a/src/components/com_weblinks/views/categories/view.html.php +++ b/src/components/com_weblinks/views/categories/view.html.php @@ -53,6 +53,7 @@ public function display($tpl = null) if (count($errors = $this->get('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); + return false; } diff --git a/src/components/com_weblinks/views/category/tmpl/default_children.php b/src/components/com_weblinks/views/category/tmpl/default_children.php index efac70a140e..2d87674444f 100644 --- a/src/components/com_weblinks/views/category/tmpl/default_children.php +++ b/src/components/com_weblinks/views/category/tmpl/default_children.php @@ -33,9 +33,9 @@ description, '', 'com_weblinks.category'); ?> - + - params->get('show_cat_num_links') == 1) :?> + params->get('show_cat_num_links') == 1) :?>