コード例 #1
0
ファイル: GRAPH.php プロジェクト: tdt/formatters
 /**
  * Print the body
  */
 public function printBody()
 {
     // Check the data first
     $this->checkData();
     // Get template to render
     $template = file_get_contents(__DIR__ . "/../../../../includes/templates/graph");
     // Get flotjs
     $data['flotjs'] = file_get_contents(__DIR__ . "/../../../../includes/js/flot.min.js");
     // Set data
     $data['data'] = $this->getData();
     $values = explode(',', $_GET['values']);
     if (count($values) > 1) {
         $data['title'] = "Chart for the properties '" . implode(', ', $values) . "'";
     } else {
         $data['title'] = "Chart for the property '" . trim($_GET['values']) . "'";
     }
     // Check graph type
     $type = $_GET['type'];
     if (!(!empty($type) && in_array($type, $this->types))) {
         $type = "lines";
     }
     $data['type'] = $type;
     $body = $this->m->render($template, $data);
     // Use the pages generator
     $generator = new Generator();
     $generator->generate($body);
 }
コード例 #2
0
ファイル: HTML.php プロジェクト: tdt/formatters
 public function printBody()
 {
     $generator = new Generator();
     $output = $this->displayTree($this->objectToPrint);
     $h = headers_list();
     $i = 0;
     $matches = array();
     while ($i < sizeof($h) && !preg_match("/Link: (.+);rel=next.*/", $h[$i], $matches)) {
         $i++;
     }
     if ($i < sizeof($h)) {
         //$output .= "<p class='nextpage'><a href='". $matches[1] ."'>Next page</a></p>";
     }
     $generator->generate($output, 'resource');
 }
コード例 #3
0
ファイル: AStrategy.php プロジェクト: Tjoosten/formatters
 /**
  * This function will print the body of the responsemessage when the object is a graph.
  */
 public function printGraph()
 {
     set_error_header(453, "RDF not supported");
     $generator = new Generator($this->rootname . " - formatter cannot process RDF");
     $body = "";
     $body .= "<h1>Formatter doesn't support RDF</h1>";
     $body .= "<p>We don't have a triple output for this formatter yet. This is a best effort in HTML.</p>";
     $body .= "<p>There are plenty of RDF formatters which do work however. Check .ttl or .json for instance.</p>";
     $rn = $this->rootname;
     $body .= "<table border=3>";
     $body .= "<tr><td>subject</td><td>predicate</td><td>object</td></tr>";
     foreach ($this->objectToPrint->{$rn}->triples as $triple) {
         $body .= "<tr><td>" . $triple["s"] . "</td>";
         $body .= "<td>" . $triple["p"] . "</td>";
         $body .= "<td>" . $triple["o"] . "</td>";
         $body .= "</tr>";
     }
     $body .= "</table>";
     $h = headers_list();
     $i = 0;
     $matches = array();
     while ($i < sizeof($h) && !preg_match("/Link: (.+);rel=next.*/", $h[$i], $matches)) {
         $i++;
     }
     if ($i < sizeof($h)) {
         $body .= "<p class='nextpage'><a href='" . $matches[1] . "'>Next page</a></p>";
     }
     $generator->generate($body);
 }
コード例 #4
0
ファイル: index.php プロジェクト: tdt/pages
<?php

include_once "../vendor/autoload.php";
use tdt\pages\Generator;
// Set base URL for public folder
$config['baseURL'] = '../public/';
// Create a new generator
$generator = new Generator($config);
// Set title
$generator->setTitle("This is an example page");
// Add a javascript library
// $generator->addJS("http://....js");
// Add some CSS
// $generator->addCSS("http://....css");
// Add a menu item: title, url, weight, active, open in new window
$generator->addMenuItem("This page", "http://thedatatank.com", false, true);
$generator->addMenuItem("This page", "#", true, false);
$generator->addMenuItem("This page", "#", false, false);
// Body
$body = '
<h1>Hello World!</h1>
<table class="table">
    <thead>
        <th>Subject</th>
        <th>Object</th>
        <th>Predicate</th>
    </thead>
    <tr>
        <td>subject</td>
        <td>object</td>
        <td>predicate</td>
コード例 #5
0
ファイル: router.php プロジェクト: tdt/start
$routes = array();
// Drop the HTTP method from the route
foreach ($allroutes as $route => $controller) {
    $route = preg_replace('/^' . strtoupper($_SERVER['REQUEST_METHOD']) . '(\\s|\\t)*\\|(\\s|\\t)*/', "", trim($route));
    $routes[trim($route)] = trim($controller);
}
//$log->logInfo("The routes we are working with", $routes);
try {
    // This function will do the magic.
    Glue::stick($routes);
} catch (Exception $e) {
    // Instantiate a Logger
    $log = new Logger('router');
    $log->pushHandler(new StreamHandler(app\core\Config::get("general", "logging", "path") . "/log_" . date('Y-m-d') . ".txt", Logger::ERROR));
    // Generator to generate an error page
    $generator = new Generator();
    $generator->setTitle("The DataTank");
    if ($e instanceof tdt\exceptions\TDTException) {
        // DataTank error
        $log->addError($e->getMessage());
        set_error_header($e->getCode(), $e->getShort());
        if ($e->getCode() < 500) {
            $generator->error($e->getCode(), "Sorry, but there seems to be something wrong with the call you've made", $e->getMessage());
        } else {
            $generator->error($e->getCode(), "Sorry, there seems to be something wrong with our servers", "If you're the system administrator, please check the logs. Otherwise, check back in a short while.");
        }
    } else {
        // General error
        $log->addCritical($e->getMessage());
        set_error_header(500, "Internal Server Error");
        $generator->error($e->getCode(), "Sorry, there seems to be something wrong with our servers", "If you're the system administrator, please check the logs. Otherwise, check back in a short while.");