anewt-developers team mailing list archive
-
anewt-developers team
-
Mailing list archive
-
Message #00314
[Branch ~uws/anewt/anewt.uws] Rev 1819: [page] Add support for a custom wrapper div element
------------------------------------------------------------
revno: 1819
committer: Wouter Bolsterlee <uws@xxxxxxxxx>
branch nick: anewt
timestamp: Thu 2011-03-17 15:52:38 +0100
message:
[page] Add support for a custom wrapper div element
AnewtPage->$wrapper_div can now be set to a custom DOM node.
If not null, this will be used as the wrapper around all
blocks on the page. If null, a new <div> element will be
used; this was the old behaviour and still is the default.
Also remove an unnecessary is_null() check for a line that
is only reached if $name is null.
modified:
page/module.doc.xml
page/page.lib.php
--
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
=== modified file 'page/module.doc.xml'
--- page/module.doc.xml 2010-11-05 13:26:24 +0000
+++ page/module.doc.xml 2011-03-17 14:52:38 +0000
@@ -242,6 +242,11 @@
Whether to use a wrapper div (<code>boolean</code>, defaults
to <code>true</code>).
</anewt:property>
+ <anewt:property name="wrapper-div">
+ A custom AnewtXMLDomNode node to use as the wrapper for all
+ content blocks. Defaults to <code>null</code>, which means a new
+ DIV element will be used.
+ </anewt:property>
<anewt:property name="wrapper-div-id">
The id attribute of the wrapper div. Defaults to <code>wrapper</code>.
</anewt:property>
=== modified file 'page/page.lib.php'
--- page/page.lib.php 2010-11-05 13:26:24 +0000
+++ page/page.lib.php 2011-03-17 14:52:38 +0000
@@ -69,6 +69,7 @@
'default-block' => null,
'use-wrapper-div' => true,
+ 'wrapper-div' => null,
'wrapper-div-id' => 'wrapper',
'wrapper-div-class' => null,
));
@@ -496,17 +497,27 @@
if ($this->_get('use-wrapper-div'))
{
- $buffer = ax_div_id(null, $this->_get('wrapper-div-id'));
+ /* Custom wrapper element? */
+ $buffer = $this->wrapper_div;
+ if (is_null($buffer))
+ $buffer = new AnewtXHTMLDiv();
+
+ $wrapper_div_id = $this->_get('wrapper-div-id');
+ if (!is_null($wrapper_div_id))
+ $buffer->set_attribute('id', $wrapper_div_id);
$wrapper_div_class = $this->_get('wrapper-div-class');
if (!is_null($wrapper_div_class))
$buffer->add_class($wrapper_div_class);
}
else
- $buffer = ax_fragment();
-
-
- /* Add the content */
+ {
+ /* No wrapper <div>, so just use a fragment */
+ $buffer = new AnewtXHTMLFragment();
+ }
+
+
+ /* Add the content blocks to the buffer */
foreach ($this->_get('blocks') as $block_name)
{
@@ -619,7 +630,7 @@
/**
* \private
*
- * Return the named block so that one can append to it using teh ArrayAccess
+ * Return the named block so that one can append to it using the ArrayAccess
* interface.
*
* For internal use only: do not invoke this method directly.
@@ -652,8 +663,7 @@
if (!is_null($name))
throw new AnewtException('Array operators on AnewtPage can only be used to append to blocks.');
- if (is_null($name))
- $this->append($value);
+ $this->append($value);
}
/**