PageRenderTime 57ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://gitlab.com/manuvelasco/agostoliquida
PHP | 416 lines | 311 code | 59 blank | 46 comment | 7 complexity | 094cb333af8eaf9660759d01a68d3d53 MD5 | raw file
  1. <?php
  2. drupal_add_js(drupal_get_path('theme', 'jollyany') . '/js/theme_settings.js');
  3. /**
  4. * Implements hook_form_system_theme_settings_alter()
  5. */
  6. function jollyany_form_system_theme_settings_alter(&$form, &$form_state) {
  7. $contact_icon = theme_get_setting('contact_icon');
  8. if (file_uri_scheme($contact_icon) == 'public') {
  9. $contact_icon = file_uri_target($contact_icon);
  10. }
  11. // Main settings wrapper
  12. $form['options'] = array(
  13. '#type' => 'vertical_tabs',
  14. '#default_tab' => 'defaults',
  15. '#weight' => '-10',
  16. '#attached' => array(
  17. 'css' => array(drupal_get_path('theme', 'jollyany') . '/css/theme-options.css'),
  18. ),
  19. );
  20. // ----------- General -----------
  21. $form['options']['general'] = array(
  22. '#type' => 'fieldset',
  23. '#title' => t('General'),
  24. );
  25. // Breadcrumbs
  26. $form['options']['general']['breadcrumbs'] = array(
  27. '#type' => 'checkbox',
  28. '#title' => 'Show Breadcrumbs',
  29. '#default_value' => theme_get_setting('breadcrumbs'),
  30. );
  31. // General Settings
  32. $form['options']['general']['settings'] = array(
  33. '#type' => 'fieldset',
  34. '#title' => '<div class="plus"></div><h3 class="options_heading">General Settings</h3>',
  35. );
  36. $form['options']['general']['settings']['showsocial'] = array(
  37. '#type' => 'select',
  38. '#title' => 'Show Social in Page detail',
  39. '#default_value' => theme_get_setting('showsocial'),
  40. '#options' => array(
  41. '0' => 'No',
  42. '1' => 'Yes',
  43. ),
  44. );
  45. // Maintenance Time
  46. $form['options']['general']['settings']['maintenance_time'] = array(
  47. '#type' => 'textfield',
  48. '#title' => 'Maintenance Time',
  49. '#default_value' => theme_get_setting('maintenance_time'),
  50. );
  51. // Maintenance Style
  52. $form['options']['general']['settings']['maintenance_style'] = array(
  53. '#type' => 'select',
  54. '#title' => 'Maintenance Style',
  55. '#default_value' => theme_get_setting('maintenance_style'),
  56. '#options' => array(
  57. '1' => 'Maintenance Style 1',
  58. '2' => 'Maintenance Style 2',
  59. ),
  60. );
  61. // Contact MAP
  62. $form['options']['general']['contactmap'] = array(
  63. '#type' => 'fieldset',
  64. '#title' => '<div class="plus"></div><h3 class="options_heading">Contact Map</h3>',
  65. );
  66. // Company Name
  67. $form['options']['general']['contactmap']['contactmap_title'] = array(
  68. '#type' => 'textfield',
  69. '#title' => 'Company Name',
  70. '#default_value' => theme_get_setting('contactmap_title'),
  71. );
  72. // Website
  73. $form['options']['general']['contactmap']['contactmap_website'] = array(
  74. '#type' => 'textfield',
  75. '#title' => 'Website',
  76. '#default_value' => theme_get_setting('contactmap_website'),
  77. );
  78. // Contact MAP Address
  79. $form['options']['general']['contactmap']['contactmap_address'] = array(
  80. '#type' => 'textarea',
  81. '#title' => 'Address',
  82. '#default_value' => theme_get_setting('contactmap_address'),
  83. );
  84. // Contact MAP Phone
  85. $form['options']['general']['contactmap']['contactmap_phone'] = array(
  86. '#type' => 'textfield',
  87. '#title' => 'Telephone',
  88. '#default_value' => theme_get_setting('contactmap_phone'),
  89. );
  90. // Contact MAP Lat
  91. $form['options']['general']['contactmap']['contactmap_lat'] = array(
  92. '#type' => 'textfield',
  93. '#title' => 'Lat',
  94. '#default_value' => theme_get_setting('contactmap_lat'),
  95. );
  96. // Contact MAP Long
  97. $form['options']['general']['contactmap']['contactmap_long'] = array(
  98. '#type' => 'textfield',
  99. '#title' => 'Long',
  100. '#default_value' => theme_get_setting('contactmap_long'),
  101. );
  102. $form['options']['general']['contactmap']['contact_icon'] = array(
  103. '#type' => 'textfield',
  104. '#title' => 'Path to Contact Icon',
  105. '#default_value' => $contact_icon,
  106. '#disabled' => TRUE,
  107. );
  108. $form['options']['general']['contactmap']['contact_icon_upload'] = array(
  109. '#type' => 'file',
  110. '#title' => 'Upload Contact Icon',
  111. '#description' => 'Upload a new Contact Icon.',
  112. );
  113. // -------- SEO ---------
  114. $form['options']['general']['seo'] = array(
  115. '#type' => 'fieldset',
  116. '#title' => '<div class="plus"></div><h3 class="options_heading">SEO</h3>',
  117. );
  118. // SEO Title
  119. $form['options']['general']['seo']['seo_title'] = array(
  120. '#type' => 'textfield',
  121. '#title' => 'Title',
  122. '#default_value' => theme_get_setting('seo_title'),
  123. );
  124. // SEO Description
  125. $form['options']['general']['seo']['seo_description'] = array(
  126. '#type' => 'textarea',
  127. '#title' => 'Description',
  128. '#default_value' => theme_get_setting('seo_description'),
  129. );
  130. // SEO Keywords
  131. $form['options']['general']['seo']['seo_keywords'] = array(
  132. '#type' => 'textarea',
  133. '#title' => 'Keywords',
  134. '#default_value' => theme_get_setting('seo_keywords'),
  135. );
  136. // ----------- Layout -----------
  137. $form['options']['layout'] = array(
  138. '#type' => 'fieldset',
  139. '#title' => t('Layout'),
  140. );
  141. // ------ Page Layout Settings ------
  142. $form['options']['layout']['page'] = array(
  143. '#type' => 'fieldset',
  144. '#title' => '<div class="plus"></div><h3 class="options_heading">Page Layout Settings</h3>',
  145. );
  146. //Page Layout Container
  147. $form['options']['layout']['page']['page_style1'] = array(
  148. '#type' => 'textarea',
  149. '#title' => 'Page Style: Boxed Layout - Topbar (Example Home Version 7)',
  150. '#default_value' => theme_get_setting('page_style1'),
  151. );
  152. //Page Layout Container
  153. $form['options']['layout']['page']['page_style2'] = array(
  154. '#type' => 'textarea',
  155. '#title' => 'Page Style: Boxed Layout (Example Home Version 8)',
  156. '#default_value' => theme_get_setting('page_style2'),
  157. );
  158. //Page Layout Container
  159. $form['options']['layout']['page']['page_onepage'] = array(
  160. '#type' => 'textarea',
  161. '#title' => 'Page Style: One Page',
  162. '#default_value' => theme_get_setting('page_onepage'),
  163. );
  164. //Page Layout Container
  165. $form['options']['layout']['page']['page_only_content'] = array(
  166. '#type' => 'textarea',
  167. '#title' => 'Page Style: Only content Layout (Example 404 page)',
  168. '#default_value' => theme_get_setting('page_only_content'),
  169. );
  170. // ------ Header Settings ------
  171. $form['options']['layout']['header'] = array(
  172. '#type' => 'fieldset',
  173. '#title' => '<div class="plus"></div><h3 class="options_heading">Header Page Settings</h3>',
  174. );
  175. $form['options']['layout']['header']['header_1'] = array(
  176. '#type' => 'textarea',
  177. '#title' => 'Page With Header Style 1',
  178. '#default_value' => theme_get_setting('header_1'),
  179. );
  180. $form['options']['layout']['header']['header_2'] = array(
  181. '#type' => 'textarea',
  182. '#title' => 'Page With Header Style 2',
  183. '#default_value' => theme_get_setting('header_2'),
  184. );
  185. $form['options']['layout']['header']['header_3'] = array(
  186. '#type' => 'textarea',
  187. '#title' => 'Page With Header Style 3',
  188. '#default_value' => theme_get_setting('header_3'),
  189. );
  190. // ------ Footer Settings ------
  191. $form['options']['layout']['footer'] = array(
  192. '#type' => 'fieldset',
  193. '#title' => '<div class="plus"></div><h3 class="options_heading">Footer Page Settings</h3>',
  194. );
  195. $form['options']['layout']['footer']['footer_1'] = array(
  196. '#type' => 'textarea',
  197. '#title' => 'Page With Footer Style 1',
  198. '#default_value' => theme_get_setting('footer_1'),
  199. );
  200. $form['options']['layout']['footer']['footer_2'] = array(
  201. '#type' => 'textarea',
  202. '#title' => 'Page With Footer Style 2',
  203. '#default_value' => theme_get_setting('footer_2'),
  204. );
  205. $form['options']['layout']['footer']['footer_3'] = array(
  206. '#type' => 'textarea',
  207. '#title' => 'Page With Footer Style 3',
  208. '#default_value' => theme_get_setting('footer_3'),
  209. );
  210. // -------- Projects Layout Settings ----------
  211. $form['options']['layout']['projects'] = array(
  212. '#type' => 'fieldset',
  213. '#title' => '<div class="plus"></div><h3 class="options_heading">Projects Page Layout</h3>',
  214. );
  215. // View Project Text Button
  216. $form['options']['layout']['projects']['project_text_button'] = array(
  217. '#type' => 'textfield',
  218. '#title' => 'View Project Text Button',
  219. '#default_value' => theme_get_setting('project_text_button'),
  220. );
  221. $form['options']['layout']['projects']['projects_fulllayout'] = array(
  222. '#type' => 'textarea',
  223. '#title' => 'Projects Page Style: Full Layout',
  224. '#default_value' => theme_get_setting('projects_fulllayout'),
  225. );
  226. // ----------- Design Settings -----------
  227. $form['options']['design'] = array(
  228. '#type' => 'fieldset',
  229. '#title' => 'Design',
  230. );
  231. // Switcher
  232. $form['options']['design']['switcher'] = array(
  233. '#type' => 'checkbox',
  234. '#title' => 'Show Switcher Control',
  235. '#default_value' => theme_get_setting('switcher'),
  236. );
  237. // Layout Option
  238. $form['options']['design']['layout_style'] = array(
  239. '#type' => 'fieldset',
  240. '#title' => '<div class="plus"></div><h3 class="options_heading">Layout Style</h3>',
  241. );
  242. $form['options']['design']['layout_style']['layout_option'] = array(
  243. '#type' => 'radios',
  244. '#title' => 'Select a layout style:',
  245. '#default_value' => theme_get_setting('layout_option'),
  246. '#options' => array(
  247. 'boxed' => 'Boxed',
  248. 'fullwidth' => 'Full Width (default)',
  249. ),
  250. );
  251. // Header Option
  252. $form['options']['design']['header_style'] = array(
  253. '#type' => 'fieldset',
  254. '#title' => '<div class="plus"></div><h3 class="options_heading">Header Style</h3>',
  255. );
  256. // Header Option
  257. $form['options']['design']['header_style']['header_option'] = array(
  258. '#type' => 'radios',
  259. '#title' => 'Select a header style option:',
  260. '#default_value' => theme_get_setting('header_option'),
  261. '#options' => array(
  262. 'header_default' => 'Header Default',
  263. 'header1' => 'Header 1',
  264. 'header2' => 'Header 2',
  265. 'header3' => 'Header 3',
  266. ),
  267. );
  268. // Footer Option
  269. $form['options']['design']['footer_style'] = array(
  270. '#type' => 'fieldset',
  271. '#title' => '<div class="plus"></div><h3 class="options_heading">Footer Style</h3>',
  272. );
  273. // Footer Option
  274. $form['options']['design']['footer_style']['footer_option'] = array(
  275. '#type' => 'radios',
  276. '#title' => 'Select a footer style option:',
  277. '#default_value' => theme_get_setting('footer_option'),
  278. '#options' => array(
  279. 'footer_default' => 'Footer Default',
  280. 'footer1' => 'Footer 1',
  281. 'footer2' => 'Footer 2',
  282. 'footer3' => 'Footer 3',
  283. ),
  284. );
  285. // Color Option
  286. $form['options']['design']['color'] = array(
  287. '#type' => 'fieldset',
  288. '#title' => '<div class="plus"></div><h3 class="options_heading">Color</h3>',
  289. );
  290. // Color Scheme Option
  291. $form['options']['design']['color']['color_scheme'] = array(
  292. '#type' => 'select',
  293. '#title' => 'Color Scheme',
  294. '#default_value' => theme_get_setting('color_scheme'),
  295. '#options' => array(
  296. 'blue' => 'Blue',
  297. 'green' => 'Green',
  298. 'light-blue' => 'Light Blue',
  299. 'light-green' => 'Light Green',
  300. 'orange' => 'Orange',
  301. 'green' => 'Green',
  302. 'purple' => 'Purple',
  303. 'red' => 'Red',
  304. 'tael' => 'Tael',
  305. 'violet' => 'Violet',
  306. 'yellow' => 'Yellow (default)',
  307. ),
  308. );
  309. // Background Option
  310. $form['options']['design']['background'] = array(
  311. '#type' => 'fieldset',
  312. '#title' => '<div class="plus"></div><h3 class="options_heading">Background</h3>',
  313. );
  314. // Background Color Option
  315. $form['options']['design']['background']['background_style'] = array(
  316. '#type' => 'radios',
  317. '#title' => 'Select a background style:',
  318. '#default_value' => theme_get_setting('background_style'),
  319. '#options' => array(
  320. 'light' => 'Light (default)',
  321. 'dark' => 'Dark',
  322. ),
  323. );
  324. // CSS
  325. $form['options']['design']['css'] = array(
  326. '#type' => 'fieldset',
  327. '#title' => '<div class="plus"></div><h3 class="options_heading">CSS</h3>',
  328. );
  329. // User CSS
  330. $form['options']['design']['css']['user_css'] = array(
  331. '#type' => 'textarea',
  332. '#title' => 'Add your own CSS',
  333. '#default_value' => theme_get_setting('user_css'),
  334. );
  335. // Submit Button
  336. $form['#submit'][] = 'jollyany_settings_submit';
  337. }
  338. function jollyany_settings_submit($form, &$form_state) {
  339. // Get the previous value
  340. $previous = 'public://' . $form['options']['general']['contactmap']['contact_icon']['#default_value'];
  341. $file = file_save_upload('contact_icon_upload');
  342. if ($file) {
  343. $parts = pathinfo($file->filename);
  344. $destination = 'public://' . $parts['basename'];
  345. $file->status = FILE_STATUS_PERMANENT;
  346. if (file_copy($file, $destination, FILE_EXISTS_REPLACE)) {
  347. $_POST['contact_icon'] = $form_state['values']['contact_icon'] = $destination;
  348. if ($destination != $previous) {
  349. return;
  350. }
  351. }
  352. } else {
  353. // Avoid error when the form is submitted without specifying a new image
  354. $_POST['contact_icon'] = $form_state['values']['contact_icon'] = $previous;
  355. }
  356. }
  357. ?>