Example #1
0
 /**
  * The constructor takes care of the page contents.
  */
 function __construct()
 {
     parent::__construct();
     $text = 'this page intentionally left blank';
     $this->set('title', $text);
     $link = ax_a_href($text, 'http://www.this-page-intentionally-left-blank.org/whythat.html', array('style' => 'color:black; text-decoration:none;'));
     $paragraph = ax_p($link, array('style' => 'position: absolute; right: 4em; bottom: 2em; font-size: small;'));
     $this->append($paragraph);
 }
Example #2
0
 function SsscrapeMonitor()
 {
     AnewtPage::AnewtPage();
     /* Provide a list of blocks */
     $this->set('blocks', array('header', 'content', 'footer'));
     /* Set some default values */
     $this->set('title', 'Ssscrape monitor');
     $this->set('default-block', 'content');
     $this->add_stylesheet_href('style.css');
     $this->init_db();
 }
    function __construct()
    {
        /* Call the parent constructor */
        AnewtPage::__construct();
        /* Add stylesheets */
        $this->add_stylesheet_href('style.css');
        $this->add_stylesheet_href_media('print.css', 'print');
        /* Link to an external JavaScript file */
        $this->add_javascript_src('some-script.js');
        /* Embed JavaScript code directly */
        $this->add_javascript_content('function foo() {
				alert("foo");
			}');
        /* Provide a list of blocks */
        $this->blocks = array('header', 'content', 'footer');
        /* Set some default values */
        $this->title = 'This is the default title';
    }
Example #4
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();
 }
Example #5
0
    }
    if (str_has_prefix($arg, '--')) {
        continue;
    }
    $fd = fopen($arg, 'r');
    $title = $arg;
    break;
}
/* Input */
$input_chunks = array();
while (!feof($fd)) {
    $input_chunks[] = fread($fd, 16384);
}
$input = join('', $input_chunks);
fclose($fd);
/* Output */
$output = TextFormatter::format($input, 'textile');
$output = trim($output);
if ($use_page) {
    anewt_include('page');
    $page = new AnewtPage();
    $page->enable_dublin_core = false;
    $page->content_type = 'application/xhtml+xml';
    $page->charset = 'UTF-8';
    $page->title = $title;
    $page->add_stylesheet_href_media('style.css', 'screen');
    $page->append(ax_raw($output));
    echo to_string($page), NL;
} else {
    echo $output, NL;
}
Example #6
0
<?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();
Example #7
0
<?php

anewt_include('page');
$p = new AnewtPage();
$p->set('title', 'Sample page');
$p->flush();
Example #8
0
        $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();
}
Example #9
0
<?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();
Example #10
0
$select->append_child(new AnewtXHTMLOption('Second', array('value' => 'second')));
$select->append_child(new AnewtXHTMLOption('Third', array('value' => 'third')));
$form->append_child(new AnewtXHTMLParagraph($select));
$fragment->append_child($form);
$form->append_child(new AnewtXHTMLParagraph(new AnewtXHTMLInput(null, array('type' => 'submit'))));
/* Convenience API */
$r = array();
$r[] = ax_h2('Convenience API');
$r[] = ax_p('Test with some <& special characters.', array('style' => 'color: #ccc;'));
$r[] = ax_p_class(ax_raw('This is <strong>strong</strong>'), 'someclass');
$r[] = ax_p(ax_abbr('ICE', 'InterCity Express'));
$r[] = ax_p(array('Test', ax_br(), 'after the break'));
$p = ax_p(array('testje', array('1', '2'), ax_strong('blablabla')));
$p->set_attribute('id', 'paragraph-id');
$p->set_class('foo bar baz');
$p->remove_class('bar');
$p->add_class('quux');
$p->append_child(ax_a_href('name', '/url/'));
$r[] = $p;
$r[] = ax_p(ax_sprintf('%s & %s', ax_span_class('Sugar', 'sweet'), 'Spice'));
$r[] = ax_p(ax_vsprintf('%s & %s', array(ax_span_class('Sugar', 'sweet'), 'Spice')));
$values = array('this', ax_strong('is'), 'a', ax_span('test'));
$r[] = ax_p(ax_join(', ', $values));
$r[] = ax_p(ax_join(ax_em(' & '), $values));
$fragment->append_child(ax_fragment($r, ax_p('final paragraph')));
/* Final output */
anewt_include('page');
$page = new AnewtPage();
$page->title = 'Anewt XHTML output test';
$page->append($fragment);
$page->flush();
Example #11
0
<?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();
Example #12
0
<?php

anewt_include('page');
$p = new AnewtPage();
$p->title = 'This is the title of the page';
$p->flush();
Example #13
0
 function MyPage()
 {
     AnewtPage::AnewtPage();
     $this->set('blocks', array('header', 'content', 'footer'));
 }
Example #14
0
<?php

$p = new AnewtPage();
$p->append(ax_p('This is a paragraph of text.'));
$p->append(ax_raw('<p>This is some <code>pre-formatted</code> text.</p>'));
$p->append('This string will be escaped: <, &, and > are no problem!');
$p->flush();
Example #15
0
        $button_fieldset->add_control($submit2);
        $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.'));
}
Example #16
0
<?php

anewt_include('page');
$p = new AnewtPage();
$p->blocks = array('header', 'content', 'footer');
$p->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();
Example #17
0
<?php

anewt_include('page');
$p = new AnewtPage();
$p->append(ax_h1('Hello, world!'));
$p->append(ax_p('This is a simple test page.'));
$p->flush();
Example #18
0
 /**
  * \private
  *
  * Show a simple error page.
  *
  * \param $exception
  *   The AnewtHTTPException instance
  */
 protected function show_error_page($exception)
 {
     assert('$exception instanceof Exception;');
     anewt_include('page');
     $p = new AnewtPage();
     $p->show_dublin_core = false;
     /* Title */
     if ($exception instanceof AnewtHTTPException) {
         $title = sprintf('%d - %s', $exception->getCode(), http_status_to_string($exception->getCode()));
     } else {
         $title = sprintf('%d - %s', HTTP_STATUS_INTERNAL_SERVER_ERROR, http_status_to_string(HTTP_STATUS_INTERNAL_SERVER_ERROR));
     }
     $p->title = $title;
     $p->append(ax_h1($title));
     /* Add default explanation (instead of just a title) for some exceptions. */
     $message = $exception->getMessage();
     if ($message) {
         $p->append(ax_p($message));
     } else {
         switch ($exception->getCode()) {
             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;
             case HTTP_STATUS_INTERNAL_SERVER_ERROR:
                 $p->append(ax_p('An internal server error occurred while processing your request.'));
                 break;
             default:
                 break;
         }
     }
     /* Backtrace */
     $p->append(ax_pre($exception->getTraceAsString()));
     $p->flush();
 }
Example #19
0
 function __construct()
 {
     parent::__construct();
     $this->set('blocks', array('header', 'main', 'footer'));
 }
Example #20
0
 function __construct()
 {
     AnewtPage::__construct();
     $this->blocks = array('header', 'content', 'footer');
 }