Clean up database interaction and migrate to Wikimedia Labs

Highlights:

* Add BaseTool option 'requireJS'.

* New LabsDB class that automatically resolves dbnames to shards
  and efficiently re-uses connections (this allows connecting to 100s
  of wikis without creating 100s of connections). Similar to how
  previously was done on Toolserver.

  The new DB layer also uses PDO instead of the legacy mysql_*
  functions. While this offsers many advantages, the main downside
  so far as it that PDO does not support switching databases on
  a connection so sending a "USE dbname;" query directly for now.
  However this can have unintended side-effects. Considered Mysqli
  classes but those don't have pretty ":named"-style bindings.

* Improve error handling.

* Remove all Toolserver stuff.

* Remove "Main connection" concept and instead only use named connections.

* Update mw/Html.php to incorporate upstream changes (such as supporting
  arrays as values for the 'class' attribute) and update the mw mock
  accordingly.

* Lots of small enhancements and bug fixes.

Interface changes:

* Function kfLog no longer takes a $current parameter, use kfLogStart()
  and kgLogEnd() to group information for profiling and logging.

* Function kfWikiHref now takes $wikiInfo instead of $wikiData.

Removed:

* Constant KR_KEEP_PRIM_DBCON.
* Constant KR_SET_AS_PRIM_DBCON.
* Method GlobalConfig::getAllDbConnects.
* Method GlobalConfig::getDbConnect.
* Method GlobalConfig::getDbExtraConnect.
* Method GlobalConfig::getRunlog.
* Method GlobalConfig::getRunlogFlushCount.
* Method GlobalConfig::setDbConnect.
* Method GlobalConfig::setDbExtraConnect.
* Method GlobalConfig::setRunlog.
* Method GlobalConfig::setRunlogFlushCount.
* Function is_odd.
* Function kfCloseAllConnections.
* Function kfConnectRRServerByDBName.
* Function kfConnectRRServerByHostname.
* Function kfConnectToAllWikiDbServers.
* Function kfDoSelectQueryRaw.
* Function kfGetAllWikiSelect.
* Function kfGetSvnInfo.
* Function kfGetSvnrev.
* Function kfGetWikiDataFromDBName.
* Function kfQueryWMFAPI.
* Function kfStripStr.
* Function kfWikiHref.
* Function mysql_clean.
* Function mysql_object_all.
* Function wikiDataFromRow.