NacoWiki PHP API

PluginHTML
in package

HTML media handler

NacoWiki HTML render.

This plugin is used to handle HTML files. Implements a media handler interface.

To maintain the HTML syntax, HTML documents must follow this template:

<html>
  <head>
    <!-- texts in meta tags are assumed to be url encoded -->
    <!--    Use "%22" to insert a quote (") -->
    <!--    Use "%25" to insert a "%" -->
    <title>Test HTML document</title>
    <meta name="sample" content="meta-data">
    <!--meta name="example-key" content="example-value"-->
  </head>
  <body>
    HTML content
  </body>
</html>

Note, only the HTML between <body> and </body> will be rendered. Also, the meta data is read from the <head> section. However, only the lines with <title> and <meta> tags are recognized.

The <title> contents uses htmlspecialchars for escaping. On the other hand, the content of the <meta> is URL encoded at least for the % (%25) and " (%22) characters.

Tags
phpcod

PluginHTML

Table of Contents

Constants

VERSION  = '2.0.0'
var string

Methods

edit()  : bool|null
Edit event handler
load()  : void
Loading entry point for this class
makeSource()  : string
Wraps metadata and HTML content
preSave()  : bool|null
preSave event handler
read()  : bool|null
Read event handler
readStruct()  : string
Read structured data

Constants

VERSION

var string

public mixed VERSION = '2.0.0'

Methods

edit()

Edit event handler

public static edit(NanoWikiApp $wiki, array<string|int, mixed> &$data) : bool|null

Handles edit:[ext] events.

It creates a CodeMirror editor page with the configuration for HTML editing.

Parameters
$wiki : NanoWikiApp

running wiki instance

$data : array<string|int, mixed>
Return values
bool|null

load()

Loading entry point for this class

public static load(array<string|int, mixed> $cfg) : void

Hooks HTML media implemented by this class

Parameters
$cfg : array<string|int, mixed>

makeSource()

Wraps metadata and HTML content

public static makeSource(array<string|int, mixed> $meta, string $body) : string

Wraps the metadata and HTML content in a formatted HTML document that follows the template.

Parameters
$meta : array<string|int, mixed>
$body : string

HTML payload

Return values
string

full HTML document (with and sections).

preSave()

preSave event handler

public static preSave(NanoWikiApp $wiki, array<string|int, mixed> &$ev) : bool|null

Handles preSave:[ext] events.

Reads from the submitted text the and parses metadata. Also, extracts the section. It then rewraps into a templated document.

This makes the saved file in a consistent format.

Parameters
$wiki : NanoWikiApp

running wiki instance

$ev : array<string|int, mixed>

passed event

Return values
bool|null

read()

Read event handler

public static read(NanoWikiApp $wiki, array<string|int, mixed> &$ev) : bool|null

Handles read:[ext] events.

Reads the source code and extract meta data tags from the

section.

Also extracts the </body and returns it as the payload.

Parameters
$wiki : NanoWikiApp

running wiki instance

$ev : array<string|int, mixed>

passed event

Return values
bool|null

readStruct()

Read structured data

public static readStruct(string $source, array<string|int, mixed> &$meta) : string

Extracts meta data tags embedded in source code and separates the from the HTML source.

Parameters
$source : string

text to process

$meta : array<string|int, mixed>

receives the read meta data

Return values
string

Returns payload within ... tags.


        
On this page

Search results