static function Init($dir) { if (!WaxConf::$init) { set_exception_handler("wax_exception_handler"); // register block directories WaxConf::BlocksAt($dir . "/blocks"); WaxConf::BlocksAt(dirname(__FILE__) . "/../../blocks"); // require Wax core $dir = dirname(__FILE__) . "/.."; if (is_dir($dir)) { require_dir("{$dir}"); } // perform block auto-loading operations BlockManager::Init(); // ready to go WaxConf::$init = true; } }
/** * Function to recursively include PHP files in a directory. * Uses require_once to ensure each file is included only * once. * * Warning: Will only include up to $max_depth directories * * @param string $dir The directory to include * @param int $max_depth The maximum depth to include directories */ function _require_dir($dir, $max_depth = 10) { if ($max_depth == 0) { return; } if (is_dir($dir)) { $objects = scandir($dir); foreach ($objects as $file) { if ($file[0] == ".") { continue; } else { if (is_dir("{$dir}/{$file}")) { require_dir("{$dir}/{$file}", $max_depth - 1); } else { if (strpos($file, ".php") != false && $file[0] != "_") { require_once "{$dir}/{$file}"; } } } } } }
private function loadResources($dir, $include_files = false) { $dhtml = array("js", "css", "images"); // creates web-relative path refs $php = array("blocks", "include", "roles", "views", "lib", "contexts"); // creates fs-absolute path refs // resource loading loop-- // determines all javascript, css, and image resources // in the current block. foreach ($dhtml as $resourcedir) { if (is_dir("{$dir}/{$resourcedir}")) { foreach (scandir("{$dir}/{$resourcedir}") as $file) { if ($file[0] == '.' || $file[0] == '_') { continue; } else { $path = str_replace($_SERVER['DOCUMENT_ROOT'], '', $this->_blockdir . "/{$resourcedir}/{$file}"); $fileparts = explode(".", $file); $title = array_shift($fileparts); $this->_resources[$resourcedir][$title] = $path; } } } } // library loading loop-- // determines all libraries, objects, roles, contexts, etc. // that need to be require()'d for this block to work like // it should. foreach ($php as $resourcedir) { if (is_dir("{$dir}/{$resourcedir}")) { switch ($resourcedir) { // these are all treated the same -- // the only thing that matters is the order, // which is specified in the $php array. case "lib": case "contexts": case "include": require_dir("{$dir}/{$resourcedir}"); break; case "views": $this->analyzeViewDir("{$dir}/{$resourcedir}"); break; // the idea behind the blocks and roles directories // is pretty much the same // the idea behind the blocks and roles directories // is pretty much the same case "blocks": case "roles": foreach (scandir("{$dir}/{$resourcedir}") as $obj) { if ($obj[0] == '.' || $obj[0] == '_') { continue; } $objname = explode(".", $obj); $key = array_shift($objname); $objval = "{$dir}/{$resourcedir}/{$obj}"; if ($resourcedir == "roles") { require_once "{$dir}/{$resourcedir}/{$obj}"; } else { $objval = BlockManager::LoadBlockAt("{$dir}/{$resourcedir}/{$obj}"); } $this->_resources[$resourcedir][$key] = $objval; } break; } } } }
* Copyright 2009 Limber Framework * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ require_once "limber_record.php"; //require models require_dir(__DIR__ . "/models"); describe("LimberRecord Base", function ($spec) { $spec->context("getting table name", function ($spec) { $spec->it("should return the pluralized name of model by default", function ($spec) { $spec(Person::table_name())->should->be("people"); $spec(Item::table_name())->should->be("items"); }); $spec->it("should use a customized net if it's set", function ($spec) { Item::table_name("collection"); $spec(Item::table_name())->should->be("collection"); Item::table_name(null); //restore table name }); }); });
<?php /** * Wax Initialization Script * * Copyright 2008-2010 (c) Joe Chrzanowski * * * @author Joe Chrzanowski * @version 0.10 */ if (defined("WAX_LOADED")) { die("ERROR: Wax is being loaded again from " . getcwd() . ".<br />Previously loaded from: " . WAX_LOADED); } require_once dirname(__FILE__) . "/include/lib.php"; require_dir(dirname(__FILE__) . "/include"); require_dir(dirname(__FILE__) . "/managers"); require_dir(dirname(__FILE__) . "/lib"); ob_start(); error_reporting(E_ALL); Wax::Init(getcwd()); define("WAX_LOADED", getcwd());