Projet

Général

Profil

Révision 13c3c9b4

Ajouté par Assos Assos il y a environ 9 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/advanced_forum/includes/advanced_forum_preprocess_comment.inc
5 5
 * Holds the contents of a preprocess function moved into its own file
6 6
 * to ease memory requirements and having too much code in one file.
7 7
 */
8

  
9
/**
10
 * Preprocess comment.
11
 */
8 12
function _advanced_forum_preprocess_comment(&$variables) {
9 13
  /* Easy links to the comment and parent node */
10 14
  $comment = $variables['comment'];
......
16 20

  
17 21
  /* Determine the template file to use for the comment. */
18 22
  if (arg(1) == 'reply' || arg(2) == 'edit') {
19
    // Use the preview version
23
    // Use the preview version.
20 24
    advanced_forum_add_template_suggestions("post-preview", $variables);
21 25
  }
22 26
  else {
23
    // Use our combined node/comment template file
27
    // Use our combined node/comment template file.
24 28
    advanced_forum_add_template_suggestions("post", $variables);
25 29
  }
26 30

  
27

  
28
  // Add in our classes overwriting existing.
29
  $variables['classes_array'] = array();
31
  if (!variable_get('advanced_forum_keep_classes', FALSE) || !is_array($variables['classes_array'])) {
32
    // Add in our classes overwriting existing.
33
    $variables['classes_array'] = array();
34
  }
30 35
  $variables['classes_array'][] = 'forum-post clearfix';
31 36

  
32 37
  // Add the current language to the classes for image handling.
......
35 40
    $variables['classes_array'][] = $language->language;
36 41
  }
37 42

  
38
  // Add the poster's UID
43
  // Add the poster's UID.
39 44
  $variables['classes_array'][] = "posted-by-$comment->uid";
40 45

  
41 46
  // Add class if the poster is the viewer.
......
49 54
    $variables['classes_array'][] = "post-by-starter";
50 55
  }
51 56

  
52
  // Set the post ID for theming / targetting
57
  // Set the post ID for theming / targetting.
53 58
  $variables['post_id'] = "post-$comment->cid";
54

  
55
  
56

  
57 59
  $num_comments = $node->comment_count;
58 60
  $posts_per_page = variable_get('comment_default_per_page_' . $node->type, 50);
59 61

  
60 62
  $page_number = !empty($_GET['page']) ? $_GET['page'] : 0;
61 63

  
62
  // page_number sanity check
63
  if ($page_number > floor($num_comments / $posts_per_page))
64
  // Page_number sanity check.
65
  if ($page_number > floor($num_comments / $posts_per_page)) {
64 66
    $page_number = floor($num_comments / $posts_per_page);
67
  }
65 68

  
66 69
  if (!$page_number) {
67 70
    $page_number = 0;
68 71
  }
69
  
70 72
  /* Linked post number */
71 73
  if (!isset($post_number)) {
72 74
    static $post_number = 1;
73 75
  }
74
 
75
  // check if node type is forum
76

  
77
  // Check if node type is forum.
76 78
  $topic_id = advanced_forum_node_is_styled($variables['node']);
77 79
  $post_number_delta = ($topic_id) ? 1 : 0;
78
   
79 80
  $linktext = '#' . (($page_number * $posts_per_page) + $post_number + $post_number_delta);
80
  
81 81
  $post_number++;
82
  
83
  // Permalink
84
  //  You can erase next 3 lines if you wish to use built-in Permalink.
85
  //  Template adjusted: $post_link -> $permalink
82

  
83
  // Permalink.
84
  // You can erase next 3 lines if you wish to use built-in Permalink.
85
  // Template adjusted: $post_link -> $permalink.
86 86
  $uri = entity_uri('comment', $comment);
87 87
  $uri['options'] += array('attributes' => array('class' => array('permalink'), 'rel' => 'bookmark'));
88 88
  $variables['permalink'] = l($linktext, $uri['path'], $uri['options']);
......
98 98
    if ($post_position > 0) {
99 99
      // Find the page the post is on. We need to compensate for the topic node
100 100
      // being #1 which puts an extra post on the first page but not on the rest.
101
      $page_number = floor(($post_position - 2) / $posts_per_page);
101
      $page_number = floor(($post_position - 1) / $posts_per_page);
102 102

  
103 103
      // Assemble the link.
104 104
      $fragment = 'comment-' . $comment->pid;
105 105

  
106
      if ($page_number)
106
      if ($page_number) {
107 107
        $query = array('page' => $page_number);
108
      }
108 109

  
109 110
      $linktext = t("(Reply to #!post_position)", array('!post_position' => $post_position));
110 111
      $linkpath = "node/$node->nid";
......
114 115

  
115 116
  /* Title */
116 117
  if (variable_get('comment_subject_field_' . $node->type, 1) == 0) {
117
    // if comment titles are disabled, don't display it.
118
    // If comment titles are disabled, don't display it.
118 119
    $variables['title'] = '';
119 120
  }
120 121
  else {
......
131 132
    $variables['account']->email = empty($comment->email) ? "" : $comment->email;
132 133
  }
133 134
  else {
134
    // Load up the real user object
135
    // Load up the real user object.
135 136
    $variables['account'] = user_load($comment->uid);
136 137
  }
137 138

  
138
  // Create the author pane
139
  // Create the author pane.
139 140
  if (module_exists('author_pane')) {
140 141
    $variables['author_pane'] = theme('author_pane', array(
141 142
      'account' => $variables['account'],
......
152 153
  /* Content */
153 154
  // Helpful $content variable for templates.
154 155
  foreach (element_children($variables['elements']) as $key) {
155
    // Adjust content vriable to suit post template
156
    if ($key == 'comment_body')
156
    // Adjust content vriable to suit post template.
157
    if ($key == 'comment_body') {
157 158
      $variables['content']['body'] = $variables['elements'][$key];
158
    else
159
    }
160
    else {
159 161
      $variables['content'][$key] = $variables['elements'][$key];
162
    }
160 163
  }
161 164

  
162
  // Adjust comment timestamp to match node template
165
  // Adjust comment timestamp to match node template.
163 166
  $variables['date'] = $variables['created'];
164 167

  
165 168
  /* Post edited */
166 169
  $variables['post_edited'] = (isset($variables['comment_edited'])) ? $variables['comment_edited'] : "";
167
}
170
}

Formats disponibles : Unified diff