Ansel::getStyleSelect PHP Method

getStyleSelect() public static method

Build a HTML element.
    public static function getStyleSelect($element_name, $selected = '')
    {
        $styles = $GLOBALS['injector']->getInstance('Ansel_Styles');
        // Build the available styles, but don't show hidden styles
        foreach ($styles as $key => $style) {
            if (empty($style['hide'])) {
                $options[$key] = $style['title'];
            }
        }
        // Nothing explicitly selected, use the global pref
        if ($selected == '') {
            $selected = $GLOBALS['prefs']->getValue('default_gallerystyle');
        }
        $html = '<select id="' . $element_name . '" name="' . $element_name . '">';
        foreach ($options as $key => $option) {
            $html .= '  <option value="' . $key . '"' . ($selected == $key ? 'selected="selected"' : '') . '>' . $option . '</option>';
        }
        return $html .= '</select>';
    }

Usage Example

Example #1
0
 /**
  */
 public function display(Horde_Core_Prefs_Ui $ui)
 {
     return _("Default style for galleries") . Ansel::getStyleSelect('default_gallerystyle_select', $GLOBALS['prefs']->getValue('default_gallerystyle')) . '<br />';
 }