예제 #1
0
파일: Page.php 프로젝트: sledgehammer/mvc
 /**
  * Vraag de headers op en werk de interne headers array bij.
  *
  * @return array
  */
 public function getHeaders()
 {
     $headers = array('http' => array('Content-Type' => $this->contentType), 'charset' => Framework::$charset, 'htmlParameters' => array(), 'bodyParameters' => array());
     if (defined('Sledgehammer\\WEBPATH') && \Sledgehammer\WEBPATH != '/' && file_exists(\Sledgehammer\PATH . 'application/public/favicon.ico')) {
         $headers['link']['favicon'] = array('rel' => 'shortcut icon', 'href' => \Sledgehammer\WEBROOT . 'favicon.ico', 'type' => 'image/x-icon');
     }
     // $headers['http']['Content-Type'] = 'application/xhtml+xml';
     if (ErrorHandler::instance()->html) {
         $headers['css']['debug'] = \Sledgehammer\WEBROOT . 'core/css/debug.css';
     }
     $this->headers = \Sledgehammer\merge_headers($headers, $this->content);
     if (empty($this->headers['title'])) {
         notice('getHeaders() should contain a "title" element for a HTMLDocument');
     }
     return $this->headers;
 }
예제 #2
0
<?php

/**
 * Install a PEAR package into the /verdor/pear/ folder.
 */
namespace Sledgehammer\Core;

use Sledgehammer\Core\Debug\Autoloader;
use Sledgehammer\Core\Debug\ErrorHandler;
require __DIR__ . '/../bootstrap.php';
ErrorHandler::instance()->html = false;
ErrorHandler::instance()->cli = true;
Autoloader::instance()->importFolder(__DIR__ . '/classes');
if ($argc < 2) {
    echo '  Usage: php ' . $argv[0] . " [channel] [channel/]package[-version] ...\n ";
    echo "  Examples:\n";
    echo '    php ' . $argv[0] . " pear.phpunit.de/PHPUnit\n";
    echo '    php ' . $argv[0] . " PhpDocumentor\n";
    echo '    php ' . $argv[0] . " pear.doctrine-project.org DoctrineORM CouchDB-alpha DoctrineCommon-2.1.2\n";
    echo "\n";
    exit(1);
}
$targets = array('php' => \Sledgehammer\PATH . 'vendor/pear/php', 'data' => \Sledgehammer\PATH . 'vendor/pear/data', 'script' => \Sledgehammer\PATH . 'vendor/pear/script', 'bin' => \Sledgehammer\PATH . 'vendor/pear/bin', 'doc' => \Sledgehammer\PATH . 'vendor/pear/docs', 'www' => APP_DIR . 'vendor/pear/www');
$pear = new PearInstaller($targets);
$pear->on('channelAdded', function ($sender, $domain, $channel) {
    echo 'Channel "' . $domain . '" loaded. (' . count($channel['packages']) . " packages)\n";
});
$pear->on('installed', function ($sender, $package, $version) {
    echo '  ' . $package . ' [' . $version . "] installed.\n";
});
unset($argv[0]);
예제 #3
0
파일: Json.php 프로젝트: sledgehammer/core
 /**
  * Reports the error/exception to the ErrorHandler and returns the error as Json object.
  * The javascript client should detect and report the error to the user:
  *   if (result.success !== true) { alert(result.error); }.
  *
  * @param string|Exception $error The error message or Exception
  * @param int              $http  The HTTP status code (defaults to 400 Bad Request)
  *
  * @return Json
  */
 public static function error($error, $http = 400)
 {
     if (headers_sent() === false && DebugR::isEnabled()) {
         ErrorHandler::instance()->html = false;
     }
     if ($error instanceof Exception) {
         \Sledgehammer\report_exception($error);
         $error = $error->getMessage();
     } else {
         \Sledgehammer\warning($error);
     }
     return new self(array('success' => false, 'error' => $error), array('http' => array('Status' => $http . ' ' . Framework::$statusCodes[$http], 'Content-Type' => ErrorHandler::instance()->html ? 'text/html;  charset=utf-8' : 'application/json')));
 }
예제 #4
0
 /**
  * Report deprecated functionality.
  *
  * @param string $message     The message
  * @param mixed  $information [optional] Additional information
  */
 function deprecated($message = 'This functionality will no longer be supported in upcomming releases', $information = null)
 {
     ErrorHandler::instance()->report(E_USER_DEPRECATED, $message, $information, true);
 }