diff --git a/administrator/components/com_admin/sql/updates/mysql/4.1.0-2021-08-09.sql b/administrator/components/com_admin/sql/updates/mysql/4.1.0-2021-08-09.sql new file mode 100644 index 00000000000..4e39ce42304 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/mysql/4.1.0-2021-08-09.sql @@ -0,0 +1,4 @@ +-- Update link to featured +UPDATE `#__menu` + SET `link` = 'index.php?option=com_content&view=articles&featured=1' + WHERE `link` = 'index.php?option=com_content&view=featured'; \ No newline at end of file diff --git a/administrator/components/com_admin/sql/updates/postgresql/4.1.0-2021-08-09.sql b/administrator/components/com_admin/sql/updates/postgresql/4.1.0-2021-08-09.sql new file mode 100644 index 00000000000..0e9b0c6ef6c --- /dev/null +++ b/administrator/components/com_admin/sql/updates/postgresql/4.1.0-2021-08-09.sql @@ -0,0 +1,4 @@ +-- Update link to featured +UPDATE "#__menu" + SET "link" = 'index.php?option=com_content&view=articles&featured=1' + WHERE "link" = 'index.php?option=com_content&view=featured'; diff --git a/administrator/components/com_content/forms/filter_articles.xml b/administrator/components/com_content/forms/filter_articles.xml index 73c1bb84e6f..f95c94a423d 100644 --- a/administrator/components/com_content/forms/filter_articles.xml +++ b/administrator/components/com_content/forms/filter_articles.xml @@ -1,5 +1,18 @@
+ + + + + - - - - - - diff --git a/administrator/components/com_content/src/Controller/ArticlesController.php b/administrator/components/com_content/src/Controller/ArticlesController.php index a037239355c..cf34305773d 100644 --- a/administrator/components/com_content/src/Controller/ArticlesController.php +++ b/administrator/components/com_content/src/Controller/ArticlesController.php @@ -153,4 +153,60 @@ public function getQuickiconContent() echo new JsonResponse($result); } + + /** + * Removes an item. + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + public function delete() + { + $articlesModel = $this->getModel('articles'); + $featured = $articlesModel->isFeatured(); + + if ($featured === "1") + { + // Check for request forgeries + $this->checkToken(); + + $user = $this->app->getIdentity(); + $ids = $this->input->get('cid', array(), 'array'); + + // Access checks. + foreach ($ids as $i => $id) + { + if (!$user->authorise('core.delete', 'com_content.article.' . (int) $id)) + { + // Prune items that you can't delete. + unset($ids[$i]); + $this->app->enqueueMessage(Text::_('JERROR_CORE_DELETE_NOT_PERMITTED'), 'notice'); + } + } + + if (empty($ids)) + { + $this->app->enqueueMessage(Text::_('JERROR_NO_ITEMS_SELECTED'), 'error'); + } + else + { + /** @var \Joomla\Component\Content\Administrator\Model\FeatureModel $model */ + $featureModel = $this->getModel('Feature'); + + // Remove the items. + if (!$featureModel->featured($ids, 0)) + { + $this->app->enqueueMessage($featureModel->getError(), 'error'); + } + } + + $this->setMessage(Text::plural('COM_CONTENT_N_ITEMS_DELETED', \count($ids))); + $this->setRedirect('index.php?option=com_content&view=articles&featured=1'); + } + else + { + parent::delete(); + } + } } diff --git a/administrator/components/com_content/src/Model/ArticlesModel.php b/administrator/components/com_content/src/Model/ArticlesModel.php index e9b8e02a02a..3f159c6be43 100644 --- a/administrator/components/com_content/src/Model/ArticlesModel.php +++ b/administrator/components/com_content/src/Model/ArticlesModel.php @@ -39,6 +39,8 @@ class ArticlesModel extends ListModel */ public function __construct($config = array()) { + $featured = $this->isFeatured(); + if (empty($config['filter_fields'])) { $config['filter_fields'] = array( @@ -55,7 +57,6 @@ public function __construct($config = array()) 'created_by', 'a.created_by', 'created_by_alias', 'a.created_by_alias', 'ordering', 'a.ordering', - 'featured', 'a.featured', 'featured_up', 'fp.featured_up', 'featured_down', 'fp.featured_down', 'language', 'a.language', @@ -72,6 +73,11 @@ public function __construct($config = array()) 'ws.title' ); + if ($featured === '1') + { + $config['filter_fields'][] = 'fp.ordering'; + } + if (Associations::isEnabled()) { $config['filter_fields'][] = 'association'; @@ -145,7 +151,7 @@ protected function populateState($ordering = 'a.id', $direction = 'desc') $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); $this->setState('filter.search', $search); - $featured = $this->getUserStateFromRequest($this->context . '.filter.featured', 'filter_featured', ''); + $featured = $this->isFeatured(); $this->setState('filter.featured', $featured); $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); @@ -349,7 +355,7 @@ protected function getListQuery() } // Filter by featured. - $featured = (string) $this->getState('filter.featured'); + $featured = $this->isFeatured(); if (in_array($featured, ['0','1'])) { @@ -358,6 +364,11 @@ protected function getListQuery() ->bind(':featured', $featured, ParameterType::INTEGER); } + if ($featured === '1') + { + $query->select($this->getDbo()->quoteName('fp.ordering')); + } + // Filter by access level on categories. if (!$user->authorise('core.admin')) { @@ -704,4 +715,16 @@ public function getItems() return $items; } + + /** + * Method to get the value of featured selector. + * + * @return string Returns the value of featured selector. + * + * @since __DEPLOY_VERSION__ + */ + public function isFeatured() + { + return $this->getUserStateFromRequest($this->context . '.featured', 'featured', ''); + } } diff --git a/administrator/components/com_content/src/View/Articles/HtmlView.php b/administrator/components/com_content/src/View/Articles/HtmlView.php index 22071cc3c5e..1ccf72ff35e 100644 --- a/administrator/components/com_content/src/View/Articles/HtmlView.php +++ b/administrator/components/com_content/src/View/Articles/HtmlView.php @@ -96,6 +96,7 @@ public function display($tpl = null) $this->activeFilters = $this->get('ActiveFilters'); $this->vote = PluginHelper::isEnabled('content', 'vote'); $this->hits = ComponentHelper::getParams('com_content')->get('record_hits', 1); + $featured = $this->state->get('filter.featured'); if (!\count($this->items) && $this->isEmptyState = $this->get('IsEmptyState')) { @@ -110,7 +111,7 @@ public function display($tpl = null) } // Check for errors. - if (\count($errors = $this->get('Errors')) || $this->transitions === false) + if (\count($errors = $this->get('Errors')) || ($this->transitions === false && $featured === '1')) { throw new GenericDataException(implode("\n", $errors), 500); } @@ -157,13 +158,21 @@ public function display($tpl = null) */ protected function addToolbar() { - $canDo = ContentHelper::getActions('com_content', 'category', $this->state->get('filter.category_id')); - $user = Factory::getApplication()->getIdentity(); + $canDo = ContentHelper::getActions('com_content', 'category', $this->state->get('filter.category_id')); + $user = Factory::getApplication()->getIdentity(); + $featured = $this->state->get('filter.featured'); // Get the toolbar object instance $toolbar = Toolbar::getInstance('toolbar'); - ToolbarHelper::title(Text::_('COM_CONTENT_ARTICLES_TITLE'), 'copy article'); + if ($featured === '1') + { + ToolbarHelper::title(Text::_('COM_CONTENT_FEATURED_TITLE'), 'star featured'); + } + else + { + ToolbarHelper::title(Text::_('COM_CONTENT_ARTICLES_TITLE'), 'copy article'); + } if ($canDo->get('core.create') || \count($user->getAuthorisedCategories('com_content', 'core.create')) > 0) { @@ -210,15 +219,21 @@ protected function addToolbar() $childBar->unpublish('articles.unpublish')->listCheck(true); - $childBar->standardButton('featured') - ->text('JFEATURE') - ->task('articles.featured') - ->listCheck(true); + if ($featured !== '1') + { + $childBar->standardButton('featured') + ->text('JFEATURE') + ->task('articles.featured') + ->listCheck(true); + } - $childBar->standardButton('circle') - ->text('JUNFEATURE') - ->task('articles.unfeatured') - ->listCheck(true); + if ($featured !== '0') + { + $childBar->standardButton('circle') + ->text('JUNFEATURE') + ->task('articles.unfeatured') + ->listCheck(true); + } $childBar->archive('articles.archive')->listCheck(true); @@ -233,7 +248,8 @@ protected function addToolbar() // Add a batch button if ($user->authorise('core.create', 'com_content') && $user->authorise('core.edit', 'com_content') - && $user->authorise('core.execute.transition', 'com_content')) + && $user->authorise('core.execute.transition', 'com_content') + && $featured !== '1') { $childBar->popupButton('batch') ->text('JTOOLBAR_BATCH') @@ -255,6 +271,13 @@ protected function addToolbar() $toolbar->preferences('com_content'); } - $toolbar->help('JHELP_CONTENT_ARTICLE_MANAGER'); + if ($featured === '1') + { + $toolbar->help('JHELP_CONTENT_ARTICLE_MANAGER'); + } + else + { + ToolbarHelper::help('JHELP_CONTENT_FEATURED_ARTICLES'); + } } } diff --git a/administrator/components/com_content/tmpl/articles/default.php b/administrator/components/com_content/tmpl/articles/default.php index 062d2ff8782..1f31b28f8e7 100644 --- a/administrator/components/com_content/tmpl/articles/default.php +++ b/administrator/components/com_content/tmpl/articles/default.php @@ -31,7 +31,9 @@ $userId = $user->get('id'); $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); -$saveOrder = $listOrder == 'a.ordering'; +$featured = $this->state->get('filter.featured'); +$orderName = $featured === "1" ? 'fp.ordering' : 'a.ordering'; +$saveOrder = $listOrder == $orderName; if (strpos($listOrder, 'publish_up') !== false) { @@ -98,7 +100,7 @@
$this)); + echo LayoutHelper::render('joomla.searchtools.default', array('view' => $this, 'options' => ['selectorFieldName' => 'featured'])); ?> items)) : ?>
@@ -108,7 +110,7 @@ @@ -118,15 +120,15 @@ - +
- , + , ,
- + - - + + - + @@ -174,6 +176,9 @@ class="js-draggable" data-url="" data-direction="" data-nested="true"> items as $i => $item) : $item->max_ordering = 0; + $ordering = ($listOrder == 'fp.ordering'); + $assetId = 'com_content.article.' . $item->id; + $canCreate = $user->authorise('core.create', 'com_content.category.' . $item->catid); $canEdit = $user->authorise('core.edit', 'com_content.article.' . $item->id); $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $userId || is_null($item->checked_out); $canEditOwn = $user->authorise('core.edit.own', 'com_content.article.' . $item->id) && $item->created_by == $userId; @@ -388,19 +393,30 @@ pagination->getListFooter(); ?> - - authorise('core.create', 'com_content') - && $user->authorise('core.edit', 'com_content') - && $user->authorise('core.edit.state', 'com_content')) : ?> + Text::_('COM_CONTENT_BATCH_OPTIONS'), - 'footer' => $this->loadTemplate('batch_footer'), + 'title' => Text::_('JTOOLBAR_CHANGE_STATUS'), + 'footer' => $this->loadTemplate('stage_footer'), ), - $this->loadTemplate('batch_body') + $this->loadTemplate('stage_body') ); ?> + + authorise('core.create', 'com_content') + && $user->authorise('core.edit', 'com_content') + && $user->authorise('core.edit.state', 'com_content')) : ?> + Text::_('COM_CONTENT_BATCH_OPTIONS'), + 'footer' => $this->loadTemplate('batch_footer'), + ), + $this->loadTemplate('batch_body') + ); ?> + diff --git a/administrator/components/com_content/tmpl/articles/default_stage_body.php b/administrator/components/com_content/tmpl/articles/default_stage_body.php new file mode 100644 index 00000000000..3dadb99058e --- /dev/null +++ b/administrator/components/com_content/tmpl/articles/default_stage_body.php @@ -0,0 +1,23 @@ + + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +defined('_JEXEC') or die; + +use Joomla\CMS\Language\Text; + +?> + +
+
+
+

+
+
+
+
+
diff --git a/administrator/components/com_content/tmpl/articles/default_stage_footer.php b/administrator/components/com_content/tmpl/articles/default_stage_footer.php new file mode 100644 index 00000000000..886538176cf --- /dev/null +++ b/administrator/components/com_content/tmpl/articles/default_stage_footer.php @@ -0,0 +1,23 @@ + + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ +defined('_JEXEC') or die; + +use Joomla\CMS\Language\Text; + +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->document->getWebAssetManager(); +$wa->useScript('com_content.admin-articles-stage'); + +?> + + diff --git a/administrator/components/com_menus/presets/alternate.xml b/administrator/components/com_menus/presets/alternate.xml index 761677398d0..c5dc9c16fef 100644 --- a/administrator/components/com_menus/presets/alternate.xml +++ b/administrator/components/com_menus/presets/alternate.xml @@ -294,7 +294,7 @@ title="COM_CONTENT_MENUS_FEATURED" type="component" element="com_content" - link="index.php?option=com_content&view=featured" + link="index.php?option=com_content&view=articles&featured=1" /> diff --git a/installation/sql/mysql/base.sql b/installation/sql/mysql/base.sql index 99199575edf..16d4696c272 100644 --- a/installation/sql/mysql/base.sql +++ b/installation/sql/mysql/base.sql @@ -512,7 +512,7 @@ SELECT 20, 'main', 'com_finder_filters', 'Smart-Search-Filters', '', 'Smart Sear INSERT INTO `#__menu` (`id`, `menutype`, `title`, `alias`, `note`, `path`, `link`, `type`, `published`, `parent_id`, `level`, `component_id`, `browserNav`, `access`, `img`, `template_style_id`, `params`, `lft`, `rgt`, `home`, `language`, `client_id`, `publish_up`, `publish_down`) SELECT 21, 'main', 'com_finder_searches', 'Smart-Search-Searches', '', 'Smart Search/Searches', 'index.php?option=com_finder&view=searches', 'component', 1, 13, 2, `extension_id`, 0, 0, 'class:finder-searches', 0, '', 36, 37, 0, '*', 1, NULL, NULL FROM `#__extensions` WHERE `name` = 'com_finder'; INSERT INTO `#__menu` (`id`, `menutype`, `title`, `alias`, `note`, `path`, `link`, `type`, `published`, `parent_id`, `level`, `component_id`, `browserNav`, `access`, `img`, `template_style_id`, `params`, `lft`, `rgt`, `home`, `language`, `client_id`, `publish_up`, `publish_down`) -SELECT 101, 'mainmenu', 'Home', 'home', '', 'home', 'index.php?option=com_content&view=featured', 'component', 1, 1, 1, `extension_id`, 0, 1, '', 0, '{"featured_categories":[""],"layout_type":"blog","blog_class_leading":"","blog_class":"","num_leading_articles":"1","num_intro_articles":"3","num_links":"0","link_intro_image":"","orderby_pri":"","orderby_sec":"front","order_date":"","show_pagination":"2","show_pagination_results":"1","show_title":"","link_titles":"","show_intro":"","info_block_position":"","info_block_show_title":"","show_category":"","link_category":"","show_parent_category":"","link_parent_category":"","show_associations":"","show_author":"","link_author":"","show_create_date":"","show_modify_date":"","show_publish_date":"","show_item_navigation":"","show_vote":"","show_readmore":"","show_readmore_title":"","show_hits":"","show_tags":"","show_noauth":"","show_feed_link":"1","feed_summary":"","menu-anchor_title":"","menu-anchor_css":"","menu_image":"","menu_image_css":"","menu_text":1,"menu_show":1,"page_title":"","show_page_heading":"1","page_heading":"","pageclass_sfx":"","menu-meta_description":"","robots":""}', 41, 42, 1, '*', 0, NULL, NULL FROM `#__extensions` WHERE `name` = 'com_content'; +SELECT 101, 'mainmenu', 'Home', 'home', '', 'home', 'index.php?option=com_content&view=articles&featured=1', 'component', 1, 1, 1, `extension_id`, 0, 1, '', 0, '{"featured_categories":[""],"layout_type":"blog","blog_class_leading":"","blog_class":"","num_leading_articles":"1","num_intro_articles":"3","num_links":"0","link_intro_image":"","orderby_pri":"","orderby_sec":"front","order_date":"","show_pagination":"2","show_pagination_results":"1","show_title":"","link_titles":"","show_intro":"","info_block_position":"","info_block_show_title":"","show_category":"","link_category":"","show_parent_category":"","link_parent_category":"","show_associations":"","show_author":"","link_author":"","show_create_date":"","show_modify_date":"","show_publish_date":"","show_item_navigation":"","show_vote":"","show_readmore":"","show_readmore_title":"","show_hits":"","show_tags":"","show_noauth":"","show_feed_link":"1","feed_summary":"","menu-anchor_title":"","menu-anchor_css":"","menu_image":"","menu_image_css":"","menu_text":1,"menu_show":1,"page_title":"","show_page_heading":"1","page_heading":"","pageclass_sfx":"","menu-meta_description":"","robots":""}', 41, 42, 1, '*', 0, NULL, NULL FROM `#__extensions` WHERE `name` = 'com_content'; -- -------------------------------------------------------- diff --git a/installation/sql/postgresql/base.sql b/installation/sql/postgresql/base.sql index 8cda51c8fee..43a575fd039 100644 --- a/installation/sql/postgresql/base.sql +++ b/installation/sql/postgresql/base.sql @@ -537,7 +537,7 @@ SELECT 20, 'main', 'com_finder_filters', 'Smart-Search-Filters', '', 'Smart Sear INSERT INTO "#__menu" ("id", "menutype", "title", "alias", "note", "path", "link", "type", "published", "parent_id", "level", "component_id", "browserNav", "access", "img", "template_style_id", "params", "lft", "rgt", "home", "language", "client_id", "publish_up", "publish_down") SELECT 21, 'main', 'com_finder_searches', 'Smart-Search-Searches', '', 'Smart Search/Searches', 'index.php?option=com_finder&view=searches', 'component', 1, 13, 2, "extension_id", 0, 0, 'class:finder-searches', 0, '', 36, 37, 0, '*', 1, NULL, NULL FROM "#__extensions" WHERE "name" = 'com_finder'; INSERT INTO "#__menu" ("id", "menutype", "title", "alias", "note", "path", "link", "type", "published", "parent_id", "level", "component_id", "browserNav", "access", "img", "template_style_id", "params", "lft", "rgt", "home", "language", "client_id", "publish_up", "publish_down") -SELECT 101, 'mainmenu', 'Home', 'home', '', 'home', 'index.php?option=com_content&view=featured', 'component', 1, 1, 1, "extension_id", 0, 1, '', 0, '{"featured_categories":[""],"layout_type":"blog","blog_class_leading":"","blog_class":"","num_leading_articles":"1","num_intro_articles":"3","num_links":"0","link_intro_image":"","orderby_pri":"","orderby_sec":"front","order_date":"","show_pagination":"2","show_pagination_results":"1","show_title":"","link_titles":"","show_intro":"","info_block_position":"","info_block_show_title":"","show_category":"","link_category":"","show_parent_category":"","link_parent_category":"","show_associations":"","show_author":"","link_author":"","show_create_date":"","show_modify_date":"","show_publish_date":"","show_item_navigation":"","show_vote":"","show_readmore":"","show_readmore_title":"","show_hits":"","show_tags":"","show_noauth":"","show_feed_link":"1","feed_summary":"","menu-anchor_title":"","menu-anchor_css":"","menu_image":"","menu_image_css":"","menu_text":1,"menu_show":1,"page_title":"","show_page_heading":"1","page_heading":"","pageclass_sfx":"","menu-meta_description":"","robots":""}', 41, 42, 1, '*', 0, NULL, NULL FROM "#__extensions" WHERE "name" = 'com_content'; +SELECT 101, 'mainmenu', 'Home', 'home', '', 'home', 'index.php?option=com_content&view=articles&featured=1', 'component', 1, 1, 1, "extension_id", 0, 1, '', 0, '{"featured_categories":[""],"layout_type":"blog","blog_class_leading":"","blog_class":"","num_leading_articles":"1","num_intro_articles":"3","num_links":"0","link_intro_image":"","orderby_pri":"","orderby_sec":"front","order_date":"","show_pagination":"2","show_pagination_results":"1","show_title":"","link_titles":"","show_intro":"","info_block_position":"","info_block_show_title":"","show_category":"","link_category":"","show_parent_category":"","link_parent_category":"","show_associations":"","show_author":"","link_author":"","show_create_date":"","show_modify_date":"","show_publish_date":"","show_item_navigation":"","show_vote":"","show_readmore":"","show_readmore_title":"","show_hits":"","show_tags":"","show_noauth":"","show_feed_link":"1","feed_summary":"","menu-anchor_title":"","menu-anchor_css":"","menu_image":"","menu_image_css":"","menu_text":1,"menu_show":1,"page_title":"","show_page_heading":"1","page_heading":"","pageclass_sfx":"","menu-meta_description":"","robots":""}', 41, 42, 1, '*', 0, NULL, NULL FROM "#__extensions" WHERE "name" = 'com_content'; SELECT setval('#__menu_id_seq', 102, false); -- diff --git a/plugins/sampledata/testing/testing.php b/plugins/sampledata/testing/testing.php index 55dbca7c149..2572a32faec 100644 --- a/plugins/sampledata/testing/testing.php +++ b/plugins/sampledata/testing/testing.php @@ -1836,7 +1836,7 @@ public function onAjaxSampledataApplyStep7() array( 'menutype' => $menuTypes[6], 'title' => Text::_('PLG_SAMPLEDATA_TESTING_SAMPLEDATA_MENUS_ITEM_18_TITLE'), - 'link' => 'index.php?option=com_content&view=featured', + 'link' => 'index.php?option=com_content&view=articles&featured=1', 'component_id' => ComponentHelper::getComponent('com_content')->id, 'params' => array( 'num_leading_articles' => 1, @@ -3113,7 +3113,7 @@ public function onAjaxSampledataApplyStep7() array( 'menutype' => $menuTypes[2], 'title' => Text::_('PLG_SAMPLEDATA_TESTING_SAMPLEDATA_MENUS_ITEM_27_0_0_8_1_TITLE'), - 'link' => 'index.php?option=com_content&view=featured', + 'link' => 'index.php?option=com_content&view=articles&featured=1', 'parent_id' => $menuIdsLevel4[8], 'component_id' => ComponentHelper::getComponent('com_content')->id, 'template_style_id' => 3, @@ -3145,7 +3145,7 @@ public function onAjaxSampledataApplyStep7() array( 'menutype' => $menuTypes[2], 'title' => Text::_('PLG_SAMPLEDATA_TESTING_SAMPLEDATA_MENUS_ITEM_27_0_0_7_3_TITLE'), - 'link' => 'index.php?option=com_content&view=featured', + 'link' => 'index.php?option=com_content&view=articles&featured=1', 'parent_id' => $menuIdsLevel4[7], 'component_id' => ComponentHelper::getComponent('com_content')->id, 'template_style_id' => 4, @@ -3177,7 +3177,7 @@ public function onAjaxSampledataApplyStep7() array( 'menutype' => $menuTypes[2], 'title' => Text::_('PLG_SAMPLEDATA_TESTING_SAMPLEDATA_MENUS_ITEM_27_0_0_9_5_TITLE'), - 'link' => 'index.php?option=com_content&view=featured', + 'link' => 'index.php?option=com_content&view=articles&featured=1', 'parent_id' => $menuIdsLevel4[9], 'component_id' => ComponentHelper::getComponent('com_content')->id, 'params' => array(