anewt-developers team mailing list archive
-
anewt-developers team
-
Mailing list archive
-
Message #00203
[Branch ~uws/anewt/anewt.uws] Rev 1748: [xhtml] Add ax_h() convenience function
------------------------------------------------------------
revno: 1748
committer: Wouter Bolsterlee <uws@xxxxxxxxx>
branch nick: anewt.uws
timestamp: Tue 2010-02-16 00:34:23 +0100
message:
[xhtml] Add ax_h() convenience function
This is just like ax_h1() and friends, but the header level
must be specified as the first parameter. This can be useful
for dynamically generating headers.
Fixes bug #503550.
modified:
xhtml/api.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 'xhtml/api.lib.php'
--- xhtml/api.lib.php 2010-02-15 23:32:03 +0000
+++ xhtml/api.lib.php 2010-02-15 23:34:23 +0000
@@ -411,6 +411,28 @@
/* Headings */
/**
+ * Create an AnewtXHTMLHeader element for the specified header level.
+ * \param $level The header level (1, 2, 3, 4, 5, or 6)
+ * \param $content The content for this element
+ * \param $attributes Additional element attributes (optional)
+ */
+function ax_h($level, $content, $attributes=null)
+{
+ assert('is_int($level);');
+ $level = max(min($level, 6), 1);
+
+ switch ($level)
+ {
+ case 1: return ax_h1($content, $attributes);
+ case 2: return ax_h2($content, $attributes);
+ case 3: return ax_h3($content, $attributes);
+ case 4: return ax_h4($content, $attributes);
+ case 5: return ax_h5($content, $attributes);
+ case 6: return ax_h6($content, $attributes);
+ }
+}
+
+/**
* Create an AnewtXHTMLHeader1 element.
* \param $content The content for this element
* \param $attributes Additional element attributes (optional)