Created
July 4, 2012 09:29
-
-
Save jacquesbh/3046344 to your computer and use it in GitHub Desktop.
Magento - Grid column decorator for 'actions' depending on row
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 | |
/** | |
* Decorate the actions column | |
* @access public | |
* @return string | |
*/ | |
public function decorateActionColumn($value, $row, $column, $isExport) | |
{ | |
$links = array(); | |
foreach ($column->getActions() as $action) { | |
if (isset($action['condition_method']) && !$row->{$action['condition_method']}()) { | |
continue; | |
} | |
if (isset($action['condition']) && !$row->getData($action['condition'])) { | |
continue; | |
} | |
$args = array(); | |
$args['href'] = 'href="' . $this->getUrl($action['url'], array($column->getIndex() => $row->{$column->getGetter()}())) . '"'; | |
$args['title'] = 'title="' . addslashes($action['caption']) . '"'; | |
if (isset($action['onclick'])) { | |
$args['onclick'] = 'onclick="' . $action['onclick'] . '"'; | |
} | |
if (isset($action['confirm'])) { | |
$args['onclick'] = 'onclick="return window.confirm(\'' | |
. addslashes($this->htmlEscape($action['confirm'])) | |
. '\')"'; | |
} | |
$links[] = '<a ' . implode(' ', $args) . '>' . $action['caption'] . '</a>'; | |
} | |
return implode(' ', $links); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment