summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kremmel <xing@synapse.plus.com>2007-07-15 09:15:13 +0000
committerMax Kremmel <xing@synapse.plus.com>2007-07-15 09:15:13 +0000
commit49c5145935f8c5d35db23ae173c6650a37a4907f (patch)
tree690e5bc3170d419842ca5a76f0a5a9b0c94c85a8
parentf21d12c855be3117654ad32a269075e0878a7ee1 (diff)
downloadliberty-49c5145935f8c5d35db23ae173c6650a37a4907f.tar.gz
liberty-49c5145935f8c5d35db23ae173c6650a37a4907f.tar.bz2
liberty-49c5145935f8c5d35db23ae173c6650a37a4907f.zip
cache output hash. this avoids having to parse all the samples on every edit pageload
-rw-r--r--help_format_tikiwiki_inc.php235
-rw-r--r--templates/help_format_tikiwiki_inc.tpl14
2 files changed, 132 insertions, 117 deletions
diff --git a/help_format_tikiwiki_inc.php b/help_format_tikiwiki_inc.php
index b3478a2..a8f4c01 100644
--- a/help_format_tikiwiki_inc.php
+++ b/help_format_tikiwiki_inc.php
@@ -1,114 +1,124 @@
<?php
global $gBitSystem, $gBitSmarty;
require_once( '../bit_setup_inc.php' );
+require_once( KERNEL_PKG_PATH.'BitCache.php' );
+$cache = new BitCache( 'liberty/help' );
-// help for generic options
-$exampleHash = array(
- 'Emphasis' => array(
- 'Headings' => array(
- 'data' => "! heading 1\n!! heading 2\n!!! heading 3",
- 'note' => "Number of ! correponds to heading level.",
+// only regenerate this thing if it's not cached yet
+$cacheFile = 'tikiwiki';
+if( $cache->isCached( $cacheFile, filemtime( __FILE__ ))) {
+ $examples = unserialize( $cache->readCacheFile( $cacheFile ));
+} else {
+ // help for generic options
+ $tikiwiki = array(
+ 'Emphasis' => array(
+ 'Headings' => array(
+ 'data' => "! apples 1\n!! heading 2\n!!! heading 3",
+ 'note' => "Number of ! correponds to heading level.",
+ ),
+ 'Italics' => array(
+ 'data' => "''text''",
+ 'note' => "Two single quotes not one double quote",
+ ),
+ 'Underline' => array(
+ 'data' => "===text===",
+ ),
+ 'Coloured Background' => array(
+ 'data' => "++yellow:text++",
+ ),
+ 'Coloured Text' => array(
+ 'data' => "~~red:text~~",
+ ),
+ 'Bold' => array(
+ 'data' => "__text__",
+ ),
+ 'Centered Text' => array(
+ 'data' => "::text::",
+ ),
+ 'Combined' => array(
+ 'data' => "__::~~red:++yellow:text++~~::__",
+ 'note' => "When you combine options make sure you open and close in the opposite order analogous to: {[(text)]}",
+ ),
),
- 'Italics' => array(
- 'data' => "''text''",
- 'note' => "Two single quotes not one double quote",
+ 'Lists' => array(
+ 'Unordered Lists' => array(
+ 'data' => "* First item\n** First subitem\n** Second subitem\n* Second item",
+ ),
+ 'Ordered Lists' => array(
+ 'data' => "# First item\n## First subitem\n## Second subitem\n# Second item",
+ ),
+ 'Definition Lists' => array(
+ 'data' => ";Term: Definition",
+ ),
),
- 'Underline' => array(
- 'data' => "===text===",
+ 'Wiki References' => array(
+ 'Double Brackets' => array(
+ 'data' => "((Wiki Page))",
+ 'result' => '<a href="#">Wiki Page</a>',
+ ),
+ 'Double Brackets + Description' => array(
+ 'data' => "((Wiki Page|Page Description))",
+ 'result' => '<a href="#">Page Description</a>',
+ ),
),
- 'Coloured Background' => array(
- 'data' => "++yellow:text++",
+ 'External Links' => array(
+ 'External Link' => array(
+ 'data' => "[http://www.example.com]",
+ ),
+ 'External Link + Description' => array(
+ 'data' => "[http://www.example.com|Description]",
+ ),
),
- 'Coloured Text' => array(
- 'data' => "~~red:text~~",
+ 'Miscellaneous' => array(
+ 'Horizontal Rule' => array(
+ 'data' => '---',
+ ),
+ 'Highlighted Bar' => array(
+ 'data' => '-=text=-',
+ ),
+ 'Highlighted Box' => array(
+ 'data' => "^text\nmore text^",
+ ),
+ 'As is Text' => array(
+ 'data' => "~np~~~yellow:yellow~~ and __bold__ text~/np~",
+ 'note' => "This text will not be parsed",
+ ),
+ 'Pre Parsed' => array(
+ 'data' => "~pp~~~yellow:yellow~~\nand\n__bold__ text~/pp~",
+ 'note' => "This text will be treated like code and will not be altered and will be displayed using a monospace font. The same can be achieved by using &lt;pre&gt;text&lt;/pre&gt;.",
+ ),
),
- 'Bold' => array(
- 'data' => "__text__",
- ),
- 'Centered Text' => array(
- 'data' => "::text::",
- ),
- 'Combined' => array(
- 'data' => "__::~~red:++yellow:text++~~::__",
- 'note' => "When you combine options make sure you open and close in the opposite order analogous to: {[(text)]}",
- ),
- ),
- 'Lists' => array(
- 'Unordered Lists' => array(
- 'data' => "* First item\n** First subitem\n** Second subitem\n* Second item",
- ),
- 'Ordered Lists' => array(
- 'data' => "# First item\n## First subitem\n## Second subitem\n# Second item",
- ),
- 'Definition Lists' => array(
- 'data' => ";Term: Definition",
- ),
- ),
- 'Wiki References' => array(
- 'Double Brackets' => array(
- 'data' => "((Wiki Page))",
- 'result' => '<a href="#">Wiki Page</a>',
- ),
- 'Double Brackets + Description' => array(
- 'data' => "((Wiki Page|Page Description))",
- 'result' => '<a href="#">Page Description</a>',
- ),
- ),
- 'External Links' => array(
- 'External Link' => array(
- 'data' => "[http://www.example.com]",
- ),
- 'External Link + Description' => array(
- 'data' => "[http://www.example.com|Description]",
- ),
- ),
- 'Miscellaneous' => array(
- 'Horizontal Rule' => array(
- 'data' => '---',
- ),
- 'Highlighted Bar' => array(
- 'data' => '-=text=-',
- ),
- 'Highlighted Box' => array(
- 'data' => "^text\nmore text^",
- ),
- 'As is Text' => array(
- 'data' => "~np~~~yellow:yellow~~ and __bold__ text~/np~",
- ),
- ),
- 'Simple Tables' => array(
- 'Simple Table' => array(
- 'data' => "|| Row1-Col1 | Row1-Col2\nRow2-Col1 | Row2-Col2 ||",
- ),
- 'With Headers' => array(
- 'data' => "||~ Header1 | Header2\nRow1-Col1 | Row1-Col2\nRow2-Col1 | Row2-Col2 ||",
- ),
- ),
-);
-
-if( $gBitSystem->getConfig( 'wiki_tables' ) == 'old' ) {
- $exampleHash['Simple Tables'] = array(
- 'Tables' => array(
- 'data' => "|| Row1-Col1 | Row1-Col2 || Row2-Col1 | Row2-Col2 ||",
+ 'Simple Tables' => array(
+ 'Simple Table' => array(
+ 'data' => "|| Row1-Col1 | Row1-Col2\nRow2-Col1 | Row2-Col2 ||",
+ ),
+ 'With Headers' => array(
+ 'data' => "||~ Header1 | Header2\nRow1-Col1 | Row1-Col2\nRow2-Col1 | Row2-Col2 ||",
+ ),
),
);
-}
-// parse example data and translate strings
-foreach( array_keys( $exampleHash ) as $section ) {
- foreach( $exampleHash[$section] as $title => $example ) {
- if( empty( $example['result'] )) {
- $example['format_guid'] = 'tikiwiki';
- $exampleHash[$section][$title]['result'] = LibertyContent::parseData( $example );
+ if( $gBitSystem->getConfig( 'wiki_tables' ) == 'old' ) {
+ $tikiwiki['Simple Tables'] = array(
+ 'Tables' => array(
+ 'data' => "|| Row1-Col1 | Row1-Col2 || Row2-Col1 | Row2-Col2 ||",
+ ),
+ );
+ }
+
+ foreach( array_keys( $tikiwiki ) as $section ) {
+ foreach( $tikiwiki[$section] as $title => $example ) {
+ if( empty( $example['result'] )) {
+ $example['format_guid'] = 'tikiwiki';
+ $tikiwiki[$section][$title]['result'] = LibertyContent::parseData( $example );
+ }
}
}
-}
-$gBitSmarty->assign( 'exampleHash', $exampleHash );
-// mediawiki type tables
-$mediawiki = array(
- 'Example 1' => array(
- 'data' =>
+ // mediawiki type tables
+ $mediawiki = array(
+ 'Example 1' => array(
+ 'data' =>
'{| border=3
|+A Simple Table
|-
@@ -122,9 +132,9 @@ $mediawiki = array(
|-
| Row3-Col1 || Row3-Col2 || Row3-Col3
|}'
- ),
- 'Example 2' => array(
- 'data' =>
+ ),
+ 'Example 2' => array(
+ 'data' =>
'{| border="2" cellpadding="5"
|+Multiplication table
|-
@@ -145,9 +155,9 @@ $mediawiki = array(
! 5
| 5 || 10 || 15
|}'
- ),
- 'Example 3' => array(
- 'data' =>
+ ),
+ 'Example 3' => array(
+ 'data' =>
'{| style="background:yellow; color:green"
|+ Table with many colours
|-
@@ -163,15 +173,20 @@ $mediawiki = array(
| style="background:silver" | vwx
| yz
|}'
- ),
-);
+ ),
+ );
-// parse tables
-foreach( $mediawiki as $title => $example ) {
- if( empty( $example['result'] )) {
- $example['format_guid'] = 'tikiwiki';
- $mediawiki[$title]['result'] = LibertyContent::parseData( $example );
+ // parse tables
+ foreach( $mediawiki as $title => $example ) {
+ if( empty( $example['result'] )) {
+ $example['format_guid'] = 'tikiwiki';
+ $mediawiki[$title]['result'] = LibertyContent::parseData( $example );
+ }
}
+
+ $examples['tikiwiki'] = $tikiwiki;
+ $examples['mediawiki'] = $mediawiki;
+ $cache->writeCacheFile( $cacheFile, serialize( $examples ));
}
-$gBitSmarty->assign( 'mediawiki', $mediawiki );
+$gBitSmarty->assign( 'examples', $examples );
?>
diff --git a/templates/help_format_tikiwiki_inc.tpl b/templates/help_format_tikiwiki_inc.tpl
index 3b958ac..b3d191e 100644
--- a/templates/help_format_tikiwiki_inc.tpl
+++ b/templates/help_format_tikiwiki_inc.tpl
@@ -1,16 +1,16 @@
{strip}
<h1>Tikiwiki Markup Syntax</h1>
-{foreach from=$exampleHash key=section item=examples name=sections}
- {if !$smarty.foreach.sections.first}<br /><hr /><br />{/if}
- <h2>{tr}{$section}{/tr}</h2>
+{foreach from=$examples.tikiwiki key=title item=tikiwiki name=tw}
+ {if !$smarty.foreach.tw.first}<br /><hr /><br />{/if}
+ <h2>{tr}{$title}{/tr}</h2>
<table class="bittable">
<tr>
<th style="width:25%">Description</th>
- <th style="width:30%">Example</th>
- <th style="width:45%">Result</th>
+ <th style="width:40%">Example</th>
+ <th style="width:35%">Result</th>
</tr>
- {foreach from=$examples key=desc item=example}
+ {foreach from=$tikiwiki key=desc item=example}
<tr>
<td>
{tr}{$desc}{/tr}
@@ -72,7 +72,7 @@
<br /> <br />
<table class="bittable">
<caption>{tr}Applied Examples{/tr}</caption>
- {foreach from=$mediawiki key=title item=example}
+ {foreach from=$examples.mediawiki key=title item=example}
<tr>
<th style="width:60%">{$title}</th>
<th style="width:40%">Result</th>