# css-javascript-toolbox/12.0/framework/php/includes.class.php

CSS &amp; JavaScript Toolbox, version 12.0. 152 lines.

- Page: https://pluginprobe.com/plugins/css-javascript-toolbox/12.0/code/framework/php/includes.class.php
- Raw: https://pluginprobe.com/plugins/css-javascript-toolbox/12.0/raw/framework/php/includes.class.php
- Modified: 2024-08-07T15:03:56+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/css-javascript-toolbox/12.0/code/framework/php/includes.class.php#L10-L20`.

```php
	<?php
/**
*
*/

/**
*
*/
class CJTIncludes implements ArrayAccess {

	/**
	* put your comment there...
	*
	* @var mixed
	*/
	private $name;

	/**
	* put your comment there...
	*
	* @var mixed
	*/
	protected $list;

	/**
	* put your comment there...
	*
	*/
	public function __construct($name, $inits = array()) {
		$this->name = $name;
		// Copy all values!
		$this->setArray($inits);
	}

	/**
	* put your comment there...
	*
	* @param mixed $key
	* @param mixed $path
	*/
	public function add($key, $path) {
		$this[$key] = $path;
	}

	/**
	* put your comment there...
	*
	* @param mixed $name
	*/
	public static function addShared($name) {
		return self::$sharedList[$name]	= new CJTIncludes(null);
	}

	/**
	* put your comment there...
	*
	*/
	public function clear() {
		$this->list = array();
	}

	/**
	* put your comment there...
	*
	* @param mixed $file
	*/
	public function exists($file) {
		$result = array();
		// Search all paths in reverve orders so override is allowed!
		end($this->list);
		do {
			$path = current($this->list);
			$fullPath = "{$path}/{$file}";
			if (file_exists($fullPath)) {
				$result['key'] =  key($this->list);
				$result['fullPath'] = $fullPath;
				break;
			}
		} while (prev($this->list));
		return $result;
	}

	/**
	* put your comment there...
	*
	*/
	public function hasPaths() {
		return !empty($this->list);
	}

	/**
	* put your comment there...
	*
	* @param mixed $file
	*/
	public function import($file) {
		$result = false;
		if ($fileInfo = $this->exists($file)) {
			$result = require_once $fileInfo['fullPath'];
		}
		return $result;
	}

	/**
	* put your comment there...
	*
	* @param mixed $path
	*/
	public function offsetExists($key): bool {
		return isset($this->list[$key]);
	}

	/**
	* put your comment there...
	*
	* @param mixed $path
	*/
	public function offsetGet($key): bool {
		return $this->list[$key];
	}

	/**
	* put your comment there...
	*
	* @param mixed $path
	*/
	public function offsetSet($key, $path): void {
		$this->list[$key]  = $path;
	}

	/**
	* put your comment there...
	*
	* @param mixed $path
	*/
	public function offsetUnset($key): void {
		unset($this->list[$key]);
	}

	/**
	* put your comment there...
	*
	* @param mixed $list
	*/
	protected function setArray(& $list) {
		foreach ($list as $key => $path) {
			$this[$key] = $path;
		}
	}

} // End class.

```
