| 1 |
<?php |
<?php |
| 2 |
// $Id: index.form.inc,v 1.1.2.12 2009/04/24 15:03:36 xano Exp $ |
// $Id: index.form.inc,v 1.1.2.13 2009/10/19 01:19:46 xano Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 6 |
* The Index administration section. |
* The Index administration section. |
| 7 |
*/ |
*/ |
| 8 |
|
|
| 9 |
/** |
/** |
| 26 |
|
|
| 27 |
$form = array( |
$form = array( |
| 28 |
'#redirect' => 'admin/build/index', |
'#redirect' => 'admin/build/index', |
| 29 |
'#prefix' => '<div id="index-form-add-wrapper"><div id="index-form-add-form"><h2>' . t('Configuration') . '</h2>', |
'#suffix' => '<div id="index-form-add-preview-page"><h2>' . t('Page preview') . '</h2><div class="content">' . $index->preview('page') . '</div></div><div id="index-form-add-preview-block"><h2>' . t('Block preview') . '</h2><div class="content">' . $index->preview('page') . '</div></div>', |
|
'#suffix' => '</div><div id="index-form-add-preview"><h2>' . t('Preview') . '</h2><div id="index-preview">' . $index->preview() . '</div></div></div>', |
|
| 30 |
); |
); |
| 31 |
|
|
| 32 |
// Internal settings. |
// Internal settings. |
| 35 |
'#value' => $iid, |
'#value' => $iid, |
| 36 |
); |
); |
| 37 |
|
|
| 38 |
// General index settings. |
// Index identification. |
| 39 |
$form['general']['title'] = array( |
$form['identification'] = array( |
| 40 |
|
'#prefix' => '<div id="index-form-add-identification">', |
| 41 |
|
'#suffix' => '</div>', |
| 42 |
|
); |
| 43 |
|
$form['identification']['title'] = array( |
| 44 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 45 |
'#title' => t('Title'), |
'#title' => t('Title'), |
| 46 |
'#default_value' => $index->title, |
'#default_value' => $index->title, |
| 47 |
'#maxlength' => 255, |
'#maxlength' => 255, |
| 48 |
'#required' => TRUE, |
'#required' => TRUE, |
| 49 |
); |
); |
| 50 |
$form['general']['description'] = array( |
$form['identification']['description'] = array( |
| 51 |
'#type' => 'textarea', |
'#type' => 'textarea', |
| 52 |
'#title' => t('Description'), |
'#title' => t('Description'), |
| 53 |
'#default_value' => $index->description, |
'#default_value' => $index->description, |
| 66 |
} |
} |
| 67 |
$page_path = check_plain($index->page_path); |
$page_path = check_plain($index->page_path); |
| 68 |
$page_path_description = $page_path ? t('Currently located at !location.', array('!location' => l('/' . $page_path, $page_path))) : ''; |
$page_path_description = $page_path ? t('Currently located at !location.', array('!location' => l('/' . $page_path, $page_path))) : ''; |
| 69 |
$form['general']['create'] = array( |
$form['create'] = array( |
| 70 |
'#type' => 'fieldset', |
'#type' => 'fieldset', |
| 71 |
'#title' => t('Create as'), |
'#title' => t('Create as'), |
| 72 |
|
'#prefix' => '<div id="index-form-add-create">', |
| 73 |
|
'#suffix' => '</div>', |
| 74 |
); |
); |
| 75 |
$form['general']['create']['page_enabled'] = array( |
$form['create']['page_enabled'] = array( |
| 76 |
'#type' => 'checkbox', |
'#type' => 'checkbox', |
| 77 |
'#title' => t('Page'), |
'#title' => t('Page'), |
| 78 |
'#default_value' => $index->page_enabled, |
'#default_value' => $index->page_enabled, |
| 79 |
); |
); |
| 80 |
$form['general']['create']['page_mode'] = array( |
$form['create']['page_mode'] = array( |
| 81 |
'#type' => 'select', |
'#type' => 'select', |
| 82 |
'#title' => t('Display mode'), |
'#title' => t('Display mode'), |
| 83 |
'#options' => $page_modes, |
'#options' => $page_modes, |
| 84 |
'#default_value' => $index->page_mode, |
'#default_value' => $index->page_mode, |
| 85 |
'#prefix' => '<div id="index-page-settings" class="index-settings">', |
'#prefix' => '<div id="index-page-settings" class="index-settings">', |
| 86 |
); |
); |
| 87 |
$form['general']['create']['page_path'] = array( |
$form['create']['page_path'] = array( |
| 88 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 89 |
'#title' => t('Path'), |
'#title' => t('Path'), |
| 90 |
'#description' => $page_path_description, |
'#description' => $page_path_description, |
| 93 |
'#element_validate' => array('index_path_validate'), |
'#element_validate' => array('index_path_validate'), |
| 94 |
'#suffix' => '</div>', |
'#suffix' => '</div>', |
| 95 |
); |
); |
| 96 |
$form['general']['create']['block_enabled'] = array( |
$form['create']['block_enabled'] = array( |
| 97 |
'#type' => 'checkbox', |
'#type' => 'checkbox', |
| 98 |
'#title' => t('Block'), |
'#title' => t('Block'), |
| 99 |
'#default_value' => $index->block_enabled, |
'#default_value' => $index->block_enabled, |
| 100 |
); |
); |
| 101 |
$form['general']['create']['block_mode'] = array( |
$form['create']['block_mode'] = array( |
| 102 |
'#type' => 'select', |
'#type' => 'select', |
| 103 |
'#title' => t('Display mode'), |
'#title' => t('Display mode'), |
| 104 |
'#options' => $block_modes, |
'#options' => $block_modes, |
| 183 |
$layer = &$form['layers']['selectors'][$i]; |
$layer = &$form['layers']['selectors'][$i]; |
| 184 |
$required = $layer["layer_type_$i"]['#required'] ? '<span class="form-required" title="' . t('This field is required.') . '">*</span>' : NULL; |
$required = $layer["layer_type_$i"]['#required'] ? '<span class="form-required" title="' . t('This field is required.') . '">*</span>' : NULL; |
| 185 |
$rows[] = array( |
$rows[] = array( |
| 186 |
$i + 1 . $required, |
theme('indentation', $i - 1) . theme('index_form_add_layer_depth', $i) . drupal_render($layer["layer_type_$i"]), |
|
drupal_render($layer["layer_type_$i"]), |
|
| 187 |
drupal_render($layer["layer_count_$i"]), |
drupal_render($layer["layer_count_$i"]), |
| 188 |
); |
); |
| 189 |
} |
} |
| 194 |
), |
), |
| 195 |
); |
); |
| 196 |
$header = array( |
$header = array( |
| 197 |
array( |
t('Data type'), |
|
'data' => t('Data type'), |
|
|
'colspan' => 2, |
|
|
), |
|
| 198 |
t('Count only'), |
t('Count only'), |
| 199 |
); |
); |
| 200 |
$layers = theme('table', $header, $rows, array(), t('Hierarchy')); |
$layers = theme('table', $header, $rows, array('id' => 'index-form-add-layers'), t('Hierarchy')); |
| 201 |
|
|
| 202 |
|
return drupal_render($form['identification']) . drupal_render($form['create']) . $layers . drupal_render($form); |
| 203 |
|
} |
| 204 |
|
|
| 205 |
|
/** |
| 206 |
|
* Theme the layer depth. |
| 207 |
|
*/ |
| 208 |
|
function theme_index_form_add_layer_depth($depth) { |
| 209 |
|
$root = !$depth ? 'root' : NULL; |
| 210 |
|
|
| 211 |
return drupal_render($form['general']) . $layers . drupal_render($form); |
return '<label for="edit-layer-type-' . $depth . '" class="index-form-add-layer-depth ' . $root . '">' . t('Layer !depth', array('!depth' => $depth)) . '</label>'; |
| 212 |
} |
} |
| 213 |
|
|
| 214 |
/** |
/** |
| 240 |
* Create the layer building widget, by default a table. |
* Create the layer building widget, by default a table. |
| 241 |
*/ |
*/ |
| 242 |
function index_form_add_layers(index $index) { |
function index_form_add_layers(index $index) { |
| 243 |
$data_types_info = index_data_types_get(); |
$entity_types_info = index_entity_types_get(); |
| 244 |
$default_option = array('<' . t('none') . '>'); |
$default_option = array('<' . t('none') . '>'); |
| 245 |
$parent_type = 0; |
$parent_type = 0; |
| 246 |
for ($i = 0; $i <= count($index->layers); $i++) { |
for ($i = 0; $i <= count($index->layers); $i++) { |
| 247 |
$current_options = array(); |
$current_options = array(); |
| 248 |
if ($parent_type) { |
if ($parent_type) { |
| 249 |
$current_data_types_info = array_intersect_key($data_types_info, $data_types_info[$parent_type]['#relations']); |
$current_entity_types_info = array_intersect_key($entity_types_info, $entity_types_info[$parent_type]['#relations']); |
| 250 |
foreach ($current_data_types_info as $data_type => $data_type_info) { |
foreach ($current_entity_types_info as $entity_type => $entity_type_info) { |
| 251 |
$current_options[$data_type] = $data_type_info['#title']; |
$current_options[$entity_type] = $entity_type_info['#title']; |
| 252 |
} |
} |
| 253 |
} |
} |
| 254 |
else { |
else { |
| 255 |
foreach ($data_types_info as $data_type => $data_type_info) { |
foreach ($entity_types_info as $entity_type => $entity_type_info) { |
| 256 |
$current_options[$data_type] = $data_type_info['#title']; |
$current_options[$entity_type] = $entity_type_info['#title']; |
| 257 |
} |
} |
| 258 |
} |
} |
| 259 |
|
|
| 301 |
$index->block_enabled = isset($_GET['block_enabled']) ? $_GET['block_enabled'] : FALSE; |
$index->block_enabled = isset($_GET['block_enabled']) ? $_GET['block_enabled'] : FALSE; |
| 302 |
$index->block_mode = $_GET['block_mode']; |
$index->block_mode = $_GET['block_mode']; |
| 303 |
|
|
| 304 |
echo $index->preview(); |
drupal_json(array( |
| 305 |
|
'page' => $index->page_enabled ? $index->preview('page') : NULL, |
| 306 |
|
'block' => $index->block_enabled ? $index->preview('block') : NULL, |
| 307 |
|
)); |
| 308 |
} |
} |
| 309 |
|
|
| 310 |
/** |
/** |