本文整理汇总了PHP中FormBuilder::addBreak方法的典型用法代码示例。如果您正苦于以下问题:PHP FormBuilder::addBreak方法的具体用法?PHP FormBuilder::addBreak怎么用?PHP FormBuilder::addBreak使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormBuilder
的用法示例。
在下文中一共展示了FormBuilder::addBreak方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: appendShortcodeForm
/**
* Handles shortcode form
* @param ctShortcode $shortcode
* @param null $containerName
* @param null $defaults
* @throws Exception
* @return bool|string
*/
protected function appendShortcodeForm($shortcode, $containerName = null, $defaults = null)
{
$containerName = $containerName ? $containerName : 'container_' . ++$this->counter;
$this->form->addBreak($containerName);
$attributes = array_diff_key($shortcode->getAttributesNormalized(), $this->bannedAttributes);
$defaults = $defaults ? $defaults : $this->defaults;
foreach ($attributes as $name => $attribute) {
$attribute = $this->normalizeAttribute($name, $attribute, $defaults);
//may be false
if ($attribute['type'] && $attribute['type'] != 'false') {
if (!method_exists($this, $attribute['type'])) {
throw new Exception("Cannot handle " . $attribute['type'] . ' type');
}
$this->{$attribute}['type']($name, $attribute);
}
}
return false;
}
示例2: 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
}
示例3: 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;
}
//.........这里部分代码省略.........
示例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;
//.........这里部分代码省略.........