tags */ function _spaces_views_arg_og_handler($args) { $gid = spaces_gid() ? array(spaces_gid()) : array(0); $args = is_array($args) ? array_merge($gid, $args) : $gid; return $args; } /** * 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 if (spaces_feature($feature) && $f = $features[$feature] && $types = $features[$feature]->node) { $content_types = node_get_types(); $type_name = $content_types[current($types)]->name; if (!$block) { $m = "
" . t('Please click below to add your first @content.', array('@content' => $type_name)) . "
"; $b = theme('spaces_button', $feature); } return $m . $b; } else { if ($block) { return ''; } else { drupal_not_found(); exit; } } } /** * 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 = "