Skip to content
This repository has been archived by the owner on Mar 17, 2020. It is now read-only.

MASTER PR DO NOT MERGE #156

Open
wants to merge 352 commits into
base: 4.0-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
352 commits
Select commit Hold shift + click to select a range
c2a9fbb
Fix filtering issue in articles list
Aug 2, 2017
2f15b10
Fix code style
Aug 2, 2017
998284d
Fix code style
Aug 2, 2017
785391c
Fix issue with run transition, Removes button in toolbar to run trans…
Aug 2, 2017
7274f93
Merge branch '0.0.1-basic' of https://github.com/joomla-projects/GSoC…
Aug 3, 2017
63764e0
Merge branch 'master' of https://github.com/joomla-projects/GSoC17_pu…
Aug 3, 2017
8d026cc
Removes descriptions from fields in adding views, Fix not displaying …
Aug 3, 2017
38f83db
Adds basic acl for toolbar buttons
Aug 3, 2017
52de06d
Adds basic staff to front with errors
Aug 10, 2017
8fd0344
Fix typos
Aug 11, 2017
91d24f2
Remove "archived" status (#69)
bembelimen Aug 11, 2017
fbfaecb
Rename the default workflow (#68)
bembelimen Aug 11, 2017
51913f1
Show workflow menu only if the parameter is activated
bembelimen Aug 11, 2017
2a5197f
Implement frontend filter (#72)
bembelimen Aug 11, 2017
aed6d55
Merge branch 'front-side' of /home/janek/Dokumenty/GSoC/PublishingWor…
Aug 11, 2017
ceb8599
Adds changes from states to workflows to all of models in com_content…
Aug 11, 2017
f23cbb5
Corrects sql queries
Aug 11, 2017
08bd28d
Set published as default state (#73)
bembelimen Aug 12, 2017
70a3685
Merge branch '0.0.1-basic' into front-side
bembelimen Aug 15, 2017
c3b70e5
Fix save as copy (#71)
bembelimen Aug 15, 2017
1a186d7
Correct typo
Aug 15, 2017
f062192
Merge branch 'front-side' of https://github.com/joomla-projects/GSoC1…
Aug 15, 2017
da5d2b9
Merge branch 'front-side' into 0.0.1-basic
Aug 15, 2017
5190905
Merge branch 'master' of https://github.com/joomla-projects/GSoC17_pu…
Aug 15, 2017
db9f642
Fix code style
Aug 15, 2017
22ea314
fixing frontend condition for decide published article (#74)
Buddhima Aug 16, 2017
b274a67
Changes to frontend to work with reordered states (#76)
Buddhima Aug 16, 2017
032a710
Changes archive view to select which state you want, Changes mod arti…
Aug 17, 2017
b1a5c80
Improve ugly part
Aug 17, 2017
0a6bd5d
Multi select states in com_content Archived Articles view
Aug 17, 2017
1ae6a60
fixing front-end issue again (#77)
Buddhima Aug 18, 2017
213110b
Merge branch 'master' of https://github.com/joomla-projects/GSoC17_pu…
Aug 22, 2017
6b7ea8c
Merge branch 'master' of https://github.com/joomla-projects/GSoC17_pu…
Aug 22, 2017
39df0f6
Merge branch '4.0-dev' of https://github.com/joomla/joomla-cms into a…
Aug 22, 2017
7549e82
Merge branch 'archived-status' of https://github.com/joomla-projects/…
Aug 22, 2017
e8ac00a
Merge branch '4.0-dev' of https://github.com/joomla/joomla-cms into a…
Aug 23, 2017
10d8da0
Changes plugins, modules to com_workflow and adds select with availab…
Aug 23, 2017
a171d64
Fix publishing fields in edit view
Aug 24, 2017
3ddf4e2
Fix menu workflow item
Aug 24, 2017
5bf746c
Fix transition select field, Adds acl checking in that field
Aug 24, 2017
21f5291
Fix plugin
Aug 24, 2017
a5dee4c
This trying to fix module issue with passing states
Aug 25, 2017
3ea6fe4
Add states to archive model
bembelimen Aug 25, 2017
0ce67f6
Fix all bugs
Aug 27, 2017
8ecbf76
Fix code style
Aug 27, 2017
0895502
Fix bug with workflows, Fix deletion issue
Aug 27, 2017
6a98f44
Fix featured list view (#83)
Buddhima Aug 27, 2017
4a74000
fix getting state in front end menu-item and module (#81)
Buddhima Aug 27, 2017
b818382
Adds minified version of core.js
Aug 28, 2017
55936ac
Merge branch 'front-side-bugs' of https://github.com/joomla-projects/…
Aug 28, 2017
8ca5202
Update filter_workflows.xml (#87)
coolcat-creations Aug 29, 2017
336e068
Update filter_transitions.xml (#92)
coolcat-creations Aug 29, 2017
dcda9a9
Update filter_states.xml (#93)
coolcat-creations Aug 29, 2017
657462c
Fixed: id of the select list mus be unique, Improve class
chmst Sep 2, 2017
e171ac9
Resolve issue #97, Resolve issue #84, Resolve partly #95
Sep 5, 2017
48c41a3
Changes default view of com_workflow to visible
Sep 5, 2017
daeabf6
Merge pull request #101 from joomla-projects/issues
bembelimen Sep 8, 2017
5faca98
Merge branch '4.0-dev' of github.com:joomla/joomla-cms into staging
bembelimen Sep 8, 2017
754d374
Merge branch 'staging' of github.com:joomla-projects/GSoC17_publishin…
bembelimen Sep 8, 2017
5c0de9f
Improve the default workflow installation
bembelimen Sep 8, 2017
2daa87c
Merge pull request #102 from joomla-projects/creation_date_on_install
bembelimen Sep 8, 2017
1f323e6
Merged modified and creation date
bembelimen Sep 8, 2017
63380cd
Merge pull request #103 from joomla-projects/merge_created_and_modifi…
bembelimen Sep 8, 2017
ef108d2
enable the workflow by default
bembelimen Sep 8, 2017
e13f314
Fix wrong enable default value
bembelimen Sep 8, 2017
5cb54a9
Fix enable check
bembelimen Sep 8, 2017
839c129
Set workflow visibility to 1 as default
bembelimen Sep 8, 2017
6fb4d80
Merge branch 'staging' into publish_parameter
bembelimen Sep 8, 2017
dc3710c
Merge branch 'publish_parameter' of github.com:joomla-projects/GSoC17…
bembelimen Sep 8, 2017
30c0353
Fix wrong component name com_workflows
bembelimen Sep 8, 2017
53a791e
Merge pull request #70 from joomla-projects/publish_parameter
bembelimen Sep 8, 2017
5f25a8b
Merge pull request #98 from chmst/Improve_transition_generic.select_l…
bembelimen Sep 8, 2017
917100e
fixing current date function issue
Buddhima Sep 8, 2017
2383382
Merge pull request #105 from Buddhima/fix_create_time_sql
bembelimen Sep 8, 2017
a9b6933
Fix context when saving a workflow
bembelimen Sep 8, 2017
b4c49ce
Merge pull request #106 from joomla-projects/Fix_context_while_saving
bembelimen Sep 8, 2017
88a0198
Create a default state while creating a new workflow
bembelimen Sep 8, 2017
63b533c
save2copy button added
HRIT-Florian Sep 8, 2017
15761f9
Rename "workflow" to "workflows" in the menu
bembelimen Sep 8, 2017
2f8e5c1
Merge branch 'staging' of github.com:joomla-projects/GSoC17_publishin…
HRIT-Florian Sep 8, 2017
b1ffd48
Auto-populate the model state. filter.extension
HRIT-Florian Sep 8, 2017
7c9bf89
Fix context for state model
bembelimen Sep 8, 2017
c9354af
Merge branch 'staging' of github.com:joomla-projects/GSoC17_publishin…
HRIT-Florian Sep 8, 2017
8118524
save2copy workfolow > states
HRIT-Florian Sep 8, 2017
376da72
Fix saving context in transiton model
bembelimen Sep 9, 2017
0769f1b
Merge branch 'staging' of github.com:joomla-projects/GSoC17_publishin…
HRIT-Florian Sep 9, 2017
ca6b85c
Add number of transitions/states in workflows view
bembelimen Sep 9, 2017
33882e0
Merge branch 'staging' of github.com:joomla-projects/GSoC17_publishin…
HRIT-Florian Sep 9, 2017
602f6ba
Clean up code
HRIT-Florian Sep 9, 2017
dea615c
save2copy workflow > transitions
HRIT-Florian Sep 9, 2017
b05fd2a
generateNewTitle when save2copy added
HRIT-Florian Sep 9, 2017
07bad9b
Merge pull request #107 from Didldu-Florian/save_copy
bembelimen Sep 9, 2017
70a2498
Add published filter for status/transition listing in workflow view
bembelimen Sep 9, 2017
74a4ef3
Fix trashed status when filtered
bembelimen Sep 9, 2017
6707421
Merge transition and state column with special transition
bembelimen Sep 9, 2017
b5180d3
Use plurals for the sidebar
chmst Sep 9, 2017
2f3a470
Align states to the left
bembelimen Sep 9, 2017
d7c3eb5
Converted articles state filter to a grouped list
bembelimen Sep 9, 2017
9588e40
Merge pull request #109 from joomla-projects/transitions_in_article_list
bembelimen Sep 9, 2017
606a7d7
Sniffer satisfaction
bembelimen Sep 9, 2017
f04f855
Sniffer satisfaction
bembelimen Sep 9, 2017
fa1c727
Code cleanup
bembelimen Sep 9, 2017
dd123d8
Fix articles count in category
bembelimen Sep 9, 2017
94260f2
Merge pull request #115 from joomla-projects/fix_sniffer
bembelimen Sep 9, 2017
0ce906d
Fix execute transitions on all articles #112 (#117)
Sep 9, 2017
0b07295
Rename extenstion => extension
bembelimen Sep 9, 2017
3904b7a
Improve state edit layout - move condition from publishing area to ma…
chmst Sep 9, 2017
9fc24fc
Label with generic text
chmst Sep 9, 2017
987bbed
adding new workflow states field
Buddhima Sep 10, 2017
2581a86
fix codesniffer issues
Buddhima Sep 10, 2017
480c779
Merge branch 'staging' of github.com:joomla-projects/GSoC17_publishin…
bembelimen Sep 10, 2017
05cdd51
Merge pull request #116 from joomla-projects/fix_articles_count_in_ca…
bembelimen Sep 10, 2017
8edc355
Merge pull request #118 from chmst/Move_field_condition
bembelimen Sep 10, 2017
c4a6d32
update field class according to suggesstions
Buddhima Sep 10, 2017
95e5d6f
Merge pull request #119 from Buddhima/grouped_state_filter_field
bembelimen Sep 10, 2017
5700ccc
Merge pull request #111 from joomla-projects/grouped_state_filter
bembelimen Sep 10, 2017
0f3f95c
fix issue with settting the default value with state edit form
Buddhima Sep 10, 2017
6d040f9
Merge pull request #120 from Buddhima/fix_issue_states_default
bembelimen Sep 10, 2017
f4a66dd
Reolve https://github.com/joomla-projects/GSoC17_publishing_workflow/…
chmst Sep 10, 2017
d45fcce
Code changed: getTable, use sprintf
chmst Sep 10, 2017
c5e3671
Unpublish new copy
HRIT-Florian Sep 10, 2017
c7bc6d9
Merge pull request #123 from Didldu-Florian/save_copy
bembelimen Sep 10, 2017
0f2fe70
Save2copy for states
HRIT-Florian Sep 10, 2017
9061873
save2copy check if title exists
HRIT-Florian Sep 10, 2017
9bd1e14
Merge pull request #122 from chmst/more_plurals_in_sidebar
bembelimen Sep 10, 2017
2fe7b6d
Disable the switcher on edit state if the state is default
chmst Sep 10, 2017
bfb899e
Fixed getValue
chmst Sep 11, 2017
5810ae5
Merge pull request #125 from chmst/disable_default-switcher_on_edit_s…
bembelimen Sep 11, 2017
71dcc6b
Simplified and escaped
chmst Sep 11, 2017
cda42b9
fixed: check for table-entry workflow
chmst Sep 11, 2017
6e963f3
Merge pull request #121 from chmst/Workflow_name_in_lists
bembelimen Sep 11, 2017
c6afde7
merge 4.0-dev
zero-24 Sep 11, 2017
dfdbd14
recompile core.min.js
zero-24 Sep 11, 2017
4a5672a
Fix new class structure
bembelimen Sep 11, 2017
5c2c1a6
Fix #110 deletion of trashed articles
bembelimen Sep 12, 2017
7298671
Readd featuring articles
bembelimen Sep 12, 2017
9fdaa16
Adds ordering to the states and transitions #94
Sep 13, 2017
b544eb2
adding current state to article edit view, transition drop-down
Buddhima Sep 16, 2017
a74dfad
remove default value in XML config
Buddhima Sep 16, 2017
4381447
Merge pull request #128 from Buddhima/improve_article_edit_transition
bembelimen Sep 16, 2017
1a9727f
Shorten return code
bembelimen Sep 16, 2017
ed9caed
Merge pull request #129 from joomla-projects/improve_article_edit_tra…
bembelimen Sep 16, 2017
cea5f1a
Merge remote-tracking branch 'origin/staging' into ordering
Sep 20, 2017
4545873
Moved form xml to "forms" folder
bembelimen Sep 29, 2017
54c8842
Moved validation to the table class
bembelimen Sep 29, 2017
b8e8541
Merge branch '4.0-dev' of github.com:joomla/joomla-cms into staging
bembelimen Sep 29, 2017
58cddb0
Add deploy version instead of a normal version
bembelimen Sep 29, 2017
057b8e2
Add more deploy versions
bembelimen Sep 29, 2017
b3688ff
Merge pull request #124 from Didldu-Florian/save_copy
bembelimen Sep 29, 2017
58e9fc6
Merge branch 'staging' into improve_saving
bembelimen Sep 29, 2017
0442c28
Fix saving with workflow_id
bembelimen Sep 30, 2017
237a912
Merge pull request #134 from joomla-projects/Deploy_version
bembelimen Sep 30, 2017
db4fdcc
Merge pull request #133 from joomla-projects/improve_saving
bembelimen Sep 30, 2017
6a28c8e
adding workflow_associations table structure
Buddhima Sep 27, 2017
cdf27ae
fix sql issue
Buddhima Sep 30, 2017
3c0ffc2
adding new workflow-association manipulations
Buddhima Sep 30, 2017
0b5d565
change article saving to use associations
Buddhima Sep 30, 2017
c4a59ab
changing article saving, transition saving actions to do via associat…
Buddhima Sep 30, 2017
7c43e94
update state filtering field to use workflow_associations
Buddhima Sep 30, 2017
01de3b7
fix issue with identifying transitionId when executing runTransition
Buddhima Sep 30, 2017
beb54f7
First rewrite to reflect the new class convention
bembelimen Sep 30, 2017
52b7736
Change table class where needed
bembelimen Sep 30, 2017
09544f4
Fix wrong language string
bembelimen Sep 30, 2017
8e432ca
More table fixes
bembelimen Sep 30, 2017
a15abdf
Next table classname fix
bembelimen Sep 30, 2017
6b8ca8b
Table::getInstance => new Table
bembelimen Sep 30, 2017
2e74e67
Sniffer fixes
bembelimen Sep 30, 2017
6dd98e4
Fix where in workflow table
bembelimen Sep 30, 2017
5994700
Fix where in workflow table
bembelimen Sep 30, 2017
5d885ca
Fix saving error for workflows
bembelimen Sep 30, 2017
808e91f
adding comments and remove an unnecessary method
Buddhima Oct 1, 2017
23b3e6f
Move the main properties auf a transition from the right column to th…
chmst Oct 1, 2017
15388f2
Merge pull request #135 from Buddhima/workflow_associations_impl
Buddhima Oct 1, 2017
66e037c
move namespace to state filter field
Buddhima Oct 1, 2017
7d86308
update featured article view according to articles view changes
Buddhima Oct 1, 2017
a116283
fixing style issue in featured default
Buddhima Oct 1, 2017
353da7e
style fixing in featured default 2
Buddhima Oct 1, 2017
1bccea0
style fixing in featured default 3
Buddhima Oct 1, 2017
7f81551
Merge branch 'staging' of https://github.com/joomla-projects/GSoC17_p…
Oct 2, 2017
3177778
Merge branch 'staging' into ordering
bembelimen Oct 3, 2017
6c5036d
Set default values
bembelimen Oct 3, 2017
c0fb0de
Merge branch 'staging' into ordering
bembelimen Oct 3, 2017
be3369f
Move table for workflow association
bembelimen Oct 3, 2017
20a95b6
Fix sql default value
bembelimen Oct 3, 2017
592c9bd
Move table for workflow association
bembelimen Oct 3, 2017
69d2f79
Merge branch 'staging' into ordering
bembelimen Oct 3, 2017
ca9693e
Merge branch '4.0-dev' of github.com:joomla/joomla-cms into staging
bembelimen Oct 3, 2017
b7faf2c
Remove colored workflow param select
bembelimen Oct 3, 2017
1abef37
Merge branch 'staging' of github.com:joomla-projects/GSoC17_publishin…
bembelimen Oct 3, 2017
640546a
Add workflow ordering
bembelimen Oct 3, 2017
cf7c0eb
Merge pull request #136 from chmst/improve-transition-edit-view
bembelimen Oct 3, 2017
3356864
Merge pull request #137 from Buddhima/update_featured_article_view_wi…
Buddhima Oct 3, 2017
82d82f1
adding final state in transition drop-down
Buddhima Oct 3, 2017
233d6ec
adding workflow helper to return condition name and append it to the …
Buddhima Oct 3, 2017
ce379ac
Add ordering to the state and transition
Oct 3, 2017
10cc00c
Merge branch 'ordering' of https://github.com/joomla-projects/GSoC17_…
Oct 3, 2017
26838ea
Add condition to the transition field
bembelimen Oct 5, 2017
fd99424
Merge pull request #1 from joomla-projects/add_state_in_transition_text
Buddhima Oct 5, 2017
829c410
Merge pull request #142 from Buddhima/add_state_in_transition_text
Buddhima Oct 5, 2017
e1df907
implementing delete record in workflow associations table when deleti…
Buddhima Oct 5, 2017
a9e3b1f
Merge pull request #144 from Buddhima/impl_workflow_associations_delete
Buddhima Oct 5, 2017
22ff96e
update admin mod_latest to use workflow_state
Buddhima Oct 5, 2017
12dbc84
Fixing issues from review
Oct 7, 2017
8e0df22
Merge remote-tracking branch 'origin/staging' into ordering
Oct 7, 2017
04c4967
Fixing conlict with staging
Oct 7, 2017
95f318b
Fixing projection to int on workflow_id
Oct 7, 2017
62476b5
Merge pull request #143 from joomla-projects/ordering
bembelimen Oct 7, 2017
4eef4fa
fixing issues with using workflow_associations in category view
Buddhima Oct 7, 2017
be78904
update archive articles modulw with workflow_association changes
Buddhima Oct 8, 2017
b091911
fixing transition field ambiguity in ordering
Buddhima Oct 8, 2017
6dc75ed
Merge pull request #149 from Buddhima/fix_transition-field_ordering
Buddhima Oct 8, 2017
ded7185
Merge pull request #147 from Buddhima/fixing_category_list_view
Buddhima Oct 8, 2017
6574b04
adding layouts for batch processing
Buddhima Oct 9, 2017
57ce615
fixing display issues with workflow states dropdown
Buddhima Oct 9, 2017
96c37db
adding workfow state change functionality
Buddhima Oct 9, 2017
175185c
adding access control checks for workflows list related places
Buddhima Oct 14, 2017
96e4750
few modifications to workflow model
Buddhima Oct 14, 2017
3efb1b8
update controller and models of state, transition
Buddhima Oct 14, 2017
3312363
modify config files according to com_workflow permission hierarchy
Buddhima Oct 18, 2017
25ecaae
refactor models and views to use permissions
Buddhima Oct 21, 2017
624ecfe
fix suggesstion in PR
Buddhima Oct 21, 2017
bdbef68
fix for adding users
Buddhima Oct 22, 2017
1025334
adding transition.run permission to com_content entry
Buddhima Oct 22, 2017
cc11b56
fixing workflow saving issue and use permissions for list view state …
Buddhima Oct 22, 2017
62131fe
fix suggesstion in PR-2
Buddhima Oct 22, 2017
7b5b9d6
fixing suggesstion in PR
Buddhima Oct 23, 2017
84a10e3
Merge branch 'master' into staging
bembelimen Dec 14, 2017
cc22a18
Merge branch '4.0-dev' into 4.0_alpha_integration
bembelimen Dec 23, 2017
d2ec5c4
Merge pull request #155 from joomla-projects/4.0_alpha_integration
bembelimen Dec 23, 2017
7e29b1b
Rename transition.run => core.execute.transition
bembelimen Dec 23, 2017
e8dd905
Merge pull request #157 from joomla-projects/impl_access_control
bembelimen Dec 23, 2017
8f46f7f
Merge branch 'staging' into update_archive_article_with_associations
bembelimen Dec 23, 2017
0486060
Add parameter to WorkflowState field, so it's possible to show all st…
bembelimen Dec 23, 2017
570a30b
Merge pull request #158 from joomla-projects/update_archive_article_w…
bembelimen Dec 23, 2017
49d8c8a
Merge branch 'staging' into implementing_batch_processing
bembelimen Dec 23, 2017
c6e230c
Add permission check for batch transition executions
bembelimen Dec 23, 2017
c29a2cb
Fix broken transition batch
bembelimen Dec 23, 2017
c4f4a7e
Merge pull request #159 from joomla-projects/implementing_batch_proce…
bembelimen Dec 23, 2017
5f81e50
Merge pull request #145 from Buddhima/update_admin_module
bembelimen Dec 23, 2017
56b9ca9
Set transition batch execution to super users only
bembelimen Dec 23, 2017
7c3d60c
Implement some cleanups
bembelimen Dec 26, 2017
b6a1429
Fix article saving
bembelimen Dec 26, 2017
c207fbb
Implement email notification for transition execution
bembelimen Dec 26, 2017
7ff5bb1
Merge pull request #160 from joomla-projects/email_notification
bembelimen Dec 26, 2017
c06af6e
Rename the transition dropdown in the article edit form
bembelimen Dec 26, 2017
71e3a8f
Readd save2copy
bembelimen Dec 27, 2017
2976e68
Convert frontend state to transition in edit form
bembelimen Jan 8, 2018
e2c437a
Merge branch '4.0-dev' into staging
bembelimen Jan 15, 2018
c4a451b
Merge 4.0 dev from core
bembelimen Jan 18, 2018
7502626
Merge branch '4.0-dev' into staging
bembelimen Apr 26, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions administrator/components/com_categories/Model/CategoryModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -388,15 +388,9 @@ protected function preprocessForm(\JForm $form, $data, $group = 'content')
// Get the component form if it exists
$name = 'category' . ($section ? ('.' . $section) : '');

// Looking first in the component forms folder
// Looking first in the component models/forms folder
$path = \JPath::clean(JPATH_ADMINISTRATOR . "/components/$component/forms/$name.xml");

// Looking in the component models/forms folder (J! 3)
if (!file_exists($path))
{
$path = \JPath::clean(JPATH_ADMINISTRATOR . "/components/$component/models/forms/$name.xml");
}

// Old way: looking in the component folder
if (!file_exists($path))
{
Expand Down Expand Up @@ -499,7 +493,7 @@ public function save($data)
$isNew = true;
$context = $this->option . '.' . $this->name;

if (!empty($data['tags']) && $data['tags'][0] != '')
if ((!empty($data['tags']) && $data['tags'][0] != ''))
{
$table->newTags = $data['tags'];
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes in this file seem not to be related to Workflow.

Expand Down
168 changes: 141 additions & 27 deletions administrator/components/com_content/Helper/ContentHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

namespace Joomla\Component\Content\Administrator\Helper;

use Joomla\CMS\Factory;

defined('_JEXEC') or die;

/**
Expand Down Expand Up @@ -41,6 +43,34 @@ public static function addSubmenu($vName)
'index.php?option=com_categories&extension=com_content',
$vName == 'categories'
);

if (\JComponentHelper::isEnabled('com_workflow') && \JComponentHelper::getParams('com_content')->get('workflows_enable', 1))
{
\JHtmlSidebar::addEntry(
\JText::_('COM_CONTENT_SUBMENU_WORKFLOWS'),
'index.php?option=com_workflow&extension=com_content',
$vName == 'workflows'
);

if ($vName == 'states' || $vName == 'transitions')
{
$app = Factory::getApplication();
$workflowID = $app->getUserStateFromRequest('filter.workflow_id', 'workflow_id', 1, 'int');

\JHtmlSidebar::addEntry(
\JText::_('COM_WORKFLOW_STATES'),
'index.php?option=com_workflow&view=states&workflow_id=' . $workflowID . "&extension=com_content",
$vName == 'states`'
);

\JHtmlSidebar::addEntry(
\JText::_('COM_WORKFLOW_TRANSITIONS'),
'index.php?option=com_workflow&view=transitions&workflow_id=' . $workflowID . "&extension=com_content",
$vName == 'transitions'
);
}
}

\JHtmlSidebar::addEntry(
\JText::_('COM_CONTENT_SUBMENU_FEATURED'),
'index.php?option=com_content&view=featured',
Expand Down Expand Up @@ -104,36 +134,38 @@ public static function countItems(&$items)

foreach ($items as $item)
{
$item->count_trashed = 0;
$item->count_archived = 0;
$item->count_trashed = 0;
$item->count_unpublished = 0;
$item->count_published = 0;
$query = $db->getQuery(true);
$query->select('state, count(*) AS count')
->from($db->qn('#__content'))
->where('catid = ' . (int) $item->id)
->group('state');
$db->setQuery($query);
$articles = $db->loadObjectList();
$item->count_published = 0;

$query = $db->getQuery(true);

$query ->select($db->qn('condition'))
->select('COUNT(*) AS ' . $db->qn('count'))
->from($db->qn('#__content', 'c'))
->from($db->qn('#__workflow_states', 's'))
->from($db->qn('#__workflow_associations', 'a'))
->where($db->qn('a.item_id') . ' = ' . $db->qn('c.id'))
->where($db->qn('s.id') . ' = ' . $db->qn('a.state_id'))
->where('catid = ' . (int) $item->id)
->where('a.extension = ' . $db->quote('com_content'))
->group($db->qn('condition'));

$articles = $db->setQuery($query)->loadObjectList();

foreach ($articles as $article)
{
if ($article->state == 1)
if ($article->condition == 1)
{
$item->count_published = $article->count;
}

if ($article->state == 0)
if ($article->condition == 0)
{
$item->count_unpublished = $article->count;
}

if ($article->state == 2)
{
$item->count_archived = $article->count;
}

if ($article->state == -2)
if ($article->condition == -2)
{
$item->count_trashed = $article->count;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach requires changes when states/conditions are added or removed. Better:
Define constants, eg.

class WorkflowConditions
{
    const PUBLISHED   =  1;
    const UNPUBLISHED =  0;
    const ARCHIVED    =  2;
    const TRASHED     = -2;
}

The loop should look like

$item->count = [];
foreach ($articles as $article)
{
    $item->count[$article->condition] = ($item->count[$article->condition] ?: 0) + $article->count;
}

In subsequent code, you'll access

$item->count[WorkflowConditions::PUBLISHED]

instead of

$item->count_published

Expand All @@ -155,9 +187,9 @@ public static function countItems(&$items)
*/
public static function countTagItems(&$items, $extension)
{
$db = \JFactory::getDbo();
$parts = explode('.', $extension);
$section = null;
$db = \JFactory::getDbo();
$parts = explode('.', $extension);
$section = null;

if (count($parts) > 1)
{
Expand All @@ -169,17 +201,17 @@ public static function countTagItems(&$items, $extension)

if ($section === 'category')
{
$join = $db->qn('#__categories') . ' AS c ON ct.content_item_id=c.id';
$join = $db->qn('#__categories') . ' AS c ON ct.content_item_id=c.id';
$state = 'published as state';
}

foreach ($items as $item)
{
$item->count_trashed = 0;
$item->count_archived = 0;
$item->count_trashed = 0;
$item->count_archived = 0;
$item->count_unpublished = 0;
$item->count_published = 0;
$query = $db->getQuery(true);
$item->count_published = 0;
$query = $db->getQuery(true);
$query->select($state . ', count(*) AS count')
->from($db->qn('#__contentitem_tag_map') . 'AS ct ')
->where('ct.tag_id = ' . (int) $item->id)
Expand Down Expand Up @@ -236,7 +268,7 @@ public static function validateSection($section)
// Editing an article
case 'form':

// Category list view
// Category list view
case 'featured':
case 'category':
$section = 'article';
Expand Down Expand Up @@ -270,4 +302,86 @@ public static function getContexts()

return $contexts;
}

/**
* Check if state can be deleted
*
* @param int $stateID Id of state to delete
*
* @return boolean
*
* @since __DEPLOY_VERSION__
*/
public static function canDeleteState($stateID)
{
$db = \JFactory::getDbo();
$query = $db->getQuery(true);

$query->select('id')
->from($db->qn('#__content'))
->where('state = ' . (int) $stateID);
$db->setQuery($query);
$states = $db->loadResult();

return empty($states);
}

/**
* Method to filter transitions by given id of state
*
* @param int $transitions Array of transitions
* @param int $pk Id of state
*
* @return array
*
* @since __DEPLOY_VERSION__
*/
public static function filterTransitions($transitions, $pk)
{
return array_values(
array_filter(
$transitions,
function ($var) use ($pk)
{
return $var['from_state_id'] == $pk;
}
)
);
}

/**
* Method to change state of multiple ids
*
* @param int $pks Array of IDs
* @param int $condition Condition of the workflow state
*
* @return boolean
*
* @since __DEPLOY_VERSION__
*/
public static function updateContentState($pks, $condition)
{
if (empty($pks))
{
return false;
}

try
{
$db = Factory::getDbo();
$query = $db->getQuery(true);

$query->update($db->qn('#__content'))
->set($db->qn('state') . '=' . (int) $condition)
->where($db->qn('id') . ' IN (' . implode(', ', $pks) . ')');

$db->setQuery($query)->execute();
}
catch (\Exception $e)
{
return false;
}

return true;
}
}
Loading