code
stringlengths
1
2.01M
language
stringclasses
1 value
<?php namespace Asar; use \Asar\Message; use \Asar\Response\ResponseInterface; /** */ class Response extends Message implements ResponseInterface { private $status = 200; private static $reason_phrases = array( 100 => 'Continue', 101 => 'Switching Protocols', 200 => 'OK', 201 => 'Created', ...
PHP
<?php namespace Asar; use \Asar\Template\TemplateInterface; /** */ class TemplateSimpleRenderer { function renderTemplate( $template, $vars, $layout = null ) { if (!$template instanceof TemplateInterface) { return null; } $output = $template->render($vars); if ( !$template-...
PHP
<?php namespace Asar\Utility\Cli; use \Asar\Utility\Cli; /** */ interface CliInterface { function setController(Cli $controller); function getTaskNamespace(); }
PHP
<?php namespace Asar\Utility\Cli; /** */ class Command { private $caller, $namespace, $command, $flags = array(), $arguments = array(); function __construct(array $options = array()) { foreach ( array('caller', 'command', 'namespace', 'flags', 'arguments') as $type ) { $...
PHP
<?php namespace Asar\Utility\Cli; class Injector { private static $cli; static function injectEnvironmentHelperCli(EnvironmentScope $env_scope) { return new \Asar\EnvironmentHelper\Cli( self::injectCli($env_scope), self::injectArgv($env_scope), self::injectInitialTaskLists($env_scope), ...
PHP
<?php namespace Asar\Utility\Cli; use \Asar\Utility\Cli; use \Asar\Utility\Cli\CliInterface; use \Asar\Utility\ClassFilePeek; /** */ class TaskFileLoader { private $cwd, $file_peek, $tasks_file, $cli; function __construct( $cwd, ClassFilePeek $file_peek, Cli $cli ) { $this->cwd = $cwd; $this-...
PHP
<?php namespace Asar\Utility\Cli\Exception; use Asar\Utility\Cli\Exception; /** */ class UndefinedTask extends Exception {}
PHP
<?php namespace Asar\Utility\Cli\Executor; use \Asar\Utility\Cli\CliInterface; use \Asar\Utility\Cli\Command; /** */ interface ExecutorInterface { function registerTasks(CliInterface $tasklist, $namespace = null); function execute(Command $command); function getRegisteredTasks(); }
PHP
<?php namespace Asar\Utility\Cli; use \Asar\Utility\Cli\CliInterface; use \Asar\Utility\Cli; /** */ class BaseTasks implements CliInterface { private $controller; private $asar = null; function setController(Cli $controller) { $this->controller = $controller; } private function getAsar() { ...
PHP
<?php namespace Asar\Utility\Cli; use \Asar\Utility\Cli\Executor\ExecutorInterface; use \Asar\Utility\Cli\CliInterface; use \Asar\Utility\Cli\Command; use \Asar\Utility\Cli\Exception\UndefinedTask; use \Asar\Utility\String; /** */ class Executor implements ExecutorInterface { private $tasklists = array(), $task...
PHP
<?php namespace Asar\Utility\Cli; /** */ class Interpreter { function interpret(array $args) { $result = array(); $result['caller'] = array_shift($args); $flags = array(); $arguments = array(); $is_command_found = false; foreach ($args as $arg) { if ($is_command_found) { $argum...
PHP
<?php namespace Asar\Utility\Cli; /** */ class Exception extends \Asar\Exception {}
PHP
<?php namespace Asar\Utility\Cli; use \Asar; use \Asar\Utility\Cli; use \Asar\Utility\String; use \Asar\FileHelper; use \Asar\FileHelper\Exception\FileAlreadyExists; use \Asar\FileHelper\Exception\DirectoryAlreadyExists; /** */ class FrameworkTasks implements CliInterface { private $controller, $file_helper, $...
PHP
<?php namespace Asar\Utility\Cli; /** */ class EnvironmentScope { private $cwd, $argv = array(); function __construct($cwd, $argv) { $this->cwd = $cwd; $this->argv = $argv; } function getArgv() { return $this->argv; } function getCurrentWorkingDirectory() { re...
PHP
<?php namespace Asar\Utility; use \Asar\Utility\Cli\Interpreter; use \Asar\Utility\Cli\Executor\ExecutorInterface; use \Asar\Utility\Cli\CliInterface; /** */ class Cli { private $interpreter, $executor, $cwd; function __construct( Interpreter $interpreter, ExecutorInterface $executor, $cwd ) { $th...
PHP
<?php namespace Asar\Utility; /** */ class ClassFilePeek { function getDefinedClasses($file) { $php_code = file_get_contents($file); $classes = $this->get_php_classes($php_code); return $classes; } private function get_php_classes($php_code) { $classes = array(); $tokens = token_get_all($...
PHP
<?php namespace Asar\Utility; /** */ class String { static function dashCamelCase($string) { return str_replace(' ', '-', self::ucwordsLower($string)); } static function dashLowerCase($string) { return self::uncamelize($string, '-'); } private static function uncamelize($string, $splitter="_")...
PHP
<?php namespace Asar\Application; use \Asar\Application\Finder\Exception as AppFinderException; class Finder { function find($app_name) { if ( $dir = ($_dir = $this->findDirIfDefined($app_name, 'Application')) ? $_dir : $this->findDirIfDefined($app_name, 'Config') ) { return $dir; ...
PHP
<?php namespace Asar\Application\Finder; class Exception extends \Asar\Exception {}
PHP
<?php namespace Asar\HttpServer; use \Asar\Resource\ResourceInterface; use \Asar\Request\RequestInterface; use \Asar\Response; /** * A wrapper class for making HTTP Requests */ class Fsocket implements ResourceInterface { private $host; /** * @param string $host the web address (e.g. www.google.com) ...
PHP
<?php namespace Asar\HttpServer; /** */ class Exception extends \Asar\Exception {}
PHP
<?php namespace Asar; use \Asar\Resource\ResourceInterface; use \Asar\Response\ResponseInterface; use \Asar\Request\RequestInterface; use \Asar\Config\ConfigInterface; use \Asar\Config; use \Asar\PathDiscover\PathDiscoverInterface; use \Asar\TemplateRenderer; /** * @todo remove "as ..." */ use \Asar\Templater\Except...
PHP
<?php namespace Asar\Templater; /** */ class Exception extends \Asar\Exception {}
PHP
<?php namespace Asar\Asset; /** * An object representation of a CSS file that might be included in a project * as additional resource when rendering HTML. */ abstract class AbstractAsset { protected $path, $dependencies, $abstract_defaults = array( 'requires' => array() ); function...
PHP
<?php namespace Asar\Asset; /** * An object representation of a CSS file that might be included in a project * as additional resource when rendering HTML. */ class Js extends AbstractAsset { function __construct($path, array $options = array()) { parent::__construct($path, $options); } function ren...
PHP
<?php namespace Asar\Asset; class Manager { private $css = array(), $js = array(); function includeCss($file, $options = array()) { $this->css[$file] = new Css($file, $options); } function includeJs($file, $options = array()) { $this->js[$file] = new Js($file, $options); } func...
PHP
<?php namespace Asar\Asset; /** * An object representation of a CSS file that might be included in a project * as additional resource when rendering HTML. */ class Css extends AbstractAsset { private $media, $defaults = array( 'media' => 'screen' ); function __construct($path, array $op...
PHP
<?php namespace Asar\Template\Exception; use \Asar\Template\Exception; /** */ class TemplateFileNotFound extends Exception {}
PHP
<?php namespace Asar\Template; use Asar\Configurable\ConfigurableInterface; /** */ interface TemplateInterface extends ConfigurableInterface { function setTemplateFile($file); function getTemplateFile(); function getLayoutVars(); function render($vars=array()); }
PHP
<?php namespace Asar\Template\Engines; use \Asar\Template\TemplateInterface; use \Asar\Template\Exception\TemplateFileNotFound; /** */ class PhpEngine implements TemplateInterface { private $file, $layout = array(), $css = array(), $config = array( 'no_layout' => false ); functi...
PHP
<?php namespace Asar\Template; /** */ class Exception extends \Asar\Exception {}
PHP
<?php namespace Asar\DebugPrinter; use Asar\Debug; /** * Inserts debug information in a content with a suitable format */ interface DebugPrinterInterface { /** * Inserts debug information from $debug into $content * * @param Asar_Debug $debug * @param string $content the content where the debug inf...
PHP
<?php namespace Asar\DebugPrinter; use Asar\DebugPrinter\DebugPrinterInterface; use Asar\Debug; /** * A Null DebugPrinter that doesn't do anything but return the content */ class NullDebugPrinter implements DebugPrinterInterface { /** * Simply returns the passed $content. Nothing more. * * @param Asar...
PHP
<?php namespace Asar\DebugPrinter; use Asar\DebugPrinter\DebugPrinterInterface; use Asar\Debug; use Asar\Utility\String as StringUtility; /** * Debug printer that outputs the debug information in HTML format */ class Html implements DebugPrinterInterface { //private $block_elements = array('div', 'table', 'tbod...
PHP
<?php namespace Asar\ResponseFilter; use \Asar\Response\ResponseInterface; /** */ interface ResponseFilterInterface { function filterResponse(ResponseInterface $response); }
PHP
<?php namespace Asar; use \Asar\Resource\ResourceInterface; use \Asar\Router\RouterInterface; use \Asar\Response\StatusMessages\StatusMessagesInterface; use \Asar\Response; use \Asar\Response\ResponseInterface; use \Asar\Request\RequestInterface; use \Asar\RequestFilter\RequestFilterInterface; use \Asar\ResponseFilter...
PHP
<?php namespace Asar\Response\StatusMessages; use \Asar\Response\ResponseInterface; use \Asar\Request\RequestInterface; /** */ interface StatusMessagesInterface { function getMessage( ResponseInterface $response, RequestInterface $request ); }
PHP
<?php namespace Asar\Response; use \Asar\Response\StatusMessages\StatusMessagesInterface; use \Asar\Response\ResponseInterface; use \Asar\Request\RequestInterface; /** */ class StatusMessages implements StatusMessagesInterface { // TODO: These status messages should be moved to the configuration static pro...
PHP
<?php namespace Asar\Response; use \Asar\Message\MessageInterface; /** */ interface ResponseInterface extends MessageInterface { function setStatus($status); function getStatus(); }
PHP
<?php namespace Asar\Logger; use Asar\Logger\Registry\Exception; use Asar\Logger\Registry\Exception\UnregisteredNamespace; use Asar\Logger\DefaultLogger; use Asar\File; /** * Registers loggers that implement the Asar_Logger_Interface * * @todo Modify. This looks more like a factory than a logger */ class Registry...
PHP
<?php namespace Asar\Logger; /** * Provides a generic interface for logging */ interface LoggerInterface { /** * Log a message * @param string $message the message to be logged */ function log($message); }
PHP
<?php namespace Asar\Logger\Registry\Exception; use Asar\Logger\Registry\Exception; /** */ class UnregisteredNamespace extends Exception {}
PHP
<?php namespace Asar\Logger\Registry; /** */ class Exception extends \Asar\Exception {}
PHP
<?php namespace Asar\Logger; use Asar\Logger\LoggerInterface; use Asar\File; /** */ class DefaultLogger implements LoggerInterface { private $file; /** * @param Asar_File $file an Asar_File object to store the log files in */ function __construct(File $file) { $this->file = $file; } /** ...
PHP
<?php namespace Asar; use \Asar\Config\ConfigInterface; use Asar\Templater; use Asar\TemplateRenderer; /** */ class ResourceFactory { function __construct( TemplatePackageProvider $tl_factory, TemplateSimpleRenderer $ts_renderer, ConfigInterface $config ) { $this->tl_factory = $tl_factory; ...
PHP
<?php namespace Asar\Config; use \Asar\Config; /** * Development configuration. Sets some request and response filters useful * during development. This is set when config 'mode' is set to 'development'. * See the FDebuggingExample functional test for ideas on usage. */ class Development extends Config { prot...
PHP
<?php namespace Asar\Config; /** * Default configuration values */ class DefaultConfig extends \Asar\Config { protected $config = array( 'map' => array('/' => 'Index'), 'template_engines' => array('php' => 'Asar\Template\Engines\PhpEngine'), 'use_templates' => true, 'default_clas...
PHP
<?php namespace Asar\Config; /** */ class Exception extends \Asar\Exception {}
PHP
<?php namespace Asar\Config; /** * Provides a generic interface for configurations */ interface ConfigInterface { /** * Returns the value of a configuration directive based on a key or * all the configuration values in a single multi-dimensional array * when no key is specified. * * @param string...
PHP
<?php namespace Asar; use \Asar\ResourceLister\ResourceListerInterface; use \Asar\Application\Finder as AppFinder; /** */ class ResourceLister implements ResourceListerInterface { private $app_finder; function __construct(AppFinder $app_finder) { $this->app_finder = $app_finder; } // TODO: Possib...
PHP
<?php namespace Asar\File\Exception; use \Asar\File\Exception; /** */ class DirectoryNotFound extends Exception {}
PHP
<?php namespace Asar\File\Exception; use \Asar\File\Exception; /** */ class FileDoesNotExist extends Exception {}
PHP
<?php namespace Asar\File\Exception; use \Asar\File\Exception; /** */ class FileAlreadyExists extends Exception {}
PHP
<?php namespace Asar\File; /** */ class Exception extends \Asar\Exception {}
PHP
<?php namespace Asar; use \Asar\Application; /** */ class ApplicationBasic extends Application {}
PHP
<?php namespace Asar\Request; use \Asar\Message\MessageInterface; /** * @todo Move Request to Message namespace */ interface RequestInterface extends MessageInterface { function setParams(array $params); function getParams(); function setPath($path); function getPath(); function setMethod($method); funct...
PHP
<?php namespace Asar; use \Asar\Config\ConfigInterface; use \Asar\ApplicationScope; use \Asar\ApplicationInjector; /** */ class ApplicationFactory { private $config; function __construct(ConfigInterface $config) { $this->config = $config; } function getApplication($app_name) { $containe...
PHP
<?php namespace Asar; use \Asar\Config\Exception as ConfigException; /** */ class Config implements Config\ConfigInterface { protected $config = array(); function __construct($init_config = array()) { if ($init_config) { $this->config = $this->configMerge($init_config, $this->config); } $...
PHP
<?php namespace Asar; use \Asar\ContentNegotiator\ContentNegotiatorInterface; /** * @todo TemplateLocator is tied closely to the default routing algorithm. * Think about how to decouple them. */ class TemplateLocator { private $app_path, $representation_path, $content_negotiator, $engine_exte...
PHP
<?php namespace Asar; /** */ class IncludePathManager { function add() { $paths = func_get_args(); foreach ($paths as $path) { if (is_array($path)) { foreach ($path as $p) { $this->add($p); } } else { $this->realAdd($path); } } } private func...
PHP
<?php namespace Asar; use \Asar\Resource\ResourceInterface; use \Asar\Config\ConfigInterface; use \Asar\Request\RequestInterface; /** */ class Representation implements ResourceInterface, ConfigInterface { protected $resource, $config = array(), $methods = array( 'text/html' => 'Html', ...
PHP
<?php namespace Asar\ContentNegotiator; /** * Provides an interface for content negotiation like how HTTP servers negotiate * the Content-type and/or language through an HTTP Request accept header. */ interface ContentNegotiatorInterface { /** * @param string $accept_header the accept header passed by a requ...
PHP
<?php namespace Asar\ContentNegotiator; /** */ class Exception extends \Asar\Exception {}
PHP
<?php namespace Asar; use \Asar\Debug; /** */ class TemplateFactory { private $engines, $debug; function __construct(Debug $debug = null) { $this->debug = $debug; } //TODO: This should be moved to constructor function registerTemplateEngine($extension, $engine) { $this->engines[$extension]...
PHP
<?php namespace Asar; use \Asar\Config\ConfigInterface; /** */ class ApplicationInjector extends \Pimple { function __construct($app_name, ConfigInterface $config) { $this->app_name = $app_name; $this->config = $config; $this->defineGraph(); } private function defineGraph() { $this->Appli...
PHP
<?php namespace Asar\FileSearcher; /** * Provides an interfaces for searching a file given a path */ interface FileSearcherInterface { /** * @param string $file_path a path to a file that is not usually absolute * @return string|boolean returns an absolute path to the file or false if it * ...
PHP
<?php namespace Asar; use \Asar\Request\RequestInterface; /** */ class TemplatePackageProvider { private $locator, $factory; function __construct( TemplateLocator $locator, TemplateFactory $factory ) { $this->locator = $locator; $this->factory = $factory; } function getTemplatesFor(...
PHP
<?php namespace Asar; use \Asar\TemplatePackageProvider; use \Asar\TemplateSimpleRenderer; use \Asar\Response\ResponseInterface; use \Asar\Request\RequestInterface; use \Asar\Template\TemplateInterface; /** */ class TemplateRenderer { private $package_provider, $renderer; function __construct( Template...
PHP
<?php namespace Asar; use \Asar\Config\ConfigInterface; use \Asar\Debug; use \Asar\DebugPrinter\Html as HtmlDebugPrinter; /** */ class MessageFilterFactory { private $config, $debug, $filters = array(); function __construct(ConfigInterface $config, Debug $debug) { $this->config = $config; $this->de...
PHP
<?php namespace Asar\FileHelper\Exception; use \Asar\FileHelper\Exception; /** */ class ParentDirectoryDoesNotExist extends Exception {}
PHP
<?php namespace Asar\FileHelper\Exception; use \Asar\FileHelper\Exception; /** */ class DirectoryAlreadyExists extends Exception {}
PHP
<?php namespace Asar\FileHelper\Exception; use \Asar\FileHelper\Exception; /** */ class FileAlreadyExists extends Exception {}
PHP
<?php namespace Asar\FileHelper; /** */ class Exception extends \Asar\Exception {}
PHP
<?php namespace Asar; use \Asar\Application; use \Asar\Request\RequestInterface; /** */ class ApplicationRunner { private $app; function __construct(Application $app) { $this->app = $app; } function run(RequestInterface $request) { return $this->app->handleRequest($request); } }
PHP
<?php namespace Asar\Representation\Exception; /** */ class Unavailable extends \Asar\Representation\Exception {}
PHP
<?php namespace Asar\Representation; /** */ class Exception extends \Asar\Exception {}
PHP
<?php /** */ interface Asar_Representation_Interface { function fetch($data, $method, array $options = array()); }
PHP
<?php namespace Asar; use \Asar\Response; /** */ class ResponseExporter { function exportResponse(Response $response) { $headers = $response->getHeaders(); foreach ($headers as $key => $value) { $this->header("$key: $value"); } $this->header( "HTTP/1.1 {$response->getStatus()} {$resp...
PHP
<?php namespace Asar\RequestFilter; use \Asar\Request\RequestInterface; /** */ interface RequestFilterInterface { function filterRequest(RequestInterface $request); }
PHP
<?php namespace Asar; /** */ class Exception extends \Exception {}
PHP
<?php namespace Asar\ResourceFactory; class Exception extends \Asar\Exception {}
PHP
<?php namespace Asar\Message; /** * A generic message interface that Asar_Request and Asar_Response shares. * */ interface MessageInterface { function setHeader($name, $value); function getHeader($name); function setHeaders(array $headers); function getHeaders(); function setContent($content); function g...
PHP
<?php namespace Asar; use \Asar\ContentNegotiator\ContentNegotiatorInterface; /** */ class ContentNegotiator implements ContentNegotiatorInterface { function negotiateFormat($accept_header, array $available_formats) { if (empty($available_formats)) { throw new \Asar\ContentNegotiator\Exception( ...
PHP
<?php namespace Asar; use \Asar\FileSearcher\FileSearcherInterface; /** */ class FileSearcher implements FileSearcherInterface { function find($file_path) { if ($this->isAbsolutePath($file_path)) { if (is_file($file_path)) { return $file_path; } else { return false; } }...
PHP
<?php namespace Asar; use \Asar\Request; /** */ class RequestFactory { function createRequest($server = array(), $params = array(), $post = null) { $options = array(); $options['method'] = $this->getIfExists('REQUEST_METHOD', $server); $options['path'] = $this->getIfExists('REQUEST_URI', $server); ...
PHP
<?php class Asar_Sniffs_WhiteSpace_ScopeClosingBraceSniff implements PHP_CodeSniffer_Sniff { /** * Returns an array of tokens this test wants to listen for. * * @return array */ public function register() { return PHP_CodeSniffer_Tokens::$scopeOpeners; }//end register() ...
PHP
<?php require_once 'PHP/CodeSniffer/Standards/PEAR/Sniffs/' . 'Functions/FunctionCallSignatureSniff.php'; class Asar_Sniffs_Functions_FunctionCallSignatureSniff extends PEAR_Sniffs_Functions_FunctionCallSignatureSniff { function processMultiLineCall( PHP_CodeSniffer_File $phpcsFile, $stackPtr, $openBr...
PHP
<?php $main_app = 'Sample';
PHP
<?php class Sample_Resource_Index extends Asar_Resource { function GET() { return array('h1' => "Hello World!"); } }
PHP
<?php class Sample_Resource_Redirect extends Asar_Resource { function GET() { $this->redirectTo('/'); } }
PHP
<?php class Sample_Resource_Hello extends Asar_Resource { function GET() { return "Hello there!"; } }
PHP
<?php class Sample_Application extends Asar_Application { }
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 : 'Sample App'?></title> </head> <body> <?php echo $content ?> </...
PHP
<h1><?= $h1 ?></h1> <p>Blalalkajdf;jasd;</p>
PHP
<?php /* set_include_path( realpath(dirname(__FILE__) . '/../../../lib/core') . PATH_SEPARATOR . realpath(dirname(__FILE__) . '/../apps') . PATH_SEPARATOR . realpath(dirname(__FILE__) . '/../lib/vendor') . PATH_SEPARATOR . get_include_path() );*/ require_once realpath(dirname(__FILE__) . '/../../../lib/core/Asa...
PHP
<?php class Agtd_Resource_Index extends Asar_Resource { function GET() { } }
PHP
<?php class Agtd_Application extends Asar_Application { }
PHP
<?php set_include_path( realpath(dirname(__FILE__) . '/../apps') . PATH_SEPARATOR . realpath(dirname(__FILE__) . '/../vendor') . PATH_SEPARATOR . get_include_path() ); require_once 'Asar.php'; Asar::start('Agtd');
PHP
<?php $main_app = 'Agtd';
PHP
<?php /* mysql_stats.php * enables cacti to read mysql statistics * by berger@hk-net.de 2005/01/18 * * usage: * mysql_stats.php section db_host db_user db_password [status_var] * sections: * cache, command, handler, thread, traffic, status */ if ($_SERVER["argc"] == 5 || ($_SERVER["argv"][1] == "stat...
PHP