/sites/all/themes/mothership/theme-settings.php

https://github.com/aakb/sport-aarhus-events · PHP · 636 lines · 462 code · 132 blank · 42 comment · 3 complexity · 712e9837b2388fb1a516c3d705e85359 MD5 · raw file

  1. <?php
  2. // $Id$
  3. /**
  4. * @file
  5. * themesettings.php
  6. */
  7. /**
  8. * Return the theme settings' default values from the .info and save them into the database.
  9. *
  10. * @param $theme
  11. * The name of theme.
  12. */
  13. function mothership_theme_get_default_settings($theme) {
  14. $themes = list_themes();
  15. // Get the default values from the .info file.
  16. $defaults = !empty($themes[$theme]->info['settings']) ? $themes[$theme]->info['settings'] : array();
  17. if (!empty($defaults)) {
  18. // Get the theme settings saved in the database.
  19. $settings = theme_get_settings($theme);
  20. // Don't save the toggle_node_info_ variables.
  21. if (module_exists('node')) {
  22. foreach (node_get_types() as $type => $name) {
  23. unset($settings['toggle_node_info_' . $type]);
  24. }
  25. }
  26. // Save default theme settings.
  27. variable_set(
  28. str_replace('/', '_', 'theme_' . $theme . '_settings'),
  29. array_merge($defaults, $settings)
  30. );
  31. // If the active theme has been loaded, force refresh of Drupal internals.
  32. if (!empty($GLOBALS['theme_key'])) {
  33. theme_get_setting('', TRUE);
  34. }
  35. }
  36. // Return the default settings.
  37. return $defaults;
  38. }
  39. /**
  40. * SETTINGS
  41. * Implementation of THEMEHOOK_settings() function.
  42. */
  43. //function phptemplate_settings($saved_settings) {
  44. function mothership_settings($saved_settings, $subtheme_defaults = array()) {
  45. // Get the default values from the .info file.
  46. $defaults = mothership_theme_get_default_settings('mothership');
  47. // Allow a subtheme to override the default values.
  48. $defaults = array_merge($defaults, $subtheme_defaults); //zen ftw
  49. // Merge the saved variables and their default values.
  50. $settings = array_merge($defaults, $saved_settings);
  51. // Merge the saved variables and their default values.
  52. $settings = array_merge($defaults, $saved_settings);
  53. GLOBAL $vars;
  54. // -- cleanup -------------------------------------
  55. $form['cleanup'] = array(
  56. '#type' => 'fieldset',
  57. '#title' => t('"Tipl Phiphs" CSS Cleanup'),
  58. '#collapsible' => TRUE,
  59. '#collapsed' => FALSE,
  60. );
  61. // -- body -------------------------------------
  62. $form['cleanup']['body'] = array(
  63. '#type' => 'fieldset',
  64. '#title' => t('body classes (page.tpl)'),
  65. '#collapsible' => TRUE,
  66. '#collapsed' => TRUE,
  67. );
  68. $form['cleanup']['body']['mothership_cleanup_body_remove'] = array(
  69. '#type' => 'checkbox',
  70. '#title' => t('Removes drupals standard body classes'),
  71. '#default_value' => $settings['mothership_cleanup_body_remove'],
  72. );
  73. $form['cleanup']['body']['add'] = array(
  74. '#type' => 'fieldset',
  75. '#title' => t('Rebuild drupal standard classes:'),
  76. '#collapsible' => FALSE,
  77. '#collapsed' => FALSE,
  78. );
  79. $form['cleanup']['body']['add']['mothership_cleanup_body_front'] = array(
  80. '#type' => 'checkbox',
  81. '#title' => t('.front : if its the frontpage '),
  82. '#default_value' => $settings['mothership_cleanup_body_front'],
  83. );
  84. $form['cleanup']['body']['add']['mothership_cleanup_body_front_not'] = array(
  85. '#type' => 'checkbox',
  86. '#title' => t('.not-front :if its not the frontpage'),
  87. '#default_value' => $settings['mothership_cleanup_body_front_not'],
  88. );
  89. $form['cleanup']['body']['add']['mothership_cleanup_body_loggedin'] = array(
  90. '#type' => 'checkbox',
  91. '#title' => t('.logged-in : if user is logged in'),
  92. '#default_value' => $settings['mothership_cleanup_body_loggedin'],
  93. );
  94. $form['cleanup']['body']['add']['mothership_cleanup_body_loggedin_not'] = array(
  95. '#type' => 'checkbox',
  96. '#title' => t('.not-logged-in : if user is not logged in'),
  97. '#default_value' => $settings['mothership_cleanup_body_loggedin_not'],
  98. );
  99. $form['cleanup']['body']['add']['mothership_cleanup_body_layout'] = array(
  100. '#type' => 'checkbox',
  101. '#title' => t('layout class: .two-sidebars | .no-sidebars | .one-sidebar .sidebar-left/right'),
  102. '#default_value' => $settings['mothership_cleanup_body_layout'],
  103. );
  104. $form['cleanup']['body']['add']['mothership_cleanup_body_nodetype'] = array(
  105. '#type' => 'checkbox',
  106. '#title' => t('.node-type-[NODETYPE]'),
  107. '#default_value' => $settings['mothership_cleanup_body_nodetype'],
  108. );
  109. $form['cleanup']['body']['mothership_cleanup_body_pagearg_one'] = array(
  110. '#type' => 'checkbox',
  111. '#title' => t('.page-[1. part of the path ] '),
  112. '#default_value' => $settings['mothership_cleanup_body_pagearg_one'],
  113. );
  114. $form['cleanup']['body']['mothership_cleanup_body_add_path'] = array(
  115. '#type' => 'checkbox',
  116. '#title' => t('.path-[URL]'),
  117. '#default_value' => $settings['mothership_cleanup_body_add_path'],
  118. );
  119. $form['cleanup']['body']['mothership_cleanup_body_add_last'] = array(
  120. '#type' => 'checkbox',
  121. '#title' => t('last path: .pathlast-[last]'),
  122. '#default_value' => $settings['mothership_cleanup_body_add_last'],
  123. );
  124. $form['cleanup']['body']['mothership_cleanup_body_actions'] = array(
  125. '#type' => 'checkbox',
  126. '#title' => t('node actions: .add, .edit, .delete'),
  127. '#default_value' => $settings['mothership_cleanup_body_actions'],
  128. );
  129. $form['cleanup']['body']['mothership_cleanup_body_admin'] = array(
  130. '#type' => 'checkbox',
  131. '#title' => t('admin module active: .adminmenu'),
  132. '#default_value' => $settings['mothership_cleanup_body_admin'],
  133. );
  134. $form['cleanup']['body']['mothership_cleanup_body_add_nid'] = array(
  135. '#type' => 'checkbox',
  136. '#title' => t('add node id class nid-[n]'),
  137. '#default_value' => $settings['mothership_cleanup_body_add_nid'],
  138. );
  139. // -- node -------------------------------------
  140. $form['cleanup']['node'] = array(
  141. '#type' => 'fieldset',
  142. '#title' => t('node.tpl'),
  143. '#collapsible' => TRUE,
  144. '#collapsed' => TRUE,
  145. );
  146. $form['cleanup']['node']['mothership_cleanup_node_node'] = array(
  147. '#type' => 'checkbox',
  148. '#title' => t('add node '),
  149. '#default_value' => $settings['mothership_cleanup_node_node'],
  150. );
  151. $form['cleanup']['node']['mothership_cleanup_node_sticky'] = array(
  152. '#type' => 'checkbox',
  153. '#title' => t('add sticky'),
  154. '#default_value' => $settings['mothership_cleanup_node_sticky'],
  155. );
  156. $form['cleanup']['node']['mothership_cleanup_node_published'] = array(
  157. '#type' => 'checkbox',
  158. '#title' => t('add node-unpublished'),
  159. '#default_value' => $settings['mothership_cleanup_node_published'],
  160. );
  161. $form['cleanup']['node']['mothership_cleanup_node_promoted'] = array(
  162. '#type' => 'checkbox',
  163. '#title' => t('add promoted'),
  164. '#default_value' => $settings['mothership_cleanup_node_promoted'],
  165. );
  166. $form['cleanup']['node']['mothership_cleanup_node_content_type'] = array(
  167. '#type' => 'checkbox',
  168. '#title' => t('node: content type '),
  169. '#default_value' => $settings['mothership_cleanup_node_content_type'],
  170. );
  171. $form['cleanup']['node']['mothership_cleanup_node_teaser'] = array(
  172. '#type' => 'checkbox',
  173. '#title' => t('node: teaser '),
  174. '#default_value' => $settings['mothership_cleanup_node_teaser'],
  175. );
  176. $form['cleanup']['node']['mothership_cleanup_node_id'] = array(
  177. '#type' => 'checkbox',
  178. '#title' => t('id - generate a #node-nid '),
  179. '#default_value' => $settings['mothership_cleanup_node_id'],
  180. );
  181. $form['cleanup']['node']['mothership_cleanup_node_clearfix'] = array(
  182. '#type' => 'checkbox',
  183. '#title' => t('add .clearfix '),
  184. '#default_value' => $settings['mothership_cleanup_node_clearfix'],
  185. );
  186. // -- block -------------------------------------
  187. $form['cleanup']['block'] = array(
  188. '#type' => 'fieldset',
  189. '#title' => t('block.tpl'),
  190. '#collapsible' => TRUE,
  191. '#collapsed' => TRUE,
  192. );
  193. $form['cleanup']['block']['mothership_cleanup_block_block'] = array(
  194. '#type' => 'checkbox',
  195. '#title' => t('add block'),
  196. '#default_value' => $settings['mothership_cleanup_block_block'],
  197. );
  198. $form['cleanup']['block']['mothership_cleanup_block_module'] = array(
  199. '#type' => 'checkbox',
  200. '#title' => t('add module name'),
  201. '#default_value' => $settings['mothership_cleanup_block_module'],
  202. );
  203. $form['cleanup']['block']['mothership_cleanup_block_region_zebra'] = array(
  204. '#type' => 'checkbox',
  205. '#title' => t('add odd / even in the region region-odd / region-even'),
  206. '#default_value' => $settings['mothership_cleanup_block_region_zebra'],
  207. );
  208. $form['cleanup']['block']['mothership_cleanup_block_region_count'] = array(
  209. '#type' => 'checkbox',
  210. '#title' => t('add region region-count-x'),
  211. '#default_value' => $settings['mothership_cleanup_block_region_count'],
  212. );
  213. $form['cleanup']['block']['mothership_cleanup_block_loggedin'] = array(
  214. '#type' => 'checkbox',
  215. '#title' => t('add block-logged-in'),
  216. '#default_value' => $settings['mothership_cleanup_block_loggedin'],
  217. );
  218. $form['cleanup']['block']['mothership_cleanup_block_front'] = array(
  219. '#type' => 'checkbox',
  220. '#title' => t('add block-front'),
  221. '#default_value' => $settings['mothership_cleanup_block_front'],
  222. );
  223. $form['cleanup']['block']['mothership_cleanup_block_zebra'] = array(
  224. '#type' => 'checkbox',
  225. '#title' => t('add odd / even for all blocks'),
  226. '#default_value' => $settings['mothership_cleanup_block_zebra'],
  227. );
  228. $form['cleanup']['block']['mothership_cleanup_block_count'] = array(
  229. '#type' => 'checkbox',
  230. '#title' => t('add count for all blocks count-x'),
  231. '#default_value' => $settings['mothership_cleanup_block_count'],
  232. );
  233. $form['cleanup']['block']['mothership_cleanup_block_id'] = array(
  234. '#type' => 'checkbox',
  235. '#title' => t('id - generate a id for the block '),
  236. '#default_value' => $settings['mothership_cleanup_block_id'],
  237. );
  238. // -- comments ------------------------------------- */
  239. $form['cleanup']['comment'] = array(
  240. '#type' => 'fieldset',
  241. '#title' => t('comments'),
  242. '#collapsible' => TRUE,
  243. '#collapsed' => TRUE,
  244. );
  245. $form['cleanup']['comment']['mothership_cleanup_comment_comment'] = array(
  246. '#type' => 'checkbox',
  247. '#title' => t('add comment'),
  248. '#default_value' => $settings['mothership_cleanup_comment_comment'],
  249. );
  250. $form['cleanup']['comment']['mothership_cleanup_comment_new'] = array(
  251. '#type' => 'checkbox',
  252. '#title' => t('add new'),
  253. '#default_value' => $settings['mothership_cleanup_comment_new'],
  254. );
  255. $form['cleanup']['comment']['mothership_cleanup_comment_status'] = array(
  256. '#type' => 'checkbox',
  257. '#title' => t('add status'),
  258. '#default_value' => $settings['mothership_cleanup_comment_status'],
  259. );
  260. $form['cleanup']['comment']['mothership_cleanup_comment_first'] = array(
  261. '#type' => 'checkbox',
  262. '#title' => t('add first'),
  263. '#default_value' => $settings['mothership_cleanup_comment_first'],
  264. );
  265. $form['cleanup']['comment']['mothership_cleanup_comment_last'] = array(
  266. '#type' => 'checkbox',
  267. '#title' => t('add last'),
  268. '#default_value' => $settings['mothership_cleanup_comment_last'],
  269. );
  270. $form['cleanup']['comment']['mothership_cleanup_comment_zebra'] = array(
  271. '#type' => 'checkbox',
  272. '#title' => t('add odd even'),
  273. '#default_value' => $settings['mothership_cleanup_comment_zebra'],
  274. );
  275. $form['cleanup']['comment']['mothership_cleanup_comment_front'] = array(
  276. '#type' => 'checkbox',
  277. '#title' => t('add front'),
  278. '#default_value' => $settings['mothership_cleanup_comment_front'],
  279. );
  280. $form['cleanup']['comment']['mothership_cleanup_comment_comment'] = array(
  281. '#type' => 'checkbox',
  282. '#title' => t('add comment'),
  283. '#default_value' => $settings['mothership_cleanup_comment_comment'],
  284. );
  285. $form['cleanup']['comment']['mothership_cleanup_comment_loggedin'] = array(
  286. '#type' => 'checkbox',
  287. '#title' => t('add logged-in'),
  288. '#default_value' => $settings['mothership_cleanup_comment_loggedin'],
  289. );
  290. $form['cleanup']['comment']['mothership_cleanup_comment_user'] = array(
  291. '#type' => 'checkbox',
  292. '#title' => t('add user-'),
  293. '#default_value' => $settings['mothership_cleanup_comment_user'],
  294. );
  295. // -- views ------------------------------------- */
  296. $form['views'] = array(
  297. '#type' => 'fieldset',
  298. '#title' => t('Views'),
  299. '#collapsible' => TRUE,
  300. '#collapsed' => FALSE,
  301. );
  302. //display
  303. $form['views']['display'] = array(
  304. '#type' => 'fieldset',
  305. '#title' => t('Display'),
  306. '#collapsible' => TRUE,
  307. '#collapsed' => FALSE,
  308. );
  309. $form['views']['display']['mothership_cleanup_views_display_view'] = array(
  310. '#type' => 'checkbox',
  311. '#title' => t('add .view - This is needed for the hover admin links '),
  312. '#default_value' => $settings['mothership_cleanup_views_display_view'],
  313. );
  314. $form['views']['display']['mothership_cleanup_views_display_cssname'] = array(
  315. '#type' => 'checkbox',
  316. '#title' => t('add .view-$css_name'),
  317. '#default_value' => $settings['mothership_cleanup_views_display_cssname'],
  318. );
  319. $form['views']['display']['mothership_cleanup_views_display_name'] = array(
  320. '#type' => 'checkbox',
  321. '#title' => t('add view-id-.$name'),
  322. '#default_value' => $settings['mothership_cleanup_views_display_name'],
  323. );
  324. $form['views']['display']['mothership_cleanup_views_display_display_id'] = array(
  325. '#type' => 'checkbox',
  326. '#title' => t('add view-display-id-.$display_id'),
  327. '#default_value' => $settings['mothership_cleanup_views_display_display_id'],
  328. );
  329. $form['views']['display']['mothership_cleanup_views_display_dom_id'] = array(
  330. '#type' => 'checkbox',
  331. '#title' => t('add view-dom-id-$dom_id'),
  332. '#default_value' => $settings['mothership_cleanup_views_display_dom_id'],
  333. );
  334. //list
  335. $form['views']['list'] = array(
  336. '#type' => 'fieldset',
  337. '#title' => t('List'),
  338. '#collapsible' => TRUE,
  339. '#collapsed' => TRUE,
  340. );
  341. $form['views']['list']['mothership_cleanup_views_first_last'] = array(
  342. '#type' => 'checkbox',
  343. '#title' => t('first & last classes to the list .first .last '),
  344. '#default_value' => $settings['mothership_cleanup_views_first_last'],
  345. );
  346. $form['views']['list']['mothership_cleanup_views_zebra'] = array(
  347. '#type' => 'checkbox',
  348. '#title' => t('odd / even class .odd, .even'),
  349. '#default_value' => $settings['mothership_cleanup_views_zebra'],
  350. );
  351. $form['views']['list']['mothership_cleanup_views_row_count'] = array(
  352. '#type' => 'checkbox',
  353. '#title' => t('Row counting .row-[count] '),
  354. '#default_value' => $settings['mothership_cleanup_views_row_count'],
  355. );
  356. $form['views']['list']['mothership_cleanup_views_row_identify'] = array(
  357. '#type' => 'checkbox',
  358. '#title' => t('adds a "views-row" prefix (.views-row-first/.views-row-last, .views-row-[count], .views-row-odd/.views-row-even '),
  359. '#default_value' => $settings['mothership_cleanup_views_row_identify'],
  360. );
  361. $form['views']['list']['mothership_cleanup_views_row_identify_single'] = array(
  362. '#type' => 'checkbox',
  363. '#title' => t('add a "views-row" class to the list'),
  364. '#default_value' => $settings['mothership_cleanup_views_row_identify_single'],
  365. );
  366. //tables
  367. $form['views']['table'] = array(
  368. '#type' => 'fieldset',
  369. '#title' => t('Tables'),
  370. '#collapsible' => TRUE,
  371. '#collapsed' => TRUE,
  372. );
  373. $form['views']['table']['mothership_cleanup_views_table_first_last'] = array(
  374. '#type' => 'checkbox',
  375. '#title' => t('add first & last class in table rows'),
  376. '#default_value' => $settings['mothership_cleanup_views_table_first_last'],
  377. );
  378. $form['views']['table']['mothership_cleanup_views_table_zebra'] = array(
  379. '#type' => 'checkbox',
  380. '#title' => t('add odd / even class to the table rows '),
  381. '#default_value' => $settings['mothership_cleanup_views_table_zebra'],
  382. );
  383. $form['views']['table']['mothership_cleanup_views_table_row_count'] = array(
  384. '#type' => 'checkbox',
  385. '#title' => t('row-x to the table rows'),
  386. '#default_value' => $settings['mothership_cleanup_views_table_row_count'],
  387. );
  388. //grid
  389. $form['views']['grid'] = array(
  390. '#type' => 'fieldset',
  391. '#title' => t('Grid'),
  392. '#collapsible' => TRUE,
  393. '#collapsed' => FALSE,
  394. );
  395. // -- menu ------------------------------------- */
  396. $form['menu'] = array(
  397. '#type' => 'fieldset',
  398. '#title' => t('Menu'),
  399. '#collapsible' => TRUE,
  400. '#collapsed' => FALSE,
  401. );
  402. $form['menu']['mothership_cleanup_menu_baseclass'] = array(
  403. '#type' => 'checkbox',
  404. '#title' => t('menus ul gets a class=menu'),
  405. '#default_value' => $settings['mothership_cleanup_menu_baseclass'],
  406. );
  407. $form['menu']['mothership_cleanup_menu_baseclass'] = array(
  408. '#type' => 'checkbox',
  409. '#title' => t('add a baseclass to the menus '),
  410. '#default_value' => $settings['mothership_cleanup_menu_baseclass'],
  411. );
  412. $form['menu']['mothership_cleanup_menu_leafs'] = array(
  413. '#type' => 'checkbox',
  414. '#title' => t('add leaf & expanded class to the li'),
  415. '#default_value' => $settings['mothership_cleanup_menu_leafs'],
  416. );
  417. $form['menu']['mothership_cleanup_menu_classes_active'] = array(
  418. '#type' => 'checkbox',
  419. '#title' => t('add a active class for the li in a menu'),
  420. '#default_value' => $settings['mothership_cleanup_menu_classes_active'],
  421. );
  422. $form['menu']['mothership_cleanup_menu_classes_first_last'] = array(
  423. '#type' => 'checkbox',
  424. '#title' => t('adds a first & last class in the li'),
  425. '#default_value' => $settings['mothership_cleanup_menu_classes_first_last'],
  426. );
  427. $form['menu']['mothership_cleanup_links_baseclass'] = array(
  428. '#type' => 'checkbox',
  429. '#title' => t('add a baseclasses to links -primary & secundary '),
  430. '#default_value' => $settings['mothership_cleanup_links_baseclass'],
  431. );
  432. $form['menu']['mothership_cleanup_links_classes_active'] = array(
  433. '#type' => 'checkbox',
  434. '#title' => t('add a active class for the li in the links'),
  435. '#default_value' => $settings['mothership_cleanup_links_classes_active'],
  436. );
  437. $form['menu']['mothership_cleanup_links_classes_first_last'] = array(
  438. '#type' => 'checkbox',
  439. '#title' => t('adds a first & last class in the li'),
  440. '#default_value' => $settings['mothership_cleanup_links_classes_first_last'],
  441. );
  442. // -- style sheet ------------------------------------- */
  443. $form['stylesheets'] = array(
  444. '#type' => 'fieldset',
  445. '#title' => t('stylesheets'),
  446. '#collapsible' => TRUE,
  447. '#collapsed' => FALSE,
  448. );
  449. $form['stylesheets']['mothership_stylesheet_load_order'] = array(
  450. '#type' => 'checkbox',
  451. '#title' => t('stylesheet loading order in the .info file'),
  452. '#default_value' => $settings['mothership_stylesheet_load_order'],
  453. '#description' => t('.info file: <strong>top stylesheets[all][] = foo.css</strong>'),
  454. );
  455. $form['stylesheets']['mothership_stylesheet_conditional'] = array(
  456. '#type' => 'checkbox',
  457. '#title' => t('ie specific stylesheet conditions in the .info file'),
  458. '#default_value' => $settings['mothership_stylesheet_conditional'],
  459. '#description' => t('.info file: <strong>ie stylesheets[ condition ][all][] = ie.css</strong> condition exampels [if lt IE 7] , [if IE 7] , [if IE 6]'),
  460. );
  461. // -- misc ------------------------------------- */
  462. $form['misc'] = array(
  463. '#type' => 'fieldset',
  464. '#title' => t('misc stuff'),
  465. '#collapsible' => TRUE,
  466. '#collapsed' => FALSE,
  467. );
  468. $form['misc']['mothership_item_list_first_last'] = array(
  469. '#type' => 'checkbox',
  470. '#title' => t('first & last classes from item lists'),
  471. '#default_value' => $settings['mothership_item_list_first_last'],
  472. );
  473. $form['misc']['mothership_item_list_zebra'] = array(
  474. '#type' => 'checkbox',
  475. '#title' => t('item lists zebra'),
  476. '#default_value' => $settings['mothership_item_list_zebra'],
  477. );
  478. $form['misc']['mothership_cleanup_user_verified'] = array(
  479. '#type' => 'checkbox',
  480. '#title' => t('show (user verified) if a user isnt verified'),
  481. '#default_value' => $settings['mothership_cleanup_user_verified'],
  482. );
  483. // -- theme development -------------------------------------
  484. $form['misc']['mothership_rebuild_registry'] = array(
  485. '#type' => 'checkbox',
  486. '#title' => t('Rebuild theme registry on every page.'),
  487. '#default_value' => $settings['mothership_rebuild_registry'],
  488. '#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')),
  489. );
  490. // -- features ------------------------------------- */
  491. $form['misc']['features'] = array(
  492. '#type' => 'fieldset',
  493. '#title' => t('Sneaky Features'),
  494. '#collapsible' => TRUE,
  495. '#collapsed' => FALSE,
  496. );
  497. $form['misc']['features']['mothership_cleanup_node_regions'] = array(
  498. '#type' => 'checkbox',
  499. '#title' => t('add regions to nodes '),
  500. '#default_value' => $settings['mothership_cleanup_node_regions'],
  501. );
  502. // Return form
  503. return $form;
  504. }