soo_editarea Page 2 of 2

soo_editarea Source code

  1 : if ( @txpinterface == 'admin' )
  2 : {
  3 :     @require_plugin('soo_plugin_pref');     // optional
  4 : 
  5 :     add_privs('plugin_prefs.soo_editarea','1,2');
  6 :     add_privs('plugin_lifecycle.soo_editarea','1,2');
  7 :     register_callback('soo_editarea_manage_prefs''plugin_prefs.soo_editarea');
  8 :     register_callback('soo_editarea_manage_prefs''plugin_lifecycle.soo_editarea');
  9 : 
 10 :     // Only activate plugin when needed
 11 :     if ( in_array(gps('event'), array('page''form''css')) )
 12 :         register_callback('soo_editarea''admin_side''head_end');
 13 : }
 14 : 
 15 : function soo_editarea_manage_prefs$event$step )
 16 : {
 17 :     if ( function_exists('soo_plugin_pref') )
 18 :         return soo_plugin_pref($event$stepsoo_editarea_pref_spec());
 19 : 
 20 :         // message to install soo_plugin_pref
 21 :     if ( substr($event012) == 'plugin_prefs' ) {
 22 :         $plugin substr($event13);
 23 :         $message '<p><br /><strong>' gTxt('edit') . " $plugin " .
 24 :             gTxt('edit_preferences') . ':</strong><br />' gTxt('install_plugin') .
 25 :             ' <a href="http://ipsedixit.net/txp/92/soo_plugin_pref">' .
 26 :             'soo_plugin_pref</a></p>';
 27 :         pagetop(gTxt('edit_preferences') . " &#8250; $plugin"$message);
 28 :     }
 29 : }
 30 : 
 31 : function soo_editarea_pref_spec( )
 32 : {
 33 :     return array(
 34 :         'page_form_lang' => array(
 35 :             'val'   => 'html',
 36 :             'html'  => 'text_input',
 37 :             'text'  => 'Page Template and Form syntax',
 38 :         ),
 39 :         'editarea_dir' => array(
 40 :             'val'   => 'edit_area',
 41 :             'html'  => 'text_input',
 42 :             'text'  => 'EditArea directory',
 43 :         ),
 44 :         'language' => array(
 45 :             'val'   => 'en',
 46 :             'html'  => 'text_input',
 47 :             'text'  => 'Language',
 48 :         ),
 49 :         'min_height' => array(
 50 :             'val'   => 500,
 51 :             'html'  => 'text_input',
 52 :             'text'  => 'Editor height',
 53 :         ),
 54 :         'min_width' => array(
 55 :             'val'   => 400,
 56 :             'html'  => 'text_input',
 57 :             'text'  => 'Editor width',
 58 :         ),
 59 :         'font_size' => array(
 60 :             'val'   => 10,
 61 :             'html'  => 'text_input',
 62 :             'text'  => 'Font size',
 63 :         ),
 64 :         'font_family' => array(
 65 :             'val'   => 'monospace',
 66 :             'html'  => 'text_input',
 67 :             'text'  => 'Font family',
 68 :         ),
 69 :         'replace_tab_by_spaces' => array(
 70 :             'val'   => 0,
 71 :             'html'  => 'text_input',
 72 :             'text'  => 'Convert tab to spaces',
 73 :         ),
 74 :         'plugins' => array(
 75 :             'val'   => '',
 76 :             'html'  => 'text_input',
 77 :             'text'  => 'EditArea plugins (comma-separated)',
 78 :         ),
 79 :     );
 80 : }
 81 : 
 82 : function soo_editarea_prefs( )
 83 : {
 84 :     static $prefs;
 85 :     if ( ! $prefs )
 86 :     {
 87 :         foreach ( soo_editarea_pref_spec() as $name => $spec )
 88 :             $prefs[$name] = $spec['val'];
 89 :         if ( function_exists('soo_plugin_pref_vals') )
 90 :             $prefs array_merge($prefssoo_plugin_pref_vals('soo_editarea'));
 91 :     }
 92 :     return $prefs;
 93 : }
 94 : 
 95 : function soo_editarea( )
 96 : {
 97 :     $prefs soo_editarea_prefs();
 98 :     extract($prefs);
 99 :     $exclude_from_init array_flip(array('page_form_lang''editarea_dir'));
100 :     $init array_diff_key($prefs$exclude_from_init);
101 :     $textarea = array(
102 :         'page' => array(
103 :             'id' => 'html',
104 :             'syntax' => $page_form_lang,
105 :         ),
106 :         'form' => array(
107 :             'id' => 'form',
108 :             'syntax' => $page_form_lang,
109 :         ),
110 :         'css' => array(
111 :             'id' => 'css',
112 :             'syntax' => 'css',
113 :         ),
114 :     );
115 :     $init array_merge($textarea[gps('event')], $init);
116 : //  if ( substr(gps('name'), -3) == '.js' )
117 : //      $init['syntax'] = 'js';
118 : 
119 :     $func 'editAreaLoader.init({' 'start_highlight: true';
120 :     foreach ( $init as $k => $v ) if ( $v )
121 :         $func .= n.",$k: " . ( is_numeric($v) ? $v "\"$v\"" );
122 :     $func .= '});';
123 : 
124 :     echo
125 :         '<script type="text/javascript" src="',
126 :         $editarea_dir,
127 :         '/edit_area_full.js"></script>',
128 :         nscript_js($func), n
129 :     ;
130 : }