Page MenuHomec4science

FORMAT_edit.php.wml
No OneTemporary

File Metadata

Created
Mon, May 6, 17:15

FORMAT_edit.php.wml

<?
/*********************************************************************
This file is part of CDS Invenio.
Copyright (C) 2002, 2003, 2004, 2005, 2006 CERN.
1211 Geneva 23 - Switzerland
<cds.support@cern.ch>
CDS Invenio 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.
CDS Invenio 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 CDS Invenio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*********************************************************************/
//==========================================================================
// File: FORMAT_edit.php (flexElink WI)
// Description: Allows to modify format data and updates the changes in the DB.
// It will only update the format data if the EL code is syntactically
// correct and it's "interpretable". It serializes the EL code into the
// corresponding semantic structure and stores it in the DB for
// optimization (no need to re-compile afterwards)
// POST parameters:
// fname --> (required) Name (id) of the format to be modified
// process -> (optional) When is set, the script updates the format data
// in the DB with the parameter values
// fname_orig -> (required if process is set) Original name of the format
// to be updated (the name format can be changed)
// doc ----> (optional) Description of the purpose of the format
// code ---> (optional) Format's EL code
// Notes: If the format is succesfully updated in the DB it closes the current
// browser and refreshes the opener one
// Requires: DB, ERROR, EXECUTOR
// Author: Hector.Sanchez@cern.ch
//==========================================================================
include("localconf.inc.php");
include(DB);
include(ERROR);
if( (!isset($fname)) or (trim($fname)=="") )
{
print "<b>Format name</b> hasn't been specified";
print "<hr>";
print "<a align=\"center\" href=\"JavaScript:window.close();\">[Close]</a>";
exit;
}
$db=mysql_connect( $DB_HOST, $DB_USER, $DB_PASSWD );
mysql_selectdb( $DB_DB );
$fname=trim(strtoupper($fname));
//--------DISPLAY
if(!isset($process))
{
$qry="select value, doc from flxFORMATS where name='$fname'";
$qh=mysql_query( $qry );
if(mysql_num_rows( $qh )<1)
{
print "<b>Format</b> not found";
print "<hr>";
print "<a align=\"center\" href=\"JavaScript:window.close();\">[Close]</a>";
exit;
}
$row=mysql_fetch_array($qh);
list($code, $doc)=$row;
$code = str_replace("&nbsp;","&amp;nbsp;",$code);
?>
<form action="FORMAT_edit.php" method="POST">
<table witdth="100%" bgcolor="#CCCCCC" cellpadding="4" cellspacing="4">
<tr align="center">
<td bgcolor="#CCCCFF">
<font size="4">
Editing format <b>'<? echo $fname;?>'</b></font>
</td>
</tr>
<td bgcolor="#FFFFFF">
<b>Format Name</b> <input name="fname" value="<?echo $fname;?>">
</td>
<tr>
<td align="center" bgcolor="#FFFFFF">
<b>Documentation</b><br>
<textarea name="doc" cols="100" rows="5"><?echo $doc;?></textarea>
</td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF">
<b>EL Code</b><br>
<textarea name="code" cols="100" rows="25"><?echo $code;?></textarea>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input class="formbutton" type="submit" value="UPDATE" name="btnUpd">
<input class="formbutton" type="submit" value="UPDATE&CLOSE" name="btnUpdClose">
</td>
</tr>
</table>
<input type="hidden" name="process" value="oo">
<input type="hidden" name="fname_orig" value="<?echo $fname;?>">
</form>
<?
}
else
{
if( (!isset($code)) )
$code="";
else
{
$temp_code=$code;
if(get_magic_quotes_gpc())
$temp_code=stripslashes($temp_code);
include(EXECUTOR);
$a=new AELExecutor();
list($ok, $msg)=$a->checkCode( $temp_code, array( $fname ) );
if(!$ok)
{
print "Code incorrect: <b>$msg</b><hr> <a href=\"JavaScript:window.history.go(-1)\">[Go Back]</a>";
exit;
}
else
{
$serialized=addslashes(serialize($msg));
}
}
if(!isset($doc))
{
$doc="";
}
if(!get_magic_quotes_gpc())
{
$fname=addslashes($fname);
$code=addslashes($code);
$doc=addslashes($doc);
}
$qry="update flxFORMATS
set name='$fname',
value='$code',
doc='$doc',
serialized='$serialized'
where name='$fname_orig'";
if(!mysql_query( $qry ))
{
print "Impossible to update format: <b>$fname</b><br>".mysql_error()."<hr> <a href=\"JavaScript:window.history.go(-1)\">[Go Back]</a>";
mysql_close( $db );
exit;
}
mysql_close( $db );
?>
<script language="JavaScript">
opener.location.reload(false);
<?
if(isset($btnUpd))
print "window.location=\"FORMAT_edit.php?fname=$fname\";";
else
print "window.close();";
?>
</script>
<?
}
?>

Event Timeline