コード例 #1
0
 function addLocationContentType(&$settings, $add = array())
 {
     // find a non-existent random type name.
     do {
         $name = strtolower($this->randomName(3, 'type_'));
     } while (node_get_types('type', $name));
     // Get the (settable) defaults.
     $defaults = array();
     $d = location_invoke_locationapi($location, 'defaults');
     $fields = location_field_names();
     foreach ($fields as $k => $v) {
         if (!isset($v['nodiff'])) {
             $defaults[$k] = $d[$k];
         }
     }
     foreach ($defaults as $k => $v) {
         // Change collection to allow.
         $defaults[$k]['collect'] = 1;
     }
     $settings = array('name' => $name, 'type' => $name, 'location_settings' => array('multiple' => array('max' => 1, 'add' => 1), 'form' => array('fields' => $defaults)));
     //$settings['location_settings'] = array_merge_recursive($settings['location_settings'], $add);
     $this->flattenPostData($settings);
     $add = array('location_settings' => $add);
     $this->flattenPostData($add);
     $settings = array_merge($settings, $add);
     $this->drupalPost('admin/content/types/add', $settings, 'Save content type');
     $this->refreshVariables();
     $settings = variable_get('location_settings_node_' . $name, array());
     return $name;
 }
コード例 #2
0
function csa_base_get_default_settings($theme)
{
    // Get node types
    $node_types = node_get_types('names');
    // The default values for the theme variables. Make sure $defaults exactly
    // matches the $defaults in the theme-settings.php file.
    $defaults = array('csa_base_move_sidebar' => 1, 'breadcrumb_display' => 0, 'breadcrumb_display_admin' => 1, 'breadcrumb_with_title' => 1, 'primary_links_display_style' => 'tabbed-menu', 'primary_links_allow_tree' => 0, 'secondary_links_display_style' => 'menu', 'secondary_links_allow_tree' => 0, 'search_snippet' => 1, 'search_info_type' => 1, 'search_info_user' => 1, 'search_info_date' => 1, 'search_info_comment' => 1, 'search_info_upload' => 1, 'mission_statement_pages' => 'home', 'hide_front_page_title' => 1, 'front_page_title_display' => 'title_slogan', 'page_title_display_custom' => '', 'other_page_title_display' => 'ptitle_slogan', 'other_page_title_display_custom' => '', 'configurable_separator' => ' | ', 'meta_keywords' => '', 'meta_description' => '', 'taxonomy_display_default' => 'only', 'taxonomy_display_vocab_name' => 1, 'taxonomy_format_default' => 'vocab', 'taxonomy_format_links' => 0, 'taxonomy_format_delimiter' => ', ', 'taxonomy_enable_content_type' => 0, 'submitted_by_author_default' => 0, 'submitted_by_date_default' => 0, 'submitted_by_enable_content_type' => 0);
    // Make the default content-type settings the same as the default theme settings,
    // so we can tell if content-type-specific settings have been altered.
    $defaults = array_merge($defaults, theme_get_settings());
    // Set the default values for content-type-specific settings
    foreach ($node_types as $type => $name) {
        $defaults["taxonomy_display_{$type}"] = $defaults['taxonomy_display_default'];
        $defaults["taxonomy_format_{$type}"] = $defaults['taxonomy_format_default'];
        $defaults["submitted_by_author_{$type}"] = $defaults['submitted_by_author_default'];
        $defaults["submitted_by_date_{$type}"] = $defaults['submitted_by_date_default'];
    }
    // Get default theme settings.
    $settings = theme_get_settings($theme);
    // Don't save the toggle_node_info_ variables
    if (module_exists('node')) {
        foreach (node_get_types() as $type => $name) {
            unset($settings['toggle_node_info_' . $type]);
        }
    }
    // Save default theme settings
    variable_set(str_replace('/', '_', 'theme_' . $theme . '_settings'), array_merge($defaults, $settings));
    // Force refresh of Drupal internals
    theme_get_setting('', TRUE);
    return $defaults;
}
コード例 #3
0
/**
 * Initialize theme settings if needed
 */
function fusion_core_initialize_theme_settings($theme_name)
{
    $theme_settings = theme_get_settings($theme_name);
    if (is_null($theme_settings['theme_font_size']) || $theme_settings['rebuild_registry'] == 1) {
        // Rebuild theme registry & notify user
        if ($theme_settings['rebuild_registry'] == 1) {
            drupal_rebuild_theme_registry();
            drupal_set_message(t('Theme registry rebuild completed. <a href="!link">Turn off</a> this feature for production websites.', array('!link' => url('admin/build/themes/settings/' . $GLOBALS['theme']))), 'warning');
        }
        // Retrieve saved or site-wide theme settings
        $theme_setting_name = str_replace('/', '_', 'theme_' . $theme_name . '_settings');
        $settings = variable_get($theme_setting_name, FALSE) ? theme_get_settings($theme_name) : theme_get_settings();
        // Skip toggle_node_info_ settings
        if (module_exists('node')) {
            foreach (node_get_types() as $type => $name) {
                unset($settings['toggle_node_info_' . $type]);
            }
        }
        // Retrieve default theme settings
        $defaults = fusion_core_default_theme_settings();
        // Set combined default & saved theme settings
        variable_set($theme_setting_name, array_merge($defaults, $settings));
        // Force theme settings refresh
        theme_get_setting('', TRUE);
    }
}
コード例 #4
0
/**
 * Initialize theme settings if needed
 */
function fusion_core_initialize_theme_settings($theme_name)
{
    $theme_settings = theme_get_settings($theme_name);
    if (!isset($theme_settings['primary_menu_dropdown']) || $theme_settings['rebuild_registry'] == 1) {
        static $registry_rebuilt = false;
        // avoid multiple rebuilds per page
        // Rebuild theme registry & notify user
        if (isset($theme_settings['rebuild_registry']) && $theme_settings['rebuild_registry'] == 1 && !$registry_rebuilt) {
            drupal_rebuild_theme_registry();
            drupal_set_message(t('Theme registry rebuild completed. <a href="!link">Turn off</a> this feature for production websites.', array('!link' => url('admin/build/themes/settings/' . $GLOBALS['theme']))), 'warning');
            $registry_rebuilt = true;
        }
        // Retrieve saved or site-wide theme settings
        $theme_setting_name = str_replace('/', '_', 'theme_' . $theme_name . '_settings');
        $settings = variable_get($theme_setting_name, FALSE) ? theme_get_settings($theme_name) : theme_get_settings();
        // Skip toggle_node_info_ settings
        if (module_exists('node')) {
            foreach (node_get_types() as $type => $name) {
                unset($settings['toggle_node_info_' . $type]);
            }
        }
        // Combine default theme settings from .info file & theme-settings.php
        $theme_data = list_themes();
        // get theme data for all themes
        $info_theme_settings = $theme_name ? $theme_data[$theme_name]->info['settings'] : array();
        $defaults = array_merge(fusion_core_default_theme_settings(), $info_theme_settings);
        // Set combined default & saved theme settings
        variable_set($theme_setting_name, array_merge($defaults, $settings));
        // Force theme settings refresh
        theme_get_setting('', TRUE);
    }
}
コード例 #5
0
function seotools_page_title_nodes_reset()
{
    $types = node_get_types();
    foreach ($types as $type) {
        // Define the node-type key
        $key = 'page_title_type_' . $type->type . '_showfield';
        variable_set($key, 1);
    }
}
コード例 #6
0
 /**
  * Creates a custom content type based on default settings.
  *
  * @param settings
  *   An array of settings to change from the defaults.
  *   Example: 'type' => 'foo'.
  * @return object Created content type.
  */
 function drupalCreateContentType($settings = array())
 {
     // find a non-existent random type name.
     do {
         $name = strtolower($this->randomName(3, 'type_'));
     } while (node_get_types('type', $name));
     // Populate defaults array
     $defaults = array('type' => $name, 'name' => $name, 'description' => '', 'help' => '', 'min_word_count' => 0, 'title_label' => 'Title', 'body_label' => 'Body', 'has_title' => 1, 'has_body' => 1);
     // imposed values for a custom type
     $forced = array('orig_type' => '', 'old_type' => '', 'module' => 'node', 'custom' => 1, 'modified' => 1, 'locked' => 0);
     $type = $forced + $settings + $defaults;
     $type = (object) $type;
     node_type_save($type);
     node_types_rebuild();
     return $type;
 }
コード例 #7
0
ファイル: Drupal.php プロジェクト: hosszukalman/wp2drupal
 /**
  * Override node_delete() core Drupal function.
  * Skip user access function during the importing.
  *
  * @param int $nid The nodeID
  */
 protected function node_delete($nid)
 {
     // Clear the cache before the load, so if multiple nodes are deleted, the
     // memory will not fill up with nodes (possibly) already removed.
     $node = node_load($nid, NULL, TRUE);
     db_query('DELETE FROM {node} WHERE nid = %d', $node->nid);
     db_query('DELETE FROM {node_revisions} WHERE nid = %d', $node->nid);
     // Call the node-specific callback (if any):
     node_invoke($node, 'delete');
     node_invoke_nodeapi($node, 'delete');
     // Clear the page and block caches.
     cache_clear_all();
     // Remove this node from the search index if needed.
     if (function_exists('search_wipe')) {
         search_wipe($node->nid, 'node');
     }
     watchdog('content', '@type: deleted %title.', array('@type' => $node->type, '%title' => $node->title));
     drupal_set_message(t('@type %title has been deleted.', array('@type' => node_get_types('name', $node), '%title' => $node->title)));
 }
コード例 #8
0
/**
 * Return the theme settings' default values from the .info and save them into the database.
 *
 * @param $theme
 *   The name of theme.
 */
function layoutstudio_theme_get_default_settings($theme)
{
    $themes = list_themes();
    // Get the default values from the .info file.
    $defaults = !empty($themes[$theme]->info['settings']) ? $themes[$theme]->info['settings'] : array();
    if (!empty($defaults)) {
        // Get the theme settings saved in the database.
        $settings = theme_get_settings($theme);
        // Don't save the toggle_node_info_ variables.
        if (module_exists('node')) {
            foreach (node_get_types() as $type => $name) {
                unset($settings['toggle_node_info_' . $type]);
            }
        }
        // Save default theme settings.
        variable_set(str_replace('/', '_', 'theme_' . $theme . '_settings'), array_merge($defaults, $settings));
        // If the active theme has been loaded, force refresh of Drupal internals.
        if (!empty($GLOBALS['theme_key'])) {
            theme_get_setting('', TRUE);
        }
    }
    // Return the default settings.
    return $defaults;
}
コード例 #9
0
ファイル: rules.api.php プロジェクト: bhuga/drupal-cypherpunk
/**
 * The configuration form callback for an action.
 *
 * It should be placed into the file MODULENAME.rules_forms.inc or into
 * MODULENAME.rules.inc.
 *
 * This callback can be used to alter the automatically generated
 * configuration form. New form elements should be put in $form['settings']
 * as its form values are used to populate $settings automatically. If some
 * postprocessing of the values is necessary the action may implement
 * rules_action_callback_submit().
 *
 * @param $settings
 *   The array of configuration settings to edit. This array is going to be
 *   passed to the action implementation once executed.
 * @param $form
 *   The configuration form as generated by rules. The modify it, has to be
 *   taken by reference. Additional form elements should go into
 *   $form['settings']. To let rules know about additional textual form
 *   elements use the 'eval input' attribute of hook_rules_action_info() so
 *   rules adds input evaluation support to them.
 * @param $form_state
 *   The form's form state.
 *
 *
 * @see rules_action_callback_validate(), rules_action_callback_submit()
 *
 */
function rules_action_callback_form($settings, &$form)
{
    $settings += array('type' => array());
    $form['settings']['type'] = array('#type' => 'select', '#title' => t('Content types'), '#options' => node_get_types('names'), '#multiple' => TRUE, '#default_value' => $settings['type'], '#required' => TRUE);
}
コード例 #10
0
ファイル: kentry.module.Test.php プロジェクト: jgosier/kamusi
 public function testCreateType()
 {
     $type = new StdClass();
     $type->iso = 'test';
     $type->name = 'Test type';
     $created_type = _kentry_create_type($type);
     $node_types = array_keys(node_get_types());
     $this->assertTrue(in_array($created_type, $node_types), sprintf('%s not created', $created_type));
 }
コード例 #11
0
 /**
  * Creates a custom content type based on default settings.
  *
  * @param $settings
  *   An array of settings to change from the defaults.
  *   Example: 'type' => 'foo'.
  * @return
  *   Created content type.
  */
 protected function drupalCreateContentType($settings = array())
 {
     // find a non-existent random type name.
     do {
         $name = strtolower($this->randomName(3, 'type_'));
     } while (node_get_types('type', $name));
     // Populate defaults array
     $defaults = array('type' => $name, 'name' => $name, 'description' => '', 'help' => '', 'min_word_count' => 0, 'title_label' => 'Title', 'body_label' => 'Body', 'has_title' => 1, 'has_body' => 1);
     // imposed values for a custom type
     $forced = array('orig_type' => '', 'old_type' => '', 'module' => 'node', 'custom' => 1, 'modified' => 1, 'locked' => 0);
     $type = $forced + $settings + $defaults;
     $type = (object) $type;
     $saved_type = node_type_save($type);
     node_types_rebuild();
     $this->assertEqual($saved_type, SAVED_NEW, t('Created content type %type.', array('%type' => $type->type)));
     // Reset permissions so that permissions for this content type are available.
     $this->checkPermissions(array(), TRUE);
     return $type;
 }
コード例 #12
0
 field-<?php 
    print $field_name_css;
    ?>
">
  <?php 
    if ($label_display == 'above') {
        ?>
    <div class="field-label"><?php 
        print t($label);
        ?>
:&nbsp;</div>
    <?php 
        if ($field_type == 'flexifield') {
            ?>
      <div class="field-value"> <?php 
            print node_get_types('name', $items[0]['type']);
            ?>
 </div>
    <?php 
        }
        ?>
  <?php 
    }
    ?>
  <div class="field-items">
    <?php 
    $count = 1;
    foreach ($items as $delta => $item) {
        if (!$item['empty']) {
            ?>
        <div class="field-item <?php 
コード例 #13
0
function guifi_node_form(&$node, $form_state)
{
    global $user;
    $form_weight = 0;
    $type = node_get_types('type', $node);
    if (!empty($node->zone_id)) {
        drupal_set_breadcrumb(guifi_node_ariadna($node));
    } else {
        drupal_set_breadcrumb(NULL);
    }
    // ----
    // El títol el primer de tot
    // ------------------------------------------------
    if ($type->has_title) {
        $form['title'] = array('#type' => 'textfield', '#title' => check_plain($type->title_label), '#required' => TRUE, '#default_value' => $node->title);
    }
    $form_weight = 2;
    /*
     * maintainers fieldset
     */
    $form_weight = -3;
    $form['maintainers'] = guifi_maintainers_form($node, $form_weight);
    /*
     * funders fieldset
     */
    $form_weight = -4;
    $form['funders'] = guifi_funders_form($node, $form_weight);
    $form_weight = 0;
    $form['nick'] = array('#type' => 'textfield', '#title' => t('Nick'), '#required' => FALSE, '#size' => 20, '#maxlength' => 20, '#element_validate' => array('guifi_node_nick_validate'), '#default_value' => $node->nick, '#description' => t("Unique identifier for this node. Avoid generic names such 'MyNode', use something that really identifies your node.<br />Short name, single word with no spaces, 7-bit chars only, will be used for  hostname, reports, etc."), '#weight' => $form_weight++);
    $form['notification'] = array('#type' => 'textfield', '#title' => t('Contact'), '#required' => FALSE, '#size' => 60, '#maxlength' => 1024, '#element_validate' => array('guifi_emails_validate'), '#default_value' => $node->notification, '#description' => t("Who did possible this node or who to contact with regarding this node if it is distinct of the owner of this page. Use valid emails, if you like to have more than one, separated by commas.'"), '#weight' => $form_weight++);
    $form['settings'] = array('#type' => 'fieldset', '#title' => t('Node settings'), '#weight' => $form_weight++, '#collapsible' => TRUE, '#collapsed' => TRUE);
    // Si ets administrador pots definir el servidor de dades
    if (user_access('administer guifi zones')) {
        $graphstr = guifi_service_str($node->graph_server);
        $form['settings']['graph_serverstr'] = array('#type' => 'textfield', '#title' => t('default graphs server'), '#maxlength' => 60, '#required' => FALSE, '#default_value' => $graphstr, '#autocomplete_path' => 'guifi/js/select-service/SNPgraphs', '#element_validate' => array('guifi_service_name_validate', 'guifi_zone_service_validate'), '#description' => t('Select the <em>graph server</em> to be used at this node.<br />You can find the <em>graph server</em> by introducing part of the id number, zone name or graph server name. A list with all matching values with a maximum of 50 values will be created.<br />You can refine the text to find your choice.'));
        $form['settings']['graph_server'] = array('#type' => 'hidden', '#value' => $node->graph_server);
    }
    $form['settings']['stable'] = array('#type' => 'select', '#title' => t("It's supposed to be a stable online node?"), '#required' => FALSE, '#default_value' => $node->stable ? $node->stable : 'Yes', '#options' => array('Yes' => t('Yes, is intended to be kept always on,  avalable for extending the mesh'), 'No' => t("I'm sorry. Will be connected just when I'm online")), '#description' => t("That helps while planning a mesh network. We should know which locations are likely available to provide stable links."), '#weight' => 1);
    // Ask for a license agreement if is a new node
    if (empty($node->nid)) {
        $form['license'] = array('#type' => 'item', '#title' => t('License and usage agreement'), '#value' => t(variable_get('guifi_license', NULL)), '#description' => t('You must accept this agreement to be authorized to create new nodes.'), '#weight' => 1);
        if (empty($node->agreement)) {
            $agreement = 'No';
        } else {
            $agreement = $node->agreement;
        }
        $form['agreement'] = array('#type' => 'radios', '#default_value' => $agreement, '#options' => array('Yes' => t('Yes, I have read this and accepted')), '#element_validate' => array('guifi_node_agreement_validate'), '#weight' => 2);
    } else {
        $form['agreement'] = array('#type' => 'hidden', '#default_value' => 'Yes');
    }
    if (empty($node->nid)) {
        if (empty($node->ndfzone)) {
            if (empty($node->zone_id)) {
                if (!empty($user->guifi_default_zone)) {
                    $zone_id = $user->guifi_default_zone;
                }
            } else {
                $zone_id = $node->zone_id;
            }
        } else {
            $zone_id = $node->ndfzone;
        }
    } else {
        $zone_id = $node->zone_id;
    }
    $form['zone_id'] = guifi_zone_autocomplete_field($zone_id, 'zone_id');
    //  $form['zone_id'] = guifi_zone_select_field($zone_id,'zone_id');
    $form['zone_id']['#weight'] = 3;
    // ----
    // position
    // ------------------------------------------------
    $form['position'] = array('#type' => 'fieldset', '#title' => t('Node position settings'), '#weight' => 4, '#collapsible' => FALSE);
    if (guifi_gmap_key()) {
        drupal_add_js(drupal_get_path('module', 'guifi') . '/js/guifi_gmap_node.js', 'module');
        $form['position']['GMAP'] = array('#type' => 'item', '#title' => t('Map'), '#description' => t('Select the point where the node has to be placed.'), '#suffix' => '<input style="width: 240px;" id="mapSearch" type="text" /><div id="map" style="width: 100%; height: 437px; margin:5px;"></div>', '#weight' => 0);
        $form['guifi_wms'] = array('#type' => 'hidden', '#value' => variable_get('guifi_wms_service', ''));
        $form['lat'] = array('#type' => 'hidden', '#value' => $node->lat);
        $form['lon'] = array('#type' => 'hidden', '#value' => $node->lon);
    }
    $form['position']['longitude'] = array('#type' => 'item', '#title' => t('Longitude'), '#prefix' => '<table><tr><th>&nbsp;</th><th>' . t('degrees (decimal values allowed)') . '</th><th>' . t('minutes') . '</th><th>' . t('seconds') . '</th></tr><tr><td>', '#suffix' => '</td>', '#weight' => 1);
    $form['position']['londeg'] = array('#type' => 'textfield', '#default_value' => $node->londeg, '#size' => 12, '#maxlength' => 24, '#element_validate' => array('guifi_lon_validate'), '#prefix' => '<td>', '#suffix' => '</td>', '#weight' => 2);
    $form['position']['lonmin'] = array('#type' => 'textfield', '#default_value' => $node->lonmin, '#size' => 12, '#maxlength' => 24, '#prefix' => '<td>', '#suffix' => '</td>', '#weight' => 3);
    $form['position']['lonseg'] = array('#type' => 'textfield', '#default_value' => $node->lonseg, '#size' => 12, '#maxlength' => 24, '#prefix' => '<td>', '#suffix' => '</td></tr>', '#weight' => 4);
    $form['position']['latitude'] = array('#type' => 'item', '#title' => t('Latitude'), '#prefix' => '<tr><td>', '#suffix' => '</td>', '#weight' => 5);
    $form['position']['latdeg'] = array('#type' => 'textfield', '#default_value' => $node->latdeg, '#size' => 12, '#maxlength' => 24, '#element_validate' => array('guifi_lat_validate'), '#prefix' => '<td>', '#suffix' => '</td>', '#weight' => 6);
    $form['position']['latmin'] = array('#type' => 'textfield', '#default_value' => $node->latmin, '#size' => 12, '#maxlength' => 24, '#prefix' => '<td>', '#suffix' => '</td>', '#weight' => 7);
    $form['position']['latseg'] = array('#type' => 'textfield', '#default_value' => $node->latseg, '#size' => 12, '#maxlength' => 24, '#prefix' => '<td>', '#suffix' => '</td></tr></table>', '#weight' => 8);
    $form['position']['zone_description'] = array('#type' => 'textfield', '#title' => t('Zone description'), '#required' => FALSE, '#size' => 60, '#maxlength' => 128, '#default_value' => $node->zone_description, '#description' => t("Zone, address, neighborhood. Something that describes your area within your location.<br />If you don't know your lat/lon, please provide street and number or crossing street."), '#weight' => 9);
    $form['position']['elevation'] = array('#type' => 'textfield', '#title' => t('Antenna elevation'), '#required' => FALSE, '#size' => 5, '#length' => 20, '#maxlength' => 20, '#default_value' => $node->elevation, '#element_validate' => array('guifi_elevation_validate'), '#description' => t("Antenna height over the floor level."), '#weight' => 10);
    if ($type->has_body) {
        $form['body_field'] = node_body_field($node, $type->body_label, $type->min_word_count);
    }
    $radios = array();
    $query = db_query("SELECT * FROM {guifi_radios} WHERE nid=%d", $node->id);
    while ($radio = db_fetch_array($query)) {
        $radios[] = $radio;
    }
    if (count($radios) < 1) {
        $form['status_flag'] = array('#type' => 'select', '#title' => t("Node status"), '#default_value' => $node->status_flag ? $node->status_flag : 'Planned', '#required' => FALSE, '#options' => array('Reserved' => t('Reserved'), 'Inactive' => t('Inactive'), 'Planned' => t('Planned')));
    } else {
        $form['status_flag'] = array('#type' => 'hidden', '#default_value' => $node->status_flag);
    }
    return $form;
}
コード例 #14
0
ファイル: search.api.php プロジェクト: rolfington/drupal
/**
 * Define a custom search routine.
 *
 * This hook allows a module to perform searches on content it defines
 * (custom node types, users, or comments, for example) when a site search
 * is performed.
 *
 * Note that you can use form API to extend the search. You will need to use
 * hook_form_alter() to add any additional required form elements. You can
 * process their values on submission using a custom validation function.
 * You will need to merge any custom search values into the search keys
 * using a key:value syntax. This allows all search queries to have a clean
 * and permanent URL. See node_form_alter() for an example.
 *
 * @param $op
 *   A string defining which operation to perform:
 *   - 'name': the hook should return a translated name defining the type of
 *     items that are searched for with this module ('content', 'users', ...)
 *   - 'reset': the search index is going to be rebuilt. Modules which use
 *     hook_update_index() should update their indexing bookkeeping so that it
 *     starts from scratch the next time hook_update_index() is called.
 *   - 'search': the hook should perform a search using the keywords in $keys
 *   - 'status': if the module implements hook_update_index(), it should return
 *     an array containing the following keys:
 *     - remaining: the amount of items that still need to be indexed
 *     - total: the total amount of items (both indexed and unindexed)
 *
 * @param $keys
 *   The search keywords as entered by the user.
 *
 * @return
 *   An array of search results.
 *   Each item in the result set array may contain whatever information
 *   the module wishes to display as a search result.
 *   To use the default search result display, each item should be an
 *   array which can have the following keys:
 *   - link: the URL of the found item
 *   - type: the type of item
 *   - title: the name of the item
 *   - user: the author of the item
 *   - date: a timestamp when the item was last modified
 *   - extra: an array of optional extra information items
 *   - snippet: an excerpt or preview to show with the result
 *     (can be generated with search_excerpt())
 *   Only 'link' and 'title' are required, but it is advised to fill in
 *   as many of these fields as possible.
 *
 * The example given here is for node.module, which uses the indexed search
 * capabilities. To do this, node module also implements hook_update_index()
 * which is used to create and maintain the index.
 *
 * We call do_search() with the keys, the module name and extra SQL fragments
 * to use when searching. See hook_update_index() for more information.
 *
 * @ingroup search
 */
function hook_search($op = 'search', $keys = null)
{
    switch ($op) {
        case 'name':
            return t('Content');
        case 'reset':
            db_query("UPDATE {search_dataset} SET reindex = %d WHERE type = 'node'", REQUEST_TIME);
            return;
        case 'status':
            $total = db_result(db_query('SELECT COUNT(*) FROM {node} WHERE status = 1'));
            $remaining = db_result(db_query("SELECT COUNT(*) FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE n.status = 1 AND d.sid IS NULL OR d.reindex <> 0"));
            return array('remaining' => $remaining, 'total' => $total);
        case 'admin':
            $form = array();
            // Output form for defining rank factor weights.
            $form['content_ranking'] = array('#type' => 'fieldset', '#title' => t('Content ranking'));
            $form['content_ranking']['#theme'] = 'node_search_admin';
            $form['content_ranking']['info'] = array('#value' => '<em>' . t('The following numbers control which properties the content search should favor when ordering the results. Higher numbers mean more influence, zero means the property is ignored. Changing these numbers does not require the search index to be rebuilt. Changes take effect immediately.') . '</em>');
            // Note: reversed to reflect that higher number = higher ranking.
            $options = drupal_map_assoc(range(0, 10));
            foreach (module_invoke_all('ranking') as $var => $values) {
                $form['content_ranking']['factors']['node_rank_' . $var] = array('#title' => $values['title'], '#type' => 'select', '#options' => $options, '#default_value' => variable_get('node_rank_' . $var, 0));
            }
            return $form;
        case 'search':
            // Build matching conditions
            list($join1, $where1) = _db_rewrite_sql();
            $arguments1 = array();
            $conditions1 = 'n.status = 1';
            if ($type = search_query_extract($keys, 'type')) {
                $types = array();
                foreach (explode(',', $type) as $t) {
                    $types[] = "n.type = '%s'";
                    $arguments1[] = $t;
                }
                $conditions1 .= ' AND (' . implode(' OR ', $types) . ')';
                $keys = search_query_insert($keys, 'type');
            }
            if ($category = search_query_extract($keys, 'category')) {
                $categories = array();
                foreach (explode(',', $category) as $c) {
                    $categories[] = "tn.tid = %d";
                    $arguments1[] = $c;
                }
                $conditions1 .= ' AND (' . implode(' OR ', $categories) . ')';
                $join1 .= ' INNER JOIN {taxonomy_term_node} tn ON n.vid = tn.vid';
                $keys = search_query_insert($keys, 'category');
            }
            if ($languages = search_query_extract($keys, 'language')) {
                $categories = array();
                foreach (explode(',', $languages) as $l) {
                    $categories[] = "n.language = '%s'";
                    $arguments1[] = $l;
                }
                $conditions1 .= ' AND (' . implode(' OR ', $categories) . ')';
                $keys = search_query_insert($keys, 'language');
            }
            // Get the ranking expressions.
            $rankings = _node_rankings();
            // When all search factors are disabled (ie they have a weight of zero),
            // The default score is based only on keyword relevance.
            if ($rankings['total'] == 0) {
                $total = 1;
                $arguments2 = array();
                $join2 = '';
                $select2 = 'i.relevance AS score';
            } else {
                $total = $rankings['total'];
                $arguments2 = $rankings['arguments'];
                $join2 = implode(' ', $rankings['join']);
                $select2 = '(' . implode(' + ', $rankings['score']) . ') AS score';
            }
            // Do search.
            $find = do_search($keys, 'node', 'INNER JOIN {node} n ON n.nid = i.sid ' . $join1, $conditions1 . (empty($where1) ? '' : ' AND ' . $where1), $arguments1, $select2, $join2, $arguments2);
            // Load results.
            $results = array();
            foreach ($find as $item) {
                // Build the node body.
                $node = node_load($item->sid);
                $node->build_mode = NODE_BUILD_SEARCH_RESULT;
                $node = node_build_content($node, FALSE, FALSE);
                $node->body = drupal_render($node->content);
                // Fetch comments for snippet.
                $node->body .= module_invoke('comment', 'node', $node, 'update_index');
                // Fetch terms for snippet.
                $node->body .= module_invoke('taxonomy', 'node', $node, 'update_index');
                $extra = module_invoke_all('node_search_result', $node);
                $results[] = array('link' => url('node/' . $item->sid, array('absolute' => TRUE)), 'type' => check_plain(node_get_types('name', $node)), 'title' => $node->title, 'user' => theme('username', $node), 'date' => $node->changed, 'node' => $node, 'extra' => $extra, 'score' => $total ? $item->score / $total : 0, 'snippet' => search_excerpt($keys, $node->body));
            }
            return $results;
    }
}
コード例 #15
0
/**
 * Implementation of THEMEHOOK_settings() function.
 *
 * @param $saved_settings 
 *   An array of saved settings for this theme.
 * @param $subtheme_defaults
 *   Allows a subtheme to override the default values.
 * @return
 *   An array of form. 
 */
function cms_base_settings($saved_settings, $subtheme_defaults = array())
{
    $defaults = cms_base_default_settings('cms_base');
    // Allows a subtheme to override the default values.
    $defaults = array_merge($defaults, $subtheme_defaults);
    // Merges the saved variables and their default values.
    $settings = array_merge($defaults, $saved_settings);
    // Creates the form for theme settings page.
    $form = array();
    // Extra variable settings for this theme
    // layout settings
    $form['layout'] = array('#type' => 'fieldset', '#title' => t('Layout settings'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['layout']['sidebar_left_width'] = array('#type' => 'textfield', '#title' => t('Left sidebar width'), '#size' => 10, '#default_value' => $settings['sidebar_left_width'], '#field_suffix' => t('px'));
    $form['layout']['width_sidebar_right'] = array('#type' => 'textfield', '#title' => t('Right sidebar width'), '#size' => 10, '#default_value' => $settings['width_sidebar_right'], '#field_suffix' => t('px'));
    $form['layout']['width_sidebar_right2'] = array('#type' => 'textfield', '#title' => t('Right sidebar 2 width'), '#size' => 10, '#default_value' => $settings['width_sidebar_right2'], '#field_suffix' => t('px'), '#description' => l(t('View instructions for using the sidebar settings'), 'http://www.cmsquickstart.com/drupal-theme-guides/sidebar-settings', array('attributes' => array('target' => "_blank"), 'absolute' => TRUE)));
    $form['layout']['show_tooltip'] = array('#type' => 'checkbox', '#title' => t('Check to show tool tip when hovering over the primary links menu.'), '#default_value' => $settings['show_tooltip'], '#weight' => 11);
    //font settings
    $form['font_settings'] = array('#type' => 'fieldset', '#title' => t('Font settings'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#description' => t(''));
    $form['font_settings']['use_css_for_fonts'] = array('#type' => 'checkbox', '#title' => t('Use CSS for fonts'), '#default_value' => $settings['use_css_for_fonts']);
    $form['font_settings']['body_text'] = array('#type' => 'fieldset', '#title' => t('Body text font'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#description' => t('Font used for the body text of content types, comments, and blocks.'));
    $form['font_settings']['body_text']['body_text_font'] = array('#type' => 'select', '#title' => t('Font family'), '#default_value' => $settings['body_text_font'], '#options' => array("Georgia, 'Times New Roman', Times, serif" => t("Georgia, 'Times New Roman', Times, serif"), "'Times New Roman', Times, Georgia, serif" => t("'Times New Roman', Times, Georgia, serif"), "Verdana, Arial, Helvetica, sans-serif" => t("Verdana, Arial, Helvetica, sans-serif"), "Helvetica, Arial, Verdana, sans-serif" => t("Helvetica, Arial, Verdana, sans-serif'"), "Tahoma, Verdana, Arial, sans-serif" => t("Tahoma, Verdana, Arial, sans-serif"), 'Custom' => t('Custom (specify below)')), '#description' => t("Default font family -  Georgia, 'Times New Roman', Times, serif"));
    $form['font_settings']['body_text']['body_text_font_custom'] = array('#type' => 'textfield', '#title' => t('Custom font-family setting'), '#default_value' => $settings['body_text_font_custom'], '#size' => 40, '#maxlength' => 200, '#description' => t("Enter fonts in order of priority separated by commas. If the user's computer does not have the font it will use the next font listed in order of priority. For example: Verdana, Arial, 'Times New Roman' - in this example if the user does not have Verdana then their computer will look for Arial and then for Times Roman.<br /><b>Note:</b> Put ' before and after any fonts that have a space such as 'Times New Roman'."));
    $form['font_settings']['headings_text_font'] = array('#type' => 'fieldset', '#title' => t('Headings text font'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#description' => t('Font used for h1-h6 headings, navigation links, site name and slogan.'));
    $form['font_settings']['headings_text_font']['heading_text_font'] = array('#type' => 'select', '#title' => t('Font family'), '#default_value' => $settings['heading_text_font'], '#options' => array("Georgia, 'Times New Roman', Times, serif" => t("Georgia, 'Times New Roman', Times, serif"), "'Times New Roman', Times, Georgia, serif" => t("'Times New Roman', Times, Georgia, serif"), "Verdana, Arial, Helvetica, sans-serif" => t("Verdana, Arial, Helvetica, sans-serif"), "Helvetica, Arial, Verdana, sans-serif" => t("Helvetica, Arial, Verdana, sans-serif'"), "Tahoma, Verdana, Arial, sans-serif" => t("Tahoma, Verdana, Arial, sans-serif"), 'Custom' => t('Custom (specify below)')), '#description' => t("Default font family -  Georgia, 'Times New Roman', Times"));
    $form['font_settings']['headings_text_font']['heading_text_font_custom'] = array('#type' => 'textfield', '#title' => t('Custom font-family setting'), '#default_value' => $settings['heading_text_font_custom'], '#size' => 40, '#maxlength' => 200, '#description' => t("Enter fonts in order of priority separated by commas. If the user's computer does not have the font it will use the next font listed in order of priority. For example: Verdana, Arial, 'Times New Roman' - in this example if the user does not have Verdana then their computer will look for Arial and then for Times Roman.<br /><b>Note:</b> Put ' before and after any fonts that have a space such as 'Times New Roman'."));
    // Search Settings
    if (module_exists('search')) {
        $form['search_settings'] = array('#type' => 'fieldset', '#title' => t('Search results'), '#description' => t('Select additional information you would like to be displayed with search results.'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['search_settings']['search_author_name'] = array('#type' => 'checkbox', '#title' => t('Author name'), '#default_value' => $settings['search_author_name']);
        $form['search_settings']['search_posted_date'] = array('#type' => 'checkbox', '#title' => t('Node posted date'), '#default_value' => $settings['search_posted_date']);
        $form['search_settings']['search_text_snippet'] = array('#type' => 'checkbox', '#title' => t('Text snippet'), '#default_value' => $settings['search_text_snippet']);
        $form['search_settings']['search_node_type'] = array('#type' => 'checkbox', '#title' => t('Content type name'), '#default_value' => $settings['search_node_type']);
        $form['search_settings']['search_node_comments'] = array('#type' => 'checkbox', '#title' => t('Comment count'), '#default_value' => $settings['search_node_comments']);
        $form['search_settings']['search_attachment_count'] = array('#type' => 'checkbox', '#title' => t('Number of attachments'), '#default_value' => $settings['search_attachment_count']);
    }
    // Node Settings
    $form['node_specific_settings'] = array('#type' => 'fieldset', '#title' => t('Node display settings'), '#description' => t("Options for displaying or hiding post information for your site's content. For example you may wish to show the author and date for Blog posts and hide these options for info pages."), '#collapsible' => TRUE, '#collapsed' => TRUE, '#attributes' => array('class' => 'node_settings'));
    // Author & Date Settings
    $form['node_specific_settings']['post_info_container'] = array('#type' => 'fieldset', '#title' => t('Author & date'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    // Default & content-type specific settings
    if (!module_exists('submitted_by')) {
        foreach (array_merge(array('default' => 'Default'), node_get_types('names')) as $type => $name) {
            $form['node_specific_settings']['post_info_container']['submitted_by'][$type] = array('#type' => 'fieldset', '#title' => t('!name', array('!name' => t($name))), '#collapsible' => TRUE, '#collapsed' => TRUE);
            $form['node_specific_settings']['post_info_container']['submitted_by'][$type]["submitted_by_author_{$type}"] = array('#type' => 'checkbox', '#title' => t('Display author\'s username'), '#default_value' => $settings["submitted_by_author_{$type}"]);
            $form['node_specific_settings']['post_info_container']['submitted_by'][$type]["submitted_by_date_{$type}"] = array('#type' => 'checkbox', '#title' => t('Display date posted'), '#default_value' => $settings["submitted_by_date_{$type}"]);
            // Options for default settings
            if ($type == 'default') {
                $form['node_specific_settings']['post_info_container']['submitted_by']['default']['#title'] = t('Default');
                $form['node_specific_settings']['post_info_container']['submitted_by']['default']['#collapsed'] = $settings['submitted_by_content_type'] ? TRUE : FALSE;
                $form['node_specific_settings']['post_info_container']['submitted_by']['submitted_by_content_type'] = array('#type' => 'checkbox', '#title' => t('Use custom settings for each content type instead of the default above'), '#default_value' => $settings['submitted_by_content_type']);
            } else {
                if ($settings['submitted_by_content_type'] == 0) {
                    $form['submitted_by'][$type]['#collapsed'] = TRUE;
                }
            }
        }
    } else {
        $form['node_specific_settings']['post_info_container']['#description'] = 'NOTICE: You currently have the "Submitted By" module installed and enabled, so the Author & Date theme settings have been disabled to prevent conflicts.  If you wish to re-enable the Author & Date theme settings, you must first disable the "Submitted By" module.';
    }
    // Read More & Comment Link Settings
    $form['node_specific_settings']['link_settings_container'] = array('#type' => 'fieldset', '#title' => t('Links'), '#description' => t('Define custom text for node links'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    // Read more link settings
    $form['node_specific_settings']['link_settings_container']['readmore'] = array('#type' => 'fieldset', '#title' => t('Read more link'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    // Default & content-type specific settings
    foreach (array_merge(array('default' => 'Default'), node_get_types('names')) as $type => $name) {
        // Read more
        $form['node_specific_settings']['link_settings_container']['readmore'][$type] = array('#type' => 'fieldset', '#title' => t('!name', array('!name' => t($name))), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['node_specific_settings']['link_settings_container']['readmore'][$type]["readmore_{$type}"] = array('#type' => 'textfield', '#title' => t('Link text'), '#default_value' => $settings["readmore_{$type}"], '#description' => t('HTML is allowed.'));
        $form['node_specific_settings']['link_settings_container']['readmore'][$type]["readmore_title_{$type}"] = array('#type' => 'textfield', '#title' => t('Title text (tool tip)'), '#default_value' => $settings["readmore_title_{$type}"], '#description' => t('Displayed when hovering over link. Plain text only.'));
        $form['node_specific_settings']['link_settings_container']['readmore'][$type]["readmore_prefix_{$type}"] = array('#type' => 'textfield', '#title' => t('Prefix'), '#default_value' => $settings["readmore_prefix_{$type}"], '#description' => t('Text or HTML placed before the link.'));
        $form['node_specific_settings']['link_settings_container']['readmore'][$type]["readmore_suffix_{$type}"] = array('#type' => 'textfield', '#title' => t('Suffix'), '#default_value' => $settings["readmore_suffix_{$type}"], '#description' => t('Text or HTML placed after the link.'));
        // Options for default settings
        if ($type == 'default') {
            $form['node_specific_settings']['link_settings_container']['readmore']['default']['#title'] = t('Default');
            $form['node_specific_settings']['link_settings_container']['readmore']['default']['#collapsed'] = $settings['readmore_content_type'] ? TRUE : FALSE;
            $form['node_specific_settings']['link_settings_container']['readmore']['readmore_content_type'] = array('#type' => 'checkbox', '#title' => t('Use custom settings for each content type instead of the default above'), '#default_value' => $settings['readmore_content_type']);
        } else {
            if ($settings['readmore_content_type'] == 0) {
                $form['readmore'][$type]['#collapsed'] = TRUE;
            }
        }
    }
    // Comments link settings
    $form['node_specific_settings']['link_settings_container']['comment'] = array('#type' => 'fieldset', '#title' => t('Comment links setting'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    // Default & content-type specific settings
    foreach (array_merge(array('default' => 'Default'), node_get_types('names')) as $type => $name) {
        $form['node_specific_settings']['link_settings_container']['comment'][$type] = array('#type' => 'fieldset', '#title' => t('!name', array('!name' => t($name))), '#collapsible' => TRUE, '#collapsed' => TRUE);
        // Full nodes
        $form['node_specific_settings']['link_settings_container']['comment'][$type]['node'] = array('#type' => 'fieldset', '#title' => t('Full node view settings'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['node_specific_settings']['link_settings_container']['comment'][$type]['node']['add'] = array('#type' => 'fieldset', '#title' => t('"Add new comment" link'), '#description' => t('The link when the full content is being displayed.'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['node_specific_settings']['link_settings_container']['comment'][$type]['node']['add']["comment_node_{$type}"] = array('#type' => 'textfield', '#title' => t('Link text'), '#default_value' => $settings["comment_node_{$type}"], '#description' => t('HTML is allowed.'));
        $form['node_specific_settings']['link_settings_container']['comment'][$type]['node']['add']["comment_node_title_{$type}"] = array('#type' => 'textfield', '#title' => t('Title text (tool tip)'), '#default_value' => $settings["comment_node_title_{$type}"], '#description' => t('Displayed when hovering over link. Plain text only.'));
        $form['node_specific_settings']['link_settings_container']['comment'][$type]['node']['add']["comment_node_prefix_{$type}"] = array('#type' => 'textfield', '#title' => t('Prefix'), '#default_value' => $settings["comment_node_prefix_{$type}"], '#description' => t('Text or HTML placed before the link.'));
        $form['node_specific_settings']['link_settings_container']['comment'][$type]['node']['add']["comment_node_suffix_{$type}"] = array('#type' => 'textfield', '#title' => t('Suffix'), '#default_value' => $settings["comment_node_suffix_{$type}"], '#description' => t('Text or HTML placed after the link.'));
        // Teasers
        $form['node_specific_settings']['link_settings_container']['comment'][$type]['teaser'] = array('#type' => 'fieldset', '#title' => t('Teasers view settings'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['node_specific_settings']['link_settings_container']['comment'][$type]['teaser']['add'] = array('#type' => 'fieldset', '#title' => t('"Add new comment" link'), '#description' => t('The link when there are no comments.'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['node_specific_settings']['link_settings_container']['comment'][$type]['teaser']['add']["comment_add_{$type}"] = array('#type' => 'textfield', '#title' => t('Link text'), '#default_value' => $settings["comment_add_{$type}"], '#description' => t('HTML is allowed.'));
        $form['node_specific_settings']['link_settings_container']['comment'][$type]['teaser']['add']["comment_add_title_{$type}"] = array('#type' => 'textfield', '#title' => t('Title text (tool tip)'), '#default_value' => $settings["comment_add_title_{$type}"], '#description' => t('Displayed when hovering over link. Plain text only.'));
        $form['node_specific_settings']['link_settings_container']['comment'][$type]['teaser']['add']["comment_add_prefix_{$type}"] = array('#type' => 'textfield', '#title' => t('Prefix'), '#default_value' => $settings["comment_add_prefix_{$type}"], '#description' => t('Text or HTML placed before the link.'));
        $form['node_specific_settings']['link_settings_container']['comment'][$type]['teaser']['add']["comment_add_suffix_{$type}"] = array('#type' => 'textfield', '#title' => t('Suffix'), '#default_value' => $settings["comment_add_suffix_{$type}"], '#description' => t('Text or HTML placed after the link.'));
        $form['node_specific_settings']['link_settings_container']['comment'][$type]['teaser']['standard'] = array('#type' => 'fieldset', '#title' => t('"Comments" link'), '#description' => t('The link when there are one or more comments.'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['node_specific_settings']['link_settings_container']['comment'][$type]['teaser']['standard']["comment_singular_{$type}"] = array('#type' => 'textfield', '#title' => t('Link text when there is 1 comment'), '#default_value' => $settings["comment_singular_{$type}"], '#description' => t('HTML is allowed.'));
        $form['node_specific_settings']['link_settings_container']['comment'][$type]['teaser']['standard']["comment_plural_{$type}"] = array('#type' => 'textfield', '#title' => t('Link text when there are multiple comments'), '#default_value' => $settings["comment_plural_{$type}"], '#description' => t('HTML is allowed. @count will be replaced with the number of comments.'));
        $form['node_specific_settings']['link_settings_container']['comment'][$type]['teaser']['standard']["comment_title_{$type}"] = array('#type' => 'textfield', '#title' => t('Title text (tool tip)'), '#default_value' => $settings["comment_title_{$type}"], '#description' => t('Displayed when hovering over link. Plain text only.'));
        $form['node_specific_settings']['link_settings_container']['comment'][$type]['teaser']['standard']["comment_prefix_{$type}"] = array('#type' => 'textfield', '#title' => t('Prefix'), '#default_value' => $settings["comment_prefix_{$type}"], '#description' => t('Text or HTML placed before the link.'));
        $form['node_specific_settings']['link_settings_container']['comment'][$type]['teaser']['standard']["comment_suffix_{$type}"] = array('#type' => 'textfield', '#title' => t('Suffix'), '#default_value' => $settings["comment_suffix_{$type}"], '#description' => t('Text or HTML placed after the link.'));
        $form['node_specific_settings']['link_settings_container']['comment'][$type]['teaser']['new'] = array('#type' => 'fieldset', '#title' => t('"New comments" link'), '#description' => t('The link when there are one or more new comments.'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['node_specific_settings']['link_settings_container']['comment'][$type]['teaser']['new']["comment_new_singular_{$type}"] = array('#type' => 'textfield', '#title' => t('Link text when there is 1 new comment'), '#default_value' => $settings["comment_new_singular_{$type}"], '#description' => t('HTML is allowed.'));
        $form['node_specific_settings']['link_settings_container']['comment'][$type]['teaser']['new']["comment_new_plural_{$type}"] = array('#type' => 'textfield', '#title' => t('Link text when there are multiple new comments'), '#default_value' => $settings["comment_new_plural_{$type}"], '#description' => t('HTML is allowed. @count will be replaced with the number of comments.'));
        $form['node_specific_settings']['link_settings_container']['comment'][$type]['teaser']['new']["comment_new_title_{$type}"] = array('#type' => 'textfield', '#title' => t('Title text (tool tip)'), '#default_value' => $settings["comment_new_title_{$type}"], '#description' => t('Displayed when hovering over link. Plain text only.'));
        $form['node_specific_settings']['link_settings_container']['comment'][$type]['teaser']['new']["comment_new_prefix_{$type}"] = array('#type' => 'textfield', '#title' => t('Prefix'), '#default_value' => $settings["comment_new_prefix_{$type}"], '#description' => t('Text or HTML placed before the link.'));
        $form['node_specific_settings']['link_settings_container']['comment'][$type]['teaser']['new']["comment_new_suffix_{$type}"] = array('#type' => 'textfield', '#title' => t('Suffix'), '#default_value' => $settings["comment_new_suffix_{$type}"], '#description' => t('Text or HTML placed after the link.'));
        // Options for default settings
        if ($type == 'default') {
            $form['node_specific_settings']['link_settings_container']['comment']['default']['#title'] = t('Default');
            $form['node_specific_settings']['link_settings_container']['comment']['default']['#collapsed'] = $settings['comment_content_type'] ? TRUE : FALSE;
            $form['node_specific_settings']['link_settings_container']['comment']['comment_content_type'] = array('#type' => 'checkbox', '#title' => t('Use custom settings for each content type instead of the default above'), '#default_value' => $settings['comment_content_type']);
        } else {
            if ($settings['comment_content_type'] == 0) {
                $form['comment'][$type]['#collapsed'] = TRUE;
            }
        }
    }
    // Taxonomy Settings
    if (module_exists('taxonomy')) {
        $form['node_specific_settings']['taxonomy_settings_container'] = array('#type' => 'fieldset', '#title' => t('Taxonomy terms'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        // Default & content-type specific settings
        foreach (array_merge(array('default' => 'Default'), node_get_types('names')) as $type => $name) {
            // taxonomy display per node
            $form['node_specific_settings']['taxonomy_settings_container']['display_taxonomy'][$type] = array('#type' => 'fieldset', '#title' => t('!name', array('!name' => t($name))), '#collapsible' => TRUE, '#collapsed' => TRUE);
            // display
            $form['node_specific_settings']['taxonomy_settings_container']['display_taxonomy'][$type]["taxonomy_display_{$type}"] = array('#type' => 'select', '#title' => t('When should taxonomy terms be displayed?'), '#default_value' => $settings["taxonomy_display_{$type}"], '#options' => array('' => '', 'never' => t('Never display taxonomy terms'), 'all' => t('Always display taxonomy terms'), 'only' => t('Only display taxonomy terms on full node pages')));
            // format
            $form['node_specific_settings']['taxonomy_settings_container']['display_taxonomy'][$type]["taxonomy_format_{$type}"] = array('#type' => 'radios', '#title' => t('Taxonomy display format'), '#default_value' => $settings["taxonomy_format_{$type}"], '#options' => array('vocab' => t('Display each vocabulary on a new line'), 'list' => t('Display all taxonomy terms together in single list')));
            // Gets taxonomy vocabularies by node type
            $vocabs = array();
            $vocabs_by_type = $type == 'default' ? taxonomy_get_vocabularies() : taxonomy_get_vocabularies($type);
            foreach ($vocabs_by_type as $key => $value) {
                $vocabs[$value->vid] = $value->name;
            }
            // Displays taxonomy checkboxes
            foreach ($vocabs as $key => $vocab_name) {
                $form['node_specific_settings']['taxonomy_settings_container']['display_taxonomy'][$type]["taxonomy_vocab_hide_{$type}_{$key}"] = array('#type' => 'checkbox', '#title' => t('Hide vocabulary: ' . $vocab_name), '#default_value' => $settings["taxonomy_vocab_hide_{$type}_{$key}"]);
            }
            // Options for default settings
            if ($type == 'default') {
                $form['node_specific_settings']['taxonomy_settings_container']['display_taxonomy']['default']['#title'] = t('Default');
                $form['node_specific_settings']['taxonomy_settings_container']['display_taxonomy']['default']['#collapsed'] = $settings['taxonomy_enable_content_type'] ? TRUE : FALSE;
                $form['node_specific_settings']['taxonomy_settings_container']['display_taxonomy']['taxonomy_enable_content_type'] = array('#type' => 'checkbox', '#title' => t('Use custom settings for each content type instead of the default above'), '#default_value' => $settings['taxonomy_enable_content_type']);
            } else {
                if ($settings['taxonomy_enable_content_type'] == 0) {
                    $form['display_taxonomy'][$type]['#collapsed'] = TRUE;
                }
            }
        }
    }
    // Username display settings
    $form['username'] = array('#type' => 'fieldset', '#title' => t('Username'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['username']['user_notverified_display'] = array('#type' => 'checkbox', '#title' => t('Display "not verified" for unregistered usernames'), '#default_value' => $settings['user_notverified_display']);
    // Block editing settings
    $form['block_settings'] = array('#type' => 'fieldset', '#title' => t('Block editing settings'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['block_settings']['block_editing_link'] = array('#type' => 'checkbox', '#title' => t('Show block editing links on hover'), '#description' => t('When hovering over a block, privileged users will see block editing links.'), '#default_value' => $settings['block_editing_link']);
    // Breadcrumb display settings
    $form['breadcrumb'] = array('#type' => 'fieldset', '#title' => t('Breadcrumb settings'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['breadcrumb']['breadcrumb'] = array('#type' => 'radios', '#title' => t('Display breadcrumb'), '#default_value' => $settings['breadcrumb'], '#options' => array('yes' => t('Yes'), 'no' => t('No'), 'admin' => t('Only in admin section')));
    $form['breadcrumb']['breadcrumb_separator'] = array('#type' => 'textfield', '#title' => t('Breadcrumb separator'), '#description' => t('Text only. Don’t forget to include spaces.'), '#default_value' => $settings['breadcrumb_separator'], '#size' => 5, '#maxlength' => 10);
    $form['breadcrumb']['breadcrumb_home_link'] = array('#type' => 'checkbox', '#title' => t('Show home page link in breadcrumb'), '#default_value' => $settings['breadcrumb_home_link']);
    $form['breadcrumb']['breadcrumb_trailing_separator'] = array('#type' => 'checkbox', '#title' => t('Append a separator to the end of the breadcrumb'), '#default_value' => $settings['breadcrumb_trailing_separator'], '#description' => t('Useful when the breadcrumb is placed just before the title.'));
    $form['breadcrumb']['breadcrumb_title'] = array('#type' => 'checkbox', '#title' => t('Append the content title to the end of the breadcrumb'), '#default_value' => $settings['breadcrumb_title'], '#description' => t('Useful when the breadcrumb is not placed just before the title.'));
    // Development phase settings
    $form['theme_development'] = array('#type' => 'fieldset', '#title' => t('Theme development settings'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['theme_development']['rebuild_registry'] = array('#type' => 'checkbox', '#title' => t('Rebuild theme registry on every page.'), '#default_value' => $settings['rebuild_registry'], '#description' => t('During theme development, it can be very useful to continuously <a href="!link">rebuild the theme registry</a>. WARNING: this is a huge performance penalty and must be turned off on production websites.', array('!link' => 'http://drupal.org/node/173880#theme-registry')), '#prefix' => '<strong>' . t('Theme registry:') . '</strong>');
    return $form;
}
コード例 #16
0
/**
 * Return details about an indexed path (required sub-module hook).
 *
 * This hook is invoked after a search, to get full information about
 * what to display.
 *
 * This hook is also invoked during search indexing to get the page title
 * which is added to the indexed text. In this case, $keys will be null, and
 * the module can also return rendered content to be indexed, if desired.
 *
 * @param $id
 *    The ID corresponding to the path. This is the ID number you
 *    returned in hook_sbp_paths(), for this path.
 * @param $environment
 *   ID of environment currently being indexed or searched.
 * @param $keys
 *    The keywords being searched for (useful in extracting a snippet). NULL
 *    indicates this call is for search indexing.
 *
 * @return
 *    - If for some reason this path should not be displayed or indexed,
 *      return NULL or zero.
 *    - If $keys is null, return an associative array for search
 *      indexing, with component 'title' (the page title) and optional
 *      component 'content' (an override of the page content, to avoid
 *      standard Drupal rendering).
 *    - If keywords are not null, return an associative array of fields
 *      suitable for display on search results screen for this path. See
 *      the Drupal documentation for hook_search() for a list of what
 *      the fields are. The 'title' component must be given.  The 'link'
 *      component should be omitted (it is handled by the main
 *      search_by_page module).  The search_by_page_excerpt() function may be
 *      useful in extracting a 'snippet'.
 *
 * @see hook_sbp_paths()
 */
function hook_sbp_details($id, $environment, $keys = NULL)
{
    $node = my_module_get_node($id);
    return array('type' => check_plain(node_get_types('name', $node)), 'title' => search_by_page_strip_tags($node->title, $environment), 'user' => theme('username', $node), 'date' => $node->changed, 'extra' => $node->extra, 'snippet' => search_by_page_excerpt($keys, search_by_page_strip_tags($node->body, $environment)));
}
コード例 #17
0
ファイル: signup.api.php プロジェクト: joachim-n/signup
/**
 * Hook invoked when a signup is being created to gather other signup data.
 *
 * This hook allows other modules to inject information into the custom signup
 * data for each signup.  The array is merged with the values of any custom
 * fields from hook_signup_pane_info(), serialized, and stored in the
 * {signup_log} database table.
 *
 * @param $node
 *   Fully-loaded node object being signed up to.
 * @param $account
 *   Full-loaded user object who is signing up.
 *
 * @return
 *   Keyed array of fields to include in the custom data for this signup. The
 *   keys for the array are used as labels when displaying the field, so they
 *   should be human-readable (and wrapped in t() to allow translation).
 *
 * @see signup_sign_up_user()
 * @see hook_signup_pane_info()
 */
function hook_signup_sign_up($node, $account)
{
    return array(t('Node type') => node_get_types('name', $node->type), t('User created') => format_date($account->created));
}
コード例 #18
0
function budgets_supplier_form(&$node, &$param)
{
    $type = node_get_types('type', $node);
    if (!empty($param['values'])) {
        $node = (object) $param['values'];
    }
    guifi_log(GUIFILOG_TRACE, 'function budgets_supplier_form(READ)', $node->role);
    if ($type->has_title) {
        $form['title'] = array('#type' => 'textfield', '#title' => check_plain($type->title_label), '#required' => TRUE, '#default_value' => $node->title);
    }
    /*
     * Professional or Volunteer?
     */
    $form['role'] = array('#type' => 'radios', '#title' => t('Role'), '#options' => array('volunteer' => t('Volunteer'), 'professional' => t('Professional')), '#default_value' => $node->role, '#description' => t('Use professional for Service Level commitments and economic professional activities, volunteer when is not.<br>' . 'Note: You can rebuild the form to select available capabilities by pressing "Preview" button.'), '#required' => TRUE);
    /*
     * Address
     */
    $form['address'] = array('#type' => 'fieldset', '#attributes' => array('class' => 'supplier-fieldset'), '#title' => t('Address'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    if (empty($node->address1) or empty($node->postal_code) or empty($node->city) or empty($node->country)) {
        $form['address']['#collapsed'] = FALSE;
    }
    $form['address']['address1'] = array('#type' => 'textfield', '#size' => 256, '#maxlength' => 256, '#title' => t('Postal Address'), '#required' => TRUE, '#default_value' => $node->address1);
    $form['address']['address2'] = array('#type' => 'textfield', '#size' => 256, '#maxlength' => 256, '#required' => FALSE, '#default_value' => $node->address2);
    $form['address']['postal_code'] = array('#type' => 'textfield', '#title' => t('Postal Code'), '#description' => t('Postal or zip code'), '#size' => 10, '#maxlength' => 20, '#required' => TRUE, '#default_value' => $node->postal_code);
    $form['address']['city'] = array('#type' => 'textfield', '#title' => t('City'), '#size' => 25, '#maxlength' => 128, '#required' => TRUE, '#default_value' => $node->city);
    $form['address']['region'] = array('#type' => 'textfield', '#title' => t('Region or province'), '#size' => 25, '#maxlength' => 128, '#required' => FALSE, '#default_value' => $node->region);
    $form['address']['country'] = array('#type' => 'textfield', '#title' => t('Country'), '#size' => 25, '#maxlength' => 128, '#required' => TRUE, '#default_value' => $node->country);
    /*
     * Zones
     */
    $zone_ids = array();
    $form['zones'] = array('#type' => 'fieldset', '#title' => t('Zones'), '#description' => t('Zones where the offerings are available, includes the selected node and childs belonging to the selected zone.<br>' . 'Use "Preview" button if all nodes are filled, and you need more rows to fill.'), '#collapsible' => TRUE, '#collapsed' => $node->zones[0] != '' ? TRUE : FALSE, '#attributes' => array('class' => 'zones'), '#tree' => TRUE);
    $zone_id = 0;
    $nzones = count($node->zones);
    guifi_log(GUIFILOG_TRACE, 'function budgets_supplier_form(zones)', $node->zones);
    do {
        $form['zones'][$zone_id] = array('#type' => 'textfield', '#size' => 80, '#default_value' => $node->zones[$zone_id] != '' ? $node->zones[$zone_id] . '-' . guifi_get_zone_name($node->zones[$zone_id]) : NULL, '#maxsize' => 256, '#autocomplete_path' => 'guifi/js/select-zone');
        $zone_id++;
    } while ($zone_id < $nzones + 3);
    if ($type->has_body) {
        $form['body_field'] = node_body_field($node, $type->body_label, $type->min_word_count);
    }
    /*
     * Tax & fiscal information
     */
    $zone_ids = array();
    $form['tax'] = array('#type' => 'fieldset', '#title' => t('Tax & Fiscal information'), '#description' => t('Zones where the offerings are available, includes the selected node and childs belonging to the selected zone.<br>' . 'Use "Preview" button if all nodes are filled, and you need more rows to fill.'), '#collapsible' => TRUE, '#collapsed' => $node->tax_code != '' ? TRUE : FALSE, '#attributes' => array('class' => 'tax supplier-fieldset'));
    $form['tax']['tax_code'] = array('#type' => 'textfield', '#size' => 25, '#maxlength' => 50, '#title' => t('Tax Code / Fiscal Number'), '#required' => TRUE, '#default_value' => $node->tax_code, '#description' => t('Whatever is the legal id in your country for tax and fiscal purposes.'));
    $form['tax']['default_tax_rate'] = array('#type' => 'textfield', '#size' => 10, '#maxlength' => 10, '#title' => t('Default tax rate'), '#required' => TRUE, '#default_value' => $node->default_tax_rate, '#description' => t('When loading quotes and items into proposals.<br> "0" means that the prices are given with the tax included.'));
    /*
     * Certifications
     */
    if (!empty($node->role)) {
        $form['certs'] = array('#type' => 'fieldset', '#title' => t('Enabling Certifications'), '#attributes' => array('class' => 'supplier-fieldset'), '#description' => t('Certificates held by the supplier for empowering activities.<br>' . "Leave blank if unknown/don't have or specify issue date in DD/MM/YYYY format. Note that the provider is required to send a copy of some of those certifications to the Foundation, and be available at any time upon request."), '#collapsible' => TRUE, '#collapsed' => ($node->tp_certs or $node->guifi_certs or $node->other_certs) ? TRUE : FALSE, '#tree' => TRUE);
    }
    $options_tp_certs = guifi_types('tp_certs');
    $count = 1;
    $totalv = count($options_tp_certs);
    if ($node->role == 'professional') {
        foreach ($options_tp_certs as $key => $cert) {
            $prefix = '';
            $suffix = '';
            if ($count == 1) {
                $prefix = '<div class=certs><table><tr><th>' . t('date') . '</th><th>' . t('Professional certificate') . '</th></tr>';
            }
            if ($count == $totalv) {
                $suffix = '</table></div>';
            }
            $form['certs']['tp_certs'][$key] = array('#type' => 'textfield', '#size' => 10, '#default_value' => $node->certs['tp_certs'][$key], '#attributes' => array('class' => "cert-field"), '#prefix' => $prefix . '<tr><td>', '#suffix' => '</td><td>' . $cert . '</td>' . $suffix);
            $count++;
        }
    }
    $options_guifi_certs = guifi_types('guifi_certs');
    $count = 1;
    $totalv = count($options_guifi_certs);
    if (!empty($node->role)) {
        foreach ($options_guifi_certs as $key => $cert) {
            $prefix = '';
            $suffix = '';
            if ($count == 1) {
                $prefix = '<div class=certs><table><tr><th>' . t('date') . '</th><th>' . t('guifi.net certificate') . '</th></tr>';
            }
            if ($count == $totalv) {
                $suffix = '</table></div>';
            }
            $form['certs']['guifi_certs'][$key] = array('#type' => 'textfield', '#size' => 10, '#default_value' => $node->certs['guifi_certs'][$key], '#attributes' => array('class' => "cert-field"), '#prefix' => $prefix . '<tr><td>', '#suffix' => '</td><td>' . $cert . '</td>' . $suffix);
            $count++;
        }
    }
    if (!empty($node->role)) {
        $form['certs']['other_certs'] = array('#type' => 'textfield', '#title' => t('Other certificates'), '#description' => t('Other certifications that might be on the interest for the activity, i.e. Quality,ISO Certs, ...<br>' . 'List them sepparated by commas.'), '#size' => 256, '#maxlength' => 1024, '#required' => FALSE, '#tree' => FALSE, '#default_value' => $node->other_certs);
    }
    /*
     * Capabilities
     */
    $skills_list = guifi_types('skills');
    if (!empty($node->role)) {
        foreach ($skills_list as $k => $value) {
            if (guifi_type_relation('skills', $k, $node->role)) {
                $skill_opts[$k] = $value;
            }
        }
    }
    if (!empty($node->role)) {
        $form['caps'] = array('#type' => 'fieldset', '#title' => t('Capabilities, services & offerings'), '#attributes' => array('class' => 'supplier-fieldset'), '#description' => t('Grid for selecting capabilities, offerings & services built for %role. Press "Preview" if you switched the role to rebuild this grid.', array('%role' => $node->role)), '#collapsible' => TRUE, '#collapsed' => ($node->caps_services or $node->caps_network or $node->caps_services or $node->other_caps) ? TRUE : FALSE, '#tree' => TRUE);
    }
    $skills = t('capability & skills');
    $opt_caps = guifi_types('caps_services');
    $count = 1;
    $totalv = count($opt_caps);
    if (!empty($node->role)) {
        foreach ($opt_caps as $key => $cap) {
            $prefix = '';
            $suffix = '';
            if ($count == 1) {
                $prefix = '<div class=certs><table><tr><th>' . $skills . '</th><th>' . t('services & content providers') . '</th></tr>';
            }
            if ($count == $totalv) {
                $suffix = '</table></div>';
            }
            $form['caps']['caps_services'][$key] = array('#type' => 'select', '#options' => $skill_opts, '#disabled' => guifi_type_relation('caps_services', $key, $node->role) ? false : true, '#default_value' => $node->caps['caps_services'][$key], '#attributes' => array('class' => "cert-field"), '#prefix' => $prefix . '<tr><td>', '#suffix' => guifi_type_relation('caps_services', $key, $node->role) ? '</td><td>' . $cap . '</td>' . $suffix : '</td><td><strike>' . $cap . '</strike></td>' . $suffix);
            $count++;
        }
    }
    $opt_caps = guifi_types('caps_network');
    $count = 1;
    $totalv = count($opt_caps);
    if (!empty($node->role)) {
        foreach ($opt_caps as $key => $cap) {
            $prefix = '';
            $suffix = '';
            if ($count == 1) {
                $prefix = '<div class=certs><table><tr><th>' . $skills . '</th><th>' . t('network dev. & mgmt.') . '</th></tr>';
            }
            if ($count == $totalv) {
                $suffix = '</table></div>';
            }
            $form['caps']['caps_network'][$key] = array('#type' => 'select', '#options' => $skill_opts, '#disabled' => guifi_type_relation('caps_network', $key, $node->role) ? false : true, '#default_value' => $node->caps['caps_network'][$key], '#attributes' => array('class' => "cert-field"), '#prefix' => $prefix . '<tr><td>', '#suffix' => guifi_type_relation('caps_network', $key, $node->role) ? '</td><td>' . $cap . '</td>' . $suffix : '</td><td><strike>' . $cap . '</strike></td>' . $suffix);
            $count++;
        }
    }
    $opt_caps = guifi_types('caps_project');
    $count = 1;
    $totalv = count($opt_caps);
    if (!empty($node->role)) {
        foreach ($opt_caps as $key => $cap) {
            $prefix = '';
            $suffix = '';
            if ($count == 1) {
                $prefix = '<div class=certs><table><tr><th>' . $skills . '</th><th>' . t('project development') . '</th></tr>';
            }
            if ($count == $totalv) {
                $suffix = '</table></div>';
            }
            $form['caps']['caps_project'][$key] = array('#type' => 'select', '#options' => $skill_opts, '#disabled' => guifi_type_relation('caps_project', $key, $node->role) ? false : true, '#default_value' => $node->caps['caps_project'][$key], '#prefix' => $prefix . '<tr><td>', '#suffix' => guifi_type_relation('caps_project', $key, $node->role) ? '</td><td>' . $cap . '</td>' . $suffix : '</td><td><strike>' . $cap . '</strike></td>' . $suffix);
            $count++;
        }
    }
    if (!empty($node->role)) {
        $form['caps']['other_caps'] = array('#type' => 'textfield', '#title' => t('Other capabilities'), '#description' => t('Other capabilities & oferings of this supplier that might be on the interest for networking infrastructure deployment and management.<br>' . 'List them sepparated by commas.'), '#size' => 256, '#maxlength' => 1024, '#required' => FALSE, '#tree' => FALSE, '#default_value' => $node->other_caps);
    }
    /*
     * Ratings
     */
    $form['ratings'] = array('#type' => 'fieldset', '#title' => t('Ratings'), '#description' => t('Self evaluation and objective rating'), '#collapsible' => TRUE, '#collapsed' => ($node->self_rating != '~~' or $node->official_rating != '~~') ? TRUE : FALSE);
    $form['ratings']['self'] = array('#type' => 'fieldset', '#title' => t('Self Ratings') . ' ' . $node->self_rating, '#attributes' => array('class' => 'supplier-fieldset'), '#description' => t('Self evaluation'), '#collapsible' => TRUE, '#collapsed' => FALSE);
    $form['ratings']['self']['sr_commitment'] = array('#type' => 'select', '#title' => t('Commitment'), '#description' => t('Commitment to the Commons and the Community'), '#default_value' => $node->sr_commitment ? $node->sr_commitment : '~', '#options' => guifi_types('commitment_rate'));
    $form['ratings']['self']['sr_experience'] = array('#type' => 'select', '#title' => t('Experience'), '#default_value' => $node->sr_experience ? $node->sr_experience : '~', '#description' => t('Proven experience on executed projects'), '#options' => guifi_types('experience_rate'));
    $form['ratings']['official'] = array('#type' => 'fieldset', '#title' => t('Official Ratings') . ' ' . $node->official_rating, '#attributes' => array('class' => 'supplier-fieldset'), '#description' => t('Objective evaluation'), '#collapsible' => TRUE, '#collapsed' => FALSE);
    $form['ratings']['official']['or_commitment'] = array('#type' => 'select', '#title' => t('Commitment'), '#description' => t('Commitment to the Commons and the Community'), '#default_value' => $node->or_commitment ? $node->or_commitment : '~', '#options' => guifi_types('commitment_rate'), '#access' => user_access('official rating'));
    $form['ratings']['official']['or_experience'] = array('#type' => 'select', '#title' => t('Experience'), '#description' => t('Proven experience on executed projects'), '#default_value' => $node->or_experience ? $node->or_experience : '~', '#options' => guifi_types('experience_rate'), '#access' => user_access('official rating'));
    $form['ratings']['official']['or_trend'] = array('#type' => 'select', '#title' => t('Trend'), '#description' => t('Revision to'), '#default_value' => $node->or_trend ? $node->or_trend : ' ', '#options' => array('+' => '+', ' ' => t('Stable'), '-' => '-'), '#access' => user_access('official rating'));
    /*
     * Accounting URLs
     */
    $k = 0;
    $total = count($node->accounting_urls);
    $form['accounting_urls'] = array('#type' => 'fieldset', '#title' => t('Accounting urls'), '#description' => t('URLs (links) to track accountings, use "Preview" if you need to fill more rows'), '#collapsible' => TRUE, '#tree' => TRUE, '#collapsed' => TRUE);
    do {
        $form['accounting_urls'][$k] = array('#type' => 'fieldset', '#title' => t('Link #') . ($k + 1), '#attributes' => array('class' => 'supplier-fieldset'), '#collapsible' => FALSE, '#tree' => TRUE, '#collapsed' => FALSE, '#attributes' => array('class' => "cert-field"));
        $form['accounting_urls'][$k]['node_id'] = array('#type' => 'textfield', '#title' => t('Node'), '#size' => 25, '#maxlength' => 256, '#description' => t('Affected guifi.net node'), '#autocomplete_path' => 'guifi/js/select-node', '#default_value' => $node->accounting_urls[$k]['node_id']);
        $form['accounting_urls'][$k]['url'] = array('#type' => 'textfield', '#title' => t('Url'), '#size' => 50, '#maxlength' => 256, '#description' => t('link to the accounting object'), '#default_value' => $node->accounting_urls[$k]['url']);
        $form['accounting_urls'][$k]['comment'] = array('#type' => 'textfield', '#title' => t('Comment'), '#size' => 256, '#maxlength' => 256, '#default_value' => $node->accounting_urls[$k]['comment']);
        $k++;
    } while (!empty($node->accounting_urls[$k - 1]['url']));
    /*
     * Contact
     */
    $form['contact'] = array('#type' => 'fieldset', '#title' => t('Contact'), '#attributes' => array('class' => 'supplier-fieldset'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    if (empty($node->notification) or empty($node->phone)) {
        $form['contact']['#collapsed'] = FALSE;
    }
    $form['contact']['notification'] = array('#type' => 'textfield', '#size' => 25, '#maxlength' => 50, '#title' => t('Contact'), '#required' => TRUE, '#element_validate' => array('guifi_emails_validate'), '#default_value' => $node->notification, '#description' => t('Mailid where changes on the device will be notified, ' . 'if many, separated by \',\'.'));
    $form['contact']['phone'] = array('#type' => 'textfield', '#size' => 25, '#maxlength' => 50, '#title' => t('Phone(s)'), '#required' => FALSE, '#default_value' => $node->phone, '#description' => t('Phone(s) for contacting this supplier'));
    $form['contact']['web_url'] = array('#type' => 'textfield', '#size' => 25, '#maxlength' => 128, '#title' => t('Web'), '#required' => FALSE, '#default_value' => $node->web_url, '#description' => t('Will be redirected if clicking on the logo'));
    if (empty($node->logo)) {
        $form['contact']['logo'] = array('#type' => 'file', '#title' => t('Logo'), '#description' => t('Best results with 4:3 ratio and 300 width (300x225 size)'), '#default_value' => $node->logo, '#prefix' => '<table><td>');
        $form['contact']['upload'] = array('#type' => 'submit', '#value' => t('Upload'), '#name' => 'Upload', '#executes_submit_callback' => TRUE, '#submit' => array('budgets_supplier_form_submit'), '#suffix' => '</td></table>');
        $form['#attributes']['enctype'] = 'multipart/form-data';
    } else {
        $form['contact']['logo'] = array('#type' => 'hidden', '#prefix' => '<table><td>', '#value' => $node->logo);
        $form['contact']['display_logo'] = array('#type' => 'item', '#title' => t('Logo'), '#description' => $node->logo, '#value' => '<img src="/' . $node->logo . '" width="100" alt="' . $node->logo . '">');
        $form['contact']['delete_logo'] = array('#type' => 'submit', '#value' => t('Delete logo'), '#name' => 'Delete', '#executes_submit_callback' => TRUE, '#submit' => array('budgets_supplier_form_submit'), '#suffix' => '</td></table>');
    }
    /*
     * Acknowledgement on the Terms & Condition and the p2p agreement
     */
    $form['ack'] = array('#type' => 'checkbox', '#title' => t('Terms & conditions agreement'), '#required' => TRUE, '#default_value' => $node->ack, '#options' => array('0' => 'No', '1' => t('Yes, I agree')), '#description' => t('I agree on:<br>' . '<ul><li>I\'m responsible for all the information I provided, that is truthfulness and available for being verified upon request. ' . 'May be corrected or cancelled if found inaccurate or inappropriate</li>' . '<li>I\'ve read and understood the <a href="http://guifi.net/ComunsXOLN">Comuns XOLN peer to peer agreement</a>, ' . 'I\'m aware that is applicable in many of the activities happening around the scope of this site ' . 'and that the guifi.net Foundation is competent for mediating in case of dispute.</li>' . '<li>Beyond the <a href="http://guifi.net/ComunsXOLN">Comuns XOLN peer to peer agreement</a> but developing it, there are Best Practices ' . 'and Ethics guidelines that also require compliance.</li>' . '<li>This information is provided with the solely purpose of being advertised through the listings of this web under the ' . '<a href="http://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA licensing</a> and be subject to the site publishing criteria.' . '<li>I can exercise the right of update or cancelation of this information directly by accessing this site by myself by using the web site interface' . '</li></ul>'));
    return $form;
}
コード例 #19
0
ファイル: system.api.php プロジェクト: rolfington/drupal
/**
 * Prepare a message based on parameters. @see drupal_mail for more.
 *
 * @param $key
 *   An identifier of the mail.
 * @param $message
 *  An array to be filled in. Keys in this array include:
 *  - 'mail_id':
 *     An id to identify the mail sent. Look into the module source codes
 *     for possible mail_id values.
 *  - 'to':
 *     The mail address or addresses where the message will be send to. The
 *     formatting of this string must comply with RFC 2822.
 *  - 'subject':
 *     Subject of the e-mail to be sent. This must not contain any newline
 *     characters, or the mail may not be sent properly. Empty string when
 *     the hook is invoked.
 *  - 'body':
 *     An array of lines containing the message to be sent. Drupal will format
 *     the correct line endings for you. Empty array when the hook is invoked.
 *  - 'from':
 *     The From, Reply-To, Return-Path and Error-To headers in $headers
 *     are already set to this value (if given).
 *  - 'headers':
 *     Associative array containing the headers to add. This is typically
 *     used to add extra headers (From, Cc, and Bcc).
 * @param $params
 *   An arbitrary array of parameters set by the caller to drupal_mail.
 */
function hook_mail($key, &$message, $params)
{
    $account = $params['account'];
    $context = $params['context'];
    $variables = array('%site_name' => variable_get('site_name', 'Drupal'), '%username' => $account->name);
    if ($context['hook'] == 'taxonomy') {
        $object = $params['object'];
        $vocabulary = taxonomy_vocabulary_load($object->vid);
        $variables += array('%term_name' => $object->name, '%term_description' => $object->description, '%term_id' => $object->tid, '%vocabulary_name' => $vocabulary->name, '%vocabulary_description' => $vocabulary->description, '%vocabulary_id' => $vocabulary->vid);
    }
    // Node-based variable translation is only available if we have a node.
    if (isset($params['node'])) {
        $node = $params['node'];
        $variables += array('%uid' => $node->uid, '%node_url' => url('node/' . $node->nid, array('absolute' => TRUE)), '%node_type' => node_get_types('name', $node), '%title' => $node->title, '%teaser' => $node->teaser, '%body' => $node->body);
    }
    $subject = strtr($context['subject'], $variables);
    $body = strtr($context['message'], $variables);
    $message['subject'] .= str_replace(array("\r", "\n"), '', $subject);
    $message['body'][] = drupal_html_to_text($body);
}
コード例 #20
0
ファイル: theme-settings.php プロジェクト: upei/drupal6-cms
/**
 * Implementation of THEMEHOOK_settings() function.
 *
 * @param $saved_settings
 *   array An array of saved settings for this theme.
 * @return
 *   array A form array.
 */
function phptemplate_settings($saved_settings)
{
    // Get the node types
    $node_types = node_get_types('names');
    // Add javascript to show/hide optional settings
    drupal_add_js(drupal_get_path('theme', 'magazeen') . '/script/theme-settings.js', 'theme');
    /**
     * The default values for the theme variables. Make sure $defaults exactly
     * matches the $defaults in the template.php file.
     */
    $defaults = array('comment_title' => 'Leave a Response', 'no_comment_message' => 'It\'s quite in here! Why not leave a <a href="#respond">response</a>?', 'breadcrumb_display' => 'yes', 'breadcrumb_separator' => ' › ', 'breadcrumb_home' => 1, 'breadcrumb_trailing' => 0, 'breadcrumb_title' => 0, 'mission_statement_pages' => 'home', 'user_notverified_display' => 0, 'search_text' => 'Search', 'search_snippet' => 1, 'search_info_type' => 1, 'search_info_user' => 1, 'search_info_date' => 1, 'search_info_comment' => 1, 'search_info_upload' => 1, 'submitted_by_author_default' => 1, 'submitted_by_date_default' => 1, 'submitted_by_enable_content_type' => 0, 'taxonomy_display_default' => 'all', 'taxonomy_format_default' => 'list', 'taxonomy_enable_content_type' => 0, 'readmore_default' => t('Continue Reading'), 'readmore_title_default' => t('Read the rest of this posting.'), 'readmore_enable_content_type' => 0, 'readmore_prefix_default' => '', 'readmore_suffix_default' => '', 'comment_singular_default' => t('1 comment'), 'comment_plural_default' => t('@count comments'), 'comment_title_default' => t('Jump to the first comment of this posting.'), 'comment_prefix_default' => '', 'comment_suffix_default' => '', 'comment_new_singular_default' => t('1 new comment'), 'comment_new_plural_default' => t('@count new comments'), 'comment_new_title_default' => t('Jump to the first new comment of this posting.'), 'comment_new_prefix_default' => '', 'comment_new_suffix_default' => '', 'comment_add_default' => t('Leave a comment'), 'comment_add_title_default' => t('Leave a new comment to this page.'), 'comment_add_prefix_default' => '', 'comment_add_suffix_default' => '', 'comment_node_default' => t('Add new comment'), 'comment_node_title_default' => t('Share your thoughts and opinions related to this posting.'), 'comment_node_prefix_default' => '', 'comment_node_suffix_default' => '', 'comment_enable_content_type' => 0, 'front_page_title_display' => 'title_slogan', 'page_title_display_custom' => '', 'other_page_title_display' => 'ptitle_stitle', 'other_page_title_display_custom' => '', 'configurable_separator' => ' | ', 'meta_keywords' => '', 'meta_description' => '', 'rebuild_registry' => 0, 'block_editing' => 1);
    // Make the default content-type settings the same as the default theme settings,
    // so we can tell if content-type-specific settings have been altered.
    $defaults = array_merge($defaults, theme_get_settings());
    // Set the default values for content-type-specific settings
    foreach ($node_types as $type => $name) {
        $defaults["submitted_by_author_{$type}"] = $defaults['submitted_by_author_default'];
        $defaults["submitted_by_date_{$type}"] = $defaults['submitted_by_date_default'];
        $defaults["taxonomy_display_{$type}"] = $defaults['taxonomy_display_default'];
        $defaults["taxonomy_format_{$type}"] = $defaults['taxonomy_format_default'];
        $defaults["readmore_{$type}"] = $defaults['readmore_default'];
        $defaults["readmore_title_{$type}"] = $defaults['readmore_title_default'];
        $defaults["readmore_prefix_{$type}"] = $defaults['readmore_prefix_default'];
        $defaults["readmore_suffix_{$type}"] = $defaults['readmore_suffix_default'];
        $defaults["comment_singular_{$type}"] = $defaults['comment_singular_default'];
        $defaults["comment_plural_{$type}"] = $defaults['comment_plural_default'];
        $defaults["comment_title_{$type}"] = $defaults['comment_title_default'];
        $defaults["comment_prefix_{$type}"] = $defaults['comment_prefix_default'];
        $defaults["comment_suffix_{$type}"] = $defaults['comment_suffix_default'];
        $defaults["comment_new_singular_{$type}"] = $defaults['comment_new_singular_default'];
        $defaults["comment_new_plural_{$type}"] = $defaults['comment_new_plural_default'];
        $defaults["comment_new_title_{$type}"] = $defaults['comment_new_title_default'];
        $defaults["comment_new_prefix_{$type}"] = $defaults['comment_new_prefix_default'];
        $defaults["comment_new_suffix_{$type}"] = $defaults['comment_new_suffix_default'];
        $defaults["comment_add_{$type}"] = $defaults['comment_add_default'];
        $defaults["comment_add_title_{$type}"] = $defaults['comment_add_title_default'];
        $defaults["comment_add_prefix_{$type}"] = $defaults['comment_add_prefix_default'];
        $defaults["comment_add_suffix_{$type}"] = $defaults['comment_add_suffix_default'];
        $defaults["comment_node_{$type}"] = $defaults['comment_node_default'];
        $defaults["comment_node_title_{$type}"] = $defaults['comment_node_title_default'];
        $defaults["comment_node_prefix_{$type}"] = $defaults['comment_node_prefix_default'];
        $defaults["comment_node_suffix_{$type}"] = $defaults['comment_node_suffix_default'];
    }
    // Merge the saved variables and their default values
    $settings = array_merge($defaults, $saved_settings);
    // If content type-specifc settings are not enabled, reset the values
    if ($settings['readmore_enable_content_type'] == 0) {
        foreach ($node_types as $type => $name) {
            $settings["readmore_{$type}"] = $settings['readmore_default'];
            $settings["readmore_title_{$type}"] = $settings['readmore_title_default'];
            $settings["readmore_prefix_{$type}"] = $settings['readmore_prefix_default'];
            $settings["readmore_suffix_{$type}"] = $settings['readmore_suffix_default'];
        }
    }
    if ($settings['comment_enable_content_type'] == 0) {
        foreach ($node_types as $type => $name) {
            $defaults["comment_singular_{$type}"] = $defaults['comment_singular_default'];
            $defaults["comment_plural_{$type}"] = $defaults['comment_plural_default'];
            $defaults["comment_title_{$type}"] = $defaults['comment_title_default'];
            $defaults["comment_prefix_{$type}"] = $defaults['comment_prefix_default'];
            $defaults["comment_suffix_{$type}"] = $defaults['comment_suffix_default'];
            $defaults["comment_new_singular_{$type}"] = $defaults['comment_new_singular_default'];
            $defaults["comment_new_plural_{$type}"] = $defaults['comment_new_plural_default'];
            $defaults["comment_new_title_{$type}"] = $defaults['comment_new_title_default'];
            $defaults["comment_new_prefix_{$type}"] = $defaults['comment_new_prefix_default'];
            $defaults["comment_new_suffix_{$type}"] = $defaults['comment_new_suffix_default'];
            $defaults["comment_add_{$type}"] = $defaults['comment_add_default'];
            $defaults["comment_add_title_{$type}"] = $defaults['comment_add_title_default'];
            $defaults["comment_add_prefix_{$type}"] = $defaults['comment_add_prefix_default'];
            $defaults["comment_add_suffix_{$type}"] = $defaults['comment_add_suffix_default'];
            $defaults["comment_node_{$type}"] = $defaults['comment_node_default'];
            $defaults["comment_node_title_{$type}"] = $defaults['comment_node_title_default'];
            $defaults["comment_node_prefix_{$type}"] = $defaults['comment_node_prefix_default'];
            $defaults["comment_node_suffix_{$type}"] = $defaults['comment_node_suffix_default'];
        }
    }
    // Create theme settings form widgets using Forms API
    // Breadcrumb
    $form['tnt_container']['general_settings']['breadcrumb'] = array('#type' => 'fieldset', '#title' => t('Breadcrumb'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['tnt_container']['general_settings']['breadcrumb']['breadcrumb_display'] = array('#type' => 'select', '#title' => t('Display breadcrumb'), '#default_value' => $settings['breadcrumb_display'], '#options' => array('yes' => t('Yes'), 'admin' => t('Only in admin section'), 'no' => t('No')));
    $form['tnt_container']['general_settings']['breadcrumb']['breadcrumb_separator'] = array('#type' => 'textfield', '#title' => t('Breadcrumb separator'), '#description' => t('Text only. Don’t forget to include spaces.'), '#default_value' => $settings['breadcrumb_separator'], '#size' => 5, '#maxlength' => 10, '#prefix' => '<div id="div-breadcrumb-collapse">');
    $form['tnt_container']['general_settings']['breadcrumb']['breadcrumb_home'] = array('#type' => 'checkbox', '#title' => t('Show home page link in breadcrumb'), '#default_value' => $settings['breadcrumb_home']);
    $form['tnt_container']['general_settings']['breadcrumb']['breadcrumb_trailing'] = array('#type' => 'checkbox', '#title' => t('Append a separator to the end of the breadcrumb'), '#default_value' => $settings['breadcrumb_trailing'], '#description' => t('Useful when the breadcrumb is placed just before the title.'));
    $form['tnt_container']['general_settings']['breadcrumb']['breadcrumb_title'] = array('#type' => 'checkbox', '#title' => t('Append the content title to the end of the breadcrumb'), '#default_value' => $settings['breadcrumb_title'], '#description' => t('Useful when the breadcrumb is not placed just before the title.'), '#suffix' => '</div>');
    // Mission Statement
    $form['tnt_container']['general_settings']['mission_statement'] = array('#type' => 'fieldset', '#title' => t('Mission statement'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['tnt_container']['general_settings']['mission_statement']['mission_statement_pages'] = array('#type' => 'radios', '#title' => t('Where should your mission statement be displayed?'), '#default_value' => $settings['mission_statement_pages'], '#options' => array('home' => t('Display mission statement only on front page'), 'all' => t('Display mission statement on all pages')));
    // Username
    $form['tnt_container']['general_settings']['username'] = array('#type' => 'fieldset', '#title' => t('Username'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['tnt_container']['general_settings']['username']['user_notverified_display'] = array('#type' => 'checkbox', '#title' => t('Display "not verified" for unregistered usernames'), '#default_value' => $settings['user_notverified_display']);
    // Search Settings
    $form['tnt_container']['general_settings']['search_container'] = array('#type' => 'fieldset', '#title' => t('Search'), '#description' => t('What additional information should be displayed on your search results page?'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    // Search Input Text
    $form['tnt_container']['general_settings']['search_container']['search_input'] = array('#type' => 'fieldset', '#title' => t('Search Input Text'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['tnt_container']['general_settings']['search_container']['search_input']['search_text'] = array('#type' => 'textfield', '#title' => t('Search Input Text'), '#description' => t('Customize the text for the search input.'), '#size' => 60, '#default_value' => $settings['search_text']);
    // Search Result
    $form['tnt_container']['general_settings']['search_container']['search_results'] = array('#type' => 'fieldset', '#title' => t('Search Result'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['tnt_container']['general_settings']['search_container']['search_results']['search_snippet'] = array('#type' => 'checkbox', '#title' => t('Display text snippet'), '#default_value' => $settings['search_snippet']);
    $form['tnt_container']['general_settings']['search_container']['search_results']['search_info_type'] = array('#type' => 'checkbox', '#title' => t('Display content type'), '#default_value' => $settings['search_info_type']);
    $form['tnt_container']['general_settings']['search_container']['search_results']['search_info_user'] = array('#type' => 'checkbox', '#title' => t('Display author name'), '#default_value' => $settings['search_info_user']);
    $form['tnt_container']['general_settings']['search_container']['search_results']['search_info_date'] = array('#type' => 'checkbox', '#title' => t('Display posted date'), '#default_value' => $settings['search_info_date']);
    $form['tnt_container']['general_settings']['search_container']['search_results']['search_info_comment'] = array('#type' => 'checkbox', '#title' => t('Display comment count'), '#default_value' => $settings['search_info_comment']);
    $form['tnt_container']['general_settings']['search_container']['search_results']['search_info_upload'] = array('#type' => 'checkbox', '#title' => t('Display attachment count'), '#default_value' => $settings['search_info_upload']);
    // Comment Setting
    $form['tnt_container']['general_settings']['comment_container'] = array('#type' => 'fieldset', '#title' => t('Comment setting'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    // Comment Title
    $form['tnt_container']['general_settings']['comment_container']['comment_title'] = array('#type' => 'textfield', '#title' => t('Comment Title'), '#description' => t('Customize the title for the comments box.'), '#size' => 60, '#default_value' => $settings['comment_title']);
    // No Comment Message
    $form['tnt_container']['general_settings']['comment_container']['no_comment_message'] = array('#type' => 'textfield', '#title' => t('No Comment Message'), '#description' => t('Display a message if there no comment. HTML is allowed.'), '#size' => 71, '#default_value' => $settings['no_comment_message']);
    // Node Settings
    $form['tnt_container']['node_type_specific'] = array('#type' => 'fieldset', '#title' => t('Node settings'), '#description' => t('Here you can make adjustments to which information is shown with your content, and how it is displayed.  You can modify these settings so they apply to all content types, or check the "Use content-type specific settings" box to customize them for each content type.  For example, you may want to show the date on stories, but not pages.'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    // Author & Date Settings
    $form['tnt_container']['node_type_specific']['submitted_by_container'] = array('#type' => 'fieldset', '#title' => t('Author & date'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    // Default & content-type specific settings
    foreach (array('default' => 'Default') + node_get_types('names') as $type => $name) {
        $form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by'][$type] = array('#type' => 'fieldset', '#title' => t('!name', array('!name' => t($name))), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by'][$type]["submitted_by_author_{$type}"] = array('#type' => 'checkbox', '#title' => t('Display author\'s username'), '#default_value' => $settings["submitted_by_author_{$type}"]);
        $form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by'][$type]["submitted_by_date_{$type}"] = array('#type' => 'checkbox', '#title' => t('Display date posted (you can customize this format on your Date and Time settings page)'), '#default_value' => $settings["submitted_by_date_{$type}"]);
        // Options for default settings
        if ($type == 'default') {
            $form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by']['default']['#title'] = t('Default');
            $form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by']['default']['#collapsed'] = $settings['submitted_by_enable_content_type'] ? TRUE : FALSE;
            $form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by']['submitted_by_enable_content_type'] = array('#type' => 'checkbox', '#title' => t('Use custom settings for each content type instead of the default above'), '#default_value' => $settings['submitted_by_enable_content_type']);
        } else {
            if ($settings['submitted_by_enable_content_type'] == 0) {
                $form['submitted_by'][$type]['#collapsed'] = TRUE;
            }
        }
    }
    // Taxonomy Settings
    if (module_exists('taxonomy')) {
        $form['tnt_container']['node_type_specific']['display_taxonomy_container'] = array('#type' => 'fieldset', '#title' => t('Taxonomy terms'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        // Default & content-type specific settings
        foreach (array('default' => 'Default') + node_get_types('names') as $type => $name) {
            // taxonomy display per node
            $form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy'][$type] = array('#type' => 'fieldset', '#title' => t('!name', array('!name' => t($name))), '#collapsible' => TRUE, '#collapsed' => TRUE);
            // display
            $form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy'][$type]["taxonomy_display_{$type}"] = array('#type' => 'select', '#title' => t('When should taxonomy terms be displayed?'), '#default_value' => $settings["taxonomy_display_{$type}"], '#options' => array('never' => t('Never display taxonomy terms'), 'all' => t('Always display taxonomy terms'), 'only' => t('Only display taxonomy terms on full node pages')));
            // format
            $form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy'][$type]["taxonomy_format_{$type}"] = array('#type' => 'radios', '#title' => t('Taxonomy display format'), '#default_value' => $settings["taxonomy_format_{$type}"], '#options' => array('vocab' => t('Display each vocabulary on a new line'), 'list' => t('Display all taxonomy terms together in single list')));
            // Get taxonomy vocabularies by node type
            $vocabs = array();
            $vocabs_by_type = $type == 'default' ? taxonomy_get_vocabularies() : taxonomy_get_vocabularies($type);
            foreach ($vocabs_by_type as $key => $value) {
                $vocabs[$value->vid] = $value->name;
            }
            // Display taxonomy checkboxes
            foreach ($vocabs as $key => $vocab_name) {
                $form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy'][$type]["taxonomy_vocab_display_{$type}_{$key}"] = array('#type' => 'checkbox', '#title' => t('Display vocabulary: ' . $vocab_name), '#default_value' => $settings["taxonomy_vocab_display_{$type}_{$key}"]);
            }
            // Options for default settings
            if ($type == 'default') {
                $form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy']['default']['#title'] = t('Default');
                $form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy']['default']['#collapsed'] = $settings['taxonomy_enable_content_type'] ? TRUE : FALSE;
                $form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy']['taxonomy_enable_content_type'] = array('#type' => 'checkbox', '#title' => t('Use custom settings for each content type instead of the default above'), '#default_value' => $settings['taxonomy_enable_content_type']);
            } else {
                if ($settings['taxonomy_enable_content_type'] == 0) {
                    $form['display_taxonomy'][$type]['#collapsed'] = TRUE;
                }
            }
        }
    }
    // Read More & Comment Link Settings
    $form['tnt_container']['node_type_specific']['link_settings'] = array('#type' => 'fieldset', '#title' => t('Links'), '#description' => t('Customize the text of node links'), '#collapsible' => TRUE, '#collapsed' => FALSE);
    // Read more link settings
    $form['tnt_container']['node_type_specific']['link_settings']['readmore'] = array('#type' => 'fieldset', '#title' => t('“Read more”'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    // Default & content-type specific settings
    foreach (array('default' => 'Default') + node_get_types('names') as $type => $name) {
        // Read more
        $form['tnt_container']['node_type_specific']['link_settings']['readmore'][$type] = array('#type' => 'fieldset', '#title' => t('!name', array('!name' => t($name))), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['tnt_container']['node_type_specific']['link_settings']['readmore'][$type]["readmore_{$type}"] = array('#type' => 'textfield', '#title' => t('Link text'), '#default_value' => $settings["readmore_{$type}"], '#description' => t('HTML is allowed.'));
        $form['tnt_container']['node_type_specific']['link_settings']['readmore'][$type]["readmore_title_{$type}"] = array('#type' => 'textfield', '#title' => t('Title text (tool tip)'), '#default_value' => $settings["readmore_title_{$type}"], '#description' => t('Displayed when hovering over link. Plain text only.'));
        $form['tnt_container']['node_type_specific']['link_settings']['readmore'][$type]["readmore_prefix_{$type}"] = array('#type' => 'textfield', '#title' => t('Prefix'), '#default_value' => $settings["readmore_prefix_{$type}"], '#description' => t('Text or HTML placed before the link.'));
        $form['tnt_container']['node_type_specific']['link_settings']['readmore'][$type]["readmore_suffix_{$type}"] = array('#type' => 'textfield', '#title' => t('Suffix'), '#default_value' => $settings["readmore_suffix_{$type}"], '#description' => t('Text or HTML placed after the link.'));
        // Options for default settings
        if ($type == 'default') {
            $form['tnt_container']['node_type_specific']['link_settings']['readmore']['default']['#title'] = t('Default');
            $form['tnt_container']['node_type_specific']['link_settings']['readmore']['default']['#collapsed'] = $settings['readmore_enable_content_type'] ? TRUE : FALSE;
            $form['tnt_container']['node_type_specific']['link_settings']['readmore']['readmore_enable_content_type'] = array('#type' => 'checkbox', '#title' => t('Use custom settings for each content type instead of the default above'), '#default_value' => $settings['readmore_enable_content_type']);
        } else {
            if ($settings['readmore_enable_content_type'] == 0) {
                $form['readmore'][$type]['#collapsed'] = TRUE;
            }
        }
    }
    // Comments link settings
    $form['tnt_container']['node_type_specific']['link_settings']['comment'] = array('#type' => 'fieldset', '#title' => t('“Comment”'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    // Default & content-type specific settings
    foreach (array('default' => 'Default') + node_get_types('names') as $type => $name) {
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type] = array('#type' => 'fieldset', '#title' => t('!name', array('!name' => t($name))), '#collapsible' => TRUE, '#collapsed' => TRUE);
        // Full nodes
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['node'] = array('#type' => 'fieldset', '#title' => t('For full content'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['node']['add'] = array('#type' => 'fieldset', '#title' => t('“Add new comment” link'), '#description' => t('The link when the full content is being displayed.'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['node']['add']["comment_node_{$type}"] = array('#type' => 'textfield', '#title' => t('Link text'), '#default_value' => $settings["comment_node_{$type}"], '#description' => t('HTML is allowed.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['node']['add']["comment_node_title_{$type}"] = array('#type' => 'textfield', '#title' => t('Title text (tool tip)'), '#default_value' => $settings["comment_node_title_{$type}"], '#description' => t('Displayed when hovering over link. Plain text only.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['node']['add']['extra'] = array('#type' => 'fieldset', '#title' => t('Advanced'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['node']['add']['extra']["comment_node_prefix_{$type}"] = array('#type' => 'textfield', '#title' => t('Prefix'), '#default_value' => $settings["comment_node_prefix_{$type}"], '#description' => t('Text or HTML placed before the link.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['node']['add']['extra']["comment_node_suffix_{$type}"] = array('#type' => 'textfield', '#title' => t('Suffix'), '#default_value' => $settings["comment_node_suffix_{$type}"], '#description' => t('Text or HTML placed after the link.'));
        // Teasers
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser'] = array('#type' => 'fieldset', '#title' => t('For teasers'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['add'] = array('#type' => 'fieldset', '#title' => t('“Add new comment” link'), '#description' => t('The link when there are no comments.'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['add']["comment_add_{$type}"] = array('#type' => 'textfield', '#title' => t('Link text'), '#default_value' => $settings["comment_add_{$type}"], '#description' => t('HTML is allowed.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['add']["comment_add_title_{$type}"] = array('#type' => 'textfield', '#title' => t('Title text (tool tip)'), '#default_value' => $settings["comment_add_title_{$type}"], '#description' => t('Displayed when hovering over link. Plain text only.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['add']['extra'] = array('#type' => 'fieldset', '#title' => t('Advanced'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['add']['extra']["comment_add_prefix_{$type}"] = array('#type' => 'textfield', '#title' => t('Prefix'), '#default_value' => $settings["comment_add_prefix_{$type}"], '#description' => t('Text or HTML placed before the link.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['add']['extra']["comment_add_suffix_{$type}"] = array('#type' => 'textfield', '#title' => t('Suffix'), '#default_value' => $settings["comment_add_suffix_{$type}"], '#description' => t('Text or HTML placed after the link.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['standard'] = array('#type' => 'fieldset', '#title' => t('“Comments” link'), '#description' => t('The link when there are one or more comments.'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['standard']["comment_singular_{$type}"] = array('#type' => 'textfield', '#title' => t('Link text when there is 1 comment'), '#default_value' => $settings["comment_singular_{$type}"], '#description' => t('HTML is allowed.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['standard']["comment_plural_{$type}"] = array('#type' => 'textfield', '#title' => t('Link text when there are multiple comments'), '#default_value' => $settings["comment_plural_{$type}"], '#description' => t('HTML is allowed. @count will be replaced with the number of comments.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['standard']["comment_title_{$type}"] = array('#type' => 'textfield', '#title' => t('Title text (tool tip)'), '#default_value' => $settings["comment_title_{$type}"], '#description' => t('Displayed when hovering over link. Plain text only.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['standard']['extra'] = array('#type' => 'fieldset', '#title' => t('Advanced'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['standard']['extra']["comment_prefix_{$type}"] = array('#type' => 'textfield', '#title' => t('Prefix'), '#default_value' => $settings["comment_prefix_{$type}"], '#description' => t('Text or HTML placed before the link.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['standard']['extra']["comment_suffix_{$type}"] = array('#type' => 'textfield', '#title' => t('Suffix'), '#default_value' => $settings["comment_suffix_{$type}"], '#description' => t('Text or HTML placed after the link.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['new'] = array('#type' => 'fieldset', '#title' => t('“New comments” link'), '#description' => t('The link when there are one or more new comments.'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['new']["comment_new_singular_{$type}"] = array('#type' => 'textfield', '#title' => t('Link text when there is 1 new comment'), '#default_value' => $settings["comment_new_singular_{$type}"], '#description' => t('HTML is allowed.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['new']["comment_new_plural_{$type}"] = array('#type' => 'textfield', '#title' => t('Link text when there are multiple new comments'), '#default_value' => $settings["comment_new_plural_{$type}"], '#description' => t('HTML is allowed. @count will be replaced with the number of comments.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['new']["comment_new_title_{$type}"] = array('#type' => 'textfield', '#title' => t('Title text (tool tip)'), '#default_value' => $settings["comment_new_title_{$type}"], '#description' => t('Displayed when hovering over link. Plain text only.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['new']['extra'] = array('#type' => 'fieldset', '#title' => t('Advanced'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['new']['extra']["comment_new_prefix_{$type}"] = array('#type' => 'textfield', '#title' => t('Prefix'), '#default_value' => $settings["comment_new_prefix_{$type}"], '#description' => t('Text or HTML placed before the link.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['new']['extra']["comment_new_suffix_{$type}"] = array('#type' => 'textfield', '#title' => t('Suffix'), '#default_value' => $settings["comment_new_suffix_{$type}"], '#description' => t('Text or HTML placed after the link.'));
        // Options for default settings
        if ($type == 'default') {
            $form['tnt_container']['node_type_specific']['link_settings']['comment']['default']['#title'] = t('Default');
            $form['tnt_container']['node_type_specific']['link_settings']['comment']['default']['#collapsed'] = $settings['comment_enable_content_type'] ? TRUE : FALSE;
            $form['tnt_container']['node_type_specific']['link_settings']['comment']['comment_enable_content_type'] = array('#type' => 'checkbox', '#title' => t('Use custom settings for each content type instead of the default above'), '#default_value' => $settings['comment_enable_content_type']);
        } else {
            if ($settings['comment_enable_content_type'] == 0) {
                $form['comment'][$type]['#collapsed'] = TRUE;
            }
        }
    }
    // SEO settings
    $form['tnt_container']['seo'] = array('#type' => 'fieldset', '#title' => t('Search engine optimization (SEO) settings'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    // Page titles
    $form['tnt_container']['seo']['page_format_titles'] = array('#type' => 'fieldset', '#title' => t('Page titles'), '#description' => t('This is the title that displays in the title bar of your web browser. Your site title, slogan, and mission can all be set on your Site Information page'), '#collapsible' => TRUE, '#collapsed' => FALSE);
    // front page title
    $form['tnt_container']['seo']['page_format_titles']['front_page_format_titles'] = array('#type' => 'fieldset', '#title' => t('Front page title'), '#description' => t('Your front page in particular should have important keywords for your site in the page title'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['tnt_container']['seo']['page_format_titles']['front_page_format_titles']['front_page_title_display'] = array('#type' => 'select', '#title' => t('Set text of front page title'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#default_value' => $settings['front_page_title_display'], '#options' => array('title_slogan' => t('Site title | Site slogan'), 'slogan_title' => t('Site slogan | Site title'), 'title_mission' => t('Site title | Site mission'), 'custom' => t('Custom (below)')));
    $form['tnt_container']['seo']['page_format_titles']['front_page_format_titles']['page_title_display_custom'] = array('#type' => 'textfield', '#title' => t('Custom'), '#size' => 60, '#default_value' => $settings['page_title_display_custom'], '#description' => t('Enter a custom page title for your front page'));
    // other pages title
    $form['tnt_container']['seo']['page_format_titles']['other_page_format_titles'] = array('#type' => 'fieldset', '#title' => t('Other page titles'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['tnt_container']['seo']['page_format_titles']['other_page_format_titles']['other_page_title_display'] = array('#type' => 'select', '#title' => t('Set text of other page titles'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#default_value' => $settings['other_page_title_display'], '#options' => array('ptitle_slogan' => t('Page title | Site slogan'), 'ptitle_stitle' => t('Page title | Site title'), 'ptitle_smission' => t('Page title | Site mission'), 'ptitle_custom' => t('Page title | Custom (below)'), 'custom' => t('Custom (below)')));
    $form['tnt_container']['seo']['page_format_titles']['other_page_format_titles']['other_page_title_display_custom'] = array('#type' => 'textfield', '#title' => t('Custom'), '#size' => 60, '#default_value' => $settings['other_page_title_display_custom'], '#description' => t('Enter a custom page title for all other pages'));
    // SEO configurable separator
    $form['tnt_container']['seo']['page_format_titles']['configurable_separator'] = array('#type' => 'textfield', '#title' => t('Title separator'), '#description' => t('Customize the separator character used in the page title'), '#size' => 60, '#default_value' => $settings['configurable_separator']);
    // Metadata
    $form['tnt_container']['seo']['meta'] = array('#type' => 'fieldset', '#title' => t('Meta tags'), '#description' => t('Meta tags aren\'t used much by search engines anymore, but the meta description is important -- this is what will be shown as the description of your link in search engine results.  NOTE: For more advanced meta tag functionality, check out the Meta Tags (aka. Node Words) module.  These theme settings do not work in conjunction with this module and will not appear if you have it enabled.'), '#collapsible' => TRUE, '#collapsed' => FALSE);
    if (module_exists('nodewords') == FALSE) {
        $form['tnt_container']['seo']['meta']['meta_keywords'] = array('#type' => 'textfield', '#title' => t('Meta keywords'), '#description' => t('Enter a comma-separated list of keywords'), '#size' => 60, '#default_value' => $settings['meta_keywords']);
        $form['tnt_container']['seo']['meta']['meta_description'] = array('#type' => 'textarea', '#title' => t('Meta description'), '#cols' => 60, '#rows' => 6, '#default_value' => $settings['meta_description']);
    } else {
        $form['tnt_container']['seo']['meta']['#description'] = 'NOTICE: You currently have the "nodewords" module installed and enabled, so the meta tag theme settings have been disabled to prevent conflicts.  If you later wish to re-enable the meta tag theme settings, you must first disable the "nodewords" module.';
        $form['tnt_container']['seo']['meta']['meta_keywords']['#disabled'] = 'disabled';
        $form['tnt_container']['seo']['meta']['meta_description']['#disabled'] = 'disabled';
    }
    // Theme Dev Setting
    $form['tnt_container']['theme_dev'] = array('#type' => 'fieldset', '#title' => t('Theme development settings'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    // Rebuild Registry
    $form['tnt_container']['theme_dev']['rebuild_registry'] = array('#type' => 'checkbox', '#title' => t('Rebuild theme registry on every page.'), '#description' => t('During theme development, it can be very useful to continuously <a href="!link">rebuild the theme registry</a>. WARNING: this is a huge performance penalty and must be turned off on production websites.', array('!link' => 'http://drupal.org/node/173880#theme-registry')), '#default_value' => $settings['rebuild_registry']);
    // Block Editing
    $form['tnt_container']['theme_dev']['block_editing'] = array('#type' => 'checkbox', '#title' => t('Show block editing on hover'), '#description' => t('When hovering over a block, privileged users will see block editing links.'), '#default_value' => $settings['block_editing']);
    // Return theme settings form
    return $form;
}
コード例 #21
0
ファイル: field.api.php プロジェクト: schuyler1d/drupal
/**
 * Inform the Field API about one or more fieldable types (object
 * types to which fields can be attached).
 *
 * @return
 *   An array whose keys are fieldable object type names and
 *   whose values identify properties of those types that the Field
 *   system needs to know about:
 *
 *   name: The human-readable name of the type.
 *   id key: The object property that contains the primary id for the
 *     object. Every object passed to the Field API must
 *     have this property and its value must be numeric.
 *   revision key: The object property that contains the revision id
 *     for the object, or NULL if the object type is not
 *     versioned. The Field API assumes that all revision ids are
 *     unique across all instances of a type; this means, for example,
 *     that every object's revision ids cannot be 0, 1, 2, ...
 *   bundle key: The object property that contains the bundle name for
 *     the object (bundle name is what nodes call "content type").
 *     The bundle name defines which fields are connected to the object.
 *   cacheable: A boolean indicating whether Field API should cache
 *     loaded fields for each object, reducing the cost of
 *     field_attach_load().
 *   bundles: An array of all existing bundle names for this object
 *     type. TODO: Define format. TODO: I'm unclear why we need
 *     this.
 */
function hook_fieldable_info()
{
    $return = array('node' => array('name' => t('Node'), 'id key' => 'nid', 'revision key' => 'vid', 'bundle key' => 'type', 'cacheable' => FALSE, 'bundles' => node_get_types('names')));
    return $return;
}
コード例 #22
0
ファイル: template.php プロジェクト: hoangbktech/bhl-bits
/*
* Initialize theme settings
*/
if (is_null(theme_get_setting('fourseasons_basecolor'))) {
    // <-- change this line
    global $theme_key;
    /*
     * The default values for the theme variables. Make sure $defaults exactly
     * matches the $defaults in the theme-settings.php file.
     */
    $defaults = array('fourseasons_basecolor' => '#FF9900');
    // Get default theme settings.
    $settings = theme_get_settings($theme_key);
    // Don't save the toggle_node_info_ variables.
    if (module_exists('node')) {
        foreach (node_get_types() as $type => $name) {
            unset($settings['toggle_node_info_' . $type]);
        }
    }
    // Save default theme settings.
    variable_set(str_replace('/', '_', 'theme_' . $theme_key . '_settings'), array_merge($defaults, $settings));
    // Force refresh of Drupal internals.
    theme_get_setting('', TRUE);
}
/**
 * Sets the body-tag class attribute.
 *
 * Adds 'sidebar-left', 'sidebar-right' or 'sidebars' classes as needed.
 */
function phptemplate_body_class($left, $right)
{
コード例 #23
0
ファイル: Drupal6.php プロジェクト: acbramley/DrupalDriver
 /**
  * Expands properties on the given entity object to the expected structure.
  *
  * @param \stdClass $entity
  *   The entity object.
  */
 protected function expandEntityProperties(\stdClass $entity)
 {
     // The created field may come in as a readable date, rather than a
     // timestamp.
     if (isset($entity->created) && !is_numeric($entity->created)) {
         $entity->created = strtotime($entity->created);
     }
     // Map human-readable node types to machine node types.
     $types = node_get_types();
     foreach ($types as $type) {
         if ($entity->type == $type->name) {
             $entity->type = $type->type;
             continue;
         }
     }
 }
コード例 #24
0
ファイル: quotes.inc.php プロジェクト: itorres/drupal-budgets
function budgets_quote_form(&$node, &$param)
{
    $type = node_get_types('type', $node);
    if (!empty($param['values'])) {
        $node = (object) $param['values'];
    }
    guifi_log(GUIFILOG_TRACE, 'function budgets_quote_form()', $node);
    $type = node_get_types('type', $node);
    if ($type->has_title) {
        $form['title'] = array('#type' => 'textfield', '#title' => check_plain($type->title_label), '#required' => TRUE, '#default_value' => $node->title);
    }
    if (isset($node->supplier)) {
        $form['supplier'] = array('#type' => 'textfield', '#required' => TRUE, '#title' => t('Supplier'), '#description' => t('Supplier for this quote.'), '#default_value' => $node->supplier, '#autocomplete_path' => 'budgets/js/select-supplier');
    } else {
        $suppliers = array();
        $qsup = db_query('SELECT id, title ' . 'FROM {supplier} ' . 'ORDER BY title');
        while ($sup = db_fetch_object($qsup)) {
            if (!user_access('administer suppliers')) {
                if (budgets_supplier_access('update', $sup->id)) {
                    $suppliers[$sup->id] = $sup->title;
                }
            } else {
                $suppliers[$sup->id] = $sup->title;
            }
        }
        $form['supplier_id'] = array('#type' => 'select', '#required' => TRUE, '#title' => t('Supplier'), '#description' => t('Supplier for this quote.'), '#default_value' => $node->supplier_id, '#options' => $suppliers);
    }
    /*
     * Quote Properties
     */
    $form['props'] = array('#type' => 'fieldset', '#title' => t('Quote properties'), '#collapsible' => false, '#collapsed' => false, '#tree' => false, '#attributes' => array('class' => 'quote'));
    $form['props']['partno'] = array('#type' => 'textfield', '#required' => TRUE, '#size' => 60, '#maxlength' => 60, '#title' => t('Part number'), '#description' => t('Part number/Code to identify this quote.'), '#default_value' => $node->partno);
    $form['props']['tax'] = array('#type' => 'textfield', '#title' => t('Tax'), '#size' => 3, '#required' => TRUE, '#maxlength' => 3, '#attributes' => array('' . 'class' => 'number required', 'min' => 0), '#default_value' => $node->tax, '#description' => t('Tax (%) to be applied to this quote.<br> 0 means tax included'));
    $form['props']['cost'] = array('#type' => 'textfield', '#title' => t('Cost'), '#size' => 12, '#required' => TRUE, '#maxlength' => 15, '#attributes' => array('' . 'class' => 'number required', 'min' => 1), '#default_value' => $node->cost, '#description' => t('Quoted value (cost) for this quoted item.'));
    $form['props']['arrexpires'] = array('#type' => 'date', '#title' => t('Expiration'), '#default_value' => $node->arrexpires, '#description' => t("Date when this quote will expire"), '#required' => TRUE);
    if ($type->has_body) {
        $form['body_field'] = node_body_field($node, $type->body_label, $type->min_word_count);
    }
    return $form;
}
コード例 #25
0
ファイル: template.php プロジェクト: 10corp/lullacog
/**
 * Format the "Submitted by username on date/time" for each node
 *
 * @ingroup themeable
 */
function lullacog_node_submitted($node, $date = NULL)
{
    $teaser = isset($node->teaser) && $node->teaser;
    $output = '';
    if ($teaser) {
        $date = is_null($date) ? format_date($node->created, 'small') : $date;
        $output .= '<span class="username">' . t('By !username', array('!username' => theme('username', $node))) . '</span>';
    } else {
        $date = is_null($date) ? format_date($node->created, 'medium') : $date;
        $output .= '<span class="username">' . t('@type by !username', array('@type' => node_get_types('name', $node), '!username' => theme('username', $node))) . '</span>';
    }
    $output .= '<span class="submitted">' . $date . '</span>';
    if ($teaser) {
        $path = NULL;
        switch ($node->type) {
            case 'lblog':
            case 'news':
                $path = 'ideas/blog';
                break;
            case 'audio':
                $path = 'ideas/podcasts';
                break;
            case 'video':
                $path = 'ideas/videocasts';
                break;
        }
        $type = node_get_types('name', $node);
        $output .= '<span class="type">' . ($path ? l($type, $path) : $type) . '</span>';
        if ($node->comment_count) {
            $output .= '<span class="comments"><a href="' . url('node/' . $node->nid, array('fragment' => 'comments')) . '">' . format_plural($node->comment_count, '@count comment', '@count comments') . '</a></span>';
        }
    }
    return $output;
}
コード例 #26
0
ファイル: node.api.php プロジェクト: rolfington/drupal
/**
 * Display a node editing form.
 *
 * This hook, implemented by node modules, is called to retrieve the form
 * that is displayed when one attempts to "create/edit" an item. This form is
 * displayed at the URI http://www.example.com/?q=node/<add|edit>/nodetype.
 *
 * @param &$node
 *   The node being added or edited.
 * @param $form_state
 *   The form state array. Changes made to this variable will have no effect.
 * @return
 *   An array containing the form elements to be displayed in the node
 *   edit form.
 *
 * The submit and preview buttons, taxonomy controls, and administrative
 * accoutrements are displayed automatically by node.module. This hook
 * needs to return the node title, the body text area, and fields
 * specific to the node type.
 *
 * For a detailed usage example, see node_example.module.
 */
function hook_form(&$node, $form_state)
{
    $type = node_get_types('type', $node);
    $form['title'] = array('#type' => 'textfield', '#title' => check_plain($type->title_label), '#required' => TRUE);
    $form['body'] = array('#type' => 'textarea', '#title' => check_plain($type->body_label), '#rows' => 20, '#required' => TRUE);
    $form['field1'] = array('#type' => 'textfield', '#title' => t('Custom field'), '#default_value' => $node->field1, '#maxlength' => 127);
    $form['selectbox'] = array('#type' => 'select', '#title' => t('Select box'), '#default_value' => $node->selectbox, '#options' => array(1 => 'Option A', 2 => 'Option B', 3 => 'Option C'), '#description' => t('Please choose an option.'));
    return $form;
}
コード例 #27
0
/**
* Implementation of THEMEHOOK_settings() function.
*
* @param $saved_settings
*   array An array of saved settings for this theme.
* @return
*   array A form array.
*/
function phptemplate_settings($saved_settings)
{
    // Only open one of the general or node setting fieldsets at a time
    $js = <<<SCRIPT
    \$(document).ready(function(){
      \$("fieldset.general_settings > legend > a").click(function(){
      \tif(!\$("fieldset.node_settings").hasClass("collapsed")) {
          Drupal.toggleFieldset(\$("fieldset.node_settings"));
      \t}
      });
      \$("fieldset.node_settings > legend > a").click(function(){
      \tif (!\$("fieldset.general_settings").hasClass("collapsed")) {
          Drupal.toggleFieldset(\$("fieldset.general_settings"));
      \t}
      });
    });
SCRIPT;
    drupal_add_js($js, 'inline');
    // Get the node types
    $node_types = node_get_types('names');
    /**
     * The default values for the theme variables. Make sure $defaults exactly
     * matches the $defaults in the template.php file.
     */
    $defaults = array('user_notverified_display' => 1, 'breadcrumb_display' => 0, 'search_snippet' => 1, 'search_info_type' => 1, 'search_info_user' => 1, 'search_info_date' => 1, 'search_info_comment' => 1, 'search_info_upload' => 1, 'mission_statement_pages' => 'home', 'front_page_title_display' => 'title_slogan', 'page_title_display_custom' => '', 'other_page_title_display' => 'ptitle_slogan', 'other_page_title_display_custom' => '', 'configurable_separator' => ' | ', 'meta_keywords' => '', 'meta_description' => '', 'taxonomy_display_default' => 'only', 'taxonomy_format_default' => 'vocab', 'taxonomy_enable_content_type' => 0, 'submitted_by_author_default' => 1, 'submitted_by_date_default' => 1, 'submitted_by_enable_content_type' => 0, 'readmore_default' => t('Read more'), 'readmore_title_default' => t('Read the rest of this posting.'), 'readmore_prefix_default' => '', 'readmore_suffix_default' => '', 'readmore_enable_content_type' => 0, 'comment_singular_default' => t('1 comment'), 'comment_plural_default' => t('@count comments'), 'comment_title_default' => t('Jump to the first comment of this posting.'), 'comment_prefix_default' => '', 'comment_suffix_default' => '', 'comment_new_singular_default' => t('1 new comment'), 'comment_new_plural_default' => t('@count new comments'), 'comment_new_title_default' => t('Jump to the first new comment of this posting.'), 'comment_new_prefix_default' => '', 'comment_new_suffix_default' => '', 'comment_add_default' => t('Add new comment'), 'comment_add_title_default' => t('Add a new comment to this page.'), 'comment_add_prefix_default' => '', 'comment_add_suffix_default' => '', 'comment_node_default' => t('Add new comment'), 'comment_node_title_default' => t('Share your thoughts and opinions related to this posting.'), 'comment_node_prefix_default' => '', 'comment_node_suffix_default' => '', 'comment_enable_content_type' => 0, 'rebuild_registry' => 0);
    // Make the default content-type settings the same as the default theme settings,
    // so we can tell if content-type-specific settings have been altered.
    $defaults = array_merge($defaults, theme_get_settings());
    // Set the default values for content-type-specific settings
    foreach ($node_types as $type => $name) {
        $defaults["taxonomy_display_{$type}"] = $defaults['taxonomy_display_default'];
        $defaults["taxonomy_format_{$type}"] = $defaults['taxonomy_format_default'];
        $defaults["submitted_by_author_{$type}"] = $defaults['submitted_by_author_default'];
        $defaults["submitted_by_date_{$type}"] = $defaults['submitted_by_date_default'];
        $defaults["readmore_{$type}"] = $defaults['readmore_default'];
        $defaults["readmore_title_{$type}"] = $defaults['readmore_title_default'];
        $defaults["readmore_prefix_{$type}"] = $defaults['readmore_prefix_default'];
        $defaults["readmore_suffix_{$type}"] = $defaults['readmore_suffix_default'];
        $defaults["comment_singular_{$type}"] = $defaults['comment_singular_default'];
        $defaults["comment_plural_{$type}"] = $defaults['comment_plural_default'];
        $defaults["comment_title_{$type}"] = $defaults['comment_title_default'];
        $defaults["comment_prefix_{$type}"] = $defaults['comment_prefix_default'];
        $defaults["comment_suffix_{$type}"] = $defaults['comment_suffix_default'];
        $defaults["comment_new_singular_{$type}"] = $defaults['comment_new_singular_default'];
        $defaults["comment_new_plural_{$type}"] = $defaults['comment_new_plural_default'];
        $defaults["comment_new_title_{$type}"] = $defaults['comment_new_title_default'];
        $defaults["comment_new_prefix_{$type}"] = $defaults['comment_new_prefix_default'];
        $defaults["comment_new_suffix_{$type}"] = $defaults['comment_new_suffix_default'];
        $defaults["comment_add_{$type}"] = $defaults['comment_add_default'];
        $defaults["comment_add_title_{$type}"] = $defaults['comment_add_title_default'];
        $defaults["comment_add_prefix_{$type}"] = $defaults['comment_add_prefix_default'];
        $defaults["comment_add_suffix_{$type}"] = $defaults['comment_add_suffix_default'];
        $defaults["comment_node_{$type}"] = $defaults['comment_node_default'];
        $defaults["comment_node_title_{$type}"] = $defaults['comment_node_title_default'];
        $defaults["comment_node_prefix_{$type}"] = $defaults['comment_node_prefix_default'];
        $defaults["comment_node_suffix_{$type}"] = $defaults['comment_node_suffix_default'];
    }
    // Merge the saved variables and their default values
    $settings = array_merge($defaults, $saved_settings);
    // If content type-specifc settings are not enabled, reset the values
    if ($settings['readmore_enable_content_type'] == 0) {
        foreach ($node_types as $type => $name) {
            $settings["readmore_{$type}"] = $settings['readmore_default'];
            $settings["readmore_title_{$type}"] = $settings['readmore_title_default'];
            $settings["readmore_prefix_{$type}"] = $settings['readmore_prefix_default'];
            $settings["readmore_suffix_{$type}"] = $settings['readmore_suffix_default'];
        }
    }
    if ($settings['comment_enable_content_type'] == 0) {
        foreach ($node_types as $type => $name) {
            $defaults["comment_singular_{$type}"] = $defaults['comment_singular_default'];
            $defaults["comment_plural_{$type}"] = $defaults['comment_plural_default'];
            $defaults["comment_title_{$type}"] = $defaults['comment_title_default'];
            $defaults["comment_prefix_{$type}"] = $defaults['comment_prefix_default'];
            $defaults["comment_suffix_{$type}"] = $defaults['comment_suffix_default'];
            $defaults["comment_new_singular_{$type}"] = $defaults['comment_new_singular_default'];
            $defaults["comment_new_plural_{$type}"] = $defaults['comment_new_plural_default'];
            $defaults["comment_new_title_{$type}"] = $defaults['comment_new_title_default'];
            $defaults["comment_new_prefix_{$type}"] = $defaults['comment_new_prefix_default'];
            $defaults["comment_new_suffix_{$type}"] = $defaults['comment_new_suffix_default'];
            $defaults["comment_add_{$type}"] = $defaults['comment_add_default'];
            $defaults["comment_add_title_{$type}"] = $defaults['comment_add_title_default'];
            $defaults["comment_add_prefix_{$type}"] = $defaults['comment_add_prefix_default'];
            $defaults["comment_add_suffix_{$type}"] = $defaults['comment_add_suffix_default'];
            $defaults["comment_node_{$type}"] = $defaults['comment_node_default'];
            $defaults["comment_node_title_{$type}"] = $defaults['comment_node_title_default'];
            $defaults["comment_node_prefix_{$type}"] = $defaults['comment_node_prefix_default'];
            $defaults["comment_node_suffix_{$type}"] = $defaults['comment_node_suffix_default'];
        }
    }
    // Create theme settings form widgets using Forms API
    // TNT Fieldset
    $form['tnt_container'] = array('#type' => 'fieldset', '#title' => t('Acquia Slate settings'), '#description' => t('Use these settings to change what and how information is displayed in your theme.'), '#collapsible' => TRUE, '#collapsed' => false);
    // General Settings
    $form['tnt_container']['general_settings'] = array('#type' => 'fieldset', '#title' => t('General settings'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#attributes' => array('class' => 'general_settings'));
    // Breadcrumb
    $form['tnt_container']['general_settings']['breadcrumb'] = array('#type' => 'fieldset', '#title' => t('Breadcrumb'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['tnt_container']['general_settings']['breadcrumb']['breadcrumb_display'] = array('#type' => 'checkbox', '#title' => t('Display breadcrumb'), '#default_value' => $settings['breadcrumb_display']);
    // Username
    $form['tnt_container']['general_settings']['username'] = array('#type' => 'fieldset', '#title' => t('Username'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['tnt_container']['general_settings']['username']['user_notverified_display'] = array('#type' => 'checkbox', '#title' => t('Display "not verified" for unregistered usernames'), '#default_value' => $settings['user_notverified_display']);
    // Search Settings
    if (module_exists('search')) {
        $form['tnt_container']['general_settings']['search_container'] = array('#type' => 'fieldset', '#title' => t('Search results'), '#description' => t('What additional information should be displayed on your search results page?'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['tnt_container']['general_settings']['search_container']['search_results']['search_snippet'] = array('#type' => 'checkbox', '#title' => t('Display text snippet'), '#default_value' => $settings['search_snippet']);
        $form['tnt_container']['general_settings']['search_container']['search_results']['search_info_type'] = array('#type' => 'checkbox', '#title' => t('Display content type'), '#default_value' => $settings['search_info_type']);
        $form['tnt_container']['general_settings']['search_container']['search_results']['search_info_user'] = array('#type' => 'checkbox', '#title' => t('Display author name'), '#default_value' => $settings['search_info_user']);
        $form['tnt_container']['general_settings']['search_container']['search_results']['search_info_date'] = array('#type' => 'checkbox', '#title' => t('Display posted date'), '#default_value' => $settings['search_info_date']);
        $form['tnt_container']['general_settings']['search_container']['search_results']['search_info_comment'] = array('#type' => 'checkbox', '#title' => t('Display comment count'), '#default_value' => $settings['search_info_comment']);
        $form['tnt_container']['general_settings']['search_container']['search_results']['search_info_upload'] = array('#type' => 'checkbox', '#title' => t('Display attachment count'), '#default_value' => $settings['search_info_upload']);
    }
    // Node Settings
    $form['tnt_container']['node_type_specific'] = array('#type' => 'fieldset', '#title' => t('Node settings'), '#description' => t('Here you can make adjustments to which information is shown with your content, and how it is displayed.  You can modify these settings so they apply to all content types, or check the "Use content-type specific settings" box to customize them for each content type.  For example, you may want to show the date on stories, but not pages.'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#attributes' => array('class' => 'node_settings'));
    // Author & Date Settings
    $form['tnt_container']['node_type_specific']['submitted_by_container'] = array('#type' => 'fieldset', '#title' => t('Author & date'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    // Default & content-type specific settings
    if (module_exists('submitted_by') == FALSE) {
        foreach (array('default' => 'Default') + node_get_types('names') as $type => $name) {
            $form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by'][$type] = array('#type' => 'fieldset', '#title' => t('!name', array('!name' => t($name))), '#collapsible' => TRUE, '#collapsed' => TRUE);
            $form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by'][$type]["submitted_by_author_{$type}"] = array('#type' => 'checkbox', '#title' => t('Display author\'s username'), '#default_value' => $settings["submitted_by_author_{$type}"]);
            $form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by'][$type]["submitted_by_date_{$type}"] = array('#type' => 'checkbox', '#title' => t('Display date posted (you can customize this format on your Date and Time settings page)'), '#default_value' => $settings["submitted_by_date_{$type}"]);
            // Options for default settings
            if ($type == 'default') {
                $form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by']['default']['#title'] = t('Default');
                $form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by']['default']['#collapsed'] = $settings['submitted_by_enable_content_type'] ? TRUE : FALSE;
                $form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by']['submitted_by_enable_content_type'] = array('#type' => 'checkbox', '#title' => t('Use custom settings for each content type instead of the default above'), '#default_value' => $settings['submitted_by_enable_content_type']);
            } else {
                if ($settings['submitted_by_enable_content_type'] == 0) {
                    $form['submitted_by'][$type]['#collapsed'] = TRUE;
                }
            }
        }
    } else {
        $form['tnt_container']['node_type_specific']['submitted_by_container']['#description'] = 'NOTICE: You currently have the "Submitted By" module installed and enabled, so the Author & Date theme settings have been disabled to prevent conflicts.  If you wish to re-enable the Author & Date theme settings, you must first disable the "Submitted By" module.';
    }
    // Taxonomy Settings
    if (module_exists('taxonomy')) {
        $form['tnt_container']['node_type_specific']['display_taxonomy_container'] = array('#type' => 'fieldset', '#title' => t('Taxonomy terms'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        // Default & content-type specific settings
        foreach (array('default' => 'Default') + node_get_types('names') as $type => $name) {
            // taxonomy display per node
            $form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy'][$type] = array('#type' => 'fieldset', '#title' => t('!name', array('!name' => t($name))), '#collapsible' => TRUE, '#collapsed' => TRUE);
            // display
            $form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy'][$type]["taxonomy_display_{$type}"] = array('#type' => 'select', '#title' => t('When should taxonomy terms be displayed?'), '#default_value' => $settings["taxonomy_display_{$type}"], '#options' => array('' => '', 'never' => t('Never display taxonomy terms'), 'all' => t('Always display taxonomy terms'), 'only' => t('Only display taxonomy terms on full node pages')));
            // format
            $form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy'][$type]["taxonomy_format_{$type}"] = array('#type' => 'radios', '#title' => t('Taxonomy display format'), '#default_value' => $settings["taxonomy_format_{$type}"], '#options' => array('vocab' => t('Display each vocabulary on a new line'), 'list' => t('Display all taxonomy terms together in single list')));
            // Get taxonomy vocabularies by node type
            $vocabs = array();
            $vocabs_by_type = $type == 'default' ? taxonomy_get_vocabularies() : taxonomy_get_vocabularies($type);
            foreach ($vocabs_by_type as $key => $value) {
                $vocabs[$value->vid] = $value->name;
            }
            // Display taxonomy checkboxes
            foreach ($vocabs as $key => $vocab_name) {
                $form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy'][$type]["taxonomy_vocab_hide_{$type}_{$key}"] = array('#type' => 'checkbox', '#title' => t('Hide vocabulary: ' . $vocab_name), '#default_value' => $settings["taxonomy_vocab_hide_{$type}_{$key}"]);
            }
            // Options for default settings
            if ($type == 'default') {
                $form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy']['default']['#title'] = t('Default');
                $form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy']['default']['#collapsed'] = $settings['taxonomy_enable_content_type'] ? TRUE : FALSE;
                $form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy']['taxonomy_enable_content_type'] = array('#type' => 'checkbox', '#title' => t('Use custom settings for each content type instead of the default above'), '#default_value' => $settings['taxonomy_enable_content_type']);
            } else {
                if ($settings['taxonomy_enable_content_type'] == 0) {
                    $form['display_taxonomy'][$type]['#collapsed'] = TRUE;
                }
            }
        }
    }
    // Read More & Comment Link Settings
    $form['tnt_container']['node_type_specific']['link_settings'] = array('#type' => 'fieldset', '#title' => t('Links'), '#description' => t('Customize the text of node links'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    // Read more link settings
    $form['tnt_container']['node_type_specific']['link_settings']['readmore'] = array('#type' => 'fieldset', '#title' => t('"Read more"'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    // Default & content-type specific settings
    foreach (array('default' => 'Default') + node_get_types('names') as $type => $name) {
        // Read more
        $form['tnt_container']['node_type_specific']['link_settings']['readmore'][$type] = array('#type' => 'fieldset', '#title' => t('!name', array('!name' => t($name))), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['tnt_container']['node_type_specific']['link_settings']['readmore'][$type]["readmore_{$type}"] = array('#type' => 'textfield', '#title' => t('Link text'), '#default_value' => $settings["readmore_{$type}"], '#description' => t('HTML is allowed.'));
        $form['tnt_container']['node_type_specific']['link_settings']['readmore'][$type]["readmore_title_{$type}"] = array('#type' => 'textfield', '#title' => t('Title text (tool tip)'), '#default_value' => $settings["readmore_title_{$type}"], '#description' => t('Displayed when hovering over link. Plain text only.'));
        $form['tnt_container']['node_type_specific']['link_settings']['readmore'][$type]["readmore_prefix_{$type}"] = array('#type' => 'textfield', '#title' => t('Prefix'), '#default_value' => $settings["readmore_prefix_{$type}"], '#description' => t('Text or HTML placed before the link.'));
        $form['tnt_container']['node_type_specific']['link_settings']['readmore'][$type]["readmore_suffix_{$type}"] = array('#type' => 'textfield', '#title' => t('Suffix'), '#default_value' => $settings["readmore_suffix_{$type}"], '#description' => t('Text or HTML placed after the link.'));
        // Options for default settings
        if ($type == 'default') {
            $form['tnt_container']['node_type_specific']['link_settings']['readmore']['default']['#title'] = t('Default');
            $form['tnt_container']['node_type_specific']['link_settings']['readmore']['default']['#collapsed'] = $settings['readmore_enable_content_type'] ? TRUE : FALSE;
            $form['tnt_container']['node_type_specific']['link_settings']['readmore']['readmore_enable_content_type'] = array('#type' => 'checkbox', '#title' => t('Use custom settings for each content type instead of the default above'), '#default_value' => $settings['readmore_enable_content_type']);
        } else {
            if ($settings['readmore_enable_content_type'] == 0) {
                $form['readmore'][$type]['#collapsed'] = TRUE;
            }
        }
    }
    // Comments link settings
    $form['tnt_container']['node_type_specific']['link_settings']['comment'] = array('#type' => 'fieldset', '#title' => t('"Comment"'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    // Default & content-type specific settings
    foreach (array('default' => 'Default') + node_get_types('names') as $type => $name) {
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type] = array('#type' => 'fieldset', '#title' => t('!name', array('!name' => t($name))), '#collapsible' => TRUE, '#collapsed' => TRUE);
        // Full nodes
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['node'] = array('#type' => 'fieldset', '#title' => t('For full content'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['node']['add'] = array('#type' => 'fieldset', '#title' => t('"Add new comment" link'), '#description' => t('The link when the full content is being displayed.'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['node']['add']["comment_node_{$type}"] = array('#type' => 'textfield', '#title' => t('Link text'), '#default_value' => $settings["comment_node_{$type}"], '#description' => t('HTML is allowed.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['node']['add']["comment_node_title_{$type}"] = array('#type' => 'textfield', '#title' => t('Title text (tool tip)'), '#default_value' => $settings["comment_node_title_{$type}"], '#description' => t('Displayed when hovering over link. Plain text only.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['node']['add']['extra'] = array('#type' => 'fieldset', '#title' => t('Advanced'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['node']['add']['extra']["comment_node_prefix_{$type}"] = array('#type' => 'textfield', '#title' => t('Prefix'), '#default_value' => $settings["comment_node_prefix_{$type}"], '#description' => t('Text or HTML placed before the link.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['node']['add']['extra']["comment_node_suffix_{$type}"] = array('#type' => 'textfield', '#title' => t('Suffix'), '#default_value' => $settings["comment_node_suffix_{$type}"], '#description' => t('Text or HTML placed after the link.'));
        // Teasers
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser'] = array('#type' => 'fieldset', '#title' => t('For teasers'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['add'] = array('#type' => 'fieldset', '#title' => t('"Add new comment" link'), '#description' => t('The link when there are no comments.'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['add']["comment_add_{$type}"] = array('#type' => 'textfield', '#title' => t('Link text'), '#default_value' => $settings["comment_add_{$type}"], '#description' => t('HTML is allowed.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['add']["comment_add_title_{$type}"] = array('#type' => 'textfield', '#title' => t('Title text (tool tip)'), '#default_value' => $settings["comment_add_title_{$type}"], '#description' => t('Displayed when hovering over link. Plain text only.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['add']['extra'] = array('#type' => 'fieldset', '#title' => t('Advanced'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['add']['extra']["comment_add_prefix_{$type}"] = array('#type' => 'textfield', '#title' => t('Prefix'), '#default_value' => $settings["comment_add_prefix_{$type}"], '#description' => t('Text or HTML placed before the link.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['add']['extra']["comment_add_suffix_{$type}"] = array('#type' => 'textfield', '#title' => t('Suffix'), '#default_value' => $settings["comment_add_suffix_{$type}"], '#description' => t('Text or HTML placed after the link.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['standard'] = array('#type' => 'fieldset', '#title' => t('"Comments" link'), '#description' => t('The link when there are one or more comments.'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['standard']["comment_singular_{$type}"] = array('#type' => 'textfield', '#title' => t('Link text when there is 1 comment'), '#default_value' => $settings["comment_singular_{$type}"], '#description' => t('HTML is allowed.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['standard']["comment_plural_{$type}"] = array('#type' => 'textfield', '#title' => t('Link text when there are multiple comments'), '#default_value' => $settings["comment_plural_{$type}"], '#description' => t('HTML is allowed. @count will be replaced with the number of comments.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['standard']["comment_title_{$type}"] = array('#type' => 'textfield', '#title' => t('Title text (tool tip)'), '#default_value' => $settings["comment_title_{$type}"], '#description' => t('Displayed when hovering over link. Plain text only.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['standard']['extra'] = array('#type' => 'fieldset', '#title' => t('Advanced'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['standard']['extra']["comment_prefix_{$type}"] = array('#type' => 'textfield', '#title' => t('Prefix'), '#default_value' => $settings["comment_prefix_{$type}"], '#description' => t('Text or HTML placed before the link.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['standard']['extra']["comment_suffix_{$type}"] = array('#type' => 'textfield', '#title' => t('Suffix'), '#default_value' => $settings["comment_suffix_{$type}"], '#description' => t('Text or HTML placed after the link.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['new'] = array('#type' => 'fieldset', '#title' => t('"New comments" link'), '#description' => t('The link when there are one or more new comments.'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['new']["comment_new_singular_{$type}"] = array('#type' => 'textfield', '#title' => t('Link text when there is 1 new comment'), '#default_value' => $settings["comment_new_singular_{$type}"], '#description' => t('HTML is allowed.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['new']["comment_new_plural_{$type}"] = array('#type' => 'textfield', '#title' => t('Link text when there are multiple new comments'), '#default_value' => $settings["comment_new_plural_{$type}"], '#description' => t('HTML is allowed. @count will be replaced with the number of comments.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['new']["comment_new_title_{$type}"] = array('#type' => 'textfield', '#title' => t('Title text (tool tip)'), '#default_value' => $settings["comment_new_title_{$type}"], '#description' => t('Displayed when hovering over link. Plain text only.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['new']['extra'] = array('#type' => 'fieldset', '#title' => t('Advanced'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['new']['extra']["comment_new_prefix_{$type}"] = array('#type' => 'textfield', '#title' => t('Prefix'), '#default_value' => $settings["comment_new_prefix_{$type}"], '#description' => t('Text or HTML placed before the link.'));
        $form['tnt_container']['node_type_specific']['link_settings']['comment'][$type]['teaser']['new']['extra']["comment_new_suffix_{$type}"] = array('#type' => 'textfield', '#title' => t('Suffix'), '#default_value' => $settings["comment_new_suffix_{$type}"], '#description' => t('Text or HTML placed after the link.'));
        // Options for default settings
        if ($type == 'default') {
            $form['tnt_container']['node_type_specific']['link_settings']['comment']['default']['#title'] = t('Default');
            $form['tnt_container']['node_type_specific']['link_settings']['comment']['default']['#collapsed'] = $settings['comment_enable_content_type'] ? TRUE : FALSE;
            $form['tnt_container']['node_type_specific']['link_settings']['comment']['comment_enable_content_type'] = array('#type' => 'checkbox', '#title' => t('Use custom settings for each content type instead of the default above'), '#default_value' => $settings['comment_enable_content_type']);
        } else {
            if ($settings['comment_enable_content_type'] == 0) {
                $form['comment'][$type]['#collapsed'] = TRUE;
            }
        }
    }
    // SEO settings
    $form['tnt_container']['seo'] = array('#type' => 'fieldset', '#title' => t('Search engine optimization (SEO) settings'), '#collapsible' => TRUE, '#collapsed' => FALSE);
    // Page titles
    $form['tnt_container']['seo']['page_format_titles'] = array('#type' => 'fieldset', '#title' => t('Page titles'), '#description' => t('This is the title that displays in the title bar of your web browser. Your site title, slogan, and mission can all be set on your Site Information page. [NOTE: For more advanced page title functionality, consider using the "Page Title" module.  However, the Page titles theme settings do not work in combination with the "Page Title" module and will be disabled if you have it enabled.]'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    if (module_exists('page_title') == FALSE) {
        // front page title
        $form['tnt_container']['seo']['page_format_titles']['front_page_format_titles'] = array('#type' => 'fieldset', '#title' => t('Front page title'), '#description' => t('Your front page in particular should have important keywords for your site in the page title'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['tnt_container']['seo']['page_format_titles']['front_page_format_titles']['front_page_title_display'] = array('#type' => 'select', '#title' => t('Set text of front page title'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#default_value' => $settings['front_page_title_display'], '#options' => array('title_slogan' => t('Site title | Site slogan'), 'slogan_title' => t('Site slogan | Site title'), 'title_mission' => t('Site title | Site mission'), 'custom' => t('Custom (below)')));
        $form['tnt_container']['seo']['page_format_titles']['front_page_format_titles']['page_title_display_custom'] = array('#type' => 'textfield', '#title' => t('Custom'), '#size' => 60, '#default_value' => $settings['page_title_display_custom'], '#description' => t('Enter a custom page title for your front page'));
        // other pages title
        $form['tnt_container']['seo']['page_format_titles']['other_page_format_titles'] = array('#type' => 'fieldset', '#title' => t('Other page titles'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['tnt_container']['seo']['page_format_titles']['other_page_format_titles']['other_page_title_display'] = array('#type' => 'select', '#title' => t('Set text of other page titles'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#default_value' => $settings['other_page_title_display'], '#options' => array('ptitle_slogan' => t('Page title | Site slogan'), 'ptitle_stitle' => t('Page title | Site title'), 'ptitle_smission' => t('Page title | Site mission'), 'ptitle_custom' => t('Page title | Custom (below)'), 'custom' => t('Custom (below)')));
        $form['tnt_container']['seo']['page_format_titles']['other_page_format_titles']['other_page_title_display_custom'] = array('#type' => 'textfield', '#title' => t('Custom'), '#size' => 60, '#default_value' => $settings['other_page_title_display_custom'], '#description' => t('Enter a custom page title for all other pages'));
        // SEO configurable separator
        $form['tnt_container']['seo']['page_format_titles']['configurable_separator'] = array('#type' => 'textfield', '#title' => t('Title separator'), '#description' => t('Customize the separator character used in the page title'), '#size' => 60, '#default_value' => $settings['configurable_separator']);
    } else {
        $form['tnt_container']['seo']['page_format_titles']['#description'] = 'NOTICE: You currently have the "Page Title" module installed and enabled, so the Page titles theme settings have been disabled to prevent conflicts.  If you wish to re-enable the Page titles theme settings, you must first disable the "Page Title" module.';
        $form['tnt_container']['seo']['page_format_titles']['configurable_separator']['#disabled'] = 'disabled';
    }
    // Metadata
    $form['tnt_container']['seo']['meta'] = array('#type' => 'fieldset', '#title' => t('Meta tags'), '#description' => t('Meta tags are not used as much by search engines anymore, but the meta description is important: it will be shown as the description of your link in search engine results. [NOTE: For more advanced meta tag functionality, consider using the "Meta Tags (or nodewords)" module.  However, the Meta tags theme settings do not work in combination with the "Meta Tags" module and will be disabled if you have it enabled.]'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    if (module_exists('nodewords') == FALSE) {
        $form['tnt_container']['seo']['meta']['meta_keywords'] = array('#type' => 'textfield', '#title' => t('Meta keywords'), '#description' => t('Enter a comma-separated list of keywords'), '#size' => 60, '#default_value' => $settings['meta_keywords']);
        $form['tnt_container']['seo']['meta']['meta_description'] = array('#type' => 'textarea', '#title' => t('Meta description'), '#cols' => 60, '#rows' => 6, '#default_value' => $settings['meta_description']);
    } else {
        $form['tnt_container']['seo']['meta']['#description'] = 'NOTICE: You currently have the "Meta Tags (or nodewords)" module installed and enabled, so the Meta tags theme settings have been disabled to prevent conflicts.  If you wish to re-enable the Meta tags theme settings, you must first disable the "Meta Tags" module.';
        $form['tnt_container']['seo']['meta']['meta_keywords']['#disabled'] = 'disabled';
        $form['tnt_container']['seo']['meta']['meta_description']['#disabled'] = 'disabled';
    }
    // Development settings
    $form['tnt_container']['themedev'] = array('#type' => 'fieldset', '#title' => t('Theme development settings'), '#collapsible' => TRUE, '#collapsed' => $settings['rebuild_registry'] ? FALSE : TRUE);
    $form['tnt_container']['themedev']['rebuild_registry'] = array('#type' => 'checkbox', '#title' => t('Rebuild theme registry on every page.'), '#default_value' => $settings['rebuild_registry'], '#description' => t('During theme development, it can be very useful to continuously <a href="!link">rebuild the theme registry</a>. WARNING: this is a huge performance penalty and must be turned off on production websites.', array('!link' => 'http://drupal.org/node/173880#theme-registry')));
    // Return theme settings form
    return $form;
}
コード例 #28
0
 /**
  * Creates a node based on default settings. This uses the internal simpletest
  * browser, meaning the node will be owned by the current simpletest _browser user.
  *
  * Code modified from #212304.
  * This is mainly for testing for differences between node_save() and
  * submitting a node/add/* form.
  *
  * @param values
  *   An associative array of values to change from the defaults, keys are
  *   node properties, for example 'body' => 'Hello, world!'.
  * @return object Created node object.
  */
 function drupalCreateNodeViaForm($values = array())
 {
     $defaults = array('type' => 'page', 'title' => $this->randomName(8));
     $edit = $values + $defaults;
     if (empty($edit['body'])) {
         $content_type = db_fetch_array(db_query("select name, has_body from {node_type} where type='%s'", $edit['type']));
         if ($content_type['has_body']) {
             $edit['body'] = $this->randomName(32);
         }
     }
     $type = $edit['type'];
     unset($edit['type']);
     // Only used in URL.
     $this->flattenPostData($edit);
     // Added by me.
     $this->drupalPost('node/add/' . str_replace('_', '-', $type), $edit, t('Save'));
     $node = node_load(array('title' => $edit['title']));
     $this->assertRaw(t('@type %title has been created.', array('@type' => node_get_types('name', $node), '%title' => $edit['title'])), t('Node created successfully.'));
     return $node;
 }
コード例 #29
0
ファイル: template.php プロジェクト: noslokire/Project-206
/**
 * Read the theme settings' default values from the .info and save them into the database.
 *
 * @param $theme
 *   The actual name of theme that is being checked.
 */
function rootcandy_settings_init($theme)
{
    $themes = list_themes();
    // Get the default values from the .info file.
    $defaults = $themes[$theme]->info['settings'];
    // Get the theme settings saved in the database.
    $settings = theme_get_settings($theme);
    // Don't save the toggle_node_info_ variables.
    if (module_exists('node')) {
        foreach (node_get_types() as $type => $name) {
            unset($settings['toggle_node_info_' . $type]);
        }
    }
    // Save default theme settings.
    variable_set(str_replace('/', '_', 'theme_' . $theme . '_settings'), array_merge($defaults, $settings));
    // Force refresh of Drupal internals.
    theme_get_setting('', TRUE);
}
コード例 #30
0
ファイル: theme-settings.php プロジェクト: chgk/db.chgk.info
/**
* Implementation of THEMEHOOK_settings() function.
*
* @param $saved_settings
*   array An array of saved settings for this theme.
* @return
*   array A form array.
*/
function zeropoint_settings($saved_settings)
{
    global $base_url;
    // Retrieve & combine default and saved theme settings
    $defaults = zeropoint_default_theme_settings();
    $settings = array_merge($defaults, $saved_settings);
    // Create theme settings form widgets using Forms API
    // TNT Fieldset
    $form['tnt_container'] = array('#type' => 'fieldset', '#title' => t('Zero Point settings'), '#description' => t('Use these settings to change what and how information is displayed in your theme.'), '#collapsible' => TRUE, '#collapsed' => FALSE);
    // Layout Settings
    $form['tnt_container']['layout_settings'] = array('#type' => 'fieldset', '#title' => t('Layout settings'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#attributes' => array('class' => 'layout_settings'));
    $form['tnt_container']['layout_settings']['style'] = array('#type' => 'select', '#title' => t('Style'), '#default_value' => $settings['style'], '#options' => array('grey' => t('0 Point'), 'sky' => t('Sky'), 'nature' => t('Nature'), 'ivy' => t('Ivy'), 'ink' => t('Ink'), 'orange' => t('Orange'), 'sangue' => t('Sangue'), 'lime' => t('Lime'), 'themer' => t('- Themer -')));
    $form['tnt_container']['layout_settings']['layout-width'] = array('#type' => 'select', '#title' => t('Layout width'), '#default_value' => $settings['layout-width'], '#description' => t('<em>Fluid width</em> and <em>Fixed width</em> can be customized in _custom/custom-style.css.'), '#options' => array(0 => 'Adaptive width', 1 => 'Fluid width (custom)', 2 => 'Fixed width (custom)'));
    $form['tnt_container']['layout_settings']['sidebarslayout'] = array('#type' => 'select', '#title' => t('Sidebars layout'), '#default_value' => $settings['sidebarslayout'], '#description' => t('<b>Variable width sidebars (wide)</b>: If only one sidebar is enabled, content width is 250px for left sidebar and 300px for right sidebar. If both sidebars are enabled, content width is 160px for left sidebar and 234px for right sidebar. <br /> <b>Fixed width sidebars (wide)</b>: Content width is 160px for left sidebar and 234px for right sidebar. <br /> <em>Equal width sidebars</em> ca be customized in _custom/custom-style.css. For other details, please refer to readme.txt.'), '#options' => array(0 => 'Variable asyimmetrical sidebars (wide)', 1 => 'Fixed asyimmetrical sidebars (wide)', 2 => 'Variable asyimmetrical sidebars (narrow)', 3 => 'Fixed asyimmetrical sidebars (narrow)', 4 => 'Equal width sidebars (custom)'));
    $form['tnt_container']['layout_settings']['themedblocks'] = array('#type' => 'select', '#title' => t('Themed blocks'), '#default_value' => $settings['themedblocks'], '#options' => array(0 => 'Sidebars only', 1 => 'Sidebars + User regions'));
    $form['tnt_container']['layout_settings']['blockicons'] = array('#type' => 'select', '#title' => t('Block icons'), '#default_value' => $settings['blockicons'], '#options' => array(0 => 'No', 1 => 'Yes (32x32 pixels)', 2 => 'Yes (48x48 pixels)'));
    $form['tnt_container']['layout_settings']['pageicons'] = array('#type' => 'checkbox', '#title' => t('Page icons'), '#default_value' => $settings['pageicons']);
    $form['tnt_container']['layout_settings']['menutype'] = array('#type' => 'select', '#title' => t('Menu type'), '#default_value' => $settings['menutype'], '#description' => t('Choose "Drop Down" to enable support for Suckerfish drop down menus. <br /> NOTE: Go to <b><a href="/admin/build/menu">admin/build/menu</a></b> and expand all parents in primary menu.'), '#options' => array(0 => 'Static Menu', 1 => 'Drop Down Menu'));
    $form['tnt_container']['layout_settings']['navpos'] = array('#type' => 'select', '#title' => t('Menu position'), '#default_value' => $settings['navpos'], '#description' => t('NOTE: Only the static menu can be properly centered. <br /> NOTE for RTL sites: IE6 will accept only left positioned Drop-Down menu.'), '#options' => array(0 => 'Left', 1 => 'Center', 2 => 'Right'));
    $form['tnt_container']['layout_settings']['roundcorners'] = array('#type' => 'checkbox', '#title' => t('Rounded corners'), '#description' => t('Some page elements (mission, comments, search, blocks) and primary menu will have rounded corners in all browsers but IE. <br /> NOTE: With this option enabled 0 Point will not validate CSS2.'), '#default_value' => $settings['roundcorners']);
    $form['tnt_container']['layout_settings']['headerimg'] = array('#type' => 'checkbox', '#title' => t('Header image rotator'), '#description' => t('Rotates images in the _custom/headerimg folder.'), '#default_value' => $settings['headerimg']);
    $form['tnt_container']['layout_settings']['cssPreload'] = array('#type' => 'checkbox', '#title' => t('jQuery CSS image preload'), '#description' => t('Automatically Preload images from CSS.'), '#default_value' => $settings['cssPreload']);
    $form['tnt_container']['layout_settings']['loginlinks'] = array('#type' => 'checkbox', '#title' => t('0 Point login/register links'), '#default_value' => $settings['loginlinks']);
    // General Settings
    $form['tnt_container']['general_settings'] = array('#type' => 'fieldset', '#title' => t('General settings'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#attributes' => array('class' => 'general_settings'));
    // Mission Statement
    $form['tnt_container']['general_settings']['mission_statement'] = array('#type' => 'fieldset', '#title' => t('Mission statement'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['tnt_container']['general_settings']['mission_statement']['mission_statement_pages'] = array('#type' => 'radios', '#title' => t('Where should your mission statement be displayed?'), '#default_value' => $settings['mission_statement_pages'], '#options' => array('home' => t('Display mission statement only on front page'), 'all' => t('Display mission statement on all pages')));
    // Breadcrumb
    $form['tnt_container']['general_settings']['breadcrumb'] = array('#type' => 'fieldset', '#title' => t('Breadcrumb'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['tnt_container']['general_settings']['breadcrumb']['breadcrumb_display'] = array('#type' => 'checkbox', '#title' => t('Display breadcrumb'), '#default_value' => $settings['breadcrumb_display']);
    // Username
    $form['tnt_container']['general_settings']['username'] = array('#type' => 'fieldset', '#title' => t('Username'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['tnt_container']['general_settings']['username']['user_notverified_display'] = array('#type' => 'checkbox', '#title' => t('Display "not verified" for unregistered usernames'), '#default_value' => $settings['user_notverified_display']);
    // Search Settings
    if (module_exists('search')) {
        $form['tnt_container']['general_settings']['search_container'] = array('#type' => 'fieldset', '#title' => t('Search results'), '#description' => t('What additional information should be displayed on your search results page?'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['tnt_container']['general_settings']['search_container']['search_results']['search_snippet'] = array('#type' => 'checkbox', '#title' => t('Display text snippet'), '#default_value' => $settings['search_snippet']);
        $form['tnt_container']['general_settings']['search_container']['search_results']['search_info_type'] = array('#type' => 'checkbox', '#title' => t('Display content type'), '#default_value' => $settings['search_info_type']);
        $form['tnt_container']['general_settings']['search_container']['search_results']['search_info_user'] = array('#type' => 'checkbox', '#title' => t('Display author name'), '#default_value' => $settings['search_info_user']);
        $form['tnt_container']['general_settings']['search_container']['search_results']['search_info_date'] = array('#type' => 'checkbox', '#title' => t('Display posted date'), '#default_value' => $settings['search_info_date']);
        $form['tnt_container']['general_settings']['search_container']['search_results']['search_info_comment'] = array('#type' => 'checkbox', '#title' => t('Display comment count'), '#default_value' => $settings['search_info_comment']);
        $form['tnt_container']['general_settings']['search_container']['search_results']['search_info_upload'] = array('#type' => 'checkbox', '#title' => t('Display attachment count'), '#default_value' => $settings['search_info_upload']);
    }
    // Node Settings
    $form['tnt_container']['node_type_specific'] = array('#type' => 'fieldset', '#title' => t('Node settings'), '#description' => t('Here you can make adjustments to which information is shown with your content, and how it is displayed.  You can modify these settings so they apply to all content types, or check the "Use content-type specific settings" box to customize them for each content type.  For example, you may want to show the date on stories, but not pages.'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#attributes' => array('class' => 'node_settings'));
    // Author & Date Settings
    $form['tnt_container']['node_type_specific']['submitted_by_container'] = array('#type' => 'fieldset', '#title' => t('Author & date'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    // Default & content-type specific settings
    if (module_exists('submitted_by') == FALSE) {
        foreach (array('default' => 'Default') + node_get_types('names') as $type => $name) {
            $form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by'][$type] = array('#type' => 'fieldset', '#title' => t('!name', array('!name' => t($name))), '#collapsible' => TRUE, '#collapsed' => TRUE);
            $form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by'][$type]["submitted_by_author_{$type}"] = array('#type' => 'checkbox', '#title' => t('Display author\'s username'), '#default_value' => $settings["submitted_by_author_{$type}"]);
            $form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by'][$type]["submitted_by_date_{$type}"] = array('#type' => 'checkbox', '#title' => t('Display date posted (you can customize this format on your Date and Time settings page)'), '#default_value' => $settings["submitted_by_date_{$type}"]);
            // Options for default settings
            if ($type == 'default') {
                $form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by']['default']['#title'] = t('Default');
                $form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by']['default']['#collapsed'] = $settings['submitted_by_enable_content_type'] ? TRUE : FALSE;
                $form['tnt_container']['node_type_specific']['submitted_by_container']['submitted_by']['submitted_by_enable_content_type'] = array('#type' => 'checkbox', '#title' => t('Use custom settings for each content type instead of the default above'), '#default_value' => $settings['submitted_by_enable_content_type']);
            } else {
                if ($settings['submitted_by_enable_content_type'] == 0) {
                    $form['submitted_by'][$type]['#collapsed'] = TRUE;
                }
            }
        }
    } else {
        $form['tnt_container']['node_type_specific']['submitted_by_container']['#description'] = 'NOTICE: You currently have the "Submitted By" module installed and enabled, so the Author & Date theme settings have been disabled to prevent conflicts.  If you wish to re-enable the Author & Date theme settings, you must first disable the "Submitted By" module.';
    }
    // Taxonomy Settings
    if (module_exists('taxonomy')) {
        $form['tnt_container']['node_type_specific']['display_taxonomy_container'] = array('#type' => 'fieldset', '#title' => t('Taxonomy terms'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        // Default & content-type specific settings
        foreach (array('default' => 'Default') + node_get_types('names') as $type => $name) {
            // taxonomy display per node
            $form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy'][$type] = array('#type' => 'fieldset', '#title' => t('!name', array('!name' => t($name))), '#collapsible' => TRUE, '#collapsed' => TRUE);
            // display
            $form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy'][$type]["taxonomy_display_{$type}"] = array('#type' => 'select', '#title' => t('When should taxonomy terms be displayed?'), '#default_value' => $settings["taxonomy_display_{$type}"], '#options' => array('' => '', 'never' => t('Never display taxonomy terms'), 'all' => t('Always display taxonomy terms'), 'only' => t('Only display taxonomy terms on full node pages')));
            // format
            $form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy'][$type]["taxonomy_format_{$type}"] = array('#type' => 'radios', '#title' => t('Taxonomy display format'), '#default_value' => $settings["taxonomy_format_{$type}"], '#options' => array('vocab' => t('Display each vocabulary on a new line'), 'list' => t('Display all taxonomy terms together in single list')));
            // Get taxonomy vocabularies by node type
            $vocabs = array();
            $vocabs_by_type = $type == 'default' ? taxonomy_get_vocabularies() : taxonomy_get_vocabularies($type);
            foreach ($vocabs_by_type as $key => $value) {
                $vocabs[$value->vid] = $value->name;
            }
            // Display taxonomy checkboxes
            foreach ($vocabs as $key => $vocab_name) {
                $form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy'][$type]["taxonomy_vocab_hide_{$type}_{$key}"] = array('#type' => 'checkbox', '#title' => t('Hide vocabulary: @vocabulary', array('@vocabulary' => $vocab_name)), '#default_value' => $settings["taxonomy_vocab_hide_{$type}_{$key}"]);
            }
            // Options for default settings
            if ($type == 'default') {
                $form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy']['default']['#title'] = t('Default');
                $form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy']['default']['#collapsed'] = $settings['taxonomy_enable_content_type'] ? TRUE : FALSE;
                $form['tnt_container']['node_type_specific']['display_taxonomy_container']['display_taxonomy']['taxonomy_enable_content_type'] = array('#type' => 'checkbox', '#title' => t('Use custom settings for each content type instead of the default above'), '#default_value' => $settings['taxonomy_enable_content_type']);
            } else {
                if ($settings['taxonomy_enable_content_type'] == 0) {
                    $form['display_taxonomy'][$type]['#collapsed'] = TRUE;
                }
            }
        }
    }
    // SEO settings
    $form['tnt_container']['seo'] = array('#type' => 'fieldset', '#title' => t('Search engine optimization (SEO) settings'), '#collapsible' => TRUE, '#collapsed' => FALSE);
    // Page titles
    $form['tnt_container']['seo']['page_format_titles'] = array('#type' => 'fieldset', '#title' => t('Page titles'), '#description' => t('This is the title that displays in the title bar of your web browser. Your site title, slogan, and mission can all be set on your Site Information page. [NOTE: For more advanced page title functionality, consider using the "Page Title" module.  However, the Page titles theme settings do not work in combination with the "Page Title" module and will be disabled if you have it enabled.]'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    if (module_exists('page_title') == FALSE) {
        // front page title
        $form['tnt_container']['seo']['page_format_titles']['front_page_format_titles'] = array('#type' => 'fieldset', '#title' => t('Front page title'), '#description' => t('Your front page in particular should have important keywords for your site in the page title'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['tnt_container']['seo']['page_format_titles']['front_page_format_titles']['front_page_title_display'] = array('#type' => 'select', '#title' => t('Set text of front page title'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#default_value' => $settings['front_page_title_display'], '#options' => array('title_slogan' => t('Site title | Site slogan'), 'slogan_title' => t('Site slogan | Site title'), 'title_mission' => t('Site title | Site mission'), 'custom' => t('Custom (below)')));
        $form['tnt_container']['seo']['page_format_titles']['front_page_format_titles']['page_title_display_custom'] = array('#type' => 'textfield', '#title' => t('Custom'), '#size' => 60, '#default_value' => $settings['page_title_display_custom'], '#description' => t('Enter a custom page title for your front page'));
        // other pages title
        $form['tnt_container']['seo']['page_format_titles']['other_page_format_titles'] = array('#type' => 'fieldset', '#title' => t('Other page titles'), '#collapsible' => TRUE, '#collapsed' => TRUE);
        $form['tnt_container']['seo']['page_format_titles']['other_page_format_titles']['other_page_title_display'] = array('#type' => 'select', '#title' => t('Set text of other page titles'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#default_value' => $settings['other_page_title_display'], '#options' => array('ptitle_slogan' => t('Page title | Site slogan'), 'ptitle_stitle' => t('Page title | Site title'), 'ptitle_smission' => t('Page title | Site mission'), 'ptitle_custom' => t('Page title | Custom (below)'), 'custom' => t('Custom (below)')));
        $form['tnt_container']['seo']['page_format_titles']['other_page_format_titles']['other_page_title_display_custom'] = array('#type' => 'textfield', '#title' => t('Custom'), '#size' => 60, '#default_value' => $settings['other_page_title_display_custom'], '#description' => t('Enter a custom page title for all other pages'));
        // SEO configurable separator
        $form['tnt_container']['seo']['page_format_titles']['configurable_separator'] = array('#type' => 'textfield', '#title' => t('Title separator'), '#description' => t('Customize the separator character used in the page title'), '#size' => 60, '#default_value' => $settings['configurable_separator']);
    } else {
        $form['tnt_container']['seo']['page_format_titles']['#description'] = 'NOTICE: You currently have the "Page Title" module installed and enabled, so the Page titles theme settings have been disabled to prevent conflicts.  If you wish to re-enable the Page titles theme settings, you must first disable the "Page Title" module.';
        $form['tnt_container']['seo']['page_format_titles']['configurable_separator']['#disabled'] = 'disabled';
    }
    // Metadata
    $form['tnt_container']['seo']['meta'] = array('#type' => 'fieldset', '#title' => t('Meta tags'), '#description' => t('Meta tags are not used as much by search engines anymore, but the meta description is important: it will be shown as the description of your link in search engine results. [NOTE: For more advanced meta tag functionality, consider using the "Meta Tags (or nodewords)" module.  However, the Meta tags theme settings do not work in combination with the "Meta Tags" module and will be disabled if you have it enabled.]'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    if (module_exists('nodewords') == FALSE) {
        $form['tnt_container']['seo']['meta']['meta_keywords'] = array('#type' => 'textfield', '#title' => t('Meta keywords'), '#description' => t('Enter a comma-separated list of keywords'), '#size' => 60, '#default_value' => $settings['meta_keywords']);
        $form['tnt_container']['seo']['meta']['meta_description'] = array('#type' => 'textarea', '#title' => t('Meta description'), '#cols' => 60, '#rows' => 6, '#default_value' => $settings['meta_description']);
    } else {
        $form['tnt_container']['seo']['meta']['#description'] = 'NOTICE: You currently have the "Meta Tags (or nodewords)" module installed and enabled, so the Meta tags theme settings have been disabled to prevent conflicts.  If you wish to re-enable the Meta tags theme settings, you must first disable the "Meta Tags" module.';
        $form['tnt_container']['seo']['meta']['meta_keywords']['#disabled'] = 'disabled';
        $form['tnt_container']['seo']['meta']['meta_description']['#disabled'] = 'disabled';
    }
    // Development settings
    $form['tnt_container']['themedev'] = array('#type' => 'fieldset', '#title' => t('Theme development settings'), '#collapsible' => TRUE, '#collapsed' => $settings['rebuild_registry'] ? FALSE : TRUE);
    $form['tnt_container']['themedev']['siteid'] = array('#type' => 'textfield', '#title' => t('Site ID bodyclass.'), '#description' => t('In order to have different styles of 0 Point in a multisite environment you may find usefull to choose a "one word" site ID and customize the look of each site in custom-style.css file.'), '#default_value' => $settings['siteid'], '#size' => 10);
    $form['tnt_container']['themedev']['fix_css_limit'] = array('#type' => 'checkbox', '#title' => t('Fix IE stylesheet limit.'), '#default_value' => $settings['fix_css_limit'], '#description' => t('This setting groups css files so Internet Explorer can see more than 30 of them. This is useful when you cannot use aggregation (e.g., when developing or using private file downloads), especially for RTL sites. But because it degrades performance and can load files out of order, CSS aggregation (<a href="!link">Optimize CSS files</a>) is <b>strongly</b> recommended instead for any production website.', array('!link' => $base_url . '/admin/settings/performance')));
    $form['tnt_container']['themedev']['rebuild_registry'] = array('#type' => 'checkbox', '#title' => t('Rebuild theme registry on every page.'), '#default_value' => $settings['rebuild_registry'], '#description' => t('During theme development, it can be very useful to continuously rebuild the theme registry. WARNING: this is a huge performance penalty and must be turned off on production websites.', array('!link' => 'http://drupal.org/node/173880#theme-registry')));
    // Return theme settings form
    return $form;
}