<?php if (!defined('PmWiki')) exit();
/*
    Provide tooltips for acryonyms, defined in a Wiki page
  COPYRIGHT
    Copyright 2004 Thomas Pahl, tp ^ codework.de
    based on: Copyright 2004 Georg Bauer, glbauer ^ gmail.com
  LICENSE
    Same as PmWiki, see www.pmwiki.org
  DESCRIPTION
    See CookBook.Acronyms for the general idea.
    This PmWiki plugin enables to maintain a Wiki page that contains
    acronyms and their short explanations.
    During rendering, each acronym found in the text will be replaced by
      <abbr title="..explanation..">acronym</abbr>
    producing a tooltip in any decent graphical browser.

    Acronyms have two sources:
    1. optional inline definition below (filling the array)
    2. optionally read from Main.Acronyms page

    The page file must contain one definition per line, of the format
      acronym=explanation
    Lines not following this syntax are ignored.

  CONFIGURATION
    $AcronymsPagename - full Wiki pagename of the Wiki page containing
      the words. Defaults to 'Main.Acronyms' (assuming 'Main' is your 
      default group). Set to blank to suppress file access.
    Note: you may want to restrict edit permission on this page.

  INSTALLATION
    * copy this script into the PmWiki 'local' directory
    * include it from local/config.php
      include_once('local/acronyms.php');

  ACKNOWLEDGEMENTS
    This code extends the idea of CookBook.Acronyms (abbr.php) by Georg Bauer.
*/

SDV($AcronymsPagename, $DefaultGroup.'/Acronyms');

function loadAcronymWords() {
  global $AcronymsPagename;
  global $AcronymWords;
  if (!trim($AcronymsPagename))
    return;
  $page = ReadPage($AcronymsPagename);
  if (!$page) return;
  $text = $page['text'];
  foreach (explode("\n",$text) as $l) {
    $l = trim($l);
    if ($l and !(strpos($l, '=') === false)) {
      list($k, $v) = explode('=', $l);
      if ($v and !isset($AcronymWords[$v]))
        $AcronymWords[$k] = $v;
    }
  }
}


// Script: Copyright 2004 Georg Bauer, glbauer > gmail.com
//

// To make this script work, add the following line to your config.php:
// include("local/acronyms.php");

// ***************************************************
// You shouldn't need to edit anything below this line, except if you want
// to add your own acronyms

$AcronymWords = array (
#   'AOL' => 'American Online',
   'API' => 'Application Programming Interface',
#   'CD' => 'Compact Disk',
   'CGI' => 'Common Gateway Interface',
   'CMS' => 'Content Management System',
   'CSS' => 'Cascading Style Sheets',
   'CVS' => 'Concurrent Versioning System',
   'DNS' => 'Domain Name System',
   'DOM' => 'Document Object Model',
   'DTD' => 'Document Type Definition',
#   'DVD' => 'Digital Video Disc',
   'FAQ' => 'Frequently Asked Questions',
#   'FOAF' => 'Friend Of A Friend is a Resource Description Framework dialect for describing relationships',
   'FSF' => 'Free Software Foundation',
   'FTP' => 'File Transfer Protocol',
   'GB' => 'Gigabyte',
   'GFDL' => 'GNU Free Documentation License',
   'GPL' => 'GNU General Public License',
#   'HDTV' => 'High Definition TeleVision',
   'HTML' => 'HyperText Markup Language',
   'HTTP' => 'HyperText Transfer Protocol',
#   'IE' => 'Internet Explorer',
#   'IHOP' => 'International House of Pancakes',
#   'IIRC' => 'if I remember correctly',
   'IIS' => 'Internet Information Server',
   'IM' => 'Instant Message',
   'IMAP' => 'Internet Message Access Protocol',
   'IRC' => 'Internet Relay Chat (like Instant Messaging for groups)',
   'ITE' => 'Internet Topic Exchange',
   'JPG' => 'Joint Photographic Experts Group - Picture Format',
   'JPEG' => 'Joint Photographic Experts Group - Picture Format',
   'JSP' => 'Java Server Pages',
   'KB' => 'Kilobyte',
   'KDE' => 'K Desktop Environment',
   'LDAP' => 'Lightweight Directory Access Protocol',
   'LGPL' => 'GNU Lesser General Public License',
   'MAPI' => 'Mail Application Programming Interface (Microsoft)',
   'MB' => 'Megabyte',
#   'MS' => 'Microsoft',
   'MSDN' => 'Microsoft Developer Network',
   'MSIE' => 'Microsoft Internet Explorer',
   'MSN' => 'Microsoft Network',
   'NNTP' => 'Network News Transfer Protocol (the protocol used for NewsGroups)',
   'OPML' => 'Outline Processor Markup Language',
   'P2P' => 'Peer To Peer',
   'PBM' => 'Portable Bitmap',
   'PBS' => 'Public Broadcasting System',
   'PDF' => 'Portable Document Format',
   'PHP' => 'Hypertext PreProcessing',
   'PNG' => 'Portable Network Graphics',
   'PNM' => 'Portable Anymap',
#   'PyDS' => 'Python Desktop Server',
#   'PyCS' => 'Python Community Server',
   'RAID' => 'Redundant Array of Independent Disks',
   'RDF' => 'Resource Description Framework',
   'RPC' => 'Remote Procedure Call',
   'RSD' => 'Really Simple Discovery',
   'RSS' => 'Really Simple Syndication',
   'SIG' => 'Special Interest Group',
   'SOAP' => 'Simple Object Access Protocol',
   'SSN' => 'Social Security Number',
   'TTF' => 'Truetype Font',
#   'TooFPy' => 'Toolserver Framework for Python',
   'UML' => 'Unified Modeling Language',
   'URI' => 'Uniform Resource Identifier',
   'URL' => 'Uniform Resource Locator',
   'USB' => 'Universal Serial Bus',
#   'VB' => 'Visual Basic',
   'VBS' => 'Visual Basic Script',
   'VNC' => 'Virtual Network Computing',
   'W3C' => 'World Wide Web Consortium',
   'WCAG' => 'Web Content Accessibility Guidelines',
   'WYSIWYG' => 'what you see is what you get',
   'XHTML' => 'eXtensible HyperText Markup Language (HTML reformulated as XML)',
   'XML' => 'eXtensible Markup Language',
   'XSL' => 'eXtensible Stylesheet Language',
   'XSLT' => 'eXtensible Stylesheet Language Transformation'
);


loadAcronymWords();

foreach ($AcronymWords as $k=>$v) {
	$abbrs2['/\b'.$k.'/'] = '<abbr title="'.$v.'">'.$k.'</abbr>';
}

#
# Merge InlineReplacements with array
#
$InlineReplacements = array_merge($InlineReplacements, $abbrs2);

#
# TO DO: modify FmtUrlLink and FmtWikiLink for abbr in Urls
#
unset($AcronymWords);
unset($abbrs2);
?>