예제 #1
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();
}
예제 #2
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();
 }
예제 #3
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();
 }
예제 #4
0
$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();