コード例 #1
0
ファイル: Radiobutton.php プロジェクト: HaldunA/phpwebsite
 /**
  * Edit this PHAT_Radiobutton
  *
  * This function provides the HTML form to edit or create a new PHAT_Radiobutton
  *
  * @return string The HTML form for editing
  * @access public
  */
 function edit()
 {
     $numOptions = sizeof($this->getOptionText());
     if (!$numOptions) {
         $numOptions = '';
     }
     $elements[0] = PHPWS_Form::formHidden('module', 'phatform') . PHPWS_Form::formHidden('PHAT_EL_OP', 'SaveElement');
     if (!$this->getLabel()) {
         $num = $_SESSION['PHAT_FormManager']->form->numElements();
         $this->setLabel('Element' . ($num + 1));
     }
     if (PHAT_SHOW_INSTRUCTIONS) {
         $GLOBALS['CNT_phatform']['title'] = dgettext('phatform', 'Radiobutton Element Instructions');
     }
     $editTags['BLURB_LABEL'] = dgettext('phatform', 'Associated Text');
     $editTags['BLURB_INPUT'] = PHPWS_Form::formTextArea('PHAT_ElementBlurb', $this->getBlurb(), PHAT_DEFAULT_ROWS, PHAT_DEFAULT_COLS);
     $editTags['NAME_LABEL'] = dgettext('phatform', 'Name');
     $editTags['NAME_INPUT'] = PHPWS_Form::formTextField('PHAT_ElementName', $this->getLabel(), PHAT_DEFAULT_SIZE, PHAT_DEFAULT_MAXSIZE);
     $editTags['OPTIONS_LABEL'] = dgettext('phatform', 'Number of Options');
     $editTags['OPTIONS_INPUT'] = PHPWS_Form::formTextField('PHAT_ElementNumOptions', $numOptions, 5, 3);
     $options = $this->getOptionSets();
     if (is_array($options)) {
         $editTags['OPTION_SET_LABEL'] = dgettext('phatform', 'Predefined Option Set');
         $editTags['OPTION_SET_INPUT'] = PHPWS_Form::formSelect('PHAT_OptionSet', $options, $this->getOptionSet(), FALSE, TRUE);
     }
     $editTags['REQUIRE_LABEL'] = dgettext('phatform', 'Required');
     $editTags['REQUIRE_INPUT'] = PHPWS_Form::formCheckBox('PHAT_ElementRequired', 1, $this->isRequired());
     $editTags['BACK_BUTTON'] = PHPWS_Form::formSubmit(dgettext('phatform', 'Back'), 'PHAT_ElementBack');
     $editTags['NEXT_BUTTON'] = PHPWS_Form::formSubmit(dgettext('phatform', 'Next'));
     $elements[0] .= PHPWS_Template::processTemplate($editTags, 'phatform', 'radiobutton/edit.tpl');
     return PHPWS_Form::makeForm('PHAT_RadiobuttonEdit', 'index.php', $elements, 'post', NULL, NULL);
 }
コード例 #2
0
ファイル: Textarea.php プロジェクト: HaldunA/phpwebsite
 /**
  * Edit this PHAT_Textarea
  *
  * @return string The HTML form needed to edit this PHAT_Textarea
  * @access public
  */
 function edit()
 {
     $elements[0] = PHPWS_Form::formHidden('module', 'phatform') . PHPWS_Form::formHidden('PHAT_EL_OP', 'SaveElement');
     if (!$this->getLabel()) {
         $num = $_SESSION['PHAT_FormManager']->form->numElements();
         $this->setLabel('Element' . ($num + 1));
     }
     if (PHAT_SHOW_INSTRUCTIONS) {
         $GLOBALS['CNT_phatform']['title'] = dgettext('phatform', 'Textarea Element Instructions');
     }
     $editTags['BLURB_LABEL'] = dgettext('phatform', 'Associated Text');
     $editTags['BLURB_INPUT'] = PHPWS_Form::formTextArea('PHAT_ElementBlurb', $this->getBlurb(), PHAT_DEFAULT_ROWS, PHAT_DEFAULT_COLS);
     $editTags['NAME_LABEL'] = dgettext('phatform', 'Name');
     $editTags['NAME_INPUT'] = PHPWS_Form::formTextField('PHAT_ElementName', $this->getLabel(), PHAT_DEFAULT_SIZE, PHAT_DEFAULT_MAXSIZE);
     $editTags['ROWS_LABEL'] = dgettext('phatform', 'Rows');
     $editTags['ROWS_INPUT'] = PHPWS_Form::formTextField('PHAT_ElementRows', $this->_rows, 5, 3);
     $editTags['COLS_LABEL'] = dgettext('phatform', 'Columns');
     $editTags['COLS_INPUT'] = PHPWS_Form::formTextField('PHAT_ElementCols', $this->_cols, 5, 3);
     $editTags['VALUE_LABEL'] = dgettext('phatform', 'Value');
     $editTags['VALUE_INPUT'] = PHPWS_Form::formTextArea('PHAT_ElementValue', $this->getValue(), PHAT_DEFAULT_ROWS, PHAT_DEFAULT_COLS);
     $editTags['REQUIRE_LABEL'] = dgettext('phatform', 'Require');
     $editTags['REQUIRE_INPUT'] = PHPWS_Form::formCheckBox('PHAT_ElementRequired', 1, $this->isRequired());
     $editTags['BACK_BUTTON'] = PHPWS_Form::formSubmit(dgettext('phatform', 'Back'), 'PHAT_ElementBack');
     $editTags['SAVE_BUTTON'] = PHPWS_Form::formSubmit(dgettext('phatform', 'Save Textarea'));
     $elements[0] .= PHPWS_Template::processTemplate($editTags, 'phatform', 'textarea/edit.tpl');
     return PHPWS_Form::makeForm('PHAT_TextareaEdit', 'index.php', $elements, 'post', NULL, NULL);
 }
コード例 #3
0
ファイル: Element.php プロジェクト: HaldunA/phpwebsite
 /**
  * Get the options for this PHAT_Element
  *
  * @return string The HTML form for retrieving the options
  * @access public
  */
 function getOptions()
 {
     $className = get_class($this);
     $properName = ucfirst(str_ireplace('phat_', '', $className));
     if (isset($_REQUEST['PHAT_OptionSet']) && $_REQUEST['PHAT_OptionSet'] != 0 && $_REQUEST['PHAT_OptionSet'] != $this->getOptionSet()) {
         $this->setOptionSet($_REQUEST['PHAT_OptionSet']);
         $db = new PHPWS_DB('mod_phatform_options');
         $db->addWhere('id', $this->getOptionSet());
         $optionResult = $db->select();
         $this->_optionText = array();
         $this->_optionValues = array();
         $this->_optionText = unserialize(stripslashes($optionResult[0]['optionSet']));
         $this->_optionValues = unserialize(stripslashes($optionResult[0]['valueSet']));
     }
     if (!empty($_REQUEST['PHAT_ElementNumOptions']) && is_numeric($_REQUEST['PHAT_ElementNumOptions'])) {
         $loops = $_REQUEST['PHAT_ElementNumOptions'];
         /* must reset these arrays for when a new number of options is entered */
         $oldText = $this->_optionText;
         $oldValues = $this->_optionValues;
         $this->_optionText = array();
         $this->_optionValues = array();
         for ($i = 0; $i < $loops; $i++) {
             if (isset($oldText[$i])) {
                 $this->_optionText[$i] = $oldText[$i];
             } else {
                 $this->_optionText[$i] = NULL;
             }
             if (isset($oldValues[$i])) {
                 $this->_optionValues[$i] = $oldValues[$i];
             } else {
                 $this->_optionValues[$i] = NULL;
             }
         }
     } else {
         if (sizeof($this->_optionText) > 0) {
             $loops = sizeof($this->_optionText);
         } else {
             return PHPWS_Error::get(PHATFORM_ZERO_OPTIONS, 'phatform', 'PHAT_Element::getOptions()');
         }
     }
     $elements[0] = '<input type="hidden" name="module" value="phatform" /><input type="hidden" name="PHAT_EL_OP" value="SaveElementOptions" />';
     if (PHAT_SHOW_INSTRUCTIONS) {
         $GLOBALS['CNT_phatform']['title'] = dgettext('phatform', 'Option Instructions');
     }
     $editTags['NUMBER_LABEL'] = dgettext('phatform', 'Option');
     $editTags['INPUT_LABEL'] = dgettext('phatform', 'Text');
     $editTags['VALUE_LABEL'] = dgettext('phatform', 'Value');
     $editTags['DEFAULT_LABEL'] = dgettext('phatform', 'Default');
     $editTags['OPTIONS'] = '';
     $rowClass = NULL;
     for ($i = 0; $i < $loops; $i++) {
         $optionRow['OPTION_NUMBER'] = $i + 1;
         $element = new Form_TextField("PHAT_ElementOptions[{$i}]", $this->_optionText[$i]);
         $element->setSize(PHAT_DEFAULT_SIZE, PHAT_DEFAULT_MAXSIZE);
         $optionRow['OPTION_INPUT'] = $element->get();
         $element = new Form_TextField("PHAT_ElementValues[{$i}]", $this->_optionValues[$i]);
         $element->setSize(PHAT_DEFAULT_SIZE, PHAT_DEFAULT_MAXSIZE);
         $optionRow['VALUE_INPUT'] = $element->get();
         $check = NULL;
         if ($className == 'PHAT_checkbox' || $className == 'PHAT_Multiselect') {
             if (isset($this->_optionValues[$i]) && (isset($this->_value[$i]) && $this->_optionValues[$i] == $this->_value[$i])) {
                 $check = $i;
             }
             $element = new Form_CheckBox("PHAT_ElementDefault[{$i}]", $i);
             $element->setMatch($check);
             $optionRow['OPTION_DEFAULT'] = $element->get();
         } else {
             if (isset($this->_optionValues[$i]) && $this->_optionValues[$i] == $this->_value) {
                 $check = $i;
             }
             $element = new Form_CheckBox('PHAT_ElementDefault', $i);
             $element->setMatch($check);
             $optionRow['OPTION_DEFAULT'] = $element->get();
         }
         $optionRow['ROW_CLASS'] = $rowClass;
         if ($i % 2) {
             $rowClass = ' class="bgcolor1"';
         } else {
             $rowClass = null;
         }
         $editTags['OPTIONS'] .= PHPWS_Template::processTemplate($optionRow, 'phatform', 'element/option.tpl');
     }
     $check = NULL;
     if ($this->getId()) {
         if ($this->_optionText == $this->_optionValues && sizeof($this->_optionText) > 0) {
             $check = 1;
         }
     }
     if (isset($_REQUEST['PHAT_SaveOptionSet'])) {
         $setName = $_REQUEST['PHAT_SaveOptionSet'];
     } else {
         $setName = NULL;
     }
     $element = new Form_Checkbox('PHAT_ElementUseText', 1);
     $element->setMatch($check);
     $editTags['USE_TEXT_CHECK'] = dgettext('phatform', 'Use option text as values') . ': ' . $element->get();
     $editTags['SAVE_OPTION_SET'] = dgettext('phatform', 'Save option set as') . ': ' . PHPWS_Form::formTextField('PHAT_SaveOptionSet', $setName, PHAT_DEFAULT_SIZE, PHAT_DEFAULT_MAXSIZE);
     $editTags['BACK_BUTTON'] = PHPWS_Form::formSubmit(dgettext('phatform', 'Back'), 'PHAT_OptionBack');
     $editTags['SAVE_BUTTON'] = PHPWS_Form::formSubmit(dgettext('phatform', 'Save ' . $properName));
     $elements[0] .= PHPWS_Template::processTemplate($editTags, 'phatform', 'element/optionList.tpl');
     return PHPWS_Form::makeForm('PHAT_Options', 'index.php', $elements, 'post', NULL, NULL);
 }
コード例 #4
0
ファイル: Report.php プロジェクト: HaldunA/phpwebsite
 /**
  *
  *
  *
  *
  */
 function listEntries()
 {
     if (isset($_REQUEST['PHAT_EntrySearch'])) {
         $this->_searchQuery = PHPWS_Text::parseInput($_REQUEST['PHAT_EntrySearch']);
         $this->_listFilter = $_REQUEST['PHAT_ListFilter'];
         $this->setEntries();
         $this->pageStart = 0;
         $this->pageSection = 1;
         $this->pageLimit = $_REQUEST['PDA_limit'];
     } elseif (isset($_REQUEST['PHAT_FullList'])) {
         $this->_searchQuery = NULL;
         $this->_listFilter = 1;
         $this->setEntries();
         $this->pageStart = 0;
         $this->pageSection = 1;
     } else {
         if (isset($_REQUEST['PDA_start'])) {
             $this->pageStart = $_REQUEST['PDA_start'];
         } else {
             $_REQUEST['PDA_start'] = $this->pageStart;
         }
         if (isset($_REQUEST['PDA_section'])) {
             $this->pageSection = $_REQUEST['PDA_section'];
         } else {
             $_REQUEST['PDA_section'] = $this->pageSection;
         }
         if (isset($_REQUEST['PDA_limit'])) {
             $this->pageLimit = $_REQUEST['PDA_limit'];
         } else {
             $_REQUEST['PDA_limit'] = $this->pageLimit;
         }
     }
     $listTags = array();
     $listTags['ID_LABEL'] = dgettext('phatform', 'ID');
     $listTags['USER_LABEL'] = dgettext('phatform', 'User');
     $listTags['UPDATED_LABEL'] = dgettext('phatform', 'Updated');
     $listTags['ACTION_LABEL'] = dgettext('phatform', 'Action');
     $highlight = ' class="bgcolor1"';
     if (sizeof($this->_entries) > 0) {
         $data = PHAT_Report::paginateDataArray($this->_entries, 'index.php?module=phatform&amp;PHAT_REPORT_OP=list', $this->pageLimit, TRUE, array('<b>[ ', ' ]</b>'), NULL, 10, TRUE);
     }
     $count = 1;
     if (isset($data) && is_array($data[0]) && sizeof($data[0]) > 0) {
         $listTags['LIST_ITEMS'] = NULL;
         foreach ($data[0] as $entry) {
             $highlight = null;
             $rowTags = array();
             $rowTags['HIGHLIGHT'] = $highlight;
             $rowTags['ID'] = $entry['id'];
             $rowTags['USER'] = $entry['user'];
             $rowTags['UPDATED'] = date(PHPWS_DATE_FORMAT . ' ' . PHPWS_TIME_FORMAT, $entry['updated']);
             $rowTags['VIEW'] = '<a href="index.php?module=phatform&amp;PHAT_REPORT_OP=view&amp;PHAT_ENTRY_ID=' . $entry['id'] . '">' . dgettext('phatform', 'View') . '</a>';
             if (!isset($this->archive)) {
                 $rowTags['EDIT'] = '<a href="index.php?module=phatform&amp;PHAT_REPORT_OP=edit&amp;PHAT_ENTRY_ID=' . $entry['id'] . '">' . dgettext('phatform', 'Edit') . '</a>';
                 $rowTags['DELETE'] = '<a href="index.php?module=phatform&amp;PHAT_REPORT_OP=confirmDelete&amp;PHAT_ENTRY_ID=' . $entry['id'] . '">' . dgettext('phatform', 'Delete') . '</a>';
             }
             if ($count % 2) {
                 $highlight = ' class="bgcolor1"';
             }
             $count++;
             $listTags['LIST_ITEMS'] .= PHPWS_Template::processTemplate($rowTags, 'phatform', 'report/row.tpl');
         }
         if (!isset($_REQUEST['lay_quiet'])) {
             if ($this->_totalEntries > $this->pageLimit) {
                 $listTags['NAVIGATION_LINKS'] = $data[1];
             }
             $listTags['SECTION_INFO'] = $data[2];
             $listTags['SECTION_INFO_LABEL'] = dgettext('phatform', 'Entries');
         }
     } else {
         $listTags['LIST_ITEMS'] = '<tr><td colspan="4" class="smalltext">' . dgettext('phatform', 'No entries were found matching your search query.') . '</td></tr>';
     }
     if (!isset($_REQUEST['lay_quiet'])) {
         $filterOptions = array(1 => dgettext('phatform', 'All'), 2 => dgettext('phatform', 'Incomplete'), 3 => dgettext('phatform', 'Complete'));
         $limitOptions = array(10 => 10, 20 => 20, 30 => 30, 40 => 40, 50 => 50);
         $elements[0] = PHPWS_Form::formHidden('module', 'phatform');
         $elements[0] .= PHPWS_Form::formHidden('PHAT_REPORT_OP', 'list');
         $elements[0] .= PHPWS_Form::formSelect('PHAT_ListFilter', $filterOptions, $this->_listFilter, FALSE, TRUE);
         $elements[0] .= PHPWS_Form::formSelect('PDA_limit', $limitOptions, $this->pageLimit, TRUE);
         if (!$_SESSION['PHAT_FormManager']->form->isAnonymous()) {
             $elements[0] .= PHPWS_Form::formTextField('PHAT_EntrySearch', $this->_searchQuery, 20, 255);
         }
         $elements[0] .= PHPWS_Form::formSubmit(dgettext('phatform', 'Search'));
         $listTags['SEARCH_FORM'] = PHPWS_Form::makeForm('PHAT_SearchEntries', 'index.php', $elements);
     }
     $GLOBALS['CNT_phatform']['title'] = $_SESSION['PHAT_FormManager']->form->getLabel();
     return PHPWS_Template::processTemplate($listTags, 'phatform', 'report/list.tpl');
 }
コード例 #5
0
ファイル: FormManager.php プロジェクト: HaldunA/phpwebsite
 function _editOptions()
 {
     if (Current_User::allow('phatform', 'edit_options')) {
         if (isset($_REQUEST['PHAT_OptionSetId']) && !is_numeric($_REQUEST['PHAT_OptionSetId']) || isset($_REQUEST['PHAT_OptionBack'])) {
             $_REQUEST['PHAT_MAN_OP'] = 'Options';
             $this->action();
             return;
         } else {
             $optionSetId = $_REQUEST['PHAT_OptionSetId'];
         }
         if (isset($_REQUEST['PHAT_SaveOptionSet'])) {
             if (is_array($_REQUEST['PHAT_ElementOptions']) && is_array($_REQUEST['PHAT_ElementValues'])) {
                 for ($i = 0; $i < sizeof($_REQUEST['PHAT_ElementOptions']); $i++) {
                     $_REQUEST['PHAT_ElementOptions'][$i] = PHPWS_Text::parseInput($_REQUEST['PHAT_ElementOptions'][$i]);
                     $_REQUEST['PHAT_ElementValues'][$i] = PHPWS_Text::parseInput($_REQUEST['PHAT_ElementValues'][$i]);
                 }
                 $options = addslashes(serialize($_REQUEST['PHAT_ElementOptions']));
                 $values = addslashes(serialize($_REQUEST['PHAT_ElementValues']));
                 $saveArray = array('optionSet' => $options, 'valueSet' => $values);
                 $db = new PHPWS_DB('mod_phatform_options');
                 $db->addWhere('id', $optionSetId);
                 $db->addValue($saveArray);
                 $db->update();
             }
         } else {
             if (isset($_REQUEST['PHAT_delete'])) {
                 $db = new PHPWS_DB('mod_phatform_options');
                 $db->addWhere('id', $optionSetId);
                 $db->delete();
                 $_REQUEST['PHAT_MAN_OP'] = 'Options';
                 $this->action();
                 return;
             }
         }
         $GLOBALS['CNT_phatform']['title'] = PHAT_TITLE;
         $sql = "SELECT * FROM mod_phatform_options WHERE id='{$optionSetId}'";
         $result = PHPWS_DB::getRow($sql);
         if ($result) {
             $elements = array();
             $elements[] = PHPWS_Form::formHidden('module', $this->_module);
             $elements[] = PHPWS_Form::formHidden('PHAT_MAN_OP', 'editOptions');
             $elements[] = PHPWS_Form::formHidden('PHAT_OptionSetId', $optionSetId);
             $options = unserialize(stripslashes($result['optionSet']));
             $values = unserialize(stripslashes($result['valueSet']));
             $editTags = array();
             $editTags['TITLE'] = dgettext('phatform', 'Edit option set') . "&#160;{$result['label']}";
             $editTags['NUMBER_LABEL'] = dgettext('phatform', 'Option');
             $editTags['INPUT_LABEL'] = dgettext('phatform', 'Text');
             $editTags['VALUE_LABEL'] = dgettext('phatform', 'Value');
             $editTags['OPTIONS'] = '';
             $rowClass = NULL;
             for ($i = 0; $i < sizeof($options); $i++) {
                 $optionRow['OPTION_NUMBER'] = $i + 1;
                 $optionRow['OPTION_INPUT'] = PHPWS_Form::formTextField("PHAT_ElementOptions[{$i}]", $options[$i], PHAT_DEFAULT_SIZE, PHAT_DEFAULT_MAXSIZE);
                 $optionRow['VALUE_INPUT'] = PHPWS_Form::formTextField("PHAT_ElementValues[{$i}]", $values[$i], PHAT_DEFAULT_SIZE, PHAT_DEFAULT_MAXSIZE);
                 $optionRow['ROW_CLASS'] = $rowClass;
                 if ($i % 2) {
                     $rowClass = ' class="bgcolor1"';
                 } else {
                     $rowClass = null;
                 }
                 $editTags['OPTIONS'] .= PHPWS_Template::processTemplate($optionRow, 'phatform', 'options/option.tpl');
             }
         }
         $editTags['BACK_BUTTON'] = PHPWS_Form::formSubmit(dgettext('phatform', 'Back'), 'PHAT_OptionBack');
         $editTags['SAVE_BUTTON'] = PHPWS_Form::formSubmit(dgettext('phatform', 'Save'), 'PHAT_SaveOptionSet');
         $elements[] = PHPWS_Template::processTemplate($editTags, 'phatform', 'options/optionList.tpl');
         return PHPWS_Form::makeForm('PHAT_Options_edit', 'index.php', $elements);
     } else {
         $this->_list();
     }
 }