3 /*******************************************************************************
5 Author: Christopher Messina
8 Copyright: (cc) Share alike 2005, some rights reserved.
10 Thanks to cxj and moshe in #drupal for their help.
12 *******************************************************************************/
14 function phptemplate_breadcrumb($breadcrumb) {
15 $breadcrumb[] = drupal_get_title();
16 return "<div class=\"hide\">You are here:</div>\n<ul>\n<li class=\"first\">". implode("</li>\n<li>", $breadcrumb) ."</li>\n</ul>\n";
19 function phptemplate_xml_icon($url) {
20 $dir = base_path() . path_to_theme() . '/images/rss.png';
21 if ($image = theme('image', $dir, t('XML feed'), t('XML feed'))) {
22 return '<div class="xml-icon"><a href="'. $url .'" title="Subscribe to RSS feed">'. $image .'</a></div>';
26 function _word_split($text) {
27 global $democratica_word_length;
28 return preg_replace('/([^ ]{'. $democratica_word_length .'})(?=[^ ])/u', '\1-<wbr />', $text[0]);
31 function word_split($text, $max_char = 15) {
32 global $democratica_word_length;
33 $democratica_word_length = $max_char;
34 return substr(preg_replace_callback('/>[^<]+</', '_word_split', '>'. $text .'<'), 1, -1);
37 function phptemplate_comment_thread_min($comment, $threshold, $pid = 0) {
38 if (comment_visible($comment, $threshold)) {
40 $output .= theme('comment_view', $comment, '', 0);
46 function phptemplate_comment_thread_max($comment, $threshold, $level = 0) {
48 if ($comment->depth) {
52 $output .= theme('comment_view', $comment, theme('links', module_invoke_all('link', 'comment', $comment, 0)), comment_visible($comment, $threshold));
54 if ($comment->depth) {
61 function phptemplate_status_messages() {
62 if ($data = drupal_get_messages()) {
64 foreach ($data as $type => $messages) {
65 $output .= "<div class=\"messages $type\">\n";
67 foreach($messages as $message) {
68 $output .= ' <li>'. $message ."</li>\n";
70 $output .= " </ul>\n";
71 $output .= "</div>\n";
77 function phptemplate_aggregator_page_item($item) {
80 $date = date('Ymd', $item->timestamp);
83 $output .= '<h2 class="aggregator-date">'. date('F j, Y', $item->timestamp) ."</h2>\n";
86 $output .= "<div class=\"news-item\">\n";
87 $output .= " <h3 class=\"news-item-title\"><a href=\"$item->link\">$item->title</a></h3>\n";
88 if ($item->ftitle && $item->fid) { $output .= ' <div class="news-item-source"> Source: '. l($item->ftitle, "aggregator/sources/$item->fid") .' @ <span class="news-item-date">'. date('H:i', $item->timestamp) ."</span>\n</div>\n"; }
89 $output .= " <div class=\"news-item-body\">\n";
90 if ($item->description) {
91 $output .= " <div class=\"news-item-description\">$item->description</div>\n";
94 $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.iid = %d ORDER BY c.title', $item->iid);
95 $categories = array();
96 while ($category = db_fetch_object($result)) {
97 $categories[] = l($category->title, 'aggregator/categories/'. $category->cid);
100 $output .= ' <div class="news-item-categories">'. t('Categories') .': '. implode(', ', $categories) ."</div>\n";
103 $output .= " </div>\n";
104 $output .= "</div>\n";
110 function phptemplate_menu_item($mid) {
111 $menu = menu_get_menu();
114 while ($menu['items'][$link_mid]['type'] & MENU_LINKS_TO_PARENT) {
115 $link_mid = $menu['items'][$link_mid]['pid'];
119 $local_tasks = menu_get_local_tasks();
120 if (menu_in_active_trail($mid)) {
121 $class = array('class' => 'current');
124 return l($menu['items'][$mid]['title'],
125 $menu['items'][$link_mid]['path'],
126 array_key_exists('description', $menu['items'][$mid]) ? array_merge($class, array("title" => $menu['items'][$mid]['description'])) : $class);
129 function phptemplate_menu_local_task($mid, $active) {
130 $local_tasks = menu_get_local_tasks();
131 $pid = menu_get_active_nontask_item();
132 $menu = menu_get_menu();
134 if ($menu['items'][$mid]['children'][0] == menu_get_active_item()) {
135 $output = '<li class="active"><span>'. $menu['items'][$mid]['title'] .'</span>';
138 $output = '<li class="active">'. theme('menu_item', $mid) ."</li>\n";
140 foreach ($local_tasks[$pid]['children'] as $mid) {
141 if (menu_in_active_trail($mid) && count($local_tasks[$mid]['children']) > 1) {
142 $output .= "<ul class=\"secondary\">\n";
143 foreach ($local_tasks[$mid]['children'] as $cid) {
144 $output .= theme('menu_local_task', $cid, 0);
146 $output .= "</ul>\n";
149 $output .= "</li>\n";
153 if (menu_in_active_trail($mid)) {
154 return '<li class="active"><span>'. $menu['items'][$mid]['title'] ."</span></li>\n";
157 return '<li>'. theme('menu_item', $mid) ."</li>\n";
162 function phptemplate_menu_local_tasks() {
163 $local_tasks = menu_get_local_tasks();
164 $pid = menu_get_active_nontask_item();
167 if (count($local_tasks[$pid]['children'])) {
168 $output .= "<div id=\"local-tasks\">\n";
169 $output .= " <ul class=\"primary\">\n";
170 foreach ($local_tasks[$pid]['children'] as $mid) {
171 $output .= theme('menu_local_task', $mid, menu_in_active_trail($mid));
173 $output .= " </ul>\n";
174 $output .= "</div>\n";