Example #1
0
 function show()
 {
     $this->count_task_types('ssscrapecontrol.ssscrape_task');
     $q = "SELECT t.id, t.type, program, args, state, hostname, periodicity, \n                     latest_run, resource_id resource, \n                     f.url, f.id feed_id, '' jobs                \n              FROM ssscrapecontrol.ssscrape_task t \n                   LEFT JOIN ssscrape_feed f ON f.url=REPLACE(REPLACE(t.args, '-u ', ''), \"'\", '')\n              ?where?";
     $this->m->append(ax_p(ax_a_href("Create new task", "editor/?show=tasks&id=NEW")));
     $this->run_query($q);
 }
Example #2
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 #3
0
 function show()
 {
     $items = array();
     foreach ($this->pages as $page) {
         if ($page['name'] != 'home') {
             $item =& ax_li(array(ax_a_href(ucfirst($page['name']), $this->m->make_url(array('show' => $page['name']))), ": " . $page['descr']));
             array_push($items, $item);
         }
     }
     $this->m->append(ax_ul($items));
 }
Example #4
0
<?php

require_once dirname(__FILE__) . '/../anewt.lib.php';
anewt_include('page');
class TestPage extends AnewtPage
{
    function __construct()
    {
        parent::__construct();
        $this->set('blocks', array('header', 'main', 'footer'));
    }
    function build_header()
    {
        return ax_fragment(array(ax_p('Header line 1'), ax_p('Header line 2')));
    }
}
$p = new TestPage();
$p->title = 'Anewt Page test';
$p->default_block = 'main';
$p->add_stylesheet_href('1.css');
$p->add_stylesheet_href('2.css');
$p->add_stylesheet(ax_stylesheet_href('3.css'));
$p->add_stylesheet(ax_stylesheet_href_media('screen.css', 'screen'));
$p->add_stylesheet_href_media('print.css', 'print');
$p->add_javascript_content('function test() {alert("test");}');
$p->add_javascript_src('foo.js');
$p->append_to('main', ax_h1('Title'));
$p->append(ax_p('Test paragraph'));
$p->append(ax_p(ax_a_href('Click me!', 'javascript:test()')));
$p->append_to('footer', ax_p('This is the footer text'));
$p->flush();
Example #5
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 #6
0
 /**
  * Renders the cell.
  *
  * \param $data
  *   Data to pack into the cell
  *
  * \return
  *   Rendered cell
  */
 function render_cell($data)
 {
     $value = $this->fetch_value_from_data($data);
     assert('is_numeric_array($value)');
     assert('count($value) == 2');
     list($name, $url) = $value;
     assert('is_string($name)');
     assert('is_string($url)');
     return $this->create_td(ax_a_href($name, $url));
 }
Example #7
0
 function make_results_summary($nrows, $more_results)
 {
     $nav = array();
     if ($this->offset > 0) {
         $prev_offset = $this->offset - $this->limit;
         if ($prev_offset < 0) {
             $prev_offset = 0;
         }
         array_push($nav, ax_a_href(ax_raw("&laquo; Previous " . $this->limit . " results"), $this->make_url(1, array('offset' => $prev_offset))));
         array_push($nav, " | ");
     }
     array_push($nav, $nrows . " results");
     if ($more_results) {
         array_push($nav, " | ");
         array_push($nav, ax_a_href(ax_raw("Next " . $this->limit . " results &raquo;"), $this->make_url(1, array('offset' => $this->offset + $this->limit))));
     }
     $nav =& ax_p($nav);
     return $nav;
 }
Example #8
0
<?php

$div = ax_blockquote(ax_p('Some text in a blockquote.'));
$div = ax_blockquote(array(ax_p('Some text in a blockquote.'), ax_p('Another paragraph in the same blockquote.')));
$p = ax_p(array('This is a ', ax_a_href('hyperlink', 'http://anewt.net'), ' inside some text.'));
Example #9
0
$fragment->append_child(new AnewtXHTMLHeader2('Forms'));
$form = new AnewtXHTMLForm(null, array('method' => 'GET'));
$input_fragment = new AnewtXHTMLFragment();
$input_fragment->append_child(new AnewtXHTMLLabel('Label: ', array('for' => 'test')));
$input_fragment->append_child(new AnewtXHTMLInput(null, array('name' => 'test', 'id' => 'test', 'type' => 'text')));
$form->append_child(new AnewtXHTMLParagraph($input_fragment));
$select = new AnewtXHTMLSelect(null, array('name' => 'select'));
$select->append_child(new AnewtXHTMLOption('First', array('value' => 'first')));
$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'));
$fragment->append_child(ax_fragment($r, ax_p('final paragraph')));
/* Final output */
echo to_string($fragment), NL;
Example #10
0
 function show()
 {
     $q = "SELECT f.id, f.url, f.title, t.id task, t.periodicity periodicity, t.state task_state, m.kind, m.tags, f.mod_date, \n                     count(i.feed_id) items, count(i.feed_id)-count(i.content_clean) errors, f.id 2_weeks\n              FROM ssscrape.ssscrape_feed f \n                   LEFT JOIN ssscrape_feed_metadata m ON f.id=m.feed_id \n                   LEFT JOIN (SELECT feed_id, content_clean \n                              FROM ssscrape_feed_item \n                              WHERE ?temp-constraint?) i \n                        ON f.id=i.feed_id \n                   LEFT JOIN ssscrapecontrol.ssscrape_task t ON LOCATE(f.url, t.args)\n              ?where?\n              GROUP BY f.id";
     $this->m->append(ax_p(ax_a_href("Create new feed", "editor/?show=feeds&id=NEW")));
     $this->run_query($q, 'pub_date');
 }
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
 function build_widget()
 {
     $value = $this->_get('value');
     if (is_null($value)) {
         $value = "";
     }
     assert('is_string($value); // only plain strings can be used as field value: type: ' . gettype($value));
     $name = $this->get('name');
     $widgets = array();
     if ($this->get('show-img-preview') && $value) {
         $widgets[] = ax_div_class(ax_img_src($this->get('preview-dir') . $value), 'preview');
     } elseif ($this->get('show-link-preview') && $value) {
         $widgets[] = ax_div_class(ax_a_href($value, $this->get('preview-dir') . $value), 'preview');
     }
     $remove_label = $this->_get('remove-label');
     if ($remove_label && $value) {
         $subattr = array('type' => 'checkbox', 'name' => $name . '-remove');
         $widgets[] = new AnewtXHTMLInput(null, $subattr);
         $subattr = array('for' => $name . '-remove');
         $widgets[] = new AnewtXHTMLLabel($remove_label, $subattr);
         $widgets[] = ax_br();
     }
     /* XML tag attributes used both for single line and multiline */
     $attr = array('name' => $this->get('name'), 'id' => $this->get('id'), 'type' => 'file');
     if ($this->_get('readonly')) {
         $attr['readonly'] = 'readonly';
     }
     if ($this->_get('disabled')) {
         $attr['disabled'] = 'disabled';
     }
     $size = $this->_get('size');
     if (!is_null($size)) {
         assert('is_int($size);');
         $attr['size'] = (string) $size;
     }
     $maxlength = $this->_get('maxlength');
     if (!is_null($maxlength)) {
         assert('is_int($maxlength);');
         $attr['maxlength'] = (string) $maxlength;
     }
     $max_file_size = $this->_get('max_file_size');
     if (!is_null($max_file_size)) {
         $subattr = array('type' => 'hidden', 'name' => 'MAX_FILE_SIZE', 'value' => (string) $max_file_size);
         $widgets[] = new AnewtXHMTLInput(null, $subattr);
     }
     $widget = new AnewtXHTMLInput(null, $attr);
     /* Styling */
     $widget->add_class('fileupload');
     if (!$this->_get('required')) {
         $widget->add_class('optional');
     }
     /* Optional extra class value */
     $class = $this->_get('class');
     if (!is_null($class)) {
         $widget->add_class($class);
     }
     /* Help text, if any */
     $help = $this->_get('help');
     if (!is_null($help)) {
         $help_text = to_string($help);
         $widget->set_attribute('title', $help_text);
         $widget->add_class('with-help');
     }
     $widgets[] = $widget;
     /* Add secondary label, if any */
     $secondary_label = $this->_get('secondary-label');
     if (!is_null($secondary_label)) {
         $widgets[] = $secondary_label;
     }
     $out = ax_fragment($widgets);
     return $out;
 }
<?php

// Results in <p class="foo">Paragraph text</p> when rendered
$p = ax_p_class('Paragraph text', 'foo');
// The same can be achieved like this:
$p = ax_p('Paragraph text');
$p->set_class('foo');
// Results in <div id="bar">Text here</div> when rendered
$p = ax_div_id('Text here', 'bar');
// The same can be achieved like this:
$div = ax_div('Text here');
$div->set_attribute('id', 'bar');
// Hyperlinks can be built like this:
$link = ax_a_href('Hyperlink text', 'http://anewt.net');
$link = ax_a_href_title('Hyperlink text', 'http://anewt.net', 'This will be a tooltip');
// Images can be built like this:
$img = ax_img_src_alt('example.png', 'An example image');
Example #14
0
<?php

$text_node_1 = ax_sprintf('This is a %s inside some text', ax_a_href('hyperlink', 'http://anewt.net'));
$spice = 'Spice';
$text_node_2 = ax_sprintf('%s & %s', ax_span_class('Sugar', 'sweet'), $spice);