<?php

Yii::import('bootstrap.widgets.input.TbInput');
abstract class FTbInput extends TbInput
    {

    protected function WidgetLabel( $label, $popover_Content )
    {
        if ($this->label !== false && !in_array($this->type, array('checkbox', 'radio')) && $this->hasModel())
        {
            return Yii::app()->controller->widget('bootstrap.widgets.FTbButton', array(
                'label' => $label,
                'type' => 'link',
                'htmlOptions' => array(
                    'data-trigger' => 'hover',
                    'data-placement' => 'right',
                    'data-animation' => true,
                    'data-selector' => true,
                    'tooltips' => true,
                    'data-content' => $popover_Content,
                    'rel' => 'popover'),
                    ), true);
        }
        else if ($this->label !== null)
            return $this->label;
        else
            return '';
    }

    protected function getLabel()
    {
        if ($this->label !== false && !in_array($this->type, array('checkbox', 'radio')) && $this->hasModel())
        {
            try
            {
                $labelText = $this->model->getAttributeLabel($this->attribute);
                $popover_Contents_Array = $this->model->attributeLabelsPopover();
                if (isset($labelText) && isset($popover_Contents_Array[$this->attribute]))
                {
                    $popover_Content = $popover_Contents_Array[$this->attribute];
                    $WidgetLabel = $this->WidgetLabel($labelText, $popover_Content);
                    if ($this->model->isAttributeRequired($this->attribute))
                        $WidgetLabel = $WidgetLabel . '<span class="required">*</span>';
                    return $WidgetLabel;
                }
                else
                {
                    return $this->form->labelEx($this->model, $this->attribute, $this->labelOptions);
                }
            }
            catch (Exception $e)
            {
                return $this->form->labelEx($this->model, $this->attribute, $this->labelOptions);
            }
        }
        else if ($this->label !== null)
            return $this->label;
        else
            return '';
    }

    }
