diff --git a/delta-override-form.tpl.php b/delta-override-form.tpl.php new file mode 100644 index 0000000000000000000000000000000000000000..65672d24fccfe419760d263f124c01c7d61ab3b8 --- /dev/null +++ b/delta-override-form.tpl.php @@ -0,0 +1,67 @@ +region_title: Region title for the listed block. + * - $data->block_title: Block title. + * - $data->region_select: Drop-down menu for assigning a region. + * - $data->weight_select: Drop-down menu for setting weights. + * - $data->throttle_check: Checkbox to enable throttling. + * - $data->configure_link: Block configuration link. + * - $data->delete_link: For deleting user added blocks. + * + * @see template_preprocess_block_admin_display_form() + * @see theme_block_admin_display() + */ +?> + $title) { + drupal_add_tabledrag('blocks', 'match', 'sibling', 'block-region-select', 'block-region-'. $region, NULL, FALSE); + drupal_add_tabledrag('blocks', 'order', 'sibling', 'block-weight', 'block-weight-'. $region); + } + */ +?> + + + + + + + + + + + + $data): ?> + + + + + + + + + + + + + +
block_title; ?>region_select; ?>weight_select; ?>throttle_check; ?>configure_link; ?>delete_link; ?>
+ + diff --git a/delta.module b/delta.module index d4f892e852ab5fd9b83c99cb12edb2d05d13298e..f2c85dcac94037cb752825ad04268e2473276584 100644 --- a/delta.module +++ b/delta.module @@ -90,16 +90,137 @@ function delta_menu() { foreach ($themes AS $id => $theme) { $items['admin/build/themes/delta/'. $theme->name] = array( 'title' => $theme->info['name'], - 'page callback' => 'drupal_get_form', - 'page arguments' => array('delta_theme_settings_config', $theme->name), + 'page callback' => 'delta_theme_overrides', + 'page arguments' => array($theme->name), 'type' => MENU_LOCAL_TASK, - 'file' => 'delta-settings.inc', 'access arguments' => array('configure delta theme api'), ); } return $items; } +/** + * Implementation of hook_theme + * @see http://api.drupal.org/api/function/hook_theme/6 + * + * @param $existing + * An array of existing implementations that may be used for override purposes. + * This is primarily useful for themes that may wish to examine existing implementations to extract + * data (such as arguments) so that it may properly register its own, higher priority implementations. + * + * @param $type + * What 'type' is being processed. This is primarily useful so that themes tell if they are the + * actual theme being called or a parent theme. + * + * @param $theme + * The actual name of theme that is being being checked (mostly only useful for theme engine). + * + * @param $path + * The directory path of the theme or module, so that it doesn't need to be looked up. + * + * @return array() + * Modules and themes implementing this return an array of arrays. + * The key to each sub-array is the internal name of the hook, and the array contains info about the hook. + */ +function delta_theme($existing, $type, $theme, $path) { + return array( + 'delta_theme_overrides_form' => array( + 'arguments' => array( + 'form' => NULL, + ), + 'file' => 'theme-functions.inc', + 'template' => 'delta-override-form', + ), + ); +} + + +/** + * Menu callback for admin/build/themes/delta/%. + */ +function delta_theme_overrides($theme) { + $result = db_query(" + SELECT + did, tid, system_name, name, type, weight, value + FROM {delta_theme_overrides} + ORDER BY weight ASC + "); + while ($delta = db_fetch_object($result)) { + $data[$delta->did] = array( + 'did' => $delta->did, + 'tid' => $delta->tid, + 'name' => $delta->name, + 'system_name' => $delta->system_name, + 'type' => $delta->type, + 'weight' => $delta->weight, + 'value' => $delta->value, + ); + } + return drupal_get_form('delta_theme_overrides_form', $theme, $data); +} + +/** + * Generate the override list page. + */ +function delta_theme_overrides_form(&$form_state, $theme, $data) { + // Build form tree + $form = array( + '#action' => url('admin/build/themes/delta/'. $theme), + '#tree' => TRUE, + ); + foreach($data AS $k => $delta) { + $key = 'delta_id_'. $k; + $form[$key]['name'] = array( + '#value' => $delta['name'], + ); + $form[$key]['weight'] = array( + '#type' => 'weight', + '#default_value' => $delta['weight'], + '#delta' => 100, + ); + $form[$key]['#info'] = 'delta_override'; + + + // operations + $form[$key]['view'] = array('#value' => l(t('view'), 'admin/build/themes/delta/'. $theme. '/view')); + $form[$key]['edit'] = array('#value' => l(t('edit'), 'admin/build/themes/delta/'. $theme. '/edit')); + $form[$key]['delete'] = array('#value' => l(t('delete'), 'admin/build/themes/delta/'. $theme. '/delete')); + $form[$key]['export'] = array('#value' => l(t('export'), 'admin/build/themes/delta/'. $theme. '/export')); + } + + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Save Changes'), + ); + + return $form; +} + +function template_preprocess_delta_theme_overrides_form(&$vars) { + krumo($vars); + foreach (element_children($vars['form']) as $i) { + $delta = &$vars['form'][$i]; + + // Only take form elements that are blocks. + if (isset($delta['#info'])) { + // Set special classes needed for table drag and drop. + $vars['form'][$i]['region']['#attributes']['class'] = 'block-region-select block-region-'. $region; + $vars['form'][$i]['weight']['#attributes']['class'] = 'block-weight block-weight-'. $region; + + $vars['delta_listing'][$i]->row_class = isset($delta['#attributes']['class']) ? $delta['#attributes']['class'] : ''; + $vars['delta_listing'][$i]->block_title = drupal_render($delta['info']); + $vars['delta_listing'][$i]->weight_select = drupal_render($delta['weight']); + $vars['delta_listing'][$i]->configure_link = drupal_render($delta['configure']); + $vars['delta_listing'][$i]->delete_link = !empty($delta['delete']) ? drupal_render($delta['delete']) : ''; + $vars['delta_listing'][$i]->printed = FALSE; + + $last_region = $region; + } + } + + $vars['form_submit'] = drupal_render($vars['form']); + krumo($vars); +} /** * Implmentation of hook_form_alter * @return $form @@ -112,7 +233,7 @@ function delta_form_system_theme_settings_alter(&$form, &$form_state) { /** * Custom function to manipulate the theme settings for current page. - * Should be called in template_preprocess_page(&$variables) + * Should be called in template_preprocess_page(&$vars) * @see http://api.drupal.org/api/function/template_preprocess_page/6 * @see http://insert_my_blog_post_here */ diff --git a/theme-functions.inc b/theme-functions.inc new file mode 100644 index 0000000000000000000000000000000000000000..b02b32d42c84f381ca2b88a31f77bfd3233b4d30 --- /dev/null +++ b/theme-functions.inc @@ -0,0 +1,3 @@ +