summaryrefslogtreecommitdiff
path: root/lib/querypath/src/qp.php
blob: 9d381375380f09e4cb084e70cd5c0c54ed805cb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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';
}