summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/data.div.php77
-rw-r--r--plugins/data.include.php6
-rw-r--r--plugins/data.module.php21
-rw-r--r--plugins/format.tikiwiki.php93
4 files changed, 142 insertions, 55 deletions
diff --git a/plugins/data.div.php b/plugins/data.div.php
new file mode 100644
index 0000000..0851980
--- /dev/null
+++ b/plugins/data.div.php
@@ -0,0 +1,77 @@
+<?php
+// $id: data.example.php,v 1.4.2.9 2005/07/14 09:03:36 starrider Exp $
+/**
+ * assigned_modules
+ *
+ * @author xing
+ * @version $Revision: 1.2 $
+ * @package liberty
+ * @subpackage plugins_data
+ * @copyright Copyright (c) 2004, bitweaver.org
+ */
+
+define( 'PLUGIN_GUID_DATADIV', 'datadiv' );
+global $gLibertySystem;
+$pluginParams = array (
+ 'tag' => 'DIV',
+ 'auto_activate' => TRUE,
+ 'requires_pair' => TRUE,
+ 'load_function' => 'data_div',
+ 'title' => 'Div (DIV)',
+ 'help_page' => 'DataPluginDiv',
+ 'description' => tra( "This plugin allows you to easily create a div with a number of optional CSS parameters." ),
+ 'help_function' => 'data_div_help',
+ 'syntax' => "{div border='3px solid blue'}",
+ 'plugin_type' => DATA_PLUGIN
+);
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATADIV, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATADIV );
+
+function data_div_help() {
+ $help =
+ '<table class="data help">'
+ .'<tr>'
+ .'<th>' . tra( "Key" ) . '</th>'
+ .'<th>' . tra( "Type" ) . '</th>'
+ .'<th>' . tra( "Comments" ) . '</th>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>' . tra( "CSS rules" ) . '</td>'
+ .'<td>' . tra( "string") . '<br />' . tra( "(optional)" ) . '</td>'
+ .'<td>' . tra( "This can be any CSS style rule. e.g.: ") . "border='3px solid blue'" .'</td>'
+ .'</tr>'
+ .'<tr class="even">'
+ .'<td>preset</td>'
+ .'<td>' . tra( "string") . '<br />' . tra( "(optional)" ) . '</td>'
+ .'<td>' . tra( "There are a few presets, which you can use to style with. Presets include: dark, orange, red, blue, centered.") .'</td>'
+ .'</tr>'
+ .'</table>'
+ . tra( "Example: " ) . "{div preset=centered border='3px solid blue'}";
+ return $help;
+}
+
+function data_div( $data, $params ) {
+ $style = '';
+ foreach( $params as $key => $value ) {
+ switch( $key ) {
+ case 'preset':
+ if( $value == 'dark' ) {
+ $style .= 'background:#333;color:#ccc;border:2px solid #000;padding:0.5em 1em;margin:0.5em;';
+ } elseif( $value == "orange" ) {
+ $style .= 'background:#f60;color:#fff;border:2px solid #900;padding:0.5em 1em;margin:0.5em;';
+ } elseif( $value == "red" ) {
+ $style .= 'background:#eee;color:#900;border:2px solid #900;padding:0.5em 1em;margin:0.5em;';
+ } elseif( $value == "blue" ) {
+ $style .= 'background:#def;color:#009;border:2px solid #acf;padding:0.5em 1em;margin:0.5em;';
+ } elseif( $value == "centered" ) {
+ $style .= 'background:#eee;color:#333;border:2px solid #ddd;padding:0.5em 1em;margin:0.5em auto;width:50%;text-align:center;';
+ }
+ break;
+ default:
+ $style .= $key.':'.$value.';';
+ break;
+ }
+ }
+ return( '<div style="'.$style.'">'.$data.'</div>' );
+}
+?>
diff --git a/plugins/data.include.php b/plugins/data.include.php
index ae416cb..be91942 100644
--- a/plugins/data.include.php
+++ b/plugins/data.include.php
@@ -1,6 +1,6 @@
<?php
/**
- * @version $Revision: 1.6 $
+ * @version $Revision: 1.7 $
* @package liberty
* @subpackage plugins_data
*/
@@ -17,7 +17,7 @@
// | Reworked for Bitweaver (& Undoubtedly Screwed-Up)
// | by: StarRider <starrrider@users.sourceforge.net>
// +----------------------------------------------------------------------+
-// $Id: data.include.php,v 1.6 2005/08/24 20:55:17 squareing Exp $
+// $Id: data.include.php,v 1.7 2005/12/26 12:25:03 squareing Exp $
/**
* definitions
@@ -77,7 +77,7 @@ function data_include($data, $params) {
require_once( WIKI_PKG_PATH.'BitPage.php');
$wp = new BitPage( $params['page_id'] );
if( $wp->load() ) {
- $ret = $wp->mInfo['data'];
+ $ret = $wp->parseData( $wp->mInfo['data'], $wp->mInfo['format_guid'] );
}
// load page by content_id
} elseif( isset( $params['content_id'] ) && is_numeric( $params['content_id'] ) ) {
diff --git a/plugins/data.module.php b/plugins/data.module.php
index 4428f9f..e28eca9 100644
--- a/plugins/data.module.php
+++ b/plugins/data.module.php
@@ -1,6 +1,6 @@
<?php
/**
- * @version $Revision: 1.6 $
+ * @version $Revision: 1.7 $
* @package liberty
* @subpackage plugins_data
*/
@@ -16,7 +16,7 @@
// | Author (TikiWiki): Mose <mose@users.sourceforge.net>
// | Reworked for Bitweaver by: Christian Fowler <spiderr@users.sourceforge.net>
// +----------------------------------------------------------------------+
-// $Id: data.module.php,v 1.6 2005/11/22 07:27:18 squareing Exp $
+// $Id: data.module.php,v 1.7 2005/12/26 12:25:03 squareing Exp $
/**
* definitions
@@ -65,7 +65,7 @@ function datamodule_help() {
.'<td colspan="3">' . tra( "Additional arguments and values depend on the selected module." )
.'</tr>'
.'</table>'
- . tra( "Example: " ) . '{MODULE module=last_modified_pages package=wiki title="Recent Wiki Modifications"}';
+ . tra( "Example: " ) . '{MODULE module=last_changes package=liberty title="Recent Changes"}';
return $help;
}
@@ -73,6 +73,7 @@ function data_datamodule( $data, $params ) {
global $modlib, $gBitSmarty;
require_once( KERNEL_PKG_PATH.'mod_lib.php' );
$out = '';
+ $ret = ' ';
extract( $params , EXTR_SKIP);
@@ -80,11 +81,15 @@ function data_datamodule( $data, $params ) {
// not sure if we can use the php file, since it sets everything to NULL when passed in - xing
global $module_rows;
$module_rows = !empty( $rows ) ? $rows : 10;
- $php = constant( strtoupper( $package ).'_PKG_PATH' ).'modules/mod_'.$module.'.php';
+ //$php = constant( strtoupper( $package ).'_PKG_PATH' ).'modules/mod_'.$module.'.php';
// TODO: assigning variables to template doesn't work since they are replaced by module paramaters set in the php file - even when it's not in use! - xing
- $tpl = 'bitpackage:'.$package.'/mod_'.$module.'.tpl';
+ if( is_file( constant( strtoupper( $package ).'_PKG_PATH' ).'modules/mod_'.$module.'.tpl' ) ) {
+ $tpl = 'bitpackage:'.$package.'/mod_'.$module.'.tpl';
+ } else {
+ return '<div class="error">'.tra( "The module / package combination you entered is not valid" ).'</div>';
+ }
} else {
- $ret = '<div class="error">'.tra( "Both paramters 'module' and 'package' are required" );
+ return '<div class="error">'.tra( "Both paramters 'module' and 'package' are required" ).'</div>';
}
if( !$out = $gBitSmarty->fetch( $tpl ) ) {
@@ -96,7 +101,6 @@ function data_datamodule( $data, $params ) {
}
}
$out = eregi_replace( "\n", "", $out );
- //vd($out);
// deal with custom styling
$style = '';
@@ -106,14 +110,13 @@ function data_datamodule( $data, $params ) {
$style .= $param.':'.$value.';';
}
}
+
if( !empty( $style ) ) {
$style = ' style="'.$style.'"';
}
if( $out ) {
$ret = '<div'.$style.'>'.$out.'</div>';
- } else {
- $ret = '<div class="error">'.tra( "Sorry no such module" ).'</div>'.$module;
}
return $ret;
}
diff --git a/plugins/format.tikiwiki.php b/plugins/format.tikiwiki.php
index 43cd847..804e6a9 100644
--- a/plugins/format.tikiwiki.php
+++ b/plugins/format.tikiwiki.php
@@ -1,6 +1,6 @@
<?php
/**
- * @version $Revision: 1.13 $
+ * @version $Revision: 1.14 $
* @package liberty
*/
global $gLibertySystem;
@@ -320,6 +320,7 @@ class TikiWikiParser extends BitBase {
$data = preg_replace("/&(?!([a-z]{1,7};))/", "&amp;", $data);
// oft-used characters (case insensitive)
+ $data = preg_replace("/~bull~/i", "&bull;", $data);
$data = preg_replace("/~bs~/i", "&#92;", $data);
$data = preg_replace("/~hs~/i", "&nbsp;", $data);
$data = preg_replace("/~amp~/i", "&amp;", $data);
@@ -912,58 +913,64 @@ class TikiWikiParser extends BitBase {
// Images
preg_match_all("/(\{img [^\}]+})/i", $data, $pages);
- foreach (array_unique($pages[1])as $page_parse) {
- $parts = explode(" ", $page_parse);
+ foreach( array_unique( $pages[1] ) as $page_parse ) {
+ // collect all parameters into $parts ( after we've removed whitespaces around '=' )
+ preg_match_all( "/(\w*)=([^=]*)(?=\s.*?|\s*\})/", preg_replace( "/\s+=\s+/", "=", $page_parse ), $parts );
$imgdata = array();
- $imgdata["src"] = '';
- $imgdata["height"] = '';
- $imgdata["width"] = '';
- $imgdata["link"] = '';
- $imgdata["align"] = '';
- $imgdata["float"] = '';
- $imgdata["desc"] = '';
-
- foreach ($parts as $part) {
- $part = str_replace('}', '', $part);
- $part = str_replace('{', '', $part);
- $part = str_replace('\'', '', $part);
- $part = str_replace('"', '', $part);
+ $imgdata['img_style'] = '';
+ $imgdata['div_style'] = '';
- if (strstr($part, '=')) {
- $subs = explode("=", $part, 2);
-
- $imgdata[$subs[0]] = $subs[1];
+ foreach( $parts[1] as $i => $key ) {
+ $value = preg_replace( '/["\']/', "", $parts[2][$i] );
+ switch( $key ) {
+ case 'width':
+ case 'height':
+ $imgdata['img_style'] .= $key.':'.$value.';';
+ break;
+ case 'float':
+ case 'padding':
+ case 'margin':
+ case 'background':
+ case 'border':
+ case 'text-align':
+ case 'color':
+ case 'font':
+ $imgdata['div_style'] .= $key.':'.$value.';';
+ break;
+ case 'align':
+ $imgdata['div_style'] .= 'text-align:'.$value.';';
+ break;
+ default:
+ $imgdata[$key] = $value;
+ break;
}
}
- //print("todo el tag es: ".$page_parse."<br/>");
- //print_r($imgdata);
- $repl = '<img alt="' . tra('Image') . '" src="'.$imgdata["src"].'" style="border:0;'.( !empty( $imgdata["float"] ) ? ' float:'.$imgdata["float"].';' : '' ).'"';
-
-
-
- if ($imgdata["width"])
- $repl .= ' width="' . $imgdata["width"] . '"';
-
- if ($imgdata["height"])
- $repl .= ' height="' . $imgdata["height"] . '"';
+ // check if we have a source to load an image from
+ if( !empty( $imgdata['src'] ) ) {
+ // set up image first
+ $repl = '<img'.
+ ' alt="'.( !empty( $imgdata['desc'] ) ? $imgdata['desc'] : tra( 'Image' ) ).'"'.
+ ' title="'.( !empty( $imgdata['desc'] ) ? $imgdata['desc'] : tra( 'Image' ) ).'"'.
+ ' src="'.$imgdata['src'].'"'.
+ ' style="'.$imgdata['img_style'].'"'.
+ ' />';
- if ($imgdata["align"])
- $repl .= ' align="' . $imgdata["align"] . '"';
-
- $repl .= ' />';
-
- if ($imgdata["link"]) {
- $repl = '<a href="' . $imgdata["link"] . '">' . $repl . '</a>';
- }
+ // if this image is linking to something, wrap the image with the <a>
+ if( !empty( $imgdata['link'] ) ) {
+ $repl = '<a href="'.trim( $imgdata['link'] ).'">'.$repl.'</a>';
+ }
- if ($imgdata["desc"]) {
- $repl = '<table cellpadding="0" cellspacing="0"><tr><td>' . $repl . '</td></tr><tr><td><small>' . $imgdata["desc"] . '</small></td></tr></table>';
+ // finally, wrap the image with a div
+ if( !empty( $imgdata['div_style'] ) || !empty( $imgdata['desc'] ) ) {
+ $repl = '<div class="img-plugin" style="'.$imgdata['div_style'].'">'.$repl.'<br />'.( !empty( $imgdata['desc'] ) ? $imgdata['desc'] : '' ).'</div>';
+ }
+ } else {
+ $repl = '<span class="warning">'.tra( 'When using <strong>{img}</strong> the <strong>src</strong> parameter is required.' ).'</span>';
}
-
- $data = str_replace($page_parse, $repl, $data);
+ $data = str_replace( $page_parse, $repl, $data );
}
$links = $this->get_links($data);