/** * Create an AnewtXHTMLSpan element with a class and id. * \param $content The content for this element * \param $class The class name for this element * \param $id The id for this element * \param $attributes Additional element attributes (optional) */ function ax_span_class_id($content, $class, $id, $attributes = null) { $element = ax_span($content, $attributes); $element->set_attribute('class', $class); $element->set_attribute('id', $id); return $element; }
function display_content($content, $row) { return ax_span($content, array('onmouseover' => 'load_content(this, "get_feed_item.php", "id=' . $row['id'] . '&what=content_clean_html&ifempty=content"); this.onmouseover=null')); }
function make_one_cell($field, $value, &$row) { $classes = array(); if (method_exists($this, "check_" . $field)) { if (!call_user_func(array($this, "check_" . $field), $value, $row)) { $classes['error'] = 1; } } if (isset($this->field_opts[$field]['truncate'])) { $value = str_truncate($value, $this->field_opts[$field]['truncate']); } if (isset($this->field_opts[$field]['datetime']) and $value) { $value = AnewtDateTime::sql($value); } if (isset($this->field_opts[$field]['time']) and $value) { $value = AnewtDateTime::time($value); } if (isset($this->field_opts[$field]['num'])) { $this->stat[$field]['sum'] += intval($value); } if (preg_match('/^[\\d\\+\\-\\.eE]+$/', $value) || isset($this->field_opts[$field]['flushright'])) { $classes['number'] = 1; } $display_value = $value; if (method_exists($this, "display_" . $field)) { $display_value = call_user_func(array($this, "display_" . $field), $value, &$row); } $expand = array_get_default($this->field_opts[$field], 'expand', "0"); $dynamic = array_get_default($this->field_opts[$field], 'dynamic', FALSE); if ($dynamic || $expand > 0 && is_string($value) && strlen($value) > 0 && strlen($value) > $expand) { $display_value = ax_a(array(str_truncate($value, $expand, "...", true), ax_span($display_value, array('class' => 'expanded'))), array('class' => 'expand')); } $c =& ax_td($display_value); foreach ($classes as $class => $val) { $c->add_class($class); } return $c; }
$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();