Wiki source code of Color Themes

Last modified by Admin on 2010/05/19 20:19

Show last authors
1 = Color Themes =
2 {{velocity output="false"}}
3 #if("$!request.xaction" == 'setTheme' && "$!request.theme" != '' && $hasAdmin)
4 #set($preferencesDoc = $xwiki.getDocument('XWiki.XWikiPreferences'))
5 #set($preferencesObj = $preferencesDoc.getObject('XWiki.XWikiPreferences'))
6 $preferencesObj.set('colorTheme', $request.theme)
7 $preferencesDoc.save()
8 ## Redirect without xaction, so that refreshing doesn't set the same theme again.
9 $response.sendRedirect($doc.getURL('view', "theme=$request.theme"))
10 #stop
11 #elseif("$!request.xaction" == 'create' && "$!request.newThemeName" != '')
12 $response.sendRedirect($xwiki.getDocument('ColorThemes', $request.newThemeName).getURL('inline', 'template=ColorThemes.ColorThemeTemplate'))
13 #stop
14 #end
15
16 $xwiki.ssx.use($doc.fullName)
17
18
19 ##
20 ## Page mockup, for displaying the theme colors
21 ##
22 #macro(themeMiniDemo $theme)
23 <div class="x-demo-page" style="background-color: $theme.pageBackgroundColor">
24 <div class="x-demo-top-menu" style="background-color: $theme.menuBackgroundColor"> </div>
25 <div class="x-demo-header" style="background-color: $theme.pageHeaderBackgroundColor"> </div>
26 <div class="x-demo-page-content" style="background-color: $theme.pageContentBackgroundColor">
27 <div class="x-demo-title" style="background-color: $theme.titleColor; border-color: $theme.borderColor"> </div>
28 <div class="x-demo-text1" style="background-color: $theme.textColor"></div>
29 <div class="x-demo-text2" style="background-color: $theme.textColor"></div>
30 <div class="x-demo-text3" style="background-color: $theme.textColor"></div>
31 <div class="x-demo-text4" style="background-color: $theme.linkColor"></div>
32 <div class="x-demo-text5" style="background-color: $theme.textColor"></div>
33 </div>
34 <div class="x-demo-right-panel">
35 <div class="x-demo-panel-header" style="background-color: $theme.panelHeaderBackgroundColor; border-color: $theme.borderColor">
36 <div class="x-demo-panel-header-text" style="background-color: $theme.panelHeaderTextColor"> </div>
37 </div>
38 <div class="x-demo-panel-contents" style="background-color: $theme.panelBackgroundColor">
39 <div class="x-demo-panel-text1" style="background-color: $theme.panelTextColor"> </div>
40 <div class="x-demo-panel-text2" style="background-color: $theme.panelTextColor"> </div>
41 <div class="x-demo-panel-text3" style="background-color: $theme.panelTextColor"> </div>
42 </div>
43 </div>
44 </div>
45 #end
46 ##
47 ##
48 ## Theme information: title, creator, mockup
49 ##
50 #macro(displayTheme $themeDocName)
51 #if($xwiki.getXWikiPreference('colorTheme') == $themeDocName)
52 #set($isCurrentTheme = true)
53 #else
54 #set($isCurrentTheme = false)
55 #end
56 #set($themeDoc = $xwiki.getDocument($themeDocName))
57 #set($themeObj = $themeDoc.getObject('ColorThemes.ColorThemeClass', true))
58 #template('colorThemeInit.vm')
59 <div class="x-theme#if($isCurrentTheme) current-theme#end">
60 #themeMiniDemo($theme)
61 <div class="x-theme-info">
62 <div class="x-theme-title">[[$themeDoc.displayTitle>>$themeDocName]]</div>
63 {{html wiki="false"}}
64 <span class="theme-info">$msg.get('core.footer.creation', [$xwiki.getUserName($themeDoc.creator), $xwiki.formatDate($themeDoc.creationDate)])</span>
65 #if($hasAdmin && !$isCurrentTheme)
66 <div class="x-theme-set" id="$themeDoc.fullName">
67 <a href="$doc.getURL('view', "xaction=setTheme&theme=${themeDoc.fullName}")" class="use-theme">$msg.get('xe.themes.useTheme')</a>
68 </div>
69 #end
70 {{/html}}
71 </div>
72 </div>
73 #end
74 ##
75 ## End macros
76 ##
77 ##
78 {{/velocity}}
79
80 {{velocity}}
81 #if("$!request.theme" != '')
82 {{info}}$msg.get('xe.themes.themeSet', [$xwiki.getDocument($request.theme).displayTitle]){{/info}}
83 #end
84 {{html wiki="true"}}
85 #set($currentTheme = $xwiki.getDocument('XWiki.XWikiPreferences').getObject('XWiki.XWikiPreferences').getProperty('colorTheme').value)
86 #if("$!currentTheme" == '')
87 #set($currentTheme = 'ColorThemes.DefaultColorTheme')
88 #end
89 == $msg.get('xe.themes.current') ==
90 #displayTheme($currentTheme)
91 <div class="clearfloats"></div>
92 #set($query = ", BaseObject as theme where doc.fullName=theme.name and theme.className='ColorThemes.ColorThemeClass' and doc.fullName<>'ColorThemes.ColorThemeTemplate' and doc.fullName<>'$currentTheme' and doc.fullName<>'ColorThemes.ColorThemeSheet' order by doc.title")
93 #set($themeList = $xwiki.searchDocuments($query, 0, 0))
94 #if($themeList.size() > 0)
95 == $msg.get('xe.themes.others') ==
96 #end
97 #if(!$isGuest)
98 <form action="$doc.getURL()" method="post">
99 <div class="x-theme-create">
100 <input type="hidden" name="xaction" value="create"/>
101 <label for="newThemeName" class="hidden">$msg.get('xe.themes.create.nameLabel')</label>
102 <input type="text" name="newThemeName" id="newThemeName" value="$msg.get('xe.themes.create.nameTip')" class="withTip"/>
103 <span class="buttonwrapper"><input type="submit" value="$msg.get('xe.themes.create')" class="button"/></span>
104 </div>
105 </form>
106 #end
107 <div class="clearfloats"></div>
108 #foreach($themeDocName in $themeList)
109 #displayTheme($themeDocName)
110 #end
111 <div class="clearfloats"></div>
112 {{/html}}
113 {{/velocity}}