You are here

function ccl_actions_ccl_link_info in Custom Contextual Links 8

Same name and namespace in other branches
  1. 7 ccl_actions/ccl_actions.module \ccl_actions_ccl_link_info()

Hook function to provide link option information for the link list page.

File

ccl_actions/ccl_actions.module, line 336
Implementation of core actions for CCL.

Code

function ccl_actions_ccl_link_info($record) {
  if ($record->type == 'action') {

    // Get content type names.
    $cts = node_type_get_names();

    // @FIXME
    // l() expects a Url object, created from a route name or external URI.
    // $options_return['op'] = l(t('Edit'), 'admin/config/user-interface/ccl/action/' . $record->clid . '/edit') . ' | ' . l(t('Delete'), 'admin/config/user-interface/ccl/' . $record->clid . '/delete');
    $options = unserialize($record->options);
    switch ($options['node_options']) {
      case 'global':
        $options_return['desc'] = t('Attached to all nodes.');
        break;
      case 'ct':
        $options_return['desc'] = t('Attached to all nodes of the content type %ct.', array(
          '%ct' => $cts[$options['node_type']],
        ));
        break;
      case 'node':
        $node_title = db_query('SELECT title FROM {node} WHERE nid = :nid', array(
          ':nid' => $options['node_id'],
        ))
          ->fetchField();
        $options_return['desc'] = t('Attached to %node_title [NID: !nid].', array(
          '%node_title' => $node_title,
          '!nid' => $options['node_id'],
        ));
        break;
    }
    return $options_return;
  }
  else {
    return "";
  }
}