File: blog_theme.php

package info (click to toggle)
dotclear 2.6.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 8,420 kB
  • sloc: php: 54,270; sql: 1,290; sh: 213; xml: 173; makefile: 158
file content (236 lines) | stat: -rw-r--r-- 6,260 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<?php
# -- BEGIN LICENSE BLOCK ---------------------------------------
#
# This file is part of Dotclear 2.
#
# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
# Licensed under the GPL version 2.0 license.
# See LICENSE file or
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK -----------------------------------------

require dirname(__FILE__).'/../inc/admin/prepend.php';

dcPage::check('admin');

# -- Loading themes --
$core->themes = new dcThemes($core);
$core->themes->loadModules($core->blog->themes_path, null);

# -- Page helper --
$list = new adminThemesList(
	$core->themes,
	$core->blog->themes_path,
	$core->blog->settings->system->store_theme_url
);
adminThemesList::$distributed_modules = explode(',', DC_DISTRIB_THEMES);

# -- Theme screenshot --
if (!empty($_GET['shot']) && $list->modules->moduleExists($_GET['shot'])) {

	$f= path::real(empty($_GET['src']) ?
		$core->blog->themes_path.'/'.$_GET['shot'].'/screenshot.jpg' :
		$core->blog->themes_path.'/'.$_GET['shot'].'/'.path::clean($_GET['src'])
	);

	if (!file_exists($f)) {
		$f = dirname(__FILE__).'/images/noscreenshot.png';
	}

	http::cache(array_merge(array($f), get_included_files()));

	header('Content-Type: '.files::getMimeType($f));
	header('Content-Length: '.filesize($f));
	readfile($f);

	exit;
}

# -- Display module configuration page --
if ($list->setConfiguration($core->blog->settings->system->theme)) {

	# Get content before page headers
	include $list->includeConfiguration();

	# Gather content
	$list->getConfiguration();

	# Display page
	dcPage::open(__('Blog appearance'),
		dcPage::jsPageTabs().
		dcPage::jsColorPicker().

		# --BEHAVIOR-- themesToolsHeaders
		$core->callBehavior('themesToolsHeaders', $core, true),

		dcPage::breadcrumb(
			array(
				html::escapeHTML($core->blog->name) => '',
				__('Blog appearance') => $list->getURL('',false),
				'<span class="page-title">'.__('Theme configuration').'</span>' => ''
			))
	);

	# Display previously gathered content
	$list->displayConfiguration();

	dcPage::helpBlock('core_blog_theme_conf');
	dcPage::close();

	# Stop reading code here
	return;
}

# -- Execute actions --
try {
	$list->doActions();
}
catch (Exception $e) {
	$core->error->add($e->getMessage());
}

# -- Page header --
dcPage::open(__('Themes management'),
	dcPage::jsLoad('js/_blog_theme.js').
	dcPage::jsPageTabs().
	dcPage::jsColorPicker().

	# --BEHAVIOR-- themesToolsHeaders
	$core->callBehavior('themesToolsHeaders', $core, false),

	dcPage::breadcrumb(
		array(
			html::escapeHTML($core->blog->name) => '',
			'<span class="page-title">'.__('Blog appearance').'</span>' => ''
		))
);

# -- Display modules lists --
if ($core->auth->isSuperAdmin() && $list->isWritablePath()) {

	# Updated modules from repo
	$modules = $list->store->get(true);
	if (!empty($modules)) {
		echo
		'<div class="multi-part" id="update" title="'.html::escapeHTML(__('Update themes')).'">'.
		'<h3>'.html::escapeHTML(__('Update themes')).'</h3>'.
		'<p>'.sprintf(
			__('There is one theme to update available from repository.', 'There are %s themes to update available from repository.', count($modules)),
			count($modules)
		).'</p>';

		$list
			->setList('theme-update')
			->setTab('themes')
			->setModules($modules)
			->displayModules(
				/*cols */		array('checkbox', 'name', 'sshot', 'desc', 'author', 'version', 'current_version', 'parent'),
				/* actions */	array('update', 'delete')
			);

		echo
		'<p class="info vertical-separator">'.sprintf(
			__("Visit %s repository, the resources center for Dotclear."),
			'<a href="http://themes.dotaddict.org/dc2/">Dotaddict</a>'
			).
		'</p>'.

		'</div>';
	}
}

# Activated modules
$modules = $list->modules->getModules();
if (!empty($modules)) {

	echo
	'<div class="multi-part" id="themes" title="'.__('Installed themes').'">'.
	'<h3>'.__('Installed themes').'</h3>'.
	'<p>'.__('You can configure and manage installed themes from this list.').'</p>';

	$list
		->setList('theme-activate')
		->setTab('themes')
		->setModules($modules)
		->displayModules(
			/* cols */		array('sshot', 'distrib', 'name', 'config', 'desc', 'author', 'version', 'parent'),
			/* actions */	array('select', 'behavior', 'deactivate', 'delete')
		);

	echo
	'</div>';
}

# Deactivated modules
$modules = $list->modules->getDisabledModules();
if (!empty($modules)) {

	echo
	'<div class="multi-part" id="deactivate" title="'.__('Deactivated themes').'">'.
	'<h3>'.__('Deactivated themes').'</h3>'.
	'<p>'.__('Deactivated themes are installed but not usable. You can activate them from here.').'</p>';

	$list
		->setList('theme-deactivate')
		->setTab('themes')
		->setModules($modules)
		->displayModules(
			/* cols */		array('name', 'distrib'),
			/* actions */	array('activate', 'delete')
		);

	echo
	'</div>';
}

if ($core->auth->isSuperAdmin() && $list->isWritablePath()) {

	# New modules from repo
	$search = $list->getSearch();
	$modules = $search ? $list->store->search($search) : $list->store->get();

	if (!empty($search) || !empty($modules)) {
		echo
		'<div class="multi-part" id="new" title="'.__('Add themes').'">'.
		'<h3>'.__('Add themes from repository').'</h3>';
//		'<p>'.__('Search and install themes directly from repository.').'</p>';

		$list
			->setList('theme-new')
			->setTab('new')
			->setModules($modules)
			->displaySearch()
			->displayIndex()
			->displayModules(
				/* cols */		array('expander', 'sshot', 'name', 'score', 'config', 'desc', 'author', 'version', 'parent', 'details', 'support'),
				/* actions */	array('install'),
				/* nav limit */	true
			);

		echo
		'<p class="info vertical-separator">'.sprintf(
			__("Visit %s repository, the resources center for Dotclear."),
			'<a href="http://themes.dotaddict.org/galerie-dc2/">Dotaddict</a>'
			).
		'</p>'.

		'</div>';
	}

	# Add a new plugin
	echo
	'<div class="multi-part" id="addtheme" title="'.__('Install or upgrade manually').'">'.
	'<h3>'.__('Add themes from a package').'</h3>'.
	'<p>'.__('You can install themes by uploading or downloading zip files.').'</p>';

	$list->displayManualForm();

	echo
	'</div>';
}

# --BEHAVIOR-- themesToolsTabs
$core->callBehavior('themesToolsTabs', $core);
dcPage::helpBlock('core_blog_theme');
dcPage::close();