| Commit | Line | Data |
|---|---|---|
| aa43a991 | 1 | <?php |
| aa43a991 | 2 | /** |
| c53fc478 | 3 | * @file |
| 8ef64592 | 4 | * Provides the settings for the Nitobe theme. |
| aa43a991 SL |
5 | */ |
| 6 | ||
| aaf80833 | 7 | require_once drupal_get_path("theme", "nitobe") . "/nitobe.utils.inc"; |
| aa43a991 SL |
8 | |
| 9 | /** | |
| 80529006 | 10 | * Exposes Nitobe's theme settings. |
| aa43a991 | 11 | * |
| 80529006 SL |
12 | * @param array &$form |
| 13 | * Nested array of form elements that comprise the form. | |
| 14 | * @param array &$form_state | |
| 15 | * A keyed array containing the current state of the form. The arguments that | |
| 16 | * drupal_get_form() was originally called with are available in the array | |
| 17 | * $form_state['build_info']['args']. | |
| aa43a991 | 18 | */ |
| 097a8340 | 19 | function nitobe_form_system_theme_settings_alter(&$form, &$form_state) { |
| aaf80833 SL |
20 | $form["nitobe_general_settings"] = array( |
| 21 | "#type" => "fieldset", | |
| 22 | "#title" => "General Nitobe settings", | |
| 23 | ); | |
| 80529006 | 24 | |
| c53fc478 | 25 | // -- What ordering should be used for the content and sidebars? |
| aaf80833 | 26 | $default = theme_get_setting("nitobe_content_placement", "nitobe"); |
| aaf80833 | 27 | $desc = t("Where should the sidebars be placed?"); |
| c53fc478 | 28 | $options = array( |
| aaf80833 SL |
29 | "center" => "On either side of the content region.", |
| 30 | "right" => "Right of the content region.", | |
| 31 | "left" => "Left of the content region.", | |
| c53fc478 SL |
32 | ); |
| 33 | ||
| aaf80833 SL |
34 | $form["nitobe_general_settings"]['nitobe_content_placement'] = array( |
| 35 | "#type" => "select", | |
| 36 | "#title" => t("Sidebar placement"), | |
| 37 | "#options" => $options, | |
| 38 | "#default_value" => $default, | |
| 39 | "#description" => $desc, | |
| c53fc478 SL |
40 | ); |
| 41 | ||
| aaf80833 SL |
42 | // -- How many page items to put in the pager widgets. |
| 43 | $default = theme_get_setting("nitobe_pager_page_count", "nitobe"); | |
| aaf80833 SL |
44 | $options = range(3, 10); |
| 45 | $desc = t("The number of default pages to include in pager controls. If you are using a three column layout, a lower number here will work better."); | |
| 09639ced | 46 | |
| aaf80833 SL |
47 | $form["nitobe_general_settings"]['nitobe_pager_page_count'] = array( |
| 48 | "#type" => 'select', | |
| 49 | "#title" => t('Pager item count'), | |
| 50 | "#options" => drupal_map_assoc($options), | |
| 51 | "#default_value" => $default, | |
| 52 | "#description" => $desc, | |
| aa43a991 | 53 | ); |
| 80529006 SL |
54 | |
| 55 | _nitobe_add_header_settings($form); | |
| 56 | _nitobe_add_time_format_settings($form); | |
| 57 | } | |
| 58 | ||
| 59 | ||
| 60 | /** | |
| 61 | * Adds the date/time format settings to the settings form. | |
| 62 | * | |
| 63 | * @param array &$form | |
| 64 | * Nested array of form elements that comprise the form. | |
| 65 | */ | |
| 66 | function _nitobe_add_time_format_settings(&$form) { | |
| 67 | $options = array( | |
| 68 | "attributes" => array("target" => "_blank"), | |
| 69 | "absolute" => TRUE, | |
| 70 | "external" => TRUE, | |
| 71 | ); | |
| 72 | ||
| 73 | $subs = array( | |
| 74 | "!link" => l(t("date()"), "http://php.net/manual/en/function.date.php", | |
| 75 | $options), | |
| 76 | ); | |
| 77 | ||
| 78 | $desc = t("These settings are used to control how dates are rendered on nodes and comments. Refer to the documentation for PHP's !link function for details on date formats.", | |
| 79 | $subs); | |
| 80 | $form["nitobe_datetime_settings"] = array( | |
| 81 | "#type" => "fieldset", | |
| 82 | "#title" => "Date and time formats", | |
| 83 | "#description" => $desc, | |
| 84 | ); | |
| 85 | ||
| 86 | // -- The node timestamp format | |
| 87 | $default = theme_get_setting("nitobe_node_datestamp_format", "nitobe"); | |
| 88 | $desc = t("This controls how dates are rendered in a node's header."); | |
| 89 | $form["nitobe_datetime_settings"]["nitobe_node_datestamp_format"] = array( | |
| 90 | "#type" => "textfield", | |
| 91 | "#title" => t("Node date format"), | |
| 92 | "#size" => 32, | |
| 93 | "#max_length" => 64, | |
| 94 | "#description" => $desc, | |
| 95 | "#default_value" => $default, | |
| 96 | ); | |
| 97 | ||
| 98 | // -- The comment attribution date format | |
| 99 | $default = theme_get_setting("nitobe_comment_date_format", "nitobe"); | |
| 100 | $desc = t("This controls how a comment's date is rendered in the author attribution text."); | |
| 101 | $form["nitobe_datetime_settings"]["nitobe_comment_date_format"] = array( | |
| 102 | "#type" => "textfield", | |
| 103 | "#title" => t("Comment date format"), | |
| 104 | "#size" => 32, | |
| 105 | "#max_length" => 64, | |
| 106 | "#description" => $desc, | |
| 107 | "#default_value" => $default, | |
| 108 | ); | |
| 109 | ||
| 110 | // -- The comment attribution time format | |
| 111 | $default = theme_get_setting("nitobe_comment_time_format", "nitobe"); | |
| 112 | $desc = t("This controls how a comment's time is rendered in the author attribution text."); | |
| 113 | $form["nitobe_datetime_settings"]["nitobe_comment_time_format"] = array( | |
| 114 | "#type" => "textfield", | |
| 115 | "#title" => t("Comment date format"), | |
| 116 | "#size" => 32, | |
| 117 | "#max_length" => 64, | |
| 118 | "#description" => $desc, | |
| 119 | "#default_value" => $default, | |
| 120 | ); | |
| aaf80833 | 121 | } |
| aa43a991 | 122 | |
| aaf80833 SL |
123 | |
| 124 | /** | |
| 125 | * Adds the header settings to the settings form. | |
| 126 | * | |
| 127 | * @param array $form | |
| 128 | * The form element array to add the settings fields to. | |
| 129 | */ | |
| 130 | function _nitobe_add_header_settings(&$form) { | |
| 131 | $form["nitobe_header_settings"] = array( | |
| 132 | "#type" => "fieldset", | |
| 133 | "#title" => "Page header settings", | |
| f7561af7 SL |
134 | ); |
| 135 | ||
| c53fc478 | 136 | // -- Should the alternating color title effect be applied? |
| 80529006 | 137 | $default = theme_get_setting("nitobe_title_effect", "nitobe"); |
| aaf80833 SL |
138 | $desc = t("Should the title be adjusted to apply an alternate color to every other word and remove inter-word spacing?"); |
| 139 | $form["nitobe_header_settings"]["nitobe_title_effect"] = array( | |
| 140 | "#type" => "checkbox", | |
| 141 | "#title" => t("Apply title effect"), | |
| 142 | "#default_value" => $default, | |
| 143 | "#description" => $desc, | |
| 41b9f453 | 144 | ); |
| 80529006 | 145 | |
| aaf80833 SL |
146 | // -- Get the header image list. |
| 147 | $images = _nitobe_get_header_list(TRUE); | |
| 80529006 | 148 | $options = array("<random>" => "<Random Header Image>"); |
| 41b9f453 | 149 | |
| aaf80833 SL |
150 | foreach ($images as $filename => $data) { |
| 151 | $options[$filename] = $data->pretty_name; | |
| 152 | } | |
| 41b9f453 | 153 | |
| aaf80833 SL |
154 | // -- The setting for the header image. |
| 155 | $current = theme_get_setting("nitobe_header_image", "nitobe"); | |
| aaf80833 SL |
156 | $default = in_array($current, array_keys($options)) ? $current : "<random>"; |
| 157 | $form["nitobe_header_settings"]["nitobe_header_image"] = array( | |
| 158 | "#type" => "select", | |
| 159 | "#title" => t("Header image"), | |
| 160 | "#options" => $options, | |
| 161 | "#default_value" => $default, | |
| 162 | ); | |
| 80529006 | 163 | |
| aaf80833 SL |
164 | // -- Show the header image if the mastead region has content? |
| 165 | $default = theme_get_setting("nitobe_masthead_always_show", "nitobe"); | |
| aaf80833 SL |
166 | $desc = t("By default, if there is block content in the Masthead region, the header image will not be displayed. Check this box to cause the header image to be displayed as the region's background image."); |
| 167 | $form["nitobe_header_settings"]["nitobe_masthead_always_show"] = array( | |
| 168 | "#type" => "checkbox", | |
| 169 | "#title" => t("Always show masthead image"), | |
| 170 | "#default_value" => $default, | |
| 171 | "#description" => $desc, | |
| 4d103886 | 172 | ); |
| aa43a991 | 173 | } |