PHP Classes
elePHPant
Icontem

File: pages/p_pubform.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Javier AP  >  Pergamus Publication Manager  >  pages/p_pubform.php  >  Download  
File: pages/p_pubform.php
Role: Auxiliary script
Content type: text/plain
Description: Publication form
Class: Pergamus Publication Manager
Web based manager for scientific publications
Author: By
Last change: New version 1.0.
Date: 10 years ago
Size: 9,903 bytes
 

Contents

Class file image Download
<?php
include '../class/class_publication.php';
include
'../class/class_collection.php';
include
'../class/autentification.php';
include
'../class/gestor_articulos.php';

$Article_fields = array('author','title','year','journal','month','volume','number','pages','key','url');
$InProceedings_fields = array('author','title','year','crossref','booktitle','pages','month','editor','volume','number','series','organization','key','url');
$InBook_fields = array('author','title','year','publisher','chapter','month','volume','address','series','edition','key','url');
$TechReport_fields = array('author','title','year','institution','month','type','number','address','key','url');
$Book_fields = array('author','title','year','publisher','month','volume','address','series','edition','key','url');
$PhDThesis_fields = array('author','title','year','school','moth','type','number','address','key','url');
?>

<html>
<head>
<title>Pergamus Publication Manager</title>
<link href="../style.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html" charset="utf-8"">
</head>
<body>

<div class="main">
  <?php
  $validation
= form_validation($year, array($author, $title, $year));
 
//If we arrive here to modify a pub, get the metadata
 
if($modify == 'true'){
    
$bib = new Collection('publications');
        
$pubs_list = $bib->build_all_pubs();
    
$pub_to_modify = $pubs_list[$bibtex_id];
    
$pub_type = $pub_to_modify->bibtex_type;
  }
 
$fields = $pub_type.'_fields';
  eval(
"\$fields_list = $$fields;");
  print(
"<h1>".get_section_title($pub_type)."</h1>");
  include
'p_session_bar.php';
  if(
$validation == 'valid' && $confirmation != 'true' && $confirmation != 'reintento') {
//********************************************//
// Data confirmation page //
//********************************************//
   
if($_FILES['file']['name'] != '') copy_file('file','../pubs/temp/');
 
?>
<table width="100%" border="0" cellpadding="0" cellspacing="5">
    <tr>
      <td colspan="3"><h2>Review the data ...</h2> </td>
    </tr>
    <?php
   
//Filter empty-string-data, uppercase & print
   
foreach($fields_list as $field){
        
$value = eval("return \"\$$field\";");
        if(
$value != ''){
          print(
"<tr>\n<td width=\"30%\"><b>".ucfirst($field)."</b></td>\n");
          print(
"<td colspan=\"2\">$value</td>\n</tr>\n");
        }
     }

    if(
$modify = 'true' && $update_file == 'false'){ ?>
<tr>
          <td><i>File:</i></td>
          <td colspan="2"><?= $file_old ?></td>
        </tr>
    <?php } else if($_FILES['file']['name'] != '' || $modify = 'true' && $update_file == 'true') {?>
        <tr>
          <td><i>File:</i></td>
          <td colspan="2"><?= $_FILES['file']['name'] ?></td>
        </tr>
    <?php } ?>
    <tr>
      <td>&nbsp;</td>
      <td width="20%">
        <?php //___Accept-button form________________________________________________
       
if($modify == 'true'){ ?>
          <form action="p_pubform.php?modify=true&bibtex_id=<?= urlencode($pub_to_modify->get_bibtex_id()) ?>" method="post" target="_self">
        <?php } else { ?>
<form action="p_pubform.php?pub_type=<?= $pub_type ?>" method="post" target="_self">
        <?php } ?>
<input name="image" TYPE="image" SRC="../img/bt_aceptar.jpg" BORDER="0">
        <input type="hidden" name="confirmation" value="true">
        <?php
       
foreach($fields_list as $field){
           
$value = eval("return \"\$$field\";");
            print(
"<input type=\"hidden\" name=\"$field\" value=\"$value\">\n");
        }
        if(isset(
$file_old)) print("<input type=\"hidden\" name=\"file_old\" value=\"$file_old\">");
        if(isset(
$update_file) && $update_file == 'true'){
            print(
"<input type=\"hidden\" name=\"file\" value=\"".$_FILES['file']['name']."\">");
            print(
"<input type=\"hidden\" name=\"update_file\" value=\"true\">");
        } else {
            print(
"<input type=\"hidden\" name=\"file\" value=\"$file_old\">");
            print(
"<input type=\"hidden\" name=\"update_file\" value=\"false\">");
        }
       
?>
        </form>
      </td>
      <td width="50%">
        <?php //___Cancel-button form______________________________________________
       
if($modify == 'true'){ ?>
          <form action="p_pubform.php?modify=true&bibtex_id=<?= urlencode($pub_to_modify->get_bibtex_id()) ?>" method="post" target="_self">
        <?php } else { ?>
<form action="p_pubform.php?pub_type=<?= $pub_type ?>" method="post" target="_self">
        <?php } ?>
<input name="image" TYPE="image" SRC="../img/bt_cancelar.jpg" BORDER="0">
        <input type="hidden" name="confirmation" value="reintento">
        <?php
       
foreach($fields_list as $field){
           
$value = eval("return \"\$$field\";");
            print(
"<input type=\"hidden\" name=\"$field\" value=\"$value\">\n");
        }
        if(isset(
$file_old)) print("<input type=\"hidden\" name=\"file_old\" value=\"$file_old\">");
        if(isset(
$update_file) && $update_file == 'true'){
            print(
"<input type=\"hidden\" name=\"file\" value=\"".$_FILES['file']['name']."\">");
            print(
"<input type=\"hidden\" name=\"update_file\" value=\"true\">");
        } else {
            print(
"<input type=\"hidden\" name=\"file\" value=\"$file_old\">");
            print(
"<input type=\"hidden\" name=\"update_file\" value=\"false\">");
        }
       
?>
</form>
      </td>
    </tr>
  </table>
      <br>
<?php
 
} else if($confirmation == 'true') {
//********************************************//
// Final page (operation confirmation) //
//********************************************//
      
    
if($modify == 'true'){
        
$bib =& new Collection('publications');
        
$bib->remove_by_attr('title', $pub_to_modify->metadata['title']);
         if(
$update_file == 'true' && $file_old != ''){
           
unlink("../pubs/$file_old");
            } else if(
$update == 'false') {
           
$file = $file_old;
         }
       }
      
      
$data = array();
       foreach(
$fields_list as $field){
        
$value = eval("return \"\$$field\";");
        if(
$value != ''){
         
$data[$field] = $value;
        }
       }
      
      
$pub = new Publication($pub_type,$data,$file,$url,$_SESSION["USER"]);
      
$pub->save_in_xml();
   
    if(
$file != '' && ($update_file == 'true' || !isset($modify)))
       
rename("../pubs/temp/$file","../pubs/$file");
?>
<h3> The new publication has been successfully
    <?php if($modify == 'true'){ echo ' modified.'; }
          else{ echo
' added.'; }?>
</h3>
    <?php include('p_options.php') ?>
     
<?php
 
} else {
//********************************************//
// Start, cancellation or modification page //
//********************************************//
       //If we arrive here after a cancellation we get sure that any temporal file is deleted.
      
if($confirmation == 'reintento' && $file != '') remove_file($file, '../pubs/temp/');
      
//Then print the form
      
print("<table border=\"0\" width=\"100%\">\n<form method=\"POST\" enctype=\"multipart/form-data\" action=\"p_pubform.php?pub_type=$pub_type\">");
       foreach(
$fields_list as $field){
          
$value = eval("return \"\$$field\";");
          print(
"<tr>\n<td><b>".ucfirst($field));
          if(
$field == 'title' || $field == 'year') print ' *';
          if(
$field == 'author') print ' **';
          print(
"</b></td>\n");
          print(
"<td><input type=\"text\" size=\"60\" name=\"$field\"");
          if(
$modify == 'true'){
             print(
" value=\"".$pub_to_modify->metadata[$field]."\"></td>\n</tr>\n");
          } else{
             print(
" value=\"$value\"></td>\n</tr>\n");
          }
       }
  
?>
<tr>
        <td><b>PDF/PS file:</b></td>
        <td><input type="file" size="50" name="file"></td>
      </tr>
      <?php if($modify && $pub_to_modify->metadata['file'] !='') { ?>
<tr>
        <td></td>
        <td><i><font color="#990000">Published file:</font></i><br>
        <a href="../pubs/<?php echo($pub_to_modify->metadata['file']) ?>"><?php echo($pub_to_modify->metadata['file']) ?></a>
        </td>
      </tr>
      <tr>
        <td></td>
        <td><font color="#990000"><i>Update file:</i></font>
           <table border="0">
           <td><input type="radio" name="update_file" value="true"> Yes<br></td>
            <td><input type="radio" name="update_file" value="false" checked> No<br></td>
           </table>
        </td>
      </tr>
      <?php } else if ($modify){?>
<input type="hidden" name="update_file" value="true">
      <?php } ?>
<tr>
        <td></td>
        <td>
       
        <?php if(isset($modify)) {
       
//Vars to post if we are modifying data that already exists
        // · bibtex_id
        // · modify
        // · file_old (if we want to update a file)
        // · update_file
       
?>
<input type="hidden" name="bibtex_id" value="<?= $pub_to_modify->get_bibtex_id() ?>">
        <input type="hidden" name="modify" value="true">
        <?php }?>
<?php if(isset($pub_to_modify->metadata['file']) && $pub_to_modify->metadata['file'] !='') { ?>
<input type="hidden" name="file_old" value="<?= $pub_to_modify->metadata['file'] ?>">
        <?php }?>

        <input type="hidden" name="confirmation" value="false">
        <input TYPE="image" SRC="../img/bt_enviar.jpg" align="middle" width="59" height="20" BORDER="0">
        </td>
      </tr>
      <?php if($confirmation == 'false' && $validation != 'valido') {?>
<tr>
        <td></td>
        <td width="81%" colspan="2"> <font color="#990000"> <strong><em>Please, correct this: <br>
        </em></strong><?php echo($validation) ?></font></td>
      </tr>
      <?php } ?>
    </form>
  </table>
  <p align="left">
     <font color="#996700"><i>
     * "author", "title" and "year" fields are mandatory.<br>
     ** Follow this format: Last name<b>,</b> First Name <b>&amp;</b> Last name<b>,</b> First Name ...
     </i></font>
  </p>
  <?php } ?>
<?php include 'p_banner.php'?>
<p>&nbsp; </p>
</div>
</body>
</html>