Changeset 4630 for extensions/FCKEditor


Ignore:
Timestamp:
01/06/10 15:37:32 (10 years ago)
Author:
patdenice
Message:

[Plugin][FCK Editor]
Add editor to page banner edition.
Allow to add FCK Editor instance in any plugin.

Location:
extensions/FCKEditor
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/FCKEditor/fckeditor.php

    r4629 r4630  
    99  if (!isset($page['page'])) return $plugin_menu_links; 
    1010 
    11   if (!($config = unserialize($conf['FCKEditor']))) 
    12   { 
    13     $config = array(); 
    14   } 
    1511  $toolbar = 'Full'; 
    1612  $width = '750px'; 
     
    4036    $template->set_prefilter('notification_by_mail', 'add_remove_button'); 
    4137  } 
     38  // Page banner 
     39  elseif ($page['page'] == 'configuration') 
     40  { 
     41    $areas[] = 'page_banner'; 
     42    $width = '70%'; 
     43    $toolbar = 'Basic'; 
     44    $template->set_outputfilter('config', 'add_remove_button_banner'); 
     45  } 
    4246  elseif ($page['page'] == 'plugin') 
    4347  { 
     
    4852      $areas[] = 'ap_content'; 
    4953      $width = '100%'; 
    50       $height = '400px'; 
    51       $template->set_prefilter('plugin_admin_content', 'add_remove_button'); 
     54      $template->set_outputfilter('module_options', 'add_remove_button_br'); 
    5255    } 
    5356    // PWG Stuffs 
     
    5558    { 
    5659      $areas[] = 'personal_content'; 
    57       $width = '100%'; 
     60      $width = '99%'; 
    5861      $height = '250px'; 
    5962      $template->set_prefilter('module_options', 'add_remove_button_stuffs'); 
     
    6366  if (!empty($areas)) 
    6467  { 
    65     $head_element = ' 
    66 <style type="text/css"> 
    67 FORM#catModify TABLE TABLE { width: 100%; } 
    68 </style> 
    69 <script type="text/javascript" src="'.FCK_PATH.'ckeditor/ckeditor.js"></script> 
    70 <script type="text/javascript"> 
    71 CKEDITOR.config.toolbar_Basic = 
    72 [ 
    73   ["Source"],["Bold","Italic","Underline"], 
    74   ["JustifyLeft","JustifyCenter","JustifyRight","JustifyBlock"], 
    75   ["Styles","Format","Font","FontSize"], 
    76   ["Link","Unlink","ShowBlocks"] 
    77 ]; 
    78 CKEDITOR.config.width = "'.$width.'"; 
    79 CKEDITOR.config.height = "'.$height.'"; 
    80 CKEDITOR.config.toolbar = "'.$toolbar.'"; 
    81 window.onload = function() 
    82 { 
    83 '; 
    84     foreach ($areas as $area) 
    85     { 
    86       if (!isset($config[$area]) or $config[$area]) 
    87       { 
    88         $head_element .= 'CKEDITOR.replace("'.$area.'");'; 
    89       } 
    90     } 
    91     $head_element .= ' 
    92 } 
    93  
    94 function toogleEditor(name) { 
    95   if (typeof( CKEDITOR.instances[name] ) != "undefined") { 
    96     CKEDITOR.instances[name].destroy(); 
    97     jQuery.post("plugins/FCKEditor/update_config.php", {area: name, status: "off"}); 
    98   } else { 
    99     CKEDITOR.replace(name); 
    100     jQuery.post("plugins/FCKEditor/update_config.php", {area: name, status: "on"}); 
    101   } 
    102 } 
    103 </script>'; 
    104  
    105     $template->append('head_elements', $head_element); 
     68    set_fckeditor_instance($areas, $toolbar, $width, $height); 
    10669  } 
    10770  return $plugin_menu_links; 
     
    12386} 
    12487 
     88function add_remove_button_banner($content, &$smarty) 
     89{ 
     90  $pattern = '#(<textarea.*?name="(.*?)".*?</textarea>)#ims'; 
     91  $replacement = '$1<a href="#" onClick="toogleEditor(\'$2\'); return false;" style="border-bottom: none; float: right; margin-right: 5%;">FCK Editor On/Off</a>'; 
     92  return preg_replace($pattern, $replacement, $content); 
     93} 
     94 
    12595?> 
  • extensions/FCKEditor/main.inc.php

    r4629 r4630  
    1717  include(FCK_PATH.'fckeditor.php'); 
    1818} 
     19 
     20function set_fckeditor_instance($areas=array(), $toolbar='Basic', $width='750px', $height='200px') 
     21{ 
     22  global $template, $conf; 
     23 
     24  if (is_string($areas)) 
     25  { 
     26    $areas = array($areas); 
     27  } 
     28  if (!($config = unserialize($conf['FCKEditor']))) 
     29  { 
     30    $config = array(); 
     31  } 
     32  $template->set_filename('fckeditor', realpath(FCK_PATH.'fckeditor.tpl')); 
     33    $template->assign( 
     34      array( 
     35        'FCK_PATH'    => FCK_PATH, 
     36        'FCK_config'  => $config, 
     37        'FCK_areas'   => $areas, 
     38        'FCK_WIDTH'   => $width, 
     39        'FCK_HEIGHT'  => $height, 
     40        'FCK_TOOLBAR' => $toolbar, 
     41        ) 
     42      ); 
     43    $template->parse('fckeditor'); 
     44} 
    1945?> 
Note: See TracChangeset for help on using the changeset viewer.