1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
3 | # |
---|
4 | # This file is part of Dotclear 2. |
---|
5 | # |
---|
6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
---|
7 | # Licensed under the GPL version 2.0 license. |
---|
8 | # See LICENSE file or |
---|
9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
10 | # |
---|
11 | # -- END LICENSE BLOCK ----------------------------------------- |
---|
12 | if (!defined('DC_RC_PATH')) { return; } |
---|
13 | |
---|
14 | define('DC_AUTH_PAGE','auth.php'); |
---|
15 | |
---|
16 | class dcPage |
---|
17 | { |
---|
18 | private static $loaded_js=array(); |
---|
19 | |
---|
20 | # Auth check |
---|
21 | public static function check($permissions) |
---|
22 | { |
---|
23 | global $core; |
---|
24 | |
---|
25 | if ($core->blog && $core->auth->check($permissions,$core->blog->id)) |
---|
26 | { |
---|
27 | return; |
---|
28 | } |
---|
29 | |
---|
30 | if (session_id()) { |
---|
31 | $core->session->destroy(); |
---|
32 | } |
---|
33 | http::redirect(DC_AUTH_PAGE); |
---|
34 | } |
---|
35 | |
---|
36 | # Check super admin |
---|
37 | public static function checkSuper() |
---|
38 | { |
---|
39 | global $core; |
---|
40 | |
---|
41 | if (!$core->auth->isSuperAdmin()) |
---|
42 | { |
---|
43 | if (session_id()) { |
---|
44 | $core->session->destroy(); |
---|
45 | } |
---|
46 | http::redirect(DC_AUTH_PAGE); |
---|
47 | } |
---|
48 | } |
---|
49 | |
---|
50 | # Top of admin page |
---|
51 | public static function open($title='', $head='') |
---|
52 | { |
---|
53 | global $core; |
---|
54 | |
---|
55 | # List of user's blogs |
---|
56 | if ($core->auth->blog_count == 1 || $core->auth->blog_count > 20) |
---|
57 | { |
---|
58 | $blog_box = |
---|
59 | '<p>'.__('Blog:').' <strong title="'.html::escapeHTML($core->blog->url).'">'. |
---|
60 | html::escapeHTML($core->blog->name).'</strong>'; |
---|
61 | |
---|
62 | if ($core->auth->blog_count > 20) { |
---|
63 | $blog_box .= ' - <a href="blogs.php">'.__('Change blog').'</a>'; |
---|
64 | } |
---|
65 | $blog_box .= '</p>'; |
---|
66 | } |
---|
67 | else |
---|
68 | { |
---|
69 | $rs_blogs = $core->getBlogs(array('order'=>'LOWER(blog_name)','limit'=>20)); |
---|
70 | $blogs = array(); |
---|
71 | while ($rs_blogs->fetch()) { |
---|
72 | $blogs[html::escapeHTML($rs_blogs->blog_name.' - '.$rs_blogs->blog_url)] = $rs_blogs->blog_id; |
---|
73 | } |
---|
74 | $blog_box = |
---|
75 | '<p><label for="switchblog" class="classic nomobile">'. |
---|
76 | __('Blogs:').'</label> '. |
---|
77 | $core->formNonce(). |
---|
78 | form::combo('switchblog',$blogs,$core->blog->id). |
---|
79 | '</p>'. |
---|
80 | '<noscript><p><input type="submit" value="'.__('ok').'" /></p></noscript>'; |
---|
81 | } |
---|
82 | |
---|
83 | $safe_mode = isset($_SESSION['sess_safe_mode']) && $_SESSION['sess_safe_mode']; |
---|
84 | |
---|
85 | # Display |
---|
86 | header('Content-Type: text/html; charset=UTF-8'); |
---|
87 | echo |
---|
88 | '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '. |
---|
89 | ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n". |
---|
90 | '<html xmlns="http://www.w3.org/1999/xhtml" '. |
---|
91 | 'xml:lang="'.$core->auth->getInfo('user_lang').'" '. |
---|
92 | 'lang="'.$core->auth->getInfo('user_lang').'">'."\n". |
---|
93 | "<head>\n". |
---|
94 | ' <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'."\n". |
---|
95 | ' <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />'."\n". |
---|
96 | ' <meta name="GOOGLEBOT" content="NOSNIPPET" />'."\n". |
---|
97 | ' <meta name="viewport" content="width=device-width, initial-scale=1.0" />'."\n". |
---|
98 | ' <title>'.$title.' - '.html::escapeHTML($core->blog->name).' - '.html::escapeHTML(DC_VENDOR_NAME).' - '.DC_VERSION.'</title>'."\n". |
---|
99 | |
---|
100 | |
---|
101 | self::jsLoadIE7(). |
---|
102 | ' <link rel="stylesheet" href="style/default.css" type="text/css" media="screen" />'."\n"; |
---|
103 | if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') { |
---|
104 | echo |
---|
105 | ' <link rel="stylesheet" href="style/default-rtl.css" type="text/css" media="screen" />'."\n"; |
---|
106 | } |
---|
107 | |
---|
108 | $core->auth->user_prefs->addWorkspace('interface'); |
---|
109 | $user_ui_hide_std_favicon = $core->auth->user_prefs->interface->hide_std_favicon; |
---|
110 | if (!$user_ui_hide_std_favicon) { |
---|
111 | echo '<link rel="icon" type="image/png" href="images/favicon.png" />'; |
---|
112 | } |
---|
113 | |
---|
114 | echo |
---|
115 | self::jsCommon(). |
---|
116 | $head; |
---|
117 | |
---|
118 | # --BEHAVIOR-- adminPageHTMLHead |
---|
119 | $core->callBehavior('adminPageHTMLHead'); |
---|
120 | |
---|
121 | echo |
---|
122 | "</head>\n". |
---|
123 | '<body id="dotclear-admin'. |
---|
124 | ($safe_mode ? ' safe-mode' : ''). |
---|
125 | '">'."\n". |
---|
126 | |
---|
127 | '<div id="header">'. |
---|
128 | '<ul id="prelude"><li><a href="#content">'.__('Go to the content').'</a></li><li><a href="#main-menu">'.__('Go to the menu').'</a></li></ul>'."\n". |
---|
129 | '<div id="top"><h1><a href="index.php">'.DC_VENDOR_NAME.'</a></h1></div>'."\n"; |
---|
130 | |
---|
131 | echo |
---|
132 | '<div id="info-boxes">'. |
---|
133 | '<div id="info-box1">'. |
---|
134 | '<form action="index.php" method="post">'. |
---|
135 | $blog_box. |
---|
136 | '<p class="nomobile"><a href="'.$core->blog->url.'" onclick="window.open(this.href);return false;" title="'.__('Go to site').' ('.__('new window').')'.'">'.__('Go to site').' <img src="images/outgoing.png" alt="" /></a>'. |
---|
137 | '</p></form>'. |
---|
138 | '</div>'. |
---|
139 | '<div id="info-box2">'. |
---|
140 | '<a class="smallscreen"'.(preg_match('/index.php$/',$_SERVER['REQUEST_URI']) ? ' class="active"' : '').' href="index.php">'.__('My dashboard').'</a>'. |
---|
141 | '<span class="smallscreen"> | </span><a class="smallscreen"'.(preg_match('/preferences.php(\?.*)?$/',$_SERVER['REQUEST_URI']) ? ' class="active smallscreen"' : '').' href="preferences.php">'.__('My preferences').'</a>'. |
---|
142 | '<span class="smallscreen"> | </span><a href="index.php?logout=1" class="logout">'.sprintf(__('Logout %s'),$core->auth->userID()).' <img src="images/logout.png" alt="" /></a>'. |
---|
143 | '</div>'. |
---|
144 | '</div>'. |
---|
145 | '</div>'; |
---|
146 | |
---|
147 | echo |
---|
148 | '<div id="wrapper">'."\n". |
---|
149 | '<div id="main">'."\n". |
---|
150 | '<div id="content">'."\n"; |
---|
151 | |
---|
152 | # Safe mode |
---|
153 | if ($safe_mode) |
---|
154 | { |
---|
155 | echo |
---|
156 | '<div class="error"><h3>'.__('Safe mode').'</h3>'. |
---|
157 | '<p>'.__('You are in safe mode. All plugins have been temporarily disabled. Remind to log out then log in again normally to get back all functionalities').'</p>'. |
---|
158 | '</div>'; |
---|
159 | } |
---|
160 | |
---|
161 | if ($core->error->flag()) { |
---|
162 | echo |
---|
163 | '<div class="error"><p><strong>'.(count($core->error->getErrors()) > 1 ? __('Errors:') : __('Error:')).'</p></strong>'. |
---|
164 | $core->error->toHTML(). |
---|
165 | '</div>'; |
---|
166 | } |
---|
167 | } |
---|
168 | |
---|
169 | public static function close() |
---|
170 | { |
---|
171 | global $core; |
---|
172 | |
---|
173 | $menu =& $GLOBALS['_menu']; |
---|
174 | |
---|
175 | echo |
---|
176 | "</div>\n". // End of #content |
---|
177 | "</div>\n". // End of #main |
---|
178 | |
---|
179 | '<div id="main-menu">'."\n". |
---|
180 | |
---|
181 | '<form id="search-menu" action="search.php" method="get">'. |
---|
182 | '<p><label for="q" class="hidden">'.__('Search:').' </label>'.form::field('q',30,255,''). |
---|
183 | '<input type="submit" value="'.__('OK').'" /></p>'. |
---|
184 | '</form>'; |
---|
185 | |
---|
186 | foreach ($menu as $k => $v) { |
---|
187 | echo $menu[$k]->draw(); |
---|
188 | } |
---|
189 | |
---|
190 | $text = sprintf(__('Thank you for using %s.'),'Dotclear '.DC_VERSION); |
---|
191 | |
---|
192 | # --BEHAVIOR-- adminPageFooter |
---|
193 | $textAlt = $core->callBehavior('adminPageFooter',$core,$text); |
---|
194 | if ($textAlt != '') { |
---|
195 | $text = $textAlt; |
---|
196 | } |
---|
197 | $text = html::escapeHTML($text); |
---|
198 | |
---|
199 | echo |
---|
200 | '</div>'."\n". // End of #main-menu |
---|
201 | '<div id="footer"><a href="http://dotclear.org/" title="'.$text.'"><img src="style/dc_logo_footer.png" alt="'.$text.'" /></a></div>'."\n". |
---|
202 | "</div>\n"; // End of #wrapper |
---|
203 | |
---|
204 | if (defined('DC_DEV') && DC_DEV === true) { |
---|
205 | echo self::debugInfo(); |
---|
206 | } |
---|
207 | |
---|
208 | echo |
---|
209 | '</body></html>'; |
---|
210 | } |
---|
211 | |
---|
212 | public static function openPopup($title='', $head='') |
---|
213 | { |
---|
214 | global $core; |
---|
215 | |
---|
216 | # Display |
---|
217 | header('Content-Type: text/html; charset=UTF-8'); |
---|
218 | echo |
---|
219 | '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '. |
---|
220 | ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n". |
---|
221 | '<html xmlns="http://www.w3.org/1999/xhtml" '. |
---|
222 | 'xml:lang="'.$core->auth->getInfo('user_lang').'" '. |
---|
223 | 'lang="'.$core->auth->getInfo('user_lang').'">'."\n". |
---|
224 | '<meta name="viewport" content="width=device-width, initial-scale=1.0" />'."\n". |
---|
225 | "<head>\n". |
---|
226 | ' <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'."\n". |
---|
227 | ' <title>'.$title.' - '.html::escapeHTML($core->blog->name).' - '.html::escapeHTML(DC_VENDOR_NAME).' - '.DC_VERSION.'</title>'."\n". |
---|
228 | |
---|
229 | ' <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />'."\n". |
---|
230 | ' <meta name="GOOGLEBOT" content="NOSNIPPET" />'."\n". |
---|
231 | |
---|
232 | self::jsLoadIE7(). |
---|
233 | ' <link rel="stylesheet" href="style/default.css" type="text/css" media="screen" />'."\n"; |
---|
234 | if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') { |
---|
235 | echo |
---|
236 | ' <link rel="stylesheet" href="style/default-rtl.css" type="text/css" media="screen" />'."\n"; |
---|
237 | } |
---|
238 | |
---|
239 | echo |
---|
240 | self::jsCommon(). |
---|
241 | $head; |
---|
242 | |
---|
243 | # --BEHAVIOR-- adminPageHTMLHead |
---|
244 | $core->callBehavior('adminPageHTMLHead'); |
---|
245 | |
---|
246 | echo |
---|
247 | "</head>\n". |
---|
248 | '<body id="dotclear-admin" class="popup">'."\n". |
---|
249 | |
---|
250 | '<div id="top hidden"><h1>'.DC_VENDOR_NAME.'</h1></div>'."\n"; |
---|
251 | |
---|
252 | echo |
---|
253 | '<div id="wrapper">'."\n". |
---|
254 | '<div id="main">'."\n". |
---|
255 | '<div id="content">'."\n"; |
---|
256 | |
---|
257 | if ($core->error->flag()) { |
---|
258 | echo |
---|
259 | '<div class="error"><strong>'.__('Errors:').'</strong>'. |
---|
260 | $core->error->toHTML(). |
---|
261 | '</div>'; |
---|
262 | } |
---|
263 | } |
---|
264 | |
---|
265 | public static function closePopup() |
---|
266 | { |
---|
267 | echo |
---|
268 | "</div>\n". // End of #content |
---|
269 | "</div>\n". // End of #main |
---|
270 | '<div id="footer"><p> </p></div>'."\n". |
---|
271 | "</div>\n". // End of #wrapper |
---|
272 | '</body></html>'; |
---|
273 | } |
---|
274 | |
---|
275 | public static function message($msg,$timestamp=true,$div=false,$echo=true) |
---|
276 | { |
---|
277 | global $core; |
---|
278 | |
---|
279 | $res = ''; |
---|
280 | if ($msg != '') { |
---|
281 | $res = ($div ? '<div class="message">' : '').'<p'.($div ? '' : ' class="message"').'>'. |
---|
282 | ($timestamp ? dt::str(__('%H:%M:%S:'),null,$core->auth->getInfo('user_tz')).' ' : '').$msg. |
---|
283 | '</p>'.($div ? '</div>' : ''); |
---|
284 | if ($echo) { |
---|
285 | echo $res; |
---|
286 | } |
---|
287 | } |
---|
288 | return $res; |
---|
289 | } |
---|
290 | |
---|
291 | private static function debugInfo() |
---|
292 | { |
---|
293 | $global_vars = implode(', ',array_keys($GLOBALS)); |
---|
294 | |
---|
295 | $res = |
---|
296 | '<div id="debug"><div>'. |
---|
297 | '<p>memory usage: '.memory_get_usage().' ('.files::size(memory_get_usage()).')</p>'; |
---|
298 | |
---|
299 | if (function_exists('xdebug_get_profiler_filename')) |
---|
300 | { |
---|
301 | $res .= '<p>Elapsed time: '.xdebug_time_index().' seconds</p>'; |
---|
302 | |
---|
303 | $prof_file = xdebug_get_profiler_filename(); |
---|
304 | if ($prof_file) { |
---|
305 | $res .= '<p>Profiler file : '.xdebug_get_profiler_filename().'</p>'; |
---|
306 | } else { |
---|
307 | $prof_url = http::getSelfURI(); |
---|
308 | $prof_url .= (strpos($prof_url,'?') === false) ? '?' : '&'; |
---|
309 | $prof_url .= 'XDEBUG_PROFILE'; |
---|
310 | $res .= '<p><a href="'.html::escapeURL($prof_url).'">Trigger profiler</a></p>'; |
---|
311 | } |
---|
312 | |
---|
313 | /* xdebug configuration: |
---|
314 | zend_extension = /.../xdebug.so |
---|
315 | xdebug.auto_trace = On |
---|
316 | xdebug.trace_format = 0 |
---|
317 | xdebug.trace_options = 1 |
---|
318 | xdebug.show_mem_delta = On |
---|
319 | xdebug.profiler_enable = 0 |
---|
320 | xdebug.profiler_enable_trigger = 1 |
---|
321 | xdebug.profiler_output_dir = /tmp |
---|
322 | xdebug.profiler_append = 0 |
---|
323 | xdebug.profiler_output_name = timestamp |
---|
324 | */ |
---|
325 | } |
---|
326 | |
---|
327 | $res .= |
---|
328 | '<p>Global vars: '.$global_vars.'</p>'. |
---|
329 | '</div></div>'; |
---|
330 | |
---|
331 | return $res; |
---|
332 | } |
---|
333 | |
---|
334 | public static function help($page,$index='') |
---|
335 | { |
---|
336 | # Deprecated but we keep this for plugins. |
---|
337 | } |
---|
338 | |
---|
339 | public static function helpBlock() |
---|
340 | { |
---|
341 | $args = func_get_args(); |
---|
342 | if (empty($args)) { |
---|
343 | return; |
---|
344 | }; |
---|
345 | |
---|
346 | global $__resources; |
---|
347 | if (empty($__resources['help'])) { |
---|
348 | return; |
---|
349 | } |
---|
350 | |
---|
351 | $content = ''; |
---|
352 | foreach ($args as $v) |
---|
353 | { |
---|
354 | if (is_object($v) && isset($v->content)) { |
---|
355 | $content .= $v->content; |
---|
356 | continue; |
---|
357 | } |
---|
358 | |
---|
359 | if (!isset($__resources['help'][$v])) { |
---|
360 | continue; |
---|
361 | } |
---|
362 | $f = $__resources['help'][$v]; |
---|
363 | if (!file_exists($f) || !is_readable($f)) { |
---|
364 | continue; |
---|
365 | } |
---|
366 | |
---|
367 | $fc = file_get_contents($f); |
---|
368 | if (preg_match('|<body[^>]*?>(.*?)</body>|ms',$fc,$matches)) { |
---|
369 | $content .= $matches[1]; |
---|
370 | } else { |
---|
371 | $content .= $fc; |
---|
372 | } |
---|
373 | } |
---|
374 | |
---|
375 | if (trim($content) == '') { |
---|
376 | return; |
---|
377 | } |
---|
378 | |
---|
379 | echo |
---|
380 | '<div id="help"><hr /><div class="help-content clear"><h2>'.__('Help').'</h2>'. |
---|
381 | $content. |
---|
382 | '</div></div>'; |
---|
383 | } |
---|
384 | |
---|
385 | public static function jsLoad($src) |
---|
386 | { |
---|
387 | $escaped_src = html::escapeHTML($src); |
---|
388 | if (!isset(self::$loaded_js[$escaped_src])) { |
---|
389 | self::$loaded_js[$escaped_src]=true; |
---|
390 | return '<script type="text/javascript" src="'.$escaped_src.'"></script>'."\n"; |
---|
391 | } |
---|
392 | } |
---|
393 | |
---|
394 | public static function jsVar($n,$v) |
---|
395 | { |
---|
396 | return $n." = '".html::escapeJS($v)."';\n"; |
---|
397 | } |
---|
398 | |
---|
399 | public static function jsCommon() |
---|
400 | { |
---|
401 | return |
---|
402 | self::jsLoad('js/jquery/jquery.js'). |
---|
403 | self::jsLoad('js/jquery/jquery.biscuit.js'). |
---|
404 | self::jsLoad('js/jquery/jquery.bgFade.js'). |
---|
405 | self::jsLoad('js/common.js'). |
---|
406 | self::jsLoad('js/prelude.js'). |
---|
407 | |
---|
408 | '<script type="text/javascript">'."\n". |
---|
409 | "//<![CDATA[\n". |
---|
410 | self::jsVar('dotclear.nonce',$GLOBALS['core']->getNonce()). |
---|
411 | |
---|
412 | self::jsVar('dotclear.img_plus_src','images/expand.png'). |
---|
413 | self::jsVar('dotclear.img_plus_alt',__('uncover')). |
---|
414 | self::jsVar('dotclear.img_minus_src','images/hide.png'). |
---|
415 | self::jsVar('dotclear.img_minus_alt',__('hide')). |
---|
416 | self::jsVar('dotclear.img_menu_on','images/menu_on.png'). |
---|
417 | self::jsVar('dotclear.img_menu_off','images/menu_off.png'). |
---|
418 | |
---|
419 | self::jsVar('dotclear.msg.help', |
---|
420 | __('Help about this page')). |
---|
421 | self::jsVar('dotclear.msg.help_hide', |
---|
422 | __('Hide')). |
---|
423 | self::jsVar('dotclear.msg.no_selection', |
---|
424 | __('no selection')). |
---|
425 | self::jsVar('dotclear.msg.select_all', |
---|
426 | __('select all')). |
---|
427 | self::jsVar('dotclear.msg.invert_sel', |
---|
428 | __('invert selection')). |
---|
429 | self::jsVar('dotclear.msg.website', |
---|
430 | __('Web site:')). |
---|
431 | self::jsVar('dotclear.msg.email', |
---|
432 | __('Email:')). |
---|
433 | self::jsVar('dotclear.msg.ip_address', |
---|
434 | __('IP address:')). |
---|
435 | self::jsVar('dotclear.msg.error', |
---|
436 | __('Error:')). |
---|
437 | self::jsVar('dotclear.msg.entry_created', |
---|
438 | __('Entry has been successfully created.')). |
---|
439 | self::jsVar('dotclear.msg.edit_entry', |
---|
440 | __('Edit entry')). |
---|
441 | self::jsVar('dotclear.msg.view_entry', |
---|
442 | __('view entry')). |
---|
443 | self::jsVar('dotclear.msg.confirm_delete_posts', |
---|
444 | __("Are you sure you want to delete selected entries (%s)?")). |
---|
445 | self::jsVar('dotclear.msg.confirm_delete_post', |
---|
446 | __("Are you sure you want to delete this entry?")). |
---|
447 | self::jsVar('dotclear.msg.confirm_spam_delete', |
---|
448 | __('Are you sure you want to delete all spams?')). |
---|
449 | self::jsVar('dotclear.msg.confirm_delete_comments', |
---|
450 | __('Are you sure you want to delete selected comments (%s)?')). |
---|
451 | self::jsVar('dotclear.msg.confirm_delete_comment', |
---|
452 | __('Are you sure you want to delete this comment?')). |
---|
453 | self::jsVar('dotclear.msg.cannot_delete_users', |
---|
454 | __('Users with posts cannot be deleted.')). |
---|
455 | self::jsVar('dotclear.msg.confirm_delete_user', |
---|
456 | __('Are you sure you want to delete selected users (%s)?')). |
---|
457 | self::jsVar('dotclear.msg.confirm_delete_category', |
---|
458 | __('Are you sure you want to delete category "%s"?')). |
---|
459 | self::jsVar('dotclear.msg.confirm_reorder_categories', |
---|
460 | __('Are you sure you want to reorder all categories?')). |
---|
461 | self::jsVar('dotclear.msg.confirm_delete_media', |
---|
462 | __('Are you sure you want to remove media "%s"?')). |
---|
463 | self::jsVar('dotclear.msg.confirm_extract_current', |
---|
464 | __('Are you sure you want to extract archive in current directory?')). |
---|
465 | self::jsVar('dotclear.msg.confirm_remove_attachment', |
---|
466 | __('Are you sure you want to remove attachment "%s"?')). |
---|
467 | self::jsVar('dotclear.msg.confirm_delete_lang', |
---|
468 | __('Are you sure you want to delete "%s" language?')). |
---|
469 | self::jsVar('dotclear.msg.confirm_delete_plugin', |
---|
470 | __('Are you sure you want to delete "%s" plugin?')). |
---|
471 | self::jsVar('dotclear.msg.use_this_theme', |
---|
472 | __('Use this theme')). |
---|
473 | self::jsVar('dotclear.msg.remove_this_theme', |
---|
474 | __('Remove this theme')). |
---|
475 | self::jsVar('dotclear.msg.confirm_delete_theme', |
---|
476 | __('Are you sure you want to delete "%s" theme?')). |
---|
477 | self::jsVar('dotclear.msg.zip_file_content', |
---|
478 | __('Zip file content')). |
---|
479 | self::jsVar('dotclear.msg.xhtml_validator', |
---|
480 | __('XHTML markup validator')). |
---|
481 | self::jsVar('dotclear.msg.xhtml_valid', |
---|
482 | __('XHTML content is valid.')). |
---|
483 | self::jsVar('dotclear.msg.xhtml_not_valid', |
---|
484 | __('There are XHTML markup errors.')). |
---|
485 | self::jsVar('dotclear.msg.confirm_change_post_format', |
---|
486 | __('You have unsaved changes. Switch post format will loose these changes. Proceed anyway?')). |
---|
487 | self::jsVar('dotclear.msg.load_enhanced_uploader', |
---|
488 | __('Loading enhanced uploader, please wait.')). |
---|
489 | "\n//]]>\n". |
---|
490 | "</script>\n"; |
---|
491 | } |
---|
492 | |
---|
493 | public static function jsLoadIE7() |
---|
494 | { |
---|
495 | return |
---|
496 | '<!--[if lt IE 8]>'."\n". |
---|
497 | self::jsLoad('js/ie7/IE8.js'). |
---|
498 | '<link rel="stylesheet" type="text/css" href="style/iesucks.css" />'."\n". |
---|
499 | '<![endif]-->'."\n"; |
---|
500 | } |
---|
501 | |
---|
502 | public static function jsConfirmClose() |
---|
503 | { |
---|
504 | $args = func_get_args(); |
---|
505 | if (count($args) > 0) { |
---|
506 | foreach ($args as $k => $v) { |
---|
507 | $args[$k] = "'".html::escapeJS($v)."'"; |
---|
508 | } |
---|
509 | $args = implode(',',$args); |
---|
510 | } else { |
---|
511 | $args = ''; |
---|
512 | } |
---|
513 | |
---|
514 | return |
---|
515 | self::jsLoad('js/confirm-close.js'). |
---|
516 | '<script type="text/javascript">'."\n". |
---|
517 | "//<![CDATA[\n". |
---|
518 | "confirmClosePage = new confirmClose(".$args."); ". |
---|
519 | "confirmClose.prototype.prompt = '".html::escapeJS(__('You have unsaved changes.'))."'; ". |
---|
520 | "\n//]]>\n". |
---|
521 | "</script>\n"; |
---|
522 | } |
---|
523 | |
---|
524 | public static function jsPageTabs($default=null) |
---|
525 | { |
---|
526 | if ($default) { |
---|
527 | $default = "'".html::escapeJS($default)."'"; |
---|
528 | } |
---|
529 | |
---|
530 | return |
---|
531 | self::jsLoad('js/jquery/jquery.pageTabs.js'). |
---|
532 | '<script type="text/javascript">'."\n". |
---|
533 | "//<![CDATA[\n". |
---|
534 | "\$(function() {\n". |
---|
535 | " \$.pageTabs(".$default.");\n". |
---|
536 | "});\n". |
---|
537 | "\n//]]>\n". |
---|
538 | "</script>\n"; |
---|
539 | } |
---|
540 | |
---|
541 | public static function jsModal() |
---|
542 | { |
---|
543 | return |
---|
544 | '<link rel="stylesheet" type="text/css" href="style/modal/modal.css" />'."\n". |
---|
545 | self::jsLoad('js/jquery/jquery.modal.js'). |
---|
546 | '<script type="text/javascript">'."\n". |
---|
547 | "//<![CDATA[\n". |
---|
548 | self::jsVar('$.modal.prototype.params.loader_img','style/modal/loader.gif'). |
---|
549 | self::jsVar('$.modal.prototype.params.close_img','style/modal/close.png'). |
---|
550 | "\n//]]>\n". |
---|
551 | "</script>\n"; |
---|
552 | } |
---|
553 | |
---|
554 | public static function jsColorPicker() |
---|
555 | { |
---|
556 | return |
---|
557 | '<link rel="stylesheet" type="text/css" href="style/farbtastic/farbtastic.css" />'."\n". |
---|
558 | self::jsLoad('js/jquery/jquery.farbtastic.js'). |
---|
559 | self::jsLoad('js/color-picker.js'); |
---|
560 | } |
---|
561 | |
---|
562 | public static function jsDatePicker() |
---|
563 | { |
---|
564 | return |
---|
565 | '<link rel="stylesheet" type="text/css" href="style/date-picker.css" />'."\n". |
---|
566 | self::jsLoad('js/date-picker.js'). |
---|
567 | '<script type="text/javascript">'."\n". |
---|
568 | "//<![CDATA[\n". |
---|
569 | |
---|
570 | "datePicker.prototype.months[0] = '".html::escapeJS(__('January'))."'; ". |
---|
571 | "datePicker.prototype.months[1] = '".html::escapeJS(__('February'))."'; ". |
---|
572 | "datePicker.prototype.months[2] = '".html::escapeJS(__('March'))."'; ". |
---|
573 | "datePicker.prototype.months[3] = '".html::escapeJS(__('April'))."'; ". |
---|
574 | "datePicker.prototype.months[4] = '".html::escapeJS(__('May'))."'; ". |
---|
575 | "datePicker.prototype.months[5] = '".html::escapeJS(__('June'))."'; ". |
---|
576 | "datePicker.prototype.months[6] = '".html::escapeJS(__('July'))."'; ". |
---|
577 | "datePicker.prototype.months[7] = '".html::escapeJS(__('August'))."'; ". |
---|
578 | "datePicker.prototype.months[8] = '".html::escapeJS(__('September'))."'; ". |
---|
579 | "datePicker.prototype.months[9] = '".html::escapeJS(__('October'))."'; ". |
---|
580 | "datePicker.prototype.months[10] = '".html::escapeJS(__('November'))."'; ". |
---|
581 | "datePicker.prototype.months[11] = '".html::escapeJS(__('December'))."'; ". |
---|
582 | |
---|
583 | "datePicker.prototype.days[0] = '".html::escapeJS(__('Monday'))."'; ". |
---|
584 | "datePicker.prototype.days[1] = '".html::escapeJS(__('Tuesday'))."'; ". |
---|
585 | "datePicker.prototype.days[2] = '".html::escapeJS(__('Wednesday'))."'; ". |
---|
586 | "datePicker.prototype.days[3] = '".html::escapeJS(__('Thursday'))."'; ". |
---|
587 | "datePicker.prototype.days[4] = '".html::escapeJS(__('Friday'))."'; ". |
---|
588 | "datePicker.prototype.days[5] = '".html::escapeJS(__('Saturday'))."'; ". |
---|
589 | "datePicker.prototype.days[6] = '".html::escapeJS(__('Sunday'))."'; ". |
---|
590 | |
---|
591 | "datePicker.prototype.img_src = 'images/date-picker.png'; ". |
---|
592 | |
---|
593 | "datePicker.prototype.close_msg = '".html::escapeJS(__('close'))."'; ". |
---|
594 | "datePicker.prototype.now_msg = '".html::escapeJS(__('now'))."'; ". |
---|
595 | |
---|
596 | "\n//]]>\n". |
---|
597 | "</script>\n"; |
---|
598 | } |
---|
599 | |
---|
600 | public static function jsToolBar() |
---|
601 | { |
---|
602 | $res = |
---|
603 | '<link rel="stylesheet" type="text/css" href="style/jsToolBar/jsToolBar.css" />'. |
---|
604 | '<script type="text/javascript" src="js/jsToolBar/jsToolBar.js"></script>'; |
---|
605 | |
---|
606 | if (isset($GLOBALS['core']->auth) && $GLOBALS['core']->auth->getOption('enable_wysiwyg')) { |
---|
607 | $res .= '<script type="text/javascript" src="js/jsToolBar/jsToolBar.wysiwyg.js"></script>'; |
---|
608 | } |
---|
609 | |
---|
610 | $res .= |
---|
611 | '<script type="text/javascript" src="js/jsToolBar/jsToolBar.dotclear.js"></script>'. |
---|
612 | '<script type="text/javascript">'."\n". |
---|
613 | "//<![CDATA[\n". |
---|
614 | "jsToolBar.prototype.dialog_url = 'popup.php'; ". |
---|
615 | "jsToolBar.prototype.iframe_css = '". |
---|
616 | 'body{'. |
---|
617 | 'font: 12px "DejaVu Sans","Lucida Grande","Lucida Sans Unicode",Arial,sans-serif;'. |
---|
618 | 'color : #000;'. |
---|
619 | 'background: #f9f9f9;'. |
---|
620 | 'margin: 0;'. |
---|
621 | 'padding : 2px;'. |
---|
622 | 'border: none;'. |
---|
623 | (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl' ? 'direction:rtl;' : ''). |
---|
624 | '}'. |
---|
625 | 'pre, code, kbd, samp {'. |
---|
626 | 'font-family:"Courier New",Courier,monospace;'. |
---|
627 | 'font-size : 1.1em;'. |
---|
628 | '}'. |
---|
629 | 'code {'. |
---|
630 | 'color : #666;'. |
---|
631 | 'font-weight : bold;'. |
---|
632 | '}'. |
---|
633 | 'body > p:first-child {'. |
---|
634 | 'margin-top: 0;'. |
---|
635 | '}'. |
---|
636 | "'; ". |
---|
637 | "jsToolBar.prototype.base_url = '".html::escapeJS($GLOBALS['core']->blog->host)."'; ". |
---|
638 | "jsToolBar.prototype.switcher_visual_title = '".html::escapeJS(__('visual'))."'; ". |
---|
639 | "jsToolBar.prototype.switcher_source_title = '".html::escapeJS(__('source'))."'; ". |
---|
640 | "jsToolBar.prototype.legend_msg = '". |
---|
641 | html::escapeJS(__('You can use the following shortcuts to format your text.'))."'; ". |
---|
642 | "jsToolBar.prototype.elements.blocks.options.none = '".html::escapeJS(__('-- none --'))."'; ". |
---|
643 | "jsToolBar.prototype.elements.blocks.options.nonebis = '".html::escapeJS(__('-- block format --'))."'; ". |
---|
644 | "jsToolBar.prototype.elements.blocks.options.p = '".html::escapeJS(__('Paragraph'))."'; ". |
---|
645 | "jsToolBar.prototype.elements.blocks.options.h1 = '".html::escapeJS(__('Level 1 header'))."'; ". |
---|
646 | "jsToolBar.prototype.elements.blocks.options.h2 = '".html::escapeJS(__('Level 2 header'))."'; ". |
---|
647 | "jsToolBar.prototype.elements.blocks.options.h3 = '".html::escapeJS(__('Level 3 header'))."'; ". |
---|
648 | "jsToolBar.prototype.elements.blocks.options.h4 = '".html::escapeJS(__('Level 4 header'))."'; ". |
---|
649 | "jsToolBar.prototype.elements.blocks.options.h5 = '".html::escapeJS(__('Level 5 header'))."'; ". |
---|
650 | "jsToolBar.prototype.elements.blocks.options.h6 = '".html::escapeJS(__('Level 6 header'))."'; ". |
---|
651 | "jsToolBar.prototype.elements.strong.title = '".html::escapeJS(__('Strong emphasis'))."'; ". |
---|
652 | "jsToolBar.prototype.elements.em.title = '".html::escapeJS(__('Emphasis'))."'; ". |
---|
653 | "jsToolBar.prototype.elements.ins.title = '".html::escapeJS(__('Inserted'))."'; ". |
---|
654 | "jsToolBar.prototype.elements.del.title = '".html::escapeJS(__('Deleted'))."'; ". |
---|
655 | "jsToolBar.prototype.elements.quote.title = '".html::escapeJS(__('Inline quote'))."'; ". |
---|
656 | "jsToolBar.prototype.elements.code.title = '".html::escapeJS(__('Code'))."'; ". |
---|
657 | "jsToolBar.prototype.elements.br.title = '".html::escapeJS(__('Line break'))."'; ". |
---|
658 | "jsToolBar.prototype.elements.blockquote.title = '".html::escapeJS(__('Blockquote'))."'; ". |
---|
659 | "jsToolBar.prototype.elements.pre.title = '".html::escapeJS(__('Preformated text'))."'; ". |
---|
660 | "jsToolBar.prototype.elements.ul.title = '".html::escapeJS(__('Unordered list'))."'; ". |
---|
661 | "jsToolBar.prototype.elements.ol.title = '".html::escapeJS(__('Ordered list'))."'; ". |
---|
662 | |
---|
663 | "jsToolBar.prototype.elements.link.title = '".html::escapeJS(__('Link'))."'; ". |
---|
664 | "jsToolBar.prototype.elements.link.href_prompt = '".html::escapeJS(__('URL?'))."'; ". |
---|
665 | "jsToolBar.prototype.elements.link.hreflang_prompt = '".html::escapeJS(__('Language?'))."'; ". |
---|
666 | |
---|
667 | "jsToolBar.prototype.elements.img.title = '".html::escapeJS(__('External image'))."'; ". |
---|
668 | "jsToolBar.prototype.elements.img.src_prompt = '".html::escapeJS(__('URL?'))."'; ". |
---|
669 | |
---|
670 | "jsToolBar.prototype.elements.img_select.title = '".html::escapeJS(__('Media chooser'))."'; ". |
---|
671 | "jsToolBar.prototype.elements.post_link.title = '".html::escapeJS(__('Link to an entry'))."'; "; |
---|
672 | |
---|
673 | if (!$GLOBALS['core']->auth->check('media,media_admin',$GLOBALS['core']->blog->id)) { |
---|
674 | $res .= "jsToolBar.prototype.elements.img_select.disabled = true;\n"; |
---|
675 | } |
---|
676 | |
---|
677 | $res .= |
---|
678 | "\n//]]>\n". |
---|
679 | "</script>\n"; |
---|
680 | |
---|
681 | return $res; |
---|
682 | } |
---|
683 | |
---|
684 | public static function jsUpload($params=array(),$base_url=null) |
---|
685 | { |
---|
686 | if (!$base_url) { |
---|
687 | $base_url = path::clean(dirname(preg_replace('/(\?.*$)?/','',$_SERVER['REQUEST_URI']))).'/'; |
---|
688 | } |
---|
689 | |
---|
690 | $params = array_merge($params,array( |
---|
691 | 'sess_id='.session_id(), |
---|
692 | 'sess_uid='.$_SESSION['sess_browser_uid'], |
---|
693 | 'xd_check='.$GLOBALS['core']->getNonce() |
---|
694 | )); |
---|
695 | |
---|
696 | return |
---|
697 | '<link rel="stylesheet" type="text/css" href="style/jsUpload/style.css" />'."\n". |
---|
698 | |
---|
699 | '<script id="template-upload" type="text/x-tmpl"> |
---|
700 | {% for (var i=0, file; file=o.files[i]; i++) { %} |
---|
701 | <div class="template-upload fade"> |
---|
702 | <div class="upload-file"> |
---|
703 | <div class="upload-fileinfo"> |
---|
704 | <span class="upload-filename">{%=file.name%}</span> |
---|
705 | <span class="upload-filesize">({%=o.formatFileSize(file.size)%})</span> |
---|
706 | <span class="upload-filecancel cancel">'.__('Cancel').'</span> |
---|
707 | {% if (!o.files.error && !i && !o.options.autoUpload) { %} |
---|
708 | <input type="submit" class="button start" value="'.__('Send').'"/> |
---|
709 | {% } %} |
---|
710 | <span class="upload-filemsg"></span> |
---|
711 | </div> |
---|
712 | {% if (!o.files.error) { %} |
---|
713 | <div class="upload-progress progress progress-success progress-striped active"><div class="bar" style="width:0%;"></div></div> |
---|
714 | {% } %} |
---|
715 | </div> |
---|
716 | {% } %} |
---|
717 | </script> |
---|
718 | <!-- The template to display files available for download --> |
---|
719 | <script id="template-download" type="text/x-tmpl"> |
---|
720 | {% for (var i=0, file; file=o.files[i]; i++) { %} |
---|
721 | <div class="template-download fade"> |
---|
722 | <div class="upload-file"> |
---|
723 | <div class="upload-fileinfo"> |
---|
724 | <span class="upload-filename">{%=file.name%}</span> |
---|
725 | <span class="upload-filesize">({%=o.formatFileSize(file.size)%})</span> |
---|
726 | <span class="upload-filemsg{% if (file.error) { %} upload-error{% } %}"> |
---|
727 | {% if (file.error) { %} |
---|
728 | '.__('Error:').' {%=file.error%} |
---|
729 | {% } else { %} |
---|
730 | '.__('File successfully uploaded.').' |
---|
731 | {% } %} |
---|
732 | </span> |
---|
733 | </div> |
---|
734 | <div class="upload-progress"> |
---|
735 | {% if (!file.error) { %} |
---|
736 | <div class="bar" style="width:100%;">100%</div> |
---|
737 | {% } %} |
---|
738 | </div> |
---|
739 | </div> |
---|
740 | {% } %} |
---|
741 | </script>'. |
---|
742 | |
---|
743 | self::jsLoad('js/jsUpload/vendor/jquery.ui.widget.js'). |
---|
744 | self::jsLoad('js/jsUpload/tmpl.js'). |
---|
745 | self::jsLoad('js/jsUpload/load-image.js'). |
---|
746 | self::jsLoad('js/jsUpload/jquery.iframe-transport.js'). |
---|
747 | self::jsLoad('js/jsUpload/jquery.fileupload.js'). |
---|
748 | self::jsLoad('js/jsUpload/jquery.fileupload-process.js'). |
---|
749 | self::jsLoad('js/jsUpload/jquery.fileupload-resize.js'). |
---|
750 | self::jsLoad('js/jsUpload/jquery.fileupload-ui.js'). |
---|
751 | |
---|
752 | '<script type="text/javascript">'."\n". |
---|
753 | "//<![CDATA[\n". |
---|
754 | "dotclear.jsUpload = {};\n". |
---|
755 | "dotclear.jsUpload.msg = {};\n". |
---|
756 | self::jsVar('dotclear.msg.enhanced_uploader_activate',__('Temporarily activate enhanced uploader')). |
---|
757 | self::jsVar('dotclear.msg.enhanced_uploader_disable',__('Temporarily disable enhanced uploader')). |
---|
758 | self::jsVar('dotclear.jsUpload.msg.limit_exceeded',__('Limit exceeded.')). |
---|
759 | self::jsVar('dotclear.jsUpload.msg.size_limit_exceeded',__('File size exceeds allowed limit.')). |
---|
760 | self::jsVar('dotclear.jsUpload.msg.canceled',__('Canceled.')). |
---|
761 | self::jsVar('dotclear.jsUpload.msg.http_error',__('HTTP Error:')). |
---|
762 | self::jsVar('dotclear.jsUpload.msg.error',__('Error:')). |
---|
763 | self::jsVar('dotclear.jsUpload.msg.choose_file',__('Choose file')). |
---|
764 | self::jsVar('dotclear.jsUpload.msg.choose_files',__('Choose files')). |
---|
765 | self::jsVar('dotclear.jsUpload.msg.cancel',__('Cancel')). |
---|
766 | self::jsVar('dotclear.jsUpload.msg.clean',__('Clean')). |
---|
767 | self::jsVar('dotclear.jsUpload.msg.upload',__('Upload')). |
---|
768 | self::jsVar('dotclear.jsUpload.msg.no_file_in_queue',__('No file in queue.')). |
---|
769 | self::jsVar('dotclear.jsUpload.msg.file_in_queue',__('1 file in queue.')). |
---|
770 | self::jsVar('dotclear.jsUpload.msg.files_in_queue',__('%d files in queue.')). |
---|
771 | self::jsVar('dotclear.jsUpload.msg.queue_error',__('Queue error:')). |
---|
772 | self::jsVar('dotclear.jsUpload.base_url',$base_url). |
---|
773 | "\n//]]>\n". |
---|
774 | "</script>\n"; |
---|
775 | } |
---|
776 | |
---|
777 | public static function jsToolMan() |
---|
778 | { |
---|
779 | return |
---|
780 | '<script type="text/javascript" src="js/tool-man/core.js"></script>'. |
---|
781 | '<script type="text/javascript" src="js/tool-man/events.js"></script>'. |
---|
782 | '<script type="text/javascript" src="js/tool-man/css.js"></script>'. |
---|
783 | '<script type="text/javascript" src="js/tool-man/coordinates.js"></script>'. |
---|
784 | '<script type="text/javascript" src="js/tool-man/drag.js"></script>'. |
---|
785 | '<script type="text/javascript" src="js/tool-man/dragsort.js"></script>'. |
---|
786 | '<script type="text/javascript" src="js/dragsort-tablerows.js"></script>'; |
---|
787 | } |
---|
788 | |
---|
789 | public static function jsMetaEditor() |
---|
790 | { |
---|
791 | return |
---|
792 | '<script type="text/javascript" src="js/meta-editor.js"></script>'; |
---|
793 | } |
---|
794 | } |
---|
795 | ?> |
---|