/[drupal]/contributions/themes/dark/template.php
ViewVC logotype

Diff of /contributions/themes/dark/template.php

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.3, Sat Dec 8 11:25:59 2007 UTC revision 1.4, Sat Dec 20 19:10:18 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2    
3    drupal_rebuild_theme_registry();
4    
5  /**  /**
6   * Allow themable wrapping of all comments.   * Allow themable wrapping of all comments.
7   */   */
# Line 8  function dark_hostname() { Line 11  function dark_hostname() {
11    return 'http://' . $host . $port . '/';    return 'http://' . $host . $port . '/';
12  }  }
13    
 function dark_node_wrapper($content, $type = null) {  
   static $node_type;  
   if (isset($type)) $node_type = $type;  
   
   if (!$content || $node_type == 'forum') {  
     return '<div id="comments">'. $content . '</div>';  
   }  
   else {  
     return '<div id="comments"><h2 class="comments">'. t('Comments') .'</h2>'. $content .'</div>';  
   }  
 }  
   
14  function dark_node_submitted($node) {  function dark_node_submitted($node) {
15    return t('<span class="cmt-author">!username</span><span class="cmt-date">@datetime</span>',    return t('<span class="cmt-author">!username</span><span class="cmt-date">!datetime</span>',
16      array(      array(
17        '!username' => theme('username', $node),        '!username' => theme('username', $node),
18        '@datetime' => format_date($node->created, 'custom', 'M d,Y')        '!datetime' => format_date($node->created, 'custom', 'M d,Y')
19      ));      )
20      );
21  }  }
22    
23  function dark_node($node, $teaser = 0, $page = 0) {  function dark_comment_submitted($comment) {
24    if (module_exists('taxonomy')) {    return t('<span class="cmt-author">!username</span><span class="post-date">!datetime</span>',
25      $taxonomy = taxonomy_link('taxonomy terms', $node);      array(
26    }        '!username' => theme('username', $comment),
27    else {        '!datetime' => format_date($comment->timestamp, 'custom', 'M d,Y')
28      $taxonomy = array();      )
   }  
   
   $variables = array(  
     'content'        => ($teaser && $node->teaser) ? $node->teaser : $node->body,  
     'date'           => format_date($node->created),  
     'links'          => $node->links ? theme('links', $node->links, array('class' => 'links inline')) : '',  
     'name'           => theme('username', $node),  
     'node'           => $node,  // we pass the actual node to allow more customization  
     'node_url'       => url('node/'. $node->nid),  
     'page'           => $page,  
     'taxonomy'       => $taxonomy,  
     'teaser'         => $teaser,  
     'terms'          => theme('links', $taxonomy, array('class' => 'links inline')),  
     'title'          => check_plain($node->title)  
29    );    );
   
   // Flatten the node object's member fields.  
   $variables = array_merge((array)$node, $variables);  
   
   // Display info only on certain node types.  
   if (theme_get_setting('toggle_node_info_' . $node->type)) {  
     $variables['submitted'] = t('<span class="cmt-author">!username</span><span class="post-date">@datetime</span>', array('!username' => theme('username', $node), '@datetime' => format_date($node->created, 'custom', 'M d,Y')));  
     $variables['picture'] = theme_get_setting('toggle_node_user_picture') ? theme('user_picture', $node) : '';  
   }  
   else {  
     $variables['submitted'] = '';  
     $variables['picture'] = '';  
   }  
   
   return _phptemplate_callback('node', $variables, array('node-' . $node->type));  
 }  
 /**  
  * Prepare the values passed to the theme_comment function to be passed  
  * into a pluggable template engine.  
  */  
 function dark_comment($comment, $links = 0) {  
   return _phptemplate_callback('comment', array(  
     'author'    => theme('username', $comment),  
     'comment'   => $comment,  
     'content'   => $comment->comment,  
     'date'      => format_date($comment->timestamp),  
     'links'     => isset($links) ? theme('links', $links) : '',  
     'new'       => $comment->new ? t('new') : '',  
     'picture'   => theme_get_setting('toggle_comment_user_picture') ? theme('user_picture', $comment) : '',  
     'submitted' => t('<span class="cmt-author">!username</span><span class="post-date">@datetime</span>', array('!username' => theme('username', $comment), '@datetime' => format_date($comment->timestamp, 'custom', 'M d,Y'))),  
     'title'     => l($comment->subject, $_GET['q'], NULL, NULL, "comment-$comment->cid")  
   ));  
30  }  }
31    
32  /**  /**
# Line 168  function dark_forum_list($forums, $paren Line 114  function dark_forum_list($forums, $paren
114            array('data' => $description, 'class' => 'forum'),            array('data' => $description, 'class' => 'forum'),
115            array('data' => $forum->num_topics . ($new_topics ? '<br />'. l(format_plural($new_topics, '1 new', '@count new'), "forum/$forum->tid", NULL, NULL, 'new') : ''), 'class' => 'topics'),            array('data' => $forum->num_topics . ($new_topics ? '<br />'. l(format_plural($new_topics, '1 new', '@count new'), "forum/$forum->tid", NULL, NULL, 'new') : ''), 'class' => 'topics'),
116            array('data' => $forum->num_posts, 'class' => 'posts'),            array('data' => $forum->num_posts, 'class' => 'posts'),
117            array('data' => _forum_format($forum->last_post), 'class' => 'last-reply'));                    array('data' => $forum->last_post && $forum->last_post->timetamp? t('@time ago<br />by !author', array('@time' => format_interval(time() - $forum->last_post->timestamp), '!author' => theme('username', $forum->last_post))) : t('n/a')));
118        }        }
119      }      }
120    
# Line 212  function dark_pager_link($text, $page_ne Line 158  function dark_pager_link($text, $page_ne
158      static $titles = NULL;      static $titles = NULL;
159      if (!isset($titles)) {      if (!isset($titles)) {
160        $titles = array(        $titles = array(
161          t('&#8676; first') => t('Go to first page'),          t('first') => t('Go to first page'),
162          t('&#8249; previous') => t('Go to previous page'),          t('previous') => t('Go to previous page'),
163          t('next &#8250;') => t('Go to next page'),          t('next') => t('Go to next page'),
164          t('last &#8677;') => t('Go to last page'),          t('last') => t('Go to last page'),
165        );        );
166      }      }
167      if (isset($titles[$text])) {      if (isset($titles[$text])) {
# Line 225  function dark_pager_link($text, $page_ne Line 171  function dark_pager_link($text, $page_ne
171        $attributes['title'] = t('Go to page @number', array('@number' => $text));        $attributes['title'] = t('Go to page @number', array('@number' => $text));
172      }      }
173    }    }
174    return '<span class="pager_button">' . l($text, $_GET['q'], $attributes, count($query) ? implode('&', $query) : NULL, NULL, FALSE, TRUE) . '</span>';    return '<span class="pager_button">' . l($text, $_GET['q'], array('attributes' => $attributes, 'query' => count($query) ? implode('&', $query) : NULL)) . '</span>';
175  }  }
176    
177  /**  /**
# Line 247  function dark_pager_link($text, $page_ne Line 193  function dark_pager_link($text, $page_ne
193   *   *
194   * @ingroup themeable   * @ingroup themeable
195   */   */
196  function dark_pager($tags = array(), $limit = 10, $element = 0, $parameters = array()) {  function dark_pager($tags = array(), $limit = 10, $element = 0, $parameters = array(), $quantity = 9) {
197    global $pager_total;    global $pager_page_array, $pager_total;
198    $output = '';  
199      // Calculate various markers within this pager piece:
200      // Middle is used to "center" pages around the current page.
201      $pager_middle = ceil($quantity / 2);
202      // current is the page we are currently paged to
203      $pager_current = $pager_page_array[$element] + 1;
204      // first is the first page listed by this pager piece (re quantity)
205      $pager_first = $pager_current - $pager_middle + 1;
206      // last is the last page listed by this pager piece (re quantity)
207      $pager_last = $pager_current + $quantity - $pager_middle;
208      // max is the maximum page number
209      $pager_max = $pager_total[$element];
210      // End of marker calculations.
211    
212      // Prepare for generation loop.
213      $i = $pager_first;
214      if ($pager_last > $pager_max) {
215        // Adjust "center" if at end of query.
216        $i = $i + ($pager_max - $pager_last);
217        $pager_last = $pager_max;
218      }
219      if ($i <= 0) {
220        // Adjust "center" if at start of query.
221        $pager_last = $pager_last + (1 - $i);
222        $i = 1;
223      }
224      // End of generation loop preparation.
225    
226      $li_first = theme('pager_first', (isset($tags[0]) ? $tags[0] : t('first')), $limit, $element, $parameters);
227      $li_previous = theme('pager_previous', (isset($tags[1]) ? $tags[1] : t('previous')), $limit, $element, 1, $parameters);
228      $li_next = theme('pager_next', (isset($tags[3]) ? $tags[3] : t('next')), $limit, $element, 1, $parameters);
229      $li_last = theme('pager_last', (isset($tags[4]) ? $tags[4] : t('last')), $limit, $element, $parameters);
230    
231    if ($pager_total[$element] > 1) {    if ($pager_total[$element] > 1) {
232      $output .= '<div class="pager">';      if ($li_first) {
233      $output .= theme('pager_first', ($tags[0] ? $tags[0] : t('&#8676; first')), $limit, $element, $parameters);        $items[] = array(
234      $output .= theme('pager_previous', ($tags[1] ? $tags[1] : t('&#8249; previous')), $limit, $element, 1, $parameters);          'class' => 'pager-first',
235      $output .= theme('pager_list', $limit, $element, ($tags[2] ? $tags[2] : 4 ), '', $parameters);          'data' => $li_first,
236      $output .= theme('pager_next', ($tags[3] ? $tags[3] : t('next &#8250;')), $limit, $element, 1, $parameters);        );
237      $output .= theme('pager_last', ($tags[4] ? $tags[4] : t('last &#8677;')), $limit, $element, $parameters);      }
238      $output .= '</div>';      if ($li_previous) {
239          $items[] = array(
240            'class' => 'pager-previous',
241            'data' => $li_previous,
242          );
243        }
244    
245      return $output;      // When there is more than one page, create the pager list.
246        if ($i != $pager_max) {
247          if ($i > 1) {
248            $items[] = array(
249              'class' => 'pager-ellipsis',
250              'data' => 'É',
251            );
252          }
253          // Now generate the actual pager piece.
254          for (; $i <= $pager_last && $i <= $pager_max; $i++) {
255            if ($i < $pager_current) {
256              $items[] = array(
257                'class' => 'pager-item',
258                'data' => theme('pager_previous', $i, $limit, $element, ($pager_current - $i), $parameters),
259              );
260            }
261            if ($i == $pager_current) {
262              $items[] = array(
263                'class' => 'pager-current',
264                'data' => $i,
265              );
266            }
267            if ($i > $pager_current) {
268              $items[] = array(
269                'class' => 'pager-item',
270                'data' => theme('pager_next', $i, $limit, $element, ($i - $pager_current), $parameters),
271              );
272            }
273          }
274          if ($i < $pager_max) {
275            $items[] = array(
276              'class' => 'pager-ellipsis',
277              'data' => 'É',
278            );
279          }
280        }
281        // End generation.
282        if ($li_next) {
283          $items[] = array(
284            'class' => 'pager-next',
285            'data' => $li_next,
286          );
287        }
288        if ($li_last) {
289          $items[] = array(
290            'class' => 'pager-last',
291            'data' => $li_last,
292          );
293        }
294        return '<div class="pager">' . theme('item_list', $items, NULL, 'ul', array('class' => 'pager')) . '</div>';
295    }    }
296  }  }
297    

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.2