Dotclear

source: inc/admin/lib.dc.page.php @ 329:0ff0593a8882

Revision 329:0ff0593a8882, 22.6 KB checked in by Tomtom33 <tbouron@…>, 14 years ago (diff)

Popup media now works for images, mp3 and other extensions except flv

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2010 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 -----------------------------------------
12if (!defined('DC_RC_PATH')) { return; }
13
14define('DC_AUTH_PAGE','auth.php');
15
16class dcPage
17{
18     # Auth check
19     public static function check($permissions)
20     {
21          global $core;
22         
23          if ($core->blog && $core->auth->check($permissions,$core->blog->id))
24          {
25               return;
26          }
27         
28          if (session_id()) {
29               $core->session->destroy();
30          }
31          http::redirect(DC_AUTH_PAGE);
32     }
33     
34     # Check super admin
35     public static function checkSuper()
36     {
37          global $core;
38         
39          if (!$core->auth->isSuperAdmin())
40          {
41               if (session_id()) {
42                    $core->session->destroy();
43               }
44               http::redirect(DC_AUTH_PAGE);
45          }
46     }
47     
48     # Top of admin page
49     public static function open($title='', $head='')
50     {
51          global $core;
52         
53          # List of user's blogs
54          if ($core->auth->blog_count == 1 || $core->auth->blog_count > 20)
55          {
56               $blog_box =
57               __('Blog:').' <strong title="'.html::escapeHTML($core->blog->url).'">'.
58               html::escapeHTML($core->blog->name).'</strong>';
59               
60               if ($core->auth->blog_count > 20) {
61                    $blog_box .= ' - <a href="blogs.php">'.__('Change blog').'</a>';
62               }
63          }
64          else
65          {
66               $rs_blogs = $core->getBlogs(array('order'=>'LOWER(blog_name)','limit'=>20));
67               $blogs = array();
68               while ($rs_blogs->fetch()) {
69                    $blogs[html::escapeHTML($rs_blogs->blog_name.' - '.$rs_blogs->blog_url)] = $rs_blogs->blog_id;
70               }
71               $blog_box =
72               '<label for="switchblog" class="classic">'.
73               __('Blogs:').' '.
74               $core->formNonce().
75               form::combo('switchblog',$blogs,$core->blog->id,  '',1).
76               '</label>'.
77               '<noscript><div><input type="submit" value="'.__('ok').'" /></div></noscript>';
78          }
79         
80          $safe_mode = isset($_SESSION['sess_safe_mode']) && $_SESSION['sess_safe_mode'];
81         
82          # Display
83          header('Content-Type: text/html; charset=UTF-8');
84          echo
85          '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '.
86          ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n".
87          '<html xmlns="http://www.w3.org/1999/xhtml" '.
88          'xml:lang="'.$core->auth->getInfo('user_lang').'" '.
89          'lang="'.$core->auth->getInfo('user_lang').'">'."\n".
90          "<head>\n".
91          '  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'."\n".
92          '  <title>'.$title.' - '.html::escapeHTML($core->blog->name).' - '.html::escapeHTML(DC_VENDOR_NAME).' - '.DC_VERSION.'</title>'."\n".
93         
94          '  <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />'."\n".
95          '  <meta name="GOOGLEBOT" content="NOSNIPPET" />'."\n".
96         
97          self::jsLoadIE7().
98          '  <style type="text/css">'."\n". 
99          '  @import "style/default.css";'."\n".
100          "  </style>\n";
101          if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') {
102               echo '  <style type="text/css">'."\n".'  @import "style/default-rtl.css";'."\n"."  </style>\n";
103          }
104         
105          echo
106          self::jsCommon().
107          $head;
108         
109          # --BEHAVIOR-- adminPageHTMLHead
110          $core->callBehavior('adminPageHTMLHead');
111         
112          echo
113          "</head>\n".
114          '<body id="dotclear-admin'.
115          ($safe_mode ? ' safe-mode' : '').
116          '">'."\n".
117         
118          '<div id="top"><h1><a href="index.php">'.DC_VENDOR_NAME.'</a></h1></div>'."\n";
119         
120         
121          echo
122          '<div id="info-box">'.
123          '<form action="index.php" method="post"><div>'.
124          $blog_box.
125          '<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>'.
126          '</div></form>'.
127          '</div>'.
128          '<div id="info-box2"><div>'.
129          ' '.__('User:').' <strong>'.$core->auth->userID().'</strong>'.
130          ' - <a href="index.php?logout=1" class="logout">'.__('Logout').' <img src="images/logout.png" alt="" /></a>'.
131          '</div>'.
132          '</div>';
133         
134          echo
135          '<div id="wrapper">'."\n".
136          '<div id="main">'."\n".
137          '<div id="content">'."\n";
138         
139          # Safe mode
140          if ($safe_mode)
141          {
142               echo
143               '<div class="error"><h3>'.__('Safe mode').'</h3>'.
144               '<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>'.
145               '</div>';
146          }
147         
148          if ($core->error->flag()) {
149               echo
150               '<div class="error"><strong>'.__('Errors:').'</strong>'.
151               $core->error->toHTML().
152               '</div>';
153          }
154     }
155     
156     public static function close()
157     {
158          $menu =& $GLOBALS['_menu'];
159         
160          echo
161          "</div>\n".         // End of #content
162          "</div>\n".         // End of #main
163         
164          '<div id="main-menu">'."\n";
165         
166          foreach ($menu as $k => $v) {
167               echo $menu[$k]->draw();
168          }
169         
170          echo
171          '</div>'."\n".      // End of #main-menu
172          '<div id="footer"><p>'.
173          sprintf(__('Thank you for using %s.'),'<a href="http://dotclear.org/">Dotclear '.DC_VERSION.'</a>').
174          ' <span class="credit"> (Icons by <a href="http://dryicons.com/">Dryicons</a>)</span>'.
175          '</p></div>'."\n".
176          "</div>\n";         // End of #wrapper
177         
178          if (defined('DC_DEV') && DC_DEV === true) {
179               echo self::debugInfo();
180          }
181         
182          echo
183          '</body></html>';
184     }
185     
186     public static function openPopup($title='', $head='')
187     {
188          global $core;
189         
190          # Display
191          header('Content-Type: text/html; charset=UTF-8');
192          echo
193          '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '.
194          ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n".
195          '<html xmlns="http://www.w3.org/1999/xhtml" '.
196          'xml:lang="'.$core->auth->getInfo('user_lang').'" '.
197          'lang="'.$core->auth->getInfo('user_lang').'">'."\n".
198          "<head>\n".
199          '  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'."\n".
200          '  <title>'.$title.' - '.html::escapeHTML($core->blog->name).' - '.html::escapeHTML(DC_VENDOR_NAME).' - '.DC_VERSION.'</title>'."\n".
201         
202          '  <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />'."\n".
203          '  <meta name="GOOGLEBOT" content="NOSNIPPET" />'."\n".
204         
205          self::jsLoadIE7().
206          '  <style type="text/css">'."\n". 
207          '  @import "style/default.css";'."\n".
208          "  </style>\n";
209          if (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl') {
210               echo '  <style type="text/css">'."\n".'  @import "style/default-rtl.css";'."\n"."  </style>\n";
211          }
212         
213          echo
214          self::jsCommon().
215          $head;
216         
217          # --BEHAVIOR-- adminPageHTMLHead
218          $core->callBehavior('adminPageHTMLHead');
219         
220          echo
221          "</head>\n".
222          '<body id="dotclear-admin" class="popup">'."\n".
223         
224          '<div id="top"><h1>'.DC_VENDOR_NAME.'</h1></div>'."\n";
225         
226          echo
227          '<div id="wrapper">'."\n".
228          '<div id="main">'."\n".
229          '<div id="content">'."\n";
230         
231          if ($core->error->flag()) {
232               echo
233               '<div class="error"><strong>'.__('Errors:').'</strong>'.
234               $core->error->toHTML().
235               '</div>';
236          }
237     }
238     
239     public static function closePopup()
240     {
241          echo
242          "</div>\n".         // End of #content
243          "</div>\n".         // End of #main
244          '<div id="footer"><p>&nbsp;</p></div>'."\n".
245          "</div>\n".         // End of #wrapper
246          '</body></html>';
247     }
248     
249     private static function debugInfo()
250     {
251          $global_vars = implode(', ',array_keys($GLOBALS));
252         
253          $res =
254          '<div id="debug"><div>'.
255          '<p>memory usage: '.memory_get_usage().' ('.files::size(memory_get_usage()).')</p>';
256         
257          if (function_exists('xdebug_get_profiler_filename'))
258          {
259               $res .= '<p>Elapsed time: '.xdebug_time_index().' seconds</p>';
260               
261               $prof_file = xdebug_get_profiler_filename();
262               if ($prof_file) {
263                    $res .= '<p>Profiler file : '.xdebug_get_profiler_filename().'</p>';
264               } else {
265                    $prof_url = http::getSelfURI();
266                    $prof_url .= (strpos($prof_url,'?') === false) ? '?' : '&amp;';
267                    $prof_url .= 'XDEBUG_PROFILE';
268                    $res .= '<p><a href="'.$prof_url.'">Trigger profiler</a></p>';
269               }
270               
271               /* xdebug configuration:
272               zend_extension = /.../xdebug.so
273               xdebug.auto_trace = On
274               xdebug.trace_format = 0
275               xdebug.trace_options = 1
276               xdebug.show_mem_delta = On
277               xdebug.profiler_enable = 0
278               xdebug.profiler_enable_trigger = 1
279               xdebug.profiler_output_dir = /tmp
280               xdebug.profiler_append = 0
281               xdebug.profiler_output_name = timestamp
282               */
283          }
284         
285          $res .=
286          '<p>Global vars: '.$global_vars.'</p>'.
287          '</div></div>';
288         
289          return $res;
290     }
291     
292     public static function help($page,$index='')
293     {
294          # Deprecated but we keep this for plugins.
295     }
296     
297     public static function helpBlock()
298     {
299          $args = func_get_args();
300          if (empty($args)) {
301               return;
302          };
303         
304          global $__resources;
305          if (empty($__resources['help'])) {
306               return;
307          }
308         
309          $content = '';
310          foreach ($args as $v)
311          {
312               if (is_object($v) && isset($v->content)) {
313                    $content .= $v->content;
314                    continue;
315               }
316               
317               if (!isset($__resources['help'][$v])) {
318                    continue;
319               }
320               $f = $__resources['help'][$v];
321               if (!file_exists($f) || !is_readable($f)) {
322                    continue;
323               }
324               
325               $fc = file_get_contents($f);
326               if (preg_match('|<body[^>]*?>(.*?)</body>|ms',$fc,$matches)) {
327                    $content .= $matches[1];
328               } else {
329                    $content .= $fc;
330               }
331          }
332         
333          if (trim($content) == '') {
334               return;
335          }
336         
337          echo
338          '<div id="help"><hr /><div class="help-content clear"><h2>'.__('Help').'</h2>'.
339          $content.
340          '</div></div>';
341     }
342     
343     public static function jsLoad($src)
344     {
345          return '<script type="text/javascript" src="'.html::escapeHTML($src).'"></script>'."\n";
346     }
347     
348     public static function jsVar($n,$v)
349     {
350          return $n." = '".html::escapeJS($v)."';\n";
351     }
352     
353     public static function jsCommon()
354     {
355          return
356          self::jsLoad('js/jquery/jquery.js').
357          self::jsLoad('js/jquery/jquery.biscuit.js').
358          self::jsLoad('js/jquery/jquery.bgFade.js').
359          self::jsLoad('js/common.js').
360         
361          '<script type="text/javascript">'."\n".
362          "//<![CDATA[\n".
363          self::jsVar('dotclear.nonce',$GLOBALS['core']->getNonce()).
364         
365          self::jsVar('dotclear.img_plus_src','images/plus.png').
366          self::jsVar('dotclear.img_plus_alt',__('uncover')).
367          self::jsVar('dotclear.img_minus_src','images/minus.png').
368          self::jsVar('dotclear.img_minus_alt',__('hide')).
369          self::jsVar('dotclear.img_menu_on','images/menu_on.png').
370          self::jsVar('dotclear.img_menu_off','images/menu_off.png').
371         
372          self::jsVar('dotclear.msg.help',
373               __('help')).
374          self::jsVar('dotclear.msg.no_selection',
375               __('no selection')).
376          self::jsVar('dotclear.msg.select_all',
377               __('select all')).
378          self::jsVar('dotclear.msg.invert_sel',
379               __('invert selection')).
380          self::jsVar('dotclear.msg.website',
381               __('Web site:')).
382          self::jsVar('dotclear.msg.email',
383               __('Email:')).
384          self::jsVar('dotclear.msg.ip_address',
385               __('IP address:')).
386          self::jsVar('dotclear.msg.error',
387               __('Error:')).
388          self::jsVar('dotclear.msg.entry_created',
389               __('Entry has been successfully created.')).
390          self::jsVar('dotclear.msg.edit_entry',
391               __('Edit entry')).
392          self::jsVar('dotclear.msg.view_entry',
393               __('view entry')).
394          self::jsVar('dotclear.msg.confirm_delete_posts',
395               __("Are you sure you want to delete selected entries (%s)?")).
396          self::jsVar('dotclear.msg.confirm_delete_post',
397               __("Are you sure you want to delete this entry?")).
398          self::jsVar('dotclear.msg.confirm_delete_comments',
399               __('Are you sure you want to delete selected comments (%s)?')).
400          self::jsVar('dotclear.msg.confirm_delete_comment',
401               __('Are you sure you want to delete this comment?')).
402          self::jsVar('dotclear.msg.cannot_delete_users',
403               __('Users with posts cannot be deleted.')).
404          self::jsVar('dotclear.msg.confirm_delete_user',
405               __('Are you sure you want to delete selected users (%s)?')).
406          self::jsVar('dotclear.msg.confirm_delete_category',
407               __('Are you sure you want to delete category "%s"?')).
408          self::jsVar('dotclear.msg.confirm_reorder_categories',
409               __('Are you sure you want to reorder all categories?')).
410          self::jsVar('dotclear.msg.confirm_delete_media',
411               __('Are you sure you want to remove media "%s"?')).
412          self::jsVar('dotclear.msg.confirm_extract_current',
413               __('Are you sure you want to extract archive in current directory?')).
414          self::jsVar('dotclear.msg.confirm_remove_attachment',
415               __('Are you sure you want to remove attachment "%s"?')).
416          self::jsVar('dotclear.msg.confirm_delete_lang',
417               __('Are you sure you want to delete "%s" language?')).
418          self::jsVar('dotclear.msg.confirm_delete_plugin',
419               __('Are you sure you want to delete "%s" plugin?')).
420          self::jsVar('dotclear.msg.use_this_theme',
421               __('Use this theme')).
422          self::jsVar('dotclear.msg.remove_this_theme',
423               __('Remove this theme')).
424          self::jsVar('dotclear.msg.confirm_delete_theme',
425               __('Are you sure you want to delete "%s" theme?')).
426          self::jsVar('dotclear.msg.zip_file_content',
427               __('Zip file content')).
428          self::jsVar('dotclear.msg.xhtml_validator',
429               __('XHTML markup validator')).
430          self::jsVar('dotclear.msg.xhtml_valid',
431               __('XHTML content is valid.')).
432          self::jsVar('dotclear.msg.xhtml_not_valid',
433               __('There are XHTML markup errors.')).
434          self::jsVar('dotclear.msg.confirm_change_post_format',
435               __('You have unsaved changes. Switch post format will loose these changes. Proceed anyway?')).
436          self::jsVar('dotclear.msg.load_enhanced_uploader',
437               __('Loading enhanced uploader, please wait.')).
438          "\n//]]>\n".
439          "</script>\n";
440     }
441     
442     public static function jsLoadIE7()
443     {
444          return
445          '<!--[if lt IE 8]>'."\n".
446          self::jsLoad('js/ie7/IE8.js').
447          '<link rel="stylesheet" type="text/css" href="style/iesucks.css" />'."\n".
448          '<![endif]-->'."\n";
449     }
450     
451     public static function jsConfirmClose()
452     {
453          $args = func_get_args();
454          if (count($args) > 0) {
455               foreach ($args as $k => $v) {
456                    $args[$k] = "'".html::escapeJS($v)."'";
457               }
458               $args = implode(',',$args);
459          } else {
460               $args = '';
461          }
462         
463          return
464          self::jsLoad('js/confirm-close.js').
465          '<script type="text/javascript">'."\n".
466          "//<![CDATA[\n".
467          "confirmClosePage = new confirmClose(".$args."); ".
468          "confirmClose.prototype.prompt = '".html::escapeJS(__('You have unsaved changes.'))."'; ".
469          "\n//]]>\n".
470          "</script>\n";
471     }
472     
473     public static function jsPageTabs($default=null)
474     {
475          if ($default) {
476               $default = "'".html::escapeJS($default)."'";
477          }
478         
479          return
480          self::jsLoad('js/jquery/jquery.pageTabs.js').
481          '<script type="text/javascript">'."\n".
482          "//<![CDATA[\n".
483          "\$(function() {\n".
484          "    \$.pageTabs(".$default.");\n".
485          "});\n".
486          "\n//]]>\n".
487          "</script>\n";
488     }
489     
490     public static function jsModal()
491     {
492          return
493          '<link rel="stylesheet" type="text/css" href="style/modal/modal.css" />'."\n".
494          self::jsLoad('js/jquery/jquery.modal.js').
495          '<script type="text/javascript">'."\n".
496          "//<![CDATA[\n".
497          self::jsVar('$.modal.prototype.params.loader_img','style/modal/loader.gif').
498          self::jsVar('$.modal.prototype.params.close_img','style/modal/close.png').
499          "\n//]]>\n".
500          "</script>\n";
501     }
502     
503     public static function jsColorPicker()
504     {
505          return
506          '<link rel="stylesheet" type="text/css" href="style/farbtastic/farbtastic.css" />'."\n".
507          self::jsLoad('js/jquery/jquery.farbtastic.js').
508          self::jsLoad('js/color-picker.js');
509     }
510     
511     public static function jsDatePicker()
512     {
513          return
514          '<link rel="stylesheet" type="text/css" href="style/date-picker.css" />'."\n".
515          self::jsLoad('js/date-picker.js').
516          '<script type="text/javascript">'."\n".
517          "//<![CDATA[\n".
518         
519          "datePicker.prototype.months[0] = '".html::escapeJS(__('January'))."'; ".
520          "datePicker.prototype.months[1] = '".html::escapeJS(__('February'))."'; ".
521          "datePicker.prototype.months[2] = '".html::escapeJS(__('March'))."'; ".
522          "datePicker.prototype.months[3] = '".html::escapeJS(__('April'))."'; ".
523          "datePicker.prototype.months[4] = '".html::escapeJS(__('May'))."'; ".
524          "datePicker.prototype.months[5] = '".html::escapeJS(__('June'))."'; ".
525          "datePicker.prototype.months[6] = '".html::escapeJS(__('July'))."'; ".
526          "datePicker.prototype.months[7] = '".html::escapeJS(__('August'))."'; ".
527          "datePicker.prototype.months[8] = '".html::escapeJS(__('September'))."'; ".
528          "datePicker.prototype.months[9] = '".html::escapeJS(__('October'))."'; ".
529          "datePicker.prototype.months[10] = '".html::escapeJS(__('November'))."'; ".
530          "datePicker.prototype.months[11] = '".html::escapeJS(__('December'))."'; ".
531         
532          "datePicker.prototype.days[0] = '".html::escapeJS(__('Monday'))."'; ".
533          "datePicker.prototype.days[1] = '".html::escapeJS(__('Tuesday'))."'; ".
534          "datePicker.prototype.days[2] = '".html::escapeJS(__('Wednesday'))."'; ".
535          "datePicker.prototype.days[3] = '".html::escapeJS(__('Thursday'))."'; ".
536          "datePicker.prototype.days[4] = '".html::escapeJS(__('Friday'))."'; ".
537          "datePicker.prototype.days[5] = '".html::escapeJS(__('Saturday'))."'; ".
538          "datePicker.prototype.days[6] = '".html::escapeJS(__('Sunday'))."'; ".
539         
540          "datePicker.prototype.img_src = 'images/date-picker.png'; ".
541         
542          "datePicker.prototype.close_msg = '".html::escapeJS(__('close'))."'; ".
543          "datePicker.prototype.now_msg = '".html::escapeJS(__('now'))."'; ".
544         
545          "\n//]]>\n".
546          "</script>\n";
547     }
548     
549     public static function jsToolBar()
550     {
551          $tb = new dcToolBar($GLOBALS['core']);
552         
553          // Add xhtml toolbar
554          $tb->addFormatter('xhtml');
555          $tb->addSettings('xhtml',array(
556               'mode' => 'textareas',
557               'relative_urls' => 'false',
558               'theme' => 'advanced',
559               'theme_advanced_toolbar_location' => 'top',
560               'theme_advanced_toolbar_align' => 'left',
561               'theme_advanced_statusbar_location' => 'bottom',
562               'theme_advanced_resizing' => 'true',
563               'theme_advanced_resize_horizontal' => 'false',
564               'theme_advanced_blockformats' => 'p,pre,h1,h2,h3,h4',
565               'convert_newlines_to_brs' => 'true',
566               'paste_auto_cleanup_on_paste' => 'true',
567               'formats' => '{underline: {inline: "ins"},strikethrough: {inline: "del"},inlinecode: {inline: "code"},quote: {inline: "q"}}'
568          ));
569          $tb->addPlugins('xhtml',array(
570               'fullscreen' => true,
571               'paste' => true,
572               'searchreplace' => true,
573               'dcControls' => true
574          ));
575          $tb->addButtons('xhtml',array(
576               1 => array(
577                    'justifyleft',
578                    'justifycenter',
579                    'justifyright',
580                    'separator',
581                    'bold',
582                    'italic',
583                    'underline',
584                    'strikethrough',
585                    'inlinecode',
586                    'quote',
587                    'sub',
588                    'sup',
589                    'separator',
590                    'blockquote',
591                    'bullist',
592                    'numlist',
593                    'outdent',
594                    'indent',
595                    'separator',
596                    'undo',
597                    'redo',
598                    'separator',
599                    'fullscreen',
600                    'separator',
601                    'code'
602               ),
603               2 => array(
604                    'formatselect',
605                    'removeformat',
606                    'cleanup',
607                    'seperator',
608                    'cut',
609                    'copy',
610                    'paste',
611                    'pastetext',
612                    'pasteword',
613                    'search',
614                    'replace'
615               ),
616               3 => array(
617                    'link',
618                    'unlink',
619                    'separator',
620                    'media',
621                    'separator',
622                    'hr',
623                    'charmap',
624                    'visualchars'
625               )
626          ));
627         
628          // Add wiki toolbar
629          $tb->addFormatter('wiki');
630          $tb->addSettings('wiki',array(
631               'mode' => 'none',
632               'relative_urls' => 'false',
633               'theme' => 'advanced',
634               'theme_advanced_toolbar_location' => 'top',
635               'theme_advanced_toolbar_align' => 'left',
636               'theme_advanced_statusbar_location' => 'bottom',
637               'theme_advanced_resizing' => 'true',
638               'theme_advanced_resize_horizontal' => 'false',
639               'theme_advanced_path'  => 'false',
640               'theme_advanced_blockformats' => 'p,pre,h1,h2,h3,h4',
641               'entity_encoding' => 'raw',
642               'remove_linebreaks' => 'false',
643               'inline_styles' => 'false',
644               'convert_fonts_to_spans' => 'false',
645               'paste_auto_cleanup_on_paste' => 'true',
646               'force_br_newlines' => 'true',
647               'force_p_newlines' => 'false',
648               'forced_root_block' => '',
649               'formats' => '{underline: {inline: "ins"},strikethrough: {inline: "del"},inlinecode: {inline: "code"},quote: {inline: "q"}}'
650          ));
651          $tb->addPlugins('wiki',array(
652               'fullscreen' => true,
653               'paste' => true,
654               'searchreplace' => true,
655               'dcControls' => true
656          ));
657          $tb->addButtons('wiki',array(
658               1 => array(
659                    'formatselect',
660                    'bold',
661                    'italic',
662                    'underline',
663                    'strikethrough',
664                    'quote',
665                    'inlinecode',
666                    'separator',
667                    'blockquote',
668                    'bullist',
669                    'numlist',
670                    'separator',
671                    'link',
672                    'unlink',
673                    'separator',
674                    'search',
675                    'replace',
676                    'separator',
677                    'undo',
678                    'redo',
679                    'separator',
680                    'fullscreen',
681                    'separator',
682                    'code'
683               )
684          ));
685         
686          $res =
687          '<script type="text/javascript" src="js/tiny_mce/tiny_mce.js"></script>'.
688          '<script type="text/javascript" src="js/dcToolBar.js"></script>'.
689          '<script type="text/javascript">'."\n".
690          "//<![CDATA[\n".
691          $tb->getJS().
692          "\n//]]>\n".
693          "</script>\n";
694         
695          return $res;
696     }
697     
698     public static function jsCandyUpload($params=array(),$base_url=null)
699     {
700          if (!$base_url) {
701               $base_url = path::clean(dirname(preg_replace('/(\?.*$)?/','',$_SERVER['REQUEST_URI']))).'/';
702          }
703         
704          $params = array_merge($params,array(
705               'sess_id='.session_id(),
706               'sess_uid='.$_SESSION['sess_browser_uid'],
707               'xd_check='.$GLOBALS['core']->getNonce()
708          ));
709         
710          return
711          '<link rel="stylesheet" type="text/css" href="style/candyUpload/style.css" />'."\n".
712          self::jsLoad('js/jquery/jquery.candyUpload.js').
713         
714          '<script type="text/javascript">'."\n".
715          "//<![CDATA[\n".
716          "dotclear.candyUpload = {};\n".
717          self::jsVar('dotclear.msg.activate_enhanced_uploader',__('Activate enhanced uploader')).
718          self::jsVar('dotclear.msg.disable_enhanced_uploader',__('Disable enhanced uploader')).
719          self::jsVar('$._candyUpload.prototype.locales.file_uploaded',__('File successfully uploaded.')).
720          self::jsVar('$._candyUpload.prototype.locales.max_file_size',__('Maximum file size allowed:')).
721          self::jsVar('$._candyUpload.prototype.locales.limit_exceeded',__('Limit exceeded.')).
722          self::jsVar('$._candyUpload.prototype.locales.size_limit_exceeded',__('File size exceeds allowed limit.')).
723          self::jsVar('$._candyUpload.prototype.locales.canceled',__('Canceled.')).
724          self::jsVar('$._candyUpload.prototype.locales.http_error',__('HTTP Error:')).
725          self::jsVar('$._candyUpload.prototype.locales.error',__('Error:')).
726          self::jsVar('$._candyUpload.prototype.locales.choose_file',__('Choose file')).
727          self::jsVar('$._candyUpload.prototype.locales.choose_files',__('Choose files')).
728          self::jsVar('$._candyUpload.prototype.locales.cancel',__('Cancel')).
729          self::jsVar('$._candyUpload.prototype.locales.clean',__('Clean')).
730          self::jsVar('$._candyUpload.prototype.locales.upload',__('Upload')).
731          self::jsVar('$._candyUpload.prototype.locales.no_file_in_queue',__('No file in queue.')).
732          self::jsVar('$._candyUpload.prototype.locales.file_in_queue',__('1 file in queue.')).
733          self::jsVar('$._candyUpload.prototype.locales.files_in_queue',__('%d files in queue.')).
734          self::jsVar('$._candyUpload.prototype.locales.queue_error',__('Queue error:')).
735          self::jsVar('dotclear.candyUpload.base_url',$base_url).
736          self::jsVar('dotclear.candyUpload.movie_url',$base_url.'index.php?pf=swfupload.swf').
737          self::jsVar('dotclear.candyUpload.params',implode('&',$params)).
738          "\n//]]>\n".
739          "</script>\n";
740     }
741     
742     public static function jsToolMan()
743     {
744          return
745          '<script type="text/javascript" src="js/tool-man/core.js"></script>'.
746          '<script type="text/javascript" src="js/tool-man/events.js"></script>'.
747          '<script type="text/javascript" src="js/tool-man/css.js"></script>'.
748          '<script type="text/javascript" src="js/tool-man/coordinates.js"></script>'.
749          '<script type="text/javascript" src="js/tool-man/drag.js"></script>'.
750          '<script type="text/javascript" src="js/tool-man/dragsort.js"></script>'.
751          '<script type="text/javascript" src="js/dragsort-tablerows.js"></script>';
752     }
753     
754     public static function jsMetaEditor()
755     {
756          return
757          '<script type="text/javascript" src="js/meta-editor.js"></script>';
758     }
759}
760?>
Note: See TracBrowser for help on using the repository browser.

Sites map