anewt-developers team mailing list archive
-
anewt-developers team
-
Mailing list archive
-
Message #00068
[Branch ~uws/anewt/anewt.uws] Rev 1689: [renderer] Cleanup renderer module (breaks API)
------------------------------------------------------------
revno: 1689
committer: Wouter Bolsterlee <uws@xxxxxxxxx>
branch nick: anewt.uws
timestamp: Sun 2009-07-19 22:14:37 +0200
message:
[renderer] Cleanup renderer module (breaks API)
Renderer is now named AnewtRenderer. Updated relevant other
modules as well to reflect this change.
modified:
form/renderer/base.lib.php
renderer/grid/grid.lib.php
renderer/main.lib.php
renderer/renderer.lib.php
=== modified file 'form/renderer/base.lib.php'
--- form/renderer/base.lib.php 2009-04-09 21:25:38 +0000
+++ form/renderer/base.lib.php 2009-07-19 20:14:37 +0000
@@ -8,6 +8,9 @@
*/
+anewt_include('renderer');
+
+
/**
* \protected
*
@@ -15,7 +18,7 @@
* provide required functionality; the base implementation only provides some
* functionality shared by all form renderers.
*/
-abstract class AnewtFormRenderer extends Renderer
+abstract class AnewtFormRenderer extends AnewtRenderer
{
/**
* Form instance of this form renderer.
=== modified file 'renderer/grid/grid.lib.php'
--- renderer/grid/grid.lib.php 2009-01-18 00:37:14 +0000
+++ renderer/grid/grid.lib.php 2009-07-19 20:14:37 +0000
@@ -39,7 +39,7 @@
* Optional AnewtGenerator instance for generating row class names. By default
* 'odd' and 'even' will be used.
*/
-class AnewtGridRenderer extends Renderer
+class AnewtGridRenderer extends AnewtRenderer
{
/* Static methods */
=== modified file 'renderer/main.lib.php'
--- renderer/main.lib.php 2006-12-01 12:05:16 +0000
+++ renderer/main.lib.php 2009-07-19 20:14:37 +0000
@@ -3,24 +3,10 @@
/*
* Anewt, Almost No Effort Web Toolkit, renderer module
*
- * Copyright (C) 2006 Wouter Bolsterlee <uws@xxxxxxxxx>
- *
- * 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+
+ * This code is copyrighted and distributed under the terms of the GNU LGPL.
+ * See the README file for more information.
*/
-
anewt_include('renderer/renderer');
?>
=== modified file 'renderer/renderer.lib.php'
--- renderer/renderer.lib.php 2008-04-03 11:18:05 +0000
+++ renderer/renderer.lib.php 2009-07-19 20:14:37 +0000
@@ -3,57 +3,48 @@
/*
* Anewt, Almost No Effort Web Toolkit, renderer module
*
- * Copyright (C) 2006 Wouter Bolsterlee <uws@xxxxxxxxx>
- *
- * 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+
+ * This code is copyrighted and distributed under the terms of the GNU LGPL.
+ * See the README file for more information.
*/
/**
- * Base Renderer class. This class is a base renderer which should be extended
- * to match your own needs. The default render() method dispatches the actual
- * rendering to your own custom functions.
+ * Base Renderer class.
+ *
+ * This class is a base renderer which should be extended to match your own
+ * needs. The default render() method dispatches the actual rendering to your
+ * own custom functions.
*/
-class Renderer extends Container {
-
+abstract class AnewtRenderer extends Container
+{
/**
- * Render to a string. This method queries the 'render-mode' property and
- * uses that string to call another method to do the actual rendering. The
- * name of the real rendering method is formed by prepending 'render_' to
- * the value of the render-mode property. Example: if the render-mode
- * proprety is set to 'list', this method calls the render_list method. If
- * the render-mode property is not set, the method render_default() is
- * used as the default fallback.
+ * Render to a string.
+ *
+ * This method queries the <code>render-mode</code> property and uses that
+ * string to call another method to do the actual rendering. The name of the
+ * real rendering method is formed by prepending <code>render_</code> to the
+ * value of the <code>render-mode</code> property. Example: if the
+ * <code>render-mode</code> property is set to <code>list</code>, this
+ * method calls the <code>render_list</code> method. If the
+ * <code>render-mode</code> property is not set, the method
+ * <code>render_default()</code> is used as the default fallback.
*
* \return
- * A string intended to be displayed.
+ * A string or object, e.g. a AnewtXMLDomNode, intended to be displayed by
+ * calling to_string().
*/
- function render() {
+ function render()
+ {
$mode = $this->getdefault('render-mode', 'default');
assert('is_string($mode)');
- $render_func = 'render_'.str_replace('-', '_', $mode);
-
- if(!method_exists($this, $render_func)) {
- trigger_error(sprintf(
- '%s::%s(): Method "%s" does not exist.',
- __CLASS__, __FUNCTION__, $render_func));
- }
-
- return $this->$render_func();
+
+ $render_method = sprintf('render_%s', str_replace('-', '_', $mode));
+
+ if (!method_exists($this, $render_method))
+ throw new AnewtException('Method "%s" does not exist.', $render_method);
+
+ return $this->$render_method();
}
-
}
?>
--
lp:anewt
https://code.launchpad.net/~uws/anewt/anewt.uws
Your team Anewt developers is subscribed to branch lp:anewt.
To unsubscribe from this branch go to https://code.launchpad.net/~uws/anewt/anewt.uws/+edit-subscription.