54 Commits

Author SHA1 Message Date
defacer
5bbbe0be91 Changing the matching function that decides if a block is applicable for
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).
2005-02-10 18:43:18 +00:00
moodler
c7a9e29326 Just a robustness test 2005-02-08 17:07:31 +00:00
defacer
8a47e075b3 Changing the way that applicable formats for each block are defined:
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
2005-02-08 02:59:44 +00:00
defacer
d49a3fc5a8 Removing the inline style, migrating to styles_layout.css 2005-02-08 00:22:37 +00:00
defacer
e1f76e76a9 Give an id attribute to the "Add Blocks" block so that the new hide/show
provisions in weblib don't print notices.
2005-02-08 00:00:21 +00:00
defacer
c1d8705fd2 Change the semantics of blocks_print_adminblock() to make life easier to
developers who use pages. Conversely simplified the code a bit in courses.
2005-02-02 02:41:56 +00:00
defacer
c6a2a401ed Making the "Add block..." menu list alphabetically sorted ;-) 2005-02-01 07:59:09 +00:00
defacer
3edc57e189 Even more automation: now blocks_execute_url_action() checks if the user
has sufficient rights to execute the action automatically. It's therefore
safe to call without ANY checks being done first.
2005-02-01 06:55:02 +00:00
defacer
da71112bed Refining the way that blocks work: now you don't have to know anything
about what editing the blocks adds to your URL. blocklib will take care
of that internally.
2005-02-01 06:24:28 +00:00
defacer
7542a4e574 Dropping the use of MOODLE_PAGE_COURSE <gasp>!
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.
2005-01-31 02:18:15 +00:00
defacer
febeb16113 Removing two error-suppression prefixes (@). I think that in the end,
the only purpose they served was to make debugging harder.
2005-01-27 23:57:37 +00:00
defacer
1345403a7c Renaming 4 internal-use-only class methods by prefixing an underscore.
I want to make a point that people should NOT be calling them.
2005-01-25 02:57:30 +00:00
moodler
7933cc6be5 Just a little bit more reobust in the face of badly-behaved blocks 2005-01-18 06:03:26 +00:00
defacer
3cacefda86 Fix for bug 2377:
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.
2005-01-17 14:26:17 +00:00
defacer
edb42f0924 Fix for bug 2328:
* 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.
2005-01-02 15:20:15 +00:00
defacer
9b12850043 Fix for bug 2241:
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.
2004-11-29 04:19:05 +00:00
gustav_delius
ab0e4dd42f If a block is unknown then ignore it rather than throwing fatal error. In future one might want to have a dummy block that is displayed in this case to alert the user to the fact that some block code is missing. 2004-11-24 09:16:39 +00:00
defacer
e89d741af3 New naming conventions for class names to bring them in line with the
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.
2004-11-23 18:53:34 +00:00
defacer
6b853ff4c7 Oops... fix for the fix :-) 2004-11-12 18:47:39 +00:00
defacer
5715e97bce Fixed a warning which appears if you move a block to a
position which doesn't currently have any blocks.
2004-11-12 18:44:54 +00:00
defacer
c8e0b57900 Pages/blocks code updates:
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.
2004-11-12 18:39:25 +00:00
defacer
f032aa7a5f MAJOR CHANGES:
--------------

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.
2004-11-08 19:36:07 +00:00
defacer
89a5baaba1 Major cleanups (removed things no longer used by the new backup).
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
2004-10-29 16:56:59 +00:00
moodler
ccc62c6e42 Fixed typo ... bug 2124 2004-10-25 15:25:58 +00:00
dhawes
a9c75a9caf fix to allow instance configuration for blocks that allow multiple but have been set by the local admin to only display one instance per page 2004-10-25 03:20:02 +00:00
dhawes
27ec21a0f6 some quote cleanup and some spacing added 2004-10-24 15:51:25 +00:00
defacer
9b4b78fd6a Da monster-commit of blocks version 2!
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.
2004-10-19 21:04:28 +00:00
stronk7
5b224948aa course/view.php is using sesskey
(changes in blocks done, please check them)

Merged from MOODLE_14_STABLE
2004-10-09 20:16:05 +00:00
moodler
3d90760aa2 Just added support for "site" format, for completeness. 2004-10-08 13:46:55 +00:00
gustav_delius
9a58f7cb85 towards XHTML compliance 2004-09-12 21:43:59 +00:00
gustav_delius
dcb1bd3c9a towards XHTML compliance 2004-09-12 13:21:01 +00:00
stronk7
a06f9887da Changed the way to determine the site course...
Merged from MOODLE_14_STABLE
2004-09-05 09:23:23 +00:00
defacer
eceb9c5ce4 Small change, checking for file existence is arguably better this way. 2004-09-04 13:14:20 +00:00
mchurch
658724df8f Added failsafe code in case config files haven't been updated. 2004-09-03 20:19:16 +00:00
mchurch
25d18413cf Added new default block definition functionality. 2004-09-03 20:09:36 +00:00
defacer
c169db3b66 Merging latest blocks-related stuff from MOODLE_14_STABLE. 2004-08-31 07:29:25 +00:00
moodler
e02c35b2ae Merged block upgrade fix from stable 2004-08-30 16:26:00 +00:00
defacer
0e9af91794 Fix for bug 1678:
Now when the format of a course is changed, all blocks which are not
applicable for it anymore are automatically purged.
2004-08-22 16:48:28 +00:00
defacer
fe78a3dc30 Ooops! Silly mistake... NOW bug 1736 is fixed. 2004-08-12 07:17:46 +00:00
defacer
0c9c6363bc Fix for bug 1736:
Invisible blocks are now not contributing to block column width calculations.
2004-08-12 07:09:18 +00:00
moodler
36a2d0f508 Pass the current course to the block class when creating it to find the name
of the block.   This allows the class to return different result depending
on the course it is in.
2004-06-30 13:17:59 +00:00
moodler
6236ed990d Pass the whole $course variable to block_print_blocks_admin()
so we have more information.
2004-06-30 13:11:15 +00:00
defacer
33bee34c0b Fix for bug #1555:
Now the test for block constructors works under PHP 5.
2004-06-18 12:25:27 +00:00
defacer
89adb17442 Merging the changes from 1.4 dev branch (site index blocks + various bugfixes) 2004-05-28 10:53:54 +00:00
defacer
b88f700492 Fixed a bug: blocks without db functions caused the upgrade process to become stuck. 2004-05-27 14:16:27 +00:00
moodler
a7b44978a3 Changed the default default blocks so that calendar block is not shown
(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
2004-05-24 07:24:36 +00:00
defacer
0784eb7ef1 Now we can get a list of the blocks being on display in the course page.
Could be used by one block to detect the existence of another, for example.
2004-05-21 11:06:49 +00:00
moodler
a71bfa1c78 Supress errors on set_time_limit() for servers with safe mode restrictions 2004-05-18 14:12:21 +00:00
defacer
828c4e095a Preparation for Nuke blocks integration, and relaxing of requirements for
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! :-)
2004-05-11 16:08:03 +00:00
moodler
c598d270de The "Add" block is now called "Blocks" ... other block admin stuff can
go in this block later.
2004-04-27 09:30:44 +00:00