<?php
//-----------------------------------------------------------------------------
//
// Copyright (C) 2003-2005 Oy Realnode Ab
//
//-----------------------------------------------------------------------------
//
// subject_headings.php
// Part of the Emilda Project (http://www.emilda.org/)
//
// Description
// Subject Headings.
//
// Authors
// Christoffer Landtman <landtman (at) realnode com>
// Erik Berglund <berglund (at) realnode com>
// Mattias Nordstrom <nordstrom (at) realnode com>
//
//-----------------------------------------------------------------------------
//
// 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, or (at your option) any later version.
//
// 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.
//
// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
//-----------------------------------------------------------------------------
//
// $Id: subject_headings.php,v 1.8.2.1 2005/06/06 14:05:29 eberglun Exp $
//
//-----------------------------------------------------------------------------
// Id used to identify this page within functions.
$PageID = "SUBJECT_HEADINGS";
require_once "common.inc";
require_once "config.inc";
require_once "constants.inc";
require_once "db.inc";
require_once "error.inc";
require_once "layout.inc";
require_once "search.inc";
require_once "language.inc";
require_once "MARC.inc";
require_once "mgmnt.inc";
layout_print_header();
?>
<style type="text/css">
body
{
background: #ffffff;
}
</style>
<form name="search" method="post" action="subject_headings.php">
<input type="hidden" name="id" value="<?php echo $_REQUEST['id']?>" />
<input type="hidden" name="auth" value="<?php echo $_REQUEST['auth']?>" />
<input type="hidden" name="action" value="search" />
<input type="hidden" name="form" value="<?php echo $_REQUEST['form'] ?>" />
<input type="text" name="query" size="12" value="<?php if (isset($_REQUEST['query'])) { echo $_REQUEST['query']; } ?>" />
<input type="submit" name="submit" value="<?php echo _("Search") ?>" />
</form>
<br />
<?php
if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'add')
{
$res = sql_query("INSERT INTO subject_headings SET subject_value='".$_REQUEST['query']."'");
if(mysql_error()) {
layout_page_info(_("Error occurred, please retry!"), 'error');
} else {
// Logging
writeLog("Subject ".$_REQUEST["query"]." added");
}
print '<script language="JavaScript1.1">add_option(window.opener.document.' . $_REQUEST['form'] . '.subjects, \'' . $_REQUEST['query'] . '\', \'' . sprintf(_("Subject %s already exists!"), $_REQUEST['query']) . '\');</script>';
}
if (isset($_REQUEST['query']))
{
$res = sql_query(" SELECT *
FROM subject_headings
WHERE subject_value LIKE '%".$_REQUEST['query']."%'
ORDER BY subject_value ASC");
if(mysql_num_rows($res))
{
while ($row = mysql_fetch_array($res)) {
print '<a href="javascript:add_option(window.opener.document.' . $_REQUEST['form'] . '.subjects, \'' . $row['subject_value'] . '\', \'' . sprintf(_("Subject %s already exists!"), $row['subject_value']) . '\');">'.$row['subject_value'].'</a><br />';
}
}
else
{
?>
<font class="error"><b><?php echo _("No Matches!") ?></b></font>
<br />
<form name="add" method="post" action="subject_headings.php">
<input type="hidden" name="id" value="<?php echo $_REQUEST['id']?>" />
<input type="hidden" name="auth" value="<?php echo $_REQUEST['auth']?>" />
<input type="hidden" name="action" value="add" />
<input type="hidden" name="form" value="<?php echo $_REQUEST['form'] ?>" />
<input type="text" name="query" size="12" value="<?php echo $_REQUEST['query']?>" />
<input type="submit" name="submit" value="<?php echo _("Add") ?>" />
</form>
<?php
}
}
?>
</body>
</html>