Location: PHPKode > scripts > AcronymIT > acronymit/doc.html
<h1>AcronymIT PHP class - v1.0</h1>
<h2>Waht the class does - Main features</h2>
<p>
	<ul>
		<li>Finds acronyms in the text and replaces them</li>
		<li>Optionally links to Wikipedia for further informations</li>
		<li>Allows users to specify their preferred Wikipedia language</li>
		<li>Lists the acronyms stored in the file</li>
		<li>Users can add new acronyms and delete them</li>
	</ul>
</p>

<h2>Functions in the class</h2>
<h3>acronym</h3>
<p>
	<code>
		function acronym($text, $link = 0, $lang = "en")
		<br /><br />
	   @param string $text the text to scan for acronyms<br />
	   @param bool $link if set, prints also the link to Wikipedia<br />
	   @param string $lang the language of the Wikipedia portal to link<br />
	   @return string the new text with the acronyms<br />
	</code>
	<br />
	Looks for the known (and most common) acronyms in the text and make them HTML acronyms (so they'll have the acronym tag).
</p>

<h3>list_acronyms</h3>
<p>
	<code>
		function list_acronyms($limit = -1)
		<br /><br />
	   @param int $limit how many acronyms do you want to print?<br />
	   @return void<br />
	</code>
	<br />
	Lists acronyms stored in the selected file
</p>

<h3>set_file</h3>
<p>
	<code>
		function set_file($file)
		<br /><br />
	   @param string $file the file path<br />
	   @return void<br />
	</code>
	<br />
	Sets the file where acronyms are stored in
</p>

<h3>add_acronym</h3>
<p>
	<code>
		function add_acronym($acronym, $definition)
		<br /><br />
	   @param string $acronym the acronym to add<br />	  
	   @param string $definition what does the acronym mean?<br />	  
	   @return bool true on success<br />
	</code>
	<br />
	Adds the specified acronym to the file set before through the set_file() method
</p>

<h3>rm_acronym</h3>
<p>
	<code>
		function rm_acronym($id)
		<br /><br />
	   @param int $id the id of the acronym to remove<br />	  
	   @return bool true on success<br />
	</code>
	<br />
	Deletes the specified acronym from the file set before through the set_file() method
</p>








<h2>Examples of use</h2>
<h3>Example #1</h3>
<p>
	The following code will find all the acronyms in the text passed to the method and will link to the italian version of Wikipedia for further explanations	
	<br /><br />	
	<code>
		include_once('acronymIT.php');<br />

		$text = "The PHP version 6 is under development. Read more on the WWW or get info via RSS"; <br />
		$acronymit = new AcronymIT();<br />
		$text = $acronymit->acronym($text, 1, "it");<br />

		echo $text;<br />
	</code>
</p>

<h3>Example #2</h3>
<p>
	Listing acronyms stored in the default file, then in another one
	<br /><br />
	<code>
		include_once('acronymIT.php');<br />
		<br />
		$acronymit = new AcronymIT();<br />
		echo "File $acronymit->file:"; // Will be "FIle acronyms.dat:"<br />
		$acronymit->list_acronyms(5); // Lists the first 5 acronyms in the default file<br />
		<br />
		$acronymit->set_file("path/to/other_acronyms.txt"); // Changing the file<br />
		<br />
		echo "File $acronymit->file:"; // Will be "File path/to/other_acronyms.txt:"<br />
		$acronymit->list_acronyms() // Lists all the acronyms in the file<br />
		<br />
		echo "Done! ;)";<br />
	</code>
</p>

<h3>Example #3</h3>
<p>
	Adding, removing acronyms and changing definitions
	<br /><br />
	<code>
		include_once('acronymIT.php');<br />
		<br />
		$acronymit = new AcronymIT();<br />
		<br /><br />
		$acronymit->add_acronym("LOL", "Lough Out Loud");<br />
		$acronymit->list_acronyms(); // Default file with LOL, Laugh Out Loud added<br />
		<br /><br />
		$acronymit->rm_acronym($LOLid);<br />
		$acronymit->list_acronyms(); // Default file without LOL, Lough Out Loud<br />
		<br /><br />
		$acronymit->add_acronym("LOL", "Lot Of Laughs");<br />
		$acronymit->list_acronyms(); // Default file with LOL, Lot Of Laughs added<br />
		<br /><br />
		$acronymit->set_file("another/file.dat");<br />
		$acronymit->list_acornyms(); // Changing the file: LOL does not exist now<br />
		<br /><br />
		$acronymit->add_acronym("LOL", "Laugh Out Loud");<br />
		$acronymit->list_acronyms(); // So let's add it again to the new file!<br />
	</code>
</p>

<h2>Changelog</h2>
<p>
	No changes made since now.
</p>

<h2>License</h2>
<p>
	Copyright (C)2007 Giulio Bai <hide@address.com>
</p>

<p>
	<blockquote>
		This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License v2 as published by the Free Software Foundation.
		<br /><br />
		This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
		<br /><br />
		You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
</blockquote>
</p>

<p>
	A copy of the full license can be found in the <a href="http://www.gnu.org/licenses/gpl.html">official GNU's site</a>
</p>

<h2>Notes</h2>
<p>
	<h3>Links</h3>
	<ul>
		<li><a href="http://hewle.com">http://hewle.com</a> - My site :)</li>
		<li><a href="http://www.phpclasses.org">http://www.phpclasses.org</a> - Lots and lots of PHP classes</li>
		<li><a href="http://www.php.net">http://www.php.net</a> - PHP official site</li>
	</ul>
	
	<h3>Plase share it!</h3>
	<p>
		If you found this program useful, share it! Maybe it can help also other people!<br />
		Don't be scared, it's free, editable, redistributable.<br />
		So... share, Share, SHARE!	
	</p>
	
	<h3>Contacts</h3>
	<p>
		If you want to know more about this program, you can contact me at <a href="mailto:hide@address.com">hide@address.com</a>.<br />
		Wht do you think about this program? Is it useful? How can be improved?	
	</p>
</p>
Return current item: AcronymIT