C:\xampp\htdocs\kptv\admin\spaw2\class\editor.class.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
<?php
/**
 * SPAW Editor v.2 Editor classes
 *
 * Main editor classes 
 * @package spaw2
 * @subpackage Editor  
 * @author Alan Mendelevich <alan@solmetra.lt> 
 * @copyright UAB Solmetra
 */ 

require_once(str_replace('\\\\','/',dirname(__FILE__)).'/config.class.php');
require_once(
str_replace('\\\\','/',dirname(__FILE__)).'/toolbar.class.php');
require_once(
str_replace('\\\\','/',dirname(__FILE__)).'/theme.class.php');
require_once(
str_replace('\\\\','/',dirname(__FILE__)).'/lang.class.php');

/**
 * Represetns editor page
 * @package spaw2
 * @subpackage Editor
 */
class SpawEditorPage
{
  
/**
   * Page name
   * @var string
   */
  
var $name;
  
  
/**
   * Name of the page input (textarea)
   * @var string
   */
  
var $inputName;
          
  
/**
   * Page caption
   * @var string
   */
  
var $caption;
  
  
/**
   * Page direction
   * @var string
   */
  
var $direction;        
  
  
/**
   * Page content
   * @var string
   */
  
var $value;
  
  
/**
   * Constructor
   * @param string $name Name
   * @param string $caption Caption
   * @param string $value Initial content
   */
  
function SpawEditorPage($name$caption$value ''$direction 'ltr')
  {
    
// workaround for names with [ and ]
    
$_page_count SpawConfig::getStaticConfigItem('_page_count');
    if (
$_page_count != null)
    {
      
SpawConfig::setStaticConfigItem('_page_count'$_page_count->value 1);
    }
    else
    {
      
SpawConfig::setStaticConfigItem('_page_count'1);
    }
    
$_pn SpawConfig::getStaticConfigValue('_page_count'); 
    
    
$ctrl_id str_replace(']','_'str_replace('[''_'$name));
    if (
$ctrl_id != $name)
      
$ctrl_id $ctrl_id '_' $_pn;
    
    
$this->name $ctrl_id;
    
$this->inputName $name;
    
$this->caption $caption;
    
$this->value $value;
    
$this->direction $direction;
  }                                     
}   

/**
 * Represents the editor as a whole
 * @package spaw2
 * @subpackage Editor
 */   
class SpawEditor
{
  
/**
   * Holds editor name
   * @var string
   */
  
var $name;        


  
/**
   * Workaround for "static" class variable under php4
   * @access private
   */      
  
function &scriptSent()
  {
    static 
$script_sent;
    
    return 
$script_sent;
  }

  
/**
   * Constructor
   * @param string $name Editor name
   */        
  
function SpawEditor($name$value=''$lang=''$toolbarset=''
                      
$theme=''$width=''$height=''$stylesheet=''$page_caption='')
  {
    
$this->name $name;

    
// add first page    
    
$page_caption = ($page_caption != '')?$page_caption:$name;
    
$page = new SpawEditorPage($name$page_caption$value);
    if (
$page->name != $this->name)
      
$this->name $page->name;
    
$this->addPage($page);
    
$this->setActivePage($page);
    
    if (
$lang != '')
      
$this->setLanguage($lang); 
//    if ($toolbarset != '')
//      $this->addToolbarSet($toolbarset);
    
if ($theme != '')
      
$this->setTheme($theme);
    if (
$width != '')
      
$this->setDimensions($widthnull);
    if (
$height != '')
      
$this->setDimensions(null$height);
    if (
$stylesheet != '')
      
$this->setStylesheet($stylesheet);
    
    
// load static config
    
$this->config = new SpawConfig();

    if (
$toolbarset != '')
      
$this->setConfigValue('default_toolbarset',$toolbarset);
  }
  
  
/**
   * Stores instance config
   * @var SpawConfig
   */
  
var $config;        
  
  
/**
   * Stores instance width
   * @var string
   */
  
var $width;        

  
/**
   * Stores instance height
   * @var string
   */
  
var $height;
  
  
/**
   * Sets editor dimensions
   * @param string width
   * @param string height
   */
  
function setDimensions($width$height)
  {
    if (
$width != null && $width != '')
      
$this->width $width;
    if (
$height != null && $height != '')
      
$this->height $height;
  }                   
  
  
/**
   * Stores toolbars used in this instance
   * @var array
   */        
  
var $toolbars;
  
  
/**
   * Adds toolbars to current instance (unlimited number of arguments could be passed)
   * 
   * Specify a comma separated list of toolbars that should be displayed (ie. "format","table",etc.).      
   * @param string $toolbar,... list of toolbar names
   */         
  
function addToolbars($toolbar='')
  {
    
$numargs func_num_args();
    if (
$numargs)
    {
      
// add specified toolbars
      
$args func_get_args();
      for (
$i=0$i<$numargs$i++)
      {
        
$this->toolbars[$args[$i]] = SpawToolbar::getToolbar($args[$i]);
        
$this->toolbars[$args[$i]]->editor = &$this;
      }
    }
  }

  
/**
   * Adds toolbar set
   * @param string toolbar set name
   */
  
function addToolbarSet($toolbarset)
  {
    
$tset SpawConfig::getStaticConfigValue("toolbarset_".$toolbarset);
    if (
is_array($tset))
    {
      foreach(
$tset as $substitute => $toolbar)
      {
        
$this->addToolbar($toolbar$substitute);
      }
    }
  }        
  
  
/**
   * Adds toolbar (substitutes other toolbar if $substiture is specified)
   * @param string $toolbar name of the toolbar to add
   * @param string $substitute place this toolbar in place of specified
   */           
  
function addToolbar($toolbar$substitute='')
  {
    
$index = empty($substitute)?$toolbar:$substitute;

    
$this->toolbars[$index] = SpawToolbar::getToolbar($toolbar);  
    
$this->toolbars[$index]->editor = &$this;
  }
  
  
/**
   * Theme/skin
   * @var SpawTheme
   */
  
var $theme;
  
  
/**
   * Sets theme/skin for the instance
   * @param string $theme Theme name
   */        
  
function setTheme($theme)
  {
    
$this->theme SpawTheme::getTheme($theme);
  }
  
  
/**
   * Language
   * @var SpawLang
   */
  
var $lang;        
  
  
/**
   * Sets editor language
   * @param string $lang abbreviation of the language code
   * @param string $out_charset output charset   
   */
  
function setLanguage($lang=''$out_charset='')
  {
    
$this->lang = new SpawLang($lang);
    if (
$out_charset != null && $out_charset != '')
      
$this->lang->setOutputCharset($out_charset);
  }         

  
/**
   * Editing area stylesheet
   * @param string path to stylesheet file
   */        
  
var $stylesheet;
  
  
/**
   * Sets editing area stylesheet
   * @param string $filename path to stylesheet file
   */
  
function setStylesheet($filename)
  {
    
$this->stylesheet $filename;
  }        

  
/**
   * Pages collection
   * @var array
   */
  
var $pages;
  
  
/**
   * Adds page
   * @param SpawEditorPage page Page object
   */
  
function addPage($page)
  {
    
$this->pages[$page->name] = $page;
  }
  
  
/**
   * Returns page
   * @param string $name Page name
   * @returns SpawEditorPage
   */
  
function getPage($name)
  {
    if (!empty(
$this->pages[$name]))
      return 
$this->pages[$name];
    else
      return 
NULL;
  }
  
  
/**
   * Holds currently active page
   * @var SpawEditorPage
   */
  
var $active_page;
  
  
/**
   * Sets active page
   * @param SpawEditorPage $page
   */
  
function setActivePage($page)
  {
    
$this->active_page $page;
  }
  
  
/**
   * Returns active page
   * @returns SpawEditorPage
   */
  
function getActivePage()
  {
    return 
$this->active_page;
  }  
  
  
/**
   * Floating toolbar mode flag
   * @var bool
   */
  
var $floating_mode false;
  
  
/**
   * Sets floating toolbar mode on or off
   * @param bool $value Should floating mode be enabled
   */
  
function setFloatingMode($controlled_by ''$value true)
  {
    
$this->floating_mode $value;
    if (
$value)
      
$this->setToolbarFrom($controlled_by);
  }                               
  
  
/**
   * Returs true if floating toolbar mode is enabled
   * @returns bool
   */
  
function getFloatingMode()
  {
    return 
$this->floating_mode;
  }   
  
  
/**
   * Holds instance of another SpawEditor which controls floating toolbar used for this instance
   * 
   * If empty, this is the "main" instance for floating toolbar
   * @var SpawEditor
   */
  
var $toolbar_from;
  
  
/**
   * Sets variable holding instance of another SpawEditor which controls floating toolbar used for this instance
   * @param SpawEditor $controlled_by
   */
  
function setToolbarFrom($controlled_by '')
  {
    if (
$controlled_by == '')
      
$controlled_by $this;
    
$this->toolbar_from $controlled_by;
  }
  
  
/**
   * Returns instance of another SpawEditor which controls floating toolbar used for this instance
   * @returns SpawEditor
   */
  
function getToolbarFrom()
  {
    if (
$this->toolbar_from)
      return 
$this->toolbar_from;
    else
      return 
$this;
  }

  
/**
   * Holds value whether mode strip should be displayed or not
   * @var bool
   */
  
var $is_mode_strip_visible true;
  
/**
   * Sets value indicating that mode strip should be shown
   */
  
function showModeStrip()
  {
    
$this->is_mode_strip_visible true;
  }             
  
/**
   * Sets value indicating that mode strip shouldn't be shown
   */
  
function hideModeStrip()
  {
    
$this->is_mode_strip_visible false;
  }
  
/**
   * Returns value indicating whether mode strip should be shown or not
   * @returns bool
   */
  
function isModeStripVisible()
  {
    return 
$this->is_mode_strip_visible;
  }                       

  
/**
   * Holds value whether status bar should be displayed or not
   * @var bool
   */
  
var $is_status_bar_visible true;
  
/**
   * Sets value indicating that status bar should be shown
   */
  
function showStatusBar()
  {
    
$this->is_status_bar_visible true;
  }             
  
/**
   * Sets value indicating that status bar shouldn't be shown
   */
  
function hideStatusBar()
  {
    
$this->is_status_bar_visible false;
  }
  
/**
   * Returns value indicating whether status bar should be shown or not
   * @returns bool
   */
  
function isStatusBarVisible()
  {
    return 
$this->is_status_bar_visible;
  }                       

  
/**
   * Holds value whether resizing grip should be displayed or not
   * @var bool
   */
  
var $is_resizable true;
  
/**
   * Sets value indicating that resizing grip should be shown
   */
  
function showResizingGrip()
  {
    
$this->is_resizable true;
  }             
  
/**
   * Sets value indicating that resizing grip shouldn't be shown
   */
  
function hideResizingGrip()
  {
    
$this->is_resizable false;
  }
  
/**
   * Returns value indicating whether resizing grip should be shown or not
   * @returns bool
   */
  
function isResizingGripVisible()
  {
    return 
$this->is_resizable;
  }                       
  
  
/** 
   * Set's instance config item
   * @param string $name Config item's name
   * @param mixed $value Config item's value
   * @param integer $transfer_type Transfer type for the value (One or several of SPAW_CFG_TRANSFER_* constants). Default value - SPAW_CFG_TRANSFER_NONE
   */
  
function setConfigItem($name$value$transfer_type=SPAW_CFG_TRANSFER_NONE)
  {
    
$this->config->setConfigItem($name$value$transfer_type);
  }

  
/**
   * Gets instance config item
   * @param string $name Config item name
   * @returns SpawConfigItem      
   */   
  
function getConfigItem($name)
  {
    return 
$this->config->getConfigItem($name);
  }   

  
/**
   * Sets instance config item value
   * @param string $name Config item name
   * @param mixed $value Config item value
   */         
  
function setConfigValue($name$value)
  {
    
$this->config->setConfigValue($name$value);
  }

  
/**
   * Sets instance value for the element of config item provided item's value is an array
   * @param string $name Config item name
   * @param mixed $index Array index
   * @param mixed $value Element value
   */
  
function setConfigValueElement($name$index$value)
  {
    
$this->config->setConfigValueElement($name$index$value);
  }              

  
/**
   * Gets instance config item value
   * @param string $name Config item name
   * @returns mixed Config item value
   */         
  
function getConfigValue($name)
  {
    return 
$this->config->getConfigValue($name);
  }
  
  
/**
   * Gets instance value for the element of config item provided item's value is an array
   * @param string $name Config item name
   * @param mixed $index Array index
   * @returns mixed Element value
   */
  
function getConfigValueElement($name$index)
  {
    return 
$this->config->getConfigValueElement($name$index);
  }              
  
  
/**
   * Sets default property values if they were not explicitly specified
   */
  
function setDefaults()
  {
    if (
$this->theme == null)
      
$this->setTheme($this->config->getConfigValue('default_theme'));
    if (
$this->toolbars == null)
      
$this->addToolbarSet($this->config->getConfigValue('default_toolbarset'));
    if (
$this->stylesheet == null)
      
$this->setStylesheet($this->config->getConfigValue('default_stylesheet'));
    if (
$this->width == null)
      
$this->setDimensions($this->config->getConfigValue('default_width'), null);
    if (
$this->height == null)
      
$this->setDimensions(null$this->config->getConfigValue('default_height'));
    if (
$this->lang == null)
      
$this->setLanguage($this->config->getConfigValue('default_lang'), $this->config->getConfigValue('default_output_charset'));
  }     
  
  
/**
   * Returns HTML and JavaScript code for the editor
   * @returns string
   */
  
function getHtml()
  {
    
$res '';
    
$this->setDefaults();
    if (
SpawAgent::getAgent() != SPAW_AGENT_UNSUPPORTED)
    {
      
// supported browser
      
$head_res '';
      
$js_res '';
      
$html_res '';
      
$ssent = &SpawEditor::scriptSent();
      if (!
$ssent)
      {
        
$head_res .= '<script type="text/javascript" src="'.SpawConfig::getStaticConfigValue("SPAW_DIR").'js/spaw.js.php" charset="utf-8"></script>';
        
$js_res .= 'SpawEngine.setSpawDir("'SpawConfig::getStaticConfigValue("SPAW_DIR") . '"); SpawEngine.setPlatform("php");';
        
$ssent true;
      }
      
$objname $this->name.'_obj';
      
$js_res .= 'var '.$objname.' = new SpawEditor("'.$this->name.'");';
      
$js_res .= 'SpawEngine.registerEditor('.$objname.');';
      
$js_res .= $objname.'.setTheme(SpawTheme'.$this->theme->name.');';
      
$js_res .= $objname.'.setLang("'.$this->lang->lang.'");';
      
$js_res .= $objname.'.setOutputCharset("'.$this->lang->getOutputCharset().'");';
      
$js_res .= $objname.'.stylesheet = "'.$this->stylesheet.'";';
      
$js_res .= $objname.'.scid = "'.$this->config->storeSecureConfig().'";';
  
      
// add javascript or request uri config items
      
$reqstr '';
      foreach(
$this->config->config as $cfg)
      {
        if ((
$cfg->transfer_type SPAW_CFG_TRANSFER_JS) && is_scalar($cfg->value))
        {
          if (
is_numeric($cfg->value))
            
$js_res .= $objname.'.setConfigValue("'.$cfg->name.'", '.$cfg->value.');';
          else if (
is_bool($cfg->value))
            
$js_res .= $objname.'.setConfigValue("'.$cfg->name.'", '.($cfg->value?'true':'false').');';
          else 
// string
            
$js_res .= $objname.'.setConfigValue("'.$cfg->name.'", "'.$cfg->value.'");';
        }
        if ((
$cfg->transfer_type SPAW_CFG_TRANSFER_REQUEST) && is_scalar($cfg->value))
        {
          if (
is_bool($cfg->value))
            
$reqstr .= '&'.$cfg->name.'='.($cfg->value?'true':'false');
          else 
// string, number
            
$reqstr .= '&'.$cfg->name.'='.$cfg->value;
        }
      }
      if (
$reqstr != '')
      {
        
$js_res .= $objname.'.setConfigValue("__request_uri", "'.$reqstr.'");';
      }
  
  
  
      
$tpl ''// template
      
$fedtpl ''// editor template in floating mode
      
$other_present false;
  
      
$tbfrom $this->getToolbarFrom();
      
      
// parse template
      
if (!$this->getFloatingMode())
      {
        
// standard mode
        
$tpl $this->theme->getTemplate();
      }
      else
      {
        
// floating mode
        
$tpl '<span id="'.$this->name.'_toolbox" ';
        
$tpl .= ' style="z-index: 10000; position: absolute; cursor: move;"';
        
$tpl .= ' onMouseDown="'.$objname.'.floatingMouseDown(event);"';
        
$tpl .= ' >';
        
$tpl .= $this->theme->getTemplateToolbar();
        
$tpl .= '</span>';
        
$tpl .= $this->theme->getTemplateFloating();
      }
      
// if this is the main toolbar instance, add toolbars
      
if ($tbfrom->name == $this->name)
      {
        foreach(
$this->toolbars as $key => $tb)
        {
          if (
strpos($tpl'{SPAW TB='.strtoupper($key).'}'))
          {
            
// toolbar placeholder found
            
$tpl preg_replace('/(\{SPAW TB='.strtoupper($key).'\})(.*)(\{SPAW TOOLBAR\})(.*)(\{\/SPAW TB\})/sU''$2'.$tb->renderToolbar($this->name$this->theme).'$4'$tpl);
          }
          else
          {
            
// add to other toolbar placeholder
            
$tpl preg_replace('/(\{SPAW TB=_OTHER\})(.*)(\{SPAW TOOLBAR\})(.*)(\{\/SPAW TB\})/sU''$1$2'.$tb->renderToolbar($this->name$this->theme).'{SPAW TOOLBAR}$4$5'$tpl);
            
$other_present true;
          }
        }
      }
      elseif (
$this->getFloatingMode() && $this->toolbar_from->name != $this->name)
      {
        
// editor template for floating mode slave
        
$tpl $this->theme->getTemplateFloating();
      }
      
      
// replace all spaw dir references
      
$tpl str_replace("{SPAW DIR}"SpawConfig::getStaticConfigValue("SPAW_DIR"), $tpl);
      
      if (
$this->getFloatingMode())
      {
        
$js_res .= $objname.'.floating_mode = true;';
      }
      
// register this editor as controlled by other editors toolbar
      
$js_res .= $tbfrom->name '_obj.addControlledEditor('.$objname.');'."\n";
      
$js_res .= $objname.'.controlled_by = '.$tbfrom->name.'_obj;'."\n";
      
// remove unused toolbars
      
if ($other_present)
      {
        
// remove other toolbar tags leaving inner content intact
        
$tpl preg_replace('/(\{SPAW TB=_OTHER\})(.*)(\{SPAW TOOLBAR\})(.*)(\{\/SPAW TB\})/sU''$2$4'$tpl);
      }
      
// remove all toolbar tags and inner code
      
$tpl preg_replace('/(\{SPAW TB=[^\}]*\})(.*)(\{\/SPAW TB\})/sU'''$tpl);
      
      
// pages and tabs
      // setup tab templates
      
$tabtpl '';
      
$atabtpl '';
      if (
sizeof($this->pages)>1)
      {
        
// tab template
        
if (preg_match("/(\{SPAW TABSTRIP\})(.*)(\{SPAW TAB\})(.*)(\{\/SPAW TAB\})(.*)(\{\/SPAW TABSTRIP\})/sU"$tpl$matches))
        {
          
$tabtpl $matches[4];
        }
        
// active tab template
        
if (preg_match("/(\{SPAW TABSTRIP\})(.*)(\{SPAW TAB ACTIVE\})(.*)(\{\/SPAW TAB\})(.*)(\{\/SPAW TABSTRIP\})/sU"$tpl$matches))
        {
          
$atabtpl $matches[4];
        }
        
// remove tabstrip markers and mark tab place
        
$tpl preg_replace('/(\{SPAW TABSTRIP\})(.*)(\{\/SPAW TABSTRIP\})/sU''$2'$tpl);
        
$tpl preg_replace('/(\{SPAW TAB ACTIVE\})(.*)(\{\/SPAW TAB\})/sU''{SPAW TABS}'$tpl);
        
$tpl preg_replace('/(\{SPAW TAB\})(.*)(\{\/SPAW TAB\})/sU'''$tpl);
      }
      else
      {
        
// tabs not needed, remove tab strip
        
$tpl preg_replace('/(\{SPAW TABSTRIP\})(.*)(\{\/SPAW TABSTRIP\})/sU'''$tpl);
      }
      
      
// mode strip
      
if (strpos($tpl'{SPAW MODESTRIP}'))
      {
        if (
$this->isModeStripVisible())
        {
          
// modestrip placeholder found
          
$mstrip SpawToolbar::getToolbar("mode_strip");
          
$mstrip->editor = &$this;
          
$tpl preg_replace('/(\{SPAW MODESTRIP\})(.*)(\{SPAW MODES\})(.*)(\{\/SPAW MODESTRIP\})/sU''$2'.$mstrip->renderToolbar($this->name$this->theme).'$4'$tpl);
        }
        else
        {
          
// just remove the placeholder
          
$tpl preg_replace('/(\{SPAW MODESTRIP\})(.*)(\{\/SPAW MODESTRIP\})/sU'''$tpl);
        }
      }
  
      
// statusbar
      
if (strpos($tpl'{SPAW STATUSBAR}'))
      {
        if (
$this->isStatusBarVisible())
        {
          
// modestrip placeholder found
          
if ($this->isResizingGripVisible() && $this->config->getConfigValue('resizing_directions') != 'none')
          {
            
$grip '<img src="'.SpawConfig::getStaticConfigValue("SPAW_DIR").'plugins/core/lib/theme/'.$this->theme->name.'/img/sizing_grip.gif" border="0" style="cursor: se-resize;"';
            
$grip .= ' onmousedown="'.$objname.'.resizingGripMouseDown(event);"';
            
$grip .= ' unselectable="on"';
            
$grip .= ' alt="" />';
          }
          else
          {
            
$grip '';
          } 
          
$tpl preg_replace('/(\{SPAW STATUSBAR\})(.*)(\{SPAW STATUS\})(.*)(\{SPAW SIZINGGRIP\})(.*)(\{\/SPAW STATUSBAR\})/sU''$2<span id="'.$this->name.'_status"></span>$4'.$grip.'$6'$tpl);
        }
        else
        {
          
// remove status bar placeholder
          
$tpl preg_replace('/(\{SPAW STATUSBAR\})(.*)(\{\/SPAW STATUSBAR\})/sU'''$tpl);
        }
      }
  
  
      
$pagetpl '';
      
$tabstpl '';
      foreach(
$this->pages as $pname => $page)
      {
        
$pagetpl .= '<textarea name="'.$page->inputName.'" id="'.$pname.'" style="width: 100%; height: '.$this->height.'; display: none; overflow: scroll;" rows="10" cols="10">'.htmlspecialchars($page->value).'</textarea>';
        
$js_res .= 'var '.$pname.'_page = new SpawEditorPage("'.$pname.'","'.htmlspecialchars($page->caption).'","'.$page->direction.'");'."\n";
        
//$js_res .= $pname.'_page.value = "'.htmlspecialchars($page->value).'";'."\n";
        
$js_res .= $objname.'.addPage('.$pname.'_page);'."\n";
        
$js_res .= $objname.'.getTab("'.$pname.'").template = "'.addslashes(str_replace("{SPAW TAB CAPTION}"$page->caption$tabtpl)).'";'."\n";
        
$js_res .= $objname.'.getTab("'.$pname.'").active_template = "'.addslashes(str_replace("{SPAW TAB CAPTION}"$page->caption$atabtpl)).'";'."\n";
        if (
$this->name == $pname)
          
$js_res .= $objname.'.active_page ='.$pname.'_page;'."\n";
              
        
$pagetpl .= '<iframe name="'.$pname.'_rEdit" id="'.$pname.'_rEdit" style="width: 100%; height: '.$this->height.'; display: '.(($this->name == $pname)?'inline':'none').';" frameborder="no" src="'.SpawConfig::getStaticConfigValue("SPAW_DIR").'empty/empty.html?'.microtime().'"></iframe>';
        
$tabstpl .= '<span id="'.$pname.'_tab" style="cursor: default;" onclick="'.$objname.'.setActivePage(\''.$pname.'\');">'.str_replace("{SPAW TAB CAPTION}"$page->caption, ($pname == $this->name)?$atabtpl:$tabtpl).'</span>'
      }
      
$tpl str_replace('{SPAW EDITOR}'$pagetpl$tpl);
  
      
$tpl str_replace('{SPAW TABS}',$tabstpl,$tpl);    
      
      
$html_res .= '<table border="0" cellpadding="0" cellspacing="0" id="'.$this->name.'_enclosure" class="'.$this->theme->name.'" style="padding: 0px 0px 0px 0px; width: '.$this->width.';"><tr><td>'.$tpl.'</td></tr></table>';
      
      
$js_res .= $objname.'.onLoadHookup();'."\n";
  
      
$res $head_res.'<script type="text/javascript" id="'.$pname.'_script">'."\n<!--\n".$js_res."\n//-->\n".'</script>'.$html_res;
    }
    else
    {
      
// standard textarea fallback
      
foreach($this->pages as $pname => $page)
      {
        if (
sizeof($this->pages)>1)
          
$res .= '<label for="'.$pname.'">'.$page->caption.'</label><br />';
        
$res .= '<textarea name="'.$pname.'" id="'.$pname.'" width="'.$this->width.'" height="'.$this->height.'" style="width: '.$this->width.'; height: '.$this->height.';" wrap="off">'.htmlspecialchars($page->value).'</textarea><br />';
      }
    }
    return 
$res;
  }
  
  
/**
   * Outputs editor's HTML code to the client
   */
  
function show()
  {
    echo 
$this->getHtml();
  }             
                                                                                            
}

/**
 * Wrapper for seamless upgrade from v.1.x
 * @package spaw2
 * @subpackage Editor
 */
class SPAW_Wysiwyg extends SpawEditor 
{
  function 
SPAW_Wysiwyg($control_name=''$value=''$lang=''$mode '',
              
$theme=''$width=''$height=''$css_stylesheet=''$dropdown_data='')
  {
    
// value translations
    
switch($mode)
    {
      case 
'default':
        
$mode 'standard';
        break;
      case 
'full':
        
$mode 'all';
        break;
      case 
'mini':
        
$mode 'mini';
        break;
      default:
        
$mode '';
        break;
    }
    
parent::SpawEditor($control_name$value$lang$mode''$width$height$css_stylesheet);
    
    if (
$mode == 'mini')
      
$this->hideStatusBar();
  }
}
?>
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586