From e0a5561fda74908f19166844da6e08a6c02ff0e1 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 18 Mar 2012 11:52:54 +0000 Subject: o Adding html templates. --- Templates.class.php | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 Templates.class.php (limited to 'Templates.class.php') diff --git a/Templates.class.php b/Templates.class.php new file mode 100644 index 0000000..9cfec4f --- /dev/null +++ b/Templates.class.php @@ -0,0 +1,120 @@ + +Number of queues: . + +toPlainText($url_generator) . "\n"); + } +} + +function template_queue_list_html(UrlGenerator $url_generator, array $queues) { + html_default(apply("render_queues", $url_generator, $queues)); +} + +function render_queues($url_generator, $queues) { + $count = count($queues); +?> +

+Number of queues: . +

+ +toHtml($url_generator, FALSE) . "\n"); + } +} + + +// Queue + +function template_queue_html(UrlGenerator $url_generator, Queue $queue) { + html_default(apply("render_queue_html", $url_generator, $queue)); +} + +function render_queue_html(UrlGenerator $url_generator, Queue $queue) { + echo url_to_a($url_generator->queues(), "All queues"); + echo $queue->toHtml($url_generator, TRUE); +} + +function template_queue_text(UrlGenerator $url_generator, Queue $queue) { + echo($queue->toPlainText($url_generator)); +} + +// Item List + +function template_item_list_html(UrlGenerator $url_generator, $queue, array $items) { + html_default(apply("render_item_list_html", $url_generator, $queue, $items)); +} + +function render_item_list_html(UrlGenerator $url_generator, $queue, array $items) { + $queue_url = url_to_a($url_generator->queue($queue)); + $html = + "

Items in $queue

" . + ""; + echo $html; + + foreach($items as $item) { + echo($item->toHtml($url_generator)); + } +} + +function template_item_list_text(UrlGenerator $url_generator, $queue, array $items) { + echo("This queue has " . count($items) . " items.\n"); + echo("\n"); + + foreach($items as $item) { + echo($item->toPlainText($url_generator)); + echo("\n"); + } +} + +// Common + +function invoke($f) { + if(is_callable($f)) { + $f(); + } + else { + echo($f); + } +} + +function html_default($body, $head = NULL) { +?> + + + + + + + + + -- cgit v1.2.3