<?php if (!defined('PmWiki')) exit(); /* Copyright 2004 Patrick R. Michaud (pmichaud@pobox.com) This file is voting.php, a PmWiki Cookbook recipe for handling voting on pages. To use this script, place it in the cookbook/ directory, modify the form below to use your desired prompts and voting values, and then add the line include_once('cookbook/voting.php'); into your config.php or other local customization file. For more details see http://www.pmwiki.org/wiki/Cookbook/Voting . */ Markup('vote', 'block', '/\\(:vote:\\)/', FmtPageName("<form class='vote' action='\$ScriptUrl' method='get'> <input type='hidden' name='pagename' value='\$FullName' /> <input type='hidden' name='action' value='vote' /> <b>Add a vote:</b> Low <input type='radio' name='vote' value='0' /> <input type='radio' name='vote' value='1' /> <input type='radio' name='vote' value='2' /> <input type='radio' name='vote' value='3' /> <input type='radio' name='vote' value='4' /> <input type='radio' name='vote' value='5' /> High <input type='submit' value=' Vote! ' /></form>", $pagename)); $HandleActions['vote'] = 'HandleVote'; function HandleVote($pagename) { global $HandleActions; Lock(2); $page = RetrieveAuthPage($pagename, 'edit'); if (!$page) Abort("?cannot edit $pagename"); if (strpos($page['text'], 'Votes:') === false) $page['text'] .= "\n\nVotes: \n"; $_POST['text'] = preg_replace("/(\\bVotes:[^\\S\n]*\\d*)/", "\${1}".$_REQUEST['vote'], $page['text'], 1); $_POST['post'] = 1; $HandleActions['edit']($pagename); } ?>