Ejemplo n.º 1
0
/**
* Implementation of THEMEHOOK_settings() function.
*
* @param $saved_settings
*   array An array of saved settings for this theme.
* @return
*   array A form array.
*/
function layoutstudio_settings($saved_settings)
{
    // Add the form's CSS
    drupal_add_css(drupal_get_path('theme', 'layoutstudio') . '/css/theme-settings.css', 'theme');
    // add the form's js
    drupal_add_js(drupal_get_path('theme', 'layoutstudio') . "/js/theme-settings.js");
    /*
     * The default values for the theme variables.
     */
    $defaults = layoutstudio_theme_get_default_settings('layoutstudio');
    // Merge the saved variables and their default values
    $settings = array_merge($defaults, $saved_settings);
    // Create the form widgets using Forms API
    $form['layoutstudio_random_class'] = array('#type' => 'textfield', '#title' => t('Body and Block class from random-1 to n'), '#default_value' => $settings['layoutstudio_random_class'], '#description' => t('This random number will appear as a body/block class that can be used to make a site more dynamic with CSS. For example, can be useful for creating header with rotating images on refresh. <strong>Value needs to be greater than one.</strong>'), '#weight' => '-1');
    $form['layoutstudio_layouts'] = array('#type' => 'fieldset', '#title' => t('Select Layout'), '#description' => t('<p>Choose a site layout for the Primary, Secondary and Tertiary regions.<p>
      <p style="margin-bottom: 0;">Color reference for Primary, Secondary & Tertiary regions:</p>
      <ul class="color-reference layouts">
            <li class="primary-region">Primary</li>
            <li class="secondary-region">Secondary</li>
            <li class="tertiary-region">Tertiary</li>
      </ul class="color-reference">
    '), '#collapsible' => FALSE);
    $layout_path = drupal_get_path("theme", "MYTHEME") . "/css/layouts";
    $form['layoutstudio_layouts']['layoutstudio_layout'] = array('#type' => 'radios', '#options' => array("layout1" => t('<strong>Layout #1</strong>') . '<div class="layout-example layout-1"><div class="secondary-region"></div><div class="primary-region">1</div><div class="tertiary-region"></div></div>' . t('<p class="layout-type")>Three column layout with secondary on the left and tertiary on the right of the main content area.</p>'), "layout2" => t('<strong>Layout #2</strong>') . '<div class="layout-example layout-2"><div class="tertiary-region"></div><div class="primary-region">2</div><div class="secondary-region"></div></div>' . t('<p class="layout-type")>Three column layout with tertiary on the left and secondary on the right of the main content area.</p>'), "layout3" => t('<strong>Layout #3</strong>') . '<div class="layout-example layout-3"><div class="primary-region">3</div><div class="secondary-region"></div><div class="tertiary-region"></div></div>' . t('<p class="layout-type")>Three column layout with secondary and tertiary to the right of the main content area.</p>'), "layout4" => t('<strong>Layout #4</strong>') . '<div class="layout-example layout-4"><div class="primary-region">4</div><div class="tertiary-region"></div><div class="secondary-region"></div></div>' . t('<p class="layout-type")>Three column layout with tertiary and secondary to the right of the main content area.</p>'), "layout5" => t('<strong>Layout #5</strong>') . '<div class="layout-example layout-5"><div class="secondary-region"></div><div class="tertiary-region"></div><div class="primary-region">5</div></div>' . t('<p class="layout-type")>Three column layout with secondary and tertiary on the left of the main content area.</p>'), "layout6" => t('<strong>Layout #6</strong>') . '<div class="layout-example layout-6"><div class="tertiary-region"></div><div class="secondary-region"></div><div class="primary-region">6</div></div>' . t('<p class="layout-type")>Three column layout with tertiary and secondary on the left of the main content area.</p>'), "layout7" => t('<strong>Layout #7</strong>') . '<div class="layout-example layout-7"><div class="primary-region">7</div><div class="secondary-region"></div><div class="tertiary-region"></div></div>' . t('<p class="layout-type")>Secondary and tertiary as two columns below main content area.</p>'), "layout8" => t('<strong>Layout #8</strong>') . '<div class="layout-example layout-8"><div class="primary-region">8</div><div class="secondary-region"></div><div class="tertiary-region"></div></div>' . t('<p class="layout-type")>No columns. Primary, secondary and tertiary display full width in semantic order.</p>')), '#default_value' => $settings['layoutstudio_layout'], '#attributes' => array('class' => 'layouts'));
    $form['layoutstudio_960'] = array('#type' => 'fieldset', '#title' => t('960 Support'), '#description' => t('<p>Choose whether you would like to have <a href="http://960.gs/">960 grid system</a> support.'), '#collapsible' => TRUE, '#collapsed' => FALSE);
    $form['layoutstudio_960']['layoutstudio_960_columns'] = array('#type' => 'select', '#options' => array("None" => t('None'), "container_12" => t('12 Columns'), "container_16" => t('16 Columns'), "container_24" => t('24 Columns')), '#default_value' => $settings['layoutstudio_960_columns'], '#attributes' => array('class' => 'layouts'));
    $ninesixyopts = layoutstudio_theme_get_960_options();
    drupal_add_js(array('layoutstudioThemeSettings960opts' => $ninesixyopts), 'setting');
    if (isset($settings['layoutstudio_960_columns'])) {
        $cols = ltrim($settings['layoutstudio_960_columns'], 'container_');
        if (is_numeric($cols)) {
            drupal_add_js(array('layoutstudioThemeSettings960optsDefault' => $cols), 'setting');
        }
    }
    $form['layoutstudio_dimensions'] = array('#type' => 'fieldset', '#title' => t('Set Dimensions'), '#description' => t('<p>Choose dimensions for a Page and for the Secondary and Tertiary regions of the site.'), '#collapsible' => TRUE, '#collapsed' => FALSE);
    $form['layoutstudio_dimensions']['layoutstudio_page_width'] = array('#type' => 'textfield', '#title' => t('Page width'), '#description' => t('Enter the desired width of the page, in pixels.'), '#required' => TRUE, '#size' => 5, '#default_value' => $settings['layoutstudio_page_width'], '#field_suffix' => t('px'));
    $form['layoutstudio_dimensions']['layoutstudio_secondary_width'] = array('#type' => 'textfield', '#title' => t('Secondary region width'), '#description' => t('Enter the desired width of the Secondary region, in pixels.'), '#required' => FALSE, '#size' => 5, '#default_value' => $settings['layoutstudio_secondary_width'], '#field_suffix' => t('px'));
    $form['layoutstudio_dimensions']['layoutstudio_tertiary_width'] = array('#type' => 'textfield', '#title' => t('Tertiary region width'), '#description' => t('Enter the desired width of the Tertiary region, in pixels.'), '#required' => FALSE, '#size' => 5, '#default_value' => $settings['layoutstudio_tertiary_width'], '#field_suffix' => t('px'));
    $form['layoutstudio_header_footer'] = array('#type' => 'fieldset', '#title' => t('Header & Footer width'), '#description' => t('<p>Choose if you want the header and footer to take up the entire width of the browser window.'), '#collapsible' => TRUE, '#collapsed' => FALSE);
    $form['layoutstudio_header_footer']['layoutstudio_header_width'] = array('#type' => 'checkbox', '#title' => t('Make header take full browser width'), '#required' => FALSE, '#default_value' => $settings['layoutstudio_header_width']);
    $form['layoutstudio_header_footer']['layoutstudio_footer_width'] = array('#type' => 'checkbox', '#title' => t('Make footer take full browser width'), '#required' => FALSE, '#default_value' => $settings['layoutstudio_footer_width']);
    $form['layoutstudio_breadcrumb'] = array('#type' => 'fieldset', '#title' => t('Breadcrumb Settings'), '#description' => t('<p>Enable / Disable and choose what region to display it in.</p>'), '#collapsible' => TRUE, '#collapsed' => FALSE);
    $form['layoutstudio_breadcrumb']['layoutstudio_enable_breadcrumb'] = array('#type' => 'checkbox', '#title' => t('Enable Breadcrumb'), '#default_value' => isset($settings['layoutstudio_enable_breadcrumb']) ? $settings['layoutstudio_enable_breadcrumb'] : 1);
    $regions = array('header' => t('Header'), 'preface_first' => t('Preface First'), 'preface' => t('Preface Middle'), 'preface_last' => t('Preface Last'), 'content_pre_title' => t('Primary Pre-title'), 'content_post_title' => t('Primary Post-title'), 'content' => t('Primary'), 'secondary_first' => t('Secondary First'), 'secondary' => t('Secondary Middle'), 'secondary_last' => t('Secondary Last'), 'tertiary_first' => t('Tertiary First'), 'tertiary' => t('Tertiary Middle'), 'tertiary_last' => t('Tertiary Last'), 'postscript_first' => t('Postscript First'), 'postscript' => t('Postscript Middle'), 'postscript_last' => t('Postscript Last'), 'navigation' => t('Navigation'), 'footer' => t('Footer'), 'closure_region' => t('Closure'));
    $form['layoutstudio_breadcrumb']['layoutstudio_breadcrumb_region'] = array('#type' => 'select', '#title' => t('Region to display breadcrumb in'), '#multiple' => FALSE, '#description' => t('Select a region'), '#options' => $regions, '#default_value' => $settings['layoutstudio_breadcrumb_region']);
    $form['layoutstudio_breadcrumb']['layoutstudio_breadcrumb_region_placement'] = array('#type' => 'select', '#title' => t('Postion in region to put breadcrumb'), '#multiple' => FALSE, '#description' => t('Top or bottom of the region'), '#options' => array('top' => 'Top', 'bottom' => 'Bottom'), '#default_value' => $settings['layoutstudio_breadcrumb_region_placement']);
    // Return the additional form widgets
    return $form;
}
Ejemplo n.º 2
0
/**
 * Implementation of THEMEHOOK_settings() function.
 *
 * @param $saved_settings
 *   An array of saved settings for this theme.
 * @return
 *   A form array.
 */
function MYTHEME_settings($saved_settings)
{
    // Get the default values from the .info file.
    $defaults = layoutstudio_theme_get_default_settings('MYTHEME');
    // Merge the saved variables and their default values.
    $settings = array_merge($defaults, $saved_settings);
    /*
     * Create the form using Forms API: http://api.drupal.org/api/6
     */
    $form = array();
    /* -- Delete this line if you want to use this setting
      $form['MYTHEME_example'] = array(
        '#type'          => 'checkbox',
        '#title'         => t('Use this sample setting'),
        '#default_value' => $settings['MYTHEME_example'],
        '#description'   => t("This option doesn't do anything; it's just an example."),
      );
      // */
    // Add the base theme's settings.
    $form += layoutstudio_settings($settings, $defaults);
    // Return the form
    return $form;
}