You are here

function fckeditor_load_toolbar_options in FCKeditor - WYSIWYG HTML editor 6.2

Same name and namespace in other branches
  1. 5.2 fckeditor.module \fckeditor_load_toolbar_options()
  2. 6 fckeditor.module \fckeditor_load_toolbar_options()
2 calls to fckeditor_load_toolbar_options()
fckeditor_admin_profile_form in ./fckeditor.admin.inc
Form builder for a normal profile
fckeditor_user_delegate in ./fckeditor.user.inc
FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2008 Frederico Caldeira Knabben

File

./fckeditor.lib.inc, line 102
FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2008 Frederico Caldeira Knabben

Code

function fckeditor_load_toolbar_options() {
  $arr = array();
  $module_drupal_path = drupal_get_path('module', 'fckeditor');
  $editor_local_path = fckeditor_path(TRUE);
  $fckconfig_js = $editor_local_path . '/fckconfig.js';
  $fckeditor_config_js = $module_drupal_path . '/fckeditor.config.js';
  if (file_exists($fckconfig_js) && is_readable($fckconfig_js)) {
    $fp = @fopen($fckconfig_js, "r");
    if ($fp) {
      while (!feof($fp)) {
        $line = fgets($fp, 1024);
        $matches = array();
        if (preg_match('/FCKConfig\\.ToolbarSets\\[("|\')(.*?)\\1\\]/i', $line, $matches)) {
          $arr[$matches[2]] = drupal_ucfirst($matches[2]);
        }
      }
      fclose($fp);
    }
  }
  if (file_exists($fckeditor_config_js) && is_readable($fckeditor_config_js)) {
    $fp = @fopen($fckeditor_config_js, "r");
    if ($fp) {
      while (!feof($fp)) {
        $line = fgets($fp, 1024);
        $matches = array();
        if (preg_match('/FCKConfig\\.ToolbarSets\\[("|\')(.*?)\\1\\]/i', $line, $matches)) {
          $arr[$matches[2]] = drupal_ucfirst($matches[2]);
        }
      }
      fclose($fp);
    }
  }

  //oops, we have no information about toolbars, let's use hardcoded array
  if (empty($arr)) {
    $arr = array(
      'Basic' => 'Basic',
      'Default' => 'Default',
    );
  }
  asort($arr);
  return $arr;
}