406 public static function lead($text, $htmlOptions = array())
409 return self::tag(
'p', $htmlOptions, $text);
418 public static function small($text, $htmlOptions = array())
420 return self::tag(
'small', $htmlOptions, $text);
429 public static function b($text, $htmlOptions = array())
431 return self::tag(
'strong', $htmlOptions, $text);
440 public static function i($text, $htmlOptions = array())
442 return self::tag(
'em', $htmlOptions, $text);
453 public static function em($text, $htmlOptions = array(), $tag =
'p')
456 if (self::popOption(
'muted', $htmlOptions,
false))
458 else if (!empty($color))
460 return self::tag($tag, $htmlOptions, $text);
470 public static function muted($text, $htmlOptions = array(), $tag =
'p')
472 $htmlOptions[
'muted'] =
true;
473 return self::em($text, $htmlOptions, $tag);
483 public static function mutedSpan($text, $htmlOptions = array())
495 public static function abbr($text, $word, $htmlOptions = array())
497 if (self::popOption(
'small', $htmlOptions,
false))
499 $htmlOptions[
'title'] = $word;
500 return self::tag(
'abbr', $htmlOptions, $text);
510 public static function smallAbbr($text, $word, $htmlOptions = array())
512 $htmlOptions[
'small'] =
true;
513 return self::abbr($text, $word, $htmlOptions);
522 public static function address($text, $htmlOptions = array())
524 return self::tag(
'address', $htmlOptions, $text);
533 public static function quote($text, $htmlOptions = array())
535 $paragraphOptions =
self::popOption(
'paragraphOptions', $htmlOptions, array());
537 $sourceOptions =
self::popOption(
'sourceOptions', $htmlOptions, array());
540 $cite = isset($cite) ?
self::tag(
'cite', $citeOptions, $cite) :
'';
541 $source = isset($source) ?
self::tag(
'small', $sourceOptions, $source .
' ' . $cite) :
'';
542 $text =
self::tag(
'p', $paragraphOptions, $text) . $source;
543 return self::tag(
'blockquote', $htmlOptions, $text);
552 public static function help($text, $htmlOptions = array())
555 return self::tag(
'span', $htmlOptions, $text);
564 public static function helpBlock($text, $htmlOptions = array())
567 return self::tag(
'p', $htmlOptions, $text);
580 public static function code($code, $htmlOptions = array())
582 return self::tag(
'code', $htmlOptions, $code);
591 public static function codeBlock($code, $htmlOptions = array())
593 return self::tag(
'pre', $htmlOptions, $code);
604 public static function tag($tag, $htmlOptions = array(), $content =
false, $closeTag =
true)
607 if (!empty($textAlign))
613 return CHtml::tag($tag, $htmlOptions, $content, $closeTag);
622 public static function openTag($tag, $htmlOptions = array())
645 public static function formTb($layout = self::FORM_LAYOUT_VERTICAL, $action =
'', $method =
'post', $htmlOptions = array())
658 public static function beginFormTb($layout = self::FORM_LAYOUT_VERTICAL, $action =
'', $method =
'post', $htmlOptions = array())
661 return CHtml::beginForm($action, $method, $htmlOptions);
671 public static function statefulFormTb($layout = self::FORM_LAYOUT_VERTICAL, $action =
'', $method =
'post', $htmlOptions = array())
673 return self::formTb($layout, $action, $method, $htmlOptions)
674 .
self::tag(
'div', array(
'style' =>
'display:none'), CHtml::pageStateField(
''));
685 public static function textField($name, $value =
'', $htmlOptions = array())
698 public static function passwordField($name, $value =
'', $htmlOptions = array())
711 public static function urlField($name, $value =
'', $htmlOptions = array())
724 public static function emailField($name, $value =
'', $htmlOptions = array())
737 public static function numberField($name, $value =
'', $htmlOptions = array())
750 public static function rangeField($name, $value =
'', $htmlOptions = array())
763 public static function dateField($name, $value =
'', $htmlOptions = array())
775 public static function textArea($name, $value =
'', $htmlOptions = array())
788 public static function radioButton($name, $checked =
false, $htmlOptions = array())
791 $labelOptions =
self::popOption(
'labelOptions', $htmlOptions, array());
804 public static function checkBox($name, $checked =
false, $htmlOptions = array())
807 $labelOptions =
self::popOption(
'labelOptions', $htmlOptions, array());
834 public static function listBox($name, $select,
$data, $htmlOptions = array())
837 if (isset($htmlOptions[
'multiple']))
839 if (substr($name, -2) !==
'[]')
858 $containerOptions =
self::popOption(
'containerOptions', $htmlOptions, array());
860 $labelOptions =
self::popOption(
'labelOptions', $htmlOptions, array());
866 $baseID = $containerOptions[
'id'] =
self::popOption(
'baseID', $htmlOptions, CHtml::getIdByName($name));
871 $checked = !strcmp($value, $select);
872 $htmlOptions[
'value'] = $value;
873 $htmlOptions[
'id'] = $baseID .
'_' . $id++;
876 $htmlOptions[
'label'] =
$label;
877 $htmlOptions[
'labelOptions'] = $labelOptions;
883 $items[] = self::label($option .
' ' .
$label,
false, $labelOptions);
887 $inputs = implode($separator, $items);
888 return !empty($container) ?
self::tag($container, $containerOptions, $inputs) : $inputs;
901 $htmlOptions[
'inline'] =
true;
918 $containerOptions =
self::popOption(
'containerOptions', $htmlOptions, array());
920 if (substr($name, -2) !==
'[]')
926 $labelOptions =
self::popOption(
'labelOptions', $htmlOptions, array());
932 $baseID = $containerOptions[
'id'] =
self::popOption(
'baseID', $htmlOptions, CHtml::getIdByName($name));
938 $checked = !is_array($select) && !strcmp($value, $select) || is_array($select) && in_array($value, $select);
939 $checkAll = $checkAll && $checked;
940 $htmlOptions[
'value'] = $value;
941 $htmlOptions[
'id'] = $baseID .
'_' . $id++;
944 $htmlOptions[
'label'] =
$label;
945 $htmlOptions[
'labelOptions'] = $labelOptions;
951 $items[] = self::label($option .
' ' .
$label,
false, $labelOptions);
955 if (isset($checkAllLabel))
957 $htmlOptions[
'value'] = 1;
958 $htmlOptions[
'id'] = $id = $baseID .
'_all';
960 $label = self::label($checkAllLabel,
'', $labelOptions);
961 $item = self::label($option .
' ' .
$label,
'', $labelOptions);
965 array_unshift($items, $item);
966 $name = strtr($name, array(
'[' =>
'\\[',
']' =>
'\\]'));
968 jQuery(
'#$id').click(
function() {
969 jQuery(
"input[name='$name']").prop(
'checked', this.checked);
971 jQuery(
"input[name='$name']").click(
function() {
972 jQuery(
'#$id').prop(
'checked', !jQuery(
"input[name='$name']:not(:checked)").length);
974 jQuery(
'#$id').prop(
'checked', !jQuery(
"input[name='$name']:not(:checked)").length);
976 $cs = Yii::app()->getClientScript();
977 $cs->registerCoreScript(
'jquery');
978 $cs->registerScript($id, $js);
981 $inputs = implode($separator, $items);
982 return !empty($container) ?
self::tag($container, $containerOptions, $inputs) : $inputs;
995 $htmlOptions[
'inline'] =
true;
1009 return self::tag(
'span', $htmlOptions, $value);
1019 public static function searchField($name, $value =
'', $htmlOptions = array())
1152 return self::controlGroup(self::INPUT_TYPE_RADIOBUTTON, $name, $checked, $htmlOptions);
1290 $controlGroupOptions =
self::popOption(
'groupOptions', $htmlOptions, array());
1291 $labelOptions =
self::popOption(
'labelOptions', $htmlOptions, array());
1292 $controlOptions =
self::popOption(
'controlOptions', $htmlOptions, array());
1294 if (in_array($type, array(self::INPUT_TYPE_CHECKBOX, self::INPUT_TYPE_RADIOBUTTON)))
1296 $htmlOptions[
'label'] =
$label;
1297 $htmlOptions[
'labelOptions'] = $labelOptions;
1315 echo CHtml::label(
$label, $name, $labelOptions);
1318 return ob_get_clean();
1331 protected static function createInput($type, $name, $value, $htmlOptions = array(),
$data = array())
1335 case self::INPUT_TYPE_TEXT:
1337 case self::INPUT_TYPE_PASSWORD:
1339 case self::INPUT_TYPE_URL:
1341 case self::INPUT_TYPE_EMAIL:
1343 case self::INPUT_TYPE_NUMBER:
1345 case self::INPUT_TYPE_RANGE:
1347 case self::INPUT_TYPE_DATE:
1349 case self::INPUT_TYPE_TEXTAREA:
1351 case self::INPUT_TYPE_FILE:
1352 return self::fileField($name, $value, $htmlOptions);
1353 case self::INPUT_TYPE_RADIOBUTTON:
1355 case self::INPUT_TYPE_CHECKBOX:
1357 case self::INPUT_TYPE_DROPDOWNLIST:
1359 case self::INPUT_TYPE_LISTBOX:
1361 case self::INPUT_TYPE_CHECKBOXLIST:
1363 case self::INPUT_TYPE_INLINECHECKBOXLIST:
1365 case self::INPUT_TYPE_RADIOBUTTONLIST:
1367 case self::INPUT_TYPE_INLINERADIOBUTTONLIST:
1369 case self::INPUT_TYPE_UNEDITABLE:
1371 case self::INPUT_TYPE_SEARCH:
1374 throw new CException(
'Invalid input type "' . $type .
'".');
1389 CHtml::clientChange(
'change', $htmlOptions);
1394 $addOnOptions =
self::popOption(
'addOnOptions', $htmlOptions, array());
1398 $prependOptions =
self::popOption(
'prependOptions', $htmlOptions, array());
1399 if (!empty($prepend))
1403 $appendOptions =
self::popOption(
'appendOptions', $htmlOptions, array());
1404 if (!empty($append))
1408 if (!empty($addOnClasses))
1410 echo $prepend . CHtml::inputField($type, $name, $value, $htmlOptions) . $append;
1411 if (!empty($addOnClasses))
1413 return ob_get_clean();
1530 $labelOptions =
self::popOption(
'labelOptions', $htmlOptions, array());
1546 $labelOptions =
self::popOption(
'labelOptions', $htmlOptions, array());
1589 CHtml::resolveNameID($model, $attribute, $htmlOptions);
1590 $selection = CHtml::resolveValue($model, $attribute);
1591 if ($model->hasErrors($attribute))
1592 CHtml::addErrorCss($htmlOptions);
1595 $hiddenOptions = isset($htmlOptions[
'id']) ? array(
'id' => CHtml::ID_PREFIX . $htmlOptions[
'id']) : array(
'id' =>
false);
1596 $hidden = $unCheck !== null ? CHtml::hiddenField($name, $unCheck, $hiddenOptions) :
'';
1610 $htmlOptions[
'inline'] =
true;
1624 CHtml::resolveNameID($model, $attribute, $htmlOptions);
1625 $selection = CHtml::resolveValue($model, $attribute);
1626 if ($model->hasErrors($attribute))
1627 CHtml::addErrorCss($htmlOptions);
1630 $hiddenOptions = isset($htmlOptions[
'id']) ? array(
'id' => CHtml::ID_PREFIX . $htmlOptions[
'id']) : array(
'id' =>
false);
1631 $hidden = $unCheck !== null ? CHtml::hiddenField($name, $unCheck, $hiddenOptions) :
'';
1645 $htmlOptions[
'inline'] =
true;
1658 CHtml::resolveNameID($model, $attribute, $htmlOptions);
1659 $value = CHtml::resolveValue($model, $attribute);
1942 $controlGroupOptions =
self::popOption(
'groupOptions', $htmlOptions, array());
1943 $labelOptions =
self::popOption(
'labelOptions', $htmlOptions, array());
1944 $controlOptions =
self::popOption(
'controlOptions', $htmlOptions, array());
1946 if (in_array($type, array(self::INPUT_TYPE_CHECKBOX, self::INPUT_TYPE_RADIOBUTTON)))
1948 $htmlOptions =
self::defaultOption(
'label', $model->getAttributeLabel($attribute), $htmlOptions);
1949 $htmlOptions[
'labelOptions'] = $labelOptions;
1968 echo CHtml::activeLabelEx($model, $attribute, $labelOptions);
1971 return ob_get_clean();
1988 case self::INPUT_TYPE_TEXT:
1990 case self::INPUT_TYPE_PASSWORD:
1992 case self::INPUT_TYPE_URL:
1994 case self::INPUT_TYPE_EMAIL:
1996 case self::INPUT_TYPE_NUMBER:
1998 case self::INPUT_TYPE_RANGE:
2000 case self::INPUT_TYPE_DATE:
2002 case self::INPUT_TYPE_TEXTAREA:
2004 case self::INPUT_TYPE_FILE:
2005 return self::activeFileField($model, $attribute, $htmlOptions);
2006 case self::INPUT_TYPE_RADIOBUTTON:
2008 case self::INPUT_TYPE_CHECKBOX:
2010 case self::INPUT_TYPE_DROPDOWNLIST:
2012 case self::INPUT_TYPE_LISTBOX:
2014 case self::INPUT_TYPE_CHECKBOXLIST:
2016 case self::INPUT_TYPE_INLINECHECKBOXLIST:
2018 case self::INPUT_TYPE_RADIOBUTTONLIST:
2020 case self::INPUT_TYPE_INLINERADIOBUTTONLIST:
2022 case self::INPUT_TYPE_UNEDITABLE:
2024 case self::INPUT_TYPE_SEARCH:
2027 throw new CException(
'Invalid input type "' . $type .
'".');
2039 public static function errorSummary($model, $header = null, $footer = null, $htmlOptions = array())
2053 public static function error($model, $attribute, $htmlOptions = array())
2055 CHtml::resolveName($model, $attribute);
2056 $error = $model->getError($attribute);
2057 return !empty($error) ?
self::help($error, $htmlOptions) :
'';
2071 CHtml::resolveNameID($model, $attribute, $htmlOptions);
2072 CHtml::clientChange(
'change', $htmlOptions);
2077 $addOnOptions =
self::popOption(
'addOnOptions', $htmlOptions, array());
2081 $prependOptions =
self::popOption(
'prependOptions', $htmlOptions, array());
2082 if (!empty($prepend))
2086 $appendOptions =
self::popOption(
'appendOptions', $htmlOptions, array());
2087 if (!empty($append))
2091 if (!empty($addOnClasses))
2093 echo $prepend . CHtml::activeInputField($type, $model, $attribute, $htmlOptions) . $append;
2094 if (!empty($addOnClasses))
2096 return ob_get_clean();
2107 if (self::getOption(
'append', $htmlOptions))
2108 $classes[] =
'input-append';
2109 if (self::getOption(
'prepend', $htmlOptions))
2110 $classes[] =
'input-prepend';
2111 return !empty($classes) ? implode(
' ', $classes) : $classes;
2122 $addOnOptions =
self::popOption(
'addOnOptions', $htmlOptions, array());
2124 return strpos($addOn,
'btn') ===
false
2125 ?
self::tag(
'span', $addOnOptions, $addOn)
2137 $type =
self::popOption(
'type', $htmlOptions, self::HELP_TYPE_INLINE);
2138 return $type === self::HELP_TYPE_INLINE
2155 else if (!empty($size))
2166 public static function controls($controls, $htmlOptions = array())
2174 if (is_array($controls))
2175 $controls = implode(
' ', $controls);
2178 echo $before . $controls . $after;
2180 return ob_get_clean();
2191 $htmlOptions[
'row'] =
true;
2204 if (is_array($actions))
2205 $actions = implode(
' ', $actions);
2210 return ob_get_clean();
2220 public static function searchForm($action, $method =
'post', $htmlOptions = array())
2223 $inputOptions =
self::popOption(
'inputOptions', $htmlOptions, array());
2224 $inputOptions =
self::mergeOptions(array(
'type' =>
'text',
'placeholder' =>
'Search'), $inputOptions);
2228 echo
self::beginFormTb(self::FORM_LAYOUT_SEARCH, $action, $method, $htmlOptions);
2230 echo CHtml::endForm();
2231 return ob_get_clean();
2241 public static function navbarForm($action, $method =
'post', $htmlOptions = array())
2244 return CHtml::form($action, $method, $htmlOptions);
2271 public static function link($text,
$url =
'#', $htmlOptions = array())
2274 self::clientChange(
'click', $htmlOptions);
2275 return self::tag(
'a', $htmlOptions, $text);
2330 $htmlOptions[
'src'] = $src;
2331 return self::btn(self::BUTTON_TYPE_IMAGE,
'Submit', $htmlOptions);
2353 public static function ajaxLink($text,
$url, $ajaxOptions = array(), $htmlOptions = array())
2355 $htmlOptions[
'url'] =
$url;
2356 $htmlOptions[
'ajaxOptions'] = $ajaxOptions;
2357 return self::btn(self::BUTTON_TYPE_AJAXLINK, $text, $htmlOptions);
2370 $ajaxOptions[
'url'] =
$url;
2371 $htmlOptions[
'ajax'] = $ajaxOptions;
2385 $ajaxOptions[
'type'] =
'POST';
2386 $htmlOptions[
'type'] =
'submit';
2397 public static function btn($type,
$label, $htmlOptions = array())
2406 if (self::popOption(
'block', $htmlOptions,
false))
2408 if (self::popOption(
'disabled', $htmlOptions,
false))
2411 if (!empty($loading))
2412 $htmlOptions[
'data-loading-text'] = $loading;
2413 if (self::popOption(
'toggle', $htmlOptions,
false))
2414 $htmlOptions[
'data-toggle'] =
'button';
2415 $items = strpos($type,
'input') ===
false ?
self::popOption(
'items', $htmlOptions, array()) : array();
2417 if (!empty($icon) && strpos($type,
'input') ===
false)
2419 $dropdownOptions = $htmlOptions;
2422 return count($items) > 0
2438 $groupOptions =
self::popOption(
'groupOptions', $htmlOptions, array());
2440 if (self::popOption(
'dropup', $htmlOptions,
false))
2444 if (self::popOption(
'split', $htmlOptions,
false))
2453 return ob_get_clean();
2469 case self::BUTTON_TYPE_HTML:
2472 case self::BUTTON_TYPE_SUBMIT:
2473 $htmlOptions[
'type'] =
'submit';
2476 case self::BUTTON_TYPE_RESET:
2477 $htmlOptions[
'type'] =
'reset';
2480 case self::BUTTON_TYPE_IMAGE:
2481 $htmlOptions[
'type'] =
'image';
2484 case self::BUTTON_TYPE_LINKBUTTON:
2487 case self::BUTTON_TYPE_AJAXLINK:
2490 case self::BUTTON_TYPE_AJAXBUTTON:
2491 $ajaxOptions[
'url'] =
$url;
2492 $htmlOptions[
'ajax'] = $ajaxOptions;
2495 case self::BUTTON_TYPE_INPUTBUTTON:
2498 case self::BUTTON_TYPE_INPUTSUBMIT:
2499 $htmlOptions[
'type'] =
'submit';
2502 case self::BUTTON_TYPE_LINK:
2506 throw new CException(
'Invalid button type "' . $type .
'".');
2521 public static function imageRounded($src, $alt =
'', $htmlOptions = array())
2534 public static function imageCircle($src, $alt =
'', $htmlOptions = array())
2560 public static function image($src, $alt =
'', $htmlOptions = array())
2579 public static function icon($icon, $htmlOptions = array(), $tagName =
'i')
2581 if (is_string($icon))
2583 if (strpos($icon,
'icon') ===
false && strpos($icon,
'fa') ===
false)
2584 $icon =
'icon-' . implode(
' icon-', explode(
' ', $icon));
2586 return self::openTag($tagName, $htmlOptions) . CHtml::closeTag($tagName);
2605 public static function dropdown($items, $htmlOptions = array())
2612 return ob_get_clean();
2648 $label .=
' <b class="caret"></b>';
2662 $label .=
' <b class="caret"></b>';
2678 if (is_array($buttons) && !empty($buttons))
2681 if (self::popOption(
'vertical', $htmlOptions,
false))
2684 if (!empty($toggle))
2685 $htmlOptions[
'data-toggle'] =
'buttons-' . $toggle;
2686 $parentOptions = array(
2687 'color' => self::popOption(
'color', $htmlOptions),
2688 'size' => self::popOption(
'size', $htmlOptions),
2689 'disabled' => self::popOption(
'disabled', $htmlOptions)
2693 foreach ($buttons as $buttonOptions)
2696 if (!empty($options))
2699 $buttonOptions =
self::copyOptions(array(
'color',
'size',
'disabled'), $parentOptions, $buttonOptions);
2707 return ob_get_clean();
2720 if (is_array($groups) && !empty($groups))
2723 $parentOptions = array(
2724 'color' => self::popOption(
'color', $htmlOptions),
2725 'size' => self::popOption(
'size', $htmlOptions),
2726 'disabled' => self::popOption(
'disabled', $htmlOptions)
2730 foreach ($groups as $groupOptions)
2736 if (!empty($options))
2738 $groupOptions =
self::copyOptions(array(
'color',
'size',
'disabled'), $parentOptions, $groupOptions);
2742 return ob_get_clean();
2760 $htmlOptions[
'items'] = $items;
2761 $type =
self::popOption(
'type', $htmlOptions, self::BUTTON_TYPE_LINKBUTTON);
2774 $htmlOptions[
'split'] =
true;
2788 public static function tabs($items, $htmlOptions = array())
2790 return self::nav(self::NAV_TYPE_TABS, $items, $htmlOptions);
2801 $htmlOptions[
'stacked'] =
true;
2811 public static function pills($items, $htmlOptions = array())
2813 return self::nav(self::NAV_TYPE_PILLS, $items, $htmlOptions);
2824 $htmlOptions[
'stacked'] =
true;
2834 public static function navList($items, $htmlOptions = array())
2836 return self::nav(self::NAV_TYPE_LIST, $items, $htmlOptions);
2846 public static function nav($type, $items, $htmlOptions = array())
2850 if ($type !== self::NAV_TYPE_LIST && self::popOption(
'stacked', $htmlOptions,
false))
2854 return ob_get_clean();
2863 public static function menu($items, $htmlOptions = array())
2867 foreach ($items as $itemOptions)
2869 if (is_string($itemOptions))
2874 if (!empty($options))
2878 if (self::popOption(
'active', $itemOptions,
false))
2880 if (self::popOption(
'disabled', $itemOptions,
false))
2882 if (self::popOption(
'header', $itemOptions,
false))
2886 $itemOptions[
'linkOptions'] =
self::getOption(
'linkOptions', $itemOptions, array());
2902 return ob_get_clean();
2919 return ob_get_clean();
2935 if (self::popOption(
'active', $htmlOptions,
false))
2942 return ob_get_clean();
2978 if (!empty($placement))
2981 $contentOptions =
self::popOption(
'contentOptions', $htmlOptions, array());
2983 $menuItems = array();
2984 foreach (
$tabs as
$i => &$tabOptions)
2988 $id = $tabOptions[
'id'] =
self::popOption(
'id', $tabOptions,
'tab_' . (
$i + 1));
2992 $linkOptions[
'data-toggle'] =
'tab';
2999 'active' => $active,
3000 'disabled' => $disabled,
3001 'itemOptions' => $itemOptions,
3002 'linkOptions' => $linkOptions,
3005 $menuItems[] = $menuItem;
3011 foreach (
$tabs as &$tabOptions)
3013 if (self::popOption(
'active', $tabOptions,
false))
3017 echo
TbHtml::tag(
'div', $tabOptions, $tabContent);
3019 echo
'</div></div>';
3020 return ob_get_clean();
3033 public static function navbar($content, $htmlOptions = array())
3037 if (!empty($display) )
3042 $innerOptions =
self::popOption(
'innerOptions', $htmlOptions, array());
3046 echo
self::tag(
'div', $innerOptions, $content);
3048 return ob_get_clean();
3071 public static function navbarText($text, $htmlOptions = array(), $tag =
'p')
3074 return self::tag($tag, $htmlOptions, $text);
3110 echo
self::tag(
'span', array(
'class' =>
'divider'), $divider);
3117 return ob_get_clean();
3130 public static function pagination($links, $htmlOptions = array())
3132 if (is_array($links) && !empty($links))
3145 foreach ($links as $itemOptions)
3148 if (!empty($options))
3154 echo
'</ul>' .
'</div>';
3155 return ob_get_clean();
3180 return ob_get_clean();
3189 public static function pager($links, $htmlOptions = array())
3191 if (is_array($links) && !empty($links))
3196 foreach ($links as $itemOptions)
3199 if (!empty($options))
3206 return ob_get_clean();
3226 if (self::popOption(
'disabled', $htmlOptions,
false))
3233 return ob_get_clean();
3281 public static function heroUnit($heading, $content, $htmlOptions = array())
3284 $headingOptions =
self::popOption(
'headingOptions', $htmlOptions, array());
3287 echo
self::tag(
'h1', $headingOptions, $heading);
3290 return ob_get_clean();
3300 public static function pageHeader($heading, $subtext, $htmlOptions = array())
3304 $headerOptions =
self::popOption(
'headerOptions', $htmlOptions, array());
3305 $subtextOptions =
self::popOption(
'subtextOptions', $htmlOptions, array());
3309 echo CHtml::encode($heading) .
' ' .
self::tag(
'small', $subtextOptions, $subtext);
3312 return ob_get_clean();
3325 public static function thumbnails($thumbnails, $htmlOptions = array())
3327 if (is_array($thumbnails) && !empty($thumbnails))
3334 foreach ($thumbnails as $thumbnailOptions)
3336 $options =
self::popOption(
'htmlOptions', $thumbnailOptions, array());
3337 if (!empty($options))
3339 $thumbnailOptions[
'itemOptions'][
'span'] =
self::popOption(
'span', $thumbnailOptions, $defaultSpan);
3341 $captionOptions =
self::popOption(
'captionOptions', $thumbnailOptions, array());
3344 $labelOptions =
self::popOption(
'labelOptions', $thumbnailOptions, array());
3347 $content = !empty($caption) ?
self::tag(
'div', $captionOptions, $caption) :
'';
3349 $imageOptions =
self::popOption(
'imageOptions', $thumbnailOptions, array());
3352 $content =
CHtml::image($image, $imageAlt, $imageOptions) . $content;
3359 return ob_get_clean();
3370 public static function thumbnail($content, $htmlOptions = array())
3380 return ob_get_clean();
3398 return ob_get_clean();
3412 public static function alert($color, $message, $htmlOptions = array())
3417 if (self::popOption(
'in', $htmlOptions,
true))
3419 if (self::popOption(
'block', $htmlOptions,
false))
3421 if (self::popOption(
'fade', $htmlOptions,
true))
3423 $closeText =
self::popOption(
'closeText', $htmlOptions, self::CLOSE_TEXT);
3424 $closeOptions =
self::popOption(
'closeOptions', $htmlOptions, array());
3427 echo $closeText !==
false ?
self::closeLink($closeText, $closeOptions) :
'';
3430 return ob_get_clean();
3440 public static function blockAlert($color, $message, $htmlOptions = array())
3442 $htmlOptions[
'block'] =
true;
3443 return self::alert($color, $message, $htmlOptions);
3456 public static function progressBar($width = 0, $htmlOptions = array())
3462 if (self::popOption(
'striped', $htmlOptions,
false))
3465 if (self::popOption(
'animated', $htmlOptions,
false))
3475 return ob_get_clean();
3486 $htmlOptions[
'striped'] =
true;
3498 $htmlOptions[
'animated'] =
true;
3510 if (is_array($bars) && !empty($bars))
3515 foreach ($bars as $barOptions)
3518 if (!empty($options))
3524 return ob_get_clean();
3535 public static function bar($width = 0, $htmlOptions = array())
3547 return self::tag(
'div', $htmlOptions, $content);
3561 if (is_array($mediaObjects) && !empty($mediaObjects))
3564 foreach ($mediaObjects as $mediaObjectOptions)
3569 $itemOptions =
self::getOption(
'htmlOptions', $mediaObjectOptions, array());
3570 $itemOptions[
'items'] =
self::popOption(
'items', $mediaObjectOptions, array());
3573 return ob_get_clean();
3586 public static function mediaObject($image, $heading, $content, $htmlOptions = array())
3591 $imageOptions =
self::popOption(
'imageOptions', $htmlOptions, array());
3593 $contentOptions =
self::popOption(
'contentOptions', $htmlOptions, array());
3595 $headingOptions =
self::popOption(
'headingOptions', $htmlOptions, array());
3604 echo
self::link(CHtml::image($image, $alt, $imageOptions), $href, $linkOptions);
3606 echo
self::tag(
'h4', $headingOptions, $heading);
3610 echo
'</div></div>';
3611 return ob_get_clean();
3624 public static function well($content, $htmlOptions = array())
3631 echo
self::tag(
'div', $htmlOptions, $content);
3632 return ob_get_clean();
3680 $htmlOptions[
'data-toggle'] =
'collapse';
3694 'data-toggle' =>
'collapse',
3695 'data-target' => $target,
3699 echo
'<span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span>';
3701 return ob_get_clean();
3723 $htmlOptions[
'rel'] =
'tooltip';
3737 $htmlOptions[
'rel'] =
'popover';
3738 $htmlOptions[
'data-content'] = $content;
3739 $htmlOptions[
'data-toggle'] =
'popover';
3754 if (self::popOption(
'animation', $htmlOptions))
3756 if (self::popOption(
'html', $htmlOptions))
3759 if (!empty($placement))
3761 if (self::popOption(
'selector', $htmlOptions))
3764 if (!empty($trigger))
3766 if (($delay = self::popOption(
'delay', $htmlOptions)) !== null)
3781 public static function carousel($items, $htmlOptions = array())
3783 if (is_array($items) && !empty($items))
3787 $selector =
'#' . $id;
3789 if (self::popOption(
'slide', $htmlOptions,
true))
3797 $indicatorOptions =
self::popOption(
'indicatorOptions', $htmlOptions, array());
3798 $innerOptions =
self::popOption(
'innerOptions', $htmlOptions, array());
3804 $hidePrevAndNext =
self::popOption(
'hidePrevAndNext', $htmlOptions,
false);
3809 foreach ($items as
$i => $itemOptions)
3817 $imageOptions =
self::popOption(
'imageOptions', $itemOptions, array());
3819 $content =
CHtml::image($image, $imageAlt, $imageOptions);
3825 if (!$hidePrevAndNext)
3831 return ob_get_clean();
3846 $overlayOptions =
self::popOption(
'overlayOptions', $htmlOptions, array());
3848 $labelOptions =
self::popOption(
'labelOptions', $htmlOptions, array());
3849 $captionOptions =
self::popOption(
'captionOptions', $htmlOptions, array());
3853 if (isset(
$label) || isset($caption))
3859 echo
self::tag(
'p', $captionOptions, $caption);
3863 return ob_get_clean();
3875 $htmlOptions[
'data-slide'] =
'prev';
3889 $htmlOptions[
'data-slide'] =
'next';
3906 for (
$i = 0;
$i < $numSlides;
$i++)
3908 $itemOptions = array(
'data-target' => $target,
'data-slide-to' =>
$i);
3910 $itemOptions[
'class'] =
'active';
3914 return ob_get_clean();
3928 if (is_array($className))
3929 $className = implode(
' ', $className);
3930 $htmlOptions[
'class'] = isset($htmlOptions[
'class']) ? $htmlOptions[
'class'] .
' ' . $className : $className;
3931 return $htmlOptions;
3942 $htmlOptions[
'style'] = isset($htmlOptions[
'style']) ? $htmlOptions[
'style'] .
' ' . $styles : $styles;
3943 return $htmlOptions;
3955 if (is_array($fromOptions) && is_array($options))
3957 foreach ($names as $key)
3959 if (isset($fromOptions[$key]) && !isset($options[$key]))
3975 if (is_array($fromOptions) && is_array($options))
3977 foreach ($names as $key)
3979 if (isset($fromOptions[$key]) && !isset($options[$key]))
3994 if (is_array($defaults) && is_array($options))
3996 foreach ($defaults as $name => $value)
4010 return CMap::mergeArray($a, $b);
4020 public static function getOption($name, $options, $defaultValue = null)
4022 return (is_array($options) && isset($options[$name])) ? $options[$name] : $defaultValue;
4032 public static function popOption($name, &$options, $defaultValue = null)
4034 if (is_array($options))
4037 unset($options[$name]);
4041 return $defaultValue;
4053 if (is_array($options) && !isset($options[$name]))
4054 $options[$name] = $value;
4066 return array_diff_key($options, array_flip($names));