本文整理汇总了PHP中FormBuilder::formSubmitted方法的典型用法代码示例。如果您正苦于以下问题:PHP FormBuilder::formSubmitted方法的具体用法?PHP FormBuilder::formSubmitted怎么用?PHP FormBuilder::formSubmitted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormBuilder
的用法示例。
在下文中一共展示了FormBuilder::formSubmitted方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processPost
/**
* Handle processing the form when it's posted, such as saving and handling errors.
*/
protected function processPost()
{
if (!$this->formObj) {
return false;
}
if ($this->formObj->formSubmitted()) {
// Form is valid, so save data
if ($this->formObj->formValid()) {
$originalFormValues = $this->formObj->getFormValues();
// Add optional filter to tweak the form values before saving
if ($this->filterBeforeSaveFunction && function_exists($this->filterBeforeSaveFunction)) {
$formValues = call_user_func($this->filterBeforeSaveFunction, $originalFormValues, $this);
} else {
$formValues = $originalFormValues;
}
// Now save the form values as normal.
$this->handleSave($formValues);
// Optional function once data has been saved
if ($this->afterSaveFunction && function_exists($this->afterSaveFunction)) {
call_user_func($this->afterSaveFunction, $formValues, $originalFormValues, $this);
}
} else {
$this->messages = $this->showListOfErrors($this->formObj->getListOfErrors());
}
}
}
示例2: processPost
/**
* Handle processing the form when it's posted, such as saving and handling errors.
*/
protected function processPost()
{
if (!$this->formObj) {
return false;
}
if ($this->formObj->formSubmitted()) {
// Form is valid, so save data
if ($this->formObj->formValid()) {
$originalFormValues = $this->formObj->getFormValues();
// Add optional function to validate the data
$gotFnErrorMsg = false;
if ($this->filterExtraValidationFunction && function_exists($this->filterExtraValidationFunction)) {
$gotFnErrorMsg = call_user_func($this->filterExtraValidationFunction, $originalFormValues, $this);
}
// Got an error message, so show and abort.
if ($gotFnErrorMsg) {
$this->messages = $this->showMessage($gotFnErrorMsg, true);
return false;
}
// Add optional filter to tweak the form values before saving
if ($this->filterBeforeSaveFunction && function_exists($this->filterBeforeSaveFunction)) {
$formValues = call_user_func($this->filterBeforeSaveFunction, $originalFormValues, $this);
// If we're modifying values, then we need to update the data being stored in the form
$this->loadDefaults($formValues);
} else {
$formValues = $originalFormValues;
}
// Now save the form values as normal.
$this->handleSave($formValues);
// Optional function once data has been saved
if ($this->afterSaveFunction && function_exists($this->afterSaveFunction)) {
call_user_func($this->afterSaveFunction, $formValues, $originalFormValues, $this);
}
} else {
$this->messages .= $this->showListOfErrors($this->formObj->getListOfErrors());
}
}
}
示例3: WPCW_showPage_ImportExport_importUsers
/**
* Show the import course page.
*/
function WPCW_showPage_ImportExport_importUsers()
{
$page = new PageBuilder(true);
$page->showPageHeader(__('Import Users from CSV File', 'wp_courseware'), '75%', WPCW_icon_getPageIconURL());
// Show selection menu for import/export to save pages
WPCW_showPage_ImportExport_menu('import_users');
// Show form to import some XML
$form = new FormBuilder('wpcw_import_users');
$form->setSubmitLabel(__('Import Users', 'wp_courseware'));
// Course upload for XML file
$formElem = new FormElement('import_course_csv', __('User Import CSV File', 'wp_courseware'), true);
$formElem->setTypeAsUploadFile();
$form->addFormElement($formElem);
if ($form->formSubmitted()) {
// Do the full export
if ($form->formValid()) {
// Handle the importing/uploading
WPCW_users_importUsersFromFile($page);
} else {
$page->showListOfErrors($form->getListOfErrors(), __('Unfortunately, there were some errors trying to import the XML file.', 'wp_courseware'));
}
}
// Workout maximum upload size
$max_upload = (int) ini_get('upload_max_filesize');
$max_post = (int) ini_get('post_max_size');
$memory_limit = (int) ini_get('memory_limit');
$upload_mb = min($max_upload, $max_post, $memory_limit);
printf('<p class="wpcw_doc_quick">');
printf(__('You can import a CSV file of users using the form below.', 'wp_courseware') . ' ' . __('The <b>maximum upload file size</b> for your server is <b>%d MB</b>.', 'wp_courseware'), $upload_mb);
printf('</p>');
echo $form->toString();
printf('<br/><br/><div class="wpcw_docs_wrapper">');
printf('<b>%s</b>', __('Some tips for importing users via a CSV file:', 'wp_courseware'));
printf('<ul>');
printf('<li>' . __('If a user email address already exists, then just the courses are updated for that user.', 'wp_courseware'));
printf('<li>' . __('User names are generated from the first and last name information. If a user name already exists, then a unique username is generated.', 'wp_courseware'));
printf('<li>' . __('To add a user to many courses, just separate those course IDs with a comma in the <code>courses_to_add_to</code> column.', 'wp_courseware'));
printf('<li>' . __('If a user is created, any courses set to be automatically assigned will be done first, and then the courses added in the <code>courses_to_add_to</code> column.', 'wp_courseware'));
printf('<li>' . __('You can download an <a href="%s">example CSV file here</a>.', 'wp_courseware') . '</li>', admin_url('?wpcw_export=csv_import_user_sample'));
printf('<li>' . __('The IDs for the training courses can be found on the <a href="%s">course summary page</a>.', 'wp_courseware') . '</li>', admin_url('admin.php?page=WPCW_wp_courseware'));
printf('</ul>');
printf('</div>');
$page->showPageFooter();
}
示例4: showMembershipMappingLevels_specificLevel
/**
* Show the form for editing the specific courses a user can access based on what level that they have access to.
* @param PageBuilder $page The page rendering object.
* @param Array $levelDetails The list of level details
*/
private function showMembershipMappingLevels_specificLevel($page, $levelDetails)
{
// Show a nice summary of what level is being edited.
printf('<div id="wpcw_member_level_name_title">%s</div>', sprintf(__('Editing permissions for <b>%s</b> level with <b>%s</b>:', 'wp_courseware'), $levelDetails['name'], $this->extensionName));
// Get a list of course IDs that exist
$courses = WPCW_courses_getCourseList(false);
// Get list of courses already associated with level.
$courseListInDB = $this->getCourseAccessListForLevel($levelDetails['id']);
// Create the summary URL to return
$summaryURL = admin_url('admin.php?page=' . $this->extensionID);
// Update form...
$form = new FormBuilder('wpcw_member_levels_edit');
$form->setSubmitLabel(__('Save Changes', 'wp_courseware'));
// Create list of courses using checkboxes (max of 2 columns)
$elem = new FormElement('level_courses', __('Courses user can access at this level', 'wp_courseware'), false);
$elem->setTypeAsCheckboxList($courses);
$elem->checkboxListCols = 2;
$form->addFormElement($elem);
// Normally would check for errors too, but there's not a lot to check here.
if ($form->formSubmitted()) {
if ($form->formValid()) {
$mapplingList = $form->getValue('level_courses');
global $wpdb, $wpcwdb;
$wpdb->show_errors();
// Remove all previous level mappings (as some will have been removed)
$wpdb->query($wpdb->prepare("\n\t\t\t\t\t\tDELETE \n\t\t\t\t\t\tFROM {$wpcwdb->map_member_levels} \n\t\t\t\t\t\tWHERE member_level_id = %s\n\t\t\t\t\t", $levelDetails['id']));
// Add all of the new mappings the user has chosen.
if ($mapplingList && count($mapplingList) > 0) {
foreach ($mapplingList as $courseID => $itemState) {
$wpdb->query($wpdb->prepare("\n\t\t\t\t\t\t\t\tINSERT INTO {$wpcwdb->map_member_levels} \n\t\t\t\t\t\t\t\t(course_id, member_level_id) \n\t\t\t\t\t\t\t\tVALUES (%d, %s)\n\t\t\t\t\t\t\t", $courseID, $levelDetails['id']));
}
}
// Show a success message.
$page->showMessage(__('Level and course permissions successfully updated.', 'wp_courseware') . '<br/><br/>' . sprintf(__('Want to return to the <a href="%s">Course Access Settings summary</a>?', 'wp_courseware'), $summaryURL));
}
// if ($form->formValid())
} else {
$form->setDefaultValues(array('level_courses' => $courseListInDB));
}
// Show the form
echo $form->toString();
printf('<a href="%s" class="button-secondary">%s</a>', $summaryURL, __('« Return to Course Access Settings summary', 'wp_courseware'));
}
示例5: STWWT_showPage_ThumbnailCache
/**
* Shows information about the thumbnail cache.
*/
function STWWT_showPage_ThumbnailCache()
{
$page = new PageBuilder(false);
$page->showPageHeader(__('Shrink The Web - Website Thumbnails - Cache', 'stwwt'), '70%');
?>
<h3>Clear Thumbnail Cache</h3>
<p>Generally speaking, you do not need to clear the thumbnail cache. The plugin automatically manages the thumbnail cache, updating thumbnails automatically. However, if you do need to clear the cache for any reason, you can use the button below to flush the cache.</p>
<?php
$form = new FormBuilder('stwwt_cache_clear');
$form->setSubmitLabel('Clear Thumbnail Cache');
if ($form->formSubmitted() && $form->formValid()) {
STWWT_cache_emptyCache(false);
$page->showMessage("Cache successfully emptied.");
}
echo $form->toString();
// #### Cache Path Information
$cachePathDir = STWWT_plugin_getCacheDirectory();
$cachePathURL = STWWT_plugin_getCacheURL();
$pathIsWriteable = file_exists($cachePathDir) && is_dir($cachePathDir) && is_writable($cachePathDir);
?>
<br/>
<h3>Cache Path Information</h3>
<p>Your server cache path is <b><?php
echo $cachePathDir;
?>
</b>, which translates to a URL of <b><?php
echo $cachePathURL;
?>
</b>.</p>
<p>Your cache path is currently <?php
echo $pathIsWriteable ? '<span class="stwwt_cache_status stwwt_cache_ok">Writeable</span>. This is fine, so you do not need to do anything more.' : '<span class="stwwt_cache_status stwwt_cache_error">Not Writeable</span>. This needs fixing for the thumbnail cache to work.';
?>
</p>
<?php
$page->showPageFooter();
}