public function setUp()
 {
     $system = realpath(__DIR__ . '/../../');
     $options = array('production' => false, 'max_age' => 3600, 'load_paths' => array(), 'output_compression' => false, 'output_style' => 'none');
     $container = new Scaffold_Container($system, $options);
     $this->object = $container->build();
 }
Beispiel #2
0
 /**
  * Finds a file relative to the source file from a URL
  * @access public
  * @param $url
  * @return mixed
  */
 public function find($url)
 {
     if ($url[0] == '/' or $url[0] == '\\') {
         $path = $_SERVER['DOCUMENT_ROOT'] . $url;
         if (!file_exists($path)) {
             $path = false;
         }
     } else {
         $Container = Scaffold_Container::getInstance();
         $import_paths = $Container->options['import_paths'];
         array_unshift($import_paths, dirname($this->basepath));
         foreach ($import_paths as $import_path) {
             $path = $import_path . DIRECTORY_SEPARATOR . $url;
             if (file_exists($path)) {
                 break;
             }
         }
         if (!file_exists($path)) {
             $path = false;
         }
     }
     return $path;
 }
Beispiel #3
0
 public function testBuild()
 {
     $obj = $this->object->build();
     $this->assertEquals(get_class($obj), 'Scaffold');
 }
Beispiel #4
0
 * @see http://au.php.net/manual/en/function.register-shutdown-function.php
 */
register_shutdown_function(array('Environment', 'shutdown_handler'));
/** 
 * Set the view to use for errors and exceptions
 */
Environment::set_view(realpath($system . '/views/error.php'));
// =========================================
// = Start the scaffolding magic  =
// =========================================
// Make sure the config var is set
if (!isset($config)) {
    $config = array();
}
// The container creates Scaffold objects
$container = new Scaffold_Container($system, $config);
// This is where the magic happens
$scaffold = $container->build();
// Get the requested source
if (isset($_GET['file'])) {
    $source = new Scaffold_Source_File($scaffold->loader->find_file($_GET['file']));
} elseif (isset($_GET['url'])) {
    $source = new Scaffold_Source_Url($_GET['url']);
} elseif (isset($_GET['string'])) {
    $source = new Scaffold_Source_String($_GET['string']);
} else {
    echo 'No source :(';
    exit;
}
// Compiles the source object
$source = $scaffold->compile($source);
Beispiel #5
0
/**
 * Set timezone, just in case it isn't set. PHP 5.3+ 
 * throws a tantrum if you try and use time() without
 * this being set.
 */
date_default_timezone_set('GMT');
/**
 * Automatically load any Scaffold Classes
 */
Scaffold_Environment::auto_load();
/**
 * Let Scaffold handle errors
 */
Scaffold_Environment::handle_errors();
/** 
 * Set the view to use for errors and exceptions
 */
Scaffold_Environment::set_view(realpath($system . '/views/error.php'));
// =========================================
// = Start the scaffolding magic  =
// =========================================
// The container creates Scaffold objects
$Container = new Scaffold_Container($system, $config);
// This is where the magic happens
$Scaffold = $Container->build();
// Get the sources
$Source = $Scaffold->getSource(null, $config);
// Compiles the source object
$Source = $Scaffold->compile($Source);
// Use the result to render it to the browser. Hooray!
$Scaffold->render($Source);
Beispiel #6
0
require_once SCAFFOLD_PATH . '/lib/Scaffold/Environment.php';
/**
 * Set timezone, just in case it isn't set. PHP 5.3+
 * throws a tantrum if you try and use time() without
 * this being set.
 */
date_default_timezone_set('GMT');
/**
 * Automatically load any Scaffold Classes
 */
Scaffold_Environment::auto_load();
/**
 * Let Scaffold handle errors
 */
Scaffold_Environment::handle_errors();
/**
 * Set the view to use for errors and exceptions
 */
Scaffold_Environment::set_view(realpath(SCAFFOLD_PATH . '/views/error.php'));
# Scaffold Config
$config = $GLOBALS['ApplicationConfiguration']['compiler']['scaffold']['config'];
# The container creates Scaffold objects
$Container = Scaffold_Container::getInstance(SCAFFOLD_PATH, $config);
# This is where the magic happens
$Scaffold = $Container->build();
# Compile
$Source = $Scaffold->getSource(null, $config);
// Compiles the source object
$Source = $Scaffold->compile($Source);
// Use the result to render it to the browser. Hooray!
$Scaffold->render($Source);