-
-
Couldn't load subscription status.
- Fork 3.7k
[4.0][Workflow] POC fixing multilingual sample data #21553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -979,13 +979,31 @@ public function addCategory($itemLanguage) | |
| // Initialize a new category. | ||
| $category = Table::getInstance('CategoryTable', '\\Joomla\\Component\\Categories\\Administrator\\Table\\'); | ||
|
|
||
| // Get Joomla default workflow // Should be modified when the title is changed to a lang string! | ||
| $db = Factory::getDbo(); | ||
| $query = $db->getQuery(true) | ||
| ->select($db->quoteName('id')) | ||
| ->from($db->quoteName('#__workflows')) | ||
| ->where($db->quoteName('extension') . ' = ' . $db->quote('com_content')) | ||
| ->where($db->quoteName('title') . ' = ' . $db->quote('Joomla! Default')); | ||
| $db->setQuery($query); | ||
|
|
||
| try | ||
| { | ||
| $workflowId = $db->loadResult(); | ||
| } | ||
| catch (\RuntimeException $e) | ||
| { | ||
| Factory::getApplication()->enqueueMessage($e->getMessage(), 'error'); | ||
| } | ||
|
|
||
| $data = array( | ||
| 'extension' => 'com_content', | ||
| 'title' => $title . ' (' . strtolower($itemLanguage->language) . ')', | ||
| 'description' => '', | ||
| 'published' => 1, | ||
| 'access' => 1, | ||
| 'params' => '{"target":"","image":""}', | ||
| 'params' => '{"target":"","image":"", "workflow_id":"' . $workflowId . '"}', | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't set the workflow_id here. Just let it away, so the default will be used. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I do not need the workflow id, then I do not need either the query as its only purpose is to get that id. But what if another workflow is set as default and it is not using Published as its default state? That one has Unpublished as default state Therefore, basically, IF workflows IS enabled, I want to force using the default Joomla defaults which should NEVER be modifed or deleted. But we get there into other issues as we do not want save2copy to autopublish the copies, etc. which means Joomla Default workflow is not fit for save2copy.... |
||
| 'metadesc' => '', | ||
| 'metakey' => '', | ||
| 'metadata' => '{"page_title":"","author":"","robots":""}', | ||
|
|
@@ -1107,6 +1125,25 @@ private function addArticle($itemLanguage, $categoryId) | |
| } | ||
| catch (JDatabaseExceptionExecuting $e) | ||
| { | ||
| $this->setError($e->getMessage()); | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| $query->clear() | ||
| ->insert($db->qn('#__workflow_associations')) | ||
| ->values($newId . ', 2,' . $db->quote('com_content')); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should not use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what if that default state is NOT "published"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looks like we have first to find which workflow is the default, and then which states are proposed by this default workflow, and then the correct condition "1" (for published) from which we have to find the id to use. In our default Joomla, that id is 2 |
||
|
|
||
| $db->setQuery($query); | ||
|
|
||
| try | ||
| { | ||
| $db->execute(); | ||
| } | ||
| catch (JDatabaseExceptionExecuting $e) | ||
| { | ||
| $this->setError($e->getMessage()); | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not check for the
titleof the workflow but for the columndefault, so you get a default workflow, when the user changes it. But you don't need any workflow ID in the category itself (which I wouldn't set), because thedefaultis always the fallback.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, if I choose the column
defaultand it is not containing thepublishedstate as I wish, what can I do?