Dotclear

source: inc/admin/lib.dc.page.php @ 399:16dff9759f10

Revision 399:16dff9759f10, 28.2 KB checked in by Tomtom33 <tbouron@…>, 14 years ago (diff)

Finished web media integration with oembed

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               'skin' => 'dotclear',
560               'theme_advanced_toolbar_location' => 'top',
561               'theme_advanced_toolbar_align' => 'left',
562               'theme_advanced_statusbar_location' => 'bottom',
563               'theme_advanced_resizing' => 'true',
564               'theme_advanced_resize_horizontal' => 'false',
565               'theme_advanced_blockformats' => 'p,pre,h1,h2,h3,h4',
566               'convert_newlines_to_brs' => 'true',
567               'paste_auto_cleanup_on_paste' => 'true',
568               'formats' => '{underline: {inline: "ins"},strikethrough: {inline: "del"},inlinecode: {inline: "code"},quote: {inline: "q"}}'
569          ));
570          $tb->addPlugins('xhtml',array(
571               'fullscreen' => true,
572               'paste' => true,
573               'searchreplace' => true,
574               'dcControls' => true
575          ));
576          $tb->addButtons('xhtml',array(
577               1 => array(
578                    'justifyleft',
579                    'justifycenter',
580                    'justifyright',
581                    'separator',
582                    'bold',
583                    'italic',
584                    'underline',
585                    'strikethrough',
586                    'inlinecode',
587                    'quote',
588                    'sub',
589                    'sup',
590                    'separator',
591                    'blockquote',
592                    'bullist',
593                    'numlist',
594                    'outdent',
595                    'indent',
596                    'separator',
597                    'undo',
598                    'redo',
599                    'separator',
600                    'fullscreen',
601                    'separator',
602                    'code'
603               ),
604               2 => array(
605                    'formatselect',
606                    'removeformat',
607                    'cleanup',
608                    'separator',
609                    'pastetext',
610                    'pasteword',
611                    'separator',
612                    'search',
613                    'replace'
614               ),
615               3 => array(
616                    'link',
617                    'unlink',
618                    'separator',
619                    'media',
620                    'webmedia',
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               'skin' => 'dotclear',
635               'theme_advanced_toolbar_location' => 'top',
636               'theme_advanced_toolbar_align' => 'left',
637               'theme_advanced_statusbar_location' => 'bottom',
638               'theme_advanced_resizing' => 'true',
639               'theme_advanced_resize_horizontal' => 'false',
640               'theme_advanced_path'  => 'false',
641               'theme_advanced_blockformats' => 'p,pre,h1,h2,h3,h4',
642               'entity_encoding' => 'raw',
643               'remove_linebreaks' => 'false',
644               'inline_styles' => 'false',
645               'convert_fonts_to_spans' => 'false',
646               'paste_auto_cleanup_on_paste' => 'true',
647               'force_br_newlines' => 'true',
648               'force_p_newlines' => 'false',
649               'forced_root_block' => '',
650               'formats' => '{underline: {inline: "ins"},strikethrough: {inline: "del"},inlinecode: {inline: "code"},quote: {inline: "q"}}'
651          ));
652          $tb->addPlugins('wiki',array(
653               'fullscreen' => true,
654               'paste' => true,
655               'searchreplace' => true,
656               'dcControls' => true
657          ));
658          $tb->addButtons('wiki',array(
659               1 => array(
660                    'formatselect',
661                    'bold',
662                    'italic',
663                    'underline',
664                    'strikethrough',
665                    'quote',
666                    'inlinecode',
667                    'separator',
668                    'blockquote',
669                    'bullist',
670                    'numlist',
671                    'separator',
672                    'link',
673                    'unlink',
674                    'separator',
675                    'search',
676                    'replace',
677                    'separator',
678                    'undo',
679                    'redo',
680                    'separator',
681                    'fullscreen',
682                    'separator',
683                    'code'
684               )
685          ));
686         
687          $tb->addI18n('common',array(
688               'edit_confirm' => __('Do you want to use the WYSIWYG mode for this textarea?'),
689               'apply' => __('Apply'),
690               'insert' => __('Insert'),
691               'update' => __('Update'),
692               'cancel' => __('Cancel'),
693               'close' => __('Close'),
694               'browse' => __('Browse'),
695               'class_name' => __('Class'),
696               'not_set' => __('-- Not set --'),
697               'clipboard_msg' => __('Copy/Cut/Paste is not available in Mozilla and Firefox. Do you want more information about this issue?'),
698               'clipboard_no_support' => __('Currently not supported by your browser, use keyboard shortcuts instead.'),
699               'popup_blocked' => __('Sorry, but we have noticed that your popup-blocker has disabled a window that provides application functionality. You will need to disable popup blocking on this site in order to fully utilize this tool.'),
700               'invalid_data' => __('{#field} is invalid'),
701               'invalid_data_number' => __('{#field} must be a number'),
702               'invalid_data_min' => __('{#field} must be a number greater than {#min}'),
703               'invalid_data_size' => __('{#field} must be a number or percentage'),
704               'more_colors' => __('More colors')
705          ));
706          $tb->addI18n('advanced',array(
707               'style_select' => __('Styles'),
708               'font_size' => __('Font size'),
709               'fontdefault' => __('Font family'),
710               'block' => __('Format'),
711               'paragraph' => __('Paragraph'),
712               'div' => __('Div'),
713               'address' => __('Address'),
714               'pre' => __('Preformatted'),
715               'h1' => __('Heading 1'),
716               'h2' => __('Heading 2'),
717               'h3' => __('Heading 3'),
718               'h4' => __('Heading 4'),
719               'h5' => __('Heading 5'),
720               'h6' => __('Heading 6'),
721               'blockquote' => __('Blockquote'),
722               'code' => __('Code'),
723               'samp' => __('Code sample'),
724               'dt' => __('Definition term '),
725               'dd' => __('Definition description'),
726               'bold_desc' => __('Bold (Ctrl+B)'),
727               'italic_desc' => __('Italic (Ctrl+I)'),
728               'underline_desc' => __('Underline (Ctrl+U)'),
729               'striketrough_desc' => __('Strikethrough'),
730               'justifyleft_desc' => __('Align left'),
731               'justifycenter_desc' => __('Align center'),
732               'justifyright_desc' => __('Align right'),
733               'justifyfull_desc' => __('Align full'),
734               'bullist_desc' => __('Unordered list'),
735               'numlist_desc' => __('Ordered list'),
736               'outdent_desc' => __('Outdent'),
737               'indent_desc' => __('Indent'),
738               'undo_desc' => __('Undo (Ctrl+Z)'),
739               'redo_desc' => __('Redo (Ctrl+Y)'),
740               'link_desc' => __('Insert/edit link'),
741               'unlink_desc' => __('Unlink'),
742               'image_desc' => __('Insert/edit image'),
743               'cleanup_desc' => __('Cleanup messy code'),
744               'code_desc' => __('Edit HTML Source'),
745               'sub_desc' => __('Subscript'),
746               'sup_desc' => __('Superscript'),
747               'hr_desc' => __('Insert horizontal ruler'),
748               'removeformat_desc' => __('Remove formatting'),
749               'custom1_desc' => __('Your custom description here'),
750               'forecolor_desc' => __('Select text color'),
751               'backcolor_desc' => __('Select background color'),
752               'charmap_desc' => __('Insert custom character'),
753               'visualaid_desc' => __('Toggle guidelines/invisible elements'),
754               'anchor_desc' => __('Insert/edit anchor'),
755               'cut_desc' => __('Cut'),
756               'copy_desc' => __('Copy'),
757               'paste_desc' => __('Paste'),
758               'image_props_desc' => __('Image properties'),
759               'newdocument_desc' => __('New document'),
760               'help_desc' => __('Help'),
761               'blockquote_desc' => __('Blockquote'),
762               'clipboard_msg' => __('Copy/Cut/Paste is not available in Mozilla and Firefox.\r\nDo you want more information about this issue?'),
763               'path' => __('Path'),
764               'newdocument' => __('Are you sure you want clear all contents?'),
765               'toolbar_focus' => __('Jump to tool buttons - Alt+Q, Jump to editor - Alt-Z, Jump to element path - Alt-X'),
766               'more_colors' => __('More colors'),
767               'shortcuts_desc' => __('Accessibility Help'),
768               'help_shortcut' => __('. Press ALT F10 for toolbar. Press ALT 0 for help.'),
769               'rich_text_area' => __('Rich Text Area'),
770               'toolbar' => __('Toolbar')
771          ));
772          $tb->addI18n('advanced_dlg',array(
773               'about_title' => __('About TinyMCE'),
774               'about_general' => __('About'),
775               'about_help' => __('Help'),
776               'about_license' => __('License'),
777               'about_plugins' => __('Plugins'),
778               'about_plugin' => __('Plugin'),
779               'about_author' => __('Author'),
780               'about_version' => __('Version'),
781               'about_loaded' => __('Loaded plugins'),
782               'anchor_title' => __('Insert/edit anchor'),
783               'anchor_name' => __('Anchor name'),
784               'anchor_invalid' => __('Please specify a valid anchor name.'),
785               'code_title' => __('HTML Source Editor'),
786               'code_wordwrap' => __('Word wrap'),
787               'charmap_title' => __('Select custom character'),
788               'accessibility_help' => __('Accessibility Help'),
789               'accessibility_usage_title' => __('General Usage')
790          ));
791          $tb->addI18n('paste',array(
792               'paste_text_desc' => __('Paste as Plain Text'),
793               'paste_word_desc' => __('Paste from Word'),
794               'selectall_desc' => __('Select All'),
795               'plaintext_mode_sticky' => __('Paste is now in plain text mode. Click again to toggle back to regular paste mode. After you paste something you will be returned to regular paste mode.'),
796               'plaintext_mode' => __('Paste is now in plain text mode. Click again to toggle back to regular paste mode.')
797          ));
798          $tb->addI18n('paste_dlg',array(
799               'text_title' => __('Use CTRL+V on your keyboard to paste the text into the window.'),
800               'text_linebreaks' => __('Keep linebreaks'),
801               'word_title' => __('Use CTRL+V on your keyboard to paste the text into the window.')
802          ));
803          $tb->addI18n('fullscreen',array('desc' => __('Toggle fullscreen mode')));
804          $tb->addI18n('aria',array('rich_text_area' => __('Rich Text Area')));
805         
806          $tb->addI18n('dcControls',array(
807               'inlinecode_desc' => __('Code'),
808               'quote_desc' => __('Quote'),
809               'link_desc' => __('Link'),
810               'media_desc' => __('Add media from media manager'),
811               'webmedia_desc' => __('Add media from web')
812          ));
813         
814          $res =
815          '<script type="text/javascript" src="js/tiny_mce/tiny_mce.js"></script>'.
816          '<script type="text/javascript" src="js/dcToolBar.js"></script>'.
817          '<script type="text/javascript">'."\n".
818          "//<![CDATA[\n".
819          $tb->getJS().
820          "\n//]]>\n".
821          "</script>\n";
822         
823          return $res;
824     }
825     
826     public static function jsCandyUpload($params=array(),$base_url=null)
827     {
828          if (!$base_url) {
829               $base_url = path::clean(dirname(preg_replace('/(\?.*$)?/','',$_SERVER['REQUEST_URI']))).'/';
830          }
831         
832          $params = array_merge($params,array(
833               'sess_id='.session_id(),
834               'sess_uid='.$_SESSION['sess_browser_uid'],
835               'xd_check='.$GLOBALS['core']->getNonce()
836          ));
837         
838          return
839          '<link rel="stylesheet" type="text/css" href="style/candyUpload/style.css" />'."\n".
840          self::jsLoad('js/jquery/jquery.candyUpload.js').
841         
842          '<script type="text/javascript">'."\n".
843          "//<![CDATA[\n".
844          "dotclear.candyUpload = {};\n".
845          self::jsVar('dotclear.msg.activate_enhanced_uploader',__('Activate enhanced uploader')).
846          self::jsVar('dotclear.msg.disable_enhanced_uploader',__('Disable enhanced uploader')).
847          self::jsVar('$._candyUpload.prototype.locales.file_uploaded',__('File successfully uploaded.')).
848          self::jsVar('$._candyUpload.prototype.locales.max_file_size',__('Maximum file size allowed:')).
849          self::jsVar('$._candyUpload.prototype.locales.limit_exceeded',__('Limit exceeded.')).
850          self::jsVar('$._candyUpload.prototype.locales.size_limit_exceeded',__('File size exceeds allowed limit.')).
851          self::jsVar('$._candyUpload.prototype.locales.canceled',__('Canceled.')).
852          self::jsVar('$._candyUpload.prototype.locales.http_error',__('HTTP Error:')).
853          self::jsVar('$._candyUpload.prototype.locales.error',__('Error:')).
854          self::jsVar('$._candyUpload.prototype.locales.choose_file',__('Choose file')).
855          self::jsVar('$._candyUpload.prototype.locales.choose_files',__('Choose files')).
856          self::jsVar('$._candyUpload.prototype.locales.cancel',__('Cancel')).
857          self::jsVar('$._candyUpload.prototype.locales.clean',__('Clean')).
858          self::jsVar('$._candyUpload.prototype.locales.upload',__('Upload')).
859          self::jsVar('$._candyUpload.prototype.locales.no_file_in_queue',__('No file in queue.')).
860          self::jsVar('$._candyUpload.prototype.locales.file_in_queue',__('1 file in queue.')).
861          self::jsVar('$._candyUpload.prototype.locales.files_in_queue',__('%d files in queue.')).
862          self::jsVar('$._candyUpload.prototype.locales.queue_error',__('Queue error:')).
863          self::jsVar('dotclear.candyUpload.base_url',$base_url).
864          self::jsVar('dotclear.candyUpload.movie_url',$base_url.'index.php?pf=swfupload.swf').
865          self::jsVar('dotclear.candyUpload.params',implode('&',$params)).
866          "\n//]]>\n".
867          "</script>\n";
868     }
869     
870     public static function jsToolMan()
871     {
872          return
873          self::jsLoad('js/tool-man/core.js').
874          self::jsLoad('js/tool-man/events.js').
875          self::jsLoad('js/tool-man/css.js').
876          self::jsLoad('js/tool-man/coordinates.js').
877          self::jsLoad('js/tool-man/drag.js').
878          self::jsLoad('js/tool-man/dragsort.js').
879          self::jsLoad('js/dragsort-tablerows.js');
880     }
881     
882     public static function jsMetaEditor()
883     {
884          return self::jsLoad('js/meta-editor.js');
885     }
886     
887     public static function jsOEmbed()
888     {
889          return self::jsLoad('js/jquery/jquery.oembed.js');
890     }
891}
892?>
Note: See TracBrowser for help on using the repository browser.

Sites map