Parent Directory
|
Revision Log
|
Revision Graph
|
Patch
| revision 1.1.2.14.2.1, Fri Nov 7 01:00:12 2008 UTC | revision 1.1.2.14.2.2, Tue Jun 16 03:46:25 2009 UTC | |
|---|---|---|
| # | Line 1 | Line 1 |
| 1 | <?php | <?php |
| 2 | // $Id$ | // $Id: drigg_ui.module,v 1.1.2.14.2.1 2008/11/07 01:00:12 mercmobily Exp $ |
| 3 | ||
| 4 | /** | /** |
| 5 | * @file | * @file |
| 6 | */ | */ |
| 7 | ||
| 8 | /** | /** |
| 9 | * Implementation of hook_help(). | * Implementation of hook_help(). |
| 10 | */ | */ |
| 11 | function drigg_ui_help($path, $arg) { | function drigg_ui_help($path, $arg) { |
| 12 | switch ($path) { | switch ($path) { |
| 13 | } | } |
| 14 | } | } |
| 15 | ||
| 16 | /** | /** |
| 17 | * Implementation of hook_menu(). | * Implementation of hook_menu(). |
| 18 | * | * |
| 19 | * This is again "the usual story". However, note that this "menu" is | * This is again "the usual story". However, note that this "menu" is |
| 20 | * quite tricky, because it needs to pass the right arguments to | * quite tricky, because it needs to pass the right arguments to |
| 21 | * drigg_ui_node_list(). The function is commented throughout | * drigg_ui_node_list(). The function is commented throughout |
| 22 | */ | */ |
| 23 | function drigg_ui_menu() { | function drigg_ui_menu() { |
| 24 | $items = array(); | $items = array(); |
| 25 | ||
| 26 | $items['admin/settings/drigg/drigg_ui'] = array( | $items['admin/settings/drigg/drigg_ui'] = array( |
| 27 | 'title' => 'Drigg UI', | 'title' => 'Drigg UI', |
| 28 | 'description' => 'Settings for the Drigg module', | 'description' => 'Settings for the Drigg module', |
| 29 | 'page callback' => 'drupal_get_form', | 'page callback' => 'drupal_get_form', |
| 30 | 'page arguments' => array('drigg_ui_admin_settings'), | 'page arguments' => array('drigg_ui_admin_settings'), |
| 31 | 'access callback' => 'user_access', | 'access callback' => 'user_access', |
| 32 | 'access arguments' => array('administer site configuration'), | 'access arguments' => array('administer site configuration'), |
| 33 | 'weight' => -7, | 'weight' => -7, |
| 34 | 'type' => MENU_LOCAL_TASK, | 'type' => MENU_LOCAL_TASK, |
| 35 | ); | ); |
| 36 | ||
| 37 | $path = variable_get('drigg_home_name', 'drigg_home'); | $path = variable_get('drigg_home_name', 'drigg_home'); |
| 38 | // CASE #-1: The home page | // CASE #-1: The home page |
| 39 | $items[$path] = array( | $items[$path] = array( |
| 40 | 'title' => 'Home', | 'title' => 'Home', |
| 41 | 'page callback' => 'drigg_ui_node_list', | 'page callback' => 'drigg_ui_node_list', |
| 42 | 'page arguments' => array('published', 'newest' ), | 'page arguments' => array('published', 'newest' ), |
| 43 | 'access callback' => TRUE, | 'access callback' => TRUE, |
| 44 | 'type' => MENU_CALLBACK_ITEM, | 'type' => MENU_CALLBACK_ITEM, |
| 45 | ); | ); |
| 46 | ||
| 47 | // CASE #0: arg(0) is a valid section, and arg(1) is empty | // CASE #0: arg(0) is a valid section, and arg(1) is empty |
| 48 | // E.g. /EndUser | // E.g. /EndUser |
| 49 | // Attempt to retrieve the node from the URL | // Attempt to retrieve the node from the URL |
| 50 | ||
| 51 | $tid = drigg_is_section_valid(arg(0)); | $tid = drigg_is_section_valid(arg(0)); |
| 52 | ||
| 53 | $catlist = drigg_section_list(); | $catlist = drigg_section_list(); |
| 54 | if ($catlist) { | if ($catlist) { |
| 55 | foreach ($catlist['by_safe_name'] as $key => $value) { | foreach ($catlist['by_safe_name'] as $key => $value) { |
| 56 | $items[$key] = array( | $items[$key] = array( |
| 57 | 'title' => 'View', | 'title' => 'View', |
| 58 | 'page callback' => 'drigg_ui_node_list', | 'page callback' => 'drigg_ui_node_list', |
| 59 | 'page arguments' => array('published', 'newest', 0), | 'page arguments' => array('published', 'newest', 0), |
| 60 | 'access callback' => TRUE, | 'access callback' => TRUE, |
| 61 | 'type' => MENU_CALLBACK_ITEM, | 'type' => MENU_CALLBACK_ITEM, |
| 62 | ); | ); |
| 63 | } | } |
| 64 | } | } |
| 65 | ||
| 66 | //######### arg(0) not working in DRUPAL-6 #################### | //######### arg(0) not working in DRUPAL-6 #################### |
| 67 | //$items['%my_special_loader'] = array( # | //$items['%my_special_loader'] = array( # |
| 68 | // 'title' => 'View', # | // 'title' => 'View', # |
| 69 | // 'page callback' => 'drigg_ui_node_list', # | // 'page callback' => 'drigg_ui_node_list', # |
| 70 | // 'page arguments' => array('published', 'newest', 0), # | // 'page arguments' => array('published', 'newest', 0), # |
| 71 | // 'access callback' => TRUE, # | // 'access callback' => TRUE, # |
| 72 | // 'type' => MENU_CALLBACK_ITEM, # | // 'type' => MENU_CALLBACK_ITEM, # |
| 73 | //); # | //); # |
| 74 | //############################################################### | //############################################################### |
| 75 | ||
| 76 | $items['published'] = array( | $items['published'] = array( |
| 77 | 'title' => 'View', | 'title' => 'View', |
| 78 | 'page callback' => 'drigg_ui_node_list', | 'page callback' => 'drigg_ui_node_list', |
| 79 | 'page arguments' => array(0), | 'page arguments' => array(0), |
| 80 | // NOTE: the following line is here because the 'path' is | // NOTE: the following line is here because the 'path' is |
| 81 | // not passed as parameters to the callback - this forces it | // not passed as parameters to the callback - this forces it |
| 82 | 'access callback' => TRUE, | 'access callback' => TRUE, |
| 83 | 'type' => MENU_CALLBACK_ITEM, | 'type' => MENU_CALLBACK_ITEM, |
| 84 | ); | ); |
| 85 | ||
| 86 | ||
| 87 | $items['upcoming'] = array( | $items['upcoming'] = array( |
| 88 | 'title' => 'View', | 'title' => 'View', |
| 89 | 'page callback' => 'drigg_ui_node_list', | 'page callback' => 'drigg_ui_node_list', |
| 90 | 'page arguments' => array(0), | 'page arguments' => array(0), |
| 91 | // NOTE: the following line is here because the 'path' is | // NOTE: the following line is here because the 'path' is |
| 92 | // not passed as parameters to the callback - this forces it | // not passed as parameters to the callback - this forces it |
| 93 | 'access callback' => TRUE, | 'access callback' => TRUE, |
| 94 | 'type' => MENU_CALLBACK_ITEM, | 'type' => MENU_CALLBACK_ITEM, |
| 95 | ); | ); |
| 96 | ||
| 97 | $items['archived'] = array( | $items['archived'] = array( |
| 98 | 'title' => 'View', | 'title' => 'View', |
| 99 | 'page callback' => 'drigg_ui_node_list', | 'page callback' => 'drigg_ui_node_list', |
| 100 | 'page arguments' => array(0), | 'page arguments' => array(0), |
| 101 | // NOTE: the following line is here because the 'path' is | // NOTE: the following line is here because the 'path' is |
| 102 | // not passed as parameters to the callback - this forces it | // not passed as parameters to the callback - this forces it |
| 103 | 'access callback' => TRUE, | 'access callback' => TRUE, |
| 104 | 'type' => MENU_CALLBACK_ITEM, | 'type' => MENU_CALLBACK_ITEM, |
| 105 | ); | ); |
| 106 | ||
| 107 | $items['feed'] = array( | $items['feed'] = array( |
| 108 | 'title' => 'View', | 'title' => 'View', |
| 109 | 'page callback' => 'drigg_ui_node_feed', | 'page callback' => 'drigg_ui_node_feed', |
| 110 | 'page arguments' => array(1, 2), | 'page arguments' => array(1, 2), |
| 111 | 'access callback' => TRUE, | 'access callback' => TRUE, |
| 112 | 'type' => MENU_CALLBACK_ITEM, | 'type' => MENU_CALLBACK_ITEM, |
| 113 | ); | ); |
| 114 | ||
| 115 | return $items; | return $items; |
| 116 | } | } |
| 117 | ||
| 118 | //########## Currently not working with DRUPAL-6 ############# | //########## Currently not working with DRUPAL-6 ############# |
| 119 | function my_special_loader_load($my_special_loader) { | function my_special_loader_load($my_special_loader) { |
| 120 | $tid = drigg_is_section_valid($my_special_loader); | $tid = drigg_is_section_valid($my_special_loader); |
| 121 | if ($tid) { | if ($tid) { |
| 122 | return $my_special_loader; | return $my_special_loader; |
| 123 | } | } |
| 124 | else { | else { |
| 125 | return FALSE; | return FALSE; |
| 126 | } | } |
| 127 | } | } |
| 128 | //################################################################ | //################################################################ |
| 129 | ||
| 130 | function drigg_ui_init() { | function drigg_ui_init() { |
| 131 | drupal_add_js(drupal_get_path('module', 'drigg') .'/drigg.js'); | drupal_add_js(drupal_get_path('module', 'drigg') .'/drigg.js'); |
| 132 | } | } |
| 133 | ||
| 134 | // FIXME: See if this needs to stay. Not sure. | // FIXME: See if this needs to stay. Not sure. |
| 135 | /*function drigg_ui_nodeapi($node, $op) { | /*function drigg_ui_nodeapi($node, $op) { |
| 136 | ||
| 137 | if ($op == 'rss item' && $node->type == 'drigg') { | if ($op == 'rss item' && $node->type == 'drigg') { |
| 138 | $node->teaser = extra_voting_forms_show_form($node,'n',3) . $node->teaser; | $node->teaser = extra_voting_forms_show_form($node,'n',3) . $node->teaser; |
| 139 | } | } |
| 140 | }*/ | }*/ |
| 141 | ||
| 142 | ///////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////// |
| 143 | // MAIN PATH ROUTING FUNCTIONS - FEED AND PAGE | // MAIN PATH ROUTING FUNCTIONS - FEED AND PAGE |
| 144 | ///////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////// |
| 145 | ||
| 146 | /** | /** |
| 147 | * Returns an RSS feed (all, or only published) for the specified category. | * Returns an RSS feed (all, or only published) for the specified category. |
| 148 | * | * |
| 149 | * @param $action | * @param $action |
| 150 | * It can be "published" (only promoted nodes are shown) or "all" (all | * It can be "published" (only promoted nodes are shown) or "all" (all |
| 151 | * submitted nodes are shown) | * submitted nodes are shown) |
| 152 | * @param $category | * @param $category |
| 153 | * A valid section (in its safe_name format). If it's empty, it's | * A valid section (in its safe_name format). If it's empty, it's |
| 154 | * assumed "all" | * assumed "all" |
| 155 | * @return | * @return |
| 156 | * The feed | * The feed |
| 157 | */ | */ |
| 158 | function drigg_ui_node_feed($action, $category) { | function drigg_ui_node_feed($action, $category) { |
| 159 | // Set some defaults, so that it's easier to know | // Set some defaults, so that it's easier to know |
| 160 | // what to do | // what to do |
| 161 | if ($action == '') { | if ($action == '') { |
| 162 | $action = 'published'; | $action = 'published'; |
| 163 | } | } |
| 164 | if ($category == '') { | if ($category == '') { |
| 165 | $category = 'All'; | $category = 'All'; |
| 166 | } | } |
| 167 | ||
| 168 | // Return errors if the wrong values are passed here | // Return errors if the wrong values are passed here |
| 169 | if ($action != 'all' && $action != 'published') { | if ($action != 'all' && $action != 'published') { |
| 170 | drupal_not_found(); | drupal_not_found(); |
| 171 | return; | return; |
| 172 | } | } |
| 173 | if ($category != 'All' && ! drigg_is_section_valid( $category )) { | if ($category != 'All' && ! drigg_is_section_valid( $category )) { |
| 174 | drupal_not_found(); | drupal_not_found(); |
| 175 | return; | return; |
| 176 | } | } |
| 177 | ||
| 178 | // Make up the URL string | // Make up the URL string |
| 179 | $url = ""; | $url = ""; |
| 180 | if ($category != 'All') { | if ($category != 'All') { |
| 181 | $url = $category; | $url = $category; |
| 182 | } | } |
| 183 | $options = array( | $options = array( |
| 184 | 'query' => NULL, | 'query' => NULL, |
| 185 | 'fragment' => NULL, | 'fragment' => NULL, |
| 186 | 'absolute' => TRUE, | 'absolute' => TRUE, |
| 187 | ); | ); |
| 188 | $url = url($url, $options); | $url = url($url, $options); |
| 189 | ||
| 190 | // Make up a decent title | // Make up a decent title |
| 191 | if ($action == 'all') { | if ($action == 'all') { |
| 192 | $title = t('Submitted news'); | $title = t('Submitted news'); |
| 193 | } | } |
| 194 | else { | else { |
| 195 | $title = t('Published news'); | $title = t('Published news'); |
| 196 | } | } |
| 197 | if ($category != '' && $category != 'All') { | if ($category != '' && $category != 'All') { |
| 198 | $title .= ' - '. drigg_section_name_by_safe_name($category); | $title .= ' - '. drigg_section_name_by_safe_name($category); |
| 199 | } | } |
| 200 | $title = variable_get('site_name', 'Drupal') .' - '. $title; | $title = variable_get('site_name', 'Drupal') .' - '. $title; |
| 201 | ||
| 202 | // Set the $channel variable, which will be used by node_feed | // Set the $channel variable, which will be used by node_feed |
| 203 | $channel['link'] = $url; | $channel['link'] = $url; |
| 204 | $channel['title'] = $title; | $channel['title'] = $title; |
| 205 | $channel['description'] = ''; | $channel['description'] = ''; |
| 206 | ||
| 207 | if ($category != 'All') { | if ($category != 'All') { |
| 208 | $tl = drigg_section_list(); | $tl = drigg_section_list(); |
| 209 | $tid = $tl['by_safe_name'][$category]; | $tid = $tl['by_safe_name'][$category]; |
| 210 | $extra_join .= ' LEFT JOIN {term_node} t ON n.nid = t.nid '; | $extra_join .= ' LEFT JOIN {term_node} t ON n.nid = t.nid '; |
| 211 | $where_conditions .=" t.tid = $tid AND "; | $where_conditions .=" t.tid = $tid AND "; |
| 212 | } | } |
| 213 | ||
| 214 | // If the action is 'published', add a WHERE condition so that only | // If the action is 'published', add a WHERE condition so that only |
| 215 | // promoted stuff is shown | // promoted stuff is shown |
| 216 | if ($action == 'published') { | if ($action == 'published') { |
| 217 | $where_conditions .= ' n.promote = 1 AND '; | $where_conditions .= ' n.promote = 1 AND '; |
| 218 | $order_by_statement = 'ORDER BY dn.promoted_on DESC'; | $order_by_statement = 'ORDER BY dn.promoted_on DESC'; |
| 219 | } | } |
| 220 | else { | else { |
| 221 | $order_by_statement = 'ORDER BY n.created DESC'; | $order_by_statement = 'ORDER BY n.created DESC'; |
| 222 | } | } |
| 223 | ||
| 224 | // Actually run the query | // Actually run the query |
| 225 | $query = 'SELECT * FROM {node} n LEFT JOIN {drigg_node} dn ON n.nid = dn.dnid '. $extra_join .' WHERE n.type = \'drigg\' AND '. $where_conditions .' n.status = 1 '. $order_by_statement; | $query = 'SELECT * FROM {node} n LEFT JOIN {drigg_node} dn ON n.nid = dn.dnid '. $extra_join .' WHERE n.type = \'drigg\' AND '. $where_conditions .' n.status = 1 '. $order_by_statement; |
| 226 | $result = db_query_range(db_rewrite_sql($query,'n','nid'), 0, 20); | $result = db_query_range(db_rewrite_sql($query,'n','nid'), 0, 20); |
| 227 | while ($rs = db_fetch_object($result)) { | while ($rs = db_fetch_object($result)) { |
| 228 | $nids[] = $rs->nid; | $nids[] = $rs->nid; |
| 229 | } | } |
| 230 | // Show the feed baby! | // Show the feed baby! |
| 231 | node_feed($nids, $channel); | node_feed($nids, $channel); |
| 232 | } | } |
| 233 | ||
| 234 | ||
| 235 | /** | /** |
| 236 | * The heart of the system. It will show the right nodes according | * The heart of the system. It will show the right nodes according |
| 237 | * to what the requested URL is. The code is self-documenting (with | * to what the requested URL is. The code is self-documenting (with |
| 238 | * tons of code) | * tons of code) |
| 239 | * The URL scheme is: | * The URL scheme is: |
| 240 | * | * |
| 241 | * http://www.site.com/Section_1/The_Title_Of_The_story | * http://www.site.com/Section_1/The_Title_Of_The_story |
| 242 | * /Section_2/Yet_another_title | * /Section_2/Yet_another_title |
| 243 | * /Section_1/ | * /Section_1/ |
| 244 | * /Section_2/ | * /Section_2/ |
| 245 | * | * |
| 246 | * /published | * /published |
| 247 | * /published/newest | * /published/newest |
| 248 | * /published/newest/Section | * /published/newest/Section |
| 249 | * /published/top24h/Section | * /published/top24h/Section |
| 250 | * /published/top7days/Sectiony | * /published/top7days/Sectiony |
| 251 | * /published/top30days/Sectiony | * /published/top30days/Sectiony |
| 252 | * /published/top365days/Section | * /published/top365days/Section |
| 253 | * | * |
| 254 | * /upcoming | * /upcoming |
| 255 | * /upcoming/newest | * /upcoming/newest |
| 256 | * /upcoming/newest/Section | * /upcoming/newest/Section |
| 257 | * /upcoming/oldest/Section | * /upcoming/oldest/Section |
| 258 | * /upcoming/mostpopular/Section | * /upcoming/mostpopular/Section |
| 259 | * /upcoming/leastpopular/Section | * /upcoming/leastpopular/Section |
| 260 | ||
| 261 | * /archived | * /archived |
| 262 | * /archived/newest | * /archived/newest |
| 263 | * /archived/newest/Section | * /archived/newest/Section |
| 264 | * /archived/oldest/Section | * /archived/oldest/Section |
| 265 | * /archived/mostpopular/Section | * /archived/mostpopular/Section |
| 266 | * /archived/leastpopular/Section | * /archived/leastpopular/Section |
| 267 | * | * |
| 268 | * @param $action | * @param $action |
| 269 | * It can be 'published', 'upcoming', 'archived' | * It can be 'published', 'upcoming', 'archived' |
| 270 | * @param $filter | * @param $filter |
| 271 | * This is tricky, because what it can be depends on the | * This is tricky, because what it can be depends on the |
| 272 | * $action. | * $action. |
| 273 | * For 'upcoming' and 'archived', it can be: | * For 'upcoming' and 'archived', it can be: |
| 274 | * 'newest', 'oldest', 'mostpopular', 'leastpopular'. | * 'newest', 'oldest', 'mostpopular', 'leastpopular'. |
| 275 | * For 'published', it can be: | * For 'published', it can be: |
| 276 | * 'newest', 'top24h', 'top7days', 'top30days', 'top356days'. | * 'newest', 'top24h', 'top7days', 'top30days', 'top356days'. |
| 277 | * | * |
| 278 | * @param $category | * @param $category |
| 279 | * A valid section (in its safe_name format). | * A valid section (in its safe_name format). |
| 280 | * | * |
| 281 | * @return | * @return |
| 282 | * | * |
| 283 | */ | */ |
| 284 | function drigg_ui_node_list($action, $filter = NULL, $category = NULL) { | function drigg_ui_node_list($action, $filter = NULL, $category = NULL) { |
| 285 | $query_vars = array(); | $query_vars = array(); |
| 286 | $where_conditions = ''; | $where_conditions = ''; |
| 287 | ||
| 288 | ||
| 289 | #drupal_set_message("Values: $action,$filter,$category"); | #drupal_set_message("Values: $action,$filter,$category"); |
| 290 | if ($filter == NULL) { | if ($filter == NULL) { |
| 291 | $filter = 'newest'; | $filter = 'newest'; |
| 292 | } | } |
| 293 | #drupal_set_message("Values (after): $action,$filter,$category"); | #drupal_set_message("Values (after): $action,$filter,$category"); |
| 294 | ||
| 295 | // Set the breadcrumb | // Set the breadcrumb |
| 296 | $breadcrumb = array(l(t('Home'), NULL), t('Scoops') ); | $breadcrumb = array(l(t('Home'), NULL), t('Scoops') ); |
| 297 | drupal_set_breadcrumb($breadcrumb); | drupal_set_breadcrumb($breadcrumb); |
| 298 | ||
| 299 | // Check that the category exists. | // Check that the category exists. |
| 300 | // Also, store it in $tid whire you're there | // Also, store it in $tid whire you're there |
| 301 | if ($category != NULL) { | if ($category != NULL) { |
| 302 | $tid = drigg_is_section_valid( $category ); | $tid = drigg_is_section_valid( $category ); |
| 303 | if (!$tid) { | if (!$tid) { |
| 304 | #drupal_set_message('1'); | #drupal_set_message('1'); |
| 305 | return drupal_not_found(); | return drupal_not_found(); |
| 306 | } | } |
| 307 | } | } |
| 308 | ||
| 309 | // Check the filter - for action "published" | // Check the filter - for action "published" |
| 310 | if ($action == 'published') { | if ($action == 'published') { |
| 311 | if ( | if ( |
| 312 | $filter != 'newest' && | $filter != 'newest' && |
| 313 | $filter != 'top24h' && | $filter != 'top24h' && |
| 314 | $filter != 'top7days' && | $filter != 'top7days' && |
| 315 | $filter != 'top30days' && | $filter != 'top30days' && |
| 316 | $filter != 'top365days') { | $filter != 'top365days') { |
| 317 | #drupal_set_message('2'); | #drupal_set_message('2'); |
| 318 | return drupal_not_found(); | return drupal_not_found(); |
| 319 | } | } |
| 320 | // Check the filter - for actions "upcoming" and "archived"" | // Check the filter - for actions "upcoming" and "archived"" |
| 321 | } | } |
| 322 | else { | else { |
| 323 | if ( | if ( |
| 324 | $filter != 'newest' && | $filter != 'newest' && |
| 325 | $filter != 'oldest' && | $filter != 'oldest' && |
| 326 | $filter != 'mostpopular' && | $filter != 'mostpopular' && |
| 327 | $filter != 'leastpopular') { | $filter != 'leastpopular') { |
| 328 | #drupal_set_message('3'); | #drupal_set_message('3'); |
| 329 | return drupal_not_found(); | return drupal_not_found(); |
| 330 | } | } |
| 331 | } | } |
| 332 | ||
| 333 | ||
| 334 | // Sort out the feed! | // Sort out the feed! |
| 335 | if ($action == 'published') { | if ($action == 'published') { |
| 336 | $feed_action = 'published'; | $feed_action = 'published'; |
| 337 | } | } |
| 338 | else { | else { |
| 339 | $feed_action = 'all'; | $feed_action = 'all'; |
| 340 | } | } |
| 341 | if ($category == 'All' || $category == '') { | if ($category == 'All' || $category == '') { |
| 342 | $feed_category = 'All'; | $feed_category = 'All'; |
| 343 | } | } |
| 344 | else { | else { |
| 345 | $feed_category = $category; | $feed_category = $category; |
| 346 | } | } |
| 347 | $options = array( | $options = array( |
| 348 | 'query' => NULL, | 'query' => NULL, |
| 349 | 'fragment' => NULL, | 'fragment' => NULL, |
| 350 | 'absolute' => TRUE, | 'absolute' => TRUE, |
| 351 | ); | ); |
| 352 | $feed_url = url("feed/$feed_action/$feed_category", $options); | $feed_url = url("feed/$feed_action/$feed_category", $options); |
| 353 | drupal_add_feed($feed_url, variable_get('site_name', 'Drupal') .' '. t('RSS')); | drupal_add_feed($feed_url, variable_get('site_name', 'Drupal') .' '. t('RSS')); |
| 354 | ||
| 355 | // Assigning a decent title to this page | // Assigning a decent title to this page |
| 356 | if ($action == 'published') { | if ($action == 'published') { |
| 357 | $page_title = t('Published scoops'); | $page_title = t('Published scoops'); |
| 358 | } | } |
| 359 | if ($action == 'upcoming') { | if ($action == 'upcoming') { |
| 360 | $page_title = t('Upcoming scoops'); | $page_title = t('Upcoming scoops'); |
| 361 | } | } |
| 362 | if ($action == 'archived') { | if ($action == 'archived') { |
| 363 | $page_title = t('Archived scoops'); | $page_title = t('Archived scoops'); |
| 364 | } | } |
| 365 | if ($category != '') { | if ($category != '') { |
| 366 | $page_title .= " - ". drigg_section_name_by_safe_name($category); | $page_title .= " - ". drigg_section_name_by_safe_name($category); |
| 367 | } | } |
| 368 | ||
| 369 | // Set the title | // Set the title |
| 370 | drupal_set_title($page_title); | drupal_set_title($page_title); |
| 371 | ||
| 372 | // Initialising the basic query variables | // Initialising the basic query variables |
| 373 | $extra_join = ''; | $extra_join = ''; |
| 374 | $where_conditions = ''; | $where_conditions = ''; |
| 375 | $query_vars = array(); | $query_vars = array(); |
| 376 | $order_by = ''; | $order_by = ''; |
| 377 | ||
| 378 | ||
| 379 | // This bit is true for every single case... so, here it is | // This bit is true for every single case... so, here it is |
| 380 | // Populate the tid bit | // Populate the tid bit |
| 381 | if ($tid) { | if ($tid) { |
| 382 | /* | /* |
| 383 | $extra_join .= ' LEFT JOIN {term_node} t ON n.nid = t.nid '; | $extra_join .= ' LEFT JOIN {term_node} t ON n.nid = t.nid '; |
| 384 | $where_conditions.=" t.tid=%d AND "; | $where_conditions.=" t.tid=%d AND "; |
| 385 | $query_vars[]=$tid; | $query_vars[]=$tid; |
| 386 | */ | */ |
| 387 | $tid_list = listize_from_array(drigg_ui_get_all_offspring_tids($tid)); //string | $tid_list = listize_from_array(drigg_ui_get_all_offspring_tids($tid)); //string |
| 388 | //now $tid_list = "12,13,14,16, "; | //now $tid_list = "12,13,14,16, "; |
| 389 | $tid_list .= $tid; | $tid_list .= $tid; |
| 390 | $extra_join .= ' LEFT JOIN {term_node} t ON n.nid = t.nid '; | $extra_join .= ' LEFT JOIN {term_node} t ON n.nid = t.nid '; |
| 391 | $where_conditions .= " t.tid IN ($tid_list) AND "; | $where_conditions .= " t.tid IN ($tid_list) AND "; |
| 392 | $query_vars[] = $tid; | $query_vars[] = $tid; |
| 393 | } | } |
| 394 | ||
| 395 | ||
| 396 | ///////////////////////////////////// | ///////////////////////////////////// |
| 397 | // DEAL WITH THE "published" OPTION | // DEAL WITH THE "published" OPTION |
| 398 | ///////////////////////////////////// | ///////////////////////////////////// |
| 399 | ||
| 400 | if ($action == 'published') { | if ($action == 'published') { |
| 401 | ||
| 402 | if ($filter == 'newest') { | if ($filter == 'newest') { |
| 403 | $order_by = 'ORDER BY n.sticky DESC, dn2.promoted_on DESC'; | $order_by = 'ORDER BY n.sticky DESC, dn2.promoted_on DESC'; |
| 404 | } | } |
| 405 | ||
| 406 | if ( $filter == 'top24h' || | if ( $filter == 'top24h' || |
| 407 | $filter == 'top7days' || | $filter == 'top7days' || |
| 408 | $filter == 'top30days' || | $filter == 'top30days' || |
| 409 | $filter == 'top365days' ) { | $filter == 'top365days' ) { |
| 410 | ||
| 411 | // Order by is different | // Order by is different |
| 412 | $order_by = 'ORDER BY vc.value DESC, dn2.promoted_on DESC'; | $order_by = 'ORDER BY vc.value DESC, dn2.promoted_on DESC'; |
| 413 | // Join something extra | // Join something extra |
| 414 | $extra_join .= ' LEFT JOIN {votingapi_cache} vc ON n.nid = vc.content_id '; | $extra_join .= ' LEFT JOIN {votingapi_cache} vc ON n.nid = vc.content_id '; |
| 415 | // Work out the timeframe | // Work out the timeframe |
| 416 | $where_bit['top24h'] = 60*60*24; | $where_bit['top24h'] = 60*60*24; |
| 417 | $where_bit['top7days'] = 60*60*24*7; | $where_bit['top7days'] = 60*60*24*7; |
| 418 | $where_bit['top30days'] = 60*60*24*30; | $where_bit['top30days'] = 60*60*24*30; |
| 419 | $where_bit['top365days'] = 60*60*24*365; | $where_bit['top365days'] = 60*60*24*365; |
| 420 | $where_conditions .= drigg_votingapi_query('vc') ." AND n.created > UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) - ". $where_bit[$filter] ." AND "; | $where_conditions .= drigg_votingapi_query('vc') ." AND n.created > UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) - ". $where_bit[$filter] ." AND "; |
| 421 | } | } |
| 422 | ||
| 423 | $query = 'SELECT * FROM {node} n '. $extra_join .' WHERE n.type = \'drigg\' AND '. $where_conditions .' n.status = 1 and n.promote = 1 '. $order_by; | $query = 'SELECT * FROM {node} n '. $extra_join .' WHERE n.type = \'drigg\' AND '. $where_conditions .' n.status = 1 and n.promote = 1 '. $order_by; |
| 424 | ||
| 425 | } | } |
| 426 | ||
| 427 | ||
| 428 | //////////////////////////////////////////////// | //////////////////////////////////////////////// |
| 429 | // DEAL WITH THE "upcoming/archived" OPTION | // DEAL WITH THE "upcoming/archived" OPTION |
| 430 | //////////////////////////////////////////////// | //////////////////////////////////////////////// |
| 431 | if ($action == 'upcoming' || $action == 'archived') { | if ($action == 'upcoming' || $action == 'archived') { |
| 432 | ||
| 433 | // Sort out the upcoming/archived stuff first. Only the operator changes | // Sort out the upcoming/archived stuff first. Only the operator changes |
| 434 | if ($action == 'upcoming') { | if ($action == 'upcoming') { |
| 435 | $operator = '>'; | $operator = '>'; |
| 436 | } | } |
| 437 | else { | else { |
| 438 | $operator = '<'; | $operator = '<'; |
| 439 | } | } |
| 440 | $where_conditions .= " n.created $operator UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) - 60*60*". variable_get('drigg_hours_in_upcoming', '48') ." AND "; | $where_conditions .= " n.created $operator UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) - 60*60*". variable_get('drigg_hours_in_upcoming', '48') ." AND "; |
| 441 | ||
| 442 | // CASE #1: It's either "newest" or "oldest" | // CASE #1: It's either "newest" or "oldest" |
| 443 | if ($filter == 'newest' || $filter == 'oldest') { | if ($filter == 'newest' || $filter == 'oldest') { |
| 444 | $order_by = 'ORDER BY n.created'; | $order_by = 'ORDER BY n.created'; |
| 445 | if ($filter == 'newest') { | if ($filter == 'newest') { |
| 446 | $order_by .= ' DESC '; | $order_by .= ' DESC '; |
| 447 | } | } |
| 448 | } | } |
| 449 | // CASE #2: It's either "mostpopular" or "leastpopular" | // CASE #2: It's either "mostpopular" or "leastpopular" |
| 450 | if ($filter == 'mostpopular' || $filter == 'leastpopular') { | if ($filter == 'mostpopular' || $filter == 'leastpopular') { |
| 451 | // Order by first... | // Order by first... |
| 452 | if ($filter == 'mostpopular') { | if ($filter == 'mostpopular') { |
| 453 | $extra_bit = ' DESC '; | $extra_bit = ' DESC '; |
| 454 | } | } |
| 455 | $order_by = "ORDER BY vc.value $extra_bit"; | $order_by = "ORDER BY vc.value $extra_bit"; |
| 456 | // Join something extra | // Join something extra |
| 457 | $extra_join .= ' LEFT JOIN {votingapi_cache} vc ON n.nid = vc.content_id '; | $extra_join .= ' LEFT JOIN {votingapi_cache} vc ON n.nid = vc.content_id '; |
| 458 | $where_conditions .= drigg_votingapi_query('vc') ." AND "; | $where_conditions .= drigg_votingapi_query('vc') ." AND "; |
| 459 | } | } |
| 460 | ||
| 461 | // Make up the query | // Make up the query |
| 462 | $query = 'SELECT * FROM {node} n '. $extra_join .' WHERE n.type = \'drigg\' AND '. $where_conditions .' n.status = 1 and n.promote = 0 '. $order_by; | $query = 'SELECT * FROM {node} n '. $extra_join .' WHERE n.type = \'drigg\' AND '. $where_conditions .' n.status = 1 and n.promote = 0 '. $order_by; |
| 463 | } | } |
| 464 | ||
| 465 | #drupal_set_message($query); | #drupal_set_message($query); |
| 466 | ||
| 467 | global $is_front; | |
| 468 | $output = ''; | if ($is_front) { |
| 469 | $output = "<div class='drigg_published'"; | |
| 470 | // How many items to be shown in each page? | } |
| 471 | if (variable_get('drigg_hide_archived_menu', FALSE) && $action == 'archived') { | else { |
| 472 | $items_per_page = 150; | $output = "<div class='drigg_$action'"; |
| 473 | } | } |
| 474 | else { | |
| 475 | $items_per_page = variable_get('drigg_items_in_main_page', 20); | // How many items to be shown in each page? |
| 476 | } | if (variable_get('drigg_hide_archived_menu', FALSE) && $action == 'archived') { |
| 477 | $items_per_page = 150; | |
| 478 | // Scan through the results | } |
| 479 | $result = pager_query(db_rewrite_sql($query), $items_per_page, 0, NULL, $query_vars); | else { |
| 480 | $items_per_page = variable_get('drigg_items_in_main_page', 20); | |
| 481 | while ($node = db_fetch_object($result)) { | } |
| 482 | $something_there = TRUE; | |
| 483 | if ($action == 'archived' && variable_get('drigg_hide_archived_menu', FALSE)) { | // Scan through the results |
| 484 | $output .= '<p> '. l($node->title, 'node/'. $node->nid) .'</p>'; | $result = pager_query(db_rewrite_sql($query), $items_per_page, 0, NULL, $query_vars); |
| 485 | } | |
| 486 | else { | while ($node = db_fetch_object($result)) { |
| 487 | $output .= node_view(node_load($node->nid), TRUE); | $something_there = TRUE; |
| 488 | } | if ($action == 'archived' && variable_get('drigg_hide_archived_menu', FALSE)) { |
| 489 | } | $output .= '<p> '. l($node->title, 'node/'. $node->nid) .'</p>'; |
| 490 | if (!$something_there) { | } |
| 491 | drupal_set_message(t(variable_get('drigg_no_items_to_display', 'No scoop available!'))); | else { |
| 492 | } | $output .= node_view(node_load($node->nid), TRUE); |
| 493 | } | |
| 494 | $output .= theme('pager', NULL, variable_get('drigg_items_in_main_page', 20), 0); | } |
| 495 | if (!$something_there) { | |
| 496 | return $output; | drupal_set_message(t(variable_get('drigg_no_items_to_display', 'No scoop available!'))); |
| 497 | } | } |
| 498 | ||
| 499 | /** | $output .= theme('pager', NULL, variable_get('drigg_items_in_main_page', 20), 0); |
| 500 | * The standard "settings" function | $output .= "</div>"; |
| 501 | * | |
| 502 | */ | return $output; |
| 503 | function drigg_ui_admin_settings() { | } |
| 504 | $form['drigg_home_name'] = array( | |
| 505 | '#type' => 'textfield', | /** |
| 506 | '#title' => t('The path to the Drigg home page'), | * The standard "settings" function |
| 507 | '#size' => 20, | * |
| 508 | '#maxlength' => 20, | */ |
| 509 | '#default_value' => variable_get('drigg_home_name', 'drigg_home'), | function drigg_ui_admin_settings() { |
| 510 | ); | $form['drigg_home_name'] = array( |
| 511 | '#type' => 'textfield', | |
| 512 | $form['drigg_hide_archived_menu'] = array( | '#title' => t('The path to the Drigg home page'), |
| 513 | '#type' => 'checkbox', | '#size' => 20, |
| 514 | '#title' => t('Hide the "archived" menu entry'), | '#maxlength' => 20, |
| 515 | '#default_value' => variable_get('drigg_hide_archived_menu', FALSE), | '#default_value' => variable_get('drigg_home_name', 'drigg_home'), |
| 516 | '#required' => FALSE, | ); |
| 517 | ); | |
| 518 | $form['drigg_hide_archived_menu'] = array( | |
| 519 | $form['drigg_items_in_main_page'] = array( | '#type' => 'checkbox', |
| 520 | '#type' => 'textfield', | '#title' => t('Hide the "archived" menu entry'), |
| 521 | '#title' => t('How many items should be shown in each page?'), | '#default_value' => variable_get('drigg_hide_archived_menu', FALSE), |
| 522 | '#size' => 5, | '#required' => FALSE, |
| 523 | '#maxlength' => 5, | ); |
| 524 | '#required' => TRUE, | |
| 525 | '#default_value' => variable_get('drigg_items_in_main_page', 20), | $form['drigg_items_in_main_page'] = array( |
| 526 | ); | '#type' => 'textfield', |
| 527 | '#title' => t('How many items should be shown in each page?'), | |
| 528 | $form['rss_icons'] = array( | '#size' => 5, |
| 529 | '#type' => 'fieldset', | '#maxlength' => 5, |
| 530 | '#title' => t('Look of the "feed" icons next to the category names in the category box'), | '#required' => TRUE, |
| 531 | '#collapsible' => FALSE, | '#default_value' => variable_get('drigg_items_in_main_page', 20), |
| 532 | '#collapsed' => FALSE, | ); |
| 533 | ); | |
| 534 | $form['rss_icons'] = array( | |
| 535 | $form['rss_icons']['drigg_look_rss_cat_all'] = array( | '#type' => 'fieldset', |
| 536 | '#type' => 'textfield', | '#title' => t('Look of the "feed" icons next to the category names in the category box'), |
| 537 | '#title' => t('Feed string for feeds pointing to all articles'), | '#collapsible' => FALSE, |
| 538 | '#size' => 25, | '#collapsed' => FALSE, |
| 539 | '#maxlength' => 255, | ); |
| 540 | '#required' => FALSE, | |
| 541 | '#default_value' => variable_get('drigg_look_rss_cat_all', ''), | $form['rss_icons']['drigg_look_rss_cat_all'] = array( |
| 542 | ); | '#type' => 'textfield', |
| 543 | '#title' => t('Feed string for feeds pointing to all articles'), | |
| 544 | $form['rss_icons']['drigg_look_rss_cat_pro'] = array( | '#size' => 25, |
| 545 | '#type' => 'textfield', | '#maxlength' => 255, |
| 546 | '#title' => t('Feed string for feeds pointing to promoted articles'), | '#required' => FALSE, |
| 547 | '#size' => 25, | '#default_value' => variable_get('drigg_look_rss_cat_all', ''), |
| 548 | '#maxlength' => 255, | ); |
| 549 | '#required' => FALSE, | |
| 550 | '#default_value' => variable_get('drigg_look_rss_cat_pro', ''), | $form['rss_icons']['drigg_look_rss_cat_pro'] = array( |
| 551 | ); | '#type' => 'textfield', |
| 552 | '#title' => t('Feed string for feeds pointing to promoted articles'), | |
| 553 | $form['drigg_no_items_to_display']=array( | '#size' => 25, |
| 554 | '#type' => 'textarea', | '#maxlength' => 255, |
| 555 | '#title' => t('Text to display if no scoop is available'), | '#required' => FALSE, |
| 556 | '#default_value' => variable_get('drigg_no_items_to_display', 'No scoop available!'), | '#default_value' => variable_get('drigg_look_rss_cat_pro', ''), |
| 557 | '#required' => FALSE, | ); |
| 558 | ); | |
| 559 | $form['drigg_no_items_to_display']=array( | |
| 560 | return system_settings_form($form); | '#type' => 'textarea', |
| 561 | } | '#title' => t('Text to display if no scoop is available'), |
| 562 | '#default_value' => variable_get('drigg_no_items_to_display', 'No scoop available!'), | |
| 563 | ################################################################## | '#required' => FALSE, |
| 564 | #### MENU RENDERING FUNCTIONS - SECTIONS, ORDER, TOP, ARTICLE | ); |
| 565 | ################################################################## | |
| 566 | return system_settings_form($form); | |
| 567 | /** | } |
| 568 | * Returns the "sections" menu. | |
| 569 | * This is complicated by the fact that each category needs to be | ################################################################## |
| 570 | * linked to correctly. The code needs to check whether drigg is | #### MENU RENDERING FUNCTIONS - SECTIONS, ORDER, TOP, ARTICLE |
| 571 | * actually handling the home page or not (the links will change). | ################################################################## |
| 572 | * Also, an "All" entry is added artificially. | |
| 573 | * The function also has a $print_rss_links flag, in case the user wants | /** |
| 574 | * rss links (for which the formatting depends on the config string) next | * Returns the "sections" menu. |
| 575 | * to each category. | * This is complicated by the fact that each category needs to be |
| 576 | * | * linked to correctly. The code needs to check whether drigg is |
| 577 | * ALSO, things are complicated by the fact that according to the | * actually handling the home page or not (the links will change). |
| 578 | * query string, order and action need to be preserved. This means that | * Also, an "All" entry is added artificially. |
| 579 | * from /upcoming/newest/Business a link to the "Community" category | * The function also has a $print_rss_links flag, in case the user wants |
| 580 | * will be /upcoming/newest/Community | * rss links (for which the formatting depends on the config string) next |
| 581 | * | * to each category. |
| 582 | * @param $print_rss_links | * |
| 583 | * If TRUE, it will print the rss links | * ALSO, things are complicated by the fact that according to the |
| 584 | * @param $depth | * query string, order and action need to be preserved. This means that |
| 585 | * Only choose the sections that are '$depth' level deep | * from /upcoming/newest/Business a link to the "Community" category |
| 586 | * counting from root, which has term_id of 0. | * will be /upcoming/newest/Community |
| 587 | * For example, if we have | * |
| 588 | * root -> technology -> CMS -> Drupal -> Drigg | * @param $print_rss_links |
| 589 | * -> Joomla | * If TRUE, it will print the rss links |
| 590 | * -> sports | * @param $depth |
| 591 | * Then drigg_ui_sections(,0) will return the menu including 'technology' + 'sports' | * Only choose the sections that are '$depth' level deep |
| 592 | * drigg_ui_sections(,1) will return 'CMS' if we are viewing content of 'Drupal', 'Joomla' or 'Drigg' | * counting from root, which has term_id of 0. |
| 593 | * and so on.... | * For example, if we have |
| 594 | * @return | * root -> technology -> CMS -> Drupal -> Drigg |
| 595 | * The menu if there is a menu to display | * -> Joomla |
| 596 | * Null if there is no sections available. | * -> sports |
| 597 | */ | * Then drigg_ui_sections(,0) will return the menu including 'technology' + 'sports' |
| 598 | function drigg_ui_sections($print_rss_links = FALSE, $depth = 0) { | * drigg_ui_sections(,1) will return 'CMS' if we are viewing content of 'Drupal', 'Joomla' or 'Drigg' |
| 599 | * and so on.... | |
| 600 | $nr_of_sections = 0; //number of sections available. | * @return |
| 601 | $output = ''; | * The menu if there is a menu to display |
| 602 | * Null if there is no sections available. | |
| 603 | //section_id (term_id) array of all the ancestors of current 'term' | */ |
| 604 | //being viewed. | function drigg_ui_sections($print_rss_links = FALSE, $depth = 0) { |
| 605 | $ancestor_arr = drigg_ui_ancestor_section_id_array(); | |
| 606 | $nr_of_sections = 0; //number of sections available. | |
| 607 | //Now find the parent term_id of the sections we are generating. | $output = ''; |
| 608 | if ($depth == 0) { | |
| 609 | $parent_tid = 0; | //section_id (term_id) array of all the ancestors of current 'term' |
| 610 | } | //being viewed. |
| 611 | else { | $ancestor_arr = drigg_ui_ancestor_section_id_array(); |
| 612 | $idx = count($ancestor_arr) - $depth - 1; | |
| 613 | if ($idx >= 0) | //Now find the parent term_id of the sections we are generating. |
| 614 | $parent_tid = $ancestor_arr[$idx]; | if ($depth == 0) { |
| 615 | else | $parent_tid = 0; |
| 616 | return NULL; //No sections available with this '$depth' | } |
| 617 | } | else { |
| 618 | $terms = drigg_section_list(); | $idx = count($ancestor_arr) - $depth - 1; |
| 619 | if ($idx >= 0) | |
| 620 | // You never know... | $parent_tid = $ancestor_arr[$idx]; |
| 621 | if (count($terms) == 0) { | else |
| 622 | return NULL; | return NULL; //No sections available with this '$depth' |
| 623 | } | } |
| 624 | $terms = drigg_section_list(); | |
| 625 | // HTML class for selected items | |
| 626 | $selected_string = ' class="active" '; | // You never know... |
| 627 | $class_string = ' class="drigg-categories" '; | if (count($terms) == 0) { |
| 628 | return NULL; | |
| 629 | // This will make the following code prettier | } |
| 630 | $p0 = arg(0); | |
| 631 | $p1 = arg(1); | // HTML class for selected items |
| 632 | $p2 = arg(2); | $selected_string = ' class="active" '; |
| 633 | $class_string = ' class="drigg-categories" '; | |
| 634 | ||
| 635 | // Little hack to have the "All" menu | // This will make the following code prettier |
| 636 | // This way, the database doesn't need to get dirty with | $p0 = arg(0); |
| 637 | // crap and it all "works" | $p1 = arg(1); |
| 638 | $terms['lookup'][ $parent_tid ]['name'] = t('All'); | $p2 = arg(2); |
| 639 | $terms['lookup'][ $parent_tid ]['safe_name'] = 'All'; | |
| 640 | $terms['lookup'][ $parent_tid ]['description'] = t('All categories'); | |
| 641 | $terms['lookup'][ $parent_tid ]['weight'] = -100; | // Little hack to have the "All" menu |
| 642 | $terms['lookup'][ $parent_tid ]['tid'] = $tid; | // This way, the database doesn't need to get dirty with |
| 643 | array_unshift($terms['by_weight'], 0); | // crap and it all "works" |
| 644 | $terms['by_safe_name']['All'] = 0; | $terms['lookup'][ $parent_tid ]['name'] = t('All'); |
| 645 | $terms['lookup'][ $parent_tid ]['safe_name'] = 'All'; | |
| 646 | $terms['lookup'][ $parent_tid ]['description'] = t('All categories'); | |
| 647 | if ($terms) { | $terms['lookup'][ $parent_tid ]['weight'] = -100; |
| 648 | foreach ($terms['by_weight'] as $tid ) { | $terms['lookup'][ $parent_tid ]['tid'] = $tid; |
| 649 | //only checks for terms that are children of $parent_tid | array_unshift($terms['by_weight'], 0); |
| 650 | if (($terms['lookup'][$tid]['parent_tid'] != $parent_tid ) /*&& ($tid != $parent_tid)*/) { | $terms['by_safe_name']['All'] = 0; |
| 651 | continue; | |
| 652 | } | |
| 653 | $category = $terms['lookup'][$tid]['safe_name']; | if ($terms) { |
| 654 | $selected = ''; | foreach ($terms['by_weight'] as $tid ) { |
| 655 | //only checks for terms that are children of $parent_tid | |
| 656 | //if $tid is an ancestor of current term being viewed. | if (($terms['lookup'][$tid]['parent_tid'] != $parent_tid ) /*&& ($tid != $parent_tid)*/) { |
| 657 | // then it should be highlighted (i.e. 'selected') | continue; |
| 658 | if ($ancestor_arr && in_array($tid, $ancestor_arr) && $tid != 0) { | } |
| 659 | $selected = $selected_string; | $category = $terms['lookup'][$tid]['safe_name']; |
| 660 | } | $selected = ''; |
| 661 | ||
| 662 | // CASE "DEFAULT" | //if $tid is an ancestor of current term being viewed. |
| 663 | // This is the default, in case another page is being seen | // then it should be highlighted (i.e. 'selected') |
| 664 | if ($category == 'All') { | if ($ancestor_arr && in_array($tid, $ancestor_arr) && $tid != 0) { |
| 665 | if ($parent_tid == 0) { // Only have 'All' for the top categories | $selected = $selected_string; |
| 666 | $link = drigg_ui_home_url(); | } |
| 667 | } | |
| 668 | } | // CASE "DEFAULT" |
| 669 | else { | // This is the default, in case another page is being seen |
| 670 | $link = "$category"; | if ($category == 'All') { |
| 671 | } | if ($parent_tid == 0) { // Only have 'All' for the top categories |
| 672 | $link = drigg_ui_home_url(); | |
| 673 | // Case #1: it's just /Category (other than /All). Check that the | } |
| 674 | // category is correct, and that there's nothing after the category's | } |
| 675 | // name | else { |
| 676 | if ( $category != 'All' && drigg_is_section_valid(arg(0)) && arg(1) == '') { | $link = "$category"; |
| 677 | if ($category == arg(0)) { | } |
| 678 | $selected = $selected_string; | |
| 679 | } | // Case #1: it's just /Category (other than /All). Check that the |
| 680 | $link = "$category"; | // category is correct, and that there's nothing after the category's |
| 681 | } | // name |
| 682 | if ( $category != 'All' && drigg_is_section_valid(arg(0)) && arg(1) == '') { | |
| 683 | if ($category == arg(0)) { | |
| 684 | // Case #2: it's just 'node' or 'drigg_home'. In this case, | $selected = $selected_string; |
| 685 | // the URL is empty, and just show the roots | } |
| 686 | if ((arg(0) == 'node' || arg(0) == variable_get('drigg_home_name', 'drigg_home')) && arg(1) == '' ) { | $link = "$category"; |
| 687 | if ($category == 'All' ) { | } |
| 688 | $selected = $selected_string; | |
| 689 | $link = drigg_ui_home_url(); | |
| 690 | } | // Case #2: it's just 'node' or 'drigg_home'. In this case, |
| 691 | else { | // the URL is empty, and just show the roots |
| 692 | $link = "$category"; | if ((arg(0) == 'node' || arg(0) == variable_get('drigg_home_name', 'drigg_home')) && arg(1) == '' ) { |
| 693 | } | if ($category == 'All' ) { |
| 694 | } | $selected = $selected_string; |
| 695 | $link = drigg_ui_home_url(); | |
| 696 | } | |
| 697 | // Case #3: it's viewing an article. In this case, | else { |
| 698 | // get the article's category | $link = "$category"; |
| 699 | if (arg(0) == 'node' && arg(1) != '' && is_numeric(arg(1))) { | } |
| 700 | $n = node_load(arg(1)); | } |
| 701 | if ($n->safe_section == $category) { | |
| 702 | $selected = $selected_string; | |
| 703 | } | // Case #3: it's viewing an article. In this case, |
| 704 | if ($category == 'All' ) { | // get the article's category |
| 705 | $link = drigg_ui_home_url(); | if (arg(0) == 'node' && arg(1) != '' && is_numeric(arg(1))) { |
| 706 | } | $n = node_load(arg(1)); |
| 707 | else { | if ($n->safe_section == $category) { |
| 708 | $link = "$category"; | $selected = $selected_string; |
| 709 | } | } |
| 710 | } | if ($category == 'All' ) { |
| 711 | $link = drigg_ui_home_url(); | |
| 712 | // Case #4: it's viewing a list. This is the most complex case. | } |
| 713 | if ($p0 == 'published' || $p0 == 'upcoming' || $p0 == 'archived') { | else { |
| 714 | $link = "$category"; | |
| 715 | if ($p1 == '') { | } |
| 716 | $p1 = 'newest'; | } |
| 717 | } | |
| 718 | // Case #4: it's viewing a list. This is the most complex case. | |
| 719 | // *** IF *** | if ($p0 == 'published' || $p0 == 'upcoming' || $p0 == 'archived') { |
| 720 | // If it's looking for the "published" and "newest", then | |
| 721 | // the link can be (and will be) shortened to /Category | if ($p1 == '') { |
| 722 | // (with the usual druligg_home trick) | $p1 = 'newest'; |
| 723 | if ($p0 == 'published' && $p1 == 'newest' ) { | } |
| 724 | if ($category == 'All' ) { | |
| 725 | $link = drigg_ui_home_url(); | // *** IF *** |
| 726 | } | // If it's looking for the "published" and "newest", then |
| 727 | else { | // the link can be (and will be) shortened to /Category |
| 728 | $link = "$category"; | // (with the usual druligg_home trick) |
| 729 | } | if ($p0 == 'published' && $p1 == 'newest' ) { |
| 730 | if ($category == 'All' ) { | |
| 731 | // *** OTHERWISE *** | $link = drigg_ui_home_url(); |
| 732 | // Otherwise, the link is just the straight "long" version | } |
| 733 | } | else { |
| 734 | else { | $link = "$category"; |
| 735 | } | |
| 736 | // Last minute change, so that it never tries to link | |
| 737 | // to upcoming/newest/All | // *** OTHERWISE *** |
| 738 | if ($category == 'All') { | // Otherwise, the link is just the straight "long" version |
| 739 | $category = ''; | } |
| 740 | } | else { |
| 741 | ||
| 742 | // It's a link! | // Last minute change, so that it never tries to link |
| 743 | $link = "$p0/$p1/$category"; | // to upcoming/newest/All |
| 744 | } | if ($category == 'All') { |
| 745 | if ($category == $p2) { | $category = ''; |
| 746 | $selected = $selected_string; | } |
| 747 | } | |
| 748 | } | // It's a link! |
| 749 | $link = "$p0/$p1/$category"; | |
| 750 | } | |
| 751 | // NOW that link is set, I will add the Drupal's root to it | if ($category == $p2) { |
| 752 | // in case there is one | $selected = $selected_string; |
| 753 | // | } |
| 754 | #$bp = base_path(); | } |
| 755 | #if ($bp != '/') { | |
| 756 | # $link = substr($bp, 0, -1) . $link; | |
| 757 | #} | // NOW that link is set, I will add the Drupal's root to it |
| 758 | // in case there is one | |
| 759 | // Work out the links for the RSS feed for that category - if | // |
| 760 | // present! | #$bp = base_path(); |
| 761 | $rss_links = ' '; | #if ($bp != '/') { |
| 762 | if ($print_rss_links) { | # $link = substr($bp, 0, -1) . $link; |
| 763 | $all_string = variable_get('drigg_look_rss_cat_all', ''); | #} |
| 764 | $cat_string = variable_get('drigg_look_rss_cat_pro', ''); | |
| 765 | // Work out the links for the RSS feed for that category - if | |
| 766 | if ($all_string || $cat_string) { | // present! |
| 767 | $rss_links .= '<span class="rss">'; | $rss_links = ' '; |
| 768 | } | if ($print_rss_links) { |
| 769 | $all_string = variable_get('drigg_look_rss_cat_all', ''); | |
| 770 | $options = array( | $cat_string = variable_get('drigg_look_rss_cat_pro', ''); |
| 771 | 'query' => NULL, | |
| 772 | 'fragment' => NULL, | if ($all_string || $cat_string) { |
| 773 | 'absolute' => FALSE, | $rss_links .= '<span class="rss">'; |
| 774 | 'html' => TRUE, | } |
| 775 | ); | |
| 776 | $options = array( | |
| 777 | if ($all_string) { | 'query' => NULL, |
| 778 | $rss_links .= l($all_string, "feed/all/$category", $options); | 'fragment' => NULL, |
| 779 | } | 'absolute' => FALSE, |
| 780 | 'html' => TRUE, | |
| 781 | if ($cat_string) { | ); |
| 782 | $rss_links .= l($cat_string, "feed/published/$category", $options); | |
| 783 | } | if ($all_string) { |
| 784 | $rss_links .= l($all_string, "feed/all/$category", $options); | |
| 785 | if ($all_string || $cat_string) { | } |
| 786 | $rss_links .= '</span>'; | |
| 787 | } | if ($cat_string) { |
| 788 | } | $rss_links .= l($cat_string, "feed/published/$category", $options); |
| 789 | } | |
| 790 | // Finally shows the output | |
| 791 | #$output .= '<li><a '. $selected .' href="'. $link .'">'. $terms['lookup'][$tid]['name'] . $rss_links .'</a></li>'; | if ($all_string || $cat_string) { |
| 792 | $output .= '<li><a '. $selected .' href="'. url($link) .'" title="'. t($terms['lookup'][$tid]['description']) .'"><span>'. t($terms['lookup'][$tid]['name']) .'</span></a>'. $rss_links .'</li>'; | $rss_links .= '</span>'; |
| 793 | $nr_of_sections ++; | } |
| 794 | } | } |
| 795 | } | |
| 796 | //return data only if there is some sections available | // Finally shows the output |
| 797 | if ($nr_of_sections >= 1) { | #$output .= '<li><a '. $selected .' href="'. $link .'">'. $terms['lookup'][$tid]['name'] . $rss_links .'</a></li>'; |
| 798 | return "<ul ". $class_string ." >$output</ul>"; | $output .= '<li><a '. $selected .' href="'. url($link) .'" title="'. t($terms['lookup'][$tid]['description']) .'"><span>'. t($terms['lookup'][$tid]['name']) .'</span></a>'. $rss_links .'</li>'; |
| 799 | } | $nr_of_sections ++; |
| 800 | else { | } |
| 801 | return NULL; | } |
| 802 | } | //return data only if there is some sections available |
| 803 | } | if ($nr_of_sections >= 1) { |
| 804 | return "<ul ". $class_string ." >$output</ul>"; | |
| 805 | function drigg_ui_home_url() { | } |
| 806 | if (variable_get('site_frontpage', '') == variable_get('drigg_home_name', 'drigg_home')) { | else { |
| 807 | return ''; | return NULL; |
| 808 | } | } |
| 809 | else { | } |
| 810 | return variable_get('drigg_home_name', 'drigg_home'); | |
| 811 | } | function drigg_ui_home_url() { |
| 812 | if (variable_get('site_frontpage', '') == variable_get('drigg_home_name', 'drigg_home')) { | |
| 813 | } | return ''; |
| 814 | } | |
| 815 | /** | else { |
| 816 | * Returns the "order" menu. | return variable_get('drigg_home_name', 'drigg_home'); |
| 817 | * This menu depends on its context: it will be different for "published" and | } |
| 818 | * "upcoming" | "archived". As for the "sections" menu, the current | |
| 819 | * path (and category) is maintained. | } |
| 820 | * However, it cannot be done all the time: for example, you cannot go from | |
| 821 | * upcoming/mostpopular/Business to published/mostpopular/Business because | /** |
| 822 | * "published" doesn't have "mostpopular" as an sorting criteria! | * Returns the "order" menu. |
| 823 | * So yes, this is a tricky one too. This is why it's basically impossible | * This menu depends on its context: it will be different for "published" and |
| 824 | * to write a Digg/Pligg clone without a _very_ specialised module. | * "upcoming" | "archived". As for the "sections" menu, the current |
| 825 | * | * path (and category) is maintained. |
| 826 | * @return | * However, it cannot be done all the time: for example, you cannot go from |
| 827 | * The actual menu | * upcoming/mostpopular/Business to published/mostpopular/Business because |
| 828 | */ | * "published" doesn't have "mostpopular" as an sorting criteria! |
| 829 | function drigg_ui_order_menu() { | * So yes, this is a tricky one too. This is why it's basically impossible |
| 830 | * to write a Digg/Pligg clone without a _very_ specialised module. | |
| 831 | // This is here simply to make the extraction of translation strings | * |
| 832 | // possible (because of that $t(item) ) | * @return |
| 833 | t('newest'); | * The actual menu |
| 834 | t('top24h'); | */ |
| 835 | t('top7days'); | function drigg_ui_order_menu() { |
| 836 | t('top30days'); | |
| 837 | t('top365days'); | // This is here simply to make the extraction of translation strings |
| 838 | // possible (because of that $t(item) ) | |
| 839 | $output = ''; | t('newest'); |
| 840 | $selected_string = ' class="active" '; | t('top24h'); |
| 841 | t('top7days'); | |
| 842 | $p0 = arg(0); | t('top30days'); |
| 843 | $p1 = arg(1); | t('top365days'); |
| 844 | $p2 = arg(2); | |
| 845 | $output = ''; | |
| 846 | // This will make sure that even the home page will work OK | $selected_string = ' class="active" '; |
| 847 | if ((arg(0)=='node' || arg(0) == variable_get('drigg_home_name', 'drigg_home') ) && arg(1) == '' ) { | |
| 848 | $p0 = 'published'; | $p0 = arg(0); |
| 849 | $p1 = 'newest'; | $p1 = arg(1); |
| 850 | } | $p2 = arg(2); |
| 851 | ||
| 852 | // This will make sure that even /Section works fine | // This will make sure that even the home page will work OK |
| 853 | if (drigg_is_section_valid( $p0 ) && $p1 == '' ) { | if ((arg(0)=='node' || arg(0) == variable_get('drigg_home_name', 'drigg_home') ) && arg(1) == '' ) { |
| 854 | $p0 = 'published'; | $p0 = 'published'; |
| 855 | $p1 = 'newest'; | $p1 = 'newest'; |
| 856 | $p2 = arg(0); | } |
| 857 | } | |
| 858 | // This will make sure that even /Section works fine | |
| 859 | if (( $p0 == 'published' || $p0 == 'upcoming' || $p0 == 'archived') && $p1 == '') { | if (drigg_is_section_valid( $p0 ) && $p1 == '' ) { |
| 860 | $p1 = 'newest'; | $p0 = 'published'; |
| 861 | } | $p1 = 'newest'; |
| 862 | $p2 = arg(0); | |
| 863 | } | |
| 864 | // This avoids doing anything if the URL is incorrect | |
| 865 | if ($p0 != 'published' && $p0 != 'upcoming' && $p0 != 'archived') { | if (( $p0 == 'published' || $p0 == 'upcoming' || $p0 == 'archived') && $p1 == '') { |
| 866 | return ''; | $p1 = 'newest'; |
| 867 | } | } |
| 868 | ||
| 869 | // Set the items in the menu | |
| 870 | if ($p0 == 'published') { | // This avoids doing anything if the URL is incorrect |
| 871 | $items = array('newest', 'top24h', 'top7days', 'top30days', 'top365days'); | if ($p0 != 'published' && $p0 != 'upcoming' && $p0 != 'archived') { |
| 872 | } | return ''; |
| 873 | else { | } |
| 874 | $items = array('newest', 'oldest', 'mostpopular', 'leastpopular'); | |
| 875 | } | // Set the items in the menu |
| 876 | if ($p0 == 'published') { | |
| 877 | // For each item, prints it, but with a twist... | $items = array('newest', 'top24h', 'top7days', 'top30days', 'top365days'); |
| 878 | // At this point, things are "normalised". So, no matter what, | } |
| 879 | // the format is for example published/top24h/Community or | else { |
| 880 | // published/top24h | $items = array('newest', 'oldest', 'mostpopular', 'leastpopular'); |
| 881 | foreach ($items as $item) { | } |
| 882 | $selected = ''; | |
| 883 | // For each item, prints it, but with a twist... | |
| 884 | // Mark it as selected if it's the same as the current one | // At this point, things are "normalised". So, no matter what, |
| 885 | if ($item == $p1) { | // the format is for example published/top24h/Community or |
| 886 | $selected = $selected_string; | // published/top24h |
| 887 | } | foreach ($items as $item) { |
| 888 | $selected = ''; | |
| 889 | // TWIST: if the item would point to published/newest, then make the | |
| 890 | // url simply /Category | // Mark it as selected if it's the same as the current one |
| 891 | if ($p0 == 'published' && $item == 'newest') { | if ($item == $p1) { |
| 892 | $link = "$p2"; | $selected = $selected_string; |
| 893 | if ($link == '') { | } |
| 894 | $link = drigg_ui_home_url(); | |
| 895 | } | // TWIST: if the item would point to published/newest, then make the |
| 896 | } | // url simply /Category |
| 897 | else { | if ($p0 == 'published' && $item == 'newest') { |
| 898 | $link = "$p0"; | $link = "$p2"; |
| 899 | if ($item != '') { | if ($link == '') { |
| 900 | $link .= "/$item"; | $link = drigg_ui_home_url(); |
| 901 | } | } |
| 902 | if ($p2 != '') { | } |
| 903 | $link .= "/$p2"; | else { |
| 904 | } | $link = "$p0"; |
| 905 | } | if ($item != '') { |
| 906 | $link .= "/$item"; | |
| 907 | // NOW that link is set, I will add the Drupal's root to it | } |
| 908 | // in case there is one | if ($p2 != '') { |
| 909 | // | $link .= "/$p2"; |
| 910 | #$bp = base_path(); | } |
| 911 | #if ($bp != '/') { | } |
| 912 | # $link = substr($bp, 0, -1) . $link; | |
| 913 | #} | // NOW that link is set, I will add the Drupal's root to it |
| 914 | // in case there is one | |
| 915 | $output .= '<li '. $selected .'><a '. $selected .' href="'. url($link) .'">'. t($item) .'</a></li>'; | // |
| 916 | #$bp = base_path(); | |
| 917 | } | #if ($bp != '/') { |
| 918 | return "<ul class=\"drigg-order\">$output</ul>"; | # $link = substr($bp, 0, -1) . $link; |
| 919 | #} | |
| 920 | } | |
| 921 | $output .= '<li '. $selected .'><a '. $selected .' href="'. url($link) .'">'. t($item) .'</a></li>'; | |
| 922 | ||
| 923 | /** | } |
| 924 | * Returns the top menu ("published", "upcoming", "archived") | return "<ul class=\"drigg-order\">$output</ul>"; |
| 925 | * This function ALSO preservs all of the links, whenever possible. | |
| 926 | * | } |
| 927 | * @return | |
| 928 | * The top menu | |
| 929 | */ | /** |
| 930 | function drigg_ui_type_menu() { | * Returns the top menu ("published", "upcoming", "archived") |
| 931 | $output = ''; | * This function ALSO preservs all of the links, whenever possible. |
| 932 | $selected_string = ' class="active" '; | * |
| 933 | * @return | |
| 934 | $p0 = arg(0); | * The top menu |
| 935 | $p1 = arg(1); | */ |
| 936 | $p2 = arg(2); | function drigg_ui_type_menu() { |
| 937 | $output = ''; | |
| 938 | // This will make sure that even the home page will work OK | $selected_string = ' class="active" '; |
| 939 | if ((arg(0) == 'node' || arg(0)== variable_get('drigg_home_name', 'drigg_home') ) && arg(1) == '' ) { | |
| 940 | $p0 = 'published'; | $p0 = arg(0); |
| 941 | $p1 = 'newest'; | $p1 = arg(1); |
| 942 | } | $p2 = arg(2); |
| 943 | ||
| 944 | // This will make sure that even /Section works fine | // This will make sure that even the home page will work OK |
| 945 | if (drigg_is_section_valid( $p0 ) && $p1 == '' ) { | if ((arg(0) == 'node' || arg(0)== variable_get('drigg_home_name', 'drigg_home') ) && arg(1) == '' ) { |
| 946 | $p0 = 'published'; | $p0 = 'published'; |
| 947 | $p1 = 'newest'; | $p1 = 'newest'; |
| 948 | $p2 = arg(0); | } |
| 949 | } | |
| 950 | // This will make sure that even /Section works fine | |
| 951 | // This avoids doing anything if the URL is incorrect | if (drigg_is_section_valid( $p0 ) && $p1 == '' ) { |
| 952 | if ($p0 != 'published' && $p0 != 'upcoming' && $p0 != 'archived') { | $p0 = 'published'; |
| 953 | return ''; | $p1 = 'newest'; |
| 954 | } | $p2 = arg(0); |
| 955 | } | |
| 956 | // Hide the "archived" menu entry, UNLESS you _ARE_ in "archived" | |
| 957 | if (variable_get('drigg_hide_archived_menu', FALSE) && $p0 != 'archived') { | // This avoids doing anything if the URL is incorrect |
| 958 | $items = array('published', 'upcoming'); | if ($p0 != 'published' && $p0 != 'upcoming' && $p0 != 'archived') { |
| 959 | } | return ''; |
| 960 | else { | } |
| 961 | $items = array('published', 'upcoming', 'archived'); | |
| 962 | } | // Hide the "archived" menu entry, UNLESS you _ARE_ in "archived" |
| 963 | if (variable_get('drigg_hide_archived_menu', FALSE) && $p0 != 'archived') { | |
| 964 | // For each item, prints it, but with a twist... | $items = array('published', 'upcoming'); |
| 965 | // At this point, things are "normalised". So, no matter what, | } |
| 966 | // the format is for example published/top24h/Community or | else { |
| 967 | // published/top24h | $items = array('published', 'upcoming', 'archived'); |
| 968 | foreach ($items as $item ) { | } |
| 969 | $selected = ''; | |
| 970 | // For each item, prints it, but with a twist... | |
| 971 | $pp1 = $p1; | // At this point, things are "normalised". So, no matter what, |
| 972 | // the format is for example published/top24h/Community or | |
| 973 | // Mark it as selected if it's the same as the current one | // published/top24h |
| 974 | if ($item == $p0) { | foreach ($items as $item ) { |
| 975 | $selected = $selected_string; | $selected = ''; |
| 976 | } | |
| 977 | $pp1 = $p1; | |
| 978 | // Last minute change: you can't jump from 'published/top24h' to | |
| 979 | // 'upcoming/24h'!!! So, if things are not right, fix them on the | // Mark it as selected if it's the same as the current one |
| 980 | // spot. From now on, $pp1 needs to be considered, rather than | if ($item == $p0) { |
| 981 | // $p1 | $selected = $selected_string; |
| 982 | // | } |
| 983 | if ($item == 'upcoming' || $item == 'archived') { | |
| 984 | if ($p1 != 'oldest' && $p1 != 'mostpopular' && $p1 != 'leastpopular') { | // Last minute change: you can't jump from 'published/top24h' to |
| 985 | $pp1 = 'newest'; | // 'upcoming/24h'!!! So, if things are not right, fix them on the |
| 986 | } | // spot. From now on, $pp1 needs to be considered, rather than |
| 987 | } | // $p1 |
| 988 | if ($item == 'published') { | // |
| 989 | if ($p1 != 'top7days' && $p1 != 'top24h' && $p1 != 'top30days' && $p1 != 'top365days') { | if ($item == 'upcoming' || $item == 'archived') { |
| 990 | $pp1 = 'newest'; | if ($p1 != 'oldest' && $p1 != 'mostpopular' && $p1 != 'leastpopular') { |
| 991 | } | $pp1 = 'newest'; |
| 992 | } | } |
| 993 | } | |
| 994 | // If the link is going to be /published/newest, then change it | if ($item == 'published') { |
| 995 | // last minute to just / | if ($p1 != 'top7days' && $p1 != 'top24h' && $p1 != 'top30days' && $p1 != 'top365days') { |
| 996 | if ($item == 'published' && $pp1 == 'newest' && $p2 == '') { | $pp1 = 'newest'; |
| 997 | $link = drigg_ui_home_url(); | } |
| 998 | // Otherwise, business as normal | } |
| 999 | } | |
| 1000 | else { | // If the link is going to be /published/newest, then change it |
| 1001 | $link = "$item"; | // last minute to just / |
| 1002 | if ($pp1 != '') { | if ($item == 'published' && $pp1 == 'newest' && $p2 == '') { |
| 1003 | $link .= "/$pp1"; | $link = drigg_ui_home_url(); |
| 1004 | } | // Otherwise, business as normal |
| 1005 | if ($p2 != '') { | } |
| 1006 | $link .= "/$p2"; | else { |
| 1007 | } | $link = "$item"; |
| 1008 | #$link="/$item" . $pp1 != '' ? "/$pp1/$p2" : ''; | if ($pp1 != '') { |
| 1009 | } | $link .= "/$pp1"; |
| 1010 | } | |
| 1011 | // NOW that link is set, I will add the Drupal's root to it | if ($p2 != '') { |
| 1012 | // in case there is one | $link .= "/$p2"; |
| 1013 | // | } |
| 1014 | #$bp = base_path(); | #$link="/$item" . $pp1 != '' ? "/$pp1/$p2" : ''; |
| 1015 | #if ($bp != '/') { | } |
| 1016 | # $link = substr($bp, 0, -1) . $link; | |
| 1017 | #} | // NOW that link is set, I will add the Drupal's root to it |
| 1018 | // in case there is one | |
| 1019 | $output .= "<li $selected><a ". $selected .' href="'. url($link) .'">'. t($item) .'</a></li>'; | // |
| 1020 | #$bp = base_path(); | |
| 1021 | } | #if ($bp != '/') { |
| 1022 | return "<ul class=\"drigg-viewtype\">$output</ul>"; | # $link = substr($bp, 0, -1) . $link; |
| 1023 | #} | |
| 1024 | } | |
| 1025 | $output .= "<li $selected><a ". $selected .' href="'. url($link) .'">'. t($item) .'</a></li>'; | |
| 1026 | ||
| 1027 | /** | } |
| 1028 | * Returns the article menu (who voted, comments, related links) | return "<ul class=\"drigg-viewtype\">$output</ul>"; |
| 1029 | * THis will most likely get called by node-drigg.tpl.php | |
| 1030 | * | } |
| 1031 | * @return | |
| 1032 | * The menu | |
| 1033 | * TODO: IMPORTANT!!! This needs to check if drigg_users AND drigg_sl are | /** |
| 1034 | * set, and base the creation of the menu according to the existence | * Returns the article menu (who voted, comments, related links) |
| 1035 | * of those modules AND the user input (which needs to be added for | * THis will most likely get called by node-drigg.tpl.php |
| 1036 | * "who voted") | * |
| 1037 | */ | * @return |
| 1038 | function drigg_ui_article_menu() { | * The menu |
| 1039 | * TODO: IMPORTANT!!! This needs to check if drigg_users AND drigg_sl are | |
| 1040 | if (! (arg(0) == 'node' && is_numeric(arg(1))) ) { | * set, and base the creation of the menu according to the existence |
| 1041 | return ''; | * of those modules AND the user input (which needs to be added for |
| 1042 | } | * "who voted") |
| 1043 | */ | |
| 1044 | // List of links at the bottom of the article | function drigg_ui_article_menu() { |
| 1045 | $items = array( '' => t('Comments'), ); | |
| 1046 | if (! (arg(0) == 'node' && is_numeric(arg(1))) ) { | |
| 1047 | return ''; | |
| 1048 | if (module_exists('drigg_users') && variable_get('drigg_users_tab_menu_show', TRUE)) { | } |
| 1049 | $items['who_voted'] = t('Who voted'); | |
| 1050 | } | // List of links at the bottom of the article |
| 1051 | $items = array( '' => t('Comments'), ); | |
| 1052 | // Only add related links if the admin wants it | |
| 1053 | if (module_exists('drigg_rl') && variable_get('drigg_rl_tab_menu_show', TRUE)) { | |
| 1054 | $items['related_links'] = t('Related links'); | if (module_exists('drigg_users') && variable_get('drigg_users_tab_menu_show', TRUE)) { |
| 1055 | }; | $items['who_voted'] = t('Who voted'); |
| 1056 | } | |
| 1057 | // For each item, prints it | |
| 1058 | foreach ($items as $item => $item_value) { | // Only add related links if the admin wants it |
| 1059 | $active_style = ''; | if (module_exists('drigg_rl') && variable_get('drigg_rl_tab_menu_show', TRUE)) { |