display in a page. Previously it returned the FIRST match; now it returns
the BEST match.
This allows things like
array('all' => true, 'mod' => false, 'mod-quiz' => true)
to work correctly regardless of the order the array elements appear in.
Also, encapsulated the check into a function (it has definitely become
non-trivial).
The format for each page is now the same as the id attribute of the
BODY tag, which in turn is a simple function of the script's relative path:
The format for e.g. a quiz view page is "mod-quiz-view". The format for the
site index is "site-index". Exception: the format for courses is not just
"course-view", but "course-view-weeks" etc.
Obviously the applicable_formats() override for each block should now take
this into account. The matching rules now are:
* You can specify the full format, e.g. "mod-quiz-view" => true
will allow the block to be added in quizzes
* Prefixes match the full page format, e.g. "mod" matches ALL activities
* You can use "*" as a wildcard, e.g. "mod-*-view" matches just the view.php
page of all activities
* These rules interoperate, thus "mod-*" is the same as "mod"
* "all" remains as a catch-all situation
The new constant is PAGE_COURSE_VIEW, and it's more streamlined with the
new CSS-related ids for 1.5. There are great possibilities for the future
here, so we 're getting ready.
On the other hand, this has to be the ugliest hack I 've ever inflicted
on any program (look at pagelib.php). Thankfully it will only stay for just
a little while.
Make it more difficult for instances with invalid blockid to be added to
mdl_block_instance. This could result in warnings, although nothing more
serious than that.
Credits to Eloy and especially Dan Marsden for reporting and providing info.
* When configuring a block instance, "Turn editing off" button is not
shown anymore.
* When configuring a block instance, the breadcrumbs are now better,
providing a link to the course page. This could be done in a much
better way if we had a comprehensive template system but it will
suffice for now.
I hope this time I got everything changed to the new Page interface! I 'm
really sorry for messing up and breaking new installations... :(
Also moved the only two functions of the API outside the page_base class.
rest of Moodle. The convention for blocks is now:
class block_something extends block_base { ... }
HOWTO updated accordingly, plus some more minor polishing. More to come.
NEW: The code now supports dynamically plugging your own Pages and block position
identifiers into Moodle without messing with the main libraries at all.
UPDATE: Many functions in blocklib now use pass-by-reference for speed.
UPDATE: Class MoodlePage has been made more presentable and robust.
--------------
Brand-new pagelib.php at your disposal! It slices, it dices, it makes your coffee.
It still doesn't understand women... Read the comments in pagelib.php for a first
impression. Feedback highly encouraged!
Blocks code has undergone significant changes to work with Pages. Flexibility is its
middle name, since I think (without having tried it) that adding e.g. a third
placeholder for "center" blocks in courses, with full support for moving around etc,
will now take about 15 lines of new or edited code. If you are not impressed yet, I
suggest watching a documentary on solar physics. :P
MINOR CHANGES:
--------------
Added instance_allow_config() in the blocks class hierarchy to supplement per-instance
configuration options. You can override it to return true and thus get configuration
amenities without allowing multiple instances.
Minor polishing to comments and documentation (whatever caught my eye was game).
Tightened up some code here and there by utilizing all the new features.
BUGFIXES:
---------
A bug in restore_execute.html caused hidden blocks to not be restored at all.
Microsoft must surely be jealous (do more with less).
Fixed a bug: if somehow the block weights in a page become discontinuous,
moving things up and down will slowly improve the situation until it's back
to normal again. It would just fail without notice before.
Fixed a bug: you could add multiple instances from a block that didn't
allow it if, after adding the first, you just hit Refresh in your browser.
Fixed a typo: missing / inside filepath
Code based on the work of Daryl Hawes for the blog module. Thanks, Daryl!
Please test the hell out of it as it's sure to have issues that need to be
ironed out.
(for CPU issues) and upcoming_events is now shown on the right between
news and recent activity
The default blocks can be overridden by a setting in config.php
$CFG->defaultblocks
See: http://moodle.org/mod/forum/discuss.php?d=7784&parent=39296
block db upgrade scripts. We 're getting to a point where you can really
have a directory with just a single 20-line file for your block and Moodle
will do all the rest. Much like Nuke does now. That is A Good Thing! :-)