You are here

public function pm_handler_area_addcontent::render in Drupal PM (Project Management) 8

Same name and namespace in other branches
  1. 7.3 includes/views/pm_handler_area_addcontent.inc \pm_handler_area_addcontent::render()
  2. 7.2 includes/views/pm_handler_area_addcontent.inc \pm_handler_area_addcontent::render()

Render the area.

File

includes/views/pm_handler_area_addcontent.inc, line 49
Area handler for PM add content link.

Class

pm_handler_area_addcontent
Area handler for PM add content link.

Code

public function render($empty = FALSE) {

  // Only show a link if the user has permissions for the destination.
  if (node_access('create', $this->options['node_type']) === TRUE) {
    $node_type_name = node_type_get_name($this->options['node_type']);
    $link_icon = pm_icon('application_add', '');
    $link_text = t('Add @node_type_name', array(
      '@node_type_name' => $node_type_name,
    ));
    $link_path = 'node/add/' . $this->options['node_type'];
    $link_options = array(
      'html' => TRUE,
    );
    if ($this->options['redirect'] == TRUE) {
      $link_options['query'] = array(
        'destination' => current_path(),
      );
    }
    return l($link_icon . $link_text, $link_path, $link_options);
  }
  else {
    return '';
  }
}