Miscellaneous fixes in the hooks file

* Less globals, more RequestContext
* Fixed error in fnNewSidebarItem() -- the condition wouldn't have been triggered for non-English wikis because "special" can be translated (as can the special page name itself, too!)
* Better URL generation in fnNewSidebarItem()
* dirname( __FILE__ ) --> __DIR__
* Removed an extraneous slash in onLoadExtensionSchemaUpdates()
* Coding style tweaks

Change-Id: I796ccfaa2b6984ff90c81e813d9866875ee98c72
Merge "Miscellaneous fixes in the hooks file"