PluginProbe
CSS & JavaScript Toolbox / 11.3
CSS & JavaScript Toolbox v11.3
trunk 0.3 0.8 10 10.1 11 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 11.9.1 12 12.0 12.0.1 12.0.3 12.0.4 12.0.5 12.0.6 12.0.7 6.0 6.0.11 All 60 releases
css-javascript-toolbox / framework / access-points / directory-spider.class.php

directory-spider.class.php in CSS & JavaScript Toolbox 11.3, at framework/access-points/directory-spider.class.php

100 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 *
4 */
5
6 // Disallow direct access.
7 defined('ABSPATH') or die("Access denied");
8
9 /**
10 *
11 */
12 class CJTAccessPointsDirectorySpider extends ArrayIterator {
13
14 /**
15 * put your comment there...
16 *
17 * @var mixed
18 */
19 protected $aPoints;
20
21 /**
22 * put your comment there...
23 *
24 * @var mixed
25 */
26 protected $dir;
27
28 /**
29 * put your comment there...
30 *
31 * @var mixed
32 */
33 protected $prefix;
34
35 /**
36 * put your comment there...
37 *
38 * @param mixed $dir
39 * @return CJTAccessPoints
40 */
41 public function __construct($prefix, $dir) {
42 // Initialize specifc!
43 $this->prefix = $prefix;
44 $this->dir = $dir;
45 // Load access points!
46 $this->load();
47 // ArrayIterator.
48 parent::__construct($this->aPoints);
49 }
50
51 /**
52 * put your comment there...
53 *
54 * @param mixed $prefix
55 * @param mixed $dir
56 */
57 public static function getInstance($prefix, $dir) {
58 return new CJTAccessPointsDirectorySpider($prefix, $dir);
59 }
60
61 /**
62 * put your comment there...
63 *
64 * @return CJTAccessPointsDirectorySpider Returns $this.
65 */
66 protected function load() {
67 // Reset access points!
68 $this->aPoints =array();
69 // Get all defined ap inside the specified directory!
70 $accessPoints = new DirectoryIterator($this->dir);
71 foreach ($accessPoints as $file) {
72 if (!$file->isDir()) {
73 // Build point info!
74 $point = array();
75 $point['file'] = $file->getFilename();
76 $point['name'] = $file->getBaseName('.accesspoint.php');
77 $point['class'] = "{$this->prefix}{$point['name']}AccessPoint";
78 // Add to points list!
79 $this->aPoints[$point['name']] = $point;
80 }
81 }
82 return $this;
83 }
84
85 /**
86 * put your comment there...
87 *
88 */
89 public function point() {
90 // Get access point info!
91 $point =& $this[$this->key()];
92 // Full absolulte path to access point file!
93 $absPath = "{$this->dir}/{$point['file']}";
94 // Instantiate point class, this will put it in action!
95 include_once $absPath;
96 return new $point['class']();
97 }
98
99 } // End class.
100