| 1 |
<?php |
<?php |
| 2 |
// $Id: index.module,v 1.1.2.8 2009/04/24 19:31:10 xano Exp $ |
// $Id: index.module,v 1.1.2.9 2009/10/19 01:19:46 xano Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 6 |
* Index is a data browser with different kinds of views. |
* Index is a data browser with different kinds of views. |
| 7 |
*/ |
*/ |
| 8 |
|
|
| 9 |
/** |
/** |
| 93 |
'form' => array(), |
'form' => array(), |
| 94 |
), |
), |
| 95 |
), |
), |
| 96 |
|
'index_form_add_layer_depth' => array( |
| 97 |
|
'arguments' => array( |
| 98 |
|
'depth' => 0, |
| 99 |
|
), |
| 100 |
|
), |
| 101 |
); |
); |
| 102 |
} |
} |
| 103 |
|
|
| 111 |
$result = db_query("SELECT iid, title FROM {index_index} WHERE block_mode IS NOT NULL"); |
$result = db_query("SELECT iid, title FROM {index_index} WHERE block_mode IS NOT NULL"); |
| 112 |
while ($block = db_fetch_object($result)) { |
while ($block = db_fetch_object($result)) { |
| 113 |
$blocks[$block->iid] = array( |
$blocks[$block->iid] = array( |
| 114 |
'info' => $block->title . ' (Index)', |
'info' => $block->title, |
| 115 |
'cache' => BLOCK_NO_CACHE, |
'cache' => BLOCK_NO_CACHE, |
| 116 |
); |
); |
| 117 |
} |
} |
| 118 |
return $blocks; |
return $blocks; |
| 119 |
case 'view': |
case 'view': |
| 120 |
index_load_include('classes'); |
index_load_include('classes'); |
| 121 |
$block = new Index($delta); |
// Deltas are saved as strings, so we cast ours to an integer. |
| 122 |
|
$index = new Index((int) $delta); |
| 123 |
return array( |
return array( |
| 124 |
'subject' => $block->title, |
'subject' => $index->title, |
| 125 |
'content' => $block->view(), |
'content' => $index->view('block'), |
| 126 |
); |
); |
| 127 |
} |
} |
| 128 |
} |
} |
| 147 |
'#block' => TRUE, |
'#block' => TRUE, |
| 148 |
'#callback_info' => array( |
'#callback_info' => array( |
| 149 |
'#callback' => 'index_render_tree', |
'#callback' => 'index_render_tree', |
| 150 |
'#file' => '/includes/index.render.inc', |
'#file' => '/includes/index.view.inc', |
| 151 |
), |
), |
| 152 |
); |
); |
| 153 |
$modes['browsable'] = array( |
$modes['browsable'] = array( |
| 155 |
'#page' => TRUE, |
'#page' => TRUE, |
| 156 |
'#callback_info' => array( |
'#callback_info' => array( |
| 157 |
'#callback' => 'index_render_browsable', |
'#callback' => 'index_render_browsable', |
| 158 |
'#file' => '/includes/index.render.inc', |
'#file' => '/includes/index.view.inc', |
| 159 |
), |
), |
| 160 |
); |
); |
| 161 |
$modes['flat'] = array( |
$modes['flat'] = array( |
| 163 |
'#block' => TRUE, |
'#block' => TRUE, |
| 164 |
'#callback_info' => array( |
'#callback_info' => array( |
| 165 |
'#callback' => 'index_render_flat', |
'#callback' => 'index_render_flat', |
| 166 |
'#file' => '/includes/index.render_tree.inc', |
'#file' => '/includes/index.view.inc', |
| 167 |
), |
), |
| 168 |
); |
); |
| 169 |
|
|
| 171 |
} |
} |
| 172 |
|
|
| 173 |
/** |
/** |
| 174 |
* Implementation of hook_index_data_type_info(). |
* Implementation of hook_index_entity_type_info(). |
| 175 |
*/ |
*/ |
| 176 |
function index_index_data_type_info() { |
function index_index_entity_type_info() { |
| 177 |
$data['node'] = array( |
$entities['node'] = array( |
| 178 |
'#title' => t('Content'), |
'#title' => t('Content'), |
| 179 |
'#relations' => array( |
'#relations' => array( |
| 180 |
'user' => 'uid', |
'user' => 'uid', |
| 182 |
'taxonomy_term' => 'nid', |
'taxonomy_term' => 'nid', |
| 183 |
'node_type' => 'type', |
'node_type' => 'type', |
| 184 |
), |
), |
| 185 |
'#callback_info' => array( |
'#data_callback_info' => array( |
| 186 |
'#callback' => 'index_data_get_node', |
'#callback' => 'index_data_get_node', |
| 187 |
'#file' => 'includes/index.data.inc', |
'#file' => 'includes/index.data.inc', |
| 188 |
), |
), |
| 189 |
); |
); |
| 190 |
$data['node_type'] = array( |
$entities['node_type'] = array( |
| 191 |
'#title' => t('Content types'), |
'#title' => t('Content types'), |
| 192 |
'#relations' => array( |
'#relations' => array( |
| 193 |
'node' => 'type', |
'node' => 'type', |
| 194 |
'taxonomy_vocabulary' => 'type', |
'taxonomy_vocabulary' => 'type', |
| 195 |
), |
), |
| 196 |
'#callback_info' => array( |
'#data_callback_info' => array( |
| 197 |
'#callback' => 'index_data_get_node_type', |
'#callback' => 'index_data_get_node_type', |
| 198 |
'#file' => 'includes/index.data.inc', |
'#file' => 'includes/index.data.inc', |
| 199 |
), |
), |
| 200 |
); |
); |
| 201 |
$data['user'] = array( |
$entities['user'] = array( |
| 202 |
'#title' => t('Users'), |
'#title' => t('Users'), |
| 203 |
'#relations' => array( |
'#relations' => array( |
| 204 |
'node' => 'uid', |
'node' => 'uid', |
| 205 |
'comment' => 'uid', |
'comment' => 'uid', |
| 206 |
'role' => 'uid', |
'user_role' => 'uid', |
| 207 |
), |
), |
| 208 |
'#callback_info' => array( |
'#data_callback_info' => array( |
| 209 |
'#callback' => 'index_data_get_user', |
'#callback' => 'index_data_get_user', |
| 210 |
'#file' => 'includes/index.data.inc', |
'#file' => 'includes/index.data.inc', |
| 211 |
), |
), |
| 212 |
|
'#theme_info' => array( |
| 213 |
|
'#theme' => 'index_data_user', |
| 214 |
|
'#file' => 'includes/index.view.inc', |
| 215 |
|
), |
| 216 |
); |
); |
| 217 |
$data['user_role'] = array( |
$entities['user_role'] = array( |
| 218 |
'#title' => t('Roles'), |
'#title' => t('Roles'), |
| 219 |
'#relations' => array( |
'#relations' => array( |
| 220 |
'user' => 'uid', |
'user' => 'uid', |
|
'comment' => 'nid', |
|
|
'taxonomy_term' => 'nid', |
|
| 221 |
), |
), |
| 222 |
'#callback_info' => array( |
'#data_callback_info' => array( |
| 223 |
'#callback' => 'index_data_get_user_role', |
'#callback' => 'index_data_get_user_role', |
| 224 |
'#file' => 'includes/index.data.inc', |
'#file' => 'includes/index.data.inc', |
| 225 |
), |
), |
| 226 |
|
'#theme_info' => array( |
| 227 |
|
'#theme' => 'index_data_user_role', |
| 228 |
|
'#file' => 'includes/index.view.inc', |
| 229 |
|
), |
| 230 |
); |
); |
| 231 |
$data['taxonomy_term'] = array( |
$entities['taxonomy_term'] = array( |
| 232 |
'#title' => t('Terms'), |
'#title' => t('Terms'), |
| 233 |
'#relations' => array( |
'#relations' => array( |
| 234 |
'node' => 'nid', |
'node' => 'nid', |
| 235 |
'taxonomy_vocabulary' => 'vid', |
'taxonomy_vocabulary' => 'vid', |
| 236 |
'taxonomy_term_synonym' => 'tid', |
'taxonomy_term_synonym' => 'tid', |
| 237 |
), |
), |
| 238 |
'#callback_info' => array( |
'#data_callback_info' => array( |
| 239 |
'#callback' => 'index_data_get_taxonomy_term', |
'#callback' => 'index_data_get_taxonomy_term', |
| 240 |
'#file' => 'includes/index.data.inc', |
'#file' => 'includes/index.data.inc', |
| 241 |
), |
), |
| 242 |
); |
); |
| 243 |
$data['taxonomy_vocabulary'] = array( |
$entities['taxonomy_vocabulary'] = array( |
| 244 |
'#title' => t('Vocabularies'), |
'#title' => t('Vocabularies'), |
| 245 |
'#relations' => array( |
'#relations' => array( |
| 246 |
'taxonomy_term' => 'vid', |
'taxonomy_term' => 'vid', |
| 247 |
'node_type' => 'type,' |
'node_type' => 'type,' |
| 248 |
), |
), |
| 249 |
'#callback_info' => array( |
'#data_callback_info' => array( |
| 250 |
'#callback' => 'index_data_get_taxonomy_vocabulary', |
'#callback' => 'index_data_get_taxonomy_vocabulary', |
| 251 |
'#file' => 'includes/index.data.inc', |
'#file' => 'includes/index.data.inc', |
| 252 |
), |
), |
| 253 |
); |
); |
| 254 |
|
|
| 255 |
return $data; |
return $entities; |
| 256 |
} |
} |
| 257 |
|
|
| 258 |
/** |
/** |
| 275 |
} |
} |
| 276 |
$modes += $module_modes; |
$modes += $module_modes; |
| 277 |
} |
} |
| 278 |
drupal_alter('_index_mode_info', $modes); |
drupal_alter('index_mode_info', $modes); |
| 279 |
} |
} |
| 280 |
|
|
| 281 |
return $modes; |
return $modes; |
| 282 |
} |
} |
| 283 |
|
|
| 284 |
/** |
/** |
| 285 |
* Return a list of all data types. |
* Return a list of all entity types. |
| 286 |
*/ |
*/ |
| 287 |
function index_data_types_get() { |
function index_entity_types_get() { |
| 288 |
static $data_types = NULL; |
static $entity_types = NULL; |
| 289 |
|
|
| 290 |
if (!$data_types) { |
if (!$entity_types) { |
| 291 |
$data_types = array(); |
$entity_types = array(); |
| 292 |
$modules = module_implements('index_data_type_info'); |
$modules = module_implements('index_entity_type_info'); |
| 293 |
foreach ($modules as $module) { |
foreach ($modules as $module) { |
| 294 |
$module_modes = call_user_func($module . '_index_data_type_info'); |
$module_modes = call_user_func($module . '_index_entity_type_info'); |
| 295 |
foreach ($module_modes as &$module_mode) { |
foreach ($module_modes as &$module_mode) { |
| 296 |
$module_mode['#callback_info']['#module'] = $module; |
$module_mode['#data_callback_info']['#module'] = $module; |
| 297 |
|
$module_mode['#theme_info']['#module'] = $module; |
| 298 |
} |
} |
| 299 |
$data_types += $module_modes; |
$entity_types += $module_modes; |
| 300 |
} |
} |
| 301 |
drupal_alter('_index_data_type_info', $data_types); |
drupal_alter('index_entity_type_info', $entity_types); |
| 302 |
} |
} |
| 303 |
|
|
| 304 |
return $data_types; |
return $entity_types; |
| 305 |
|
} |
| 306 |
|
|
| 307 |
|
/** |
| 308 |
|
* Execute a callback. |
| 309 |
|
* |
| 310 |
|
* @param $callback_info |
| 311 |
|
* An associative array containing callback information as defined in |
| 312 |
|
* hook_index_entity_type_info(), for instance. |
| 313 |
|
* @param ... |
| 314 |
|
* Additional arguments to pass on to the callback. |
| 315 |
|
*/ |
| 316 |
|
function index_callback_execute($callback_info) {echo gettype($callback_info); |
| 317 |
|
if (is_null($callback_info)) {print_r(debug_backtrace());} |
| 318 |
|
require_once('./'. drupal_get_path('module', $callback_info['#module']) . '/' . $callback_info['#file']); |
| 319 |
|
$args = func_get_args(); |
| 320 |
|
array_shift($args); |
| 321 |
|
|
| 322 |
|
return call_user_func_array($callback_info['#callback'], $args); |
| 323 |
} |
} |