/[drupal]/contributions/sandbox/fgm/themesettings/themesettings.module
ViewVC logotype

Contents of /contributions/sandbox/fgm/themesettings/themesettings.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Wed Jun 13 19:03:37 2007 UTC (2 years, 5 months ago) by fgm
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +18 -1 lines
File MIME type: text/x-php
This proof-of-concept module is no longer needed.
Use http://drupal.org/project/themesettings instead
1 <?php
2 /*
3 2007-05-13
4
5 Please no longer use this proof-of-concept module.
6 A full-fledged module has been created at:
7
8 http://drupal.org/project/themesettings
9
10 See :
11 http://blog.riff.org/2006_08_10_how_to_add_settings_to_custom_drupal_themes
12 for an intro to this method
13
14 http://wiki.audean.com/dr/themesettings
15 for a detailed explanation
16
17 */
18
19 define(TSBASEPATH, 'admin/themes/settings2');
20
21 function _themesettings_themes()
22 {
23 static $ret ;
24
25 if (isset($ret))
26 { return $ret; }
27
28 $ret = array();
29 $themes = list_themes();
30 foreach ($themes as $theme_key => $theme)
31 {
32 $function_name = $theme_key . "_settings";
33 // Test taken from system.module, but probably incomplete/incorrect
34 // We need to load the file for the function to be in memory, though
35 // Having it in a separate file avoids loading the full theme
36 if (file_exists($file = dirname($theme->filename) .'/' . $theme_key . '.theme'))
37 {
38 include_once "./$file";
39 }
40 if (function_exists($function_name))
41 {
42 $ret[$theme_key] = $theme;
43 }
44 }
45 return $ret;
46 }
47
48 function themesettings_help($section)
49 {
50 switch ($section)
51 {
52 case 'admin/modules#themesettings':
53 $ret = 'themesettings';
54 break;
55 case 'admin/modules#description':
56 $ret = t('This module allows themes to include additional settings beyond the default features like logo, slogan, or mission');
57 break;
58 }
59 return $ret;
60 }
61
62
63 function themesettings_menu($may_cache)
64 {
65 $items = array();
66
67 if (!$may_cache)
68 {
69 $access = user_access('administer site configuration');
70
71 $items[] = array(
72 'path' => TSBASEPATH,
73 'title' => t('Extended theme settings'),
74 'type' => MENU_NORMAL_ITEM,
75 'access' => $access,
76 'callback' => 'themesettings_page',
77 );
78 foreach (_themesettings_themes() as $theme_name => $theme)
79 {
80 $items[] = array(
81 'path' => TSBASEPATH . "/$theme_name",
82 'title' => $theme_name,
83 'callback' => $theme_name . '_settings',
84 'access' => $access,
85 'type' => MENU_LOCAL_TASK,
86 );
87 }
88 }
89 return $items;
90 }
91
92 function themesettings_page()
93 {
94 $ret = t('<p>Please select one of the themes having extended settings below.</p>');
95 $links = array();
96 foreach (_themesettings_themes() as $theme_name => $theme_name)
97 {
98 $links[] = l($theme_name, TSBASEPATH . "/$theme_name");
99 }
100 $ret .= theme('item_list', $links);
101 return $ret;
102 }

  ViewVC Help
Powered by ViewVC 1.1.2