diff options
author | emkael <emkael@tlen.pl> | 2017-01-18 20:07:16 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2017-01-18 20:07:16 +0100 |
commit | 9a9c04512e5dcb77c7fe5d850e3f2a0250cc160e (patch) | |
tree | fed46b5f4c2ed3a050bb1a7ad7c6d0a3ea844d55 /lib/querypath/src/qp.php | |
parent | c5bcf8f74fb80b7e163663845b0d6e35cabface3 (diff) |
* Motor Sport Magazine feed provider
Diffstat (limited to 'lib/querypath/src/qp.php')
-rw-r--r-- | lib/querypath/src/qp.php | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/lib/querypath/src/qp.php b/lib/querypath/src/qp.php new file mode 100644 index 0000000..9d38137 --- /dev/null +++ b/lib/querypath/src/qp.php @@ -0,0 +1,82 @@ +<?php +/** + * @file + * + * QueryPath bootstrap. + * + * This file holds bootstrap code to load the QueryPath library. + * + * Usage: + * + * @code + * <?php + * require 'qp.php'; + * + * qp($xml)->find('foo')->count(); + * ?> + * @endcode + * + * If no autoloader is currently operating, this will use + * QueryPath's default autoloader **unless** + * QP_NO_AUTOLOADER is defined, in which case all of the + * files will be statically required in. + */ + +// This is sort of a last ditch attempt to load QueryPath if no +// autoloader is used. +if (!class_exists('\QueryPath')) { + + // If classloaders are explicitly disabled, load everything. + if (defined('QP_NO_AUTOLOADER')) { + // This is all (and only) the required classes for QueryPath. + // Extensions are not loaded automatically. + require __DIR__ . '/QueryPath/Exception.php'; + require __DIR__ . '/QueryPath/ParseException.php'; + require __DIR__ . '/QueryPath/IOException.php'; + require __DIR__ . '/QueryPath/CSS/ParseException.php'; + require __DIR__ . '/QueryPath/CSS/NotImplementedException.php'; + require __DIR__ . '/QueryPath/CSS/EventHandler.php'; + require __DIR__ . '/QueryPath/CSS/SimpleSelector.php'; + require __DIR__ . '/QueryPath/CSS/Selector.php'; + require __DIR__ . '/QueryPath/CSS/Traverser.php'; + require __DIR__ . '/QueryPath/CSS/DOMTraverser/PseudoClass.php'; + // require __DIR__ . '/QueryPath/CSS/DOMTraverser/PseudoElement.php'; + require __DIR__ . '/QueryPath/CSS/DOMTraverser/Util.php'; + require __DIR__ . '/QueryPath/CSS/DOMTraverser.php'; + require __DIR__ . '/QueryPath/CSS/Token.php'; + require __DIR__ . '/QueryPath/CSS/InputStream.php'; + require __DIR__ . '/QueryPath/CSS/Scanner.php'; + require __DIR__ . '/QueryPath/CSS/Parser.php'; + require __DIR__ . '/QueryPath/CSS/QueryPathEventHandler.php'; + require __DIR__ . '/QueryPath/Query.php'; + require __DIR__ . '/QueryPath/Entities.php'; + require __DIR__ . '/QueryPath/Extension.php'; + require __DIR__ . '/QueryPath/ExtensionRegistry.php'; + require __DIR__ . '/QueryPath/Options.php'; + require __DIR__ . '/QueryPath/QueryPathIterator.php'; + require __DIR__ . '/QueryPath/DOMQuery.php'; + require __DIR__ . '/QueryPath.php'; + } + else { + spl_autoload_register(function ($klass) { + $parts = explode('\\', $klass); + + // Issue #164 + if ($parts[0] == '') { + array_shift($parts); + } + + if ($parts[0] == 'QueryPath') { + $path = __DIR__ . '/' . implode('/', $parts) . '.php'; + if (file_exists($path)) { + require $path; + } + } + }); + } +} + +// Define qp() and qphtml() function. +if (!function_exists('qp')) { + require __DIR__ . '/qp_functions.php'; +} |