本文整理汇总了PHP中HTML_QuickForm::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP HTML_QuickForm::validate方法的具体用法?PHP HTML_QuickForm::validate怎么用?PHP HTML_QuickForm::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTML_QuickForm
的用法示例。
在下文中一共展示了HTML_QuickForm::validate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
function handle(&$params)
{
if (!@$_REQUEST['email']) {
return PEAR::raiseError("No email address specified");
}
import('HTML/QuickForm.php');
$form = new HTML_QuickForm('opt_out_form', 'post');
$form->addElement('hidden', 'email', $_REQUEST['email']);
$form->addElement('hidden', '-action', 'email_opt_out');
$form->addElement('submit', 'submit', 'Cancel Subscription');
if ($form->validate()) {
$res = mysql_query("replace into dataface__email_blacklist (email) values ('" . addslashes($_REQUEST['email']) . "')", df_db());
if (!$res) {
trigger_error(mysql_error(df_db()), E_USER_ERROR);
}
header('Location: ' . DATAFACE_SITE_HREF . '?--msg=' . urlencode('You have successfully opted out of our mail list. You will no longer receive emails from us.'));
exit;
}
ob_start();
$form->display();
$html = ob_get_contents();
ob_end_clean();
$context = array();
$context['form'] = $html;
df_register_skin('email', DATAFACE_PATH . '/modules/Email/templates');
df_display($context, 'email/opt_out_form.html');
}
示例2: body
public function body()
{
ob_start();
//create default module form
print '<div class="title">Select modules to disable</div>';
print 'Selected modules will be marked as not installed but uninstall methods will not be called. Any database tables and other modifications made by modules\' install methods will not be reverted.<br><br>';
print 'To uninstall module please use Modules Administration in Application.';
print '<hr/><br/>';
$form = new HTML_QuickForm('modulesform', 'post', $_SERVER['PHP_SELF'] . '?' . http_build_query($_GET), '', null, true);
$states = array(ModuleManager::MODULE_ENABLED => 'Active', ModuleManager::MODULE_DISABLED => 'Inactive');
$modules = DB::GetAssoc('SELECT * FROM modules ORDER BY state, name');
foreach ($modules as $m) {
$name = $m['name'];
$state = isset($m['state']) ? $m['state'] : ModuleManager::MODULE_ENABLED;
if ($state == ModuleManager::MODULE_NOT_FOUND) {
$state = ModuleManager::MODULE_DISABLED;
}
$form->addElement('select', $name, $name, $states);
$form->setDefaults(array($name => $state));
}
$form->addElement('button', 'submit_button', 'Save', array('class' => 'button', 'onclick' => 'if(confirm("Are you sure?")) document.modulesform.submit();'));
//validation or display
if ($form->validate()) {
//uninstall
$vals = $form->exportValues();
foreach ($vals as $k => $v) {
if (isset($modules[$k]['state']) && $modules[$k]['state'] != $v) {
ModuleManager::set_module_state($k, $v);
}
}
}
$form->display();
return ob_get_clean();
}
示例3: __construct
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, ' ', false);
if ($form->validate()) {
$this->processForm();
} else {
$this->renderForm();
}
}
示例4: drawLogin
/**
* function_description
*
* @author John.meng
* @since version - Jan 5, 2006
* @param datatype paramname description
* @return datatype description
*/
function drawLogin()
{
global $__Lang__, $UrlParameter, $SiteDB, $AddIPObj, $FlushPHPObj, $form, $smarty;
include_once PEAR_DIR . 'HTML/QuickForm.php';
$form = new HTML_QuickForm('firstForm');
$replace_str = "../";
$html_code = str_replace(ROOT_DIR, $replace_str, THEMES_DIR);
echo "<link href='" . $html_code . "style.css' rel='stylesheet' type='text/css'>";
$renderer =& $form->defaultRenderer();
$renderer->setFormTemplate("\n<form{attributes}>\n<table border=\"0\" class=\"log_table\" align=\"center\">\n{content}\n</table>\n</form>");
$renderer->setHeaderTemplate("\n\t<tr>\n\t\t<td class=\"log_table_head\" align=\"left\" valign=\"top\" colspan=\"2\" ><b>{header}</b></td>\n\t</tr>");
$form->addElement('header', null, "<img src=\"" . $html_code . "images/logo.gif\" border=\"0\" >");
$form->addElement('text', 'user_name', $__Lang__['langMenuUser'] . $__Lang__['langGeneralName'] . ' : ');
$form->addElement('password', 'user_passwd', $__Lang__['langMenuUser'] . $__Lang__['langGeneralPassword'] . ' : ');
$form->addRule('user_name', $__Lang__['langGeneralPleaseEnter'] . " " . $__Lang__['langMenuUser'] . " " . $__Lang__['langGeneralName'], 'required');
$form->addRule('user_passwd', $__Lang__['langGeneralPleaseEnter'] . " " . $__Lang__['langMenuUser'] . " " . $__Lang__['langGeneralPassword'], 'required');
$form->addElement('hidden', 'Action', 'LOGON');
$form->setDefaults(array('user_name' => $_COOKIE['UserName']));
$form->addElement('submit', null, $__Lang__['langGeneralSubmit']);
$form->addElement('static', 'login_message');
if ($form->validate() && $_POST['Action'] == 'LOGON') {
$user_name = $_POST['user_name'];
$user_password = md5($_POST['user_passwd']);
$this->checkAuth($user_name, $user_password);
}
$form->display();
exit;
}
示例5: makeExportForm
function makeExportForm($selfurl, $inbox)
{
global $uid;
$form = new HTML_QuickForm('export', 'post', "{$selfurl}&op=export&noheaderfooter=true");
$msg = "<p>You can export this data as a CSV (comma-separated values) file, " . "<br/>which can then be imported into Excel for analysis and graphing." . "</p><br/>";
$form->addElement('header', '', 'Export');
$form->addElement('static', '', '', $msg);
$datatype = $form->addElement('select', 'datatype', "Export What", array(EXPORT_ALLDATA => 'All Data', EXPORT_HISTOGRAM_MSG => 'Histogram by Message', EXPORT_HISTOGRAM_DAY => 'Histogram by Day', EXPORT_HISTOGRAM_MONTH => 'Histogram by Month'));
$form->addElement('submit', 'submit', 'Export');
if ($form->validate()) {
$datatypeval = $datatype->getValue();
switch ($datatypeval[0]) {
case EXPORT_ALLDATA:
exportAllData($inbox);
break;
default:
$uidquery = $uid;
if (isadmin() && !$uid) {
unset($uidquery);
}
if ($inbox) {
$counts = generateHistogramInbox($datatypeval[0], $uid);
} else {
$counts = generateHistogramOutbox($datatypeval[0], $uid);
}
$filename = $inbox ? 'inbox-hist-export.csv' : 'outbox-hist-export.csv';
exportHistogram($counts, $filename);
break;
}
exit;
}
$form->display();
}
示例6: __construct
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();
}
}
示例7: __construct
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>';
}
}
示例8: renderHtml
function renderHtml()
{
$type_key = $this->context->getTypeKeys();
if (is_numeric($this->query('sletbillede'))) {
$fields = array('date_updated', 'pic_id');
$values = array('NOW()', 0);
$sth = $this->db->autoPrepare('langtkursus_tilmelding', $fields, DB_AUTOQUERY_UPDATE, 'id = ' . $this->query('id'));
$res = $this->db->execute($sth, $values);
if (PEAR::isError($res)) {
throw new Exception($res->getMessage());
}
}
$form = new HTML_QuickForm();
$form->addElement('hidden', 'id', $this->name());
$form->addElement('file', 'userfile', 'Fil');
$form->addElement('submit', null, 'Upload');
if ($form->validate()) {
$file = new VIH_FileHandler();
if ($file->upload('userfile')) {
$fields = array('date_updated', 'pic_id');
$values = array('NOW()', $file->get('id'));
$sth = $this->db->autoPrepare('langtkursus_tilmelding', $fields, DB_AUTOQUERY_UPDATE, 'id = ' . $form->exportValue('id'));
$res = $this->db->execute($sth, $values);
if (PEAR::isError($res)) {
throw new Exception($res->getMessage());
}
return new k_SeeOther($this->url('./'));
}
}
$tilmelding = new VIH_Model_LangtKursus_Tilmelding($this->name());
if ($tilmelding->get('id') == 0) {
throw new k_http_Response(404);
}
$file = new VIH_FileHandler($tilmelding->get('pic_id'));
$file->loadInstance('small');
$extra_html = $file->getImageHtml($tilmelding->get('name'), 'width="100""');
$file->loadInstance('medium');
$stor = $file->get('file_uri');
if (empty($extra_html)) {
$extra_html = $form->toHTML();
} else {
$extra_html .= ' <br /><a href="' . $stor . '">stor</a> <a href="' . url('./') . '?sletbillede=' . $this->name() . '" onclick="return confirm(\'Er du sikker\');">slet billede</a>';
}
$res = $this->db->query('SELECT *, DATE_FORMAT(date_start, "%d-%m %H:%i") AS date_start_dk, DATE_FORMAT(date_end, "%d-%m %H:%i") AS date_end_dk FROM langtkursus_tilmelding_protokol_item WHERE tilmelding_id = ' . (int) $this->name() . ' ORDER BY date_start DESC, date_end DESC');
if (PEAR::isError($res)) {
throw new Exception($res->getMessage());
}
$data = array('items' => $res, 'type_key' => $type_key, 'vis_navn' => false);
$this->document->setTitle($tilmelding->get('navn'));
$this->document->addOption('Ret', $this->url('../../../langekurser/tilmeldinger/' . $tilmelding->get('id')));
$this->document->addOption('Indtast', $this->url('indtast'));
$this->document->addOption('Tilmelding', $this->url('../../../langekurser/tilmeldinger/' . $tilmelding->get('id')));
$this->document->addOption('Fag', $this->url('../../../langekurser/tilmeldinger/' . $tilmelding->get('id') . '/fag'));
$this->document->addOption('Holdliste', $this->context->url());
$this->document->addOption('Diplom', $this->url('../../../langekurser/tilmeldinger/' . $tilmelding->get('id') . '/diplom'));
$tpl = $this->template->create('protokol/liste');
return '<div style="border: 1px solid #ccc; padding: 0.5em; float: right;">' . $extra_html . '</div>
' . $tpl->render($this, $data);
}
示例9: opAdd
/**
* function_description
*
* @author John.meng
* @since version - Jan 19, 2006
* @param datatype paramname description
* @return datatype description
*/
function opAdd()
{
global $__Lang__, $UrlParameter, $SiteDB, $AddIPObj, $__SITE_VAR__, $form, $FlushPHPObj, $thisDAO, $smarty, $class_path;
include_once PEAR_DIR . 'HTML/QuickForm.php';
$form = new HTML_QuickForm('firstForm', 'post', '', '_self', "onsubmit='save_in_textarea_all();'");
$renderer =& $form->defaultRenderer();
$renderer->setFormTemplate("\n<form{attributes}>\n<table border=\"0\" class=\"new_table\" width='100%'>\n{content}\n</table>\n</form>");
$renderer->setHeaderTemplate("\n\t<tr>\n\t\t<td class=\"grid_table_head\" align=\"left\" valign=\"top\" colspan=\"2\"><b>{header}</b></td>\n\t</tr>");
$Content = $_POST['Content'];
if ($_REQUEST['Action'] == 'Update') {
$this_data = $this->_DAO->getRowByID(SITE_NEWS_TABLE, "NewsID", $_REQUEST['ID']);
$form->setDefaults(array("Title" => $this_data['Title'], "Summary" => $this_data['Summary'], "Source" => $this_data['Source'], "Author" => $this_data['Author']));
$Content = $this_data['Content'];
$form->addElement('hidden', 'ID', $this_data['NewsID']);
}
$class_path = INCLUDE_DIR . "editor/";
$CurrentUserPathImages = HTML_IMAGES_DIR;
$SiteCssFile = CURRENT_HTML_DIR . "style.css";
$ed_4 =& new rich("", 'Content', $Content, "380", "350", "../../" . $CurrentUserPathImages, "../../" . $CurrentUserPathImages, false, false);
$ed_4->set_default_stylesheet($SiteCssFile);
$ed_4->myModule(true);
$editors = $ed_4->draw();
$smarty->assign("class_path_editor", $class_path);
$form->addElement('header', null, $__Lang__['langGeneralAdd'] . " " . $__Lang__['langSiteModuleNews']);
$form->addElement('text', 'Title', $__Lang__['langModuleNewsTitle'] . ' : ', array('size' => 40));
$form->addElement('textarea', 'Summary', $__Lang__['langModuleNewsSummary'] . ' : ', array('rows' => 5, 'cols' => 40));
$form->addElement('static', 'Content', NULL, $editors);
$form->addElement('text', 'Source', $__Lang__['langModuleNewsSource'] . ' : ', array('size' => 30));
$form->addElement('text', 'Author', $__Lang__['langModuleNewsAuthor'] . ' : ', array('size' => 20));
$form->addElement('submit', null, $__Lang__['langGeneralSubmit']);
$form->addRule('Title', $__Lang__['langGeneralPleaseEnter'] . " " . $__Lang__['langModuleNewsTitle'], 'required');
$form->addElement('hidden', 'Module', $_REQUEST['Module']);
$form->addElement('hidden', 'Page', $_REQUEST['Page']);
$form->addElement('hidden', 'Action', $_REQUEST['Action']);
$form->addElement('hidden', 'MenuID', $_GET['MenuID']);
if ($form->validate()) {
if (get_magic_quotes_gpc()) {
$record["Content"] = stripslashes($_POST['Content']);
} else {
$record["Content"] = $_POST['Content'];
}
$record["Title"] = $_POST['Title'];
$record["Summary"] = $_POST['Summary'];
$record["Source"] = $_POST['Source'];
$record["Author"] = $_POST['Author'];
$record["SiteMenuID"] = $_POST['MenuID'];
$record = $record + $this->_DAO->baseField();
if ($_POST['ID'] && $_POST['Action'] == 'Update') {
$this->_DAO->opUpdate(SITE_NEWS_TABLE, $record, " NewsID = " . $_POST['ID']);
} else {
$this->_DAO->opAdd(SITE_NEWS_TABLE, $record);
}
echo "<SCRIPT LANGUAGE='JavaScript'>opener.window.location.reload();window.close();</SCRIPT>";
}
$html_code = "<link rel=\"StyleSheet\" type=\"text/css\" href=\"" . $class_path . "rich_files/rich.css\"><script language=\"JScript.Encode\" src=\"" . $class_path . "rich_files/rich.js\"></script>" . $form->toHTML();
$smarty->assign("Main", str_replace(ROOT_DIR, "../", $html_code));
}
示例10: handle
function handle(&$params)
{
$app =& Dataface_Application::getInstance();
$query =& $app->getQuery();
$this->table =& Dataface_Table::loadTable($query['-table']);
$translations =& $this->table->getTranslations();
foreach (array_keys($translations) as $trans) {
$this->table->getTranslation($trans);
}
//print_r($translations);
if (!isset($translations) || count($translations) < 2) {
// there are no translations to be made
trigger_error('Attempt to translate a record in a table "' . $this->table->tablename . '" that contains no translations.', E_USER_ERROR);
}
$this->translatableLanguages = array_keys($translations);
$translatableLanguages =& $this->translatableLanguages;
$this->languageCodes = new I18Nv2_Language($app->_conf['lang']);
$languageCodes =& $this->languageCodes;
$currentLanguage = $languageCodes->getName($app->_conf['lang']);
if (count($translatableLanguages) < 2) {
return PEAR::raiseError(df_translate('Not enough languages to translate', 'There aren\'t enough languages available to translate.'), DATAFACE_E_ERROR);
}
//$defaultSource = $translatableLanguages[0];
//$defaultDest = $translatableLanguages[1];
$options = array();
foreach ($translatableLanguages as $lang) {
$options[$lang] = $languageCodes->getName($lang);
}
unset($options[$app->_conf['default_language']]);
$tt = new Dataface_TranslationTool();
$form = new HTML_QuickForm('StatusForm', 'POST');
$form->addElement('select', '--language', 'Translation', $options);
$form->addElement('select', '--status', 'Status', $tt->translation_status_codes);
//$form->setDefaults( array('-sourceLanguage'=>$defaultSource, '-destinationLanguage'=>$defaultDest));
$form->addElement('submit', '--set_status', 'Set Status');
foreach ($query as $key => $value) {
$form->addElement('hidden', $key);
$form->setDefaults(array($key => $value));
}
if ($form->validate()) {
$res = $form->process(array(&$this, 'processForm'));
if (PEAR::isError($res)) {
return $res;
} else {
header('Location: ' . $app->url('-action=list&-sourceLanguage=&-destinationLanguage=&-translate=') . '&--msg=' . urlencode('Translation status successfully set.'));
exit;
}
}
ob_start();
$form->display();
$out = ob_get_contents();
ob_end_clean();
$records =& $this->getRecords();
df_display(array('form' => $out, 'translationTool' => &$tt, 'records' => &$records, 'translations' => &$options, 'context' => &$this), 'Dataface_set_translation_status.html');
}
示例11: validate
function validate()
{
$ret = parent::validate();
if (!$ret) {
// The form returned an error. We need to generate a new CSRF token, in any.
$token = $this->getElement('token');
if (!empty($token) && !PEAR::isError($token)) {
$token->setValue(phpAds_SessionGetToken());
}
}
return $ret;
}
示例12: __construct
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
<p/>
If an author is not already in the database press the <b>Add Author not
in DB</b> 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', '', ' ', false);
$this->form =& $form;
if ($form->validate()) {
$this->processForm();
} else {
$this->renderForm();
}
}
示例13: __construct
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', '', ' ', 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);
}
示例14: __construct
public function __construct()
{
parent::__construct('login');
if ($this->loginError) {
return;
}
$this->loadHttpVars(true, false);
$this->password_hash = "aicml";
if ($this->access_level > 0) {
echo 'You are already logged in as ', $_SESSION['user']->login, '.';
$this->pageError = true;
return;
}
if (empty($this->redirect) || strpos($this->redirect, 'login.php') !== false) {
// never redirect to the login page
$this->redirect = 'index.php';
}
$form = new HTML_QuickForm('login');
$form->addElement('header', 'login_header', 'Login');
$form->addElement('text', 'username', 'Login:', array('size' => 25, 'maxlength' => 40));
$form->addRule('username', 'login cannot be empty', 'required', null, 'client');
$form->addElement('password', 'password', 'Password:', array('size' => 25, 'maxlength' => 40));
$form->addRule('password', 'password cannot be empty', 'required', null, 'client');
$form->addElement('submit', 'submit_username', 'Login');
$form->addElement('header', 'new_users', 'New Users Only');
$form->addElement('password', 'password_again', 'Confirm Password:', array('size' => 25, 'maxlength' => 40));
$form->addElement('text', 'email', 'email:', array('size' => 25, 'maxlength' => 80));
$form->addRule('email', 'invalid email address', 'email', null, 'client');
$form->addElement('text', 'realname', 'Real Name:', array('size' => 25, 'maxlength' => 80));
$form->addElement('submit', 'newaccount', 'Create new account');
$form->addElement('hidden', 'redirect', $this->redirect);
$this->form =& $form;
if ($form->validate()) {
$this->processForm();
return;
}
// only get here if form hasn't been submitted
echo '<h2><a href="#">Log In or Create a New Account</a></h2>';
}
示例15: manage_display
//.........这里部分代码省略.........
$row['actions'] = "<a href=\"index.php?view=manage&task=edit_problem&id={$_GET['id']}&prob_id={$row['prob_id']}\">edit</a>, " . "<a href=\"index.php?view=manage&task=del_problem&id={$_GET['id']}&prob_id={$row['prob_id']}\">delete</a>";
$table->addRow(array_values($row));
$res->fetchInto($row);
}
$res->free();
// display tables
$table->altRowAttributes(1, null, array("class" => "altrow"));
echo '<div class="overflow">' . $table->toHtml() . '</div>';
}
echo "<hr />";
// form for adding a problem
$form = new HTML_QuickForm('problemAddForm', 'post', selflink());
$form->addElement('header', null, 'Add a problem');
$form->addElement('text', 'prob_id', 'Name (one word ID): ');
$form->addElement('text', 'summary', 'Summary: ');
$form->addElement('text', 'weight', 'Points weightage: ');
$form->addElement('text', 'time_limit', 'Time limit: ');
$form->addElement('text', 'mem_limit', 'Memory limit: ');
$elem =& $form->addElement('textarea', 'content', 'Problem content (XML): ');
$elem->setRows(10);
$elem->setCols(80);
$form->addElement('submit', null, 'Submit');
$form->applyFilter('prob_id', 'trim');
$form->applyFilter('summary', 'trim');
$form->applyFilter('weight', 'trim');
$form->applyFilter('time_limit', 'trim');
$form->applyFilter('mem_limit', 'trim');
$form->addRule('prob_id', 'Problem ID is required', 'required', null, 'client');
$form->addRule('summary', 'Problem summary is required', 'required', null, 'client');
$form->addRule('weight', 'Points weightage is required', 'required', null, 'client');
$form->addRule('time_limit', 'Time limit is required', 'required', null, 'client');
$form->addRule('mem_limit', 'Memory limit is required', 'required', null, 'client');
$form->addRule('content', 'Problem content in XML is required', 'required', null, 'client');
if ($form->validate()) {
$data = $form->getSubmitValues();
$errs = problem_check($data['content']);
if ($errs == null) {
$data['contest_id'] = $_GET['id'];
$res =& $db->autoExecute('problems', $data, DB_AUTOQUERY_INSERT);
if (PEAR::isError($res)) {
error($res->toString());
}
$cache->remove(problem_cache_id($_GET['id'], $data['prob_id']) . '.htm');
$cache->remove(problem_cache_id($_GET['id'], $data['prob_id']) . '.prob');
redirect('index.php?view=manage&task=problems&id=' . $_GET['id']);
} else {
?>
<p><b>Error:</b> The problem could not be added due to the following errors encountered while
parsing the problem XML file. Please fix them and try submitting again.</p>
<?php
echo "<ol class=\"errors\">\n";
foreach ($errs as $line) {
echo "<li>{$line}</li>\n";
}
echo "</ol>\n<hr />\n";
}
}
$form->display();
break;
case 'del_problem':
db_query('del_problem_by_id', array($_GET['prob_id'], $_GET['id']));
redirect('index.php?view=manage&task=problems&id=' . $_GET['id']);
break;
case 'edit_problem':
$res =& db_query('problem_by_id', array($_GET['prob_id'], $_GET['id']));
$res->fetchInto($row);