Classes with magic properties such as context do not pass through json_encode().
The solution is to implement iterator in such classes and convert what we
feed to json_encode to array using 'foreach' before we pass it to json_encode():
- class context implements IteratorAggregate
- added function convert_to_array() that converts anything to array
- before calling json_encode we convert the argument to array
Big thanks to the developers who put effort into this improvement:
* Jonathan Robson <jonathan.robson@remote-learner.net>
* Jonathan Harker <jonathan@catalyst.net.nz>
This is a reimplementation of the multi-language support for the
custom_menu class. The menu items now accept the forth optional
parameter with the explicit list of languages the item is valid for. If
no languages are listed, the item is valid for any language. The caller
of the custom_menu constructor must provide the user's current language
or null if the multi-language should not be supported (all items are
valid for any language then, regardless the definition).
See the attached unit tests for the examples of usage.
This improves custom_menu constructor by dropping support for useless
$text parameter and replacing it with the menu definition. This makes
custom_menu instance independent on the place where the menu is defined
($CFG->custommenuitems) and can be unit-tested. Also, multiple instances
of custom_menu can be instantiated now which can be interesting in the
future.
The new public static method user_picture::unalias() picks the user
picture fields from the given record and maps the properties back to
unaliased form so that the result can be rendered.
Also fixes a forgotten bug in previous commit and adds a unit test for
both aliasing and unaliasing.
When user table is joined twice or more within a single query, it is
important to be able to provide aliases to all returned files. This
patch adds optional parameter that, if provided, is used as a prefix
for columns aliases. Does not apply to the 'id' column, use $idalias for
that.
New string is available. Use get_string('labelsep', 'langconfig') to be used
as a separator between a label and the labelled text. If you want to
produce <label> HTML element, you may be interested in the new
html_writer::label() method. Simple selects and URL selects now use it.
There are bambillion places where ': ' is hardcoded as a separator. I do
not think we have to fix them manually now (and mass search and replace
would be tricky) but everybody should stop adding new.
Do not abuse 'labelsep' for any other purposes. Note that it may not be
colon in some languages or sites.