You are here

delta_ui.module in Delta 7.2

File

delta_ui.module
View source
<?php

/**
 * Implementation of hook_menu().
 */

/**
 * Implementation of hook_permission().
 */
function delta_ui_permission() {
  return array(
    'administer delta' => array(
      'title' => t('Administer Delta'),
      'description' => t('Administer settings for the Delta module.'),
    ),
  );
}

/**
 * Implementation of hook_menu().
 */
function delta_ui_menu() {
  $items['admin/appearance/delta'] = array(
    'title' => 'Delta',
    'description' => 'Manage your delta settings and rules, import and export delta settings for each theme',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'delta_theme_settings_config',
    ),
    'access arguments' => array(
      'administer delta',
    ),
    'file' => 'delta_ui.admin.inc',
    'type' => MENU_LOCAL_TASK,
  );
  $items['admin/appearance/delta/settings'] = array(
    'title' => 'Settings',
    'description' => 'Manage Delta settings.',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'parent' => 'admin/appearance/delta',
    'weight' => -10,
  );
  $items['admin/appearance/delta/layouts'] = array(
    'title' => 'Layouts',
    'description' => 'Manage theme setting layouts.',
    'page callback' => 'delta_layouts_view',
    'access arguments' => array(
      'administer delta',
    ),
    'file' => 'delta_ui.admin.inc',
    'type' => MENU_LOCAL_TASK,
    'parent' => 'admin/appearance/delta',
  );
  $items['admin/appearance/delta/layouts/list'] = array(
    'title' => 'List',
    'description' => 'Manage your theme setting layouts.',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'parent' => 'admin/appearance/delta/layouts',
    'weight' => -1,
  );
  $items['admin/appearance/delta/layouts/add'] = array(
    'title' => 'Add Template',
    'description' => 'Create a new theme setting layout.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'delta_layout_edit',
    ),
    'access arguments' => array(
      'administer delta',
    ),
    'file' => 'delta_ui.admin.inc',
    'type' => MENU_LOCAL_ACTION,
    'parent' => 'admin/appearance/delta/layouts',
  );
  $items['admin/appearance/delta/layouts/edit/%'] = array(
    'title' => 'Edit',
    'description' => 'Edit a Theme Settings Layout.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'delta_layout_edit',
      5,
    ),
    'access arguments' => array(
      'administer delta',
    ),
    'file' => 'delta_ui.admin.inc',
    'type' => MENU_NORMAL_ITEM,
    'tab_parent' => 'admin/appearance/delta/layouts',
  );
  $items['admin/appearance/delta/layouts/configure/%'] = array(
    'title' => 'Settings',
    'description' => 'Override settings for Layout.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'delta_layout_configure',
      5,
    ),
    'access arguments' => array(
      'administer delta',
    ),
    'file' => 'delta_ui.admin.inc',
    'type' => MENU_NORMAL_ITEM,
    'tab_parent' => 'admin/appearance/delta/layouts',
  );
  $items['admin/appearance/delta/layouts/delete/%'] = array(
    'title' => 'Delete',
    'description' => 'Delete Theme Settings Layout.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'delta_layout_delete',
      5,
    ),
    'access arguments' => array(
      'administer delta',
    ),
    'file' => 'delta_ui.admin.inc',
    'type' => MENU_NORMAL_ITEM,
    'tab_parent' => 'admin/appearance/delta/layouts',
  );
  return $items;
}

/**
 * Pull data from actively selected themes
 * @return the full theme array as normally pulled by list_themes(), but filters out the inactive themes.
 */
function delta_get_themes_array() {
  $system_themes = list_themes();
  $themes = array();
  $configurable_themes = variable_get('delta_themes', array());
  if (is_array($system_themes)) {
    foreach ($system_themes as $name => $theme) {

      // let's gather active themes only, and the ones that have been set in Delta API global settings
      if ($theme->status == 1 && isset($configurable_themes[$theme->name]) && $configurable_themes[$theme->name]) {
        $themes[$name] = $theme;
      }
    }
    return $themes;
  }
  return FALSE;
}

/**
 * Pull data from actively selected themes
 * @return a usable array of theme data for use in forms for checkboxes or radio buttons
 */
function delta_get_themes_form_array(&$filter) {
  $system_themes = list_themes();
  $configurable_themes = variable_get('delta_themes', array());
  $themes = array();
  if (is_array($system_themes)) {
    foreach ($system_themes as $name => $theme) {

      // let's gather active themes only
      if (!$filter) {
        if ($theme->status == 1) {
          $themes[$name] = $theme->info['name'];
        }
      }
      else {
        if ($theme->status == 1 && isset($configurable_themes[$theme->name]) && $configurable_themes[$theme->name]) {
          $themes[$name] = $theme->info['name'];
        }
      }
    }
    return $themes;
  }
  return FALSE;
}

/**
 * Called when saving the default delta settings form.
 * This is needed to rebuild the menu when an update occurs in order to
 * Add/Remove any themes that need to be in the menu system for rendering
 * the appropriate sub-tabs.
 */
function delta_menu_rebuild() {
  menu_rebuild();
  menu_cache_clear_all();
}

/**
 * Implmentation of hook_form_alter for delta_theme_settings_config()
 * @return $form
 * @see http://api.drupal.org/api/function/hook_form_FORM_ID_alter/6
 * @see http://api.drupal.org/api/function/hook_form_alter/6
 */
function delta_form_delta_theme_settings_config_alter(&$form, &$form_state) {

  // adding submit handler to rebuild the menu on submitting this form
  $form['#submit'][] = 'delta_menu_rebuild';
}
function delta_ui_form_delta_layout_configure_alter($form, &$form_state) {
}
function delta_ui_layout_configure_submit($form, &$form_state) {
  $values = $form_state['values'];
  $values = $form_state['values'];
  $key = $values['var'];
  unset($values['var'], $values['submit'], $values['reset'], $values['form_id'], $values['op'], $values['form_build_id'], $values['form_token'], $values['toggle_logo'], $values['toggle_name'], $values['toggle_slogan'], $values['toggle_node_user_picture'], $values['toggle_comment_user_picture'], $values['toggle_comment_user_verification'], $values['toggle_favicon'], $values['toggle_main_menu'], $values['toggle_secondary_menu'], $values['default_logo'], $values['logo_path'], $values['logo_upload'], $values['default_favicon'], $values['favicon_path'], $values['favicon_upload'], $values['theme_settings_export_code']);
  variable_set($key, $values);
  drupal_set_message(t('The configuration options have been saved.'));
  cache_clear_all();
}
function delta_ui_layout_delete_submit($form, &$form_state) {
  $values = $form_state['values'];
  $key = $values['tid'];
  variable_del($key, $values);
  db_delete('delta_theme_settings')
    ->condition('tid', $key)
    ->execute();
  drupal_set_message(t('The item has been deleted.'));
  cache_clear_all();
  drupal_goto('admin/appearance/delta/layouts');
}
function delta_ui_layout_configure_validate($form, &$form_state) {
}

Functions

Namesort descending Description
delta_form_delta_theme_settings_config_alter Implmentation of hook_form_alter for delta_theme_settings_config()
delta_get_themes_array Pull data from actively selected themes
delta_get_themes_form_array Pull data from actively selected themes
delta_menu_rebuild Called when saving the default delta settings form. This is needed to rebuild the menu when an update occurs in order to Add/Remove any themes that need to be in the menu system for rendering the appropriate sub-tabs.
delta_ui_form_delta_layout_configure_alter
delta_ui_layout_configure_submit
delta_ui_layout_configure_validate
delta_ui_layout_delete_submit
delta_ui_menu Implementation of hook_menu().
delta_ui_permission Implementation of hook_permission().