Skip to main content
PHP HTML Editor

Modern API

Load richtexteditor/phphtmleditor/autoload.php and use the PhpHtmlEditor namespace. No Composer needed.

PhpHtmlEditor\Editor

MemberDescription
new Editor($name)The editor's name is its form field name.
$htmlThe content to edit.
$width, $heightCSS lengths; '100%' and '400px' by default.
$toolbardefault, basic, full, mobile, office, or the name of a custom toolbar defined in $config.
$configAny option of the JavaScript editor, passed as-is: $editor->config['readOnly'] = true;
$languageA file in richtexteditor/lang: 'de' loads rte-lang-de.js. The file manager and the server's messages (a refused upload, rename or delete) follow it in 12 languages (en, zh-Hans, zh-Hant, de, fr, es, it, pt, nl, ru, ja, ko); any of the file manager's texts can be replaced with $config['text_phpfiles_<key>'].
$policyFileThe policy file in richtexteditor/config, or a full path. Choose it from your login system.
$runtimeUrlURL of the richtexteditor folder; detected when it is under the web root.
$appRoot, $appUrlWhat ~/ means in a policy (path and URL); the web root by default.
handleRequest()Answers this editor's upload, gallery and file requests and ends them. Call it before any output; it also starts the PHP session that protects them.
render()The editor's HTML for your form.
posted()The submitted HTML of this editor, sanitized with its policy.
sanitize($html)Sanitizes any HTML with this editor's policy.
setSecurity($category, $storage, $name, $value)Overrides one policy setting for this editor.
policy()The Policy object in use.

Other classes

  • Policy::fromFile($path), get($category, $storage, $name), getBool(), getInt(), setSecurity(), storages($category): read a policy file.
  • new Storage($policy, $category, $storage): listFolder(), upload(), createFolder(), rename(), delete(), permissions(), with every check of the policy applied. Use it to build your own file pages.
  • new Sanitizer($policy) and sanitize($html): the server-side cleaning on its own.

Several editors

$summary = new Editor('Summary');
$body = new Editor('Body');
$summary->handleRequest();
$body->handleRequest();
// later: $summary->render(), $body->render(); $summary->posted(), $body->posted()