Exemplo n.º 1
0
 public function __construct()
 {
     parent::__construct('view_authors', 'Author Information', 'view_author.php');
     if ($this->loginError) {
         return;
     }
     $this->loadHttpVars(true, false);
     $this->use_mootools = true;
     // check if this author id is valid
     if (!isset($this->author_id) || !is_numeric($this->author_id)) {
         $this->pageError = true;
         return;
     }
     $auth = new pdAuthor();
     $auth->dbLoad($this->db, $this->author_id, pdAuthor::DB_LOAD_PUBS_MIN | pdAuthor::DB_LOAD_INTERESTS);
     if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], 'Admin/add_author.php?author_id=') !== false) {
         // the user added or changed an author
         echo "Your change has been sumitted.<br/><hr/>\n";
     }
     echo '<h3>', $auth->name;
     if ($this->access_level > 0) {
         echo $this->getAuthorIcons($auth, 0x6);
     }
     echo '</h3>', $this->authorShow($auth);
     echo "<hr><a href='list_author.php?tab=" . $auth->name[0] . "'>Author List</a>";
 }
Exemplo n.º 2
0
 public static function &newFromDb(&$db, $author_id, $flags = self::DB_LOAD_ALL)
 {
     assert('is_numeric($author_id)');
     $author = new pdAuthor();
     $author->dbLoad($db, $author_id, $flags);
     return $author;
 }
Exemplo n.º 3
0
 public function __construct()
 {
     parent::__construct('delete_author', 'Delete Author', 'Admin/delete_author.php');
     if ($this->loginError) {
         return;
     }
     $this->loadHttpVars();
     if (!isset($this->author_id) || !is_numeric($this->author_id)) {
         $this->pageError = true;
         return;
     }
     $author = new pdAuthor();
     $result = $author->dbLoad($this->db, $this->author_id);
     if (!$result) {
         $this->pageError = true;
         return;
     }
     $pub_list = pdPubList::create($this->db, array('author_id' => $this->author_id));
     if (isset($pub_list) && count($pub_list) > 0) {
         echo 'Cannot delete Author <b>', $author->name, '</b>.<p/>', 'The author has the following publications in the database:', displayPubList($this->db, $pub_list, true, -1, null, null, '../');
         return;
     }
     $form =& $this->confirmForm('deleter');
     $form->addElement('hidden', 'author_id', $this->author_id);
     if ($form->validate()) {
         $values = $form->exportValues();
         // This is where the actual deletion happens.
         $name = $author->name;
         $author->dbDelete($this->db);
         echo 'You have successfully removed the following author from the database:', '<p/><b>', $name, '</b>';
     } else {
         if (!isset($this->author_id) || !is_numeric($this->author_id)) {
             $this->pageError = true;
             return;
         }
         $renderer = new HTML_QuickForm_Renderer_QuickHtml();
         $form->accept($renderer);
         $table = new HTML_Table(array('width' => '100%', 'border' => '0', 'cellpadding' => '6', 'cellspacing' => '0'));
         $table->addRow(array('Name:', $author->name));
         if (isset($author->title) && trim($author->title != '')) {
             $table->addRow(array('Title:', $author->title));
         }
         $table->addRow(array('Email:', $author->email));
         $table->addRow(array('Organization:', $author->organization));
         $cell = '';
         if (isset($author->webpage) && trim($author->webpage != '')) {
             $cell = '<a href="' . $author->webpage . '">' . $author->webpage . '</a>';
         } else {
             $cell = "none";
         }
         $table->addRow(array('Web page:', $cell));
         $table->updateColAttributes(0, array('class' => 'emph', 'width' => '25%'));
         echo '<h3>Delete Author</h3><p/>Delete the following author?';
         $this->form =& $form;
         $this->renderer =& $renderer;
         $this->table =& $table;
     }
 }
Exemplo n.º 4
0
 public function __construct()
 {
     parent::__construct('all_authors');
     if ($this->loginError) {
         return;
     }
     $this->loadHttpVars(true, false);
     if (!isset($this->tab)) {
         $this->tab = 'A';
     } else {
         $tab = strtoupper($this->tab);
         if (strlen($tab) != 1 || ord($tab) < ord('A') || ord($tab) > ord('Z')) {
             $this->pageError = true;
             return;
         }
     }
     $auth_list = pdAuthorList::create($this->db, null, $this->tab);
     echo $this->alphaSelMenu($this->tab, get_class($this) . '.php');
     echo "<h2>Authors</h2>";
     if (empty($auth_list) || count($auth_list) == 0) {
         echo 'No authors with last name starting with ', $this->tab, '<br/>';
         return;
     }
     foreach ($auth_list as $author_id => $name) {
         $author = new pdAuthor();
         $author->dbLoad($this->db, $author_id, pdAuthor::DB_LOAD_BASIC | pdAuthor::DB_LOAD_PUBS_MIN);
         $name = '<span class="emph"><a href="view_author.php?author_id=' . $author_id . '">' . $name . '</a>&nbsp;';
         $icons = $this->getAuthorIcons($author) . '</span>';
         $info = array();
         if ($author->title != '') {
             $info[] = '<span class="small">' . $author->title . '</span>';
         }
         if ($author->organization != '') {
             $info[] = '<span class="small">' . $author->organization . '</span>';
         }
         $info[] .= '<a href="list_publication.php?author_id=' . $author_id . '&menu=0"><span class="small" style="color:#000;font-weight:normal;">' . 'Publication entries in database: ' . $author->totalPublications . '</span>';
         $table = new HTML_Table(array('class' => 'publist'));
         $table->addRow(array($name . '<br/>' . implode('<br/>', $info), $icons));
         $table->updateColAttributes(1, array('class' => 'icons'), NULL);
         echo $table->toHtml();
         unset($table);
     }
 }
Exemplo n.º 5
0
 public function __construct()
 {
     parent::__construct('view_publications');
     if ($this->loginError) {
         return;
     }
     $this->loadHttpVars();
     if (!isset($this->menu)) {
         $this->menu = 1;
     }
     if (isset($this->year)) {
         $pub_list = pdPubList::create($this->db, array('year_cat' => $this->year));
         $title = '<h1>Publications in ' . $this->year . '</h1>';
     } else {
         if (isset($this->venue_id)) {
             $vl = pdVenueList::create($this->db);
             if (!array_key_exists($this->venue_id, $vl)) {
                 $this->pageError = true;
                 return;
             }
             $pub_list = pdPubList::create($this->db, array('venue_id' => $this->venue_id));
             $title = '<h1>Publications in Venue "' . $vl[$this->venue_id] . '"</h1>';
         } else {
             if (isset($this->cat_id)) {
                 $cl = pdCatList::create($this->db);
                 if (!array_key_exists($this->cat_id, $cl)) {
                     $this->pageError = true;
                     return;
                 }
                 $pub_list = pdPubList::create($this->db, array('cat_id' => $this->cat_id));
                 $title = '<h1>Publications in Category "' . $cl[$this->cat_id] . '"</h1>';
             } else {
                 if (isset($this->keyword)) {
                     $pub_list = pdPubList::create($this->db, array('keyword' => $this->keyword));
                     $title = '<h1>Publications with keyword "' . $this->keyword . '"</h1>';
                 } else {
                     if (isset($this->author_id)) {
                         // If there exists an author_id, only extract the publications for
                         // that author
                         //
                         // This is used when viewing an author.
                         $pub_list = pdPubList::create($this->db, array('author_id_cat' => $this->author_id));
                         $auth = new pdAuthor();
                         $auth->dbLoad($this->db, $this->author_id, pdAuthor::DB_LOAD_BASIC);
                         $title = '<h1>Publications by ' . $auth->name . '</h1>';
                     } else {
                         if (isset($this->by) || !isset($_GET) == 0) {
                             if (count($_GET) == 0) {
                                 $viewCat = 'year';
                             } else {
                                 $viewCat = $this->by;
                             }
                             $this->pubSelect($viewCat);
                             return;
                         } else {
                             $this->pageError = true;
                         }
                     }
                 }
             }
         }
     }
     if ($this->menu) {
         echo $this->pubSelMenu(), "<br/>\n";
     }
     echo $title;
     echo displayPubList($this->db, $pub_list);
 }
Exemplo n.º 6
0
    public function __construct()
    {
        parent::__construct('add_author');
        $this->loadHttpVars();
        $this->use_mootools = true;
        $this->all_interests = pdAuthInterests::createList($this->db);
        // before showing a loggin error, show the correct title for the page
        if (isset($_SESSION['state']) && $_SESSION['state'] == 'pub_add') {
            $pub =& $_SESSION['pub'];
            if (isset($pub->pub_id)) {
                $this->page_title = 'Edit Publication';
            } else {
                $this->page_title = 'Add Publication';
            }
        } else {
            if ($this->author_id == null) {
                $this->page_title = 'Add Author';
            } else {
                $this->page_title = 'Edit Author';
            }
        }
        if ($this->loginError) {
            return;
        }
        $author = new pdAuthor();
        if ($this->author_id != null) {
            $result = $author->dbLoad($this->db, $this->author_id, pdAuthor::DB_LOAD_BASIC | pdAuthor::DB_LOAD_INTERESTS);
            if (!$result) {
                $this->pageError = true;
                return;
            }
        }
        $form = new HTML_QuickForm('authorForm');
        $form->addElement('hidden', 'author_id', $this->author_id);
        if ($this->author_id == null) {
            $form->addElement('header', 'add_author_hdr', '<span class="Tips1" title="Adding an Author::Input the
 author\'s first name, last name, email address and organization. Optionally,
 interests may be selected from the list given or new interest can be added to
 the database.
 &lt;p/&gt;
 Multiple interests can be selected by holding down the control
 key and then left-clicking on the text. If you do not see the
 appropriate interests you can add them using the &lt;b&gt;Add
 Interest&lt;/b&gt; link.
 &lt;p/&gt;
 Clicking the &lt;b&gt;Add Interest&lt;/b&gt; link will bring up a
 new field each it is pressed. Type the text of the new interest into the
 this field.">Add Author</span>');
        } else {
            $form->addElement('header', null, 'Edit Author');
        }
        $form->addElement('text', 'firstname', 'First Name:', array('size' => 50, 'maxlength' => 250));
        $form->registerRule('invalid_punct', 'regex', '/^[^()\\/\\*\\^\\?#!@$%+=,\\"\'><~\\[\\]{}]+$/');
        $form->addRule('firstname', 'the first name cannot contain punctuation', 'invalid_punct', null, 'client');
        $form->addElement('text', 'lastname', 'Last Name:', array('size' => 50, 'maxlength' => 250));
        $form->addElement('select', 'authors_in_db', null, pdAuthorList::create($this->db), array('style' => 'overflow: hidden; visibility: hidden; width: 1px; height: 0;'));
        $tooltip = 'Title::The author\'s formal title. For example:
 &lt;ul&gt;
 &lt;li&gt;Professor&lt;/li&gt;
 &lt;li&gt;PostDoc&lt;/li&gt;
 &lt;li&gt;PhD Student&lt;/li&gt;
 &lt;li&gt;MSc Student&lt;/li&gt;
 &lt;li&gt;Colleague&lt;/li&gt;
 &lt;/ul&gt;';
        $form->addElement('text', 'title', "<span class=\"Tips1\" title=\"{$tooltip}\">Title:</span>", array('size' => 50, 'maxlength' => 250));
        $form->addElement('text', 'email', 'email:', array('size' => 50, 'maxlength' => 250));
        $form->addRule('email', 'invalid email address', 'email', null, 'client');
        $form->addElement('text', 'organization', 'Organization:', array('size' => 50, 'maxlength' => 250));
        $form->addElement('text', 'webpage', 'Webpage:', array('size' => 50, 'maxlength' => 250));
        $ref = '<br/><div class="small"><a href="javascript:dataKeep(' . ($this->numNewInterests + 1) . ')">[Add Interest]</a></div>';
        $ams = $form->addElement('advmultiselect', 'interests', null, $this->all_interests, array('size' => 15, 'class' => 'pool', 'style' => 'width:200px;'));
        $ams->setLabel(array('Interests:' . $ref, 'Available', 'Selected'));
        $ams->setButtonAttributes('add', array('value' => 'Add >>', 'class' => 'inputCommand'));
        $ams->setButtonAttributes('remove', array('value' => '<< Remove', 'class' => 'inputCommand'));
        $template = <<<TEMPLATE_END
{javascript}
<table{class}>
  <thead>
    <tr>
      <!-- BEGIN label_2 --><tr><th align="center">{label_2}</th><!-- END label_2 -->
      <!-- BEGIN label_3 --><th align="center">{label_3}</th><!-- END label_3 -->
    <tr>
  </thead>
<tr>
  <td>{unselected}</td>
  <td>{selected}</td>
</tr>
<tr>
  <td>{add}</td>
  <td>{remove}</td>
</tr>
</table>
TEMPLATE_END;
        $ams->setElementTemplate($template);
        if (isset($_SESSION['state']) && $_SESSION['state'] == 'pub_add') {
            $form->addElement('static', null, null, '<span class="small">When done adding new authors press the "Next Step" button</span>');
        }
        for ($i = 0; $i < $this->numNewInterests; $i++) {
            $form->addElement('text', 'newInterests[' . $i . ']', 'Interest Name ' . ($i + 1) . ':', array('size' => 50, 'maxlength' => 250));
        }
        if (isset($_SESSION['state']) && $_SESSION['state'] == 'pub_add') {
            $pos = strpos($_SERVER['PHP_SELF'], 'papersdb');
            $next_page = substr($_SERVER['PHP_SELF'], 0, $pos) . 'papersdb/Admin/add_pub2.php';
            $url = substr($_SERVER['PHP_SELF'], 0, $pos) . 'papersdb';
            $buttons[] = HTML_QuickForm::createElement('button', 'prev_step', '<< Previous Step', array('onClick' => "location.href='" . $next_page . "';"));
            $buttons[] = HTML_QuickForm::createElement('button', 'cancel', 'Cancel', array('onclick' => "cancelConfirm();"));
            $buttons[] = HTML_QuickForm::createElement('reset', 'reset', 'Reset');
            $buttons[] = HTML_QuickForm::createElement('submit', 'add_another', 'Submit and Add Another Author');
            $buttons[] = HTML_QuickForm::createElement('submit', 'next_step', 'Next Step >>');
            if ($pub->pub_id != '') {
                $buttons[] = HTML_QuickForm::createElement('submit', 'finish', 'Finish');
            }
            $form->addGroup($buttons, 'buttons', '', '&nbsp', false);
            add_pub_base::addPubDisableMenuItems();
        } else {
            $form->addRule('firstname', 'a first name is required', 'required', null, 'client');
            $form->addRule('lastname', 'a last name is required', 'required', null, 'client');
            if ($this->author_id == null) {
                $button_label = 'Add Author';
            } else {
                $button_label = 'Submit';
            }
            $form->addGroup(array(HTML_QuickForm::createElement('reset', 'reset', 'Reset'), HTML_QuickForm::createElement('submit', 'submit', $button_label)), null, null, '&nbsp;');
        }
        $form->addElement('hidden', 'numNewInterests', $this->numNewInterests);
        $this->form =& $form;
        if ($form->validate()) {
            $this->processForm();
        } else {
            $this->renderForm($author);
        }
    }
Exemplo n.º 7
0
#!/usr/bin/env php

<?php 
require_once '../includes/defines.php';
require_once 'includes/functions.php';
require_once 'includes/pdDb.php';
require_once 'includes/pdAuthorList.php';
require_once 'includes/pdPubList.php';
$db = new pdDb(array('name' => 'pubDB'));
$authors = pdAuthorList::create($db);
if (count($authors) == 0) {
    echo 'No authors in database';
    $db->close();
    exit;
}
foreach ($authors as $auth_id => $name) {
    $author = new pdAuthor();
    $author->dbLoad($db, $auth_id);
    foreach ($author->pub_list as $pub) {
        $pub->dbLoad($db, $pub->pub_id);
        $auth_names = array();
        foreach ($pub->authors as $other_auths) {
            $auth_names[] = $other_auths->name;
        }
        echo $author->name, "\t", $pub->title, "\t";
        echo implode("\t", array_diff($auth_names, array($author->name)));
        echo "\n";
    }
}
$db->close();
Exemplo n.º 8
0
 public function addAuthor($db, $mixed)
 {
     if (is_object($mixed)) {
         // check if publication already has this author
         if (isset($this->authors)) {
             foreach ($this->authors as $author) {
                 if ($author->author_id == $mixed->author_id) {
                     return;
                 }
             }
         }
         $this->authors[] = $mixed;
         return;
     } else {
         if (is_array($mixed)) {
             // replaces all authors
             unset($this->authors);
             // assigns each author
             foreach ($mixed as $index => $author_id) {
                 $author = new pdAuthor();
                 $result = $author->dbLoad($db, $author_id, pdAuthor::DB_LOAD_BASIC);
                 assert('$result');
                 $this->authors[$index] = $author;
             }
             return;
         }
     }
     // check if publication already has this author
     if (isset($this->authors) && count($this->authors) > 0) {
         foreach ($this->authors as $author) {
             assert('$author->author_id != $mixed');
         }
     }
     assert('is_numeric($mixed)');
     $author = new pdAuthor();
     $result = $author->dbLoad($db, $mixed, pdAuthor::DB_LOAD_BASIC);
     assert('$result');
     $this->authors[] = $author;
 }
Exemplo n.º 9
0
<?php

/**
 * This script is meant to be called in response to an AJAX request.
 * 
 * It returns a listing of all the publication by a specified author. The
 * author is specified in the URL query string.
 */
require_once '../includes/defines.php';
require_once 'includes/functions.php';
require_once 'includes/htmlUtils.php';
require_once 'includes/pdDb.php';
require_once 'includes/pdAuthor.php';
if (!isset($_GET['author_id'])) {
    exit('script called with invalid arguments');
}
$db = pdDb::defaultNew();
$auth = new pdAuthor();
$auth->dbLoad($db, $_GET['author_id'], pdAuthor::DB_LOAD_PUBS_ALL | pdAuthor::DB_LOAD_INTERESTS);
if (!is_array($auth->pub_list)) {
    exit('Author with id ' . $_GET['author_id'] . ' does not have any publication entries in the database');
}
echo displayPubList($db, $auth->pub_list);