Zeta Components - high quality PHP components

Zeta Components Manual :: Docs For Class ezcDocumentWiki

Document::ezcDocumentWiki

Class ezcDocumentWiki

Document handler for wiki text documents.

This document handler implements generic conversions for wiki markup languages. The tokenizer, which differs for each wiki language, can be set directly, or you may use the extended implementations for the specific sytaxes:

  • ezcDocumentConfluenceWiki
  • ezcDocumentCreoleWiki
  • ezcDocumentDokuwikiWiki
Each wiki syntax has some sort of plugin mechanism, which allows you to handle the contents of a special formatted syntax element using custom classes or external applications. You can register a plugin for this, which then need to "parse" the element contents itself and may return random docbook markup.

The basic conversion of a wiki document into a docbook document, using the default creole tokenizer, looks like:

  1.   $document = new ezcDocumentWiki();
  2.   $document->loadString( '
  3.   = Example text =
  4.  
  5.   Just some exaple paragraph with a heading, some **emphasis** markup and a
  6.   [[http://ezcomponents.org|link]].' );
  7.  
  8.   $docbook = $document->getAsDocbook();
  9.   echo $docbook->save();

You may switch the used tokenizer using the respective options of the document class, defined in the ezcDocumentWikiOptions class:

  1.   $document = new ezcDocumentWiki();
  2.   $document->options->tokenizer = new ezcDocumentWikiConfluenceTokenizer();
  3.   $document->loadString( '
  4.   h1. Example text
  5.  
  6.   Just some exaple paragraph with a heading, some *emphasis* markup and a
  7.   [link|http://ezcomponents.org].' );
  8.  
  9.   $docbook = $document->getAsDocbook();
  10.   echo $docbook->save();

For the conversion back from docbook to wiki markup, currently only one converter to creole markup has been implemented. This conversion can be used like:

  1.   $docbook = new ezcDocumentDocbook();
  2.   $docbook->loadFile( 'docbook.xml' );
  3.  
  4.   $document = new ezcDocumentWiki();
  5.   $document->createFromDocbook( $docbook );
  6.   echo $document->save();

Source for this file: /Document/src/document/wiki.php

Implements interfaces:

ezcDocument
   |
   --ezcDocumentWiki
Version:   //autogen//

Descendants

Child Class Description
ezcDocumentConfluenceWiki Document handler for Confluence wiki text documents.
ezcDocumentCreoleWiki Document handler for Creole wiki text documents.
ezcDocumentDokuwikiWiki Document handler for Dokuwiki wiki text documents.

Member Variables

protected ezcDocumentWikiDocumentNode $ast
Asbtract syntax tree.

The internal representation of RST documents.

protected string $contents
Plain RST contents as a string
protected array $plugins = array(
'code' => 'ezcDocumentWikiCodePlugin',
)

Registered plugins

Plugins are special RST element, which are documented at: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#plugins

Plugins are the best entry point for custom rules, and you may register custom plugin classes using the class method registerPlugin().

Inherited Member Variables

From ezcDocument
protected ezcDocument::$errors
protected ezcDocument::$options
protected ezcDocument::$path

Method Summary

public void createFromDocbook( $document )
Create document from docbook document
public ezcDocumentDocbook getAsDocbook( )
Return document compiled to the docbook format
public string getPluginHandler( $name )
Get plugin handler
public void loadString( $string )
Create document from input string
public void registerPlugin( $name , $class )
Register plugin handler
public string save( )
Return document as string
public mixed validateFile( $file )
Validate the input file
public mixed validateString( $string )
Validate the input string

Inherited Methods

From ezcDocument
public ezcDocument ezcDocument::__construct()
Construct new document
public abstract void ezcDocument::createFromDocbook()
Create document from docbook document
public abstract ezcDocumentDocbook ezcDocument::getAsDocbook()
Return document compiled to the docbook format
public array ezcDocument::getErrors()
Return list of errors occured during visiting the document.
public string ezcDocument::getPath()
Get document base path
public void ezcDocument::loadFile()
Create document from file
public abstract void ezcDocument::loadString()
Create document from input string
public abstract string ezcDocument::save()
Return document as string
public void ezcDocument::setPath()
Set document base path
public void ezcDocument::triggerError()
Trigger visitor error

Methods

createFromDocbook

void createFromDocbook( ezcDocumentDocbook $document )

Create document from docbook document

A document of the docbook format is provided and the internal document structure should be created out of this.

This method is required for all formats to have one central format, so that each format can be compiled into each other format using docbook as an intermediate format.

You may of course just call an existing converter for this conversion.

Parameters:
Name Type Description
$document ezcDocumentDocbook
Redefinition of:
Method Description
ezcDocument::createFromDocbook() Create document from docbook document
Redefined in descendants as:
Method Description
ezcDocumentConfluenceWiki::createFromDocbook() Create document from docbook document 
ezcDocumentDokuwikiWiki::createFromDocbook() Create document from docbook document 

getAsDocbook

ezcDocumentDocbook getAsDocbook( )

Return document compiled to the docbook format

The internal document structure is compiled to the docbook format and the resulting docbook document is returned.

This method is required for all formats to have one central format, so that each format can be compiled into each other format using docbook as an intermediate format.

You may of course just call an existing converter for this conversion.

Redefinition of:
Method Description
ezcDocument::getAsDocbook() Return document compiled to the docbook format

getPluginHandler

string getPluginHandler( string $name )

Get plugin handler

Get plugin handler class name for the specified name.

Parameters:
Name Type Description
$name string

loadString

void loadString( string $string )

Create document from input string

Create a document of the current type handler class and parse it into a usable internal structure.

Parameters:
Name Type Description
$string string
Redefinition of:
Method Description
ezcDocument::loadString() Create document from input string

registerPlugin

void registerPlugin( string $name , string $class )

Register plugin handler

Register a custom plugin handler for special plugins or overwrite existing plugin handlers. The plugins are specified by its (lowercase) name and the class name, which should handle the plugin and extend from ezcDocumentWikiPlugin.

Parameters:
Name Type Description
$name string
$class string

save

string save( )

Return document as string

Serialize the document to a string an return it.

Redefinition of:
Method Description
ezcDocument::save() Return document as string

validateFile

mixed validateFile( string $file )

Validate the input file

Validate the input file against the specification of the current document format.

Returns true, if the validation succeded, and an array with ezcDocumentValidationError objects otherwise.

Parameters:
Name Type Description
$file string
Implementation of:
Method Description
ezcDocumentValidation::validateFile() Validate the input file

validateString

mixed validateString( string $string )

Validate the input string

Validate the input string against the specification of the current document format.

Returns true, if the validation succeded, and an array with ezcDocumentValidationError objects otherwise.

Parameters:
Name Type Description
$string string
Implementation of:
Method Description
ezcDocumentValidation::validateString() Validate the input string
Documentation generated by phpDocumentor 1.4.3