Index: project/project.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/project/project.module,v retrieving revision 1.304 diff -u -p -r1.304 project.module --- project/project.module 6 Oct 2007 19:42:32 -0000 1.304 +++ project/project.module 27 Nov 2007 12:20:23 -0000 @@ -408,6 +408,11 @@ function project_menu($may_cache) { } else { drupal_add_css(drupal_get_path('module', 'project') .'/project.css'); + $project_path = drupal_get_path('module', 'project'); + if (module_exists('views')) { + require './'. $project_path .'/project_views.inc'; + } + if (arg(0) == 'node' && is_numeric(arg(1))) { $node = node_load(arg(1)); if ($node->type == 'project_project' && node_access('update', $node) && Index: project/project_views.inc =================================================================== RCS file: project/project_views.inc diff -N project/project_views.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ project/project_views.inc 27 Nov 2007 12:20:23 -0000 @@ -0,0 +1,225 @@ + 'project_projects', + 'join' => array( + 'type' => 'inner', + 'left' => array( + 'table' => 'node', + 'field' => 'nid' + ), + 'right' => array( + 'field' => 'nid' + ), + ), + 'fields' => array( + 'uri' => array( + 'name' => t('Project project: Short name'), + 'sortable' => true, + 'help' => t('The project\'s short name.'), + ), + 'homepage' => array( + 'name' => t('Project project: homepage'), + 'handler' => 'views_handler_field_project_project_url', + 'sortable' => true, + 'help' => t('The project\'s homepage.'), + 'option' => array( + '#type' => 'select', + '#options' => array( + 'link' => t('As link'), + 'nolink' => t('Without link') + ), + ), + ), + 'changelog' => array( + 'name' => t('Project project: changelog'), + 'handler' => 'views_handler_field_project_project_url', + 'sortable' => true, + 'help' => t('The project\'s changelog.'), + 'option' => array( + '#type' => 'select', + '#options' => array( + 'link' => t('As link'), + 'nolink' => t('Without link') + ), + ), + ), + 'cvs' => array( + 'name' => t('Project project: cvs'), + 'handler' => 'views_handler_field_project_project_url', + 'sortable' => true, + 'help' => t('The project\'s cvs directory.'), + 'option' => array( + '#type' => 'select', + '#options' => array( + 'link' => t('As link'), + 'nolink' => t('Without link') + ), + ), + ), + 'demo' => array( + 'name' => t('Project project: demo'), + 'help' => t('The project\'s homepage.'), + 'sortable' => true, + 'handler' => 'views_handler_field_project_project_url', + 'option' => array( + '#type' => 'select', + '#options' => array( + 'link' => t('As link'), + 'nolink' => t('Without link') + ), + ), + ), + 'release_directory' => array( + 'name' => t('Project project: release directory'), + 'help' => t('The project\'s release directory.'), + 'sortable' => true, + ), + 'version' => array( + 'name' => t('Project project: version'), + 'help' => t('The project\'s version.'), + 'sortable' => true, + ), + 'documentation' => array( + 'name' => t('Project project: documentation'), + 'help' => t('The project\'s documentation.'), + 'sortable' => true, + 'handler' => 'views_handler_field_project_project_url', + 'option' => array( + '#type' => 'select', + '#options' => array( + 'link' => t('As link'), + 'nolink' => t('Without link') + ), + ), + ), + 'screenshort' => array( + 'name' => t('Project project: screenshot'), + 'help' => t('The project\'s screenshot.'), + 'sortable' => true, + 'handler' => 'views_handler_field_project_project_url', + 'option' => array( + '#type' => 'select', + '#options' => array( + 'link' => t('As link'), + 'nolink' => t('Without link') + ), + ), + ), + 'license' => array( + 'name' => t('Project project: license'), + 'help' => t('The project\'s license.'), + 'sortable' => true, + 'handler' => 'views_handler_field_project_project_url', + 'option' => array( + '#type' => 'select', + '#options' => array( + 'link' => t('As link'), + 'nolink' => t('Without link') + ), + ), + ), + ), + ); + + // Add data from the project_issue module + $tables['project_issue_projects'] = array( + 'name' => 'project_issue_projects', + 'join' => array( + 'type' => 'inner', + 'left' => array( + 'table' => 'project_projects', + 'field' => 'nid' + ), + 'right' => array( + 'field' => 'nid' + ), + ), + 'fields' => array( + 'issues' => array( + 'name' => t('Project project: Issues'), + 'sortable' => true, + 'help' => t('Display whether the project node is associated with any issues.'), + ), + ), + ); + return $tables; +} + +/* + * Format a field as a link. + */ +function views_handler_field_project_project_url($fieldinfo, $fielddata, $value, $data) { + if ($fielddata['options'] == 'nolink') { + return check_plain($value); + } + return l($value, $value); +} + +/** + * Implementation of hook_views_style_plugins + */ +function project_views_style_plugins() { + $items['project_overview'] = array( + 'name' => t('Project overview'), + 'theme' => 'project_overview_view', + 'validate' => 'views_ui_plugin_validate_list', // I'm not sure if I need this and if so what it should do + 'needs_fields' => true, + 'weight' => 1, + ); + return $items; +} + +function theme_project_overview_view($view, $nodes, $type) { +$version = -1; // this is set for testing purposes. There isn't an actual version selector yet. + foreach ($nodes as $node) { + $project = node_load(array('nid' => $node->nid)); + + // Merge $node properties (from views) into $project object + $properties = get_object_vars($node); + foreach ($properties as $property => $property_value) { + $project->$property = $property_value; + } + + $project->links = array(); + if ($version != -1) { + if ($project->project_release_nodes_file_path) { + $project->links['project_download'] = theme('project_release_download_link', $project->file_path, t('Download'), 'array'); + } + } + else { + $release_type = $project->snapshot_table ? 'all' : 'official'; + $project->download_table = theme('project_release_table_overview', $project, 'defaults', $release_type, t('Version'), FALSE); + } + + $project->links['project_more_info'] = array( + 'title' => t('Find out more'), + 'href' => "node/$project->nid", + ); + if ($project->project_issue_projects_issues) { + $project->links['project_issues'] = array( + 'title' => t('Bugs and feature requests'), + 'href' => "project/issues/$project->nid", + ); + } +// The different sort methods pages should probably be handled by views and not directly by project.module now. +// if (module_invoke($module, 'project_sort_methods', 'group by date', $sort_method) && $date = _project_date($project->changed)) { +// $projects .= "