<?php
/************************************************************************/
/* Maximus CMS: Web Portal System                                       */
/* ==============================                                       */
/*                                                                      */
/* Copyright (c) 2002 - 2006                                            */
/* http://www.php-maximus.fr                                            */
/* dev@php-maximus.org                                                  */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
/* Based on PHP-NUKE: Web Portal System                                 */
/************************************************************************/
defined('MAXIMUS') or Header("Location: ../../index.php");

$module_name = "Encyclopedia";
get_lang($module_name);

$pagetitle = "- "._ENCYCLOPEDIA."";

function encysearch($eid) {
	global $module_name;
	echo "<center><form action=\"modules.php?name=$module_name&amp;file=search\" method=\"post\">"
	."<input type=\"text\" size=\"20\" name=\"query\" />&nbsp;&nbsp;"
	."<input type=\"hidden\" name=\"eid\" value=\"$eid\" />"
	."<input type=\"submit\" value=\""._SEARCH."\" />"
	."</form>"
	."</center>";
}

function alpha($eid) {
	global $module_name;
	echo "<center>"._ENCYSELECTLETTER."</center><br /><br />";
	$alphabet = array ("A","B","C","D","E","F","G","H","I","J","K","L","M",
	"N","O","P","Q","R","S","T","U","V","W","X","Y","Z");
	$num = count($alphabet) - 1;
	echo "<center>[ ";
	$counter = 0;
	$eid = $GLOBALS['db']->XMFnum($eid);
	while (list(, $ltr) = each($alphabet)) {
		$ltr = substr("$ltr", 0,1);
		$numrows = $GLOBALS['db']->sql_numrows($GLOBALS['db']->sql_query("SELECT * FROM `".TABLE_ENCYCLOPEDIA_TEXT."` WHERE `eid`='$eid' AND UPPER(title) LIKE '$ltr%'"));
		if ($numrows > 0) {
			echo "<a href=\"modules.php?name=$module_name&amp;op=terms&amp;eid=$eid&amp;ltr=$ltr\">$ltr</a>";
		} else {
			echo "$ltr";
		}
		if ( $counter == round($num/2) ) {
			echo " ]\n<br />\n[ ";
		} elseif ( $counter != $num ) {
			echo "&nbsp;|&nbsp;\n";
		}
		$counter++;
	}
	echo " ]</center>";
	br('2');
	encysearch($eid);
	echo "<center>"._GOBACK."</center>";
}

switch($op) {

	case 'content':include_once('modules/Encyclopedia/includes/content.php');break;
	case 'list_content':include_once('modules/Encyclopedia/includes/list_content.php');break;
	case 'terms':include_once('modules/Encyclopedia/includes/terms.php');break;
	case 'search':search($query, $eid);break;
	default:include_once('modules/Encyclopedia/includes/list_themes.php');break;

}