Terms Infusion (Dictionary/Glossary) v2.00
PHP-Fusion: v6.01.13
original author: muscapaul
email: muscapaul@gmail.com)
web: www.muscapaul.com
date: 17 December 2007
--------------------------------------------------
Copyright: Released under the terms and conditions
of the GNU General Public License (Version 2)
--------------------------------------------------


INTRODUCTION
------------

This document describes the procedure on how to add the use of [glos] [/glos] tags to your site. Using the tags will enable you to make links of terms (single words or specific phrases) that will lead to a page where the term is explained and show popup layers with the same content.

Please note that there are are two circumstances when the popup layer will have a problem:
1. The first letter of the Term is uppercase (for example because it is used at the start of a sentence) whereas the Term is described with the firt letter in lowercase. The resulting popup layer will show that the Term cannot be found while the term itseld is in fact listed. So one is advised to label only Term mid-sentence or (if that cannot be prevented) to add the Term with the uppercase initial as a fixed synonym of the Term with the lowercase initial.
2. Term descriptions using square brackets are not show in the popup layer. The part of the popup layer which should give the description is simple not displayed. One should not use square brackets in descriptions.

The file that MUST be modified to use the tags in the forum is ../maincore.php, since that file is responsible for parsing of bbcode. The tags can be added manually by typing them in, but the scripts can be modified to add buttons to the relevant pages.

AUTOMATIC INSTALLATION
----------------------

Automatic installation is possible by uploading the contents of the changed_files folder to your server. You should only do this AFTER you made a backup of the following files and ascertained that no modifications were made to them already:
../articles.php
../maincore.php
../news.php
../readarticle.php
../subheader.php
../viewpage.php
../administration/articles.php
../administration/custom_pages.php
../administration/news.php
../administration/subheader.php
../forum/postedit.php
../forum/postreply.php
../forum/postnewthread.php
../forum/viewthread.php

One file is added:
../includes/boxover.js


MODIFYING MAINCORE.PHP TO PARSE GLOS TAGS
-----------------------------------------

1. Make a backup of the following file:
../maincore.php

2. Open the file ../maincore.php in a text editor of your choice and find on approx. line 327:

// Parse bbcode into HTML code

Immediately BEFORE add the following code:

//included line for correct parsing of code for Glossary
if (file_exists(INFUSIONS."terms/include/functions.php")) { include INFUSIONS."terms/include/functions.php"; }

In the same file find on approx.line 357:

	for ($i=0;$i < $ccount;$i++) $text = preg_replace('#\[code\](.*?)\[/code\]#si', '<div class=\'quote\' style=\'width:400px;white-space:nowrap;overflow:auto\'><code style=\'white-space:nowrap\'>\1<br><br><br></code></div>', $text);

Immediately AFTER add the following code:

//four added lines for parsing Glossary codes
    $title='"header=[\2] body=[-expl-\2-expl-<br /><img src=\'-img-\2-img-\' style=\'vertical-align:middle;\'>] delay=[0] fade=[on]"';
    $text = preg_replace('#\[glos\]([\r\n]*)([^\'\";:\+]*?)([\r\n]*)\[/glos\]#si', '<a href=\''.INFUSIONS.'terms/terms.php?op=glos&amp;term=\2\3\'>\2\3<img src=\''.INFUSIONS.'terms/images/help.gif\' border=\'0\' title='.$title.'></a>', $text);
    $text = parseterm($text);
    $text = parsetermimg($text);

Save the file and close it.


MODIFYING SUBHEADER.PHP TO PARSE GLOS TAGS
-----------------------------------------

1. Make a backup of the following file:
../subheader.php

2. Open the file ../subheader.php in a text editor of your choice and find on approx. line 29:

<body bgcolor='$body_bg' text='$body_text'>\n";

Immediately AFTER add the following code:

echo "<script type='text/javascript' language='JavaScript' src='".INCLUDES."boxover.js'></script>

<script type='text/javascript' language='JavaScript'>
function showhide(id){
    if (document.getElementById){
        obj = document.getElementById(id);
        if (obj.style.display == 'none'){
            obj.style.display = '';
        } else {
            obj.style.display = 'none';
        }
    }
}
</script>";

Save the file and close it.


ADDING A GLOS TAGS BUTTON TO THE FORUM
--------------------------------------

1. Make a backup of the following four files:
../forum/postedit.php
../forum/postreply.php
../forum/postnewthread.php
../forum/viewthread.php

2. Open the file ../forum/postedit.php in a text editor of your choice and find on approx.lines 192:

<input type='button' value='quote' class='button' style='width:45px;' onClick=\"addText('message', '[quote]', '[/quote]');\">

Immediately after add the following code:

<input type='button' value='glos' class='button' style='width:45px;' onClick=\"addText('message', '[glos]', '[/glos]');\">

Save the file and close it.

3. Open the file ../forum/postnewthread.php in a text editor of your choice and find on approx.lines 161:

<input type='button' value='quote' class='button' style='width:45px;' onClick=\"addText('message', '[quote]', '[/quote]');\">

Immediately after add the following code:

<input type='button' value='glos' class='button' style='width:45px;' onClick=\"addText('message', '[glos]', '[/glos]');\">

Save the file and close it.

4. Open the file ../forum/postreply.php in a text editor of your choice and find on approx.lines 181:

<input type='button' value='quote' class='button' style='width:45px;' onClick=\"addText('message', '[quote]', '[/quote]');\">

Immediately after add the following code:

<input type='button' value='glos' class='button' style='width:45px;' onClick=\"addText('message', '[glos]', '[/glos]');\">

Save the file and close it.

5. Open the file ../forum/viewthread.php in a text editor of your choice and find on approx.lines 304:

<<input type='button' value='quote' class='button' style='width:45px;' onClick=\"addText('message', '[quote]', '[/quote]');\"></td>


Replace this code with the following code:

<input type='button' value='quote' class='button' style='width:45px;' onClick=\"addText('message', '[quote]', '[/quote]');\">
<input type='button' value='glos' class='button' style='width:45px;' onClick=\"addText('message', '[glos]', '[/glos]');\"></td>

Save the file and close it.


MODIFYING ../ADMINISTRATION/SUBHEADER.PHP TO PARSE GLOS TAGS IN ARTICLE AND NEWS PREVIEW
----------------------------------------------------------------------------------------

This will add code to ../administration/subheader.php that will enable glos tags to be parsed in preview of Articles and News from the Admin Panel.

1. Make a backup of the following file:
../administration/subheader.php


2. Open the file ../administration/subheader.php in a text editor of your choice and find on approx. line 27:

<script language='javascript' type='text/javascript' src='".INCLUDES."jscript.js'></script>\n";

Immediately AFTER add the following code:

echo "<script type='text/javascript' language='JavaScript' src='".INCLUDES."boxover.js'></script>

<script type='text/javascript' language='JavaScript'>
function showhide(id){
    if (document.getElementById){
        obj = document.getElementById(id);
        if (obj.style.display == 'none'){
            obj.style.display = '';
        } else {
            obj.style.display = 'none';
        }
    }
}
</script>";

Save the file and close it.


ADDING A GLOS TAGS BUTTON TO ARTICLES ADMIN PAGE
------------------------------------------------

This will add [glos] [/glos] tags around a selected word or phrase in an article that will to a page with the term eclosed between the tags and show a popup layer with the Term Explanation.

1. Make a backup of the following file:
../administration/articles.php


2. Open the file ../administration/articles.php in a text editor of your choice and find on approx. lineS  66-67:

			$bodypreview = str_replace("src='".str_replace("../", "", IMAGES_A), "src='".IMAGES_A, stripslash($_POST['body']));
			$body2preview = str_replace("src='".str_replace("../", "", IMAGES_A), "src='".IMAGES_A, stripslash($_POST['body2']));

Replace this code with the following code:

			$bodypreview = parseglos(str_replace("src='".str_replace("../", "", IMAGES_A), "src='".IMAGES_A, stripslash($_POST['body'])));
			$body2preview = parseglos(str_replace("src='".str_replace("../", "", IMAGES_A), "src='".IMAGES_A, stripslash($_POST['body2'])));


3. In the same file find on approx. line  164:

<input type='button' value='alt' class='button' style='width:25px;' onClick=\"addText('body', '<span class=\'alt\'>', '</span>');\"><br>

Replace this code with the following code:

<input type='button' value='alt' class='button' style='width:25px;' onClick=\"addText('body', '<span class=\'alt\'>', '</span>');\">";
$settings = dbarray(dbquery("SELECT * FROM ".$db_prefix."settings"));
echo " <input type='button' value='glos' class='button' style='width:35px;' onClick=\"addText('body', '[glos]', '[/glos]');\"><br>


4. In the same file find on approx.line 204:

<input type='button' value='alt' class='button' style='width:25px;' onClick=\"addText('body2', '<span class=\'alt\'>', '</span>');\">

Replace this code with the following code:

<input type='button' value='alt' class='button' style='width:25px;' onClick=\"addText('body2', '<span class=\'alt\'>', '</span>');\">";
$settings = dbarray(dbquery("SELECT * FROM ".$db_prefix."settings"));
echo " <input type='button' value='glos' class='button' style='width:35px;' onClick=\"addText('body2', '[glos]', '[/glos]');\"><br>

Save the file and close it.


ADDING A GLOS TAGS BUTTON TO CUSTOM PAGES ADMIN PAGE
----------------------------------------------------

This will add [glos] [/glos] tags around a selected word or phrase in an article that will to a page with the term eclosed between the tags and show a popup layer with the Term Explanation.

1. Make a backup of the following file:
../administration/custom_pages.php

2. Open the file ../administration/custom_pages.php in a text editor of your choice and find on approx. line 71:

		eval("?>".$page_content."<?php ");

Replace this code with the following code:

		eval("?>".parseglos($page_content)."<?php ");


3. In the same file find on approx. line 154:

<input type='button' value='alt' class='button' style='width:25px;' onClick=\"addText('page_content', '<span class=\'alt\'>', '</span>');\">

Replace this code with the following code:

<input type='button' value='alt' class='button' style='width:25px;' onClick=\"addText('page_content', '<span class=\'alt\'>', '</span>');\">";
$settings = dbarray(dbquery("SELECT * FROM ".$db_prefix."settings"));
echo " <input type='button' value='glos' class='button' style='width:35px;' onClick=\"addText('page_content', '[glos]', '[/glos]');\"><br>

Save the file and close it.


ADDING A GLOS TAGS BUTTON TO NEWS ADMIN PAGE
--------------------------------------------

This will add [glos] [/glos] tags around a selected word or phrase in an article that will to a page with the term eclosed between the tags and show a popup layer with the Term Explanation.

1. Make a backup of the following file:
../administration/news.php


2. Open the file ../administration/articles.php in a text editor of your choice and find on approx. lineS 74-77:

		$bodypreview = str_replace("src='".str_replace("../", "", IMAGES_N), "src='".IMAGES_N, stripslash($_POST['body']));
		if ($_POST['body2']) {
			$body2 = phpentities(stripslash($_POST['body2']));
			$body2preview = str_replace("src='".str_replace("../", "", IMAGES_N), "src='".IMAGES_N, stripslash($_POST['body2']));

Replace this code with the following code:

		$bodypreview = parseglos(str_replace("src='".str_replace("../", "", IMAGES_N), "src='".IMAGES_N, stripslash($_POST['body'])));
		if ($_POST['body2']) {
			$body2 = phpentities(stripslash($_POST['body2']));
			$body2preview = parseglos(str_replace("src='".str_replace("../", "", IMAGES_N), "src='".IMAGES_N, stripslash($_POST['body2'])));

3. In the same file find on approx. line 210:

<input type='button' value='alt' class='button' style='width:25px' onClick=\"addText('body', '<span class=\'alt\'>', '</span>');\"><br>

Replace this code with the following code:

<input type='button' value='alt' class='button' style='width:25px' onClick=\"addText('body', '<span class=\'alt\'>', '</span>');\">";
$settings = dbarray(dbquery("SELECT * FROM ".$db_prefix."settings"));
echo " <input type='button' value='glos' class='button' style='width:35px;' onClick=\"addText('body', '[glos]', '[/glos]');\"><br>

4. In the same file find on approx. line 250:

<input type='button' value='alt' class='button' style='width:25px' onClick=\"addText('body2', '<span class=\'alt\'>', '</span>');\"><br>

Replace this code with the following code:

<input type='button' value='alt' class='button' style='width:25px' onClick=\"addText('body2', '<span class=\'alt\'>', '</span>');\">";
$settings = dbarray(dbquery("SELECT * FROM ".$db_prefix."settings"));
echo " <input type='button' value='glos' class='button' style='width:35px;' onClick=\"addText('body2', '[glos]', '[/glos]');\"><br>

Save the file and close it.


ADDING PARSE FUNCTION TO ARTICLE, CUSTOM AND NEWS PAGES
-------------------------------------------------------

This will add [glos] [/glos] tags around a selected word or phrase in an article that will to a page with the term eclosed between the tags and show a popup layer with the Term Explanation.

1. Make a backup of the following files:
../articles.php
../news.php
../readarticle.php
../viewpage.php


2. Open the file ../articles.php in a text editor of your choice and find on approx. line 57:

					echo "<a href='readarticle.php?article_id=".$data['article_id']."'>".$data['article_subject']."</a>$new<br>\n".stripslashes($data['article_snippet']);

Replace this code with the following code:

					echo "<a href='readarticle.php?article_id=".$data['article_id']."'>".$data['article_subject']."</a>$new<br>\n".stripslashes(parseglos($data['article_snippet']));

Save the file and close it.


3. Open the file ../news.php in a text editor of your choice and find on approx. line 45:

			$news_news = $data['news_breaks'] == "y" ? nl2br(stripslashes($data['news_news'])) : stripslashes($data['news_news']);

Replace this code with the following code:

			$news_news = $data['news_breaks'] == "y" ? nl2br(parseglos(stripslashes($data['news_news']))) : parseglos(stripslashes($data['news_news']));


In the same file find on approx. line 145:

			$news_news = $data['news_breaks'] == "y" ? nl2br(stripslashes($data['news_news'])) : stripslashes($data['news_news']);

Replace this code with the following code:

			$news_news = parseglos(stripslashes($data['news_extended'] ? $data['news_extended'] : $data['news_news']));

Save the file and close it.


4. Open the file ../readarticle.php in a text editor of your choice and find on approx. line 33:

		$article = stripslashes($data['article_article']);

Replace this code with the following code:

		$article = parseglos(stripslashes($data['article_article']));

Save the file and close it.


5. Open the file ../viewpage.php in a text editor of your choice and find on approx. line 26:

		eval("?>".stripslashes($data['page_content'])."<?php ");

Replace this code with the following code:

		eval("?>".parseglos(stripslashes($data['page_content']))."<?php ");

Save the file and close it.


