Permalink
Browse files

Base and working framework

  • Loading branch information...
1 parent e10b3fe commit 10811e077c760d7eddb9e3a704030f3d7a951c7f @rdohms committed Dec 27, 2010
Showing with 6,518 additions and 1 deletion.
  1. +1 −0 .gitignore
  2. +7 −1 README.md
  3. +4 −0 config/config.ini.php
  4. +25 −0 library/App/Action/Base.php
  5. +24 −0 library/App/Action/ErrorAction.php
  6. +20 −0 library/App/Action/ListAction.php
  7. +12 −0 library/App/Action/iAction.php
  8. +68 −0 library/App/Application.php
  9. +27 −0 library/App/Mustache/Mustache.php
  10. +22 −0 library/App/Mustache/TemplateLoader.php
  11. +25 −0 library/bootstrap.php
  12. +96 −0 library/vendor/Zend/Exception.php
  13. +329 −0 library/vendor/Zend/Loader.php
  14. +23 −0 library/vendor/Zend/Loader/.svn/all-wcprops
  15. +136 −0 library/vendor/Zend/Loader/.svn/entries
  16. +9 −0 library/vendor/Zend/Loader/.svn/prop-base/Autoloader.php.svn-base
  17. +5 −0 library/vendor/Zend/Loader/.svn/prop-base/Exception.php.svn-base
  18. +5 −0 library/vendor/Zend/Loader/.svn/prop-base/PluginLoader.php.svn-base
  19. +582 −0 library/vendor/Zend/Loader/.svn/text-base/Autoloader.php.svn-base
  20. +35 −0 library/vendor/Zend/Loader/.svn/text-base/Exception.php.svn-base
  21. +484 −0 library/vendor/Zend/Loader/.svn/text-base/PluginLoader.php.svn-base
  22. +582 −0 library/vendor/Zend/Loader/Autoloader.php
  23. +17 −0 library/vendor/Zend/Loader/Autoloader/.svn/all-wcprops
  24. +5 −0 library/vendor/Zend/Loader/Autoloader/.svn/dir-prop-base
  25. +96 −0 library/vendor/Zend/Loader/Autoloader/.svn/entries
  26. +5 −0 library/vendor/Zend/Loader/Autoloader/.svn/prop-base/Interface.php.svn-base
  27. +5 −0 library/vendor/Zend/Loader/Autoloader/.svn/prop-base/Resource.php.svn-base
  28. +43 −0 library/vendor/Zend/Loader/Autoloader/.svn/text-base/Interface.php.svn-base
  29. +460 −0 library/vendor/Zend/Loader/Autoloader/.svn/text-base/Resource.php.svn-base
  30. +43 −0 library/vendor/Zend/Loader/Autoloader/Interface.php
  31. +460 −0 library/vendor/Zend/Loader/Autoloader/Resource.php
  32. +35 −0 library/vendor/Zend/Loader/Exception.php
  33. +484 −0 library/vendor/Zend/Loader/PluginLoader.php
  34. +17 −0 library/vendor/Zend/Loader/PluginLoader/.svn/all-wcprops
  35. +96 −0 library/vendor/Zend/Loader/PluginLoader/.svn/entries
  36. +5 −0 library/vendor/Zend/Loader/PluginLoader/.svn/prop-base/Exception.php.svn-base
  37. +5 −0 library/vendor/Zend/Loader/PluginLoader/.svn/prop-base/Interface.php.svn-base
  38. +39 −0 library/vendor/Zend/Loader/PluginLoader/.svn/text-base/Exception.php.svn-base
  39. +75 −0 library/vendor/Zend/Loader/PluginLoader/.svn/text-base/Interface.php.svn-base
  40. +39 −0 library/vendor/Zend/Loader/PluginLoader/Exception.php
  41. +75 −0 library/vendor/Zend/Loader/PluginLoader/Interface.php
  42. +209 −0 library/vendor/Zend/Registry.php
  43. +955 −0 library/vendor/facebook/facebook.php
  44. +795 −0 library/vendor/mustache/Mustache.php
  45. +11 −0 public/.htaccess
  46. +8 −0 public/index.php
  47. +4 −0 templates/error.mustache
  48. +10 −0 templates/layout.mustache
  49. +1 −0 templates/list.mustache
View
1 .gitignore
@@ -0,0 +1 @@
+.DS_Store
View
8 README.md
@@ -6,4 +6,10 @@ With the Graph API and OAuth 2.0 Facebook also introduced special test user acco
## Pre-Requisites
-## About Author
+* PHP 5.3
+
+## About Author
+
+**Rafael Dohms** is a PHP Evangelist in Brazil and a very active member of the PHP Community. He helped found two PHP User Groups over the years and currently shares the lead of PHPSP. Developer, gamer and lover of code he also hosts Brazil’s first PHP Podcast: PHPSPCast.
+
+Currently he works for MIH SWAT Team, a group of experts that provides technical knowledge to the MIH group as well as working on R&D in search of the new and exciting niches of the web. His role as a Senior PHP Developer is to code, train and aid other companies and to have fun doing so.
View
4 config/config.ini.php
@@ -0,0 +1,4 @@
+<?php
+
+define('FACEBOOK_APP_ID', 'Insert key');
+define('FACEBOOK_APP_SECRET', 'Insert key');
View
25 library/App/Action/Base.php
@@ -0,0 +1,25 @@
+<?php
+
+namespace App\Action;
+
+abstract class Base implements iAction
+{
+ /**
+ * @return \Facebook
+ */
+ public function getFacebookClient()
+ {
+ return \Zend_Registry::get('facebook');
+ }
+
+ /**
+ * @return App/Mustache/Mustache
+ */
+ public function getMustache()
+ {
+ return \Zend_Registry::get('mustache');
+ }
+
+}
+
+?>
View
24 library/App/Action/ErrorAction.php
@@ -0,0 +1,24 @@
+<?php
+namespace App\Action;
+
+class ErrorAction extends Base
+{
+
+ protected $error;
+
+ public function run()
+ {
+ $error = new \stdClass();
+ $error->message = $this->error->getMessage();
+
+ $this->getMustache()->renderContent('error', array('error' => (array) $error));
+ }
+
+ public function setError($e)
+ {
+ $this->error = $e;
+
+ }
+}
+
+?>
View
20 library/App/Action/ListAction.php
@@ -0,0 +1,20 @@
+<?php
+
+namespace App\Action;
+
+class ListAction extends Base
+{
+
+ public function run()
+ {
+ //Get list of users
+ $users = array();
+ //Get extra data
+
+ //Render Template
+ $this->getMustache()->renderContent('list', array('users' => $users));
+ }
+
+}
+
+?>
View
12 library/App/Action/iAction.php
@@ -0,0 +1,12 @@
+<?php
+
+namespace App\Action;
+
+interface iAction
+{
+
+ public function run();
+
+}
+
+?>
View
68 library/App/Application.php
@@ -0,0 +1,68 @@
+<?php
+
+namespace App;
+
+class Application
+{
+
+ public function __construct()
+ {
+ $mustache = new \App\Mustache\Mustache();
+ $facebook = new \Facebook(array(
+ 'appId' => FACEBOOK_APP_ID,
+ 'secret' => FACEBOOK_APP_SECRET
+ ));
+
+ \Zend_Registry::set('mustache', $mustache);
+ \Zend_Registry::set('facebook', $facebook);
+
+ }
+
+ public function run()
+ {
+ try {
+ var_dump($_SERVER);
+ $action = $this->getActionClass($_SERVER['REQUEST_URI']);
+ $action->run();
+
+ } catch (\Exception $e) {
+ $action = new Action\ErrorAction();
+ $action->setError($e);
+ $action->run();
+ }
+ }
+
+ private function getActionClass($name)
+ {
+ //Strip rest of url if not in its own VirtualHost
+ $name = substr($name, strrpos($name, 'public') );
+ $name = str_replace('public/', '', $name);
+ var_dump($name);
+ $name = ($name == "" || null === $name || $name == "/")? 'list':$name;
+ var_dump($name);
+ if (strpos($name, '/') !== false) {
+ $name = strstr($name, '/', true);
+ }
+ var_dump($name);
+ $name = str_replace('-', ' ', $name);
+ var_dump($name);
+ $name = ucwords($name);
+ var_dump($name);
+ $name = str_replace(' ', '', $name);
+ var_dump($name);
+
+ $class = 'App\\Action\\' . $name . 'Action';
+ var_dump($class);var_dump(class_exists($class));
+ if (!class_exists($class)){
+ $action = new \App\Action\ErrorAction();
+ $action->setError( new \Exception('Action '.$name.' not defined') );
+
+ return $action;
+ }
+
+ return new $class;
+
+ }
+}
+
+?>
View
27 library/App/Mustache/Mustache.php
@@ -0,0 +1,27 @@
+<?php
+
+namespace App\Mustache;
+
+use App\Mustache\TemplateLoader;
+
+class Mustache extends \Mustache
+{
+
+ public function renderContent($tpl, $data)
+ {
+ $template = TemplateLoader::loadTpl($tpl);
+
+ $content = parent::render($template, $data);
+
+ echo $this->layoutRender($content);
+ }
+
+ public function layoutRender($content)
+ {
+ $layout = TemplateLoader::loadTpl('layout');
+
+ return parent::render($layout, array('content' => $content));
+ }
+}
+
+?>
View
22 library/App/Mustache/TemplateLoader.php
@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Mustache;
+
+class TemplateLoader
+{
+ public static function loadTpl($tpl)
+ {
+ //Check for file
+ $file = TPL_PATH . $tpl . '.mustache';
+
+ if (!file_exists($file)) {
+ throw new Exception('Template file '.$file.' not found');
+ }
+
+ //Load file
+ return file_get_contents($file);
+
+ }
+}
+
+?>
View
25 library/bootstrap.php
@@ -0,0 +1,25 @@
+<?php
+
+define('ROOT_PATH', __DIR__ . '/../');
+define('LIB_PATH', ROOT_PATH . 'library/');
+define('TPL_PATH', ROOT_PATH . 'templates/');
+
+//Define library folders
+$includePaths = array();
+$includePaths[] = LIB_PATH;
+$includePaths[] = LIB_PATH . "vendor/";
+set_include_path( get_include_path() . PATH_SEPARATOR . implode(PATH_SEPARATOR, $includePaths) );
+
+//Include basic files
+include_once ROOT_PATH . 'config/config.ini.php';
+include_once LIB_PATH . 'vendor/facebook/facebook.php';
+include_once LIB_PATH . 'vendor/mustache/Mustache.php';
+include_once LIB_PATH . 'vendor/Zend/Loader/Autoloader.php';
+
+//Load an autoloader for App
+$loader = Zend_Loader_Autoloader::getInstance();
+$loader->registerNamespace('App');
+$loader->suppressNotFoundWarnings(true);
+
+?>
+
View
96 library/vendor/Zend/Exception.php
@@ -0,0 +1,96 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Exception.php 20978 2010-02-08 15:35:25Z matthew $
+ */
+
+/**
+* @category Zend
+* @package Zend
+* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+* @license http://framework.zend.com/license/new-bsd New BSD License
+*/
+class Zend_Exception extends Exception
+{
+ /**
+ * @var null|Exception
+ */
+ private $_previous = null;
+
+ /**
+ * Construct the exception
+ *
+ * @param string $msg
+ * @param int $code
+ * @param Exception $previous
+ * @return void
+ */
+ public function __construct($msg = '', $code = 0, Exception $previous = null)
+ {
+ if (version_compare(PHP_VERSION, '5.3.0', '<')) {
+ parent::__construct($msg, (int) $code);
+ $this->_previous = $previous;
+ } else {
+ parent::__construct($msg, (int) $code, $previous);
+ }
+ }
+
+ /**
+ * Overloading
+ *
+ * For PHP < 5.3.0, provides access to the getPrevious() method.
+ *
+ * @param string $method
+ * @param array $args
+ * @return mixed
+ */
+ public function __call($method, array $args)
+ {
+ if ('getprevious' == strtolower($method)) {
+ return $this->_getPrevious();
+ }
+ return null;
+ }
+
+ /**
+ * String representation of the exception
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ if (version_compare(PHP_VERSION, '5.3.0', '<')) {
+ if (null !== ($e = $this->getPrevious())) {
+ return $e->__toString()
+ . "\n\nNext "
+ . parent::__toString();
+ }
+ }
+ return parent::__toString();
+ }
+
+ /**
+ * Returns previous Exception
+ *
+ * @return Exception|null
+ */
+ protected function _getPrevious()
+ {
+ return $this->_previous;
+ }
+}
View
329 library/vendor/Zend/Loader.php
@@ -0,0 +1,329 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Loader
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id: Loader.php 22019 2010-04-27 16:33:31Z matthew $
+ */
+
+/**
+ * Static methods for loading classes and files.
+ *
+ * @category Zend
+ * @package Zend_Loader
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class Zend_Loader
+{
+ /**
+ * Loads a class from a PHP file. The filename must be formatted
+ * as "$class.php".
+ *
+ * If $dirs is a string or an array, it will search the directories
+ * in the order supplied, and attempt to load the first matching file.
+ *
+ * If $dirs is null, it will split the class name at underscores to
+ * generate a path hierarchy (e.g., "Zend_Example_Class" will map
+ * to "Zend/Example/Class.php").
+ *
+ * If the file was not found in the $dirs, or if no $dirs were specified,
+ * it will attempt to load it from PHP's include_path.
+ *
+ * @param string $class - The full class name of a Zend component.
+ * @param string|array $dirs - OPTIONAL Either a path or an array of paths
+ * to search.
+ * @return void
+ * @throws Zend_Exception
+ */
+ public static function loadClass($class, $dirs = null)
+ {
+ if (class_exists($class, false) || interface_exists($class, false)) {
+ return;
+ }
+
+ if ((null !== $dirs) && !is_string($dirs) && !is_array($dirs)) {
+ require_once 'Zend/Exception.php';
+ throw new Zend_Exception('Directory argument must be a string or an array');
+ }
+
+ // Autodiscover the path from the class name
+ // Implementation is PHP namespace-aware, and based on
+ // Framework Interop Group reference implementation:
+ // http://groups.google.com/group/php-standards/web/psr-0-final-proposal
+ $className = ltrim($class, '\\');
+ $file = '';
+ $namespace = '';
+ if ($lastNsPos = strripos($className, '\\')) {
+ $namespace = substr($className, 0, $lastNsPos);
+ $className = substr($className, $lastNsPos + 1);
+ $file = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
+ }
+ $file .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
+
+ if (!empty($dirs)) {
+ // use the autodiscovered path
+ $dirPath = dirname($file);
+ if (is_string($dirs)) {
+ $dirs = explode(PATH_SEPARATOR, $dirs);
+ }
+ foreach ($dirs as $key => $dir) {
+ if ($dir == '.') {
+ $dirs[$key] = $dirPath;
+ } else {
+ $dir = rtrim($dir, '\\/');
+ $dirs[$key] = $dir . DIRECTORY_SEPARATOR . $dirPath;
+ }
+ }
+ $file = basename($file);
+ self::loadFile($file, $dirs, true);
+ } else {
+ self::loadFile($file, null, true);
+ }
+
+ if (!class_exists($class, false) && !interface_exists($class, false)) {
+ require_once 'Zend/Exception.php';
+ throw new Zend_Exception("File \"$file\" does not exist or class \"$class\" was not found in the file");
+ }
+ }
+
+ /**
+ * Loads a PHP file. This is a wrapper for PHP's include() function.
+ *
+ * $filename must be the complete filename, including any
+ * extension such as ".php". Note that a security check is performed that
+ * does not permit extended characters in the filename. This method is
+ * intended for loading Zend Framework files.
+ *
+ * If $dirs is a string or an array, it will search the directories
+ * in the order supplied, and attempt to load the first matching file.
+ *
+ * If the file was not found in the $dirs, or if no $dirs were specified,
+ * it will attempt to load it from PHP's include_path.
+ *
+ * If $once is TRUE, it will use include_once() instead of include().
+ *
+ * @param string $filename
+ * @param string|array $dirs - OPTIONAL either a path or array of paths
+ * to search.
+ * @param boolean $once
+ * @return boolean
+ * @throws Zend_Exception
+ */
+ public static function loadFile($filename, $dirs = null, $once = false)
+ {
+ self::_securityCheck($filename);
+
+ /**
+ * Search in provided directories, as well as include_path
+ */
+ $incPath = false;
+ if (!empty($dirs) && (is_array($dirs) || is_string($dirs))) {
+ if (is_array($dirs)) {
+ $dirs = implode(PATH_SEPARATOR, $dirs);
+ }
+ $incPath = get_include_path();
+ set_include_path($dirs . PATH_SEPARATOR . $incPath);
+ }
+
+ /**
+ * Try finding for the plain filename in the include_path.
+ */
+ if ($once) {
+ include_once $filename;
+ } else {
+ include $filename;
+ }
+
+ /**
+ * If searching in directories, reset include_path
+ */
+ if ($incPath) {
+ set_include_path($incPath);
+ }
+
+ return true;
+ }
+
+ /**
+ * Returns TRUE if the $filename is readable, or FALSE otherwise.
+ * This function uses the PHP include_path, where PHP's is_readable()
+ * does not.
+ *
+ * Note from ZF-2900:
+ * If you use custom error handler, please check whether return value
+ * from error_reporting() is zero or not.
+ * At mark of fopen() can not suppress warning if the handler is used.
+ *
+ * @param string $filename
+ * @return boolean
+ */
+ public static function isReadable($filename)
+ {
+ if (is_readable($filename)) {
+ // Return early if the filename is readable without needing the
+ // include_path
+ return true;
+ }
+
+ if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN'
+ && preg_match('/^[a-z]:/i', $filename)
+ ) {
+ // If on windows, and path provided is clearly an absolute path,
+ // return false immediately
+ return false;
+ }
+
+ foreach (self::explodeIncludePath() as $path) {
+ if ($path == '.') {
+ if (is_readable($filename)) {
+ return true;
+ }
+ continue;
+ }
+ $file = $path . '/' . $filename;
+ if (is_readable($file)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Explode an include path into an array
+ *
+ * If no path provided, uses current include_path. Works around issues that
+ * occur when the path includes stream schemas.
+ *
+ * @param string|null $path
+ * @return array
+ */
+ public static function explodeIncludePath($path = null)
+ {
+ if (null === $path) {
+ $path = get_include_path();
+ }
+
+ if (PATH_SEPARATOR == ':') {
+ // On *nix systems, include_paths which include paths with a stream
+ // schema cannot be safely explode'd, so we have to be a bit more
+ // intelligent in the approach.
+ $paths = preg_split('#:(?!//)#', $path);
+ } else {
+ $paths = explode(PATH_SEPARATOR, $path);
+ }
+ return $paths;
+ }
+
+ /**
+ * spl_autoload() suitable implementation for supporting class autoloading.
+ *
+ * Attach to spl_autoload() using the following:
+ * <code>
+ * spl_autoload_register(array('Zend_Loader', 'autoload'));
+ * </code>
+ *
+ * @deprecated Since 1.8.0
+ * @param string $class
+ * @return string|false Class name on success; false on failure
+ */
+ public static function autoload($class)
+ {
+ trigger_error(__CLASS__ . '::' . __METHOD__ . ' is deprecated as of 1.8.0 and will be removed with 2.0.0; use Zend_Loader_Autoloader instead', E_USER_NOTICE);
+ try {
+ @self::loadClass($class);
+ return $class;
+ } catch (Exception $e) {
+ return false;
+ }
+ }
+
+ /**
+ * Register {@link autoload()} with spl_autoload()
+ *
+ * @deprecated Since 1.8.0
+ * @param string $class (optional)
+ * @param boolean $enabled (optional)
+ * @return void
+ * @throws Zend_Exception if spl_autoload() is not found
+ * or if the specified class does not have an autoload() method.
+ */
+ public static function registerAutoload($class = 'Zend_Loader', $enabled = true)
+ {
+ trigger_error(__CLASS__ . '::' . __METHOD__ . ' is deprecated as of 1.8.0 and will be removed with 2.0.0; use Zend_Loader_Autoloader instead', E_USER_NOTICE);
+ require_once 'Zend/Loader/Autoloader.php';
+ $autoloader = Zend_Loader_Autoloader::getInstance();
+ $autoloader->setFallbackAutoloader(true);
+
+ if ('Zend_Loader' != $class) {
+ self::loadClass($class);
+ $methods = get_class_methods($class);
+ if (!in_array('autoload', (array) $methods)) {
+ require_once 'Zend/Exception.php';
+ throw new Zend_Exception("The class \"$class\" does not have an autoload() method");
+ }
+
+ $callback = array($class, 'autoload');
+
+ if ($enabled) {
+ $autoloader->pushAutoloader($callback);
+ } else {
+ $autoloader->removeAutoloader($callback);
+ }
+ }
+ }
+
+ /**
+ * Ensure that filename does not contain exploits
+ *
+ * @param string $filename
+ * @return void
+ * @throws Zend_Exception
+ */
+ protected static function _securityCheck($filename)
+ {
+ /**
+ * Security check
+ */
+ if (preg_match('/[^a-z0-9\\/\\\\_.:-]/i', $filename)) {
+ require_once 'Zend/Exception.php';
+ throw new Zend_Exception('Security check: Illegal character in filename');
+ }
+ }
+
+ /**
+ * Attempt to include() the file.
+ *
+ * include() is not prefixed with the @ operator because if
+ * the file is loaded and contains a parse error, execution
+ * will halt silently and this is difficult to debug.
+ *
+ * Always set display_errors = Off on production servers!
+ *
+ * @param string $filespec
+ * @param boolean $once
+ * @return boolean
+ * @deprecated Since 1.5.0; use loadFile() instead
+ */
+ protected static function _includeFile($filespec, $once = false)
+ {
+ if ($once) {
+ return include_once $filespec;
+ } else {
+ return include $filespec ;
+ }
+ }
+}
View
23 library/vendor/Zend/Loader/.svn/all-wcprops
@@ -0,0 +1,23 @@
+K 25
+svn:wc:ra_dav:version-url
+V 78
+/svn/framework/!svn/ver/23461/standard/tags/release-1.11.1/library/Zend/Loader
+END
+Exception.php
+K 25
+svn:wc:ra_dav:version-url
+V 92
+/svn/framework/!svn/ver/23461/standard/tags/release-1.11.1/library/Zend/Loader/Exception.php
+END
+Autoloader.php
+K 25
+svn:wc:ra_dav:version-url
+V 93
+/svn/framework/!svn/ver/23461/standard/tags/release-1.11.1/library/Zend/Loader/Autoloader.php
+END
+PluginLoader.php
+K 25
+svn:wc:ra_dav:version-url
+V 95
+/svn/framework/!svn/ver/23461/standard/tags/release-1.11.1/library/Zend/Loader/PluginLoader.php
+END
View
136 library/vendor/Zend/Loader/.svn/entries
@@ -0,0 +1,136 @@
+10
+
+dir
+23572
+http://framework.zend.com/svn/framework/standard/tags/release-1.11.1/library/Zend/Loader
+http://framework.zend.com/svn/framework
+
+
+
+2010-10-19T16:08:36.011979Z
+23161
+matthew
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+44c647ce-9c0f-0410-b52a-842ac1e357ba
+
+Autoloader
+dir
+
+Exception.php
+file
+
+
+
+
+2010-12-03T16:16:50.000000Z
+8d0304f03525e2a455025fce1f9fc275
+2010-01-06T02:05:09.675189Z
+20096
+bkarwin
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1121
+
+Autoloader.php
+file
+
+
+
+
+2010-12-03T16:16:50.000000Z
+cc3fab7dfe4cfc92ccd72db5af5376f5
+2010-10-19T16:08:36.011979Z
+23161
+matthew
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+16617
+
+PluginLoader
+dir
+
+PluginLoader.php
+file
+
+
+
+
+2010-12-03T16:16:50.000000Z
+ea38f3c5f1b86db73dd97dc1d51e1df5
+2010-07-17T00:02:10.590647Z
+22603
+ramon
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+14749
+
View
9 library/vendor/Zend/Loader/.svn/prop-base/Autoloader.php.svn-base
@@ -0,0 +1,9 @@
+K 12
+svn:keywords
+V 18
+Id Author Date Rev
+K 13
+svn:mergeinfo
+V 0
+
+END
View
5 library/vendor/Zend/Loader/.svn/prop-base/Exception.php.svn-base
@@ -0,0 +1,5 @@
+K 12
+svn:keywords
+V 2
+Id
+END
View
5 library/vendor/Zend/Loader/.svn/prop-base/PluginLoader.php.svn-base
@@ -0,0 +1,5 @@
+K 12
+svn:keywords
+V 2
+Id
+END
View
582 library/vendor/Zend/Loader/.svn/text-base/Autoloader.php.svn-base
@@ -0,0 +1,582 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Loader
+ * @subpackage Autoloader
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @version $Id$
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+
+/** Zend_Loader */
+require_once 'Zend/Loader.php';
+
+/**
+ * Autoloader stack and namespace autoloader
+ *
+ * @uses Zend_Loader_Autoloader
+ * @package Zend_Loader
+ * @subpackage Autoloader
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class Zend_Loader_Autoloader
+{
+ /**
+ * @var Zend_Loader_Autoloader Singleton instance
+ */
+ protected static $_instance;
+
+ /**
+ * @var array Concrete autoloader callback implementations
+ */
+ protected $_autoloaders = array();
+
+ /**
+ * @var array Default autoloader callback
+ */
+ protected $_defaultAutoloader = array('Zend_Loader', 'loadClass');
+
+ /**
+ * @var bool Whether or not to act as a fallback autoloader
+ */
+ protected $_fallbackAutoloader = false;
+
+ /**
+ * @var array Callback for internal autoloader implementation
+ */
+ protected $_internalAutoloader;
+
+ /**
+ * @var array Supported namespaces 'Zend' and 'ZendX' by default.
+ */
+ protected $_namespaces = array(
+ 'Zend_' => true,
+ 'ZendX_' => true,
+ );
+
+ /**
+ * @var array Namespace-specific autoloaders
+ */
+ protected $_namespaceAutoloaders = array();
+
+ /**
+ * @var bool Whether or not to suppress file not found warnings
+ */
+ protected $_suppressNotFoundWarnings = false;
+
+ /**
+ * @var null|string
+ */
+ protected $_zfPath;
+
+ /**
+ * Retrieve singleton instance
+ *
+ * @return Zend_Loader_Autoloader
+ */
+ public static function getInstance()
+ {
+ if (null === self::$_instance) {
+ self::$_instance = new self();
+ }
+ return self::$_instance;
+ }
+
+ /**
+ * Reset the singleton instance
+ *
+ * @return void
+ */
+ public static function resetInstance()
+ {
+ self::$_instance = null;
+ }
+
+ /**
+ * Autoload a class
+ *
+ * @param string $class
+ * @return bool
+ */
+ public static function autoload($class)
+ {
+ $self = self::getInstance();
+
+ foreach ($self->getClassAutoloaders($class) as $autoloader) {
+ if ($autoloader instanceof Zend_Loader_Autoloader_Interface) {
+ if ($autoloader->autoload($class)) {
+ return true;
+ }
+ } elseif (is_array($autoloader)) {
+ if (call_user_func($autoloader, $class)) {
+ return true;
+ }
+ } elseif (is_string($autoloader) || is_callable($autoloader)) {
+ if ($autoloader($class)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Set the default autoloader implementation
+ *
+ * @param string|array $callback PHP callback
+ * @return void
+ */
+ public function setDefaultAutoloader($callback)
+ {
+ if (!is_callable($callback)) {
+ throw new Zend_Loader_Exception('Invalid callback specified for default autoloader');
+ }
+
+ $this->_defaultAutoloader = $callback;
+ return $this;
+ }
+
+ /**
+ * Retrieve the default autoloader callback
+ *
+ * @return string|array PHP Callback
+ */
+ public function getDefaultAutoloader()
+ {
+ return $this->_defaultAutoloader;
+ }
+
+ /**
+ * Set several autoloader callbacks at once
+ *
+ * @param array $autoloaders Array of PHP callbacks (or Zend_Loader_Autoloader_Interface implementations) to act as autoloaders
+ * @return Zend_Loader_Autoloader
+ */
+ public function setAutoloaders(array $autoloaders)
+ {
+ $this->_autoloaders = $autoloaders;
+ return $this;
+ }
+
+ /**
+ * Get attached autoloader implementations
+ *
+ * @return array
+ */
+ public function getAutoloaders()
+ {
+ return $this->_autoloaders;
+ }
+
+ /**
+ * Return all autoloaders for a given namespace
+ *
+ * @param string $namespace
+ * @return array
+ */
+ public function getNamespaceAutoloaders($namespace)
+ {
+ $namespace = (string) $namespace;
+ if (!array_key_exists($namespace, $this->_namespaceAutoloaders)) {
+ return array();
+ }
+ return $this->_namespaceAutoloaders[$namespace];
+ }
+
+ /**
+ * Register a namespace to autoload
+ *
+ * @param string|array $namespace
+ * @return Zend_Loader_Autoloader
+ */
+ public function registerNamespace($namespace)
+ {
+ if (is_string($namespace)) {
+ $namespace = (array) $namespace;
+ } elseif (!is_array($namespace)) {
+ throw new Zend_Loader_Exception('Invalid namespace provided');
+ }
+
+ foreach ($namespace as $ns) {
+ if (!isset($this->_namespaces[$ns])) {
+ $this->_namespaces[$ns] = true;
+ }
+ }
+ return $this;
+ }
+
+ /**
+ * Unload a registered autoload namespace
+ *
+ * @param string|array $namespace
+ * @return Zend_Loader_Autoloader
+ */
+ public function unregisterNamespace($namespace)
+ {
+ if (is_string($namespace)) {
+ $namespace = (array) $namespace;
+ } elseif (!is_array($namespace)) {
+ throw new Zend_Loader_Exception('Invalid namespace provided');
+ }
+
+ foreach ($namespace as $ns) {
+ if (isset($this->_namespaces[$ns])) {
+ unset($this->_namespaces[$ns]);
+ }
+ }
+ return $this;
+ }
+
+ /**
+ * Get a list of registered autoload namespaces
+ *
+ * @return array
+ */
+ public function getRegisteredNamespaces()
+ {
+ return array_keys($this->_namespaces);
+ }
+
+ public function setZfPath($spec, $version = 'latest')
+ {
+ $path = $spec;
+ if (is_array($spec)) {
+ if (!isset($spec['path'])) {
+ throw new Zend_Loader_Exception('No path specified for ZF');
+ }
+ $path = $spec['path'];
+ if (isset($spec['version'])) {
+ $version = $spec['version'];
+ }
+ }
+
+ $this->_zfPath = $this->_getVersionPath($path, $version);
+ set_include_path(implode(PATH_SEPARATOR, array(
+ $this->_zfPath,
+ get_include_path(),
+ )));
+ return $this;
+ }
+
+ public function getZfPath()
+ {
+ return $this->_zfPath;
+ }
+
+ /**
+ * Get or set the value of the "suppress not found warnings" flag
+ *
+ * @param null|bool $flag
+ * @return bool|Zend_Loader_Autoloader Returns boolean if no argument is passed, object instance otherwise
+ */
+ public function suppressNotFoundWarnings($flag = null)
+ {
+ if (null === $flag) {
+ return $this->_suppressNotFoundWarnings;
+ }
+ $this->_suppressNotFoundWarnings = (bool) $flag;
+ return $this;
+ }
+
+ /**
+ * Indicate whether or not this autoloader should be a fallback autoloader
+ *
+ * @param bool $flag
+ * @return Zend_Loader_Autoloader
+ */
+ public function setFallbackAutoloader($flag)
+ {
+ $this->_fallbackAutoloader = (bool) $flag;
+ return $this;
+ }
+
+ /**
+ * Is this instance acting as a fallback autoloader?
+ *
+ * @return bool
+ */
+ public function isFallbackAutoloader()
+ {
+ return $this->_fallbackAutoloader;
+ }
+
+ /**
+ * Get autoloaders to use when matching class
+ *
+ * Determines if the class matches a registered namespace, and, if so,
+ * returns only the autoloaders for that namespace. Otherwise, it returns
+ * all non-namespaced autoloaders.
+ *
+ * @param string $class
+ * @return array Array of autoloaders to use
+ */
+ public function getClassAutoloaders($class)
+ {
+ $namespace = false;
+ $autoloaders = array();
+
+ // Add concrete namespaced autoloaders
+ foreach (array_keys($this->_namespaceAutoloaders) as $ns) {
+ if ('' == $ns) {
+ continue;
+ }
+ if (0 === strpos($class, $ns)) {
+ $namespace = $ns;
+ $autoloaders = $autoloaders + $this->getNamespaceAutoloaders($ns);
+ break;
+ }
+ }
+
+ // Add internal namespaced autoloader
+ foreach ($this->getRegisteredNamespaces() as $ns) {
+ if (0 === strpos($class, $ns)) {
+ $namespace = $ns;
+ $autoloaders[] = $this->_internalAutoloader;
+ break;
+ }
+ }
+
+ // Add non-namespaced autoloaders
+ $autoloaders = $autoloaders + $this->getNamespaceAutoloaders('');
+
+ // Add fallback autoloader
+ if (!$namespace && $this->isFallbackAutoloader()) {
+ $autoloaders[] = $this->_internalAutoloader;
+ }
+
+ return $autoloaders;
+ }
+
+ /**
+ * Add an autoloader to the beginning of the stack
+ *
+ * @param object|array|string $callback PHP callback or Zend_Loader_Autoloader_Interface implementation
+ * @param string|array $namespace Specific namespace(s) under which to register callback
+ * @return Zend_Loader_Autoloader
+ */
+ public function unshiftAutoloader($callback, $namespace = '')
+ {
+ $autoloaders = $this->getAutoloaders();
+ array_unshift($autoloaders, $callback);
+ $this->setAutoloaders($autoloaders);
+
+ $namespace = (array) $namespace;
+ foreach ($namespace as $ns) {
+ $autoloaders = $this->getNamespaceAutoloaders($ns);
+ array_unshift($autoloaders, $callback);
+ $this->_setNamespaceAutoloaders($autoloaders, $ns);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Append an autoloader to the autoloader stack
+ *
+ * @param object|array|string $callback PHP callback or Zend_Loader_Autoloader_Interface implementation
+ * @param string|array $namespace Specific namespace(s) under which to register callback
+ * @return Zend_Loader_Autoloader
+ */
+ public function pushAutoloader($callback, $namespace = '')
+ {
+ $autoloaders = $this->getAutoloaders();
+ array_push($autoloaders, $callback);
+ $this->setAutoloaders($autoloaders);
+
+ $namespace = (array) $namespace;
+ foreach ($namespace as $ns) {
+ $autoloaders = $this->getNamespaceAutoloaders($ns);
+ array_push($autoloaders, $callback);
+ $this->_setNamespaceAutoloaders($autoloaders, $ns);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Remove an autoloader from the autoloader stack
+ *
+ * @param object|array|string $callback PHP callback or Zend_Loader_Autoloader_Interface implementation
+ * @param null|string|array $namespace Specific namespace(s) from which to remove autoloader
+ * @return Zend_Loader_Autoloader
+ */
+ public function removeAutoloader($callback, $namespace = null)
+ {
+ if (null === $namespace) {
+ $autoloaders = $this->getAutoloaders();
+ if (false !== ($index = array_search($callback, $autoloaders, true))) {
+ unset($autoloaders[$index]);
+ $this->setAutoloaders($autoloaders);
+ }
+
+ foreach ($this->_namespaceAutoloaders as $ns => $autoloaders) {
+ if (false !== ($index = array_search($callback, $autoloaders, true))) {
+ unset($autoloaders[$index]);
+ $this->_setNamespaceAutoloaders($autoloaders, $ns);
+ }
+ }
+ } else {
+ $namespace = (array) $namespace;
+ foreach ($namespace as $ns) {
+ $autoloaders = $this->getNamespaceAutoloaders($ns);
+ if (false !== ($index = array_search($callback, $autoloaders, true))) {
+ unset($autoloaders[$index]);
+ $this->_setNamespaceAutoloaders($autoloaders, $ns);
+ }
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Constructor
+ *
+ * Registers instance with spl_autoload stack
+ *
+ * @return void
+ */
+ protected function __construct()
+ {
+ spl_autoload_register(array(__CLASS__, 'autoload'));
+ $this->_internalAutoloader = array($this, '_autoload');
+ }
+
+ /**
+ * Internal autoloader implementation
+ *
+ * @param string $class
+ * @return bool
+ */
+ protected function _autoload($class)
+ {
+ $callback = $this->getDefaultAutoloader();
+ try {
+ if ($this->suppressNotFoundWarnings()) {
+ @call_user_func($callback, $class);
+ } else {
+ call_user_func($callback, $class);
+ }
+ return $class;
+ } catch (Zend_Exception $e) {
+ return false;
+ }
+ }
+
+ /**
+ * Set autoloaders for a specific namespace
+ *
+ * @param array $autoloaders
+ * @param string $namespace
+ * @return Zend_Loader_Autoloader
+ */
+ protected function _setNamespaceAutoloaders(array $autoloaders, $namespace = '')
+ {
+ $namespace = (string) $namespace;
+ $this->_namespaceAutoloaders[$namespace] = $autoloaders;
+ return $this;
+ }
+
+ /**
+ * Retrieve the filesystem path for the requested ZF version
+ *
+ * @param string $path
+ * @param string $version
+ * @return void
+ */
+ protected function _getVersionPath($path, $version)
+ {
+ $type = $this->_getVersionType($version);
+
+ if ($type == 'latest') {
+ $version = 'latest';
+ }
+
+ $availableVersions = $this->_getAvailableVersions($path, $version);
+ if (empty($availableVersions)) {
+ throw new Zend_Loader_Exception('No valid ZF installations discovered');
+ }
+
+ $matchedVersion = array_pop($availableVersions);
+ return $matchedVersion;
+ }
+
+ /**
+ * Retrieve the ZF version type
+ *
+ * @param string $version
+ * @return string "latest", "major", "minor", or "specific"
+ * @throws Zend_Loader_Exception if version string contains too many dots
+ */
+ protected function _getVersionType($version)
+ {
+ if (strtolower($version) == 'latest') {
+ return 'latest';
+ }
+
+ $parts = explode('.', $version);
+ $count = count($parts);
+ if (1 == $count) {
+ return 'major';
+ }
+ if (2 == $count) {
+ return 'minor';
+ }
+ if (3 < $count) {
+ throw new Zend_Loader_Exception('Invalid version string provided');
+ }
+ return 'specific';
+ }
+
+ /**
+ * Get available versions for the version type requested
+ *
+ * @param string $path
+ * @param string $version
+ * @return array
+ */
+ protected function _getAvailableVersions($path, $version)
+ {
+ if (!is_dir($path)) {
+ throw new Zend_Loader_Exception('Invalid ZF path provided');
+ }
+
+ $path = rtrim($path, '/');
+ $path = rtrim($path, '\\');
+ $versionLen = strlen($version);
+ $versions = array();
+ $dirs = glob("$path/*", GLOB_ONLYDIR);
+ foreach ((array) $dirs as $dir) {
+ $dirName = substr($dir, strlen($path) + 1);
+ if (!preg_match('/^(?:ZendFramework-)?(\d+\.\d+\.\d+((a|b|pl|pr|p|rc)\d+)?)(?:-minimal)?$/i', $dirName, $matches)) {
+ continue;
+ }
+
+ $matchedVersion = $matches[1];
+
+ if (('latest' == $version)
+ || ((strlen($matchedVersion) >= $versionLen)
+ && (0 === strpos($matchedVersion, $version)))
+ ) {
+ $versions[$matchedVersion] = $dir . '/library';
+ }
+ }
+
+ uksort($versions, 'version_compare');
+ return $versions;
+ }
+}
View
35 library/vendor/Zend/Loader/.svn/text-base/Exception.php.svn-base
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Loader
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id$
+ */
+
+/**
+ * @see Zend_Exception
+ */
+require_once 'Zend/Exception.php';
+
+/**
+ * @category Zend
+ * @package Zend_Loader
+ * @uses Zend_Exception
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class Zend_Loader_Exception extends Zend_Exception
+{}
View
484 library/vendor/Zend/Loader/.svn/text-base/PluginLoader.php.svn-base
@@ -0,0 +1,484 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Loader
+ * @subpackage PluginLoader
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id$
+ */
+
+/** Zend_Loader_PluginLoader_Interface */
+require_once 'Zend/Loader/PluginLoader/Interface.php';
+
+/** Zend_Loader */
+require_once 'Zend/Loader.php';
+
+/**
+ * Generic plugin class loader
+ *
+ * @category Zend
+ * @package Zend_Loader
+ * @subpackage PluginLoader
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class Zend_Loader_PluginLoader implements Zend_Loader_PluginLoader_Interface
+{
+ /**
+ * Class map cache file
+ * @var string
+ */
+ protected static $_includeFileCache;
+
+ /**
+ * Instance loaded plugin paths
+ *
+ * @var array
+ */
+ protected $_loadedPluginPaths = array();
+
+ /**
+ * Instance loaded plugins
+ *
+ * @var array
+ */
+ protected $_loadedPlugins = array();
+
+ /**
+ * Instance registry property
+ *
+ * @var array
+ */
+ protected $_prefixToPaths = array();
+
+ /**
+ * Statically loaded plugin path mappings
+ *
+ * @var array
+ */
+ protected static $_staticLoadedPluginPaths = array();
+
+ /**
+ * Statically loaded plugins
+ *
+ * @var array
+ */
+ protected static $_staticLoadedPlugins = array();
+
+ /**
+ * Static registry property
+ *
+ * @var array
+ */
+ protected static $_staticPrefixToPaths = array();
+
+ /**
+ * Whether to use a statically named registry for loading plugins
+ *
+ * @var string|null
+ */
+ protected $_useStaticRegistry = null;
+
+ /**
+ * Constructor
+ *
+ * @param array $prefixToPaths
+ * @param string $staticRegistryName OPTIONAL
+ */
+ public function __construct(Array $prefixToPaths = array(), $staticRegistryName = null)
+ {
+ if (is_string($staticRegistryName) && !empty($staticRegistryName)) {
+ $this->_useStaticRegistry = $staticRegistryName;
+ if(!isset(self::$_staticPrefixToPaths[$staticRegistryName])) {
+ self::$_staticPrefixToPaths[$staticRegistryName] = array();
+ }
+ if(!isset(self::$_staticLoadedPlugins[$staticRegistryName])) {
+ self::$_staticLoadedPlugins[$staticRegistryName] = array();
+ }
+ }
+
+ foreach ($prefixToPaths as $prefix => $path) {
+ $this->addPrefixPath($prefix, $path);
+ }
+ }
+
+ /**
+ * Format prefix for internal use
+ *
+ * @param string $prefix
+ * @return string
+ */
+ protected function _formatPrefix($prefix)
+ {
+ if($prefix == "") {
+ return $prefix;
+ }
+
+ $last = strlen($prefix) - 1;
+ if ($prefix{$last} == '\\') {
+ return $prefix;
+ }
+
+ return rtrim($prefix, '_') . '_';
+ }
+
+ /**
+ * Add prefixed paths to the registry of paths
+ *
+ * @param string $prefix
+ * @param string $path
+ * @return Zend_Loader_PluginLoader
+ */
+ public function addPrefixPath($prefix, $path)
+ {
+ if (!is_string($prefix) || !is_string($path)) {
+ require_once 'Zend/Loader/PluginLoader/Exception.php';
+ throw new Zend_Loader_PluginLoader_Exception('Zend_Loader_PluginLoader::addPrefixPath() method only takes strings for prefix and path.');
+ }
+
+ $prefix = $this->_formatPrefix($prefix);
+ $path = rtrim($path, '/\\') . '/';
+
+ if ($this->_useStaticRegistry) {
+ self::$_staticPrefixToPaths[$this->_useStaticRegistry][$prefix][] = $path;
+ } else {
+ if (!isset($this->_prefixToPaths[$prefix])) {
+ $this->_prefixToPaths[$prefix] = array();
+ }
+ if (!in_array($path, $this->_prefixToPaths[$prefix])) {
+ $this->_prefixToPaths[$prefix][] = $path;
+ }
+ }
+ return $this;
+ }
+
+ /**
+ * Get path stack
+ *
+ * @param string $prefix
+ * @return false|array False if prefix does not exist, array otherwise
+ */
+ public function getPaths($prefix = null)
+ {
+ if ((null !== $prefix) && is_string($prefix)) {
+ $prefix = $this->_formatPrefix($prefix);
+ if ($this->_useStaticRegistry) {
+ if (isset(self::$_staticPrefixToPaths[$this->_useStaticRegistry][$prefix])) {
+ return self::$_staticPrefixToPaths[$this->_useStaticRegistry][$prefix];
+ }
+
+ return false;
+ }
+
+ if (isset($this->_prefixToPaths[$prefix])) {
+ return $this->_prefixToPaths[$prefix];
+ }
+
+ return false;
+ }
+
+ if ($this->_useStaticRegistry) {
+ return self::$_staticPrefixToPaths[$this->_useStaticRegistry];
+ }
+
+ return $this->_prefixToPaths;
+ }
+
+ /**
+ * Clear path stack
+ *
+ * @param string $prefix
+ * @return bool False only if $prefix does not exist
+ */
+ public function clearPaths($prefix = null)
+ {
+ if ((null !== $prefix) && is_string($prefix)) {
+ $prefix = $this->_formatPrefix($prefix);
+ if ($this->_useStaticRegistry) {
+ if (isset(self::$_staticPrefixToPaths[$this->_useStaticRegistry][$prefix])) {
+ unset(self::$_staticPrefixToPaths[$this->_useStaticRegistry][$prefix]);
+ return true;
+ }
+
+ return false;
+ }
+
+ if (isset($this->_prefixToPaths[$prefix])) {
+ unset($this->_prefixToPaths[$prefix]);
+ return true;
+ }
+
+ return false;
+ }
+
+ if ($this->_useStaticRegistry) {
+ self::$_staticPrefixToPaths[$this->_useStaticRegistry] = array();
+ } else {
+ $this->_prefixToPaths = array();
+ }
+
+ return true;
+ }
+
+ /**
+ * Remove a prefix (or prefixed-path) from the registry
+ *
+ * @param string $prefix
+ * @param string $path OPTIONAL
+ * @return Zend_Loader_PluginLoader
+ */
+ public function removePrefixPath($prefix, $path = null)
+ {
+ $prefix = $this->_formatPrefix($prefix);
+ if ($this->_useStaticRegistry) {
+ $registry =& self::$_staticPrefixToPaths[$this->_useStaticRegistry];
+ } else {
+ $registry =& $this->_prefixToPaths;
+ }
+
+ if (!isset($registry[$prefix])) {
+ require_once 'Zend/Loader/PluginLoader/Exception.php';
+ throw new Zend_Loader_PluginLoader_Exception('Prefix ' . $prefix . ' was not found in the PluginLoader.');
+ }
+
+ if ($path != null) {
+ $pos = array_search($path, $registry[$prefix]);
+ if (false === $pos) {
+ require_once 'Zend/Loader/PluginLoader/Exception.php';
+ throw new Zend_Loader_PluginLoader_Exception('Prefix ' . $prefix . ' / Path ' . $path . ' was not found in the PluginLoader.');
+ }
+ unset($registry[$prefix][$pos]);
+ } else {
+ unset($registry[$prefix]);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Normalize plugin name
+ *
+ * @param string $name
+ * @return string
+ */
+ protected function _formatName($name)
+ {
+ return ucfirst((string) $name);
+ }
+
+ /**
+ * Whether or not a Plugin by a specific name is loaded
+ *
+ * @param string $name
+ * @return Zend_Loader_PluginLoader
+ */
+ public function isLoaded($name)
+ {
+ $name = $this->_formatName($name);
+ if ($this->_useStaticRegistry) {
+ return isset(self::$_staticLoadedPlugins[$this->_useStaticRegistry][$name]);
+ }
+
+ return isset($this->_loadedPlugins[$name]);
+ }
+
+ /**
+ * Return full class name for a named plugin
+ *
+ * @param string $name
+ * @return string|false False if class not found, class name otherwise
+ */
+ public function getClassName($name)
+ {
+ $name = $this->_formatName($name);
+ if ($this->_useStaticRegistry
+ && isset(self::$_staticLoadedPlugins[$this->_useStaticRegistry][$name])
+ ) {
+ return self::$_staticLoadedPlugins[$this->_useStaticRegistry][$name];
+ } elseif (isset($this->_loadedPlugins[$name])) {
+ return $this->_loadedPlugins[$name];
+ }
+
+ return false;
+ }
+
+ /**
+ * Get path to plugin class
+ *
+ * @param mixed $name
+ * @return string|false False if not found
+ */
+ public function getClassPath($name)
+ {
+ $name = $this->_formatName($name);
+ if ($this->_useStaticRegistry
+ && !empty(self::$_staticLoadedPluginPaths[$this->_useStaticRegistry][$name])
+ ) {
+ return self::$_staticLoadedPluginPaths[$this->_useStaticRegistry][$name];
+ } elseif (!empty($this->_loadedPluginPaths[$name])) {
+ return $this->_loadedPluginPaths[$name];
+ }
+
+ if ($this->isLoaded($name)) {
+ $class = $this->getClassName($name);
+ $r = new ReflectionClass($class);
+ $path = $r->getFileName();
+ if ($this->_useStaticRegistry) {
+ self::$_staticLoadedPluginPaths[$this->_useStaticRegistry][$name] = $path;
+ } else {
+ $this->_loadedPluginPaths[$name] = $path;
+ }
+ return $path;
+ }
+
+ return false;
+ }
+
+ /**
+ * Load a plugin via the name provided
+ *
+ * @param string $name
+ * @param bool $throwExceptions Whether or not to throw exceptions if the
+ * class is not resolved
+ * @return string|false Class name of loaded class; false if $throwExceptions
+ * if false and no class found
+ * @throws Zend_Loader_Exception if class not found
+ */
+ public function load($name, $throwExceptions = true)
+ {
+ $name = $this->_formatName($name);
+ if ($this->isLoaded($name)) {
+ return $this->getClassName($name);
+ }
+
+ if ($this->_useStaticRegistry) {
+ $registry = self::$_staticPrefixToPaths[$this->_useStaticRegistry];
+ } else {
+ $registry = $this->_prefixToPaths;
+ }
+
+ $registry = array_reverse($registry, true);
+ $found = false;
+ $classFile = str_replace('_', DIRECTORY_SEPARATOR, $name) . '.php';
+ $incFile = self::getIncludeFileCache();
+ foreach ($registry as $prefix => $paths) {
+ $className = $prefix . $name;
+
+ if (class_exists($className, false)) {
+ $found = true;
+ break;
+ }
+
+ $paths = array_reverse($paths, true);
+
+ foreach ($paths as $path) {
+ $loadFile = $path . $classFile;
+ if (Zend_Loader::isReadable($loadFile)) {
+ include_once $loadFile;
+ if (class_exists($className, false)) {
+ if (null !== $incFile) {
+ self::_appendIncFile($loadFile);
+ }
+ $found = true;
+ break 2;
+ }
+ }
+ }
+ }
+
+ if (!$found) {
+ if (!$throwExceptions) {
+ return false;
+ }
+
+ $message = "Plugin by name '$name' was not found in the registry; used paths:";
+ foreach ($registry as $prefix => $paths) {
+ $message .= "\n$prefix: " . implode(PATH_SEPARATOR, $paths);
+ }
+ require_once 'Zend/Loader/PluginLoader/Exception.php';
+ throw new Zend_Loader_PluginLoader_Exception($message);
+ }
+
+ if ($this->_useStaticRegistry) {
+ self::$_staticLoadedPlugins[$this->_useStaticRegistry][$name] = $className;
+ } else {
+ $this->_loadedPlugins[$name] = $className;
+ }
+ return $className;
+ }
+
+ /**
+ * Set path to class file cache
+ *
+ * Specify a path to a file that will add include_once statements for each
+ * plugin class loaded. This is an opt-in feature for performance purposes.
+ *
+ * @param string $file
+ * @return void
+ * @throws Zend_Loader_PluginLoader_Exception if file is not writeable or path does not exist
+ */
+ public static function setIncludeFileCache($file)
+ {
+ if (null === $file) {
+ self::$_includeFileCache = null;
+ return;
+ }
+
+ if (!file_exists($file) && !file_exists(dirname($file))) {
+ require_once 'Zend/Loader/PluginLoader/Exception.php';
+ throw new Zend_Loader_PluginLoader_Exception('Specified file does not exist and/or directory does not exist (' . $file . ')');
+ }
+ if (file_exists($file) && !is_writable($file)) {
+ require_once 'Zend/Loader/PluginLoader/Exception.php';
+ throw new Zend_Loader_PluginLoader_Exception('Specified file is not writeable (' . $file . ')');
+ }
+ if (!file_exists($file) && file_exists(dirname($file)) && !is_writable(dirname($file))) {
+ require_once 'Zend/Loader/PluginLoader/Exception.php';
+ throw new Zend_Loader_PluginLoader_Exception('Specified file is not writeable (' . $file . ')');
+ }
+
+ self::$_includeFileCache = $file;
+ }
+
+ /**
+ * Retrieve class file cache path
+ *
+ * @return string|null
+ */
+ public static function getIncludeFileCache()
+ {
+ return self::$_includeFileCache;
+ }
+
+ /**
+ * Append an include_once statement to the class file cache
+ *
+ * @param string $incFile
+ * @return void
+ */
+ protected static function _appendIncFile($incFile)
+ {
+ if (!file_exists(self::$_includeFileCache)) {
+ $file = '<?php';
+ } else {
+ $file = file_get_contents(self::$_includeFileCache);
+ }
+ if (!strstr($file, $incFile)) {
+ $file .= "\ninclude_once '$incFile';";
+ file_put_contents(self::$_includeFileCache, $file);
+ }
+ }
+}
View
582 library/vendor/Zend/Loader/Autoloader.php
@@ -0,0 +1,582 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Loader
+ * @subpackage Autoloader
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @version $Id: Autoloader.php 23161 2010-10-19 16:08:36Z matthew $
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+
+/** Zend_Loader */
+require_once 'Zend/Loader.php';
+
+/**
+ * Autoloader stack and namespace autoloader
+ *
+ * @uses Zend_Loader_Autoloader
+ * @package Zend_Loader
+ * @subpackage Autoloader
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class Zend_Loader_Autoloader
+{
+ /**
+ * @var Zend_Loader_Autoloader Singleton instance
+ */
+ protected static $_instance;
+
+ /**
+ * @var array Concrete autoloader callback implementations
+ */
+ protected $_autoloaders = array();
+
+ /**
+ * @var array Default autoloader callback
+ */
+ protected $_defaultAutoloader = array('Zend_Loader', 'loadClass');
+
+ /**
+ * @var bool Whether or not to act as a fallback autoloader
+ */
+ protected $_fallbackAutoloader = false;
+
+ /**
+ * @var array Callback for internal autoloader implementation
+ */
+ protected $_internalAutoloader;
+
+ /**
+ * @var array Supported namespaces 'Zend' and 'ZendX' by default.
+ */
+ protected $_namespaces = array(
+ 'Zend_' => true,
+ 'ZendX_' => true,
+ );
+
+ /**
+ * @var array Namespace-specific autoloaders
+ */
+ protected $_namespaceAutoloaders = array();
+
+ /**
+ * @var bool Whether or not to suppress file not found warnings
+ */
+ protected $_suppressNotFoundWarnings = false;
+
+ /**
+ * @var null|string
+ */
+ protected $_zfPath;
+
+ /**
+ * Retrieve singleton instance
+ *
+ * @return Zend_Loader_Autoloader
+ */
+ public static function getInstance()
+ {
+ if (null === self::$_instance) {
+ self::$_instance = new self();
+ }
+ return self::$_instance;
+ }
+
+ /**
+ * Reset the singleton instance
+ *
+ * @return void
+ */
+ public static function resetInstance()
+ {
+ self::$_instance = null;
+ }
+
+ /**
+ * Autoload a class
+ *
+ * @param string $class
+ * @return bool
+ */
+ public static function autoload($class)
+ {
+ $self = self::getInstance();
+
+ foreach ($self->getClassAutoloaders($class) as $autoloader) {
+ if ($autoloader instanceof Zend_Loader_Autoloader_Interface) {
+ if ($autoloader->autoload($class)) {
+ return true;
+ }
+ } elseif (is_array($autoloader)) {
+ if (call_user_func($autoloader, $class)) {
+ return true;
+ }
+ } elseif (is_string($autoloader) || is_callable($autoloader)) {
+ if ($autoloader($class)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Set the default autoloader implementation
+ *
+ * @param string|array $callback PHP callback
+ * @return void
+ */
+ public function setDefaultAutoloader($callback)
+ {
+ if (!is_callable($callback)) {
+ throw new Zend_Loader_Exception('Invalid callback specified for default autoloader');
+ }
+
+ $this->_defaultAutoloader = $callback;
+ return $this;
+ }
+
+ /**
+ * Retrieve the default autoloader callback
+ *
+ * @return string|array PHP Callback
+ */
+ public function getDefaultAutoloader()
+ {
+ return $this->_defaultAutoloader;
+ }
+
+ /**
+ * Set several autoloader callbacks at once
+ *
+ * @param array $autoloaders Array of PHP callbacks (or Zend_Loader_Autoloader_Interface implementations) to act as autoloaders
+ * @return Zend_Loader_Autoloader
+ */
+ public function setAutoloaders(array $autoloaders)
+ {
+ $this->_autoloaders = $autoloaders;
+ return $this;
+ }
+
+ /**
+ * Get attached autoloader implementations
+ *
+ * @return array
+ */
+ public function getAutoloaders()
+ {
+ return $this->_autoloaders;
+ }
+
+ /**
+ * Return all autoloaders for a given namespace
+ *
+ * @param string $namespace
+ * @return array
+ */
+ public function getNamespaceAutoloaders($namespace)
+ {
+ $namespace = (string) $namespace;
+ if (!array_key_exists($namespace, $this->_namespaceAutoloaders)) {
+ return array();
+ }
+ return $this->_namespaceAutoloaders[$namespace];
+ }
+
+ /**
+ * Register a namespace to autoload
+ *
+ * @param string|array $namespace
+ * @return Zend_Loader_Autoloader
+ */
+ public function registerNamespace($namespace)
+ {
+ if (is_string($namespace)) {
+ $namespace = (array) $namespace;
+ } elseif (!is_array($namespace)) {
+ throw new Zend_Loader_Exception('Invalid namespace provided');
+ }
+
+ foreach ($namespace as $ns) {
+ if (!isset($this->_namespaces[$ns])) {
+ $this->_namespaces[$ns] = true;
+ }
+ }
+ return $this;
+ }
+
+ /**
+ * Unload a registered autoload namespace
+ *
+ * @param string|array $namespace
+ * @return Zend_Loader_Autoloader
+ */
+ public function unregisterNamespace($namespace)
+ {
+ if (is_string($namespace)) {
+ $namespace = (array) $namespace;
+ } elseif (!is_array($namespace)) {
+ throw new Zend_Loader_Exception('Invalid namespace provided');
+ }
+
+ foreach ($namespace as $ns) {
+ if (isset($this->_namespaces[$ns])) {
+ unset($this->_namespaces[$ns]);
+ }
+ }
+ return $this;
+ }
+
+ /**
+ * Get a list of registered autoload namespaces
+ *
+ * @return array
+ */
+ public function getRegisteredNamespaces()
+ {
+ return array_keys($this->_namespaces);
+ }
+
+ public function setZfPath($spec, $version = 'latest')
+ {
+ $path = $spec;
+ if (is_array($spec)) {
+ if (!isset($spec['path'])) {
+ throw new Zend_Loader_Exception('No path specified for ZF');
+ }
+ $path = $spec['path'];
+ if (isset($spec['version'])) {
+ $version = $spec['version'];
+ }
+ }
+
+ $this->_zfPath = $this->_getVersionPath($path, $version);
+ set_include_path(implode(PATH_SEPARATOR, array(
+ $this->_zfPath,
+ get_include_path(),
+ )));
+ return $this;
+ }
+
+ public function getZfPath()
+ {
+ return $this->_zfPath;
+ }
+
+ /**
+ * Get or set the value of the "suppress not found warnings" flag
+ *
+ * @param null|bool $flag
+ * @return bool|Zend_Loader_Autoloader Returns boolean if no argument is passed, object instance otherwise
+ */
+ public function suppressNotFoundWarnings($flag = null)
+ {
+ if (null === $flag) {
+ return $this->_suppressNotFoundWarnings;
+ }
+ $this->_suppressNotFoundWarnings = (bool) $flag;
+ return $this;
+ }
+
+ /**
+ * Indicate whether or not this autoloader should be a fallback autoloader
+ *
+ * @param bool $flag
+ * @return Zend_Loader_Autoloader
+ */
+ public function setFallbackAutoloader($flag)
+ {
+ $this->_fallbackAutoloader = (bool) $flag;
+ return $this;
+ }
+
+ /**
+ * Is this instance acting as a fallback autoloader?
+ *
+ * @return bool
+ */
+ public function isFallbackAutoloader()
+ {
+ return $this->_fallbackAutoloader;
+ }
+
+ /**
+ * Get autoloaders to use when matching class
+ *
+ * Determines if the class matches a registered namespace, and, if so,
+ * returns only the autoloaders for that namespace. Otherwise, it returns
+ * all non-namespaced autoloaders.
+ *
+ * @param string $class
+ * @return array Array of autoloaders to use
+ */
+ public function getClassAutoloaders($class)
+ {
+ $namespace = false;
+ $autoloaders = array();
+
+ // Add concrete namespaced autoloaders
+ foreach (array_keys($this->_namespaceAutoloaders) as $ns) {
+ if ('' == $ns) {
+ continue;
+ }
+ if (0 === strpos($class, $ns)) {
+ $namespace = $ns;
+ $autoloaders = $autoloaders + $this->getNamespaceAutoloaders($ns);
+ break;
+ }
+ }
+
+ // Add internal namespaced autoloader
+ foreach ($this->getRegisteredNamespaces() as $ns) {
+ if (0 === strpos($class, $ns)) {
+ $namespace = $ns;
+ $autoloaders[] = $this->_internalAutoloader;
+ break;
+ }
+ }
+
+ // Add non-namespaced autoloaders
+ $autoloaders = $autoloaders + $this->getNamespaceAutoloaders('');
+
+ // Add fallback autoloader
+ if (!$namespace && $this->isFallbackAutoloader()) {
+ $autoloaders[] = $this->_internalAutoloader;
+ }
+
+ return $autoloaders;
+ }
+
+ /**
+ * Add an autoloader to the beginning of the stack
+ *
+ * @param object|array|string $callback PHP callback or Zend_Loader_Autoloader_Interface implementation
+ * @param string|array $namespace Specific namespace(s) under which to register callback
+ * @return Zend_Loader_Autoloader
+ */
+ public function unshiftAutoloader($callback, $namespace = '')
+ {
+ $autoloaders = $this->getAutoloaders();
+ array_unshift($autoloaders, $callback);
+ $this->setAutoloaders($autoloaders);
+
+ $namespace = (array) $namespace;
+ foreach ($namespace as $ns) {
+ $autoloaders = $this->getNamespaceAutoloaders($ns);
+ array_unshift($autoloaders, $callback);
+ $this->_setNamespaceAutoloaders($autoloaders, $ns);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Append an autoloader to the autoloader stack
+ *
+ * @param object|array|string $callback PHP callback or Zend_Loader_Autoloader_Interface implementation
+ * @param string|array $namespace Specific namespace(s) under which to register callback
+ * @return Zend_Loader_Autoloader
+ */
+ public function pushAutoloader($callback, $namespace = '')
+ {
+ $autoloaders = $this->getAutoloaders();
+ array_push($autoloaders, $callback);
+ $this->setAutoloaders($autoloaders);
+
+ $namespace = (array) $namespace;
+ foreach ($namespace as $ns) {
+ $autoloaders = $this->getNamespaceAutoloaders($ns);
+ array_push($autoloaders, $callback);
+ $this->_setNamespaceAutoloaders($autoloaders, $ns);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Remove an autoloader from the autoloader stack
+ *
+ * @param object|array|string $callback PHP callback or Zend_Loader_Autoloader_Interface implementation
+ * @param null|string|array $namespace Specific namespace(s) from which to remove autoloader
+ * @return Zend_Loader_Autoloader
+ */
+ public function removeAutoloader($callback, $namespace = null)
+ {
+ if (null === $namespace) {
+ $autoloaders = $this->getAutoloaders();
+ if (false !== ($index = array_search($callback, $autoloaders, true))) {
+ unset($autoloaders[$index]);
+ $this->setAutoloaders($autoloaders);
+ }
+
+ foreach ($this->_namespaceAutoloaders as $ns => $autoloaders) {
+