예제 #1
0
 public function show()
 {
     PHPWS_Core::initCoreClass('Form.php');
     $form = new PHPWS_Form();
     $form->addDropBox('rlc', HMS_Learning_Community::getRlcList());
     $form->setClass('rlc', 'form-control');
     $form->addHidden('module', 'hms');
     $form->addHidden('action', 'ShowSearchByRlc');
     $form->addSubmit('submit', _('Search'));
     $form->setClass('submit', 'btn btn-primary pull-right');
     $tags = $form->getTemplate();
     $tags['TITLE'] = "RLC Search";
     Layout::addPageTitle("RLC Search");
     $final = PHPWS_Template::processTemplate($tags, 'hms', 'admin/search_by_rlc.tpl');
     return $final;
 }
예제 #2
0
 public static function editChannel(RSS_Channel $channel)
 {
     $form = new PHPWS_Form();
     $form->addHidden('module', 'rss');
     $form->addHidden('command', 'post_channel');
     $form->addSubmit(dgettext('rss', 'Save Channel'));
     if ($channel->id) {
         $form->addHidden('channel_id', $channel->id);
     }
     $form->addText('title', $channel->title);
     $form->setLabel('title', dgettext('rss', 'Title'));
     $form->addTextArea('description', $channel->description);
     $form->setLabel('description', dgettext('rss', 'Description'));
     $formtpl = $form->getTemplate();
     $tpl['CONTENT'] = PHPWS_Template::processTemplate($formtpl, 'rss', 'channel_form.tpl');
     $tpl['TITLE'] = dgettext('rss', 'Edit channel');
     return $tpl;
 }
예제 #3
0
파일: Form.php 프로젝트: HaldunA/phpwebsite
 function emailBodyHtml($content)
 {
     $entryTags = array();
     $entryTags['ENTRY_DATA'] = array();
     /* Step through the entries values and feed them through the entryRow template */
     $rowClass = NULL;
     $tog = 1;
     foreach ($content as $key => $value) {
         $rowTags = array();
         if ($key == 'position') {
             continue;
         } elseif ($key == 'updated') {
             $value = date(PHPWS_DATE_FORMAT . ' ' . PHPWS_TIME_FORMAT, $value);
         }
         /* Toggle the row colors for better visability */
         if ($tog % 2) {
             $rowClass = PHAT_SECTION_HEX;
         } else {
             $rowClass = null;
         }
         $tog++;
         if (isset($rowClass)) {
             $rowTags['ROW_CLASS'] = " bgcolor=\"{$rowClass}\"";
         }
         $rowTags['ENTRY_LABEL'] = $key;
         if (preg_match('/a:.:{/', $value)) {
             $rowTags['ENTRY_VALUE'] = implode(', ', unserialize(stripslashes($value)));
         } else {
             $rowTags['ENTRY_VALUE'] = PHPWS_Text::parseOutput($value, ENCODE_PARSED_TEXT, false, true);
         }
         $entryTags['ENTRY_DATA'][] = PHPWS_Template::processTemplate($rowTags, 'phatform', 'report/entryRow.tpl');
     }
     $entryTags['ENTRY_DATA'] = implode('', $entryTags['ENTRY_DATA']);
     $message = PHPWS_Template::processTemplate($entryTags, 'phatform', 'report/entry.tpl');
     return $message;
 }
예제 #4
0
 /**
  * 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);
 }
 function testEditors($text)
 {
     if ($_SESSION["OBJ_user"]->allow_access("xwysiwyg", "settings")) {
         $this->content .= "<a href=\"" . $this->linkRef . "&amp;action=admin" . "\">" . $_SESSION['translate']->it("Back to administration") . "</a>";
         $tags = array();
         $tags["TESTAREA"] = PHPWS_WizardBag::js_insert("wysiwyg", "xw_test_form", "xw_testarea") . PHPWS_Form::formTextArea("xw_testarea", $text, 10, 70);
         $tags["SUBMIT_BUTTON"] = PHPWS_Form::formSubmit($_SESSION["translate"]->it("Save"));
         $elements[0] = PHPWS_Form::formHidden("module", "xwysiwyg");
         $elements[0] .= PHPWS_Form::formHidden("action", "testEditor");
         $elements[0] .= PHPWS_Template::processTemplate($tags, "xwysiwyg", "test_editor.tpl");
         $this->content .= PHPWS_Form::makeForm("xw_test_form", "index.php", $elements, "post", FALSE, TRUE);
         $this->content .= "<hr /><br />" . PHPWS_Text::parseOutput($text);
     } else {
         $this->content .= $_SESSION['translate']->it("Access was denied due to lack of proper permissions.");
     }
     // End of ADMINISTRATOR condition
 }
예제 #6
0
 /**
  * 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);
 }
예제 #7
0
 /**
  *
  *
  *
  *
  */
 function confirmDelete()
 {
     $hiddens['module'] = 'phatform';
     $hiddens['PHAT_REPORT_OP'] = 'delete';
     $hiddens['PHAT_ENTRY_ID'] = $_REQUEST['PHAT_ENTRY_ID'];
     foreach ($hiddens as $key => $value) {
         $eles[] = PHPWS_Form::formHidden($key, $value);
     }
     $elements[0] = implode("\n", $eles);
     $confirmTags['MESSAGE'] = dgettext('phatform', 'Are you sure you want to delete this entry?');
     $confirmTags['NO_BUTTON'] = PHPWS_Form::formSubmit(dgettext('phatform', 'No'), 'PHAT_DeleteNo');
     $confirmTags['YES_BUTTON'] = PHPWS_Form::formSubmit(dgettext('phatform', 'Yes'), 'PHAT_DeleteYes');
     $elements[0] .= PHPWS_Template::processTemplate($confirmTags, 'phatform', 'report/deleteConfirm.tpl');
     $content = PHPWS_Form::makeForm('PHAT_EntryDeleteConfirm', 'index.php', $elements);
     $content .= '<br /><hr /><br />';
     $content .= $this->view(FALSE);
     return $content;
 }
예제 #8
0
 /**
  * Edit a new or existing PHAT_Dropbox element
  *
  * The edit function provides the HTML form to edit a new or existing
  * PHAT_Dropbox element.
  * g
  * return string The HTML form to edit a PHAT_Dropbox
  */
 function edit()
 {
     $numOptions = sizeof($this->getOptionText());
     if (!$numOptions || $this->getOptionSet()) {
         $numOptions = '';
     }
     $form = new PHPWS_Form();
     $form->addHidden('module', 'phatform');
     $form->addHidden('PHAT_EL_OP', 'SaveElement');
     if (!$this->getLabel()) {
         $num = $_SESSION['PHAT_FormManager']->form->numElements();
         $this->setLabel('Element' . ($num + 1));
     }
     $form->addTextArea('PHAT_ElementBlurb', $this->getBlurb());
     $form->setRows('PHAT_ElementBlurb', PHAT_DEFAULT_ROWS);
     $form->setCols('PHAT_ElementBlurb', PHAT_DEFAULT_COLS);
     $form->setLabel('PHAT_ElementBlurb', dgettext('phatform', 'Associated Text'));
     $form->addText('PHAT_ElementName', $this->getLabel());
     $form->setSize('PHAT_ElementName', PHAT_DEFAULT_SIZE, PHAT_DEFAULT_MAXSIZE);
     $form->setLabel('PHAT_ElementName', dgettext('phatform', 'Name'));
     $form->addText('PHAT_ElementNumOptions', $numOptions);
     $form->setSize('PHAT_ElementNumOptions', 5, 3);
     $form->setLabel('PHAT_ElementNumOptions', dgettext('phatform', 'Number of Options'));
     $options = $this->getOptionSets();
     if (is_array($options)) {
         $editTags['OPTION_SET_LABEL'] = dgettext('phatform', 'Predefined Option Set');
         $form->addSelect('PHAT_OptionSet', $options);
         $form->setMatch('PHAT_OptionSet', $this->getOptionSet());
     }
     $form->addCheck('PHAT_ElementRequired', 1);
     $form->setMatch('PHAT_ElementRequired', $this->isRequired());
     $form->setLabel('PHAT_ElementRequired', dgettext('phatform', 'Required'));
     $form->addSubmit('PHAT_ElementBack', dgettext('phatform', 'Back'));
     $form->addSubmit('NEXT_BUTTON', dgettext('phatform', 'Next'));
     $template = $form->getTemplate();
     return PHPWS_Template::processTemplate($template, 'phatform', 'dropbox/edit.tpl');
 }
예제 #9
0
 /**
  * Remove this PHAT_Element
  *
  * @accesss public
  */
 function remove()
 {
     if (isset($_REQUEST['PHAT_Yes'])) {
         $result = $this->kill();
         if (PHPWS_Error::isError($result)) {
             return PHPWS_Error::get(PHATFORM_CANNOT_DELETE_ELEMENT, 'phatform', 'PHAT_Element::remove()');
         } else {
             $result = $_SESSION['PHAT_FormManager']->form->popElement();
             if (PHPWS_Error::isError($result)) {
                 return $result;
             } else {
                 return dgettext('phatform', 'The element was successfully removed.');
             }
         }
     } else {
         if (isset($_REQUEST['PHAT_No'])) {
             return dgettext('phatform', 'No element was removed.');
         } else {
             $className = get_class($this);
             $properName = ucfirst(str_ireplace('phat_', '', $className));
             $tags['MESSAGE'] = sprintf(dgettext('phatform', 'Are you sure you want to remove this %s element?'), '<b><i>' . $properName . '</i></b>');
             $tags['YES_BUTTON'] = PHPWS_Form::formSubmit('Yes', 'PHAT_Yes');
             $tags['NO_BUTTON'] = PHPWS_Form::formSubmit('No', 'PHAT_No');
             $tags['ELEMENT_PREVIEW'] = $this->view();
             $elements[0] = PHPWS_Form::formHidden('module', 'phatform');
             $elements[0] .= PHPWS_Form::formHidden('PHAT_EL_OP', 'RemoveElement');
             $elements[0] .= PHPWS_Template::processTemplate($tags, 'phatform', 'form/deleteConfirm.tpl');
             $content = PHPWS_Form::makeForm('PHAT_Confirm', 'index.php', $elements);
         }
     }
     return $content;
 }
예제 #10
0
파일: WikiImage.php 프로젝트: Jopperi/wiki
 /**
  * Delete
  *
  * @author Greg Meiste <*****@*****.**>
  */
 function delete()
 {
     if (!Current_User::authorized('wiki', 'upload_images') && !(PHPWS_Settings::get('wiki', 'allow_image_upload') && Current_User::isLogged())) {
         Current_User::disallow(dgettext('wiki', 'User attempted access to image delete.'));
         return;
     }
     if (isset($_REQUEST['yes'])) {
         @unlink(PHPWS_HOME_DIR . 'images/wiki/' . $this->getFilename());
         $db = new PHPWS_DB('wiki_images');
         $db->addWhere('id', $this->getId());
         if (PHPWS_Error::logIfError($db->delete())) {
             return dgettext('wiki', 'Error deleting image.');
         }
         return dgettext('wiki', 'Image deleted!');
     } else {
         if (isset($_REQUEST['no'])) {
             return dgettext('wiki', 'Image was not deleted!');
         }
     }
     $tags = array();
     $tags['MESSAGE'] = dgettext('wiki', 'Are you sure you want to delete this image?');
     $tags['YES'] = PHPWS_Text::secureLink(dgettext('wiki', 'Yes'), 'wiki', array('op' => 'doimagedelete', 'yes' => 1, 'id' => $this->getId()));
     $tags['NO'] = PHPWS_Text::secureLink(dgettext('wiki', 'No'), 'wiki', array('op' => 'doimagedelete', 'no' => 1, 'id' => $this->getId()));
     $tags['WIKIPAGE'] = '<img src="images/wiki/' . $this->getFilename() . '" alt="" />';
     return PHPWS_Template::processTemplate($tags, 'wiki', 'confirm.tpl');
 }
예제 #11
0
 function viewArchives()
 {
     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['FORMNAME_LABEL'] = dgettext('phatform', 'Form Name');
     $listTags['FILENAME_LABEL'] = dgettext('phatform', 'Filename');
     $listTags['DATE_LABEL'] = dgettext('phatform', 'Date Created');
     $listTags['ACTION_LABEL'] = dgettext('phatform', 'Action');
     $highlight = ' class="bgcolor1"';
     $files = array();
     $total_files = 0;
     $dir = PHPWS_HOME_DIR . 'files/phatform/archive/';
     if (is_dir($dir)) {
         if ($dh = opendir($dir)) {
             while (($file = readdir($dh)) !== false) {
                 if (preg_match('/phat$/', $file)) {
                     $files[$total_files]['filename'] = $file;
                     $timeStamp = preg_split('/\\./', $file);
                     $files[$total_files]['date'] = date('m / d / y', $timeStamp[1]);
                     $total_files++;
                 }
             }
             closedir($dh);
         }
     }
     if (sizeof($files) > 0) {
         $data = paginateDataArray($files, 'index.php?module=phatform&amp;PHAT_MAN_OP=viewArchives', $this->pageLimit, TRUE, array('<b>[ ', ' ]</b>'), NULL, 10, TRUE);
     }
     if (isset($data) && is_array($data[0]) && sizeof($data[0]) > 0) {
         $listTags['LIST_ITEMS'] = NULL;
         $tog = 1;
         foreach ($data[0] as $entry) {
             $rowTags = array();
             $formNum = array();
             ereg('^([0-9]+)', $entry['filename'], $formNum);
             if ($formname = $this->getArchiveFormName($entry['filename'], $formNum[0])) {
                 $rowTags['FORMNAME'] = $formname;
             } else {
                 $rowTags['FORMNAME'] = dgettext('phatform', 'Unknown');
             }
             $rowTags['HIGHLIGHT'] = $highlight;
             $rowTags['FILENAME'] = $entry['filename'];
             $rowTags['DATE'] = $entry['date'];
             $rowTags['DOWNLOAD'] = '<a href="index.php?module=phatform&amp;ARCHIVE_OP=downloadArchive&amp;ARCHIVE_filename=' . $entry['filename'] . '">' . dgettext('phatform', 'Download') . '</a>';
             $rowTags['VIEW'] = '<a href="index.php?module=phatform&amp;ARCHIVE_OP=viewArchive&amp;ARCHIVE_filename=' . $entry['filename'] . '">' . dgettext('phatform', 'View') . '</a>';
             $db = new PHPWS_DB('mod_phatform_forms');
             $db->addWhere('archiveFileName', '%' . $entry['filename'] . '%', 'LIKE');
             $result = $db->select();
             if ($result) {
                 $rowTags['CLEANUP'] = '<a href="index.php?module=phatform&amp;ARCHIVE_OP=cleanUpArchive&amp;ARCHIVE_filename=' . $entry['filename'] . '">' . dgettext('phatform', 'Clean-Up') . '</a>';
             }
             $rowTags['DELETE'] = '<a href="index.php?module=phatform&amp;ARCHIVE_OP=deleteArchive&amp;ARCHIVE_filename=' . $entry['filename'] . '">' . dgettext('phatform', 'Delete') . '</a>';
             if ($tog % 2) {
                 $highlight = ' class="bgcolor1"';
             } else {
                 $highlight = null;
             }
             $tog++;
             $listTags['LIST_ITEMS'] .= PHPWS_Template::processTemplate($rowTags, 'phatform', 'report/archive/row.tpl');
         }
         if (count($files) > $this->pageLimit) {
             $listTags['NAVIGATION_LINKS'] = $data[1];
         }
         $listTags['SECTION_INFO'] = $data[2];
         $listTags['SECTION_INFO_LABEL'] = dgettext('phatform', 'Entries');
         $listTags['LINK_BACK'] = '<a href="index.php?module=phatform&amp;PHAT_FORM_OP=report">' . dgettext('phatform', 'Report View') . '</a>';
     } else {
         $listTags['LIST_ITEMS'] = '<tr><td colspan="4" class="smalltext">' . dgettext('phatform', 'No entries were found matching your search query.') . '</td></tr>';
     }
     $GLOBALS['CNT_phatform']['title'] = dgettext('phatform', 'Existing Archives');
     return PHPWS_Template::processTemplate($listTags, 'phatform', 'report/archive/list.tpl');
 }
예제 #12
0
 /**
  * Returns a list of items based on the table currently set in this manager
  *
  * @param  string  $listName The name of the list wanting to be returned
  * @param  string  $title    The title of the list
  * @param  boolean $makeForm Flag whether or not to make a form out of the list
  * @access public
  */
 function getList($listName, $title = NULL, $makeForm = TRUE, $overRideOp = NULL)
 {
     $this->listName = $listName;
     if (!isset($this->_table) && !isset($this->_request)) {
         $message = _('Manager was not fully initialized to get a list.');
         $error = new PHPWS_Error('core', 'PHPWS_Manager::getList()', $message, 'exit', 1);
         $error->message(NULL);
     }
     $theme = Layout::getCurrentTheme();
     $themeModuleRowTpl = "themes/{$theme}/templates/" . $this->_module . '/' . $this->_templates[$this->listName] . '/row.tpl';
     $moduleRowTpl = PHPWS_SOURCE_DIR . 'mod/' . $this->_module . '/templates/' . $this->_templates[$this->listName] . '/row.tpl';
     $themeCoreRowTpl = 'themes/' . $theme . '/templates/core/defaultRow.tpl';
     $coreRowTpl = PHPWS_SOURCE_DIR . 'templates/defaultRow.tpl';
     $themeModuleListTpl = "themes/{$theme}/templates/" . $this->_module . '/' . $this->_templates[$this->listName] . '/list.tpl';
     $moduleListTpl = PHPWS_SOURCE_DIR . 'mod/' . $this->_module . '/templates/' . $this->_templates[$this->listName] . '/list.tpl';
     $themeCoreListTpl = "themes/{$theme}/templates/core/defaultList.tpl";
     $coreListTpl = PHPWS_SOURCE_DIR . 'templates/defaultList.tpl';
     if (file_exists($themeModuleRowTpl)) {
         $rowTpl = $themeModuleRowTpl;
     } else {
         if (file_exists($moduleRowTpl)) {
             $rowTpl = $moduleRowTpl;
         } else {
             if (file_exists($themeCoreRowTpl)) {
                 $rowTpl = $themeCoreRowTpl;
             } else {
                 $rowTpl = $coreRowTpl;
             }
         }
     }
     if (file_exists($themeModuleListTpl)) {
         $listTpl = $themeModuleListTpl;
     } else {
         if (file_exists($moduleListTpl)) {
             $listTpl = $moduleListTpl;
         } else {
             if (file_exists($themeCoreListTpl)) {
                 $listTpl = $themeCoreListTpl;
             } else {
                 $listTpl = $coreListTpl;
             }
         }
     }
     if (isset($_REQUEST['PHPWS_MAN_LIST']) && $this->listName == $_REQUEST['PHPWS_MAN_LIST']) {
         $this->catchOrder();
     }
     if (isset($overRideOp)) {
         $op = $overRideOp;
     } else {
         if (isset($this->_listPaging[$this->listName]['op'])) {
             $op = $this->_listPaging[$this->listName]['op'];
         }
     }
     if (isset($this->_listPaging[$this->listName]) && is_array($this->_listPaging[$this->listName])) {
         if (!isset($this->_pagers[$this->listName])) {
             $this->_pagers[$this->listName] = new PHPWS_Pager();
             $this->_pagers[$this->listName]->setLinkBack('./index.php?module=' . $this->_module . '&amp;' . $op . '&amp;PHPWS_MAN_PAGE=' . $this->listName);
             $this->_pagers[$this->listName]->setLimits($this->_listPaging[$this->listName]['limits']);
             $this->_pagers[$this->listName]->makeArray(TRUE);
             if ($this->_anchor) {
                 $this->_pagers[$this->listName]->setAnchor('#' . $this->listName);
             }
             $this->_pagers[$this->listName]->limit = $this->_listPaging[$this->listName]['limit'];
         }
         $this->_pagers[$this->listName]->setData($this->_getIds());
         if (isset($_REQUEST['PHPWS_MAN_PAGE']) && $this->listName == $_REQUEST['PHPWS_MAN_PAGE']) {
             $this->_pagers[$this->listName]->pageData();
         } else {
             $this->_pagers[$this->listName]->pageData(FALSE);
         }
         if (isset($this->_class)) {
             $items = $this->getItems($this->_pagers[$this->listName]->getData(), FALSE, TRUE);
         } else {
             $items = $this->getItems($this->_pagers[$this->listName]->getData());
         }
         $totalItems = count($items);
         //            $totalItems = $this->_pagers[$this->listName]->getNumRows();
     } else {
         if (isset($this->_class)) {
             $items = $this->getItems(NULL, FALSE, TRUE);
         } else {
             $items = $this->getItems();
         }
         $totalItems = sizeof($items);
     }
     /* Begin building main list tags array for processTemplate() */
     $listTags = array();
     if (isset($this->_listExtraLabels) && is_array($this->_listExtraLabels)) {
         $listTags = $this->_listExtraLabels;
     }
     $listTags['TITLE'] = $title;
     $listTags['ANCHOR'] = '<a id="' . $this->listName . '" name="' . $this->listName . '"></a>';
     if ($makeForm) {
         $listTags['SELECT_LABEL'] = '&#160;';
     }
     $columns = 0;
     foreach ($this->_listColumns[$this->listName] as $listColumn => $listLabel) {
         $column = strtoupper($listColumn);
         $key0 = $column . '_LABEL';
         $key1 = $column . '_ORDER_LINK';
         $listTags[$key0] = NULL;
         $listTags[$key1] = NULL;
         $listTags[$key0] = $listLabel;
         if (isset($overRideOp)) {
             $request = $overRideOp;
         } else {
             if (isset($this->_listPaging[$this->listName]['op'])) {
                 $request = $this->_listPaging[$this->listName]['op'];
             } else {
                 $request = $this->_request . '=list';
             }
         }
         if ($totalItems > 0) {
             $anchor = '';
             if ($this->_anchor) {
                 $anchor = '#' . $this->listName;
             }
             if (isset($this->_overrideOrder[$this->listName][$listColumn][0])) {
                 $overRide = $this->_overrideOrder[$this->listName][$listColumn][0];
             } else {
                 $overRide = 'default';
             }
             if (isset($this->_listPaging[$this->listName])) {
                 switch ($overRide) {
                     case 0:
                         $listTags[$key1] .= '<a href="./index.php?module=' . $this->_module . '&amp;' . $request . '&amp;PHPWS_MAN_LIST=' . $this->listName . '&amp;PHPWS_MAN_COLUMN=' . $listColumn . '&amp;PHPWS_MAN_ORDER=1&amp;' . 'PHPWS_MAN_PAGE=' . $this->listName . '&amp;' . 'PAGER_limit=' . $this->_pagers[$this->listName]->limit . '&amp;' . 'PAGER_start=' . $this->_pagers[$this->listName]->start . '&amp;' . 'PAGER_section=' . $this->_pagers[$this->listName]->section . $anchor . '">';
                         $listTags[$key1] .= Icon::show('sort') . '</a>';
                         break;
                     case 1:
                         $listTags[$key1] .= '<a href="./index.php?module=' . $this->_module . '&amp;' . $request . '&amp;PHPWS_MAN_LIST=' . $this->listName . '&amp;PHPWS_MAN_COLUMN=' . $listColumn . '&amp;PHPWS_MAN_ORDER=2&amp;' . 'PHPWS_MAN_PAGE=' . $this->listName . '&amp;' . 'PAGER_limit=' . $this->_pagers[$this->listName]->limit . '&amp;' . 'PAGER_start=' . $this->_pagers[$this->listName]->start . '&amp;' . 'PAGER_section=' . $this->_pagers[$this->listName]->section . $anchor . '">';
                         $listTags[$key1] .= Icon::show('sort-up') . '</a>';
                         break;
                     case 2:
                         $listTags[$key1] .= '<a href="./index.php?module=' . $this->_module . '&amp;' . $request . '&amp;PHPWS_MAN_LIST=' . $this->listName . '&amp;PHPWS_MAN_COLUMN=' . $listColumn . '&amp;PHPWS_MAN_ORDER=0&amp;' . 'PHPWS_MAN_PAGE=' . $this->listName . '&amp;' . 'PAGER_limit=' . $this->_pagers[$this->listName]->limit . '&amp;' . 'PAGER_start=' . $this->_pagers[$this->listName]->start . '&amp;' . 'PAGER_section=' . $this->_pagers[$this->listName]->section . $anchor . '">';
                         $listTags[$key1] .= Icon::show('sort-down') . '</a>';
                         break;
                     default:
                         $listTags[$key1] .= '<a href="./index.php?module=' . $this->_module . '&amp;' . $request . '&amp;PHPWS_MAN_LIST=' . $this->listName . '&amp;PHPWS_MAN_COLUMN=' . $listColumn . '&amp;PHPWS_MAN_ORDER=1&amp;' . 'PHPWS_MAN_PAGE=' . $this->listName . '&amp;' . 'PAGER_limit=' . $this->_pagers[$this->listName]->limit . '&amp;' . 'PAGER_start=' . $this->_pagers[$this->listName]->start . '&amp;' . 'PAGER_section=' . $this->_pagers[$this->listName]->section . $anchor . '">';
                         $listTags[$key1] .= Icon::show('sort') . '</a>';
                 }
             }
         }
         $columns++;
     }
     /* Build each item's row */
     $listTags['LIST_ITEMS'] = NULL;
     if ($totalItems > 0) {
         $tog = 1;
         foreach ($items as $item) {
             $object = NULL;
             if (isset($this->_class)) {
                 $object = new $this->_class($item);
                 $className = get_class($object);
                 $classMethods = get_class_methods($className);
                 @array_walk($classMethods, 'manager_lower_methods');
                 $objectVars = get_object_vars($object);
                 if (is_array($objectVars)) {
                     $item = $objectVars;
                     foreach ($item as $key => $value) {
                         if ($key[0] == '_') {
                             $key = substr($key, 1, strlen($key));
                             $item[$key] = $value;
                         }
                     }
                 }
             }
             if ($tog % 2) {
                 $row_class = ' class="bgcolor1"';
             } else {
                 $row_class = null;
             }
             $tog++;
             /* Build row tags array for processTemplate() */
             $rowTags = array();
             if (isset($this->_listExtraLabels) && is_array($this->_listExtraLabels)) {
                 $rowTags = $this->_listExtraLabels;
             }
             $rowTags['ROW_CLASS'] = $row_class;
             if ($makeForm) {
                 $ele = new Form_CheckBox('PHPWS_MAN_ITEMS[]', $item['id']);
                 $rowTags['SELECT'] = $ele->get();
             }
             foreach ($this->_listColumns[$this->listName] as $listColumn => $listLabel) {
                 $column = strtoupper($listColumn);
                 if ($listColumn == 'created') {
                     /* Set created date using phpwebsite's default date and time formats */
                     $rowTags['CREATED'] = date(PHPWS_DATE_FORMAT . ' ' . PHPWS_TIME_FORMAT, $item['created']);
                 } else {
                     if ($listColumn == 'updated') {
                         /* Set updated date using phpwebsite's default date and time formats */
                         $rowTags['UPDATED'] = date(PHPWS_DATE_FORMAT . ' ' . PHPWS_TIME_FORMAT, $item['updated']);
                     } else {
                         if ($listColumn == 'hidden') {
                             /* Setting message depending if this item is hidden or not */
                             if (isset($this->_listValues['hidden'])) {
                                 $rowTags['HIDDEN'] = $this->_listValues['hidden'][$item['hidden']];
                             } else {
                                 if ($item['hidden'] == 1) {
                                     $rowTags['HIDDEN'] = _('Hidden');
                                 } else {
                                     $rowTags['HIDDEN'] = _('Visible');
                                 }
                             }
                         } else {
                             if ($listColumn == 'approved') {
                                 /* Setting message depending if this item is approved or not */
                                 if (isset($this->_listValues['hidden'])) {
                                     $rowTags['APPROVED'] = $this->_listValues['approved'][$item['approved']];
                                 } else {
                                     if ($item['approved'] == 1) {
                                         $rowTags['APPROVED'] = _('Approved');
                                     } else {
                                         $rowTags['APPROVED'] = _('Unapproved');
                                     }
                                 }
                             } else {
                                 if ($listColumn == 'groups') {
                                     $groups = unserialize($item['groups']);
                                     if (is_array($groups) && sizeof($groups) > 0) {
                                         /* Set flag to check whether to add a comma or not */
                                         $flag = FALSE;
                                         /* Create a string of group names the current item belongs to */
                                         foreach ($groups as $group) {
                                             if ($flag) {
                                                 $rowTags['GROUPS'] .= ', ';
                                             }
                                             $rowTags['GROUPS'] .= $group;
                                             $flag = TRUE;
                                         }
                                     } else {
                                         $rowTags['GROUPS'] = _('All');
                                     }
                                 } else {
                                     $method = 'get' . $listColumn;
                                     if (is_object($object) && in_array($method, $classMethods)) {
                                         $rowTags[$column] = $object->{$method}();
                                     } else {
                                         $rowTags[$column] = $item[$listColumn];
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             /* Process this item and concatenate onto the current list of items */
             $listTags['LIST_ITEMS'] .= PHPWS_Template::processTemplate($rowTags, 'core', $rowTpl, FALSE);
         }
         if (isset($this->_listPaging[$this->listName]) && is_array($this->_listPaging[$this->listName]) && sizeof($this->_listPaging[$this->listName]) > 0) {
             $listTags['NAV_BACKWARD'] = $this->_pagers[$this->listName]->getBackLink($this->_listPaging[$this->listName]['back']);
             $listTags['NAV_FORWARD'] = $this->_pagers[$this->listName]->getForwardLink($this->_listPaging[$this->listName]['forward']);
             if (isset($this->_listPaging[$this->listName]['section'])) {
                 $listTags['NAV_SECTIONS'] = $this->_pagers[$this->listName]->getSectionLinks();
             }
             $listTags['NAV_LIMITS'] = $this->_pagers[$this->listName]->getLimitLinks();
             $listTags['NAV_INFO'] = $this->_pagers[$this->listName]->getSectionInfo();
         }
         $actions = array();
         if (isset($this->_listActions[$this->listName]) && is_array($this->_listActions[$this->listName])) {
             foreach ($this->_listActions[$this->listName] as $actionString => $actionLabel) {
                 if (isset($this->_listPermissions[$this->listName][$actionString])) {
                     $permission = $this->_listPermissions[$this->listName][$actionString];
                 }
                 if (isset($permission)) {
                     if (Current_User::allow($this->_module, $permission)) {
                         $actions[$actionString] = $actionLabel;
                     }
                 } else {
                     $actions[$actionString] = $actionLabel;
                 }
             }
         }
         if ($makeForm) {
             /* Create action select and Go button */
             $ele = new Form_Select($this->_request, $actions);
             $listTags['ACTION_SELECT'] = $ele->get();
             $listTags['ACTION_BUTTON'] = sprintf('<input type="submit" value="%s" />', _('Go'));
             $listTags['TOGGLE_ALL'] = javascript('check_all', array('FORM_NAME' => 'PHPWS_MAN_LIST_' . $this->listName));
             /* Add hidden variable to designate the current module */
             $ele = new Form_Hidden('module', $this->_module);
             $elements[0] = $ele->get();
             $elements[0] .= PHPWS_Template::processTemplate($listTags, 'core', $listTpl, FALSE);
             /* Create final form and dump it into a content variable to be returned */
             $content = sprintf('<form name="%s" action="index.php" method="post">%s</form>', 'PHPWS_MAN_LIST_' . $this->listName, implode("\n", $elements));
         } else {
             $content = PHPWS_Template::processTemplate($listTags, 'core', $listTpl, FALSE);
         }
     } else {
         $listTags['LIST_ITEMS'] = '<tr><td colspan="' . $columns . '">' . _('No items for the current list.') . '</td></tr>';
         $content = PHPWS_Template::processTemplate($listTags, 'core', $listTpl, FALSE);
     }
     /* reinitialize sort and order before next list */
     $this->setSort(NULL);
     $this->setOrder(NULL);
     $this->_class = NULL;
     return $content;
 }
예제 #13
0
 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();
     }
 }