Tripal v1.0 (6.x-1.0)
|
00001 <?php 00002 00003 require_once "tripal_views.views.inc"; 00004 00005 require_once "includes/tripal_views_integration.inc"; 00006 require_once "includes/tripal_views_form_elements.inc"; 00007 require_once "includes/tripal_views_integration_port.inc"; 00008 00016 function tripal_views_menu() { 00017 $items = array(); 00018 00019 $items['chado'] = array( 00020 'title' => 'Search Biological Data', 00021 'description' => 'Listings of the various biological data available categorized by type.', 00022 'page callback' => 'tripal_views_biological_data_page', 00023 'access arguments' => array('access content'), 00024 'expanded' => TRUE, 00025 'type' => MENU_NORMAL_ITEM, 00026 ); 00027 00028 $items['admin/tripal/views'] = array( 00029 'title' => 'Views Integration', 00030 'description' => 'Integration with Drupal Views', 00031 'page callback' => 'tripal_views_description_page', 00032 'access arguments' => array('administer site configuration'), 00033 'type' => MENU_NORMAL_ITEM, 00034 ); 00035 00036 $items['admin/tripal/views/integration/list'] = array( 00037 'title' => 'List of Integrated Tables', 00038 'description' => 'Provide a list of all integrated tables and allows for adding new tables or editing already integrated tables.', 00039 'page callback' => 'tripal_views_integration_setup_list', 00040 'access arguments' => array('manage tripal_views_integration'), 00041 'type' => MENU_NORMAL_ITEM, 00042 'weight' => 0, 00043 ); 00044 00045 $items['admin/tripal/views/integration/new'] = array( 00046 'title' => 'Integrate A Table', 00047 'page callback' => 'drupal_get_form', 00048 'page arguments' => array('tripal_views_integration_form'), 00049 'access arguments' => array('manage tripal_views_integration'), 00050 'type' => MENU_NORMAL_ITEM, 00051 ); 00052 00053 $items['admin/tripal/views/integration/edit/%'] = array( 00054 'title' => 'Edit Views Integration', 00055 'page callback' => 'drupal_get_form', 00056 'page arguments' => array('tripal_views_integration_form', 5), 00057 'access arguments' => array('manage tripal_views_integration'), 00058 'type' => MENU_CALLBACK, 00059 ); 00060 00061 $items['admin/tripal/views/integration/delete/%'] = array( 00062 'title' => 'Delete Views Integration', 00063 'page callback' => 'tripal_views_integration_delete', 00064 'page arguments' => array(5), 00065 'access arguments' => array('manage tripal_views_integration'), 00066 'type' => MENU_CALLBACK, 00067 ); 00068 00069 $items['admin/tripal/views/import'] = array( 00070 'title' => 'Import Views Integration', 00071 'page callback' => 'drupal_get_form', 00072 'page arguments' => array('tripal_views_integration_import_form'), 00073 'access arguments' => array('manage tripal_views_integration'), 00074 'type' => MENU_NORMAL_ITEM, 00075 ); 00076 00077 $items['admin/tripal/views/integration/export/%'] = array( 00078 'title' => 'Import Views Integration', 00079 'page callback' => 'drupal_get_form', 00080 'page arguments' => array('tripal_views_integration_export_form', 5), 00081 'access arguments' => array('manage tripal_views_integration'), 00082 'type' => MENU_CALLBACK, 00083 ); 00084 00085 // Menu item for the AJAX callback function that retrieves the 00086 // portion of the form that contains all of the fields for the table being integrated 00087 $items['tripal/views/integration/ajax/view_setup_table'] = array( 00088 'title' => 'Import Views Integration', 00089 'page callback' => 'tripal_views_integration_ajax_view_setup_table', 00090 'page arguments' => array(), 00091 'access arguments' => array('manage tripal_views_integration'), 00092 'type' => MENU_CALLBACK, 00093 ); 00094 00095 // Menu item for the AJAX callback function that retrieves the list of 00096 // column names for the table that is selected to be joined. 00097 $items['tripal/views/integration/ajax/join_field/%/%'] = array( 00098 'title' => 'Import Views Integration', 00099 'page callback' => 'tripal_views_integration_ajax_join_field', 00100 'page arguments' => array(5, 6), 00101 'access arguments' => array('manage tripal_views_integration'), 00102 'type' => MENU_CALLBACK, 00103 ); 00104 00105 return $items; 00106 } 00107 00111 function tripal_views_init() { 00112 00113 // Need to ensure that all chado tables are integrated w/out making 00114 // the user go to views UI. It would be ideal to do this in a hook called only once 00115 // directly after install/enabling of the module but such a hook doesn't 00116 // exist in Drupal 6 00117 $tripal_views = db_fetch_object(db_query("SELECT true as has_rows FROM {tripal_views}")); 00118 if (!$tripal_views->has_rows) { 00119 tripal_views_integrate_all_chado_tables(); 00120 } 00121 } 00122 00130 function tripal_views_perm() { 00131 return array( 00132 'manage tripal_views_integration', 00133 ); 00134 } 00135 00145 function tripal_views_views_api() { 00146 return array( 00147 'api' => 2.0, 00148 ); 00149 } 00150 00159 function tripal_views_theme() { 00160 return array( 00161 'tripal_views_integration_form' => array( 00162 'arguments' => array('form' => NULL), 00163 'template' => 'tripal_views_integration_fields_form', 00164 ), 00165 'tripal_views_data_export_download_form' => array( 00166 'arguments' => array('form' => NULL), 00167 'template' => 'tripal_views_data_export_download_form', 00168 ), 00169 'file_upload_combo' => array( 00170 'arguments' => array('element' => NULL) 00171 ), 00172 'sequence_combo' => array( 00173 'arguments' => array('element' => NULL) 00174 ), 00175 ); 00176 } 00177 00182 function tripal_views_coder_ignore() { 00183 return array( 00184 'path' => drupal_get_path('module', 'tripal_views'), 00185 'line prefix' => drupal_get_path('module', 'tripal_views'), 00186 ); 00187 } 00188 00193 function tripal_views_biological_data_page() { 00194 $output = ''; 00195 00196 $item = menu_get_item(); 00197 $content = system_admin_menu_block($item); 00198 00199 $output .= '<dl class="admin-list">'; 00200 foreach ($content as $item) { 00201 $output .= '<dt>'. l($item['title'], $item['href'], $item['localized_options']) .'</dt>'; 00202 $output .= '<dd>'. $item['description'] .'</dd>'; 00203 } 00204 $output .= '</dl>'; 00205 00206 return $output; 00207 } 00208 00209 /* 00210 * 00211 */ 00212 function tripal_views_form_alter(&$form, &$form_state, $form_id) { 00213 if ($form_id == "tripal_views_integration_form") { 00214 // updating the form through the ahah callback sets the action of 00215 // the form to the ahah callback URL. We need to set it back 00216 // to the normal form URL 00217 if ($form_state['values']['setup_id']) { 00218 $form['#action'] = url("admin/tripal/views/integration/edit/" . $form_state['values']['setup_id']); 00219 } 00220 else { 00221 $form['#action'] = url("admin/tripal/views/integration/new"); 00222 } 00223 } 00224 }