Permalink
Browse files

added support for instances AND

changed some Zoop stuff to Zinc
  • Loading branch information...
1 parent d6b54ca commit 37b1969f8a8e78d0c52b38c47b8c8facb5d859c7 Rick Gigger committed Jul 28, 2010
View
@@ -0,0 +1,24 @@
+<?php
+class App extends ZoneApplication
+{
+ public function init()
+ {
+ Zoop::loadLib('zone');
+ Zoop::loadLib('db');
+ Zoop::loadLib('session');
+ Zoop::loadLib('zend');
+
+ // register classess in the application that extend Zoop classes
+ Zoop::registerClass('AppZone', dirname(__file__) . '/extend/AppZone.php');
+ Zoop::registerClass('AppGui', dirname(__file__) . '/extend/AppGui.php');
+
+ // register domain classess in the application
+ Zoop::registerClass('RequestApp', dirname(__file__) . '/domain/RequestApp.php');
+ Zoop::registerClass('Person', dirname(__file__) . '/domain/Person.php');
+ Zoop::registerClass('Request', dirname(__file__) . '/domain/Request.php');
+ Zoop::registerClass('Filter', dirname(__file__) . '/domain/Filter.php');
+
+ // register the zones
+ Zoop::registerClass('ZoneFilter', dirname(__file__) . '/zones/ZoneFilter.php');
+ }
+}
View
@@ -1,3 +0,0 @@
-<?php
-define('zoop_dir', dirname(__file__) . '/../../framework');
-define('app_dir', dirname(__file__));
View
@@ -1,19 +0,0 @@
-<?php
-include(zoop_dir . '/Zoop.php');
-Zoop::loadLib('zone');
-Zoop::loadLib('db');
-Zoop::loadLib('session');
-Zoop::loadLib('zend');
-
-// register classess in the application that extend Zoop classes
-Zoop::registerClass('AppZone', dirname(__file__) . '/extend/AppZone.php');
-Zoop::registerClass('AppGui', dirname(__file__) . '/extend/AppGui.php');
-
-// register domain classess in the application
-Zoop::registerClass('RequestApp', dirname(__file__) . '/domain/RequestApp.php');
-Zoop::registerClass('Person', dirname(__file__) . '/domain/Person.php');
-Zoop::registerClass('Request', dirname(__file__) . '/domain/Request.php');
-Zoop::registerClass('Filter', dirname(__file__) . '/domain/Filter.php');
-
-// register the zones
-Zoop::registerClass('ZoneFilter', dirname(__file__) . '/zones/ZoneFilter.php');
View
@@ -1,5 +0,0 @@
-<?php
-include('config.php');
-include('includes.php');
-session::start();
-ZoneApplication::handleRequest();
View
@@ -1,4 +0,0 @@
-#!/usr/bin/env php
-<?php
-//include('config.php');
-include(dirname(dirname(__file__)) . '/framework/core/zap/zap.php');
View
3 bin/zn
@@ -0,0 +1,3 @@
+#!/usr/bin/env php
+<?php
+include(dirname(__dir__) . '/framework/core/zn/zn.php');
View
@@ -0,0 +1,255 @@
+<?php
+// do some bootstrapping
+
+if(!defined("zoop_dir"))
+ define("zoop_dir", dirname(__file__));
+
+function define_once($name, $value)
+{
+ if(!defined($name))
+ define($name, $value);
+}
+// now we load the default config for zoop
+// include(zoop_dir . '/config.php'); // this file is now obsolete and depricated, in favor of the new config module
+include(zoop_dir . '/ZoopLibrary.php');
+include(zoop_dir . '/ZoopModule.php');
+include(zoop_dir . '/ZoopLoader.php');
+
+// we want to load this before we do anything else so that everything else is easier to debug
+// include(zoop_dir . '/core/app/Error.php');
+// include(zoop_dir . '/core/app/Globals.php');
+
+/**
+ * This object is for basic framework management tasks, such as:
+ * * Configuring auto-loading of zones and modules
+ * * Loading libraries and domains
+ */
+class Zoop
+{
+ // static private $loaded = array(), $registered = array();
+ static private $libs = array();
+
+ /**
+ * registers a library
+ */
+
+ static public function registerLib($libName, $path = null)
+ {
+ if(!$path)
+ $path = zoop_dir . '/' . $libName;
+
+ if(isset(self::$libs[$libName]))
+ return;
+ $libClassName = ucfirst($libName) . 'Library';
+ include("$path/$libClassName.php");
+ self::$libs[$libName] = new $libClassName($path);
+ }
+
+ /**
+ * loads a library, which just means loading all of it's modules
+ */
+
+ static public function loadLib($libName)
+ {
+ // for check is for backwards compatibility
+ // in the future we can depricate it and change the self::loadMod
+ // call to a trigger_error("lib '$libName' not found") call
+ if(isset(self::$libs[$libName]))
+ self::$libs[$libName]->loadMods();
+ else
+ self::loadMod($libName);
+ }
+
+ /**
+ * finds out what lib a module is in and then loads it
+ */
+
+ static public function loadMod($modName)
+ {
+ foreach(self::$libs as $lib)
+ if($lib->hasMod($modName))
+ return $lib->loadMod($modName);
+
+ trigger_error("mod '$modName' not found");
+ }
+
+ static public function expandPath($path)
+ {
+ if($path[0] == '/')
+ return $path;
+
+ return app_dir . '/' . $path;
+ }
+
+ static public function getTmpDir()
+ {
+ return Config::getFilePath('zoop.tmpDir');;
+ }
+
+ // deprecated stuff
+
+ /**
+ * static -- Register a class for auto-loading with the name of the class
+ * and the full path of the file that contains it.
+ *
+ * @param string $className
+ * @param string $fullPath
+ */
+ static function registerClass($className, $fullPath)
+ {
+ ZoopLoader::addClass($className, $fullPath);
+ }
+
+ /**
+ * Register a "domain" class for autoload (a domain class is a
+ * class that is located in the "domains" directory under
+ * the project root with the filename <classname>.php)
+ *
+ * @param unknown_type $className
+ */
+ static public function registerDomain($className)
+ {
+ self::registerClass($className, app_dir . '/domain/' . $className . '.php');
+ }
+
+ // static $libList = array();
+ //
+ // /**
+ // * Key => Value list of registered classes and the full path of the file that contains them
+ // *
+ // * @var array
+ // */
+ // var $classList;
+ //
+ //
+ // /**
+ // * Register a class for auto-loading with the name of the class
+ // * and the full path of the file that contains it.
+ // *
+ // * @param string $className
+ // * @param string $fullPath
+ // */
+ // function _registerClass($className, $fullPath)
+ // {
+ // $this->classList[strtolower($className)] = $fullPath;
+ // }
+ //
+ // /**
+ // * Returns the full path and filename associated with the given registered class
+ // *
+ // * @param string $className
+ // * @return string - full path and filename of the class
+ // */
+ // function _getClassPath($className)
+ // {
+ // $className = strtolower($className);
+ // if(isset($this->classList[$className]))
+ // return $this->classList[$className];
+ //
+ // return false;
+ // }
+ //
+ // /**
+ // * static -- Register a class for auto-loading with the name of the class
+ // * and the full path of the file that contains it.
+ // *
+ // * @param string $className
+ // * @param string $fullPath
+ // */
+ // static function registerClass($className, $fullPath)
+ // {
+ // global $zoop;
+ // $zoop->_registerClass($className, $fullPath);
+ // }
+ //
+ // /**
+ // * static -- Returns the full path and filename associated with the given registered class
+ // *
+ // * @param string $className
+ // * @return string - full path and filename of the class
+ // */
+ // function getClassPath($className)
+ // {
+ // global $zoop;
+ // return $zoop->_getClassPath($className);
+ // }
+ //
+ // /**
+ // * Loads a library of specified name. Modules are located in the root
+ // * directory of the framework, using the following naming scheme:
+ // * <root>/<module>/<module>.php
+ // *
+ // * @param string $name
+ // */
+ // static function loadLib($name, $isVendor = false)
+ // {
+ // echo "$name<br>";
+ // var_dump($isVendor);
+ // // put some code in here to make sure we don't reload modules that have already been loaded
+ // if(isset(self::$libList[$name]))
+ // return;
+ // self::$libList[$name] = 1;
+ //
+ // // temporary measure so I can test without having to convert all of the modules over to the new format right away
+ // if(file_exists(zoop_dir . "/$name/module.php"))
+ // {
+ // include(zoop_dir . "/$name/module.php");
+ // }
+ // else
+ // {
+ // if($isVendor)
+ // {
+ // $moduleName = ucfirst($name) . 'Module';
+ // include(zoop_dir . "/vendor/$moduleName.php");
+ // $module = new $moduleName();
+ // }
+ // else
+ // {
+ // $moduleName = ucfirst($name) . 'Module';
+ // include(zoop_dir . "/$name/$moduleName.php");
+ // $module = new $moduleName();
+ // }
+ // }
+ // }
+ //
+
+ /**
+ * Automatic class loading handler. This automatically loads a class using the path
+ * information that was registered using the Zoop::registerClass or ::registerDomain
+ * method
+ *
+ * @param string $className Name of the class to load
+ */
+ /*
+
+ moved to ZoopLoader.php
+
+ static function autoload($className)
+ {
+ if(headers_sent())
+ {
+ echo_r($className);
+ die('here');
+ }
+
+ $classPath = Zoop::getClassPath($className);
+ if($classPath)
+ {
+ require_once($classPath);
+ }
+
+ if(substr($className, 0, 5) == 'Zend_')
+ {
+ $parts = explode('_', $className);
+ $modName = $parts[1];
+ require_once(zoop_dir . "/Zend/$modName.php");
+ }
+ }
+ */
+}
+
+Zoop::registerLib('boot');
+Zoop::registerLib('core');
+Zoop::registerLib('experimental');
+Zoop::registerLib('vendor');
+Zoop::loadLib('boot');
Oops, something went wrong.

0 comments on commit 37b1969

Please sign in to comment.