示例#1
0
/**
 * Define internal Drupal links.
 *
 * This hook enables modules to add links to many parts of Drupal. Links
 * may be added in the navigation block, for example.
 *
 * The returned array should be a keyed array of link entries. Each link can
 * be in one of two formats.
 *
 * The first format will use the l() function to render the link:
 *   - attributes: Optional. See l() for usage.
 *   - fragment: Optional. See l() for usage.
 *   - href: Required. The URL of the link.
 *   - html: Optional. See l() for usage.
 *   - query: Optional. See l() for usage.
 *   - title: Required. The name of the link.
 *
 * The second format can be used for non-links. Leaving out the href index will
 * select this format:
 *   - title: Required. The text or HTML code to display.
 *   - attributes: Optional. An associative array of HTML attributes to apply to the span tag.
 *   - html: Optional. If not set to true, check_plain() will be run on the title before it is displayed.
 *
 * @param $type
 *   An identifier declaring what kind of link is being requested.
 *   Possible values:
 *   - comment: Links to be placed below a comment being viewed.
 * @param $object
 *   A comment object.
 * @param $teaser
 *   A 0/1 flag depending on whether the node is
 *   displayed with its teaser or its full form.
 * @return
 *   An array of the requested links.
 *
 */
function hook_link($type, $object, $teaser = FALSE)
{
    $links = array();
    if ($type == 'comment') {
        $links = comment_links($object, FALSE);
        return $links;
    }
    return $links;
}
示例#2
0
function boinc_preprocess_comment(&$vars, $hook)
{
    global $user;
    //$vars['sample_variable'] = t('Lorem ipsum.');
    //drupal_set_message('debug: <pre>' . print_r($vars,true) . '</pre>');
    $links = array();
    $moderator_links = array();
    $cid = $vars['comment']->cid;
    $nid = $vars['comment']->nid;
    if ($hook == 'comment') {
        if (user_access('administer comments')) {
            // Reorganize links for moderators
            $vars['links'] = array();
            $links['reply'] = array('title' => bts('Reply'), 'href' => "comment/reply/{$nid}/{$cid}", 'attributes' => array('title' => bts('Reply to this comment')));
            $links['quote'] = array('title' => bts('Quote'), 'href' => "comment/reply/{$nid}/{$cid}", 'attributes' => array('title' => bts('Reply to this comment with quote')), 'fragment' => 'comment-form', 'query' => 'quote=1');
            // Move edit and delete controls into moderator links
            $moderator_links['edit'] = array('title' => bts('Edit'), 'href' => "comment/edit/{$cid}", 'attributes' => array('title' => bts('Edit this comment')));
            $moderator_links['delete'] = array('title' => bts('Delete'), 'href' => "comment/delete/{$cid}", 'attributes' => array('title' => bts('Delete this comment')));
            // Add hide link
            $comment_control = "comment_control/{$cid}";
            if ($vars['comment']->status == 0) {
                $moderator_links['hide'] = array('title' => bts('Hide'), 'href' => "{$comment_control}/hide", 'attributes' => array('title' => bts('Hide this comment')));
            } else {
                $moderator_links['unhide'] = array('title' => bts('Unhide'), 'href' => "{$comment_control}/unhide", 'attributes' => array('title' => bts('Unhide this comment')));
            }
            // Add link to convert comment into a new topic
            $reply_count = db_result(db_query('
        SELECT COUNT(*) FROM comments WHERE pid = %d', $cid));
            if ($reply_count == 0) {
                $moderator_links['convert'] = array('title' => bts('Convert'), 'href' => "{$comment_control}/convert", 'attributes' => array('title' => bts('Convert this comment to a new topic')));
            }
            $vars['moderator_links'] = theme_links($moderator_links);
        } else {
            $links = comment_links($vars['comment'], FALSE);
            if (user_access('post comments')) {
                $links['comment_quote'] = array('title' => bts('Quote'), 'href' => "comment/reply/{$nid}/{$cid}", 'attributes' => array('title' => bts('Reply to this comment with quote')), 'fragment' => 'comment-form', 'query' => 'quote=1');
            }
        }
        ksort($links);
        $vars['links'] = theme_links($links);
        if ($user->uid) {
            $abuse_link = flag_create_link('abuse_comment', $cid);
            if ($abuse_link) {
                $report_comment_link = '' . '<ul class="links">' . '<li class="first">' . $abuse_link . '</li>' . '</ul>';
                $vars['links'] = $report_comment_link . $vars['links'];
            }
        }
        // Show signatures based on user preference
        $vars['show_signatures'] = $user->hide_signatures ? FALSE : TRUE;
    }
}
示例#3
0
/**
 * Define internal Drupal links.
 *
 * This hook enables modules to add links to many parts of Drupal. Links
 * may be added in the navigation block, for example.
 *
 * The returned array should be a keyed array of link entries. Each link can
 * be in one of two formats.
 *
 * The first format will use the l() function to render the link:
 *   - attributes: Optional. See l() for usage.
 *   - fragment: Optional. See l() for usage.
 *   - href: Required. The URL of the link.
 *   - html: Optional. See l() for usage.
 *   - query: Optional. See l() for usage.
 *   - title: Required. The name of the link.
 *
 * The second format can be used for non-links. Leaving out the href index will
 * select this format:
 *   - title: Required. The text or HTML code to display.
 *   - attributes: Optional. An associative array of HTML attributes to apply to the span tag.
 *   - html: Optional. If not set to true, check_plain() will be run on the title before it is displayed.
 *
 * @param $type
 *   An identifier declaring what kind of link is being requested.
 *   Possible values:
 *   - comment: Links to be placed below a comment being viewed.
 * @param $object
 *   A comment object.
 * @param $build_mode
 *   Build mode for the node, e.g. 'full', 'teaser'...
 * @return
 *   An array of the requested links.
 *
 */
function hook_link($type, $object, $build_mode)
{
    $links = array();
    if ($type == 'comment') {
        $links = comment_links($object, FALSE);
        return $links;
    }
    return $links;
}