Skip to content

Instantly share code, notes, and snippets.

@mgcrea
Created November 29, 2010 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgcrea/720424 to your computer and use it in GitHub Desktop.
Save mgcrea/720424 to your computer and use it in GitHub Desktop.
<?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