Permalink
Browse files

Changed templates and helper to remove SPAN tags used to display icon…

…s and add icon name to link/button class attribute.
  • Loading branch information...
1 parent 74f822d commit b3a74f2010d601e79d50cb2d00b4c101453b5319 @mgiagnoni mgiagnoni committed Jan 30, 2011
@@ -14,59 +14,53 @@ class Base<?php echo ucfirst($this->getModuleName()) ?>GeneratorHelper extends s
public function linkToShow($object, $params)
{
- $params['ui-icon'] = $this->getIcon('show', $params);
- return '<li class="sf_admin_action_show">'.link_to(UIHelper::addIcon($params) . __($params['label'], array(), 'sf_admin'), $this->getUrlForAction('show'), $object, $params['params']).'</li>';
+ $params = $this->addClass('show', $params);
+ return '<li class="sf_admin_action_show">'.link_to(__($params['label'], array(), 'sf_admin'), $this->getUrlForAction('show'), $object, $params['params']).'</li>';
}
public function linkToNew($params)
{
- if (!key_exists('ui-icon', $params)) $params['ui-icon'] = '';
- $params['params'] = UIHelper::addClasses($params, '');
- $params['ui-icon'] = $this->getIcon('new', $params);
- return '<li class="sf_admin_action_new">'.link_to(UIHelper::addIcon($params) . __($params['label'] , array(), 'sf_admin'), '@'.$this->getUrlForAction('new'), $params['params']).'</li>';
+ $params = $this->addClass('new', $params);
+ return '<li class="sf_admin_action_new">'.link_to(__($params['label'] , array(), 'sf_admin'), '@'.$this->getUrlForAction('new'), $params['params']).'</li>';
}
public function linkToEdit($object, $params)
{
- $params['ui-icon'] = $this->getIcon('edit', $params);
- return '<li class="sf_admin_action_edit">'.link_to(UIHelper::addIcon($params) . __($params['label'], array(), 'sf_admin'), $this->getUrlForAction('edit'), $object, $params['params']).'</li>';
+ $params = $this->addClass('edit', $params);
+ return '<li class="sf_admin_action_edit">'.link_to(__($params['label'], array(), 'sf_admin'), $this->getUrlForAction('edit'), $object, $params['params']).'</li>';
}
public function linkToDelete($object, $params)
{
- $params['params'] = UIHelper::arrayToString(array('class' => UIHelper::getClasses($params['params']).' ui-priority-secondary'));
-
if ($object->isNew())
{
return '';
}
- $params['ui-icon'] = $this->getIcon('delete', $params);
- return '<li class="sf_admin_action_delete">'.link_to(UIHelper::addIcon($params) . __($params['label'], array(), 'sf_admin'), $this->getUrlForAction('delete'), $object, array('class' => UIHelper::getClasses($params['params']),'method' => 'delete', 'confirm' => !empty($params['confirm']) ? __($params['confirm'], array(), 'sf_admin') : $params['confirm'])).'</li>';
+ $params = $this->addClass('delete', $params, ' ui-priority-secondary');
+ return '<li class="sf_admin_action_delete">'.link_to(__($params['label'], array(), 'sf_admin'), $this->getUrlForAction('delete'), $object, array('class' => UIHelper::getClasses($params['params']),'method' => 'delete', 'confirm' => !empty($params['confirm']) ? __($params['confirm'], array(), 'sf_admin') : $params['confirm'])).'</li>';
}
public function linkToList($params)
{
- $params['ui-icon'] = $this->getIcon('list', $params);
- return '<li class="sf_admin_action_list">'.link_to(UIHelper::addIcon($params) . __($params['label'], array(), 'sf_admin'), '@'.$this->getUrlForAction('list'),$params['params']).'</li>';
+ $params = $this->addClass('list', $params);
+ return '<li class="sf_admin_action_list">'.link_to(__($params['label'], array(), 'sf_admin'), '@'.$this->getUrlForAction('list'),$params['params']).'</li>';
}
public function linkToSave($object, $params)
{
- $params['ui-icon'] = $this->getIcon('save', $params);
- return '<li class="sf_admin_action_save"><button type="submit" class="fg-button ui-state-default fg-button-icon-left">'. UIHelper::addIcon($params) . __($params['label'], array(), 'sf_admin').'</button></li>';
+ $params = $this->addClass('save', $params);
+ return '<li class="sf_admin_action_save"><button type="submit" class="'. UIHelper::getClasses($params['params']) . '">'. __($params['label'], array(), 'sf_admin').'</button></li>';
}
public function linkToSaveAndAdd($object, $params)
{
- $params['ui-icon'] = $this->getIcon('saveAndAdd', $params);
-
if (!$object->isNew())
{
return '';
}
-
- return '<li class="sf_admin_action_save_and_add"><button type="submit" name="_save_and_add" class="fg-button ui-state-default fg-button-icon-left"/>'. UIHelper::addIcon($params) . __($params['label'], array(), 'sf_admin').'</button></li>';
+ $params = $this->addClass('saveAndAdd', $params);
+ return '<li class="sf_admin_action_save_and_add"><button type="submit" name="_save_and_add" class="'. UIHelper::getClasses($params['params']) . '">'. UIHelper::addIcon($params) . __($params['label'], array(), 'sf_admin').'</button></li>';
}
public function getUrlForAction($action)
@@ -78,4 +72,16 @@ protected function getIcon($type, $params)
{
return empty($params['ui-icon']) ? UIHelper::getIcon($type) : $params['ui-icon'];
}
+
+ protected function addClass($type, $params, $extra = '')
+ {
+ $icon = $this->getIcon($type, $params);
+ if($icon)
+ {
+ $icon = ' ui-icon-' . $icon;
+ }
+ $params['params'] = UIHelper::arrayToString(array('class' => UIHelper::getClasses($params['params']).$icon.' '.$extra));
+
+ return $params;
+ }
}
@@ -4,9 +4,9 @@
<table>
<caption class="fg-toolbar ui-widget-header ui-corner-top">
<?php if ($this->configuration->hasFilterForm()): ?>
- <div id="sf_admin_filters_buttons" class="fg-buttonset fg-buttonset-multi ui-state-default">
- <a href="#sf_admin_filter" id="sf_admin_filter_button" class="fg-button ui-state-default fg-button-icon-left ui-corner-left">[?php echo UIHelper::addIconByConf('filters') . __('Filters', array(), 'sf_admin') ?]</a>
- [?php echo link_to(UIHelper::addIconByConf('reset') . __('Reset', array(), 'sf_admin'), '<?php echo $this->getUrlForAction('collection') ?>', array('action' => 'filter'), array('query_string' => '_reset', 'method' => 'post', 'class' => 'fg-button ui-state-default fg-button-icon-left ui-corner-right')) ?]</span>
+ <div id="sf_admin_filters_buttons">
+ <a href="#sf_admin_filter" id="sf_admin_filter_button" class="ui-corner-left [?php echo UIHelper::getIconClass('filters')?]">[?php echo __('Filters', array(), 'sf_admin') ?]</a>
+ [?php echo link_to(__('Reset', array(), 'sf_admin'), '<?php echo $this->getUrlForAction('collection') ?>', array('action' => 'filter'), array('query_string' => '_reset', 'method' => 'post', 'class' => 'ui-corner-right '. UIHelper::getIconClass('reset'))) ?]</span>
</div>
<?php endif; ?>
<h1><span class="ui-icon ui-icon-triangle-1-s"></span> [?php echo <?php echo $this->getI18NString('list.title') ?> ?]</h1>
@@ -25,10 +25,10 @@
<table>
<caption class="fg-toolbar ui-widget-header ui-corner-top">
<?php if ($this->configuration->hasFilterForm()): ?>
- <div id="sf_admin_filters_buttons" class="fg-buttonset fg-buttonset-multi ui-state-default">
- <a href="#sf_admin_filter" id="sf_admin_filter_button" class="fg-button ui-state-default fg-button-icon-left ui-corner-left">[?php echo UIHelper::addIconByConf('filters') . __('Filters', array(), 'sf_admin') ?]</a>
- [?php $isDisabledResetButton = ($hasFilters->getRawValue()) ? '' : ' ui-state-disabled' ?]
- [?php echo link_to(UIHelper::addIconByConf('reset') . __('Reset', array(), 'sf_admin'), '<?php echo $this->getUrlForAction('collection') ?>', array('action' => 'filter'), array('query_string' => '_reset', 'method' => 'post', 'class' => 'fg-button ui-state-default fg-button-icon-left ui-corner-right'.$isDisabledResetButton)) ?]</span>
+ <div id="sf_admin_filters_buttons">
+ <a href="#sf_admin_filter" id="sf_admin_filter_button" class="ui-corner-left [?php echo UIHelper::getIconClass('filters')?]">[?php echo __('Filters', array(), 'sf_admin') ?]</a>
+ [?php $isDisabledResetButton = ($hasFilters->getRawValue()) ? '' : ' disabled' ?]
+ [?php echo link_to(__('Reset', array(), 'sf_admin'), '<?php echo $this->getUrlForAction('collection') ?>', array('action' => 'filter'), array('query_string' => '_reset', 'method' => 'post', 'class' => 'ui-corner-right '.UIHelper::getIconClass('reset').$isDisabledResetButton)) ?]</span>
</div>
<?php endif; ?>
<h1><span class="ui-icon ui-icon-triangle-1-s"></span> [?php echo <?php echo $this->getI18NString('list.title') ?> ?]</h1>
@@ -3,7 +3,7 @@
<?php foreach ($this->configuration->getValue('list.object_actions') as $name => $params): ?>
<?php
if (!key_exists('ui-icon', $params)) $params['ui-icon'] = '';
- $params['params'] = UIHelper::addClasses($params, 'fg-button-mini');
+ $params['params'] = UIHelper::addClasses($params);
?>
<?php if ('_delete' == $name): ?>
@@ -18,8 +18,7 @@ class UIHelper
*/
static public function addClasses(array $params, $extra = '')
{
- $iconClass = (isset($params['ui-icon'])) ? 'fg-button-icon-left' : '';
- $uiClasses = sprintf('%s fg-button ui-state-default %s', $extra, $iconClass);
+ $uiClasses = sprintf('%s ui-state-default', $extra);
$uiParams = is_array($params['params']) ? $params['params'] : sfToolkit::stringToArray($params['params']);
$uiParams['class'] = $uiClasses;
@@ -101,4 +100,13 @@ static public function getIcon($type)
return array_key_exists($type, self::$icons) ? self::$icons[$type] : '';
}
+ static public function getIconClass($type)
+ {
+ if($icon = self::getIcon($type))
+ {
+ $icon = 'ui-icon-' . $icon;
+ }
+
+ return $icon;
+ }
}

0 comments on commit b3a74f2

Please sign in to comment.