Beispiel #1
0
 function getForm()
 {
     if ($this->form) {
         return $this->form;
     }
     $options = array('format' => 'd m Y H i', 'optionIncrement' => array('i' => 15), 'minYear' => date('Y') - 2, 'maxYear' => date('Y') + 2);
     $form = new HTML_QuickForm('protokol', 'POST', $this->url());
     $form->addElement('hidden', 'elev_id');
     $form->addElement('hidden', 'id');
     $form->addElement('date', 'date_start', 'Startdato:', $options);
     $form->addElement('date', 'date_end', 'Slutdato:', $options);
     $radio[0] =& HTML_QuickForm::createElement('radio', null, null, 'fri', '1');
     $radio[1] =& HTML_QuickForm::createElement('radio', null, null, 'syg', '2');
     $radio[2] =& HTML_QuickForm::createElement('radio', null, null, 'fraværende', '3');
     $radio[5] =& HTML_QuickForm::createElement('radio', null, null, 'henstilling', '6');
     $radio[3] =& HTML_QuickForm::createElement('radio', null, null, 'mundtlig advarsel', '4');
     $radio[4] =& HTML_QuickForm::createElement('radio', null, null, 'skriftlig advarsel', '5');
     $radio[6] =& HTML_QuickForm::createElement('radio', null, null, 'hjemsendt', '7');
     $radio[7] =& HTML_QuickForm::createElement('radio', null, null, 'andet', '8');
     $form->addGroup($radio, 'type', 'Type:', ' ');
     $form->addElement('textarea', 'text', '');
     $form->addElement('submit', null, 'Send');
     $form->addRule('date_start', 'Husk dato', 'required', null, 'client');
     $form->addRule('date_end', 'Husk dato', 'required', null, 'client');
     $form->addRule('type', 'Husk type', 'required', null, 'client');
     $form->addRule('text', 'Tekst', 'required', null, 'client');
     return $this->form = $form;
 }
Beispiel #2
0
 public function __construct()
 {
     parent::__construct('delete_interest', 'Delete Interest', 'Admin/delete_interest.php');
     if ($this->loginError) {
         return;
     }
     $form = new HTML_QuickForm('deleter');
     $interest_list = new pdAuthInterests($this->db);
     $form->addElement('select', 'interests', 'Select interest(s) to delete:', $interest_list->list, array('multiple' => 'multiple', 'size' => 15));
     $form->addGroup(array(HTML_QuickForm::createElement('button', 'cancel', 'Cancel', array('onclick' => 'history.back()')), HTML_QuickForm::createElement('submit', 'submit', 'Delete')), null, null, ' ', false);
     if ($form->validate()) {
         $values = $form->exportValues();
         foreach ($values['interests'] as $interest_id) {
             $names[] = $interest_list->list[$interest_id];
         }
         $interest_list->dbDelete($this->db, $values['interests']);
         echo 'You have successfully removed the following interest from the ', 'database: <br/><b>', implode(', ', $names), '</b></p>', '<br><a href="', $_SERVER['PHP_SELF'], '">Delete another interest</a>';
     } else {
         $renderer =& $form->defaultRenderer();
         $form->accept($renderer);
         $this->form =& $form;
         $this->renderer =& $renderer;
         echo '<h3>Delete Interest </h3>';
     }
 }
 public function __construct()
 {
     parent::__construct('authorize_new_users');
     if ($this->loginError) {
         return;
     }
     $this->loadHttpVars(true, true);
     $this->users = pdUserList::getNotVerified($this->db);
     echo '<h2>Users Requiring Authentication</h2>';
     if ($this->users == null || count($this->users) == 0) {
         echo 'All users authorized.';
         return;
     }
     $form = new HTML_QuickForm('authorizeUsers', 'post');
     foreach ($this->users as $user) {
         $form->addGroup(array(HTML_QuickForm::createElement('advcheckbox', "submit[auth][{$user->login}]", null, null, null, array('no', 'yes')), HTML_QuickForm::createElement('select', "submit[access][{$user->login}]", null, AccessLevel::getAccessLevels()), HTML_QuickForm::createElement('static', null, null, $user->login), HTML_QuickForm::createElement('static', null, null, $user->name), HTML_QuickForm::createElement('static', null, null, $user->email)), 'all', null, '</td><td class="stats_odd">', false);
     }
     $form->addElement('submit', null, 'Submit');
     $this->form =& $form;
     if ($form->validate()) {
         $this->processForm();
     } else {
         $this->renderForm();
     }
 }
Beispiel #4
0
 public function __construct()
 {
     parent::__construct();
     if ($this->loginError) {
         return;
     }
     $this->use_mootools = true;
     $this->pub =& $_SESSION['pub'];
     if (isset($this->pub->pub_id)) {
         $this->page_title = 'Edit Publication';
     }
     // initialize attachments
     if (!isset($_SESSION['paper']) && !isset($_SESSION['attachments'])) {
         $_SESSION['paper'] = $this->pub->paperFilenameGet();
         if (count($this->pub->additional_info) > 0) {
             for ($i = 0, $n = count($this->pub->additional_info); $i < $n; $i++) {
                 $_SESSION['attachments'][$i] = $this->pub->attFilenameGet($i);
                 $_SESSION['att_types'][$i] = $this->pub->additional_info[$i]->type;
             }
         }
     }
     $form = new HTML_QuickForm('add_pub4');
     $this->form =& $form;
     $this->formAddAttachments();
     $this->formAddWebLinks();
     $this->formRelatedPubs();
     $pos = strpos($_SERVER['PHP_SELF'], 'papersdb');
     $url = substr($_SERVER['PHP_SELF'], 0, $pos) . 'papersdb';
     $form->addGroup(array(HTML_QuickForm::createElement('submit', 'prev_step', '<< Previous Step'), HTML_QuickForm::createElement('button', 'cancel', 'Cancel', array('onclick' => "cancelConfirm();")), HTML_QuickForm::createElement('reset', 'reset', 'Reset'), HTML_QuickForm::createElement('submit', 'finish', 'Finish')), 'buttons', null, '&nbsp;', false);
     if ($form->validate()) {
         $this->processForm();
     } else {
         $this->renderForm();
     }
 }
Beispiel #5
0
 function getForm()
 {
     if ($this->form) {
         return $this->form;
     }
     $faggruppe = VIH_Model_Fag_Gruppe::getList();
     foreach ($faggruppe as $grp) {
         $faggruppelist[$grp->get('id')] = $grp->get('navn');
     }
     $undervisere = VIH_Model_Ansat::getList('lærere');
     $form = new HTML_QuickForm('f*g', 'POST', $this->url());
     $form->addElement('hidden', 'id');
     $form->addElement('text', 'navn', 'Navn');
     $form->addElement('select', 'faggruppe_id', 'Faggruppe', $faggruppelist);
     $form->addElement('text', 'identifier', 'Identifier');
     $form->addElement('textarea', 'kort_beskrivelse', 'Kort beskrivelse', array('cols' => 80, 'rows' => 5));
     $form->addElement('textarea', 'beskrivelse', 'Beskrivelse', array('cols' => 80, 'rows' => 20));
     $form->addElement('textarea', 'udvidet_beskrivelse', 'Udvidet beskrivelse', array('cols' => 80, 'rows' => 20));
     $form->addElement('header', null, 'Til søgemaskinerne');
     $form->addElement('text', 'title', 'Titel');
     $form->addElement('textarea', 'description', 'Beskrivelse');
     $form->addElement('textarea', 'keywords', 'Nøgleord');
     $underviserlist = array();
     foreach ($undervisere as $underviser) {
         $underviserlist[] = HTML_QuickForm::createElement('checkbox', $underviser->get('id'), null, $underviser->get('navn'));
     }
     $form->addGroup($underviserlist, 'underviser', 'Underviser', '<br />');
     $form->addElement('checkbox', 'published', 'Udgivet');
     $form->addElement('submit', null, 'Gem');
     return $this->form = $form;
 }
Beispiel #6
0
    public function __construct()
    {
        parent::__construct();
        if ($this->loginError) {
            return;
        }
        $this->use_mootools = true;
        $this->pub =& $_SESSION['pub'];
        if (isset($this->pub->pub_id)) {
            $this->page_title = 'Edit Publication';
        }
        $this->authors = pdAuthorList::create($this->db, null, null, true);
        $form = new HTML_QuickForm('add_pub2', 'post', '', '', array('onsubmit' => 'return check_authors("add_pub2");'));
        $form->addElement('header', null, 'Select from Authors in Database');
        $tooltip = 'Authors::The authors of the publication. Listed in the
same order as in the publication
&lt;p/&gt;
If an author is not already in the database press the &lt;b&gt;Add Author not
in DB&lt;/b&gt; button.';
        $form->addElement('textarea', 'authors', "<div id=\"MYCUSTOMFLOATER\"  class=\"myCustomFloater\" style=\"position:absolute;top:200px;left:600px;background-color:#cecece;display:none;visibility:hidden\"><div class=\"myCustomFloaterContent\"></div></div>" . "<span class=\"Tips1\" title=\"{$tooltip}\">Authors</span>:", array('cols' => 60, 'rows' => 5, 'class' => 'wickEnabled:MYCUSTOMFLOATER', 'wrap' => 'virtual'));
        $form->addElement('static', null, null, '<span class="small">' . 'There are ' . count($this->authors) . ' authors in the database. Type a partial name to ' . 'see a list of matching authors. Separate names ' . 'using commas.</span>');
        $form->addElement('submit', 'add_new_author', 'Add Author not in DB');
        // collaborations radio selections
        $tooltip = 'Collaborations::If the publication is a collaboration,
select the options that apply to this paper.';
        $form->addElement('header', null, "<span class=\"Tips1\" title=\"{$tooltip}\">Collaborations</span>");
        $collaborations = pdPublication::collaborationsGet($this->db);
        foreach ($collaborations as $col_id => $description) {
            $radio_cols[] = HTML_QuickForm::createElement('checkbox', 'paper_col[' . $col_id . ']', null, $description, 1);
        }
        $form->addGroup($radio_cols, 'group_collaboration', null, '<br/>', false);
        $pos = strpos($_SERVER['PHP_SELF'], 'papersdb');
        $url = substr($_SERVER['PHP_SELF'], 0, $pos) . 'papersdb';
        $buttons[] = HTML_QuickForm::createElement('submit', 'prev_step', '<< Previous Step');
        $buttons[] = HTML_QuickForm::createElement('button', 'cancel', 'Cancel', array('onclick' => "cancelConfirm();"));
        $buttons[] = HTML_QuickForm::createElement('submit', 'next_step', 'Next Step >>');
        if ($this->pub->pub_id != '') {
            $buttons[] = HTML_QuickForm::createElement('submit', 'finish', 'Finish');
        }
        $form->addGroup($buttons, 'buttons', '', '&nbsp;', false);
        $this->form =& $form;
        if ($form->validate()) {
            $this->processForm();
        } else {
            $this->renderForm();
        }
    }
Beispiel #7
0
 /**
  *
  */
 public function otherFormatForm($result_pubs)
 {
     if ($result_pubs == null) {
         return;
     }
     $form = new HTML_QuickForm('otherFormatForm');
     $form->addElement('hidden', 'pub_ids', implode(",", $result_pubs));
     $form->addGroup(array(HTML_QuickForm::createElement('submit', 'cv_format', 'Show results in CV format'), HTML_QuickForm::createElement('submit', 'bibtex_format', 'Show results in BibTex format')), null, null, '&nbsp;');
     return $form;
 }
Beispiel #8
0
 function getForm()
 {
     if ($this->form) {
         return $this->form;
     }
     $form = new HTML_QuickForm('', 'post', $this->url());
     $form->addElement('text', 'email', 'E-mail');
     $radio[0] =& HTML_QuickForm::createElement('radio', null, null, 'tilmeld', '1');
     $radio[1] =& HTML_QuickForm::createElement('radio', null, null, 'frameld', '2');
     $form->addGroup($radio, 'mode', null, null);
     $form->addElement('submit', null, 'Gem');
     $form->setDefaults(array('mode' => 1));
     $form->addRule('email', 'Du skal skrive en e-mail-adresse', 'required', null);
     return $this->form = $form;
 }
Beispiel #9
0
 public function __construct()
 {
     parent::__construct('view_publication', 'View Publication', 'view_publication.php');
     if ($this->loginError) {
         return;
     }
     $this->loadHttpVars();
     if (!isset($this->pub_id) || !is_numeric($this->pub_id)) {
         $this->pageError = true;
         return;
     }
     $pub = new pdPublication();
     $result = $pub->dbLoad($this->db, $this->pub_id);
     if (!$result) {
         echo 'Publication does not exist';
         return;
     }
     if (isset($this->submit_pending) && $this->submit_pending) {
         // check if this pub entry is pending
         $q = $this->db->selectRow('pub_pending', '*', array('pub_id' => $this->pub_id));
         assert('$q');
         $form = new HTML_QuickForm('submit_pending');
         $form->addElement('hidden', 'submit_pending', true);
         $form->addElement('hidden', 'pub_id', $this->pub_id);
         $elements = array();
         $elements[] = HTML_QuickForm::createElement('advcheckbox', 'valid', null, 'Valid', null, array(0, 1));
         $elements[] = HTML_QuickForm::createElement('submit', 'submit', 'Submit');
         $form->addGroup($elements, 'elgroup', '', '&nbsp', false);
         // create a new renderer because $form->defaultRenderer() creates
         // a single copy
         $renderer = new HTML_QuickForm_Renderer_Default();
         $form->accept($renderer);
         if ($form->validate()) {
             $values =& $form->exportValues();
             $pub->markValid($this->db);
             echo 'Publication entry marked as valid.';
             return;
         } else {
             echo "<h2>This publication entry requires validation</h2>\n";
             echo $renderer->toHtml();
         }
     }
     $this->showPublication($pub);
 }
Beispiel #10
0
 public function __construct()
 {
     parent::__construct('tag_non_ml');
     if ($this->loginError) {
         return;
     }
     $this->loadHttpVars();
     $pubs =& $this->getNonMachineLearningPapers();
     $form = new HTML_QuickForm('tag_non_ml_form', 'post', './tag_ml_submit.php');
     $form->addElement('header', null, 'Citation</th><th style="width:7%">Is ML');
     $count = 0;
     foreach ($pubs as &$pub) {
         $pub->dbLoad($this->db, $pub->pub_id, pdPublication::DB_LOAD_VENUE | pdPublication::DB_LOAD_CATEGORY | pdPublication::DB_LOAD_AUTHOR_FULL);
         ++$count;
         $form->addGroup(array(HTML_QuickForm::createElement('static', null, null, $pub->getCitationHtml() . '&nbsp;' . getPubIcons($this->db, $pub, 0x7)), HTML_QuickForm::createElement('advcheckbox', 'pub_tag[' . $pub->pub_id . ']', null, null, null, array('no', 'yes'))), 'tag_ml_group', $count, '</td><td>', false);
     }
     $form->addElement('submit', 'submit', 'Submit');
     $renderer =& $form->defaultRenderer();
     $form->accept($renderer);
     $this->renderer =& $renderer;
 }
$form->addElement('header', '', 'Normal Elements');
$form->addElement('hidden', 'ihidTest', 'hiddenField');
$form->addElement('text', 'itxtTest', 'Test Text');
$form->addElement('textarea', 'itxaTest', 'Test TextArea');
// will be later assigned to style green
$form->addElement('password', 'ipwdTest', array('Test Password', 'Please choose a password which is hard to guess'));
$select =& $form->addElement('select', 'iselTest', 'Test Select', array('A' => 'A', 'B' => 'B', 'C' => 'C', 'D' => 'D'));
$select->setSize(5);
$select->setMultiple(true);
$form->addElement('submit', 'isubTest', 'Test Submit');
$form->addElement('header', '', 'Grouped Elements');
$checkbox[] =& HTML_QuickForm::createElement('checkbox', 'A', null, 'A');
$checkbox[] =& HTML_QuickForm::createElement('checkbox', 'B', null, 'B');
$checkbox[] =& HTML_QuickForm::createElement('checkbox', 'C', null, 'C');
$checkbox[] =& HTML_QuickForm::createElement('checkbox', 'D', null, 'D');
$form->addGroup($checkbox, 'ichkABCD', 'ABCD', '<br />');
// will be later assigned to style fancygroup
$radio[] =& HTML_QuickForm::createElement('radio', null, null, 'Yes', 'Y');
$radio[] =& HTML_QuickForm::createElement('radio', null, null, 'No', 'N');
$form->addGroup($radio, 'iradYesNo', 'Yes/No');
// will be later assigned to style fancygroup
$name['first'] =& HTML_QuickForm::createElement('text', 'first', 'First:');
$name['first']->setSize(20);
$name['last'] =& HTML_QuickForm::createElement('text', 'last', 'Last:');
$name['last']->setSize(30);
$form->addGroup($name, 'name', 'Name');
// add some 'required' rules to show "stars" and (possible) errors...
$form->addRule('itxtTest', 'Test Text is a required field', 'required');
$form->addRule('itxaTest', 'Test TextArea is a required field', 'required');
$form->addGroupRule('iradYesNo', 'Check Yes or No', 'required');
$form->addGroupRule('name', array('last' => array(array('Last name is required', 'required'))));
 $form->addElement('html', '</fieldset>');
 $form->addElement('html', '<div class="both"></div>');
 // Price
 $form->addElement('html', '<fieldset id="price">');
 $form->addElement('header', 'price_header', 'Price');
 $form->addElement('text', 'price', 'Price:', array('size' => 10, 'maxlength' => 10, 'class' => 'inputbox'));
 $errors[] = 'price';
 if ($ushop->checkout['stock_control']) {
     $form->addElement('text', 'quantity', 'Quantity:', array('size' => 5, 'maxlength' => 5, 'class' => 'inputbox'));
     $form->addRule('quantity', 'quatity has to be a number.', 'numeric');
     $errors[] = 'quantity';
 }
 if ($ushop->checkout['vat_state'] == 1) {
     $group_radio[] = $form->createElement('radio', null, null, 'Yes', '1');
     $group_radio[] = $form->createElement('radio', null, null, 'No', '0');
     $form->addGroup($group_radio, 'vat_inc', 'Include Tax:');
     $errors[] = 'vat_inc';
     $s = $form->createElement('select', 'tax_code_id', 'Tax Code:');
     $opts[0] = 'Select One';
     foreach ($ushop->formatTaxCodes() as $code) {
         $opts[$code['tax_code_id']] = $code['tax_code'];
     }
     $s->loadArray($opts);
     $form->addElement($s);
     $errors[] = 'taxcode_id';
 } else {
     $no_tax = $this->getResult('tax_code_id', $ushop->db_name . 'tax_codes', null, array('where' => "tax_code='N'"));
     $form->addElement('hidden', 'tax_code_id', $no_tax[0]->tax_code_id);
     $form->addElement('hidden', 'vat_inc', 0);
 }
 // price groups.
Beispiel #13
0
// no direct access
defined('PARENT_FILE') or die('Restricted access');
if ($this->authorize()) {
    if (isset($this->registry->params['id'])) {
        $form = new HTML_QuickForm('contentPage', 'post', $_SERVER['REQUEST_URI']);
        // Remove name attribute for xhtml strict compliance.
        $form->removeAttribute('name');
        $form->addElement('html', '<div id="edit_params">');
        $form->addElement('text', 'page', 'Page Title:', array('size' => 50, 'maxlength' => 255, 'class' => 'inputbox'));
        $form->addElement('html', '<fieldset>');
        $form->addElement('header', 'parameters', 'Parameters');
        $params = array('show_title', 'show_cdate', 'show_mdate');
        foreach ($params as $value) {
            $radio_set = array($form->createElement('radio', null, null, 'Yes', '1'), $form->createElement('radio', null, null, 'No', '0'));
            $form->addGroup($radio_set, 'params[' . $value . ']', ucwords(str_replace('_', ' ', $value)) . ':');
        }
        $form->addElement('html', '</fieldset>');
        $form->addElement('html', '<fieldset>');
        $form->addElement('header', 'metadata', 'Metadata');
        $form->addElement('textarea', 'params[metadata][description]', 'Description:');
        $form->addElement('textarea', 'params[metadata][keywords]', 'Keywords:');
        $form->addElement('html', '</fieldset>');
        $form->addElement('html', '</div>');
        $form->addElement('html', '<div id="edit_html">');
        $form->addElement('textarea', 'content', null, array('id' => 'content_textarea', 'class' => 'mceEditor'));
        $form->addElement('html', '</div>');
        $form->addRule('page', 'Please enter a title', 'required');
        if ($form->validate()) {
            // Apply form element filters.
            $form->freeze();
Beispiel #14
0
 /**
  * Overrides method from parent, append name defaults to false
  * @param    array      $elements       array of elements composing the group
  * @param    string     $name           (optional)group name
  * @param    string     $groupLabel     (optional)group label
  * @param    string     $separator      (optional)string to separate elements
  * @param    string     $appendName     (optional)specify whether the group name should be
  *                                      used in the form element name ex: group[element], defaults to false
  * @return   HTML_QuickForm_group       reference to a newly added group
  * @since    2.8
  * @access   public
  * @throws   HTML_QuickForm_Error
  */
 function &addGroup($elements, $name = null, $groupLabel = '', $separator = null, $appendName = false)
 {
     return parent::addGroup($elements, $name, $groupLabel, $separator, $appendName);
 }
Beispiel #15
0
 function getForm()
 {
     if ($this->form) {
         return $this->form;
     }
     $tilmelding = VIH_Model_KortKursus_Tilmelding::factory($this->context->name());
     $tilmelding->loadBetaling();
     $forsikringstekst = '';
     if ($tilmelding->get('pris_forsikring') > 0) {
         $forsikringstekst = ' og afbestillingsforsikring';
     }
     $form = new HTML_QuickForm('onlinebetaling', 'POST', $this->url());
     if ($tilmelding->get('skyldig_depositum') > 0 and $tilmelding->get('dato_forfalden') > date('Y-m-d')) {
         $form->addElement('header', null, 'Hvilket beløb vil du betale?');
         $options[] =& HTML_QuickForm::createElement('radio', null, null, $tilmelding->get('pris_total') . ' kroner (DKK) - dækker hele kursusprisen', $tilmelding->get('pris_total') * 100);
         $options[] =& HTML_QuickForm::createElement('radio', null, null, $tilmelding->get('pris_forudbetaling') . ' kroner (DKK) - dækker depositum' . $forsikringstekst, $tilmelding->get('pris_forudbetaling') * 100);
         $form->addGroup($options, 'amount', 'Beløb', '<br />');
         $form->addGroupRule('amount', 'Du skal vælge et beløb', 'required', null);
     } else {
         $form->addElement('header', null, 'Du skal betale nedenstående beløb');
         $form->addElement('radio', 'amount', 'Beløb', $tilmelding->get('skyldig') . ' kroner (DKK) - dækker resten af beløbet', $tilmelding->get('skyldig') * 100);
         $form->addRule('amount', 'Du skal vælge et beløb', 'required');
         $form->addRule('amount', 'Du skal vælge et beløb', 'numeric');
         $form->setDefaults(array('amount' => $tilmelding->get('skyldig') * 100));
     }
     $form->addElement('header', null, 'Betaling');
     $form->addElement('text', 'cardnumber', 'Kortnummer');
     $form->addElement('text', 'cvd', 'Sikkerhedsnummer');
     $form->addElement('text', 'mm', 'Mdr.');
     $form->addElement('text', 'yy', 'år');
     $form->addElement('html', null, 'Vær opmærksom på, at det kan tage helt op til et minut at gennemføre transaktionen hos PBS.');
     $form->addElement('submit', null, 'Betal');
     $form->addRule('cardnumber', 'Du skal skrive et kortnummer', 'required');
     $form->addRule('cardnumber', 'Du skal skrive et kortnummer', 'numeric');
     $form->addRule('cvd', 'Du skal skrive et sikkerhedsnummer', 'required');
     $form->addRule('cvd', 'Du skal skrive et sikkerhedsnummer', 'numeric');
     $form->addRule('mm', 'Du skal udfylde Mdr.', 'required');
     $form->addRule('mm', 'Du skal udfylde Mdr.', 'numeric');
     $form->addRule('yy', 'Du skal udfylde år ', 'required');
     $form->addRule('yy', 'Du skal udfylde år', 'numeric');
     $form->applyFilter('__ALL__', 'trim');
     $form->applyFilter('__ALL__', 'addslashes');
     $form->applyFilter('__ALL__', 'strip_tags');
     return $this->form = $form;
 }
    function display($self_link) {
        $this->self_link = $self_link;

        #print "<pre>"; print_r($_POST); print "</pre>";
        $view = get_http_var('view', 'needattention');
        $id = get_http_var("id");
        $rep_id = get_http_var("rep_id");

        // Display about id
        if ($id) {
            if ($this->do_actions($id)) {
#               header("Location: ".$_SERVER['REQUEST_URI'] . "\n");
#               exit;
            }

            // Navigation bar
            $this->render_bar($view, false, $id);

            // Display general information
            print "<h2>Message id " . make_ids_links($id) . ":</h2>";

            $message = msg_admin_get_message($id);
            msg_check_error($message);
            $this->print_message($message);

            // Commands
            $form = new HTML_QuickForm('messageForm', 'post', $self_link);
            if (!get_http_var('note')) {
                $actiongroup[] = &HTML_QuickForm::createElement('text', 'notebody', null, array('size'=>30));
                $actiongroup[] = &HTML_QuickForm::createElement('submit', 'note', 'Note');
            }
            $actiongroup[] = &HTML_QuickForm::createElement('static', null, null, " <b>Action:</b>");
            if ($message['frozen']) {
                if ($message['state'] != 'error' and $message['state'] != 'failed' and $message['state'] != 'failed_closed') 
                    $actiongroup[] = &HTML_QuickForm::createElement('submit', 'error', 'Error with email');
                if ($message['state'] != 'failed' and $message['state'] != 'failed_closed')
                    $actiongroup[] = &HTML_QuickForm::createElement('submit', 'failed', 'Fail silently');
                if ($message['state'] != 'error' and $message['state'] != 'failed' and $message['state'] != 'failed_closed')
                    $actiongroup[] = &HTML_QuickForm::createElement('submit', 'thaw', 'Thaw');
            }
            else {
                if ($message['state'] != 'error' and $message['state'] != 'failed' and $message['state'] != 'failed_closed') 
                    $actiongroup[] = &HTML_QuickForm::createElement('submit', 'freeze', 'Freeze');
            }
            if ($message['no_questionnaire'])
                $actiongroup[] = &HTML_QuickForm::createElement('submit', 'yes_questionnaire', 'Allow Questionnaire');
            else
                $actiongroup[] = &HTML_QuickForm::createElement('submit', 'no_questionnaire', 'No Questionnaire');
            if ($message['state'] == 'pending')
                $actiongroup[] = &HTML_QuickForm::createElement('submit', 'ready', 'Confirm');
            elseif ($message['state'] == 'failed' || $message['state'] == 'failed_closed')
                $actiongroup[] = &HTML_QuickForm::createElement('submit', 'ready', 'Retry');

            if (!get_http_var('body'))
                $actiongroup[] = &HTML_QuickForm::createElement('submit', 'body', 'View Body');
            else
                $actiongroup[] = &HTML_QuickForm::createElement('submit', 'nobody', 'Hide Body');
            if (!get_http_var('wire_emails'))
                $actiongroup[] = &HTML_QuickForm::createElement('submit', 'wire_emails', 'View Emails');
            else
                $actiongroup[] = &HTML_QuickForm::createElement('submit', 'no_wire_emails', 'Hide Emails');
            $form->addElement('hidden', 'id', $id);
            $form->addElement('hidden', 'token', get_token());
            $form->addGroup($actiongroup, "actiongroup", "",' ', false);

            admin_render_form($form);
            print 'Similar messages: ';
            print '<a href="'
                    .  htmlspecialchars(url_new("", true, 'view', 'similarbody', 'simto', $id, 'id', null))
                    .  '">different rep</a>, ';
            print '<a href="'
                    .  htmlspecialchars(url_new("", true, 'view', 'similarbodysamerep', 'simto', $id, 'id', null))
                    .  '">same rep</a> ';

            // Links to send messages to sender
            print " Email sender: <small>";
            make_mailto_link($message['sender_email'], 
                "Your message to " . $message['recipient_name'] . " has not been sent",
                "Hi " . $message['sender_name']. ",

Unfortunately, your message to " . $message['recipient_name'] . " has not been sent. You can only use our service to write to your own elected representatives, not to representatives for other places.  Here is a full explanation as to why we have this policy:
    http://www.writetothem.com/about-qa#onlyrep

There's a copy of your message below, so you can send it another way, if you like.

-------------------------------------------------------------",
                "write-to-own-reps-only");
            make_mailto_link($message['sender_email'], 
                "Your message to " . $message['recipient_name'],
                "Hi " . $message['sender_name']. ",



-------------------------------------------------------------\n\n".
                $message['message'],
                "blank-mail-quoting-message");
            print "</small>";

            // Body text if enabled
            if (get_http_var('body')) {
                print "<h2>Body text of message (only read if you really need to)</h2>";
                print "<blockquote>";
                print nl2br(htmlspecialchars($message['message']));
                print "</blockquote>";
            }

            // Body text if enabled
            if (get_http_var('wire_emails')) {
                foreach (array('representative', 'confirm', 'confirm-reminder', 'failure', 'questionnaire', 'questionnaire-reminder') as $type) {
                    print "<h2>Wire text of email - $type</h2>";
                    $wire = msg_admin_get_wire_email($message['id'], $type);
                    if (msg_get_error($wire)) {
                        print "Error contacting queue:";
                        print_r($wire);
                    } else {
                        print "<pre>";
                        print ms_make_clickable(htmlspecialchars($wire));
                        print "</pre>";
                    }
                }
            }

            // Questionnaire answers if there are any
            if (is_array($message['questionnaires']) and count($message['questionnaires']) > 0) {
                print "<h2>Questionnaire Responses</h2>";
                foreach ($message['questionnaires'] as $q) {
                    if ($q['question_id'] == 0) {
                        print "Reply within two/three weeks:";
                    } elseif ($q['question_id'] == 1) {
                        print "First time contacted any representative:";
                    } else {
                        print $q['question_id'] . ":";
                    }
                    print " <b>" . $q['answer'] .  "</b><br>";
                }
            }
 
            // Log of what has happened to message
            $allevents = get_http_var('allevents', 0);

            print '<h2>' .
                    ($allevents
                        ? 'All events for this message'
                        : 'Important events for this message')
                    . '</h2>';

            print ($allevents
                    ? '<a href="'
                        . htmlspecialchars(url_new('', true, 'allevents', null))
                        . '">View only important events</a>'
                    : '<a href="'
                        . htmlspecialchars(url_new('', true, 'allevents', 1))
                        . '">View all events</a>');
                    
            $recents = msg_admin_message_events($id, !$allevents);
            if (msg_get_error($recents)) {
                print "Error contacting queue:";
                print_r($recents);
                $recents = array();
            }

            $this->print_events($recents);

            if (count($message['bounces']) > 0) {
                print "<h2>Bounce Messages</h2>";
                foreach ($message['bounces'] as $bounce) {
                    print "<hr>";
                    print "<blockquote>" .  nl2br(htmlspecialchars($bounce)) .  "</blockquote>";
                }
                print "<hr>";
                if ($message['state'] == 'bounce_confirm') {
                    $form = new HTML_QuickForm('bounceForm', 'post', $self_link);
                    $bouncegroup[] = &HTML_QuickForm::createElement('submit', 'error', 'Fatal Delivery Error');
                    $bouncegroup[] = &HTML_QuickForm::createElement('submit', 'bounce_wait', 'Temporary Problem');
                    $bouncegroup[] = &HTML_QuickForm::createElement('submit', 'ready', 'Fatal Delivery Error, but should retry with same details');
                    $form->addGroup($bouncegroup, "bouncegroup", "Which kind of bounce message is this?",' ', false);
                    $form->addElement('hidden', 'id', $id);
                    $form->addElement('hidden', 'token', get_token());
                    admin_render_form($form);
                }
            }
         } elseif ($view == 'statistics') {
            // Display general statistics
            $stats = msg_admin_get_stats(1);
            if (msg_get_error($stats)) {
                print "Error contacting queue:";
                print_r($stats);
            }

            $freq_referrers_day = msg_admin_get_popular_referrers(60 * 60 * 24);
            if (msg_get_error($freq_referrers_day)) {
                print "Error contacting queue:";
                print_r($freq_referrers_day);
            }

            $freq_referrers_week = msg_admin_get_popular_referrers(60 * 60 * 24 * 7);
            if (msg_get_error($freq_referrers_week)) {
                print "Error contacting queue:";
                print_r($freq_referrers_week);
            }

            // Navigation bar
            $this->render_bar($view, false, $id);


?>
<h2>Queue statistics</h2>
<p>
<b><?=$stats["created_1"]?></b> new in last hour,
<b><?=$stats["created_24"]?></b> new in last day,
<b><?=$stats["created_168"]?></b> new in last week
<br>last fax sent <b><?=strftime('%e %b %Y, %H:%M', $stats["last_fax_time"])?></b>, 
last email sent <b><?=strftime('%e %b %Y, %H:%M', $stats["last_email_time"])?></b>
</p>
<h2>Messages in each state by type (created in last day)</h2>
<? $this->_display_state_table($stats, "day "); ?>
<h2>Messages in each state by type (created in last week)</h2>
<? $this->_display_state_table($stats, "week "); ?>
<h2>Messages in each state by type (created in last four weeks)</h2>
<? $this->_display_state_table($stats, "four "); ?>
<h2>Messages in each state by type (all time)</h2>
<? $this->_display_state_table($stats, "alltime "); ?>

<h2>Top referrers in last day</h2>
<table border=1>
<?
    foreach ($freq_referrers_day as $row) {
        if ($row[1] > 1 && $row[0] != "") {
            print "<tr><td>" . trim_url($row[0]) . "</td><td>$row[1]</td></tr>";
        }
    }
?>
</table>
<h2>Top referrers in last week</h2>
<table border=1>
<?
    foreach ($freq_referrers_week as $row) {
        if ($row[1] > 1 && $row[0] != "") {
            print "<tr><td>" . trim_url($row[0]) . "</td><td>$row[1]</td></tr>";
        }
    }
?>
</table>
<?
         } elseif ($rep_id) {
            $repinfo = dadem_get_representative_info($rep_id);
            dadem_check_error($repinfo);
            $sameperson = null;
            if ($repinfo['parlparse_person_id']) {
                $sameperson = dadem_get_same_person($repinfo['parlparse_person_id']);
                dadem_check_error($sameperson);
            }
            if (!$sameperson) 
                $sameperson = array($rep_id);
 
            $messages = array();
            $this->render_bar("rep_id", true, $id);
            $rep_ids = '';
            foreach ($sameperson as $this_rep_id) {
                $params = array('rep_id' => $this_rep_id);
                $new_messages = msg_admin_get_queue('rep_id', $params);
                if (msg_get_error($new_messages)) {
                    print "Error contacting queue:";
                    print_r($new_messages);
                    $new_messages = array();
                }
                $messages = array_merge($messages, $new_messages);
                $rep_ids = ' ' . $this_rep_id;
            }

            $by_year = array();
            foreach ($messages as $message) {
                if ($message['dispatched'])
                    $year = strftime('%Y', $message['dispatched']);
                else
                    $year = strftime('%Y', $message['created']);

                $by_year[$year][] = $message;
            }
            
            $years = array_keys($by_year);
            sort($years);
            foreach ($years as $year) {
                $year_array = $by_year[$year];
                print "<h2>Year $year for rep ids $rep_ids";
                print " (" . count($year_array) . " of them): </h2>";

                $q_by_email = array();
                $q_by_email_yes = array();
                $dispatched_by_email = array();
                $sent_by_email = array();
                $q_0_no = 0; $q_0_yes = 0;
                $q_1_no = 0; $q_1_yes = 0;
                $dispatched = 0;
                foreach ($year_array as $message) {
                    if (!array_key_exists($message['sender_email'], $q_by_email)) {
                        $q_by_email[$message['sender_email']] = 0;
                        $q_by_email_yes[$message['sender_email']] = 0;
                        $sent_by_email[$message['sender_email']] = 0;
                    }
                    $q_by_email[$message['sender_email']] += $message['questionnaire_0_no'];
                    $q_by_email[$message['sender_email']] += $message['questionnaire_0_yes'];
                    $q_by_email_yes[$message['sender_email']] += $message['questionnaire_0_yes'];
                    $q_0_no += $message['questionnaire_0_no'];
                    $q_0_yes += $message['questionnaire_0_yes'];
                    $q_1_no += $message['questionnaire_1_no'];
                    $q_1_yes += $message['questionnaire_1_yes'];
                    if ($message['dispatched'] && ($message['state'] == 'sent' || $message['state'] == 'finished')) {
                        $sent_by_email[$message['sender_email']] = $sent_by_email[$message['sender_email']] + 1;
                        $dispatched++;
                        $dispatched_by_email[$message['sender_email']] = true;
                    }
                }
                print "Dispatched: $dispatched (unique: " . count($dispatched_by_email) . ")";
                if ($q_0_yes + $q_0_no > 0) {
                    print " Responsiveness: $q_0_yes / " . ($q_0_no + $q_0_yes);
                }
                if ($q_1_yes + $q_1_no > 0) {
                    print " First time: $q_1_yes / " . ($q_1_no + $q_1_yes);
                }

                $html = '';
                foreach ($q_by_email as $email => $q_count) {
                    $sent_count = $sent_by_email[$email];
                    $q_count_yes = $q_by_email_yes[$email];
                    if ($q_count > 1 || $sent_count > 1) {
                        $html .= "<tr><td>$email</td><td>$sent_count</td><td>$q_count_yes / $q_count</td></tr>";
                    }
                }
                if ($html) {
                    print '<table border="1">';
                    print '<th>Multiple mailers</th><th>Message dispatched</th><th>Responses to first question</th>';
                    print $html;
                    print '</table>';
                } else {
                    print ' Nobody succesfully sent more than one message to this rep using same email.';
                }
                print '<p>';

                $this->print_messages($year_array, null);
            }
         } else {
            // Perform actions on checked items
            $sender_emails = array();
            $sender_full = array();
            foreach ($_POST as $k=>$v) {
                if (stristr($k, "check_")) {
                    $checkid = str_replace("check_", "", $k);
                    $this->do_actions($checkid);
                    $message = msg_admin_get_message($checkid);
                    msg_check_error($message);
                    array_push($sender_emails, $message['sender_email']);
                    array_push($sender_full, $message['sender_name'] . 
                            " &lt;" .  $message['sender_email'] . "&gt;");
                }
            }
            if (count($sender_emails) > 0) {
                print "<p><b>Email list for BCCing:</b><br>" .
                    implode(",", array_unique($sender_emails));
                print "<p><b>List of names and addresses:</b><br>" .
                    implode("<br>", array_unique($sender_full));
            }

            // Decide what message view to show
            $params = array();
            $reverse = false;
            if (stristr($view, "_rev")) {
                $view = str_replace("_rev", "", $view);
                $reverse = true;
            }
            if (get_http_var('search')) {
                $view = "search";
            }

            // Set up additional parameters for view if necessary.
            if ($view == "similarbody" || $view == 'similarbodysamerep') {
                $params['msgid'] = get_http_var('simto');
            } else if ($view == "search" || $view == "logsearch") {
                $params['query'] = get_http_var('query');
            }
            
            // Get details about view
            $messages = msg_admin_get_queue($view, $params);
            if (msg_get_error($messages)) {
                print "Error contacting queue:";
                print_r($messages);
                $messages = array();
            }

            // Navigation bar
            $this->render_bar($view, $reverse, $id);

            // Display messages
            print "<h2>Messages which";
            if ($view == "similarbody") {
                print " have similar bodies to " . make_ids_links(get_http_var('simto'));
            } elseif ($view == "similarbodysamerep") {
                print " are to the same representative and have similar bodies to " . make_ids_links(get_http_var('simto'));
            } elseif ($view == "search") {
                print " match search query '" . htmlspecialchars(get_http_var('query')) . "'";
            } elseif ($view == "logsearch") {
                print " whose log matches '" . htmlspecialchars(get_http_var('query')) . "'";
            } else {
                print " are $view";
            }
            print " (" . count($messages) . " messages): </h2>";
            if ($reverse) {
                $messages = array_reverse($messages);
            }
            $this->print_messages($messages, ($view == 'similarbody' || $view == 'similarbodysamerep') ? $params['msgid'] : null);
            if ($view == 'recentchanged' or $view == 'recentcreated')
                print "<p>..."; /* indicate that this isn't all the messages... */

            // Help
            ?>
            <h2>Help &mdash; what views/searches are there?</h2>
            <p>
            <b>Need Attention:</b> Message which are frozen, most likely
            due to possible abuse, or need bounce messages classifying.
            <br><b>Failing:</b> Messages for which delivery is failing, most like
            incorrect contact details.  Sorted by recipient.
            <br><b>Recently Created:</b> Most recent messages constituents have made.
            <br><b>Recently Changed:</b> Messages which something has happened to recently.
            <br><b>Similar to:</b> Shows messages with bodies similar to a given message.
            Click on "View similar messages" from a message page to get to this view.  Displays
            colourful diffs of the differences.
            <br><b>Contains:</b> Searches the sender details, recipient details and message
            body.  Enter multiple terms separate by spaces, all must be
            present to match.  If you query by state name ('pending') or
            representative type ('EUR') you must enter the whole word, case
            sensitive.  Otherwise queries are case insensitive.  Yes, you
            can query on the referrer URL.  If you have one, you can enter
            a confirmation or questionnaire token from an email, such as
            cqyv7yrisjugc5i5rfz4w75tmnxzi.  Examples: '<b>ready EUR</b>' - all messages to MEPs
            which are ready to be sent.  '<b>francis theyworkforyou</b>' - probably
            all messages written by someone called Francis who came to WTT via
            theyworkforyou.com.
            </p>
            <?
        }
        if ($view != "statistics") {
?>
<h2>Help &mdash; what do the buttons do?</h2>
<?
        if (!$id) {
?>
<p>They apply to all items you have checked.</p>
<?
        }
?>
<p>
<b>note</b> adds the text entered as a remark in the message's log
<br><b>freeze</b> stops delivery to representative, but other stuff
(such as confirmation message) still happens
<br><b>thaw</b> undoes a freeze, so message gets delivered.
<br><b>no questionnaire</b> makes the message one for which no questionnaire is sent.
<br><b>error with email</b> rejects a message, sending a "could not deliver" email to constituent.
<br><b>fail silently</b> rejects a message, with no email to the constituent.
<br><b>confirm</b> moves 'pending' to 'ready', the same as user clicking confirm link in email
<br><b>retry</b> moves a failed message back to 'ready', restarting the sending process
<br><b>view body</b> should only be done if you have good reason to believe it is an abuse of our service.
<br><b>edit contact details</b> by clicking on the recipient name
</p>
<p>To find out <b>state meanings</b>, point the mouse to find out what they are
</p>
<?
        if (!$id) {
        ?>
<h2>Help &mdash; what do the states mean?</h2>
<p>Here is a diagram of state changes:</p>
<p><img src="queue-state-machine.png"></p>

<p>Description of states in the normal lifetime of a message:</p>

<dl>
<dt>new</dt>
<dd>The message has been created by the user but it has not yet been sent to
them for confirmation.</dd>

<dt>pending</dt>
<dd>The message has been sent to the user but not confirmed yet. A reminder
copy of the message is sent if the user does not confirm it within a day.</dd>

<dt>ready</dt>
<dd>The message has been confirmed by the user but it has not yet been
successfully sent; <em>or</em> it has been sent by email but encountered a
fatal bounce for a transient error condition (such as the recipient's mailbox
being full).</dd>

<dt>bounce_wait <em>email only</em></dt>
<dd>The message has been sent, but we hang on to it for a little while in case
a bounce message arrives. Bounce messages are either automatically classified
(where they meet the RFC1892 standard for delivery status notifications) or
passed into the bounce_confirm state for manual classification.</dd>

<dt>sent</dt>
<dd>The message has been sent (and, in case of an email, no bounce message has
arrived within the set time). This is the state in which the questionnaire and
questionnaire reminder are sent.</dd>

<dt>finished</dt>
<dd>All our processing of the message has completed successfully.</dd>
</dl>

</dl>

        <?
        }
        }
    }
Beispiel #17
0
 for ($i = 0; $i < sizeof($poll_votes); $i++) {
     $votes_distrib[$poll_votes[$i]['vote']]['vote']++;
 }
 for ($i = 0; $i < sizeof($votes_distrib); $i++) {
     $votes_distrib[$i]['perc'] = round($votes_distrib[$i]['vote'] / sizeof($poll_votes), 2);
     $votes_distrib[$i]['text'] = $poll_data[0]['options'][$i];
     $votes_distrib[$i]['width'] = $votes_distrib[$i]['perc'] * 200;
 }
 $smarty->assign("T_POLL_VOTES", $votes_distrib);
 $smarty->assign("T_POLL_TOTALVOTES", sizeof($poll_votes));
 $form = new HTML_QuickForm("poll_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=forum&poll=" . $_GET['poll'], "", null, true);
 //Build the form
 foreach ($poll_data[0]['options'] as $key => $option) {
     $group[] = HTML_Quickform::createElement('radio', 'vote', null, $option, $key);
 }
 $form->addGroup($group, 'options', '', '<br/>');
 $form->addRule('options', _PLEASEPICKANOPTION, 'required', null, 'client');
 $form->addElement('submit', 'submit_poll', _VOTE, 'class = "flatButton"');
 if ($form->isSubmitted() && $form->validate()) {
     $values = $form->exportValues();
     //pr($values);
     //debug();
     $res = eF_getTableData("f_users_to_polls", "*", "f_poll_ID=" . $values['options']['vote'] . " and users_LOGIN='******'login'] . "'");
     //debug(false);
     if (sizeof($res) > 0) {
         $message = _YOUHAVEALREADYVOTED;
         $message_type = 'failure';
     } else {
         $fields = array('f_poll_ID' => $_GET['poll'], 'users_LOGIN' => $_SESSION['s_login'], 'vote' => $values['options']['vote'], 'timestamp' => time());
         if (eF_insertTableData("f_users_to_polls", $fields)) {
             $message = _SUCCESFULLYVOTED;
/** baz_formulaire_des_formulaires() retourne le formulaire de saisie des formulaires
 *   @return  Object    le code HTML
 */
function baz_formulaire_des_formulaires($mode, $valeursformulaire = '')
{
    $GLOBALS['_BAZAR_']['url']->addQueryString('action_formulaire', $mode);
    //contruction du squelette du formulaire
    $formtemplate = new HTML_QuickForm('formulaire', 'post', preg_replace('/&amp;/', '&', $GLOBALS['_BAZAR_']['url']->getURL()));
    $GLOBALS['_BAZAR_']['url']->removeQueryString('action_formulaire');
    $squelette =& $formtemplate->defaultRenderer();
    $squelette->setFormTemplate('<form {attributes} class="form-horizontal">' . "\n" . '{content}' . "\n" . '</form>' . "\n");
    $squelette->setElementTemplate('<div class="control-group form-group">' . "\n" . '<label class="control-label col-sm-3">' . "\n" . '{label}' . '<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->' . "\n" . ' </label>' . "\n" . '<div class="controls col-sm-9"> ' . "\n" . '{element}' . "\n" . '<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->' . "\n" . '</div>' . "\n" . '</div>' . "\n");
    $squelette->setElementTemplate('<div class="form-actions form-group">' . "\n" . '<div class="col-sm-9 col-sm-offset-3">{label}{element}</div></div>' . "\n", 'groupe_boutons');
    $squelette->setRequiredNoteTemplate("\n" . '<div class="col-sm-9 col-sm-offset-3 symbole_obligatoire">* {requiredNote}</div>' . "\n");
    //traduction de champs requis
    $formtemplate->setRequiredNote(_t('BAZ_CHAMPS_REQUIS'));
    $formtemplate->setJsWarnings(_t('BAZ_ERREUR_SAISIE'), _t('BAZ_VEUILLEZ_CORRIGER'));
    //champs du formulaire
    if (isset($_GET['idformulaire'])) {
        $formtemplate->addElement('hidden', 'bn_id_nature', $_GET['idformulaire']);
    }
    $formtemplate->addElement('text', 'bn_label_nature', _t('BAZ_NOM_FORMULAIRE'), array('class' => 'form-control input-xxlarge'));
    $formtemplate->addElement('text', 'bn_type_fiche', _t('BAZ_CATEGORIE_FORMULAIRE'), array('class' => 'form-control input-xxlarge'));
    $formtemplate->addElement('textarea', 'bn_description', _t('BAZ_DESCRIPTION'), array('class' => 'form-control input-xxlarge', 'cols' => '20', 'rows' => '3'));
    $formtemplate->addElement('textarea', 'bn_condition', _t('BAZ_CONDITION'), array('class' => 'form-control input-xxlarge', 'cols' => '20', 'rows' => '3'));
    $formtemplate->addElement('text', 'bn_label_class', _t('BAZ_NOM_CLASSE_CSS'), array('class' => 'form-control input-xxlarge'));
    $formtemplate->addElement('textarea', 'bn_template', _t('BAZ_TEMPLATE'), array('class' => 'form-control input-xxlarge', 'cols' => '20', 'rows' => '15'));
    //champs obligatoires
    $formtemplate->addRule('bn_label_nature', _t('BAZ_CHAMPS_REQUIS') . ' : ' . _t('BAZ_FORMULAIRE'), 'required', '', 'client');
    $formtemplate->addRule('bn_template', _t('BAZ_CHAMPS_REQUIS') . ' : ' . _t('BAZ_TEMPLATE'), 'required', '', 'client');
    // Nettoyage de l'url avant les return
    $GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION);
    $HTML_QuickForm = new HTML_QuickForm();
    $buttons[] = $HTML_QuickForm->createElement('submit', 'valider', _t('BAZ_VALIDER'), array('class' => 'btn btn-success'));
    $buttons[] = $HTML_QuickForm->createElement('link', 'annuler', _t('BAZ_ANNULER'), str_replace('&amp;', '&', $GLOBALS['_BAZAR_']['url']->getURL()), _t('BAZ_ANNULER'), array('class' => 'btn btn-mini btn-xs btn-danger'));
    $formtemplate->addGroup($buttons, 'groupe_boutons', null, '&nbsp;', 0);
    return $formtemplate;
}
Beispiel #19
0
    if ($_POST['autoArrange'] == 'A') {
        $sort = SORT_ASC;
    } elseif ($_POST['autoArrange'] == 'D') {
        $sort = SORT_DESC;
    } else {
        $sort = false;
    }
} else {
    $sort = false;
}
// rendering with QF renderer engine and template system
$form->addElement('header', null, 'For demo purpose only: must be validate to be active');
$arrange[] =& $form->createElement('radio', null, null, 'Auto arrange asc.', 'A');
$arrange[] =& $form->createElement('radio', null, null, 'Auto arrange desc.', 'D');
$arrange[] =& $form->createElement('radio', null, null, 'No auto arrange', 'N');
$form->addGroup($arrange, 'autoArrange', 'Sort list:');
$form->setDefaults(array('autoArrange' => 'N'));
$form->addElement('submit', 'validate', 'Validate');
$form->addElement('header', null, 'Advanced Multiple Select: custom layout ');
$ams =& $form->addElement('advmultiselect', 'fruit', null, $fruit_array, array('class' => 'pool', 'style' => 'width:200px;'), $sort);
$ams->setLabel(array('Fruit:', 'Available', 'Selected'));
$ams->setButtonAttributes('add', 'class=inputCommand');
$ams->setButtonAttributes('remove', 'class=inputCommand');
$ams->setButtonAttributes('moveup', 'class=inputCommand');
$ams->setButtonAttributes('movedown', 'class=inputCommand');
// template for a dual multi-select element shape
$template = '
<table{class}>
<!-- BEGIN label_2 --><tr><th>{label_2}</th><!-- END label_2 -->
<!-- BEGIN label_3 --><th>&nbsp;</th><th>{label_3}</th></tr><!-- END label_3 -->
<tr>
    function display($self_link) {
        $action = get_http_var('action');
        if ($action == "")
            $action = "listrules";
        if ($action <> "editrule" && $action <> "listrules") {
            print "<p>Unknown ratty admin display action '$action'</p>";
        }

        if ($action == "editrule") {
            if (!array_key_exists('sequence', $_POST)) {
                if (get_http_var('rule_id') == "") {
                    $ruledata = array();
                    $conditiondata = array();
                } else {
                    $ruledata = ratty_admin_get_rule($this->scope, get_http_var('rule_id'));
                    $ruledata['rule_id'] = get_http_var('rule_id');
                    $conditiondata = ratty_admin_get_conditions($this->scope, get_http_var('rule_id'));
                }
            } else {
                // Load data from form
                $ruledata = array();
                $ruledata['rule_id'] = intval(get_http_var('rule_id'));
                $ruledata['requests'] = intval(get_http_var('requests')); 
                $ruledata['interval'] = intval(get_http_var('interval'));
                $ruledata['sequence'] = intval(get_http_var('sequence'));
                $ruledata['note'] = get_http_var('note'); 
                $ruledata['message'] = get_http_var('message'); 
                $conditiondata = array();
                for ($ix = 1; get_http_var("condition$ix") != ""; $ix++) {
                    if (get_http_var("delete$ix") != "")
                        continue;
                    $condition = array();
                    /* Parse normal/inverted condition */
                    $c = get_http_var("condition$ix");
                    $condition['invert'] = (substr($c, 0, 1) == '+') ? 0 : 1;
                    $condition['condition'] = substr($c, 1, 1);
                    $condition['field'] = get_http_var("field$ix");
                    $condition['value'] = get_http_var("value$ix");
                    array_push($conditiondata, $condition);
                }
            }

            if (get_http_var('newfilter') != "") {
                array_push($conditiondata, array('condition' => 'E', 'invert' => 0));
            }
            if (get_http_var('newsingle') != "") {
                array_push($conditiondata, array("condition" => 'S', 'invert' => 0));
            }
            if (get_http_var('newdistinct') != "") {
                array_push($conditiondata, array("condition" => 'D', 'invert' => 0));
            }

            $form = new HTML_QuickForm('adminRattyRuleForm', 'post', $self_link);
            # Resplice conditions with numbers for form
            $cform = array();

            /* Copy condition data into form, fixing up normal/inverted rules
             * as we go. */
            for ($ix = 1; $ix <= count($conditiondata); ++$ix) {
                foreach ($conditiondata[$ix - 1] as $key => $value) {
                    if ($key == 'condition')
                        $cform["condition$ix"] = ($conditiondata[$ix - 1]['invert'] ? '-' : '+') . $value;
                    else if ($key != 'invert')
                        $cform[$key . $ix] = $value;
                }
            }
            $form->setDefaults(array_merge($ruledata, $cform));

            if (array_key_exists('rule_id', $ruledata))
                $form->addElement('hidden', 'rule_id', $ruledata['rule_id']);
            $form->addElement('hidden', 'page', $this->id);
            $form->addElement('hidden', 'action', $action);

            $form->addElement('header', '', $rule = "" ? 'New Rate-Limiting Rule' : 'Edit Rate-Limiting Rule');

            $titlegroup = array();
            $titlegroup[] = &HTML_QuickForm::createElement('text', 'note', null, array('size' => 40));
            $titlegroup[] = &HTML_QuickForm::createElement('static', null, null, "<b>Eval position:</b>");
            $titlegroup[] = &HTML_QuickForm::createElement('text', 'sequence', "Rule evaluation position:", array('size' => 5, 'maxlength' => 10));
            $form->addRule('sequence', 'Rule position must be numeric', 'numeric', null, 'server');
            $form->addGroup($titlegroup, "titlegroup", "Title of rule:", null, false);

            $limitgroup = array();
            $limitgroup[] = &HTML_QuickForm::createElement('text', 'requests', null, array('size' => 5, 'maxlength' => 10));
            $limitgroup[] = &HTML_QuickForm::createElement('static', null, null, "<b> hits every </b>");
            $limitgroup[] = &HTML_QuickForm::createElement('text', 'interval', null, array('size' => 5, 'maxlength' => 10));
            $limitgroup[] = &HTML_QuickForm::createElement('static', null, null, "<b> seconds</b>. Leave blank/zero to block completely.");
            $form->addGroup($limitgroup, "limitgroup", "Limit rate to:", null, false);

            $form->addElement('textarea', 'message', "Action when rule fires:<br>(for help see below)", array('rows' => 3, 'cols' => 60));
            $form->addRule('requests', 'Hit count must be numeric', 'numeric', null, 'server');
            $form->addRule('interval', 'Time period must be numeric', 'numeric', null, 'server');
            $form->addRule('note', 'Description is required', 'required', null, 'server');
            $form->addRule('requests', 'Requests is required', 'required', null, 'server');
            $form->addRule('interval', 'Interval is required', 'required', null, 'server');

            $form->addElement('header', '', 'Conditions for Rule');
    
            // Get list of fields from ratty
            $fieldarray = ratty_admin_available_fields($this->scope);
            sort($fieldarray);
            $fields = array();
            foreach ($fieldarray as $row) {
                list($field_name, $field_description, $field_examples) = $row;
                $fields[$field_name] = $field_name;
                if (count($field_examples) > 0) {
                    // Get field as an example
                    $example = $field_examples[0];
                    // Search for one that isn't empty
                    if (!$example and count($field_examples) > 1) {
                        $example = $field_examples[1];
                    }
                    $fields[$field_name] .= " (e.g. " .  trim_characters($example, 0, 20) . ")";
                }
            }

            // Grouped elements
            $ix = 0;
            foreach ($conditiondata as $condition) {
                $ix++;
                $condgroup = array();
                $condgroup[0] = &HTML_QuickForm::createElement('select', "field$ix", null, $fields);

                if ($condition['condition'] == 'S') {
                    $condgroup[1] = &HTML_QuickForm::createElement('hidden', "condition$ix", 'S');
                    $desc = 'Limit hits separately for each:';
                } else if ($condition['condition'] == 'D') {
                    $condgroup[1] = &HTML_QuickForm::createElement('hidden', "condition$ix", 'D');
                    $desc = 'Limit number of distinct values of:';
                } else {
                    $condgroup[1] = &HTML_QuickForm::createElement('select', "condition$ix", null, 
                            array(
                                '+E' => 'exactly equals',
                                '-E' => 'does not equal',
                                '+R' => 'matches regexp',
                                '-R' => 'does not match regexp',
                                '+T' => 'roughly matches text',
                                '-T' => 'does not roughly match text',
                                '+I' => 'matches IP mask',
                                '-I' => 'does not match IP mask',
                                '+>' => 'is greater than',
                                '+<' => 'is smaller than',
                                '+P' => 'is present',
                                '-P' => 'is not present',
                            )
                        );
                    $desc = 'Applies only when:';
                    $condgroup[2] = &HTML_QuickForm::createElement('text', "value$ix", null, array('size' => 15));
                }
                array_push($condgroup, HTML_QuickForm::createElement('submit', "delete$ix", 'Del'));
                $form->addGroup($condgroup, "c$ix", $desc, null, false);
                $form->addRule("c$ix", 'Please use a valid regular expression', 'callback', 'check_condition_regexp');

            }

            $buttongroup[0] = &HTML_QuickForm::createElement('submit', 'newfilter', 'Apply only when...');
            $buttongroup[1] = &HTML_QuickForm::createElement('submit', 'newsingle', 'Limit hits separately for each...');
            $buttongroup[2] = &HTML_QuickForm::createElement('submit', 'newdistinct', 'Limit number of distinct values of...');
            $form->addGroup($buttongroup, "buttongroup", "Add new rule condition:",' <br> ', false);

            $form->addElement('header', '', 'Submit Changes');
            $finalgroup = array();
            $finalgroup[] = &HTML_QuickForm::createElement('submit', 'done', 'Done');
            $finalgroup[] = &HTML_QuickForm::createElement('submit', 'cancel', 'Cancel');
            $finalgroup[] = &HTML_QuickForm::createElement('submit', 'deleterule', 'Delete Rule');
            $form->addGroup($finalgroup, "finalgroup", "",' ', false);

            if (get_http_var('done') != "") {
                if ($form->validate()) {
                    $new_rule_id = ratty_admin_update_rule($this->scope, $ruledata, $conditiondata);
                    $action = "listrules";
                }
            } else if (get_http_var('cancel') != "") {
                $action = "listrules";
            } else if (get_http_var('deleterule') != "") {
                if ($ruledata['rule_id'] != "") {
                    ratty_admin_delete_rule($this->scope, $ruledata['rule_id']);
                }
                $action = "listrules";
            }
            
            if ($action == "editrule") {
                admin_render_form($form);

                print "<h2>Help &mdash; What goes in the action box?</h2>";
                print $this->scope_messageblurb; 
                print "<h2>Help &mdash; What do all the fields mean?</h2>";
                print "<p>";
                foreach ($fieldarray as $row) {
                    list($field_name, $field_description, $field_examples) = $row;
                    print "<b>$field_name:</b> $field_description. ";
                    print "e.g. " . implode(", ", array_map(
                    create_function('$a', 'return "\'".trim_characters($a, 0, 50)."\'";'), $field_examples));
                    print "<br>";
                }
                print "</p>";
            }
        }
        if ($action == "listrules") {
            $rules = ratty_admin_get_rules($this->scope);
            print <<<EOF
<h2>$this->scope_title Rules</h2> 
<p>$this->scope_description</p>
<table border="1" width="100%">
    <tr>
        <th>Order</th>
        <th>Description</th>
        <th>Hit limit</th>
        <th>Action</th>
        <th>Matches in<br>time period[1]</th>
EOF;
            if ($this->scope == "fyr-abuse") {
                print "<th>Messages</th>";
            }
            print <<<EOF
    </tr>
EOF;
            $c = 1;
            foreach ($rules as $rule) {
                if ($rule['note'] == "") 
                    $rule['note'] = "&lt;unnamed&gt;";
                print '<tr'.($c==1?' class="v"':'').'>';
                print "<td>" . $rule['sequence'] . "</td>";
                print "<td><a href=\"$self_link&amp;action=editrule&amp;rule_id=" .     /* XXX use url_new... */
                    $rule['id'] . "\">" . $rule['note'] . "</a></td>";
                if ($rule['requests'] == 0 && $rule['interval'] == 0) {
                    print "<td>blocked</td>";
                } else {
                    print "<td>" . $rule['requests'] . " hits / " . $rule['interval'] . " " . make_plural($rule['interval'], 'sec'). "</td>";
                }
                print "<td>" . trim_characters($rule['message'], 0, 40) . "</td>";
                print "<td>" . $rule['hits'] . "</td>";
                if ($this->scope == "fyr-abuse") {
                    print "<td><a href=\"?page=fyrqueue&amp;view=logsearch&amp;query=" .     /* XXX use url_new... */
                    urlencode(" rule #" . $rule['id'] . " ") . "\">View</a></td>";
                }
                print "</tr>";

                $c = 1 - $c;
            }
?>
</table>
<?
            print "<p><a href=\"$self_link&amp;action=editrule\">New rule</a>";
?>
<h2>Help &mdash; how do these rules work?</h2>
<p>
Each rule has a hit rate limit, which limits the number of times a
request or operation is permitted to, at most, the maximum number of
hits in any given specific time period.  (You can set the hit limit to 0
to completely block access.)
</p>
<p>
Conditions within the rule let you specify when it applies.  For example, you
can apply the rule only for certain URLs, IP addresses or postcodes. You can
also make the rule count limits separately for each distinct value of
something, for example, IP addresses, or alternatively limit the number of
distinct representatives which can be viewed per unit time.
</p>
<p>
Rules are applied in order. Each request is tested against each rule in turn
until one matches, in which case the request is denied; or until there are no
more rules, in which case the request is permitted.
</p>
<p>[1] <b>Matches</b> has slightly different meanings for different rules types.
For straightforward filter rules, it means the number of hits in the last 
time period (roughly - it actually means the number of hits in the time period
up until the last hit).  "Time period" here is the number of seconds in the
"Hit limit" column.  For more complicated "Limit hits separately..." and "Limit
number of distinct..." rules, matches is a count of how many times just the 
simple filter conditions were met, not how many times the rule actually triggered.
Note that if the time period is zero, you don't get very useful results.
</p>
<?
        }

    }
Beispiel #21
0
    /**
     * Constructor.
     *
     */
    public function __construct()
    {
        parent::__construct();
        if ($this->loginError) {
            return;
        }
        $this->loadHttpVars(true, false);
        $this->use_mootools = true;
        if (isset($_SESSION['pub'])) {
            // according to session variables, we are already editing a
            // publication
            $this->pub =& $_SESSION['pub'];
        } else {
            if ($this->pub_id != '') {
                // pub_id passed in with $_GET variable
                $this->pub = new pdPublication();
                $result = $this->pub->dbLoad($this->db, $this->pub_id);
                if (!$result) {
                    $this->pageError = true;
                    return;
                }
                $_SESSION['pub'] =& $this->pub;
            } else {
                // create a new publication
                $this->pub = new pdPublication();
                $_SESSION['pub'] =& $this->pub;
            }
        }
        if ($this->pub->pub_id != '') {
            $this->page_title = 'Edit Publication';
        }
        $form = new HTML_QuickForm('add_pub1');
        $form->addElement('header', null, 'Add Publication');
        // title
        $form->addElement('text', 'title', '<span class="Tips1" title="Title::The title of the publication.">Title:</span>', array('size' => 60, 'maxlength' => 250));
        $form->addRule('title', 'please enter a title', 'required', null, 'client');
        $tooltip = 'Abstract::If available, enter the abstract of the document
 you are submitting. &lt;p/&gt;
 Plain text or HTML text (using HTML tags) can be used.';
        $form->addElement('textarea', 'abstract', "<span class=\"Tips1\" title=\"{$tooltip}\">Abstract</span>:<br/><div class=\"small\">HTML Enabled</div>", array('cols' => 60, 'rows' => 10));
        $tooltip = 'Keywords::Enter keywords that describe your paper and could
 possibly be used to find your paper by other users searching the database. You
 may want to enter multiple terms that are associated with your document.
 &lt;p/&gt;
 &lt;i&gt;&lt;b&gt;If your paper is Machine Learning related please put
 \'mahcine learning\' here.&lt;/b&gt;&lt;/i&gt;
 &lt;p/&gt;
 Examples may include words like: medical imaging; robotics; data mining.';
        $form->addGroup(array(HTML_QuickForm::createElement('text', 'keywords', null, array('size' => 60, 'maxlength' => 250)), HTML_QuickForm::createElement('static', 'kwgroup_help', null, '<span class="small">separate using semi-colons (;)</span>')), 'kwgroup', "<span class=\"Tips1\" title=\"{$tooltip}\">Keywords:</span>", '<br/>', false);
        $tooltip = 'User Info::A place for the user to enter his/her own information';
        $form->addElement('textarea', 'user', "<span class=\"Tips1\" title=\"{$tooltip}\">User Info:</span>", array('cols' => 60, 'rows' => 2));
        $buttons[] = HTML_QuickForm::createElement('button', 'cancel', 'Cancel', array('onclick' => "cancelConfirm();"));
        $buttons[] = HTML_QuickForm::createElement('reset', 'reset', 'Reset');
        $buttons[] = HTML_QuickForm::createElement('submit', 'step2', '>> Step 2');
        $buttons[] = HTML_QuickForm::createElement('submit', 'step3', '>> Step 3');
        $buttons[] = HTML_QuickForm::createElement('submit', 'step4', '>> Step 4');
        if ($this->pub->pub_id != '') {
            $buttons[] = HTML_QuickForm::createElement('submit', 'finish', 'Finish');
        }
        $form->addGroup($buttons, 'buttons', '', '&nbsp;', false);
        $this->db =& $this->db;
        $this->form =& $form;
        if ($form->validate()) {
            $this->processForm();
        } else {
            $this->renderForm();
        }
    }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <title>Simple HTML_QuickForm Example</title>
  </head>
  <body>
    <h1>Simple HTML_QuickForm Example</h1>
<?php 
require_once "HTML/QuickForm.php";
$form = new HTML_QuickForm("", "post", "", "", null, true);
$form->addElement("text", "username", "Username");
$password = $form->addElement("password", "password", "Password");
$password->setValue("");
$buttons = array();
$buttons[] = HTML_QuickForm::createElement("submit", "submitButton", "Send Details");
$buttons[] = HTML_QuickForm::createElement("reset", "resetButton", "Reset Form");
$form->addGroup($buttons, null, null, "&nbsp;");
if ($form->isSubmitted()) {
    echo "<p>Thanks for your details!</p>";
} else {
    echo $form->toHtml();
}
?>
  </body>
</html>
Beispiel #23
0
$form->addElement('text', 'itxtTest', 'Test Text:');
// will be rendered in qf_textarea block, as it exists in template
$form->addElement('textarea', 'itxaTest', 'Test TextArea:', array('rows' => 5, 'cols' => 40));
// will be later assigned to qf_green, note that an array of labels is passed
$form->addElement('password', 'ipwdTest', array('Test Password:'******'The password is expected to be long enough.'));
$select =& $form->addElement('select', 'iselTest', 'Test Select:', array('A' => 'A', 'B' => 'B', 'C' => 'C', 'D' => 'D'));
$select->setSize(5);
$select->setMultiple(true);
$form->addElement('submit', 'isubTest', 'Test Submit');
$form->addElement('header', '', 'Grouped Elements');
// will be rendered in default qf_group block
$checkbox[] =& HTML_QuickForm::createElement('checkbox', 'A', null, 'A');
$checkbox[] =& HTML_QuickForm::createElement('checkbox', 'B', null, 'B');
$checkbox[] =& HTML_QuickForm::createElement('checkbox', 'C', null, 'C');
$checkbox[] =& HTML_QuickForm::createElement('checkbox', 'D', null, 'D');
$form->addGroup($checkbox, 'ichkABCD', 'ABCD:', array('&nbsp;', '<br />'));
// fancygroup candidates
// will be rendered in qf_fancygroup_radio
$radio[] =& HTML_QuickForm::createElement('radio', null, null, 'Yes', 'Y');
$radio[] =& HTML_QuickForm::createElement('radio', null, null, 'No', 'N');
$form->addGroup($radio, 'iradYesNo', 'Yes/No:');
// will be rendered in qf_fancygroup_element
$name['first'] =& HTML_QuickForm::createElement('text', 'first', 'First:');
$name['first']->setSize(20);
$name['last'] =& HTML_QuickForm::createElement('text', 'last', 'Last:');
$name['last']->setSize(30);
$form->addGroup($name, 'name', 'Name');
// add some 'required' rules to show "stars" and (possible) errors...
$form->addRule('itxtTest', 'Test Text is a required field', 'required');
$form->addRule('itxaTest', 'Test TextArea is a required field', 'required');
$form->addRule('iradYesNo', 'Check Yes or No', 'required');
Beispiel #24
0
if (isset($_POST['multiselect'])) {
    $ams->setElementTemplate($template2);
} else {
    $ams->setElementTemplate($template1);
}
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    // fruit default values already selected without any end-user actions
    $form->setDefaults(array('fruit' => array('kiwi', 'lime')));
} elseif (isset($_POST['fruit'])) {
    // fruit end-user selection
    $form->setDefaults(array('fruit' => $_POST['fruit']));
}
$buttons[] =& $form->createElement('submit', null, 'Submit');
$buttons[] =& $form->createElement('reset', null, 'Reset');
$buttons[] =& $form->createElement('checkbox', 'multiselect', null, 'use dual select boxes layout');
$form->addGroup($buttons, null, '&nbsp;');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>HTML_QuickForm::advMultiSelect custom example 6</title>
<style type="text/css">
<!--
body {
  background-color: #FFF;
  font-family: Verdana, Arial, helvetica;
  font-size: 10pt;
}
Beispiel #25
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);
        }
    }
Beispiel #26
0
    public function __construct()
    {
        parent::__construct();
        if ($this->loginError) {
            return;
        }
        $this->use_mootools = true;
        $this->loadHttpVars(true, false);
        $this->pub =& $_SESSION['pub'];
        if (isset($this->pub->pub_id)) {
            $this->page_title = 'Edit Publication';
        }
        if (empty($this->venue_id) && is_object($this->pub->venue) && !empty($this->pub->venue->venue_id)) {
            $this->venue_id = $this->pub->venue->venue_id;
        }
        if (isset($this->venue_id)) {
            if ($this->venue_id >= 0) {
                $this->pub->addVenue($this->db, $this->venue_id);
            } else {
                $this->pub->venue = null;
            }
        }
        if (isset($this->cat_id)) {
            $this->pub->addCategory($this->db, $this->cat_id);
        } else {
            if (is_object($this->pub->category)) {
                $this->cat_id = $this->pub->category->cat_id;
            }
        }
        $this->addPubDisableMenuItems();
        $form = new HTML_QuickForm('add_pub3');
        $form->addElement('header', null, 'Category Information');
        // category
        $category_list = pdCatList::create($this->db);
        $category[] = HTML_QuickForm::createElement('select', 'cat_id', null, array('' => '--- Please Select a Category ---') + $category_list, array('onchange' => 'dataKeep();'));
        $text = '';
        if (is_object($this->pub->venue) && is_object($this->pub->category) && $this->pub->venue->cat_id != 0 && $this->pub->venue->cat_id != $this->pub->category->cat_id) {
            $text = '<span class="emph">(venue default is: ' . $category_list[$this->pub->venue->cat_id] . ')</span>';
        }
        $category[] = HTML_QuickForm::createElement('static', null, null, $text);
        $tooltip = 'Category::The type of publication entry being
submitted to the database. For example this could be a conference paper, a
journal entry, a book chapter, etc.
&lt;p/&gt;
Select the appropriate category from the drop down menu';
        $form->addGroup($category, null, "<span class=\"Tips1\" title=\"{$tooltip}\">Category</span>:", '&nbsp;&nbsp;', false);
        // Venue
        if (is_object($this->pub->category) && in_array($this->cat_id, array(1, 3, 4))) {
            $vlist = pdVenueList::create($this->db, array('cat_id' => $this->cat_id, 'concat' => true));
        } else {
            $vlist = pdVenueList::create($this->db, array('concat' => true));
        }
        $venues[''] = '--Select Venue--';
        $venues['-1'] = '--No Venue--';
        // check if user info has 'Venues previously used by me' checked
        if ($this->used_by_me == 'yes') {
            $user =& $_SESSION['user'];
            $user->venueIdsGet($this->db);
            foreach ($vlist as $venue_id => $name) {
                if (isset($user->venue_ids[$venue_id])) {
                    $venues[$venue_id] = htmlentities($name);
                }
            }
        } else {
            foreach ($vlist as $venue_id => $name) {
                $venues[$venue_id] = htmlentities($name);
            }
        }
        $tooltip = 'Venue::Where the paper was published -- specific journal,
conference, workshop, etc. If many of the database papers are in the same
venue, you can create a single <b>label</b> for that
venue, to specify name of the venue, location, date, editors
and other common information. You will then be able to use
and re-use that information.';
        $form->addElement('select', 'venue_id', "<span class=\"Tips1\" title=\"{$tooltip}\">Venue</span>:", $venues, array('style' => 'width: 70%;', 'onchange' => 'dataKeep();'));
        $form->addElement('submit', 'add_venue', 'Add New Venue');
        $form->addElement('advcheckbox', 'used_by_me', null, 'Only show venues previously used by me', array('onchange' => 'dataKeep();'), array('', 'yes'));
        // rankings radio selections
        $rankings = pdPublication::rankingsGlobalGet($this->db);
        foreach ($rankings as $rank_id => $description) {
            $text = $description;
            if (is_object($this->pub->venue)) {
                if ($this->pub->venue->rank_id == $rank_id) {
                    $text .= ' <span class="emph">(venue default)</span>';
                }
            } else {
                if (is_object($this->pub->category) && ($this->pub->category->cat_id == 1 && $rank_id == 2 || $this->pub->category->cat_id == 3 && $rank_id == 2 || $this->pub->category->cat_id == 4 && $rank_id == 3)) {
                    $text .= ' <span class="emph">(category default)</span>';
                }
            }
            $radio_rankings[] = HTML_QuickForm::createElement('radio', 'paper_rank', null, $text, $rank_id);
        }
        $radio_rankings[] = HTML_QuickForm::createElement('radio', 'paper_rank', null, 'other (fill in box below)', -1);
        $radio_rankings[] = HTML_QuickForm::createElement('text', 'paper_rank_other', null, array('size' => 30, 'maxlength' => 250));
        $tooltip = 'Ranking::Select the ranking of the venue. If the venue is
already in the database the ranking should be selected automatically.
Sometimes the paper may have a ranking different from the venue ranking.';
        $form->addGroup($radio_rankings, 'group_rank', "<span class=\"Tips1\" title=\"{$tooltip}\">Ranking</span>:", '<br/>', false);
        if ($this->cat_id > 0 && is_object($this->pub->category) && is_array($this->pub->category->info) && count($this->pub->category->info) > 0) {
            foreach ($this->formInfoElementsGet() as $element => $name) {
                $form->addElement('text', $element, $name . ':', array('size' => 50, 'maxlength' => 250));
            }
        }
        $tooltip = 'Date::The date the publication was published.';
        $form->addElement('date', 'pub_date', "<span class=\"Tips1\" title=\"{$tooltip}\">Date</span>:", array('format' => 'YM', 'minYear' => pdPublication::MIN_YEAR, 'maxYear' => pdPublication::MAX_YEAR));
        $form->addElement('header', 'other_info', 'Other information', null);
        $tooltip = 'Extra Information::Specify auxiliary information to help
classify this publication. Eg, &quot;with student&quot; or &quot;best
paper&quot;, etc.
&lt;p/&gt;
Note: by default this information will NOT be shown
when this publication entry is displayed.';
        $form->addElement('textarea', 'extra_info', "<span class=\"Tips1\" title=\"{$tooltip}\">Extra Information</span>:", array('cols' => 60, 'rows' => 5));
        $form->addElement('static', null, null, '<span class="small">' . 'Separate using semicolons.' . ' See help text for examples of what goes here ' . '(use mouse to hover over \'Extra Information\' ' . 'text).' . '</span>');
        $pos = strpos($_SERVER['PHP_SELF'], 'papersdb');
        $url = substr($_SERVER['PHP_SELF'], 0, $pos) . 'papersdb';
        $buttons[] = HTML_QuickForm::createElement('submit', 'prev_step', '<< Previous Step');
        $buttons[] = HTML_QuickForm::createElement('button', 'cancel', 'Cancel', array('onclick' => "cancelConfirm();"));
        $buttons[] = HTML_QuickForm::createElement('reset', 'reset', 'Reset');
        $buttons[] = HTML_QuickForm::createElement('submit', 'next_step', 'Next Step >>');
        if ($this->pub->pub_id != '') {
            $buttons[] = HTML_QuickForm::createElement('submit', 'finish', 'Finish');
        }
        $form->addGroup($buttons, 'buttons', '', '&nbsp;', false);
        $this->form =& $form;
        if ($form->validate()) {
            $this->processForm();
        } else {
            $this->renderForm();
        }
    }
Beispiel #27
0
 public function __construct()
 {
     parent::__construct('add_category');
     $this->loadHttpVars();
     if ($this->loginError) {
         return;
     }
     $category = new pdCategory();
     if (isset($this->cat_id)) {
         if (!is_numeric($this->cat_id)) {
             $this->pageError = true;
             return;
         }
         $result = $category->dbLoad($this->db, $this->cat_id);
         if (!$result) {
             $this->pageError = true;
             return;
         }
     }
     if (isset($this->numNewFields)) {
         if (!is_numeric($this->numNewFields)) {
             $this->pageError = true;
             return;
         }
     } else {
         $this->numNewFields = 0;
     }
     if ($category->cat_id != '') {
         $label = 'Edit Category';
     } else {
         $label = 'Add Category';
     }
     $this->pageTitle = $label;
     $form = new HTML_QuickForm('catForm');
     $form->addElement('header', null, $this->helpTooltip($label, 'addCategoryPageHelp', 'helpHeading'));
     $form->addElement('text', 'catname', 'Category Name:', array('size' => 50, 'maxlength' => 250));
     $form->addRule('catname', 'category name cannot be empty', 'required', null, 'client');
     // info list
     $label = 'Related Fields:';
     $info_list = pdInfoList::create($this->db);
     foreach ($info_list as $info_id => $name) {
         $form->addElement('advcheckbox', 'info[' . $info_id . ']', $label, $name, null, array('', $name));
         $label = '';
     }
     for ($i = 0; $i < $this->numNewFields; $i++) {
         $form->addElement('text', 'new_fields[' . $i . ']', 'New field ' . ($i + 1) . ':', array('size' => 50, 'maxlength' => 250));
     }
     $form->addElement('hidden', 'numNewFields', $this->numNewFields);
     $form->addGroup(array(HTML_QuickForm::createElement('reset', 'reset', 'Reset'), HTML_QuickForm::createElement('button', 'add_field', 'Add Related Field', array('onClick' => 'dataKeep(' . ($this->numNewFields + 1) . ');')), HTML_QuickForm::createElement('submit', 'submit', 'Submit New Category')), 'submit_group', null, '&nbsp;');
     if ($form->validate()) {
         $values = $form->exportValues();
         $category->category = $values['catname'];
         if (isset($values['new_fields'])) {
             $values['info'] = array_merge($values['info'], $values['new_fields']);
         }
         foreach ($values['info'] as $infoname) {
             if ($infoname == '') {
                 continue;
             }
             $obj = new stdClass();
             $obj->name = $infoname;
             $category->info[] = $obj;
         }
         $category->dbSave($this->db);
         echo 'Category "', $category->category, '" succesfully added to the database.', '<p/>', '<a href="' . $_SERVER['PHP_SELF'] . '">', 'Add another new category</a>';
     } else {
         foreach (array_keys(get_class_vars(get_class($this))) as $member) {
             $defaults[$member] = $this->{$member};
         }
         $defaults['catname'] = $category->category;
         if (isset($category->info) && count($category->info) > 0) {
             foreach ($category->info as $info_id => $name) {
                 $defaults['info[' . $info_id . ']'] = $name;
             }
         }
         $form->setDefaults($defaults);
         $renderer =& $form->defaultRenderer();
         $form->accept($renderer);
         $this->form =& $form;
         $this->renderer =& $renderer;
         $this->javascript();
     }
 }
Beispiel #28
0
$qfe['close'] = $qf->addElement('hidden', 'close');
// URLと連番設定
$qfe['uri'] = $qf->addElement('text', 'uri', 'URL', $_attr_uri);
$qfe['serial'] = $qf->addElement('checkbox', 'serial', '連番', null, $_attr_s_chk);
$qfe['from'] = $qf->addElement('text', 'from', 'From', $_attr_s_from);
$qfe['to'] = $qf->addElement('text', 'to', 'To', $_attr_s_to);
$qfe['padding'] = $qf->addElement('text', 'padding', '0で詰める桁数', $_attr_s_pad);
// リファラとメモ
$qfe['ref'] = $qf->addElement('text', 'ref', 'リファラ', $_attr_ref);
$qfe['memo'] = $qf->addElement('text', 'memo', '  メモ', $_attr_memo);
// プレビューの大きさ
$preview_size = array();
foreach ($_preview_size as $value => $lavel) {
    $preview_size[$value] = HTML_QuickForm::createElement('radio', null, null, $lavel, $value);
}
$qf->addGroup($preview_size, 'preview_size', 'プレビュー', '&nbsp;');
if (!isset($_GET['preview_size'])) {
    $preview_size[1]->updateAttributes('checked="checked"');
}
// 決定・リセット・閉じる
$qfe['download'] = $qf->addElement('submit', 'download');
$qfe['reset'] = $qf->addElement('reset', 'reset');
$qfe['close'] = $qf->addElement('button', 'close', null, $_attr_close);
// Flexy
$_flexy_options =& PEAR5::getStaticProperty('HTML_Template_Flexy', 'options');
$_flexy_options = array('locale' => 'ja', 'charset' => 'Shift_JIS', 'compileDir' => $_conf['compile_dir'] . DIRECTORY_SEPARATOR . 'ic2', 'templateDir' => P2EX_LIB_DIR . '/ImageCache2/templates', 'numberFormat' => '');
$flexy = new HTML_Template_Flexy();
$flexy->setData('php_self', $_SERVER['SCRIPT_NAME']);
$flexy->setData('p2vid', P2_VERSION_ID);
$flexy->setData('skin', $skin_en);
$flexy->setData('isPopUp', $isPopUp);
Beispiel #29
0
// Fills with some defaults values
$defaultValues['company'] = 'Mamasam';
$defaultValues['country'] = array();
$defaultValues['name'] = array('first' => 'Bertrand', 'last' => 'Mansion');
$defaultValues['phone'] = array('513', '123', '4567');
$form->setDefaults($defaultValues);
// Hidden
$form->addElement('hidden', 'session', '1234567890');
// Personal information
$form->addElement('header', 'personal', 'Personal Information');
$form->addElement('hidden', 'ihidTest', 'hiddenField');
$form->addElement('text', 'email', 'Your email:');
$form->addElement('password', 'pass', array('Your password:'******'note' => 'Please, choose a 8-10 characters password.'), 'size=10');
$name['last'] =& HTML_QuickForm::createElement('text', 'first', 'First', 'size=10');
$name['first'] =& HTML_QuickForm::createElement('text', 'last', 'Last', 'size=10');
$form->addGroup($name, 'name', 'Name:', ',&nbsp;');
$areaCode =& HTML_QuickForm::createElement('text', '', null, 'size=4 maxlength=3');
$phoneNo1 =& HTML_QuickForm::createElement('text', '', null, 'size=4 maxlength=3');
$phoneNo2 =& HTML_QuickForm::createElement('text', '', null, 'size=5 maxlength=4');
$form->addGroup(array($areaCode, $phoneNo1, $phoneNo2), 'phone', 'Telephone:', '-');
// Company information
$form->addElement('header', 'company_info', 'Company Information');
$form->addElement('text', 'company', 'Company:', 'size=20');
$str[] =& HTML_QuickForm::createElement('text', '', null, 'size=20');
$str[] =& HTML_QuickForm::createElement('text', '', null, 'size=20');
$form->addGroup($str, 'street', 'Street:', '<br />');
$addr['zip'] =& HTML_QuickForm::createElement('text', 'zip', 'Zip', 'size=6 maxlength=10');
$addr['city'] =& HTML_QuickForm::createElement('text', 'city', 'City', 'size=15');
$form->addGroup($addr, 'address', 'Zip, city:');
$select = array('' => 'Please select...', 'AU' => 'Australia', 'FR' => 'France', 'DE' => 'Germany', 'IT' => 'Italy');
$form->addElement('select', 'country', 'Country:', $select);
Beispiel #30
0
 $pl_s = $form->createElement('select', 'post_level_id', 'Post Level:');
 $pl_opts[0] = 'Select One';
 foreach ($post_zones as $value) {
     $pz_opts[$value->post_zone_id] = $value->zone;
 }
 foreach ($post_levels as $value) {
     $pl_opts[$value->post_level_id] = $value->post_level;
 }
 // Remove name attribute for xhtml strict compliance.
 $form->removeAttribute('name');
 $form->addElement('html', '<fieldset>');
 $form->addElement('header', 'edit_cost', 'Edit Post Cost');
 $form->addElement('text', 'cost', 'Cost:', array('size' => 5, 'maxlength' => 5, 'class' => 'inputbox'));
 $radio[] = $form->createElement('radio', null, null, 'Yes', '1');
 $radio[] = $form->createElement('radio', null, null, 'No', '0');
 $form->addGroup($radio, 'vat_inc', 'Include Tax:');
 $pl_s->loadArray($pl_opts);
 $form->addElement($pl_s);
 $pz_s->loadArray($pz_opts);
 $form->addElement($pz_s);
 $form->addElement('html', '</fieldset>');
 $form->addRule('cost', 'Please enter a post cost', 'required');
 $form->addRule('cost', 'post costs have to be a number', 'numeric');
 $form->addGroupRule('vat_inc', 'Please choose whether to include tax or not.', 'required', null, 1);
 $form->addRule('post_zone_id', 'Please select a post zone', 'nonzero');
 $form->addRule('post_level_id', 'Please select a post level', 'nonzero');
 if ($form->validate()) {
     $form->freeze();
     $values = $form->process(array(&$this, 'formValues'), false);
     $menuBar['back'] = '/ushop/postage/overview';
     //check then enter the record.