You are here

function _advanced_forum_buttonify_links in Advanced Forum 6

Same name and namespace in other branches
  1. 5 advanced_forum.module \_advanced_forum_buttonify_links()
2 calls to _advanced_forum_buttonify_links()
advanced_forum_preprocess_comment in ./advanced_forum.module
Preprocesses template variables for the comment template.
advanced_forum_preprocess_node in ./advanced_forum.module
Preprocesses template variables for the node template.

File

./advanced_forum.module, line 1332
Enables the look and feel of other popular forum software.

Code

function _advanced_forum_buttonify_links(&$links) {
  $buttonify = variable_get('advanced_forum_button_links', 1);
  if ($buttonify && !empty($links)) {
    foreach ($links as $link_key => $link) {
      switch ($link_key) {

        // First, take care of the special cases
        case 'comment_add':
          $links[$link_key]['title'] = advanced_forum_theme_image(t('reply.png'), t('reply'));
          $links[$link_key]['html'] = TRUE;
          break;
        case 'comment_reply':
          $links[$link_key]['title'] = advanced_forum_theme_image(t('reply.png'), t('reply'));
          $links[$link_key]['html'] = TRUE;
          break;
        case 'comment_edit':
          $links[$link_key]['title'] = advanced_forum_theme_image(t('edit.png'), t('edit'));
          $links[$link_key]['html'] = TRUE;
          break;
        case 'comment_delete':
          $links[$link_key]['title'] = advanced_forum_theme_image(t('delete.png'), t('delete'));
          $links[$link_key]['html'] = TRUE;
          break;
        default:

          // Attempt to buttonify by key name.
          $image = advanced_forum_theme_image($link_key . '.png', $link['title']);
          if (!$image) {

            // If no luck there, try the adjusted title.
            $title = strtolower(str_replace(' ', '-', $link['title']));
            $image = advanced_forum_theme_image($title . '.png', $link['title']);
          }
          if ($image) {

            // If we found an image, use it. Otherwise leave the title alone.
            $links[$link_key]['title'] = $image;
            $links[$link_key]['html'] = TRUE;
          }
      }
    }
  }
}