NOBUG: Make globals static public for reuse.
NOBUG: Tidy library code a bit.
CONTRIB-4696 Support distributed 3rd part lib xml

Since Moodle 2.6 we have split the old, unique thirdpartylibs.xml
file, distributing it along codebase for plugins having their own libs.

This patch addresses:

- Support those distributed xml files.
- Do it conditionally, so it will continue working against old branches.
- Fix a existing problem about some paths being generated wrongly in the past.
- Debug information about any incorrect path defined in the xml files
Merge pull request #13 from stronk7/CONTRIB-4696

CONTRIB-4696 Support distributed 3rd part lib xml