diff options
| author | Max Kremmel <xing@synapse.plus.com> | 2005-12-18 22:30:28 +0000 |
|---|---|---|
| committer | Max Kremmel <xing@synapse.plus.com> | 2005-12-18 22:30:28 +0000 |
| commit | 8aa72c09216fff4609f4fc222404aa0620b5f1c1 (patch) | |
| tree | 91ff1661d48fa1ae9b1420276e0dc80c67fb27b6 | |
| parent | df9edaccf6ea14537dbcce9dee550ce23505082b (diff) | |
| download | liberty-8aa72c09216fff4609f4fc222404aa0620b5f1c1.tar.gz liberty-8aa72c09216fff4609f4fc222404aa0620b5f1c1.tar.bz2 liberty-8aa72c09216fff4609f4fc222404aa0620b5f1c1.zip | |
merge recent changes into HEAD
| -rw-r--r-- | LibertyAttachable.php | 18 | ||||
| -rw-r--r-- | LibertyContent.php | 26 | ||||
| -rwxr-xr-x | LibertyStructure.php | 37 | ||||
| -rwxr-xr-x | LibertySystem.php | 85 | ||||
| -rw-r--r-- | ajax_attachment_browser.php | 5 | ||||
| -rw-r--r-- | plugins/data.code.php | 49 | ||||
| -rw-r--r-- | plugins/data.comment.php | 8 | ||||
| -rw-r--r-- | plugins/format.tikiwiki.php | 69 | ||||
| -rw-r--r-- | templates/attachment_browser.tpl | 4 | ||||
| -rw-r--r-- | templates/edit_storage.tpl | 5 | ||||
| -rw-r--r-- | templates/libertypagination.tpl | 10 |
11 files changed, 210 insertions, 106 deletions
diff --git a/LibertyAttachable.php b/LibertyAttachable.php index 5b92179..cf8daa2 100644 --- a/LibertyAttachable.php +++ b/LibertyAttachable.php @@ -3,7 +3,7 @@ * Management of Liberty Content * * @package liberty - * @version $Header: /cvsroot/bitweaver/_bit_liberty/LibertyAttachable.php,v 1.8 2005/11/22 07:27:18 squareing Exp $ + * @version $Header: /cvsroot/bitweaver/_bit_liberty/LibertyAttachable.php,v 1.9 2005/12/18 22:30:20 squareing Exp $ * @author spider <spider@steelsun.com> */ // +----------------------------------------------------------------------+ @@ -455,7 +455,7 @@ function liberty_process_archive( &$pFileHash ) { switch( $mimeExt ) { case 'x-rar-compressed': case 'x-rar': - $shellResult = shell_exec( "unrar x $pFileHash[tmp_name] \"$destDir\"" ); + $shellResult = shell_exec( "unrar x \"$pFileHash[tmp_name]\" \"$destDir\"" ); break; case 'x-bzip2': case 'bzip2': @@ -470,25 +470,25 @@ function liberty_process_archive( &$pFileHash ) { case 'bz2': $compressFlag = '-j'; break; default: $compressFlag = ''; break; } - $shellResult = shell_exec( "tar -x $compressFlag -f $pFileHash[tmp_name] -C \"$destDir\"" ); + $shellResult = shell_exec( "tar -x $compressFlag -f \"$pFileHash[tmp_name]\" -C \"$destDir\"" ); break; case 'x-zip-compressed': case 'x-zip': case 'zip': - $shellResult = shell_exec( "unzip $pFileHash[tmp_name] -d \"$destDir\"" ); + $shellResult = shell_exec( "unzip \"$pFileHash[tmp_name]\" -d \"$destDir\"" ); break; case 'x-stuffit': case 'stuffit': - $shellResult = shell_exec( "unstuff -d=\"$destDir\" $pFileHash[tmp_name] " ); + $shellResult = shell_exec( "unstuff -d=\"$destDir\" \"$pFileHash[tmp_name]\" " ); break; default: if( $upExt == 'zip' ) { - $shellResult = shell_exec( "unzip $pFileHash[tmp_name] -d \"$destDir\"" ); + $shellResult = shell_exec( "unzip \"$pFileHash[tmp_name]\" -d \"$destDir\"" ); } elseif( $upExt == 'rar' ) { - $shellResult = shell_exec( "unrar x $pFileHash[tmp_name] \"$destDir\"" ); + $shellResult = shell_exec( "unrar x \"$pFileHash[tmp_name]\" \"$destDir\"" ); } elseif( $upExt == 'sit' || $upExt == 'sitx' ) { - print( "unstuff -d=\"$destDir\" $pFileHash[tmp_name] " ); - $shellResult = shell_exec( "unstuff -d=\"$destDir\" $pFileHash[tmp_name] " ); + print( "unstuff -d=\"$destDir\" \"$pFileHash[tmp_name]\" " ); + $shellResult = shell_exec( "unstuff -d=\"$destDir\" \"$pFileHash[tmp_name]\" " ); } else { $destDir = NULL; } diff --git a/LibertyContent.php b/LibertyContent.php index 204f1d8..6bc4a8e 100644 --- a/LibertyContent.php +++ b/LibertyContent.php @@ -3,7 +3,7 @@ * Management of Liberty content * * @package liberty -* @version $Header: /cvsroot/bitweaver/_bit_liberty/LibertyContent.php,v 1.11 2005/12/05 23:53:17 squareing Exp $ +* @version $Header: /cvsroot/bitweaver/_bit_liberty/LibertyContent.php,v 1.12 2005/12/18 22:30:21 squareing Exp $ * @author spider <spider@steelsun.com> */ @@ -127,6 +127,12 @@ class LibertyContent extends LibertyBase { */ function verify( &$pParamHash ) { global $gLibertySystem, $gBitSystem; + + // It is possible a derived class set this to something different + if( empty( $pParamHash['content_type_guid'] ) ) { + $pParamHash['content_type_guid'] = $this->mContentTypeGuid; + } + if( empty( $pParamHash['user_id'] ) ) { global $gBitUser; $pParamHash['user_id'] = $gBitUser->getUserId(); @@ -284,25 +290,15 @@ class LibertyContent extends LibertyBase { } */ + // Remove individual permissions for this object if they exist + $query = "delete from `".BIT_DB_PREFIX."users_objectpermissions` where `object_id`=? and `object_type`=?"; + $result = $this->mDb->query( $query, array( $this->mContentId, $this->mContentTypeGuid ) ); + $query = "DELETE FROM `".BIT_DB_PREFIX."tiki_content` WHERE `content_id` = ?"; $result = $this->mDb->query( $query, array( $this->mContentId ) ); $this->mDb->CompleteTrans(); $ret = TRUE; } -/* -// ported from gBitSystem - this should probably be execute as well - spiderr - function remove_object($type, $id) { - $this->uncategorize_object($type, $id); - // Now remove comments - $object = $type . $id; - $query = "delete from `".BIT_DB_PREFIX."tiki_comments` where `object`=? and `object_type`=?"; - $result = $this->mDb->query($query, array( $id, $type )); - // Remove individual permissions for this object if they exist - $query = "delete from `".BIT_DB_PREFIX."users_objectpermissions` where `object_id`=? and `object_type`=?"; - $result = $this->mDb->query($query,array((int)$object,$type)); - return true; - } -*/ return $ret; } diff --git a/LibertyStructure.php b/LibertyStructure.php index 9450790..ea850f5 100755 --- a/LibertyStructure.php +++ b/LibertyStructure.php @@ -3,7 +3,7 @@ * Management of Liberty Content * * @package liberty - * @version $Header: /cvsroot/bitweaver/_bit_liberty/LibertyStructure.php,v 1.9 2005/12/09 19:42:48 lsces Exp $ + * @version $Header: /cvsroot/bitweaver/_bit_liberty/LibertyStructure.php,v 1.10 2005/12/18 22:30:21 squareing Exp $ * @author spider <spider@steelsun.com> */ @@ -468,32 +468,39 @@ class LibertyStructure extends LibertyBase { } } - function s_remove_page($structure_id, $delete) { + function s_remove_page( $structure_id, $delete ) { // Now recursively remove if( is_numeric( $structure_id ) ) { $query = "SELECT `structure_id`, ts.`content_id` FROM `".BIT_DB_PREFIX."tiki_structures` ts WHERE `parent_id`=?"; - $result = $this->mDb->query( $query,array( (int)$structure_id) ); + $result = $this->mDb->query( $query, array( (int)$structure_id ) ); //Iterate down through the child nodes - while ($res = $result->fetchRow()) { - $this->s_remove_page($res["structure_id"], $delete); + while( $res = $result->fetchRow() ) { + $this->s_remove_page( $res["structure_id"], $delete ); } //Only delete a page if other structures arent referencing it - if ($delete) { - $page_info = $this->getNode($structure_id); - $query = "select count(*) from `".BIT_DB_PREFIX."tiki_structures` where `content_id`=?"; - $count = $this->mDb->getOne($query, array((int)$page_info["page_id"])); - if ($count = 1) { - $this->remove_all_versions($page_info["page_id"]); + if( $delete ) { + $page_info = $this->getNode( $structure_id ); + $query = "SELECT COUNT(*) FROM `".BIT_DB_PREFIX."tiki_structures` WHERE `content_id`=?"; + $count = $this->mDb->getOne( $query, array( (int)$page_info["page_id"] ) ); + if( $count = 1 ) { + $this->remove_all_versions( $page_info["page_id"] ); } } - //Remove the structure node - $query = "delete from `".BIT_DB_PREFIX."tiki_structures` where `structure_id`=?"; + //Get the correct content_id and remove it from tiki_content + $query = "SELECT `content_id` + FROM `".BIT_DB_PREFIX."tiki_structures` ts + WHERE `structure_id`=?"; + $content_id = $this->mDb->getOne( $query, array( (int)$structure_id ) ); + $query = "DELETE FROM `".BIT_DB_PREFIX."tiki_content` WHERE `content_id`=?"; + $result = $this->mDb->query( $query, array( (int)$content_id) ); - $result = $this->mDb->query($query, array( (int)$structure_id) ); + //Remove the structure node + $query = "DELETE FROM `".BIT_DB_PREFIX."tiki_structures` WHERE `structure_id`=?"; + $result = $this->mDb->query( $query, array( (int)$structure_id) ); return true; } } @@ -533,7 +540,7 @@ class LibertyStructure extends LibertyBase { function getContentIds( $pStructureId, &$pToc, $pLevel=0 ) { $ret = array(); - $query = "SELECT * from `".BIT_DB_PREFIX."tiki_structures` where `parent_id`=? ORDER BY `pos`, `page_alias`, `content_id`"; + $query = "SELECT * from `".BIT_DB_PREFIX."tiki_structures` where `parent_id`=? ORDER BY pos, page_alias, content_id"; $result = $this->mDb->query( $query, array( (int)$pStructureId ) ); while ( !$result->EOF ) { array_push( $pToc, $result->fields['content_id'] ); diff --git a/LibertySystem.php b/LibertySystem.php index 3f1c791..7199634 100755 --- a/LibertySystem.php +++ b/LibertySystem.php @@ -3,7 +3,7 @@ * System class for handling the liberty package * * @package liberty -* @version $Header: /cvsroot/bitweaver/_bit_liberty/LibertySystem.php,v 1.9 2005/11/22 07:27:18 squareing Exp $ +* @version $Header: /cvsroot/bitweaver/_bit_liberty/LibertySystem.php,v 1.10 2005/12/18 22:30:22 squareing Exp $ * @author spider <spider@steelsun.com> */ @@ -34,8 +34,8 @@ define( 'LIBERTY_SERVICE_DOCUMENT_GENERATION', 'document_generation' ); define( 'DEFAULT_ACCEPTABLE_TAGS', '<a><br><b><blockquote><cite><code><div><dd><dl><dt><em><h1><h2><h3><h4><hr>' - .' <i><it><img><li><ol><p><pre><span><strong><table><tbody><div><tr><td><th><u><ul>' - .' <button><fieldset><form><label><input><option><select><textarea>' ); + .' <i><it><img><li><ol><p><pre><span><strong><table><tbody><div><tr><td><th><u><ul>' + .' <button><fieldset><form><label><input><option><select><textarea>' ); /** * Link to base class @@ -240,41 +240,66 @@ class LibertySystem extends LibertyBase { } } -function parse_data_plugins(&$data, &$preparsed, &$noparsed, &$pParser ) { +function parse_data_plugins( &$data, &$preparsed, &$noparsed, &$pParser ) { global $gLibertySystem; // Find the plugins // note: $curlyTags[0] is the complete match, $curlyTags[1] is plugin name, $curlyTags[2] is plugin arguments - preg_match_all("/\{([A-Za-z]+)([^\}]*)\}/", $data, $curlyTags); + preg_match_all("/\{\/?([A-Za-z]+)([^\}]*)\}/", $data, $curlyTags); - if( count($curlyTags[0]) ) { + if( count( $curlyTags[0] ) ) { // if true, replace only CODE plugin, if false, replace all other plugins $code_first = true; // Process plugins in reverse order, so that nested plugins are handled // from the inside out. - $i = count($curlyTags[0]) - 1; - - while ($i >= 0) { + $i = count( $curlyTags[0] ) - 1; + $paired_tag_seen = array(); + while( $i >= 0 ) { $plugin_start = $curlyTags[0][$i]; $plugin = $curlyTags[1][$i]; $pos = strpos( $data, $plugin_start ); // where plugin starts $dataTag = strtolower( $plugin ); - if ( + // hush up the return of this in case someone uses curly braces to enclose text + $pluginInfo = $gLibertySystem->getPluginInfo( @$gLibertySystem->mDataTags[$dataTag] ) ; + + // only process a standalone unpaired tag or the start tag for a paired tag + if( empty( $paired_close_tag_seen[$dataTag] ) || $paired_close_tag_seen[$dataTag] == 0 ) { + $paired_close_tag_seen[$dataTag] = 1; + } else { + $paired_close_tag_seen[$dataTag] = 0; + } + + $is_opening_tag = 0; + if( ( empty( $pluginInfo['requires_pair'] ) && (strtolower($plugin_start) != '{/'. $dataTag . '}' ) ) + || (strpos( $plugin_start, ' ' ) > 0) + || (strtolower($plugin_start) == '{'.$dataTag.'}' && !$paired_close_tag_seen[$dataTag] ) + ) { + $is_opening_tag = 1; + } + + if( // when in CODE parsing mode, replace only CODE plugins - (($code_first && ($dataTag == 'code')) - // when NOT in CODE parsing mode, replace all other plugins - || (!$code_first && ($dataTag <> 'code'))) + ( ( $code_first && ( $dataTag == 'code' ) ) + // when NOT in CODE parsing mode, replace all other plugins + || ( !$code_first && ( $dataTag <> 'code' ) ) + ) && isset( $gLibertySystem->mDataTags[$dataTag] ) - && ( $pluginInfo = $gLibertySystem->getPluginInfo( $gLibertySystem->mDataTags[$dataTag] ) ) + && ( $pluginInfo ) && ( $gLibertySystem->getPluginFunction( $gLibertySystem->mDataTags[$dataTag], 'load_function' ) ) && ( $loadFunc = $gLibertySystem->getPluginFunction( $gLibertySystem->mDataTags[$dataTag], 'load_function' ) ) - // make sure we don't have a closing plugin - && ( empty( $pluginInfo['requires_pair'] ) || (strtolower($plugin_start) != '{'.$dataTag.'}') ) + && ( $is_opening_tag ) ) { if( $pluginInfo['requires_pair'] ) { - $plugin_end = '{'.$plugin.'}'; - $pos_end = strpos(strtolower( $data ), strtolower( $plugin_end ), $pos); // where plugin data ends + $plugin_end = '{/'.$plugin.'}'; + $pos_end = strpos( strtolower( $data ), strtolower( $plugin_end ), $pos ); // where plugin data ends + $plugin_end2 = '{'.$plugin.'}'; + $pos_end2 = strpos( strtolower( $data ), strtolower( $plugin_end2 ), $pos+1 ); // where plugin data ends + + if( ( $pos_end2 > 0 && $pos_end2 > 0 && $pos_end2 < $pos_end ) || $pos_end === false ) { + $pos_end = $pos_end2; + $plugin_end = $plugin_end2; + } } else { $pos_end = $pos + strlen( $curlyTags[0][$i] ); $plugin_end = ''; @@ -283,27 +308,27 @@ function parse_data_plugins(&$data, &$preparsed, &$noparsed, &$pParser ) { //print " if ( ((($code_first) && ($plugin == 'CODE')) || ((!$code_first) && ($plugin <> 'CODE'))) && ($pos_end > $pos)) { <br/>"; // Extract the plugin data - $plugin_data_len = $pos_end - $pos - strlen($curlyTags[0][$i]); + $plugin_data_len = $pos_end - $pos - strlen( $curlyTags[0][$i] ); - $plugin_data = substr($data, $pos + strlen($plugin_start), $plugin_data_len); + $plugin_data = substr( $data, $pos + strlen( $plugin_start ), $plugin_data_len ); //print " $plugin_data_len = $pos_end - $pos - strlen(".$curlyTags[0][$i].") substr( $pos + strlen($plugin_start), $plugin_data_len);"; $arguments = array(); // Construct argument list array - $paramString = str_replace('>', '>', trim( $curlyTags[2][$i] ) ); + $paramString = str_replace( '>', '>', trim( $curlyTags[2][$i] ) ); if( preg_match( '/^\(.*=>.*\)$/', $paramString ) ) { - $paramString = preg_replace('/[\(\)]/', '', $paramString); + $paramString = preg_replace( '/[\(\)]/', '', $paramString ); //we have the old style parms like {CODE (in=>1)} - $params = split(',', trim( $paramString )); + $params = split( ',', trim( $paramString ) ); - foreach ($params as $param) { + foreach( $params as $param ) { // the following str_replace line is to decode the > char when html is turned off // perhaps the plugin syntax should be changed in 1.8 not to use any html special chars $parts = split( '=>?', $param ); - if (isset($parts[0]) && isset($parts[1])) { - $name = trim($parts[0]); - $arguments[$name] = trim($parts[1]); + if( isset( $parts[0] ) && isset( $parts[1] ) ) { + $name = trim( $parts[0] ); + $arguments[$name] = trim( $parts[1] ); } } } else { @@ -331,9 +356,8 @@ function parse_data_plugins(&$data, &$preparsed, &$noparsed, &$pParser ) { } $i--; // if we are in CODE parsing mode and list is done, switch to 'parse other plugins' mode and start all over - if (($code_first) && ($i < 0)) { - $i = count($curlyTags[0]) - 1; - + if( ( $code_first ) && ( $i < 0 ) ) { + $i = count( $curlyTags[0] ) - 1; $code_first = false; } } // while @@ -342,5 +366,4 @@ function parse_data_plugins(&$data, &$preparsed, &$noparsed, &$pParser ) { global $gLibertySystem; $gLibertySystem = new LibertySystem(); - ?> diff --git a/ajax_attachment_browser.php b/ajax_attachment_browser.php new file mode 100644 index 0000000..3bcd5c1 --- /dev/null +++ b/ajax_attachment_browser.php @@ -0,0 +1,5 @@ +<?php +require_once( '../bit_setup_inc.php' ); +include_once( LIBERTY_PKG_PATH.'attachment_browser.php' ); +echo $gBitSmarty->fetch( 'bitpackage:liberty/attachment_browser.tpl' ); +?> diff --git a/plugins/data.code.php b/plugins/data.code.php index 75cb53b..3f95f84 100644 --- a/plugins/data.code.php +++ b/plugins/data.code.php @@ -1,6 +1,6 @@ <?php /** - * @version $Revision: 1.7 $ + * @version $Revision: 1.8 $ * @package liberty * @subpackage plugins_data */ @@ -17,7 +17,7 @@ // | Reworked for Bitweaver (& Undoubtedly Screwed-Up) // | by: StarRider <starrrider@users.sourceforge.net> // +----------------------------------------------------------------------+ -// $Id: data.code.php,v 1.7 2005/11/22 07:27:18 squareing Exp $ +// $Id: data.code.php,v 1.8 2005/12/18 22:30:26 squareing Exp $ /** * definitions @@ -32,7 +32,7 @@ $pluginParams = array ( 'tag' => 'CODE', 'help_page' => 'DataPluginCode', 'description' => tra("Displays the Source Code Snippet between {Code} blocks."), 'help_function' => 'data_code_help', - 'syntax' => " {CODE source= num= }". tra("Sorce Code Snippet") . "{code}", + 'syntax' => " {CODE source= num= }". tra("Sorce Code Snippet") . "{/code}", 'plugin_type' => DATA_PLUGIN ); $gLibertySystem->registerPlugin( PLUGIN_GUID_DATACODE, $pluginParams ); @@ -75,7 +75,7 @@ function data_code_help() { .'</td>' .'</tr>' .'</table>' - . tra("Example: ") . "{CODE source='php' num='on' }" . tra("Sorce Code Snippet") . "{code}"; + . tra("Example: ") . "{CODE source='php' num='on' }" . tra("Sorce Code Snippet") . "{/code}"; return $help; } @@ -90,7 +90,6 @@ function data_code( $data, $params ) { // Pre-Clyde Changes // Parameters were $In & $Colors // Added testing to maintain Pre-Clyde compatability // $num = NULL; - $add_tags = false; extract ($params, EXTR_SKIP); // This maintains Pre-Clyde Parameters if (isset($colors) and ($colors == 'php') ) $source = 'php'; @@ -108,13 +107,20 @@ function data_code( $data, $params ) { // Pre-Clyde Changes } } $num = (isset($num)) ? $num : FALSE; - $code = ''; // Lets make it pretty by eliminating all empty lines + // trim any trailing spaces + $code = ''; $lines = explode("\n", $data); foreach ($lines as $line) { - if (strlen($line) > 1) - $code .= rtrim($line) . "\n"; // The Strings length is > 1 + $code .= rtrim($line) . "\n"; } + $code = unhtmlentities( $code ); + + // Trim any leading blank linkes + $code = preg_replace('/^[\n\r]+/', "",$code); + // Trim any trailing blank linkes + $code = preg_replace('/[\n\r]+$/', "\n",$code); + if( file_exists( UTIL_PKG_PATH.'geshi/geshi.php' ) ) { // Include the GeSHi library include_once( UTIL_PKG_PATH.'geshi/geshi.php' ); @@ -136,24 +142,17 @@ function data_code( $data, $params ) { // Pre-Clyde Changes } } } - if( preg_match( '/php/i', $source ) && substr($code, 0, 2) != '<?') { // Check it if code starts with PHP tags, if not: add 'em. - $code = "<?php\n".$code."\n?>"; // The require these tags to function - $add_tags = true; - } - switch ($source) { // I used a switch here to make it easy to expand this plugin for other kinds of source code + switch (strtoupper($source)) { // I used a switch here to make it easy to expand this plugin for other kinds of source code case 'HTML': $code = highlight_string(decodeHTML($code),true); - if (substr($code, 0, 6) == '<code>') // Remove the first <code>" tags + if (substr($code, 0, 6) == '<code>') { // Remove the first <code>" tags $code = substr($code, 6, (strlen($code) - 13)); - if ($add_tags) { //strip the PHP tags if they were added by the script - if ($num) { // Line Numbering has been added - $code = substr($code, 50, (strlen($code) -125)); - } else { - $code = substr($code, 63, (strlen($code) -125)); - } } break; case 'PHP': + if(!preg_match( '/^[ 0-9:]*<\?/i', $code ) ) { // Check it if code starts with PHP tags, if not: add 'em. + $code = "<?php\n".$code."?>"; // The require these tags to function + } $code = highlight_string($code, true); $convmap = array( // Replacement-map to replace Colors '#000000">' => '#004A4A">', // The Default Color @@ -169,14 +168,20 @@ function data_code( $data, $params ) { // Pre-Clyde Changes $code = highlight_string( $code, true ); break; } + $code = "<pre>$code</pre>"; } - return "~np~<div class='codelisting'>".unhtmlentities( $code )."</div>~/np~"; + + + $work = "~np~<div class='codelisting'>". $code ."</div>~/np~"; + return $work; } function unhtmlentities($string) { $trans_tbl = get_html_translation_table(HTML_ENTITIES); $trans_tbl = array_flip($trans_tbl); - return strtr($string, $trans_tbl); + $trans_tbl[' '] = ' '; + $ret = strtr($string, $trans_tbl); + return preg_replace('/&#(\d+);/me', "chr('\\1')",$ret); } ?> diff --git a/plugins/data.comment.php b/plugins/data.comment.php index bf493e0..b3285ac 100644 --- a/plugins/data.comment.php +++ b/plugins/data.comment.php @@ -1,10 +1,10 @@ <?php -// $Id: data.comment.php,v 1.5 2005/08/07 17:40:31 squareing Exp $ +// $Id: data.comment.php,v 1.6 2005/12/18 22:30:26 squareing Exp $ /** * assigned_modules * * @author StarRider <starrrider@sourceforge.net> - * @version $Revision: 1.5 $ + * @version $Revision: 1.6 $ * @package liberty * @subpackage plugins_data * @copyright Copyright (c) 2004, bitweaver.org @@ -25,7 +25,7 @@ $pluginParams = array ( 'tag' => 'COMMENT', 'help_page' => 'DataPluginComment', 'description' => tra("This plugin allows Comments (Text that will not be displayed) to be added to a page."), 'help_function' => 'data__comment_help', - 'syntax' => "{COMMENT}Data Not Displayed{COMMENT}", + 'syntax' => "{COMMENT}Data Not Displayed{/COMMENT}", 'plugin_type' => DATA_PLUGIN ); $gLibertySystem->registerPlugin( PLUGIN_GUID_COMMENT, $pluginParams ); @@ -46,7 +46,7 @@ function data_comment_help() { . ' <strong>{COMMENT}</strong> ' . tra("Blocks is not displayed.") . '</td>' .'</tr>' .'</table>' - . tra("Example: ") . "{COMMENT}" . tra("Everything in here is not displayed.") . "{COMMENT}"; + . tra("Example: ") . "{COMMENT}" . tra("Everything in here is not displayed.") . "{/COMMENT}"; return $help; } /**************** diff --git a/plugins/format.tikiwiki.php b/plugins/format.tikiwiki.php index 92e79a9..43cd847 100644 --- a/plugins/format.tikiwiki.php +++ b/plugins/format.tikiwiki.php @@ -1,6 +1,6 @@ <?php /** - * @version $Revision: 1.12 $ + * @version $Revision: 1.13 $ * @package liberty */ global $gLibertySystem; @@ -499,6 +499,68 @@ class TikiWikiParser extends BitBase { return $cant; } + function parse_mediawiki_tables( $data ) { + //DEBUG: $data = "\n<!-- parse_mediawiki_tables() called. -->\n" . $data; + /* Find all matches to {|...|} with no {| inside. */ + while (preg_match('/\n\{\|(((?<!\{)\||[^\|])+)\n\|\}/sm', $data, $matches)) { + //DEBUG: vd($matches); + $table_data = str_replace("\r", "", $matches[1]); + $table_data = str_replace('||', "\n|", $table_data); + while (preg_match('/^![^!]+!!/m', $table_data)) { + /* Replace !! with \n! but ONLY in !-defined header rows. */ + $table_data = preg_replace('/^!(^!]+)!!/m', "!$1\n!", $table_data); + } + if (substr($table_data, 0, 1) != "\n") { + /* We have table parameters. */ + list($table_params, $table_data) = explode("\n", $table_data, 2); + $table_params = trim($table_params); + /* FIXME: This attempt to support foo:bar table params needs help! + if (strlen($table_params)) { + $table_params = preg_replace("/\b(\w+):/", '$1=', $table_params); + } + */ + } else { + $table_params = ''; + } + $content = "<table class=\"bittable\" $table_params>"; + $lines = explode("\n", $table_data); + $row = 0; + foreach ($lines as $line) { + if ((substr($line, 0, 1) == '|') || (substr($line, 0, 1) == '!')) { + if (preg_match('/^\|\+\s*(.+)$/', $line, $row_matches)) { + $content .= "<caption>$row_matches[1]</caption>"; + } else if (preg_match('/^\|-\s*(.+)?$/', $line, $row_matches)) { + if ($row) { + $content .= '</tr>'; + $row++; + } else { + $row = 1; + } + $content .= '<tr' . ((isset($row_matches[1])) ? ($row_matches[1]) : ("")) + . '>'; + } else if (preg_match('/^([\|!])\s*([^\|]+\s*\|)?\s*(.*)$/', $line, $row_matches)) { + if (! $row) { + $content .= '<tr>'; + $row = 1; + } + $content .= '<t' . (($row_matches[1] == '!') ? ('h') : ('d')) + . ((strlen($row_matches[2])) ? (' ' . trim(substr($row_matches[2], 0, -1))) : ('')) + . '>' . $row_matches[3] . '</t' + . (($row_matches[1] == '!') ? ('h') : ('d')) + . '>'; + } else { + $content .= "<!-- ERROR: Ignoring invalid line \"$line\" -->"; + } + } else { + $content .= "<!-- ERROR: Ignoring invalid line \"$line\" -->"; + } + } + $content .= '</table>'; + $data = str_replace($matches[0], $content, $data); + } + //DEBUG: $data .= "\n<!-- parse_mediawiki_tables() done. -->\n"; + return $data; + } function parse_data( $data, &$pCommonObject ) { global $gBitSystem; @@ -570,6 +632,11 @@ class TikiWikiParser extends BitBase { // smileys $data = $this->parse_smileys($data); + // Parse MediaWiki-style pipe syntax tables. + if ((strpos($data, "\n{|") !== FALSE) && (strpos($data, "\n|}") !== FALSE)) { + $data = $this->parse_mediawiki_tables($data); + } + // Replace links to slideshows if ($gBitSystem->getPreference('feature_drawings') == 'y') { // Replace drawings diff --git a/templates/attachment_browser.tpl b/templates/attachment_browser.tpl index 0d4f3ad..26340fa 100644 --- a/templates/attachment_browser.tpl +++ b/templates/attachment_browser.tpl @@ -1,6 +1,6 @@ {strip} <div class="row"> - {formlabel label="Attach File(s)"} + {formlabel label="Attach Existing File(s)" for="existing_attachment_id_input"} {forminput} <input type="text" name="existing_attachment_id[]" id="existing_attachment_id_input" size="20"/> {formhelp note="Attaching an item to your page will insert a small icon representing the file. Please use the attachment IDs listed below.<br />You can attach multiple items at once by seperating them with a ',' (comma)."} @@ -45,5 +45,5 @@ {/if} </table> -{libertypagination pgnName="pgnPage" pgnPage=$curPage numPages=$numPages offset=$smarty.request.offset} +{libertypagination pgnName="pgnPage" pgnPage=$curPage numPages=$numPages offset=$smarty.request.offset ajaxId=attbrowser} {/strip} diff --git a/templates/edit_storage.tpl b/templates/edit_storage.tpl index 5de6896..a1c3a58 100644 --- a/templates/edit_storage.tpl +++ b/templates/edit_storage.tpl @@ -1,7 +1,8 @@ {php} include (LIBERTY_PKG_PATH."edit_storage_inc.php"); {/php} {strip} {foreach from=$gLibertySystem->mPlugins item=plugin key=guid} - {if $plugin.is_active eq 'y' and $plugin.edit_field and $plugin.plugin_type eq 'storage'} + {* $no_plugins is set by the including template *} + {if $plugin.is_active eq 'y' and $plugin.edit_field and $plugin.plugin_type eq 'storage' and !$no_plugins} <div class="row"> {formlabel label=`$plugin.edit_label`} {forminput} @@ -12,7 +13,7 @@ {/if} {/foreach} - <h2 class="clear"><a href="javascript:sendRequest( 'attbrowser' );" onclick="javascript:document.getElementById( 'attbrowser' ).innerHTML = '<br />{tr}Loading Attachment Browser...{/tr}'">{tr}Attachment Browser{/tr}</a></h2> + <h2 class="clear"><a href="javascript:ajax_updater( 'attbrowser', '{$smarty.const.LIBERTY_PKG_URL}ajax_attachment_browser.php', 'ajax=true' );" onclick="javascript:document.getElementById( 'attbrowser' ).innerHTML = '{tr}Loading Attachment Browser...{/tr}'">{tr}Attachment Browser{/tr}</a></h2> <noscript><div class="warning">{tr}The attachment browser only works with javascript enabled.{/tr}</div></noscript> <div id="attbrowser" class="attbrowser"></div> {/strip} diff --git a/templates/libertypagination.tpl b/templates/libertypagination.tpl index 7cc0ec0..d71a272 100644 --- a/templates/libertypagination.tpl +++ b/templates/libertypagination.tpl @@ -1,8 +1,8 @@ {strip} <div class="pagination"> {if $pgnPage gt 1} - {if $smarty.request.ajaxid} - <a href="javascript:sendRequest( '{$smarty.request.ajaxid}','{$pgnName}={$pgnPage-1}{$pgnVars}' )">«</a> + {if $ajaxId} + <a href="javascript:ajax_updater( '{$ajaxId}', '{$smarty.const.LIBERTY_PKG_URL}ajax_attachment_browser.php', '{$pgnName}={$pgnPage-1}{$pgnVars}' );">«</a> {else} <a href="{$smarty.server.PHP_SELF}?{$pgnName}={$pgnPage-1}{$pgnVars}">«</a> {/if} @@ -13,8 +13,8 @@ {tr}Page {$pgnPage} of {$numPages}{/tr} {if $pgnPage lt $numPages} - {if $smarty.request.ajaxid} - <a href="javascript:sendRequest( '{$smarty.request.ajaxid}','{$pgnName}={$pgnPage+1}{$pgnVars}' )">»</a> + {if $ajaxId} + <a href="javascript:ajax_updater( '{$ajaxId}', '{$smarty.const.LIBERTY_PKG_URL}ajax_attachment_browser.php', '{$pgnName}={$pgnPage+1}{$pgnVars}' );">»</a> {else} <a href="{$smarty.server.PHP_SELF}?{$pgnName}={$pgnPage+1}{$pgnVars}">»</a> {/if} @@ -25,7 +25,7 @@ <br /> {* MSIE dies when we use a form in the pagination when doing ajax stuff *} - {if $gBitSystem->isFeatureActive( 'direct_pagination' ) or $smarty.request.ajaxid} + {if $gBitSystem->isFeatureActive( 'direct_pagination' ) or $ajaxId} {foreach from=$pgnPages item=link} {$link} {/foreach} |
