Comparing revisions for WikkaMenulets

Additions:
Prints the number of pages owned by the current user.
Displays a clickable link to the current skin: {{skin}}
* @copyright Copyright © 2005, Marjolein Katsma
Deletions:
In the trac as [[Ticket:28]].

Prints the number of pages owned by the current user: {{countowned}}
==##""{{countreferrers}}""##==
Prints the total number of referrers to the wiki: {{countreferrers}}
* Print number of referrers to this site.
echo $this->getCount('referrers');
==##""{{linkcount}}""##==
Count (and display) the number of Wikka-formatted links (##""[[http:...]]""##) in a page. Needs some optimization work.
**actions/linkcount.php**
* Link count action
* Maintain a count of links on a page (could be extended to track
* other entities)
* Usage:
* {{linkcount preformatted="0"}}
* ...
* {{linkcount start="1"}}
* link1
* link2
* ...
* linkn
* {{linkcount stop="1"}}
* Optionally: {{linkcount preformatted="1"
* pretext="Some pretext"
* posttext="Some posttext"}}
* where preformatted = "1" produces "+++Link count: 9999 link(s)+++"
* pretext is the text to precede the link count (overrides
* preformatted)
* posttest is the text to follow the link count (overrides
* preformatted)
* TODO: Performance is miserable beyond a couple hundred links, so
* the next step would be to optimize it.
* @author {@link http://wikkawiki.org/BrianKoontz Brian Koontz}
* @copyright Copyright (c) 2006, Brian Koontz <brian@pongonova.net>
* @name LinkcountAction
* @license http://www.gnu.org/copyleft/gpl.html
* @since Wikka 1.1.7
* @uses /actions/linkcount.php
* @version $Id: linkcount.php,v 1.1.1.1 2006/10/07 16:30:42 brian Exp brian $
// Necessary to prevent "already defined" errors when the Wikka parser
// comes across a "start" or "stop" action tag
include_once("actions/linkcount.inc.php");
if(isset($vars['start']) || isset($vars['stop'])) {
return;
$preformatted = $vars['preformatted'];
$pretext = $vars['pretext'];
$posttext = $vars['posttext'];
if( isset($pretext) || isset($posttext)) {
$pretext ? 1 : $pretext = '';
$posttext ? 1 : $posttext = '';
} else if(isset($preformatted)) {
$pretext = "+++Link count: ";
$posttext = " link(s)+++";
$body = explode("\n", $this->page['body']);
parse($body);
**actions/linkcount.inc.php**
* Link count action
* Maintain a count of links on a page (could be extended to track
* other entities)
* @see LinkcountAction
* @see actions/linkcount.php
* @author {@link http://wikkawiki.org/BrianKoontz Brian Koontz}
* @copyright Copyright (c) 2006, Brian Koontz <brian@pongonova.net>
* @name LinkcountAction
* @license http://www.gnu.org/copyleft/gpl.html
* @since Wikka 1.1.7
* @uses /actions/linkcount.inc.php
* @version $Id: linkcount.inc.php,v 1.1.1.1 2006/10/07 16:32:17 brian Exp brian $
function parse(&$body) {
$linkcount = 0;
if(!$body) {
return;
$state = null; #null, start
foreach($body as $line) {
switch($state) {
case null:
if(preg_match('/\{\{linkcount[\s]+start.*\}\}/', $line)) {
$state = 'start';
}
case 'start':
if (preg_match('/\{\{linkcount[\s]+stop.*\}\}/', $line)) {
$state = null;
} elseif (preg_match('/\[\[http:.*\]\]/', $line)) {
$linkcount++;
}
echo $pretext.$linkcount.$posttext;
~& Needs to be updated for new ##templates/## directory structure
Displays a clickable link to the current skin: ""{{skin}}""
* @copyright Copyright � 2005, Marjolein Katsma
==##""{{randompage}}""##==//like the "Random Article" on wikipedia...//
~ ##""{{randompage}}""##
~~ Prints a link to a random page on this wiki. e.g. [[HomePage RandomPage]]
~ ##""{{randompage title="Random"}}""##
~~ Change the title, use ##""{{randompage title=""}}""## to display the real pagename.
~ ##""{{randompage pos="ActionInfo, HandlerInfo, FunctionInfo"}}""##
~~ Make a positive list to choose from, don't use all pages. (note the default neg list)
~ ##""{{randompage neg="HomePage, PageIndex"}}""##
~~ Use all pages exept the ones used in this negative list / override the default neg list in $neg_list_default
~ ##""{{randompage title="Random Link" pos="ActionInfo, HandlerInfo, FunctionInfo" neg=""}}""##
~~ Clear the default negative list, use only pages from the pos list and use "Random Link" as title.
~ ##""{{randompage pos="HomePage|DonateNow|DonateNow|DonateNow"}}""##
~~ You can influence the random ratio... (+other way of defining the list)
~& **Original idea**
~& %%(php)<?php
$all = $this->LoadAll("select distinct tag from ".$this->config["table_prefix"]."pages");
print $this->Link( $all[array_rand($all)]['tag'], '', 'RandomPage', FALSE, TRUE, 'A random page on this site' );
* Prints a link to a random page.
* syntax:
* {{randompage [title="string"] [pos="PageName, PageName2"] [neg="PageName3, PageName4"]}}
* @package Actions
* @subpackage Menulets
* @name RandomPage
* @author {@link http://wikkawiki.org/OnegWR OnegWR}
* @copyright Copyright � 2006, OnegWR
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
* @since Wikka 1.1.6.0
* @input string $title optional: alternative for "RandomPage"
* if set to "" the real pagename is used
* @input string $pos optional: comma separated list of pages
* only pages out of this list will be chosen
* default: all pages
* @input string $neg optional: comma separated list of pages
* pages in this list will not be used
* exeption: if the errorpage is in the list
* default: defined by $neg_list_default array
* If no match could be found, HomePage/config["root_page"] is returned.
* @ToDo Get list of pages from the tagCache of the ExistsPage function by IanAndolina
$errorpage = $this->config["root_page"];
$neg_list_default = array("HomePage","UserSettings","TextSearch","TextSearchExpanded","PageIndex");
$title = isset($vars['title']) ? $this->htmlspecialchars_ent($vars['title']) : "RandomPage"; //i18n
foreach( $this->LoadAll("select distinct tag from ".$this->config["table_prefix"]."pages") as $key => $val ){
$all[]=$val['tag'];
$pos_list = isset($vars['pos']) ? split('[|,]', ereg_replace( "[\ ]", '', $vars['pos'] ) ) : $all ;
$neg_list = isset($vars['neg']) ? split('[|,]', ereg_replace( "[\ ]", '', $vars['neg'] ) ) : $neg_list_default ;
$try = 0;
while ( $try < 5 ) {
$try++;
$page = $pos_list[array_rand($pos_list)];
if( !in_array($page, $all) ) continue;
if( in_array($page, $neg_list) ) continue;
if( $try > 4 ) $page = $errorpage;
if( $title=='' ) $title = $page;
print $this->Link( $page, '', $title, FALSE, TRUE, "$page, a random page on this site" ); //i18n
?>%%
-- OnegWR
==##""{{contributors}}""##==
~ Prints a space separated list of all users that have edited the current page, the most active user first.
~ A bit like ##""{{lasteditauthor}}""##, but with all editing authors...
%%<?php
* Shows the contributors of this page, most active user first.
* syntax: {{contributors}}
* @package Actions
* @subpackage Menulets
* @name Contributors
* @author {@link http://wikkawiki.org/OnegWR OnegWR}
* @copyright Copyright © 2006, OnegWR
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
* @since Wikka 1.1.6.0
$q = 'SELECT Count(*) AS cnt, `user` FROM '.$this->config["table_prefix"].'pages '.
'WHERE `tag`="'.$this->tag.'" GROUP BY user ORDER BY cnt DESC;';
$all = $this->LoadAll( $q );
foreach($all as $key=>$val)
print $this->Link($val['user'],'',$val['user'], FALSE, TRUE, '('.$val['cnt'].')') ." \n";
?>%%
-- OnegWR
==##""{{wordcount}}""##==
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.
##""+++Word count: 9999 word(s)+++""##
==actions/wordcount.php==
/*
* Word count action
* Author: Brian Koontz <brian@pongonova.net>
* 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)
* @package Actions
* @subpackage Menulets
* @name Contributors
* @author {@link http://wikkawiki.org/BrianKoontz Brian Koontz}
* @copyright Copyright � 2006, Brian Koontz <brian@pongonova.net>
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
* @since Wikka 1.1.6.2
* 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;
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki