Skip to content

Instantly share code, notes, and snippets.

@kallepersson
Created January 12, 2013 00:00
Show Gist options
  • Save kallepersson/4515056 to your computer and use it in GitHub Desktop.
Save kallepersson/4515056 to your computer and use it in GitHub Desktop.
<?php
/**
* TmSectionHeader class file.
* @author Kalle Persson <[email protected]>
* @copyright Copyright &copy; Afonso Wilsson 2013 -
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @package tm.widgets
* @since 1.0
*/
class TmSectionHeader extends CWidget
{
public $label = 'Title';
public $button = array(
'type' => '',
'htmlOptions' => array()
);
public $encodeLabel = true;
public $htmlOptions = array();
public function init()
{
/*
if(isset($this->button['htmlOptions'])) {
$this->button['htmlOptions'] = array_merge_recursive($this->pre_button, $this->button['htmlOptions']);
}
*/
if (!isset($this->button['htmlOptions'])) {
$this->button['htmlOptions'] = array('class'=>'');
}
if (!isset($this->button['type'])) {
$this->button['type'] = 'add';
}
if (!isset($this->button['label'])) {
$this->button['label'] = '';
}
if (isset($this->htmlOptions['class'])) {
$this->htmlOptions['class'] .= ' section-title';
}
else {
$this->htmlOptions['class'] = 'section-title';
}
if(!isset($this->button['htmlOptions']['class'])) {
$this->button['htmlOptions']['class'] = '';
}
$this->button['htmlOptions']['class'] .= ' header-button-'.$this->button['type'];
if ($this->encodeLabel) {
$this->label = CHtml::encode($this->label);
}
if (isset($this->button['url'])) {
$this->label .= CHtml::link($this->button['label'], $this->button['url'], $this->button['htmlOptions']);
}
echo CHtml::tag('h2', $this->htmlOptions, $this->label);
}
public function run()
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment