<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="home" title="HomePage" href="HomePage.html" />
<link rel="help" title="HowToUseWiki" href="HowToUseWiki.html" />
<link rel="copyright" title="GNU General Public License" href="http://www.gnu.org/copyleft/gpl.html#SEC1" />
<link rel="author" title="The PhpWiki Programming Team" href="http://phpwiki.org/ThePhpWikiProgrammingTeam" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Content-Language" content="en" />
<meta name="robots" content="noindex,nofollow" />
<meta name="language" content="en" />
<meta name="document-type" content="Public" />
<meta name="document-rating" content="General" />
<meta name="generator" content="PhpWiki" />
<meta name="PHPWIKI_VERSION" content="1.3.14" />

<base href="../" />
<link rel="stylesheet" type="text/css" charset="iso-8859-1" href="phpwiki-printer.css" />
<title>PhpWiki - Help  /  Hello World Plugin</title>
</head>
<body>

<div id="header">
  
<!-- Page title -->
<h1>Help  /  Hello World Plugin</h1>
</div>
<div id="content">



<div class="wikitext"><p class="tightenable top">A simple example plugin.</p>
<div class="plugin tightenable" id="HelloWorldPlugin"><tt>Hello,: <u title="Empty link to: WikiUser" onmouseover="window.status=&quot;Empty link to: WikiUser&quot;; return true;" onmouseout="window.status='';return true;" class="wikiunknown">WikiUser</u>!</tt></div>
<p class="tightenable">From the source of this page:</p>
<pre class="tightenable">
&lt;?plugin HelloWorld salutation=&quot;Hello,&quot; name=&quot;WikiUser&quot; ?&gt;</pre>
<hr />
<p class="tightenable top"><a href="PhpWiki.html" class="wiki">PhpWiki</a>'s plugin architecture allows you to add custom page elements to your wiki. All you have to do is extend (subclass) the WikiPlugin class and create your output via the run() method, dependend on the Wiki- or Request arguments,</p>
<ul><li class="tightenable bottom">either with the predefined HTML classes to create valid XHTML,</li>
<li class="tightenable top">or by using templates, which are easier customizable, but generally more a mess to use and easier to create invalid XHTML.</li>
</ul>
<div class="plugin tightenable bottom" id="PhpHighlightPlugin"><code><font color="#000000">
<font color="#FF8000">/**<br /> * A simple demonstration Help:WikiPlugin.<br /> *<br /> * Usage:<br /> * &lt;?plugin HelloWorld?&amp;gt;<br /> * &lt;?plugin HelloWorld<br /> *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;salutation="Greetings, "<br /> *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name=Wikimeister<br /> * ? &gt;<br /> * &lt;?plugin HelloWorld salutation=Hi ? &gt;<br /> * &lt;?plugin HelloWorld name=WabiSabi ? &gt;<br /> */<br /><br />// Constants are defined before the class.<br /></font><font color="#007700">if (!</font><font color="#0000BB">defined</font><font color="#007700">(</font><font color="#DD0000">'THE_END'</font><font color="#007700">))<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">define</font><font color="#007700">(</font><font color="#DD0000">'THE_END'</font><font color="#007700">, </font><font color="#DD0000">"!"</font><font color="#007700">);<br /><br />class </font><font color="#0000BB">Help</font><font color="#007700">:</font><font color="#0000BB">WikiPlugin_HelloWorld<br /></font><font color="#007700">extends </font><font color="#0000BB">Help</font><font color="#007700">:</font><font color="#0000BB">WikiPlugin<br /></font><font color="#007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// Five required functions in a Help:WikiPlugin.<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">function </font><font color="#0000BB">getName </font><font color="#007700">() {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return </font><font color="#0000BB">_</font><font color="#007700">(</font><font color="#DD0000">"HelloWorld"</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;function </font><font color="#0000BB">getDescription </font><font color="#007700">() {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return </font><font color="#0000BB">_</font><font color="#007700">(</font><font color="#DD0000">"Simple Sample Plugin"</font><font color="#007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;function </font><font color="#0000BB">getVersion</font><font color="#007700">() {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return </font><font color="#0000BB">preg_replace</font><font color="#007700">(</font><font color="#DD0000">"/ Help:n : $]/"</font><font color="#007700">, </font><font color="#DD0000">''</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">"\$Revision: 1.1 $"</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// Establish default values for each of this plugin's arguments.<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">function </font><font color="#0000BB">getDefaultArguments</font><font color="#007700">() {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return array(</font><font color="#DD0000">'salutation' </font><font color="#007700">=&gt; </font><font color="#DD0000">"Hello,"</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'name'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&gt; </font><font color="#DD0000">"World"</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;function </font><font color="#0000BB">run</font><font color="#007700">(</font><font color="#0000BB">$dbi</font><font color="#007700">, </font><font color="#0000BB">$argstr</font><font color="#007700">, </font><font color="#0000BB">$request</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">extract</font><font color="#007700">(</font><font color="#0000BB">$this</font><font color="#007700">-&gt;</font><font color="#0000BB">getArgs</font><font color="#007700">(</font><font color="#0000BB">$argstr</font><font color="#007700">, </font><font color="#0000BB">$request</font><font color="#007700">));<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// Any text that is returned will not be further transformed,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// so use html where necessary.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$html </font><font color="#007700">= </font><font color="#0000BB">HTML</font><font color="#007700">::</font><font color="#0000BB">tt</font><font color="#007700">(</font><font color="#0000BB">fmt</font><font color="#007700">(</font><font color="#DD0000">'%s: %s'</font><font color="#007700">, </font><font color="#0000BB">$salutation</font><font color="#007700">, </font><font color="#0000BB">WikiLink</font><font color="#007700">(</font><font color="#0000BB">$name</font><font color="#007700">, </font><font color="#DD0000">'auto'</font><font color="#007700">)),<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">THE_END</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return </font><font color="#0000BB">$html</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />};<br /></font>
</font>
</code></div>
<hr />
<p class="tightenable bottom"><a href="PhpWikiDocumentation.html" class="wiki">PhpWikiDocumentation</a> <a href="Help/WikiPlugin" class="interwiki"><span style="white-space: nowrap"><img src="images/interwiki.png" alt="" class="linkicon" border="0" />Help:</span><span class="wikipage">WikiPlugin</span></a></p>
</div>

<div id="footer">  <hr class="printer" noshade="noshade" />
<p class="editdate">Owner: &quot;admin&quot;  Last edited on August 14, 2007  7:11 am by &quot;The PhpWiki programming team&quot;</p>
</div>

</div>
<!-- Add your Disclaimer here -->
</body>
</html>
