Converting 4.1.x modules to 4.2.x
Some points posted by Axel on drupal-devel on migrating 4.1.0 modules to CVS [updated and added to by ax]:
- the big "clean URL" patch: Over the weekend, [dries] bit the bullet and converted every single URL in Drupal's code. meaning we'll [can] have clean URLs like http://foo.com/archive/2003/01/06, http://foo.com/user/42, http://foo.com/blog, and so on.. meaning, for the code:
-
drupal_url(array("mod" => "search", "op" => "bla"), "module"[, $anchor = ""])
became
url("search/bla"),
with the first url part being the module, the second (typically) being the operation ($op); more arguments are handled differently per module convention. -
l("view node", array("op" => "view", "id" => $nid), "node"[, $anchor = "", $attributes = array()])
became
l("view node", "node/view/$nid"[,$attributes = array(), $query = NULL]) -
similar,
lm(), which meant "module link" and used to bemodule.php?mod=bla&op=blub..., is nowl("title", "bla/blub/..."); and
la(), which meant "admin link" and used to beadmin.php?mod=bla&op=blub..., is nowl("title", "admin/bla/blub/..." - After fixing those functions, you'll need to edit your _page() function and possibly others so that they get their arguments using the arg() function (see includes/common.inc. These arguments used to be globals called "mod", "op", "id" etc. now these same arguments must be accessed as arg(1), arg(3), for example.
$theme->function() became theme("function"). see [drupal-devel] renaming 2 functions, [drupal-devel] theme("function") vs $theme->function() and [drupal-devel] [CVS] theme()<module>_conf_options() became <module>_settings() - see [drupal-devel] renaming 2 functions. note that doesn't get an extra menu entry, butis accessed via "site configuration > modules > modules settings"
the administration pages got changed quite a lot to use a "database driven link system" and become more logical/intuitive - see [drupal-devel] X-mas commit: administration pages. this first try resulted in poor performance and a not-so-good api, so it got refactored - see [PATCH] menus. this, as of time ax is writing this, isn't really satisfying, neither (you cannot build arbitrary menu-trees, some forms don't work (taxonomy > add term), ...), so it probably will change again. and i won't write more about this here.
well, this: you use menu() to add entries to the admin menu. menu("admin/node/nodes/0", "new or updated posts", "node_admin", "help", 0); adds a menu entry "new or updated posts" 1 level below "post overview" (admin/node/nodes) and 2 level below "node management" (admin/node) (ie. at the 3. level), with a weight of 0 in the 3. level, with a line "help" below the main heading. for the callback ("node_admin") ... ask dries or zbynek
one more note, though: you do not add <module>_settings() to the menu (they automatically go to "site configuration > modules > module settings" - you only add <module>_admin...() ... things.
- comment_is_new($comment)
+ node_is_new($comment->nid, $comment->timestamp)please add / update / correct!
