cvs: pear /Text_Wiki/Text/Wiki/Render/Xhtml Heading.php
| From: | bertrand GUGGER | Date: | Fri, 29 Jul 2005 13:45:47 +0000 |
| Subject: | cvs: pear /Text_Wiki/Text/Wiki/Render/Xhtml Heading.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-33458@lists.php.net to get a copy of this message | ||
toggg Fri Jul 29 09:45:47 2005 EDT
Modified files:
/pear/Text_Wiki/Text/Wiki/Render/Xhtml Heading.php
Log:
Introduces tikiwiki/justin's collapsing in headers, needs some refactoting though
http://cvs.php.net/diff.php/pear/Text_Wiki/Text/Wiki/Render/Xhtml/Heading.php?r1=1.7&r2=1.8&ty=u
Index: pear/Text_Wiki/Text/Wiki/Render/Xhtml/Heading.php
diff -u pear/Text_Wiki/Text/Wiki/Render/Xhtml/Heading.php:1.7
pear/Text_Wiki/Text/Wiki/Render/Xhtml/Heading.php:1.8
--- pear/Text_Wiki/Text/Wiki/Render/Xhtml/Heading.php:1.7 Sat Sep 25 15:05:14 2004
+++ pear/Text_Wiki/Text/Wiki/Render/Xhtml/Heading.php Fri Jul 29 09:45:46 2005
@@ -1,7 +1,7 @@
<?php
class Text_Wiki_Render_Xhtml_Heading extends Text_Wiki_Render {
-
+
var $conf = array(
'css_h1' => null,
'css_h2' => null,
@@ -10,20 +10,55 @@
'css_h5' => null,
'css_h6' => null
);
-
+
function token($options)
{
+ static $jsOutput = false;
// get nice variable names (id, type, level)
extract($options);
-
- if ($type == 'start') {
+
+ switch($type) {
+ case 'start':
$css = $this->formatConf(' class="%s"',
"css_h$level");
- return "<h$level$css id=\"$id\">";
- }
-
- if ($type == 'end') {
- return "</h$level>\n";
+ return '
+<h'.$level.$css.' id="'.$id.'"'.($collapse !== null ? '
onclick="hideTOC(\''.$id.'\');"' :
'').'>';
+
+ case 'end':
+ return '</h'.$level.'>
+'.($collapse !== null ? '<a id="'.$id.'__link"
href="javascript:void();"
onclick="hideTOC(\''.$id.'\')">['.($collapse ? '+' :
'-').']</a>
+' : '');
+ case 'startContent':
+ if ($collapse !== null) {
+ if ($jsOutput) {
+ $js = '';
+ } else {
+ $js = '
+<script language="javascript">
+function hideTOC(id) {
+ div = document.getElementById(id+"__content");
+ link = document.getElementById(id+"__link");
+ if (div.style.display == "none") {
+ div.style.display = "";
+ link.innerHTML = "[-]";
+ } else {
+ div.style.display = "none";
+ link.innerHTML = "[+]";
+ }
+}
+</script>
+';
+ }
+ } else {
+ $js = '';
+ }
+ return $js.'
+<div style="'.($collapse === true ? 'display: none; ' :
'').'padding: 0px; margin: 0px; border: none;"
id="'.$id.'__content">
+';
+ case 'endContent':
+ return '
+</div>
+';
}
}
}
-?>
\ No newline at end of file
+?>