예제 #1
0
 /**
  * Setup a new database connection.
  *
  * This stores the connection configuration in the database pool.
  * See the AnewtDatabaseConnection (and subclasses) documentation for the
  * description of the settings array.
  *
  * \param $settings
  *   An associative array with connection settings. At least the \c type
  *   key must be provided to specify the database connection type. See
  *   AnewtDatabaseConnection for the possible values.
  * \param $id
  *   The connection id to use for this connection (optional, defaults to
  *   <code>default</code>)
  *
  * \see AnewtDatabaseConnection
  */
 public static function setup_connection($settings, $id = 'default')
 {
     assert('is_assoc_array($settings)');
     assert('array_has_key($settings, "type"); // "type" key must be present in database settings array');
     assert('is_string($id)');
     /* A connection can be setup only once */
     if (array_key_exists($id, AnewtDatabase::$connections)) {
         throw new AnewtDatabaseException('Connection "%s" has been setup already.', $id);
     }
     /* Create an AnewtDatabaseConnection instance */
     $connection_type = $settings['type'];
     switch ($connection_type) {
         case 'sqlite':
             anewt_include('database/backend-sqlite');
             $connection = new AnewtDatabaseConnectionSQLite($settings);
             break;
         case 'mysql':
             anewt_include('database/backend-mysql');
             $connection = new AnewtDatabaseConnectionMySQL($settings);
             break;
         case 'mysql-old':
             anewt_include('database/backend-mysql-old');
             $connection = new AnewtDatabaseConnectionMySQLOld($settings);
             break;
         case 'postgresql':
             anewt_include('database/backend-postgresql');
             $connection = new AnewtDatabaseConnectionPostgreSQL($settings);
             break;
         case 'memcache':
             anewt_include('database/backend-memcache');
             $connection = new AnewtDatabaseConnectionMemcache($settings);
             break;
         default:
             throw new AnewtDatabaseException('Database type "%s" is not supported', $connection_type);
             break;
     }
     /* Connect by default, unless instructed not to */
     if (array_get_bool($settings, 'autoconnect', true)) {
         $connection->connect();
     }
     /* Store the connection instance */
     AnewtDatabase::$connections[$id] = $connection;
 }
예제 #2
0
<?php

/*
 * Anewt, Almost No Effort Web Toolkit, form module
 *
 * This code is copyrighted and distributed under the terms of the GNU LGPL.
 * See the README file for more information.
 */
anewt_include('validator');
mkenum('ANEWT_FORM_METHOD_POST', 'ANEWT_FORM_METHOD_GET');
/**
 * Basic form class.
 *
 * This class can be used to create an XHTML form. An AnewtForm instance holds
 * a number of controls, fieldset or custom XHTML elements. Additionally, it has
 * a few properties that influence its behaviour:
 *
 * - \c id property is the form id
 * - \c method is either \c ANEWT_FORM_METHOD_GET or \c ANEWT_FORM_METHOD_POST
 * - \c action is the URL the form will be posted to
 *
 * Usually an AnewtForm subclass is created. The constructor of this subclass
 * adds controls to the form, and optionally the handle_valid() and
 * handle_invalid() methods are overridden. Calling code then instantiates this
 * subclass, fills it with values using fill() or autofill(), then processes the
 * form using process().
 *
 * \todo Reference module documentation once it's written.
 */
class AnewtForm extends Container
{
예제 #3
0
<?php

/*
 * Anewt, Almost No Effort Web Toolkit, form module
 *
 * This code is copyrighted and distributed under the terms of the GNU LGPL.
 * See the README file for more information.
 */
anewt_include('form/controls/base');
anewt_include('form/controls/text');
anewt_include('form/controls/button');
anewt_include('form/controls/choice');
anewt_include('form/controls/fileupload');
예제 #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();
예제 #5
0
<?php

/*
 * Anewt, Almost No Effort Web Toolkit, core module
 *
 * This code is copyrighted and distributed under the terms of the GNU LGPL.
 * See the README file for more information.
 */
anewt_include('core/exception');
anewt_include('core/constants');
anewt_include('core/string');
anewt_include('core/array');
anewt_include('core/datetime');
anewt_include('core/noquotes');
anewt_include('core/container');
anewt_include('core/redirect');
anewt_include('core/request');
anewt_include('core/url');
// anewt_include('core/aasprintf'); /* Disable for now */
예제 #6
0
<?php

/*
 * Anewt, Almost No Effort Web Toolkit, gpc module
 *
 * This code is copyrighted and distributed under the terms of the GNU LGPL.
 * See the README file for more information.
 */
anewt_include('gpc/gpc');
예제 #7
0
<?php

anewt_include('page');
anewt_include('database');
require 'utils.php';
require 'home.php';
require 'table.php';
require 'feeds.php';
require 'feed_items.php';
require 'feed_item_comments.php';
require 'feed_item_comment_counts.php';
require 'tags.php';
require 'tasks.php';
require 'jobs.php';
require 'job_logs.php';
require 'resources.php';
require 'errors.php';
class SsscrapeMonitor extends AnewtPage
{
    public $interval = "1 DAY";
    // default interval
    public $pages = array(array('name' => 'home', 'class' => 'HomePage', 'descr' => 'Ssscrape monitor'), array('name' => 'feeds', 'class' => 'FeedTable', 'descr' => 'Basic statistics for feeds'), array('name' => 'items', 'class' => 'FeedItemTable', 'descr' => 'Information about feeds items'), array('name' => 'comments', 'class' => 'FeedItemCommentsTable', 'descr' => 'Information about comments', 'parent' => 'comments'), array('name' => 'commentCounts', 'class' => 'FeedItemCommentCountsTable', 'descr' => 'Basic statistics for comments', 'tab' => False, 'parent' => 'comments'), array('name' => 'tags', 'class' => 'TagsTable', 'descr' => 'Feed tags'), array('name' => 'tasks', 'class' => 'TasksTable', 'descr' => 'Periodic tasks'), array('name' => 'jobs', 'class' => 'JobsTable', 'descr' => 'Jobs in the job queue'), array('name' => 'jobLogs', 'class' => 'JobLogsTable', 'descr' => 'Jobs in the log table'), array('name' => 'resources', 'class' => 'ResourcesTable', 'descr' => 'Resources shared by jobs'), array('name' => 'errors', 'class' => 'ErrorsTable', 'descr' => 'Errors in job execution'));
    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 library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA+
 */
anewt_include('smarty');
/**
 * Renderer for Smarty templates.
 */
class SmartyTemplateRenderer extends SmartyTemplate
{
    /**
     * Constructor for a new SmartyTemplateRenderer instance
     *
     * \param $basetemplate Template name (optional, default is null)
     * \param $directories Directories to use (optional, see SmartyTemplate documentation for more information)
     * \param $mode Default render mode (optional, default is null)
     *
     * \see SmartyTemplate
     */
    function SmartyTemplateRenderer($basetemplate = null, $directories = null, $mode = null)
예제 #9
0
<?php

/*
 * Anewt, Almost No Effort Web Toolkit, smarty module
 *
 * Copyright (C) 2006  Wouter Bolsterlee <*****@*****.**>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA+
 */
anewt_include('smarty/smartytemplate');
예제 #10
0
<?php

require_once dirname(__FILE__) . '/../anewt.lib.php';
anewt_include('calendar');
$calendar = new AnewtCalendar();
$event = new AnewtCalendarEvent('Title');
$event->date_start = AnewtDateTime::parse_string('2009-01-01 12:00');
$event->date_end = AnewtDateTime::parse_string('2009-01-01 14:00');
$event->summary = 'This is the summary';
$event->location = 'This is the location';
$event->url = 'http://example.org/foo';
$event->uid = 'abc1234567890';
$calendar->add_event($event);
$event = new AnewtCalendarEvent('Another event', AnewtDateTime::now());
$event->summary = "This is a multiline\nsummary";
$event->summary = "This is a multiline\ndescription";
$calendar->add_event($event);
$calendar->flush();
예제 #11
0
<?php

error_reporting(E_ALL | E_STRICT);
require_once '../anewt.lib.php';
anewt_include('sparkline');
anewt_include('sparkline/bar');
$sl =& new AnewtSparklineImageBar();
$sl->set('debug-resize-factor', 1);
$sl->set('debug-resize-factor', 4);
$sl->set('draw-zero-axis', true);
$sl->set('image-border', 1, 2);
$sl->set('bar-spacing', 1);
$sl->set('bar-width', 2);
//$sl->set('bar-height', 5);
$sl->set('value-scale', 1.2);
//$sl->set('max-value', 5);
//$sl->set('min-value', -5);
$values = range(-7, 7);
/* Random values */
for ($i = 0; $i < 30; $i++) {
    $values[] = rand(-7, 7);
}
$sl->set('values', $values);
$sl->flush_png();
예제 #12
0
<?php

/*
 * Anewt, Almost No Effort Web Toolkit, logging module
 *
 * This code is copyrighted and distributed under the terms of the GNU LGPL.
 * See the README file for more information.
 */
anewt_include('logging/logging');
anewt_include('logging/loghandlers');
예제 #13
0
<?php

require_once dirname(__FILE__) . '/../anewt.lib.php';
anewt_include('page');
anewt_include('page/blank');
$bp = new AnewtBlankPage();
$bp->flush();
예제 #14
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();
예제 #15
0
<?php

error_reporting(E_ALL | E_STRICT);
require_once '../anewt.lib.php';
anewt_include('logging');
AnewtLog::init(false);
AnewtLog::add_handler(new AnewtLogHandlerDefault());
AnewtLog::add_handler(new AnewtLogHandlerFile('test.log'));
AnewtLog::add_handler(new AnewtLogHandlerFile('test-debug.log'), ANEWT_LOG_LEVEL_DEBUG);
AnewtLog::set_domain('a');
AnewtLog::error('An error occured.');
AnewtLog::set_domain('b');
AnewtLog::error('Error number %d', 3);
AnewtLog::reset_domain();
AnewtLog::debug('Debugging message: %d: %s', 4, 'dbg');
AnewtLog::set_domain('c');
AnewtLog::warning('This is a warning message without arguments');
AnewtLog::reset_domain();
AnewtLog::warning('This is a warning message: %d: %s', 2, 'test1');
AnewtLog::reset_domain();
AnewtLog::warning('This is a warning message: %d: %s', array(2, 'test2'));
AnewtLog::warning('This is warning with format characters but no values, %s %s %s');
예제 #16
0
<?php

/*
 * Anewt, Almost No Effort Web Toolkit, session module
 *
 * Copyright (C) 2004  Wouter Bolsterlee <*****@*****.**>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA+
 */
anewt_include('session/session');
예제 #17
0
<?php

error_reporting(E_ALL | E_STRICT);
require_once dirname(__FILE__) . '/../anewt.lib.php';
anewt_include('rss');
$channel = new AnewtRssChannel('Title', 'http://example.com', 'This is a test');
$channel->set('author', 'Anewt test');
$channel->set('build-date', AnewtDateTime::now());
$item = new AnewtRssItem('test', 'http://example.com/some-item');
$item->set('description', 'The description goes here.');
$item->set('guid', 'http://example.com/some-item');
$item->set('date', AnewtDateTime::now());
$channel->add_item($item);
$item = new AnewtRssItem('another test');
$item->set('description', 'The description goes here.');
$item->set('link', 'http://example.com/another-item');
$item->set('guid', 'http://example.com/another-item');
$item->set('date', AnewtDateTime::now());
$channel->add_item($item);
$channel->flush();
예제 #18
0
<?php

error_reporting(E_ALL);
require_once dirname(__FILE__) . '/../anewt.lib.php';
anewt_include('xml');
anewt_include('xml/abstractxmlparser');
function println($str)
{
    echo $str, "\n";
}
function printfln()
{
    $args = func_get_args();
    $pattern = array_shift($args);
    println(vsprintf($pattern, $args));
}
class TestParser extends AbstractXMLParser
{
    function handle_p_data($data)
    {
        if (trim($data)) {
            printfln('Data in a <p> tag: %s', $data);
        }
    }
    function handle_b_data($data)
    {
        if (trim($data)) {
            printfln('Data in a <b> tag: %s', $data);
        }
    }
    function handle_data($data)
예제 #19
0
<?php

/*
 * Anewt, Almost No Effort Web Toolkit, validator module
 *
 * This code is copyrighted and distributed under the terms of the GNU LGPL.
 * See the README file for more information.
 */
anewt_include('datetime');
/**
 * Validator for dates.
 *
 * This validator only accepts valid dates in \c YYYY-MM-DD format.
 */
class AnewtValidatorDate extends AnewtValidator
{
    function is_valid($value)
    {
        assert('is_string($value)');
        $pattern = '/^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})$/';
        if (!preg_match($pattern, $value, $matches)) {
            return false;
        }
        return AnewtDateTime::is_valid_date_ymd($matches[1], $matches[2], $matches[3]);
    }
}
예제 #20
0
<?php

anewt_include('database.new');
class AnewtDatabaseTest extends PHPUnit_Framework_TestCase
{
    /**
     * @expectedException AnewtDatabaseException
     */
    function test_invalid_connection_type()
    {
        $settings = array('type' => 'invalid-database-type');
        AnewtDatabase::setup_connection($settings, 'invalid-connection');
    }
    function test_two_connections()
    {
        $settings = array('type' => 'sqlite');
        AnewtDatabase::setup_connection($settings);
        AnewtDatabase::setup_connection($settings, 'connection2');
        $c2 = AnewtDatabase::get_connection('connection2');
        $c1 = AnewtDatabase::get_connection();
        $this->assertTrue($c1->is_connected());
        $this->assertTrue($c2->is_connected());
        $c1->disconnect();
        $this->assertFalse($c1->is_connected());
        $this->assertTrue($c2->is_connected());
    }
}
예제 #21
0
#!/usr/bin/php -q
<?php 
require_once '../anewt.lib.php';
anewt_include('mail');
$m = new AnewtMailMessage();
function usage()
{
    printf("Usage: %s address\n", $_SERVER['argv'][0]);
    exit(1);
}
$address = array_get_default($_SERVER['argv'], 1, null);
if (is_null($address)) {
    echo 'Error: no address specified', NL;
    usage();
}
$m->add_header('To', $address);
$m->add_header('Subject', 'Test');
$m->add_header('From', $address);
$m->set('body', 'This is a test message sent using the AnewtMailMessage class.');
$result = $m->send();
if ($result) {
    echo 'Mail sent successfully.', NL;
} else {
    echo 'Sending mail failed.', NL;
}
예제 #22
0
<?php

/*
 * Anewt, Almost No Effort Web Toolkit, filters module
 *
 * Copyright (C) 2005  Wouter Bolsterlee <*****@*****.**>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA+
 */
anewt_include('filters/filter');
// String filters
anewt_include('filters/lowercasefilter');
anewt_include('filters/maxlengthfilter');
anewt_include('filters/stripwhitespacefilter');
anewt_include('filters/uppercasefilter');
anewt_include('filters/firstuppercasefilter');
anewt_include('filters/pregfilter');
예제 #23
0
<?php

error_reporting(E_ALL);
require_once '../anewt.lib.php';
anewt_include('textformatting');
/* Simple text */
$input = 'This is a test.';
var_dump(TextFormatter::format($input));
var_dump(TextFormatter::format($input, 'raw'));
var_dump(TextFormatter::format($input, 'specialchars'));
var_dump(TextFormatter::format($input, 'entities'));
var_dump(TextFormatter::format($input, 'textile'));
/* HTML text (with leading whitespace!) */
$input = ' <p>This is a <strong>test</strong>.</p>';
var_dump(TextFormatter::format($input));
var_dump(TextFormatter::format($input, 'raw'));
var_dump(TextFormatter::format($input, 'specialchars'));
var_dump(TextFormatter::format($input, 'entities'));
var_dump(TextFormatter::format($input, 'textile'));
예제 #24
0
<?php

/*
 * Anewt, Almost No Effort Web Toolkit, form module
 *
 * This code is copyrighted and distributed under the terms of the GNU LGPL.
 * See the README file for more information.
 */
anewt_include('form/renderer');
/**
 * Default form renderer.
 *
 * This form renderer will render all controls into div elements, handles
 * fieldsets and hidden inputs correctly, and supports custom nodes as well. The
 * \c error, \c description and \c label properties are properly rendered before
 * each control widget. Many output elements have class names for easy styling
 * using CSS.
 */
class AnewtFormRendererDefault extends AnewtFormRenderer
{
    /**
     * Render the form into XHTML.
     */
    function render_default()
    {
        $f = $this->build_form_element();
        $f->append_child($this->_build_error_node($this->_form));
        $f->append_child($this->_build_description_node($this->_form));
        /* Add all form children */
        $children = $this->_form->_children();
        foreach (array_keys($children) as $key) {
예제 #25
0
<?php

error_reporting(E_ALL | E_STRICT);
require_once '../anewt.lib.php';
anewt_include('sparkline');
$values = array(5, 6, 8, 9);
/**
 * Calculate the mean of a series of numbers.
 */
function mean($values)
{
    assert('is_numeric_array($values)');
    return array_sum($values) / count($values);
}
function variance($values)
{
    $mean = mean($values);
    $num = count($values);
    $x = 0;
    foreach ($values as $value) {
        $diff = $value - $mean;
        $x += $diff * $diff;
    }
    $variance = $x / $num;
    return $variance;
}
function stddev($values)
{
    return sqrt(variance($values));
}
header('Content-type: text/plain');
예제 #26
0
<?php

/*
 * Anewt, Almost No Effort Web Toolkit, renderer module
 *
 * This code is copyrighted and distributed under the terms of the GNU LGPL.
 * See the README file for more information.
 */
anewt_include('renderer/renderer');
예제 #27
0
<?php

/*
 * Anewt, Almost No Effort Web Toolkit, XHTML module
 *
 * This code is copyrighted and distributed under the terms of the GNU LGPL.
 * See the README file for more information.
 */
anewt_include('xml/dom');
/**
 * XHTML fragment class use to hold zero or more XHTML elements.
 *
 * This class is useful to group XHTML elements into one entity. It is basically
 * a list that can be inserted into a DOM tree.
 *
 * \see AnewtXMLDomDocumentFragment
 */
final class AnewtXHTMLFragment extends AnewtXMLDomDocumentFragment
{
    /**
     * Render this fragment into a string.
     *
     * This method renders all children and concenates those strings into one
     * single value. Usually XHTML fragments are not rendered directly, but
     * added to a DOM tree instead. When that happens, all child nodes of the
     * fragment are added to the DOM tree, and the document fragment instance
     * itself is no longer of any use. This means that this method is not
     * invoked if document fragments are used in combination with a proper DOM
     * document (e.g. as used by AnewtPage).
     *
     * \return
예제 #28
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();
 }
예제 #29
0
<?php

/*
 * Anewt, Almost No Effort Web Toolkit, page module
 *
 * This code is copyrighted and distributed under the terms of the GNU LGPL.
 * See the README file for more information.
 */
anewt_include('xhtml');
/**
 * Class for building XHTML pages.
 */
class AnewtPage extends AnewtContainer implements ArrayAccess
{
    /** \private Page content */
    private $_content;
    /** \private Associative array of blocks */
    private $_blocks = array();
    /** \private List of link nodes */
    private $_links = array();
    /** \private List of JavaScript nodes */
    private $_javascripts = array();
    /**
     * Create a new AnewtPage instance.
     */
    public function __construct()
    {
        /* Figure out the content type based on the HTTP_ACCEPT header of the
         * current request. */
        if (array_key_exists('HTTP_ACCEPT', $_SERVER) && str_contains($_SERVER['HTTP_ACCEPT'], 'application/xhtml+xml')) {
            $content_type = 'application/xhtml+xml';
예제 #30
0
 /**
  * Create a new drawing context for this image. You should set some
  * properties and call drawing methods on the returned object instance to
  * create dynamic images.
  *
  * \return
  *   A new AnewtImageDrawingContext instance.
  */
 public function create_drawing_context()
 {
     /* Lazy load the AnewtImageDrawingContext class, since it is not needed
      * at all for many basic operations like image rescaling. */
     anewt_include('image/drawingcontext');
     $dc = new AnewtImageDrawingContext($this);
     return $dc;
 }