Created
November 29, 2010 19:26
-
-
Save mgcrea/720424 to your computer and use it in GitHub Desktop.
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
<?php | |
class MgHtmlHelper extends HtmlHelper { | |
var $helpers = array('Html', 'Form'); | |
function __construct($paths = array()) { | |
$this->View =& ClassRegistry::getObject('view'); | |
} | |
function link($content = null, $action = array(), $options = array()) { | |
//unset($this->View->helpers['Analogue.Analogue']); | |
$defaults = array( | |
'role' => 'button', | |
'aria-disabled' => 'false', | |
'class' => null, | |
'icon' => null, | |
'text' => null, | |
'overlay' => false, | |
'action' => array(), | |
'escape' => false, | |
'data' => array(), | |
'ui' => array(), | |
'before' => null, | |
'after' => null | |
); | |
$options = array_merge($defaults, $options); | |
# generic preProcess | |
$this->_preProcess($content, $options); | |
# overlay handler | |
if(!empty($options['overlay'])) { | |
$options['before'] = $this->span(null, 'ui-button-overlay') . $options['before']; | |
} | |
unset($options['overlay']); | |
# content | |
$content = $this->span($content, 'ui-button-text'); | |
if(!empty($options['icon'])) { | |
$content = $this->span(null, 'ui-icon ui-icon-' . $options['icon']) . $content; | |
$options['ui'][] = 'button-icon'; | |
$options['ui'][] = 'button-icon-primary'; | |
} | |
if(!empty($options['icon-right'])) { | |
$content = $content . $this->span(null, 'ui-icon ui-icon-' . $options['icon-right']); | |
$options['ui'][] = 'button-icon'; | |
$options['ui'][] = 'button-icon-secondary'; | |
} | |
unset($options['icon']); | |
# js message handling | |
$message = false; | |
if(!empty($options['message'])) { | |
$message = $options['message']; | |
} | |
unset($options['message']); | |
unset($options['action']); | |
# generic postProcess | |
$this->_postProcess($content, $options); | |
return $this->Html->link($content, $action, $options, $message); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment