| 1 |
<?php
|
| 2 |
|
| 3 |
drupal_rebuild_theme_registry();
|
| 4 |
|
| 5 |
/**
|
| 6 |
* Allow themable wrapping of all comments.
|
| 7 |
*/
|
| 8 |
function dark_hostname() {
|
| 9 |
$host = $_SERVER['SERVER_NAME'];
|
| 10 |
$port = $_SERVER['SERVER_PORT']=='80' ? '' : ':'.$_SERVER['SERVER_PORT'];
|
| 11 |
return 'http://' . $host . $port . '/';
|
| 12 |
}
|
| 13 |
|
| 14 |
function dark_node_submitted($node) {
|
| 15 |
return t('<span class="cmt-author">!username</span><span class="cmt-date">!datetime</span>',
|
| 16 |
array(
|
| 17 |
'!username' => theme('username', $node),
|
| 18 |
'!datetime' => format_date($node->created, 'custom', 'M d,Y')
|
| 19 |
)
|
| 20 |
);
|
| 21 |
}
|
| 22 |
|
| 23 |
function dark_comment_submitted($comment) {
|
| 24 |
return t('<span class="cmt-author">!username</span><span class="post-date">!datetime</span>',
|
| 25 |
array(
|
| 26 |
'!username' => theme('username', $comment),
|
| 27 |
'!datetime' => format_date($comment->timestamp, 'custom', 'M d,Y')
|
| 28 |
)
|
| 29 |
);
|
| 30 |
}
|
| 31 |
|
| 32 |
/**
|
| 33 |
* Format an individual feed item for display on the aggregator page.
|
| 34 |
*
|
| 35 |
* @ingroup themeable
|
| 36 |
*/
|
| 37 |
function dark_aggregator_page_item($item) {
|
| 38 |
|
| 39 |
$source = '';
|
| 40 |
if ($item->ftitle && $item->fid) {
|
| 41 |
$source = l($item->ftitle, "aggregator/sources/$item->fid", array('class' => 'feed-item-source'));
|
| 42 |
}
|
| 43 |
|
| 44 |
if (date('Ymd', $item->timestamp) == date('Ymd')) {
|
| 45 |
$source_date = t('%ago ago', array('%ago' => format_interval(time() - $item->timestamp)));
|
| 46 |
}
|
| 47 |
else {
|
| 48 |
$source_date = format_date($item->timestamp, 'custom', 'M d, Y');
|
| 49 |
}
|
| 50 |
|
| 51 |
$output .= "<div class=\"feed-item\">\n";
|
| 52 |
$output .= "<div class=\"feed-item-meta\">$source <span class=\"feed-item-date\">$source_date</span></div>\n";
|
| 53 |
$output .= '<h3 class="feed-item-title"><a href="'. check_url($item->link) .'">'. check_plain($item->title) ."</a></h3>\n";
|
| 54 |
|
| 55 |
if ($item->description) {
|
| 56 |
$output .= '<div class="feed-item-body">'. aggregator_filter_xss($item->description) ."</div>\n";
|
| 57 |
}
|
| 58 |
|
| 59 |
$result = db_query('SELECT c.title, c.cid FROM {aggregator_category_item} ci LEFT JOIN {aggregator_category} c ON ci.cid = c.cid WHERE ci.ii
|
| 60 |
d = %d ORDER BY c.title', $item->iid);
|
| 61 |
$categories = array();
|
| 62 |
while ($category = db_fetch_object($result)) {
|
| 63 |
$categories[] = l($category->title, 'aggregator/categories/'. $category->cid);
|
| 64 |
}
|
| 65 |
if ($categories) {
|
| 66 |
$output .= '<div class="feed-item-categories">'. t('Categories') .': '. implode(', ', $categories) ."</div>\n";
|
| 67 |
}
|
| 68 |
|
| 69 |
$output .= "</div>\n";
|
| 70 |
|
| 71 |
return $output;
|
| 72 |
}
|
| 73 |
|
| 74 |
/**
|
| 75 |
* Format the forum listing.
|
| 76 |
*
|
| 77 |
* @ingroup themeable
|
| 78 |
*/
|
| 79 |
function dark_forum_list($forums, $parents, $tid) {
|
| 80 |
global $user;
|
| 81 |
|
| 82 |
if ($forums) {
|
| 83 |
|
| 84 |
$header = array(t('Forum'), t('Topics'), t('Posts'), t('Last post'));
|
| 85 |
|
| 86 |
foreach ($forums as $forum) {
|
| 87 |
if ($forum->container) {
|
| 88 |
$description = '<div style="margin-left: '. ($forum->depth * 30) ."px;\">\n";
|
| 89 |
$description .= ' <div class="name forum_depth' . $forum->depth . '">'. l($forum->name, "forum/$forum->tid") ."</div>\n";
|
| 90 |
|
| 91 |
if ($forum->description) {
|
| 92 |
$description .= ' <div class="description">'. filter_xss_admin($forum->description) ."</div>\n";
|
| 93 |
}
|
| 94 |
$description .= "</div>\n";
|
| 95 |
|
| 96 |
$rows[] = array(array('data' => $description, 'class' => 'container', 'colspan' => '4'));
|
| 97 |
}
|
| 98 |
else {
|
| 99 |
$new_topics = _forum_topics_unread($forum->tid, $user->uid);
|
| 100 |
$forum->old_topics = $forum->num_topics - $new_topics;
|
| 101 |
if (!$user->uid) {
|
| 102 |
$new_topics = 0;
|
| 103 |
}
|
| 104 |
|
| 105 |
$description = '<div style="margin-left: '. ($forum->depth * 30) ."px;\">\n";
|
| 106 |
$description .= ' <div class="name forum_depth' . $forum->depth . '">'. l($forum->name, "forum/$forum->tid") ."</div>\n";
|
| 107 |
|
| 108 |
if ($forum->description) {
|
| 109 |
$description .= ' <div class="description">'. filter_xss_admin($forum->description) ."</div>\n";
|
| 110 |
}
|
| 111 |
$description .= "</div>\n";
|
| 112 |
|
| 113 |
$rows[] = array(
|
| 114 |
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'),
|
| 116 |
array('data' => $forum->num_posts, 'class' => 'posts'),
|
| 117 |
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 |
|
| 121 |
return theme('table', $header, $rows);
|
| 122 |
|
| 123 |
}
|
| 124 |
|
| 125 |
}
|
| 126 |
|
| 127 |
/**
|
| 128 |
* Format a link to a specific query result page.
|
| 129 |
*
|
| 130 |
* @param $page_new
|
| 131 |
* The first result to display on the linked page.
|
| 132 |
* @param $element
|
| 133 |
* An optional integer to distinguish between multiple pagers on one page.
|
| 134 |
* @param $parameters
|
| 135 |
* An associative array of query string parameters to append to the pager link.
|
| 136 |
* @param $attributes
|
| 137 |
* An associative array of HTML attributes to apply to a pager anchor tag.
|
| 138 |
* @return
|
| 139 |
* An HTML string that generates the link.
|
| 140 |
*/
|
| 141 |
function dark_pager_link($text, $page_new, $element, $parameters = array(), $attributes = array()) {
|
| 142 |
$page = isset($_GET['page']) ? $_GET['page'] : '';
|
| 143 |
if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
|
| 144 |
$parameters['page'] = $new_page;
|
| 145 |
}
|
| 146 |
|
| 147 |
$query = array();
|
| 148 |
if (count($parameters)) {
|
| 149 |
$query[] = drupal_query_string_encode($parameters, array());
|
| 150 |
}
|
| 151 |
$querystring = pager_get_querystring();
|
| 152 |
if ($querystring != '') {
|
| 153 |
$query[] = $querystring;
|
| 154 |
}
|
| 155 |
|
| 156 |
// Set each pager link title
|
| 157 |
if (!isset($attributes['title'])) {
|
| 158 |
static $titles = NULL;
|
| 159 |
if (!isset($titles)) {
|
| 160 |
$titles = array(
|
| 161 |
t('first') => t('Go to first page'),
|
| 162 |
t('previous') => t('Go to previous page'),
|
| 163 |
t('next') => t('Go to next page'),
|
| 164 |
t('last') => t('Go to last page'),
|
| 165 |
);
|
| 166 |
}
|
| 167 |
if (isset($titles[$text])) {
|
| 168 |
$attributes['title'] = $titles[$text];
|
| 169 |
}
|
| 170 |
else if (is_numeric($text)) {
|
| 171 |
$attributes['title'] = t('Go to page @number', array('@number' => $text));
|
| 172 |
}
|
| 173 |
}
|
| 174 |
return '<span class="pager_button">' . l($text, $_GET['q'], array('attributes' => $attributes, 'query' => count($query) ? implode('&', $query) : NULL)) . '</span>';
|
| 175 |
}
|
| 176 |
|
| 177 |
/**
|
| 178 |
* Format a query pager.
|
| 179 |
*
|
| 180 |
* Menu callbacks that display paged query results should call theme('pager') to
|
| 181 |
* retrieve a pager control so that users can view other results.
|
| 182 |
*
|
| 183 |
* @param $tags
|
| 184 |
* An array of labels for the controls in the pager.
|
| 185 |
* @param $limit
|
| 186 |
* The number of query results to display per page.
|
| 187 |
* @param $element
|
| 188 |
* An optional integer to distinguish between multiple pagers on one page.
|
| 189 |
* @param $parameters
|
| 190 |
* An associative array of query string parameters to append to the pager links.
|
| 191 |
* @return
|
| 192 |
* An HTML string that generates the query pager.
|
| 193 |
*
|
| 194 |
* @ingroup themeable
|
| 195 |
*/
|
| 196 |
function dark_pager($tags = array(), $limit = 10, $element = 0, $parameters = array(), $quantity = 9) {
|
| 197 |
global $pager_page_array, $pager_total;
|
| 198 |
|
| 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) {
|
| 232 |
if ($li_first) {
|
| 233 |
$items[] = array(
|
| 234 |
'class' => 'pager-first',
|
| 235 |
'data' => $li_first,
|
| 236 |
);
|
| 237 |
}
|
| 238 |
if ($li_previous) {
|
| 239 |
$items[] = array(
|
| 240 |
'class' => 'pager-previous',
|
| 241 |
'data' => $li_previous,
|
| 242 |
);
|
| 243 |
}
|
| 244 |
|
| 245 |
// 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 |
|
| 298 |
/**
|
| 299 |
* Format a list of nearby pages with additional query results.
|
| 300 |
*
|
| 301 |
* @param $limit
|
| 302 |
* The number of query results to display per page.
|
| 303 |
* @param $element
|
| 304 |
* An optional integer to distinguish between multiple pagers on one page.
|
| 305 |
* @param $quantity
|
| 306 |
* The number of pages in the list.
|
| 307 |
* @param $text
|
| 308 |
* A string of text to display before the page list.
|
| 309 |
* @param $parameters
|
| 310 |
* An associative array of query string parameters to append to the pager links.
|
| 311 |
* @return
|
| 312 |
* An HTML string that generates this piece of the query pager.
|
| 313 |
*
|
| 314 |
* @ingroup themeable
|
| 315 |
*/
|
| 316 |
function dark_pager_list($limit, $element = 0, $quantity = 5, $text = '', $parameters = array()) {
|
| 317 |
global $pager_page_array, $pager_total;
|
| 318 |
|
| 319 |
$output = '<span class="pager-list">';
|
| 320 |
// Calculate various markers within this pager piece:
|
| 321 |
// Middle is used to "center" pages around the current page.
|
| 322 |
$pager_middle = ceil($quantity / 2);
|
| 323 |
// current is the page we are currently paged to
|
| 324 |
$pager_current = $pager_page_array[$element] + 1;
|
| 325 |
// first is the first page listed by this pager piece (re quantity)
|
| 326 |
$pager_first = $pager_current - $pager_middle + 1;
|
| 327 |
// last is the last page listed by this pager piece (re quantity)
|
| 328 |
$pager_last = $pager_current + $quantity - $pager_middle;
|
| 329 |
// max is the maximum page number
|
| 330 |
$pager_max = $pager_total[$element];
|
| 331 |
// End of marker calculations.
|
| 332 |
|
| 333 |
// Prepare for generation loop.
|
| 334 |
$i = $pager_first;
|
| 335 |
if ($pager_last > $pager_max) {
|
| 336 |
// Adjust "center" if at end of query.
|
| 337 |
$i = $i + ($pager_max - $pager_last);
|
| 338 |
$pager_last = $pager_max;
|
| 339 |
}
|
| 340 |
if ($i <= 0) {
|
| 341 |
// Adjust "center" if at start of query.
|
| 342 |
$pager_last = $pager_last + (1 - $i);
|
| 343 |
$i = 1;
|
| 344 |
}
|
| 345 |
// End of generation loop preparation.
|
| 346 |
|
| 347 |
// When there is more than one page, create the pager list.
|
| 348 |
if ($i != $pager_max) {
|
| 349 |
$output .= $text;
|
| 350 |
if ($i > 1) {
|
| 351 |
$output .= '<span class="pager_button">' . '<span class="pager-ellipsis">...</span>' . '</span>';
|
| 352 |
}
|
| 353 |
|
| 354 |
// Now generate the actual pager piece.
|
| 355 |
for (; ($i <= $pager_last) && ($i <= $pager_max); $i++) {
|
| 356 |
if ($i < $pager_current) {
|
| 357 |
$output .= theme('pager_previous', $i, $limit, $element, ($pager_current - $i), $parameters);
|
| 358 |
}
|
| 359 |
if ($i == $pager_current) {
|
| 360 |
$output .= '<span class="pager_button">' . '<strong class="pager-current">'. $i .'</strong>' . '</span>';
|
| 361 |
}
|
| 362 |
if ($i > $pager_current) {
|
| 363 |
$output .= theme('pager_next', $i, $limit, $element, ($i - $pager_current), $parameters);
|
| 364 |
}
|
| 365 |
}
|
| 366 |
|
| 367 |
if ($i < $pager_max) {
|
| 368 |
$output .= '<span class="pager_button">' . '<span class="pager-ellipsis">...</span>' . '</span>';
|
| 369 |
}
|
| 370 |
}
|
| 371 |
$output .= '</span>';
|
| 372 |
|
| 373 |
return $output;
|
| 374 |
}
|
| 375 |
|
| 376 |
/**
|
| 377 |
* Theme the theme search form.
|
| 378 |
*/
|
| 379 |
function dark_search_theme_form($form) {
|
| 380 |
return '<div id="search" class="container-inline">'. str_replace('id="edit-submit"','id="edit-search-submit"',drupal_render($form)) .'</div>';
|
| 381 |
}
|
| 382 |
|
| 383 |
?>
|