summaryrefslogtreecommitdiff
path: root/includes/pear/Text/Wiki/Parse/Creole/Image.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/pear/Text/Wiki/Parse/Creole/Image.php')
-rw-r--r--includes/pear/Text/Wiki/Parse/Creole/Image.php69
1 files changed, 69 insertions, 0 deletions
diff --git a/includes/pear/Text/Wiki/Parse/Creole/Image.php b/includes/pear/Text/Wiki/Parse/Creole/Image.php
new file mode 100644
index 0000000..09ddb8b
--- /dev/null
+++ b/includes/pear/Text/Wiki/Parse/Creole/Image.php
@@ -0,0 +1,69 @@
+<?php
+
+/**
+ *
+ * Parse for images in the source text.
+ *
+ * @category Text
+ *
+ * @package Text_Wiki
+ *
+ * @author Tomaiuolo Michele <tomamic@yahoo.it>
+ *
+ * @license LGPL
+ *
+ * @version $Id: Image.php 243106 2007-09-28 22:02:50Z mic $
+ *
+ */
+
+
+class Text_Wiki_Parse_Image 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_Image(&$obj)
+ {
+ parent::Text_Wiki_Parse($obj);
+ $this->regex = '/{{([^' . $this->wiki->delim . ']*)(\|([^' . $this->wiki->delim . ']*))?}}/U';
+ }
+
+
+ /**
+ *
+ * Generates a replacement token for the matched text.
+ *
+ * @access public
+ *
+ * @param array &$matches The array of matches from parse().
+ *
+ * @return string A token marking the horizontal rule.
+ *
+ */
+
+ function process(&$matches)
+ {
+ $src = trim($matches[1]);
+ $src = ltrim($src, '/');
+ $alt = isset($matches[3]) ? trim($matches[3]) : $src;
+
+ return $this->wiki->addToken(
+ $this->rule,
+ array(
+ 'src' => $src,
+ 'attr' => array('alt' => $alt, 'title' => $alt)
+ )
+ );
+ }
+
+}
+?> \ No newline at end of file