summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhimerus2009-11-05 04:09:25 (GMT)
committer himerus2009-11-05 04:09:25 (GMT)
commit2b5d94540f3e6b3a3043c966164f107048946d91 (patch)
treecf619bc0b2b1d9043249fe9fd33be9395b9daec4
parentf75258bf1ba440db99eed640eae54d8b073bf0f6 (diff)
Commiting major theming changes. Please do not use this yet, or it will destroy everything you own, and delete your data
-rw-r--r--delta-override-form.tpl.php67
-rw-r--r--delta.module129
-rw-r--r--theme-functions.inc3
3 files changed, 195 insertions, 4 deletions
diff --git a/delta-override-form.tpl.php b/delta-override-form.tpl.php
new file mode 100644
index 0000000..65672d2
--- /dev/null
+++ b/delta-override-form.tpl.php
@@ -0,0 +1,67 @@
+<?php
+// $Id$
+
+/**
+ * @file block-admin-display-form.tpl.php
+ * Default theme implementation to configure blocks.
+ *
+ * Available variables:
+ * - $block_regions: An array of regions. Keyed by name with the title as value.
+ * - $block_listing: An array of blocks keyed by region and then delta.
+ * - $form_submit: Form submit button.
+ * - $throttle: TRUE or FALSE depending on throttle module being enabled.
+ *
+ * Each $block_listing[$region] contains an array of blocks for that region.
+ *
+ * Each $data in $block_listing[$region] contains:
+ * - $data->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()
+ */
+?>
+<?php
+ // Add table javascript.
+ /*
+ drupal_add_js('misc/tableheader.js');
+ drupal_add_js(drupal_get_path('module', 'block') .'/block.js');
+ foreach ($block_regions as $region => $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);
+ }
+ */
+?>
+<table id="blocks" class="sticky-enabled">
+ <thead>
+ <tr>
+ <th><?php print t('Name'); ?></th>
+ <th><?php print t('Type'); ?></th>
+ <th><?php print t('Operations'); ?></th>
+ <th><?php print t('Current Theme Template'); ?></th>
+ </tr>
+ </thead>
+ <tbody>
+ <?php $row = 0; ?>
+ <?php foreach ($delta_listing as $delta => $data): ?>
+ <tr class="draggable <?php print $row % 2 == 0 ? 'odd' : 'even'; ?><?php print $data->row_class ? ' '. $data->row_class : ''; ?>">
+ <td class="block"><?php print $data->block_title; ?></td>
+ <td><?php print $data->region_select; ?></td>
+ <td><?php print $data->weight_select; ?></td>
+ <?php if ($throttle): ?>
+ <td><?php print $data->throttle_check; ?></td>
+ <?php endif; ?>
+ <td><?php print $data->configure_link; ?></td>
+ <td><?php print $data->delete_link; ?></td>
+ </tr>
+ <?php $row++; ?>
+ <?php endforeach; ?>
+ </tbody>
+</table>
+
+<?php print $form_submit; ?>
diff --git a/delta.module b/delta.module
index d4f892e..f2c85dc 100644
--- a/delta.module
+++ b/delta.module
@@ -90,10 +90,9 @@ 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'),
);
}
@@ -101,6 +100,128 @@ function delta_menu() {
}
/**
+ * 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
* @see http://api.drupal.org/api/function/hook_form_FORM_ID_alter/6
@@ -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 0000000..b02b32d
--- /dev/null
+++ b/theme-functions.inc
@@ -0,0 +1,3 @@
+<?php
+// $Id$
+