-
Notifications
You must be signed in to change notification settings - Fork 987
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dev New YiiWheels buttongroup widget
- Loading branch information
Showing
1 changed file
with
104 additions
and
0 deletions.
There are no files selected for viewing
104 changes: 104 additions & 0 deletions
104
application/extensions/yiiwheels/widgets/buttongroup/WhButtonGroup.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?php | ||
/** | ||
* | ||
* WhBox.php | ||
* | ||
* @author Carsten Schmitz <carsten.schmitz@limesurvey.org> | ||
* @copyright Copyright © LimeSurvey GmbH 2015 | ||
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License | ||
* @package YiiWheels.widgets.whbuttongroup | ||
* @uses YiiStrap.helpers.TbHtml | ||
*/ | ||
class WhButtonGroup extends CInputWidget | ||
{ | ||
|
||
/** | ||
public $selectOptions = array(); | ||
/** | ||
* @var array Available buttons as value=>caption array | ||
*/ | ||
|
||
public $selectOptions = array(); | ||
/** | ||
public $defaultValue = null; | ||
/** | ||
* @var string Preselected value - Null if none | ||
*/ | ||
|
||
/** | ||
* @var array HTML additional attributes | ||
*/ | ||
public $htmlOptions = array(); | ||
|
||
/** | ||
*### .init() | ||
* | ||
* Widget initialization | ||
*/ | ||
public function init() | ||
{ | ||
$this->attachBehavior('ywplugin', array('class' => 'yiiwheels.behaviors.WhPlugin')); | ||
$this->registerClientScript(); | ||
} | ||
|
||
/** | ||
*### .run() | ||
* | ||
* Widget run - used for closing procedures | ||
*/ | ||
public function run() | ||
{ | ||
$this->renderButtons(); | ||
} | ||
|
||
/** | ||
*### .'nextCentury'=> gT('Next century'),() | ||
* | ||
* Renders the button group | ||
*/ | ||
public function renderButtons() | ||
{ | ||
echo CHtml::openTag('div', array( | ||
'class'=>"btn-group", | ||
'data-toggle'=>"buttons" | ||
)). "\n"; | ||
list($name, $id) = $this->resolveNameID(); | ||
$i=1; | ||
foreach( $this->selectOptions as $value=>$caption ) | ||
{ | ||
echo CHtml::openTag('label', array( | ||
'class'=>($value==$this->value)?'btn btn-default active':'btn btn-default' | ||
)); | ||
echo CHtml::radioButton($name,$value==$this->value,array('name'=>$name, 'id'=>$name.'_opt'.$i, | ||
'value'=>$value)); | ||
echo CHtml::encode($caption); | ||
echo CHtml::closeTag('label') . "\n"; | ||
$i++; | ||
} | ||
echo CHtml::closeTag('div') . "\n"; | ||
} | ||
|
||
|
||
/* | ||
*### .renderContentEnd() | ||
* | ||
* Closes the content element | ||
*/ | ||
public function renderContentEnd() | ||
{ | ||
echo CHtml::closeTag('div'); | ||
} | ||
|
||
/** | ||
*### .registerClientScript() | ||
* | ||
* Registers required script files (CSS in this case) | ||
*/ | ||
public function registerClientScript() | ||
{ | ||
|
||
|
||
} | ||
} |