Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F88488783
LINK_COND_add_edit.shtml.wml
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Oct 19, 02:16
Size
9 KB
Mime Type
text/x-php
Expires
Mon, Oct 21, 02:16 (2 d)
Engine
blob
Format
Raw Data
Handle
21780394
Attached To
R3600 invenio-infoscience
LINK_COND_add_edit.shtml.wml
View Options
<?
/*********************************************************************
This file is part of the CERN Document Server Software (CDSware).
Copyright (C) 2002 CERN.
1211 Geneva 23 - Switzerland
<cds.support@cern.ch>
The CDSware 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.
The CDSware 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 CDSware; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*********************************************************************/
//==========================================================================
// File: LINK_COND_add_edit.shtml (flexElink WI)
// Description: Adds a new condition to an existing link or allows to modify
// the data of an existing condition of a link.
// POST parameters:
// linktype --> (required) Name (id) of the link definition which the
// condition belongs (or will belong) to
// action ----> (optional, possible values: ADD, EDIT) Determines which
// operations wants to be performed: adding a new condition or
// editing an existing one. When is set, the update or insert is
// made in the DB; if not, the needed controls for the adding or
// modifying are displayed
// eorder ---> (required if action is EDIT) Evalutation order of the
// condition inside the corresponding link definition. When adding,
// if this parameter is not set the script will look for the last
// evaluation order number assigned in this link definition
// stype ----> (optional, allowed values: EXT, INT) Condition solving type;
// if it isn't specified is put to the default value (EXT)
// el_condition -> (optional) Condition's EL code
// bfile ----> (optional) Base file path for internal link solving
// burl -----> (optional) Base url path for internal link solving
// formats --> (optional) List of file formats ids separated by "|"
// Notes: If the condition is succesfully added to the DB it closes the current
// browser and refreshes the opener one
// Requires: DB, ERROR
// Author: Hector.Sanchez@cern.ch
//==========================================================================
include("localconf.inc.shtml");
include(DB);
include(ERROR);
if( (!isset($linktype)) or (trim($linktype)=="") )
{
print "<b>Link type</b> hasn't been specified";
print "<hr>";
print "<a align=\"center\" href=\"JavaScript:window.close();\">[Close]</a>";
exit;
}
if(get_magic_quotes_gpc())
$linktype=stripslashes($linktype);
$linktype=trim(strtoupper($linktype));
if(!isset($action))
{
$action="ADD";
if( (isset($eorder)) or (trim($eorder)!="") )
{
$action="EDIT";
}
else
{
$eorder="";
}
$el_condition="";
$formats="";
$db=mysql_connect( $DB_HOST, $DB_USER, $DB_PASSWD );
mysql_selectdb( $DB_DB );
if($action=="EDIT")
{
$qry="select el_condition, solvingtype,
base_file, base_url
from flxLINKTYPECONDITIONS
where linktype='$linktype'
and eval_order='$eorder'";
$qh=mysql_query($qry);
if(mysql_num_rows($qh)<=0)
{
print "<b>Condition not found</b>";
print "<hr>";
print "<a align=\"center\" href=\"JavaScript:window.close();\">[Close]</a>";
mysql_close($db);
exit;
}
list($el_condition, $stype, $bfile, $burl)=mysql_fetch_array($qh);
$qry="select f.name
from flxLINKTYPECONDITIONSFILEFORMATS cf, flxFILEFORMATS f
where cf.linktype='$linktype'
and cf.eval_order='$eorder'
and f.name=cf.fname";
$qh=mysql_query($qry);
$formats="";
while($row=mysql_fetch_array($qh))
{
$f=$row[0];
$formats.="$f | ";
}
}
else //Add action
{
$qry="select solvingtype, base_file, base_url
from flxLINKTYPES
where linktype='".addslashes($linktype)."'";
$qh=mysql_query($qry, $db);
list($stype, $bfile, $burl)=mysql_fetch_array($qh);
}
mysql_close($db);
?>
<form action="LINK_COND_add_edit.shtml" method="POST">
<table>
<tr>
<td colspan="2" bgcolor="black">
<font color="white" align="center">
<? echo $action; ?> condition for linktype '
<? echo $linktype;?>'</font>
</td>
</tr>
<tr>
<td>Evaluation order: </td>
<td><input type="text" name="<?
if($action=="EDIT")
print "";
else
print "eorder";?>" value="<?echo $eorder;?>"></td>
</tr>
<tr>
<td>Condition EL Code: </td>
<td><textarea name="el_condition" cols="80" rows="2"><?echo $el_condition;?></textarea></td>
</tr>
<tr>
<td>Solving type</td>
<td><select name="stype">
<option value="EXT"
<?if($stype=="EXT") echo "selected";?>>External</option>
<option value="INT"
<?if($stype=="INT") echo "selected";?>>Internal</option>
</select>
</td>
</tr>
<tr>
<td>Base file path</td>
<td><input type="text" name="bfile" value="<? echo $bfile; ?>" size="107"></td>
</tr>
<tr>
<td>Base url</td>
<td><input type="text" name="burl" value="<? echo $burl; ?>" size="107"></td>
</tr>
<tr>
<td>Associated file formats</td>
<td><input type="text" name="formats" size="107" value="<?echo $formats;?>"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit"></td>
</tr>
</table>
<input type="hidden" name="linktype" value="<?echo $linktype;?>">
<input type="hidden" name="process" value="oo">
<input type="hidden" name="action" value="<?echo $action;?>">
<?if($action=="EDIT"){
print "<input type=\"hidden\" name=\"eorder\" value=\"$eorder\">";
}?>
</form>
<?
}
else
{
if( (!isset($el_condition)) )
$el_condition="";
else
{
$temp_code=$el_condition;
if(get_magic_quotes_gpc())
$temp_code=stripslashes($temp_code);
include(EXECUTOR);
$a=new AELExecutor();
list($ok, $msg)=$a->checkCode( $temp_code );
if(!$ok)
{
print "Condition code incorrect: <b>$msg</b><hr>
<a href=\"JavaScript:window.history.go(-1)\">[Go Back]</a>";
exit;
}
}
$db=mysql_connect( $DB_HOST, $DB_USER, $DB_PASSWD );
mysql_selectdb( $DB_DB );
if( (!isset($eorder)) or (trim($eorder)==""))
{
$qry="select max(eval_order)+1 from flxLINKTYPECONDITIONS
where linktype='$linktype'";
$qh=mysql_query($qry, $db);
list($eorder)=mysql_fetch_array( $qh );
if($eorder==null)
$eorder=0;
}
if(!isset($formats))
{
$formats="";
}
if(!get_magic_quotes_gpc())
{
$el_condition=addslashes($el_condition);
$bfile=addslashes($bfile);
$burl=addslashes($burl);
}
$qry="";
if($action=="ADD")
{
$qry="insert into flxLINKTYPECONDITIONS
(linktype, eval_order, el_condition,
solvingtype, base_file, base_url)
values
('$linktype', '$eorder', '$el_condition',
'$stype', '$bfile', '$burl')";
}
elseif($action=="EDIT")
{
$qry="update flxLINKTYPECONDITIONS
set linktype='$linktype',
eval_order='$eorder',
el_condition='$el_condition',
solvingtype='$stype',
base_file='$bfile',
base_url='$burl'
where linktype='$linktype'
and eval_order='$eorder'";
}
if(!mysql_query( $qry ))
{
print "Impossible to $action condition:<br> ".mysql_error()."<br>".
"<a href=\"JavaScript:window.history.go(-1)\">[Go Back]</a>";
mysql_close($db);
exit;
}
$qry="delete from flxLINKTYPECONDITIONSFILEFORMATS
where linktype='$linktype'
and eval_order='$eorder'";
if(!mysql_query( $qry ))
{
print "Impossible to update associated formats<br> ".mysql_error().
"<a href=\"JavaScript:window.history.go(-1)\">[Go Back]</a>";
mysql_close($db);
exit;
}
$f=split("\|", $formats);
$errors="";
foreach($f as $format)
{
$format=strtoupper(trim($format));
if($format=="")
continue;
$qry="select name
from flxFILEFORMATS
where name='$format'";
$qh=mysql_query($qry);
if(mysql_num_rows($qh)<1)
{
$errors.="Format '$format' doesn't exist, couldn't associate<hr>";
continue;
}
$qry="insert into flxLINKTYPECONDITIONSFILEFORMATS(linktype, eval_order, fname)
values ('$linktype', '$eorder', '$format')";
if(!mysql_query( $qry ))
{
$errors.="Couldn't associate format '$format'<br> ".mysql_error();
}
}
if($errors!="")
{
print "Record succesfully updated but ERRORS found associating formats:<br> <b>$errors</b><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);
window.close();
</script>
<?
}
?>
Event Timeline
Log In to Comment