class pm_handler_field_operation in Drupal PM (Project Management) 8
Same name and namespace in other branches
- 7.3 includes/views/pm_handler_field_operation.inc \pm_handler_field_operation
- 7 pm_handler_field_operation.inc \pm_handler_field_operation
- 7.2 includes/views/pm_handler_field_operation.inc \pm_handler_field_operation
Field handler for PM operation (edit and delete) links.
Hierarchy
- class \pm_handler_field_operation extends \views_handler_field_node_link
Expanded class hierarchy of pm_handler_field_operation
9 string references to 'pm_handler_field_operation'
- pmexpense_views_default_views in pmexpense/
pmexpense.views_default.inc - Implements hook_views_default_views().
- pmissue_views_default_views in pmissue/
pmissue.views_default.inc - Implements hook_views_default_views().
- pmnote_views_default_views in pmnote/
pmnote.views_default.inc - Implements hook_views_default_views().
- pmorganization_views_default_views in pmorganization/
pmorganization.views_default.inc - Implements hook_views_default_views().
- pmproject_views_default_views in pmproject/
pmproject.views_default.inc - Implements hook_views_default_views().
File
- includes/
views/ pm_handler_field_operation.inc, line 10 - Field handler for PM operation (edit and delete) links.
View source
class pm_handler_field_operation extends views_handler_field_node_link {
/**
* Defines views field options.
*/
public function option_definition() {
$options = parent::option_definition();
$options['display_icons'] = array(
'default' => TRUE,
);
return $options;
}
/**
* Defines views field option form.
*/
public function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$form['display_icons'] = array(
'#type' => 'checkbox',
'#title' => t('Display icon links'),
'#description' => t('Display a icon or a text link for edit, delete and view node links.'),
'#default_value' => $this->options['display_icons'],
);
}
/**
* Renders field to show icon.
*/
public function render($values) {
if ($node = $this
->get_value($values)) {
$id = $node->nid;
if ($this->options['display_icons']) {
$value = "";
$value .= pm_icon_edit_node($node, $_GET);
if (!empty($value)) {
$value .= ' ';
}
$value .= pm_icon_delete_node($node, $_GET);
return $value;
}
else {
$links = array();
if ($link = $this
->create_link_definition(t('edit'), "node/{$id}/edit")) {
$links[] = $link;
}
if ($link = $this
->create_link_definition(t('delete'), "node/{$id}/delete")) {
$links[] = $link;
}
if ($link = $this
->create_link_definition(t('view'), "node/{$id}")) {
$links[] = $link;
}
$vars = array(
'title' => t('Quick Links'),
'links' => $links,
);
return theme('links', $vars);
}
}
}
/**
* Check if path is valid and create links. Returns false otherwise.
*/
public function create_link_definition($title, $path) {
if (drupal_valid_path($path)) {
return array(
'title' => $title,
'href' => $path,
);
}
return FALSE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
pm_handler_field_operation:: |
public | function | Check if path is valid and create links. Returns false otherwise. | |
pm_handler_field_operation:: |
public | function | Defines views field option form. | |
pm_handler_field_operation:: |
public | function | Defines views field options. | |
pm_handler_field_operation:: |
public | function | Renders field to show icon. |