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. <p/> 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 <b>Add Interest</b> link. <p/> Clicking the <b>Add Interest</b> 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: <ul> <li>Professor</li> <li>PostDoc</li> <li>PhD Student</li> <li>MSc Student</li> <li>Colleague</li> </ul>'; $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', '', ' ', 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, ' '); } $form->addElement('hidden', 'numNewInterests', $this->numNewInterests); $this->form =& $form; if ($form->validate()) { $this->processForm(); } else { $this->renderForm($author); } }
public function __construct() { parent::__construct('add_venue'); if ($this->loginError) { return; } $this->loadHttpVars(); if (!isset($this->referer)) { $referer = getenv('HTTP_REFERER'); if (strpos($referer, 'list_venues.php') !== false) { $this->referer = $referer; } } $this->venue = new pdVenue(); if ($this->venue_id != null) { $this->venue->dbLoad($this->db, $this->venue_id); } if (!empty($this->cat_id)) { $this->venue->categoryAdd($this->db, $this->cat_id); } else { if (is_object($this->venue->category)) { $this->cat_id = $this->venue->category->cat_id; } } $this->newOccurrences = 0; if (is_object($this->venue->category) && ($this->venue->category->category == 'In Conference' || $this->venue->category->category == 'In Workshop')) { if (isset($this->numNewOccurrences) && is_numeric($this->numNewOccurrences)) { $this->newOccurrences = intval($this->numNewOccurrences); } else { $this->newOccurrences = count($this->venue->occurrences); } } $this->form = new HTML_QuickForm('venueForm', 'post', './add_venue.php?submit=true'); $form =& $this->form; 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'; } $label = 'Add Venue'; } else { if (!empty($this->venue_id)) { $this->page_title = 'Edit Venue'; $label = 'Edit Venue'; } else { $this->page_title = 'Add Venue'; $label = 'Add Venue'; } } $form->addElement('header', null, $label); if (!empty($this->venue_id)) { $form->addElement('hidden', 'venue_id', $this->venue_id); } $form->addElement('hidden', 'referer', $this->referer); // category $category_list = pdCatList::create($this->db); // Remove "In " from category names foreach ($category_list as $key => $category) { if (strpos($category, 'In ') === 0) { $category_list[$key] = substr($category, 3); } } $onchange = 'javascript:dataKeep(' . $this->newOccurrences . ');'; $form->addElement('select', 'cat_id', $this->helpTooltip('Category', 'categoryHelp') . ':', array('' => '--- Please Select a Category ---', '-1' => '-- No Category --') + $category_list, array('onchange' => $onchange)); if (isset($_SESSION['state']) && $_SESSION['state'] == 'pub_add') { $form->addElement('advcheckbox', 'v_usage', 'Usage:', 'Use for this Publication only', null, array('all', 'single')); } $form->addElement('text', 'title', 'Acronym:', array('size' => 50, 'maxlength' => 250)); $form->addGroup(array(HTML_QuickForm::createElement('text', 'name', null, array('size' => 50, 'maxlength' => 250)), HTML_QuickForm::createElement('static', null, null, '<span style="font-size:0.85em;">' . 'If venue has an acronym please append it to the Venue ' . 'Name in parenthesis,<br/>eg. International Joint ' . 'Conference on Artificial Intelligence (IJCAI).</span>')), 'venue_name_group', 'Venue Name:', '<br/>', false); $form->addGroupRule('venue_name_group', array('name' => array(array('a venue name is required', 'required', null, 'client')))); $form->addElement('text', 'url', 'Venue URL:', array('size' => 50, 'maxlength' => 250)); // rankings radio selections $rankings = pdVenue::rankingsGlobalGet($this->db); foreach ($rankings as $rank_id => $description) { $radio_rankings[] = HTML_QuickForm::createElement('radio', 'venue_rank', null, $description, $rank_id); } $radio_rankings[] = HTML_QuickForm::createElement('radio', 'venue_rank', null, 'other (fill in box below)', -1); $radio_rankings[] = HTML_QuickForm::createElement('text', 'venue_rank_other', null, array('size' => 30, 'maxlength' => 250)); $form->addGroup($radio_rankings, 'group_rank', 'Ranking:', '<br/>', false); if (is_object($this->venue->category)) { $vopts = $this->venue->voptsGet($this->venue->category->cat_id); if (!empty($vopts) && count($vopts) > 0) { foreach ($vopts as $vopt) { $name = strtolower(preg_replace('/\\s+/', '_', $vopt)); if ($name == 'location' && $this->newOccurrences > 0) { continue; } $form->addElement('text', $name, $vopt . ':', array('size' => 50, 'maxlength' => 250)); } } if ($this->venue->category->category == 'In Workshop') { $form->addElement('text', 'editor', 'Editor:', array('size' => 50, 'maxlength' => 250)); $form->addElement('date', 'venue_date', 'Date:', array('format' => 'YM', 'minYear' => pdPublication::MIN_YEAR, 'maxYear' => pdPublication::MAX_YEAR)); } if ($this->venue->category->category == 'In Conference' || $this->venue->category->category == 'In Workshop') { $form->addElement('hidden', 'numNewOccurrences', $this->newOccurrences); for ($i = 0; $i < $this->newOccurrences; $i++) { $form->addElement('header', null, 'Occurrence ' . ($i + 1)); $form->addElement('text', 'newOccurrenceLocation[' . $i . ']', 'Location:', array('size' => 50, 'maxlength' => 250)); $form->addRule('newOccurrenceLocation[' . $i . ']', 'venue occurrence ' . ($i + 1) . ' location cannot be left blank', 'required', null, 'client'); $form->addElement('date', 'newOccurrenceDate[' . $i . ']', 'Date:', array('format' => 'YM', 'minYear' => pdPublication::MIN_YEAR, 'maxYear' => pdPublication::MAX_YEAR)); $form->addElement('text', 'newOccurrenceUrl[' . $i . ']', 'URL:', array('size' => 50, 'maxlength' => 250)); $form->addElement('button', 'delOccurrence[' . $i . ']', 'Delete Occurrence', 'onClick=dataRemove(' . $i . ');'); } } } if (isset($_SESSION['state']) && $_SESSION['state'] == 'pub_add') { $pos = strpos($_SERVER['PHP_SELF'], 'papersdb'); $prev_page = substr($_SERVER['PHP_SELF'], 0, $pos) . 'papersdb/Admin/add_pub3.php'; $url = substr($_SERVER['PHP_SELF'], 0, $pos) . 'papersdb'; $buttons[] = HTML_QuickForm::createElement('button', 'prev_step', '<< Previous Step', array('onClick' => "location.href='" . $prev_page . "';")); $buttons[] = HTML_QuickForm::createElement('button', 'cancel', 'Cancel', array('onclick' => "location.href='" . $url . "';")); $buttons[] = HTML_QuickForm::createElement('reset', 'reset', 'Reset'); if (is_object($this->venue->category) && ($this->venue->category->category == 'In Conference' || $this->venue->category->category == 'In Workshop')) { $buttons[] = HTML_QuickForm::createElement('button', 'addOccurrence', 'Add Occurrence', 'onClick=dataKeep(' . ($this->newOccurrences + 1) . ');'); } $buttons[] = HTML_QuickForm::createElement('submit', 'next_step', 'Next Step >>'); if ($pub->pub_id != '') { $buttons[] = HTML_QuickForm::createElement('submit', 'finish', 'Finish'); } $form->addGroup($buttons, 'buttons', '', ' ', false); add_pub_base::addPubDisableMenuItems(); } else { if (!empty($this->venue_id)) { $label = 'Submit'; } else { $label = 'Add Venue'; } $buttons[] = HTML_QuickForm::createElement('reset', 'Reset', 'Reset'); if (is_object($this->venue->category) && ($this->venue->category->category == 'In Conference' || $this->venue->category->category == 'In Workshop')) { $buttons[] = HTML_QuickForm::createElement('button', 'addOccurrence', 'Add Occurrence', 'onClick=dataKeep(' . ($this->newOccurrences + 1) . ');'); } $buttons[] = HTML_QuickForm::createElement('submit', 'Submit', $label); $form->addGroup($buttons, 'submit_group', null, ' ', false); } if ($form->validate()) { $this->processForm(); } else { $this->renderForm(); } }