===Word Count Action=== Inserts a wordcount (my format, your format, or no format) into a document. Needed something quick and dirty, so there's some refinement yet to be done. ==actions/wordcount.php== %%(php) * * Replace instances of {{wordcount}} with the number of words in the * text * * Optionally: {{wordcount preformatted="1" * pretext="Some pretext" * posttext="Some posttext"}} * * where preformatted = "1" produces "+++Word count: 9999 word(s)+++" * pretext is the text to precede the word count (overrides preformatted) * posttest is the text to follow the word count (overrides preformatted) * * TODO: Probably counts a lot of things it should, and a lot of * things it shouldn't. Probably shouldn't count actions or other * special items. */ $preformatted = $vars['preformatted']; $pretext = $vars['pretext']; $posttext = $vars['posttext']; if( $pretext || $posttext) { $pretext ? 1 : $pretext = ''; $posttext ? 1 : $posttext = ''; } else if($preformatted) { $pretext = "+++Word count: "; $posttext = " word(s)+++"; } $wc = str_word_count($this->page['body']); echo $pretext.$wc.$posttext; ?> %% CategoryUserContributions