| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @file 4 * Hooks and API functions for Data UI module. 5 */ 6 7 /** 8 * Implementation of hook_help(). 9 */ 10 function data_ui_help($path, $arg) { 11 switch ($path) { 12 case 'admin/content/data': 13 $output = '<p>'. t('View content in data tables. If you would like to edit these tables, visit the !data_manage_page.', array('!data_manage_page' => l(t('Data table management page'), 'admin/build/data'))) .'</p><p>' . t('Some tables may not have a \'view\' link; this happens when a table doesn\'t have a \'primary key\' or is not joined to another table with a primary key. You can add a primary key field or a join from the table\'s \'Edit schema\' page.') . '</p>'; 14 return $output; 15 case 'admin/build/data/adopt': 16 $output = '<p>' . t('Manage database tables that aren\'t claimed by other modules. Adopting tables listed here will add them to Data\'s list of tables.') . '</p>'; 17 return $output; 18 case 'admin/build/data': 19 if (module_exists('views')) { 20 $output = '<p>'. t('Manage data tables. If you would like to view the content of these tables, visit the !data_view_page.', array('!data_view_page' => l(t('Data table content page'), 'admin/content/data'))) .'</p>'; 21 } 22 else { 23 $output = '<p>'. t('Manage data tables.') .'</p>'; 24 } 25 return $output; 26 } 27 } 28 29 /** 30 * Implementation of hook_menu() 31 */ 32 function data_ui_menu() { 33 $items = array(); 34 if (module_exists('views')) { 35 $items['admin/content/data'] = array( 36 'title' => 'Data tables', 37 'description' => 'View data tables.', 38 'page callback' => 'data_ui_view', 39 'file' => 'data_ui.admin.inc', 40 'access arguments' => array('administer data tables'), 41 ); 42 } 43 $items['admin/build/data'] = array( 44 'title' => 'Data tables', 45 'description' => 'Create, modify and delete data tables.', 46 'page callback' => 'data_ui_manage', 47 'file' => 'data_ui.admin.inc', 48 'access arguments' => array('administer data tables'), 49 ); 50 $items['admin/build/data/overview'] = array( 51 'title' => 'Overview', 52 'type' => MENU_DEFAULT_LOCAL_TASK, 53 'weight' => -10, 54 ); 55 // Only offer these options if schema module exists. 56 if (module_exists('schema')) { 57 $items['admin/build/data/compare'] = array( 58 'title' => 'Compare schemas', 59 'description' => 'Administer data tables.', 60 'page callback' => 'data_ui_compare', 61 'file' => 'data_ui.admin.inc', 62 'access arguments' => array('administer data tables'), 63 'type' => MENU_LOCAL_TASK, 64 ); 65 $items['admin/build/data/compare/%data_ui_table'] = array( 66 'title' => 'Adjust schema', 67 'description' => 'Administer data tables.', 68 'page callback' => 'drupal_get_form', 69 'page arguments' => array('data_ui_adjust_form', 4), 70 'file' => 'data_ui.admin.inc', 71 'access arguments' => array('administer data tables'), 72 'type' => MENU_LOCAL_TASK, 73 ); 74 $items['admin/build/data/adopt'] = array( 75 'title' => 'Adopt tables', 76 'description' => 'Adopt data tables that aren\'t claimed by any module.', 77 'page callback' => 'drupal_get_form', 78 'page arguments' => array('data_ui_adopt_form'), 79 'file' => 'data_ui.admin.inc', 80 'access arguments' => array('administer data tables'), 81 'type' => MENU_LOCAL_TASK, 82 'weight' => 10, 83 ); 84 } 85 $items['admin/build/data/create'] = array( 86 'title' => 'Create a table', 87 'description' => 'Create a data table.', 88 'page callback' => 'drupal_get_form', 89 'page arguments' => array('data_ui_create_form'), 90 'file' => 'data_ui.admin.inc', 91 'access arguments' => array('administer data tables'), 92 'type' => MENU_CALLBACK, 93 ); 94 $items['admin/build/data/drop/%data_ui_table'] = array( 95 'title' => 'Drop table', 96 'description' => 'Drop a data table.', 97 'page callback' => 'drupal_get_form', 98 'page arguments' => array('data_ui_drop_form', 4), 99 'file' => 'data_ui.admin.inc', 100 'access arguments' => array('administer data tables'), 101 'type' => MENU_CALLBACK, 102 ); 103 $items['admin/build/data/edit/%data_ui_table'] = array( 104 'title' => 'Data table', 105 'description' => 'Administer data tables.', 106 'page callback' => 'drupal_get_form', 107 'page arguments' => array('data_ui_edit_form', 4), 108 'file' => 'data_ui.admin.inc', 109 'access arguments' => array('administer data tables'), 110 'type' => MENU_CALLBACK, 111 ); 112 $items['admin/build/data/edit/%data_ui_table/edit'] = array( 113 'title' => 'Edit schema', 114 'type' => MENU_DEFAULT_LOCAL_TASK, 115 'weight' => -10, 116 ); 117 $items['admin/build/data/edit/%data_ui_table/title'] = array( 118 'title' => 'Edit title', 119 'description' => 'Edit the title of the table.', 120 'page callback' => 'drupal_get_form', 121 'page arguments' => array('data_ui_edit_title_form', 4), 122 'file' => 'data_ui.admin.inc', 123 'access arguments' => array('administer data tables'), 124 'type' => MENU_LOCAL_TASK, 125 'weight' => -9, 126 ); 127 if (module_exists('views')) { 128 $items['admin/build/data/edit/%data_ui_table/views'] = array( 129 'title' => 'Configure views', 130 'description' => 'Administer data tables.', 131 'page callback' => 'drupal_get_form', 132 'page arguments' => array('data_ui_views_form', 4), 133 'file' => 'data_ui.admin.inc', 134 'access arguments' => array('administer data tables'), 135 'type' => MENU_LOCAL_TASK, 136 ); 137 } 138 if (module_exists('devel')) { 139 $items['admin/build/data/edit/%data_ui_table/view-schema'] = array( 140 'title' => 'Devel load', 141 'description' => 'Administer data tables.', 142 'page callback' => 'data_ui_view_schema', 143 'page arguments' => array(4), 144 'file' => 'data_ui.admin.inc', 145 'access arguments' => array('administer data tables'), 146 'type' => MENU_LOCAL_TASK, 147 'weight' => 10, 148 ); 149 } 150 $items['admin/build/data/edit/%data_ui_table/join'] = array( 151 'title' => 'Join tables', 152 'description' => 'Administer data tables.', 153 'page callback' => 'drupal_get_form', 154 'page arguments' => array('data_ui_join_form', 4, 6), 155 'file' => 'data_ui.admin.inc', 156 'access arguments' => array('administer data tables'), 157 'type' => MENU_CALLBACK, 158 ); 159 $items['admin/build/data/revert/%data_ui_table'] = array( 160 'title' => 'Revert data table', 161 'description' => 'Administer data tables.', 162 'page callback' => 'drupal_get_form', 163 'page arguments' => array('data_ui_revert_form', 4), 164 'file' => 'data_ui.admin.inc', 165 'access arguments' => array('administer data tables'), 166 'type' => MENU_CALLBACK, 167 ); 168 $items['admin/build/data/export/%data_ui_table'] = array( 169 'title' => 'Data table', 170 'description' => 'Export data table.', 171 'page callback' => 'drupal_get_form', 172 'page arguments' => array('data_ui_export_form', 4), 173 'file' => 'data_ui.admin.inc', 174 'access arguments' => array('administer data tables'), 175 'type' => MENU_CALLBACK, 176 ); 177 return $items; 178 } 179 180 /** 181 * Menu loader callback. 182 */ 183 function data_ui_table_load($table_name) { 184 return data_get_table($table_name); 185 } 186 187 /** 188 * Title callback. 189 */ 190 function data_ui_title($title) { 191 return t('Edit table @table', array('@table' => $table->get('title'))); 192 } 193 194 /** 195 * Implementation of hook_views_api(). 196 */ 197 function data_ui_views_api() { 198 return array( 199 'api' => '2.0', 200 ); 201 } 202 203 /** 204 * Implementation of hook_theme() 205 */ 206 function data_ui_theme() { 207 return array( 208 'data_ui_edit_form' => array( 209 'arguments' => array('form' => array()), 210 ), 211 'data_ui_views_form' => array( 212 'arguments' => array('form' => array()), 213 ), 214 'data_ui_create_form' => array( 215 'arguments' => array('form' => array()), 216 ), 217 'data_ui_schema_compare_table' => array( 218 'arguments' => array('comparison' => array()), 219 ), 220 ); 221 } 222 223 /** 224 * Implementation of hook_perm(). 225 */ 226 function data_ui_perm() { 227 return array('administer data tables'); 228 } 229 230 /** 231 * Creates the default path for a data table. 232 */ 233 function data_ui_get_default_path($name) { 234 if ($table = data_get_table($name)) { 235 // Check whether this can be a Views base table. 236 $table_schema = $table->get('table_schema'); 237 if (isset($table_schema['primary key'])) { 238 return 'admin/content/data/view/'. $name; 239 } 240 241 // Check whether there is a data mananged table to the left. 242 // @todo: go all the way to the left. 243 $path = ''; 244 $meta = $table->get('meta'); 245 if (isset($meta['join']) && is_array($meta['join']) && !empty($meta['join'])) { 246 $left_table_name = key($meta['join']); 247 if ($left_table = data_get_table($left_table_name)) { 248 $path .= $left_table_name .'/'; 249 } 250 return 'admin/content/data/view/'. $path . $name; 251 } 252 } 253 return ''; 254 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |