? Success

User tests: Successful: Unsuccessful:

avatar andrepereiradasilva
andrepereiradasilva
13 Aug 2016

Summary of Changes

This PR adds a new property to JModelAdmin categoriesContext.

The porpose of this new property is to be able to define the categories context (aka extension) in the item model.

This is useful when you have several items with categories in the same component. Examples:

  • com_mycomponent
    • Item 1
    • Categories for Item 1 (context: com_mycomponent.item1)
    • Item 2
    • Categories for Item 2 (context: com_mycomponent.item2)
    • Item 3
    • Categories for Item 3 (context: com_mycomponent.item3)

If empty or null one assume we are using the default context for that component, ie, the component (ex: com_mycomponent).

Testing Instructions

Just a new property. Code review.

Documentation Changes Required

Don't really know...

Notes

mantainers, if ok i can add this property to all models that use categories for code consistency.

This is needed for the GsoC multilingual project where we need to know when a component uses several items, if those each of those items support categories and with what context.

avatar joomla-cms-bot joomla-cms-bot - change - 13 Aug 2016
Category Libraries
avatar andrepereiradasilva andrepereiradasilva - open - 13 Aug 2016
avatar andrepereiradasilva andrepereiradasilva - change - 13 Aug 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 13 Aug 2016
Labels Added: ?
avatar andrepereiradasilva andrepereiradasilva - change - 13 Aug 2016
The description was changed
avatar andrepereiradasilva andrepereiradasilva - edited - 13 Aug 2016
avatar andrepereiradasilva andrepereiradasilva - change - 13 Aug 2016
Title
Add categoriesContext property to JModalAdmin
Add categoriesContext property to JModelAdmin
avatar andrepereiradasilva andrepereiradasilva - edited - 13 Aug 2016
avatar andrepereiradasilva andrepereiradasilva - change - 13 Aug 2016
The description was changed
avatar andrepereiradasilva andrepereiradasilva - edited - 13 Aug 2016
avatar andrepereiradasilva andrepereiradasilva - change - 13 Aug 2016
The description was changed
avatar andrepereiradasilva andrepereiradasilva - edited - 13 Aug 2016
avatar andrepereiradasilva andrepereiradasilva - change - 13 Aug 2016
The description was changed
avatar andrepereiradasilva andrepereiradasilva - edited - 13 Aug 2016
avatar andrepereiradasilva andrepereiradasilva - change - 13 Aug 2016
The description was changed
avatar andrepereiradasilva andrepereiradasilva - edited - 13 Aug 2016
avatar andrepereiradasilva andrepereiradasilva - edited - 13 Aug 2016
avatar andrepereiradasilva andrepereiradasilva - change - 13 Aug 2016
The description was changed
avatar andrepereiradasilva andrepereiradasilva - edited - 13 Aug 2016
avatar andrepereiradasilva andrepereiradasilva - change - 13 Aug 2016
The description was changed
avatar andrepereiradasilva andrepereiradasilva - edited - 13 Aug 2016
avatar alikon alikon - test_item - 14 Aug 2016 - Tested successfully
avatar alikon
alikon - comment - 14 Aug 2016

I have tested this item successfully on


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11590.

avatar andrepereiradasilva andrepereiradasilva - change - 14 Aug 2016
The description was changed
avatar andrepereiradasilva andrepereiradasilva - edited - 14 Aug 2016
avatar jeckodevelopment jeckodevelopment - test_item - 14 Aug 2016 - Tested successfully
avatar jeckodevelopment
jeckodevelopment - comment - 14 Aug 2016

I have tested this item successfully on


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11590.

avatar andrepereiradasilva
andrepereiradasilva - comment - 14 Aug 2016

mantainers, if ok i can add this property to all models that use categories for code consistency.

avatar jeckodevelopment
jeckodevelopment - comment - 14 Aug 2016

@rdeutz , @roland-d , @wilsonge
can you please look at this?

avatar rdeutz
rdeutz - comment - 14 Aug 2016

I am afraid but I can't see the need for this property, why this can't be defined at the concrete class level?

avatar andrepereiradasilva
andrepereiradasilva - comment - 14 Aug 2016

This is needed for the GsoC multilingual project where we need to know when a component uses several items, if those each of those items support categories and with what context.

How else can we know this?

avatar rdeutz
rdeutz - comment - 14 Aug 2016

@andrepereiradasilva show me the code, because you are not doing anything with the property on this level why do you need to declare it on this level

avatar yvesh
yvesh - comment - 14 Aug 2016

hmm sorry to ask that, but can't you add just an test if that variable exists on the child of JModelAdmin?

isset(it[$key]->model->get('categoryContext')) && $it[$key]->model->get('categoryContext') ? ..

then you won't need to introduce another property, where people wonder what it's all about :-)

Keep up your good work! Really awesome how much work you put into that project!

avatar andrepereiradasilva
andrepereiradasilva - comment - 14 Aug 2016

Let me try to explain this better:

Just for the sake of an example, imagine a component for some library (com_library), we will have something like this:

  • Authors (item type: author | category context: com_library.authors)
  • Authors Categories (item type: category &extension=com_library.authors)
  • Books (item type: book | category context: com_library.books)
  • Books Categories (item type: category &extension=com_library.books)
  • Clients (item type: client | category context: null)
  • Loans (item type: loan | category context: null)
  • [...]

As you can see in this case you can't use only &extension=com_library for the categories because you have two categories contexts.

That is how it works now.

Now, in com_associations, if those items support language associations we need to get all those item types and theit correct category contexts (aka extension). Because categories support associations too.

So, for com_associations to support components with multiple itemtypes (each one using categories) we need to know the category context (aka extension) of each item type.

That i know of this isn't declared anywhere in joomla, ie, the category context (aka extension) is always hardcoded in links or xml files).

So this new property would allow extension developers to do just that by overriding the property in their model.

And, for code consistency, i proposed also to add this property to all models that use categories.

avatar rdeutz
rdeutz - comment - 14 Aug 2016

Where is the place you will set the property?

avatar andrepereiradasilva
andrepereiradasilva - comment - 14 Aug 2016

For example here: https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_contact/models/contact.php#L31

For contacts there is only one item type (contact) so there is no need for that (if null or empty it will use the component name com_contact as the categories context), but in this case we could use:

protected $categoriesContext = 'com_contact';

Because the context is already com_contact
/administrator/index.php?option=com_categories&extension=com_contact

avatar rdeutz
rdeutz - comment - 14 Aug 2016

OK, so why not declaring the property there. You have to set it there anyway.

avatar andrepereiradasilva
andrepereiradasilva - comment - 14 Aug 2016

Please see the associationsContext property in JModelAdmin (https://github.com/joomla/joomla-cms/blob/staging/libraries/legacy/model/admin.php#L88) ...

that is overrided by the Item Type Model (https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_contact/models/contact.php#L32).

I just followed the same principle...

avatar rdeutz
rdeutz - comment - 14 Aug 2016

This is different, associationsContext is used in the class. I don't think it is right to define properties at a certain level when we don't use them at a certain level.

avatar andrepereiradasilva
andrepereiradasilva - comment - 14 Aug 2016

ok i see now what you mean.

i'm going to close this them.

avatar andrepereiradasilva andrepereiradasilva - change - 14 Aug 2016
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2016-08-14 19:07:11
Closed_By andrepereiradasilva
avatar andrepereiradasilva andrepereiradasilva - close - 14 Aug 2016

Add a Comment

Login with GitHub to post a comment