PageRenderTime 63ms CodeModel.GetById 34ms RepoModel.GetById 0ms app.codeStats 1ms

/thirdparty/ZendFramework/library/Zend.php

https://github.com/sfsergey/knowledgetree
PHP | 293 lines | 84 code | 21 blank | 188 comment | 1 complexity | 09357352c755474d5608fb3db5a29e8c MD5 | raw file
Possible License(s): Apache-2.0, LGPL-2.1, GPL-3.0
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend
  17. * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
  18. * @license http://framework.zend.com/license/new-bsd New BSD License
  19. * @version $Id: Zend.php 3900 2007-03-13 18:51:49Z bkarwin $
  20. */
  21. /**
  22. * Zend_Exception
  23. */
  24. require_once 'Zend/Exception.php';
  25. /**
  26. * Utility class for common functions.
  27. *
  28. * @deprecated Since Zend Framework 0.9.0.
  29. *
  30. * @category Zend
  31. * @package Zend
  32. * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
  33. * @license http://framework.zend.com/license/new-bsd New BSD License
  34. */
  35. final class Zend
  36. {
  37. /**
  38. * Zend Framework version identification - see compareVersion()
  39. *
  40. * @deprecated Since 0.9.0 -- use Zend_Version::VERSION instead.
  41. */
  42. const VERSION = '0.9.0dev';
  43. /**
  44. * Object registry provides storage for shared objects
  45. *
  46. * @var Zend_Registry
  47. */
  48. static private $_registry = null;
  49. /**
  50. * Loads a class from a PHP file. The filename must be formatted
  51. * as "$class.php".
  52. *
  53. * If $dirs is a string or an array, it will search the directories
  54. * in the order supplied, and attempt to load the first matching file.
  55. *
  56. * If $dirs is null, it will split the class name at underscores to
  57. * generate a path hierarchy (e.g., "Zend_Example_Class" will map
  58. * to "Zend/Example/Class.php").
  59. *
  60. * If the file was not found in the $dirs, or if no $dirs were specified,
  61. * it will attempt to load it from PHP's include_path.
  62. *
  63. * @param string $class - The full class name of a Zend component.
  64. * @param string|array $dirs - OPTIONAL either a path or array of paths to search
  65. * @throws Zend_Exception
  66. * @return void
  67. *
  68. * @deprecated Since 0.9.0 -- Use Zend_Loader::loadClass() instead.
  69. */
  70. static public function loadClass($class, $dirs = null)
  71. {
  72. trigger_error(__CLASS__ . "::" . __FUNCTION__ . " deprecated since 0.9.0, use Zend_Loader::loadClass() instead");
  73. require_once 'Zend/Loader.php';
  74. Zend_Loader::loadClass($class, $dirs);
  75. }
  76. /**
  77. * Loads an interface from a PHP file
  78. *
  79. * @deprecated Since 0.6
  80. */
  81. static public function loadInterface($class, $dirs = null)
  82. {
  83. throw new Zend_Exception(__FUNCTION__ . " has been removed. Please use require_once().");
  84. }
  85. /**
  86. * Loads a PHP file. This is a wrapper for PHP's include() function.
  87. *
  88. * $filename must be the complete filename, including any
  89. * extension such as ".php". Note that a security check is performed that
  90. * does not permit extended characters in the filename. This method is
  91. * intended for loading Zend Framework files.
  92. *
  93. * If $dirs is a string or an array, it will search the directories
  94. * in the order supplied, and attempt to load the first matching file.
  95. *
  96. * If the file was not found in the $dirs, or if no $dirs were specified,
  97. * it will attempt to load it from PHP's include_path.
  98. *
  99. * If $once is TRUE, it will use include_once() instead of include().
  100. *
  101. * @param string $filename
  102. * @param string|array $dirs - OPTIONAL either a path or array of paths to search
  103. * @param boolean $once
  104. * @throws Zend_Exception
  105. * @return mixed
  106. *
  107. * @deprecated Since 0.9.0 -- Use Zend_Loader::loadFile() instead.
  108. */
  109. static public function loadFile($filename, $dirs = null, $once = false)
  110. {
  111. trigger_error(__CLASS__ . "::" . __FUNCTION__ . " deprecated since 0.9.0, use Zend_Loader::loadFile() instead");
  112. require_once 'Zend/Loader.php';
  113. Zend_Loader::loadFile($filename, $dirs, $once);
  114. }
  115. /**
  116. * Returns TRUE if the $filename is readable, or FALSE otherwise. This
  117. * function uses the PHP include_path, where PHP's is_readable() does not.
  118. *
  119. * @param string $filename
  120. * @return boolean
  121. *
  122. * @deprecated Since 0.9.0 -- Use Zend_Loader::isReadable() instead.
  123. */
  124. static public function isReadable($filename)
  125. {
  126. trigger_error(__CLASS__ . "::" . __FUNCTION__ . " deprecated since 0.9.0, use Zend_Loader::isReadable() instead");
  127. require_once 'Zend/Loader.php';
  128. return Zend_Loader::isReadable($filename);
  129. }
  130. /**
  131. * Return a new exception
  132. *
  133. * Loads an exception class as specified by $class, and then passes the
  134. * message and code arguments to the Exception's constructor, returning the
  135. * new Exception object.
  136. *
  137. * If the exception created is not a true Exception, throws a Zend_Exception
  138. * indicating an invalid exception class was passed.
  139. *
  140. * Usage:
  141. * <code>
  142. * throw Zend::exception('Some_Exception', 'exception message');
  143. * </code>
  144. *
  145. * @param string $class
  146. * @param string $message Defaults to empty string
  147. * @param int $code Defaults to 0
  148. * @return Exception
  149. * @throws Zend_Exception when invalid exception class passed
  150. *
  151. * @deprecated Since 0.6.1
  152. */
  153. static public function exception($class, $message = '', $code = 0)
  154. {
  155. trigger_error(__CLASS__ . "::" . __FUNCTION__ . " deprecated since 0.6.1");
  156. $class = (string) $class;
  157. require_once 'Zend/Loader.php';
  158. Zend_Loader::loadClass($class);
  159. $exception = new $class($message, $code);
  160. if (!$exception instanceof Exception) {
  161. throw new Zend_Exception('Invalid exception class used in Zend::exception()');
  162. }
  163. return $exception;
  164. }
  165. /**
  166. * offsetSet stores $newval at key $index
  167. *
  168. * @param mixed $index index to set
  169. * @param $newval new value to store at offset $index
  170. * @return void
  171. *
  172. * @deprecated Since 0.9.0 -- Use Zend_Registry::set() instead.
  173. */
  174. static public function register($index, $newval)
  175. {
  176. trigger_error(__CLASS__ . "::" . __FUNCTION__ . " deprecated since 0.9.0, use Zend_Registry::set() instead");
  177. require_once 'Zend/Registry.php';
  178. Zend_Registry::set($index, $newval);
  179. }
  180. /**
  181. * registry() retrieves the value stored at an index.
  182. *
  183. * If the $index argument is NULL or not specified,
  184. * this method returns the registry object (iterable).
  185. *
  186. * @see register()
  187. * @param string $index The name for the value.
  188. * @throws Zend_Registry_Exception
  189. * @return mixed The registered value for $index.
  190. *
  191. * @deprecated Since 0.9.0 -- Use Zend_Registry::get() instead.
  192. */
  193. static public function registry($index = null)
  194. {
  195. trigger_error(__CLASS__ . "::" . __FUNCTION__ . " deprecated since 0.9.0, use Zend_Registry::get() instead");
  196. require_once 'Zend/Registry.php';
  197. Zend_Registry::get($index);
  198. }
  199. /**
  200. * Returns TRUE if the $index is a named value in the
  201. * registry, or FALSE if $index was not found in the registry.
  202. *
  203. * @param string $index
  204. * @return boolean
  205. *
  206. * @deprecated Since 0.9.0 -- Use Zend_Registry::isRegistered() instead.
  207. */
  208. static public function isRegistered($index)
  209. {
  210. trigger_error(__CLASS__ . "::" . __FUNCTION__ . " deprecated since 0.9.0, use Zend_Registry::isRegistered() instead");
  211. require_once 'Zend/Registry.php';
  212. return Zend_Registry::isRegistered($index);
  213. }
  214. /**
  215. * Initialize the registry. Invoking this method more than once will generate an exception.
  216. *
  217. * @param mixed $registry - Either a name of the registry class (Zend_Registry, or a subclass)
  218. * or an instance of Zend_Registry (or subclass)
  219. * @return Zend_Registry
  220. *
  221. * @deprecated Since 0.9.0 -- Use Zend_Registry::setClassName() instead.
  222. */
  223. static public function initRegistry($registry = 'Zend_Registry')
  224. {
  225. trigger_error(__CLASS__ . "::" . __FUNCTION__ . " deprecated since 0.9.0, use Zend_Registry::setClassName() instead");
  226. require_once 'Zend/Registry.php';
  227. Zend_Registry::setClassName($registry);
  228. return Zend_Registry::getInstance();
  229. }
  230. /**
  231. * primarily for tearDown() in unit tests
  232. *
  233. * @deprecated Since 0.9.0 -- Use Zend_Registry::_unsetInstance() instead.
  234. */
  235. static public function __unsetRegistry()
  236. {
  237. trigger_error(__CLASS__ . "::" . __FUNCTION__ . " deprecated since 0.9.0, use Zend_Registry::_unsetInstance() instead");
  238. require_once 'Zend/Registry.php';
  239. Zend_Registry::_unsetInstance();
  240. }
  241. /**
  242. * Debug helper function. This is a wrapper for var_dump() that adds
  243. * the <pre /> tags, cleans up newlines and indents, and runs
  244. * htmlentities() before output.
  245. *
  246. * @param mixed $var The variable to dump.
  247. * @param string $label An optional label.
  248. * @return string
  249. *
  250. * @deprecated since 0.9.0
  251. */
  252. static public function dump($var, $label=null, $echo=true)
  253. {
  254. trigger_error(__CLASS__ . "::" . __FUNCTION__ . " deprecated since 0.9.0, use Zend_Debug::dump() instead");
  255. require_once 'Zend/Debug.php';
  256. return Zend_Debug::dump($var, $label, $echo);
  257. }
  258. /**
  259. * Compare the specified ZF $version with the current Zend::VERSION of the ZF.
  260. *
  261. * @param string $version A version identifier for the ZF (e.g. "0.7.1")
  262. * @return boolean -1 if the $version is older, 0 if they are the same, and +1 if $version is newer
  263. *
  264. * @deprecated Since 0.9.0 -- Use Zend_Version::compareVersion() instead.
  265. */
  266. static public function compareVersion($version)
  267. {
  268. trigger_error(__CLASS__ . "::" . __FUNCTION__ . " deprecated since 0.9.0, use Zend_Version::compareVersion() instead");
  269. require_once 'Zend/Version.php';
  270. return Zend_Version::compareVersion($version);
  271. }
  272. }