class pm_handler_area_addcontent in Drupal PM (Project Management) 8
Same name and namespace in other branches
- 7.3 includes/views/pm_handler_area_addcontent.inc \pm_handler_area_addcontent
- 7.2 includes/views/pm_handler_area_addcontent.inc \pm_handler_area_addcontent
Area handler for PM add content link.
Hierarchy
- class \pm_handler_area_addcontent extends \views_handler_area
Expanded class hierarchy of pm_handler_area_addcontent
10 string references to 'pm_handler_area_addcontent'
- 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_area_addcontent.inc, line 10 - Area handler for PM add content link.
View source
class pm_handler_area_addcontent extends views_handler_area {
/**
* Get this field's label.
*/
public function option_definition() {
$options = parent::option_definition();
$options['node_type'] = array(
'default' => NULL,
);
$options['redirect'] = array(
'default' => 1,
'bool' => TRUE,
);
return $options;
}
/**
* Define options form.
*/
public function options_form(&$form, &$form_state) {
$form['node_type'] = array(
'#type' => 'select',
'#title' => t('Content type'),
'#options' => node_type_get_names(),
'#default_value' => $this->options['node_type'],
);
$form['redirect'] = array(
'#type' => 'checkbox',
'#title' => t('Redirect'),
'#description' => t('If checked, the user will be redirected back to this view after saving the new content.'),
'#default_value' => $this->options['redirect'],
);
}
/**
* Render the area.
*/
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 '';
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
pm_handler_area_addcontent:: |
public | function | Define options form. | |
pm_handler_area_addcontent:: |
public | function | Get this field's label. | |
pm_handler_area_addcontent:: |
public | function | Render the area. |