Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F75748253
BIBREFORMAT_tree.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
Sun, Aug 4, 00:47
Size
5 KB
Mime Type
text/x-c
Expires
Tue, Aug 6, 00:47 (2 d)
Engine
blob
Format
Raw Data
Handle
19604881
Attached To
R3600 invenio-infoscience
BIBREFORMAT_tree.shtml.wml
View Options
## This file is part of the CERN Document Server Software (CDSware).
## Copyright (C) 2002 CERN.
##
## 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.
<?
include("localconf.inc.shtml");
?>
#include "cdspage.wml" \
title="Reformat Records" \
navbar_name="admin" \
navbar_select="bibformat" \
cdspageboxlefttopadd="<protect><?displayLoginMenu('admin');?> </protect>"
<?
include("security.inc.shtml");
<protect>
## $Id$
## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES.
</protect>
//==========================================================================
// File: BIBREFORMAT_tree.shtml
// Description: Shows the collection tree together with the available
// formats. The user chooses there the collections and formats
// to be updated.
// POST parameters:
// Notes:
// Requires: DB, ERROR
// Author: Eduardo.Margallo@cern.ch
//==========================================================================
include(DB);
include(ERROR);
include(HEADER);
?>
<p>This utility allows you to reformat all the records in a collection and
upload them back to the database. Selecting an output type in an upper
node will cause all the subtree to be rebuilt.
<p>If you need more specific patterns to choose records please use
<a href="BIBREFORMAT_hand.shtml">Manual Choice</a>.
<br><br>
<?
$db = mysql_connect( $DB_HOST, $DB_USER, $DB_PASSWD ) or
errormsg( "Coudn't connect to mySQL" );
mysql_select_db( $DB_DB ) or
errrormsg( "Couldn't connect into database " . $DB_DB );
$query = "select f.name from format as f left join
flxBEHAVIORS as ot ON ot.name=UPPER(f.code) where
f.code NOT LIKE 'x%' and ot.name is not
null";
$result = mysql_query( $query );
$num_fmts = mysql_num_rows( $result );
/* returns a string limited to $length, truncating the original one if
necessary and adding ... */
function limit_length( $name, $length ) {
return strlen( $name ) < $length ?
$name : substr( $name, 0, $length-3 ) . "...";
}
/* Puts out a checkbox list with the available formats for a collection */
function print_formats( $id ) {
// For the time being formats are hard-coded. collection_format will
// later on be the source for the options in this select item
$query = "select f.code,f.name from collection_format as cf, format as f left join
flxBEHAVIORS as ot ON ot.name=UPPER(f.code) where
cf.id_format=f.id and f.code NOT LIKE 'x%' and ot.name is not
null and cf.id_collection=$id";
$result = mysql_query( $query );
$i = 0;
?>
<td><table width='100%' cellpadding='0' cellspacing='0' border='0'>
<small><tr>
<?
while( $row = mysql_fetch_array( $result ) ) {
if( $i % 4 == 0 ) {
?></tr><tr><?
}
?>
<td align=right width="25%">
<small><small> <? echo limit_length( $row["name"], 20 )?> </small></small>
<input type=checkbox name=<? echo "'chk_" . $id . "_" . $i ."'"?>
value=<? echo "'" . $row["code"] ."'>" ?>
</td>
<?
$i = $i + 1;
}
for( ; $i % 4 <> $num_fmts % 4; $i++ )
print "<td> </td>";
?></tr></small></table></td><?
}
/* Prints out the category tree with the available formats for each
cathegory */
function generate_tree( $id, $level ) {
global $row_number;
$query = "select name from collection where id=$id";
$result = mysql_query( $query );
$row = mysql_fetch_array( $result );
if( $id ) {
$header = "h" . ($level+2);
$size = max( 10, 16-2*$level );
$syms = array( "+ ", "* ", "- " );
$name = limit_length( $row["name"], 40 );
$color = $row_number%2==0 ? "#E0E0D0": "#FFFFFF";
$row_number = $row_number + 1;
echo "<tr bgcolor='$color' ><td>";
for( $i = 1; $i < 2 * $level; $i++ ) echo " ";
echo "<span style=\"font-size: " . $size . "pt\">" . $syms[$level%3] .
$name . "</span></td>";
print_formats( $id );
echo "</tr>\n";
}
else {
?><table width='100%' border=0>
<form action='BIBREFORMAT_process.shtml' method='post'>
<th width=300 align=center>Collection name</th>
<th colspan=1 align=center>Output Format Selection</th></tr><?
}
$sub_query = "select * from collection_collection where id_dad=$id";
$result = mysql_query( $sub_query );
$num_results = mysql_num_rows( $result );
if( $num_results == 0 ) return;
for( $i=0; $i < $num_results; $i++ ) {
$row = mysql_fetch_array( $result );
generate_tree( $row["id_son"], $level + 1 );
echo "\n";
}
if( !$id ) {
echo "<tr><td></td><td><input type='submit'></td></tr>\n";
echo "</table>\n";
echo "</form>\n";
}
}
generate_tree( 0, 0 );
include(FOOTER)
?>
Event Timeline
Log In to Comment