/admincrud/extensions/bootstrap/helpers/TbHtml.php
PHP | 4080 lines | 2184 code | 316 blank | 1580 comment | 162 complexity | c7c17d9238ae7d340c9015e511d1ea0d MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause
Large files files are truncated, but you can click here to view the full file
- <?php
- /**
- * TbHtml class file.
- * @author Antonio Ramirez <ramirez.cobos@gmail.com>
- * @author Christoffer Niska <christoffer.niska@gmail.com>
- * @copyright Copyright © Christoffer Niska 2013-
- * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
- * @package bootstrap.helpers
- */
- /**
- * Bootstrap HTML helper.
- */
- class TbHtml extends CHtml // required in order to access the protected methods in CHtml
- {
- //
- // TYPOGRAPHY
- // --------------------------------------------------
- const TEXT_ALIGN_LEFT = 'left';
- const TEXT_ALIGN_CENTER = 'center';
- const TEXT_ALIGN_RIGHT = 'right';
- const TEXT_COLOR_DEFAULT = '';
- const TEXT_COLOR_WARNING = 'warning';
- const TEXT_COLOR_ERROR = 'error';
- const TEXT_COLOR_INFO = 'info';
- const TEXT_COLOR_SUCCESS = 'success';
- const HELP_TYPE_INLINE = 'inline';
- const HELP_TYPE_BLOCK = 'block';
- //
- // FORM
- // --------------------------------------------------
- const FORM_LAYOUT_VERTICAL = 'vertical';
- const FORM_LAYOUT_HORIZONTAL = 'horizontal';
- const FORM_LAYOUT_INLINE = 'inline';
- const FORM_LAYOUT_SEARCH = 'search';
- const INPUT_TYPE_TEXT = 'textField';
- const INPUT_TYPE_PASSWORD = 'passwordField';
- const INPUT_TYPE_URL = 'urlField';
- const INPUT_TYPE_EMAIL = 'emailField';
- const INPUT_TYPE_NUMBER = 'numberField';
- const INPUT_TYPE_RANGE = 'rangeField';
- const INPUT_TYPE_DATE = 'dateField';
- const INPUT_TYPE_TEXTAREA = 'textArea';
- const INPUT_TYPE_FILE = 'fileField';
- const INPUT_TYPE_RADIOBUTTON = 'radioButton';
- const INPUT_TYPE_CHECKBOX = 'checkBox';
- const INPUT_TYPE_DROPDOWNLIST = 'dropDownList';
- const INPUT_TYPE_LISTBOX = 'listBox';
- const INPUT_TYPE_CHECKBOXLIST = 'checkBoxList';
- const INPUT_TYPE_INLINECHECKBOXLIST = 'inlineCheckBoxList';
- const INPUT_TYPE_RADIOBUTTONLIST = 'radioButtonList';
- const INPUT_TYPE_INLINERADIOBUTTONLIST = 'inlineRadioButtonList';
- const INPUT_TYPE_UNEDITABLE = 'uneditableField';
- const INPUT_TYPE_SEARCH = 'searchQuery';
- const INPUT_SIZE_MINI = 'mini';
- const INPUT_SIZE_SMALL = 'small';
- const INPUT_SIZE_DEFAULT = '';
- const INPUT_SIZE_MEDIUM = 'medium';
- const INPUT_SIZE_LARGE = 'large';
- const INPUT_SIZE_XLARGE = 'xlarge';
- const INPUT_SIZE_XXLARGE = 'xxlarge';
- const INPUT_COLOR_DEFAULT = '';
- const INPUT_COLOR_WARNING = 'warning';
- const INPUT_COLOR_ERROR = 'error';
- const INPUT_COLOR_INFO = 'info';
- const INPUT_COLOR_SUCCESS = 'success';
- //
- // BUTTONS
- // --------------------------------------------------
- const BUTTON_TYPE_LINK = 'link';
- const BUTTON_TYPE_HTML = 'htmlButton';
- const BUTTON_TYPE_SUBMIT = 'submitButton';
- const BUTTON_TYPE_RESET = 'resetButton';
- const BUTTON_TYPE_IMAGE = 'imageButton';
- const BUTTON_TYPE_LINKBUTTON = 'linkButton';
- const BUTTON_TYPE_AJAXLINK = 'ajaxLink';
- const BUTTON_TYPE_AJAXBUTTON = 'ajaxButton';
- const BUTTON_TYPE_INPUTBUTTON = 'inputButton';
- const BUTTON_TYPE_INPUTSUBMIT = 'inputSubmit';
- const BUTTON_COLOR_DEFAULT = '';
- const BUTTON_COLOR_PRIMARY = 'primary';
- const BUTTON_COLOR_INFO = 'info';
- const BUTTON_COLOR_SUCCESS = 'success';
- const BUTTON_COLOR_WARNING = 'warning';
- const BUTTON_COLOR_DANGER = 'danger';
- const BUTTON_COLOR_INVERSE = 'inverse';
- const BUTTON_COLOR_LINK = 'link';
- const BUTTON_SIZE_MINI = 'mini';
- const BUTTON_SIZE_SMALL = 'small';
- const BUTTON_SIZE_DEFAULT = '';
- const BUTTON_SIZE_LARGE = 'large';
- const BUTTON_TOGGLE_CHECKBOX = 'checkbox';
- const BUTTON_TOGGLE_RADIO = 'radio';
- //
- // IMAGES
- // --------------------------------------------------
- const IMAGE_TYPE_ROUNDED = 'rounded';
- const IMAGE_TYPE_CIRCLE = 'circle';
- const IMAGE_TYPE_POLAROID = 'polaroid';
- //
- // NAV
- // --------------------------------------------------
- const NAV_TYPE_NONE = '';
- const NAV_TYPE_TABS = 'tabs';
- const NAV_TYPE_PILLS = 'pills';
- const NAV_TYPE_LIST = 'list';
- const TABS_PLACEMENT_ABOVE = '';
- const TABS_PLACEMENT_BELOW = 'below';
- const TABS_PLACEMENT_LEFT = 'left';
- const TABS_PLACEMENT_RIGHT = 'right';
- //
- // NAVBAR
- // --------------------------------------------------
- const NAVBAR_DISPLAY_NONE = '';
- const NAVBAR_DISPLAY_FIXEDTOP = 'fixed-top';
- const NAVBAR_DISPLAY_FIXEDBOTTOM = 'fixed-bottom';
- const NAVBAR_DISPLAY_STATICTOP = 'static-top';
- const NAVBAR_COLOR_INVERSE = 'inverse';
- //
- // PAGINATION
- // --------------------------------------------------
- const PAGINATION_SIZE_MINI = 'mini';
- const PAGINATION_SIZE_SMALL = 'small';
- const PAGINATION_SIZE_DEFAULT = '';
- const PAGINATION_SIZE_LARGE = 'large';
- const PAGINATION_ALIGN_LEFT = 'left';
- const PAGINATION_ALIGN_CENTER = 'centered';
- const PAGINATION_ALIGN_RIGHT = 'right';
- //
- // LABELS AND BADGES
- // --------------------------------------------------
- const LABEL_COLOR_DEFAULT = '';
- const LABEL_COLOR_SUCCESS = 'success';
- const LABEL_COLOR_WARNING = 'warning';
- const LABEL_COLOR_IMPORTANT = 'important';
- const LABEL_COLOR_INFO = 'info';
- const LABEL_COLOR_INVERSE = 'inverse';
- const BADGE_COLOR_DEFAULT = '';
- const BADGE_COLOR_SUCCESS = 'success';
- const BADGE_COLOR_WARNING = 'warning';
- const BADGE_COLOR_IMPORTANT = 'important';
- const BADGE_COLOR_INFO = 'info';
- const BADGE_COLOR_INVERSE = 'inverse';
- //
- // TOOLTIPS AND POPOVERS
- // --------------------------------------------------
- const TOOLTIP_PLACEMENT_TOP = 'top';
- const TOOLTIP_PLACEMENT_BOTTOM = 'bottom';
- const TOOLTIP_PLACEMENT_LEFT = 'left';
- const TOOLTIP_PLACEMENT_RIGHT = 'right';
- const TOOLTIP_TRIGGER_CLICK = 'click';
- const TOOLTIP_TRIGGER_HOVER = 'hover';
- const TOOLTIP_TRIGGER_FOCUS = 'focus';
- const TOOLTIP_TRIGGER_MANUAL = 'manual';
- const POPOVER_PLACEMENT_TOP = 'top';
- const POPOVER_PLACEMENT_BOTTOM = 'bottom';
- const POPOVER_PLACEMENT_LEFT = 'left';
- const POPOVER_PLACEMENT_RIGHT = 'right';
- const POPOVER_TRIGGER_CLICK = 'click';
- const POPOVER_TRIGGER_HOVER = 'hover';
- const POPOVER_TRIGGER_FOCUS = 'focus';
- const POPOVER_TRIGGER_MANUAL = 'manual';
- //
- // ALERT
- // --------------------------------------------------
- const ALERT_COLOR_DEFAULT = '';
- const ALERT_COLOR_INFO = 'info';
- const ALERT_COLOR_SUCCESS = 'success';
- const ALERT_COLOR_WARNING = 'warning';
- const ALERT_COLOR_ERROR = 'error';
- const ALERT_COLOR_DANGER = 'danger';
- //
- // PROGRESS BARS
- // --------------------------------------------------
- const PROGRESS_COLOR_DEFAULT = '';
- const PROGRESS_COLOR_INFO = 'info';
- const PROGRESS_COLOR_SUCCESS = 'success';
- const PROGRESS_COLOR_WARNING = 'warning';
- const PROGRESS_COLOR_DANGER = 'danger';
- //
- // MISC
- // --------------------------------------------------
- const WELL_SIZE_SMALL = 'small';
- const WELL_SIZE_DEFAULT = '';
- const WELL_SIZE_LARGE = 'large';
- const PULL_LEFT = 'left';
- const PULL_RIGHT = 'right';
- //
- // GRID VIEW
- // --------------------------------------------------
- const GRID_TYPE_STRIPED = 'striped';
- const GRID_TYPE_BORDERED = 'bordered';
- const GRID_TYPE_CONDENSED = 'condensed';
- const GRID_TYPE_HOVER = 'hover';
- //
- // AFFIX
- // --------------------------------------------------
- const AFFIX_POSITION_TOP = 'top';
- const AFFIX_POSITION_BOTTOM = 'bottom';
- //
- // ICON
- // --------------------------------------------------
- const ICON_GLASS = 'icon-glass';
- const ICON_MUSIC = 'icon-music';
- const ICON_SEARCH = 'icon-search';
- const ICON_ENVELOPE = 'icon-envelope';
- const ICON_HEART = 'icon-heart';
- const ICON_STAR = 'icon-star';
- const ICON_STAR_EMPTY = 'icon-star-empty';
- const ICON_USER = 'icon-user';
- const ICON_FILM = 'icon-film';
- const ICON_TH_LARGE = 'icon-th-large';
- const ICON_TH = 'icon-th';
- const ICON_TH_LIST = 'icon-th-list';
- const ICON_OK = 'icon-ok';
- const ICON_REMOVE = 'icon-remove';
- const ICON_ZOOM_IN = 'icon-zoom-in';
- const ICON_ZOOM_OUT = 'icon-zoom-out';
- const ICON_OFF = 'icon-off';
- const ICON_SIGNAL = 'icon-signal';
- const ICON_COG = 'icon-cog';
- const ICON_TRASH = 'icon-trash';
- const ICON_HOME = 'icon-home';
- const ICON_FILE = 'icon-file';
- const ICON_TIME = 'icon-time';
- const ICON_ROAD = 'icon-road';
- const ICON_DOWNLOAD_ALT = 'icon-download-alt';
- const ICON_DOWNLOAD = 'icon-download';
- const ICON_UPLOAD = 'icon-upload';
- const ICON_INBOX = 'icon-inbox';
- const ICON_PLAY_CIRCLE = 'icon-play-circle';
- const ICON_REPEAT = 'icon-repeat';
- const ICON_REFRESH = 'icon-refresh';
- const ICON_LIST_ALT = 'icon-list-alt';
- const ICON_LOCK = 'icon-lock';
- const ICON_FLAG = 'icon-flag';
- const ICON_HEADPHONES = 'icon-headphones';
- const ICON_VOLUME_OFF = 'icon-volume-off';
- const ICON_VOLUME_DOWN = 'icon-volume-down';
- const ICON_VOLUME_UP = 'icon-volume-up';
- const ICON_QRCODE = 'icon-qrcode';
- const ICON_BARCODE = 'icon-barcode';
- const ICON_TAG = 'icon-tag';
- const ICON_TAGS = 'icon-tags';
- const ICON_BOOK = 'icon-book';
- const ICON_BOOKMARK = 'icon-bookmark';
- const ICON_PRINT = 'icon-print';
- const ICON_CAMERA = 'icon-camera';
- const ICON_FONT = 'icon-font';
- const ICON_BOLD = 'icon-bold';
- const ICON_ITALIC = 'icon-italic';
- const ICON_TEXT_HEIGHT = 'icon-text-height';
- const ICON_TEXT_WIDTH = 'icon-text-width';
- const ICON_ALIGN_LEFT = 'icon-align-left';
- const ICON_ALIGN_CENTER = 'icon-align-center';
- const ICON_ALIGN_RIGHT = 'icon-align-right';
- const ICON_ALIGN_JUSTIFY = 'icon-align-justify';
- const ICON_LIST = 'icon-list';
- const ICON_INDENT_LEFT = 'icon-indent-left';
- const ICON_INDENT_RIGHT = 'icon-indent-right';
- const ICON_FACETIME_VIDEO = 'icon-facetime-video';
- const ICON_PICTURE = 'icon-picture';
- const ICON_PENCIL = 'icon-pencil';
- const ICON_MAP_MARKER = 'icon-map-marker';
- const ICON_ADJUST = 'icon-adjust';
- const ICON_TINT = 'icon-tint';
- const ICON_EDIT = 'icon-edit';
- const ICON_SHARE = 'icon-share';
- const ICON_CHECK = 'icon-check';
- const ICON_MOVE = 'icon-move';
- const ICON_STEP_BACKWARD = 'icon-step-backward';
- const ICON_FAST_BACKWARD = 'icon-fast-backward';
- const ICON_BACKWARD = 'icon-backward';
- const ICON_PLAY = 'icon-play';
- const ICON_PAUSE = 'icon-pause';
- const ICON_STOP = 'icon-pause';
- const ICON_FORWARD = 'icon-forward';
- const ICON_FAST_FORWARD = 'icon-fast-forward';
- const ICON_STEP_FORWARD = 'icon-step-forward';
- const ICON_EJECT = 'icon-eject';
- const ICON_CHEVRON_LEFT = 'icon-chevron-left';
- const ICON_CHEVRON_RIGHT = 'icon-chevron-right';
- const ICON_PLUS_SIGN = 'icon-plus-sign';
- const ICON_MINUS_SIGN = 'icon-minus-sign';
- const ICON_REMOVE_SIGN = 'icon-remove-sign';
- const ICON_OK_SIGN = 'icon-ok-sign';
- const ICON_QUESTION_SIGN = 'icon-question-sign';
- const ICON_INFO_SIGN = 'icon-info-sign';
- const ICON_SCREENSHOT = 'icon-screenshot';
- const ICON_REMOVE_CIRCLE = 'icon-remove-circle';
- const ICON_OK_CIRCLE = 'icon-ok-circle';
- const ICON_BAN_CIRCLE = 'icon-ban-circle';
- const ICON_ARROW_LEFT = 'icon-arrow-left';
- const ICON_ARROW_RIGHT = 'icon-arrow-right';
- const ICON_ARROW_UP = 'icon-arrow-up';
- const ICON_ARROW_DOWN = 'icon-arrow-down';
- const ICON_SHARE_ALT = 'icon-share-alt';
- const ICON_RESIZE_FULL = 'icon-resize-full';
- const ICON_RESIZE_SMALL = 'icon-resize-small';
- const ICON_PLUS = 'icon-plus';
- const ICON_MINUS = 'icon-minus';
- const ICON_ASTERISK = 'icon-asterisk';
- const ICON_EXCLAMATION_SIGN = 'icon-exclamation-sign';
- const ICON_GIFT = 'icon-gift';
- const ICON_LEAF = 'icon-leaf';
- const ICON_FIRE = 'icon-fire';
- const ICON_EYE_OPEN = 'icon-eye-open';
- const ICON_EYE_CLOSE = 'icon-eye-close';
- const ICON_WARNING_SIGN = 'icon-warning-sign';
- const ICON_PLANE = 'icon-plane';
- const ICON_CALENDAR = 'icon-calendar';
- const ICON_RANDOM = 'icon-random';
- const ICON_COMMENT = 'icon-comment';
- const ICON_MAGNET = 'icon-magnet';
- const ICON_CHEVRON_UP = 'icon-chevron-up';
- const ICON_CHEVRON_DOWN = 'icon-chevron-down';
- const ICON_RETWEET = 'icon-retweet';
- const ICON_SHOPPING_CART = 'icon-shopping-cart';
- const ICON_FOLDER_CLOSE = 'icon-folder-close';
- const ICON_FOLDER_OPEN = 'icon-folder-open';
- const ICON_RESIZE_VERTICAL = 'icon-resize-vertical';
- const ICON_RESIZE_HORIZONTAL = 'icon-resize-horizontal';
- const ICON_HDD = 'icon-hdd';
- const ICON_BULLHORN = 'icon-bullhorn';
- const ICON_BELL = 'icon-bell';
- const ICON_CERTFICATE = 'icon-certificate';
- const ICON_THUMBS_UP = 'icon-thumbs-up';
- const ICON_THUMBS_DOWN = 'icon-thumbs-down';
- const ICON_HAND_RIGHT = 'icon-hand-right';
- const ICON_HAND_LEFT = 'icon-hand-left';
- const ICON_HAND_UP = 'icon-hand-up';
- const ICON_HAND_DOWN = 'icon-hand-down';
- const ICON_CIRCLE_ARROW_RIGHT = 'icon-circle-arrow-right';
- const ICON_CIRCLE_ARROW_LEFT = 'icon-circle-arrow-left';
- const ICON_CIRCLE_ARROW_UP = 'icon-circle-arrow-up';
- const ICON_CIRCLE_ARROW_DOWN = 'icon-circle-arrow-down';
- const ICON_GLOBE = 'icon-globe';
- const ICON_WRENCH = 'icon-wrench';
- const ICON_TASKS = 'icon-tasks';
- const ICON_FILTER = 'icon-filter';
- const ICON_BRIEFCASE = 'icon-briefcase';
- const ICON_FULLSCREEN = 'icon-fullscreen';
- // Default close text.
- const CLOSE_TEXT = '×';
- //
- // BASE CSS
- // --------------------------------------------------
- // Typography
- // http://twitter.github.com/bootstrap/base-css.html#typography
- // --------------------------------------------------
- /**
- * Generates a paragraph that stands out.
- * @param string $text the lead text.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated paragraph.
- */
- public static function lead($text, $htmlOptions = array())
- {
- $htmlOptions = self::addClassName('lead', $htmlOptions);
- return self::tag('p', $htmlOptions, $text);
- }
- /**
- * Generates small text.
- * @param string $text the text to style.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated text.
- */
- public static function small($text, $htmlOptions = array())
- {
- return self::tag('small', $htmlOptions, $text);
- }
- /**
- * Generates bold text.
- * @param string $text the text to style.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated text.
- */
- public static function b($text, $htmlOptions = array())
- {
- return self::tag('strong', $htmlOptions, $text);
- }
- /**
- * Generates italic text.
- * @param string $text the text to style.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated text.
- */
- public static function i($text, $htmlOptions = array())
- {
- return self::tag('em', $htmlOptions, $text);
- }
- /**
- * Generates an emphasized text.
- * @param string $style the text style.
- * @param string $text the text to emphasize.
- * @param array $htmlOptions additional HTML attributes.
- * @param string $tag the HTML tag.
- * @return string the generated text.
- */
- public static function em($text, $htmlOptions = array(), $tag = 'p')
- {
- $color = self::popOption('color', $htmlOptions);
- if (self::popOption('muted', $htmlOptions, false))
- $htmlOptions = self::addClassName('muted', $htmlOptions);
- else if (!empty($color))
- $htmlOptions = self::addClassName('text-' . $color, $htmlOptions);
- return self::tag($tag, $htmlOptions, $text);
- }
- /**
- * Generates a muted text block.
- * @param string $text the text.
- * @param array $htmlOptions additional HTML attributes.
- * @param string $tag the HTML tag.
- * @return string the generated text block.
- */
- public static function muted($text, $htmlOptions = array(), $tag = 'p')
- {
- $htmlOptions['muted'] = true;
- return self::em($text, $htmlOptions, $tag);
- }
- /**
- * Generates a muted span.
- * @param string $text the text.
- * @param array $htmlOptions additional HTML attributes.
- * @param string $tag the HTML tag.
- * @return string the generated span.
- */
- public static function mutedSpan($text, $htmlOptions = array())
- {
- return self::muted($text, $htmlOptions, 'span');
- }
- /**
- * Generates an abbreviation with a help text.
- * @param string $text the abbreviation.
- * @param string $word the word the abbreviation is for.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated abbreviation.
- */
- public static function abbr($text, $word, $htmlOptions = array())
- {
- if (self::popOption('small', $htmlOptions, false))
- $htmlOptions = self::addClassName('initialism', $htmlOptions);
- $htmlOptions['title'] = $word;
- return self::tag('abbr', $htmlOptions, $text);
- }
- /**
- * Generates a small abbreviation with a help text.
- * @param string $text the abbreviation.
- * @param string $word the word the abbreviation is for.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated abbreviation.
- */
- public static function smallAbbr($text, $word, $htmlOptions = array())
- {
- $htmlOptions['small'] = true;
- return self::abbr($text, $word, $htmlOptions);
- }
- /**
- * Generates an address block.
- * @param string $quote the address text.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated block.
- */
- public static function address($text, $htmlOptions = array())
- {
- return self::tag('address', $htmlOptions, $text);
- }
- /**
- * Generates a quote.
- * @param string $text the quoted text.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated quote.
- */
- public static function quote($text, $htmlOptions = array())
- {
- $paragraphOptions = self::popOption('paragraphOptions', $htmlOptions, array());
- $source = self::popOption('source', $htmlOptions);
- $sourceOptions = self::popOption('sourceOptions', $htmlOptions, array());
- $cite = self::popOption('cite', $htmlOptions);
- $citeOptions = self::popOption('citeOptions', $htmlOptions, array());
- $cite = isset($cite) ? self::tag('cite', $citeOptions, $cite) : '';
- $source = isset($source) ? self::tag('small', $sourceOptions, $source . ' ' . $cite) : '';
- $text = self::tag('p', $paragraphOptions, $text) . $source;
- return self::tag('blockquote', $htmlOptions, $text);
- }
- /**
- * Generates a help text.
- * @param string $text the help text.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated text.
- */
- public static function help($text, $htmlOptions = array())
- {
- $htmlOptions = self::addClassName('help-inline', $htmlOptions);
- return self::tag('span', $htmlOptions, $text);
- }
- /**
- * Generates a help block.
- * @param string $text the help text.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated block.
- */
- public static function helpBlock($text, $htmlOptions = array())
- {
- $htmlOptions = self::addClassName('help-block', $htmlOptions);
- return self::tag('p', $htmlOptions, $text);
- }
- // Code
- // http://twitter.github.com/bootstrap/base-css.html#code
- // --------------------------------------------------
- /**
- * Generates inline code.
- * @param string $code the code.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated code.
- */
- public static function code($code, $htmlOptions = array())
- {
- return self::tag('code', $htmlOptions, $code);
- }
- /**
- * Generates a code block.
- * @param string $code the code.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated block.
- */
- public static function codeBlock($code, $htmlOptions = array())
- {
- return self::tag('pre', $htmlOptions, $code);
- }
- /**
- * Generates an HTML element.
- * @param string $tag the tag name.
- * @param array $htmlOptions the element attributes.
- * @param mixed $content the content to be enclosed between open and close element tags.
- * @param boolean $closeTag whether to generate the close tag.
- * @return string the generated HTML element tag.
- */
- public static function tag($tag, $htmlOptions = array(), $content = false, $closeTag = true)
- {
- $textAlign = self::popOption('textAlign', $htmlOptions);
- if (!empty($textAlign))
- $htmlOptions = self::addClassName('text-' . $textAlign, $htmlOptions);
- $pull = self::popOption('pull', $htmlOptions);
- if (!empty($pull))
- $htmlOptions = self::addClassName('pull-' . $pull, $htmlOptions);
- self::addSpanClass($htmlOptions);
- return CHtml::tag($tag, $htmlOptions, $content, $closeTag);
- }
- /**
- * Generates an open HTML element.
- * @param string $tag the tag name.
- * @param array $htmlOptions the element attributes.
- * @return string the generated HTML element tag.
- */
- public static function openTag($tag, $htmlOptions = array())
- {
- return self::tag($tag, $htmlOptions);
- }
- // Tables
- // http://twitter.github.com/bootstrap/base-css.html#forms
- // --------------------------------------------------
- // todo: create table methods here.
- // Forms
- // http://twitter.github.com/bootstrap/base-css.html#tables
- // --------------------------------------------------
- /**
- * Generates a form tag.
- * @param string $layout the form layout.
- * @param string $action the form action URL.
- * @param string $method form method (e.g. post, get).
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated tag.
- */
- public static function formTb($layout = self::FORM_LAYOUT_VERTICAL, $action = '', $method = 'post', $htmlOptions = array())
- {
- return self::beginFormTb($layout, $action, $method, $htmlOptions);
- }
- /**
- * Generates an open form tag.
- * @param string $layout the form layout.
- * @param string $action the form action URL.
- * @param string $method form method (e.g. post, get).
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated tag.
- */
- public static function beginFormTb($layout = self::FORM_LAYOUT_VERTICAL, $action = '', $method = 'post', $htmlOptions = array())
- {
- $htmlOptions = self::addClassName('form-' . $layout, $htmlOptions);
- return CHtml::beginForm($action, $method, $htmlOptions);
- }
- /**
- * Generates a stateful form tag.
- * @param mixed $action the form action URL.
- * @param string $method form method (e.g. post, get).
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated form tag.
- */
- public static function statefulFormTb($layout = self::FORM_LAYOUT_VERTICAL, $action = '', $method = 'post', $htmlOptions = array())
- {
- return self::formTb($layout, $action, $method, $htmlOptions)
- . self::tag('div', array('style' => 'display:none'), CHtml::pageStateField(''));
- }
- /**
- * Generates a text field input.
- * @param string $name the input name.
- * @param string $value the input value.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated input field.
- * @see TbHtml::textInputField
- */
- public static function textField($name, $value = '', $htmlOptions = array())
- {
- return self::textInputField('text', $name, $value, $htmlOptions);
- }
- /**
- * Generates a password field input.
- * @param string $name the input name.
- * @param string $value the input value.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated input field.
- * @see TbHtml::textInputField
- */
- public static function passwordField($name, $value = '', $htmlOptions = array())
- {
- return self::textInputField('password', $name, $value, $htmlOptions);
- }
- /**
- * Generates an url field input.
- * @param string $name the input name.
- * @param string $value the input value.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated input field.
- * @see TbHtml::textInputField
- */
- public static function urlField($name, $value = '', $htmlOptions = array())
- {
- return self::textInputField('url', $name, $value, $htmlOptions);
- }
- /**
- * Generates an email field input.
- * @param string $name the input name.
- * @param string $value the input value.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated input field.
- * @see TbHtml::textInputField
- */
- public static function emailField($name, $value = '', $htmlOptions = array())
- {
- return self::textInputField('email', $name, $value, $htmlOptions);
- }
- /**
- * Generates a number field input.
- * @param string $name the input name.
- * @param string $value the input value.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated input field.
- * @see TbHtml::textInputField
- */
- public static function numberField($name, $value = '', $htmlOptions = array())
- {
- return self::textInputField('number', $name, $value, $htmlOptions);
- }
- /**
- * Generates a range field input.
- * @param string $name the input name.
- * @param string $value the input value.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated input field.
- * @see TbHtml::textInputField
- */
- public static function rangeField($name, $value = '', $htmlOptions = array())
- {
- return self::textInputField('range', $name, $value, $htmlOptions);
- }
- /**
- * Generates a date field input.
- * @param string $name the input name.
- * @param string $value the input value.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated input field.
- * @see TbHtml::textInputField
- */
- public static function dateField($name, $value = '', $htmlOptions = array())
- {
- return self::textInputField('date', $name, $value, $htmlOptions);
- }
- /**
- * Generates a text area input.
- * @param string $name the input name.
- * @param string $value the input value.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated text area.
- */
- public static function textArea($name, $value = '', $htmlOptions = array())
- {
- $htmlOptions = self::normalizeInputOptions($htmlOptions);
- return CHtml::textArea($name, $value, $htmlOptions);
- }
- /**
- * Generates a radio button.
- * @param string $name the input name.
- * @param boolean $checked whether the radio button is checked.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated radio button.
- */
- public static function radioButton($name, $checked = false, $htmlOptions = array())
- {
- $label = self::popOption('label', $htmlOptions, false);
- $labelOptions = self::popOption('labelOptions', $htmlOptions, array());
- $labelOptions = self::addClassName('radio', $labelOptions);
- $radioButton = CHtml::radioButton($name, $checked, $htmlOptions);
- return $label !== false ? self::tag('label', $labelOptions, $radioButton . $label) : $radioButton;
- }
- /**
- * Generates a check box.
- * @param string $name the input name.
- * @param boolean $checked whether the check box is checked.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated check box.
- */
- public static function checkBox($name, $checked = false, $htmlOptions = array())
- {
- $label = self::popOption('label', $htmlOptions, false);
- $labelOptions = self::popOption('labelOptions', $htmlOptions, array());
- $labelOptions = self::addClassName('checkbox', $labelOptions);
- $checkBox = CHtml::checkBox($name, $checked, $htmlOptions);
- return $label !== false ? self::tag('label', $labelOptions, $checkBox . $label) : $checkBox;
- }
- /**
- * Generates a drop down list.
- * @param string $name the input name.
- * @param string $select the selected value.
- * @param array $data data for generating the list options (value=>display).
- * @return string the generated drop down list.
- */
- public static function dropDownList($name, $select, $data, $htmlOptions = array())
- {
- $htmlOptions = self::normalizeInputOptions($htmlOptions);
- return CHtml::dropDownList($name, $select, $data, $htmlOptions);
- }
- /**
- * Generates a list box.
- * @param string $name the input name.
- * @param mixed $select the selected value(s).
- * @param array $data data for generating the list options (value=>display).
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated list box
- */
- public static function listBox($name, $select, $data, $htmlOptions = array())
- {
- $htmlOptions = self::defaultOption('size', 4, $htmlOptions);
- if (isset($htmlOptions['multiple']))
- {
- if (substr($name, -2) !== '[]')
- $name .= '[]';
- }
- return self::dropDownList($name, $select, $data, $htmlOptions);
- }
- /**
- * Generates a radio button list.
- * @param string $name name of the radio button list.
- * @param mixed $select selection of the radio buttons.
- * @param array $data $data value-label pairs used to generate the radio button list.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated list.
- */
- public static function radioButtonList($name, $select, $data, $htmlOptions = array())
- {
- $inline = self::popOption('inline', $htmlOptions, false);
- $separator = self::popOption('separator', $htmlOptions, ' ');
- $container = self::popOption('container', $htmlOptions);
- $containerOptions = self::popOption('containerOptions', $htmlOptions, array());
- $labelOptions = self::popOption('labelOptions', $htmlOptions, array());
- $labelOptions = self::addClassName('radio', $labelOptions);
- if ($inline)
- $labelOptions = self::addClassName('inline', $labelOptions);
- $items = array();
- $baseID = $containerOptions['id'] = self::popOption('baseID', $htmlOptions, CHtml::getIdByName($name));
- $id = 0;
- foreach ($data as $value => $label)
- {
- $checked = !strcmp($value, $select);
- $htmlOptions['value'] = $value;
- $htmlOptions['id'] = $baseID . '_' . $id++;
- if ($inline)
- {
- $htmlOptions['label'] = $label;
- $htmlOptions['labelOptions'] = $labelOptions;
- $items[] = self::radioButton($name, $checked, $htmlOptions);
- }
- else
- {
- $option = self::radioButton($name, $checked, $htmlOptions);
- $items[] = self::label($option . ' ' . $label, false, $labelOptions);
- }
- }
- $inputs = implode($separator, $items);
- return !empty($container) ? self::tag($container, $containerOptions, $inputs) : $inputs;
- }
- /**
- * Generates an inline radio button list.
- * @param string $name name of the radio button list.
- * @param mixed $select selection of the radio buttons.
- * @param array $data $data value-label pairs used to generate the radio button list.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated list.
- */
- public static function inlineRadioButtonList($name, $select, $data, $htmlOptions = array())
- {
- $htmlOptions['inline'] = true;
- return self::radioButtonList($name, $select, $data, $htmlOptions);
- }
- /**
- * Generates a check box list.
- * @param string $name name of the check box list.
- * @param mixed $select selection of the check boxes.
- * @param array $data $data value-label pairs used to generate the check box list.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated list.
- */
- public static function checkBoxList($name, $select, $data, $htmlOptions = array())
- {
- $inline = self::popOption('inline', $htmlOptions, false);
- $separator = self::popOption('separator', $htmlOptions, ' ');
- $container = self::popOption('container', $htmlOptions);
- $containerOptions = self::popOption('containerOptions', $htmlOptions, array());
- if (substr($name, -2) !== '[]')
- $name .= '[]';
- $checkAllLabel = self::popOption('checkAll', $htmlOptions);
- $checkAllLast = self::popOption('checkAllLast', $htmlOptions);
- $labelOptions = self::popOption('labelOptions', $htmlOptions, array());
- $labelOptions = self::addClassName('checkbox', $labelOptions);
- if ($inline)
- $labelOptions = self::addClassName('inline', $labelOptions);
- $items = array();
- $baseID = $containerOptions['id'] = self::popOption('baseID', $htmlOptions, CHtml::getIdByName($name));
- $id = 0;
- $checkAll = true;
- foreach ($data as $value => $label)
- {
- $checked = !is_array($select) && !strcmp($value, $select) || is_array($select) && in_array($value, $select);
- $checkAll = $checkAll && $checked;
- $htmlOptions['value'] = $value;
- $htmlOptions['id'] = $baseID . '_' . $id++;
- if ($inline)
- {
- $htmlOptions['label'] = $label;
- $htmlOptions['labelOptions'] = $labelOptions;
- $items[] = self::checkBox($name, $checked, $htmlOptions);
- }
- else
- {
- $option = self::checkBox($name, $checked, $htmlOptions);
- $items[] = self::label($option . ' ' . $label, false, $labelOptions);
- }
- }
- if (isset($checkAllLabel))
- {
- $htmlOptions['value'] = 1;
- $htmlOptions['id'] = $id = $baseID . '_all';
- $option = self::checkBox($id, $checkAll, $htmlOptions);
- $label = self::label($checkAllLabel, '', $labelOptions);
- $item = self::label($option . ' ' . $label, '', $labelOptions);
- if ($checkAllLast)
- $items[] = $item;
- else
- array_unshift($items, $item);
- $name = strtr($name, array('[' => '\\[', ']' => '\\]'));
- $js = <<<EOD
- jQuery('#$id').click(function() {
- jQuery("input[name='$name']").prop('checked', this.checked);
- });
- jQuery("input[name='$name']").click(function() {
- jQuery('#$id').prop('checked', !jQuery("input[name='$name']:not(:checked)").length);
- });
- jQuery('#$id').prop('checked', !jQuery("input[name='$name']:not(:checked)").length);
- EOD;
- $cs = Yii::app()->getClientScript();
- $cs->registerCoreScript('jquery');
- $cs->registerScript($id, $js);
- }
- $inputs = implode($separator, $items);
- return !empty($container) ? self::tag($container, $containerOptions, $inputs) : $inputs;
- }
- /**
- * Generates an inline check box list.
- * @param string $name name of the check box list.
- * @param mixed $select selection of the check boxes.
- * @param array $data $data value-label pairs used to generate the check box list.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated list.
- */
- public static function inlineCheckBoxList($name, $select, $data, $htmlOptions = array())
- {
- $htmlOptions['inline'] = true;
- return self::checkBoxList($name, $select, $data, $htmlOptions);
- }
- /**
- * Generates an uneditable input.
- * @param string $value the value.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated input.
- */
- public static function uneditableField($value = '', $htmlOptions = array())
- {
- $htmlOptions = self::addClassName('uneditable-input', $htmlOptions);
- $htmlOptions = self::normalizeInputOptions($htmlOptions);
- return self::tag('span', $htmlOptions, $value);
- }
- /**
- * Generates a search input.
- * @param string $name the input name.
- * @param string $value the input value.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated input.
- */
- public static function searchField($name, $value = '', $htmlOptions = array())
- {
- $htmlOptions = self::addClassName('search-query', $htmlOptions);
- return self::textField($name, $value, $htmlOptions);
- }
- /**
- * Generates a control group with a text field.
- * @param string $name the input name.
- * @param string $value the input value.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated control group.
- * @see TbHtml::controlGroup
- */
- public static function textFieldControlGroup($name, $value = '', $htmlOptions = array())
- {
- return self::controlGroup(self::INPUT_TYPE_TEXT, $name, $value, $htmlOptions);
- }
- /**
- * Generates a control group with a password field.
- * @param string $name the input name.
- * @param string $value the input value.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated control group.
- * @see TbHtml::textInputField
- */
- public static function passwordFieldControlGroup($name, $value = '', $htmlOptions = array())
- {
- return self::controlGroup(self::INPUT_TYPE_PASSWORD, $name, $value, $htmlOptions);
- }
- /**
- * Generates a control group with an url field.
- * @param string $name the input name.
- * @param string $value the input value.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated control group.
- * @see TbHtml::controlGroup
- */
- public static function urlFieldControlGroup($name, $value = '', $htmlOptions = array())
- {
- return self::controlGroup(self::INPUT_TYPE_URL, $name, $value, $htmlOptions);
- }
- /**
- * Generates a control group with an email field.
- * @param string $name the input name.
- * @param string $value the input value.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated control group.
- * @see TbHtml::controlGroup
- */
- public static function emailFieldControlGroup($name, $value = '', $htmlOptions = array())
- {
- return self::controlGroup(self::INPUT_TYPE_EMAIL, $name, $value, $htmlOptions);
- }
- /**
- * Generates a control group with a number field.
- * @param string $name the input name.
- * @param string $value the input value.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated control group.
- * @see TbHtml::textInputField
- */
- public static function numberFieldControlGroup($name, $value = '', $htmlOptions = array())
- {
- return self::controlGroup(self::INPUT_TYPE_NUMBER, $name, $value, $htmlOptions);
- }
- /**
- * Generates a control group with a range field.
- * @param string $name the input name
- * @param string $value the input value
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated control group.
- * @see TbHtml::controlGroup
- */
- public static function rangeFieldControlGroup($name, $value = '', $htmlOptions = array())
- {
- return self::controlGroup(self::INPUT_TYPE_RANGE, $name, $value, $htmlOptions);
- }
- /**
- * Generates a control group with a date field.
- * @param string $name the input name.
- * @param string $value the input value.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated control group.
- * @see TbHtml::controlGroup
- */
- public static function dateFieldControlGroup($name, $value = '', $htmlOptions = array())
- {
- return self::controlGroup(self::INPUT_TYPE_DATE, $name, $value, $htmlOptions);
- }
- /**
- * Generates a control group with a text area.
- * @param string $name the input name.
- * @param string $value the input value.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated control group.
- * @see TbHtml::controlGroup
- */
- public static function textAreaControlGroup($name, $value = '', $htmlOptions = array())
- {
- return self::controlGroup(self::INPUT_TYPE_TEXTAREA, $name, $value, $htmlOptions);
- }
- /**
- * Generates a control group with a file field.
- * @param string $name the input name.
- * @param string $value the input value.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated control group.
- * @see TbHtml::controlGroup
- */
- public static function fileFieldControlGroup($name, $value = '', $htmlOptions = array())
- {
- return self::controlGroup(self::INPUT_TYPE_FILE, $name, $value, $htmlOptions);
- }
- /**
- * Generates a control group with a radio button.
- * @param string $name the input name.
- * @param string $checked whether the radio button is checked.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated control group.
- * @see TbHtml::controlGroup
- */
- public static function radioButtonControlGroup($name, $checked = false, $htmlOptions = array())
- {
- return self::controlGroup(self::INPUT_TYPE_RADIOBUTTON, $name, $checked, $htmlOptions);
- }
- /**
- * Generates a control group with a check box.
- * @param string $name the input name.
- * @param string $checked whether the check box is checked.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated control group.
- * @see TbHtml::controlGroup
- */
- public static function checkBoxControlGroup($name, $checked = false, $htmlOptions = array())
- {
- return self::controlGroup(self::INPUT_TYPE_CHECKBOX, $name, $checked, $htmlOptions);
- }
- /**
- * Generates a control group with a drop down list.
- * @param string $name the input name.
- * @param string $select the selected value.
- * @param array $data data for generating the list options (value=>display).
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated control group.
- * @see TbHtml::controlGroup
- */
- public static function dropDownListControlGroup($name, $select = '', $data = array(), $htmlOptions = array())
- {
- return self::controlGroup(self::INPUT_TYPE_DROPDOWNLIST, $name, $select, $htmlOptions, $data);
- }
- /**
- * Generates a control group with a list box.
- * @param string $name the input name.
- * @param string $select the selected value.
- * @param array $data data for generating the list options (value=>display).
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated control group.
- * @see TbHtml::controlGroup
- */
- public static function listBoxControlGroup($name, $select = '', $data = array(), $htmlOptions = array())
- {
- return self::controlGroup(self::INPUT_TYPE_LISTBOX, $name, $select, $htmlOptions, $data);
- }
- /**
- * Generates a control group with a radio button list.
- * @param string $name the input name.
- * @param string $select the selected value.
- * @param array $data data for generating the list options (value=>display).
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated control group.
- * @see TbHtml::controlGroup
- */
- public static function radioButtonListControlGroup($name, $select = '', $data = array(), $htmlOptions = array())
- {
- return self::controlGroup(self::INPUT_TYPE_RADIOBUTTONLIST, $name, $select, $htmlOptions, $data);
- }
- /**
- * Generates a control group with an inline radio button list.
- * @param string $name the input name.
- * @param string $select the selected value.
- * @param array $data data for generating the list options (value=>display).
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated control group.
- * @see TbHtml::controlGroup
- */
- public static function inlineRadioButtonListControlGroup($name, $select = '', $data = array(), $htmlOptions = array())
- {
- return self::controlGroup(self::INPUT_TYPE_INLINERADIOBUTTONLIST, $name, $select, $htmlOptions, $data);
- }
- /**
- * Generates a control group with a check box list.
- * @param string $name the input name.
- * @param string $select the selected value.
- * @param array $data data for generating the list options (value=>display).
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated control group.
- * @see TbHtml::controlGroup
- */
- public static function checkBoxListControlGroup($name, $select = '', $data = array(), $htmlOptions = array())
- {
- return self::controlGroup(self::INPUT_TYPE_CHECKBOXLIST, $name, $select, $htmlOptions, $data);
- }
- /**
- * Generates a control group with an inline check box list.
- * @param string $name the input name.
- * @param string $select the selected value.
- * @param array $data data for generating the list options (value=>display).
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated control group.
- * @see TbHtml::controlGroup
- */
- public static function inlineCheckBoxListControlGroup($name, $select = '', $data = array(), $htmlOptions = array())
- {
- return self::controlGroup(self::INPUT_TYPE_INLINECHECKBOXLIST, $name, $select, $htmlOptions, $data);
- }
- /**
- * Generates a control group with an uneditable field.
- * @param string $select the input value.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated control group.
- * @see TbHtml::controlGroup
- */
- public static function uneditableFieldControlGroup($value = '', $htmlOptions = array())
- {
- return self::controlGroup(self::INPUT_TYPE_UNEDITABLE, '', $value, $htmlOptions);
- }
- /**
- * Generates a control group with a search field.
- * @param string $name the input name.
- * @param string $select the input value.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated control group.
- * @see TbHtml::controlGroup
- */
- public static function searchFieldControlGroup($name, $value = '', $htmlOptions = array())
- {
- return self::controlGroup(self::INPUT_TYPE_SEARCH, $name, $value, $htmlOptions);
- }
- /**
- * Generates a form control group.
- * @param string $type the input type.
- * @param string $name the input name.
- * @param string $value the input value.
- * @param array $htmlOptions additional HTML attributes.
- * @param array $data data for multiple select inputs.
- * @return string the generated control group.
- */
- public static function controlGroup($type, $name, $value, $htmlOptions = array(), $data = array())
- {
- $label = self::popOption('label', $htmlOptions, false);
- $color = self::popOption('color', $htmlOptions);
- $controlGroupOptions = self::popOption('groupOptions', $htmlOptions, array());
- $labelOptions = self::popOption('labelOptions', $htmlOptions, array());
- $controlOptions = self::popOption('controlOptions', $htmlOptions, array());
- if (in_array($type, array(self::INPUT_TYPE_CHECKBOX, self::INPUT_TYPE_RADIOBUTTON)))
- {
- $htmlOptions['label'] = $label;
- $htmlOptions['labelOptions'] = $labelOptions;
- $label = false;
- }
- $help = self::popOption('help', $htmlOptions, '');
- $helpOptions = self::popOption('helpOptions', $htmlOptions, array());
- if (!empty($help))
- $help = self::inputHelp($help, $helpOptions);
- $input = static::createInput($type, $name, $value, $htmlOptions, $data);
- $controlGroupOptions = self::addClassName('control-group', $controlGroupOptions);
- if (!empty($color))
- $controlGroupOptions = self::addClassName($color, $controlGroupOptions);
- $labelOptions = self::addClassName('control-label', $labelOptions);
- ob_start();
- echo self::openTag('div', $controlGroupOptions);
- if ($label !== false)
- echo CHtml::label($label, $name, $labelOptions);
- echo self::controls($input . $help, $controlOptions);
- echo '</div>';
- return ob_get_clean();
- }
- /**
- * Creates a form input of the given type.
- * @param string $type the input type.
- * @param string $name the input name.
- * @param string $value the input value.
- * @param array $htmlOptions additional HTML attributes.
- * @param array $data data for multiple select inputs.
- * @return string the input.
- * @throws CException if the input type is invalid.
- */
- protected static function createInput($type, $name, $value, $htmlOptions = array(), $data = array())
- {
- switch ($type)
- {
- case self::INPUT_TYPE_TEXT:
- return self::textField($name, $value, $htmlOptions);
- case self::INPUT_TYPE_PASSWORD:
- return self::passwordField($name, $value, $htmlOptions);
- case self::INPUT_TYPE_URL:
- return self::urlField($name, $value, $htmlOptions);
- case self::INPUT_TYPE_EMAIL:
- return self::emailField($name, $value, $htmlOptions);
- case self::INPUT_TYPE_NUMBER:
- return self::numberField($name, $value, $htmlOptions);
- case self::INPUT_TYPE_RANGE:
- return self::rangeField($name, $value, $htmlOptions);
- case self::INPUT_TYPE_DATE:
- return self::dateField($name, $value, $htmlOptions);
- case self::INPUT_TYPE_TEXTAREA:
- return self::textArea($name, $value, $htmlOptions);
- case self::INPUT_TYPE_FILE:
- return self::fileField($name, $value, $htmlOptions);
- case self::INPUT_TYPE_RADIOBUTTON:
- return self::radioButton($name, $value, $htmlOptions);
- case self::INPUT_TYPE_CHECKBOX:
- return self::checkBox($name, $value, $htmlOptions);
- case self::INPUT_TYPE_DROPDOWNLIST:
- return self::dropDownList($name, $value, $data, $htmlOptions);
- case self::INPUT_TYPE_LISTBOX:
- return self::listBox($name, $value, $data, $htmlOptions);
- case self::INPUT_TYPE_CHECKBOXLIST:
- return self::checkBoxList($name, $value, $data, $htmlOptions);
- case self::INPUT_TYPE_INLINECHECKBOXLIST:
- return self::inlineCheckBoxList($name, $value, $data, $htmlOptions);
- case self::INPUT_TYPE_RADIOBUTTONLIST:
- return self::radioButtonList($name, $value, $data, $htmlOptions);
- case self::INPUT_TYPE_INLINERADIOBUTTONLIST:
- return self::inlineRadioButtonList($name, $value, $data, $htmlOptions);
- case self::INPUT_TYPE_UNEDITABLE:
- return self::uneditableField($value, $htmlOptions);
- case self::INPUT_TYPE_SEARCH:
- return self::searchField($name, $value, $htmlOptions);
- default:
- throw new CException('Invalid input type "' . $type . '".');
- }
- }
- /**
- * Generates an input HTML tag.
- * This method generates an input HTML tag based on the given input name and value.
- * @param string $type the input type.
- * @param string $name the input name.
- * @param string $value the input value.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated input tag.
- */
- protected static function textInputField($type, $name, $value, $htmlOptions)
- {
- CHtml::clientChange('change', $htmlOptions);
- $htmlOptions = self::normalizeInputOptions($htmlOptions);
- $addOnClasses = self::getAddOnClasses($htmlOptions);
- $addOnOptions = self::popOption('addOnOptions', $htmlOptions, array());
- $addOnOptions = self::addClassName($addOnClasses, $addOnOptions);
- $prepend = self::popOption('prepend', $htmlOptions, '');
- $prependOptions = self::popOption('prependOptions', $htmlOptions, array());
- if (!empty($prepend))
- $prepend = self::inputAddOn($prepend, $prependOptions);
- $append = self::popOption('append', $htmlOptions, '');
- $appendOptions = self::popOption('appendOptions', $htmlOptions, array());
- if (!empty($append))
- $append = self::inputAddOn($append, $appendOptions);
- ob_start();
- if (!empty($addOnClasses))
- echo self::openTag('div', $addOnOptions);
- echo $prepend . CHtml::inputField($type, $name, $value, $htmlOptions) . $append;
- if (!empty($addOnClasses))
- echo '</div>';
- return ob_get_clean();
- }
- /**
- * Generates a text field input for a model attribute.
- * @param CModel $model the data model.
- * @param string $attribute the attribute.
- * @param array $htmlOptions additional HTML attributes.
- * @return string the generated input field.
- * @see TbHtml::activeTextInputField
- */
- public static function activeTextField($model, $attribute, $htmlOptions = array())
- {
- return self::activeTextIn…
Large files files are truncated, but you can click here to view the full file