code
stringlengths
1
2.01M
language
stringclasses
1 value
<?php /** * Asar_Client_Default_Exception class definition - Asar Web Framework Core * * 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://www.opensource.org/license...
PHP
<?php class Asar_Client_Default extends Asar_Client { function createRequest($arguments = null) { $request = parent::createRequest( array( 'authority' => $_SERVER['SERVER_NAME'], 'scheme' => 'http', 'path' => $this->getUriFromServerVars(), 'method' => $_SERVER['REQUEST_METHOD'...
PHP
<?php /** * Asar_Client_Exception class definition - Asar Web Framework Core * * 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://www.opensource.org/licenses/bsd-li...
PHP
<?php /** * A wrapper class for simplifying file creation and access * * EXAMPLE - File Creation * The following code creates a file named 'filename.ext' * with the content 'Hello World!' and saves it. * * Asar_File::create('filename.ext')->write('Hello World!')->save(); * * The following code creates a ...
PHP
<?php class Asar_Client extends Asar_Base { private $name = NULL; protected $request = NULL; protected $response = NULL; function createRequest($arguments = NULL) { $req = new Asar_Request(); if (is_array($arguments)) { $req->setUriAuthority($arguments['authority']); $req->setUriScheme...
PHP
<?php /** * @todo Application, Controller, & Action names validation */ require_once 'Asar.php'; class Asar_Response extends Asar_Message { private $status_code = 200; function setStatus($code) { // Check code against bounds if ($code >= 100 && $code <= 599) { $this->status_code = $code; } else ...
PHP
<?php /** * Created on Jun 21, 2007 * * @author Wayne Duran */ class Asar_Utility_RandomStringGenerator { private static $instance; private static $characters = array(); private static $lower_a_start; private static $lower_a_end; private static $upper_a_start; private static $upper_a_end; private sta...
PHP
<?php #require_once 'Asar/File.php'; /** * Helper class for Asar Framework Tests * * This class provides methods to help with tests. Some of these are: * - Creating and cleaning up dummy files * - assertStringContains * * @package asar-web-framework * @todo Make exceptions friendly **/ abstract class Asar_Te...
PHP
<?php /** * Asar_Controller class definition - Asar Web Framework Core * * 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://www.opensource.org/licenses/bsd-license....
PHP
<?php /** * Asar_Template_Exception class definition - Asar Web Framework Core * * 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://www.opensource.org/licenses/bsd-...
PHP
<?php /** * Html Template Class * * This template is called whenever an HTML representation * is needed for a certain resources. Use this to create * HTML-based templates * **/ class Asar_Template_Html extends Asar_Template { private $layout_path = null; private $layout = null; /** *...
PHP
<?php abstract class Asar_Application extends Asar_Request_Handler { private $root_controller = null; function __construct() { $root_controller_class_name = $this->getAppName().'_Controller_Index'; try { $this->root_controller = Asar::instantiate($root_controller_class_...
PHP
<?php /** * Asar_Response_Exception class definition - Asar Web Framework Core * * 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://www.opensource.org/licenses/bsd-...
PHP
<?php class Asar_Template extends Asar_Base implements ArrayAccess { protected $vars = array(); // Holds all the template variables protected $path; // Path to the templates protected $template_file; // Template file to use protected $controller; public function getPath() { return $this->path; } public fu...
PHP
<?php /** * Asar_Base_Exception class definition - Asar Web Framework Core * * 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://www.opensource.org/licenses/bsd-lice...
PHP
<?php abstract class Asar_Request_Handler extends Asar_Base implements Asar_Requestable { final function handleRequest(Asar_Request $request, array $arguments = NULL) { if (!empty($this->request_filters)) { foreach($this->request_filters as $filter) { call_user_func( $filte...
PHP
<?php /** * Asar_Request_Exception class definition - Asar Web Framework Core * * 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://www.opensource.org/licenses/bsd-l...
PHP
<?php /** * @todo The logic of this class needs a lot of rethinking and rethinking. It smells ugly. */ class Asar_Controller_Default extends Asar_Base implements Asar_Requestable { function handleRequest(Asar_Request $request, array $arguments = NULL) { $this->response = $request->getContent(); $this->view ...
PHP
<?php /** * Asar_Exception class definition - Asar Web Framework Core * * 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://www.opensource.org/licenses/bsd-license.p...
PHP
<?php /** * Asar_Helper_String class definition - Asar Web Framework Core * * 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://www.opensource.org/licenses/bsd-licen...
PHP
<?php /** * Asar_Helper_Html class definition - Asar Web Framework Core * * 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://www.opensource.org/licenses/bsd-license...
PHP
<?php /** * Asar_Message_Exception class definition - Asar Web Framework Core * * 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://www.opensource.org/licenses/bsd-l...
PHP
<?php interface Asar_Requestable { function handleRequest(Asar_Request $handler, array $arguments = NULL); //function processResponse(Asar_Response $response); }
PHP
<?php /** * Layout.html.php, Layout file for Sample Applicatoin * * @package Sample */ ?> <html> <head> <title>Sample Application for Asar Web Framework</title> </head> <body> <?= $contents ?> </body> </html>
PHP
<h1>Em Calculator</h1> <p> Em Calculator is a tool to calculate em values given a base font-size. It can also suggest to you a line-height value in ems if you want. <br /> <a href="<?=$this->getController()->getContext()->getPath()?>">Back to parent...</a> </p> <p> This page can be found at: <a href="<?=$this->get...
PHP
<h1><?=$what_to_say?></h1>
PHP
<h1><?=$hello?></h1> <ul> <li><a href="<?=$follow_url?>" id="follow_link">Follow Me!</a></li> <li><a href="<?=$this['em_calculator']?>">Em Calculator</a></li> </ul>
PHP
<?php require_once 'Asar.php'; /** * Application Object for testapp * * @package functional_test_app **/ class Sample_Application extends Asar_Application { } // END class testapp_Application extends Asasr_Application
PHP
<?php /** * EmCalculator Class calculates pixel values to ems */ class Sample_Model_EmCalculator { private $base; private $base_line_height; private $inherited; private $precision = 4; function setBaseFontSize($value) { $this->base = $value; } function getBaseFontSize() { return $this->base; } fun...
PHP
<?php require_once 'PHPUnit/Framework/TestSuite.php'; require_once 'PHPUnit/TextUI/TestRunner.php'; class AllTests { private static $_suite = null; public static function main() { PHPUnit_TextUI_TestRunner::run(self::suite()); } public static function suite() { ...
PHP
<?php class Sample_Controller_Index extends Asar_Controller { protected $map = array( 'follow' => 'FollowTest', 'em_calculator' => 'EmCalculator' ); function GET() { $this->view['hello'] = 'Hello World!'; $this->view['follow_url'] = '/follow/'; $this->view['em_calculator'] = '/em_calculator/'; } }
PHP
<?php class Sample_Controller_FollowTest extends Asar_Controller { function GET() { $this->view['what_to_say'] = 'I\'ve been followed!'; } }
PHP
<?php /** * */ class Sample_Controller_EmCalculator extends Asar_Controller { function GET() { } function POST() { $this->calc = new Sample_Model_EmCalculator; $post = $this->request->getContent(); $this->calc->setBaseFontSize($post['emcalc_base-font-size']); $this->calc->setBaseLineHeight($post['em...
PHP
<?php require_once 'Asar.php'; Asar::setMode(Asar::MODE_DEVELOPMENT); Asar::start('Sample');
PHP
<?php /** * Layout.html.php, Layout file for Sample Applicatoin * * @package Sample */ ?> <html> <head> <title>Sample Application for Asar Web Framework</title> </head> <body> <?= $contents ?> </body> </html>
PHP
<h1>Em Calculator</h1> <p> Em Calculator is a tool to calculate em values given a base font-size. It can also suggest to you a line-height value in ems if you want. <br /> <a href="<?=$this->getController()->getContext()->getPath()?>">Back to parent...</a> </p> <p> This page can be found at: <a href="<?=$this->get...
PHP
<h1><?=$what_to_say?></h1>
PHP
<h1><?=$hello?></h1> <ul> <li><a href="<?=$follow_url?>" id="follow_link">Follow Me!</a></li> <li><a href="<?=$this['em_calculator']?>">Em Calculator</a></li> </ul>
PHP
<?php require_once 'Asar.php'; /** * Application Object for testapp * * @package functional_test_app **/ class Sample_Application extends Asar_Application { } // END class testapp_Application extends Asasr_Application
PHP
<?php /** * EmCalculator Class calculates pixel values to ems */ class Sample_Model_EmCalculator { private $base; private $base_line_height; private $inherited; private $precision = 4; function setBaseFontSize($value) { $this->base = $value; } function getBaseFontSize() { return $this->base; } fun...
PHP
<?php require_once 'PHPUnit/Framework/TestSuite.php'; require_once 'PHPUnit/TextUI/TestRunner.php'; class AllTests { private static $_suite = null; public static function main() { PHPUnit_TextUI_TestRunner::run(self::suite()); } public static function suite() { ...
PHP
<?php class Sample_Controller_Index extends Asar_Controller { protected $map = array( 'follow' => 'FollowTest', 'em_calculator' => 'EmCalculator' ); function GET() { $this->view['hello'] = 'Hello World!'; $this->view['follow_url'] = '/follow/'; $this->view['em_calculator'] = '/em_calculator/'; } }
PHP
<?php class Sample_Controller_FollowTest extends Asar_Controller { function GET() { $this->view['what_to_say'] = 'I\'ve been followed!'; } }
PHP
<?php /** * */ class Sample_Controller_EmCalculator extends Asar_Controller { function GET() { } function POST() { $this->calc = new Sample_Model_EmCalculator; $post = $this->request->getContent(); $this->calc->setBaseFontSize($post['emcalc_base-font-size']); $this->calc->setBaseLineHeight($post['em...
PHP
<?php require_once 'Asar.php'; Asar::setMode(Asar::MODE_DEVELOPMENT); Asar::start('Sample');
PHP
<?php class RemoveSvnEntries implements Asar_Utility_CLI_Interface { private $cwd; private $controller = null; function __construct() { $this->cwd = getcwd(); } function setController(Asar_Utility_CLI $controller) { $this->controller = $controller; } function removeSvnDirs($path) { ...
PHP
<?php // INTERNAL HEADERS 'Asar-Internal' => array( 'original_path' => '/some/where', 'isForwarded' => true, ); // CONFIG DEFAULTS: array( 'default_classes' => array( 'application' => 'Asar_ApplicationBasic', 'config' => 'Asar_Config_Default' ), 'templates' => array( 'engines' => array...
PHP
<?php $foo = array('bar' => array('baz' => 'yo')); var_dump(isset($foo['bar']['baz']));
PHP
<?php ini_set('error_reporting', E_ALL | E_STRICT); require_once realpath(dirname(__FILE__) . '/../lib/core/Asar.php'); $__asar = Asar::getInstance(); $__asar->getToolSet()->getIncludePathManager()->add( $__asar->getFrameworkCorePath(), $__asar->getFrameworkDevTestingPath(), $__asar->getFrameworkExtensionsPath(...
PHP
<?php require_once realpath(dirname(__FILE__). '/../config.php'); require_once 'PHPUnit/Framework/TestSuite.php'; require_once 'PHPUnit/TextUI/TestRunner.php'; class AllUnitTests { private static $_suite = null; public static function main() { PHPUnit_TextUI_TestRunner::run(self::s...
PHP
<?php // This is just dummy data. // Please see tests/unit/core/Asar/Utility/Cli/TaskFileLoaderTest.php return 'foobar';
PHP
<?php // See tests/unit/core/Asar/Utility/ClassFilePeekTest.php class Asar_ClassFilePeekTest_Foo { } class Asar_ClassFilePeekTest_Bar extends Asar_ClassFilePeekTest_Foo { }
PHP
<?php var_dump($_POST); var_dump($_SERVER); var_dump($_ENV); var_dump( file_get_contents('php://input') );
PHP
<?php require_once 'PHPUnit/Framework/TestSuite.php'; require_once 'PHPUnit/TextUI/TestRunner.php'; class AllTests { private static $_suite = null; public static function main() { PHPUnit_TextUI_TestRunner::run(self::suite()); } public static function suite() { ...
PHP
<?php class DebuggingExample_Resource_Index extends Asar_Resource { function GET() { return array( 'h1' => 'Debugging Tests' ); /* * TODO: Fix: This code introduces an error "Creating default object from empty value." $this->template->h1 = 'Debugging Tests'; */ } }
PHP
<?php class DebuggingExample_Config extends Asar_Config { protected $config = array( 'mode' => 'development', ); }
PHP
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <title><?= isset($title) ? $title : 'Debugging Functional Tests'?></title> </head> <body> <?= $content ?> ...
PHP
<h1 id="the_head"><?=$h1?></h1>
PHP
<?php // TODO: Use Asar_Utility_ServerSetup instead set_include_path( realpath(dirname(__FILE__) .'/../../../../core') . PATH_SEPARATOR . realpath(dirname(__FILE__) . '/..') . PATH_SEPARATOR . get_include_path() ); require_once 'Asar.php'; Asar::setMode(Asar::MODE_DEBUG); Asar::start('DebuggingExample');...
PHP
<?php class RepresentationExample_Resource_Index extends Asar_Resource { function GET() { return array( 'h1' => 'Hello World!', 'p' => 'This is the paragraph. Easy, no?' ); } }
PHP
<?php class RepresentationExample_Application extends Asar_Application { protected function setUp() { } }
PHP
<representation> <h1><?php echo $h1 ?></h1> <p><?php echo $p ?></p> </representation>
PHP
<?php class RepresentationExample_Representation_Index extends Asar_Representation { function getHtml($data) { return '<html> <head> <title>Representation Example Index</title> </head> <body> <h1>'. $data['h1'] . '</h1> <p>'. $data['p'] . '</p> ...
PHP
<?php require_once realpath(dirname(__FILE__) . '/../config.php'); require_once 'PHPUnit/Framework/TestSuite.php'; require_once 'PHPUnit/TextUI/TestRunner.php'; class AllFunctionalTests { private static $_suite = null; public static function main() { PHPUnit_TextUI_TestRunner::run...
PHP
<?php class Example1_Resource_What extends Asar_Resource { function setUp() { $this->config['use_templates'] = false; } function GET() { return "What's your name?"; } function POST() { $name = $_POST['name']; return "Hello $name!"; } }
PHP
<?php class Example1_Resource_Index extends Asar_Resource { function setUp() { $this->config['use_templates'] = false; } function GET() { return 'Hello World!'; } }
PHP
<?php /** * Test Example1 Application Class * * This is the Application definition for the application application * named 'Example1'. This test application is used only for integration * testing. */ class Example1_Config extends Asar_Config { protected $config = array( 'map' => array( '/what' => ...
PHP
<?php class TemplatesExample_Resource_PhpHaml extends Asar_Resource { function setUp() { // TODO: How do we set a different template engine? $this->setTemplateEngine('phphaml'); } public function GET() { return array('p' => 'This is an alternative template setup.'); } }
PHP
<?php class TemplatesExample_Resource_Xml extends Asar_Resource { public function GET() { return array('foo' => 'This is from Xml.php'); } }
PHP
<?php class TemplatesExample_Resource_Index extends Asar_Resource { public function GET() { return array('p' => 'This is the paragraph. Easy, no?'); } public function POST() { return array( 'h2' => 'This is the subheading for the POST template', 'p' => 'And this is the paragraph' );...
PHP
<?php class TemplatesExample_Resource_ContentNegotiation extends Asar_Resource { public function GET() { return array('foo' => 'This is from ContentNegotiation.php'); } }
PHP
<?php class TemplatesExample_Resource_Alternative extends Asar_Resource { public function GET() { return array('p' => 'This is an alternative template setup.'); } }
PHP
<?php class TemplatesExample_Resource_SetLayout extends Asar_Resource { public function GET() { return array( 'p' => 'This is the paragraph from SetLayout.php' ); } }
PHP
<?php class TemplatesExample_Resource_Nolayout extends Asar_Resource { public function GET() { return array( 'h1' => 'This is the main heading.', 'p' => 'This is the paragraph. Easy, no?' ); } }
PHP
<?php class TemplatesExample_Application extends Asar_Application { protected function setUp() { $this->setMap('/', 'Index'); $this->setMap('/nolayout', 'Nolayout'); $this->setMap('/set-layout', 'SetLayout'); $this->setMap('/alternative', 'Alternative'); $this->setMap('/xml', 'Xml'); } }
PHP
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <title><?php echo isset($title) ? $title : 'Template Functional Tests'?></title> </head> <body> <?php echo...
PHP
<h1>In ContentNegotiation/GET.html.php.</h1> <p><?= $foo ?></p>
PHP
===================================================== In ContentNegotiation/GET.txt.php. ===================================================== <?= $foo ?>
PHP
<h1>This is the main heading found in Alternative.GET.html.php.</h1> <p><?php echo $p ?></p>
PHP
<h1>This is the main heading found in Index/GET.html.php.</h1> <p><?= $p ?></p>
PHP
===================================================== This is the main heading found in Index/GET.txt.php. ===================================================== <?= $p ?>
PHP
<h1>This is the main heading found in Index/POST.html.php.</h1> <h2><?= $h2 ?></h2> <div> <p><?= $p ?></p> </div>
PHP
<bar> <foo><?= $foo ?></foo> </bar>
PHP
<?php class StatusCodesExample_Resource_Page extends Asar_Resource { function GET() { return array('heading' => "This is a test."); } }
PHP
<?php class StatusCodesExample_Resource_500 extends Asar_Resource { public function GET() { throw new Exception('Something is wrong.'); } }
PHP
<?php class StatusCodesExample_Resource_Index extends Asar_Resource { public function GET() { $this->setConfig('use_templates', false); return "This is a test."; } }
PHP
<?php class StatusCodesExample_Application extends Asar_Application { protected function setUp() { $this->setMap('/', 'Index'); $this->setMap('/page', 'Page'); $this->setMap('/500', '500'); } }
PHP
<html> <head> <title>A Page</title> </head> <body> <h1><?=$heading?> </body> </html>
PHP
<?php class ResourceTraversing_Resource_Blog_RtYear extends Asar_Resource { function GET() { return $this->request->getPath() . ' GET.'; } function qualify($path) { return preg_match('/^[1-9][0-9]{3}$/' , $path['year']); } }
PHP
<?php class ResourceTraversing_Resource_Blog_RtYear_RtMonth_RtTitle extends Asar_Resource { function GET() { $path = $this->getPathComponents(); return $path['title']; } function qualify($path) { return preg_match('/^[1-9][0-9]{3}$/' , $path['year']) && preg_match('/^[0-1][0-9]$/...
PHP
<?php class ResourceTraversing_Resource_Blog_RtYear_RtMonth extends Asar_Resource { function GET() { return $this->request->getPath() . ' GET.'; } function qualify($path) { return preg_match('/^[1-9][0-9]{3}$/' , $path['year']) && preg_match('/^[0-1][0-9]$/' , $path['month']); } }
PHP
<?php class ResourceTraversing_Resource_Parent extends Asar_Resource { function GET() { return '/parent GET.'; } }
PHP
<?php class ResourceTraversing_Resource_Index extends Asar_Resource { function GET() { return '/ GET.'; } }
PHP
<?php class ResourceTraversing_Resource_ForwardToChild extends Asar_Resource { function GET() { $this->forwardTo('Parent_Child'); } }
PHP
<?php class ResourceTraversing_Resource_Parent_Child_GrandChild extends Asar_Resource { function GET() { return $this->getPath() . ' GET.'; } }
PHP
<?php class ResourceTraversing_Resource_Parent_Child extends Asar_Resource { function GET() { return '/parent/child GET.'; } }
PHP
<?php class ResourceTraversing_Resource_Blog extends Asar_Resource { function GET() { return '/blog GET.'; } }
PHP
<?php class ResourceTraversing_Resource_RedirectOne extends Asar_Resource { function GET() { $this->redirectTo('Parent_Child_GrandChild'); } }
PHP
<?php class ResourceTraversing_Config extends Asar_Config { protected $config = array( 'use_templates' => false, 'site_domain' => 'asar-test.local', 'site_protocol' => 'http', ); }
PHP
<?php abstract class Asar_Model_RedBean { private $oodb, $bean; function __construct(RedBean_ObjectDatabase $oodb, RedBean_OODBBean $bean = NULL) { $this->oodb = $oodb; if ($bean) { $this->bean = $bean; } else { $this->bean = $this->oodb->dispense(get_class($this)); } $this->d...
PHP