CMS  Version 3.9
html_editor_manager.inc
Go to the documentation of this file.
1 <?php
13 {
14  static $plugins = array();
15  static $additionalPlugins = array();
16  static $actionFilters = array();
17 
18  function HtmlEditorManager()
19  {
20 
21  }
22 
23  static function registerPlugin($title, $plugin)
24  {
26  }
27 
28  static function registerAdditionalPlugin($title, $plugin)
29  {
31  }
32 
33  static function registerActionFilter($filter)
34  {
36  }
37 
38  static function upgradeComponent($version)
39  {
41  $mgr->upgrade($version);
42  }
43 
44  static function setDefaults()
45  {
46  Settings::setDefaultValue("html_editor", "CSS_files", "", Text, "List of CSS files to apply within the editor. Put each CSS file on a separate line.", "Appearance");
47  Settings::setDefaultValue("html_editor", "body_class", "", String, "Body class to be applied to content within the editor - use this to override inappropriate styles", "Appearance");
48 
49  Settings::setDefaultValue("html_editor", "enable_custom_CSS", false, Boolean, "", "Custom CSS", null, 1);
50  Settings::setDefaultValue("html_editor", "custom_CSS", "", Text, "This setting can be used to provide custom CSS styles, configurable from the HTML editor. A link tag to /action/html_editor/custom_styles must be added to your site's template files.", "Custom CSS", null, 2);
51  }
52 
53  static function registerSerializationHandler()
54  {
56  return true;
57  }
58 
59  static function onInitialize()
60  {
61  global $tiny_mce_application_plugins;
62  global $tiny_mce_application_toolbar_section;
63  global $tiny_mce_application_context_menu_section;
64  global $tiny_mce_content_css;
65  global $tiny_mce_body_class;
66 
67  ComponentManager::fireEvent("RegisterHTMLEditorPlugins");
68  ComponentManager::fireEvent("RegisterHTMLEditorActionFilters");
69 
70  $tiny_mce_application_plugins = implode(",", array_keys(HtmlEditorManager::$plugins));
71  $tiny_mce_application_toolbar_section = implode(" ", array_keys(HtmlEditorManager::$plugins)) . " |";
72  $tiny_mce_application_context_menu_section = implode(" ", array_keys(HtmlEditorManager::$plugins)) . " |";
73  $tiny_mce_content_css = Settings::getValue("html_editor", "CSS_files");
74  $tiny_mce_body_class = Settings::getValue("html_editor", "body_class");
75 
76  if (count(HtmlEditorManager::$actionFilters) > 0)
77  {
78  HTMLFieldRenderer::$actionFilter = 'HTMLEditorManager::handleActionFilters';
79  }
80  }
81 
82  static function handleActionFilters($context)
83  {
84  foreach(HTMLEditorManager::$actionFilters as $filter)
85  {
86  $context = $filter($context);
87  }
88  return $context;
89  }
90 
91  static function applyCustomCSS($template)
92  {
93  if (Settings::getValue("html_editor", "enable_custom_css"))
94  {
95  $template = str_replace("</head>", " <link href='/action/html_editor/custom_css' rel='stylesheet'/>\n</head>", $template);
96  }
97  return $template;
98  }
99 
101  {
102  $matches = array();
103  if (preg_match_all("/{([^}]+)}/", $snippet->snippet, $matches, PREG_PATTERN_ORDER))
104  {
105  $fields = array_unique($matches[1]);
106 
107  ?>
108  <h4>Snippet Parameters</h4>
109  <table class='form' id='snippet_parameters'>
110 
111  <?
112  foreach($fields as $field)
113  {
114  ?>
115  <tr><td class='label'><label><?echo $field?></label></td>
116  <td class='value'><input type='text' name='<?echo $field?>' class='snippet_parameter' id='snippet_parameter_{$i}' value='' size='75'/></td></tr>
117  <?
118  }
119  ?>
120  </table>
121  <br/>
122  <?
123  }
124  }
125 
126 }
127 ?>
$imageUpload size
Definition: image_form.inc:68
$filter
Definition: update.inc:44
static fireEvent($event, $parameter=null, $mustBeConsumed=false)
Fire an event to all subscribers as detailed in their manifests.
Provides a central management class for event handlers and common functionality for the html_editor c...
static applyCustomCSS($template)
static formatSnippetParameters($snippet)
static registerSerializationHandler()
static registerActionFilter($filter)
static registerPlugin($title, $plugin)
static upgradeComponent($version)
static handleActionFilters($context)
static registerAdditionalPlugin($title, $plugin)
registerHandler($component, $title, $handler)
Registers a serialization handler for a component.
static getValue($component, $name)
Retrieve the value of the specified Setting.
Definition: settings.inc:104
static setDefaultValue($component, $name, $value, $field_type="String", $annotation="", $category="", $options="", $weight=0)
Sets the default value of the given component setting.
Definition: settings.inc:174
Provides a simple implementation of a SerializationHandler that can serialize a single DataItem class...
$snippet
Definition: snippet.inc:7