diff --git a/wicked/lib/Text_Wiki/.gitignore b/wicked/lib/Text_Wiki/.gitignore new file mode 100644 index 00000000000..869f4985844 --- /dev/null +++ b/wicked/lib/Text_Wiki/.gitignore @@ -0,0 +1,4 @@ +# composer related +composer.lock +composer.phar +vendor diff --git a/wicked/lib/Text_Wiki/.travis.yml b/wicked/lib/Text_Wiki/.travis.yml new file mode 100644 index 00000000000..5ba3d83539d --- /dev/null +++ b/wicked/lib/Text_Wiki/.travis.yml @@ -0,0 +1,7 @@ +language: php +install: + - pear install package.xml +php: + - 5.4 +sudo: false +script: phpunit tests/ \ No newline at end of file diff --git a/wicked/lib/Text_Wiki/Text/Wiki.php b/wicked/lib/Text_Wiki/Text/Wiki.php new file mode 100644 index 00000000000..3f1ab9d6346 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki.php @@ -0,0 +1,1559 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * The baseline abstract parser class. + */ +require_once 'Text/Wiki/Parse.php'; + +/** + * The baseline abstract render class. + */ +require_once 'Text/Wiki/Render.php'; + +/** + * Parse structured wiki text and render into arbitrary formats such as XHTML. + * + * This is the "master" class for handling the management and convenience + * functions to transform Wiki-formatted text. + * + * @category Text + * @package Text_Wiki + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + */ +class Text_Wiki { + + /** + * + * The default list of rules, in order, to apply to the source text. + * + * @access public + * + * @var array + * + */ + + var $rules = array( + 'Prefilter', + 'Delimiter', + 'Code', + 'Function', + 'Html', + 'Raw', + 'Include', + 'Embed', + 'Anchor', + 'Heading', + 'Toc', + 'Horiz', + 'Break', + 'Blockquote', + 'List', + 'Deflist', + 'Table', + 'Image', + 'Phplookup', + 'Center', + 'Newline', + 'Paragraph', + 'Url', + 'Freelink', + 'Interwiki', + 'Wikilink', + 'Colortext', + 'Strong', + 'Bold', + 'Emphasis', + 'Italic', + 'Underline', + 'Tt', + 'Superscript', + 'Subscript', + 'Revise', + 'Tighten' + ); + + + /** + * + * The list of rules to not-apply to the source text. + * + * @access public + * + * @var array + * + */ + + var $disable = array( + 'Html', + 'Include', + 'Embed' + ); + + + /** + * + * Custom configuration for rules at the parsing stage. + * + * In this array, the key is the parsing rule name, and the value is + * an array of key-value configuration pairs corresponding to the $conf + * property in the target parsing rule. + * + * For example: + * + * + * $parseConf = array( + * 'Include' => array( + * 'base' => '/path/to/scripts/' + * ) + * ); + * + * + * Note that most default rules do not need any parsing configuration. + * + * @access public + * + * @var array + * + */ + + var $parseConf = array(); + + + /** + * + * Custom configuration for rules at the rendering stage. + * + * Because rendering may be different for each target format, the + * first-level element in this array is always a format name (e.g., + * 'Xhtml'). + * + * Within that first level element, the subsequent elements match the + * $parseConf format. That is, the sub-key is the rendering rule name, + * and the sub-value is an array of key-value configuration pairs + * corresponding to the $conf property in the target rendering rule. + * + * @access public + * + * @var array + * + */ + + var $renderConf = array( + 'Docbook' => array(), + 'Latex' => array(), + 'Pdf' => array(), + 'Plain' => array(), + 'Rtf' => array(), + 'Xhtml' => array() + ); + + + /** + * + * Custom configuration for the output format itself. + * + * Even though Text_Wiki will render the tokens from parsed text, + * the format itself may require some configuration. For example, + * RTF needs to know font names and sizes, PDF requires page layout + * information, and DocBook needs a section hierarchy. This array + * matches the $conf property of the the format-level renderer + * (e.g., Text_Wiki_Render_Xhtml). + * + * In this array, the key is the rendering format name, and the value is + * an array of key-value configuration pairs corresponding to the $conf + * property in the rendering format rule. + * + * @access public + * + * @var array + * + */ + + var $formatConf = array( + 'Docbook' => array(), + 'Latex' => array(), + 'Pdf' => array(), + 'Plain' => array(), + 'Rtf' => array(), + 'Xhtml' => array() + ); + + + /** + * + * The delimiter for token numbers of parsed elements in source text. + * + * @access public + * + * @var string + * + */ + + var $delim = "\31"; + + + /** + * + * The tokens generated by rules as the source text is parsed. + * + * As Text_Wiki applies rule classes to the source text, it will + * replace portions of the text with a delimited token number. This + * is the array of those tokens, representing the replaced text and + * any options set by the parser for that replaced text. + * + * The tokens array is sequential; each element is itself a sequential + * array where element 0 is the name of the rule that generated the + * token, and element 1 is an associative array where the key is an + * option name and the value is an option value. + * + * @access private + * + * @var array + * + */ + + var $tokens = array(); + + /** + * How many tokens generated pro rules. + * + * Intended to load only necessary render objects + * + * @access private + * @var array + */ + var $_countRulesTokens = array(); + + + /** + * + * The source text to which rules will be applied. + * + * This text will be transformed in-place, which means that it will + * change as the rules are applied. + * + * @access private + * + * @var string + * + */ + + var $source = ''; + + /** + * The output text + * + * @var string + */ + var $output = ''; + + + /** + * + * Array of rule parsers. + * + * Text_Wiki creates one instance of every rule that is applied to + * the source text; this array holds those instances. The array key + * is the rule name, and the array value is an instance of the rule + * class. + * + * @access private + * + * @var array + * + */ + + var $parseObj = array(); + + + /** + * + * Array of rule renderers. + * + * Text_Wiki creates one instance of every rule that is applied to + * the source text; this array holds those instances. The array key + * is the rule name, and the array value is an instance of the rule + * class. + * + * @access private + * + * @var array + * + */ + + var $renderObj = array(); + + + /** + * + * Array of format renderers. + * + * @access private + * + * @var array + * + */ + + var $formatObj = array(); + + + /** + * + * Array of paths to search, in order, for parsing and rendering rules. + * + * @access private + * + * @var array + * + */ + + var $path = array( + 'parse' => array(), + 'render' => array() + ); + + + + /** + * + * The directory separator character. + * + * @access private + * + * @var string + * + */ + + var $_dirSep = DIRECTORY_SEPARATOR; + + /** + * Temporary configuration variable + * + * @var string + */ + var $renderingType = 'normal'; + + /** + * Stack of rendering callbacks + * + * @var Array + */ + var $_renderCallbacks = array(); + + /** + * Current output block + * + * @var string + */ + var $_block; + + /** + * A stack of blocks + * + * @param Array + */ + var $_blocks; + + /** + * A fix for PHP5. + * + * **DEPRECATED** + * Please use the singleton() or factory() methods. + * + * @param mixed $rules null or an array. + * + * @return $this + * @uses self::Text_Wiki() + */ + function __construct($rules = null) + { + if (is_array($rules)) { + $this->rules = array(); + foreach ($rules as $rule) { + $this->rules[] = ucfirst($rule); + } + } + + $this->addPath( + 'parse', + $this->fixPath(dirname(__FILE__)) . 'Wiki/Parse/Default/' + ); + $this->addPath( + 'render', + $this->fixPath(dirname(__FILE__)) . 'Wiki/Render/' + ); + } + + /** + * + * Constructor. + * + * **DEPRECATED** + * Please use the singleton() or factory() methods. + * + * @access public + * + * @param array $rules The set of rules to load for this object. Defaults to null + * which will load the default ruleset for this parser. + * + * @return $this + * @see self::__construct() + */ + function Text_Wiki($rules = null) + { + $this->__construct($rules); + } + + /** + * Singleton. + * + * This avoids instantiating multiple Text_Wiki instances where a number + * of objects are required in one call, e.g. to save memory in a + * CMS invironment where several parsers are required in a single page. + * + * $single = singleton(); + * + * or + * + * $single = singleton('Parser', array('Prefilter', 'Delimiter', 'Code', 'Function', + * 'Html', 'Raw', 'Include', 'Embed', 'Anchor', 'Heading', 'Toc', 'Horiz', + * 'Break', 'Blockquote', 'List', 'Deflist', 'Table', 'Image', 'Phplookup', + * 'Center', 'Newline', 'Paragraph', 'Url', 'Freelink', 'Interwiki', 'Wikilink', + * 'Colortext', 'Strong', 'Bold', 'Emphasis', 'Italic', 'Underline', 'Tt', + * 'Superscript', 'Subscript', 'Revise', 'Tighten')); + * + * Call using a subset of this list. The order of passing rulesets in the + * $rules array is important! + * + * After calling this, call $single->setParseConf(), setRenderConf() or setFormatConf() + * as usual for a constructed object of this class. + * + * The internal static array of singleton objects has no index on the parser + * rules, the only index is on the parser name. So if you call this multiple + * times with different rules but the same parser name, you will get the same + * static parser object each time. + * + * @since Method available since Release 1.1.0 + * @param string $parser The parser to be used (defaults to 'Default'). + * @param array $rules The set of rules to instantiate the object. This + * will only be used when the first call to singleton is made, if included + * in further calls it will be effectively ignored. + * @return &object a reference to the Text_Wiki unique instantiation. + */ + public static function singleton($parser = 'Default', $rules = null) + { + static $only = array(); + if (!isset($only[$parser])) { + $ret = Text_Wiki::factory($parser, $rules); + if (Text_Wiki::isError($ret)) { + return $ret; + } + $only[$parser] = $ret; + } + return $only[$parser]; + } + + /** + * Returns a Text_Wiki Parser class for the specified parser. + * + * @param string $parser The name of the parse to instantiate + * you need to have Text_Wiki_XXX installed to use $parser = 'XXX', it's E_FATAL + * @param array $rules The rules to pass into the constructor + * {@see Text_Wiki::singleton} for a list of rules + * @return Text_Wiki a Parser object extended from Text_Wiki + */ + public static function factory($parser = 'Default', $rules = null) + { + $class = 'Text_Wiki_' . $parser; + $file = str_replace('_', '/', $class).'.php'; + if (!class_exists($class)) { + require_once $file; + if (!class_exists($class)) { + return Text_Wiki::error( + 'Class ' . $class . ' does not exist after requiring '. $file . + ', install package ' . $class . "\n"); + } + } + + return new $class($rules); + } + + /** + * + * Set parser configuration for a specific rule and key. + * + * @access public + * + * @param string $rule The parse rule to set config for. + * + * @param array|string $arg1 The full config array to use for the + * parse rule, or a conf key in that array. + * + * @param string $arg2 The config value for the key. + * + * @return void + * + */ + + function setParseConf($rule, $arg1, $arg2 = null) + { + $rule = ucwords(strtolower($rule)); + + if (! isset($this->parseConf[$rule])) { + $this->parseConf[$rule] = array(); + } + + // if first arg is an array, use it as the entire + // conf array for the rule. otherwise, treat arg1 + // as a key and arg2 as a value for the rule conf. + if (is_array($arg1)) { + $this->parseConf[$rule] = $arg1; + } else { + $this->parseConf[$rule][$arg1] = $arg2; + } + } + + + /** + * + * Get parser configuration for a specific rule and key. + * + * @access public + * + * @param string $rule The parse rule to get config for. + * + * @param string $key A key in the conf array; if null, + * returns the entire conf array. + * + * @return mixed The whole conf array if no key is specified, + * or the specific conf key value. + * + */ + + function getParseConf($rule, $key = null) + { + $rule = ucwords(strtolower($rule)); + + // the rule does not exist + if (! isset($this->parseConf[$rule])) { + return null; + } + + // no key requested, return the whole array + if (is_null($key)) { + return $this->parseConf[$rule]; + } + + // does the requested key exist? + if (isset($this->parseConf[$rule][$key])) { + // yes, return that value + return $this->parseConf[$rule][$key]; + } else { + // no + return null; + } + } + + + /** + * + * Set renderer configuration for a specific format, rule, and key. + * + * @access public + * + * @param string $format The render format to set config for. + * + * @param string $rule The render rule to set config for in the format. + * + * @param array|string $arg1 The config array, or the config key + * within the render rule. + * + * @param string $arg2 The config value for the key. + * + * @return void + * + */ + + function setRenderConf($format, $rule, $arg1, $arg2 = null) + { + $format = ucwords(strtolower($format)); + $rule = ucwords(strtolower($rule)); + + if (! isset($this->renderConf[$format])) { + $this->renderConf[$format] = array(); + } + + if (! isset($this->renderConf[$format][$rule])) { + $this->renderConf[$format][$rule] = array(); + } + + // if first arg is an array, use it as the entire + // conf array for the render rule. otherwise, treat arg1 + // as a key and arg2 as a value for the render rule conf. + if (is_array($arg1)) { + $this->renderConf[$format][$rule] = $arg1; + } else { + $this->renderConf[$format][$rule][$arg1] = $arg2; + } + } + + + /** + * + * Get renderer configuration for a specific format, rule, and key. + * + * @access public + * + * @param string $format The render format to get config for. + * + * @param string $rule The render format rule to get config for. + * + * @param string $key A key in the conf array; if null, + * returns the entire conf array. + * + * @return mixed The whole conf array if no key is specified, + * or the specific conf key value. + * + */ + + function getRenderConf($format, $rule, $key = null) + { + $format = ucwords(strtolower($format)); + $rule = ucwords(strtolower($rule)); + + if (! isset($this->renderConf[$format]) || + ! isset($this->renderConf[$format][$rule])) { + return null; + } + + // no key requested, return the whole array + if (is_null($key)) { + return $this->renderConf[$format][$rule]; + } + + // does the requested key exist? + if (isset($this->renderConf[$format][$rule][$key])) { + // yes, return that value + return $this->renderConf[$format][$rule][$key]; + } else { + // no + return null; + } + + } + + /** + * + * Set format configuration for a specific rule and key. + * + * @access public + * + * @param string $format The format to set config for. + * + * @param string $key The config key within the format. + * + * @param string $val The config value for the key. + * + * @return void + * + */ + + function setFormatConf($format, $arg1, $arg2 = null) + { + if (! isset($this->formatConf[$format]) || ! is_array($this->formatConf[$format])) { + $this->formatConf[$format] = array(); + } + + // if first arg is an array, use it as the entire + // conf array for the format. otherwise, treat arg1 + // as a key and arg2 as a value for the format conf. + if (is_array($arg1)) { + $this->formatConf[$format] = $arg1; + } else { + $this->formatConf[$format][$arg1] = $arg2; + } + } + + + + /** + * + * Get configuration for a specific format and key. + * + * @access public + * + * @param string $format The format to get config for. + * + * @param mixed $key A key in the conf array; if null, + * returns the entire conf array. + * + * @return mixed The whole conf array if no key is specified, + * or the specific conf key value. + * + */ + + function getFormatConf($format, $key = null) + { + // the format does not exist + if (! isset($this->formatConf[$format])) { + return null; + } + + // no key requested, return the whole array + if (is_null($key)) { + return $this->formatConf[$format]; + } + + // does the requested key exist? + if (isset($this->formatConf[$format][$key])) { + // yes, return that value + return $this->formatConf[$format][$key]; + } else { + // no + return null; + } + } + + + /** + * + * Inserts a rule into to the rule set. + * + * @access public + * + * @param string $name The name of the rule. Should be different from + * all other keys in the rule set. + * + * @param string $tgt The rule after which to insert this new rule. By + * default (null) the rule is inserted at the end; if set to '', inserts + * at the beginning. + * + * @return void + * + */ + + function insertRule($name, $tgt = null) + { + $name = ucwords(strtolower($name)); + if (! is_null($tgt)) { + $tgt = ucwords(strtolower($tgt)); + } + + // does the rule name to be inserted already exist? + if (in_array($name, $this->rules)) { + // yes, return + return null; + } + + // the target name is not null, and not '', but does not exist + // in the list of rules. this means we're trying to insert after + // a target key, but the target key isn't there. + if (! is_null($tgt) && $tgt != '' && + ! in_array($tgt, $this->rules)) { + return false; + } + + // if $tgt is null, insert at the end. We know this is at the + // end (instead of resetting an existing rule) becuase we exited + // at the top of this method if the rule was already in place. + if (is_null($tgt)) { + $this->rules[] = $name; + return true; + } + + // save a copy of the current rules, then reset the rule set + // so we can insert in the proper place later. + // where to insert the rule? + if ($tgt == '') { + // insert at the beginning + array_unshift($this->rules, $name); + return true; + } + + // insert after the named rule + $tmp = $this->rules; + $this->rules = array(); + + foreach ($tmp as $val) { + $this->rules[] = $val; + if ($val == $tgt) { + $this->rules[] = $name; + } + } + + return true; + + } + + + /** + * + * Delete (remove or unset) a rule from the $rules property. + * + * @access public + * + * @param string $rule The name of the rule to remove. + * + * @return void + * + */ + + function deleteRule($name) + { + $name = ucwords(strtolower($name)); + $key = array_search($name, $this->rules); + if ($key !== false) { + unset($this->rules[$key]); + } + } + + + /** + * + * Change from one rule to another in-place. + * + * @access public + * + * @param string $old The name of the rule to change from. + * + * @param string $new The name of the rule to change to. + * + * @return void + * + */ + + function changeRule($old, $new) + { + $old = ucwords(strtolower($old)); + $new = ucwords(strtolower($new)); + $key = array_search($old, $this->rules); + if ($key !== false) { + // delete the new name , case it was already there + $this->deleteRule($new); + $this->rules[$key] = $new; + } + } + + + /** + * + * Enables a rule so that it is applied when parsing. + * + * @access public + * + * @param string $rule The name of the rule to enable. + * + * @return void + * + */ + + function enableRule($name) + { + $name = ucwords(strtolower($name)); + $key = array_search($name, $this->disable); + if ($key !== false) { + unset($this->disable[$key]); + } + } + + + /** + * + * Disables a rule so that it is not applied when parsing. + * + * @access public + * + * @param string $rule The name of the rule to disable. + * + * @return void + * + */ + + function disableRule($name) + { + $name = ucwords(strtolower($name)); + $key = array_search($name, $this->disable); + if ($key === false) { + $this->disable[] = $name; + } + } + + + /** + * + * Parses and renders the text passed to it, and returns the results. + * + * First, the method parses the source text, applying rules to the + * text as it goes. These rules will modify the source text + * in-place, replacing some text with delimited tokens (and + * populating the $this->tokens array as it goes). + * + * Next, the method renders the in-place tokens into the requested + * output format. + * + * Finally, the method returns the transformed text. Note that the + * source text is transformed in place; once it is transformed, it is + * no longer the same as the original source text. + * + * @access public + * + * @param string $text The source text to which wiki rules should be + * applied, both for parsing and for rendering. + * + * @param string $format The target output format, typically 'xhtml'. + * If a rule does not support a given format, the output from that + * rule is rule-specific. + * + * @return string The transformed wiki text. + * + */ + + function transform($text, $format = 'Xhtml') + { + $this->parse($text); + return $this->render($format); + } + + + /** + * + * Sets the $_source text property, then parses it in place and + * retains tokens in the $_tokens array property. + * + * @access public + * + * @param string $text The source text to which wiki rules should be + * applied, both for parsing and for rendering. + * + * @return void + * + */ + + function parse($text) + { + // set the object property for the source text + $this->source = $text; + + // reset the tokens. + $this->tokens = array(); + $this->_countRulesTokens = array(); + + // apply the parse() method of each requested rule to the source + // text. + foreach ($this->rules as $name) { + // do not parse the rules listed in $disable + if (! in_array($name, $this->disable)) { + + // load the parsing object + $this->loadParseObj($name); + + // load may have failed; only parse if + // an object is in the array now + if (is_object($this->parseObj[$name])) { + $this->parseObj[$name]->parse(); + } + } + } + } + + + /** + * + * Renders tokens back into the source text, based on the requested format. + * + * @access public + * + * @param string $format The target output format, typically 'xhtml'. + * If a rule does not support a given format, the output from that + * rule is rule-specific. + * + * @return string The transformed wiki text. + * + */ + + function render($format = 'Xhtml') + { + // the rendering method we're going to use from each rule + $format = ucwords(strtolower($format)); + + // the eventual output text + $this->output = ''; + + // when passing through the parsed source text, keep track of when + // we are in a delimited section + $in_delim = false; + + // when in a delimited section, capture the token key number + $key = ''; + + // load the format object, or crap out if we can't find it + $result = $this->loadFormatObj($format); + if ($this->isError($result)) { + return $result; + } + + // pre-rendering activity + if (is_object($this->formatObj[$format])) { + $this->output .= $this->formatObj[$format]->pre(); + } + + // load the render objects + foreach (array_keys($this->_countRulesTokens) as $rule) { + $this->loadRenderObj($format, $rule); + } + + if ($this->renderingType == 'preg') { + $this->output = preg_replace_callback('/'.$this->delim.'(\d+)'.$this->delim.'/', + array(&$this, '_renderToken'), + $this->source); + /* +//Damn strtok()! Why does it "skip" empty parts of the string. It's useless now! + } elseif ($this->renderingType == 'strtok') { + echo '
'.htmlentities($this->source).'
'; + $t = strtok($this->source, $this->delim); + $inToken = true; + $i = 0; + while ($t !== false) { + echo 'Token: '.$i.'
"'.htmlentities($t).'"


'; + if ($inToken) { + //$this->output .= $this->renderObj[$this->tokens[$t][0]]->token($this->tokens[$t][1]); + } else { + $this->output .= $t; + } + $inToken = !$inToken; + $t = strtok($this->delim); + ++$i; + } + */ + } else { + // pass through the parsed source text character by character + $this->_block = ''; + $tokenStack = array(); + $k = strlen($this->source); + for ($i = 0; $i < $k; $i++) { + + // the current character + $char = $this->source{$i}; + + // are alredy in a delimited section? + if ($in_delim) { + + // yes; are we ending the section? + if ($char == $this->delim) { + + if (count($this->_renderCallbacks) == 0) { + $this->output .= $this->_block; + $this->_block = ''; + } + if (isset($opts['type'])) { + if ($opts['type'] == 'start') { + array_push($tokenStack, $rule); + } elseif ($opts['type'] == 'end') { + if ($tokenStack[count($tokenStack) - 1] != $rule) { + return Text_Wiki::error('Unbalanced tokens, check your syntax'); + } else { + array_pop($tokenStack); + } + } + } + + // yes, get the replacement text for the delimited + // token number and unset the flag. + $key = (int)$key; + $rule = $this->tokens[$key][0]; + $opts = $this->tokens[$key][1]; + $this->_block .= $this->renderObj[$rule]->token($opts); + $in_delim = false; + + } else { + + // no, add to the delimited token key number + $key .= $char; + + } + + } else { + + // not currently in a delimited section. + // are we starting into a delimited section? + if ($char == $this->delim) { + // yes, reset the previous key and + // set the flag. + $key = ''; + $in_delim = true; + + } else { + // no, add to the output as-is + $this->_block .= $char; + } + } + } + } + + if (count($this->_renderCallbacks)) { + return $this->error('Render callbacks left over after processing finished'); + } + /* + while (count($this->_renderCallbacks)) { + $this->popRenderCallback(); + } + */ + if (strlen($this->_block)) { + $this->output .= $this->_block; + $this->_block = ''; + } + + // post-rendering activity + if (is_object($this->formatObj[$format])) { + $this->output .= $this->formatObj[$format]->post(); + } + + // return the rendered source text. + return $this->output; + } + + /** + * Renders a token, for use only as an internal callback + * + * @param array Matches from preg_rpelace_callback, [1] is the token number + * @return string The rendered text for the token + * @access private + */ + function _renderToken($matches) { + return $this->renderObj[$this->tokens[$matches[1]][0]]->token($this->tokens[$matches[1]][1]); + } + + function registerRenderCallback($callback) { + $this->_blocks[] = $this->_block; + $this->_block = ''; + $this->_renderCallbacks[] = $callback; + } + + function popRenderCallback() { + if (count($this->_renderCallbacks) == 0) { + return Text_Wiki::error('Render callback popped when no render callbacks in stack'); + } else { + $callback = array_pop($this->_renderCallbacks); + $this->_block = call_user_func($callback, $this->_block); + if (count($this->_blocks)) { + $parentBlock = array_pop($this->_blocks); + $this->_block = $parentBlock.$this->_block; + } + if (count($this->_renderCallbacks) == 0) { + $this->output .= $this->_block; + $this->_block = ''; + } + } + } + + /** + * + * Returns the parsed source text with delimited token placeholders. + * + * @access public + * + * @return string The parsed source text. + * + */ + + function getSource() + { + return $this->source; + } + + + /** + * + * Returns tokens that have been parsed out of the source text. + * + * @access public + * + * @param array $rules If an array of rule names is passed, only return + * tokens matching these rule names. If no array is passed, return all + * tokens. + * + * @return array An array of tokens. + * + */ + + function getTokens($rules = null) + { + if (is_null($rules)) { + return $this->tokens; + } else { + settype($rules, 'array'); + $result = array(); + foreach ($this->tokens as $key => $val) { + if (in_array($val[0], $rules)) { + $result[$key] = $val; + } + } + return $result; + } + } + + + /** + * + * Add a token to the Text_Wiki tokens array, and return a delimited + * token number. + * + * @access public + * + * @param array $options An associative array of options for the new + * token array element. The keys and values are specific to the + * rule, and may or may not be common to other rule options. Typical + * options keys are 'text' and 'type' but may include others. + * + * @param boolean $id_only If true, return only the token number, not + * a delimited token string. + * + * @return string|int By default, return the number of the + * newly-created token array element with a delimiter prefix and + * suffix; however, if $id_only is set to true, return only the token + * number (no delimiters). + * + */ + + function addToken($rule, $options = array(), $id_only = false) + { + // increment the token ID number. note that if you parse + // multiple times with the same Text_Wiki object, the ID number + // will not reset to zero. + static $id; + if (! isset($id)) { + $id = 0; + } else { + $id ++; + } + + // force the options to be an array + settype($options, 'array'); + + // add the token + $this->tokens[$id] = array( + 0 => $rule, + 1 => $options + ); + if (!isset($this->_countRulesTokens[$rule])) { + $this->_countRulesTokens[$rule] = 1; + } else { + ++$this->_countRulesTokens[$rule]; + } + + // return a value + if ($id_only) { + // return the last token number + return $id; + } else { + // return the token number with delimiters + return $this->delim . $id . $this->delim; + } + } + + + /** + * + * Set or re-set a token with specific information, overwriting any + * previous rule name and rule options. + * + * @access public + * + * @param int $id The token number to reset. + * + * @param int $rule The rule name to use. + * + * @param array $options An associative array of options for the + * token array element. The keys and values are specific to the + * rule, and may or may not be common to other rule options. Typical + * options keys are 'text' and 'type' but may include others. + * + * @return void + * + */ + + function setToken($id, $rule, $options = array()) + { + $oldRule = isset($this->tokens[$id]) ? $this->tokens[$id][0] : null; + // reset the token + $this->tokens[$id] = array( + 0 => $rule, + 1 => $options + ); + if ($rule != $oldRule) { + if (isset($oldRule) && !($this->_countRulesTokens[$oldRule]--)) { + unset($this->_countRulesTokens[$oldRule]); + } + if (!isset($this->_countRulesTokens[$rule])) { + $this->_countRulesTokens[$rule] = 1; + } else { + ++$this->_countRulesTokens[$rule]; + } + } + } + + + /** + * + * Load a rule parser class file. + * + * @access public + * + * @return bool True if loaded, false if not. + * + */ + + function loadParseObj($rule) + { + $rule = ucwords(strtolower($rule)); + $file = $rule . '.php'; + $class = "Text_Wiki_Parse_$rule"; + + if (! class_exists($class)) { + $loc = $this->findFile('parse', $file); + if ($loc) { + // found the class + include_once $loc; + } else { + // can't find the class + $this->parseObj[$rule] = null; + // can't find the class + return $this->error( + "Parse rule '$rule' not found" + ); + } + } + + $this->parseObj[$rule] = new $class($this); + + } + + + /** + * + * Load a rule-render class file. + * + * @access public + * + * @return bool True if loaded, false if not. + * + */ + + function loadRenderObj($format, $rule) + { + $format = ucwords(strtolower($format)); + $rule = ucwords(strtolower($rule)); + $file = "$format/$rule.php"; + $class = "Text_Wiki_Render_$format" . "_$rule"; + + if (! class_exists($class)) { + // load the class + $loc = $this->findFile('render', $file); + if ($loc) { + // found the class + include_once $loc; + } else { + // can't find the class + return $this->error( + "Render rule '$rule' in format '$format' not found" + ); + } + } + + $this->renderObj[$rule] = new $class($this); + } + + + /** + * + * Load a format-render class file. + * + * @access public + * + * @return bool True if loaded, false if not. + * + */ + + function loadFormatObj($format) + { + $format = ucwords(strtolower($format)); + $file = $format . '.php'; + $class = "Text_Wiki_Render_$format"; + + if (! class_exists($class)) { + $loc = $this->findFile('render', $file); + if ($loc) { + // found the class + include_once $loc; + } else { + // can't find the class + return $this->error( + "Rendering format class '$class' not found" + ); + } + } + + $this->formatObj[$format] = new $class($this); + } + + + /** + * + * Add a path to a path array. + * + * @access public + * + * @param string $type The path-type to add (parse or render). + * + * @param string $dir The directory to add to the path-type. + * + * @return void + * + */ + + function addPath($type, $dir) + { + $dir = $this->fixPath($dir); + if (! isset($this->path[$type])) { + $this->path[$type] = array($dir); + } else { + array_unshift($this->path[$type], $dir); + } + } + + + /** + * + * Get the current path array for a path-type. + * + * @access public + * + * @param string $type The path-type to look up (plugin, filter, or + * template). If not set, returns all path types. + * + * @return array The array of paths for the requested type. + * + */ + + function getPath($type = null) + { + if (is_null($type)) { + return $this->path; + } elseif (! isset($this->path[$type])) { + return array(); + } else { + return $this->path[$type]; + } + } + + + /** + * + * Searches a series of paths for a given file. + * + * @param array $type The type of paths to search (template, plugin, + * or filter). + * + * @param string $file The file name to look for. + * + * @return string|bool The full path and file name for the target file, + * or boolean false if the file is not found in any of the paths. + * + */ + + function findFile($type, $file) + { + // get the set of paths + $set = $this->getPath($type); + + // start looping through them + foreach ($set as $path) { + $fullname = $path . $file; + if (file_exists($fullname) && is_readable($fullname)) { + return $fullname; + } + } + + // could not find the file in the set of paths + return false; + } + + + /** + * + * Append a trailing '/' to paths, unless the path is empty. + * + * @access private + * + * @param string $path The file path to fix + * + * @return string The fixed file path + * + */ + + function fixPath($path) + { + $len = strlen($this->_dirSep); + + if (! empty($path) && + substr($path, -1 * $len, $len) != $this->_dirSep) { + return $path . $this->_dirSep; + } else { + return $path; + } + } + + + /** + * + * Simple error-object generator. + * + * @access public + * + * @param string $message The error message. + * + * @return object PEAR_Error + * + */ + + function error($message) + { + if (! class_exists('PEAR_Error')) { + include_once 'PEAR.php'; + } + $pear = new PEAR(); + return $pear->throwError($message); + } + + + /** + * + * Simple error checker. + * + * @param mixed $obj Check if this is a PEAR_Error object or not. + * + * @return bool True if a PEAR_Error, false if not. + * + */ + + public static function isError(&$obj) + { + return is_a($obj, 'PEAR_Error'); + } +} diff --git a/wicked/lib/Text_Wiki/Text/Wiki/BBCode.php b/wicked/lib/Text_Wiki/Text/Wiki/BBCode.php new file mode 100644 index 00000000000..9374259b630 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/BBCode.php @@ -0,0 +1,100 @@ + + * @copyright 2005 bertrand Gugger + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * "master" class for handling the management and convenience + */ +require_once 'Text/Wiki.php'; + +/** + * Base Text_Wiki handler class extension for BBCode + * + * @category Text + * @package Text_Wiki + * @author Bertrand Gugger + * @copyright 2005 bertrand Gugger + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + * @see Text_Wiki::Text_Wiki() + */ +class Text_Wiki_BBCode extends Text_Wiki { + + /** + * The default list of rules, in order, to apply to the source text. + * + * @access public + * @var array + */ + var $rules = array( + 'Prefilter', + 'Delimiter', + 'Code', +// 'Plugin', +// 'Function', +// 'Html', +// 'Raw', +// 'Preformatted', +// 'Include', +// 'Embed', +// 'Page', +// 'Anchor', +// 'Heading', +// 'Toc', +// 'Titlebar', +// 'Horiz', +// 'Break', + 'Blockquote', + 'List', +// 'Deflist', +// 'Table', +// 'Box', + 'Image', + 'Smiley', +// 'Phplookup', +// 'Center', + 'Newline', + 'Paragraph', + 'Url', +// 'Freelink', + 'Colortext', + 'Font', +// 'Strong', + 'Bold', +// 'Emphasis', + 'Italic', + 'Underline', +// 'Tt', + 'Superscript', + 'Subscript', +// 'Specialchar', +// 'Revise', +// 'Interwiki', + 'Tighten' + ); + + /** + * Constructor: just adds the path to BBCode rules + * + * @access public + * @param array $rules The set of rules to load for this object. + */ + function Text_Wiki_BBCode($rules = null) + { + parent::Text_Wiki($rules); + $this->addPath('parse', $this->fixPath(dirname(__FILE__)).'Parse/BBCode'); + } +} diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Cowiki.php b/wicked/lib/Text_Wiki/Text/Wiki/Cowiki.php new file mode 100644 index 00000000000..77135609592 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Cowiki.php @@ -0,0 +1,43 @@ + + * @author Bertrand Gugger + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * "master" class for handling the management and convenience + */ +require_once('Text/Wiki.php'); + +/** + * Base Text_Wiki handler class extension for Cowiki markup + * + * @category Text + * @package Text_Wiki + * @author Justin Patrin + * @author Bertrand Gugger + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + * @see Text_Wiki::Text_Wiki() + */ +class Text_Wiki_Cowiki extends Text_Wiki { + + function Text_Wiki_Cowiki() { + parent::Text_Wiki(); + $paths = $this->getPath('parse'); + $this->addPath('parse', str_replace('Default', 'Cowiki', $paths[0])); + } +} diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Creole.php b/wicked/lib/Text_Wiki/Text/Wiki/Creole.php new file mode 100644 index 00000000000..06b7cd6f36f --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Creole.php @@ -0,0 +1,150 @@ + + * + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * + * @link http://pear.php.net/package/Text_Wiki + * + * @version CVS: $Id$ + * + */ + +/** + * + * "Master" class for handling the management and convenience + * + */ + +require_once 'Text/Wiki.php'; + +/** + * + * Base Text_Wiki handler class extension for Creole markup + * + * @category Text + * + * @package Text_Wiki + * + * @author Michele Tomaiuolo + * + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * + * @link http://pear.php.net/package/Text_Wiki + * + * @see Text_Wiki::Text_Wiki() + * + */ + +class Text_Wiki_Creole extends Text_Wiki { + + // *single newlines* are handled as in most wikis (ignored) + // if Newline is removed from rules, they will be handled as in word-processors (meaning a paragraph break) + + var $rules = array( + 'Prefilter', + 'Delimiter', + 'Preformatted', + 'Tt', + 'Trim', + 'Break', + 'Raw', + 'Box', + 'Footnote', + 'Heading', + 'Newline', + 'Deflist', + 'Blockquote', + 'Newline', + 'Url', + 'Wikilink', + 'Image', + //'Heading', + 'Table', + 'Center', + 'Horiz', + 'Deflist', + 'List', + 'Address', + 'Paragraph', + 'Superscript', + 'Subscript', + 'Underline', + 'Emphasis', + 'Strong', + //'Italic', + //'Bold', + 'Tighten' + ); + + /** + * Constructor: just adds the path to Creole rules + * + * @access public + * @param array $rules The set of rules to load for this object. + */ + + function Text_Wiki_Creole($rules = null) { + parent::Text_Wiki($rules); + $this->addPath('parse', $this->fixPath(dirname(__FILE__)).'Parse/Creole'); + $this->renderingType = 'char'; + $this->setRenderConf('xhtml', 'center', 'css', 'center'); + $this->setRenderConf('xhtml', 'url', 'target', null); + } + + function checkInnerTags(&$text) { + $started = array(); + $i = false; + while (($i = strpos($text, $this->delim, $i)) !== false) { + $j = strpos($text, $this->delim, $i + 1); + $t = substr($text, $i + 1, $j - $i - 1); + $i = $j + 1; + $rule = strtolower($this->tokens[$t][0]); + $type = $this->tokens[$t][1]['type']; + + if ($type == 'start') { + if (empty($started[$rule])) { + $started[$rule] = 0; + } + $started[$rule] += 1; + } + else if ($type == 'end') { + if (empty($started[$rule])) return false; + + $started[$rule] -= 1; + if (! $started[$rule]) unset($started[$rule]); + } + } + return ! (count($started) > 0); + } + + function restoreRaw($text) { + $i = false; + while (($i = strpos($text, $this->delim, $i)) !== false) { + $j = strpos($text, $this->delim, $i + 1); + $t = substr($text, $i + 1, $j - $i - 1); + $rule = strtolower($this->tokens[$t][0]); + + if ($rule == 'raw') { + $text = str_replace($this->delim. $t. $this->delim, $this->tokens[$t][1]['text'], $text); + } + else { + $i = $j + 1; + } + } + return $text; + } +} + +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Default.php b/wicked/lib/Text_Wiki/Text/Wiki/Default.php new file mode 100644 index 00000000000..354f31c99a5 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Default.php @@ -0,0 +1,27 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +require_once('Text/Wiki.php'); + +/** + * This is the parser for the Default ruleset. For now, this simply extends Text_Wiki. + * + * @category Text + * @package Text_Wiki + * @version Release: @package_version@ + * @author Justin Patrin + */ +class Text_Wiki_Default extends Text_Wiki { +} diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Doku.php b/wicked/lib/Text_Wiki/Text/Wiki/Doku.php new file mode 100644 index 00000000000..3bd21d743b4 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Doku.php @@ -0,0 +1,43 @@ + + * @author Bertrand Gugger + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * "master" class for handling the management and convenience + */ +require_once('Text/Wiki.php'); + +/** + * Base Text_Wiki handler class extension for Dokuwiki markup + * + * @category Text + * @package Text_Wiki + * @author Justin Patrin + * @author Bertrand Gugger + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + * @see Text_Wiki::Text_Wiki() + */ +class Text_Wiki_Doku extends Text_Wiki { + + function Text_Wiki_Doku($rules = null) { + parent::Text_Wiki($rules); + $paths = $this->getPath('parse'); + $this->addPath('parse', str_replace('Default', 'Doku', $paths[0])); + } +} diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Mediawiki.php b/wicked/lib/Text_Wiki/Text/Wiki/Mediawiki.php new file mode 100644 index 00000000000..441d0ae910c --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Mediawiki.php @@ -0,0 +1,95 @@ + + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * "master" class for handling the management and convenience + */ +require_once('Text/Wiki.php'); + +/** + * Base Text_Wiki handler class extension for Mediawiki markup + * + * @category Text + * @package Text_Wiki + * @author Bertrand Gugger + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + * @see Text_Wiki::Text_Wiki() + */ +class Text_Wiki_Mediawiki extends Text_Wiki { + var $rules = array( + 'Prefilter', + 'Delimiter', + 'Code', + 'Comment', + 'Preformatted', +// 'Plugin', +// 'Function', +// 'Html', + 'Raw', +// 'Include', +// 'Embed', +// 'Page', +// 'Anchor', + 'Heading', + 'Toc', +// 'Titlebar', + 'Horiz', + 'Redirect', + 'Break', +// 'Blockquote', +// 'Box', + 'Wikilink', +// 'Image', // done by Wikilink but still possible to disable/configure +// 'Interwiki', // done by Wikilink but still possible to disable/configure + 'Table', +// 'Phplookup', +// 'Center', + 'List', + 'Deflist', +// 'Strong', ** will be only fake inserted by Emphasis if needed for render + 'Emphasis', // must run before Newline (see Text_Wiki_Parse_Emphasis::parse()) + 'Newline', + 'Paragraph', + 'Url', +// 'Freelink', +// 'Colortext', +// 'Bold', +// 'Italic', +// 'Underline', + 'Tt', + 'Superscript', + 'Subscript', +// 'Specialchar', +// 'Revise', + 'Tighten' + ); + + /** + * Constructor: just adds the path to Mediawiki rules + * + * @access public + * @param array $rules The set of rules to load for this object. + */ + function Text_Wiki_Mediawiki($rules = null) { + parent::Text_Wiki($rules); + $this->addPath('parse', $this->fixPath(dirname(__FILE__)).'Parse/Mediawiki'); + } +} + +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Parse.php b/wicked/lib/Text_Wiki/Text/Wiki/Parse.php new file mode 100644 index 00000000000..d04b1a21205 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Parse.php @@ -0,0 +1,280 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * Baseline rule class for extension into a "real" parser component. + * + * Text_Wiki_Rule classes do not stand on their own; they are called by a + * Text_Wiki object, typcially in the transform() method. Each rule class + * performs three main activities: parse, process, and render. + * + * The parse() method takes a regex and applies it to the whole block of + * source text at one time. Each match is sent as $matches to the + * process() method. + * + * The process() method acts on the matched text from the source, and + * then processes the source text is some way. This may mean the + * creation of a delimited token using addToken(). In every case, the + * process() method returns the text that should replace the matched text + * from parse(). + * + * @category Text + * @package Text_Wiki + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + */ +class Text_Wiki_Parse { + + + /** + * + * Configuration options for this parser rule. + * + * @access public + * + * @var string + * + */ + + var $conf = array(); + + + /** + * + * Regular expression to find matching text for this rule. + * + * @access public + * + * @var string + * + * @see parse() + * + */ + + var $regex = null; + + + /** + * + * The name of this rule for new token array elements. + * + * @access public + * + * @var string + * + */ + + var $rule = null; + + + /** + * + * A reference to the calling Text_Wiki object. + * + * This is needed so that each rule has access to the same source + * text, token set, URLs, interwiki maps, page names, etc. + * + * @access public + * + * @var object + */ + + var $wiki = null; + + + /** + * + * Constructor for this parser rule. + * + * @access public + * + * @param object &$obj The calling "parent" Text_Wiki object. + * + */ + + function __construct(&$obj) + { + // set the reference to the calling Text_Wiki object; + // this allows us access to the shared source text, token + // array, etc. + $this->wiki =& $obj; + + // set the name of this rule; generally used when adding + // to the tokens array. strip off the Text_Wiki_Parse_ portion. + // text_wiki_parse_ + // 0123456789012345 + $tmp = substr(get_class($this), 16); + $this->rule = ucwords(strtolower($tmp)); + + // override config options for the rule if specified + if (isset($this->wiki->parseConf[$this->rule]) && + is_array($this->wiki->parseConf[$this->rule])) { + + $this->conf = array_merge( + $this->conf, + $this->wiki->parseConf[$this->rule] + ); + + } + } + + + /** + * + * Constructor for this parser rule. + * + * @access public + * + * @param object &$obj The calling "parent" Text_Wiki object. + * + */ + + function Text_Wiki_Parse(&$obj) + { + $this->__construct($obj); + } + + + /** + * + * Abstrct method to parse source text for matches. + * + * Applies the rule's regular expression to the source text, passes + * every match to the process() method, and replaces the matched text + * with the results of the processing. + * + * @access public + * + * @see Text_Wiki_Parse::process() + * + */ + + function parse() + { + $this->wiki->source = preg_replace_callback( + $this->regex, + array(&$this, 'process'), + $this->wiki->source + ); + } + + + /** + * + * Abstract method to generate replacements for matched text. + * + * @access public + * + * @param array $matches An array of matches from the parse() method + * as generated by preg_replace_callback. $matches[0] is the full + * matched string, $matches[1] is the first matched pattern, + * $matches[2] is the second matched pattern, and so on. + * + * @return string The processed text replacement; defaults to the + * full matched string (i.e., no changes to the text). + * + * @see Text_Wiki_Parse::parse() + * + */ + + function process(&$matches) + { + return $matches[0]; + } + + + /** + * + * Simple method to safely get configuration key values. + * + * @access public + * + * @param string $key The configuration key. + * + * @param mixed $default If the key does not exist, return this value + * instead. + * + * @return mixed The configuration key value (if it exists) or the + * default value (if not). + * + */ + + function getConf($key, $default = null) + { + if (isset($this->conf[$key])) { + return $this->conf[$key]; + } else { + return $default; + } + } + + + /** + * + * Extract 'attribute="value"' portions of wiki markup. + * + * This kind of markup is typically used only in macros, but is useful + * anywhere. + * + * The syntax is pretty strict; there can be no spaces between the + * option name, the equals, and the first double-quote; the value + * must be surrounded by double-quotes. You can escape characters in + * the value with a backslash, and the backslash will be stripped for + * you. + * + * @access public + * + * @param string $text The "attributes" portion of markup. + * + * @return array An associative array of key-value pairs where the + * key is the option name and the value is the option value. + * + */ + + function getAttrs($text) + { + // find the =" sections; + $tmp = explode('="', trim($text)); + + // basic setup + $k = count($tmp) - 1; + $attrs = array(); + $key = null; + + // loop through the sections + foreach ($tmp as $i => $val) { + + // first element is always the first key + if ($i == 0) { + $key = trim($val); + continue; + } + + // find the last double-quote in the value. + // the part to the left is the value for the last key, + // the part to the right is the next key name + $pos = strrpos($val, '"'); + $attrs[$key] = stripslashes(substr($val, 0, $pos)); + $key = trim(substr($val, $pos+1)); + + } + + return $attrs; + + } +} +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Blockquote.php b/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Blockquote.php new file mode 100644 index 00000000000..613fb0365e8 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Blockquote.php @@ -0,0 +1,91 @@ + + * @copyright 2005 bertrand Gugger + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * Block-quoted text rule parser class (with nesting) for BBCode. + * + * @category Text + * @package Text_Wiki + * @author Bertrand Gugger + * @copyright 2005 bertrand Gugger + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + * @see Text_Wiki_Parse::Text_Wiki_Parse() + */ +class Text_Wiki_Parse_Blockquote extends Text_Wiki_Parse { + + /** + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * We match [quote=..] ... [/quote] with nesting + * + * @access public + * @var string + * @see Text_Wiki_Parse::parse() + */ + var $regex = '#\[quote(?:=\s*"(.*?)")?\s*]((?:((?R))|.)*?)\[/quote]#msi'; + + /** + * The current quote nesting depth, starts by zero + * + * @access private + * @var int + */ + var $_level = 0; + + /** + * Generates a replacement for the matched text. Token options are: + * - 'type' => ['start'|'end'] The starting or ending point of the block-quoted text. + * The text itself is left in the source but may content bested blocks + * - 'level' => the level of nesting (starting 0) + * - 'name' => the author indicator (optional) + * + * @param array &$matches The array of matches from parse(). + * @return string Delimited by start/end tokens to be used as + * placeholder in the source text surrounding the text to be quoted. + * @access public + */ + function process(&$matches) + { + // nested block ? + if (array_key_exists(3, $matches)) { + $this->_level++; + $expsub = preg_replace_callback( + $this->regex, + array(&$this, 'process'), + $matches[2] + ); + $this->_level--; + } else { + $expsub = $matches[2]; + } + + // builds the option array + $options = array('type' => 'start', 'level'=>$this->_level); + if (isset($matches[1])) { + $options['name'] = $matches[1]; + } + $statok = $this->wiki->addToken($this->rule, $options); + $options['type'] = 'end'; + return $statok . $expsub . $this->wiki->addToken($this->rule, $options); + } +} diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Bold.php b/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Bold.php new file mode 100644 index 00000000000..8643715d987 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Bold.php @@ -0,0 +1,63 @@ + + * @copyright 2005 bertrand Gugger + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * Bold text rule parser class for BBCode. + * + * @category Text + * @package Text_Wiki + * @author Bertrand Gugger + * @copyright 2005 bertrand Gugger + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + * @see Text_Wiki_Parse::Text_Wiki_Parse() + */ +class Text_Wiki_Parse_Bold extends Text_Wiki_Parse { + + /** + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * + * @access public + * @var string + * @see parse() + */ + var $regex = "#\[b](.*?)\[/b]#i"; + + + /** + * Generates a replacement for the matched text. Token options are: + * - 'type' => ['start'|'end'] The starting or ending point of the + * emphasized text. The text itself is left in the source. + * + * @param array &$matches The array of matches from parse(). + * @return A pair of delimited tokens to be used as a placeholder in + * the source text surrounding the text to be emphasized. + * @access public + */ + function process(&$matches) + { + $start = $this->wiki->addToken($this->rule, array('type' => 'start')); + $end = $this->wiki->addToken($this->rule, array('type' => 'end')); + return $start . $matches[1] . $end; + } +} diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Code.php b/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Code.php new file mode 100644 index 00000000000..59cd223018c --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Code.php @@ -0,0 +1,63 @@ + + * @copyright 2005 bertrand Gugger + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * Code block rule parser class for BBCode. + * + * @category Text + * @package Text_Wiki + * @author Bertrand Gugger + * @copyright 2005 bertrand Gugger + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + * @see Text_Wiki_Parse::Text_Wiki_Parse() + */ +class Text_Wiki_Parse_Code extends Text_Wiki_Parse { + + /** + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * + * @access public + * @var string + * @see parse() + */ + var $regex = "#\[code]((?:(?R)|.)*?)\[/code]#msi"; + + + /** + * Generates a replacement for the matched text. Token options are: + * - 'text' => the contained text + * - 'attr' => type empty + * + * @param array &$matches The array of matches from parse(). + * @return A delimited token to be used as a placeholder in + * the source text and containing the original block of text + * @access public + */ + function process(&$matches) + { + return $this->wiki->addToken($this->rule, array( + 'text' => $matches[1], + 'attr' => array('type' => '') ) ); + } +} diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Colortext.php b/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Colortext.php new file mode 100755 index 00000000000..5840043410f --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Colortext.php @@ -0,0 +1,92 @@ + + * @copyright 2005 bertrand Gugger + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * Colored text rule parser class (with nesting) for BBCode. + * + * @category Text + * @package Text_Wiki + * @author Bertrand Gugger + * @copyright 2005 bertrand Gugger + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + * @see Text_Wiki_Parse::Text_Wiki_Parse() + */ +class Text_Wiki_Parse_Colortext extends Text_Wiki_Parse { + + /** + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * We match either [color..] ... [/color] nested + * + * @access public + * @var string + * @see Text_Wiki_Parse::parse() + */ + + var $regex = "'(?:\[color=(aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|purple|red|silver|teal|white|yellow|\#?[0-9a-f]{6})]((?:((?R))|.)*?)\[/color])'msi"; + + /** + * The current color nesting depth, starts by zero + * + * @access private + * @var int + */ + var $_level = 0; + + /** + * Generates a replacement for the matched text. Token options are: + * - 'type' => ['start'|'end'] The starting or ending point of the colored text. + * The text itself is left in the source but may content bested blocks + * - 'level' => the level of nesting (starting 0) + * - 'color' => the color indicator + * + * @param array &$matches The array of matches from parse(). + * @return string Delimited by start/end tokens to be used as + * placeholder in the source text surrounding the text to be colored. + * @access public + */ + function process(&$matches) + { + // nested block ? + if (array_key_exists(2, $matches)) { + $this->_level++; + $expsub = preg_replace_callback( + $this->regex, + array(&$this, 'process'), + $matches[2] + ); + $this->_level--; + } else { + $expsub = $matches[2]; + } + + // needs to withdraw leading # as renderer put it in + $color = $matches[1]{0} == '#' ? substr($matches[1], 1) : $matches[1]; + + // builds the option array + $options = array('type' => 'start', 'level' => $this->_level, 'color' => $color); + $statok = $this->wiki->addToken($this->rule, $options); + $options['type'] = 'end'; + return $statok . $expsub . $this->wiki->addToken($this->rule, $options); + } +} diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Font.php b/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Font.php new file mode 100644 index 00000000000..e81bf57af1f --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Font.php @@ -0,0 +1,87 @@ + + * @copyright 2005 bertrand Gugger + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * Font rule parser class (with nesting) for BBCode. ([size=...]...[/size]) + * + * @category Text + * @package Text_Wiki + * @author Bertrand Gugger + * @copyright 2005 bertrand Gugger + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + * @see Text_Wiki_Parse::Text_Wiki_Parse() + */ +class Text_Wiki_Parse_Font extends Text_Wiki_Parse { + + /** + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * + * @access public + * @var string + * @see parse() + */ + var $regex = "#\[size=(\d+)]((?:((?R))|.)*?)\[/size]#msi"; + + /** + * The current font nesting depth, starts by zero + * + * @access private + * @var int + */ + var $_level = 0; + + /** + * Generates a replacement for the matched text. Token options are: + * - 'type' => ['start'|'end'] The starting or ending point of the sized text. + * The text itself is left in the source but may content bested blocks + * - 'level' => the level of nesting (starting 0) + * - 'size' => the size indicator + * + * @param array &$matches The array of matches from parse(). + * @return string Delimited by start/end tokens to be used as + * placeholder in the source text surrounding the text to be sized. + * @access public + */ + function process(&$matches) + { + // nested block ? + if (array_key_exists(3, $matches)) { + $this->_level++; + $expsub = preg_replace_callback( + $this->regex, + array(&$this, 'process'), + $matches[2] + ); + $this->_level--; + } else { + $expsub = $matches[2]; + } + + // builds the option array + $options = array('type' => 'start', 'level' => $this->_level, 'size' => $matches[1]); + $statok = $this->wiki->addToken($this->rule, $options); + $options['type'] = 'end'; + return $statok . $expsub . $this->wiki->addToken($this->rule, $options); + } +} diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Image.php b/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Image.php new file mode 100644 index 00000000000..1d50bdc9c18 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Image.php @@ -0,0 +1,102 @@ + + * @copyright 2005 bertrand Gugger + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * Image rule parser class for BBCode. + * + * @category Text + * @package Text_Wiki + * @author Bertrand Gugger + * @copyright 2005 bertrand Gugger + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + * @see Text_Wiki_Parse::Text_Wiki_Parse() + */ +class Text_Wiki_Parse_Image extends Text_Wiki_Parse { + + /** + * Configuration keys for this rule + * 'schemes' => URL scheme(s) (array) recognized by this rule, default is 'http|ftp|https|ftps' + * That is some (array of) regex string(s), must be safe with a pattern delim '#' + * 'extensions' => URL scheme(s) (array) recognized by this rule, default is 'jpg|jpeg|gif|png' + * That is some (array of) regex string(s), must be safe with a pattern delim '#' + * 'url_regexp' => the regexp used to match the url after 'scheme://' and before '.extension' + * 'path_regexp' => the regexp used to match the local images path before '.extension' + * + * @access public + * @var array 'config-key' => mixed config-value + */ + var $conf = array( + 'schemes' => 'http|ftp|https|ftps', // can be also as array of regexps/strings + 'extensions' => 'jpg|jpeg|gif|png', // can be also as array of regexps/strings + 'url_regexp' => + '(?:[^.\s/"\'<\\\#delim#\ca-\cz]+\.)*[a-z](?:[-a-z0-9]*[a-z0-9])?\.?(?:/[^\s"<>\\\#delim#\ca-\cz]*)?', + 'local_regexp' => '(?:/?[^/\s"<\\\#delim#\ca-\cz]+)*' + ); + + /** + * Constructor. + * We override the constructor to build up the regex from config + * + * @param object &$obj the base conversion handler + * @return The parser object + * @access public + */ + function Text_Wiki_Parse_Image(&$obj) + { + $default = $this->conf; + parent::Text_Wiki_Parse($obj); + + // convert the list of recognized schemes to a regex OR, + $schemes = $this->getConf('schemes', $default['schemes']); + $this->regex = '#\[img]((?:(?:' . (is_array($schemes) ? implode('|', $schemes) : $schemes) . ')://' . + $this->getConf('url_regexp', $default['url_regexp']); + if ($local = $this->getConf('local_regexp', $default['local_regexp'])) { + $this->regex .= '|' . ( is_array($local) ? implode('|', $local) : $local ); + } + $this->regex .= ')'; + // add the extensions if any + if ($extensions = $this->getConf('extensions', array())) { + if (is_array($extensions)) { + $extensions = implode('|', $extensions); + } + $this->regex .= '\.(?:' . $extensions . ')'; + } + // replace delim in the regexps + $this->regex = str_replace( '#delim#', $this->wiki->delim, $this->regex); + $this->regex .= ')\[/img]#i'; + } + + /** + * Generates a replacement token for the matched text. Token options are: + * 'src' => the URL / path to the image + * 'attr' => empty for basic BBCode + * + * @param array &$matches The array of matches from parse(). + * @return string Delimited token representing the image + * @access public + */ + function process(&$matches) + { + // tokenize + return $this->wiki->addToken($this->rule, array('src' => $matches[1], 'attr' => array())); + } +} diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Italic.php b/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Italic.php new file mode 100644 index 00000000000..ededd50448d --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Italic.php @@ -0,0 +1,62 @@ + + * @copyright 2005 bertrand Gugger + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * Italic text rule parser class for BBCode. + * + * @category Text + * @package Text_Wiki + * @author Bertrand Gugger + * @copyright 2005 bertrand Gugger + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + * @see Text_Wiki_Parse::Text_Wiki_Parse() + */ +class Text_Wiki_Parse_Italic extends Text_Wiki_Parse { + + /** + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * + * @access public + * @var string + * @see parse() + */ + var $regex = "#\[i](.*?)\[/i]#i"; + + /** + * Generates a replacement for the matched text. Token options are: + * - 'type' => ['start'|'end'] The starting or ending point of the + * emphasized text. The text itself is left in the source. + * + * @param array &$matches The array of matches from parse(). + * @return A pair of delimited tokens to be used as a placeholder in + * the source text surrounding the text to be emphasized. + * @access public + */ + function process(&$matches) + { + $start = $this->wiki->addToken($this->rule, array('type' => 'start')); + $end = $this->wiki->addToken($this->rule, array('type' => 'end')); + return $start . $matches[1] . $end; + } +} diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/List.php b/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/List.php new file mode 100644 index 00000000000..09616013132 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/List.php @@ -0,0 +1,187 @@ + + * @copyright 2005 bertrand Gugger + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * List rule parser class for BBCode. + * + * @category Text + * @package Text_Wiki + * @author Bertrand Gugger + * @copyright 2005 bertrand Gugger + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + * @see Text_Wiki_Parse::Text_Wiki_Parse() + */ +class Text_Wiki_Parse_List extends Text_Wiki_Parse { + + /** + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * + * @access public + * @var string + * @see parse() + */ + var $regex = "#\[list(?:=(.+?))?]\n?((?:((?R))|.)*?)\[/list]\n?#msi"; + + /** + * The regular expression used in second stage to find list's elements + * used by process() to call back processElement() + * + * @access public + * @var string + * @see process() + * @see processElement() + */ + var $regexElement = '#\[\*](.*?)(?=\[\*]|$)\n?#msi'; + + /** + * The current list nesting depth, starts by zero + * + * @access private + * @var int + */ + var $_level = 0; + + /** + * The count of items for this level + * + * @access private + * @var int + */ + var $_count = array(); + + /** + * The type of list for this level ('bullet' or 'number') + * + * @access private + * @var int + */ + var $_type = array(); + + /** + * Generates a replacement for the matched text. Returned token options are: + * 'type' => + * 'bullet_list_start' : the start of a bullet list + * 'bullet_list_end' : the end of a bullet list + * 'number_list_start' : the start of a number list + * 'number_list_end' : the end of a number list + * 'item_start' : the start of item text (bullet or number) + * 'item_end' : the end of item text (bullet or number) + * 'unknown' : unknown type of list or item + * + * 'level' => the indent level (0 for the first level, 1 for the + * second, etc) + * + * 'count' => the list item number at this level. not needed for + * xhtml, but very useful for PDF and RTF. + * + * 'format' => the optional enumerating type : A, a, I, i, or 1 (default) + * as HTML
    tag's type attribute (only for number_... type) + * + * 'key' => the optional starting number/letter (not for items) + * + * @param array &$matches The array of matches from parse(). + * @return A delimited token to be used as a placeholder in + * the source text and containing the original block of text + * @access public + */ + function process(&$matches) + { + if (!empty($matches[3])) { + $this->_level++; + $expsub = preg_replace_callback( + $this->regex, + array(&$this, 'process'), + $matches[2] + ); + $this->_level--; + } else { + $expsub = $matches[2]; + } + if ($matches[1]) { + $this->_type[$this->_level] = 'number'; + if (is_numeric($matches[1])) { + $format = '1'; + $key = $matches[1] + 0; + } elseif (($matches[1] == 'i') || ($matches[1] == 'I')) { + $format = $matches[1]; + } else { + $format = + ($matches[1] >= 'a') && ($matches[1] <='z') ? 'a' : 'A'; + $key = $matches[1]; + } + } else { + $this->_type[$this->_level] = 'bullet'; + } + $this->_count[$this->_level] = -1; + $sub = preg_replace_callback( + $this->regexElement, + array(&$this, 'processElement'), + $expsub + ); + $param = array( + 'level' => $this->_level, + 'count' => $this->_count[$this->_level] ); + $param['type'] = $this->_type[$this->_level].'_list_start'; + if (isset($format)) { + $param['format'] = $format; + } + if (isset($key)) { + $param['key'] = $key; + } + $ret = $this->wiki->addToken($this->rule, $param ); + $param['type'] = $this->_type[$this->_level].'_list_end'; + return $ret . $sub . $this->wiki->addToken($this->rule, $param ); + } + + /** + * Generates a replacement for the matched list elements. Token options are: + * 'type' => + * '[listType]_item_start' : the start of item text (bullet or number) + * '[listType]_item_end' : the end of item text (bullet or number) + * where [listType] is bullet or number + * + * 'level' => the indent level (0 for the first level, 1 for the + * second, etc) + * + * 'count' => the item ordeer at this level. + * + * @param array &$matches The array of matches from parse(). + * @return A delimited token to be used as a placeholder in + * the source text and containing the original block of text + * @access public + */ + function processElement(&$matches) + { + return $this->wiki->addToken($this->rule, array( + 'type' => $this->_type[$this->_level] . '_item_start', + 'level' => $this->_level, + 'count' => ++$this->_count[$this->_level]) ) . + rtrim($matches[1]) . + $this->wiki->addToken($this->rule, array( + 'type' => $this->_type[$this->_level] . '_item_end', + 'level' => $this->_level, + 'count' => $this->_count[$this->_level]) ); + } +} diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Subscript.php b/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Subscript.php new file mode 100644 index 00000000000..cbe0bc4c5b1 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Subscript.php @@ -0,0 +1,85 @@ + + * @copyright 2005 bertrand Gugger + * @license http://www.gnu.org/copyleft/lgpl.html + * GNU Lesser General Public License, version 2.1 + * @version CVS: $Id$ + */ + +// }}} +// {{{ Class: Text_Wiki_Parse_Subscript + +/** + * Subscript text rule parser class for BBCode. + * + * @category Text + * @package Text_Wiki + * @author Firman Wandayandi + * @copyright 2005 bertrand Gugger + * @license http://www.gnu.org/copyleft/lgpl.html + * GNU Lesser General Public License, version 2.1 + * @version Release: @package_version@ + */ +class Text_Wiki_Parse_Subscript extends Text_Wiki_Parse +{ + // {{{ Properties + + /** + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * + * @access public + * @var string + * @see parse() + */ + var $regex = "#\[sub](.*?)\[/sub]#i"; + + // }}} + // {{{ process() + + /** + * Generates a replacement for the matched text. Token options are: + * - 'type' => ['start'|'end'] The starting or ending point of the + * emphasized text. The text itself is left in the source. + * + * @param array &$matches The array of matches from parse(). + * @return A pair of delimited tokens to be used as a placeholder in + * the source text surrounding the text to be emphasized. + * @access public + */ + function process(&$matches) + { + $start = $this->wiki->addToken($this->rule, array('type' => 'start')); + $end = $this->wiki->addToken($this->rule, array('type' => 'end')); + return $start . $matches[1] . $end; + } + + // }}} +} + +// }}} + +/* + * Local variables: + * mode: php + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Superscript.php b/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Superscript.php new file mode 100644 index 00000000000..3a9327aeff7 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Superscript.php @@ -0,0 +1,84 @@ + + * @copyright 2005 bertrand Gugger + * @license http://www.gnu.org/copyleft/lgpl.html + * GNU Lesser General Public License, version 2.1 + * @version CVS: $Id$ + */ + +// }}} +// {{{ Class: Text_Wiki_Parse_Superscript + +/** + * Superscript text rule parser class for BBCode. + * + * @category Text + * @package Text_Wiki + * @author Firman Wandayandi + * @copyright 2005 bertrand Gugger + * @license http://www.gnu.org/copyleft/lgpl.html + * GNU Lesser General Public License, version 2.1 + * @version Release: @package_version@ + */ +class Text_Wiki_Parse_Superscript extends Text_Wiki_Parse +{ + // {{{ Properties + + /** + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * + * @access public + * @var string + * @see parse() + */ + var $regex = "#\[sup](.*?)\[/sup]#i"; + + // {{{ process() + + /** + * Generates a replacement for the matched text. Token options are: + * - 'type' => ['start'|'end'] The starting or ending point of the + * emphasized text. The text itself is left in the source. + * + * @param array &$matches The array of matches from parse(). + * @return A pair of delimited tokens to be used as a placeholder in + * the source text surrounding the text to be emphasized. + * @access public + */ + function process(&$matches) + { + $start = $this->wiki->addToken($this->rule, array('type' => 'start')); + $end = $this->wiki->addToken($this->rule, array('type' => 'end')); + return $start . $matches[1] . $end; + } + + // }}} +} + +// }}} + +/* + * Local variables: + * mode: php + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Underline.php b/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Underline.php new file mode 100644 index 00000000000..86b429fe219 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Underline.php @@ -0,0 +1,63 @@ + + * @copyright 2005 bertrand Gugger + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * Underlined text rule parser class for BBCode. + * + * @category Text + * @package Text_Wiki + * @author Bertrand Gugger + * @copyright 2005 bertrand Gugger + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + * @see Text_Wiki_Parse::Text_Wiki_Parse() + */ +class Text_Wiki_Parse_Underline extends Text_Wiki_Parse { + + /** + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * + * @access public + * @var string + * @see parse() + */ + var $regex = "#\[u](.*?)\[/u]#i"; + + + /** + * Generates a replacement for the matched text. Token options are: + * - 'type' => ['start'|'end'] The starting or ending point of the + * emphasized text. The text itself is left in the source. + * + * @param array &$matches The array of matches from parse(). + * @return A pair of delimited tokens to be used as a placeholder in + * the source text surrounding the text to be emphasized. + * @access public + */ + function process(&$matches) + { + $start = $this->wiki->addToken($this->rule, array('type' => 'start')); + $end = $this->wiki->addToken($this->rule, array('type' => 'end')); + return $start . $matches[1] . $end; + } +} diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Url.php b/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Url.php new file mode 100644 index 00000000000..7ae4ea83e0f --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Parse/BBCode/Url.php @@ -0,0 +1,185 @@ + + * @copyright 2005 bertrand Gugger + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * Url rule parser class for BBCode. + * + * @category Text + * @package Text_Wiki + * @author Bertrand Gugger + * @copyright 2005 bertrand Gugger + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + * @see Text_Wiki_Parse::Text_Wiki_Parse() + */ +class Text_Wiki_Parse_Url extends Text_Wiki_Parse { + + /** + * Configuration keys for this rule + * 'schemes' => URL scheme(s) (array) recognized by this rule, default is the single rfc2396 pattern + * That is some (array of) regex string(s), must be safe with a pattern delim '#' + * 'refused' => which schemes are refused (usefull if 'schemes' is not an exhaustive list as by default + * 'prefixes' => which prefixes are usable for "lazy" url as www.xxxx.yyyy... (defaulted to http://...) + * 'host_regexp' => the regexp used to match the host part of url (after 'scheme://') + * 'path_regexp' => the regexp used to match the rest of url (starting with '/' included) + * 'user_regexp' => the regexp used to match user name in email + * 'inline_enable' => are inline urls and emails enabled (default true) + * + * @var array 'config-key' => mixed config-value + * @access public + */ + var $conf = array( + 'schemes' => '[a-z][-+.a-z0-9]*', // can be also as array('htpp', 'htpps', 'ftp') + 'refused' => array('script', 'about', 'applet', 'activex', 'chrome'), + 'prefixes' => array('www', 'ftp'), + 'host_regexp' => '(?:[^.\s/"\'<\\\#delim#\ca-\cz]+\.)*[a-z](?:[-a-z0-9]*[a-z0-9])?\.?', + 'path_regexp' => '(?:/[^][\'\s"<\\\#delim#\ca-\cz]*)?', + 'user_regexp' => '[^]()<>[:;@\,."\s\\\#delim#\ca-\cz]+(?:\.[^]()<>[:;@\,."\s\\\#delim#\ca-\cz]+)*', + 'inline_enable' => true, + 'relative_enable' => false + ); + + /** + * The regular expressions used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * + * @access public + * @var string + * @see parse() + */ + var $regex = array( + '#\[url(?:(=)|])(#url#)(?(1)](.*?))\[/url]#mi', + '#([\n\r\s#delim#])(#url#)#i', + '#\[(email)(?:(=)|])(#email#)(?(2)](.*?))\[/email]#mi', + '#([\n\r\s#delim#](mailto:)?)(#email#)#i', + ); + + /** + * Constructor. + * We override the constructor to build up the regex from config + * + * @param object &$obj the base conversion handler + * @return The parser object + * @access public + */ + function Text_Wiki_Parse_Url(&$obj) + { + $default = $this->conf; + parent::Text_Wiki_Parse($obj); + + // store the list of refused schemes + $this->refused = $this->getConf('refused', array()); + if (is_string($this->refused)) { + $this->refused = array($this->refused); + } + // convert the list of recognized schemes to a regex OR, + $schemes = $this->getConf('schemes', $default['schemes']); + $url = '(?:(' . (is_array($schemes) ? implode('|', $schemes) : $schemes) . ')://'; + // add the "lazy" prefixes if any + $prefixes = $this->getConf('prefixes', array()); + foreach ($prefixes as $val) { + $url .= '|' . preg_quote($val, '#') . '\.'; + } + $host = $this->getConf('host_regexp', $default['host_regexp']); + $path = $this->getConf('path_regexp', $default['path_regexp']); + // the full url regexp + $url .= ')' . $host . $path; + // the full email regexp + $email = $this->getConf('user_regexp', $default['user_regexp']) . '@' . $host; + // inline to disable ? + if (!$this->getConf('inline_enable', true)) { + unset($this->regex[1]); + unset($this->regex[3]); + } + // relative url to enable ? + if ($this->getConf('relative_enable', false)) { + $this->regex[5] = str_replace( '#url#', $path, $this->regex[0]); + } + // replace in the regexps + $this->regex = str_replace( '#url#', $url, $this->regex); + $this->regex = str_replace( '#email#', $email, $this->regex); + $this->regex = str_replace( '#delim#', $this->wiki->delim, $this->regex); + } + + /** + * Generates a replacement for the matched text. Token options are: + * 'type' => ['inline'|'footnote'|'descr'] the type of URL + * 'href' => the URL link href portion + * 'text' => the displayed text of the URL link + * + * @param array &$matches The array of matches from parse(). + * @return string Delimited token representing the url + * @access public + */ + function process(&$matches) + { + if ($this->refused && isset($matches[3]) && in_array($matches[3], $this->refused)) { + return $matches[0]; + } + $pre = ''; + $type = 'inline'; + if (isset($matches[1])) { + if (strpos(strtolower($matches[1]), 'mail')) { + if (isset($matches[2])) { + if ($matches[2] === '=') { + $type = 'descr'; + } elseif ($matches[2]) { + $pre = $matches[1]{0}; + } + } + $matches[2] = 'mailto:' . $matches[3]; + if (!isset($matches[4])) { + $matches[4] = $matches[3]; + } + } elseif ($matches[1] === '=') { + $type = 'descr'; + } else { + $pre = $matches[1]; + if (!$matches[2]) { + $matches[2] = 'mailto:' . $matches[3]; + $matches[4] = $matches[3]; + } + } + } + // set options + $href = (isset($matches[3]) ? '' : 'http://') . $matches[2]; + $text = isset($matches[4]) ? $matches[4] : $matches[2]; + + // tokenize + if ($type == 'inline') { + return $pre . $this->wiki->addToken($this->rule, array( + 'type' => $type, + 'href' => $href, + 'text' => $text)); + } + return $pre . + $this->wiki->addToken($this->rule, array( + 'type' => 'start', + 'href' => $href, + 'text' => '')) . + $text . + $this->wiki->addToken($this->rule, array( + 'type' => 'end', + 'href' => $href, + 'text' => '')); + } +} diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Parse/Cowiki/Anchor.php b/wicked/lib/Text_Wiki/Text/Wiki/Parse/Cowiki/Anchor.php new file mode 100644 index 00000000000..fe0987e9ac3 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Parse/Cowiki/Anchor.php @@ -0,0 +1,88 @@ + +* +* @author Paul M. Jones +* +* @license LGPL +* +* @version $Id$ +* +*/ + +/** +* +* This class implements a Text_Wiki_Parse to add an anchor target name +* in the wiki page. +* +* @author Manuel Holtgrewe +* +* @author Paul M. Jones +* +* @category Text +* +* @package Text_Wiki +* +*/ + +//Not used in CoWiki +class Text_Wiki_Parse_Anchor extends Text_Wiki_Parse { + + + /** + * + * The regular expression used to find source text matching this + * rule. Looks like a macro: [[# anchor_name]] + * + * @access public + * + * @var string + * + */ + + var $regex = '/(\[\[# )([-_A-Za-z0-9.]+?)( .+)?(\]\])/i'; + + + /** + * + * Generates a token entry for the matched text. Token options are: + * + * 'text' => The full matched text, not including the tags. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return A delimited token number to be used as a placeholder in + * the source text. + * + */ + + function process(&$matches) { + + $name = $matches[2]; + $text = $matches[3]; + + $start = $this->wiki->addToken( + $this->rule, + array('type' => 'start', 'name' => $name) + ); + + $end = $this->wiki->addToken( + $this->rule, + array('type' => 'end', 'name' => $name) + ); + + // done, place the script output directly in the source + return $start . trim($text) . $end; + } +} +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Parse/Cowiki/Blockquote.php b/wicked/lib/Text_Wiki/Text/Wiki/Parse/Cowiki/Blockquote.php new file mode 100644 index 00000000000..07cb58e0e0a --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Parse/Cowiki/Blockquote.php @@ -0,0 +1,180 @@ + +* +* @license LGPL +* +* @version $Id$ +* +*/ + +/** +* +* Parse for block-quoted text. +* +* Find source text marked as a blockquote, identified by any number of +* greater-than signs '>' at the start of the line, followed by a space, +* and then the quote text; each '>' indicates an additional level of +* quoting. +* +* @category Text +* +* @package Text_Wiki +* +* @author Paul M. Jones +* +*/ + +//Not really used in CoWiki...sort of like +class Text_Wiki_Parse_Blockquote extends Text_Wiki_Parse { + + + /** + * + * Regex for parsing the source text. + * + * @access public + * + * @var string + * + * @see parse() + * + */ + + var $regex = '/\n((\>).*\n)(?!(\>))/Us'; + + + /** + * + * Generates a replacement for the matched text. + * + * Token options are: + * + * 'type' => + * 'start' : the start of a blockquote + * 'end' : the end of a blockquote + * + * 'level' => the indent level (0 for the first level, 1 for the + * second, etc) + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return A series of text and delimited tokens marking the different + * list text and list elements. + * + */ + + function process(&$matches) + { + // the replacement text we will return to parse() + $return = ''; + + // the list of post-processing matches + $list = array(); + + // $matches[1] is the text matched as a list set by parse(); + // create an array called $list that contains a new set of + // matches for the various list-item elements. + preg_match_all( + '=^(\>+) (.*\n)=Ums', + $matches[1], + $list, + PREG_SET_ORDER + ); + + // a stack of starts and ends; we keep this so that we know what + // indent level we're at. + $stack = array(); + + // loop through each list-item element. + foreach ($list as $key => $val) { + + // $val[0] is the full matched list-item line + // $val[1] is the number of initial '>' chars (indent level) + // $val[2] is the quote text + + // we number levels starting at 1, not zero + $level = strlen($val[1]); + + // get the text of the line + $text = $val[2]; + + // add a level to the list? + while ($level > count($stack)) { + + // the current indent level is greater than the number + // of stack elements, so we must be starting a new + // level. push the new level onto the stack with a + // dummy value (boolean true)... + array_push($stack, true); + + $return .= "\n"; + + // ...and add a start token to the return. + $return .= $this->wiki->addToken( + $this->rule, + array( + 'type' => 'start', + 'level' => $level - 1 + ) + ); + + $return .= "\n\n"; + } + + // remove a level? + while (count($stack) > $level) { + + // as long as the stack count is greater than the + // current indent level, we need to end list types. + // continue adding end-list tokens until the stack count + // and the indent level are the same. + array_pop($stack); + + $return .= "\n\n"; + + $return .= $this->wiki->addToken( + $this->rule, + array ( + 'type' => 'end', + 'level' => count($stack) + ) + ); + + $return .= "\n"; + } + + // add the line text. + $return .= $text; + } + + // the last line may have been indented. go through the stack + // and create end-tokens until the stack is empty. + $return .= "\n"; + + while (count($stack) > 0) { + array_pop($stack); + $return .= $this->wiki->addToken( + $this->rule, + array ( + 'type' => 'end', + 'level' => count($stack) + ) + ); + } + + // we're done! send back the replacement text. + return "\n$return\n\n"; + } +} +?> \ No newline at end of file diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Parse/Cowiki/Bold.php b/wicked/lib/Text_Wiki/Text/Wiki/Parse/Cowiki/Bold.php new file mode 100644 index 00000000000..5f79ba203af --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Parse/Cowiki/Bold.php @@ -0,0 +1,79 @@ + +* +* @license LGPL +* +* @version $Id$ +* +*/ + +/** +* +* Parses for bold text. +* +* This class implements a Text_Wiki_Rule to find source text marked for +* strong emphasis (bold) as defined by text surrounded by three +* single-quotes. On parsing, the text itself is left in place, but the +* starting and ending instances of three single-quotes are replaced with +* tokens. +* +* @category Text +* +* @package Text_Wiki +* +* @author Paul M. Jones +* +*/ + +class Text_Wiki_Parse_Bold extends Text_Wiki_Parse { + + + /** + * + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * + * @access public + * + * @var string + * + * @see parse() + * + */ + + var $regex = '/\*(()|.*)\*/U'; + + + /** + * + * Generates a replacement for the matched text. Token options are: + * + * 'type' => ['start'|'end'] The starting or ending point of the + * emphasized text. The text itself is left in the source. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return A pair of delimited tokens to be used as a placeholder in + * the source text surrounding the text to be emphasized. + * + */ + + function process(&$matches) + { + $start = $this->wiki->addToken($this->rule, array('type' => 'start')); + $end = $this->wiki->addToken($this->rule, array('type' => 'end')); + return $start . $matches[1] . $end; + } +} +?> \ No newline at end of file diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Parse/Cowiki/Break.php b/wicked/lib/Text_Wiki/Text/Wiki/Parse/Cowiki/Break.php new file mode 100644 index 00000000000..1bb264c4e24 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Parse/Cowiki/Break.php @@ -0,0 +1,73 @@ + +* +* @license LGPL +* +* @version $Id$ +* +*/ + +/** +* +* Parses for explicit line breaks. +* +* This class implements a Text_Wiki_Parse to mark forced line breaks in the +* source text. +* +* @category Text +* +* @package Text_Wiki +* +* @author Paul M. Jones +* +*/ + +//Not used in CoWiki +class Text_Wiki_Parse_Break extends Text_Wiki_Parse { + + + /** + * + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * + * @access public + * + * @var string + * + * @see parse() + * + */ + + var $regex = '/ \\\n/'; + + + /** + * + * Generates a replacement token for the matched text. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return string A delimited token to be used as a placeholder in + * the source text. + * + */ + + function process(&$matches) + { + return $this->wiki->addToken($this->rule); + } +} + +?> \ No newline at end of file diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Parse/Cowiki/Center.php b/wicked/lib/Text_Wiki/Text/Wiki/Parse/Cowiki/Center.php new file mode 100644 index 00000000000..08cc1c75fd2 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Parse/Cowiki/Center.php @@ -0,0 +1,79 @@ + +* +* @license LGPL +* +* @version $Id$ +* +*/ + +/** +* +* Parses for centered lines of text. +* +* This class implements a Text_Wiki_Parse to find lines marked for centering. +* The line must start with "= " (i.e., an equal-sign followed by a space). +* +* @category Text +* +* @package Text_Wiki +* +* @author Paul M. Jones +* +*/ + +//None in CoWiki +class Text_Wiki_Parse_Center extends Text_Wiki_Parse { + + + /** + * + * The regular expression used to find source text matching this + * rule. + * + * @access public + * + * @var string + * + */ + + var $regex = '/\n::(.*?)::\n/'; + + /** + * + * Generates a token entry for the matched text. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return A delimited token number to be used as a placeholder in + * the source text. + * + */ + + function process(&$matches) + { + $start = $this->wiki->addToken( + $this->rule, + array('type' => 'start') + ); + + $end = $this->wiki->addToken( + $this->rule, + array('type' => 'end') + ); + + return "\n" . $start . $matches[1] . $end . "\n"; + } +} +?> \ No newline at end of file diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Parse/Cowiki/Code.php b/wicked/lib/Text_Wiki/Text/Wiki/Parse/Cowiki/Code.php new file mode 100644 index 00000000000..4a0f8d2f886 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Parse/Cowiki/Code.php @@ -0,0 +1,99 @@ + +* +* @license LGPL +* +* @version $Id$ +* +*/ + +/** +* +* Parses for text marked as a code example block. +* +* This class implements a Text_Wiki_Parse to find sections marked as code +* examples. Blocks are marked as the string on a line by itself, +* followed by the inline code example, and terminated with the string +* on a line by itself. The code example is run through the +* native PHP highlight_string() function to colorize it, then surrounded +* with
    ...
    tags when rendered as XHTML. +* +* @category Text +* +* @package Text_Wiki +* +* @author Paul M. Jones +* +*/ + +class Text_Wiki_Parse_Code extends Text_Wiki_Parse { + + + /** + * + * The regular expression used to find source text matching this + * rule. + * + * @access public + * + * @var string + * + */ + + var $regex = '/^(]*)?>)\n(.+)\n(<\/code>)(\s|$)/Umsi'; + + + /** + * + * Generates a token entry for the matched text. Token options are: + * + * 'text' => The full matched text, not including the tags. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return A delimited token number to be used as a placeholder in + * the source text. + * + */ + + function process(&$matches) + { + // are there additional attribute arguments? + $args = trim($matches[2]); + + if ($args == '') { + $options = array( + 'text' => $matches[3], + 'attr' => array('type' => '') + ); + } else { + // get the attributes... + $attr = $this->getAttrs($args); + + // ... and make sure we have a 'type' + if (!isset($attr['type'])) { + $attr['type'] = ''; + } + + // retain the options + $options = array( + 'text' => $matches[3], + 'attr' => $attr + ); + } + + return $this->wiki->addToken($this->rule, $options) . $matches[5]; + } +} +?> \ No newline at end of file diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Parse/Cowiki/Colortext.php b/wicked/lib/Text_Wiki/Text/Wiki/Parse/Cowiki/Colortext.php new file mode 100644 index 00000000000..16b9bb48691 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Parse/Cowiki/Colortext.php @@ -0,0 +1,90 @@ + +* +* @license LGPL +* +* @version $Id$ +* +*/ + +/** +* +* Parses for colorized text. +* +* @category Text +* +* @package Text_Wiki +* +* @author Paul M. Jones +* +*/ + +//Not used in CoWiki +class Text_Wiki_Parse_Colortext extends Text_Wiki_Parse { + + /** + * + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * + * @access public + * + * @var string + * + * @see parse() + * + */ + + var $regex = "/~~(.+?):(.+?)~~/"; + + + /** + * + * Generates a replacement for the matched text. Token options are: + * + * 'type' => ['start'|'end'] The starting or ending point of the + * emphasized text. The text itself is left in the source. + * + * 'color' => the color indicator + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return string A pair of delimited tokens to be used as a + * placeholder in the source text surrounding the text to be + * emphasized. + * + */ + + function process(&$matches) + { + $start = $this->wiki->addToken( + $this->rule, + array( + 'type' => 'start', + 'color' => $matches[1] + ) + ); + + $end = $this->wiki->addToken( + $this->rule, + array( + 'type' => 'end', + 'color' => $matches[1] + ) + ); + + return $start . $matches[2] . $end; + } +} +?> \ No newline at end of file diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Parse/Cowiki/Deflist.php b/wicked/lib/Text_Wiki/Text/Wiki/Parse/Cowiki/Deflist.php new file mode 100644 index 00000000000..7099f7fab51 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Parse/Cowiki/Deflist.php @@ -0,0 +1,123 @@ + +* +* @license LGPL +* +* @version $Id$ +* +*/ + +/** +* +* Parses for definition lists. +* +* This class implements a Text_Wiki_Parse to find source text marked as a +* definition list. In short, if a line starts with ':' then it is a +* definition list item; another ':' on the same line indicates the end +* of the definition term and the beginning of the definition narrative. +* The list items must be on sequential lines (no blank lines between +* them) -- a blank line indicates the beginning of a new list. +* +* @category Text +* +* @package Text_Wiki +* +* @author Paul M. Jones +* +*/ + +//Not used in CoWiki +class Text_Wiki_Parse_Deflist extends Text_Wiki_Parse { + + + /** + * + * The regular expression used to parse the source text and find + * matches conforming to this rule. Used by the parse() method. + * + * @access public + * + * @var string + * + * @see parse() + * + */ + + var $regex = '/\n((; ).*\n)(?!(; |\n))/Us'; + + + /** + * + * Generates a replacement for the matched text. Token options are: + * + * 'type' => + * 'list_start' : the start of a definition list + * 'list_end' : the end of a definition list + * 'term_start' : the start of a definition term + * 'term_end' : the end of a definition term + * 'narr_start' : the start of definition narrative + * 'narr_end' : the end of definition narrative + * 'unknown' : unknown type of definition portion + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return A series of text and delimited tokens marking the different + * list text and list elements. + * + */ + + function process(&$matches) + { + // the replacement text we will return to parse() + $return = ''; + + // the list of post-processing matches + $list = array(); + + // start the deflist + $options = array('type' => 'list_start'); + $return .= $this->wiki->addToken($this->rule, $options); + + // $matches[1] is the text matched as a list set by parse(); + // create an array called $list that contains a new set of + // matches for the various definition-list elements. + preg_match_all( + '/^(; )(.*)?( ; )(.*)?$/Ums', + $matches[1], + $list, + PREG_SET_ORDER + ); + + // add each term and narrative + foreach ($list as $key => $val) { + $return .= ( + $this->wiki->addToken($this->rule, array('type' => 'term_start')) . + trim($val[2]) . + $this->wiki->addToken($this->rule, array('type' => 'term_end')) . + $this->wiki->addToken($this->rule, array('type' => 'narr_start')) . + trim($val[4]) . + $this->wiki->addToken($this->rule, array('type' => 'narr_end')) + ); + } + + + // end the deflist + $options = array('type' => 'list_end'); + $return .= $this->wiki->addToken($this->rule, $options); + + // done! + return "\n" . $return . "\n\n"; + } +} +?> \ No newline at end of file diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Parse/Cowiki/Delimiter.php b/wicked/lib/Text_Wiki/Text/Wiki/Parse/Cowiki/Delimiter.php new file mode 100644 index 00000000000..cd7f1b15b05 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Parse/Cowiki/Delimiter.php @@ -0,0 +1,80 @@ + +* +* @license LGPL +* +* @version $Id$ +* +*/ + +/** +* +* Parses for Text_Wiki delimiter characters already in the source text. +* +* This class implements a Text_Wiki_Parse to find instances of the delimiter +* character already embedded in the source text; it extracts them and replaces +* them with a delimited token, then renders them as the delimiter itself +* when the target format is XHTML. +* +* @category Text +* +* @package Text_Wiki +* +* @author Paul M. Jones +* +*/ + +class Text_Wiki_Parse_Delimiter extends Text_Wiki_Parse { + + /** + * + * Constructor. Overrides the Text_Wiki_Parse constructor so that we + * can set the $regex property dynamically (we need to include the + * Text_Wiki $delim character. + * + * @param object &$obj The calling "parent" Text_Wiki object. + * + * @param string $name The token name to use for this rule. + * + */ + + function Text_Wiki_Parse_delimiter(&$obj) + { + parent::Text_Wiki_Parse($obj); + $this->regex = '/' . $this->wiki->delim . '/'; + } + + + /** + * + * Generates a token entry for the matched text. Token options are: + * + * 'text' => The full matched text. + * + * @access public + * + * @param array &$matches The array of matches from parse(). + * + * @return A delimited token number to be used as a placeholder in + * the source text. + * + */ + + function process(&$matches) + { + return $this->wiki->addToken( + $this->rule, + array('text' => $this->wiki->delim) + ); + } +} +?> \ No newline at end of file diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Parse/Cowiki/Embed.php b/wicked/lib/Text_Wiki/Text/Wiki/Parse/Cowiki/Embed.php new file mode 100644 index 00000000000..2c30ac203dd --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Parse/Cowiki/Embed.php @@ -0,0 +1,107 @@ + +* +* @license LGPL +* +* @version $Id$ +* +*/ + +/** +* +* Embeds the results of a PHP script at render-time. +* +* This class implements a Text_Wiki_Parse to embed the contents of a URL +* inside the page at render-time. Typically used to get script output. +* This differs from the 'include' rule, which incorporates results at +* parse-time; 'embed' output does not get parsed by Text_Wiki, while +* 'include' ouput does. +* +* This rule is inherently not secure; it allows cross-site scripting to +* occur if the embedded output has +'; + } + } else { + $js = ''; + } + return $js.' +
    +'; + case 'endContent': + return ' +
    +'; + } + } +} +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Horiz.php b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Horiz.php new file mode 100644 index 00000000000..9346ac13d96 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Horiz.php @@ -0,0 +1,51 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * This class renders an horizontal bar in XHTML. + * + * @category Text + * @package Text_Wiki + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + */ +class Text_Wiki_Render_Xhtml_Horiz extends Text_Wiki_Render { + + var $conf = array( + 'css' => null + ); + + /** + * + * Renders a token into text matching the requested format. + * + * @access public + * + * @param array $options The "options" portion of the token (second + * element). + * + * @return string The text rendered from the token options. + * + */ + + function token($options) + { + $css = $this->formatConf(' class="%s"', 'css'); + return "\n"; + } +} +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Html.php b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Html.php new file mode 100644 index 00000000000..35f8ec871f1 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Html.php @@ -0,0 +1,47 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * This class renders preformated html in XHTML. + * + * @category Text + * @package Text_Wiki + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + */ +class Text_Wiki_Render_Xhtml_Html extends Text_Wiki_Render { + + + /** + * + * Renders a token into text matching the requested format. + * + * @access public + * + * @param array $options The "options" portion of the token (second + * element). + * + * @return string The text rendered from the token options. + * + */ + + function token($options) + { + return $options['text']; + } +} +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Image.php b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Image.php new file mode 100644 index 00000000000..afa832309bb --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Image.php @@ -0,0 +1,184 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * This class inserts an image in XHTML. + * + * @category Text + * @package Text_Wiki + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + */ +class Text_Wiki_Render_Xhtml_Image extends Text_Wiki_Render { + + var $conf = array( + 'base' => '/', + 'url_base' => null, + 'css' => null, + 'css_link' => null + ); + + + /** + * + * Renders a token into text matching the requested format. + * + * @access public + * + * @param array $options The "options" portion of the token (second + * element). + * + * @return string The text rendered from the token options. + * + */ + + function token($options) + { + // note the image source + $src = $options['src']; + + // is the source a local file or URL? + if (strpos($src, '://') === false) { + // the source refers to a local file. + // add the URL base to it. + $src = $this->getConf('base', '/') . $src; + } + + // stephane@metacites.net + // is the image clickable? + if (isset($options['attr']['link'])) { + // yes, the image is clickable. + // are we linked to a URL or a wiki page? + if (strpos($options['attr']['link'], '://')) { + // it's a URL, prefix the URL base + $href = $this->getConf('url_base') . $options['attr']['link']; + } else { + // it's a WikiPage; assume it exists. + /** @todo This needs to honor sprintf wikilinks (pmjones) */ + /** @todo This needs to honor interwiki (pmjones) */ + /** @todo This needs to honor freelinks (pmjones) */ + $href = $this->wiki->getRenderConf('xhtml', 'wikilink', 'view_url') . + $options['attr']['link']; + } + } else { + // image is not clickable. + $href = null; + } + // unset so it won't show up as an attribute + unset($options['attr']['link']); + + // stephane@metacites.net -- 25/07/2004 + // use CSS for all alignment + if (isset($options['attr']['align'])) { + // make sure we have a style attribute + if (!isset($options['attr']['style'])) { + // no style, set up a blank one + $options['attr']['style'] = ''; + } else { + // style exists, add a space + $options['attr']['style'] .= ' '; + } + + if ($options['attr']['align'] == 'center') { + // add a "center" style to the existing style. + $options['attr']['style'] .= + 'display: block; margin-left: auto; margin-right: auto;'; + } else { + // add a float style to the existing style + $options['attr']['style'] .= + 'float: '.$options['attr']['align']; + } + + // unset so it won't show up as an attribute + unset($options['attr']['align']); + } + + // stephane@metacites.net -- 25/07/2004 + // try to guess width and height + if (! isset($options['attr']['width']) && + ! isset($options['attr']['height'])) { + + // does the source refer to a local file or a URL? + if (strpos($src,'://')) { + // is a URL link + $imageFile = $src; + } elseif ($src[0] == '.') { + // reg at dav-muz dot net -- 2005-03-07 + // is a local file on relative path. + $imageFile = $src; # ...don't do anything because it's perfect! + } else { + // is a local file on absolute path. + $imageFile = $_SERVER['DOCUMENT_ROOT'] . $src; + } + + // attempt to get the image size + $imageSize = @getimagesize($imageFile); + + if (is_array($imageSize)) { + $options['attr']['width'] = $imageSize[0]; + $options['attr']['height'] = $imageSize[1]; + } + + } + + // start the HTML output + $output = 'formatConf(' class="%s"', 'css'); + + // add the attributes to the output, and be sure to + // track whether or not we find an "alt" attribute + $alt = false; + foreach ($options['attr'] as $key => $val) { + + // track the 'alt' attribute + if (strtolower($key) == 'alt') { + $alt = true; + } + + // the 'class' attribute overrides the CSS class conf + if (strtolower($key) == 'class') { + $css = null; + } + + $key = $this->textEncode($key); + $val = $this->textEncode($val); + $output .= " $key=\"$val\""; + } + + // always add an "alt" attribute per Stephane Solliec + if (! $alt) { + $alt = $this->textEncode(basename($options['src'])); + $output .= " alt=\"$alt\""; + } + + // end the image tag with the automatic CSS class (if any) + $output .= "$css />"; + + // was the image clickable? + if ($href) { + // yes, add the href and return + $href = $this->textEncode($href); + $css = $this->formatConf(' class="%s"', 'css_link'); + $output = "$output"; + } + + return $output; + } +} +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Include.php b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Include.php new file mode 100644 index 00000000000..7997d79cff7 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Include.php @@ -0,0 +1,32 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * This class renders included maekup in XHTML. (empty) + * + * @category Text + * @package Text_Wiki + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + */ +class Text_Wiki_Render_Xhtml_Include extends Text_Wiki_Render { + function token() + { + return ''; + } +} +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Interwiki.php b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Interwiki.php new file mode 100644 index 00000000000..4cab68fd1eb --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Interwiki.php @@ -0,0 +1,103 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * This class renders inter wikis links in XHTML. + * + * @category Text + * @package Text_Wiki + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + */ +class Text_Wiki_Render_Xhtml_Interwiki extends Text_Wiki_Render { + + var $conf = array( + 'sites' => array( + 'MeatBall' => 'http://www.usemod.com/cgi-bin/mb.pl?%s', + 'Advogato' => 'http://advogato.org/%s', + 'Wiki' => 'http://c2.com/cgi/wiki?%s' + ), + 'target' => '_blank', + 'css' => null + ); + + + /** + * + * Renders a token into text matching the requested format. + * + * @access public + * + * @param array $options The "options" portion of the token (second + * element). + * + * @return string The text rendered from the token options. + * + */ + + function token($options) + { + $text = $options['text']; + if (isset($options['url'])) { + // calculated by the parser (e.g. Mediawiki) + $href = $options['url']; + } else { + $site = $options['site']; + // toggg 2006/02/05 page name must be url encoded (e.g. may contain spaces) + $page = $this->urlEncode($options['page']); + + if (isset($this->conf['sites'][$site])) { + $href = $this->conf['sites'][$site]; + } else { + return $text; + } + + // old form where page is at end, + // or new form with %s placeholder for sprintf()? + if (strpos($href, '%s') === false) { + // use the old form + $href = $href . $page; + } else { + // use the new form + $href = sprintf($href, $page); + } + } + + // allow for alternative targets + $target = $this->getConf('target'); + + // build base link + $css = $this->formatConf(' class="%s"', 'css'); + $text = $this->textEncode($text); + $output = "textEncode($target); + $output .= " onclick=\"window.open(this.href, '$target');"; + $output .= " return false;\""; + } + + $output .= ">$text"; + + return $output; + } +} +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Italic.php b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Italic.php new file mode 100644 index 00000000000..20e75359e55 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Italic.php @@ -0,0 +1,57 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * This class renders italic text in XHTML. + * + * @category Text + * @package Text_Wiki + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + */ +class Text_Wiki_Render_Xhtml_Italic extends Text_Wiki_Render { + + var $conf = array( + 'css' => null + ); + + /** + * + * Renders a token into text matching the requested format. + * + * @access public + * + * @param array $options The "options" portion of the token (second + * element). + * + * @return string The text rendered from the token options. + * + */ + + function token($options) + { + if ($options['type'] == 'start') { + $css = $this->formatConf(' class="%s"', 'css'); + return ""; + } + + if ($options['type'] == 'end') { + return ''; + } + } +} +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/List.php b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/List.php new file mode 100644 index 00000000000..5514cd22539 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/List.php @@ -0,0 +1,172 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * This class renders bullet and ordered lists in XHTML. + * + * @category Text + * @package Text_Wiki + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + */ +class Text_Wiki_Render_Xhtml_List extends Text_Wiki_Render { + + var $conf = array( + 'css_ol' => null, + 'css_ol_li' => null, + 'css_ul' => null, + 'css_ul_li' => null + ); + + /** + * + * Renders a token into text matching the requested format. + * + * This rendering method is syntactically and semantically compliant + * with XHTML 1.1 in that sub-lists are part of the previous list item. + * + * @access public + * + * @param array $options The "options" portion of the token (second + * element). + * + * @return string The text rendered from the token options. + * + */ + + function token($options) + { + // make nice variables (type, level, count) + extract($options); + + // set up indenting so that the results look nice; we do this + // in two steps to avoid str_pad mathematics. ;-) + $pad = str_pad('', $level, "\t"); + $pad = str_replace("\t", ' ', $pad); + + switch ($type) { + + case 'bullet_list_start': + + // build the base HTML + $css = $this->formatConf(' class="%s"', 'css_ul'); + $html = ""; + + /* + // if this is the opening block for the list, + // put an extra newline in front of it so the + // output looks nice. + if ($level == 0) { + $html = "\n$html"; + } + */ + + // done! + return $html; + break; + + case 'bullet_list_end': + + // build the base HTML + $html = "\n$pad"; + + // if this is the closing block for the list, + // put extra newlines after it so the output + // looks nice. + if ($level == 0) { + $html .= "\n\n"; + } + + // done! + return $html; + break; + + case 'number_list_start': + if (isset($format)) { + $format = ' type="' . $format . '"'; + } else { + $format = ''; + } + // build the base HTML + $css = $this->formatConf(' class="%s"', 'css_ol'); + $html = ""; + + /* + // if this is the opening block for the list, + // put an extra newline in front of it so the + // output looks nice. + if ($level == 0) { + $html = "\n$html"; + } + */ + + // done! + return $html; + break; + + case 'number_list_end': + + // build the base HTML + $html = "\n$pad
"; + + // if this is the closing block for the list, + // put extra newlines after it so the output + // looks nice. + if ($level == 0) { + $html .= "\n\n"; + } + + // done! + return $html; + break; + + case 'bullet_item_start': + case 'number_item_start': + + // pick the proper CSS class + if ($type == 'bullet_item_start') { + $css = $this->formatConf(' class="%s"', 'css_ul_li'); + } else { + $css = $this->formatConf(' class="%s"', 'css_ol_li'); + } + + // build the base HTML + $html = "\n$pad"; + + // for the very first item in the list, do nothing. + // but for additional items, be sure to close the + // previous item. + if ($count > 0) { + $html = "$html"; + } + + // done! + return $html; + break; + + case 'bullet_item_end': + case 'number_item_end': + default: + // ignore item endings and all other types. + // item endings are taken care of by the other types + // depending on their place in the list. + return ''; + break; + } + } +} +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Newline.php b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Newline.php new file mode 100644 index 00000000000..dfae5432129 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Newline.php @@ -0,0 +1,35 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * This class renders new lines in XHTML. + * + * @category Text + * @package Text_Wiki + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + */ +class Text_Wiki_Render_Xhtml_Newline extends Text_Wiki_Render { + + + function token($options) + { + return "
\n"; + } +} + +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Page.php b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Page.php new file mode 100644 index 00000000000..4c2cf3d4903 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Page.php @@ -0,0 +1,46 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * This class renders page markers in XHTML. + * + * @category Text + * @package Text_Wiki + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + */ +class Text_Wiki_Render_Xhtml_Page extends Text_Wiki_Render { + + /** + * + * Renders a token into text matching the requested format. + * + * @access public + * + * @param array $options The "options" portion of the token (second + * element). + * + * @return string The text rendered from the token options. + * + */ + + function token($options) + { + return 'PAGE MARKER HERE*&^%$#^$%*PAGEMARKERHERE'; + } +} +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Paragraph.php b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Paragraph.php new file mode 100644 index 00000000000..503c38fccb4 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Paragraph.php @@ -0,0 +1,59 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * This class renders paragraphs in XHTML. + * + * @category Text + * @package Text_Wiki + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + */ +class Text_Wiki_Render_Xhtml_Paragraph extends Text_Wiki_Render { + + var $conf = array( + 'css' => null + ); + + /** + * + * Renders a token into text matching the requested format. + * + * @access public + * + * @param array $options The "options" portion of the token (second + * element). + * + * @return string The text rendered from the token options. + * + */ + + function token($options) + { + extract($options); //type + + if ($type == 'start') { + $css = $this->formatConf(' class="%s"', 'css'); + return ""; + } + + if ($type == 'end') { + return "

\n\n"; + } + } +} +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Phplookup.php b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Phplookup.php new file mode 100644 index 00000000000..08952542259 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Phplookup.php @@ -0,0 +1,81 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * This class renders a link to php functions description in XHTML. + * + * @category Text + * @package Text_Wiki + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + */ +class Text_Wiki_Render_Xhtml_Phplookup extends Text_Wiki_Render { + + var $conf = array( + 'target' => '_blank', + 'css' => null + ); + + + /** + * + * Renders a token into text matching the requested format. + * + * @access public + * + * @param array $options The "options" portion of the token (second + * element). + * + * @return string The text rendered from the token options. + * + */ + + function token($options) + { + $text = trim($options['text']); + $css = $this->formatConf(' class="%s"', 'css'); + + // start the html + $output = "getConf('target', ''); + if ($target && $target != '_self') { + // use a "popup" window. this is XHTML compliant, suggested by + // Aaron Kalin. uses the $target as the new window name. + $target = $this->textEncode($target); + $output .= " onclick=\"window.open(this.href, '$target');"; + $output .= " return false;\""; + } + + // take off the final parens for functions + if (substr($text, -2) == '()') { + $q = substr($text, 0, -2); + } else { + $q = $text; + } + + // toggg 2006/02/05 page name must be url encoded (e.g. may contain spaces) + $q = $this->urlEncode($q); + $text = $this->textEncode($text); + + // finish and return + $output .= " href=\"http://php.net/$q\">$text"; + return $output; + } +} +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Plugin.php b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Plugin.php new file mode 100644 index 00000000000..1fa8aeadb9d --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Plugin.php @@ -0,0 +1,47 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * This class renders wiki plugins in XHTML. (empty) + * + * @category Text + * @package Text_Wiki + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + */ +class Text_Wiki_Render_Xhtml_Plugin extends Text_Wiki_Render { + + /** + * + * Renders a token into text matching the requested format. + * Plugins produce wiki markup so are processed by parsing, no tokens produced + * + * @access public + * + * @param array $options The "options" portion of the token (second + * element). + * + * @return string The text rendered from the token options. + * + */ + + function token($options) + { + return ''; + } +} +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Prefilter.php b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Prefilter.php new file mode 100644 index 00000000000..8c278ee8eab --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Prefilter.php @@ -0,0 +1,34 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * This class implements a Text_Wiki_Render_Xhtml to "pre-filter" source text so + * that line endings are consistently \n, lines ending in a backslash \ + * are concatenated with the next line, and tabs are converted to spaces. + * + * @category Text + * @package Text_Wiki + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + */ +class Text_Wiki_Render_Xhtml_Prefilter extends Text_Wiki_Render { + function token() + { + return ''; + } +} +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Preformatted.php b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Preformatted.php new file mode 100644 index 00000000000..a162525b88c --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Preformatted.php @@ -0,0 +1,47 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * This class renders preformated text in XHTML. + * + * @category Text + * @package Text_Wiki + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + */ +class Text_Wiki_Render_Xhtml_Preformatted extends Text_Wiki_Render { + + /** + * + * Renders a token into text matching the requested format. + * + * @access public + * + * @param array $options The "options" portion of the token (second + * element). + * + * @return string The text rendered from the token options. + * + */ + + function token($options) + { + $text = $this->textEncode($options['text']); + return '
'.$text.'
'; + } +} +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Raw.php b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Raw.php new file mode 100644 index 00000000000..97413ae676e --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Raw.php @@ -0,0 +1,46 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * This class renders not processed blocks in XHTML. + * + * @category Text + * @package Text_Wiki + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + */ +class Text_Wiki_Render_Xhtml_Raw extends Text_Wiki_Render { + + /** + * + * Renders a token into text matching the requested format. + * + * @access public + * + * @param array $options The "options" portion of the token (second + * element). + * + * @return string The text rendered from the token options. + * + */ + + function token($options) + { + return $this->textEncode($options['text']); + } +} +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Revise.php b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Revise.php new file mode 100644 index 00000000000..9596ef01164 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Revise.php @@ -0,0 +1,68 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * This class renders revision marks in XHTML. + * + * @category Text + * @package Text_Wiki + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + */ +class Text_Wiki_Render_Xhtml_Revise extends Text_Wiki_Render { + + var $conf = array( + 'css_ins' => null, + 'css_del' => null + ); + + + /** + * + * Renders a token into text matching the requested format. + * + * @access public + * + * @param array $options The "options" portion of the token (second + * element). + * + * @return string The text rendered from the token options. + * + */ + + function token($options) + { + if ($options['type'] == 'del_start') { + $css = $this->formatConf(' class="%s"', 'css_del'); + return ""; + } + + if ($options['type'] == 'del_end') { + return ""; + } + + if ($options['type'] == 'ins_start') { + $css = $this->formatConf(' class="%s"', 'css_ins'); + return ""; + } + + if ($options['type'] == 'ins_end') { + return ""; + } + } +} +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Smiley.php b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Smiley.php new file mode 100644 index 00000000000..7003f075f98 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Smiley.php @@ -0,0 +1,74 @@ + + * @copyright 2005 bertrand Gugger + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * Smiley rule Xhtml render class + * + * @category Text + * @package Text_Wiki + * @author Bertrand Gugger + * @copyright 2005 bertrand Gugger + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + * @see Text_Wiki::Text_Wiki_Render() + */ +class Text_Wiki_Render_Xhtml_Smiley extends Text_Wiki_Render { + + /** + * Configuration keys for this rule + * 'prefix' => the path to smileys images inclusive file name prefix, + * starts with '/' ==> abolute reference + * if no file names prefix but some folder, terminates with '/' + * 'extension' => the file extension (inclusive '.'), e.g. : + * if prefix 'smileys/icon_' and extension '.gif' + * ':)' whose name is 'smile' will give relative file 'smileys/icon_smile.gif' + * if prefix '/image/smileys/' and extension '.png': absolute '/image/smileys/smile.gif' + * 'css' => optional style applied to smileys + * + * @access public + * @var array 'config-key' => mixed config-value + */ + var $conf = array( + 'prefix' => 'images/smiles/icon_', + 'extension' => '.gif', + 'css' => null + ); + + /** + * Renders a token into text matching the requested format. + * process the Smileys + * + * @access public + * @param array $options The "options" portion of the token (second element). + * @return string The text rendered from the token options. + */ + function token($options) + { + $imageFile = $this->getConf('prefix') . $options['name'] . $this->getConf('extension'); + + // attempt to get the image size + $imageSize = @getimagesize($imageFile); + + // return the HTML output + return '' . $options['desc'] . 'formatConf(' class="%s"', 'css') . ' />'; + } +} +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Specialchar.php b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Specialchar.php new file mode 100644 index 00000000000..ce5903db78d --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Specialchar.php @@ -0,0 +1,52 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * This class renders special characters in XHTML. + * + * @category Text + * @package Text_Wiki + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + */ +class Text_Wiki_Render_Xhtml_SpecialChar extends Text_Wiki_Render { + + var $types = array('~bs~' => '\', + '~hs~' => ' ', + '~amp~' => '&', + '~ldq~' => '“', + '~rdq~' => '”', + '~lsq~' => '‘', + '~rsq~' => '’', + '~c~' => '©', + '~--~' => '—', + '" -- "' => '—', + '" -- "' => '—', + '~lt~' => '<', + '~gt~' => '>'); + + function token($options) + { + if (isset($this->types[$options['char']])) { + return $this->types[$options['char']]; + } else { + return '&#'.substr($options['char'], 1, -1).';'; + } + } +} + +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Strong.php b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Strong.php new file mode 100644 index 00000000000..ce47dca708f --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Strong.php @@ -0,0 +1,58 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * This class renders text marked as strong in XHTML. + * + * @category Text + * @package Text_Wiki + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + */ +class Text_Wiki_Render_Xhtml_Strong extends Text_Wiki_Render { + + + var $conf = array( + 'css' => null + ); + + /** + * + * Renders a token into text matching the requested format. + * + * @access public + * + * @param array $options The "options" portion of the token (second + * element). + * + * @return string The text rendered from the token options. + * + */ + + function token($options) + { + if ($options['type'] == 'start') { + $css = $this->formatConf(' class="%s"', 'css'); + return ""; + } + + if ($options['type'] == 'end') { + return ''; + } + } +} +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Subscript.php b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Subscript.php new file mode 100644 index 00000000000..53f0fdd4bc6 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Subscript.php @@ -0,0 +1,57 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * This class renders subscript text in XHTML. + * + * @category Text + * @package Text_Wiki + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + */ +class Text_Wiki_Render_Xhtml_Subscript extends Text_Wiki_Render { + + var $conf = array( + 'css' => null + ); + + /** + * + * Renders a token into text matching the requested format. + * + * @access public + * + * @param array $options The "options" portion of the token (second + * element). + * + * @return string The text rendered from the token options. + * + */ + + function token($options) + { + if ($options['type'] == 'start') { + $css = $this->formatConf(' class="%s"', 'css'); + return ""; + } + + if ($options['type'] == 'end') { + return ''; + } + } +} +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Superscript.php b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Superscript.php new file mode 100644 index 00000000000..b92e0599ff7 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Superscript.php @@ -0,0 +1,57 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * This class renders superscript text in XHTML. + * + * @category Text + * @package Text_Wiki + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + */ +class Text_Wiki_Render_Xhtml_Superscript extends Text_Wiki_Render { + + var $conf = array( + 'css' => null + ); + + /** + * + * Renders a token into text matching the requested format. + * + * @access public + * + * @param array $options The "options" portion of the token (second + * element). + * + * @return string The text rendered from the token options. + * + */ + + function token($options) + { + if ($options['type'] == 'start') { + $css = $this->formatConf(' class="%s"', 'css'); + return ""; + } + + if ($options['type'] == 'end') { + return ''; + } + } +} +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Table.php b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Table.php new file mode 100644 index 00000000000..344298d8aee --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Table.php @@ -0,0 +1,140 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * This class renders tables in XHTML. + * + * @category Text + * @package Text_Wiki + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + */ +class Text_Wiki_Render_Xhtml_Table extends Text_Wiki_Render { + + var $conf = array( + 'css_table' => null, + 'css_caption' => null, + 'css_tr' => null, + 'css_th' => null, + 'css_td' => null + ); + + + /** + * + * Renders a token into text matching the requested format. + * + * @access public + * + * @param array $options The "options" portion of the token (second + * element). + * + * @return string The text rendered from the token options. + * + */ + + function token($options) + { + // make nice variable names (type, attr, span) + $span = $rowspan = 1; + extract($options); + + // free format + $format = isset($format) ? ' '. $format : ''; + + $pad = ' '; + + switch ($type) { + + case 'table_start': + $css = $this->formatConf(' class="%s"', 'css_table'); + return "\n\n\n"; + break; + + case 'table_end': + return "\n\n"; + break; + + case 'caption_start': + $css = $this->formatConf(' class="%s"', 'css_caption'); + return "\n"; + break; + + case 'caption_end': + return "\n"; + break; + + case 'row_start': + $css = $this->formatConf(' class="%s"', 'css_tr'); + return "$pad\n"; + break; + + case 'row_end': + return "$pad\n"; + break; + + case 'cell_start': + + // base html + $html = $pad . $pad; + + // is this a TH or TD cell? + if ($attr == 'header') { + // start a header cell + $css = $this->formatConf(' class="%s"', 'css_th'); + $html .= "formatConf(' class="%s"', 'css_td'); + $html .= " 1) { + $html .= " colspan=\"$span\""; + } + + // add the row span + if ($rowspan > 1) { + $html .= " rowspan=\"$rowspan\""; + } + + // add alignment + if ($attr != 'header' && $attr != '') { + $html .= " style=\"text-align: $attr;\""; + } + + // done! + $html .= "$format>"; + return $html; + break; + + case 'cell_end': + if ($attr == 'header') { + return "\n"; + } else { + return "\n"; + } + break; + + default: + return ''; + + } + } +} +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Tighten.php b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Tighten.php new file mode 100644 index 00000000000..4c28cd70d53 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Tighten.php @@ -0,0 +1,34 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * This class makes the tightening in XHTML. (empty) + * + * @category Text + * @package Text_Wiki + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + */ +class Text_Wiki_Render_Xhtml_Tighten extends Text_Wiki_Render { + + + function token() + { + return ''; + } +} +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Titlebar.php b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Titlebar.php new file mode 100644 index 00000000000..80364b98fd1 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Titlebar.php @@ -0,0 +1,57 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * This class renders a title bar in XHTML. + * + * @category Text + * @package Text_Wiki + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + */ +class Text_Wiki_Render_Xhtml_Titlebar extends Text_Wiki_Render { + + var $conf = array( + 'css' => 'titlebar' + ); + + /** + * + * Renders a token into text matching the requested format. + * + * @access public + * + * @param array $options The "options" portion of the token (second + * element). + * + * @return string The text rendered from the token options. + * + */ + + function token($options) + { + if ($options['type'] == 'start') { + $css = $this->formatConf(' class="%s"', 'css'); + return ""; + } + + if ($options['type'] == 'end') { + return ''; + } + } +} +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Toc.php b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Toc.php new file mode 100644 index 00000000000..a886012836c --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Toc.php @@ -0,0 +1,116 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * This class inserts a table of content in XHTML. + * + * @category Text + * @package Text_Wiki + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + */ +class Text_Wiki_Render_Xhtml_Toc extends Text_Wiki_Render { + + var $conf = array( + 'css_list' => null, + 'css_item' => null, + 'title' => 'Table of Contents', + 'div_id' => 'toc', + 'base_url' => '', + 'collapse' => true + ); + + var $min = 2; + + /** + * + * Renders a token into text matching the requested format. + * + * @access public + * + * @param array $options The "options" portion of the token (second + * element). + * + * @return string The text rendered from the token options. + * + */ + + function token($options) + { + // type, id, level, count, attr + extract($options); + + switch ($type) { + + case 'list_start': + + $css = $this->getConf('css_list'); + $html = ''; + + // collapse div within a table? + if ($this->getConf('collapse')) { + $html .= ''; + $html .= "
\n"; + } + + // add the div, class, and id + $html .= 'getConf('div_id'); + if ($div_id) { + $html .= " id=\"$div_id\""; + } + + // add the title, and done + $html .= '>'; + $html .= $this->getConf('title'); + return $html; + break; + + case 'list_end': + if ($this->getConf('collapse')) { + return "\n\n
\n\n"; + } else { + return "\n\n\n"; + } + break; + + case 'item_start': + $html = "\n\tgetConf('css_item'); + if ($css) { + $html .= " class=\"$css\""; + } + + $pad = ($level - $this->min); + $html .= " style=\"margin-left: {$pad}em;\">"; + + $html .= ''; + return $html; + break; + + case 'item_end': + return ""; + break; + } + } +} +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Tt.php b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Tt.php new file mode 100644 index 00000000000..f5ca2cec970 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Tt.php @@ -0,0 +1,58 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * This class renders monospaced text in XHTML. + * + * @category Text + * @package Text_Wiki + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + */ +class Text_Wiki_Render_Xhtml_Tt extends Text_Wiki_Render { + + + var $conf = array( + 'css' => null + ); + + /** + * + * Renders a token into text matching the requested format. + * + * @access public + * + * @param array $options The "options" portion of the token (second + * element). + * + * @return string The text rendered from the token options. + * + */ + + function token($options) + { + if ($options['type'] == 'start') { + $css = $this->formatConf(' class="%s"', 'css'); + return ""; + } + + if ($options['type'] == 'end') { + return ''; + } + } +} +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Underline.php b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Underline.php new file mode 100644 index 00000000000..51c97600edf --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Underline.php @@ -0,0 +1,57 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * This class renders underlined text in XHTML. + * + * @category Text + * @package Text_Wiki + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + */ +class Text_Wiki_Render_Xhtml_Underline extends Text_Wiki_Render { + + var $conf = array( + 'css' => null + ); + + /** + * + * Renders a token into text matching the requested format. + * + * @access public + * + * @param array $options The "options" portion of the token (second + * element). + * + * @return string The text rendered from the token options. + * + */ + + function token($options) + { + if ($options['type'] == 'start') { + $css = $this->formatConf(' class="%s"', 'css'); + return ""; + } + + if ($options['type'] == 'end') { + return ''; + } + } +} +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Url.php b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Url.php new file mode 100644 index 00000000000..794ba16c032 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Url.php @@ -0,0 +1,131 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * This class renders URL links in XHTML. + * + * @category Text + * @package Text_Wiki + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + */ +class Text_Wiki_Render_Xhtml_Url extends Text_Wiki_Render { + + + var $conf = array( + 'target' => '_blank', + 'images' => true, + 'img_ext' => array('jpg', 'jpeg', 'gif', 'png'), + 'css_inline' => null, + 'css_footnote' => null, + 'css_descr' => null, + 'css_img' => null + ); + + /** + * + * Renders a token into text matching the requested format. + * + * @access public + * + * @param array $options The "options" portion of the token (second + * element). + * + * @return string The text rendered from the token options. + * + */ + + function token($options) + { + // create local variables from the options array (text, + // href, type) + extract($options); + + // find the rightmost dot and determine the filename + // extension. + $pos = strrpos($href, '.'); + $ext = strtolower(substr($href, $pos + 1)); + $href = $this->textEncode($href); + + // does the filename extension indicate an image file? + if ($this->getConf('images') && + in_array($ext, $this->getConf('img_ext', array()))) { + + // create alt text for the image + if (! isset($text) || $text == '') { + $text = basename($href); + $text = $this->textEncode($text); + } + + // generate an image tag + $css = $this->formatConf(' class="%s"', 'css_img'); + $start = ""; + + } else { + + // should we build a target clause? + if ($href{0} == '#' || + strtolower(substr($href, 0, 7)) == 'mailto:') { + // targets not allowed for on-page anchors + // and mailto: links. + $target = ''; + } else { + // allow targets on non-anchor non-mailto links + $target = $this->getConf('target'); + } + + // generate a regular link (not an image) + $text = $this->textEncode($text); + $css = $this->formatConf(' class="%s"', "css_$type"); + $start = "textEncode($target); + $start .= " onclick=\"window.open(this.href, '$target');"; + $start .= " return false;\""; + } + + if (isset($name)) { + $start .= " id=\"$name\""; + } + + // finish up output + $start .= ">"; + $end = ""; + + // make numbered references look like footnotes when no + // CSS class specified, make them superscript by default + if ($type == 'footnote' && ! $css) { + $start = '' . $start; + $end = $end . ''; + } + } + + if ($options['type'] == 'start') { + $output = $start; + } else if ($options['type'] == 'end') { + $output = $end; + } else { + $output = $start . $text . $end; + } + return $output; + } +} +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Wikilink.php b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Wikilink.php new file mode 100644 index 00000000000..734df33f879 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Render/Xhtml/Wikilink.php @@ -0,0 +1,177 @@ + + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * This class renders wiki links in XHTML. + * + * @category Text + * @package Text_Wiki + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + */ +class Text_Wiki_Render_Xhtml_Wikilink extends Text_Wiki_Render { + + var $conf = array( + 'pages' => array(), // set to null or false to turn off page checks + 'view_url' => 'http://example.com/index.php?page=%s', + 'new_url' => 'http://example.com/new.php?page=%s', + 'new_text' => '?', + 'new_text_pos' => 'after', // 'before', 'after', or null/false + 'css' => null, + 'css_new' => null, + 'exists_callback' => null // call_user_func() callback + ); + + + /** + * + * Renders a token into XHTML. + * + * @access public + * + * @param array $options The "options" portion of the token (second + * element). + * + * @return string The text rendered from the token options. + * + */ + + function token($options) + { + // make nice variable names (page, anchor, text) + extract($options); + + // is there a "page existence" callback? + // we need to access it directly instead of through + // getConf() because we'll need a reference (for + // object instance method callbacks). + if (isset($this->conf['exists_callback'])) { + $callback =& $this->conf['exists_callback']; + } else { + $callback = false; + } + + if ($callback) { + // use the callback function + $exists = call_user_func($callback, $page); + } else { + // no callback, go to the naive page array. + $list = $this->getConf('pages'); + if (is_array($list)) { + // yes, check against the page list + $exists = in_array($page, $list); + } else { + // no, assume it exists + $exists = true; + } + } + + $anchor = '#'.$this->urlEncode(substr($anchor, 1)); + + // does the page exist? + if ($exists) { + + // PAGE EXISTS. + + // link to the page view, but we have to build + // the HREF. we support both the old form where + // the page always comes at the end, and the new + // form that uses %s for sprintf() + $href = $this->getConf('view_url'); + + if (strpos($href, '%s') === false) { + // use the old form (page-at-end) + $href = $href . $this->urlEncode($page) . $anchor; + } else { + // use the new form (sprintf format string) + $href = sprintf($href, $this->urlEncode($page)) . $anchor; + } + + // get the CSS class and generate output + $css = ' class="'.$this->textEncode($this->getConf('css')).'"'; + + $start = ''; + $end = ''; + } else { + + // PAGE DOES NOT EXIST. + + // link to a create-page url, but only if new_url is set + $href = $this->getConf('new_url', null); + + // set the proper HREF + if (! $href || trim($href) == '') { + + // no useful href, return the text as it is + //TODO: This is no longer used, need to look closer into this branch + $output = $text; + + } else { + + // yes, link to the new-page href, but we have to build + // it. we support both the old form where + // the page always comes at the end, and the new + // form that uses sprintf() + if (strpos($href, '%s') === false) { + // use the old form + $href = $href . $this->urlEncode($page); + } else { + // use the new form + $href = sprintf($href, $this->urlEncode($page)); + } + } + + // get the appropriate CSS class and new-link text + $css = ' class="'.$this->textEncode($this->getConf('css_new')).'"'; + $new = $this->getConf('new_text'); + + // what kind of linking are we doing? + $pos = $this->getConf('new_text_pos'); + if (! $pos || ! $new) { + // no position (or no new_text), use css only on the page name + + $start = ''; + $end = ''; + } elseif ($pos == 'before') { + // use the new_text BEFORE the page name + $start = ''.$this->textEncode($new).''; + $end = ''; + } else { + // default, use the new_text link AFTER the page name + $start = ''; + $end = ''.$this->textEncode($new).''; + } + } + if (!strlen($text)) { + $start .= $this->textEncode($page); + } + if (isset($type)) { + switch ($type) { + case 'start': + $output = $start; + break; + case 'end': + $output = $end; + break; + } + } else { + $output = $start.$this->textEncode($text).$end; + } + return $output; + } +} +?> diff --git a/wicked/lib/Text_Wiki/Text/Wiki/Tiki.php b/wicked/lib/Text_Wiki/Text/Wiki/Tiki.php new file mode 100644 index 00000000000..8153f439eb7 --- /dev/null +++ b/wicked/lib/Text_Wiki/Text/Wiki/Tiki.php @@ -0,0 +1,92 @@ + + * @author Bertrand Gugger + * @author Paul M. Jones + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Wiki + */ + +/** + * "master" class for handling the management and convenience + */ +require_once('Text/Wiki.php'); + +/** + * Base Text_Wiki handler class extension for tikiwiki markup + * + * @category Text + * @package Text_Wiki + * @author Justin Patrin + * @author Bertrand Gugger + * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Wiki + * @see Text_Wiki::Text_Wiki() + */ +class Text_Wiki_Tiki extends Text_Wiki { + var $rules = array( + 'Prefilter', + 'Delimiter', + 'Code', + 'Plugin', +// 'Function', + 'Html', + 'Raw', // Now Parsed in Plugin + 'Preformatted', // Now Parsed in Plugin + 'Include', + 'Embed', + 'Page', + 'Anchor', + 'Heading', + 'Toc', + 'Titlebar', + 'Horiz', + 'Redirect', + 'Break', + 'Blockquote', + 'List', + 'Deflist', + 'Table', + 'Box', + 'Image', + 'Smiley', +// 'Phplookup', + 'Center', + 'Newline', + 'Paragraph', + 'Url', + //'Freelink', + 'Colortext', + 'Wikilink', + 'Strong', + 'Bold', + 'Emphasis', + 'Italic', + 'Underline', + 'Tt', + 'Superscript', + 'Subscript', + 'Specialchar', + 'Revise', + 'Interwiki', + 'Tighten' + ); + + function Text_Wiki_Tiki($rules = null) { + parent::Text_Wiki($rules); + $this->addPath('parse', $this->fixPath(dirname(__FILE__)).'Parse/Tiki'); +// $this->addPath('render', $this->fixPath(dirname(__FILE__)).'Render'); + } +} + +?> diff --git a/wicked/lib/Text_Wiki/composer.json b/wicked/lib/Text_Wiki/composer.json new file mode 100644 index 00000000000..ea9e62561f4 --- /dev/null +++ b/wicked/lib/Text_Wiki/composer.json @@ -0,0 +1,41 @@ +{ + "authors": [ + { + "email": "pmjones@ciaweb.net", + "name": "Paul Jones", + "role": "Lead" + }, + { + "email": "papercrane@reversefold.com", + "name": "Justin Patrin", + "role": "Lead" + }, + { + "email": "del@babel.com.au", + "name": "Del Elson", + "role": "Developer" + } + ], + "autoload": { + "psr-0": { + "Text": "./" + } + }, + "description": "More info available on: http://pear.php.net/package/Text_Wiki", + "include-path": [ + "./" + ], + "license": "LGPL", + "name": "pear/text_wiki", + "support": { + "issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Text_Wiki", + "source": "https://github.com/pear/Text_Wiki" + }, + "type": "library", + "require": { + "pear/pear_exception": "*" + }, + "require-dev": { + "phpunit/phpunit": "*" + } +} \ No newline at end of file diff --git a/wicked/lib/Text_Wiki/doc/BBCodeParser.php b/wicked/lib/Text_Wiki/doc/BBCodeParser.php new file mode 100644 index 00000000000..63a74a4d149 --- /dev/null +++ b/wicked/lib/Text_Wiki/doc/BBCodeParser.php @@ -0,0 +1,427 @@ + + * @author Bertrand Gugger + * @copyright 1997-2005 The PHP Group + * @copyright 2005 bertrand Gugger + * @license http://www.php.net/license/3_0.txt PHP License 3.0 + * @version CVS: $Id$ + * @link http://pear.php.net/package/HTML_BBCodeParser + * @see Text_Wiki + */ + +/** + * Text transformation engine + */ +require_once 'Text/Wiki/BBCode.php'; + +/** + * PEAR base class to get the static properties + */ +if (!defined('HTML_BBCODEPARSER_V2')) { + require_once 'PEAR.php'; +} + +/** + * Base HTML_BBCodeParser class to transform BBCode in XHTML + * + * This is a parser to replace UBB style tags with their xhtml equivalents. + * It's the refundation of the class using the Text_Wiki transform engine + * + * Usage: + * $parser = new HTML_BBCodeParser(); + * $parser->setText('normal [b]bold[/b] and normal again'); + * $parser->parse(); + * echo $parser->getParsed(); + * or: + * $parser = new HTML_BBCodeParser(); + * echo $parser->qparse('normal [b]bold[/b] and normal again'); + * or: + * echo HTML_BBCodeParser::staticQparse('normal [b]bold[/b] and normal again'); + * + * Setting the options from the ini file: + * $config = parse_ini_file('BBCodeParser.ini', true); + * $options = &PEAR::getStaticProperty('HTML_BBCodeParser', '_options'); + * $options = $config['HTML_BBCodeParser']; + * unset($options); + * + * @category HTML + * @package HTML_BBCodeParser + * @author Stijn de Reede + * @author Bertrand Gugger + * @copyright 1997-2005 The PHP Group + * @copyright 2005 bertrand Gugger + * @license http://www.php.net/license/3_0.txt PHP License 3.0 + * @version Release: @package_version@ + * @link http://pear.php.net/package/HTML_BBCodeParser + * @see Text_Wiki::BBCode() + */ +class HTML_BBCodeParser extends Text_Wiki_BBCode +{ + /** + * A string containing the input + * + * @access private + * @var string + */ + var $_text = ''; + + /** + * A string containing the parsed version of the text + * + * @access private + * @var string + */ + var $_parsed = ''; + + /** + * An array of options, filled by an ini file or through the contructor + * + * @access private + * @var array + */ + var $_options = array( 'quotestyle' => 'double', // fixed, ignored + 'quotewhat' => 'all', // fixed, ignored + 'open' => '[', // fixed, rejected + 'close' => ']', // fixed, rejected + 'xmlclose' => true, // fixed, ignored + 'filters' => 'Basic', + 'rules' => array(), + 'parse' => array(), + 'render' => array() + ); + + /** + * Constructor, initialises the options and filters + * + * Sets the private variable _options with base options defined with + * &PEAR::getStaticProperty(), overwriting them with (if present) + * the argument to this method. + * Then it sets the extra options to properly escape the tag + * characters in preg_replace() etc. The set options are + * then stored back with &PEAR::getStaticProperty(), so that the filter + * classes can use them. + * All the filters in the options are initialised and their defined tags + * are copied into the private variable _definedTags. + * + * @param mixed array or string options or ini file to use, can be left out + * @return none + * @access public + * @author Stijn de Reede + */ + function HTML_BBCodeParser($options = array()) + { + // instantiate the Text_Wiki transformer + parent::Text_Wiki_BBCode(); + + // config file (.ini) ? + if (is_string($options)) { + $options = HTML_BBCodeParser::parseIniFile($options); + } + + // set the already set options + if (!defined('HTML_BBCODEPARSER_V2')) { + $baseoptions = PEAR::getStaticProperty('HTML_BBCodeParser', '_options'); + if (is_array($baseoptions)) { + foreach ($baseoptions as $k => $v) { + $this->_options[$k] = $v; + } + } + } + + // set the options passed as an argument + foreach ($options as $k => $v ) { + $this->_options[$k] = $v; + } + + // open and close tags are fixed by Text_Wiki_BBCode + if ((isset($this->_options['open']) && ($this->_options['open'] != '[')) + || (isset($this->_options['close']) && ($this->_options['close'] != ']'))) { + return + "

Sorry, open/close tags are fixed to '[' and ']', put a RFE if neede

\n"; + } + // set the rules + $rules = array_merge( + // mandatory rules + array('Prefilter', 'Delimiter'), + // old style ? + isset($this->_options['filters']) ? + HTML_BBCodeParser::filtersToRules($this->_options['filters']) : array(), + // new style ? + isset($this->_options['rules']) ? + is_array($this->_options['rules']) ? + $this->_options['rules'] : explode(',', $this->_options['rules']) + : array() + ); + + // filter rules so their order is kept + foreach ($this->rules as $rule) { + if (!in_array( $rule, $rules)) { + $this->deleteRule($rule); + } + } + if (isset($options['parse'][$options['set_parse']])) { + $this->parseConf = $options['parse'][$options['set_parse']]; + } + if (isset($options['format'])) { + foreach (array_keys($options['format']) as $render) { + if (!isset($options['set_render']) + || in_array($render, $options['set_render'])) { + $this->setFormatConf($render, $options['format'][$render]); + } + } + } + if (isset($options['render'])) { + foreach (array_keys($options['render']) as $render) { + if (in_array($render, $options['set_render'])) { + $this->renderConf[$render] = $options['render'][$render]; + } + } + } +// var_dump( $options);var_dump($this->parseConf);var_dump($this->formatConf);var_dump($this->renderConf); die(); + } + + /** + * Prune (unset) empty arrays in options + * + * @param string $iniFile the configuration file name (default 'BBCodeParser.ini') + * @return array the corresponding options as a tree array general|Parse|Render*Format*Rule + * @access public + * @static + */ + function pruneOptions(&$options) + { + foreach (array_keys($options) as $k0) { + if (is_array($options[$k0])) { + if ($options[$k0]) { + HTML_BBCodeParser::pruneOptions($options[$k0]); + } + if (!$options[$k0]) { + unset($options[$k0]); + } + } + } + } + + /** + * Parse configuration file to set an option array + * + * @param string $iniFile the configuration file name (default 'BBCodeParser.ini') + * @return array the corresponding options + * as a tree general|parse|render|format*Format*Rule + * @access public + * @static + */ + function parseIniFile($iniFile = 'BBCodeParser.ini') + { + static $isArray = array( + 'set_render', 'filters', 'rules', + 'schemes', 'extensions', 'refused', 'prefixes', 'img_ext'); + $options = array(); + // Parse the ini file + $config = parse_ini_file($iniFile, true); + // Normalize if old config + if (isset($config['HTML_BBCodeParser'])) { + $config = array_merge($config['HTML_BBCodeParser'], $config); + unset($config['HTML_BBCodeParser']); + } + // proceed each section or general items + foreach ($config as $name => $section) { + if (is_string($section)) { + $options[$name] = in_array($name, $isArray) ? + explode(',', $section) : $section; + continue; + } + $keys = explode('_', $name); + $here = & $options; + foreach ($keys as $key) { + if (!isset($here[$key])) { + $here[$key] = array(); + } + $here = & $here[$key]; + } + $smiley = (count($keys) == 3) && ($keys[0] == 'parse') && ($keys[2] == 'Smiley'); + foreach ($section as $itk => $item) { + if ($item === '') { + continue; + } + if ($smiley && (substr($itk, 0, 7) == 'smiley_')) { + $words = explode(' ', $item); + $equal = false; + $variante = array(); + for ($i = 1; $i < count($words); $i++) { + if ($equal) { + $variante[] = $words[$i]; + $equal = false; + continue; + } + if (!$equal = ($words[$i] == '=')) { + break; + } + } + $here[$words[0]] = array_merge( + array( + substr($itk, 7), + $equal || (count($words) == $i + 1) ? + $itk + : implode(' ', array_slice($words, $i)) + ), + $variante); + } else { + $here[$itk] = in_array($itk, $isArray) ? + explode(',', $item) : $item; + } + } + } + HTML_BBCodeParser::pruneOptions($options); + return $options; + } + + /** + * Sets rules list from Filters (groups of rules) + * + * @param mixed filters to set as a comma separated string or array + * @return array the corresponding rules + * @access public + * @static + */ + function filtersToRules($filters = array()) + { + $conv = array( + // todo: , 'Strike', ' Subscript', 'Superscript' + 'Basic' => array('Bold', 'Italic', 'Underline'), + 'Extended' => array('Colortext', 'Font', 'Blockquote', 'Code'), //todo: , 'align' + 'Links' => array('Url'), + 'Images' => array('Image'), + 'Lists' => array('List'), + 'Email' => array('Url') + ); + if (!is_array($filters)) { + $filters = explode(',', $filters); + } + foreach ($conv as $filter => $rules) { + if (!in_array( $filter, $filters)) { + unset($conv[$filter]); + } + } + return $conv; + } + + /** + * Sets text in the object to be parsed + * + * @param string the text to set in the object + * @return none + * @access public + * @see getText() + * @see $_text + * @author Stijn de Reede + */ + function setText($str) + { + $this->_text = $str; + } + + /** + * Gets the unparsed text from the object + * + * @return string the text set in the object + * @access public + * @see setText() + * @see $_text + * @author Stijn de Reede + */ + function getText() + { + return $this->_text; + } + + /** + * Gets the preparsed text from the object + * + * @return string the text set in the object + * @access public + * @see _preparse() + * @see $_preparsed + * @author Stijn de Reede + */ + function getPreparsed() + { + return $this->_preparsed; + } + + /** + * Gets the parsed text from the object + * + * @return string the parsed text set in the object + * @access public + * @see parse() + * @see $_parsed + * @author Stijn de Reede + */ + function getParsed() + { + return $this->_parsed; + } + + /** + * Parses the text set in the object + * + * @param string $text : if set, that's a call to the parent Text_Wiki::parse() + * @return none + * @access public + * @see Text_Wiki::parse() + * @see Text_Wiki::render() + */ + function parse($text = null) + { + if (isset($text)) { + parent::parse($text); + return; + } + parent::parse($this->_text); + $this->_preparsed = $this->source; + $this->_parsed = parent::render('Xhtml'); + } + + /** + * Quick method to do setText(), parse() and getParsed at once + * + * @return none + * @access public + * @see parse() + * @see $_text + * @author Stijn de Reede + */ + function qparse($str) + { + $this->_text = $str; + $this->parse(); + return $this->_parsed; + } + + /** + * Quick static method to do setText(), parse() and getParsed at once + * + * @return none + * @access public + * @see parse() + * @see $_text + * @author Stijn de Reede + */ + function staticQparse($str) + { + $p = new HTML_BBCodeParser(); + $str = $p->qparse($str); + unset($p); + return $str; + } +} +?> diff --git a/wicked/lib/Text_Wiki/doc/BBCodeParser_V2.ini b/wicked/lib/Text_Wiki/doc/BBCodeParser_V2.ini new file mode 100644 index 00000000000..ce47dd0dd05 --- /dev/null +++ b/wicked/lib/Text_Wiki/doc/BBCodeParser_V2.ini @@ -0,0 +1,160 @@ +[HTML_BBCodeParser] +; THESE OPTIONS ARE FIXED ! JUST HERE FOR VISIBILITY, DON'T CHANGE ! +; possible values: single|double +; use single or double quotes for attributes +quotestyle = double + +; possible values: all|nothing|strings +; quote all attribute values, none, or only the strings +quotewhat = all + +; the opening tag character +open = [ + +; the closing tag character +close = ] + +; possible values: true|false +; use xml style closing tags for single html tags ( or ) +xmlclose = true +; END FIXED OPTIONS + +; WILL BE SUPERSEDED BY 'rules' IF PRESENT +; possible values with the corresponding rules [not yet implemented] +; Basic => Bold,Italic,Underline [,Strike, Subscript,Superscript] +; Extended => Colortext,Font,Blockquote,Code, [,align] +; Links => Url +; Images => Image +; Lists => List +; Email => Url +; comma seperated list of filters to use +filters = Basic,Extended,Links,Images,Lists,Email + +;********************* +;* Text_Wiki options * +;********************* +set_parse=BBCode +set_render=Xhtml + +; comma seperated list of rules to use, possible values: +; Prefilter,Delimiter,Code,Blockquote,List,Image,Smiley, +; Newline,Paragraph,Url,Colortext,Font,Bold,Italic,Underline,Tighten +rules = Code,Blockquote,List,Image,Smiley,Newline,Paragraph,Url,Colortext,Font,Bold,Italic,Underline,Tighten + +;************** Parse options ************ + +[parse_BBCode_Image] +schemes= +url_regexp= +local_regexp= +extensions= + +[parse_BBCode_Smiley] +smiley_biggrin = ":D = :grin: Very Happy" +smiley_smile = ":) = (: Smile" +smiley_sad = ":( = ): Sad" +smiley_surprised = ":o = :eek: = o: Surprised" +smiley_eek = ":shock: Shocked" +smiley_confused = ":? = :???: Confused" +smiley_cool = "8) = (8 Cool" +smiley_lol = ":lol: Laughing" +smiley_mad = ":x = x: Mad" +smiley_razz = ":P Razz" +smiley_redface = ":oops Embarassed" +smiley_cry = ":cry: Crying or Very sad" +smiley_evil = ":evil: Evil or Very Mad" +smiley_twisted = ":twisted: Twisted Evil" +smiley_rolleyes = ":roll: Rolling Eyes" +smiley_wink = ";) = (; Wink" +smiley_exclaim = ":!: Exclamation" +smiley_question = ":?: Question" +smiley_idea = ":idea: Idea" +smiley_arrow = ":arrow: Arrow" +smiley_neutral = ":| = |: Neutral" +smiley_mrgreen = ":mrgreen: Mr. Green" +auto_nose=1 + +[parse_BBCode_Paragraph] +skip= + +[parse_BBCode_Url] +schemes= +refused= +prefixes= +host_regexp= +path_regexp= +user_regexp= + +;[parse_BBCode_Prefilter] +;[parse_BBCode_Delimiter] +;[parse_BBCode_Code] +;[parse_BBCode_Blockquote] +;[parse_BBCode_List] +;[parse_BBCode_Newline] +;[parse_BBCode_Colortext] +;[parse_BBCode_Font] +;[parse_BBCode_Bold] +;[parse_BBCode_Italic] +;[parse_BBCode_Underline] +;[parse_BBCode_Tighten] + +;************** Renderer options ************ +[format_Xhtml] +translate=HTML_ENTITIES +quotes= ENT_COMPAT +charset=ISO-8859-1 + +[render_Xhtml_Image] +base=/ +;url_base= +css= +css_link= + +[render_Xhtml_Smiley] +prefix=images/smiles/icon_ +extension=.gif +css= + +[render_Xhtml_Url] +images=true +img_ext=jpg,jpeg,gif,png +target=_blank +css_inline= +css_descr= +;css_footnote= +css_img= + +[render_Xhtml_Code] +css= +css_code= +css_php= +css_html= +css_filename= + +[render_Xhtml_Blockquote] +css= + +[render_Xhtml_List] +css_ol= +css_ol_li= +css_ul= +css_ul_li= + +[render_Xhtml_Paragraph] +css= + +[render_Xhtml_Bold] +css= + +[render_Xhtml_Italic] +css= + +[render_Xhtml_Underline] +css= + +;[render_Xhtml_Prefilter] +;[render_Xhtml_Delimiter] +;[render_Xhtml_Newline] +;[render_Xhtml_Colortext] +;[render_Xhtml_Font] +;[render_Xhtml_Tighten] diff --git a/wicked/lib/Text_Wiki/doc/BBtest.txt b/wicked/lib/Text_Wiki/doc/BBtest.txt new file mode 100644 index 00000000000..0ae0403d14b --- /dev/null +++ b/wicked/lib/Text_Wiki/doc/BBtest.txt @@ -0,0 +1,103 @@ +Essai + +Code block, with other BBCode inside. +[b]bolded[/b] +[i]italic[/i] +[i][b] bold italic[/b] +simple italic[/i] +[u] underline[/u] +[u] underline[i]underline italic[b]underline bold italic[/b] +underline italic[/i]underline[/u] + +Font size and color: +[color=red]Hello![/color] +or +[color=#FF0000]Hello![/color] +[color=#FF0000]Hello [color=green]You[/color] , how are you[/color] +[size=9]SMALL[/size] +[size=24]HUGE![/size] +[size=18][color=red][b]LOOK AT ME![/b][/color][/size] + +url: +[url=http://pear.php.net][img]http://pear.php.net/gifs/pearsmall.gif[/img][/url] +[url=http://www.totalgeek.org]totalgeek.org[/url] +[url=/some/relative/url.php]relative url[/url] +[url]www.totalgeek.org[/url] +www.totalgeek.org +[email=user@example.com]example Mail[/email] +[email]user@example.com[/email] +user@example.com +An [url=http://www.totalgeek.org]totalgeek.org[/url] is an url as [url=/some/relative/url.php]relative url[/url], [url]www.totalgeek.org[/url], www.totalgeek.org also emails as [email=user@example.com]example Mail[/email], [email]user@example.com[/email] or user@example.com + +[img]rond.gif[/img] +[img]http://pear.php.net/gifs/pearsmall.gif[/img] + +[u][b][i]Test for BBCode lists[/i][/b][/u] + +Unordered list: +[list] +[*] This is the first bulleted item. +[*] This is the second bulleted item. +[/list] + +Ordered list: +[list=A] +[*] This is the first bulleted item. +[*] This is the second bulleted item. +[/list] + +[list] +[*]unordered item 1 +[*]unordered item 2 +[/list] + +[list=1] +[*]ordered item 1 +[*]ordered item 2 +[/list] + +[list=i][*]ordered item 1 type i[*]ordered item 2 type i[/list] + +an empty one: +[list][/list] +some more: + [list=I] + [*]ordered item 1 type I + [/list] + [list=a] + [*]ordered item 1 type a + [*]ordered item 2 type a + [/list] + [list=A] + [*]ordered item 1 type A + [*]ordered item 2 type A + [/list] + + [list=X] + [*]ordered item 1, nested list: + [list=99] + [*]nested item 1 + [*]nested item 2 + [/list] + [*]ordered item 2 + [/list] + +[quote="bibi"]And a quote! +[quote]And a second +inside +[/quote] +[/quote] + +[code] +Hello +[code] +You +[/code] + , how are you +[/code] + +[size=18][color=red][b]CRAP ![/b][/color][/size] + +[color=expression(alert('fooba'));]test[/color] + +[size=18pt;width:expression(alert("foobar"));]test[/size] diff --git a/wicked/lib/Text_Wiki/doc/README_BBCodeParser b/wicked/lib/Text_Wiki/doc/README_BBCodeParser new file mode 100644 index 00000000000..735a46490d8 --- /dev/null +++ b/wicked/lib/Text_Wiki/doc/README_BBCodeParser @@ -0,0 +1,45 @@ +README_BBCodeParser +------------------- + +These notes introduce the changes in HTML_BBCodeParser refunded on Text_Wiki + +1) PEAR static properties +Options can still be initialized thru PEAR static properties, +however this feature is deprecated. +You may define the constant HTML_BBCODEPARSER_V2 to avoid requiring PEAR +and shut off totally this feature + +2) Droped out options +* Open/close tags + 'open' => '[' + 'close' => ']' + The tags are fixed to square brackets, if different rejected +* XHTML compatibility + The rendering is exlusively XHTML, so old rendering options are fixed : + 'quotestyle' => 'double', + 'quotewhat' => 'all', + 'xmlclose' => true, + Differents will be ignored. + +3) Choice of filters/rules +The option 'filters' is still in use + 'filters' => 'Basic,Extended,Links,Images,Lists,Email' (default 'Basic') +and will determine the list of active rules (tags) as usual + +It's a way of grouping rules and you may prefer the option 'rules' +which enables a detailed list of activated tags. +You can use both 'filters' and 'rules', they are additive. + +NOTE: as for the initial release, only standard BBCode tags are implemented +in the parser. Therefore, [s], [sub], [sup], [font], [align] and [ulist] +even if they exist in the renderer are not yet implemented in the parser + +4) New options +* General +The 'filters' and 'rules' options detail the enabled tags +* Parser +The 'parser_BBCode_xxx' options cares for Text_Wiki_Parse_BBCode options for rule/tag xxx +* Renderer +Then 'render_Xhtml_xxx' options cares for Text_Wiki_Render_Xhtml options for rule/tag xxx + +See full example BBCodeParser_V2.ini diff --git a/wicked/lib/Text_Wiki/doc/parser.php b/wicked/lib/Text_Wiki/doc/parser.php new file mode 100644 index 00000000000..2cd5b7e1419 --- /dev/null +++ b/wicked/lib/Text_Wiki/doc/parser.php @@ -0,0 +1,121 @@ +setText(@$_GET['string']); +$parser->parse(); +$parsed = $parser->getParsed(); + +?> + + + +HTML_BBCodeParser (by Stijn de Reede) + + +
+ + + + + + +
+input:
+
+
+ouput:
+
+
+
+
+ +
+possible codes: +
+[b]bold[/b]
+[i]italic[/i]
+[u]underline[/u]
+[s]strike[/s]
+[sub]subscript[/sub]
+[sup]superscript[/sup]
+
+[color=blue]blue text[/color]
+[size=18]the size of this text is 18pt[/size]
+[font=arial]different font type[/font]
+[align=right]yes, you're right, this isn't on the left[/align]
+he said: [quote=http://www.server.org/quote.html]i'm tony montana[/quote]
+[code]x + y = 6;[/code]
+
+http://www.server.org
+[url]http://www.server.org[/url]
+[url=http://www.server.org]server[/url]
+[url=http://www.server.org t=new]server[/url]
+
+guest@anonymous.org
+[email]guest@anonymous.org[/email]
+[email=guest@anonymous.org]mail me[/email]
+
+[img]http://www.server.org/image.jpg[/img]
+[img w=100 h=200]http://www.server.org/image.jpg[/img]
+
+[ulist]
+[*]unordered item 1
+[*]unordered item 2
+[/ulist]
+[list]
+[*]unordered item 1
+[*]unordered item 2
+[/list]
+
+[list=1]
+[*]ordered item 1
+[*]ordered item 2
+[/list]
+[list=i]
+[*]ordered item 1 type i
+[li=4]ordered item 4 type i[/li]
+[/list]
+[list=I]
+[*]ordered item 1 type I
+[/list]
+[list=a s=5]
+[li]ordered item 5 type a[/li]
+[*]ordered item 6 type a
+[/list]
+[list=A]
+[li]ordered item 1 type A[/li]
+[li=12]ordered item 12 type A[/li]
+[/list]
+
+[list=A s=3]
+[li]ordered item 1, nested list:
+    [list=I]
+    [li]nested item 1[/li]
+    [li]nested item 2[/li]
+    [/list][/li]
+[li]ordered item 2[/li]
+[/list]
+
+
+
+ diff --git a/wicked/lib/Text_Wiki/doc/test_Text_Wiki.php b/wicked/lib/Text_Wiki/doc/test_Text_Wiki.php new file mode 100644 index 00000000000..b59a31a68a0 --- /dev/null +++ b/wicked/lib/Text_Wiki/doc/test_Text_Wiki.php @@ -0,0 +1,184 @@ +$plist[0], 'render'=>$rlist[0], + 'exchoice'=>($elist ? $elist[0] : ''), 'source'=>'') + as $fld=>$def) { + if(!isset($_REQUEST[$fld])) { + $_REQUEST[$fld] = $def; + } + $$fld = $_REQUEST[$fld]; + } + if (!isset($_REQUEST['translate'])) { + echo bldHtml('', $plist, $rlist, $elist); + die(); + } +} + +// instantiate a Text_Wiki object from the given class +$wiki = & Text_Wiki::singleton($parser); + +// If you want to include rules, use +//$wiki = & Text_Wiki::singleton($parser, $rules); + +// If you want to get a new copy of the class use factory +//$wiki =& Text_Wiki::factory($parser); + +//print "
\n";
+//print_r($wiki);
+//print "
\n"; + +// when rendering XHTML, make sure wiki links point to a +// specific base URL +//$wiki->setRenderConf('xhtml', 'wikilink', 'view_url', +// 'http://example.com/view.php?page='); + +// set an array of pages that exist in the wiki +// and tell the XHTML renderer about them +//$pages = array('HomePage', 'AnotherPage', 'SomeOtherPage'); + +$wiki->setRenderConf('xhtml', 'code', 'css_filename', 'codefilename'); + +// transform the wiki text into given rendering +$result = $wiki->transform($source, $render); + +// display the transformed text +if ($html) { + echo bldHtml($result, $plist, $rlist, $elist); +} else { + if (PEAR::isError($result)) { + var_dump($result); + } else { + echo $result; + } +} +function bldOpt($name, $list) { + $ret = ''; + foreach($list as $opt) { + $ret .= "\n"; + } + return $ret; +} +function bldHtml($result, $plist, $rlist, $elist) { + $optparser = bldOpt('parser', $plist); + $optrender = bldOpt('render', $rlist); + $optexample = bldOpt('exchoice', $elist); + if (PEAR::isError($result)) { + $hresult = '' . + nl2br(htmlentities($result->toString ())) . ''; + $result = ''; + } else { + $hresult = nl2br(htmlentities($result)); + } + if ($_REQUEST['render'] != 'Xhtml') { + $result = ''; + } + $_REQUEST['source'] = htmlspecialchars($_REQUEST['source']); + return << + + + + PEAR::Text_Wiki Demo + + + + + + +

PEAR::Text_Wiki Demo

+
+
+Translate from + + to + + +
+ +
+

Or choose + + and + +

+
+
+
+{$hresult} +
+
+{$result} +
+ + +EOT; +} +function findExamples($dir=null) { + $ret = array(); + $dh=opendir($dir? $dir : '.'); + while ($subfil = readdir($dh)) { + if (!is_dir($subfil) && is_readable($subfil) + && (substr($subfil, -4) == '.txt')) { + $ret[] = $subfil; + } + } + closedir($dh); + return $ret; +} +?> diff --git a/wicked/lib/Text_Wiki/package.xml b/wicked/lib/Text_Wiki/package.xml new file mode 100644 index 00000000000..1a5577ea0e3 --- /dev/null +++ b/wicked/lib/Text_Wiki/package.xml @@ -0,0 +1,526 @@ + + + Text_Wiki + pear.php.net + Transforms Wiki and BBCode markup into XHTML, LaTeX or plain text markup. This is the base engine for all of the Text_Wiki sub-classes. + The text transformation is done in 2 steps. +The chosen parser uses markup rules to tokenize the tags and content. +Renderers output the tokens and text into the requested format. +The tokenized form replaces the tags by a protected byte value associated to an index in an options table. This form shares up to 50 rules by all parsers and renderers. +The package is intented for versatile transformers as well as converters. +Text_Wiki is delivered with its own parser, which is used by Yawiki or Horde's Wicked and three basic renderers: XHTML , LaTeX and plain text. +Strong sanitizing of XHTML is default. +Parsers (* and Renderers) exist for BBCode, Cowiki (*), Dokuwiki (*), Mediawiki and Tikiwiki (*). +It is highly configurable and can be easily extended. + + Paul Jones + pmjones + pmjones@ciaweb.net + yes + + + Justin Patrin + justinpatrin + papercrane@reversefold.com + yes + + + Del Elson + delatbabel + del@babel.com.au + yes + + 2014-06-07 + + + 1.2.2 + 1.2.0 + + + stable + stable + + LGPL + +QA release + +Bug #11649 Closed New Code regex fails +Req #12569 Closed Adding 'base_url' to XHTML Toc renderer +Bug #12719 Closed Blockquote parsing bugs +Bug #12722 Closed HTML Blockquote compliance +Bug #14604 Closed Unresolved dependency in Text_Wiki_Render_Latex_Freelink +Bug #18289 Closed List not properly parsed +Bug #19028 Closed remove error_reporting (for PEAR QA team) +Bug #20110 Closed package.xml does not validate +Req #20274 Closed Please Provides LICENSE file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 4.0.0 + + + 1.4.4 + + + + + + + + 1.0.1 + 1.0.1 + + + stable + stable + + 2005-09-12 + LGPL + +This is a bug fix and security release, also preparing the introduction of new parsers/renderers +* Fixed bug 3881 and 4442, UTF-8 encoding problems. There are new config options for Render_Xhtml, 'charset' and 'quotes', that allow you to specify the charset for translation. +* Fixed bug 3959, "XHTML lists not rendered according W3C Standards" (where a line of text before a list leaves an open paragraph tag and closes it after the list) +* In Parse_Xhtml_Toc, returns an extra newline before the parsed replacement text to comply with the matching regex. +* In Render_Xhtml_Toc, added a 'collapse' config key to collapse the div horizontally within a table; this is for aesthetics, nothing else. The 'collapse' option is true by default. +* Added general rules Smiley, Subscript ",,text,," and Underline "__text__" +* Added rendering rules Box, Font, Page, Plugin, Preformatted, Specialchar and Titelbar + for the optional extra parsers (BBCode, Cowiki, Doku, Mediawiki and Tiki) +* Fixed bug 4175 "Wrong transform method" by generating PEAR_Error objects when a parse, format, or render rule cannot be found. +* applied feature request 4436 "Add option to getTokens to get original token indices" -- now the return array from getTokens() is keyed to the original token index number. +* Fixed Bug #4473 Undefined variables in error() +* Fixed bug 4474 to silence calls to htmlentities and htmlspecialchars so that errors about charsets don't pop up, per counsel from Jan at Horde. +* Fixed Code potential nesting +* Fixed bug #4719, "In Latex, newline rule does not produce a new line" +* Request #4520 Additional space confuses image tag, adapted regexp +* Request #4634 Code block title/filename, uses conf css_filename +* Code Xhtml: add php tags only if not there +* Heading: collapsing in headers +* Colortext Xhtml: don't add # if allready present +* Anchor Xhtml htlmentify the link +* Cleaned Xhtml renderers documentation headers +* Added an example in doc +* Rowspan and space before free format in Table renderer +* Secured url linked on images + + + + + 1.0.2 + 1.0.2 + + + stable + stable + + 2005-11-06 + LGPL + +This is a bug fix release, also with a few enhancements +Default parser: +* Bug #5660: The # is to be kept in the anchor option, (jeremy Lecour) +* Bug #5863: Don't mix bullet and numbered lists when following each other, (stefan dot kilp at gmx dot net) +* Bug #5397: variable used inside single quotes bugs WikiLinks (kristof dot coomans at sckcen dot be) +Xhtml renderer: +* Bug #5447: Preset $collapse to null (martin at mein-horde dot de) +* Bug #5847: onclick in lowercase for Xhtml compliance (meisteg at msoe dot edu) +* Unitiliazed row and column 's spans when coming from not mediawiki parser +Xhtml and Latex renderers: +* Render enumeration type a, A, i, or I in lists + + + + + 1.0.3 + 1.0.3 + + + stable + stable + + 2005-11-08 + LGPL + +This is a bug fix release, the Bug #5863: mixed <ul> <ol> when using * and # fix introduced a potential BBC: Bug #5879 Nested lists to do not parse properly in Text_Wiki + + + + + 1.1.0 + 1.1.0 + + + stable + stable + + 2006-03-02 + LGPL + +This is a major release as we reduce global resource usage +# instantiate renderers only as needed +# factory() method introduced for instantiating Text_Wiki objects +# singleton() static method to get a single object instanciated pro parser (merci davidc for advices) + +The constructor is now deprecated in favor of the new singleton() or factory() methods +Default also have its own class now, wich means Text_Wiki is a pure abstract class + +Renderers now have their own methods for: +# text: textEncode() defaulted to php htmlspecialchars() +for Xhtml render to the text encoding choosed in conf (#5953, thanks jocke at selincite dot com) +# url: urlEncode() defaulted to the php rawurlencode() + +Wiki general: +# Correct the key used in changeRule(), ensure no double new rule. +# Page names and anchors Urlencode() as render required (e.g. may contain spaces) +# Interwiki: parser may now give the full url instead of site+page (Mediawiki need) +# Improved test. + +Latex render: +# Only variables should be assigned by reference (#6010, thanks twells at smarterliving dot com) + +Plain render: +# Interwiki: Complete the rendering with indication of (url) or (site:page) + +Xhtml render: +# Rendering Fix for Tables (Missing Whitespace) (thanks ritzmo) +# Added support for two-token URLs +## This allows formatting within URL text and proper rendering into other Wiki dialects (assuming that your parser supports the new feature. The Default parser does not yet support this.) + +Maintainers: +# Del , one of the funders of the original code fully as pear developer +# JustinP is now lead + + + + + 1.2.0RC1 + 1.2.0RC1 + + + beta + beta + + LGPL + 2006-10-10 + +New Features: +# Experimental new rendering method introduced that uses preg instead of char-by-char parsing +## Please test for both speed and memory usage + +Changes: +# Internal Text_Wiki error handling used in factory and singleton +# Needed files are now required +# bertrand Gugger has left development of Text_Wiki + +Bugs fixed: +# Raw output is now encoded in Xhtml renderer to avoid XSS attacks +# Bug 8313 fix anchor output in Xhtml/Wikilink when used in conjuction with sprintf (thanks to bjs5075 at rit dot edu) +# Fixed various encoding issues with Xhtml/Wikilink URLs +# Bug #7091 fixed variable substitution in Latex renderer (thanks randlem at bgsu dot edu) + + + + + 1.2.0 + 1.2.0RC2 + + + beta + beta + + 2007-03-11 + LGPL + +New Features: +# Added an Address Xhtml renderer +# Balanced token checking has been added (this means that output such as <b><i>italic</b></i> is caught) +# A new stack-based callback system for renderers has been added to allow for more flexible output handling (see BlockQuote) +# The Url Xhtml renderer now allows a name to be passed in +# The Url Xhtml, Plain, Latex renderers now allow start/end tokens + +Changes: +# Experimental preg rendering method deprecated as it had problems +# Package.xml 2.0 is now used exclusively + +Bugs fixed: +# Bug #7320 fix UTF-8 rendering in WikiLink and Freelink +# Various UTF-8 fixes +# Bug #6292 remove paragraph tags from around headings and hrs in Xhtml renderer +# Preformatted Xhtml renderer now correctly escapes output + + + + + 1.2.2 + 1.2.0 + + + stable + stable + + 2014-06-07 + LGPL + +QA release + +Bug #11649 Closed New Code regex fails +Req #12569 Closed Adding 'base_url' to XHTML Toc renderer +Bug #12719 Closed Blockquote parsing bugs +Bug #12722 Closed HTML Blockquote compliance +Bug #14604 Closed Unresolved dependency in Text_Wiki_Render_Latex_Freelink +Bug #18289 Closed List not properly parsed +Bug #19028 Closed remove error_reporting (for PEAR QA team) +Bug #20110 Closed package.xml does not validate +Req #20274 Closed Please Provides LICENSE file + + + + diff --git a/wicked/lib/Text_Wiki/packageBBCode.xml b/wicked/lib/Text_Wiki/packageBBCode.xml new file mode 100644 index 00000000000..715ea762ade --- /dev/null +++ b/wicked/lib/Text_Wiki/packageBBCode.xml @@ -0,0 +1,146 @@ + + + + Text_Wiki_BBCode + pear.php.net + BBCode parser for Text_Wiki + Parses BBCode mark-up to tokenize the text for Text_Wiki +rendering (Xhtml, plain, Latex) +or for conversions using the existing renderers (wiki). +IT IS USING PCRE, SO IS UNDER PCRE LIMITATIONS, see http://php.net/pcre + + + Firman Wandayandi + firman + firman at php dot net + yes + + + bertrand Gugger + toggg + toggg at php dot net + yes + + 2006-12-23 + + + 0.0.4 + 0.0.4 + + + alpha + alpha + + LGPL + * Url: in case of [url=...]description[/url] , description is now parsed (#9393, thanks laurent from invisibleray) +* List: secured recursion risk but the simple #7908 is causing the state of the package to be kept alpha. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 4.0.0 + + + 1.4.0b1 + + + Text_Wiki + pear.php.net + 1.0.2 + + + + + + + + 0.0.3 + 0.0.3 + + + alpha + alpha + + 2006-02-06 + LGPL + * List: Swallow away line breaks within the lists which produced unwanted <br /> +* List: Starting count by zero as Xhtml render relies on it (erroneous </li> at begin) +* Really add superscript and subscript extensions (forgoten in package file list) + + + + + + 0.0.2 + 0.0.2 + + + alpha + alpha + + 2005-11-06 + LGPL + * Firman is now co-lead of the package +* Added a test file to use with doc/Text_Wiki/doc/test_Text_Wiki.php +* Added examples showing how to replace deprecated HTML_BBCodeParser by Text_Wiki_BBCode +* # is optional for hexadecimal colours +* Add superscript and subscript extension +* Option relative_enable default false for relative urls, e.g., [url=/contact.php] (Request #5767) +* Refuse ] , [ and ' in path part of the url, should be urlencoded +* Fixed enumeration type [list=A] (as html type: a,A,i or I) + + + + + + 0.0.1 + 0.0.1 + + + alpha + alpha + + 2005-09-13 + LGPL + This is the basic BBCode syntax as per http://www.phpbb.com/phpBB/faq.php?mode=bbcode + + + + + diff --git a/wicked/lib/Text_Wiki/packageCowiki.xml b/wicked/lib/Text_Wiki/packageCowiki.xml new file mode 100644 index 00000000000..9ad5f72ce3b --- /dev/null +++ b/wicked/lib/Text_Wiki/packageCowiki.xml @@ -0,0 +1,144 @@ + + + Text_Wiki_Cowiki + pear.php.net + Cowiki parser and renderer for Text_Wiki + Note: coWiki has been offically discontinued. This package is being kept to allow conversion of coWiki syntax to other wiki markups. + +Parses coWiki mark-up to tokenize the text for Text_Wiki rendering and also renders for wiki conversion. + +See: http://cowiki.org/ + + + Justin Patrin + justinpatrin + papercrane@reversefold.com + yes + + 2014-03-22 + + + 0.0.2 + 0.0.2 + + + alpha + alpha + + LGPL + +coWiki is no longer maintained. Please use this package only for conversion of coWiki syntax to other markups. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 4.0.0 + + + 1.4.0b1 + + + Text_Wiki + pear.php.net + 1.0.1 + + + + + diff --git a/wicked/lib/Text_Wiki/packageCreole.xml b/wicked/lib/Text_Wiki/packageCreole.xml new file mode 100644 index 00000000000..c0a6f7308c0 --- /dev/null +++ b/wicked/lib/Text_Wiki/packageCreole.xml @@ -0,0 +1,132 @@ + + + Text_Wiki_Creole + pear.php.net + Creole parser and renderer for Text_Wiki + Parses Creole mark-up to tokenize the text for Text_Wiki rendering and also renders for wiki conversion. You can see a reference for this syntax here: http://www.wikicreole.org/ + + + Michele Tomaiuolo + mic + tomamic@yahoo.it + yes + + 2010-10-25 + + + 1.0.2 + 1.0.1 + + + stable + stable + + LGPL + QA Release +Bug #15717 Header shouldn't need a following empty line + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 4.0.0 + + + 1.4.0b1 + + + Text_Wiki + pear.php.net + 1.0.1 + + + + + diff --git a/wicked/lib/Text_Wiki/packageDoku.xml b/wicked/lib/Text_Wiki/packageDoku.xml new file mode 100644 index 00000000000..e903eac741c --- /dev/null +++ b/wicked/lib/Text_Wiki/packageDoku.xml @@ -0,0 +1,140 @@ + + + Text_Wiki_Doku + pear.php.net + Doku parser and renderer for Text_Wiki + Parses DokuWiki mark-up to tokenize the text for Text_Wiki rendering and also renders for wiki conversion. You can see a reference for this syntax here: http://wiki.splitbrain.org/wiki:syntax + + + Justin Patrin + justinpatrin + papercrane@reversefold.com + yes + + 2014-03-22 + + + 0.0.1 + 0.0.1 + + + alpha + alpha + + LGPL + +First released version of Text_Wiki_Doku. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 4.0.0 + + + 1.4.0b1 + + + Text_Wiki + pear.php.net + 1.0.1 + + + + + diff --git a/wicked/lib/Text_Wiki/packageMediawiki.xml b/wicked/lib/Text_Wiki/packageMediawiki.xml new file mode 100644 index 00000000000..32e9da1b80d --- /dev/null +++ b/wicked/lib/Text_Wiki/packageMediawiki.xml @@ -0,0 +1,160 @@ + + + Text_Wiki_Mediawiki + pear.php.net + Mediawiki parser for Text_Wiki + Parses Mediawiki mark-up to tokenize the text for Text_Wiki renderings. You can see a reference for this syntax here: http://meta.wikimedia.org/wiki/Help:Editing#The_wiki_markup + + + Moritz Venn + ritzmo + moritz.venn@freaque.net + yes + + + bertrand Gugger + toggg + toggg at php dot net + yes + + + Rodrigo Sampaio Primo + rodrigosprimo + rodrigo at utopia dot org dot br + yes + + 2009-08-10 + + + 0.2.0 + 0.2.0 + + + alpha + alpha + + LGPL + +This release has the following improvements: + +* PHPUnit tests for Mediawiki parser +* Support for heading with only one level (ie: =heading=) +* Add parse for redirect rule +* Fix bug #16455: proper parsing of bold and italic + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 4.0.0 + + + 1.4.0b1 + + + Text_Wiki + pear.php.net + 1.1.0 + + + + + + + + 0.1.0 + 0.1.0 + + + alpha + alpha + + 2006-04-10 + LGPL + +Major release of Text_Wiki_Mediawiki : several rules have been added or revamped +It also takes advantage of the new Text_Wiki-1.1.0 engine. + +* Add the Wikilink rule (#6623) + Configuration: + - 'spaceUnderscore' : boolean (true) replace spaces in page name by underscores, + - 'project' : optional array of prefixes for the local project (array('demo', 'd')), + - 'url' : base url of the project for interlanguage ('http://example.com/en/page=%s'), + - 'langage' : language of the project, will be replaced case interlanguage ('en'). + +* Unify all links parsing: Image and Interwiki are now done by the Wikilink rule + These 2 rules don't exist anymore as independant classes + but are still configurable/switchable as normal rules + +* Interwiki's configuration for urls is now done parser side + Configuration: + - 'sites' : associative array of url patterns indexed by site prefixes, + - 'interlangage' : array of accepted interlanguages codes. + +* Image corrected to be complient with Mediawiki syntax + Take align attribute (left, center, or right) as piped after the | in image tag + Configuration: + - 'prefix' : array of accepted image prefixes (array('Image', 'image')). + +* List rule added , it's no more using the Text_Wiki default but a complient proper class + +* Deflist rule added (definitions list) + +* Heading corrected : it does not more require extra spaces and line feed (#6623) + +* Emphasis corrected to produce also Strong and not Bold (Strong exists only by rendering) + +* Raw : <nowiki> ... </nowiki> may be multiline + +* Overwrite of getTokens() removed, was not needed and even dangerous ... + + + + + 0.0.1 + 0.0.1 + + + alpha + alpha + + 2006-01-07 + LGPL + +First released version of Text_Wiki_Mediawiki. + + + + diff --git a/wicked/lib/Text_Wiki/packageTiki.xml b/wicked/lib/Text_Wiki/packageTiki.xml new file mode 100644 index 00000000000..423180c2209 --- /dev/null +++ b/wicked/lib/Text_Wiki/packageTiki.xml @@ -0,0 +1,178 @@ + + + Text_Wiki_Tiki + pear.php.net + Tiki parser and renderer for Text_Wiki + Parses TikiWiki mark-up to tokenize the text for Text_Wiki rendering and also renders for wiki conversion. You can see a reference for this syntax here: http://tikiwiki.org/tiki-index.php?page=WikiSyntax + + + Justin Patrin + justinpatrin + papercrane@reversefold.com + yes + + + Rodrigo Sampaio Primo + rodrigosprimo + rodrigo at utopia dot org dot br + yes + + 2009-08-10 + + + 0.1.0 + 0.1.0 + + + alpha + alpha + + LGPL + +Release with some improvements to Tiki Render: + +* New supported render rules: Paragraph, Preformatted, Redirect +* Fix bug #16322: properly URL rendering +* Fix render for heading rule +* Fix render for code rule +* Fix render for definition list +* Improvement to image render: can render images without additional params and has configuration option for the image path +* Add PHPUnit tests for Tiki render + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 4.0.0 + + + 1.4.0b1 + + + Text_Wiki + pear.php.net + 1.0.1 + + + + + + + 2005-10-14 + + 0.0.1 + 0.0.1 + + + alpha + alpha + + LGPL + +First released version of Text_Wiki_Tiki. + + + + diff --git a/wicked/lib/Text_Wiki/tests/AllTests.php b/wicked/lib/Text_Wiki/tests/AllTests.php new file mode 100644 index 00000000000..fd28c061a2f --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/AllTests.php @@ -0,0 +1,41 @@ +addTestSuite($phptTests); */ + + $suite->addTestSuite('Text_Wiki_Tests'); + $suite->addTestSuite('Text_Wiki_Render_Tests'); + //TODO: integrate Text_Wiki_Parse_Tiki_AllTests + //$suite->addTestSuite('Text_Wiki_Parse_Tiki_AllTests'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_AllTests'); + $suite->addTestSuite('Text_Wiki_Parse_Mediawiki_AllTests'); + $suite->addTestSuite('Text_Wiki_Generic_Transform_Tests'); + + /** + * @desc This suite currently 'fails' when run through here. + * Standalone works. + */ + $suite->addTestSuite('Text_Wiki_BugTests'); + + return $suite; + } +} diff --git a/wicked/lib/Text_Wiki/tests/BBCode/7908.phpt b/wicked/lib/Text_Wiki/tests/BBCode/7908.phpt new file mode 100644 index 00000000000..054e06e5d3d --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/BBCode/7908.phpt @@ -0,0 +1,243 @@ +--TEST-- +Text_Wiki_BBCode_Parse_List +--FILE-- +parse( + +'[b]Services Provided:[/b] +[list] +[*]Matters pertinent to co-habitation and non-marital relationships, +including tax, property and probate matters. +[*]Guidance on how to deal with the breakdown or dissolution of a +marriage and other relationships. +[*]Advice on commencing and enabling judicial separation proceedings. +[*]Guidance through the process involved in initiating divorce +proceedings following the breakdown of a marriage. +[*]Practical guidance on financial settlements, property disputes, +maintenance rights and other financial orders arising from divorce and +separation. +[*]Advice on matters relating to children, including custody, contact +and residence rights and disputes. +[/list]', + 'BBCode'); + +echo "---Text---\n"; +var_dump(str_replace($t->delim, '<@>', $t->source)); + +echo "---Tokens---\n"; +var_dump($t->tokens); +?> +--EXPECT-- +---Text--- +string(757) "[b]Services Provided:[/b] +<@>12<@><@>0<@>Matters pertinent to co-habitation and non-marital relationships,<@>1<@>including tax, property and probate matters. +<@>2<@>Guidance on how to deal with the breakdown or dissolution of a<@>3<@>marriage and other relationships. +<@>4<@>Advice on commencing and enabling judicial separation proceedings.<@>5<@><@>6<@>Guidance through the process involved in initiating divorce<@>7<@>proceedings following the breakdown of a marriage. +<@>8<@>Practical guidance on financial settlements, property disputes,<@>9<@>maintenance rights and other financial orders arising from divorce and +separation. +<@>10<@>Advice on matters relating to children, including custody, contact<@>11<@>and residence rights and disputes. +<@>13<@>" +---Tokens--- +array(14) { + [0]=> + array(2) { + [0]=> + string(4) "List" + [1]=> + array(3) { + ["type"]=> + string(17) "bullet_item_start" + ["level"]=> + int(0) + ["count"]=> + int(0) + } + } + [1]=> + array(2) { + [0]=> + string(4) "List" + [1]=> + array(3) { + ["type"]=> + string(15) "bullet_item_end" + ["level"]=> + int(0) + ["count"]=> + int(0) + } + } + [2]=> + array(2) { + [0]=> + string(4) "List" + [1]=> + array(3) { + ["type"]=> + string(17) "bullet_item_start" + ["level"]=> + int(0) + ["count"]=> + int(1) + } + } + [3]=> + array(2) { + [0]=> + string(4) "List" + [1]=> + array(3) { + ["type"]=> + string(15) "bullet_item_end" + ["level"]=> + int(0) + ["count"]=> + int(1) + } + } + [4]=> + array(2) { + [0]=> + string(4) "List" + [1]=> + array(3) { + ["type"]=> + string(17) "bullet_item_start" + ["level"]=> + int(0) + ["count"]=> + int(2) + } + } + [5]=> + array(2) { + [0]=> + string(4) "List" + [1]=> + array(3) { + ["type"]=> + string(15) "bullet_item_end" + ["level"]=> + int(0) + ["count"]=> + int(2) + } + } + [6]=> + array(2) { + [0]=> + string(4) "List" + [1]=> + array(3) { + ["type"]=> + string(17) "bullet_item_start" + ["level"]=> + int(0) + ["count"]=> + int(3) + } + } + [7]=> + array(2) { + [0]=> + string(4) "List" + [1]=> + array(3) { + ["type"]=> + string(15) "bullet_item_end" + ["level"]=> + int(0) + ["count"]=> + int(3) + } + } + [8]=> + array(2) { + [0]=> + string(4) "List" + [1]=> + array(3) { + ["type"]=> + string(17) "bullet_item_start" + ["level"]=> + int(0) + ["count"]=> + int(4) + } + } + [9]=> + array(2) { + [0]=> + string(4) "List" + [1]=> + array(3) { + ["type"]=> + string(15) "bullet_item_end" + ["level"]=> + int(0) + ["count"]=> + int(4) + } + } + [10]=> + array(2) { + [0]=> + string(4) "List" + [1]=> + array(3) { + ["type"]=> + string(17) "bullet_item_start" + ["level"]=> + int(0) + ["count"]=> + int(5) + } + } + [11]=> + array(2) { + [0]=> + string(4) "List" + [1]=> + array(3) { + ["type"]=> + string(15) "bullet_item_end" + ["level"]=> + int(0) + ["count"]=> + int(5) + } + } + [12]=> + array(2) { + [0]=> + string(4) "List" + [1]=> + array(3) { + ["level"]=> + int(0) + ["count"]=> + int(5) + ["type"]=> + string(17) "bullet_list_start" + } + } + [13]=> + array(2) { + [0]=> + string(4) "List" + [1]=> + array(3) { + ["level"]=> + int(0) + ["count"]=> + int(5) + ["type"]=> + string(15) "bullet_list_end" + } + } +} diff --git a/wicked/lib/Text_Wiki/tests/Cowiki_Render_Url.phpt b/wicked/lib/Text_Wiki/tests/Cowiki_Render_Url.phpt new file mode 100644 index 00000000000..799e3f151b9 --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/Cowiki_Render_Url.phpt @@ -0,0 +1,18 @@ +--TEST-- +Text_Wiki_Cowiki_Render_Url +--FILE-- +transform(' +[[http://www.example.com/page|An example page]] +[[http://www.example.com/page]] +http://www.example.com/page +', 'Cowiki')); +?> +--EXPECT-- +string(106) " +((http://www.example.com/page)(An example page)) +http://www.example.com/page +http://www.example.com/page +" diff --git a/wicked/lib/Text_Wiki/tests/Creole_Parse_Url.phpt b/wicked/lib/Text_Wiki/tests/Creole_Parse_Url.phpt new file mode 100644 index 00000000000..4c003d28e74 --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/Creole_Parse_Url.phpt @@ -0,0 +1,70 @@ +--TEST-- +Text_Wiki_Creole_Parse_Url +--FILE-- +parse(' +[[http://www.example.com/page|An example page]] +[[http://www.example.com/page]] +http://www.example.com/page +', 'Creole'); +var_dump($t->source); +var_dump($t->tokens); +?> +--EXPECT-- +string(31) " +0An example page1 +2 +3 +" +array(4) { + [0]=> + array(2) { + [0]=> + string(3) "Url" + [1]=> + array(3) { + ["type"]=> + string(5) "start" + ["href"]=> + string(27) "http://www.example.com/page" + ["text"]=> + string(15) "An example page" + } + } + [1]=> + array(2) { + [0]=> + string(3) "Url" + [1]=> + array(3) { + ["type"]=> + string(3) "end" + ["href"]=> + string(27) "http://www.example.com/page" + ["text"]=> + string(15) "An example page" + } + } + [2]=> + array(2) { + [0]=> + string(3) "Url" + [1]=> + array(1) { + ["href"]=> + string(27) "http://www.example.com/page" + } + } + [3]=> + array(2) { + [0]=> + string(3) "Url" + [1]=> + array(1) { + ["href"]=> + string(27) "http://www.example.com/page" + } + } +} diff --git a/wicked/lib/Text_Wiki/tests/Creole_Render_Url.phpt b/wicked/lib/Text_Wiki/tests/Creole_Render_Url.phpt new file mode 100644 index 00000000000..fec9cdbbf7b --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/Creole_Render_Url.phpt @@ -0,0 +1,18 @@ +--TEST-- +Text_Wiki_Creole_Render_Url +--FILE-- +transform(' +[[http://www.example.com/page|An example page]] +[[http://www.example.com/page]] +http://www.example.com/page +', 'Creole')); +?> +--EXPECT-- +string(113) " +[[http://www.example.com/page|An example page]] +[[http://www.example.com/page]] +[[http://www.example.com/page]] +" diff --git a/wicked/lib/Text_Wiki/tests/Default_Parse_BlockQuote.phpt b/wicked/lib/Text_Wiki/tests/Default_Parse_BlockQuote.phpt new file mode 100644 index 00000000000..5338be91699 --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/Default_Parse_BlockQuote.phpt @@ -0,0 +1,72 @@ +--TEST-- +Text_Wiki_Default_Blockquote +--FILE-- +parse(' +> test 1 +> test 2 +>> test 11 +>> test 22 +', 'Xhtml'); +var_dump($t->source); +var_dump($t->tokens); +?> +--EXPECT-- +string(43) " +0test 1 +test 2 +1test 11 +test 22 +23" +array(4) { + [0]=> + array(2) { + [0]=> + string(10) "Blockquote" + [1]=> + array(2) { + ["type"]=> + string(5) "start" + ["level"]=> + int(1) + } + } + [1]=> + array(2) { + [0]=> + string(10) "Blockquote" + [1]=> + array(2) { + ["type"]=> + string(5) "start" + ["level"]=> + int(2) + } + } + [2]=> + array(2) { + [0]=> + string(10) "Blockquote" + [1]=> + array(2) { + ["type"]=> + string(3) "end" + ["level"]=> + int(2) + } + } + [3]=> + array(2) { + [0]=> + string(10) "Blockquote" + [1]=> + array(2) { + ["type"]=> + string(3) "end" + ["level"]=> + int(1) + } + } +} diff --git a/wicked/lib/Text_Wiki/tests/Docbook_Render_Url.phpt b/wicked/lib/Text_Wiki/tests/Docbook_Render_Url.phpt new file mode 100644 index 00000000000..ebb56a134d7 --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/Docbook_Render_Url.phpt @@ -0,0 +1,14 @@ +--TEST-- +Text_Wiki_Docbook_Render_Url +--FILE-- +transform(' +[http://www.example.com/page An example page] +http://www.example.com/page +', 'Docbook'); +?> +--EXPECT-- +An example page +http://www.example.com/page diff --git a/wicked/lib/Text_Wiki/tests/Doku_Render_Url.phpt b/wicked/lib/Text_Wiki/tests/Doku_Render_Url.phpt new file mode 100644 index 00000000000..90b59978eb6 --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/Doku_Render_Url.phpt @@ -0,0 +1,18 @@ +--TEST-- +Text_Wiki_Doku_Render_Url +--FILE-- +transform(' +[[http://www.example.com/page|An example page]] +[[http://www.example.com/page]] +http://www.example.com/page +', 'Doku')); +?> +--EXPECT-- +string(105) " +[[http://www.example.com/page|An example page]] +http://www.example.com/page +http://www.example.com/page +" diff --git a/wicked/lib/Text_Wiki/tests/Latex_Render_Url.phpt b/wicked/lib/Text_Wiki/tests/Latex_Render_Url.phpt new file mode 100644 index 00000000000..199856addd0 --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/Latex_Render_Url.phpt @@ -0,0 +1,20 @@ +--TEST-- +Text_Wiki_Latex_Render_Url +--FILE-- +transform(' +[http://www.example.com/page An example page] +http://www.example.com/page +', 'Latex'); +?> +--EXPECT-- +\documentclass{article} +\usepackage{ulem} +\pagestyle{headings} +\begin{document} + +An example page\footnote{http://www.example.com/page} +http://www.example.com/page\footnote{http://www.example.com/page} +\end{document} diff --git a/wicked/lib/Text_Wiki/tests/Plain_Render_Url.phpt b/wicked/lib/Text_Wiki/tests/Plain_Render_Url.phpt new file mode 100644 index 00000000000..0205608a7fa --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/Plain_Render_Url.phpt @@ -0,0 +1,15 @@ +--TEST-- +Text_Wiki_Plain_Render_Url +--FILE-- +transform(' +[http://www.example.com/page An example page] +http://www.example.com/page +', 'Plain'); +?> +--EXPECT-- + +An example page +http://www.example.com/page diff --git a/wicked/lib/Text_Wiki/tests/Text_Wiki_BugTests.php b/wicked/lib/Text_Wiki/tests/Text_Wiki_BugTests.php new file mode 100644 index 00000000000..94c49cfe4b5 --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/Text_Wiki_BugTests.php @@ -0,0 +1,56 @@ +wiki = Text_Wiki::factory('Default'); + } + + protected function tearDown() + { + unset($this->wiki); + } + + /** + * @see http://pear.php.net/bugs/bug.php?id=18289 + */ + public function test18289() + { + $text = <<wiki->transform($text); + + // strip all whitespace to make assertEquals() easier + $html = preg_replace('/\s+/','',$html); + + $assertion = '
  • level1
    • level2
  • '; + $assertion .= '
  • level1
    • level2
'; + $this->assertEquals($assertion, $html); + } + + /** + * parsing fails ("blank page") for large data. Let's make sure it works. + * + * @uses fixtures/bug11649.txt + * @see http://pear.php.net/bugs/bug11649 + */ + public function testbug11649() + { + $data = file_get_contents(dirname(__FILE__) . '/fixtures/bug11649.txt'); + $html = $this->wiki->transform($data); + $this->assertTrue(is_string($html)); + } +} diff --git a/wicked/lib/Text_Wiki/tests/Text_Wiki_Generic_Transform_Tests.php b/wicked/lib/Text_Wiki/tests/Text_Wiki_Generic_Transform_Tests.php new file mode 100644 index 00000000000..32ef4220339 --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/Text_Wiki_Generic_Transform_Tests.php @@ -0,0 +1,36 @@ +parseConf['Wikilink']['spaceUnderscore'] = false; + $source = file_get_contents(dirname(__FILE__) . '/fixtures/test_mediawiki_to_tiki_source.txt'); + $expectedResult = file_get_contents(dirname(__FILE__) . '/fixtures/test_mediawiki_to_tiki_output.txt'); + $this->assertEquals($expectedResult, $obj->transform($source, 'Tiki')); + } + + public function testTransformFromMediawikiToTikiListSyntax() + { + $obj = Text_Wiki::factory('Mediawiki'); + $obj->parseConf['Wikilink']['spaceUnderscore'] = false; + $source = file_get_contents(dirname(__FILE__) . '/fixtures/test_mediawiki_to_tiki_lists_source.txt'); + $expectedResult = file_get_contents(dirname(__FILE__) . '/fixtures/test_mediawiki_to_tiki_lists_output.txt'); + $this->assertEquals($expectedResult, $obj->transform($source, 'Tiki')); + } + + public function testTransformFromMediawikiToTikiRedirectSyntax() + { + $obj = Text_Wiki::factory('Mediawiki'); + $obj->parseConf['Wikilink']['spaceUnderscore'] = false; + $source = file_get_contents(dirname(__FILE__) . '/fixtures/test_mediawiki_to_tiki_redirect_source.txt'); + $expectedResult = file_get_contents(dirname(__FILE__) . '/fixtures/test_mediawiki_to_tiki_redirect_output.txt'); + $this->assertEquals($expectedResult, $obj->transform($source, 'Tiki')); + } +} diff --git a/wicked/lib/Text_Wiki/tests/Text_Wiki_Parse_Mediawiki_Tests.php b/wicked/lib/Text_Wiki/tests/Text_Wiki_Parse_Mediawiki_Tests.php new file mode 100644 index 00000000000..16420e63264 --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/Text_Wiki_Parse_Mediawiki_Tests.php @@ -0,0 +1,765 @@ +addTestSuite('Text_Wiki_Parse_Mediawiki_Break_Test'); + /*$suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Code_Test'); + $suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Comment_Test');*/ + $suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Deflist_Test'); + $suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Emphasis_Test'); + $suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Heading_Test'); + $suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Horiz_Test'); + $suite->addTestSuite('Text_Wiki_Parse_Mediawiki_List_Test'); + //$suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Newline_Test'); + $suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Preformatted_Test'); + $suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Raw_Test'); + $suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Redirect_Test'); + /*$suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Subscript_Test'); + $suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Superscript_Test');*/ + $suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Table_Test'); + //$suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Tt_Test'); + $suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Url_Test'); + $suite->addTestSuite('Text_Wiki_Parse_Mediawiki_Wikilink_Test'); + + return $suite; + } + +} + +class Text_Wiki_Parse_Mediawiki_SetUp_Tests extends PHPUnit_Framework_TestCase +{ + + protected function setUp() + { + $obj = Text_Wiki::factory('Mediawiki'); + $testClassName = get_class($this); + $ruleName = preg_replace('/Text_Wiki_Parse_Mediawiki_(.+?)_Test/', '\\1', $testClassName); + $this->className = 'Text_Wiki_Parse_' . $ruleName; + $this->t = new $this->className($obj); + + if (file_exists(dirname(__FILE__) . '/fixtures/mediawiki_syntax_to_test_' . strtolower($ruleName) . '.txt')) { + $this->fixture = file_get_contents(dirname(__FILE__) . '/fixtures/mediawiki_syntax_to_test_' . strtolower($ruleName) . '.txt'); + } else { + $this->fixture = file_get_contents(dirname(__FILE__) . '/fixtures/mediawiki_syntax.txt'); + } + + preg_match_all($this->t->regex, $this->fixture, $this->matches); + } + +} + +class Text_Wiki_Parse_Mediawiki_Break_Test extends Text_Wiki_Parse_Mediawiki_SetUp_Tests +{ + + public function testMediawikiParseBreakProcess() + { + $matches1 = array(0 => '
'); + $matches2 = array(0 => '
'); + + $this->assertRegExp('/\d+?/', $this->t->process($matches1)); + $this->assertRegExp('/\d+?/', $this->t->process($matches2)); + + $tokens = array(0 => array(0 => 'Break', 1 => array()), + 1 => array(0 => 'Break', 1 => array())); + + $this->assertEquals(array_values($tokens), array_values($this->t->wiki->tokens)); + } + + public function testMediawikiParseBreakRegex() + { + $expectedResult = array(0 => array(0 => '
', 1 => '
')); + $this->assertEquals($expectedResult, $this->matches); + } + +} + +class Text_Wiki_Parse_Mediawiki_Deflist_Test extends Text_Wiki_Parse_Mediawiki_SetUp_Tests +{ + + public function testMediawikiParseDeflistProcess() + { + $matches1 = array( + 0 => "\n;Definition lists\n;item : definition\n;semicolon plus term\n:colon plus definition\n", + 1 => ";Definition lists\n;item : definition\n;semicolon plus term\n:colon plus definition\n", + ); + + $this->assertRegExp("/\d+?\d+?Definition lists\d+?\d+?item\d+?\d+?definition\d+?\d+?semicolon plus term\d+?\d+?colon plus definition\d+?\d+?/", $this->t->process($matches1)); + + $tokens = array( + 2 => array(0 => 'Deflist', 1 => array('type' => 'list_start', 'level' => 0)), + 3 => array(0 => 'Deflist', 1 => array('type' => 'term_start', 'level' => 1, 'count' => 0, 'first' => true)), + 4 => array(0 => 'Deflist', 1 => array('type' => 'term_end', 'level' => 1, 'count' => 0)), + 5 => array(0 => 'Deflist', 1 => array('type' => 'term_start', 'level' => 1, 'count' => 1, 'first' => false)), + 6 => array(0 => 'Deflist', 1 => array('type' => 'term_end', 'level' => 1, 'count' => 1)), + 7 => array(0 => 'Deflist', 1 => array('type' => 'narr_start', 'level' => 1, 'count' => 2, 'first' => false)), + 8 => array(0 => 'Deflist', 1 => array('type' => 'narr_end', 'level' => 1, 'count' => 2)), + 9 => array(0 => 'Deflist', 1 => array('type' => 'term_start', 'level' => 1, 'count' => 3, 'first' => false)), + 10 => array(0 => 'Deflist', 1 => array('type' => 'term_end', 'level' => 1, 'count' => 3)), + 11 => array(0 => 'Deflist', 1 => array('type' => 'narr_start', 'level' => 1, 'count' => 4, 'first' => false)), + 12 => array(0 => 'Deflist', 1 => array('type' => 'narr_end', 'level' => 1, 'count' => 4)), + 13 => array(0 => 'Deflist', 1 => array('type' => 'list_end', 'level' => 0)) + ); + + $this->assertEquals(array_values($tokens), array_values($this->t->wiki->tokens)); + } + + public function testMediawikiParseDeflistRegex() + { + $expectedResult = array( + 0 => array( + 0 => " +;Definition lists +;item : definition +;semicolon plus term +:colon plus definition +", + ), + 1 => array( + 0 => ";Definition lists +;item : definition +;semicolon plus term +:colon plus definition +", + ), + ); + $this->assertEquals($expectedResult, $this->matches); + } + +} + + +class Text_Wiki_Parse_Mediawiki_Emphasis_Test extends PHPUnit_Framework_TestCase +{ + + public function testMediawikiParseEmphasisParse() + { + $obj = $this->getMock('Text_Wiki_Parse_Emphasis', array('process'), array(), 'Text_Wiki_Parse_Emphasis_Parse_Mock', false); + $obj->wiki = $this->getMock('Text_Wiki'); + $obj->wiki->source = file_get_contents(dirname(__FILE__) . '/fixtures/mediawiki_syntax.txt'); + + $lines = explode("\n", $obj->wiki->source); + $i = count($lines); + $obj->expects($this->exactly($i))->method('process'); + + $obj->parse(); + } + + public function testMediawikiParseEmphasisProcess() + { + $textwiki = Text_Wiki::factory('Mediawiki'); + $obj = new Text_Wiki_Parse_Emphasis($textwiki); + + $lines = array( + "'''Bold text''' and ''italic text'' and even '''''bold italic text'''''", + "'''Bold text''' and ''italic text'' and even '''''bold italic text''''' some text '''bold then ''italic'' then bold''' more text ''italic then '''bold''' then italic again'' some text '''''bold and italic'''''", + "'''''bold and italic''' and italic''", + "''italic and '''bold and italic'''''" + ); + + foreach ($lines as $line) { + $obj->process($line); + } + + $expectedResult = array( + 14 => array(0 => 'Strong', 1 => array('type' => 'start')), + 15 => array(0 => 'Strong', 1 => array('type' => 'end')), + 16 => array(0 => 'Emphasis', 1 => array('type' => 'start')), + 17 => array(0 => 'Emphasis', 1 => array('type' => 'end')), + 18 => array(0 => 'Emphasis', 1 => array('type' => 'start')), + 19 => array(0 => 'Strong', 1 => array('type' => 'start')), + 20 => array(0 => 'Strong',1 => array('type' => 'end')), + 21 => array(0 => 'Emphasis', 1 => array('type' => 'end')), + 22 => array(0 => 'Strong', 1 => array('type' => 'start')), + 23 => array(0 => 'Strong', 1 => array('type' => 'end')), + 24 => array(0 => 'Emphasis', 1 => array('type' => 'start')), + 25 => array(0 => 'Emphasis', 1 => array('type' => 'end')), + 26 => array(0 => 'Emphasis', 1 => array('type' => 'start')), + 27 => array(0 => 'Strong', 1 => array('type' => 'start')), + 28 => array(0 => 'Strong', 1 => array('type' => 'end')), + 29 => array(0 => 'Emphasis', 1 => array('type' => 'end')), + 30 => array(0 => 'Strong', 1 => array('type' => 'start')), + 31 => array(0 => 'Emphasis', 1 => array('type' => 'start')), + 32 => array(0 => 'Emphasis', 1 => array('type' => 'end')), + 33 => array(0 => 'Strong', 1 => array('type' => 'end')), + 34 => array(0 => 'Emphasis', 1 => array('type' => 'start')), + 35 => array(0 => 'Strong', 1 => array('type' => 'start')), + 36 => array(0 => 'Strong', 1 => array('type' => 'end')), + 37 => array(0 => 'Emphasis', 1 => array('type' => 'end')), + 38 => array(0 => 'Emphasis', 1 => array('type' => 'start')), + 39 => array(0 => 'Strong', 1 => array('type' => 'start')), + 40 => array(0 => 'Strong', 1 => array('type' => 'end')), + 41 => array(0 => 'Emphasis', 1 => array('type' => 'end')), + 42 => array(0 => 'Emphasis', 1 => array('type' => 'start')), + 43 => array(0 => 'Strong', 1 => array('type' => 'start')), + 44 => array(0 => 'Strong', 1 => array('type' => 'end')), + 45 => array(0 => 'Emphasis', 1 => array('type' => 'end')), + 46 => array(0 => 'Emphasis', 1 => array('type' => 'start')), + 47 => array(0 => 'Strong', 1 => array('type' => 'start')), + 48 => array(0 => 'Strong', 1 => array('type' => 'end')), + 49 => array(0 => 'Emphasis', 1 => array('type' => 'end')), + ); + + $this->assertEquals(array_values($expectedResult), array_values($obj->wiki->tokens)); + } + +} + +class Text_Wiki_Parse_Mediawiki_Heading_Test extends Text_Wiki_Parse_Mediawiki_SetUp_Tests +{ + + public function testMediawikiParseHeadingProcess() + { + $matches1 = array(0 => "======Level 6 heading======", 1 => '======', 2 => 'Level 6 heading'); + $matches2 = array(0 => "=Level 1 heading=", 1 => '=', 2 => 'Level 1 heading'); + $matches3 = array(0 => "==Level 2 heading==", 1 => '==', 2 => 'Level 2 heading'); + + $this->assertRegExp("/\d+?Level 6 heading\d+?\n/", $this->t->process($matches1)); + $this->assertRegExp("/\d+?Level 1 heading\d+?\n/", $this->t->process($matches2)); + $this->assertRegExp("/\d+?Level 2 heading\d+?\n/", $this->t->process($matches3)); + + $tokens = array( + 0 => array(0 => 'Heading', 1 => array('type' => 'start', 'level' => 6, 'text' => 'Level 6 heading', 'id' => 'toc0')), + 1 => array(0 => 'Heading', 1 => array('type' => 'end', 'level' => 6)), + 2 => array(0 => 'Heading', 1 => array('type' => 'start', 'level' => 1, 'text' => 'Level 1 heading', 'id' => 'toc1')), + 3 => array(0 => 'Heading', 1 => array('type' => 'end', 'level' => 1)), + 4 => array(0 => 'Heading', 1 => array('type' => 'start', 'level' => 2, 'text' => 'Level 2 heading', 'id' => 'toc2')), + 5 => array(0 => 'Heading', 1 => array('type' => 'end', 'level' => 2)) + ); + + $this->assertEquals(array_values($tokens), array_values($this->t->wiki->tokens)); + } + + public function testMediawikiParseHeadingRegex() + { + $expectedResult = array( + 0 => array(0 => "=Level 1 heading=", 1 => "==Level 2 heading==", 2 => "==Level 2 heading==", 3 => "===Level 3 heading===", 4 => "====Level 4 heading====", 5 => "===Level 3 heading===", 6 => "===Level 3 heading===", 7 => "=====Level 5 heading=====", 8 => "======Level 6 heading======"), + 1 => array(0 => '=', 1 => '==', 2 => '==', 3 => '===', 4 => '====', 5 => '===', 6 => '===', 7 => '=====', 8 => '======'), + 2 => array(0 => 'Level 1 heading', 1 => 'Level 2 heading', 2 => 'Level 2 heading', 3 => 'Level 3 heading', 4 => 'Level 4 heading', 5 => 'Level 3 heading', 6 => 'Level 3 heading', 7 => 'Level 5 heading', 8 => 'Level 6 heading') + ); + $this->assertEquals($expectedResult, $this->matches); + } + +} + +// Mediawiki parse uses horiz rule from default parser +class Text_Wiki_Parse_Mediawiki_Horiz_Test extends Text_Wiki_Parse_Mediawiki_SetUp_Tests +{ + + public function testMediawikiParseHorizProcess() + { + $matches1 = array(0 => '----', 1 => '----'); + $matches2 = array(0 => '------', 1 => '------'); + + $this->assertRegExp("/\d+?/", $this->t->process($matches1)); + $this->assertRegExp("/\d+?/", $this->t->process($matches2)); + + $tokens = array( + 0 => array(0 => 'Horiz', array()), + 1 => array(0 => 'Horiz', array()), + ); + + $this->assertEquals(array_values($tokens), array_values($this->t->wiki->tokens)); + } + + public function testMediawikiParseHeadingRegex() + { + $expectedResult = array( + 0 => array(0 => '----', 1 => '------'), + 1 => array(0 => '----', 1 => '------'), + ); + $this->assertEquals($expectedResult, $this->matches); + } + +} + +class Text_Wiki_Parse_Mediawiki_List_Test extends Text_Wiki_Parse_Mediawiki_SetUp_Tests +{ + + public function testMediawikiParseListProcess() + { + $matches1 = array( + 1 => " +* List example +** List example +**# List example +**# List example +*** List example +**** List example +** List example +", + 2 => "* List example +** List example +**# List example +**# List example +*** List example +**** List example +** List example +" + ); + + $this->assertRegExp("/\d+?\d+? List example\d+?\d+?\d+? List example\d+?\d+?\d+? List example\d+?\d+? List example\d+?\d+? List example\d+?\d+?\d+? List example\d+?\d+?\d+?\d+? List example\d+?\d+?\d+?/", $this->t->process($matches1)); + + $tokens = array( + 432 => array(0 => 'List', 1 => array('type' => 'bullet_list_start', 'level' => 1)), + 433 => array(0 => 'List', 1 => array('type' => 'bullet_item_start', 'level' => 1, 'count' => 0, 'first' => true)), + 434 => array(0 => 'List', 1 => array('type' => 'bullet_item_end', 'level' => 1, 'count' => 0)), + 435 => array(0 => 'List', 1 => array('type' => 'bullet_list_start', 'level' => 2)), + 436 => array(0 => 'List', 1 => array('type' => 'bullet_item_start', 'level' => 2, 'count' => 0, 'first' => false)), + 437 => array(0 => 'List', 1 => array('type' => 'bullet_item_end', 'level' => 2, 'count' => 0)), + 438 => array(0 => 'List', 1 => array('type' => 'number_list_start', 'level' => 3)), + 439 => array(0 => 'List', 1 => array('type' => 'number_item_start', 'level' => 3, 'count' => 0, 'first' => false)), + 440 => array(0 => 'List', 1 => array('type' => 'number_item_end', 'level' => 3, 'count' => 0)), + 441 => array(0 => 'List', 1 => array('type' => 'number_item_start', 'level' => 3, 'count' => 1, 'first' => false)), + 442 => array(0 => 'List', 1 => array('type' => 'number_item_end', 'level' => 3, 'count' => 1)), + 443 => array(0 => 'List', 1 => array('type' => 'bullet_item_start', 'level' => 3, 'count' => 2, 'first' => false)), + 444 => array(0 => 'List', 1 => array('type' => 'bullet_item_end', 'level' => 3, 'count' => 2)), + 445 => array(0 => 'List', 1 => array('type' => 'bullet_list_start', 'level' => 4)), + 446 => array(0 => 'List', 1 => array('type' => 'bullet_item_start', 'level' => 4, 'count' => 0, 'first' => false)), + 447 => array(0 => 'List', 1 => array('type' => 'bullet_item_end', 'level' => 4, 'count' => 0)), + 448 => array(0 => 'List', 1 => array('type' => 'bullet_list_end', 'level' => 3)), + 449 => array(0 => 'List', 1 => array('type' => 'number_list_end', 'level' => 2)), + 450 => array(0 => 'List', 1 => array('type' => 'bullet_item_start', 'level' => 2, 'count' => 1, 'first' => false)), + 451 => array(0 => 'List', 1 => array('type' => 'bullet_item_end', 'level' => 2, 'count' => 1)), + 452 => array(0 => 'List', 1 => array('type' => 'bullet_list_end', 'level' => 1)), + 453 => array(0 => 'List', 1 => array('type' => 'bullet_list_end', 'level' => 0)), + ); + + $this->assertEquals(array_values($tokens), array_values($this->t->wiki->tokens)); + } + + public function testMediawikiParseListRegex() + { + $expectedResult = array( + 0 => array( + 0 => " +* List +* List +** List +** List +*** List +* List +* List +", + 1 => " +# List +# List +## List +## List +### List +# List +# List +", + 2 => " +* List example +** List example +**# List example +**# List example +*** List example +**** List example +*# List example +*# List example +** List example +* List example +** List example +** List example +**# List example +", + ), + 1 => array( + 0 => "* List +* List +** List +** List +*** List +* List +* List +", + 1 => "# List +# List +## List +## List +### List +# List +# List +", + 2 => "* List example +** List example +**# List example +**# List example +*** List example +**** List example +*# List example +*# List example +** List example +* List example +** List example +** List example +**# List example +" + ) + ); + + $this->assertEquals($expectedResult, $this->matches); + } + +} + +class Text_Wiki_Parse_Mediawiki_Preformatted_Test extends Text_Wiki_Parse_Mediawiki_SetUp_Tests +{ + + public function testMediawikiParsePreformattedProcess() + { + $matches1 = array(0 => "
pre tag without line break
", 1 => 'pre tag without line break'); + // not sure why Text_Wiki_Parse_Preformatted uses $matches[2] + $matches2 = array(0 => "
pre tag without line break
", 1 => 'pre tag without line break', 2 => 'some text'); + + $this->assertRegExp("/\d+?/", $this->t->process($matches1)); + $this->assertRegExp("/\d+?/", $this->t->process($matches2)); + + $tokens = array( + 0 => array(0 => 'Preformatted', 1 => array('text' => 'pre tag without line break')), + 1 => array(0 => 'Preformatted', 1 => array('text' => 'some text')) + ); + + $this->assertEquals(array_values($tokens), array_values($this->t->wiki->tokens)); + } + + public function testMediawikiParsePreformattedRegex() + { + $expectedResult = array( + 0 => array( + 0 => "
+The pre tag ignores [[Wiki]] ''markup''.
+It also doesn't     reformat text.
+It still interprets special characters:
+ &rarr;
+
", + 1 => "
pre tag without line break
", + 2 => "
some ''text'' without '''wiki''' parsing
" + ), + 1 => array( + 0 => "The pre tag ignores [[Wiki]] ''markup''. +It also doesn't reformat text. +It still interprets special characters: + &rarr;", + 1 => "pre tag without line break", + 2 => "some ''text'' without '''wiki''' parsing", + ), + 2 => array(0 => '', 1 => '', 2 => '') + ); + + $this->assertEquals($expectedResult, $this->matches); + } + +} + +class Text_Wiki_Parse_Mediawiki_Raw_Test extends Text_Wiki_Parse_Mediawiki_SetUp_Tests +{ + + public function testMediawikiParseRawProcess() + { + $matches1 = array(0 => "nowiki tag without break line", 1 => 'nowiki tag without line break'); + + $this->assertRegExp("/\d+?/", $this->t->process($matches1)); + + $tokens = array( + 0 => array(0 => 'Raw', 1 => array('text' => 'nowiki tag without line break')), + ); + + $this->assertEquals(array_values($tokens), array_values($this->t->wiki->tokens)); + } + + public function testMediawikiParseRawRegex() + { + $expectedResult = array( + 0 => array( + 0 => " +The nowiki tag ignores [[Wiki]] ''markup''. +It reformats text by removing newlines +and multiple spaces. +It still interprets special +characters: → +", + 1 => "''ignores markup''", + ), + 1 => array( + 0 => "The nowiki tag ignores [[Wiki]] ''markup''. +It reformats text by removing newlines +and multiple spaces. +It still interprets special +characters: →", + 1 => "''ignores markup''", + ) + ); + + $this->assertEquals($expectedResult, $this->matches); + } + +} + +class Text_Wiki_Parse_Mediawiki_Redirect_Test extends Text_Wiki_Parse_Mediawiki_SetUp_Tests +{ + + public function testMediawikiParseRedirectProcess() + { + $matches1 = array(0 => "#REDIRECT [[Some page name]]", 1 => 'Some page name'); + $matches2 = array(0 => "#redirect [[Other page name]]", 1 => 'Other page name'); + + $this->assertRegExp("/\d+?Some page name\d+?/", $this->t->process($matches1)); + $this->assertRegExp("/\d+?Other page name\d+?/", $this->t->process($matches2)); + + $tokens = array( + 0 => array(0 => 'Redirect', 1 => array('type' => 'start', 'text' => 'Some page name')), + 1 => array(0 => 'Redirect', 1 => array('type' => 'end')), + 2 => array(0 => 'Redirect', 1 => array('type' => 'start', 'text' => 'Other page name')), + 3 => array(0 => 'Redirect', 1 => array('type' => 'end')), + ); + + $this->assertEquals(array_values($tokens), array_values($this->t->wiki->tokens)); + } + + public function testMediawikiParseRedirectRegex() + { + $expectedResult = array( + 0 => array(0 => "#REDIRECT [[Some page name]]", 1 => "#redirect [[Other page name]]"), + 1 => array(0 => 'Some page name', 1 => 'Other page name'), + ); + $this->assertEquals($expectedResult, $this->matches); + } + +} + +class Text_Wiki_Parse_Mediawiki_Table_Test extends Text_Wiki_Parse_Mediawiki_SetUp_Tests +{ + + public function testMediawikiParseTableProcess() + { + + $matches = array( + 0 => '{| +| A || B +|- +| C || D +|}', + 1 => ' +', + 2 => '', + 3 => '| A || B +|- +| C || D +' + ); + + $this->assertRegExp("/\d+?\d+?\d+? A \d+?\d+? B\d+?\d+?\d+?\d+? C \d+?\d+? D \d+?\d+?\d+?/", $this->t->process($matches)); + + $tokens = array( + 487 => array(0 => 'Table', 1 => array('type' => 'cell_start', 'attr' => '', 'span' => 1, 'rowspan' => 1, 'order' => 0)), + 488 => array(0 => 'Table', 1 => array('type' => 'cell_end', 'attr' => '', 'span' => 1, 'rowspan' => 1, 'order' => 0)), + 489 => array(0 => 'Table', 1 => array('type' => 'cell_start', 'attr' => '', 'span' => 1, 'rowspan' => 1, 'order' => 1)), + 490 => array(0 => 'Table', 1 => array('type' => 'cell_end', 'attr' => '', 'span' => 1, 'rowspan' => 1, 'order' => 1)), + 491 => array(0 => 'Table', 1 => array('type' => 'row_start', 'order' => 0, 'cols' => 2)), + 492 => array(0 => 'Table', 1 => array('type' => 'row_end', 'order' => 0, 'cols' => 2)), + 493 => array(0 => 'Table', 1 => array('type' => 'cell_start', 'attr' => '', 'span' => 1, 'rowspan' => 1, 'order' => 0)), + 494 => array(0 => 'Table', 1 => array('type' => 'cell_end', 'attr' => '', 'span' => 1, 'rowspan' => 1, 'order' => 0)), + 495 => array(0 => 'Table', 1 => array('type' => 'cell_start', 'attr' => '', 'span' => 1, 'rowspan' => 1, 'order' => 1)), + 496 => array(0 => 'Table', 1 => array('type' => 'cell_end', 'attr' => '', 'span' => 1, 'rowspan' => 1, 'order' => 1)), + 497 => array(0 => 'Table', 1 => array('type' => 'row_start', 'order' => 1, 'cols' => 2)), + 498 => array(0 => 'Table', 1 => array('type' => 'row_end', 'order' => 1, 'cols' => 2)), + 499 => array(0 => 'Table', 1 => array('type' => 'table_start', 'level' => 0, 'rows' => 2, 'cols' => 2)), + 500 => array(0 => 'Table', 1 => array('type' => 'table_end', 'level' => 0, 'rows' => 2, 'cols' => 2)) + ); + + $this->assertEquals(array_values($tokens), array_values($this->t->wiki->tokens)); + } + + public function testMediawikiParseTableRegex() + { + + $expectedResult = array( + 0 => array( + 0 => "{| +| A || B +|- +| C || D +|}", + ), + 1 => array(0 => " \n"), + 2 => array(0 => ''), + 3 => array( + 0 => "| A || B +|- +| C || D +" + ), + 4 => array( + 0 => '' + ) + ); + + $this->assertEquals($expectedResult, $this->matches); + } + +} + + +class Text_Wiki_Parse_Mediawiki_Wikilink_Test extends Text_Wiki_Parse_Mediawiki_SetUp_Tests +{ + + public function testMediawikiParseWikilinkProcessWithSpaceUnderscoreFalse() + { + $this->t->conf['spaceUnderscore'] = false; + + $matches1 = array(0 => '[[convallis elementum]]', 1 => '', 2 => '', 3 => 'convallis elementum', 4 => '', 5 => '', 6 => ''); + $matches2 = array(0 => '[[Etiam]]', 1 => '', 2 => '', 3 => 'Etiam', 4 => '', 5 => '', 6 => ''); + $matches3 = array(0 => '[[pt:Language link]]', 1 => '', 2 => 'pt:', 3 => 'Language link', 4 => '', 5 => '', 6 => ''); + $matches4 = array(0 => '[[Image:some image]]', 1 => '', 2 => 'Image:', 3 => 'some image', 4 => '', 5 => '', 6 => ''); + $matches5 = array(0 => '[[Etiam|description text]]', 1 => '', 2 => '', 3 => 'Etiam', 4 => '', 5 => 'description text', 6 => ''); + + $this->assertRegExp("/\d+?/", $this->t->process($matches1)); + $this->assertRegExp("/\d+?/", $this->t->process($matches2)); + $this->assertRegExp("/\d+?/", $this->t->process($matches3)); + $this->assertRegExp("/\d+?/", $this->t->process($matches4)); + $this->assertRegExp("/\d+?/", $this->t->process($matches5)); + + $tokens = array( + 0 => array(0 => 'Wikilink', 1 => array('page' => 'convallis elementum', 'anchor' => '', 'text' => 'convallis elementum')), + 1 => array(0 => 'Wikilink', 1 => array('page' => 'Etiam', 'anchor' => '', 'text' => 'Etiam')), + 2 => array(0 => 'Wikilink', 1 => array('page' => 'pt:Language link', 'anchor' => '', 'text' => 'pt:Language link')), + 3 => array(0 => 'Image', 1 => array('src' => 'some image', 'attr' => array('alt' => 'some image'))), + 4 => array(0 => 'Wikilink', 1 => array('page' => 'Etiam', 'anchor' => '', 'text' => 'description text')), + ); + + $this->assertEquals(array_values($tokens), array_values($this->t->wiki->tokens)); + } + + public function testMediawikiParseWikilinkProcessWithSpaceUnderscoreTrue() + { + $this->t->conf['spaceUnderscore'] = true; + + $matches1 = array(0 => '[[convallis elementum]]', 1 => '', 2 => '', 3 => 'convallis elementum', 4 => '', 5 => '', 6 => ''); + + $this->assertRegExp("/\d+?/", $this->t->process($matches1)); + + $tokens = array( + 0 => array(0 => 'Wikilink', 1 => array('page' => 'convallis_elementum', 'anchor' => '', 'text' => 'convallis elementum')), + ); + + $this->assertEquals(array_values($tokens), array_values($this->t->wiki->tokens)); + } + + public function testMediawikiParseWikilinkRegex() + { + require_once(dirname(__FILE__) . '/fixtures/test_mediawiki_wikilink_expected_matches.php'); + global $expectedWikilinkMatches; + $fixture = file_get_contents(dirname(__FILE__) . '/fixtures/mediawiki_syntax_to_test_wikilink.txt'); + preg_match_all($this->t->regex, $fixture, $matches); + + $this->assertEquals($expectedWikilinkMatches, $matches); + } + +} + +class Text_Wiki_Parse_Mediawiki_Url_Test extends PHPUnit_Framework_TestCase +{ + + protected function setUp() + { + $textWiki = new Text_Wiki('Mediawiki'); + $this->obj = new Text_Wiki_Parse_Url($textWiki); + } + + public function testMediawikiParseUrlParse() + { + // for some weird reason I was unable to mock this class calling the constructor that is why to + // test the regular expression I'm testing the tokens created (instead of testing many times each process function was called) + $this->obj->wiki->source = file_get_contents(dirname(__FILE__) . '/fixtures/mediawiki_syntax.txt'); + $this->obj->parse(); + + $tokens = array( + 1 => array(0 => 'Url', 1 => array('type' => 'descr', 'href' => 'http://www.example.com', 'text' => 'See the example site')), + 2 => array(0 => 'Url', 1 => array('type' => 'descr', 'href' => 'http://exemple.com/index.php', 'text' => 'consectetur adipiscing')), + 3 => array(0 => 'Url', 1 => array('type' => 'descr', 'href' => 'http://exemple.com/index.php#anchor', 'text' => 'Pellentesque')), + 4 => array(0 => 'Url', 1 => array('type' => 'descr', 'href' => 'http://www.somelink.com/index.php', 'text' => 'http://www.somelink.com/index.php')), + 5 => array(0 => 'Url', 1 => array('type' => 'inline', 'href' => 'http://example.com/index.php', 'text' => 'http://example.com/index.php')) + ); + + $this->assertEquals(array_values($tokens), array_values($this->obj->wiki->tokens)); + } + +/* public function testMediawikiParseUrlParseWithMocking() + { + // NOT WORKING: unable to mock the class Text_Wiki_Parse_Url using its constructor + $textWiki = Text_Wiki::factory('Mediawiki'); + $obj = $this->getMock('Text_Wiki_Parse_Url', + array('process', 'processWithoutProtocol', 'processInlineEmail', 'processFootnote', 'processOrdinary', 'processDescr'), + array($textWiki), + ); + $obj->expects($this->once())->method('process'); + $obj->expects($this->never())->method('processWithoutProtocol'); + $obj->expects($this->never())->method('processInlineEmail'); + $obj->expects($this->never())->method('processFootnote'); + $obj->expects($this->exactly(2))->method('processOrdinary'); + $obj->expects($this->exactly(5))->method('processDescr'); + $obj->wiki->source = file_get_contents(dirname(__FILE__) . '/fixtures/mediawiki_syntax.txt'); + $obj->parse(); + }*/ + + public function testProcess() + { + $this->markTestIncomplete('Test incomplete'); + } + + public function testProcessWithoutProtocol() + { + $this->markTestIncomplete('Test incomplete'); + } + + public function testProcessInlineEmail() + { + $this->markTestIncomplete('Test incomplete'); + } + + public function testProcessFootnote() + { + $this->markTestIncomplete('Test incomplete'); + } + + public function testProcessOrdinary() + { + $this->markTestIncomplete('Test incomplete'); + } + + public function testProcessDescr() + { + $this->markTestIncomplete('Test incomplete'); + } +} + +?> diff --git a/wicked/lib/Text_Wiki/tests/Text_Wiki_Parse_Tiki_Tests.php b/wicked/lib/Text_Wiki/tests/Text_Wiki_Parse_Tiki_Tests.php new file mode 100644 index 00000000000..7a268250097 --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/Text_Wiki_Parse_Tiki_Tests.php @@ -0,0 +1,127 @@ +addTestSuite('Text_Wiki_Parse_Tiki_Heading_Test'); + + return $suite; + } + +} + +class Text_Wiki_Parse_Tiki_SetUp_Tests extends PHPUnit_Framework_TestCase +{ + + protected function setUp() + { + $obj = Text_Wiki::factory('Tiki'); + $testClassName = get_class($this); + $ruleName = preg_replace('/Text_Wiki_Parse_Tiki_(.+?)_Test/', '\\1', $testClassName); + $this->className = 'Text_Wiki_Parse_' . $ruleName; + $this->t = new $this->className($obj); + + if (file_exists(dirname(__FILE__) . '/fixtures/tiki_syntax_to_test_' . strtolower($ruleName) . '.txt')) { + $this->fixture = file_get_contents(dirname(__FILE__) . '/fixtures/tiki_syntax_to_test_' . strtolower($ruleName) . '.txt'); + } else { + $this->fixture = file_get_contents(dirname(__FILE__) . '/fixtures/tiki_syntax.txt'); + } + + preg_match_all($this->t->regex, $this->fixture, $this->matches); + } + +} + +class Text_Wiki_Parse_Tiki_Heading_Test extends Text_Wiki_Parse_Tiki_SetUp_Tests +{ + + public function testTikiParseHeadingProcess() + { + $matches1 = array( + 0 => " +!! Heading 2 + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae est sit amet metus consequat scelerisque at accumsan dolor. Quisque posuere, mauris a fermentum sagittis, sem quam blandit tortor, vitae ullamcorper nulla velit placerat lacus. Nullam rutrum quam id est convallis luctus. Vivamus et urna odio. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut at augue eget elit feugiat pretium. + ", + 1 => "\n", + 2 => "!!", + 3 => "", + 4 => " Heading 2", + 5 => " + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae est sit amet metus consequat scelerisque at accumsan dolor. Quisque posuere, mauris a fermentum sagittis, sem quam blandit tortor, vitae ullamcorper nulla velit placerat lacus. Nullam rutrum quam id est convallis luctus. Vivamus et urna odio. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut at augue eget elit feugiat pretium. +" + ); + + $this->assertRegExp("/\n\d+? Heading 2\d+?\d+?$matches1[5]\d+?/", $this->t->process($matches1)); + + $tokens = array( + 0 => array(0 => 'Heading', 1 => array('type' => 'start', 'level' => 2, 'text' => ' Heading 2', 'id' => 'toc0', 'collapse' => '')), + 1 => array(0 => 'Heading', 1 => array('type' => 'end', 'text' => ' Heading 2', 'level' => 2, 'collapse' => '', 'id' => 'toc0')), + 2 => array(0 => 'Heading', 1 => array('type' => 'startContent', 'id' => 'toc0', 'level' => 2, 'collapse' => '', 'text' => ' Heading 2')), + 3 => array(0 => 'Heading', 1 => array('type' => 'endContent', 'collapse' => '', 'level' => 2, 'id' => 'toc0', 'text' => ' Heading 2')) + ); + + $this->assertEquals(array_values($tokens), array_values($this->t->wiki->tokens)); + } + + public function testMediawikiParseHeadingRegex() + { + require_once dirname(__FILE__) . '/fixtures/test_tiki_heading_expected_matches.php'; + global $expectedHeadingMatches; + + $this->assertEquals($expectedHeadingMatches, $this->matches); + } + +} + +?> diff --git a/wicked/lib/Text_Wiki/tests/Text_Wiki_Render_Tests.php b/wicked/lib/Text_Wiki/tests/Text_Wiki_Render_Tests.php new file mode 100644 index 00000000000..7ff3a868234 --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/Text_Wiki_Render_Tests.php @@ -0,0 +1,98 @@ +obj = new Text_Wiki_Render($obj); + + $this->conf = array('firstConf' => 'firstConfValue', + 'secondConf' => 'secondConfValue', + 'thirdConf' => 'thirdConfValue', + 'img_ext' => array('jpg', 'jpeg', 'gif', 'png'), + 'css_table' => 'className', + ); + } + + public function testTextWikiRenderConstructor() + { + /* It is hard to test directly the constructor of the class Text_Wiki_Render as it + * internally has logic expecting a child class name (to define the $this->rule and + * $this->format variables). That is why we are creating an instance of + * Text_Wiki_Render_Xhtml and Text_Wiki_Render_Xhtml_Address instead. If you have a + * better idea feel free to improve this test + */ + $wiki = Text_Wiki::singleton(); + + $obj = new Text_Wiki_Render_Xhtml($wiki); + $this->assertEquals($wiki, $obj->wiki, 'Should set reference to Text_Wiki object'); + $this->assertEquals('Xhtml', $obj->format); + $this->assertNull($obj->rule); + $this->assertEquals(array('translate' => 1, 'quotes' => 2, 'charset' => 'ISO-8859-1'), $obj->conf); + + $obj = new Text_Wiki_Render_Xhtml_Address($wiki); + $this->assertEquals($wiki, $obj->wiki, 'Should set reference to Text_Wiki object'); + $this->assertEquals('Xhtml', $obj->format); + $this->assertEquals('Address', $obj->rule); + $this->assertEquals(array('css' => null), $obj->conf); + } + + public function testGetConfShouldReturnConfValue() + { + $this->obj->conf = $this->conf; + + foreach ($this->conf as $key => $value) { + $this->assertEquals($value, $this->obj->getConf($key)); + $this->assertEquals($value, $this->obj->getConf($key, 'DefaultValue')); + } + } + + public function testGetConfShouldReturnDefaultValue() + { + $this->obj->conf = $this->conf; + $this->assertEquals('DefaultValue', $this->obj->getConf('InvalidKey', 'DefaultValue')); + } + + public function testFormatConfShouldReturnSprinfFormatedValue() + { + $this->obj->conf = $this->conf; + foreach ($this->conf as $key => $value) { + $this->assertEquals(" class=\"$value\"", $this->obj->formatConf(' class="%s"', $key)); + } + } + + public function testFormatConfShouldReturnNull() + { + $this->obj->conf = $this->conf; + $this->assertNull($this->obj->formatConf(' class="%s"', 'InvalidKey')); + $this->assertNull($this->obj->formatConf(' class="%s"', null)); + } + + public function testUrlEncode() + { + $texts = array('ftp://user:foo @+%/@ftp.example.com/x.txt' => 'ftp%3A%2F%2Fuser%3Afoo%20%40%2B%25%2F%40ftp.example.com%2Fx.txt', + 'http://example.com/department_list_script/sales and marketing/Miami' => 'http%3A%2F%2Fexample.com%2Fdepartment_list_script%2Fsales%20and%20marketing%2FMiami' + ); + foreach ($texts as $inputString => $outputString) { + $this->assertEquals($outputString, $this->obj->urlEncode($inputString)); + } + } + + public function testTextEncode() + { + // need more strings to test + $text = "Test"; + $this->assertEquals("<a href='test'>Test</a>", $this->obj->textEncode($text)); + } + +} + +?> diff --git a/wicked/lib/Text_Wiki/tests/Text_Wiki_Render_Tiki_Tests.php b/wicked/lib/Text_Wiki/tests/Text_Wiki_Render_Tiki_Tests.php new file mode 100644 index 00000000000..6c05381147e --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/Text_Wiki_Render_Tiki_Tests.php @@ -0,0 +1,728 @@ +addTestSuite('Text_Wiki_Render_Tiki_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Anchor_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Blockquote_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Bold_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Box_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Break_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Center_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Code_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Colortext_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Deflist_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Delimiter_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Embed_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Emphasis_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Freelink_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Function_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Heading_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Horiz_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Html_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Image_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Include_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Interwiki_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Italic_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_List_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Newline_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Paragraph_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Phplookup_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Prefilter_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Preformatted_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Raw_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Redirect_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Revise_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Strong_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Subscript_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Superscript_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Table_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Tighten_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Toc_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Tt_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Underline_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Url_Test'); + $suite->addTestSuite('Text_Wiki_Render_Tiki_Wikilink_Test'); + + return $suite; + } + +} + +class Text_Wiki_Render_Tiki_Test extends PHPUnit_Framework_TestCase +{ + + protected function setUp() + { + $obj = Text_Wiki::singleton('Tiki'); + $this->t = new Text_Wiki_Render_Tiki($obj); + } + + public function testTikiRenderPre() + { + $this->assertEquals('', $this->t->pre()); + } + + public function testTikiRenderPost() + { + $this->assertEquals('', $this->t->post()); + } + +} + +class Text_Wiki_Render_Tiki_SetUp_Tests extends PHPUnit_Framework_TestCase +{ + + protected function setUp() + { + $obj = Text_Wiki::singleton('Tiki'); + $testClassName = get_class($this); + $ruleName = preg_replace('/Text_Wiki_Render_Tiki_(.+?)_Test/', '\\1', $testClassName); + $className = 'Text_Wiki_Render_Tiki_' . $ruleName; + $this->t = new $className($obj); + } + +} + +class Text_Wiki_Render_Tiki_Anchor_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderAnchor() + { + $options = array('type' => 'start', 'name' => 'Page name'); + $this->assertEquals('((Page name', $this->t->token($options)); + $options = array('type' => 'end'); + $this->assertEquals('))', $this->t->token($options)); + } + +} + +class Text_Wiki_Render_Tiki_Blockquote_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderBlockquote() + { + $this->markTestIncomplete('check if Text_Wiki_Render_Tiki_Blockquote output a valid Tiki syntax.'); + } + +} + +class Text_Wiki_Render_Tiki_Bold_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderBold() + { + $options = array(); + $this->assertEquals('__', $this->t->token($options)); + } + +} + +class Text_Wiki_Render_Tiki_Box_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderBox() + { + $options = array('type' => 'start'); + $this->assertEquals('^', $this->t->token($options)); + $options = array('type' => 'end'); + $this->assertEquals('^', $this->t->token($options)); + } + +} + +class Text_Wiki_Render_Tiki_Break_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderBreak() + { + $options = array(); + $this->assertEquals("\n", $this->t->token($options)); + } + +} + +class Text_Wiki_Render_Tiki_Center_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderCenter() + { + $options = array('type' => 'start'); + $this->assertEquals('::', $this->t->token($options)); + $options = array('type' => 'end'); + $this->assertEquals('::', $this->t->token($options)); + } + +} + + +class Text_Wiki_Render_Tiki_Code_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderCode() + { + $options = array('text' => 'Some code text as a sample'); + $this->assertEquals("{CODE()}\nSome code text as a sample\n{CODE}", $this->t->token($options)); + $options = array('text' => 'Some code text as a sample', 'attr' => array('type' => '')); + $this->assertEquals("{CODE()}\nSome code text as a sample\n{CODE}", $this->t->token($options)); + $options = array('text' => 'Some code text as a sample', 'attr' => array('type' => 'php')); + $this->assertEquals("{CODE(colors=>php)}\nSome code text as a sample\n{CODE}", $this->t->token($options)); + } + +} + +class Text_Wiki_Render_Tiki_Colortext_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderColortext() + { + $options = array('type' => 'start', 'color' => 'red'); + $this->assertEquals('~~red:', $this->t->token($options)); + $options = array('type' => 'start', 'color' => 'FFFFFF'); + $this->assertEquals('~~#FFFFFF:', $this->t->token($options)); + $options = array('type' => 'end'); + $this->assertEquals('~~', $this->t->token($options)); + } + +} + +class Text_Wiki_Render_Tiki_Deflist_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderDeflist() + { + $options = array('type' => 'list_start'); + $this->assertEquals("{DL()}\n", $this->t->token($options)); + $options = array('type' => 'list_end'); + $this->assertEquals("{DL}\n\n", $this->t->token($options)); + $options = array('type' => 'term_start'); + $this->assertEquals('', $this->t->token($options)); + $options = array('type' => 'term_end'); + $this->assertEquals(': ', $this->t->token($options)); + $options = array('type' => 'narr_start'); + $this->assertEquals('', $this->t->token($options)); + $options = array('type' => 'narr_end'); + $this->assertEquals("\n", $this->t->token($options)); + + // test definition item without definition narrative + $this->t->token(array('type' => 'term_end')); + $this->assertEquals('term_end', $this->t->last); + $options = array('type' => 'term_start'); + $this->assertEquals("\n", $this->t->token($options)); + $this->assertEquals('term_start', $this->t->last); + + // test default swicth behavior + $options = array('type' => 'InvalidType'); + $this->assertEquals('', $this->t->token($options)); + } + +} + +class Text_Wiki_Render_Tiki_Delimiter_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderDelimiter() + { + $options = array('text' => 'Sample text'); + $this->assertEquals('Sample text', $this->t->token($options)); + } + +} + +class Text_Wiki_Render_Tiki_Embed_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderEmbed() + { + $options = array('text' => 'Sample text'); + $this->assertEquals('Sample text', $this->t->token($options)); + } + +} + +class Text_Wiki_Render_Tiki_Emphasis_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderEmphasis() + { + $options = array(); + $this->assertEquals("''", $this->t->token($options)); + } + +} + +class Text_Wiki_Render_Tiki_Freelink_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderFreelink() + { + $options = array('type' => 'start', 'page' => 'Sample page', 'text' => 'Sample text'); + $this->assertEquals('((Sample page|', $this->t->token($options)); + $options = array('type' => 'end'); + $this->assertEquals('))', $this->t->token($options)); + $options = array('page' => 'Sample page', 'text' => 'Sample text'); + $this->assertEquals('((Sample page|Sample text))', $this->t->token($options)); + } + +} + +class Text_Wiki_Render_Tiki_Function_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderFunction() + { + $this->markTestIncomplete('This test has not been implemented yet.'); + } + +} + +class Text_Wiki_Render_Tiki_Heading_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderHeading() + { + $options = array('type' => 'start', 'level' => 1); + $this->assertEquals("!", $this->t->token($options)); + $options = array('type' => 'start', 'level' => 2); + $this->assertEquals("!!", $this->t->token($options)); + $options = array('type' => 'start', 'level' => 6); + $this->assertEquals("!!!!!!", $this->t->token($options)); + $options = array('type' => 'end'); + $this->assertEquals("\n", $this->t->token($options)); + } + +} + +class Text_Wiki_Render_Tiki_Horiz_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderHoriz() + { + $options = array(); + $this->assertEquals("\n---\n", $this->t->token($options)); + } + +} + +class Text_Wiki_Render_Tiki_Html_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderHtml() + { + $this->markTestIncomplete('This test has not been implemented yet.'); + } + +} + +class Text_Wiki_Render_Tiki_Image_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderImage() + { + $options = array('src' => 'src/image.jpg'); + $this->assertEquals('{img src="img/wiki_up/src/image.jpg"}', $this->t->token($options)); + $options = array('src' => 'src/image.jpg', 'attr' => array()); + $this->assertEquals('{img src="img/wiki_up/src/image.jpg"}', $this->t->token($options)); + $options = array('src' => 'src/image.jpg', 'attr' => array('width' => 600, 'height' => 500)); + $this->assertEquals('{img src="img/wiki_up/src/image.jpg" width="600" height="500"}', $this->t->token($options)); + + $this->t->conf = array('prefix' => 'different/path/'); + $options = array('src' => 'image.jpg'); + $this->assertEquals('{img src="different/path/image.jpg"}', $this->t->token($options)); + } + +} + +class Text_Wiki_Render_Tiki_Include_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderInclude() + { + $this->markTestIncomplete('This test has not been implemented yet.'); + } + +} + +class Text_Wiki_Render_Tiki_Interwiki_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderInterwiki() + { + $this->markTestIncomplete('Check if Text_Wiki_Render_Tiki_Interwiki output a valid Tiki syntax.'); + $options = array('site' => 'doc.tikiwiki.org', 'page' => 'WikiSyntax'); + $this->assertEquals('((doc.tikiwiki.org:WikiSyntax))', $this->t->token($options)); + $options = array('site' => 'doc.tikiwiki.org', 'page' => 'WikiSyntax', 'text' => 'Page WikiSyntax from doc.tikiwiki.org'); + $this->assertEquals('((doc.tikiwiki.org:WikiSyntax|Page WikiSyntax from doc.tikiwiki.org))', $this->t->token($options)); + } + +} + +class Text_Wiki_Render_Tiki_Italic_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderItalic() + { + $options = array(); + $this->assertEquals("''", $this->t->token($options)); + } + +} + +class Text_Wiki_Render_Tiki_List_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderNumberItemStart() + { + $options = array('type' => 'number_item_start', 'level' => 1); + $this->assertEquals("#", $this->t->token($options)); + $options = array('type' => 'number_item_start', 'level' => 3); + $this->assertEquals("###", $this->t->token($options)); + } + + public function testTikiRenderBulletItemStart() + { + $options = array('type' => 'bullet_item_start', 'level' => 1); + $this->assertEquals("*", $this->t->token($options)); + $options = array('type' => 'bullet_item_start', 'level' => 3); + $this->assertEquals("***", $this->t->token($options)); + } + + public function testTikiRenderBulletAndNumberedListEnd() + { + $options = array('type' => 'bullet_list_end', 'level' => 0); + $this->assertEquals("\n", $this->t->token($options)); + $options = array('type' => 'number_list_end', 'level' => 0); + $this->assertEquals("\n", $this->t->token($options)); + $options = array('type' => 'bullet_list_end', 'level' => 1); + $this->assertEquals("", $this->t->token($options)); + $options = array('type' => 'number_list_end', 'level' => 1); + $this->assertEquals("", $this->t->token($options)); + } + + public function testTikiRenderBulletAndNumberedListStart() + { + $options = array('type' => 'bullet_list_start'); + $this->assertEquals("", $this->t->token($options)); + $options = array('type' => 'number_list_start'); + $this->assertEquals("", $this->t->token($options)); + } + + public function testTikiRenderBullerAndNumberedItemEnd() + { + $options = array('type' => 'bullet_item_end'); + $this->assertEquals("\n", $this->t->token($options)); + $options = array('type' => 'number_item_end'); + $this->assertEquals("\n", $this->t->token($options)); + } + +} + +class Text_Wiki_Render_Tiki_Newline_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderNewline() + { + $options = array(); + $this->assertEquals("\n", $this->t->token($options)); + } + +} + +class Text_Wiki_Render_Tiki_Paragraph_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderParagraph() + { + $options = array('type' => 'start'); + $this->assertEquals('', $this->t->token($options)); + $options = array('type' => 'end'); + $this->assertEquals("\n\n", $this->t->token($options)); + } + +} + +class Text_Wiki_Render_Tiki_Phplookup_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderPhplookup() + { + $this->markTestIncomplete('This test has not been implemented yet.'); + } + +} + +class Text_Wiki_Render_Tiki_Prefilter_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderPrefilter() + { + $this->markTestIncomplete('This test has not been implemented yet.'); + } + +} + +class Text_Wiki_Render_Tiki_Preformatted_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderPreformatted() + { + $options = array('text' => 'Some preformatted text'); + $this->assertEquals('~pp~Some preformatted text~/pp~', $this->t->token($options)); + } + +} + +class Text_Wiki_Render_Tiki_Raw_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderRaw() + { + $options = array('text' => 'Some raw text'); + $this->assertEquals('~np~Some raw text~/np~', $this->t->token($options)); + } + +} + +class Text_Wiki_Render_Tiki_Redirect_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderRedirect() + { + $options = array('type' => 'start', 'text' => 'Some wiki link'); + $this->assertEquals('{redirect page="', $this->t->token($options)); + + $options = array('type' => 'end'); + $this->assertEquals('"}', $this->t->token($options)); + } + +} + +class Text_Wiki_Render_Tiki_Revise_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderRevise() + { + $this->markTestIncomplete('Check if Text_Wiki_Render_Tiki_Revise output a valid Tiki syntax.'); + } + +} + +class Text_Wiki_Render_Tiki_Strong_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderStrong() + { + $options = array(); + $this->assertEquals('__', $this->t->token($options)); + } + +} + +class Text_Wiki_Render_Tiki_Subscript_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderSubscript() + { + $this->markTestIncomplete('Check if Text_Wiki_Render_Tiki_Subscript output a valid Tiki syntax.'); + } + +} + +class Text_Wiki_Render_Tiki_Superscript_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderSuperscript() + { + $this->markTestIncomplete('Check if Text_Wiki_Render_Tiki_Superscript output a valid Tiki syntax.'); + } + +} + +class Text_Wiki_Render_Tiki_Table_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderTable() + { + /* test cases that doesn't depend on the static variable $last */ + $options = array('type' => 'table_start'); + $this->assertEquals('||', $this->t->token($options)); + + $options = array('type' => 'table_end'); + $this->assertEquals('||', $this->t->token($options)); + + $options = array('type' => 'row_end'); + $this->assertEquals('', $this->t->token($options)); + + $options = array('type' => 'cell_end', 'span' => 1); + $this->assertEquals('', $this->t->token($options)); + + $options = array('type' => 'cell_end', 'span' => 4); + $this->assertEquals(' | | | ', $this->t->token($options)); + + $options = array('type' => 'cell_end'); + $this->assertEquals('', $this->t->token($options)); + } + + public function testTikiRenderTableDependLastVariable() + { + /* test cases that depend on the static variable $last. we run token() + with a different type first to set the appropiate $last value and then + we run it again we the desirable assert value */ + $options = array('type' => 'table_start'); + $this->t->token($options); + $options = array('type' => 'row_start'); + $this->assertEquals('', $this->t->token($options)); + + + $options = array('type' => 'cell_end'); + $this->t->token($options); + $options = array('type' => 'cell_start'); + $this->assertEquals(' | ', $this->t->token($options)); + } + +} + +class Text_Wiki_Render_Tiki_Tighten_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderTighten() + { + $options = array(); + $this->assertEquals('', $this->t->token($options)); + } + +} + +class Text_Wiki_Render_Tiki_Toc_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderToc() + { + $options = array(); + $this->assertEquals("\n{maketoc}\n", $this->t->token($options)); + } + +} + +class Text_Wiki_Render_Tiki_tt_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRendertt() + { + $this->markTestIncomplete('Check if Text_Wiki_Render_Tiki_tt output a valid Tiki syntax.'); + } + +} + +class Text_Wiki_Render_Tiki_Underline_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderUnderline() + { + $options = array(); + $this->assertEquals('===', $this->t->token($options)); + } + +} + +class Text_Wiki_Render_Tiki_Url_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderUrlMultiToken() + { + $options = array('type' => 'start', 'href' => 'http://example.com'); + $this->assertEquals('[http://example.com', $this->t->token($options)); + $options = array('type' => 'start', 'href' => 'http://example.com', 'text' => 'http://example.com'); + $this->assertEquals('[http://example.com', $this->t->token($options)); + $options = array('type' => 'start', 'href' => 'http://example.com', 'text' => 'Sample text'); + $this->assertEquals('[http://example.com|', $this->t->token($options)); + $options = array('type' => 'end'); + $this->assertEquals(']', $this->t->token($options)); + } + + public function testTikiRenderUrlSingleToken() + { + $options = array('href' => 'http://example.com'); + $this->assertEquals('[http://example.com]', $this->t->token($options)); + $options = array( 'href' => 'http://example.com', 'text' => 'http://example.com'); + $this->assertEquals('[http://example.com]', $this->t->token($options)); + $options = array( 'href' => 'http://example.com', 'text' => 'Sample text'); + $this->assertEquals('[http://example.com|Sample text]', $this->t->token($options)); + } + +} + +class Text_Wiki_Render_Tiki_Wikilink_Test extends Text_Wiki_Render_Tiki_SetUp_Tests +{ + + public function testTikiRenderWikilinkMultiToken() + { + $options = array('type' => 'start', 'page' => 'Sample page', 'text' => 'Sample text'); + $this->assertEquals('((Sample page|', $this->t->token($options)); + $options = array('type' => 'start', 'page' => 'Sample page', 'text' => 'Sample page'); + $this->assertEquals('((Sample page|', $this->t->token($options)); + $options = array('type' => 'end'); + $this->assertEquals('))', $this->t->token($options)); + } + + public function testTikiRenderWikilinkSingleToken() + { + $options = array('page' => 'Sample page'); + $this->assertEquals('((Sample page))', $this->t->token($options)); + $options = array('page' => 'Sample page', 'text' => 'Sample text'); + $this->assertEquals('((Sample page|Sample text))', $this->t->token($options)); + $options = array('page' => 'Sample page', 'text' => 'Sample page'); + $this->assertEquals('((Sample page))', $this->t->token($options)); + } + +} + +?> diff --git a/wicked/lib/Text_Wiki/tests/Text_Wiki_Tests.php b/wicked/lib/Text_Wiki/tests/Text_Wiki_Tests.php new file mode 100644 index 00000000000..fdead08572e --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/Text_Wiki_Tests.php @@ -0,0 +1,505 @@ +obj = Text_Wiki::factory(); + + $this->obj->renderConf = array(); + $this->obj->parseConf = array(); + $this->obj->formatConf = array(); + $this->obj->rules = array('Prefilter', 'Delimiter', 'Code', 'Function', 'Html', 'Raw', 'Include'); + $this->obj->disable = array('Html', 'Include', 'Embed'); + $this->obj->path = array('parse' => array(), 'render' => array()); + + $this->sourceText = 'A very \'\'simple\'\' \'\'\'source\'\'\' text. Not sure [[how]] to [http://example.com improve] the transform() tests.' . "\n"; + $this->tokens = array( + 0 => array(0 => 'Heading', 1 => array('type' => 'start', 'level' => 6, 'text' => 'Level 6 heading', 'id' => 'toc0')), + 1 => array(0 => 'Heading', 1 => array('type' => 'end', 'level' => 6)), + 2 => array(0 => 'Heading', 1 => array('type' => 'start', 'level' => 1, 'text' => 'Level 1 heading', 'id' => 'toc1')), + 3 => array(0 => 'Heading', 1 => array('type' => 'end', 'level' => 1)), + 4 => array(0 => 'Heading', 1 => array('type' => 'start', 'level' => 2, 'text' => 'Level 2 heading', 'id' => 'toc2')), + 5 => array(0 => 'Heading', 1 => array('type' => 'end', 'level' => 2)), + 6 => array(0 => 'Break', 1 => array()), + 7 => array(0 => 'Break', 1 => array()) + ); + $this->_countRulesTokens = array('Heading' => 6, 'Break' => 2); + } + + public function testSingletonOfSameParserShouldReturnSameObject() + { + $obj1 = Text_Wiki::singleton(); + $obj2 = Text_Wiki::singleton(); + $this->assertEquals(spl_object_hash($obj1), spl_object_hash($obj2)); + } + + public function testSingletonOfDifferentParserShouldReturnDifferentObject() + { + $obj1 = Text_Wiki::singleton('Tiki'); + $obj2 = Text_Wiki::singleton(); + $this->assertNotEquals(spl_object_hash($obj1), spl_object_hash($obj2)); + } + + public function testFactoryReturnDefaultParserInstance() + { + $obj = Text_Wiki::factory(); + $this->assertTrue(is_a($obj, 'Text_Wiki_Default')); + } + + public function testFactoryRestrictRulesUniverse() + { + $rules = array('Heading', 'Bold', 'Italic', 'Paragraph'); + $obj = Text_Wiki::factory('Default', $rules); + $this->assertEquals($rules, $obj->rules); + } + + public function testTokenIdForMultipleParsingDontCollideWithDifferentObjects() + { + $sampleText = file_get_contents(dirname(__FILE__) . '/fixtures/text_wiki_sample_mediawiki_syntax.txt'); + $sampleTextTransformed2Xhtml = file_get_contents(dirname(__FILE__) . '/fixtures/text_wiki_sample_syntax_transformed_to_xhtml.txt'); + $sampleTextTransformed2Plain = file_get_contents(dirname(__FILE__) . '/fixtures/text_wiki_sample_syntax_transformed_to_plain.txt'); + $sampleTextTransformed2Plain2 = file_get_contents(dirname(__FILE__) . '/fixtures/text_wiki_sample_syntax_transformed_to_plain2.txt'); + $obj1 = Text_Wiki::factory('Mediawiki'); + $this->assertEquals($sampleTextTransformed2Xhtml, $obj1->transform($sampleText, 'Xhtml')); + $obj2 = Text_Wiki::factory('Mediawiki'); + $this->assertEquals($sampleTextTransformed2Plain, $obj2->transform($sampleText, 'Plain')); + $obj3 = Text_Wiki::factory('Tiki'); + $this->assertEquals($sampleTextTransformed2Plain2, $obj3->transform($sampleText, 'Plain')); + } + + public function testTokenIdForMultipleParsingDontCollideWithSameObjects() + { + $sampleText = file_get_contents(dirname(__FILE__) . '/fixtures/text_wiki_sample_mediawiki_syntax.txt'); + $sampleTextTransformed2Xhtml = file_get_contents(dirname(__FILE__) . '/fixtures/text_wiki_sample_syntax_transformed_to_xhtml.txt'); + $sampleTextTransformed2Plain = file_get_contents(dirname(__FILE__) . '/fixtures/text_wiki_sample_syntax_transformed_to_plain.txt'); + $sampleTextTransformed2Plain2 = file_get_contents(dirname(__FILE__) . '/fixtures/text_wiki_sample_syntax_transformed_to_plain2.txt'); + $obj1 = Text_Wiki::singleton('Mediawiki'); + $this->assertEquals($sampleTextTransformed2Xhtml, $obj1->transform($sampleText, 'Xhtml')); + $obj2 = Text_Wiki::singleton('Mediawiki'); + $this->assertEquals($sampleTextTransformed2Plain, $obj2->transform($sampleText, 'Plain')); + $obj3 = Text_Wiki::singleton('Tiki'); + $this->assertEquals($sampleTextTransformed2Plain2, $obj3->transform($sampleText, 'Plain')); + } + + public function testSetParseConf() + { + $expectedResult = array('Center' => array('css' => 'center')); + $this->obj->setParseConf('center', 'css', 'center'); + $this->assertEquals($expectedResult, $this->obj->parseConf); + + $this->obj->parseConf = array(); + $expectedResult = array('Center' => array('css' => 'center')); + $this->obj->setParseConf('center', array('css' => 'center')); + $this->assertEquals($expectedResult, $this->obj->parseConf); + } + + public function testGetParseConf() + { + $this->obj->parseConf = array('Include' => array('base' => '/path/to/scripts/', + 'anotherKey' => 'anotherValue'), + 'Secondrule' => array('base' => '/other/path/')); + + $this->assertEquals(array('base' => '/other/path/'), $this->obj->getParseConf('Secondrule')); + $this->assertEquals('/path/to/scripts/', $this->obj->getParseConf('include', 'base')); + $this->assertNull($this->obj->getParseConf('inexistentRule', 'inexistentKey')); + } + + public function testSetRenderConf() + { + $this->obj->setRenderConf('xhtml', 'center', 'css', 'center'); + $expectedResult = array('Center' => array('css' => 'center')); + $this->assertEquals($expectedResult, $this->obj->renderConf['Xhtml']); + + $this->obj->setRenderConf('xhtml', 'center', 'secondConfig', 'secondConfigValue'); + $expectedResult = array('Center' => array('css' => 'center', 'secondConfig' => 'secondConfigValue')); + $this->assertEquals($expectedResult, $this->obj->renderConf['Xhtml']); + + $arg = array('firstConfig' => 'firstConfigValue', 'secondConfig' => 'diferentValue'); + $this->obj->setRenderConf('xhtml', 'newrule', $arg); + $expectedResult = array_merge($expectedResult, array('Newrule' => $arg)); + $this->assertEquals($expectedResult, $this->obj->renderConf['Xhtml']); + } + + public function testGetRenderConfReturnRule() + { + $this->obj->renderConf['Xhtml'] = array('Center' => array('css' => 'center', 'align' => 'left')); + $this->assertEquals(array('css' => 'center', 'align' => 'left'), $this->obj->getRenderConf('Xhtml', 'Center')); + } + + public function testGetRenderConfReturnEspecifKeyRule() + { + $this->obj->renderConf['Xhtml'] = array('Center' => array('css' => 'center', 'align' => 'left')); + $this->assertEquals('center', $this->obj->getRenderConf('Xhtml', 'Center', 'css')); + } + + public function testGetRenderConfReturnFalseForInvalidFormatOrConfOrKey() + { + $this->obj->renderConf['Xhtml'] = array('Center' => array('css' => 'center', 'align' => 'left')); + $this->assertNull($this->obj->getRenderConf('InvalidFormat', 'InvalidRule', 'InvalidKey')); + $this->assertNull($this->obj->getRenderConf('Xhtml', 'InvalidRule')); + $this->assertNull($this->obj->getRenderConf('Xhtml', 'Center', 'InvalidKey')); + } + + public function testSetFormatConfWithThreeArguments() + { + $expectedResult = array('Xhtml' => array('css' => 'center')); + $this->obj->setFormatConf('Xhtml', 'css', 'center'); + $this->assertEquals($expectedResult, $this->obj->formatConf); + } + + public function testSetFormatConfWithTwoArguments() + { + $expectedResult = array('Xhtml' => array('css' => 'center')); + $this->obj->setFormatConf('Xhtml', array('css' => 'center')); + $this->assertEquals($expectedResult, $this->obj->formatConf); + } + + public function testGetFormatConf() + { + $this->obj->formatConf = array('Xhtml' => array('base' => '/path/to/scripts/', + 'anotherKey' => 'anotherValue'), + 'Docbook' => array('base' => '/other/path/')); + + $this->assertEquals(array('base' => '/other/path/'), $this->obj->getFormatConf('Docbook')); + $this->assertEquals('/path/to/scripts/', $this->obj->getFormatConf('Xhtml', 'base')); + $this->assertNull($this->obj->getFormatConf('inexistentFormat')); + } + + public function testInsertRuleShouldReturnNullIfRuleAlreadyExist() + { + $this->assertNull($this->obj->insertRule('Code', 'Prefilter')); + } + + public function testInsertRuleShouldReturnNullIfInexistentRuleToInsertAfter() + { + $this->assertNull($this->obj->insertRule('Code', 'InexistentRule')); + } + + public function testInsertRuleShouldInsertRuleAtTheEnd() + { + $return = $this->obj->insertRule('NewRule'); + $this->assertTrue($return); + $this->assertEquals('Newrule', end($this->obj->rules)); + } + + public function testInsertRuleShouldInsertRuleAtTheBeginning() + { + $return = $this->obj->insertRule('NewRule', ''); + $this->assertTrue($return); + $this->assertEquals('Newrule', $this->obj->rules[0]); + } + + public function testInsertRuleShouldInsertRuleInExactPlace() + { + $key = array_search('Function', $this->obj->rules); + $return = $this->obj->insertRule('NewRule', 'Function'); + $this->assertTrue($return); + $this->assertEquals('Newrule', $this->obj->rules[$key+1]); + } + + public function testDeleteRule() + { + $rules = array(0 => 'Prefilter', 1 => 'Delimiter', 2 => 'Code', 3 => 'Function', 5 => 'Raw', 6 => 'Include'); + $this->obj->deleteRule('Html'); + $this->assertEquals($rules, $this->obj->rules); + + $rules = array(0 => 'Prefilter', 2 => 'Code', 3 => 'Function', 5 => 'Raw', 6 => 'Include'); + $this->obj->deleteRule('Delimiter'); + $this->assertEquals($rules, $this->obj->rules); + } + + public function testChangeRule() + { + $rules = array('Prefilter', 'Delimiter', 'Code', 'Function', 'Html', 'Newrulename', 'Include'); + $this->obj->changeRule('Raw', 'NewRuleName'); + $this->assertEquals($rules, $this->obj->rules); + + // should delete the 'Function' rule and rename 'Code' rule to 'Function' + $rules = array(0 => 'Prefilter', 1 => 'Delimiter', 2 => 'Function', 4 => 'Html', 5 => 'Newrulename', 6 => 'Include'); + $this->obj->changeRule('Code', 'Function'); + $this->assertEquals($rules, $this->obj->rules); + + // no changes as inexistent old rule name + $this->obj->changeRule('InexistentRule', 'NewRule'); + $this->assertEquals($rules, $this->obj->rules); + } + + public function testEnableRule() + { + $this->obj->enableRule('Include'); + $disable = array(0 => 'Html', 2 => 'Embed'); + $this->assertEquals($disable, $this->obj->disable); + $this->obj->enableRule('InvalidRule'); + $this->assertEquals($disable, $this->obj->disable); + } + + public function testDisableRule() + { + $this->obj->disableRule('Newrule'); + $disable = array(0 => 'Html', 1 => 'Include', 2 => 'Embed', 3 => 'Newrule'); + $this->assertEquals($disable, $this->obj->disable); + + // nothing change as rule is already marked as disabled + $this->obj->disableRule('Include'); + $this->assertEquals($disable, $this->obj->disable); + } + + public function testTransform() + { + $obj = Text_Wiki::factory('Mediawiki'); + $expectedResult = 'A very \'\'simple\'\' __source__ text. Not sure ((how)) to [http://example.com|improve] the transform() tests.' . "\n\n"; + $this->assertEquals($expectedResult, $obj->transform($this->sourceText, 'Tiki')); + } + + public function testParse() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + public function testParseShouldSetSourceProperty() + { + $this->obj->parse($this->sourceText); + // TODO: check why there is a line break at the beginning and end of $this->obj->source + $this->assertEquals("\n".$this->sourceText."\n", $this->obj->source); + } + + public function testRender() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + public function testRenderShouldReturnErrorIfInvalidFormat() + { + $result = $this->obj->render('InvalidFormat'); + $this->assertTrue(is_a($result, 'PEAR_Error')); + } + + public function test_renderToken() + { + // $matches = array(0 => '0', 1 => 0); + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + public function testRegisterRenderCallback() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + public function testPopRenderCallback() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + public function testGetSource() + { + $this->obj->source = $this->sourceText; + $this->assertEquals($this->sourceText, $this->obj->getSource()); + } + + public function testGetTokens() + { + $breakTokens = array_slice($this->tokens, 6, 2, true); + + $this->obj->tokens = $this->tokens; + $this->assertEquals($this->tokens, $this->obj->getTokens()); + $this->assertEquals($breakTokens, $this->obj->getTokens('Break')); + } + + public function testAddTokenReturnIdOnly() + { + $options = array('type' => 'someType', 'anotherOption' => 'value'); + $id = $this->obj->addToken('Test', $options, true); + $this->assertEquals(0, $id); + } + + public function testAddTokenReturnTokenNumberWithDelimiters() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + public function testSetTokenShouldChangeOptionsOfAlreadyExistingRuleAndKeepName() + { + $this->obj->tokens = $this->tokens; + $this->obj->_countRulesTokens = $this->_countRulesTokens; + + $tokens = array( + 0 => array(0 => 'Heading', 1 => array('type' => 'start', 'level' => 6, 'text' => 'Level 6 heading', 'id' => 'toc0')), + 1 => array(0 => 'Heading', 1 => array('type' => 'end', 'level' => 6)), + 2 => array(0 => 'Heading', 1 => array()), + 3 => array(0 => 'Heading', 1 => array('type' => 'end', 'level' => 1)), + 4 => array(0 => 'Heading', 1 => array('type' => 'start', 'level' => 2, 'text' => 'Level 2 heading', 'id' => 'toc2')), + 5 => array(0 => 'Heading', 1 => array('type' => 'end', 'level' => 2)), + 6 => array(0 => 'Break', 1 => array()), + 7 => array(0 => 'Break', 1 => array()) + ); + $this->obj->setToken(2, 'Heading', array()); + $this->assertEquals($tokens, $this->obj->tokens); + $this->assertEquals($this->_countRulesTokens, $this->obj->_countRulesTokens); + } + + public function testSetTokenShouldReplaceRuleWithNewRule() + { + $this->obj->tokens = $this->tokens; + $this->obj->_countRulesTokens = $this->_countRulesTokens; + + $tokens = array( + 0 => array(0 => 'Heading', 1 => array('type' => 'start', 'level' => 6, 'text' => 'Level 6 heading', 'id' => 'toc0')), + 1 => array(0 => 'Heading', 1 => array('type' => 'end', 'level' => 6)), + 2 => array(0 => 'Heading', 1 => array('type' => 'start', 'level' => 1, 'text' => 'Level 1 heading', 'id' => 'toc1')), + 3 => array(0 => 'Raw', 1 => array('type' => 'end')), + 4 => array(0 => 'Heading', 1 => array('type' => 'start', 'level' => 2, 'text' => 'Level 2 heading', 'id' => 'toc2')), + 5 => array(0 => 'Heading', 1 => array('type' => 'end', 'level' => 2)), + 6 => array(0 => 'Break', 1 => array()), + 7 => array(0 => 'Break', 1 => array()) + ); + $this->_countRulesTokens = array('Heading' => 5, 'Break' => 2, 'Raw' => 1); + $this->obj->setToken(3, 'Raw', array('type' => 'end')); + $this->assertEquals($tokens, $this->obj->tokens); + $this->assertEquals($this->_countRulesTokens, $this->obj->_countRulesTokens); + } + + public function testSetTokenShouldAddNewRule() + { + $this->obj->tokens = $this->tokens; + $this->obj->_countRulesTokens = $this->_countRulesTokens; + + $tokens = array( + 0 => array(0 => 'Heading', 1 => array('type' => 'start', 'level' => 6, 'text' => 'Level 6 heading', 'id' => 'toc0')), + 1 => array(0 => 'Heading', 1 => array('type' => 'end', 'level' => 6)), + 2 => array(0 => 'Heading', 1 => array('type' => 'start', 'level' => 1, 'text' => 'Level 1 heading', 'id' => 'toc1')), + 3 => array(0 => 'Heading', 1 => array('type' => 'end', 'level' => 1)), + 4 => array(0 => 'Heading', 1 => array('type' => 'start', 'level' => 2, 'text' => 'Level 2 heading', 'id' => 'toc2')), + 5 => array(0 => 'Heading', 1 => array('type' => 'end', 'level' => 2)), + 6 => array(0 => 'Break', 1 => array()), + 7 => array(0 => 'Break', 1 => array()), + 8 => array(0 => 'Raw', 1 => array('type' => 'end')), + ); + $this->_countRulesTokens = array('Heading' => 6, 'Break' => 2, 'Raw' => 1); + $this->obj->setToken(8, 'Raw', array('type' => 'end')); + $this->assertEquals($tokens, $this->obj->tokens); + $this->assertEquals($this->_countRulesTokens, $this->obj->_countRulesTokens); + } + + public function testLoadParseObj() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + public function testLoadRenderObj() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + public function testLoadFormatObj() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + public function testAddPathShouldAddDirToExistentType() + { + $path = array('parse' => array('Text/Wiki/Parse/Default/'), 'render' => array()); + $this->obj->addPath('parse', 'Text/Wiki/Parse/Default/'); + $this->assertEquals($path, $this->obj->path); + + // dir without trailing trailing slash + $path = array('parse' => array('Text/Wiki/Parse/Other/', 'Text/Wiki/Parse/Default/'), 'render' => array()); + $this->obj->addPath('parse', 'Text/Wiki/Parse/Other'); + $this->assertEquals($path, $this->obj->path); + } + + public function testAddPathCreateTypeAndThenAddDir() + { + $this->obj->path = array(); + $path = array('parse' => array('Text/Wiki/Parse/Default/')); + $this->obj->addPath('parse', 'Text/Wiki/Parse/Default/'); + $this->assertEquals($path, $this->obj->path); + } + + public function testGetPathShouldReturnPathArray() + { + $path = array('parse' => array('Text/Wiki/Parse/Default/', 'Text/Wiki/Parse/Other/'), 'render' => array('Text/Wiki/Parse/Xhtml/')); + $this->obj->path = $path; + $this->assertEquals($path, $this->obj->getPath()); + } + + public function testGetPathShouldReturnTypePaths() + { + $path = array('parse' => array('Text/Wiki/Parse/Default/', 'Text/Wiki/Parse/Other/'), 'render' => array('Text/Wiki/Parse/Xhtml/')); + $this->obj->path = $path; + $this->assertEquals($path['parse'], $this->obj->getPath('parse')); + $this->assertEquals($path['render'], $this->obj->getPath('render')); + } + + public function testGetPathShouldReturnEmptyArray() + { + $path = array('parse' => array('Text/Wiki/Parse/Default/', 'Text/Wiki/Parse/Other/'), 'render' => array('Text/Wiki/Parse/Xhtml/')); + $this->obj->path = $path; + $this->assertEquals(array(), $this->obj->getPath('InexistentType')); + } + + public function testFindFile() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + public function testFixPath() + { + $this->assertEquals('path/', $this->obj->fixPath('path')); + $this->assertEquals('/longer/path/path/', $this->obj->fixPath('/longer/path/path')); + $this->assertEquals('/longer/path/path/with/trailing/slash/', $this->obj->fixPath('/longer/path/path/with/trailing/slash/')); + $this->assertEquals('', $this->obj->fixPath('')); + } + + public function testError() + { + $errorObject = $this->obj->error('Some error message'); + $this->assertTrue(is_a($errorObject, 'PEAR_Error')); + $this->assertEquals('Some error message', $errorObject->message); + } + + public function testIsError() + { + + $this->assertTrue($this->obj->isError(PEAR::throwError('Some error message'))); + $notPearErrorObject = new Text_Wiki; + $this->assertFalse($this->obj->isError($notPearErrorObject)); + } + +} + +?> diff --git a/wicked/lib/Text_Wiki/tests/Xhtml_Render_Url.phpt b/wicked/lib/Text_Wiki/tests/Xhtml_Render_Url.phpt new file mode 100644 index 00000000000..f87fba8900e --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/Xhtml_Render_Url.phpt @@ -0,0 +1,15 @@ +--TEST-- +Text_Wiki_Xhtml_Render_Url +--FILE-- +setRenderConf('Xhtml', 'Url', 'target', ''); +print $t->transform(' +[http://www.example.com/page An example page] +http://www.example.com/page +', 'Xhtml'); +?> +--EXPECT-- +An example page +http://www.example.com/page diff --git a/wicked/lib/Text_Wiki/tests/fixtures/bug11649.txt b/wicked/lib/Text_Wiki/tests/fixtures/bug11649.txt new file mode 100644 index 00000000000..b35be4d9cb7 --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/fixtures/bug11649.txt @@ -0,0 +1,521 @@ +[[toc]] + ++ Configuring Turba to use the same fields as Outlook 2003 + +This document is intended to help Horde administrators create a more Outlook-like experience for their users by giving them the address book fields they are accustomed to. An export of an Outlook 2003 address book contains a number of fields not included in the Outlook UI. This document only covers the fields available in the Outlook UI. + +++ Modifying attributes.php + +//turba/config/attributes.php// is the file that defines which fields are available to turba, and what type of data they can hold. Make the following changes and additions to the default //attributes.php//. (**Note:** the //addresslink// type is only available in the CVS version of Horde/Turba. If you want to use this howto for the current stable Horde/Turba, use //address// instead. It's not as pretty, but it will do the job) + +Modify the //name// field to look like: + +$attributes['name'] = array( + 'label' => '', + 'type' => 'html', + 'required' => true +); + + +Modify the //lastname// field to look like: + +$attributes['lastname'] = array( + 'label' => _("Last Name"), + 'type' => 'text', + 'required' => false +); + + +Modify the //homeAddress// field to look like: + + $attributes['homeAddress'] = array( + 'label' => '', + 'type' => 'addresslink', + 'required' => false, +); + + +Modify the //workAddress// field to look like: + +$attributes['workAddress'] = array( + 'label' => '', + 'type' => 'addresslink', + 'required' => false, +); + + +Modify the //cellPhone// field to look like: + +$attributes['cellPhone'] = array( + 'label' => _("Mobile Phone"), + 'type' => 'text', + 'required' => false +); + + +And, add the following to the end of the file: + +$attributes['homeStreet2'] = array( + 'label' => _("Home Street 2"), + 'type' => 'text', + 'required' => false, +); +$attributes['homeStreet3'] = array( + 'label' => _("Home Street 3"), + 'type' => 'text', + 'required' => false, +); +$attributes['workStreet2'] = array( + 'label' => _("Work Street 2"), + 'type' => 'text', + 'required' => false, +); +$attributes['workStreet3'] = array( + 'label' => _("Work Street 3"), + 'type' => 'text', + 'required' => false, +); +$attributes['employeeType'] = array( + 'label' => _("Employee Type"), + 'type' => 'text', + 'required' => false +); +require_once 'Horde/Prefs/CategoryManager.php'; +$cManager = &new Prefs_CategoryManager(); +$categories = array_merge(array(_("Unfiled")), $cManager->get()); +$attributes['category'] = array( + 'label' => _("Category"), + 'type' => 'enum', + 'params' => array($categories), + 'required' => false +); + +$attributes['jobtitle'] = array( + 'label' => _("Job Title"), + 'type' => 'text', + 'required' => false, + ); + +$attributes['profession'] = array( + 'label' => _("Profession"), + 'type' => 'text', + 'required' => false, + ); + +$attributes['manager'] = array( + 'label' => _("Manager's Name"), + 'type' => 'text', + 'required' => false, + ); + +$attributes['assistant'] = array( + 'label' => _("Assistant's Name"), + 'type' => 'text', + 'required' => false, + ); + +$attributes['suffix'] = array( + 'label' => _("Suffix"), + 'type' => 'text', + 'required' => false, + ); + +$attributes['spouse'] = array( + 'label' => _("Spouse's Name"), + 'type' => 'text', + 'required' => false, + ); + +$attributes['anniversary'] = array( + 'label' => _("Anniversary"), + 'type' => 'monthdayyear', + 'params' => array(1900, null, true, 1), + 'required' => false, +); + +$attributes['pager'] = array( + 'label' => _("Pager"), + 'type' => 'text', + 'required' => false, + 'params' => array('', 40, 25) +); + +$attributes['callbackPhone'] = array( + 'label' => _("Callback Phone"), + 'type' => 'text', + 'required' => false, + 'params' => array('', 40, 25) +); + +$attributes['email2'] = array( + 'label' => _("Email") . ' 2', + 'type' => 'email', + 'required' => false, + 'params' => array('', 40, 255) +); + +$attributes['email3'] = array( + 'label' => _("Email") . ' 3', + 'type' => 'email', + 'required' => false, + 'params' => array('', 40, 255) +); + +$attributes['assistantPhone'] = array( + 'label' => _("Assistant's Phone"), + 'type' => 'text', + 'required' => false, + 'params' => array('', 40, 25) +); + +$attributes['workPhone2'] = array( + 'label' => _("Work Phone") . ' 2', + 'type' => 'text', + 'required' => false, + 'params' => array('', 40, 25) +); + +$attributes['Phone'] = array( + 'label' => _("Home Phone"), + 'type' => 'text', + 'required' => false, + 'params' => array('', 40, 25) +); + +$attributes['workFax'] = array( + 'label' => _("Work Fax"), + 'type' => 'text', + 'required' => false, + 'params' => array('', 40, 25) +); + +$attributes['callback'] = array( + 'label' => _("Callback"), + 'type' => 'text', + 'required' => false, + 'params' => array('', 40, 25) +); + +$attributes['carPhone'] = array( + 'label' => _("Car Phone"), + 'type' => 'text', + 'required' => false, + 'params' => array('', 40, 25) +); + +$attributes['companyPhone'] = array( + 'label' => _("Company Main Phone"), + 'type' => 'text', + 'required' => false, + 'params' => array('', 40, 25) +); + +$attributes['homePhone2'] = array( + 'label' => _("Home Phone") . ' 2', + 'type' => 'text', + 'required' => false, + 'params' => array('', 40, 25) +); + +$attributes['homeFax'] = array( + 'label' => _("Home Fax") . ' 2', + 'type' => 'text', + 'required' => false, + 'params' => array('', 40, 25) +); + +$attributes['isdn'] = array( + 'label' => _("ISDN"), + 'type' => 'text', + 'required' => false, + 'params' => array('', 40, 25) +); + +$attributes['otherPhone'] = array( + 'label' => _("Other Phone"), + 'type' => 'text', + 'required' => false, + 'params' => array('', 40, 25) +); + +$attributes['otherFax'] = array( + 'label' => _("Other Fax"), + 'type' => 'text', + 'required' => false, + 'params' => array('', 40, 25) +); + +$attributes['primaryPhone'] = array( + 'label' => _("Primary Phone"), + 'type' => 'text', + 'required' => false, + 'params' => array('', 40, 25) +); + +$attributes['radio'] = array( + 'label' => _("Radio Phone"), + 'type' => 'text', + 'required' => false, + 'params' => array('', 40, 25) +); + +$attributes['telex'] = array( + 'label' => _("Telex"), + 'type' => 'text', + 'required' => false, + 'params' => array('', 40, 25) +); + +$attributes['tty/tdd'] = array( + 'label' => _("TTY/TDD Phone"), + 'type' => 'text', + 'required' => false, + 'params' => array('', 40, 25) +); + +$attributes['otherAddress'] = array( + 'label' => '', + 'type' => 'addresslink', + 'required' => false, +); +$attributes['otherStreet'] = array( + 'label' => _("Other Street Address"), + 'type' => 'text', + 'required' => false, +); +$attributes['otherStreet2'] = array( + 'label' => _("Other Street 2"), + 'type' => 'text', + 'required' => false, +); +$attributes['otherStreet3'] = array( + 'label' => _("Other Street 3"), + 'type' => 'text', + 'required' => false, +); +$attributes['otherCity'] = array( + 'label' => _("Other City"), + 'type' => 'text', + 'required' => false +); +$attributes['otherProvince'] = array( + 'label' => _("Other State/Province"), + 'type' => 'text', + 'required' => false +); +$attributes['otherPostalCode'] = array( + 'label' => _("Other Postal Code"), + 'type' => 'text', + 'required' => false +); +$attributes['otherCountry'] = array( + 'label' => _("Other Country"), + 'type' => 'text', + 'required' => false +); + +$attributes['middlename'] = array( + 'label' => _("Middle Name"), + 'type' => 'text', + 'required' => false +); + + +++ Modifying sources.php + +//turba/config/sources.php// is the file that tells Turba which sources to use, and gives it all of the parameters for that source, such as what fields from //attributes.php// are used. + +Use the following for your sql source's //'map'// parameter: + + 'map' => array( + '__key' => 'object_id', + '__owner' => 'owner_id', + '__type' => 'object_type', + '__members' => 'object_members', + '__uid' => 'object_uid', + + 'name' => array('fields' => array('firstname', 'lastname'), + 'format' => '%s %s'), + 'title' => 'object_title', + 'firstname' => 'object_firstname', + 'middlename' => 'object_middlename', + 'lastname' => 'object_lastname', + 'suffix' => 'object_suffix', + 'company' => 'object_company', + 'department' => 'object_department', + 'jobtitle' => 'object_jobtitle', + 'workStreet' => 'object_workstreet', + 'workStreet2' => 'object_workstreet2', + 'workStreet3' => 'object_workstreet3', + 'workCity' => 'object_workcity', + 'workProvince' => 'object_workprovince', + 'workPostalCode' => 'object_workpostalcode', + 'workCountry' => 'object_workcountry', + 'workAddress' => array('fields' => array('workStreet', 'workStreet2', 'workStreet3', 'workCity', 'workProvince', + 'workPostalCode'), + 'format' => "%s\n%s\n%s\n%s, %s %s"), + 'homeStreet' => 'object_homestreet', + 'homeStreet2' => 'object_homestreet2', + 'homeStreet3' => 'object_homestreet3', + 'homeCity' => 'object_homecity', + 'homeProvince' => 'object_homeprovince', + 'homePostalCode' => 'object_homepostalcode', + 'homeCountry' => 'object_homecountry', + 'homeAddress' => array('fields' => array('homeStreet', 'homeStreet2', 'homeStreet3', 'homeCity', 'homeProvince', + 'homePostalCode'), + 'format' => "%s\n%s\n%s\n%s, %s %s"), + 'otherStreet' => 'object_otherstreet', + 'otherStreet2' => 'object_otherstreet2', + 'otherStreet3' => 'object_otherstreet3', + 'otherCity' => 'object_othercity', + 'otherProvince' => 'object_otherprovince', + 'otherPostalCode' => 'object_otherpostalcode', + 'otherCountry' => 'object_othercountry', + 'otherAddress' => array('fields' => array('otherStreet', 'otherStreet2', 'otherStreet3', 'otherCity', 'otherProvince', + 'otherPostalCode'), + 'format' => "%s\n%s\n%s\n%s, %s %s"), + 'assistantPhone' => 'object_assistantphone', + 'workFax' => 'object_workfax', + 'workPhone' => 'object_workphone', + 'workPhone2' => 'object_workphone2', + 'callback' => 'object_callback', + 'carPhone' => 'object_carphone', + 'companyPhone' => 'object_companyphone', + 'homeFax' => 'object_homefax', + 'homePhone' => 'object_homephone', + 'homePhone2' => 'object_homephone2', + 'isdn' => 'object_isdn', + 'cellPhone' => 'object_cellphone', + 'otherFax' => 'object_otherfax', + 'otherPhone' => 'object_otherphone', + 'pager' => 'object_pager', + 'primaryPhone' => 'object_primaryphone', + 'radio' => 'object_radio', + 'tty/tdd' => 'object_ttytdd', + 'telex' => 'object_telex', + 'anniversary' => 'object_anniversary', + 'assistant' => 'object_assistant', + 'birthday' => 'object_birthday', + 'category' => 'object_category', + 'email' => 'object_email', + 'email2' => 'object_email2', + 'email3' => 'object_email3', + 'freebusyUrl' => 'object_freebusyurl', + 'manager' => 'object_manager', + 'notes' => 'object_notes', + 'office' => 'object_office', + 'profession' => 'object_profession', + 'spouse' => 'object_spouse', + 'website' => 'object_website', + 'alias' => 'object_alias', + 'nickname' => 'object_nickname', + 'pgpPublicKey' => 'object_pgppublickey', + 'smimePublicKey' => 'object_smimepublickey', + ), + + +And, use the following for your sql source's //'tabs'// parameter. This is not included in the default //sources.php//, so you will have to add it. + + 'tabs' => array( + 'General' => array('name', 'firstname', 'middlename', 'lastname', 'jobtitle', 'company', 'email', 'email2', + 'email3', 'alias', 'website', 'category'), + 'Phone Numbers' => array('primaryPhone', 'homePhone', 'homePhone2', 'homeFax', 'workPhone', 'workPhone2', + 'workFax', 'cellPhone', 'pager', 'assistantPhone', 'callback', 'carPhone', + 'companyPhone', 'isdn', 'otherPhone', 'otherFax', 'radio', 'telex', 'tty/tdd'), + 'Home Address' => array('homeStreet', 'homeStreet2', 'homeStreet3', 'homeCity', 'homeProvince', 'homePostalCode', + 'homeCountry', 'homeAddress'), + 'Work Address' => array('workStreet', 'workStreet2', 'workStreet3', 'workCity', 'workProvince', 'workPostalCode', + 'workCountry', 'workAddress'), + 'Other Address' => array('otherStreet', 'otherStreet2', 'otherStreet3', 'otherCity', 'otherProvince', 'otherPostalCode', + 'otherCountry', 'otherAddress'), + 'Details' => array('department', 'office', 'profession', 'manager', 'assistant', 'nickname', 'title', + 'suffix', 'spouse', 'birthday', 'anniversary', 'freebusyUrl', 'notes'), + 'Certificates' => array('pgpPublicKey', 'smimePublicKey'), + ), + + +++ Preparing the database + +The following SQL script will create a turba database table to hold all of the new fields. + +CREATE TABLE turba_objects ( + object_id VARCHAR(32) NOT NULL, + owner_id VARCHAR(255) NOT NULL, + object_type VARCHAR(255) DEFAULT 'Object' NOT NULL, + object_uid VARCHAR(255), + object_members BLOB, + object_lastname VARCHAR(255), + object_alias VARCHAR(32), + object_email VARCHAR(255), + object_homestreet VARCHAR(255), + object_homestreet3 VARCHAR(255), + object_workstreet VARCHAR(255), + object_workstreet3 VARCHAR(255), + object_homephone VARCHAR(25), + object_workphone VARCHAR(25), + object_cellphone VARCHAR(25), + object_workfax VARCHAR(25), + object_title VARCHAR(255), + object_company VARCHAR(255), + object_notes TEXT, + object_pgppublickey TEXT, + object_smimepublickey TEXT, + object_freebusyurl VARCHAR(255), + object_firstname VARCHAR(255), + object_homecity VARCHAR(255), + object_homeprovince VARCHAR(255), + object_homepostalcode VARCHAR(255), + object_homecountry VARCHAR(255), + object_homestreet2 VARCHAR(255), + object_workstreet2 VARCHAR(255), + object_workcity VARCHAR(255), + object_workprovince VARCHAR(255), + object_workpostalcode VARCHAR(255), + object_workcountry VARCHAR(255), + object_website VARCHAR(255), + object_birthday VARCHAR(255), + object_nickname VARCHAR(255), + object_office VARCHAR(255), + object_jobtitle VARCHAR(255), + object_profession VARCHAR(255), + object_manager VARCHAR(255), + object_assistant VARCHAR(255), + object_suffix VARCHAR(255), + object_spouse VARCHAR(255), + object_anniversary VARCHAR(255), + object_email2 VARCHAR(255), + object_email3 VARCHAR(255), + object_category VARCHAR(255), + object_assistantphone VARCHAR(25), + object_workphone2 VARCHAR(25), + object_callback VARCHAR(255), + object_carphone VARCHAR(25), + object_companyphone VARCHAR(25), + object_homephone2 VARCHAR(25), + object_homefax VARCHAR(25), + object_isdn VARCHAR(255), + object_otherphone VARCHAR(25), + object_otherfax VARCHAR(25), + object_pager VARCHAR(25), + object_primaryphone VARCHAR(25), + object_radio VARCHAR(255), + object_telex VARCHAR(255), + object_ttytdd VARCHAR(255), + object_otherstreet VARCHAR(255), + object_otherstreet2 VARCHAR(255), + object_otherstreet3 VARCHAR(255), + object_othercity VARCHAR(255), + object_otherprovince VARCHAR(255), + object_otherpostalcode VARCHAR(255), + object_othercountry VARCHAR(255), + object_middlename VARCHAR(255), + object_department VARCHAR(255), +-- + PRIMARY KEY(object_id) +); + +CREATE INDEX turba_owner_idx ON turba_objects (owner_id); + +GRANT SELECT, INSERT, UPDATE, DELETE ON turba_objects TO horde; + + diff --git a/wicked/lib/Text_Wiki/tests/fixtures/mediawiki_syntax.txt b/wicked/lib/Text_Wiki/tests/fixtures/mediawiki_syntax.txt new file mode 100644 index 00000000000..f5ea00561e2 --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/fixtures/mediawiki_syntax.txt @@ -0,0 +1,123 @@ +#REDIRECT [[Some page name]] +#redirect [[Other page name]] + +[http://www.example.com See the example site] + +[http://www.somelink.com/index.php] + +http://example.com/index.php + +'''Bold text''' and ''italic text'' and even '''''bold italic text''''' + +'''Bold text''' and ''italic text'' and even '''''bold italic text''''' some text '''bold then ''italic'' then bold''' more text ''italic then '''bold''' then italic again'' some text '''''bold and italic''''' + +'''''bold and italic'' and bold''' + +'''''bold and italic''' and italic'' + +'''bold and ''bold and italic''''' + +''italic and '''bold and italic''''' + +=Level 1 heading= +Lorem ipsum dolor sit amet, [http://exemple.com/index.php consectetur adipiscing] elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +[http://exemple.com/index.php#anchor Pellentesque] sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +==Level 2 heading== +'''Lorem ipsum dolor sit amet''', consectetur ''adipiscing elit''. '''''Etiam commodo felis''''' vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +==Level 2 heading== +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +===Level 3 heading=== +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +====Level 4 heading==== +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +===Level 3 heading=== +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem [[convallis elementum]] vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +===Level 3 heading=== +Lorem ipsum dolor sit amet, consectetur adipiscing elit. [[Etiam]] commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +=====Level 5 heading===== +Lorem ipsum dolor sit amet, [[consectetur adipiscing]] elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +======Level 6 heading====== +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, [[cursus]] nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + + +{| +| A || B +|- +| C || D +|} + + +
+
+Horizontal line: + +---- + +Can be 4 hyphens or more: + +------ + + +* List +* List +** List +** List +*** List +* List +* List + +Invalid horizontal rule +--- + +# List +# List +## List +## List +### List +# List +# List + +;Definition lists +;item : definition +;semicolon plus term +:colon plus definition + +Mixed list: +* List example +** List example +**# List example +**# List example +*** List example +**** List example +*# List example +*# List example +** List example +* List example +** List example +** List example +**# List example diff --git a/wicked/lib/Text_Wiki/tests/fixtures/mediawiki_syntax_to_test_preformatted.txt b/wicked/lib/Text_Wiki/tests/fixtures/mediawiki_syntax_to_test_preformatted.txt new file mode 100644 index 00000000000..c4681c1a8e4 --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/fixtures/mediawiki_syntax_to_test_preformatted.txt @@ -0,0 +1,10 @@ +
+The pre tag ignores [[Wiki]] ''markup''.
+It also doesn't     reformat text.
+It still interprets special characters:
+ &rarr;
+
+ +
pre tag without line break
+ +Some text
some ''text'' without '''wiki''' parsing
more text diff --git a/wicked/lib/Text_Wiki/tests/fixtures/mediawiki_syntax_to_test_raw.txt b/wicked/lib/Text_Wiki/tests/fixtures/mediawiki_syntax_to_test_raw.txt new file mode 100644 index 00000000000..9372eab89ef --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/fixtures/mediawiki_syntax_to_test_raw.txt @@ -0,0 +1,9 @@ + +The nowiki tag ignores [[Wiki]] ''markup''. +It reformats text by removing newlines +and multiple spaces. +It still interprets special +characters: → + + +Some text ''ignores markup'' more text diff --git a/wicked/lib/Text_Wiki/tests/fixtures/mediawiki_syntax_to_test_wikilink.txt b/wicked/lib/Text_Wiki/tests/fixtures/mediawiki_syntax_to_test_wikilink.txt new file mode 100644 index 00000000000..cef3f07039f --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/fixtures/mediawiki_syntax_to_test_wikilink.txt @@ -0,0 +1,88 @@ +[http://www.example.com] + +[http://www.example.com See the example site] + +'''Bold text''' and ''italic text'' and even '''''bold italic text''''' + +'''Bold then into ''italics'' and bold again''' ''going to italics '''then bold''''' + +=Level 1 heading= +Lorem ipsum dolor sit amet, [http://exemple.com/index.php consectetur adipiscing] elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +[http://exemple.com/index.php#anchor Pellentesque] sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +==Level 2 heading== +'''Lorem ipsum dolor sit amet''', consectetur ''adipiscing elit''. '''''Etiam commodo felis''''' vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +==Level 2 heading== +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +===Level 3 heading=== +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +====Level 4 heading==== +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +===Level 3 heading=== +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem [[convallis elementum]] vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +===Level 3 heading=== +Lorem ipsum dolor sit amet, consectetur adipiscing elit. [[Etiam]] commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +=====Level 5 heading===== +Lorem ipsum dolor sit amet, [[consectetur adipiscing]] elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +======Level 6 heading====== +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, [[cursus]] nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +
+
+Horizontal line: + +---- + +Can be 4 hyphens or more: + +------ + +[[pt:Language link]] +[[Image:someImagePath]] + +* List +* List +** List +** List +*** List +* List +* List + +Invalid horizontal rule +--- + +# List +# List +## List +## List +### List +# List +# List + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. [[Donec sagittis|description text]] turpis nec erat dictum a ultrices enim mollis. + + diff --git a/wicked/lib/Text_Wiki/tests/fixtures/test_mediawiki_to_tiki_lists_output.txt b/wicked/lib/Text_Wiki/tests/fixtures/test_mediawiki_to_tiki_lists_output.txt new file mode 100644 index 00000000000..ba0cd3c455b --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/fixtures/test_mediawiki_to_tiki_lists_output.txt @@ -0,0 +1,17 @@ +!!Other Glossaries +{img src="img/wiki_up/Swiss-army-knife1.jpg" alt="Swiss-army-knife1.jpg"} + +* We were inspired by the [http://www.wikipedia.org/|Wikipedia] share-alike dictionary +* The [http://glossarist.com/|Glossarist] gives access to a huge range of Glossaries +* Looking for a particular word? [http://thesaurus.reference.com/|Roget's Thesaurus] helps you find it + +* Check out new words in the [http://www.wordspy.com/|WordSpy] dictionary + +* Here is an [http://www.pbs.org/art21/education/glossary_pop.html|Art-related Glossary] + +* You may be interested in [http://www.cooper.edu/art/techno/essays/gloss.html|Roy Ascott's glossary] of neologisms for art and technology (1996) + +* See the Attainable Utopias [http://attainable-utopias.org/tiki/tiki-index.php?page=NewDefinitions|AU Glossary] page + +return to [http://writing-pad.org/glossary/index.php/Main_Page|Main Page] + diff --git a/wicked/lib/Text_Wiki/tests/fixtures/test_mediawiki_to_tiki_lists_source.txt b/wicked/lib/Text_Wiki/tests/fixtures/test_mediawiki_to_tiki_lists_source.txt new file mode 100644 index 00000000000..d3eccd877b6 --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/fixtures/test_mediawiki_to_tiki_lists_source.txt @@ -0,0 +1,18 @@ +==Other Glossaries== +[[Image:Swiss-army-knife1.jpg]] + +* We were inspired by the [http://www.wikipedia.org/ Wikipedia] share-alike dictionary +* The [http://glossarist.com/ Glossarist] gives access to a huge range of Glossaries +* Looking for a particular word? [http://thesaurus.reference.com/ Roget's Thesaurus] helps you find it + +* Check out new words in the [http://www.wordspy.com/ WordSpy] dictionary + +* Here is an [http://www.pbs.org/art21/education/glossary_pop.html Art-related Glossary] + +* You may be interested in [http://www.cooper.edu/art/techno/essays/gloss.html Roy Ascott's glossary] of neologisms for art and technology (1996) + +* See the Attainable Utopias [http://attainable-utopias.org/tiki/tiki-index.php?page=NewDefinitions AU Glossary] page + + +return to [http://writing-pad.org/glossary/index.php/Main_Page Main Page] + diff --git a/wicked/lib/Text_Wiki/tests/fixtures/test_mediawiki_to_tiki_output.txt b/wicked/lib/Text_Wiki/tests/fixtures/test_mediawiki_to_tiki_output.txt new file mode 100644 index 00000000000..807337a2cd4 --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/fixtures/test_mediawiki_to_tiki_output.txt @@ -0,0 +1,52 @@ +__Alexander Sutherland Neill__ (((Forfar)), ((Escócia)), ((17 de outubro)) de ((1883)) - ((23 de setembro)) de ((1973))), ((educador)), ((Literatura|escritor)) e fundador da escola ((Summerhill)). Ficou famoso por defender a liberdade das crianças na educação escolar. + +!!Vida +Filho de uma numerosa família, seu pai, um mestre-escola, usava um bastão de ferro para disciplinar a classe. Trabalhou um tempo como auxiliar do seu pai e aos 25 anos de idade foi para a ((Universidade de Edimburgo)) onde se graduou em Inglês. Em ((1914)), se tornou diretor de uma pequena escola em ((Gretna Greem)) e lá escreveu ''A Dominie Log'' (O mestre inconsciente), o seu primeiro livro. Já nessa publicação, manisfesta seu descontentamento com a escola tradicional. + +Em ((1917)) visitou ((Little Commonwealth)), uma instituição para jovens delinqüentes que funcionava com base no princípio do auto-governo. ((Homer Lane)), que coordenava o reformatório, introduziu Neill a dois elementos que foram essenciais em sua prática pedagógica: o auto-governo e a importância do bem-estar emocional das crianças. + +Em ((1921)) fundou a ((International Schoool)), que mudou de sede por algumas vezes até se estabelecer em ((Leiston)), condado de ((Suffolk)), a 160 quilômetros de ((Londres)), passando então a se chamar ((Summerhill)). + +Casou duas vezes. Sua segunda mulher, Ena Wood Neill, administrou Summerhill junto com ele por algumas décadas até que a filha do casal, Zoe Readhead, assumiu o cargo. + +!!Summerhill +Na área da educação, o educador britânico ((Homer Lane)) foi a principal influência de Neill. Ele também era um grande admirador e amigo do ((psicanalista)) ((Wilhelm Reich)) e se dedicava aos estudos da teoria ((freud))iana. + +O autor acreditava que a felicidade é fundamental para o desenvolvimento das crianças e que essa felicidade tem origem num senso de liberdade das mesmas. Para ele, as escolas tradicionais privam de liberdade seus alunos e as consequências da infelicidade vivida pelas crianças reprimidas estão na origem da maioria dos problemas psicológicos da vida adulta. + +A fundação de Summerhill deu formato as propostas pedagógicas de Neill, distintas da linha hegemônica da época. Sustentava que os jovens devem ser estimulados a aprender em um ambiente de liberdade e de responsabilidade. + +Influenciado pelo pós-((I Guerra Mundial)), o autor parte do princípio de que a humanidade está doente e essa doença decorre do tratamento repressivo que as crianças recebem numa sociedade patriarcal. Inclusive nas questões ligadas à repressão sexual, em especial quando associadas a normas religiosas mal compreendidas. Responde a isso afirmando que toda criança tem direito à liberdade e que um grupo de crianças se auto-regula, estabelecendo em conjunto as próprias normas. "Para resumir, meu ponto de vista é que a educação sem liberdade resulta numa vida que não pode ser integralmente vivida. Tal educação ignora quase inteiramente as emoções da vida, e porque essas emoções são dinâmicas, a falta de oportunidade de expressão deve resultar, e resulta, em insignificância, em fealdade, em hostilidade. Apenas a cabeça é instruída. Se as emoções tivessem livre expansão, o intelecto saberia cuidar de si próprio." (NEILL, 1963, p.93) + +Em Summerhill, as crianças não são obrigadas a assistir as aulas e, além disso, as decisões da escola são tomadas em assembléias onde todos votam, incluindo professores, alunos e funcionários. Para o autor, a experiência nessa escola mostrou que, sem a coerção das escolas tradicionais, os estudantes orientam sua aprendizagem através do seu próprio interesse, ao invés de orientar pelo que lhe é imposto. +!!Heading +Na escola, nenhum adulto tem mais direitos que uma criança, todos tem direitos iguais. Nesse sentido o autor destaca a diferença entre os conceitos de liberdade e licença. Para Neill todos devem ser livres, porém isso não implica numa liberdade sem limites. Ninguém tem licença para interferir no espaço de outra pessoa e, ao mesmo tempo, todos têm total liberdade para fazerem o que quiserem no que disser respeito a si próprio. Por isso que ninguém deve determinar quais aulas uma criança deve freqüentar. Mas, ao mesmo tempo, ninguém tem direito de atrapalhar uma atividade coletiva. Liberdade não pode significar direito de fazer o que bem quiser a hora que quiser. Excesso de liberdade se transforma em licenciosidade. + +Neill criticava a escola tradicional também por enfatizar demais o lado racional das pessoas, em detrimento do lado emocional. Nesse sentido, em sua escola o teatro, a dança, os trabalhos manuais, ganham um destaque grande frente às disciplinas tradicionais. As aulas das matérias convencionais existem, mas não são o centro da escola. + +Como diretor, ele dava aulas de álgebra, geometria e trabalhos manuais. Geralmente dizia que admirava mais aqueles que possuíam habilidades para o trabalho manual do que aqueles que se restringiam ao trabalho intelectual. Durante um período trabalhava individualmente com alguns alunos numa espécie de sessão de terapia. Após algum tempo abandonou esse trabalho individual, pois concluiu que com as sessões ou sem os alunos resolviam seus problemas de qualquer forma. A liberdade era a responsável por isso. + +!!Obras +*((1960)): ''Liberdade sem medo'' (''Sumerhill'') +*((1966)): ''Liberdade sem excesso'' (''Freedom - Not License!'') +*((1967)): ''Liberdade no lar'' (''The problem family'') +*((1967)): ''Liberdade na escola'' (''Talking of Summerhill'') + +!!Referências +* NEILL, A. S. “Liberdade sem medo”. São Paulo: Ibrasa, 1963. + +!!Ver também +*((Escola da Ponte)) +*((Escolas democráticas)) +*((Pedagogia libertária)) + +!!Ligações externas +*[http://www.summerhillschool.co.uk|Summerhill Schooll] + +~pp~The pre tag ignores [[Wiki]] ''markup''. +It also doesn't reformat text. +It still interprets special characters: + →~/pp~ + +~pp~pre tag without line break~/pp~ + diff --git a/wicked/lib/Text_Wiki/tests/fixtures/test_mediawiki_to_tiki_redirect_output.txt b/wicked/lib/Text_Wiki/tests/fixtures/test_mediawiki_to_tiki_redirect_output.txt new file mode 100644 index 00000000000..11fe3f14a6e --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/fixtures/test_mediawiki_to_tiki_redirect_output.txt @@ -0,0 +1,3 @@ +{redirect page="Some page name"} +{redirect page="Other page name"} + diff --git a/wicked/lib/Text_Wiki/tests/fixtures/test_mediawiki_to_tiki_redirect_source.txt b/wicked/lib/Text_Wiki/tests/fixtures/test_mediawiki_to_tiki_redirect_source.txt new file mode 100644 index 00000000000..954c84c04b9 --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/fixtures/test_mediawiki_to_tiki_redirect_source.txt @@ -0,0 +1,2 @@ +#REDIRECT [[Some page name]] +#redirect [[Other page name]] diff --git a/wicked/lib/Text_Wiki/tests/fixtures/test_mediawiki_to_tiki_source.txt b/wicked/lib/Text_Wiki/tests/fixtures/test_mediawiki_to_tiki_source.txt new file mode 100644 index 00000000000..d548a91e74b --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/fixtures/test_mediawiki_to_tiki_source.txt @@ -0,0 +1,58 @@ +'''Alexander Sutherland Neill''' ([[Forfar]], [[Escócia]], [[17 de outubro]] de [[1883]] - [[23 de setembro]] de [[1973]]), [[educador]], [[Literatura|escritor]] e fundador da escola [[Summerhill]]. Ficou famoso por defender a liberdade das crianças na educação escolar. + +==Vida== + +Filho de uma numerosa família, seu pai, um mestre-escola, usava um bastão de ferro para disciplinar a classe. Trabalhou um tempo como auxiliar do seu pai e aos 25 anos de idade foi para a [[Universidade de Edimburgo]] onde se graduou em Inglês. Em [[1914]], se tornou diretor de uma pequena escola em [[Gretna Greem]] e lá escreveu ''A Dominie Log'' (O mestre inconsciente), o seu primeiro livro. Já nessa publicação, manisfesta seu descontentamento com a escola tradicional. + +Em [[1917]] visitou [[Little Commonwealth]], uma instituição para jovens delinqüentes que funcionava com base no princípio do auto-governo. [[Homer Lane]], que coordenava o reformatório, introduziu Neill a dois elementos que foram essenciais em sua prática pedagógica: o auto-governo e a importância do bem-estar emocional das crianças. + +Em [[1921]] fundou a [[International Schoool]], que mudou de sede por algumas vezes até se estabelecer em [[Leiston]], condado de [[Suffolk]], a 160 quilômetros de [[Londres]], passando então a se chamar [[Summerhill]]. + +Casou duas vezes. Sua segunda mulher, Ena Wood Neill, administrou Summerhill junto com ele por algumas décadas até que a filha do casal, Zoe Readhead, assumiu o cargo. + +==Summerhill== + +Na área da educação, o educador britânico [[Homer Lane]] foi a principal influência de Neill. Ele também era um grande admirador e amigo do [[psicanalista]] [[Wilhelm Reich]] e se dedicava aos estudos da teoria [[freud]]iana. + +O autor acreditava que a felicidade é fundamental para o desenvolvimento das crianças e que essa felicidade tem origem num senso de liberdade das mesmas. Para ele, as escolas tradicionais privam de liberdade seus alunos e as consequências da infelicidade vivida pelas crianças reprimidas estão na origem da maioria dos problemas psicológicos da vida adulta. + +A fundação de Summerhill deu formato as propostas pedagógicas de Neill, distintas da linha hegemônica da época. Sustentava que os jovens devem ser estimulados a aprender em um ambiente de liberdade e de responsabilidade. + +Influenciado pelo pós-[[I Guerra Mundial]], o autor parte do princípio de que a humanidade está doente e essa doença decorre do tratamento repressivo que as crianças recebem numa sociedade patriarcal. Inclusive nas questões ligadas à repressão sexual, em especial quando associadas a normas religiosas mal compreendidas. Responde a isso afirmando que toda criança tem direito à liberdade e que um grupo de crianças se auto-regula, estabelecendo em conjunto as próprias normas. "Para resumir, meu ponto de vista é que a educação sem liberdade resulta numa vida que não pode ser integralmente vivida. Tal educação ignora quase inteiramente as emoções da vida, e porque essas emoções são dinâmicas, a falta de oportunidade de expressão deve resultar, e resulta, em insignificância, em fealdade, em hostilidade. Apenas a cabeça é instruída. Se as emoções tivessem livre expansão, o intelecto saberia cuidar de si próprio." (NEILL, 1963, p.93) + +Em Summerhill, as crianças não são obrigadas a assistir as aulas e, além disso, as decisões da escola são tomadas em assembléias onde todos votam, incluindo professores, alunos e funcionários. Para o autor, a experiência nessa escola mostrou que, sem a coerção das escolas tradicionais, os estudantes orientam sua aprendizagem através do seu próprio interesse, ao invés de orientar pelo que lhe é imposto. +== Heading == + +Na escola, nenhum adulto tem mais direitos que uma criança, todos tem direitos iguais. Nesse sentido o autor destaca a diferença entre os conceitos de liberdade e licença. Para Neill todos devem ser livres, porém isso não implica numa liberdade sem limites. Ninguém tem licença para interferir no espaço de outra pessoa e, ao mesmo tempo, todos têm total liberdade para fazerem o que quiserem no que disser respeito a si próprio. Por isso que ninguém deve determinar quais aulas uma criança deve freqüentar. Mas, ao mesmo tempo, ninguém tem direito de atrapalhar uma atividade coletiva. Liberdade não pode significar direito de fazer o que bem quiser a hora que quiser. Excesso de liberdade se transforma em licenciosidade. + +Neill criticava a escola tradicional também por enfatizar demais o lado racional das pessoas, em detrimento do lado emocional. Nesse sentido, em sua escola o teatro, a dança, os trabalhos manuais, ganham um destaque grande frente às disciplinas tradicionais. As aulas das matérias convencionais existem, mas não são o centro da escola. + +Como diretor, ele dava aulas de álgebra, geometria e trabalhos manuais. Geralmente dizia que admirava mais aqueles que possuíam habilidades para o trabalho manual do que aqueles que se restringiam ao trabalho intelectual. Durante um período trabalhava individualmente com alguns alunos numa espécie de sessão de terapia. Após algum tempo abandonou esse trabalho individual, pois concluiu que com as sessões ou sem os alunos resolviam seus problemas de qualquer forma. A liberdade era a responsável por isso. + +==Obras== +*[[1960]]: ''Liberdade sem medo'' (''Sumerhill'') +*[[1966]]: ''Liberdade sem excesso'' (''Freedom - Not License!'') +*[[1967]]: ''Liberdade no lar'' (''The problem family'') +*[[1967]]: ''Liberdade na escola'' (''Talking of Summerhill'') + +==Referências== +* NEILL, A. S. “Liberdade sem medo”. São Paulo: Ibrasa, 1963. + +==Ver também== +*[[Escola da Ponte]] +*[[Escolas democráticas]] +*[[Pedagogia libertária]] + +==Ligações externas== +*[http://www.summerhillschool.co.uk Summerhill Schooll] + + +
+The pre tag ignores [[Wiki]] ''markup''.
+It also doesn't     reformat text.
+It still interprets special characters:
+ →
+
+ +
pre tag without line break
+ diff --git a/wicked/lib/Text_Wiki/tests/fixtures/test_mediawiki_wikilink_expected_matches.php b/wicked/lib/Text_Wiki/tests/fixtures/test_mediawiki_wikilink_expected_matches.php new file mode 100644 index 00000000000..3eee666798b --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/fixtures/test_mediawiki_wikilink_expected_matches.php @@ -0,0 +1,70 @@ + array( + 0 => '[[convallis elementum]]', + 1 => '[[Etiam]]', + 2 => '[[consectetur adipiscing]]', + 3 => '[[cursus]]', + 4 => '[[pt:Language link]]', + 5 => '[[Image:someImagePath]]', + 6 => '[[Donec sagittis|description text]]', + ), + 1 => array ( + 0 => '', + 1 => '', + 2 => '', + 3 => '', + 4 => '', + 5 => '', + 6 => '', + ), + 2 => array( + 0 => '', + 1 => '', + 2 => '', + 3 => '', + 4 => 'pt:', + 5 => 'Image:', + 6 => '', + ), + 3 => array( + 0 => 'convallis elementum', + 1 => 'Etiam', + 2 => 'consectetur adipiscing', + 3 => 'cursus', + 4 => 'Language link', + 5 => 'someImagePath', + 6 => 'Donec sagittis', + ), + 4 => array( + 0 => '', + 1 => '', + 2 => '', + 3 => '', + 4 => '', + 5 => '', + 6 => '', + ), + 5 => array( + 0 => '', + 1 => '', + 2 => '', + 3 => '', + 4 => '', + 5 => '', + 6 => 'description text', + ), + 6 => array( + 0 => '', + 1 => '', + 2 => '', + 3 => '', + 4 => '', + 5 => '', + 6 => '', + ), +); + +?> diff --git a/wicked/lib/Text_Wiki/tests/fixtures/test_tiki_heading_expected_matches.php b/wicked/lib/Text_Wiki/tests/fixtures/test_tiki_heading_expected_matches.php new file mode 100644 index 00000000000..9a68d8ab8e7 --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/fixtures/test_tiki_heading_expected_matches.php @@ -0,0 +1,60 @@ + array( + 0 => " +! Heading 1 +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae est sit amet metus consequat scelerisque at accumsan dolor. Quisque posuere, mauris a fermentum sagittis, sem quam blandit tortor, vitae ullamcorper nulla velit placerat lacus. Nullam rutrum quam id est convallis luctus. Vivamus et urna odio. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut at augue eget elit feugiat pretium. + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae est sit amet metus consequat scelerisque at accumsan dolor. Quisque posuere, mauris a fermentum sagittis, sem quam blandit tortor, vitae ullamcorper nulla velit placerat lacus. Nullam rutrum quam id est convallis luctus. Vivamus et urna odio. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut at augue eget elit feugiat pretium. +", + 1 => " +!! Heading 2 + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae est sit amet metus consequat scelerisque at accumsan dolor. Quisque posuere, mauris a fermentum sagittis, sem quam blandit tortor, vitae ullamcorper nulla velit placerat lacus. Nullam rutrum quam id est convallis luctus. Vivamus et urna odio. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut at augue eget elit feugiat pretium. +", + 2 => " +!!!Heading 3 +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae est sit amet metus consequat scelerisque at accumsan dolor. Quisque posuere, mauris a fermentum sagittis, sem quam blandit tortor, vitae ullamcorper nulla velit placerat lacus. Nullam rutrum quam id est convallis luctus. Vivamus et urna odio. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut at augue eget elit feugiat pretium. +", + 3 => " +!!- Heading 2 + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae est sit amet metus consequat scelerisque at accumsan dolor. Quisque posuere, mauris a fermentum sagittis, sem quam blandit tortor, vitae ullamcorper nulla velit placerat lacus. Nullam rutrum quam id est convallis luctus. Vivamus et urna odio. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut at augue eget elit feugiat pretium. +", + 4 => " +!!+ Heading 2 + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae est sit amet metus consequat scelerisque at accumsan dolor. Quisque posuere, mauris a fermentum sagittis, sem quam blandit tortor, vitae ullamcorper nulla velit placerat lacus. Nullam rutrum quam id est convallis luctus. Vivamus et urna odio. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut at augue eget elit feugiat pretium. +" + ), + 1 => array(0 => "\n", 1 => "\n", 2 => "\n", 3 => "\n", 4 => "\n"), + 2 => array(0 => "!", 1 => "!!", 2 => "!!!", 3 => "!!", 4 => "!!"), + 3 => array(0 => "", 1 => "", 2 => "", 3 => "-", 4 => "+"), + 4 => array(0 => " Heading 1", 1 => " Heading 2", 2 => "Heading 3", 3 => " Heading 2", 4 => " Heading 2"), + 5 => array( + 0 => " +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae est sit amet metus consequat scelerisque at accumsan dolor. Quisque posuere, mauris a fermentum sagittis, sem quam blandit tortor, vitae ullamcorper nulla velit placerat lacus. Nullam rutrum quam id est convallis luctus. Vivamus et urna odio. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut at augue eget elit feugiat pretium. + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae est sit amet metus consequat scelerisque at accumsan dolor. Quisque posuere, mauris a fermentum sagittis, sem quam blandit tortor, vitae ullamcorper nulla velit placerat lacus. Nullam rutrum quam id est convallis luctus. Vivamus et urna odio. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut at augue eget elit feugiat pretium. +", + 1 => " + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae est sit amet metus consequat scelerisque at accumsan dolor. Quisque posuere, mauris a fermentum sagittis, sem quam blandit tortor, vitae ullamcorper nulla velit placerat lacus. Nullam rutrum quam id est convallis luctus. Vivamus et urna odio. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut at augue eget elit feugiat pretium. +", + 2 => " +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae est sit amet metus consequat scelerisque at accumsan dolor. Quisque posuere, mauris a fermentum sagittis, sem quam blandit tortor, vitae ullamcorper nulla velit placerat lacus. Nullam rutrum quam id est convallis luctus. Vivamus et urna odio. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut at augue eget elit feugiat pretium. +", + 3 => " + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae est sit amet metus consequat scelerisque at accumsan dolor. Quisque posuere, mauris a fermentum sagittis, sem quam blandit tortor, vitae ullamcorper nulla velit placerat lacus. Nullam rutrum quam id est convallis luctus. Vivamus et urna odio. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut at augue eget elit feugiat pretium. +", + 4 => " + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae est sit amet metus consequat scelerisque at accumsan dolor. Quisque posuere, mauris a fermentum sagittis, sem quam blandit tortor, vitae ullamcorper nulla velit placerat lacus. Nullam rutrum quam id est convallis luctus. Vivamus et urna odio. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut at augue eget elit feugiat pretium. +", + ), +); + +?> diff --git a/wicked/lib/Text_Wiki/tests/fixtures/test_tiki_to_tiki_heading_source.txt b/wicked/lib/Text_Wiki/tests/fixtures/test_tiki_to_tiki_heading_source.txt new file mode 100644 index 00000000000..05477810ce8 --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/fixtures/test_tiki_to_tiki_heading_source.txt @@ -0,0 +1,11 @@ +!! heading 1 with new line + +some text after the heading with a new line before + +!!heading 2 without new line +some text right after the heading + +!!heading 3 +two heading almost togheter +!! heading 4 +text after heading that has now new line to separate from the last heading diff --git a/wicked/lib/Text_Wiki/tests/fixtures/text_wiki_sample_mediawiki_syntax.txt b/wicked/lib/Text_Wiki/tests/fixtures/text_wiki_sample_mediawiki_syntax.txt new file mode 100644 index 00000000000..4479c55e2a3 --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/fixtures/text_wiki_sample_mediawiki_syntax.txt @@ -0,0 +1,66 @@ + +[http://www.example.com] + +[http://www.example.com See the example site] + +Lorem ipsum dolor sit amet, [http://exemple.com/index.php consectetur adipiscing] elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +[http://exemple.com/index.php#anchor Pellentesque] sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +'''Lorem ipsum dolor sit amet''', consectetur ''adipiscing elit''. '''''Etiam commodo felis''''' vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + + +Horizontal line: + +---- + +Can be 4 hyphens or more: + +------ + + +* List +* List +** List +** List +*** List +* List +* List + +# List +# List +## List +## List +### List +# List +# List diff --git a/wicked/lib/Text_Wiki/tests/fixtures/text_wiki_sample_syntax_transformed_to_plain.txt b/wicked/lib/Text_Wiki/tests/fixtures/text_wiki_sample_syntax_transformed_to_plain.txt new file mode 100644 index 00000000000..0a5f26368a7 --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/fixtures/text_wiki_sample_syntax_transformed_to_plain.txt @@ -0,0 +1,64 @@ +http://www.example.com + +See the example site + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +Horizontal line: + + +Can be 4 hyphens or more: + + + + List + List + List + List + List + List + List + + + List + List + List + List + List + List + List + diff --git a/wicked/lib/Text_Wiki/tests/fixtures/text_wiki_sample_syntax_transformed_to_plain2.txt b/wicked/lib/Text_Wiki/tests/fixtures/text_wiki_sample_syntax_transformed_to_plain2.txt new file mode 100644 index 00000000000..0a5f26368a7 --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/fixtures/text_wiki_sample_syntax_transformed_to_plain2.txt @@ -0,0 +1,64 @@ +http://www.example.com + +See the example site + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris. + +Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis. + +Horizontal line: + + +Can be 4 hyphens or more: + + + + List + List + List + List + List + List + List + + + List + List + List + List + List + List + List + diff --git a/wicked/lib/Text_Wiki/tests/fixtures/text_wiki_sample_syntax_transformed_to_xhtml.txt b/wicked/lib/Text_Wiki/tests/fixtures/text_wiki_sample_syntax_transformed_to_xhtml.txt new file mode 100644 index 00000000000..35a0c0a6fd5 --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/fixtures/text_wiki_sample_syntax_transformed_to_xhtml.txt @@ -0,0 +1,70 @@ +

http://www.example.com

+ +

See the example site

+ +

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris.

+ +

Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis.

+ +

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris.

+ +

Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis.

+ +

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris.

+ +

Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis.

+ +

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris.

+ +

Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis.

+ +

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris.

+ +

Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis.

+ +

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris.

+ +

Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis.

+ +

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris.

+ +

Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis.

+ +

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris.

+ +

Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis.

+ +

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis vitae sem convallis elementum vel a mauris. Sed rhoncus dapibus orci ullamcorper tempor. Mauris tortor ante, hendrerit ut scelerisque ut, aliquet blandit metus. Morbi fermentum vulputate mi ac sagittis. Suspendisse in vehicula mauris.

+ +

Pellentesque sed luctus metus. Morbi posuere euismod placerat. Aliquam erat volutpat. Phasellus elit quam, cursus nec fringilla nec, egestas a libero. Integer aliquet gravida sem. Donec sagittis turpis nec erat dictum a ultrices enim mollis.

+ +

Horizontal line:

+ +
+

Can be 4 hyphens or more:

+ +
+
    +
  • List
  • +
  • List
      +
    • List
    • +
    • List
        +
      • List
      • +
    • +
  • +
  • List
  • +
  • List
  • +
+ +
    +
  1. List
  2. +
  3. List
      +
    1. List
    2. +
    3. List
        +
      1. List
      2. +
    4. +
  4. +
  5. List
  6. +
  7. List
  8. +
+ diff --git a/wicked/lib/Text_Wiki/tests/fixtures/tiki_syntax.txt b/wicked/lib/Text_Wiki/tests/fixtures/tiki_syntax.txt new file mode 100644 index 00000000000..3970b290e57 --- /dev/null +++ b/wicked/lib/Text_Wiki/tests/fixtures/tiki_syntax.txt @@ -0,0 +1,23 @@ + +[http://www.example.com/page|An example page] some text that is not an URL [http://www.example.com/page.php#anchor|Other example page] + +! Heading 1 +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae est sit amet metus consequat scelerisque at accumsan dolor. Quisque posuere, mauris a fermentum sagittis, sem quam blandit tortor, vitae ullamcorper nulla velit placerat lacus. Nullam rutrum quam id est convallis luctus. Vivamus et urna odio. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut at augue eget elit feugiat pretium. + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae est sit amet metus consequat scelerisque at accumsan dolor. Quisque posuere, mauris a fermentum sagittis, sem quam blandit tortor, vitae ullamcorper nulla velit placerat lacus. Nullam rutrum quam id est convallis luctus. Vivamus et urna odio. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut at augue eget elit feugiat pretium. + +!! Heading 2 + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae est sit amet metus consequat scelerisque at accumsan dolor. Quisque posuere, mauris a fermentum sagittis, sem quam blandit tortor, vitae ullamcorper nulla velit placerat lacus. Nullam rutrum quam id est convallis luctus. Vivamus et urna odio. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut at augue eget elit feugiat pretium. + +!!!Heading 3 +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae est sit amet metus consequat scelerisque at accumsan dolor. Quisque posuere, mauris a fermentum sagittis, sem quam blandit tortor, vitae ullamcorper nulla velit placerat lacus. Nullam rutrum quam id est convallis luctus. Vivamus et urna odio. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut at augue eget elit feugiat pretium. + +!!- Heading 2 + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae est sit amet metus consequat scelerisque at accumsan dolor. Quisque posuere, mauris a fermentum sagittis, sem quam blandit tortor, vitae ullamcorper nulla velit placerat lacus. Nullam rutrum quam id est convallis luctus. Vivamus et urna odio. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut at augue eget elit feugiat pretium. + +!!+ Heading 2 + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vitae est sit amet metus consequat scelerisque at accumsan dolor. Quisque posuere, mauris a fermentum sagittis, sem quam blandit tortor, vitae ullamcorper nulla velit placerat lacus. Nullam rutrum quam id est convallis luctus. Vivamus et urna odio. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut at augue eget elit feugiat pretium. +