function webspark_seven_form_required_marker($variables) { // This is also used in the installer, pre-database setup. $t = get_t(); $attributes = array('class' => 'form-required', 'title' => $t('This field is required.')); return '<span' . drupal_attributes($attributes) . '> * </span>'; }
/** * Return a themed form element. * Edited to remove colon. * * @param element * An associative array containing the properties of the element. * Properties used: title, description, id, required * @param $value * The form element's data. * @return * A string representing the form element. * * @ingroup themeable */ function marco_form_element($element, $value) { // This is also used in the installer, pre-database setup. $t = get_t(); $output = '<div class="form-item"'; if (!empty($element['#id'])) { $output .= ' id="' . $element['#id'] . '-wrapper"'; } $output .= ">\n"; $required = !empty($element['#required']) ? '<span class="form-required" title="' . $t('This field is required.') . '"></span>' : ''; if (!empty($element['#title'])) { $title = $element['#title']; if (!empty($element['#id'])) { $output .= ' <label for="' . $element['#id'] . '">' . $t('!title !required', array('!title' => filter_xss_admin($title), '!required' => $required)) . "</label>\n"; } else { $output .= ' <label>' . $t('!title !required', array('!title' => filter_xss_admin($title), '!required' => $required)) . "</label>\n"; } } $output .= " {$value}\n"; if (!empty($element['#description'])) { $output .= ' <div class="description">' . $element['#description'] . "</div>\n"; } $output .= "</div>\n"; return $output; }
/** * @file * form mothership overwrites */ function mothership_form_element($element, $value) { // This is also used in the installer, pre-database setup. $t = get_t(); //add a more specific form-item-$type $output = "<div class=\"form-item form-item-" . $element['#type'] . " \" "; // TODO cant this be dublicated on a page? //and then its not unique if (!empty($element['#id'])) { $output .= ' id="' . $element['#id'] . '-wrapper"'; } $output .= ">\n"; $required = !empty($element['#required']) ? '<span class="form-required" title="' . $t('This field is required.') . '">*</span>' : ''; if (!empty($element['#title'])) { $title = $element['#title']; if (!empty($element['#id'])) { $output .= ' <label for="' . $element['#id'] . '">' . $t('!title: !required', array('!title' => filter_xss_admin($title), '!required' => $required)) . "</label>\n"; } else { $output .= ' <label>' . $t('!title: !required', array('!title' => filter_xss_admin($title), '!required' => $required)) . "</label>\n"; } } //TODO test to see if this is clean text - then we might need a <span> //if we need to catch the content with $output .= "{$value}\n"; if (!empty($element['#description'])) { $output .= '<div class="form-description">' . $element['#description'] . "</div>\n"; } $output .= "</div>\n"; return $output; }
function mothership_form_element($element, $value) { // This is also used in the installer, pre-database setup. $t = get_t(); //$output = '<div>'; // removed $output = '<div class="form-item"'; //so we dont know its a div hmm? form>div .... $output = '<div '; // removed the ID wrapper? if (!empty($element['#id'])) { $output .= ' id="' . $element['#id'] . '-wrapper"'; } $output .= ">\n"; $required = !empty($element['#required']) ? '<span class="form-required" title="' . $t('This field is required.') . '">*</span>' : ''; if (!empty($element['#title'])) { $title = $element['#title']; if (!empty($element['#id'])) { $output .= ' <label for="' . $element['#id'] . '">' . $t('!title: !required', array('!title' => filter_xss_admin($title), '!required' => $required)) . "</label>\n"; } else { $output .= ' <label>' . $t('!title: !required', array('!title' => filter_xss_admin($title), '!required' => $required)) . "</label>\n"; } } //TODO test to see if this is clean text - then we might need a <span> etc $output .= "{$value}\n"; if (!empty($element['#description'])) { $output .= '<div class="description">' . $element['#description'] . "</div>\n"; } $output .= "</div>\n"; return $output; }
/** * Implements theme_form_element_label(). */ function tibco_styles_form_element_label($variables) { $element = $variables['element']; // This is also used in the installer, pre-database setup. $t = get_t(); // If title and required marker are both empty, output no label. if ((!isset($element['#title']) || $element['#title'] === '') && empty($element['#required'])) { return ''; } // If the element is required, a required marker is appended to the label. $required = !empty($element['#required']) ? theme('form_required_marker', array('element' => $element)) : ''; $title = filter_xss_admin($element['#title']); $attributes = array(); // Style the label as class option to display inline with the element. if ($element['#title_display'] == 'after') { $attributes['class'] = 'option'; } elseif ($element['#title_display'] == 'invisible') { $attributes['class'] = 'element-invisible'; } if (!empty($element['#id'])) { $attributes['for'] = $element['#id']; } $help = ''; if ($element['#type'] == 'checkbox' && $element['#entity_type'] == 'entityform') { $help = $element['#checkbox_suffix']; } // The leading whitespace helps visually separate fields from inline labels. return ' <label' . drupal_attributes($attributes) . '>' . $t('!title !required', array('!title' => $title, '!required' => $required)) . $help . "</label>\n"; }
/** * Overrides theme_form_required_marker(). */ function europa_form_required_marker($variables) { // This is also used in the installer, pre-database setup. $t = get_t(); $attributes = array('class' => 'form-required text-danger glyphicon glyphicon-asterisk', 'title' => $t('This field is required.')); return '<span' . drupal_attributes($attributes) . '></span>'; }
/** * Check installation requirements and do status reporting. * * This hook has two closely related uses, determined by the $phase argument: * checking installation requirements ($phase == 'install') * and status reporting ($phase == 'runtime'). * * Note that this hook, like all others dealing with installation and updates, * must reside in a module_name.install file, or it will not properly abort * the installation of the module if a critical requirement is missing. * * During the 'install' phase, modules can for example assert that * library or server versions are available or sufficient. * Note that the installation of a module can happen during installation of * Drupal itself (by install.php) with an installation profile or later by hand. * As a consequence, install-time requirements must be checked without access * to the full Drupal API, because it is not available during install.php. * For localisation you should for example use $t = get_t() to * retrieve the appropriate localisation function name (t() or st()). * If a requirement has a severity of REQUIREMENT_ERROR, install.php will abort * or at least the module will not install. * Other severity levels have no effect on the installation. * Module dependencies do not belong to these installation requirements, * but should be defined in the module's .info file. * * The 'runtime' phase is not limited to pure installation requirements * but can also be used for more general status information like maintenance * tasks and security issues. * The returned 'requirements' will be listed on the status report in the * administration section, with indication of the severity level. * Moreover, any requirement with a severity of REQUIREMENT_ERROR severity will * result in a notice on the the administration overview page. * * @param $phase * The phase in which hook_requirements is run: * - 'install': the module is being installed. * - 'runtime': the runtime requirements are being checked and shown on the * status report page. * * @return * A keyed array of requirements. Each requirement is itself an array with * the following items: * - 'title': the name of the requirement. * - 'value': the current value (e.g. version, time, level, ...). During * install phase, this should only be used for version numbers, do not set * it if not applicable. * - 'description': description of the requirement/status. * - 'severity': the requirement's result/severity level, one of: * - REQUIREMENT_INFO: For info only. * - REQUIREMENT_OK: The requirement is satisfied. * - REQUIREMENT_WARNING: The requirement failed with a warning. * - REQUIREMENT_ERROR: The requirement failed with an error. */ function hook_requirements($phase) { $requirements = array(); // Ensure translations don't break at install time $t = get_t(); // Report Drupal version if ($phase == 'runtime') { $requirements['drupal'] = array('title' => $t('Drupal'), 'value' => VERSION, 'severity' => REQUIREMENT_INFO); } // Test PHP version $requirements['php'] = array('title' => $t('PHP'), 'value' => $phase == 'runtime' ? l(phpversion(), 'admin/logs/status/php') : phpversion()); if (version_compare(phpversion(), DRUPAL_MINIMUM_PHP) < 0) { $requirements['php']['description'] = $t('Your PHP installation is too old. Drupal requires at least PHP %version.', array('%version' => DRUPAL_MINIMUM_PHP)); $requirements['php']['severity'] = REQUIREMENT_ERROR; } // Report cron status if ($phase == 'runtime') { $cron_last = variable_get('cron_last', NULL); if (is_numeric($cron_last)) { $requirements['cron']['value'] = $t('Last run !time ago', array('!time' => format_interval(time() - $cron_last))); } else { $requirements['cron'] = array('description' => $t('Cron has not run. It appears cron jobs have not been setup on your system. Please check the help pages for <a href="@url">configuring cron jobs</a>.', array('@url' => 'http://drupal.org/cron')), 'severity' => REQUIREMENT_ERROR, 'value' => $t('Never run')); } $requirements['cron']['description'] .= ' ' . t('You can <a href="@cron">run cron manually</a>.', array('@cron' => url('admin/logs/status/run-cron'))); $requirements['cron']['title'] = $t('Cron maintenance tasks'); } return $requirements; }
/** * Overrides theme_form_element_label(). */ function bootstrap_psdpt_form_element_label(&$variables) { $element = $variables['element']; // This is also used in the installer, pre-database setup. $t = get_t(); // Determine if certain things should skip for checkbox or radio elements. $skip = isset($element['#type']) && ('checkbox' === $element['#type'] || 'radio' === $element['#type']); // If title and required marker are both empty, output no label. if ((!isset($element['#title']) || $element['#title'] === '' && !$skip) && empty($element['#required'])) { return ''; } // If the element is required, a required marker is appended to the label. $required = !empty($element['#required']) ? theme('form_required_marker', array('element' => $element)) : ''; $title = filter_xss_admin($element['#title']); $attributes = array(); // Style the label as class option to display inline with the element. if ($element['#title_display'] == 'after' && !$skip) { $attributes['class'][] = $element['#type']; } elseif ($element['#title_display'] == 'invisible') { $attributes['class'][] = 'element-invisible'; } if (!empty($element['#id'])) { $attributes['for'] = $element['#id']; } // Insert radio and checkboxes inside label elements. $output = ''; if (isset($variables['#children'])) { $output .= $variables['#children']; } // Append label. $output .= $t('!title !required', array('!title' => $title, '!required' => $required)); // The leading whitespace helps visually separate fields from inline labels. return ' <label' . drupal_attributes($attributes) . '>' . $output . "</label>\n"; }
public function __construct() { // Beeptify values $this->id = 'beeptify'; $this->method_title = 'Beeptify'; $this->icon = WP_PLUGIN_URL . "/" . plugin_basename(dirname(__FILE__)) . '/images/logo.png'; $this->has_fields = false; $this->liveurl = 'https://my.beeptify.com/payment?registered=False'; // Load the form fields $this->init_form_fields(); // Load the settings. $this->init_settings(); // Define user set variables $this->title = $this->settings['title']; $this->description = $this->settings['description']; $this->merchant_id = $this->settings['merchant_id']; $this->pay_language = $this->settings['pay_language']; $this->mode = $this->settings['mode']; $this->frame = $this->settings['frame']; $this->secret = $this->settings['secret']; $this->testmode = $this->settings['testmode']; if (empty($this->pay_language)) { $this->pay_language = 'en-GB.php'; } // Translations require_once 'lang/' . $this->pay_language . '.php'; $this->_t = get_t(); // Order btn text $this->order_button_text = $this->_t['pay_beeptify']; // Test mode values if ($this->yesnotoint($this->testmode)) { $this->liveurl = 'https://stage.beeptify.com/payment'; } // Logs $this->log = new WC_Logger(); // Actions // Add check for callback add_action('init', array(&$this, 'check_callback')); // Check for successful callback add_action('valid_beeptify_callback', array(&$this, 'successful_request')); add_action('woocommerce_api_wc_payment_gateway_beeptify', array($this, 'check_callback')); // Add our admin options add_action('woocommerce_update_options_payment_gateways', array(&$this, 'process_admin_options')); add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); // Hook in to reciept add_action('woocommerce_receipt_beeptify', array($this, 'receipt')); // Hook in to thank you add_action('woocommerce_thankyou_beeptify', array($this, 'thankyou')); // Test if costumer can use plugin, eg lang if (!$this->is_valid_for_use()) { $this->enabled = false; } }
/** * Implements hook_requirements(). */ function ding_wayf_dk_login_requirements($phase) { $requirements = array(); // Ensure translations don't break at install time. $t = get_t(); if ($phase == 'runtime') { if (!variable_get('wayf_hash', FALSE)) { $requirements['wayf_hash'] = array('value' => $t('WAYF not configured correctly'), 'description' => $t('WAYF is not properly configured, you need to set $conf[\'wayf_hash\'] in setttings.php.'), 'severity' => REQUIREMENT_ERROR); } } return $requirements; }
/** * Overriding theme_form_element(). */ function form_fun_form_element($element, $value) { // This is also used in the installer, pre-database setup. $t = get_t(); $attributes = array(); // Add drupal defaults if (!empty($element['#id'])) { $attributes['id'] = $element['#id'] . '-wrapper'; } $attributes['class'][] = 'form-item'; // Add a class indicating if a label isn't inside this element. // (Not sure if I'm keeping this or not) if (empty($element['#title'])) { $attributes['class'][] = 'form-item-no-label'; } // Add a clearfix classes on most elements, might add some more here. $inline = array('radio', 'checkbox'); if (!in_array($element['#type'], $inline)) { $attributes['class'][] = 'clearfix'; } // Flatten the attributes for output. $attributes = theme('render_attributes', $attributes); // Form required marker $required = !empty($element['#required']) ? '<span class="form-required" title="' . $t('This field is required.') . '">*</span>' : ''; // Label if (!empty($element['#title'])) { $title = $element['#title']; if (!empty($element['#id'])) { $label = '<label for="' . $element['#id'] . '">' . $t('!title !required', array('!title' => filter_xss_admin($title), '!required' => $required)) . '</label>' . "\n"; } else { $label = '<label>' . $t('!title !required', array('!title' => filter_xss_admin($title), '!required' => $required)) . '</label>' . "\n"; } } // Description if (!empty($element['#description'])) { $description = '<div class="description">' . $element['#description'] . '</div>' . "\n"; } // Prepare the output $output = "\n" . '<div' . $attributes . '>' . "\n"; // If there is no label, we can have less markup. Wrapper level class can handle positioning. if (!$label) { $output .= '<div class="inner">' . "\n" . $value . "\n" . $description . '</div>'; } else { $output .= $label . '<div class="right">' . "\n" . '<div class="inner">' . "\n" . $value . "\n" . $description . '</div>' . "\n" . '</div>' . "\n"; } $output .= '</div>' . "\n"; return $output; }
/** * Override of theme_form_element(). * Take a more sensitive/delineative approach toward theming form elements. */ function tao_form_element($element, $value) { $output = ''; // This is also used in the installer, pre-database setup. $t = get_t(); // Add a wrapper id $attr = array('class' => ''); $attr['id'] = !empty($element['#id']) ? "{$element['#id']}-wrapper" : NULL; // Type logic $label_attr = array(); $label_attr['for'] = !empty($element['#id']) ? $element['#id'] : ''; if (!empty($element['#type']) && in_array($element['#type'], array('checkbox', 'radio'))) { $label_type = 'label'; $attr['class'] .= ' form-item form-option'; } else { $label_type = 'label'; $attr['class'] .= ' form-item'; } // Generate required markup $required_title = $t('This field is required.'); $required = !empty($element['#required']) ? "<span class='form-required' title='{$required_title}'>*</span>" : ''; // Generate label markup if (!empty($element['#title'])) { $title = $t('!title: !required', array('!title' => filter_xss_admin($element['#title']), '!required' => $required)); $label_attr = drupal_attributes($label_attr); $output .= "<{$label_type} {$label_attr}>{$title}</{$label_type}>"; $attr['class'] .= ' form-item-labeled'; } // Add child values $output .= "{$value}"; // Description markup $output .= !empty($element['#description']) ? "<div class='description'>{$element['#description']}</div>" : ''; // Render the whole thing $attr = drupal_attributes($attr); $output = "<div {$attr}>{$output}</div>"; return $output; }
function townsquare_bootstrap_form_element($variables) { $element =& $variables['element']; // This is also used in the installer, pre-database setup. $t = get_t(); // This function is invoked as theme wrapper, but the rendered form element // may not necessarily have been processed by form_builder(). $element += array('#title_display' => 'before'); // Add element #id for #type 'item'. if (isset($element['#markup']) && !empty($element['#id'])) { $attributes['id'] = $element['#id']; } // Add element's #type and #name as class to aid with JS/CSS selectors. $attributes['class'] = array('form-item'); if (!empty($element['#type'])) { $attributes['class'][] = 'form-type-' . strtr($element['#type'], '_', '-'); } if (!empty($element['#name'])) { $attributes['class'][] = 'form-item-' . strtr($element['#name'], array(' ' => '-', '_' => '-', '[' => '-', ']' => '')); } // Add a class for disabled elements to facilitate cross-browser styling. if (!empty($element['#attributes']['disabled'])) { $attributes['class'][] = 'form-disabled'; } $attributes['class'][] = 'control-group'; $output = '<div' . drupal_attributes($attributes) . '>' . "\n"; // If #title is not set, we don't display any label or required marker. if (!isset($element['#title'])) { $element['#title_display'] = 'none'; } $prefix = '<div class="controls">'; $prefix .= isset($element['#field_prefix']) ? '<span class="field-prefix">' . $element['#field_prefix'] . '</span> ' : ''; $suffix = isset($element['#field_suffix']) ? ' <span class="field-suffix">' . $element['#field_suffix'] . '</span>' : ''; $suffix .= '</div>'; switch ($element['#title_display']) { case 'before': case 'invisible': $output .= ' ' . theme('form_element_label', $variables); $output .= ' ' . $prefix . $element['#children'] . $suffix . "\n"; break; case 'after': $output .= ' ' . $prefix . $element['#children'] . $suffix; $output .= ' ' . theme('form_element_label', $variables) . "\n"; break; case 'none': case 'attribute': // Output no label and no required marker, only the children. $output .= ' ' . $prefix . $element['#children'] . $suffix . "\n"; break; } $output .= "</div>\n"; return $output; }
/** * Overrides theme_form_element_label(). */ function teamwork_15_subtheme_form_element_label(&$variables) { $element = $variables['element']; $title = filter_xss_admin($element['#title']); // If the element is required, a required marker is appended to the label. $required = !empty($element['#required']) ? theme('form_required_marker', array('element' => $element)) : ''; // // This is also used in the installer, pre-database setup. $t = get_t(); $attributes = array(); if (!empty($element['#id'])) { $attributes['for'] = $element['#id']; } $output = ''; if (isset($variables['#children'])) { if ($element['#type'] === "radio") { $output .= $variables['#children']; } if ($element['#type'] === "checkbox") { $output .= $variables['#children']; } } return ' <label' . backdrop_attributes($attributes) . '></label><div>' . $t('!title', array('!title' => $title)) . "</div> \n"; }
function mothership_checkbox($variables) { $element = $variables['element']; $t = get_t(); $element['#attributes']['type'] = 'checkbox'; element_set_attributes($element, array('id', 'name', '#return_value' => 'value')); // Unchecked checkbox has #value of integer 0. if (!empty($element['#checked'])) { $element['#attributes']['checked'] = 'checked'; } if (!theme_get_setting('mothership_classes_form_input')) { _form_set_class($element, array('form-checkbox')); } return '<input' . drupal_attributes($element['#attributes']) . ' />'; }
/** * Overwrite theme_form_element_label(). */ function bht_theme_form_element_label($variables) { $element = $variables['element']; // This is also used in the installer, pre-database setup. $t = get_t(); // If title and required marker are both empty, output no label. if ((!isset($element['#title']) || $element['#title'] === '') && empty($element['#required'])) { return ''; } $attributes = array(); // If the element is required, add a required class. if (!empty($element['#required'])) { $attributes['class'][] = 'required'; } // If it's invisble, add class. if ($element['#title_display'] == 'invisible') { $attributes['class'] = 'element-invisible'; } $title = filter_xss_admin($element['#title']); if (!empty($element['#id'])) { $attributes['for'] = $element['#id']; } // The leading whitespace helps visually separate fields from inline labels. return ' <label' . drupal_attributes($attributes) . '>' . $t('!title', array('!title' => $title)) . "</label>\n"; }
function opcaim_form_element_label($variables) { $element = $variables ['element']; // This is also used in the installer, pre-database setup. $t = get_t(); // If title and required marker are both empty, output no label. if ((!isset($element ['#title']) || $element ['#title'] === '') && empty($element ['#required'])) { return ''; } // If the element is required, a required marker is appended to the label. $required = !empty($element ['#required']) ? theme('form_required_marker', array('element' => $element)) : ''; $title = filter_xss_admin($element ['#title']); $attributes = array(); // Style the label as class option to display inline with the element. if ($element ['#title_display'] == 'after') { $attributes ['class'] = 'option'; } // Show label only to screen readers to avoid disruption in visual flows. elseif ($element ['#title_display'] == 'invisible') { $attributes ['class'] = 'element-invisible'; } if (!empty($element ['#id'])) { $attributes ['for'] = $element ['#id']; } // Ajout d'un trim dans les balises label // The leading whitespace helps visually separate fields from inline labels. return ' <label' . drupal_attributes($attributes) . '>' . trim($t('!title !required', array('!title' => $title, '!required' => $required))) . "</label>\n"; }
function phptemplate_form_element($element, $value) { if (empty($element['#comments_element'])) { return theme_form_element($element, $value); } else { $t = get_t(); $output = '<div class="form-item container-inline comments-element"'; if (!empty($element['#id'])) { $output .= ' id="' . $element['#id'] . '-wrapper"'; } $output .= ">\n"; $output .= " {$value}\n"; $required = !empty($element['#required']) ? '<span class="form-required" title="' . $t('This field is required.') . '">(' . $t('required') . ')</span>' : ''; if (!empty($element['#title'])) { $title = $element['#title']; if (!empty($element['#id'])) { $output .= ' <label for="' . $element['#id'] . '"><small>' . $t('!title !required', array('!title' => filter_xss_admin($title), '!required' => $required)) . "</small></label>\n"; } else { $output .= ' <label><small>' . $t('!title !required', array('!title' => filter_xss_admin($title), '!required' => $required)) . "</small></label>\n"; } } if (!empty($element['#description'])) { $output .= ' <div class="description">' . $element['#description'] . "</div>\n"; } $output .= "</div>\n"; return $output; } }
function realia_form_element($variables) { $element =& $variables['element']; // This function is invoked as theme wrapper, but the rendered form element // may not necessarily have been processed by form_builder(). $element += array('#title_display' => 'before'); // Add element #id for #type 'item'. if (isset($element['#markup']) && !empty($element['#id'])) { $attributes['id'] = $element['#id']; } // Add element's #type and #name as class to aid with JS/CSS selectors. $attributes['class'] = array('form-item'); if (!empty($element['#type'])) { $attributes['class'][] = 'form-type-' . strtr($element['#type'], '_', '-'); } if (!empty($element['#name'])) { $attributes['class'][] = 'form-item-' . strtr($element['#name'], array(' ' => '-', '_' => '-', '[' => '-', ']' => '')); } // Add a class for disabled elements to facilitate cross-browser styling. if (!empty($element['#attributes']['disabled'])) { $attributes['class'][] = 'form-disabled'; } $label = TRUE; if ($element['#type'] == 'radio') { $styles = realia_aviators_collect_styles(); if (in_array($element['#array_parents'][0], array_keys($styles))) { $label = FALSE; if (isset($element['#return_value'])) { $attributes['class'][] = str_replace('_', '-', $element['#return_value']); } } } if (!$label) { $element_output = '<div' . drupal_attributes($attributes) . '>'; } else { $output = '<div' . drupal_attributes($attributes) . '>' . "\n"; } if ($element['#type'] == 'radio') { if (!$label) { $element = $variables['element']; // This is also used in the installer, pre-database setup. $t = get_t(); // If the element is required, a required marker is appended to the label. $required = !empty($element['#required']) ? theme('form_required_marker', array('element' => $element)) : ''; $title = filter_xss_admin($element['#title']); $attributes = array(); // Style the label as class option to display inline with the element. if ($element['#title_display'] == 'after') { $attributes['class'] = 'option'; } elseif ($element['#title_display'] == 'invisible') { $attributes['class'] = 'element-invisible'; } if (!empty($element['#id'])) { $attributes['for'] = $element['#id']; } // The leading whitespace helps visually separate fields from inline labels. $output = $element_output . '<label' . drupal_attributes($attributes) . '>' . $element['#children'] . $t('!title !required', array('!title' => $title, '!required' => $required)) . "</label>"; if (!empty($element['#description'])) { $output .= '<div class="description">' . $element['#description'] . "</div>\n"; } $output .= "</div>\n"; } } // If #title is not set, we don't display any label or required marker. if (!isset($element['#title'])) { $element['#title_display'] = 'none'; } $prefix = isset($element['#field_prefix']) ? '<span class="field-prefix">' . $element['#field_prefix'] . '</span> ' : ''; $suffix = isset($element['#field_suffix']) ? ' <span class="field-suffix">' . $element['#field_suffix'] . '</span>' : ''; if ($label) { switch ($element['#title_display']) { case 'before': case 'invisible': $output .= ' ' . theme('form_element_label', $variables); $output .= ' ' . $prefix . $element['#children'] . $suffix . "\n"; break; case 'after': $output .= ' ' . $prefix . $element['#children'] . $suffix; $output .= ' ' . theme('form_element_label', $variables) . "\n"; break; case 'none': case 'attribute': // Output no label and no required marker, only the children. $output .= ' ' . $prefix . $element['#children'] . $suffix . "\n"; break; } } if ($label) { if (!empty($element['#description'])) { $output .= '<div class="description">' . $element['#description'] . "</div>\n"; } $output .= "</div>\n"; } return $output; }
/** * Implementation of preprocess_form_element(). * Take a more sensitive/delineative approach toward theming form elements. */ function tao_preprocess_form_element(&$vars) { $element = $vars['element']; // Main item attributes. $vars['attr'] = array(); $vars['attr']['class'] = 'form-item'; $vars['attr']['id'] = !empty($element['#id']) ? "{$element['#id']}-wrapper" : NULL; if (!empty($element['#type']) && in_array($element['#type'], array('checkbox', 'radio'))) { $vars['attr']['class'] .= ' form-option'; } $vars['description'] = isset($element['#description']) ? $element['#description'] : ''; // Generate label markup if (!empty($element['#title'])) { $t = get_t(); $required_title = $t('This field is required.'); $required = !empty($element['#required']) ? "<span class='form-required' title='{$required_title}'>*</span>" : ''; $vars['label_title'] = $t('!title: !required', array('!title' => filter_xss_admin($element['#title']), '!required' => $required)); $vars['label_attr'] = array(); if (!empty($element['#id'])) { $vars['label_attr']['for'] = $element['#id']; } // Indicate that this form item is labeled $vars['attr']['class'] .= ' form-item-labeled'; } }
/** * Override theme_form_element_label() to support #attributes on label form elements. */ function bc_theme_form_element_label($variables) { $element = $variables['element']; // This is also used in the installer, pre-database setup. $t = get_t(); // If title and required marker are both empty, output no label. if ((!isset($element['#title']) || $element['#title'] === '') && empty($element['#required'])) { return ''; } // If the element is required, a required marker is appended to the label. $required = !empty($element['#required']) ? theme('form_required_marker', array('element' => $element)) : ''; $title = filter_xss_admin($element['#title']); // If there are attributes already, use them. If not, create empty array. $attributes = isset($element['#label_attributes']) ? $element['#label_attributes'] : array(); $attributes['title'] = isset($element['#description']) ? strip_tags($element['#description']) : strip_tags($element['#title']); // Add required to tooltip. if (isset($element['#required']) and $element['#required']) { $attributes['title'] .= ' ' . t('(required)'); } $attributes['data-toggle'] = 'tooltip'; $attributes['data-placement'] = 'auto left'; // Style the label as class option to display inline with the element. if ($element['#title_display'] == 'after') { $attributes['class'] = 'option'; } elseif ($element['#title_display'] == 'invisible') { $attributes['class'] = 'element-invisible'; } if (!empty($element['#id'])) { $attributes['for'] = $element['#id']; } // The leading whitespace helps visually separate fields from inline labels. return ' <label' . drupal_attributes($attributes) . '>' . $t('!title !required', array('!title' => $title, '!required' => $required)) . "</label>\n"; }
/** * Theme override for theme_form_required_marker(). */ function codedotorg_form_required_marker($variables) { // This is also used in the installer, pre-database setup. $t = get_t(); $attributes = array('class' => 'form-required', 'title' => $t('This field is required.')); /* CUSTOMIZATION FOR CODE.ORG */ return '<span' . drupal_attributes($attributes) . '>(Required)</span>'; /* END CUSTOMIZATION FOR CODE.ORG */ }
/** * Overriding HTML for a marker for required form elements. * * @param $variables * An associative array containing: * - element: An associative array containing the properties of the element. * * @ingroup themeable */ function glossy_form_required_marker($variables) { // This is also used in the installer, pre-database setup. $t = get_t(); $attributes = array( 'class' => 'form-required', 'title' => $t('This field is required.'), ); return '*'; }
function blendedmalts_form_element($element, $value) { // This is also used in the installer, pre-database setup. $t = get_t(); $output = '<div class="form-item"'; if (!empty($element['#id'])) { $output .= ' id="' . $element['#id'] . '-wrapper"'; } $output .= ">\n"; $required = !empty($element['#required']) ? '<span class="form-required" title="' . $t('This field is required.') . '">*</span>' : ''; global $base_url; // $help = !empty($element['#attributes']['wisski_help']) ? '<span class="form-wisski-tooltip"><img src="' . $base_url . '/' . path_to_theme() . '/pics/help_small.png" alt="?" width="15px"/><em>' . $t($element['#attributes']['wisski_help']) . '</em></span>' : ''; $help = !empty($element['#attributes']['wisski_help']) ? '<span class="form-wisski-tooltip">?<em>' . $t($element['#attributes']['wisski_help']) . '</em></span>' : ''; if (!empty($element['#title'])) { $title = $element['#title']; if (!empty($element['#id'])) { $output .= ' <label for="' . $element['#id'] . '">' . $t('!title: !required !help', array('!title' => filter_xss_admin($title), '!required' => $required, '!help' => $help)) . "</label>\n"; } else { $output .= ' <label>' . $t('!title: !required !help', array('!title' => filter_xss_admin($title), '!required' => $required, '!help' => $help)) . "</label>\n"; } } $output .= " {$value}\n"; if (!empty($element['#description'])) { $output .= ' <div class="description">' . $element['#description'] . "</div>\n"; } $output .= "</div>\n"; return $output; }
function neb_checkbox($variables) { $element = $variables['element']; $t = get_t(); $element['#attributes']['type'] = 'checkbox'; element_set_attributes($element, array('id', 'name', '#return_value' => 'value')); // Unchecked checkbox has #value of integer 0. if (!empty($element['#checked'])) { $element['#attributes']['checked'] = 'checked'; } return '<input' . drupal_attributes($element['#attributes']) . ' />'; }
/** * Implements theme_form_required_marker(). */ function govcms_zen_form_required_marker($variables) { // This is also used in the installer, pre-database setup. $t_function = get_t(); $attributes = array('class' => 'form-required', 'title' => $t_function('This field is required.')); return '<span' . drupal_attributes($attributes) . '>(' . $t_function('mandatory') . ')</span>'; }
function bbcom_theme_form_element($element, $value) { // This is also used in the installer, pre-database setup. $t = get_t(); // DRS: my changes here $output = '<div class="form-item ' . (isset($element['#inline']) && $element['#inline'] ? 'inline-form-item' : 'block-form-item') . '"'; // DRS: Pretty much original from here on in if (!empty($element['#id'])) { $output .= ' id="' . $element['#id'] . '-wrapper"'; } $output .= ">\n"; $required = !empty($element['#required']) ? '<span class="form-required" title="' . $t('This field is required.') . '">*</span>' : ''; if (!empty($element['#title'])) { $title = $element['#title']; if (!empty($element['#id'])) { $output .= ' <label for="' . $element['#id'] . '">' . $t('!title: !required', array('!title' => filter_xss_admin($title), '!required' => $required)) . "</label>\n"; } else { $output .= ' <label>' . $t('!title: !required', array('!title' => filter_xss_admin($title), '!required' => $required)) . "</label>\n"; } } $output .= " {$value}\n"; if (!empty($element['#description'])) { $output .= ' <div class="description">' . $element['#description'] . "</div>\n"; } $output .= "</div>\n"; return $output; }
function _os_poker_country_options() { $countries_list = array_map(get_t(), countries_api_get_array('iso2', 'printable_name')); uasort($countries_list, "strnatcmp"); $head = array(NULL => '--', 'DE' => $countries_list['DE'], 'AT' => $countries_list['AT'], 'CH' => $countries_list['CH'], '00' => '----'); foreach (array_keys($head) as $code) { unset($countries_list[$code]); } return array_merge($head, $countries_list); }
<?php // This is also used in the installer, pre-database setup. $t = get_t(); $attributes = array('class' => 'text-danger', 'title' => $t('This field is required.')); print '<span' . drupal_attributes($attributes) . '>*</span>';