/**
 * Returns the algorithm examples, source code and docblock
 *
 * @param  string $algorithm
 * @return array
 */
function get_algorithm_details($algorithm)
{
    $filename = str_replace('_', '-', $algorithm) . '.php';
    $examples = get_examples($filename);
    $source_code = get_source_code($filename);
    $docblock = get_docblock($algorithm, $source_code);
    return array($filename, $examples, $source_code, $docblock);
}
 protected function examples()
 {
     global $db;
     $params = array();
     if ($this->method == "GET") {
         if (sizeof($this->args) == 0) {
             return get_examples($db, $params);
         } else {
             return "This returns all sections, therefore no parameters are taken!";
         }
     } else {
         return "This only accepts GET requests!";
     }
 }
Esempio n. 3
0
<?php

error_reporting(E_ALL | E_NOTICE);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
set_time_limit(0);
require_once __DIR__ . '/get_examples.php';
require_once __DIR__ . '/../vendor/autoload.php';
if (!isset($_GET['name'])) {
    echo 'Available examples:<br />';
    $examples = get_examples();
    echo '<ul>';
    foreach ($examples as $example) {
        echo '<li>' . $example . ' (<a href="?name=' . $example . '">pdf</a> or <a href="?name=' . $example . '&engine=image">image</a>)';
    }
    echo '</ul>';
    exit;
}
$engine = isset($_GET['engine']) ? $_GET['engine'] : 'pdf';
// set different way of configuration
//$facade = PHPPdf\Core\FacadeBuilder::create(new PHPPdf\Core\Configuration\DependencyInjection\LoaderImpl())//->setCache('File', array('cache_dir' => __DIR__.'/cache/'))
$facade = PHPPdf\Core\FacadeBuilder::create()->setEngineType($engine)->setEngineOptions(array('format' => 'jpg', 'quality' => 70, 'engine' => 'imagick'))->build();
$name = basename($_GET['name']);
$documentFilename = __DIR__ . '/' . $name . '.xml';
$stylesheetFilename = __DIR__ . '/' . $name . '-style.xml';
if (!is_readable($documentFilename)) {
    die(sprintf('Example "%s" dosn\'t exist.', $name));
}
$xml = str_replace('dir:', __DIR__ . '/', file_get_contents($documentFilename));
$stylesheetXml = is_readable($stylesheetFilename) ? str_replace('dir:', __DIR__ . '/', file_get_contents($stylesheetFilename)) : null;
$stylesheet = $stylesheetXml ? PHPPdf\DataSource\DataSource::fromString($stylesheetXml) : null;
Esempio n. 4
0
if (empty($opts['p']) || empty($opts['t'])) {
    echo "\nInfo: Both -p (phpdoc path) and -t (temporary directory) must be set\n";
    usage();
}
if (!is_dir($opts['p']) || !is_dir($opts['t'])) {
    trigger_error('Unknown directory passed in', E_USER_WARNING);
    usage();
}
$tmpdir = $opts['t'];
$path = $opts['p'];
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)) as $file) {
    $filename = $file->getPathname();
    if (!$file->isFile() || pathinfo($filename, PATHINFO_EXTENSION) !== 'xml' || is_known_failure($filename)) {
        continue;
    }
    $examples = get_examples($filename);
    if ($examples) {
        foreach ($examples as $example) {
            $parsed_example = validate_example($example, "{$tmpdir}/phplint{$_SERVER['REQUEST_TIME']}.php");
            if (isset($parsed_example['error_line_num'])) {
                $errors[] = $parsed_example;
            }
        }
    }
}
if (empty($errors)) {
    echo "No errors were found in examples!\n";
    exit;
} else {
    $o = '';
    foreach ($errors as $error) {