Skip to content
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

[6.0] Add a global master language for Multilingual Associations #25403

Draft
wants to merge 127 commits into
base: 6.0-dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
cec6bd5
fill select boxes with default values to avoid empty list
lavipr May 27, 2019
57c3a12
Display always the toolbar and adjust its functions
lavipr May 27, 2019
655f7bb
merge the Association- and the "Not Associated"-column together
lavipr May 27, 2019
9cd69c0
Add fields for setting a masterlanguage
lavipr May 28, 2019
b74930c
save the master item in the associations table
lavipr May 29, 2019
d20257a
Merge remote-tracking branch 'parent/4.0-dev' into addingMasterlanguage
lavipr May 29, 2019
eb72d74
change color of associations and center associations column
lavipr May 30, 2019
cc03c48
add masterlanguage information to the language select box
lavipr May 30, 2019
b669d7b
fix the toolbar button where variables have to be checked if they are…
lavipr May 30, 2019
d834ab6
center and widen the association column also in the associations modal
lavipr May 30, 2019
cd7aeb4
Merge remote-tracking branch 'parent/4.0-dev' into addingMasterlanguage
lavipr May 30, 2019
391e1a0
display the master-child associations in the list views
lavipr May 31, 2019
72f8963
Merge remote-tracking branch 'parent/4.0-dev' into addingMasterlanguage
lavipr May 31, 2019
03818fd
Merge remote-tracking branch 'parent/4.0-dev' into addingMasterlanguage
lavipr May 31, 2019
577c1c6
Merge remote-tracking branch 'parent/4.0-dev' into Feature-Multilingu…
lavipr Jun 2, 2019
6812d99
add masterlanguage as default to language select box
lavipr Jun 3, 2019
1495977
Add modified date of a master item to the associations table
lavipr Jun 8, 2019
7da2da0
display new association state 'outdated' in list views
lavipr Jun 8, 2019
8c61dd6
Add a filter for association states to the Associations View
lavipr Jun 8, 2019
e6d7e3c
Add sql for filter for association states to the Associations View
lavipr Jun 8, 2019
e0ceadd
Fix Bug when changing global master language
lavipr Jun 8, 2019
0eed838
Fix bug where newsfeeds and contacts get the same assoc key
lavipr Jun 8, 2019
211400d
Fix Bug for displaying associations without master language
lavipr Jun 8, 2019
75ccfe9
Adding labels to select for accessibility reasons
lavipr Jun 10, 2019
b9361e6
change fields order and add description to these fields
lavipr Jun 10, 2019
500f10e
Merge remote-tracking branch 'parent/4.0-dev' into Feature-Multilingu…
lavipr Jun 10, 2019
b9d451c
fix filter by association state
lavipr Jun 11, 2019
628c22e
Merge remote-tracking branch 'parent/4.0-dev' into Feature-Multilingu…
lavipr Jun 15, 2019
69b7c05
fix filter with correct context for categories in the associations table
lavipr Jun 16, 2019
7171c11
add modified date when installing multilingual sample data
lavipr Jun 16, 2019
a123b14
use date of history if enabled instead of modified date for master item
lavipr Jun 16, 2019
4ab0293
improve filtering by associations state
lavipr Jun 23, 2019
cb4a7d3
undo master language activation for multilingual sample data
lavipr Jun 23, 2019
666acbd
set default value for the association state filter
lavipr Jun 23, 2019
9b3d1c6
fix filter by association state also for modal
lavipr Jun 23, 2019
dbe7494
remove hardcoded table names
lavipr Jun 25, 2019
28010b8
update outdated child of a master item
lavipr Jun 25, 2019
b74287e
add forgotten file for update outdated child of a master item
lavipr Jun 25, 2019
b34c098
remove unused functions, change function name and change comments
lavipr Jun 25, 2019
561c01e
merge from 4.0-dev
lavipr Jun 25, 2019
9f29efd
merge from 4.0-dev
lavipr Jun 26, 2019
be8fdbf
Merge remote-tracking branch 'parent/4.0-dev' into Feature-Multilingu…
lavipr Jul 1, 2019
591ced4
revert some changes and adjust tooltips in List Views with Associations
lavipr Jul 1, 2019
e22457d
adjust code style and rename variables and function
lavipr Jul 1, 2019
fc95e69
open item as target if it is a child language
lavipr Jul 1, 2019
550db64
don't display other target languages if master language is one of them
lavipr Jul 1, 2019
eaf8ce2
improve code style and new function for masterInfo in ListViews
lavipr Jul 1, 2019
2275c8a
Merge remote-tracking branch 'parent/4.0-dev' into Feature-Multilingu…
lavipr Jul 1, 2019
ca7d5b0
rename table columns for master lang
lavipr Jul 1, 2019
7df0d4a
fix display assoc without other children
lavipr Jul 1, 2019
ef78227
fix compare Master View when there is name instead of title used
lavipr Jul 1, 2019
3a109bb
change links to edit association in other listviews with master
lavipr Jul 1, 2019
7f42c40
fix missed renaming table column for master_id
lavipr Jul 2, 2019
978aac0
Merge remote-tracking branch 'parent/4.0-dev' into Feature-Multilingu…
lavipr Jul 2, 2019
e6cdd7e
fix hound
lavipr Jul 2, 2019
506059f
fix hound again
lavipr Jul 2, 2019
a866a13
fix phpcs
lavipr Jul 2, 2019
0acf809
fix phpcs again
lavipr Jul 2, 2019
047bf74
fix hound
lavipr Jul 2, 2019
55e46d1
Update administrator/components/com_associations/forms/filter_associa…
lavipr Jul 2, 2019
eb2bdbb
Update administrator/components/com_associations/Model/AssociationsMo…
lavipr Jul 2, 2019
285944f
Update administrator/components/com_associations/Model/AssociationsMo…
lavipr Jul 2, 2019
3ac1800
Update administrator/components/com_associations/Helper/MasterAssocia…
lavipr Jul 2, 2019
6e30b12
Update administrator/components/com_associations/Helper/MasterAssocia…
lavipr Jul 2, 2019
ad19dc3
Update administrator/components/com_associations/Helper/AssociationsH…
lavipr Jul 2, 2019
42a39b2
Update administrator/components/com_categories/Model/CategoryModel.php
lavipr Jul 2, 2019
ba57d95
Update administrator/components/com_categories/Service/HTML/Administr…
lavipr Jul 2, 2019
190ab67
Update administrator/components/com_contact/Service/HTML/Administrato…
lavipr Jul 2, 2019
3918c30
Update administrator/components/com_content/Service/HTML/Administrato…
lavipr Jul 2, 2019
ef1eb55
Update administrator/components/com_menus/Service/HTML/Menus.php
lavipr Jul 2, 2019
5052e70
Update administrator/components/com_newsfeeds/Service/HTML/Administra…
lavipr Jul 2, 2019
dc44040
Update administrator/language/en-GB/en-GB.com_associations.ini
lavipr Jul 2, 2019
3215e64
Update installation/src/Model/LanguagesModel.php
lavipr Jul 2, 2019
3c182ae
Update libraries/src/MVC/Model/AdminModel.php
lavipr Jul 2, 2019
88ddb2a
Update plugins/system/languagefilter/languagefilter.xml
lavipr Jul 2, 2019
952d7fb
Update administrator/language/en-GB/en-GB.ini
lavipr Jul 2, 2019
393ed64
Update administrator/language/en-GB/en-GB.ini
lavipr Jul 2, 2019
588ee55
fix alpha ordering in 'use' and removed commented out code line
lavipr Jul 2, 2019
3951117
remove fieldset wrapping table
lavipr Jul 2, 2019
f6ba2ee
Update plugins/sampledata/multilang/multilang.php
lavipr Jul 2, 2019
7104b51
Merge branch '4.0-dev' into Feature_Global-Master-For-Multilingual-As…
infograf768 Jul 2, 2019
f6f3e9d
fix correct typeAlias for categories
lavipr Jul 2, 2019
2733b6a
Merge remote-tracking branch 'origin/Feature_Global-Master-For-Multil…
lavipr Jul 2, 2019
439c6ad
get modified table name from contentType table
lavipr Jul 2, 2019
8f97cc0
Update plugins/system/languagefilter/languagefilter.xml
lavipr Jul 2, 2019
a7c72db
Update plugins/sampledata/multilang/multilang.php
lavipr Jul 2, 2019
da88da9
Update plugins/system/languagefilter/languagefilter.php
lavipr Jul 2, 2019
01f9cd8
fix wrong uppercase filename
lavipr Jul 2, 2019
5c321cb
change type of master_date to date and add update sqls
lavipr Jul 2, 2019
ab0e2bd
Add schema updates to pr 25403
richard67 Jul 2, 2019
77bb4f7
Merge pull request #6 from richard67/Feature_Global-Master-For-Multil…
lavipr Jul 2, 2019
e81e549
Merge branch '4.0-dev' into Feature_Global-Master-For-Multilingual-As…
infograf768 Jul 3, 2019
1f8fb0b
Merge remote-tracking branch 'parent/4.0-dev' into Feature_Global-Mas…
lavipr Jul 8, 2019
6304010
Merge remote-tracking branch 'origin/Feature_Global-Master-For-Multil…
lavipr Jul 8, 2019
de8a1b1
remove disabled for filters
lavipr Jul 8, 2019
04ee4a7
rename outdated into out of date
lavipr Jul 8, 2019
fcb4f22
move Route::_call() to the layout
lavipr Jul 8, 2019
059ad32
fix phpcs
lavipr Jul 8, 2019
822eeba
Merge branch '4.0-dev' into Feature_Global-Master-For-Multilingual-As…
lavipr Jul 21, 2019
5dbad04
Merge remote-tracking branch 'parent/4.0-dev' into Global-Master-For-…
lavipr Jul 22, 2019
8f65a6c
fix phpcs
lavipr Jul 22, 2019
e705cf5
Merge branch '4.0-dev' into Feature_Global-Master-For-Multilingual-As…
infograf768 Jul 23, 2019
3069cd7
Merge branch '4.0-dev' into Feature_Global-Master-For-Multilingual-As…
lavipr Aug 6, 2019
197d0ce
avoid using the term master
lavipr Aug 7, 2019
9f5c7a3
use prepared statements and save parent_date value as date
lavipr Aug 21, 2019
c6e83ed
merge with 4.0-dev and resolve conflicts
lavipr Aug 21, 2019
6e74985
fix phpcs
lavipr Aug 21, 2019
f8866a2
fix bug for correct parent_date when adding child from other association
lavipr Aug 21, 2019
1b14de0
Update administrator/components/com_associations/Model/AssociationsMo…
lavipr Aug 22, 2019
41d85a7
Update administrator/components/com_associations/Model/AssociationsMo…
lavipr Aug 22, 2019
6cd6fcb
Merge remote-tracking branch 'parent/4.0-dev' into Global-Master-For-…
lavipr Aug 22, 2019
b4d0019
use getContentLanguage method to count languages
lavipr Aug 23, 2019
5c9d903
use prepared statement and bind variable to the main query
lavipr Aug 23, 2019
6193b2b
Merge remote-tracking branch 'parent/4.0-dev' into Global-Master-For-…
lavipr Aug 23, 2019
4e7e99f
declare variable before running the loop
lavipr Aug 24, 2019
58d567d
Merge remote-tracking branch 'parent/4.0-dev' into Global-Master-For-…
lavipr Aug 24, 2019
a596d3a
Update plugins/system/languagefilter/languagefilter.php
lavipr Aug 24, 2019
f5b6dcb
Fix PHP notices in languagefilter.php
richard67 Aug 24, 2019
1844027
PHPCS, type-safe comparison
richard67 Aug 24, 2019
a17cef8
Merge pull request #7 from richard67/4.0-dev-pr-25403-fix-php-notices-2
lavipr Aug 24, 2019
ac231c8
Fix PHP Notice "Only variables ... by reference" in languagefilter.php
richard67 Aug 24, 2019
fbf0c44
Merge pull request #8 from richard67/Feature_Global-Master-For-Multil…
lavipr Aug 24, 2019
ffc4e27
fix controller name with correct casing
lavipr Aug 24, 2019
6dcae08
fix model call name with correct casing
lavipr Aug 24, 2019
0023d72
Fix PHP Notice "Only variables ... by reference" in DefaultAssocLangM…
richard67 Aug 24, 2019
062dd08
Add missing semicolon
richard67 Aug 24, 2019
440584d
Merge pull request #9 from richard67/Feature_Global-Master-For-Multil…
lavipr Aug 24, 2019
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
Prev Previous commit
Next Next commit
fix phpcs
  • Loading branch information
lavipr committed Jul 2, 2019
commit a866a1371f9fcc91d277a747f588df37dec5c542
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ class AssociationMasterController extends BaseController
public function update()
{
$targetId = $this->input->get('targetId', '', 'int');
$masterId = $this->input->get('id', '' , 'int');
$masterId = $this->input->get('id', '', 'int');
$itemtype = $this->input->get('itemtype', '', 'string');

$this->getModel('associationmaster')->update($targetId, $masterId, $itemtype);

$this->setRedirect(Route::_('index.php?option=com_associations&view=associations', false));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ private static function getExtensionRealName($extensionName)
*
* @since 3.7.0
*/
public static function getAssociationHtmlList($extensionName, $typeName, $itemId, $itemLanguage, $addLink = true, $assocLanguages = true, $assocState = 'all')
public static function getAssociationHtmlList($extensionName, $typeName, $itemId, $itemLanguage,
$addLink = true, $assocLanguages = true, $assocState = 'all')
{
// Get the associations list for this item.
$items = self::getAssociationList($extensionName, $typeName, $itemId);
Expand All @@ -234,6 +235,7 @@ public static function getAssociationHtmlList($extensionName, $typeName, $itemId

// Get the global master language, empty if not used
$globalMasterLang = Associations::getGlobalMasterLanguage();

// Check if versions are enabled
$saveHistory = ComponentHelper::getParams($extensionName)->get('save_history', 0);
$context = ($typeName === 'category') ? 'com_categories.item' : $extensionName . '.item';
Expand All @@ -252,7 +254,7 @@ public static function getAssociationHtmlList($extensionName, $typeName, $itemId
$update = false;
$masterInfo = '';

if(!$globalMasterLang)
if (!$globalMasterLang)
{
// Don't do for the reference language.
if ($langCode == $itemLanguage)
Expand Down Expand Up @@ -352,7 +354,8 @@ public static function getAssociationHtmlList($extensionName, $typeName, $itemId
else
{
// When there is no associated master item, set it to target
if (!$masterId){
if (!$masterId)
{
$target = $globalMasterLang . ':0:add';
}

Expand All @@ -364,7 +367,7 @@ public static function getAssociationHtmlList($extensionName, $typeName, $itemId
if ($associatedModifiedMaster < $lastModifiedMaster)
{
// Don't display not corresponding item
if($assocState !== 'all' && $assocState !== 'outdated'){
if ($assocState !== 'all' && $assocState !== 'outdated'){
unset($items[$langCode]);
continue;
}
Expand All @@ -374,25 +377,27 @@ public static function getAssociationHtmlList($extensionName, $typeName, $itemId
$target = $langCode . ':' . $items[$langCode]['id'] . ':edit';
$update = true;

// When versions are disabled than the modified date is used for the master item.
// That means that when no changes were made and the master item has been saved the modified date has been changed.
// So the outdated state means in that case there might have been made changes and it is necessary to check manually and update the target.
/*
When versions are disabled than the modified date is used for the master item.
lavipr marked this conversation as resolved.
Show resolved Hide resolved
That means that when no changes were made and the master item has been saved the modified date has been changed.
So the outdated state means in that case there might have been made changes and it is necessary to check manually and update the target.
*/
$masterInfo = $saveHistory
? $masterInfoSpace . Text::_('JGLOBAL_ASSOCIATIONS_STATE_OUTDATED_DESC')
: $masterInfoSpace . Text::_('JGLOBAL_ASSOCIATIONS_STATE_MIGHT_BE_OUTDATED_DESC');
}
else
{
// Don't display not corresponding item
if($assocState !== 'all' && $assocState !== 'up_to_date'){
if ($assocState !== 'all' && $assocState !== 'up_to_date'){
unset($items[$langCode]);
continue;
}

$additional .= $addLink && $allow ? Text::_('COM_ASSOCIATIONS_EDIT_ASSOCIATION') : '';
$masterInfo = $masterInfoSpace . Text::_('JGLOBAL_ASSOCIATIONS_STATE_UP_TO_DATE_DESC');

// for item types that do not use modified date or versions like menu items
// For item types that do not use modified date or versions like menu items
if (!$associatedModifiedMaster)
{
$masterInfo = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class MasterAssociationsHelper extends ContentHelper
/**
* Method to create a link for a child item that has no master item
*
* @param string $globalMasterLang The global master language
* @param integer $itemId The item id
* @param string $itemType The item type
* @param string $globalMasterLang The global master language
* @param integer $itemId The item id
* @param string $itemType The item type
*
* @return string the link for the not associated master item
*/
Expand All @@ -51,10 +51,10 @@ public static function addNotAssociatedMasterLink($globalMasterLang, $itemId, $i
$title = Text::_('JGLOBAL_ASSOCIATIONS_STATE_NOT_ASSOCIATED_DESC');
$url = self::getAssociationUrl($itemId, $globalMasterLang, $itemType);

$tooltip = '<strong>' . htmlspecialchars( $globalMasterLangInfos['title'], ENT_QUOTES, 'UTF-8') . '</strong><br>'
$tooltip = '<strong>' . htmlspecialchars( $globalMasterLangInfos['title'],ENT_QUOTES, 'UTF-8') . '</strong><br>'
. htmlspecialchars($title, ENT_QUOTES, 'UTF-8') . $masterInfo;

$link = '<a href="' . $url . '" title="' . $globalMasterLangInfos['title'] . '" class="' . $classes . '">' . $text . '</a>'
$link = '<a href="' . $url . '" title="' . $globalMasterLangInfos['title'] . '" class="' . $classes . '">' . $text . '</a>'
. '<div role="tooltip" id="tip_no_Master">' . $tooltip . '</div>';

return $link;
Expand All @@ -67,7 +67,6 @@ public static function addNotAssociatedMasterLink($globalMasterLang, $itemId, $i
* @param string $context the association context
*
* @return array association with master dates
*
*/
public static function getMasterDates($associations, $context)
{
Expand All @@ -86,7 +85,7 @@ public static function getMasterDates($associations, $context)
->where($db->quoteName('id') . ' = ' . $db->quote($id))
->where($db->quoteName('context') . ' = ' . $db->quote($context));
$db->setQuery($query);
$masterDates[$id] = $db->loadResult();;
$masterDates[$id] = $db->loadResult();
}

return $masterDates;
Expand All @@ -104,15 +103,15 @@ public static function getMasterDates($associations, $context)
*
* @return array master id and master dates for an associated item
*/
public static function getMasterValues($id, $dataId, $masterId, $masterModified, $assocMasterDates, $old_key) {

public static function getMasterValues($id, $dataId, $masterId, $masterModified, $assocMasterDates, $old_key)
{
if ($masterId)
{
// For the master item
if ($masterId === $id)
{
$masterIdValue = 0;
// set always the last modified date
// Set always the last modified date
$masterDateValue = $masterModified ?? null;
}

Expand Down Expand Up @@ -154,19 +153,19 @@ public static function getMasterValues($id, $dataId, $masterId, $masterModified,
*/
public static function getMasterModifiedDate($masterId, $tableName, $typeAlias)
Copy link
Member

Choose a reason for hiding this comment

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

PHP Deprecated: Non-static method Joomla\CMS\Helper\ContentHistoryHelper::getHistory() should not be called statically in /Applications/MAMP/htdocs/newfolder/joomla40/administrator/components/com_associations/Helper/MasterAssociationsHelper.php on line 179

Copy link
Member

Choose a reason for hiding this comment

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

same error with other methods in this file using ContentHistoryHelper

{
// check if the content version is enabled
// Check if the content version is enabled
$option = Factory::getApplication()->input->get('option');
$saveHistory = ComponentHelper::getParams($option)->get('save_history', 0);

if ($masterId)
{
// if versions are enabled get the save_data of the master item from history table
// If versions are enabled get the save_data of the master item from history table
lavipr marked this conversation as resolved.
Show resolved Hide resolved
if ($saveHistory)
{
$typeId = Table::getInstance('ContentType')->getTypeId($typeAlias);
$masterHistory = ContentHistoryHelper::getHistory($typeId, $masterId);

// latest saved date of the master item
// Latest saved date of the master item
$masterModified = $masterHistory[0]->save_date;
}
else
Expand Down Expand Up @@ -228,7 +227,7 @@ public static function setMasterAndChildInfos($itemId, $items, $key, $item, $glo
}
else
{
// get association state of child when a master exists
// Get association state of child when a master exists
if ($masterId && (array_key_exists($key, $assocMasterDates)) && (array_key_exists($masterId, $assocMasterDates)))
{
$associatedModifiedMaster = $assocMasterDates[$key];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ class AssociationMasterModel extends BaseModel
/**
* Update the childs modified date of the master item from #__associations table.
*
* @param integer $childId The id of the item that gets updated
* @param integer $masterId The associated master item of the child item
* @param string $itemtype The component item type
* @param integer $childId The id of the item that gets updated
* @param integer $masterId The associated master item of the child item
* @param string $itemtype The component item type
*
* @return boolean True on success.
*
* @since 4.0
*/
public function update($childId, $masterId, $itemtype) {

public function update($childId, $masterId, $itemtype)
{
list($extensionName, $typeName) = explode('.', $itemtype, 2);

$context = ($typeName ==='category')
Expand Down Expand Up @@ -69,4 +69,4 @@ public function update($childId, $masterId, $itemtype) {

return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,9 @@ protected function getListQuery()

// Join over associations where id does not exists
lavipr marked this conversation as resolved.
Show resolved Hide resolved
$query->where('((' . $db->quoteName('asso.id') . ' IS NULL )'
Copy link
Member

Choose a reason for hiding this comment

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

Convert to prepared statements please and maybe use orWhere, maybe whereIn is also possible

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@HLeithner Here I could not use prepared statement successfully. It probably doesn't work without further ado within "IN". The rewriting to "orWhere" and "whereIn" does not seem possible here, because the enclosing brackets at the beginning of "where" are essential.

// or if we are on the child language and there is no master language
// Or if we are on the child language and there is no master language
. ' OR ( ' . $db->quoteName('asso2.master_id') . ' = ' . $db->quote('-1') . ')'
// or a child of the master does not exist.
// Or a child of the master does not exist.
. ' OR ( ' . $db->quoteName('asso.key') . ' IN (' . $assocQuery . ')
Copy link
Contributor Author

@lavipr lavipr Aug 23, 2019

Choose a reason for hiding this comment

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

@HLeithner , @SharkyKZ , @alikon, @richard67 Thank you! Now that I've added the getContentLanguages function to count languages, I guess I've removed our previous conversation. I would like to continue it here.
I think the problem is no longer in the prepared statement in $assocQuery, but probably here in the usage. Because filtering doesn't work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@HLeithner thanks for the hint to bind the variable to the main query!

AND ' . $db->quoteName('asso.master_id') . ' = ' . $db->quote('0') . ')'
. ')');
Expand All @@ -481,7 +481,7 @@ protected function getListQuery()
// If we are on the masterlanguage and we check the state of the children
$query->where('((' . $db->quoteName('asso2.master_id') . ' = ' . $db->quoteName('asso.id')
. ' AND ' . $db->quoteName('asso2.master_date') . ' < ' . $db->quoteName('asso.master_date') . ')'
// or we are on the child language and we check its state comparing to its master.
// Or we are on the child language and we check its state comparing to its master.
. ' OR (' . $db->quoteName('asso.master_date') . ' < ' . $db->quoteName('asso2.master_date')
. ' AND ' . $db->quoteName('asso2.id') . ' = ' . $db->quoteName('asso.master_id') . '))');
}
Expand All @@ -492,7 +492,7 @@ protected function getListQuery()
// If we are on the masterlanguage and we check the state of the children
$query->where('((' . $db->quoteName('asso2.master_id') . ' = ' . $db->quoteName('asso.id')
. ' AND ' . $db->quoteName('asso2.master_date') . ' = ' . $db->quoteName('asso.master_date') . ')'
// or we are on the child language and we check its state comparing to its master.
// Or we are on the child language and we check its state comparing to its master.
. ' OR (' . $db->quoteName('asso.master_date') . ' = ' . $db->quoteName('asso2.master_date')
. ' AND ' . $db->quoteName('asso2.id') . ' = ' . $db->quoteName('asso.master_id') . '))');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ public function display($tpl = null)
$task = $typeName . '.' . $this->targetAction;

// The update layout can only be set when a global master language is used.
// get version ids of the master item, when versions are enabled.
if($this->getLayout() === 'update'){
// Get version ids of the master item, when versions are enabled.
if ($this->getLayout() === 'update'){
$saveHistory = ComponentHelper::getParams($extensionName)->get('save_history', 0);

if($saveHistory)
if ($saveHistory)
{
$typeAlias = $typeName === 'category' ? $extensionName . '.' . $typeName : $reference['typeAlias'];
$model = $this->getModel();
Expand Down Expand Up @@ -229,7 +229,7 @@ protected function addToolbar()
$toolbar = Toolbar::getInstance('toolbar');

// The update layout can only be set when a global master language is used.
if($this->getLayout() === 'update')
if ($this->getLayout() === 'update')
{
// In the update view we can just save the target
$toolbar->appendButton(
Expand All @@ -238,9 +238,10 @@ protected function addToolbar()
. Text::_('COM_ASSOCIATIONS_SAVE_AND_UPDATE_TARGET') . '</button>', 'target'
);

// and when saving the target this button gets activated via js to update the master date for the child
// And when saving the target this button gets activated via js to update the master date for the child
$toolbar->appendButton(
'Custom', '<button class="btn btn-sm btn-success hidden" id="updateChild" onclick="Joomla.submitbutton(\'associationmaster.update\')"></button>', 'target'
'Custom', '<button class="btn btn-sm btn-success hidden" id="updateChild"
onclick="Joomla.submitbutton(\'associationmaster.update\')"></button>', 'target'
);
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ public function display($tpl = null)
unset($this->activeFilters['language']);
unset($this->activeFilters['assocstate']);

//Remove association state filter depending on global master language
// Remove association state filter depending on global master language
$globalMasterLang = Associations::getGlobalMasterLanguage();

if(!$globalMasterLang){
if (!$globalMasterLang){
$this->filterForm->removeField('assocstate', 'filter');
}

Expand Down Expand Up @@ -269,8 +269,7 @@ protected function addToolbar()
->text('COM_ASSOCIATIONS_PURGE')
->message((isset($this->extensionName) && isset($languageKey))
? Text::plural('COM_ASSOCIATIONS_PURGE_CONFIRM_PROMPT', (Text::_($this->extensionName) . ' > ' . Text::_($languageKey)))
: Text::_('COM_ASSOCIATIONS_PURGE_CONFIRM_PROMPT')
)
: Text::_('COM_ASSOCIATIONS_PURGE_CONFIRM_PROMPT'))
->task('associations.purge');
ToolbarHelper::custom('associations.clean', 'refresh', 'refresh', 'COM_ASSOCIATIONS_DELETE_ORPHANS', false, false);
ToolbarHelper::preferences('com_associations');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -699,8 +699,10 @@ public function save($data)
{
$masterIdAndDateValues = MasterAssociationsHelper::getMasterValues($id, $dataId, $masterId, $masterModified, $assocMasterDates, $oldKey);

$query->values(((int) $id) . ',' . $db->quote($this->associationsContext) . ',' . $db->quote($key) . ','
. $db->quote($masterIdAndDateValues[0]) . ',' . $db->quote($masterIdAndDateValues[1]));
$query->values(
lavipr marked this conversation as resolved.
Show resolved Hide resolved
((int) $id) . ',' . $db->quote($this->associationsContext) . ',' . $db->quote($key) . ','
. $db->quote($masterIdAndDateValues[0]) . ',' . $db->quote($masterIdAndDateValues[1])
);
}

$db->setQuery($query);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,17 @@ public function association($catid, $extension = 'com_content')
continue;
}

$classMasterInfoItems = MasterAssociationsHelper::setMasterAndChildInfos($catid, $items, $key, $item,
$globalMasterLang, $isMaster, $masterId, $assocMasterDates, $saveHistory);
$classMasterInfoItems = MasterAssociationsHelper::setMasterAndChildInfos(
$catid, $items, $key, $item, $globalMasterLang, $isMaster, $masterId, $assocMasterDates, $saveHistory
);
$labelClass = $classMasterInfoItems[0];
$masterInfo = $classMasterInfoItems[1];
$items = $classMasterInfoItems[2];
$needsUpdate = $classMasterInfoItems[3];

$url = MasterAssociationsHelper::getAssociationUrl($item->id, $globalMasterLang, $extension . '.category', $item->lang_code, $key, $masterId, $needsUpdate);
$url = MasterAssociationsHelper::getAssociationUrl(
$item->id, $globalMasterLang, $extension . '.category', $item->lang_code, $key, $masterId, $needsUpdate
);
}

$text = $item->lang_sef ? strtoupper($item->lang_sef) : 'XX';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,17 @@ public function association($contactid)
continue;
}

$classMasterInfoItems = MasterAssociationsHelper::setMasterAndChildInfos($contactid, $items, $key, $item,
$globalMasterLang, $isMaster, $masterId, $assocMasterDates, $saveHistory);
$classMasterInfoItems = MasterAssociationsHelper::setMasterAndChildInfos(
$contactid, $items, $key, $item, $globalMasterLang, $isMaster, $masterId, $assocMasterDates, $saveHistory
);
$labelClass = $classMasterInfoItems[0];
$masterInfo = $classMasterInfoItems[1];
$items = $classMasterInfoItems[2];
$needsUpdate = $classMasterInfoItems[3];

$url = MasterAssociationsHelper::getAssociationUrl($item->id, $globalMasterLang, 'com_contact.contact', $item->lang_code, $key, $masterId, $needsUpdate);
$url = MasterAssociationsHelper::getAssociationUrl(
$item->id, $globalMasterLang, 'com_contact.contact', $item->lang_code, $key, $masterId, $needsUpdate
);
}

$text = strtoupper($item->lang_sef);
Expand All @@ -147,7 +150,7 @@ public function association($contactid)
{
$link = MasterAssociationsHelper::addNotAssociatedMasterLink($globalMasterLang, $contactid, 'com_contact.contact');

// add this on the top of the array
// Add this on the top of the array
$items = array('master' => array('link' => $link)) + $items;
}
}
Expand Down
Loading