本文整理汇总了PHP中FormElement::setTypeAsComboBox方法的典型用法代码示例。如果您正苦于以下问题:PHP FormElement::setTypeAsComboBox方法的具体用法?PHP FormElement::setTypeAsComboBox怎么用?PHP FormElement::setTypeAsComboBox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormElement
的用法示例。
在下文中一共展示了FormElement::setTypeAsComboBox方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: WPCW_showPage_ImportExport_export
/**
* Show the export course page.
*/
function WPCW_showPage_ImportExport_export()
{
$page = new PageBuilder(true);
$page->showPageHeader(__('Export Training Course', 'wp_courseware'), '75%', WPCW_icon_getPageIconURL());
// Show form of courses that can be exported.
$form = new FormBuilder('wpcw_export');
$form->setSubmitLabel(__('Export Course', 'wp_courseware'));
// Course selection
$formElem = new FormElement('export_course_id', __('Course to Export', 'wp_courseware'), true);
$formElem->setTypeAsComboBox(WPCW_courses_getCourseList(__('--- Select a course to export ---', 'wp_courseware')));
$form->addFormElement($formElem);
// Options for what to export
$formElem = new FormElement('what_to_export', __('What to Export', 'wp_courseware'), true);
$formElem->setTypeAsRadioButtons(array('whole_course' => __('<b>All</b> - The whole course - including modules, units and quizzes.', 'wp_courseware'), 'just_course' => __('<b>Just the Course</b> - Just the course title, description and settings (no modules, units or quizzes).', 'wp_courseware'), 'course_modules' => __('<b>Course and Modules</b> - Just the course settings and module settings (no units or quizzes).', 'wp_courseware'), 'course_modules_and_units' => __('<b>Course, Modules and Units</b> - The course settings and module settings and units (no quizzes).', 'wp_courseware')));
$form->addFormElement($formElem);
$form->setDefaultValues(array('what_to_export' => 'whole_course'));
if ($form->formSubmitted()) {
// Do the full export
if ($form->formValid()) {
// If data is valid, export will be handled by export class.
} else {
$page->showListOfErrors($form->getListOfErrors(), __('Sorry, but unfortunately there were some errors. Please fix the errors and try again.', 'wp_courseware'));
}
}
// Show selection menu for import/export to save pages
WPCW_showPage_ImportExport_menu('export');
printf('<p class="wpcw_doc_quick">');
_e('When you export a course, you\'ll get an <b>XML file</b>, which you can then <b>import into another WordPress website</b> that\'s running <b>WP Courseware</b>.<br/>
When you export the course units with a course, just the <b>HTML to render images and video</b> will be copied, but the <b>actual images and video files will not be exported</b>.', 'wp_courseware');
printf('</p>');
echo $form->toString();
$page->showPageFooter();
}
示例2: createElementObject
/**
* Convert an array of details into a form element.
* @param String $fieldName The name of the form element
* @param Array $fieldDetails The list of details for the form element.
*/
protected function createElementObject($fieldName, $fieldDetails)
{
// Extract fields
$label = $this->formObj->getArrayValue($fieldDetails, 'label');
$type = $this->formObj->getArrayValue($fieldDetails, 'type');
// Required 'true' or true are valid
$required = $this->formObj->getArrayValue($fieldDetails, 'required');
$required = $required == 'true' || $required == '1';
// Start creating form element if anything other than a break.
$elem = false;
if ($type != 'break') {
$elem = new FormElement($fieldName, $label, $required);
}
// Handle specific types
switch ($type) {
// Text Area
case 'textarea':
$rows = $this->formObj->getArrayValue($fieldDetails, 'rows') + 0;
if ($rows == 0) {
$rows = 5;
}
$elem->setTypeAsTextArea($rows, 70);
break;
// Select/Dropdown
// Select/Dropdown
case 'select':
$options = false;
if (isset($fieldDetails['data']) && is_array($fieldDetails['data'])) {
$options = $fieldDetails['data'];
}
$elem->setTypeAsComboBox($options);
break;
// Radio Buttons
// Radio Buttons
case 'radio':
$options = false;
if (isset($fieldDetails['data']) && is_array($fieldDetails['data'])) {
$options = $fieldDetails['data'];
}
$elem->setTypeAsRadioButtons($options);
break;
// Checkbox
// Checkbox
case 'checkbox':
$label = false;
if (isset($fieldDetails['extralabel'])) {
$label = $fieldDetails['extralabel'];
}
$elem->setTypeAsCheckbox($label);
break;
// Checkbox List
// Checkbox List
case 'checkboxlist':
$options = false;
if (isset($fieldDetails['data']) && is_array($fieldDetails['data'])) {
$options = $fieldDetails['data'];
}
$elem->setTypeAsCheckboxList($options);
break;
// Merged Fields - process each sub element
// Merged Fields - process each sub element
case 'merge':
$elementList = array();
if (!empty($fieldDetails['merge'])) {
foreach ($fieldDetails['merge'] as $fieldName => $fieldDetails) {
$elementList[] = $this->createElementObject($fieldName, $fieldDetails);
}
}
$elem->setTypeAsMergedElements($elementList);
break;
// File upload
// File upload
case 'uploadfile':
$elem->setTypeAsUploadFile($this->formObj->getArrayValue($fieldDetails, 'show_existing'), $this->formObj->getArrayValue($fieldDetails, 'valid_if_value'));
break;
// Custom HTML
// Custom HTML
case 'custom':
$elem->setTypeAsCustom($this->formObj->getArrayValue($fieldDetails, 'html'));
break;
// Hidden field
// Hidden field
case 'hidden':
$elem->setTypeAsHidden();
break;
// Section break
// Section break
case 'break':
$this->formObj->addBreak($fieldName, $this->formObj->getArrayValue($fieldDetails, 'html'));
break;
// Text box
// Text box
default:
break;
}
//.........这里部分代码省略.........
示例3: WPPortfolio_modify_website
//.........这里部分代码省略.........
$data['customthumb'] = false;
$data['siteactive'] = 1;
// The default is that the website is visible.
$data['displaylink'] = 1;
// The default is to show the link.
$data['siteorder'] = 0;
$data['specificpage'] = 0;
$data['customfield'] = false;
}
} else {
$message = __("Sorry, but unfortunately there were some errors. Please fix the errors and try again.", 'wp-portfolio') . '<br><br>';
$message .= "<ul style=\"margin-left: 20px; list-style-type: square;\">";
// Loop through all errors in the $error list
foreach ($errors as $errormsg) {
$message .= "<li>{$errormsg}</li>";
}
$message .= "</ul>";
WPPortfolio_showMessage($message, true);
$websitedetails = $data;
}
}
$form = new FormBuilder();
$formElem = new FormElement("website_sitename", __("Website Name", 'wp-portfolio'));
$formElem->value = WPPortfolio_getArrayValue($websitedetails, 'sitename');
$formElem->description = __("The proper name of the website.", 'wp-portfolio') . ' <em>' . __('(Required)', 'wp-portfolio') . '</em>';
$form->addFormElement($formElem);
$formElem = new FormElement("website_siteurl", __("Website URL", 'wp-portfolio'));
$formElem->value = WPPortfolio_getArrayValue($websitedetails, 'siteurl');
$formElem->description = __("The URL for the website, including the leading", 'wp-portfolio') . ' <em>http://</em>. <em>' . __('(Required)', 'wp-portfolio') . '</em>';
$form->addFormElement($formElem);
$formElem = new FormElement("website_sitedescription", __("Website Description", 'wp-portfolio'));
$formElem->value = WPPortfolio_getArrayValue($websitedetails, 'sitedescription');
$formElem->description = __("The description of your website. HTML is permitted.", 'wp-portfolio') . ' <em>' . __('(Required)', 'wp-portfolio') . "</em>";
$formElem->setTypeAsTextArea(4, 70);
$form->addFormElement($formElem);
global $wpdb;
$table_name = $wpdb->prefix . TABLE_WEBSITE_GROUPS;
$SQL = "SELECT * FROM {$table_name} ORDER BY groupname";
$groups = $wpdb->get_results($SQL, OBJECT);
$grouplist = array();
foreach ($groups as $group) {
$grouplist[$group->groupid] = stripslashes($group->groupname);
}
$formElem = new FormElement("website_sitegroup", "Website Group");
$formElem->setTypeAsComboBox($grouplist);
$formElem->value = WPPortfolio_getArrayValue($websitedetails, 'sitegroup');
$formElem->description = __("The group you want to assign this website to.", 'wp-portfolio');
$form->addFormElement($formElem);
$form->addBreak('advanced-options', '<div id="wpp-hide-show-advanced" class="wpp_hide"><a href="#">' . __('Show Advanced Settings', 'wp-portfolio') . '</a></div>');
$formElem = new FormElement("website_siteactive", __("Show Website?", 'wp-portfolio'));
$formElem->setTypeAsComboBox(array('1' => __('Show Website', 'wp-portfolio'), '0' => __('Hide Website', 'wp-portfolio')));
$formElem->value = WPPortfolio_getArrayValue($websitedetails, 'siteactive');
$formElem->description = __("By changing this option, you can show or hide a website from the portfolio.", 'wp-portfolio');
$form->addFormElement($formElem);
$formElem = new FormElement("website_displaylink", __("Show Link?", 'wp-portfolio'));
$formElem->setTypeAsComboBox(array('show_link' => __('Show Link', 'wp-portfolio'), 'hide_link' => __('Hide Link', 'wp-portfolio')));
$formElem->value = WPPortfolio_getArrayValue($websitedetails, 'displaylink');
$formElem->description = __("With this option, you can choose whether or not to display the URL to the website.", 'wp-portfolio');
$form->addFormElement($formElem);
$formElem = new FormElement("siteadded", __("Date Website Added", 'wp-portfolio'));
$formElem->value = WPPortfolio_getArrayValue($websitedetails, 'siteadded');
$formElem->description = __("Here you can adjust the date in which the website was added to the portfolio. This is useful if you're adding items retrospectively. (valid format is yyyy-mm-dd hh:mm:ss)", 'wp-portfolio');
$form->addFormElement($formElem);
$formElem = new FormElement("website_siteorder", __("Website Ordering", 'wp-portfolio'));
$formElem->value = WPPortfolio_getArrayValue($websitedetails, 'siteorder');
$formElem->description = '• ' . __("The number to use for ordering the websites. Websites are rendered in ascending order, first by this order value (lowest value first), then by website name.", 'wp-portfolio') . '<br/>' . '• ' . __("e.g. Websites (A, B, C, D) with ordering (50, 100, 0, 50) will be rendered as (C, A, D, B).", 'wp-portfolio') . '<br/>' . '• ' . __("If all websites have 0 for ordering, then the websites are rendered in alphabetical order by name.", 'wp-portfolio');
$form->addFormElement($formElem);
$formElem = new FormElement("website_customthumb", __("Custom Thumbnail URL", 'wp-portfolio'));
$formElem->value = WPPortfolio_getArrayValue($websitedetails, 'customthumb');
$formElem->cssclass = "long-text";
$formElem->description = __("If specified, the URL of a custom thumbnail to use <em>instead</em> of the screenshot of the URL above.", 'wp-portfolio') . '<br/>' . '• ' . __("The image URL must include the leading <em>http://</em>, e.g.", 'wp-portfolio') . ' <em>http://www.yoursite.com/wp-content/uploads/yourfile.jpg</em><br/>' . '• ' . __("Leave this field blank to use an automatically generated screenshot of the website specified above.", 'wp-portfolio') . '<br/>' . '• ' . __("Custom thumbnails are automatically resized to match the size of the other thumbnails.", 'wp-portfolio');
$form->addFormElement($formElem);
$formElem = new FormElement("website_customfield", __("Custom Field", 'wp-portfolio') . "<br/><span class=\"wpp-advanced-feature\">• " . __("Advanced Feature", 'wp-portfolio') . "</span>");
$formElem->value = WPPortfolio_getArrayValue($websitedetails, 'customfield');
$formElem->cssclass = "long-text";
$formElem->description = sprintf(__("Allows you to specify a value that is substituted into the <code><b>%s</b></code> field. This can be any value. Examples of what you could use the custom field for include:", 'wp-portfolio'), WPP_STR_WEBSITE_CUSTOM_FIELD) . '<br/>' . '• ' . __("Affiliate URLs for the actual URL that visitors click on.", 'wp-portfolio') . '<br/>' . '• ' . __("Information as to the type of work a website relates to (e.g. design work, SEO, web development).", 'wp-portfolio');
$form->addFormElement($formElem);
// Advanced Features
$formElem = new FormElement("website_specificpage", __("Use Specific Page Capture", 'wp-portfolio') . "<br/>" . "<span class=\"wpp-advanced-feature\">• " . __("Advanced Feature", 'wp-portfolio') . "</span><br/>" . "<span class=\"wpp-stw-paid\">• " . __("STW Paid Account Only", 'wp-portfolio') . "</span>");
$formElem->setTypeAsComboBox(array('0' => __('No - Homepage Only', 'wp-portfolio'), '1' => __('Yes - Show Specific Page', 'wp-portfolio')));
$formElem->value = WPPortfolio_getArrayValue($websitedetails, 'specificpage');
$formElem->description = '• <b>' . __("Requires Shrink The Web 'Specific Page Capture' Paid (Basic or Plus) feature.", 'wp-portfolio') . '</b><br/>' . '• ' . __("If enabled show internal web page rather than website's homepage. If in doubt, select <b>'No - Homepage Only'</b>.", 'wp-portfolio');
$form->addFormElement($formElem);
// Hidden Elements
$formElem = new FormElement("website_siteid", false);
$formElem->value = WPPortfolio_getArrayValue($websitedetails, 'siteid');
$formElem->setTypeAsHidden();
$form->addFormElement($formElem);
$formElem = new FormElement("editmode", false);
$formElem->value = $editmode ? "edit" : "add";
$formElem->setTypeAsHidden();
$form->addFormElement($formElem);
$form->setSubmitLabel(($editmode ? __("Update", 'wp-portfolio') : __("Add", 'wp-portfolio')) . " " . __("Website Details", 'wp-portfolio'));
echo $form->toString();
?>
<br><br>
</div><!-- wrap -->
<?php
}
示例4: createElementObject
/**
* Convert an array of details into a form element.
* @param String $fieldName The name of the form element
* @param Array $fieldDetails The list of details for the form element.
*/
protected function createElementObject($fieldName, $fieldDetails)
{
// Extract fields
$label = $this->formObj->getArrayValue($fieldDetails, 'label');
$type = $this->formObj->getArrayValue($fieldDetails, 'type');
// Required 'true' or true are valid
$required = $this->formObj->getArrayValue($fieldDetails, 'required');
$required = $required == 'true' || $required == '1';
// Start creating form element if anything other than a break.
$elem = false;
if ($type != 'break') {
$elem = new FormElement($fieldName, $label, $required);
}
// Handle specific types
switch ($type) {
// Text Area
case 'textarea':
$rows = $this->formObj->getArrayValue($fieldDetails, 'rows') + 0;
if ($rows == 0) {
$rows = 5;
}
$elem->setTypeAsTextArea($rows, 70);
break;
// Select/Dropdown
// Select/Dropdown
case 'select':
$options = false;
if (isset($fieldDetails['data']) && is_array($fieldDetails['data'])) {
$options = $fieldDetails['data'];
}
$elem->setTypeAsComboBox($options);
break;
// Radio Buttons
// Radio Buttons
case 'radio':
$options = false;
if (isset($fieldDetails['data']) && is_array($fieldDetails['data'])) {
$options = $fieldDetails['data'];
}
$elem->setTypeAsRadioButtons($options);
break;
// Checkbox
// Checkbox
case 'checkbox':
$label = false;
if (isset($fieldDetails['extralabel'])) {
$label = $fieldDetails['extralabel'];
}
$elem->setTypeAsCheckbox($label);
break;
// Checkbox List
// Checkbox List
case 'checkboxlist':
$options = false;
if (isset($fieldDetails['data']) && is_array($fieldDetails['data'])) {
$options = $fieldDetails['data'];
}
$elem->setTypeAsCheckboxList($options);
break;
// Merged Fields - process each sub element
// Merged Fields - process each sub element
case 'merge':
$elementList = array();
if (!empty($fieldDetails['merge'])) {
foreach ($fieldDetails['merge'] as $fieldName => $fieldDetails) {
$elementList[] = $this->createElementObject($fieldName, $fieldDetails);
}
}
$elem->setTypeAsMergedElements($elementList);
break;
// Custom HTML
// Custom HTML
case 'custom':
$elem->setTypeAsCustom($this->formObj->getArrayValue($fieldDetails, 'html'));
break;
// Hidden field
// Hidden field
case 'hidden':
$elem->setTypeAsHidden();
break;
// Section break
// Section break
case 'break':
$this->formObj->addBreak($fieldName, $this->formObj->getArrayValue($fieldDetails, 'html'));
break;
// Text box
// Text box
default:
break;
}
// Add optional fields
if ($type != 'break') {
// Element description
if ($desc = $this->formObj->getArrayValue($fieldDetails, 'desc')) {
$elem->description = $desc;
//.........这里部分代码省略.........