コード例 #1
0
 /**
  * \private
  *
  * Show a simple error page.
  *
  * \param $http_status_code
  *   The http status code.
  */
 function _show_error_page($http_status_code)
 {
     anewt_include('page');
     $title = sprintf('%d - %s', $http_status_code, http_status_to_string($http_status_code));
     $p = new AnewtPage();
     $p->set('show-dublin-core', false);
     $p->set('title', $title);
     $p->append(ax_h1($title));
     switch ($http_status_code) {
         case HTTP_STATUS_NOT_FOUND:
             $p->append(ax_p('The requested resource cannot be found.'));
             break;
         case HTTP_STATUS_FORBIDDEN:
             $p->append(ax_p('Access to the requested resource was denied.'));
             break;
         default:
             /* No explanation (just a title) */
             break;
     }
     $p->flush();
 }
コード例 #2
0
ファイル: image.test.php プロジェクト: jijkoun/ssscrape
        $ctx1->draw_filled_rectangle_size(3, 3, 4, 3);
        $ctx1->set('color', $img->color_from_string('#969'));
        $ctx1->draw_rectangle(3, 3, 6, 7);
        $ctx1->draw_filled_rectangle_size(15, 2, 2, 2);
        $ctx1->draw_filled_rectangle_size(15, 2, -1, -1);
        $col = $img->color_from_string('#36c');
        $ctx1->set('color', $col);
        $ctx1->draw_filled_rectangle(20, 2, 18, 3);
        assert('$ctx1->color_at(19, 2) == $col');
        /* Blow up so we can count the pixels in the result */
        $img->resize_relative(10, false);
        $img->flush_png();
        $img->destroy();
    }
}
$test = AnewtRequest::get_string('test');
if (is_null($test)) {
    /* Show test chooser */
    anewt_include('page');
    $p = new AnewtPage();
    $p->set('title', 'Choose a test');
    $p->append(ax_h1('Choose a test'));
    foreach (get_class_methods('AnewtImageTestCases') as $name) {
        $url = AnewtURL::build(AnewtRequest::relative_url(), array('test' => $name));
        $p->append(ax_p(ax_a_href(sprintf('Test: %s', $name), $url)));
    }
    $p->flush();
} else {
    /* Invoke test function */
    AnewtImageTestCases::$test();
}
コード例 #3
0
ファイル: grid.test.php プロジェクト: jijkoun/ssscrape
<?php

require_once dirname(__FILE__) . '/../../anewt.lib.php';
anewt_include('page');
anewt_include('renderer/grid');
$grid = new AnewtGridRenderer();
$column = new AnewtGridColumn('col-2', 'Second column', 2);
$grid->add_column($column);
$column = new AnewtGridColumn('somecol', 'First column', 1);
$cell_renderer = new AnewtGridCellRenderer('col-1a', 'Column 1a');
$cell_renderer->set('title', 'Column 1a');
$column->add_cell_renderer($cell_renderer);
$cell_renderer = new AnewtGridCellRenderer('col-1b', 'Column 1b');
$cell_renderer->set('title', 'Column 1b');
$column->add_cell_renderer($cell_renderer);
$grid->add_column($column);
$rows = array(array('col-1a' => 'r1c1a', 'col-1b' => 'r1c1b', 'col-2' => 'r1c2'), array('col-1a' => 'r2c1a', 'col-1b' => 'r2c1b', 'col-2' => 'r2c2'));
$grid->set_rows($rows);
$grid->add_row(array('col-1a' => 'r3c1a', 'col-2' => 'r3c2'));
$p = new AnewtPage();
$p->set('title', 'Anewt Grid Renderer');
$p->append($grid);
$p->flush();
コード例 #4
0
ファイル: page-basic-usage.php プロジェクト: jijkoun/ssscrape
<?php

anewt_include('page');
$p = new AnewtPage();
$p->set('title', 'Sample page');
$p->flush();
コード例 #5
0
ファイル: page-blocks.php プロジェクト: jijkoun/ssscrape
<?php

anewt_include('page');
$p = new AnewtPage();
$p->set('blocks', array('header', 'content', 'footer'));
$p->set('default-block', 'content');
/* Add content to specific blocks */
$p->append_to('header', ax_p('This is the header text.'));
$p->append_to('footer', ax_p('This is the footer text.'));
/* Add content to the default block */
$p->append(ax_h1('Hello, world!'));
$p->append(ax_p('This is a simple test page.'));
/* You can add content to the default block using append_to() as well, but that
 * involves a bit more typing. */
$p->append_to('content', ax_p('Another paragraph.'));
$p->flush();
コード例 #6
0
ファイル: textile.test.php プロジェクト: jijkoun/ssscrape
<?php

require_once dirname(__FILE__) . '/../anewt.lib.php';
define('ANEWT_TEXTILE_DEVELOPMENT', 1);
anewt_include('page');
$p = new AnewtPage();
$p->set('title', 'Textile formatting test');
if (AnewtRequest::get_bool('debug')) {
    header('Content-type: text/plain');
    $p->set('content_type', 'text/plain');
} else {
    list($base_url, $params) = AnewtUrl::parse(AnewtRequest::url());
    $params['debug'] = '1';
    $debug_url = AnewtUrl::build(array($base_url), $params);
    $p->append(ax_p(ax_a_href('(Page source for debugging)', $debug_url)));
}
anewt_include('textformatting');
anewt_include('textile');
$text = file_get_contents(dirname(__FILE__) . '/sample-text.txt');
$formatted_text = TextFormatter::format($text, 'textile');
$p->append(ax_raw($formatted_text));
$p->flush();
コード例 #7
0
ファイル: form.test.php プロジェクト: jijkoun/ssscrape
        $submit = new AnewtFormControlButtonSubmit('submit3');
        $submit->set('label', 'Another submit button');
        $button_fieldset->add_control($submit);
        $reset = new AnewtFormControlButtonReset('reset');
        $reset->set('label', 'Reset to default values');
        $reset->set('help', 'Reset the values of the form fields to their original values');
        $button_fieldset->add_control($reset);
        $extra = new AnewtFormControlButton('extra-button');
        $extra->set('label', 'Extra button that does not do anything');
        $button_fieldset->add_control($extra);
        $this->add_fieldset($button_fieldset);
    }
}
/* Show a page and test the form */
$page = new AnewtPage();
$page->set('title', 'Anewt form test page');
$page->add_stylesheet(ax_stylesheet($css));
$page->append(ax_h1('Test form'));
$form = new TestForm();
assert('$form->get_control_value("text5") === "7"');
$form->set_control_value('text5', '8');
if ($form->autofill()) {
    if ($form->process()) {
        $page->append(ax_p('Form succesfully processed!'));
    } else {
        $page->append(ax_p('Error while processing form!'));
    }
} else {
    $page->append(ax_p('Form not processed.'));
}
$fr = new AnewtFormRendererDefault();