display_handler->definition['handler'] == 'views_plugin_display_page') { if ($feature = context_get('spaces', 'feature')) { // This breaks shiz! not sure why. // $view->display_handler->set_option('empty', _spaces_views_empty($feature)); } } } /** * Implementation of hook_views_handlers(). */ function spaces_views_handlers() { return array( 'info' => array( 'path' => drupal_get_path('module', 'spaces') .'/includes', ), 'handlers' => array( 'spaces_handler_filter_spaces_current' => array( 'parent' => 'views_handler_filter', ), ), ); } /** * Implementation of hook_views_data(). * Adds a meta-filter that provides a layer of abstraction that * delegates actual filtering to the implementing space type modules. */ function spaces_views_data() { $data = array(); // This defines a fake "pseudo" table. $data['spaces']['table']['group'] = t('Spaces'); $data['spaces']['table']['join'] = array( 'node' => array( 'left_field' => 'nid', 'field' => 'sid', ), ); $data['spaces']['current'] = array( 'title' => t('Spaces: node in current space'), 'help' => t('Posts in current space.'), 'filter' => array( 'handler' => 'spaces_handler_filter_spaces_current', ), ); return $data; } /** * Function that handles a variety of tasks needed when view is empty */ function _spaces_views_empty($feature, $block = false) { $features = spaces_features(); // Check to see if user has access to this feature $space = spaces_get_space(); if ($space && $space->feature_access($feature) && $types = $features[$feature]->node) { $content_types = node_get_types(); $type_name = $content_types[current($types)]->name; if (!$block) { $b = spaces_node_links(); if ($b) { $m = "
" . t('Please click below to add your first @content.', array('@content' => $type_name)) . "
"; } else { $m = "" . t('No entries were found.', array('@content' => $type_name)) . "
"; } } return $m . $b; } else { if ($block) { return ''; } else { drupal_not_found(); exit; } } } /** * THE FUNCTIONS BELOW ARE ALMOST CERTAINLY DEPRECATED ================ * @TODO: remove or adapt the functions for Views2 */ /** * Custom view handler for filetypes */ function spaces_views_handler_filetype($fieldinfo, $fielddata, $value, $data) { $file = new stdClass(); $file->filemime = $data->files_filemime; $file->filename = $data->files_filename; $file->filepath = $data->files_filepath; return theme('fileview', $file); } /** * Custom view handler for coloration projects */ function spaces_views_handler_crayon_name($fieldinfo, $fielddata, $value, $data) { switch ($fielddata['options']) { case 'og': $og = db_fetch_object(og_get_node_groups_result($data->nid)); $og->nid = $og->group_nid; return theme('crayon_popup', $og); break; case 'casetracker': static $nodes = array(); $pid = $data->casetracker_case_pid; if (!$nodes[$pid]) { $nodes[$pid] = db_fetch_object(db_query(db_rewrite_sql("SELECT n.nid, n.title FROM {node} n WHERE n.nid = %d"), $pid)); } return theme('crayon_popup', $nodes[$pid]); break; } } /** * hook_views_style_plugins */ function spaces_views_style_plugins($value='') { $items['spaces_datetitle'] = array( 'name' => t('Spaces: Date title listing'), 'theme' => 'spaces_datetitle_view_style', 'validate' => 'views_ui_plugin_validate_list', 'needs_fields' => true, 'weight' => 0, ); return $items; } /** * retrieves the field id of the $op type provided */ function _spaces_views_get_field($op, $view) { switch ($op) { case 'cck_date': $view = (object) $view; $fields = _views_get_fields(); // iterate through provided fields and check for date field foreach ($view->field as $field_id => $field) { $field_key = $field['tablename'] .'.'. $field['field']; if (($fields[$field_key]['content_field_module'] == 'date') && $view->field[$field_id]) { return $field_id; } } return false; } } function theme_spaces_datetitle_view_style($view, $nodes, $type) { $fields = _views_get_fields(); $taken = array(); // Set up the fields in nicely named chunks. foreach ($view->field as $id => $field) { $field_name = $field['field']; if (isset($taken[$field_name])) { $field_name = $field['queryname']; } $taken[$field_name] = true; $field_names[$id] = $field_name; } // Set up some variables that won't change. $base_vars = array( 'view' => $view, 'view_type' => $type, ); // CCK fields can be named anything, so we use // a custom function to ransack the view for fields we might want $custom_fields = array(); if (_spaces_views_get_field('cck_date', $view) !== false) { $custom_fields[_spaces_views_get_field('cck_date', $view)] = 'cck_date'; } foreach ($nodes as $i => $node) { $vars = $base_vars; $vars['node'] = $node; $vars['count'] = $i; $vars['stripe'] = $i % 2 ? 'even' : 'odd'; foreach ($view->field as $id => $field) { if (isset($custom_fields[$id])) { $name = $custom_fields[$id]; } else{ $name = $field_names[$id]; } $vars[$name] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view); if (isset($field['label'])) { $vars[$name . '_label'] = $field['label']; } } $items[] = theme('datetime_view_style_item', $vars); } if ($items) { return theme('item_list', $items); } } /** * */ function theme_datetime_view_style_item($vars) { $item = (object)$vars; $_date = array( $item->created, $item->changed, $item->last_comment_timestamp, $item->cck_date ); foreach ($_date as $t) { if ($t) { $d = $t; break; } } $_user = array($item->assign_to, $item->name, $item->user); foreach ($_user as $t) { if ($t) { $u = $t; break; } } $_title = array( $item->subject, $item->node_title, // node title gets precedence over group title $item->title, ); foreach ($_title as $t) { if ($t) { $title = $t; break; } } $output = "