'blog', '%blog-wildcard' => 'blog/*', '%front' => '')); if ($access) { $options[] = t('Show if the following PHP code returns TRUE (PHP-mode, experts only).'); $description .= ' '. t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code can break your Drupal site.', array('%php' => '')); } $form['section_settings'] = array( '#type' => 'fieldset', '#title' => t('Section settings') ); $form['section_settings']['name'] = array( '#type' => 'textfield', '#title' => t('Name'), '#default_value' => $edit['name'], '#size' => 40, '#maxlength' => 64, '#description' => t('Give the name of the section') ); $form['section_settings']['visibility'] = array( '#type' => 'radios', '#title' => t('Activate section on the specific pages'), '#options' => $options, '#default_value' => $edit['visibility'] ? $edit['visibility'] : 0 ); $form['section_settings']['path'] = array( '#type' => 'textarea', '#title' => t('Pages'), '#default_value' => $edit['path'], '#cols' => 40, '#rows' => 5, '#description' => $description ); $form['section_settings']['status'] = array( '#type' => 'checkbox', '#title' => t('Enabled'), '#default_value' => $edit['status'], '#description' => t('Enable or disable this section') ); $form['section_settings']['theme'] = array( '#type' => 'select', '#title' => t('Select theme'), '#default_value' => $edit['theme'], '#options' => _sections_theme_select(), '#description' => t('Select the theme you want to use for this section') ); $form['section_settings']['weight'] = array( '#type' => 'weight', '#title' => t('Weight'), '#default_value' => $edit['weight'] ? $edit['weight'] : 0 ); if($edit['sid']) { // we are updating drupal_set_title(t('Edit section %name', array('%name' => $section->name))); $form['sid'] = array('#type' => 'hidden', '#value' => $edit['sid']); $form['save'] = array('#type' => 'submit', '#value' => t('Save'), '#submit' => array('sections_admin_settings_form_save_function')); } else { // we are adding drupal_set_title(t('Add section')); $form['submit'] = array('#type' => 'submit', '#value' => t('Add section')); } return $form; } function sections_admin_settings_form_save_function($form, &$form_state) { db_query("UPDATE {sections_data} SET name = '%s', status = %d, visibility = %d, theme = '%s', path = '%s', weight = %d WHERE sid = %d", $form_state['values']['name'], $form_state['values']['status'], $form_state['values']['visibility'], $form_state['values']['theme'], $form_state['values']['path'], $form_state['values']['weight'], $form_state['values']['sid']); drupal_set_message(t('The sections configuration has been saved.')); $form_state['redirect'] = 'admin/build/sections'; } function sections_admin_settings_form_submit($form, &$form_state) { db_query("INSERT INTO {sections_data} (name, status, visibility, path, theme, weight) VALUES ('%s', %d, %d, '%s', '%s', %d)", $form_state['values']['name'], $form_state['values']['status'], $form_state['values']['visibility'], $form_state['values']['path'], $form_state['values']['theme'], $form_state['values']['weight']); drupal_set_message(t('The sections configuration has been saved.')); $form_state['redirect'] = 'admin/build/sections'; } function sections_delete_form(&$form_state, $section) { $form['name'] = array('#type' => 'hidden', '#value' => $section->name); $form['sid'] = array('#type' => 'hidden', '#value' => $section->sid); return confirm_form( $form, t('Delete section %name', array('%name' => $section->name)), 'admin/build/sections', '

'. t('Are you sure you want to delete the section %name?', array('%name' => $section->name)) .'

', t('Delete'), t('Cancel') ); } function sections_delete_form_submit($form, &$form_state) { db_query('DELETE FROM {sections_data} WHERE sid = %d', $form_state['values']['sid']); drupal_set_message(t('The section %name has been deleted.', array('%name' => $form_state['values']['name']))); $form_state['redirect'] = 'admin/build/sections'; return; } /** * Build the list of sections */ function _sections_list() { $header = array( array('data' => t('Section')), array('data' => t('Status')), array('data' => t('Theme')), array('data' => t('Weight')), array('data' => t('Operations')) ); $rows = array(); foreach(_sections_load() as $section) { $rows[] = array( $section->name, $section->status ? t('Enabled') : t('Disabled'), $section->theme, $section->weight, l(t('Edit'), 'admin/build/sections/edit/'. $section->sid) .' ยท '. l(t('Delete'), 'admin/build/sections/delete/'. $section->sid) ); } if (empty($rows)) { $rows[] = array(array('data' => t('No sections available.'), 'colspan' => '5')); } $output = theme('table', $header, $rows); return $output; } /** * Loads the options for the themes select form element */ function _sections_theme_select() { $themes = list_themes(); $options = array(); foreach (array_keys($themes) as $name) { $options[$name] = $name; } return $options; }