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>"; }
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; }
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; } }
public function __construct() { parent::__construct('aicml_staff'); if ($this->loginError) { return; } echo '<h1>AICML Staff</h1>'; $table = new HTML_Table(array('class' => 'stats')); $table->addRow(array('Name', 'Start', 'End', 'Num Pubs', 'Pub Ids')); $table->setRowType(0, 'th'); //pdDb::debugOn(); $staff_list = pdAicmlStaffList::create($this->db); foreach ($staff_list as $staff_id => $author_id) { $staff = pdAicmlStaff::newFromDb($this->db, $staff_id, pdAicmlStaff::DB_LOAD_PUBS_MIN); $author = pdAuthor::newFromDb($this->db, $author_id, pdAuthor::DB_LOAD_MIN); //debugVar('staff', array($staff, $author)); $pub_links = array(); if (isset($staff->pub_ids)) { foreach ($staff->pub_ids as $pub_id) { $pub_links[] = '<a href="../view_publication.php?pub_id=' . $pub_id . '">' . $pub_id . '</a>'; } } $table->addRow(array($author->name, $staff->start_date, $staff->end_date, count($staff->pub_ids), implode(', ', $pub_links)), array('class' => 'stats_odd')); } echo $table->toHtml(); }
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> '; $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); } }
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); }
public function processForm() { $form =& $this->form; $values =& $form->exportValues(); // check if user pressed "Next Step >>" button and did not enter // a name if (isset($values['next_step']) && isset($_SESSION['state']) && $_SESSION['state'] == 'pub_add') { if ((!isset($values['firstname']) || $values['firstname'] == '') && (!isset($values['lastname']) || $values['lastname'] == '')) { header('Location: add_pub3.php'); return; } } // if user has not entered a name then bring if (isset($values['add_another']) && isset($_SESSION['state']) && $_SESSION['state'] == 'pub_add') { if ((!isset($values['firstname']) || $values['firstname'] == '') && (!isset($values['lastname']) || $values['lastname'] == '')) { header('Location: add_author.php'); return; } } $author = new pdAuthor(); if ($this->author_id != null) { $author->author_id = $this->author_id; } $author->name = $values['lastname'] . ', ' . $values['firstname']; $author->firstname = $values['firstname']; $author->lastname = $values['lastname']; $author->title = $values['title']; $author->email = $values['email']; $author->organization = $values['organization']; $author->webpage = $values['webpage']; $author->interests = array(); if (isset($values['interests']) && count($values['interests']) > 0) { foreach ($values['interests'] as $int_id) { $author->interests[$int_id] = $this->all_interests[$int_id]; } } if (isset($values['newInterests']) && count($values['newInterests']) > 0) { $author->interests = array_merge($author->interests, $values['newInterests']); } // check if an author with a similar name already exists if ($this->author_id == null) { $like_authors = pdAuthorList::create($this->db, $values['firstname'], $values['lastname']); if (count($like_authors) > 0) { $_SESSION['new_author'] = $author; header('Location: author_confirm.php'); return; } } $author->dbSave($this->db); if (isset($_SESSION['state']) && $_SESSION['state'] == 'pub_add') { assert('isset($_SESSION["pub"])'); $pub =& $_SESSION['pub']; $pub->addAuthor($this->db, $author->author_id); if ($this->debug) { return; } if (isset($values['finish'])) { header('Location: add_pub_submit.php'); } else { if (isset($values['add_another'])) { header('Location: add_author.php'); } else { header('Location: add_pub2.php'); } } return; } header('Location: ../view_author.php?author_id=' . $author->author_id); }
#!/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();
foreach ($all_interests as $k => $i) { if (is_numeric($i)) { $numeric_interests[$k] = $i; } } if (count($numeric_interests) == 0) { exit(0); } //pdDb::debugOn(); //debugVar('n', $numeric_interests); $q = $db->select(array('author', 'author_interest', 'interest'), array('author.author_id', 'interest.interest_id', 'interest.interest'), array('interest.interest_id' => array_keys($numeric_interests), 'interest.interest_id=author_interest.interest_id', 'author.author_id=author_interest.author_id')); $authors = array(); $author_info_list = array(); foreach ($q as $r) { if (!isset($authors[$r->author_id])) { $authors[$r->author_id] = pdAuthor::newFromDb($db, $r->author_id, pdAuthor::DB_LOAD_BASIC | pdAuthor::DB_LOAD_INTERESTS); } $author_info_list[] = array('interest_id' => $r->interest_id, 'new_interest' => array($all_interests[$r->interest_id] => $all_interests[$all_interests[$r->interest_id]]), 'author' => &$authors[$r->author_id]); } //debugVar('$author_info_list', $author_info_list); foreach ($author_info_list as $info) { $info['author']->interests = $info['author']->interests + $info['new_interest']; unset($info['author']->interests[$info['interest_id']]); } //debugVar('$authors', $authors); foreach ($authors as $author) { $author->dbSave($db); } debugVar('$numeric_interests', $numeric_interests); foreach ($numeric_interests as $k => $i) { $q = $db->select('author_interest', '*', array('interest_id' => $k));
public function __construct() { parent::__construct('batch_add_authors'); if ($this->loginError) { return; } $this->use_mootools = true; $form = new HTML_QuickForm('batch_add', 'post', null, '_self', 'multipart/form-data'); $tooltip = <<<TOOLTIP_END New Authors::A semi-colon separated list of author names. Names can be in the following formats: <ul> <li>fist last</li> <li>fist initials last</li> <li>last, first</li> <li>last, first initials</li> </ul> TOOLTIP_END; $form->addGroup(array(HTML_QuickForm::createElement('textarea', 'new_authors', null, array('cols' => 60, 'rows' => 10)), HTML_QuickForm::createElement('static', 'kwgroup_help', null, '<span class="small">Name format is: GIVEN_NAME1 [GIVEN_NAME2 .. etc.] LAST_NAME. Separate using semi-colons (;)</span>')), 'new_auth_group', "<span class=\"Tips1\" title=\"{$tooltip}\">New Authors:</span>", '<br/>', false); $form->addGroup(array(HTML_QuickForm::createElement('submit', 'submit', 'Add New Authors'), HTML_QuickForm::createElement('button', 'cancel', 'Cancel', array('onclick' => 'history.back()'))), null, null, ' ', false); if ($form->validate()) { $values = $form->exportValues(); $values['new_authors'] = preg_replace("/;\\s*;/", ';', $values['new_authors']); $new_authors = preg_split('/;\\s*/', $values['new_authors']); $fl_auth_list = pdAuthorList::create($this->db, null, null, true); $in_db_auths = array_intersect($fl_auth_list, $new_authors); $new_auths = array_diff($new_authors, $fl_auth_list); foreach ($new_auths as $auth_name) { $auth = new pdAuthor(); $auth->nameSet($auth_name); $auth->dbSave($this->db); unset($auth); } if (count($in_db_auths) > 0) { echo 'These authors were already in the database:<ul>'; foreach ($in_db_auths as $auth_name) { echo '<li>', $auth_name, '</li>'; } } if (count($new_auths) > 0) { if (count($in_db_auths) > 0) { echo '</ul>', 'Only these authors were added to the database:', '<ul>'; } else { echo 'These authors were added to the database:<ul>'; } foreach ($new_auths as $auth_name) { echo '<li>', $auth_name, '</li>'; } echo '</ul>'; } else { echo '</ul>No authors were added to the database.'; } } else { echo '<h2>Batch Add Authors</h2>'; $renderer =& $form->defaultRenderer(); $form->setRequiredNote('<font color="#FF0000">*</font> shows the required fields.'); $form->accept($renderer); $this->form =& $form; $this->renderer =& $renderer; $this->js = <<<JS_END window.addEvent('domready', function() { var Tips1 = new Tips(\$\$('.Tips1')); }); JS_END; } }
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; }
David Horn, Kimmen Sjölander, Steven L. Salzberg, Dennis Vitkup, Stanley Letovsky, Daniel Segrè, Charles DeLisi, Richard J. Roberts, Martin Steffen, Simon Kasif AUTHORS_NEW_END; $db = new pdDb(array('server' => "localhost", 'user' => "dummy", 'passwd' => "ozzy498", 'name' => "pubdbdev")); // this array contains the names in the format: FIRST OTHER LAST $authors_in_db = pdAuthorList::create($db, null, null, true); var_dump($authors_in_db); $authors = array(); foreach (explode(',', $authors_new_raw) as $author_name) { if (in_array($author_name, $authors_in_db)) { exit("author {$author_name} already exists in the database"); } $author = new pdAuthor(); $author->nameSet($author_name); $authors[] = $author; } print "adding " . count($authors) . " new authors...\n"; // none of the authors already exist in the database, they can be saved foreach ($authors as $author) { $author->dbSave($db); } print "new authors added.\n"; //var_dump($authors);
<?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);