Update of /cvsroot/php-blog/serendipity/bundled-libs/Text/Wiki
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27598/bundled-libs/Text/Wiki
Modified Files:
Rule.php
Log Message:
PEAR::Text_Wiki Upgade from Tobias Schlitt
Index: Rule.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/bundled-libs/Text/Wiki/Rule.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Rule.php 26 Feb 2004 11:27:53 -0000 1.1
+++ Rule.php 25 May 2004 09:57:53 -0000 1.2
@@ -103,6 +103,19 @@
/**
*
+ * Configuration options for this rule.
+ *
+ * @access private
+ *
+ * @var string
+ *
+ */
+
+ var $_conf = null;
+
+
+ /**
+ *
* Constructor for the rule.
*
* @access public
@@ -123,6 +136,9 @@
// set the name of this rule; generally used when adding
// to the tokens array.
$this->_rule = $name;
+
+ // config options reference
+ $this->_conf =& $this->_wiki->rules[$this->_rule]['conf'];
}
@@ -261,23 +277,69 @@
*
* @access public
*
- * @param int $key The key number of the token being referenced from the
- * "parent" Text_Wiki object.
- *
* @param array $options The "options" portion of the token (second element).
*
- * @param string $format The target format for the text rendered from the
- * token options, typically 'xhtml', although it may be 'latex' or 'rtf'.
- * In your subclass, you should provide 'xhtml' support at a minimum.
- *
- * @return string The text redered from the token options; by default,
+ * @return string The text rendered from the token options; by default,
* no text is returned. You should change this in your subclass. ;-)
*
*/
- function renderXhtml($key, $options, $format)
+ function renderXhtml($options)
{
return '';
}
+
+
+ /**
+ *
+ * Simple method to extract 'option="value"' portions of wiki markup,
+ * typically used only in macros.
+ *
+ * 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 "macro options" portion of macro 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 getMacroArgs($text)
+ {
+ // find the =" sections;
+ $tmp = explode('="', trim($text));
+
+ // basic setup
+ $k = count($tmp) - 1;
+ $arg = 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, '"');
+ $arg[$key] = stripslashes(substr($val, 0, $pos));
+ $key = trim(substr($val, $pos+1));
+
+ }
+
+ return $arg;
+
+ }
}
?>
\ No newline at end of file
|