summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbitweaver.org <bitweaver@users.sourceforge.net>2005-06-19 04:55:51 +0000
committerbitweaver.org <bitweaver@users.sourceforge.net>2005-06-19 04:55:51 +0000
commit9263d2df0226a118f4add4664d746a266ce5aa78 (patch)
tree7bc560ee5a4111a80f7b4ecd23afe53278cfd352
downloadliberty-9263d2df0226a118f4add4664d746a266ce5aa78.tar.gz
liberty-9263d2df0226a118f4add4664d746a266ce5aa78.tar.bz2
liberty-9263d2df0226a118f4add4664d746a266ce5aa78.zip
IMPORT TikiPro CLYDE FINAL
-rw-r--r--LibertyAttachable.php701
-rw-r--r--LibertyBase.php62
-rw-r--r--LibertyComment.php236
-rw-r--r--LibertyContent.php856
-rwxr-xr-xLibertyStructure.php910
-rwxr-xr-xLibertySystem.php303
-rw-r--r--admin/admin_liberty_inc.php49
-rw-r--r--admin/plugins.php28
-rw-r--r--admin/schema_inc.php166
-rw-r--r--admin/upgrade_inc.php211
-rw-r--r--attachment_browser.php14
-rw-r--r--bit_setup_inc.php7
-rw-r--r--comments_inc.php121
-rw-r--r--display_content_inc.php10
-rw-r--r--display_structure_inc.php10
-rw-r--r--edit_storage_inc.php46
-rw-r--r--edit_structure_inc.php138
-rw-r--r--get_content_list_inc.php19
-rw-r--r--icons/Mind-Reader.swfbin0 -> 122367 bytes
-rw-r--r--icons/accept.pngbin0 -> 635 bytes
-rw-r--r--icons/active.pngbin0 -> 348 bytes
-rw-r--r--icons/administration.pngbin0 -> 823 bytes
-rw-r--r--icons/assign.gifbin0 -> 240 bytes
-rw-r--r--icons/back.gifbin0 -> 182 bytes
-rw-r--r--icons/bithelp.pngbin0 -> 636 bytes
-rw-r--r--icons/bitweaver.gifbin0 -> 2901 bytes
-rw-r--r--icons/bitweaver/adodb.gifbin0 -> 1091 bytes
-rw-r--r--icons/bitweaver/bitweaver.gifbin0 -> 1764 bytes
-rw-r--r--icons/bitweaver/smarty.gifbin0 -> 1175 bytes
-rw-r--r--icons/close.pngbin0 -> 820 bytes
-rw-r--r--icons/collapsed.gifbin0 -> 59 bytes
-rw-r--r--icons/config.gifbin0 -> 1062 bytes
-rw-r--r--icons/copy.pngbin0 -> 285 bytes
-rw-r--r--icons/copy_folder.pngbin0 -> 472 bytes
-rw-r--r--icons/current.pngbin0 -> 571 bytes
-rw-r--r--icons/delete.pngbin0 -> 778 bytes
-rw-r--r--icons/delete_small.gifbin0 -> 839 bytes
-rw-r--r--icons/detach.pngbin0 -> 611 bytes
-rw-r--r--icons/edit.gifbin0 -> 612 bytes
-rw-r--r--icons/edit_small.gifbin0 -> 170 bytes
-rw-r--r--icons/error.pngbin0 -> 784 bytes
-rw-r--r--icons/expanded.gifbin0 -> 56 bytes
-rw-r--r--icons/export.gifbin0 -> 624 bytes
-rw-r--r--icons/folder.pngbin0 -> 359 bytes
-rw-r--r--icons/folder_open.pngbin0 -> 448 bytes
-rw-r--r--icons/gd_logo.jpgbin0 -> 1139 bytes
-rw-r--r--icons/help.pngbin0 -> 665 bytes
-rw-r--r--icons/home.pngbin0 -> 608 bytes
-rw-r--r--icons/imagick_logo.jpgbin0 -> 1314 bytes
-rw-r--r--icons/inactive.pngbin0 -> 228 bytes
-rw-r--r--icons/index.php6
-rw-r--r--icons/info.pngbin0 -> 543 bytes
-rw-r--r--icons/list.pngbin0 -> 428 bytes
-rw-r--r--icons/lulu.gifbin0 -> 516 bytes
-rw-r--r--icons/mail_send.pngbin0 -> 433 bytes
-rw-r--r--icons/mime/css.pngbin0 -> 3216 bytes
-rw-r--r--icons/mime/generic.pngbin0 -> 4382 bytes
-rw-r--r--icons/mime/html.pngbin0 -> 3104 bytes
-rw-r--r--icons/mime/mp3.pngbin0 -> 3902 bytes
-rw-r--r--icons/mime/mpg.pngbin0 -> 4030 bytes
-rw-r--r--icons/mime/pdf.pngbin0 -> 3541 bytes
-rw-r--r--icons/mime/plain.pngbin0 -> 2855 bytes
-rw-r--r--icons/mime/zip.pngbin0 -> 3721 bytes
-rw-r--r--icons/move.gifbin0 -> 323 bytes
-rw-r--r--icons/move_down.pngbin0 -> 342 bytes
-rw-r--r--icons/move_left.pngbin0 -> 339 bytes
-rw-r--r--icons/move_left_right.pngbin0 -> 339 bytes
-rw-r--r--icons/move_right.pngbin0 -> 331 bytes
-rw-r--r--icons/move_up.pngbin0 -> 343 bytes
-rw-r--r--icons/nav_down.gifbin0 -> 179 bytes
-rw-r--r--icons/nav_first.gifbin0 -> 321 bytes
-rw-r--r--icons/nav_last.gifbin0 -> 321 bytes
-rw-r--r--icons/nav_next.gifbin0 -> 182 bytes
-rw-r--r--icons/nav_prev.gifbin0 -> 182 bytes
-rw-r--r--icons/nav_up.gifbin0 -> 178 bytes
-rw-r--r--icons/new.pngbin0 -> 483 bytes
-rw-r--r--icons/note.pngbin0 -> 543 bytes
-rw-r--r--icons/pbase.gifbin0 -> 99 bytes
-rw-r--r--icons/pdf.gifbin0 -> 1015 bytes
-rw-r--r--icons/permissions.gifbin0 -> 213 bytes
-rw-r--r--icons/permissions_set.gifbin0 -> 319 bytes
-rw-r--r--icons/pkg_global.pngbin0 -> 4118 bytes
-rw-r--r--icons/pkg_liberty.pngbin0 -> 2797 bytes
-rw-r--r--icons/plugin.pngbin0 -> 444 bytes
-rw-r--r--icons/post.gifbin0 -> 612 bytes
-rw-r--r--icons/print.gifbin0 -> 603 bytes
-rw-r--r--icons/refresh.pngbin0 -> 626 bytes
-rw-r--r--icons/reply.pngbin0 -> 497 bytes
-rw-r--r--icons/save.gifbin0 -> 599 bytes
-rw-r--r--icons/settings.pngbin0 -> 3254 bytes
-rw-r--r--icons/sort.pngbin0 -> 265 bytes
-rw-r--r--icons/sort_asc.pngbin0 -> 316 bytes
-rw-r--r--icons/sort_desc.pngbin0 -> 300 bytes
-rw-r--r--icons/sort_none.pngbin0 -> 310 bytes
-rw-r--r--icons/spacer.gifbin0 -> 55 bytes
-rw-r--r--icons/spacer_small.gifbin0 -> 48 bytes
-rw-r--r--icons/success.pngbin0 -> 652 bytes
-rw-r--r--icons/tree.gifbin0 -> 105 bytes
-rw-r--r--icons/upload.pngbin0 -> 3471 bytes
-rw-r--r--icons/view.gifbin0 -> 373 bytes
-rw-r--r--icons/warning.pngbin0 -> 809 bytes
-rw-r--r--list_content.php30
-rw-r--r--lookup_content_inc.php31
-rw-r--r--modules/help_mod_last_changes.tpl18
-rw-r--r--modules/help_mod_top_authors.tpl13
-rw-r--r--modules/mod_last_changes.php34
-rw-r--r--modules/mod_last_changes.tpl23
-rw-r--r--modules/mod_structure_navigation.php2
-rw-r--r--modules/mod_structure_navigation.tpl5
-rw-r--r--modules/mod_top_authors.php31
-rw-r--r--modules/mod_top_authors.tpl17
-rw-r--r--plugins/data.addtabs.php71
-rw-r--r--plugins/data.agentinfo.php95
-rw-r--r--plugins/data.article.php90
-rw-r--r--plugins/data.articles.php115
-rw-r--r--plugins/data.attachment.php113
-rw-r--r--plugins/data.avatar.php96
-rw-r--r--plugins/data.backlinks.php163
-rw-r--r--plugins/data.category.php241
-rw-r--r--plugins/data.catorphans.php131
-rw-r--r--plugins/data.catpath.php115
-rw-r--r--plugins/data.code.php200
-rw-r--r--plugins/data.copyright.php122
-rw-r--r--plugins/data.countdown.php117
-rw-r--r--plugins/data.example.php129
-rw-r--r--plugins/data.flash.php105
-rw-r--r--plugins/data.freemind.php90
-rw-r--r--plugins/data.gauge.php169
-rw-r--r--plugins/data.include.php85
-rw-r--r--plugins/data.lang.php64
-rw-r--r--plugins/data.maketoc.php202
-rw-r--r--plugins/data.module.php117
-rw-r--r--plugins/data.pluginhelp.php71
-rw-r--r--plugins/data.rss.php51
-rw-r--r--plugins/data.sf.php175
-rw-r--r--plugins/data.sort.php91
-rw-r--r--plugins/data.split.php103
-rw-r--r--plugins/data.titlesearch.php114
-rw-r--r--plugins/data.toc.php50
-rw-r--r--plugins/data.tp.php53
-rw-r--r--plugins/data.translated.php105
-rw-r--r--plugins/data.usercount.php57
-rw-r--r--plugins/data.userlist.php189
-rw-r--r--plugins/data.wikilist.php154
-rw-r--r--plugins/format.pearwiki.php50
-rw-r--r--plugins/format.pearwiki_tiki.php59
-rw-r--r--plugins/format.tikihtml.php82
-rw-r--r--plugins/format.tikiwiki.php1329
-rw-r--r--plugins/storage.bitfile.php114
-rw-r--r--plugins/storage.lulu.php60
-rw-r--r--plugins/storage.pbase.php55
-rw-r--r--templates/admin_liberty.tpl72
-rw-r--r--templates/admin_plugins.tpl62
-rw-r--r--templates/attachment_browser.tpl86
-rw-r--r--templates/comments.tpl73
-rw-r--r--templates/display_comment.tpl18
-rw-r--r--templates/display_content.tpl5
-rw-r--r--templates/display_structure.tpl45
-rw-r--r--templates/edit_format.tpl40
-rw-r--r--templates/edit_help.tpl134
-rw-r--r--templates/edit_storage.tpl56
-rw-r--r--templates/edit_storage_list.tpl27
-rw-r--r--templates/edit_structure.tpl58
-rw-r--r--templates/edit_structure_alias.tpl45
-rw-r--r--templates/edit_structure_content.tpl79
-rw-r--r--templates/libertypagination.tpl34
-rw-r--r--templates/list_content.tpl11
-rw-r--r--templates/list_content_inc.tpl48
-rw-r--r--templates/menu_liberty_admin.tpl18
-rw-r--r--templates/storage_thumbs.tpl17
170 files changed, 10617 insertions, 0 deletions
diff --git a/LibertyAttachable.php b/LibertyAttachable.php
new file mode 100644
index 0000000..0760268
--- /dev/null
+++ b/LibertyAttachable.php
@@ -0,0 +1,701 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Authors: spider <spider@steelsun.com>
+// +----------------------------------------------------------------------+
+//
+// $Id: LibertyAttachable.php,v 1.1 2005/06/19 04:55:47 bitweaver Exp $
+
+/**
+* Virtual base class (as much as one can have such things in PHP) for all
+* derived tikiwiki classes that require database access.
+*
+* @abstract
+* @author spider <spider@steelsun.com>
+* @version $Revision: 1.1 $
+* @package BitBase
+*/
+
+
+require_once( LIBERTY_PKG_PATH.'LibertyContent.php' );
+require_once( LIBERTY_PKG_PATH.'LibertySystem.php' );
+
+class LibertyAttachable extends LibertyContent {
+ var $mContentId;
+ var $mStorage;
+
+ function LibertyAttachable() {
+ LibertyContent::LibertyContent();
+ }
+
+ /**
+ * getStoragePath - get path to store files for the feature centralized_upload_dir. It creates a calculable hierarchy of directories
+ *
+ * @access public
+ * @author Christian Fowler<spider@steelsun.com>
+ * @param $pSubDir any desired directory below the StoragePath. this will be created if it doesn't exist
+ * @param $pCommon indicates not to use the 'common' branch, and not the 'users/.../<user_id>' branch
+ * @return string full path on local filsystem to store files.
+ */
+ function getStoragePath( $pSubDir = NULL, $pUserId = NULL, $pPackage = ACTIVE_PACKAGE ) {
+ $ret = null;
+ if( $storageUrl = $this->getStorageBranch( $pSubDir, $pUserId, $pPackage ) ) {
+ $ret = BIT_ROOT_PATH.$storageUrl;
+ //$ret = $storageUrl;
+ }
+ return $ret;
+ }
+
+
+ function getStorageUrl( $pSubDir = NULL, $pUserId = NULL, $pPackage = ACTIVE_PACKAGE ) {
+ return BIT_ROOT_URL.$this->getStorageBranch( $pSubDir, $pUserId, $pPackage );
+ }
+
+
+ /**
+ * getStorageBranch - get url to store files for the feature centralized_upload_dir. It creates a calculable hierarchy of directories
+ *
+ * @access public
+ * @author Christian Fowler<spider@steelsun.com>
+ * @param $pSubDir any desired directory below the StoragePath. this will be created if it doesn't exist
+ * @param $pUserId indicates the 'users/.../<user_id>' branch or use the 'common' branch if null
+ * @return string full path on local filsystem to store files.
+ */
+ function getStorageBranch( $pSubDir = NULL, $pUserId = NULL, $pPackage = ACTIVE_PACKAGE ) {
+ // *PRIVATE FUNCTION. GO AWAY! DO NOT CALL DIRECTLY!!!
+ global $gBitSystem;
+ $baseUrl = null;
+ $pathParts = array();
+ $pref = split( '/',$gBitSystem->getPreference('centralized_upload_dir') );
+ if( empty( $pref ) ) {
+ $pathParts[] = 'storage';
+ } else {
+ $pathParts = $pref;
+ }
+ if( !$pUserId ) {
+ $pathParts[] = 'common';
+ } else {
+ $pathParts[] = 'users';
+ $pathParts[] = (int)($pUserId % 1000);
+ $pathParts[] = $pUserId;
+ }
+ if ($pPackage) {
+ $pathParts[] = $pPackage;
+ }
+ // In case $pSubDir is multiple levels deep we'll need to mkdir each directory if they don't exist
+ $pSubDirParts = split('/',$pSubDir);
+ foreach ($pSubDirParts as $subDir) {
+ $pathParts[] = $subDir;
+ }
+ foreach( $pathParts as $p ) {
+ if( !empty( $p ) ) {
+ $baseUrl .= $p.'/';
+ if( !file_exists( BIT_ROOT_PATH.$baseUrl ) ) {
+ if( !mkdir( BIT_ROOT_PATH.$baseUrl ) ) {
+ // ACK, something went very wrong.
+ $baseUrl = FALSE;
+ break;
+ }
+ }
+ }
+ }
+ return $baseUrl;
+ }
+
+ /**
+ * verifyStorageFile - verify if a file exists
+ *
+ * @access public
+ * @author Christian Fowler<spider@steelsun.com>
+ * @param $pFileName name of the file that needs to be checked for
+ * @param $pSubDir any desired directory below the StoragePath.
+ * @param $pCommon indicates usage of the 'common' branch, and not the 'users/.../<user_id>' branch
+ * @param $pPackage indicates what package the data is from. defaults to the currently active package
+ * @return on success return full path to file, if it fails to find the file, returns false
+ */
+ function verifyStorageFile( $pFileName, $pSubDir = NULL, $pUserId = NULL, $pPackage = ACTIVE_PACKAGE ) {
+ // don't worry about double slashes '//' for now. we'll remove them later
+ $path = $this->getPreference('centralized_upload_dir').'/';
+ if( empty( $path ) ) {
+ $path = 'storage/';
+ }
+ if( !$pUserId ) {
+ $path .= 'common/';
+ } else {
+ $path .= 'users/'.(int)($pUserId % 1000).'/'.$pUserId.'/';
+ }
+ $path .= $pPackage.'/'.$pSubDir.'/'.$pFileName;
+ $path = BIT_ROOT_PATH.ereg_replace( '//','/',$path );
+ if( file_exists( $path ) ) {
+ return $path;
+ } else {
+ return FALSE;
+ }
+ }
+
+ function verify( &$pParamHash ) {
+ global $gBitSystem, $gBitUser;
+ if( !empty( $pParamHash['attachment_id'] ) && !is_numeric( $pParamHash['attachment_id'] ) ) {
+ $this->mErrors['file'] = 'System Error: Non-numeric storage_id.';
+ }
+
+ if( empty( $pParamHash['user_id'] ) ) {
+ // storage is always owned by the user that uploaded it!
+ // er... or at least admin if somehow we have a NULL mUserId - anon uploads maybe?
+ $pParamHash['user_id'] = is_numeric( $gBitUser->mUserId ) ? $gBitUser->mUserId : ROOT_USER_ID;
+ }
+ if( empty( $pParamHash['process_storage'] ) ) {
+ $pParamHash['process_storage'] = NULL;
+ }
+
+ if( empty( $pParamHash['subdir'] ) ) {
+ $pParamHash['subdir'] = 'files';
+ }
+
+ if( !empty( $_FILES['upload'] ) ) {
+ // tiki files upload
+ $pParamHash['upload'] = $_FILES['upload'];
+ }
+
+ if( !empty( $pParamHash['upload']['size'] ) && !empty( $pParamHash['upload'] ) && is_array( $pParamHash['upload'] ) ) {
+
+ $save = TRUE;
+ if( $gBitSystem->isPackageActive( 'quota' ) && !$gBitUser->isAdmin() ) {
+ require_once( QUOTA_PKG_PATH.'LibertyQuota.php' );
+ $quota = new LibertyQuota();
+ // Prevent people from uploading more than there quota
+ $q = $quota->getUserQuota( $pParamHash['user_id'] );
+ $u = (int)$quota->getUserUsage( $pParamHash['user_id'] );
+ if( $u + $pParamHash['upload']['size'] > $q ) {
+ $save = FALSE;
+ $this->mErrors['upload'] = $pParamHash['upload']['name'].' '.tra( 'could not be stored because you do not have enough disk quota.' ).' '.round(($u + $pParamHash['upload']['size'] - $q)/1000).'KB Needed' ;
+ }
+ }
+
+ if( $save ) {
+ // - TODO: get common preferences page with this as an option, but right now files are only option cuz no blobs - SPIDERR
+ $storageGuid = $gBitSystem->getPreference( 'common_storage_plugin', PLUGIN_GUID_BIT_FILES );
+ if( !empty( $pParamHash['upload']['size'] ) ) {
+ $pParamHash['upload']['dest_base_name'] = substr( $pParamHash['upload']['name'], 0, strrpos( $pParamHash['upload']['name'], '.' ) );
+ $pParamHash['upload']['source_file'] = $pParamHash['upload']['tmp_name'];
+ // lowercase all file extensions
+ $pParamHash['upload']['name'] = $pParamHash['upload']['dest_base_name'].strtolower( substr( $pParamHash['upload']['name'], strrpos( $pParamHash['upload']['name'], '.' ) ) );
+ $pParamHash['STORAGE'][$storageGuid] = $pParamHash['upload'];
+ }
+ }
+ }
+
+ if( isset( $pParamHash['STORAGE'] ) && is_array( $pParamHash['STORAGE'] ) ) {
+ foreach( array_keys( $pParamHash['STORAGE'] ) as $guid ) {
+ if( empty( $pParamHash['STORAGE'][$guid] ) ) {
+ unset( $pParamHash['STORAGE'][$guid] );
+ } else {
+ // reassign uploaded guid value to array element hashed under the guid. we are going to add more stuff to the guid hash
+ $inputValue = $pParamHash['STORAGE'][$guid];
+ $pParamHash['STORAGE'][$guid] = array();
+ $pParamHash['STORAGE'][$guid]['upload'] = $inputValue;
+ }
+ }
+ }
+ return( count( $this->mErrors ) == 0 );
+ }
+
+ // Things to be stored should be shoved in the array $pParamHash['STORAGE']
+ function store ( &$pParamHash ) {
+ global $gLibertySystem;
+ if( LibertyAttachable::verify( $pParamHash ) && LibertyContent::store( $pParamHash ) && !empty( $pParamHash['STORAGE'] ) && count( $pParamHash['STORAGE'] ) ) {
+ $this->mDb->StartTrans();
+ foreach( array_keys( $pParamHash['STORAGE'] ) as $guid ) {
+ $storeRow = &$pParamHash['STORAGE'][$guid]; // short hand variable assignment
+ $storeRow['plugin_guid'] = $guid;
+ $storeRow['content_id'] = $pParamHash['content_id']; // copy in content_id
+ $storeRow['user_id'] = $pParamHash['user_id']; // copy in the user_id
+ // do we have a verify function for this storage type, and do things verify?
+ if( function_exists( $gLibertySystem->mPlugins[$guid]['verify_function'] )
+ && $gLibertySystem->mPlugins[$guid]['verify_function']( $storeRow ) ) {
+ if( empty( $pParamHash['attachment_id'] ) ) {
+ $sql = "SELECT `attachment_id` FROM `".BIT_DB_PREFIX."tiki_attachments`
+ WHERE `attachment_plugin_guid` = ? AND `content_id` = ? AND `foreign_id`=?";
+ $rs = $this->query( $sql, array( $storeRow['plugin_guid'], (int)$storeRow['content_id'], (int)$storeRow['foreign_id'] ) );
+ if( empty( $rs ) || !$rs->NumRows() ) {
+ $pParamHash['attachment_id'] = $this->GenID( 'tiki_attachments_id_seq' );
+ $sql = "INSERT INTO `".BIT_DB_PREFIX."tiki_attachments` ( `attachment_id`, `attachment_plugin_guid`, `content_id`, `foreign_id`, `user_id` ) VALUES ( ?, ?, ?, ?, ? )";
+ $rs = $this->query( $sql, array( $pParamHash['attachment_id'], $storeRow['plugin_guid'], $pParamHash['content_id'], (int)$storeRow['foreign_id'], $storeRow['user_id'] ) );
+ } else {
+ $this->mErrors['storage'] = $guid.' '.$storeRow['foreign_id'].' has already been added to this content.';
+ $pParamHash['attachment_id'] = NULL;
+ }
+ }
+ $storeRow['attachment_id'] = $pParamHash['attachment_id'];
+
+ // if we have uploaded a file, we can take care of that generically
+ if( is_array( $storeRow['upload'] ) && !empty( $storeRow['upload']['size'] ) ) {
+ $storeRow['upload']['dest_path'] = $this->getStorageBranch( $storeRow['attachment_id'], $pParamHash['user_id'], 'images' );
+ $storagePath = liberty_process_upload( $storeRow );
+ // We're gonna store to local file system & tiki_files table
+ if( empty( $storagePath ) ) {
+ $this->mErrors['file'] = 'Could not store file '.$storeRow['upload']['name'].'.';
+ } else {
+ $storeRow['upload']['dest_file_path'] = $storagePath;
+ }
+ }
+
+ if( $pParamHash['attachment_id'] && function_exists( $gLibertySystem->mPlugins[$storeRow['plugin_guid']]['store_function'] ) ) {
+ $storeFunc = $gLibertySystem->mPlugins[$storeRow['plugin_guid']]['store_function'];
+ $this->mStorage = $storeFunc( $storeRow );
+ }
+ } else {
+ }
+ }
+ $this->mDb->CompleteTrans();
+ }
+
+ if( !empty( $pParamHash['existing_attachment_id'] ) ) {
+ foreach($pParamHash['existing_attachment_id'] as $existingAttachmentId) {
+ if( !empty($existingAttachmentId) ) {
+ $this->cloneAttachment($existingAttachmentId, $pParamHash['content_id']);
+ }
+ }
+ }
+ return( count( $this->mErrors ) == 0 );
+ }
+
+ // Clone an existing attachment but have it reference another content_id
+ function cloneAttachment($pAttachmentId, $pNewContentId) {
+ global $gLibertySystem;
+ global $gBitUser;
+
+ $sql = "SELECT * FROM `".BIT_DB_PREFIX."tiki_attachments` WHERE `attachment_id` = ?";
+ $rs = $this->query($sql, array( $pAttachmentId ));
+ $tmpAttachment = $rs->fields;
+
+ if ( !empty($tmpAttachment['attachment_id']) ) {
+ $newAttachmentId = $this->GenID( 'tiki_attachments_id_seq' );
+ $sql = "INSERT INTO `".BIT_DB_PREFIX."tiki_attachments` ( `attachment_id`, `attachment_plugin_guid`, `content_id`, `foreign_id`, `user_id` ) VALUES ( ?, ?, ?, ?, ? )";
+ $rs = $this->query( $sql, array( $newAttachmentId, $tmpAttachment['attachment_plugin_guid'], $pNewContentId, $tmpAttachment['foreign_id'], $gBitUser->mUserId ) );
+ }
+ }
+
+
+ function expunge () {
+ if( !empty( $this->mStorage ) && count( $this->mStorage ) ) {
+ foreach( array_keys( $this->mStorage ) as $i ) {
+ $this->expungeAttachment( $this->mStorage[$i]['attachment_id'] );
+ }
+ }
+ return LibertyContent::expunge();
+ }
+
+ function expungeAttachment( $pAttachmentId ) {
+ global $gLibertySystem;
+ global $gBitUser;
+ $ret = NULL;
+
+ if( is_numeric( $pAttachmentId ) ) {
+ $sql = "SELECT `attachment_plugin_guid`, `user_id` FROM `".BIT_DB_PREFIX."tiki_attachments` WHERE `attachment_id`=?";
+ $rs = $this->query( $sql, array( $pAttachmentId ) );
+ $guid = $rs->fields['attachment_plugin_guid'];
+ $user_id = $rs->fields['user_id'];
+
+ if( $guid && ($user_id == $gBitUser->mUserId || $gBitUser->isAdmin()) ) {
+ if ( function_exists( $gLibertySystem->mPlugins[$guid]['expunge_function'])) {
+ $expungeFunc = $gLibertySystem->mPlugins[$guid]['expunge_function'];
+ if( $expungeFunc( $pAttachmentId ) ) {
+ $sql = "DELETE FROM `".BIT_DB_PREFIX."tiki_attachments` WHERE `attachment_id`=?";
+ $this->query( $sql, array( $pAttachmentId ) );
+ }
+ } else {
+ print("Expunge function not found for this content!");
+ $ret = NULL;
+ }
+ }
+ }
+
+ return $ret;
+ }
+
+ function detachAttachment( $pAttachmentId ) {
+ if (is_numeric($pAttachmentId)) {
+ $attachmentInfo = $this->getAttachment($pAttachmentId);
+ if (!empty($attachmentInfo['user_id'])) {
+ $attachmentOwner = new BitUser($attachmentInfo['user_id']);
+ $attachmentOwner->load();
+ if ($attachmentOwner->mContentId) {
+ $query = "UPDATE `".BIT_DB_PREFIX."tiki_attachments` SET `content_id` = ? WHERE `attachment_id` = ?";
+ $result = $this->query($query, array($attachmentOwner->mContentId, $pAttachmentId));
+ } else {
+ $this->mErrors[] = "Unable to detach this attachment because the owner does not have a content row";
+ }
+ } else {
+ $this->mErrors[] = "An attachment with this id does not exist: $pAttachmentId";
+ }
+ }
+ return TRUE;
+ }
+
+ // allow an optional content_id to be passed in to ease legacy lib style objects (like blogs, articles, etc.)
+ function load( $pContentId=NULL ) {
+ // assume a derived class has joined on the tiki_content table, and loaded it's columns already.
+ global $gLibertySystem;
+ $conId = ( isset( $pContentId ) && is_numeric( $pContentId ) ? $pContentId : $this->mContentId );
+
+ if( !empty( $conId ) ) {
+ LibertyContent::load($pContentId);
+ $query = "SELECT * FROM `".BIT_DB_PREFIX."tiki_attachments` ta
+ WHERE ta.`content_id`=?";
+ if( $result = $this->query($query,array((int) $conId)) ) {
+ $this->mStorage = array();
+ while( !$result->EOF ) {
+ $row = &$result->fields;
+ if( $func = $gLibertySystem->getPluginFunction( $row['attachment_plugin_guid'], 'load_function' ) ) {
+ $this->mStorage[$row['attachment_id']] = $func( $row );
+ } else {
+ print "NO load_function for ".$row['attachment_plugin_guid']." ".$gLibertySystem->mPlugins[$row['attachment_plugin_guid']];
+ }
+ $result->MoveNext();
+ }
+ }
+ }
+ return( TRUE );
+ }
+
+ // allow an optional content_id to be passed in to ease legacy lib style objects (like blogs, articles, etc.)
+ function getAttachment( $pAttachmentId ) {
+ // assume a derived class has joined on the tiki_content table, and loaded it's columns already.
+ global $gLibertySystem;
+ $ret = NULL;
+
+ if( is_numeric( $pAttachmentId ) ) {
+ $query = "SELECT * FROM `".BIT_DB_PREFIX."tiki_attachments` ta
+ WHERE ta.`attachment_id`=?";
+ if( $result = $this->query($query,array((int) $pAttachmentId)) ) {
+ $ret = array();
+ if( !$result->EOF ) {
+ $row = &$result->fields;
+ if( $func = $gLibertySystem->getPluginFunction( $row['attachment_plugin_guid'], 'load_function' ) ) {
+ $ret = $func( $row );
+ }
+ }
+ }
+ }
+ return $ret;
+ }
+
+ // Get a list of attachments which also reference the foreign_id of the given attachment
+ function getSiblingAttachments( $pAttachmentId ) {
+ $ret = NULL;
+
+ $attachmentInfo = $this->getAttachment( $pAttachmentId );
+
+ if (!empty($attachmentInfo['attachment_id']) && !empty($attachmentInfo['foreign_id']) && !empty($attachmentInfo['attachment_plugin_guid']) ) {
+ $query = "SELECT * FROM `".BIT_DB_PREFIX."tiki_attachments` WHERE `foreign_id` = ? AND `attachment_plugin_guid` = ? AND `attachment_id` <> ?";
+ $result = $this->query($query, array($attachmentInfo['foreign_id'], $attachmentInfo['attachment_plugin_guid'], $attachment['attachment_id']));
+ $ret = $result->getRows();
+ }
+
+ return $ret;
+ }
+}
+
+function liberty_process_upload( &$pFileHash ) {
+ // Check for evil file extensions that could be execed on the server
+ if( preg_match( '/(.pl|.php|.php3|.php4|.phtml|.cgi|.asp|.sh|.shtml)$/', $pFileHash['upload']['name'] ) ) {
+ $pFileHash['upload']['name'] = $pFileHash['upload']['name'].'.txt';
+ }
+ // Thumbs.db is a windows My Photos/ folder file, and seems to really piss off imagick
+ if( preg_match( '/^image\/*/', $pFileHash['upload']['type'] ) && $pFileHash['upload']['name'] != 'Thumbs.db' ) {
+ $ret = liberty_process_image( $pFileHash['upload'] );
+ } else {
+ $ret = liberty_process_generic( $pFileHash['upload'] );
+ }
+ return $ret;
+}
+
+
+function liberty_process_generic( &$pFileHash ) {
+ $ret = NULL;
+ $destBase = $pFileHash['dest_path'].$pFileHash['name'];
+ $actualPath = BIT_ROOT_PATH.$destBase;
+ if( is_uploaded_file( $pFileHash['source_file']) ) {
+ if( move_uploaded_file( $pFileHash['source_file'], $actualPath ) ) {
+ $ret = $destBase;
+ }
+ } elseif( copy( $pFileHash['source_file'], $actualPath ) ) {
+ $ret = $destBase;
+ }
+ $pFileHash['size'] = filesize( $actualPath );
+
+ return $ret;
+}
+
+
+function liberty_process_image( &$pFileHash ) {
+ global $gBitSystem;
+ $ret = NULL;
+ $resizeFunc = ($gBitSystem->getPreference( 'image_processor' ) == 'imagick' ) ? 'liberty_imagick_resize_image' : 'liberty_gd_resize_image';
+ list($type, $ext) = split( '/', strtolower( $pFileHash['type'] ) );
+
+ if( $resizePath = $resizeFunc( $pFileHash, $ext ) ) {
+ $pFileHash['source_file'] = BIT_ROOT_PATH.$resizePath;
+ $nameHold = $pFileHash['name'];
+ $sizeHold = $pFileHash['size'];
+ $ret = $pFileHash['source_file'];
+ // do not thumbnail only if intentionally set to FALSE
+ if( !isset( $pFileHash['thumbnail'] ) || $pFileHash['thumbnail']==TRUE ) {
+ liberty_generate_thumbnails( $pFileHash );
+ }
+ $pFileHash['name'] = $nameHold;
+ $pFileHash['size'] = $sizeHold;
+ }
+ return $ret;
+}
+
+
+function liberty_clear_thumbnails( &$pFileHash ) {
+ $thumbsizes = array( 'avatar', 'small', 'medium', 'large' );
+ foreach( $thumbsizes as $size ) {
+ $fullPath = BIT_PKG_PATH.$pFileHash['dest_path']."$size.jpg";
+ if( file_exists( $fullPath ) ) {
+ unlink( $fullPath );
+ }
+ }
+}
+
+
+function liberty_generate_thumbnails( &$pFileHash ) {
+ global $gBitSystem;
+ $resizeFunc = ($gBitSystem->getPreference( 'image_processor' ) == 'imagick' ) ? 'liberty_imagick_resize_image' : 'liberty_gd_resize_image';
+ // Small thumb is 160x120
+ $pFileHash['dest_base_name'] = 'avatar';
+ $pFileHash['name'] = 'avatar.jpg';
+ $pFileHash['max_width'] = 100;
+ $pFileHash['max_height'] = 100;
+ $pFileHash['small_thumb_path'] = BIT_ROOT_PATH.$resizeFunc( $pFileHash );
+ // Small thumb is 160x120
+ $pFileHash['dest_base_name'] = 'small';
+ $pFileHash['name'] = 'small.jpg';
+ $pFileHash['max_width'] = 160;
+ $pFileHash['max_height'] = 120;
+ $pFileHash['small_thumb_path'] = BIT_ROOT_PATH.$resizeFunc( $pFileHash );
+ // Medium thumb is 400x300
+ $pFileHash['dest_base_name'] = 'medium';
+ $pFileHash['name'] = 'medium.jpg';
+ $pFileHash['max_width'] = 400;
+ $pFileHash['max_height'] = 300;
+ $pFileHash['medium_thumb_path'] = BIT_ROOT_PATH.$resizeFunc( $pFileHash );
+ // Large thumb is 800x600
+ $pFileHash['dest_base_name'] = 'large';
+ $pFileHash['name'] = 'large.jpg';
+ $pFileHash['max_width'] = 800;
+ $pFileHash['max_height'] = 600;
+ $pFileHash['large_thumb_path'] = BIT_ROOT_PATH.$resizeFunc( $pFileHash );
+}
+
+function liberty_imagick_resize_image( &$pFileHash, $pFormat = NULL ) {
+ $ret = NULL;
+ if( !empty( $pFileHash['source_file'] ) && is_file( $pFileHash['source_file'] ) ) {
+ $iImg = imagick_readimage( $pFileHash['source_file'] );
+ if( !$iImg ) {
+// $pFileHash['error'] = $pFileHash['name'].' '.tra ( "is not a known image file" );
+ $destUrl = liberty_process_generic( $pFileHash );
+ } elseif( imagick_iserror( $iImg ) ) {
+// $pFileHash['error'] = imagick_failedreason( $iImg ) . imagick_faileddescription( $iImg );
+ $destUrl = liberty_process_generic( $pFileHash );
+ } else {
+ $iwidth = imagick_getwidth( $iImg );
+ $iheight = imagick_getheight( $iImg );
+ if( (($iwidth / $iheight) > 0) && !empty( $pFileHash['max_width'] ) && !empty( $pFileHash['max_height'] ) ) {
+ // we have a portrait image, flip everything
+ $temp = $pFileHash['max_width'];
+ $pFileHash['max_height'] = $pFileHash['max_width'];
+ $pFileHash['max_width'] = $temp;
+ }
+ $itype = imagick_getmimetype( $iImg );
+ list($type, $mimeExt) = split( '/', strtolower( $itype ) );
+ if( !empty( $pFileHash['max_width'] ) && !empty( $pFileHash['max_height'] ) && ( ($pFileHash['max_width'] < $iwidth || $pFileHash['max_height'] < $iheight ) || ($mimeExt != 'jpeg')) ) {
+ // We have to resize. *ALL* resizes are converted to jpeg
+ $destExt = '.jpg';
+ $destUrl = $pFileHash['dest_path'].$pFileHash['dest_base_name'].$destExt;
+ $destFile = BIT_PKG_PATH.'/'.$destUrl;
+ $pFileHash['name'] = $pFileHash['dest_base_name'].$destExt;
+
+ //print " if ( !imagick_resize( $iImg, $pFileHash[max_width], $pFileHash[max_height], IMAGICK_FILTER_LANCZOS, 0.5, $pFileHash[max_width] x $pFileHash[max_height] > ) ) {";
+
+ // Alternate Filter settings can seen here http://www.dylanbeattie.net/magick/filters/result.html
+
+ if ( !imagick_resize( $iImg, $pFileHash['max_width'], $pFileHash['max_height'], IMAGICK_FILTER_CATROM, 1.00, '>' ) ) {
+ $pFileHash['error'] .= imagick_failedreason( $iImg ) . imagick_faileddescription( $iImg );
+ }
+ //print "2YOYOYOYO $iwidth x $iheight $destUrl <br/>";
+
+ imagick_set_image_quality( $iImg, 85 );
+ if( function_exists( 'imagick_set_attribute' ) ) {
+ // this exists in the PECL package, but not php-imagick
+ $imagick_set_attribute($iImg,array("quality"=>1) );
+ }
+
+ if( !imagick_writeimage( $iImg, $destFile ) ) {
+ $pFileHash['error'] .= imagick_failedreason( $iImg ) . imagick_faileddescription( $iImg );
+ }
+ $pFileHash['size'] = filesize( $destFile );
+ } else {
+ //print "GENERIC";
+ $destUrl = liberty_process_generic( $pFileHash );
+ }
+ }
+ $ret = $destUrl;
+ } else {
+ $pFileHash['error'] = "No source file to resize";
+ }
+
+ return $ret;
+}
+
+
+function liberty_gd_resize_image( &$pFileHash, $pFormat = NULL ) {
+ $ret = NULL;
+ list($iwidth, $iheight, $itype, $iattr) = @getimagesize( $pFileHash['source_file'] );
+ list($type, $ext) = split( '/', strtolower( $pFileHash['type'] ) );
+ $destUrl = $pFileHash['dest_path'].$pFileHash['dest_base_name'];
+ if( (empty( $pFileHash['max_width'] ) || empty( $pFileHash['max_height'] )) || ($iwidth <= $pFileHash['max_width'] && $iheight <= $pFileHash['max_height'] && ( $ext == 'gif' || $ext == 'png' || $ext == 'jpg' || $ext == 'jpeg' ) ) ) {
+ // Keep the same dimensions as input file
+ $pFileHash['max_width'] = $iwidth;
+ $pFileHash['max_height'] = $iheight;
+ } elseif( $iheight && (($iwidth / $iheight) > 0) && !empty( $pFileHash['max_width'] ) && !empty( $pFileHash['max_height'] ) ) {
+ // we have a portrait image, flip everything
+ $temp = $pFileHash['max_width'];
+ $pFileHash['max_height'] = $pFileHash['max_width'];
+ $pFileHash['max_width'] = $temp;
+ }
+
+ // we need to scale and/or reformat
+ $fp = fopen( $pFileHash['source_file'], "rb" );
+ $data = fread( $fp, filesize( $pFileHash['source_file'] ) );
+ fclose ($fp);
+ if( function_exists("ImageCreateFromString") ) {
+ $img = @imagecreatefromstring($data);
+ }
+
+ if( !empty( $img ) ) {
+ $size_x = imagesx($img);
+ $size_y = imagesy($img);
+ }
+
+ if( !empty( $img ) && $size_x && $size_y ) {
+ $transColor = imagecolortransparent( $img );
+ if( $size_x > $size_y && !empty( $pFileHash['max_width'] ) ) {
+ $tscale = ((int)$size_x / $pFileHash['max_width']);
+ } elseif( !empty( $pFileHash['max_height'] ) ) {
+ $tscale = ((int)$size_y / $pFileHash['max_height']);
+ } else {
+ $tscale = 1;
+ }
+ $tw = ((int)($size_x / $tscale));
+ $ty = ((int)($size_y / $tscale));
+ if (chkgd2()) {
+ $t = imagecreatetruecolor($tw, $ty);
+// png alpha stuff - needs more testing - spider
+// imagecolorallocatealpha ( $t, 0, 0, 0, 127 );
+// $ImgWhite = imagecolorallocate($t, 255, 255, 255);
+// imagefill($t, 0, 0, $ImgWhite);
+// imagecolortransparent($t, $ImgWhite);
+ imagecopyresampled($t, $img, 0, 0, 0, 0, $tw, $ty, $size_x, $size_y);
+ } else {
+ $t = imagecreate($tw, $ty);
+ $imagegallib->ImageCopyResampleBicubic($t, $img, 0, 0, 0, 0, $tw, $ty, $size_x, $size_y);
+ }
+ switch( $pFormat ) {
+ case 'png':
+ $ext = '.png';
+ $destFile = BIT_PKG_PATH.'/'.$destUrl.$ext;
+ imagepng( $t, $destFile );
+ break;
+ case 'gif':
+ // This must go immediately before default so default will be hit for PHP's without gif support
+ if( function_exists( 'imagegif' ) ) {
+ $ext = '.gif';
+ $destFile = BIT_PKG_PATH.'/'.$destUrl.$ext;
+ imagegif( $t, $destFile );
+ break;
+ }
+ default:
+ $ext = '.jpg';
+ $destFile = BIT_PKG_PATH.'/'.$destUrl.$ext;
+ imagejpeg( $t, $destFile );
+ break;
+ }
+ $pFileHash['name'] = $pFileHash['dest_base_name'].$ext;
+ $pFileHash['size'] = filesize( $destFile );
+ $ret = $destUrl.$ext;
+ } elseif( $iwidth && $iheight ) {
+ $ret = liberty_process_generic( $pFileHash );
+ }
+
+ return $ret;
+}
+
+
+function liberty_imagick_rotate_image( &$pFileHash ) {
+ $ret = FALSE;
+ if( !empty( $pFileHash['source_file'] ) && is_file( $pFileHash['source_file'] ) ) {
+ $iImg = imagick_readimage( $pFileHash['source_file'] );
+ if( !$iImg ) {
+ $pFileHash['error'] = $pFileHash['name'].' '.tra ( "is not a known image file" );
+ } elseif( imagick_iserror( $iImg ) ) {
+ $pFileHash['error'] = imagick_failedreason( $iImg ) . imagick_faileddescription( $iImg );
+ } elseif( empty( $pFileHash['degrees'] ) || !is_numeric( $pFileHash['degrees'] ) ) {
+ $pFileHash['error'] = tra( 'Invalid rotation amount' );
+ } else {
+ if ( !imagick_rotate( $iImg, $pFileHash['degrees'] ) ) {
+ $pFileHash['error'] .= imagick_failedreason( $iImg ) . imagick_faileddescription( $iImg );
+ }
+ if( !imagick_writeimage( $iImg, $pFileHash['source_file'] ) ) {
+ $pFileHash['error'] .= imagick_failedreason( $iImg ) . imagick_faileddescription( $iImg );
+ }
+ }
+ } else {
+ $pFileHash['error'] = "No source file to resize";
+ }
+
+ return( empty( $pFileHash['error'] ) );
+}
+
+
+function liberty_gd_rotate_image( &$pFileHash, $pFormat = NULL ) {
+ if( !function_exists( 'imagerotate' ) ) {
+ $pFileHash['error'] = "Rotate is not available on this webserver.";
+ } elseif( empty( $pFileHash['degrees'] ) || !is_numeric( $pFileHash['degrees'] ) ) {
+ $pFileHash['error'] = tra( 'Invalid rotation amount' );
+ } else {
+ // we need to scale and/or reformat
+ $fp = fopen( $pFileHash['source_file'], "rb" );
+ $data = fread( $fp, filesize( $pFileHash['source_file'] ) );
+ fclose ($fp);
+ if( function_exists("ImageCreateFromString") ) {
+ $img = @imagecreatefromstring($data);
+ }
+
+ if( !empty( $img ) ) {
+ //image rotate degrees seems back ass words.
+ $rotateImg = imagerotate ( $img, (-1 * $pFileHash['degrees']), 0 );
+ if( !empty( $rotateImg ) ) {
+ imagejpeg( $rotateImg, $pFileHash['source_file'] );
+ } else {
+ $pFileHash['error'] = "Image rotation failed.";
+ }
+ } else {
+ $pFileHash['error'] = "Image could not be opened for rotation.";
+ }
+ }
+
+ return( empty( $pFileHash['error'] ) );
+}
+
+?>
diff --git a/LibertyBase.php b/LibertyBase.php
new file mode 100644
index 0000000..d526ff1
--- /dev/null
+++ b/LibertyBase.php
@@ -0,0 +1,62 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Authors: spider <spider@steelsun.com>
+// +----------------------------------------------------------------------+
+//
+// $Id: LibertyBase.php,v 1.1 2005/06/19 04:55:47 bitweaver Exp $
+
+/**
+* Virtual base class (as much as one can have such things in PHP) for all
+* derived tikiwiki classes that require database access.
+*
+* @abstract
+* @author spider <spider@steelsun.com>
+* @version $Revision: 1.1 $
+* @package BitBase
+*/
+
+require_once( KERNEL_PKG_PATH.'BitBase.php' );
+
+class LibertyBase extends BitBase {
+
+ function LibertyBase () {
+ // we need to init our mDb early
+ BitBase::BitBase();
+ }
+
+ /**
+ * Given a content_id, this will return and object of the proper type
+ * @param pConId content_id of the object to be returned
+ * @param pGuid optional content_type_guid of pConId. This will save a select if you happen to have this info. If not, this method will look it up for you.
+ * @returns an object of the appropriate content type class
+ */
+ function getLibertyObject( $pContentId, $pContentGuid=NULL ) {
+ $ret = NULL;
+ global $gLibertySystem;
+
+ if( BitBase::verifyId( $pContentId ) ) {
+ if( empty( $pContentGuid ) ) {
+ $pContentGuid = $gLibertySystem->GetOne( "SELECT `content_type_guid` FROM `".BIT_DB_PREFIX."tiki_content` WHERE `content_id`=?", array( $pContentId ) );
+ }
+ if( !empty( $pContentGuid) && isset( $gLibertySystem->mContentTypes[$pContentGuid] ) ) {
+ $type = $gLibertySystem->mContentTypes[$pContentGuid];
+ require_once( constant( strtoupper( $type['handler_package'] ).'_PKG_PATH' ).$type['handler_file'] );
+ $ret = new $type['handler_class']( NULL, $pContentId );
+ $ret->load();
+ } else {
+ print "UNHANDLED ERROR. UNKNOWN CONTENT: $pContentId -> $pContentGuid";
+ }
+ }
+ return $ret;
+ }
+}
+
+?>
diff --git a/LibertyComment.php b/LibertyComment.php
new file mode 100644
index 0000000..8d5dc07
--- /dev/null
+++ b/LibertyComment.php
@@ -0,0 +1,236 @@
+<?php
+require_once( LIBERTY_PKG_PATH.'LibertyContent.php' );
+
+define( 'BITCOMMENT_CONTENT_TYPE_GUID', 'bitcomment' );
+
+class LibertyComment extends LibertyContent {
+ var $mCommentId;
+
+ function LibertyComment($pCommentId = NULL, $pContentId = NULL) {
+ LibertyContent::LibertyContent();
+ $this->registerContentType( BITCOMMENT_CONTENT_TYPE_GUID, array(
+ 'content_type_guid' => BITCOMMENT_CONTENT_TYPE_GUID,
+ 'content_description' => 'Comment',
+ 'handler_class' => 'LibertyComment',
+ 'handler_package' => 'liberty',
+ 'handler_file' => 'LibertyComment.php',
+ 'maintainer_url' => 'http://www.bitweaver.org'
+ ) );
+ $this->mCommentId = $pCommentId;
+ $this->mContentId = $pContentId;
+
+ if ($this->mCommentId || $this->mContentId) {
+ $this->loadComment();
+ }
+ }
+
+
+ function loadComment() {
+ global $gBitSystem;
+ if (!$this->mCommentId && !$this->mContentId) {
+ return NULL;
+ }
+
+ if ($this->mCommentId) {
+ $mid = 'WHERE tc.`comment_id` = ?';
+ $bindVars = array($this->mCommentId);
+ } else {
+ $mid = 'WHERE tcn.`content_id` = ?';
+ $bindVars = array($this->mContentId);
+ }
+
+ $sql = "SELECT tc.*, tcn.*, uu.`email`, uu.`real_name`, uu.`login` AS `user`
+ FROM `".BIT_DB_PREFIX."tiki_comments` tc LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_content` tcn ON (tc.`content_id` = tcn.`content_id`)
+ LEFT OUTER JOIN `".BIT_DB_PREFIX."users_users` uu ON (tcn.`user_id` = uu.`user_id`)
+ $mid";
+ $rs = $this->query($sql, $bindVars);
+
+ if ($rs && $rs->numRows()) {
+ $this->mInfo = $rs->fields;
+ $this->mContentId = $rs->fields['content_id'];
+ $this->mCommentId = $rs->fields['comment_id'];
+ }
+ return count($this->mInfo);
+ }
+
+ function verifyComment(&$pStorageHash) {
+ if (!$pStorageHash['parent_id']) {
+ $this->mErrors['parent_id'] = "Missing parent id for comment";
+ }
+ return (count($this->mErrors) == 0);
+ }
+
+ function storeComment($pStorageHash) {
+ $pStorageHash['content_type_guid'] = BITCOMMENT_CONTENT_TYPE_GUID;
+ if (!$this->mCommentId) {
+ if( LibertyContent::store( $pStorageHash ) ) {
+ if ($this->verifyComment($pStorageHash)) {
+ $this->mCommentId = $this->GenID( 'tiki_comments_comment_id_seq');
+ $sql = "INSERT INTO `".BIT_DB_PREFIX."tiki_comments` (`comment_id`, `content_id`, `parent_id`) VALUES (?,?,?)";
+ $this->query($sql, array($this->mCommentId, $pStorageHash['content_id'], $pStorageHash['parent_id']));
+ $this->mInfo['parent_id'] = $pStorageHash['parent_id'];
+ $this->mInfo['content_id'] = $pStorageHash['content_id'];
+ $this->mContentId = $pStorageHash['content_id'];
+ }
+ }
+ } else {
+ if( $this->verifyComment($pStorageHash) && LibertyContent::store($pStorageHash) ) {
+ $sql = "UPDATE `".BIT_DB_PREFIX."tiki_comments` SET `parent_id` = ?, `content_id`= ? WHERE `comment_id` = ?";
+ $this->query($sql, array($pStorageHash['parent_id'], $pStorageHash['content_id'], $this->mCommentId));
+ $this->mInfo['parent_id'] = $pStorageHash['parent_id'];
+ $this->mInfo['content_id'] = $pStorageHash['content_id'];
+ $this->mContentId = $pStorageHash['content_id'];
+ }
+ }
+ return (count($this->mErrors) == 0);
+ }
+
+ function deleteComment() {
+ $sql = "SELECT `comment_id` FROM `".BIT_DB_PREFIX."tiki_comments` WHERE `parent_id` = ?";
+ $rs = $this->query($sql, array($this->mContentId));
+
+ $rows = $rs->getRows();
+ foreach ($rows as $row) {
+ $comment = new LibertyComment($row['comment_id']);
+ $comment->deleteComment();
+ }
+
+ $sql = "DELETE FROM `".BIT_DB_PREFIX."tiki_comments` WHERE `comment_id` = ?";
+ $rs = $this->query($sql, array($this->mCommentId));
+
+ $sql = "DELETE FROM `".BIT_DB_PREFIX."tiki_content` WHERE `content_id` = ?";
+ $rs = $this->query($sql, array($this->mContentId));
+ }
+
+ function userCanEdit($pUserId = NULL) {
+ global $gBitUser;
+
+ if (empty($pUserId)) {
+ if (!empty($gBitUser)) {
+ return ($gBitUser->isAdmin() || $gBitUser->mUserId == $this->mInfo['user_id']);
+ } else {
+ return FALSE;
+ }
+ }
+ if ($pUserId == $this->mInfo['user_id']) {
+ return TRUE;
+ }
+ $tmpUser = new BitUser($pUserId);
+ $tmpUser->load();
+ return ($tmpUser->isAdmin());
+ }
+
+ /**
+ * @param pLinkText name of
+ * @param pMixed different possibilities depending on derived class
+ * @return the link to display the page.
+ */
+ function getDisplayUrl( $pLinkText=NULL, $pMixed=NULL ) {
+ if( empty( $pMixed ) ) {
+ $pMixed = &$this->mInfo;
+ }
+ $ret = NULL;
+ if( !empty( $pMixed['parent_id'] ) && $viewContent = LibertyBase::getLibertyObject( $pMixed['parent_id'] ) ) {
+ $ret = $viewContent->getDisplayUrl();
+ }
+ return( $ret );
+ }
+
+
+ function getList( $pParamHash ) {
+ global $gBitSystem;
+ if ( !isset( $pParamHash['sort_mode']) or $pParamHash['sort_mode'] == '' ){
+ $pParamHash['sort_mode'] = 'last_modified_desc';
+ }
+ if( empty( $pParamHash['max_records'] ) ) {
+ $pParamHash['max_records'] = $gBitSystem->getPreference( 'maxRecords' );
+ }
+ LibertyContent::prepGetList( $pParamHash );
+ $sort_mode = $this->convert_sortmode($pParamHash['sort_mode']);
+
+ $mid = '';
+ $bindVars = array();
+ if ( !empty( $pParamHash['content_type_guid'] ) ) {
+ $mid .= " AND tc.`content_type_guid`=? ";
+ $bindVars[] = $pParamHash['content_type_guid'];
+ }
+ if ( !empty( $pParamHash['user_id'] ) ) {
+ $mid .= " AND tc.`user_id`=? ";
+ $bindVars[] = $pParamHash['user_id'];
+ }
+
+ $query = "SELECT DISTINCT( tc.`content_id` ), tc.`title` AS `content_title`, tc.`created`, tcmc.`last_modified`, tcmc.`title`, uu.`login` AS `user`, uu.`real_name`
+ FROM `".BIT_DB_PREFIX."tiki_comments` tcm INNER JOIN `".BIT_DB_PREFIX."tiki_content` tcmc ON (tcm.`content_id`=tcmc.`content_id` ), `".BIT_DB_PREFIX."tiki_content` tc, `".BIT_DB_PREFIX."users_users` uu
+ WHERE tcm.`parent_id`=tc.`content_id` AND uu.`user_id`=tcmc.`user_id` $mid ORDER BY $sort_mode";
+ if( $result = $this->query($query, $bindVars, $pParamHash['max_records'], $pParamHash['offset']) ) {
+ $ret = $result->GetRows();
+ }
+
+ return $ret;
+ }
+
+
+ function getNumComments($pContentId = NULL) {
+ $contentId = NULL;
+ if (!$pContentId && $this->mContentId) {
+ $contentId = $this->mContentId;
+ } elseif ($pContentId) {
+ $contentId = $pContentId;
+ }
+ $commentCount = 0;
+ if ($contentId) {
+ $sql = "SELECT tcm.*, tcmc.`parent_id` AS `child_content_id`
+ FROM `tiki_comments` tcm LEFT OUTER JOIN `tiki_comments` tcmc ON (tcm.`content_id`=tcmc.`parent_id`)
+ WHERE tcm.`parent_id` = ?";
+ $rows = $this->GetAssoc($sql, array($contentId));
+ $commentCount += count($rows);
+/* We do not want to count the children since they will be displayed on the page and it would mess up pagination - spiderr
+ I may be wrong, so I'll leave the complete code in for now
+ foreach ($rows as $row) {
+ if( !empty( $row['child_content_id'] ) ) {
+ $commentCount += $this->getNumComments( $row['child_content_id'] );
+ }
+ }
+*/
+ }
+ return $commentCount;
+ }
+
+ // Returns a hash containing the comment tree of comments related to this content
+ function getComments( $pContentId = NULL, $pMaxComments = NULL, $pOffset = NULL ) {
+ static $curLevel = 0;
+
+ $contentId = NULL;
+ $ret = array();
+ if (!$pContentId && $this->mContentId) {
+ $contentId = $this->mContentId;
+ } elseif ($pContentId) {
+ $contentId = $pContentId;
+ }
+ if ($contentId) {
+ $sql = "SELECT tcm.`comment_id` FROM `".BIT_DB_PREFIX."tiki_comments` tcm, `".BIT_DB_PREFIX."tiki_content` tc
+ WHERE tcm.`parent_id` = ? AND tcm.`content_id` = tc.`content_id` ORDER BY tc.`created`";
+ $rs = $this->query( $sql, array($contentId), $pMaxComments, $pOffset );
+ $rows = $rs->getRows();
+ foreach ($rows as $row) {
+ $comment = new LibertyComment($row['comment_id']);
+ $comment->mInfo['level'] = $curLevel;
+ $curLevel++;
+ $comment->mInfo['children'] = $this->getComments($comment->mInfo['content_id']);
+ $comment->mInfo['parsed_data'] = $this->parseData($comment->mInfo['data'], $comment->mInfo['format_guid']);
+ $curLevel--;
+ $ret[] = $comment->mInfo;
+ }
+ }
+ return $ret;
+ }
+
+ // Basic formatting for quoting comments
+ function quoteComment($commentData) {
+ $ret = '> '.$commentData;
+ $ret = eregi_replace("\n", "\n>", $ret);
+ return $ret;
+ }
+}
+
+?>
diff --git a/LibertyContent.php b/LibertyContent.php
new file mode 100644
index 0000000..e02f304
--- /dev/null
+++ b/LibertyContent.php
@@ -0,0 +1,856 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Authors: spider <spider@steelsun.com>
+// +----------------------------------------------------------------------+
+//
+// $Id: LibertyContent.php,v 1.1 2005/06/19 04:55:47 bitweaver Exp $
+
+/**
+* Virtual base class (as much as one can have such things in PHP) for all
+* derived tikiwiki classes that require database access.
+*
+* @abstract
+* @author spider <spider@steelsun.com>
+* @version $Revision: 1.1 $
+* @package BitBase
+*/
+
+// define( 'CONTENT_TYPE_WIKI', '1' );
+// define( 'CONTENT_TYPE_COMMENT', '3' );
+// define( 'CONTENT_TYPE_USER', '4' );
+
+// Maximum lengths for database fields
+define( 'BIT_CONTENT_MAX_TITLE_LEN', 160);
+define( 'BIT_CONTENT_MAX_LANGUAGE_LEN', 4);
+define( 'BIT_CONTENT_MAX_IP_LEN', 39);
+define( 'BIT_CONTENT_MAX_FORMAT_GUID_LEN', 16);
+
+require_once( LIBERTY_PKG_PATH.'LibertyBase.php' );
+
+class LibertyContent extends LibertyBase {
+ var $mContentId;
+ /**
+ * If this content is being viewed within a structure
+ * @public
+ */
+ var $mStructureId;
+ /**
+ * Content type GUID for this LibertyContent object
+ * @public
+ */
+ var $mContentTypeGuid;
+ /**
+ * Content type hash for this LibertyContent object
+ * @public
+ */
+ var $mType;
+ /**
+ * Permissions hash specific to this LibertyContent object
+ * @public
+ */
+ var $mPerms;
+
+ function LibertyContent () {
+ LibertyBase::LibertyBase();
+ $this->mPerms = array();
+ }
+
+ function load($pContentId = NULL) {
+ // assume a derived class has joined on the tiki_content table, and loaded it's columns already.
+ if( !empty( $this->mInfo['content_type_guid'] ) ) {
+ global $gLibertySystem, $gBitSystem;
+ $this->mInfo['content_type'] = $gLibertySystem->mContentTypes[$this->mInfo['content_type_guid']];
+ if( $gBitSystem->isPackageActive( 'gatekeeper' ) ) {
+// $this->mInfo['perm_level'] = $this->getUserPermissions();
+ }
+ }
+
+ }
+
+ function verify( &$pParamHash ) {
+ global $gLibertySystem;
+ if( empty( $pParamHash['user_id'] ) ) {
+ global $gBitUser;
+ $pParamHash['user_id'] = $gBitUser->getUserId();
+ }
+
+ if( empty( $pParamHash['content_id'] ) ) {
+ if( empty( $this->mContentId ) ) {
+ // These should never be updated, only inserted
+ $pParamHash['content_store']['created'] = !empty( $pParamHash['created'] ) ? $pParamHash['created'] : date( "U" );
+ $pParamHash['content_store']['user_id'] = $pParamHash['user_id'];
+ } else {
+ $pParamHash['content_id'] = $this->mContentId;
+ }
+ }
+
+ $pParamHash['field_changed'] = empty( $pParamHash['content_id'] )
+ || (!empty($this->mInfo["data"]) && !empty($_REQUEST["edit"]) && (md5($this->mInfo["data"]) != md5($_REQUEST["edit"])))
+ || (!empty($_REQUEST["title"]) && !empty($this->mInfo["title"]) && (md5($this->mInfo["title"]) != md5($_REQUEST["title"])));
+ // check some lengths, if too long, then truncate
+ if( !empty( $pParamHash['title'] ) ) {
+ $pParamHash['content_store']['title'] = substr( $pParamHash['title'], 0, 160 );
+ }
+
+ $pParamHash['content_store']['last_modified'] = !empty( $pParamHash['last_modified'] ) ? $pParamHash['last_modified'] : date("U");
+
+ // WARNING: Assume WIKI if t
+ if( isset( $pParamHash['content_id'] ) ) {
+ // do NOT allow changing of content_type_guid in update for safety of overridden secondary classes (like BitBook )
+ unset( $pParamHash['content_store']['content_type_guid'] );
+ } elseif( empty( $pParamHash['content_type_guid'] ) ) {
+ $this->mErrors['content_type'] = tra( 'System Error: Unknown content type' );
+ } else {
+ $pParamHash['content_store']['content_type_guid'] = $pParamHash['content_type_guid'];
+ }
+
+ // setup some required defaults if not defined
+ if( empty( $pParamHash['ip'] ) ) {
+ if( empty( $_SERVER["REMOTE_ADDR"] ) ) {
+ $pParamHash['ip'] = '127.0.0.1';
+ } else {
+ $pParamHash['ip'] = $_SERVER["REMOTE_ADDR"];
+ }
+ }
+ $pParamHash['content_store']['ip'] = $pParamHash['ip'];
+
+ if( empty( $pParamHash['modifier_user_id'] ) ) {
+ global $gBitUser;
+ $pParamHash['modifier_user_id'] = $gBitUser->getUserId();
+ }
+ $pParamHash['content_store']['modifier_user_id'] = $pParamHash['modifier_user_id'];
+
+ if( empty( $pParamHash['format_guid'] ) ) {
+ $pParamHash['format_guid'] = 'tikiwiki';
+ }
+ $pParamHash['content_store']['format_guid'] = $pParamHash['format_guid'];
+
+ if( !empty( $pParamHash['hits'] ) ) {
+ $pParamHash['content_store']['hits'] = $pParamHash['hits'] + 1;
+ }
+
+ if( !empty( $pParamHash['edit'] ) && $func = $gLibertySystem->getPluginFunction( $pParamHash['format_guid'], 'verify_function' ) ) {
+ $error = $func( $pParamHash );
+ if( $error ) {
+ $this->mErrors['format'] = $error;
+ }
+ }
+
+ return( count( $this->mErrors ) == 0 );
+
+ }
+
+ // Things to be stored should be shoved in the array $pParamHash['STORAGE']
+ function store( &$pParamHash ) {
+ global $gBitSystem;
+ global $gLibertySystem;
+ if( LibertyContent::verify( $pParamHash ) ) {
+ $this->mDb->StartTrans();
+ $table = BIT_DB_PREFIX."tiki_content";
+ if( empty( $pParamHash['content_id'] ) ) {
+ $pParamHash['content_store']['content_id'] = $this->GenID( 'tiki_content_id_seq' );
+ $pParamHash['content_id'] = $pParamHash['content_store']['content_id'];
+ $result = $this->associateInsert( $table, $pParamHash['content_store'] );
+ } else {
+ if( !empty( $pParamHash['content_store']['title'] ) ) {
+ $renamed = $pParamHash['content_store']['title'] != $this->mInfo['title'];
+ }
+ $locId = array ( "name" => "content_id", "value" => $pParamHash['content_id'] );
+ $result = $this->associateUpdate( $table, $pParamHash['content_store'], $locId );
+ }
+
+ // If a content access system is active, let's call it
+ if( $gBitSystem->isPackageActive( 'gatekeeper' ) ) {
+ global $gGatekeeper;
+ if( !$gGatekeeper->storeSecurity( $pParamHash ) ) {
+ $this->mErrors['security'] = $gGatekeeper->mErrors['security'];
+ }
+ }
+
+ // Call the formatter's save
+ if( !empty( $pParamHash['edit'] ) ) {
+ if( $func = $gLibertySystem->getPluginFunction( $pParamHash['format_guid'], 'store_function' ) ) {
+ $ret = $func( $pParamHash );
+ }
+ }
+
+ // If we renamed the page, we need to update the backlinks
+ if( !empty( $renamed ) && $func = $gLibertySystem->getPluginFunction( $pParamHash['format_guid'], 'rename_function' ) ) {
+ $ret = $func( $this->mContentId, $this->mInfo['title'], $pParamHash['content_store']['title'], $this );
+ }
+ $this->mDb->CompleteTrans();
+ }
+ return( count( $this->mErrors ) == 0 );
+ }
+
+ function expungeComments() {
+ require_once( LIBERTY_PKG_PATH.'LibertyComment.php' );
+ // Delete all comments associated with this piece of content
+ $query = "SELECT `comment_id` FROM `".BIT_DB_PREFIX."tiki_comments` WHERE `parent_id` = ?";
+ $result = $this->query($query, array( $this->mContentId ) );
+ $commentIds = $result->getRows();
+ foreach ($commentIds as $commentId) {
+ $tmpComment = new LibertyComment($commentId);
+ $tmpComment->deleteComment();
+ }
+ return TRUE;
+ }
+
+ function expunge() {
+ global $gBitSystem;
+ $ret = FALSE;
+ if( $this->isValid() ) {
+ $this->mDb->StartTrans();
+ $this->expungeComments();
+
+ if( $gBitSystem->isPackageActive( 'categories' ) ) {
+ require_once( CATEGORIES_PKG_PATH.'categ_lib.php' );
+ global $categlib;
+ $categlib->uncategorize_object( $this->mType['content_type_guid'], $this->mContentId );
+ }
+
+ /* seems out of place - xing
+ if( $func = $gLibertySystem->getPluginFunction( $pParamHash['format_guid'], 'expunge_function' ) ) {
+ $ret = $func( $this->mContentId );
+ }
+ */
+
+ $query = "DELETE FROM `".BIT_DB_PREFIX."tiki_content` WHERE `content_id` = ?";
+ $result = $this->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->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->query($query,array((int)$object,$type));
+ return true;
+ }
+*/
+ return $ret;
+ }
+
+ function exportHtml( $pData = NULL ) {
+ $ret = NULL;
+ $ret[] = array( 'type' => $this->mContentTypeGuid,
+ 'landscape' => FALSE,
+ 'url' => $this->getDisplayUrl(),
+ 'content_id' => $this->mContentId,
+ );
+ return $ret;
+ }
+
+ function isValid() {
+ return( !empty( $this->mContentId ) && is_numeric( $this->mContentId ) );
+ }
+
+ function isOwner() {
+ global $gBitUser;
+ return( $this->isValid() && !empty( $this->mInfo['user_id'] ) && $this->mInfo['user_id'] == $gBitUser->mUserId );
+ }
+
+ function loadPermissions() {
+ if( $this->isValid() && empty( $this->mPerms ) && $this->mContentTypeGuid ) {
+ //$object_id = md5($object_type . $object_id);
+ $query = "select uop.`perm_name`, ug.`group_id`, ug.`group_name`
+ FROM `".BIT_DB_PREFIX."users_objectpermissions` uop
+ INNER JOIN `".BIT_DB_PREFIX."users_groups` ug ON( uop.`group_id`=ug.`group_id` )
+ WHERE uop.`object_id` = ? AND uop.`object_type` = ?";
+ $bindVars = array( $this->mContentId, $this->mContentTypeGuid );
+ $this->mPerms = $this->GetAssoc($query, $bindVars);
+ }
+ return( count( $this->mPerms ) );
+ }
+
+
+ /**
+ * Function that determines if this content specified permission for the current gBitUser
+ * @return the fully specified path to file to be included
+ */
+ function hasUserPermission( $pPermName, $pFatalIfFalse=FALSE, $pFatalMessage=NULL ) {
+ global $gBitUser;
+ if( !$gBitUser->isRegistered() || !($ret = $this->isOwner()) ) {
+ if( !($ret = $gBitUser->isAdmin()) ) {
+ if( $this->loadPermissions() ) {
+ $userPerms = $this->getUserPermissions( $gBitUser->mUserId );
+ $ret = isset( $userPerms[$pPermName]['user_id'] ) && ( $userPerms[$pPermName]['user_id'] == $gBitUser->mUserId );
+ } else {
+ $ret = $gBitUser->hasPermission( $pPermName );
+ }
+ }
+ }
+ return( $ret );
+ }
+
+
+ // get specific permissions for the specified user for this content
+ function getUserPermissions( $pUserId ) {
+ $ret = array();
+ if( $pUserId ) {
+ $query = "SELECT uop.`perm_name`, ug.`group_id`, ug.`group_name`, ugm.`user_id`
+ FROM `".BIT_DB_PREFIX."users_objectpermissions` uop
+ INNER JOIN `".BIT_DB_PREFIX."users_groups` ug ON( uop.`group_id`=ug.`group_id` )
+ INNER JOIN `".BIT_DB_PREFIX."users_groups_map` ugm ON( ugm.`group_id`=ug.`group_id` )
+ WHERE ugm.`user_id`=? AND uop.`object_id` = ? AND uop.`object_type` = ? ";
+ $bindVars = array( $pUserId, $this->mContentId, $this->mContentTypeGuid );
+ $ret = $this->GetAssoc($query, $bindVars);
+ }
+ return $ret;
+ }
+
+
+ function storePermission( $pGroupId, $perm_name, $object_id=NULL ) {
+ if( empty( $object_id ) ) {
+ $object_id = $this->mContentId;
+ }
+ //$object_id = md5($object_type . $object_id);
+ $query = "DELETE FROM `".BIT_DB_PREFIX."users_objectpermissions`
+ WHERE `group_id` = ? AND `perm_name` = ? AND `object_id` = ?";
+ $result = $this->query($query, array($pGroupId, $perm_name, $object_id), -1, -1);
+ $query = "insert into `".BIT_DB_PREFIX."users_objectpermissions`
+ (`group_id`,`object_id`, `object_type`, `perm_name`)
+ VALUES ( ?, ?, ?, ? )";
+ $result = $this->query($query, array($pGroupId, $object_id, $this->mContentTypeGuid, $perm_name));
+ return true;
+ }
+
+
+ function hasPermission( $pUserId, $object_id, $object_type, $perm_name ) {
+ $ret = FALSE;
+ $groups = $this->get_user_groups( $pUserId );
+ foreach ( $groups as $group_name ) {
+ $query = "SELECT count(*)
+ FROM `".BIT_DB_PREFIX."users_objectpermissions`
+ WHERE `group_name` = ? and `object_id` = ? and `object_type` = ? and `perm_name` = ?";
+ $bindVars = array($group_name, $object_id, $object_type, $perm_name);
+ $result = $this->getOne( $query, $bindVars );
+ if ($result>0) {
+ $ret = true;
+ }
+ }
+ return $ret;
+ }
+
+
+ function removePermission( $pGroupId, $perm_name ) {
+ //$object_id = md5($object_type . $object_id);
+ $query = "delete from `".BIT_DB_PREFIX."users_objectpermissions`
+ where `group_id` = ? and `object_id` = ?
+ and `object_type` = ? and `perm_name` = ?";
+ $bindVars = array($pGroupId, $this->mContentId, $this->mContentTypeGuid, $perm_name);
+ $result = $this->query($query, $bindVars);
+ return true;
+ }
+
+
+ function copyPermissions( $destinationObjectId ) {
+ //$object_id = md5($object_type.$object_id);
+ $query = "select `perm_name`, `group_name`
+ from `".BIT_DB_PREFIX."users_objectpermissions`
+ where `object_id` =? and `object_type` = ?";
+ $bindVars = array( $this->mContentId, $this->mContentTypeGuid );
+ $result = $this->query($query, $bindVars);
+ while($res = $result->fetchRow()) {
+ $this->storePermission( $res["group_name"], $this->mContentTypeGuid, $res["perm_name"], $destinationObjectId );
+ }
+ return true;
+ }
+
+
+
+
+ function registerContentType( $pContentGuid, $pTypeParams ) {
+ global $gLibertySystem;
+ $gLibertySystem->registerContentType( $pContentGuid, $pTypeParams );
+ $this->mType = $pTypeParams;
+ }
+
+ function addHit() {
+ global $gBitUser;
+ if( $this->mContentId && ($gBitUser->mUserId != $this->mInfo['user_id'] ) ) {
+ $query = "update `".BIT_DB_PREFIX."tiki_content` set `hits`=`hits`+1 where `content_id` = ?";
+ $result = $this->query( $query, array( $this->mContentId ) );
+ }
+ return true;
+ }
+
+
+ /**
+ * Determines if a wiki page (row in tiki_pages) exists, and returns a hash of important info. If N pages exists with $pPageName, returned existsHash has a row for each unique pPageName row.
+ * @param pPageName name of the wiki page
+ * @param pCaseSensitive look for case sensitive names
+ */
+ function pageExists( $pPageName, $pCaseSensitive=FALSE ) {
+ $ret = NULL;
+ $pageWhere = $pCaseSensitive ? 'tc.`title`' : 'LOWER( tc.`title` )';
+ $bindVars = array( ($pCaseSensitive ? $pPageName : strtolower( $pPageName ) ) );
+ $query = "SELECT `page_id`, tp.`content_id`, `description`, tc.`last_modified`, tc.`title`
+ FROM `".BIT_DB_PREFIX."tiki_pages` tp, `".BIT_DB_PREFIX."tiki_content` tc
+ WHERE tc.`content_id`=tp.`content_id` AND $pageWhere = ?";
+ $result = $this->query($query, array( $bindVars ));
+
+ if( $result->numRows() ) {
+ $ret = $result->getArray();
+ }
+
+ return $ret;
+ }
+
+
+ function getTitle( $pHash=NULL ) {
+ $ret = NULL;
+ if( empty( $pHash ) ) {
+ $pHash = &$this->mInfo;
+ }
+ if( !empty( $pHash['title'] ) ) {
+ $ret = $pHash['title'];
+ } elseif( !empty( $pHash['content_description'] ) ) {
+ $ret = $pHash['content_description'];
+ }
+ return $ret;
+ }
+
+
+ function getContentType() {
+ $ret = NULL;
+ if( isset( $this->mInfo['content_type_guid'] ) ) {
+ $ret = $this->mInfo['content_type_guid'];
+ }
+ return $ret;
+ }
+
+
+ /**
+ * Pure virtual function that returns the include file that should render a page of content of this type
+ * @return the fully specified path to file to be included
+ */
+ function getRenderFile() {
+ return LIBERTY_PKG_PATH.'display_content_inc.php';
+ }
+
+ /**
+ * Pure virtual function that returns link to display a piece of content
+ * @param pLinkText name of
+ * @param pMixed different possibilities depending on derived class
+ * @return the link to display the page.
+ */
+ function getDisplayLink( $pLinkText, $pMixed ) {
+ $ret = '';
+ if( $this ) {
+ $title = $this->getTitle();
+ if( empty( $title ) && !empty( $pMixed['title'] ) ) {
+ $title = $pMixed['title'];
+ }
+ $ret = '<a href="'.BIT_ROOT_URL.'index.php?content_id='.$pMixed['content_id'].'">'.$title.'</a>';
+ }
+ return $ret;
+ }
+
+ /**
+ * Pure virtual function that returns Request_URI to a piece of content
+ * @param pLinkText name of
+ * @param pMixed different possibilities depending on derived class
+ * @return the link to display the page.
+ */
+ function getDisplayUrl( $pLinkText, $pMixed ) {
+ print "UNDEFINED PURE VIRTUAL FUNCTION: LibertyContent::getDisplayUrl";
+ }
+
+ /**
+ * Updates results from any getList function to provide the control set
+ * displaying in the smarty template
+ * @param pParamHash hash of parameters returned by any getList() function
+ * @return - none the hash is updated via the reference
+ */
+ function postGetList( &$pListHash ) {
+
+ $pListHash['control']['cant_pages'] = ceil($pListHash["cant"] / $pListHash['max_records']);
+
+ $pListHash['control']['actual_page'] = 1 + ($pListHash['offset'] / $pListHash['max_records']);
+
+ if ($pListHash["cant"] > ($pListHash['offset'] + $pListHash['max_records']) ) {
+ $pListHash['control']['next_offset'] = $pListHash['offset'] + $pListHash['max_records'];
+ } else {
+ $pListHash['control']['next_offset'] = -1;
+ }
+ // If offset is > 0 then prev_offset
+ if ($pListHash['offset'] > 0) {
+ $pListHash['control']['prev_offset'] = $pListHash['offset'] - $pListHash['max_records'];
+ } else {
+ $pListHash['control']['prev_offset'] = -1;
+ }
+ $pListHash['control']['offset'] = $pListHash['offset'];
+ $pListHash['control']['find'] = $pListHash['find'];
+ $pListHash['control']['sort_mode'] = $pListHash['sort_mode'];
+ $pListHash['control']['max_records'] = $pListHash['max_records'];
+ }
+
+ /**
+ * Get a list of users this content is a member of
+ **/
+ function getAuthorList( &$pListHash ) {
+ $ret = NULL;
+ $mid = '';
+
+ $bindVars = array();
+ if( !empty( $pListHash['content_type_guid'] ) ) {
+ $mid .= ' AND tc.`content_type_guid`=? ';
+ $bindVars[] = $pListHash['content_type_guid'];
+ }
+
+ $this->prepGetList( $pListHash );
+ $query = "SELECT DISTINCT(uu.`user_id`) AS hash_key, uu.`user_id`, SUM( tc.`hits` ) AS `ag_hits`, uu.`login` AS `user`, uu.`real_name`
+ FROM `".BIT_DB_PREFIX."tiki_content` tc INNER JOIN `".BIT_DB_PREFIX."users_users` uu ON( uu.`user_id`=tc.`user_id` )
+ WHERE uu.`user_id` != ".ANONYMOUS_USER_ID." AND tc.`hits` > 0 $mid
+ GROUP BY uu.`user_id`, uu.`login`, uu.`real_name`
+ ORDER BY `ag_hits` DESC";
+ if( $result = $this->query( $query, $bindVars, $pListHash['max_records'], $pListHash['offset'] ) ) {
+ $ret = $result->GetRows();
+ }
+ return $ret;
+ }
+
+
+ /**
+ * Get a list of all structures this content is a member of
+ **/
+ function getContentList( $pContentGuid=NULL, $offset = 0, $maxRecords = -1, $sort_mode = 'title_desc', $find = NULL, $pUserId=NULL ) {
+ global $gLibertySystem, $gBitSystem, $gBitUser, $smarty;
+ if ($sort_mode == 'size_desc') {
+ $sort_mode = 'page_size_desc';
+ }
+
+ if ($sort_mode == 'size_asc') {
+ $sort_mode = 'page_size_asc';
+ }
+
+ $old_sort_mode = '';
+
+ if (in_array($sort_mode, array(
+ 'versions_desc',
+ 'versions_asc',
+ 'links_asc',
+ 'links_desc',
+ 'backlinks_asc',
+ 'backlinks_desc'
+ ))) {
+ $old_offset = $offset;
+ $old_maxRecords = $maxRecords;
+ $old_sort_mode = $sort_mode;
+ $sort_mode = 'modifier_user_desc';
+ $offset = 0;
+ $maxRecords = -1;
+ }
+
+ $bindVars = array();
+ $mid = NULL;
+ $gateSelect = '';
+ $gateFrom = '';
+
+ if (is_array($find)) { // you can use an array of pages
+ $mid = " WHERE tc.`title` IN (".implode(',',array_fill(0,count($find),'?')).")";
+ $bindVars[] = $find;
+ } elseif (!empty($find) && is_string($find)) { // or a string
+ $mid = " WHERE UPPER(tc.`title`) like ? ";
+ $bindVars[] = ('%' . strtoupper( $find ) . '%');
+ }
+
+ if( $gBitSystem->isPackageActive( 'gatekeeper' ) ) {
+ empty( $mid ) ? $mid = ' WHERE ' : $mid .= ' AND ';
+ $gateSelect .= ' ,ts.`security_id`, ts.`security_description`, ts.`is_private`, ts.`is_hidden`, ts.`access_question`, ts.`access_answer` ';
+ $gateFrom .= " LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_content_security_map` tcs ON (tc.`content_id`=tcs.`content_id`) LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_security` ts ON (ts.`security_id`=tcs.`security_id` )";
+ $mid .= ' (tcs.`security_id` IS NULL OR tc.`user_id`=?) ';
+ $bindVars[] = $gBitUser->mUserId;
+ }
+
+ if( !empty( $pUserId ) ) {
+ empty( $mid ) ? $mid = ' WHERE ' : $mid .= ' AND ';
+ $mid .= " tc.`user_id` = ? ";
+ $bindVars[] = $pUserId;
+ }
+
+ if( !empty( $pContentGuid ) ) {
+ empty( $mid ) ? $mid = ' WHERE ' : $mid .= ' AND ';
+ $mid .= ' `content_type_guid`=? ';
+ $bindVars[] = $pContentGuid;
+ }
+
+
+
+ // If sort mode is versions then offset is 0, maxRecords is -1 (again) and sort_mode is nil
+ // If sort mode is links then offset is 0, maxRecords is -1 (again) and sort_mode is nil
+ // If sort mode is backlinks then offset is 0, maxRecords is -1 (again) and sort_mode is nil
+ $query = "SELECT uue.`login` AS `modifier_user`, uue.`real_name` AS `modifier_real_name`, uue.`user_id` AS `modifier_user_id`, uuc.`login` AS`creator_user`, uuc.`real_name` AS `creator_real_name`, uuc.`user_id` AS `creator_user_id`, `hits`, tc.`title`, tc.`last_modified`, tc.`content_type_guid`, `ip`, tc.`content_id` $gateSelect
+ FROM `".BIT_DB_PREFIX."tiki_content` tc $gateFrom, `".BIT_DB_PREFIX."users_users` uue, `".BIT_DB_PREFIX."users_users` uuc
+ ".(!empty( $mid ) ? $mid.' AND ' : ' WHERE ')." tc.`modifier_user_id`=uue.`user_id` AND tc.`user_id`=uuc.`user_id`
+ ORDER BY tc.".$this->convert_sortmode($sort_mode);
+ $query_cant = "select count(*) FROM `".BIT_DB_PREFIX."tiki_content` tc $gateFrom $mid";
+ // previous cant query - updated by xing
+ // $query_cant = "select count(*) from `".BIT_DB_PREFIX."tiki_pages` tp INNER JOIN `".BIT_DB_PREFIX."tiki_content` tc ON (tc.`content_id` = tp.`content_id`) $mid";
+ $result = $this->query($query,$bindVars,$maxRecords,$offset);
+ $cant = $this->getOne($query_cant,$bindVars);
+ $ret = array();
+ $contentTypes = $gLibertySystem->mContentTypes;
+ while ($res = $result->fetchRow()) {
+ $aux = array();
+ $aux = $res;
+ if( !empty( $contentTypes[$res['content_type_guid']] ) ) {
+ $contentHash = &$contentTypes[$res['content_type_guid']];
+ if( empty( $contentHash['content_object'] ) ) {
+ include_once( $gBitSystem->mPackages[$contentHash['handler_package']]['path'].$contentHash['handler_file'] );
+ $contentHash['content_object'] = new $contentHash['handler_class']();
+ }
+ $aux['creator'] = (isset( $res['creator_real_name'] ) ? $res['creator_real_name'] : $res['creator_user'] );
+ $aux['real_name'] = (isset( $res['creator_real_name'] ) ? $res['creator_real_name'] : $res['creator_user'] );
+ $aux['editor'] = (isset( $res['modifier_real_name'] ) ? $res['modifier_real_name'] : $res['modifier_user'] );
+ $aux['content_description'] = $contentHash['content_description'];
+//WIKI_PKG_URL."index.php?page_d=".$res['page_id'];
+ $aux['user'] = $res['creator_user'];
+ $aux['real_name'] = (isset( $res['creator_real_name'] ) ? $res['creator_real_name'] : $res['creator_user'] );
+ $aux['user_id'] = $res['creator_user_id'];
+ require_once $smarty->_get_plugin_filepath( 'modifier', 'bit_long_date' );
+ $aux['display_link'] =
+ '<a title="'.tra( 'Last modified by' ).': '.$gBitUser->getDisplayName( FALSE, $aux ).' - '.smarty_modifier_bit_long_date( $aux['last_modified'], $smarty ).
+ '" href="'.BIT_ROOT_URL.'index.php?content_id='.$aux['content_id'].'">'.
+ $contentHash['content_object']->getTitle( $aux ).
+ '</a>';
+// $aux['display_url'] = $contentType['content_object']->getDisplayUrl( $aux['title'], $aux );
+ $ret[] = $aux;
+ }
+ }
+
+ // If sortmode is versions, links or backlinks sort using the ad-hoc function and reduce using old_offse and old_maxRecords
+ if ($old_sort_mode == 'versions_asc' && !empty( $ret['versions'] ) ) {
+ usort($ret, 'compare_versions');
+ }
+
+ if ($old_sort_mode == 'versions_desc' && !empty( $ret['versions'] ) ) {
+ usort($ret, 'r_compare_versions');
+ }
+
+ if ($old_sort_mode == 'links_desc' && !empty( $ret['links'] ) ) {
+ usort($ret, 'compare_links');
+ }
+
+ if ($old_sort_mode == 'links_asc' && !empty( $ret['links'] ) ) {
+ usort($ret, 'r_compare_links');
+ }
+
+ if( $old_sort_mode == 'backlinks_desc' && !empty( $ret['backlinks'] ) ) {
+ usort($ret, 'compare_backlinks');
+ }
+
+ if( $old_sort_mode == 'backlinks_asc' && !empty( $ret['backlinks'] ) ) {
+ usort($ret, 'r_compare_backlinks');
+ }
+
+ if (in_array($old_sort_mode, array(
+ 'versions_desc',
+ 'versions_asc',
+ 'links_asc',
+ 'links_desc',
+ 'backlinks_asc',
+ 'backlinks_desc'
+ ))) {
+ $ret = array_slice($ret, $old_offset, $old_maxRecords);
+ }
+
+ $retval = array();
+ $retval["data"] = $ret;
+ $retval["cant"] = $cant;
+ return $retval;
+ }
+
+
+ /**
+ * Get a list of all structures this content is a member of
+ **/
+ function getStructures() {
+ $ret = NULL;
+ if( $this->isValid() ) {
+ $ret = array();
+ $structures_added = array();
+ $query = 'SELECT ts.*, tc.`title`, tcr.`title` AS `root_title`
+ FROM `'.BIT_DB_PREFIX.'tiki_content` tc, `'.BIT_DB_PREFIX.'tiki_structures` ts
+ INNER JOIN `'.BIT_DB_PREFIX.'tiki_structures` tsr ON( tsr.`structure_id`=ts.`root_structure_id` )
+ INNER JOIN `'.BIT_DB_PREFIX.'tiki_content` tcr ON( tsr.`content_id`=tcr.`content_id` )
+ WHERE tc.`content_id`=ts.`content_id` AND ts.`content_id`=?';
+ if( $result = $this->query( $query,array( $this->mContentId ) ) ) {
+ while ($res = $result->fetchRow()) {
+ $ret[] = $res;
+ $result->MoveNext();
+ }
+ }
+ }
+ return $ret;
+ }
+
+
+
+
+
+ // This is the "object like" method. It should be more object like,
+ // but for now, we'll just point to the old lib style "parse_data" - XOXO spiderr
+ function parseData( $pData=NULL, $pFormatGuid=NULL ) {
+ $ret = &$pData;
+ if( empty( $pFormatGuid ) ) {
+ $pFormatGuid = isset( $this->mInfo['format_guid'] ) ? $this->mInfo['format_guid'] : NULL;
+ }
+ if( empty( $pData ) ) {
+ $pData = isset( $this->mInfo['data'] ) ? $this->mInfo['data'] : NULL;
+ }
+ if( $pData && $pFormatGuid ) {
+ global $gLibertySystem;
+ if( $func = $gLibertySystem->getPluginFunction( $pFormatGuid, 'load_function' ) ) {
+ $ret = $func( $pData, $this );
+ }
+ }
+ return $ret;
+ }
+
+
+ //Special parsing for multipage articles
+ function getNumberOfPages( &$data ) {
+ // Temporary remove <PRE></PRE> secions to protect
+ // from broke <PRE> tags and leave well known <PRE>
+ // behaviour (i.e. type all text inside AS IS w/o
+ // any interpretation)
+ $preparsed = array();
+
+ preg_match_all("/(<[Pp][Rr][Ee]>)((.|\n)*?)(<\/[Pp][Rr][Ee]>)/", $data, $preparse);
+ $idx = 0;
+
+ foreach (array_unique($preparse[2])as $pp) {
+ $key = md5(BitSystem::genPass());
+
+ $aux["key"] = $key;
+ $aux["data"] = $pp;
+ $preparsed[] = $aux;
+ $data = str_replace($preparse[1][$idx] . $pp . $preparse[4][$idx], $key, $data);
+ $idx = $idx + 1;
+ }
+
+ $parts = explode(defined('PAGE_SEP') ? PAGE_SEP : "...page...", $data);
+ return count($parts);
+ }
+
+ function getPage( &$data, $i ) {
+ // Temporary remove <PRE></PRE> secions to protect
+ // from broke <PRE> tags and leave well known <PRE>
+ // behaviour (i.e. type all text inside AS IS w/o
+ // any interpretation)
+ $preparsed = array();
+
+ preg_match_all("/(<[Pp][Rr][Ee]>)((.|\n)*?)(<\/[Pp][Rr][Ee]>)/", $data, $preparse);
+ $idx = 0;
+
+ foreach (array_unique($preparse[2])as $pp) {
+ $key = md5(BitSystem::genPass());
+
+ $aux["key"] = $key;
+ $aux["data"] = $pp;
+ $preparsed[] = $aux;
+ $data = str_replace($preparse[1][$idx] . $pp . $preparse[4][$idx], $key, $data);
+ $idx = $idx + 1;
+ }
+
+ // Get slides
+ $parts = explode(defined('PAGE_SEP') ? PAGE_SEP : "...page...", $data);
+
+ if (substr($parts[$i - 1], 1, 5) == "<br/>")
+ $ret = substr($parts[$i - 1], 6);
+ else
+ $ret = $parts[$i - 1];
+
+ // Replace back <PRE> sections
+ foreach ($preparsed as $pp)
+ $ret = str_replace($pp["key"], "<pre>" . $pp["data"] . "</pre>", $ret);
+
+ return $ret;
+ }
+
+
+
+ // ****** LEGACY FUNCTIONS that need to be cleaned / moved / or deprecated & deleted
+
+ function isCached($url) {
+ $query = "select `cache_id` from `".BIT_DB_PREFIX."tiki_link_cache` where `url`=?";
+ // sometimes we can have a cache_id of 0(?!) - seen it with my own eyes, spiderr
+ $ret = $this->getOne($query, array( $url ) );
+ return( isset( $ret ) );
+ }
+
+ /**
+ * \brief Cache given url
+ * If \c $data present (passed) it is just associated \c $url and \c $data.
+ * Else it will request data for given URL and store it in DB.
+ * Actualy (currently) data may be proviced by TIkiIntegrator only.
+ */
+ function cacheUrl($url, $data = '') {
+ // Avoid caching internal references... (only if $data not present)
+ // (cdx) And avoid other protocols than http...
+ // 03-Nov-2003, by zaufi
+ // preg_match("_^(mailto:|ftp:|gopher:|file:|smb:|news:|telnet:|javascript:|nntp:|nfs:)_",$url)
+ // was removed (replaced to explicit http[s]:// detection) bcouse
+ // I now (and actualy use in my production Tiki) another bunch of protocols
+ // available in my konqueror... (like ldap://, ldaps://, nfs://, fish://...)
+ // ... seems like it is better to enum that allowed explicitly than all
+ // noncacheable protocols.
+ if (((strstr($url, 'tiki-') || strstr($url, 'messu-')) && $data == '')
+ || (substr($url, 0, 7) != 'http://' && substr($url, 0, 8) != 'https://'))
+ return false;
+ // Request data for URL if nothing given in parameters
+ // (reuse $data var)
+ if ($data == '') $data = tp_http_request($url);
+
+ // If stuff inside [] is *really* malformatted, $data
+ // will be empty. -rlpowell
+ if (!$this->isCached( $url ) && $data)
+ {
+ $refresh = date("U");
+ $query = "insert into `".BIT_DB_PREFIX."tiki_link_cache`(`url`,`data`,`refresh`) values(?,?,?)";
+ $result = $this->query($query, array($url,BitDb::db_byte_encode($data),$refresh) );
+ return !isset($error);
+ }
+ else return false;
+ }
+
+ function setStructure( $pStructureId ) {
+ if( $this->verifyId( $pStructureId ) ) {
+ $this->mStructureId = $pStructureId;
+ }
+ }
+
+ function isInStructure( $pStructureId=NULL ) {
+ if( $this->isValid() ) {
+ $whereSql = NULL;
+ $bindVars = array( $this->mContentId );
+ if( $pStructureId ) {
+ array_push( $bindVars, $pStructureId );
+ $whereSql = ' AND ts.`root_structure_id`=? ';
+ }
+ $query = "SELECT `structure_id` FROM `".BIT_DB_PREFIX."tiki_structures` ts
+ WHERE ts.`content_id`=? $whereSql";
+ $cant = $this->getOne( $query, $bindVars );
+ return $cant;
+ }
+ }
+
+}
+
+?>
diff --git a/LibertyStructure.php b/LibertyStructure.php
new file mode 100755
index 0000000..d329000
--- /dev/null
+++ b/LibertyStructure.php
@@ -0,0 +1,910 @@
+<?php
+require_once( LIBERTY_PKG_PATH.'LibertyBase.php' );
+class LibertyStructure extends LibertyBase {
+ var $mStructureId;
+
+ function LibertyStructure ( $pStructureId=NULL, $pContentId=NULL ) {
+ // we need to init our mDb early
+ LibertyBase::LibertyBase();
+ $this->mStructureId = $pStructureId;
+ $this->mContentId = $pContentId;
+ }
+
+ function load() {
+ if( $this->mStructureId || $this->mContentId ) {
+ if( $this->mInfo = $this->getNode( $this->mStructureId, $this->mContentId ) ) {
+ global $gLibertySystem;
+ $this->mStructureId = $this->mInfo['structure_id'];
+ $this->mContentId = $this->mInfo['content_id'];
+ $this->mInfo['content_type'] = $gLibertySystem->mContentTypes[$this->mInfo['content_type_guid']];
+ }
+ }
+ return( $this->mInfo && count( $this->mInfo ) );
+ }
+
+ function getNode( $pStructureId=NULL, $pContentId=NULL ) {
+ $ret = NULL;
+ $query = 'SELECT ts.*,tc.`title`, tc.`content_type_guid`, tc.`user_id`
+ FROM `'.BIT_DB_PREFIX.'tiki_structures` ts INNER JOIN `'.BIT_DB_PREFIX.'tiki_content` tc ON (ts.`content_id`=tc.`content_id`)';
+ if( is_numeric( $pStructureId ) ) {
+ $query .= ' WHERE ts.`structure_id`=?';
+ $bindVars = array( $pStructureId );
+ } elseif( is_numeric( $pContentId ) ) {
+ $query .= ' WHERE ts.`content_id`=?';
+ $bindVars = array( $pContentId );
+ }
+ if( $result = $this->query( $query, $bindVars ) ) {
+ $ret = $result->fields;
+ }
+ return $ret;
+ }
+
+ function isRootNode() {
+ $ret = FALSE;
+ if( !empty( $this->mInfo['structure_id'] ) ) {
+ $ret = $this->mInfo['root_structure_id'] == $this->mInfo['structure_id'];
+ }
+ return $ret;
+ }
+
+ function getRootTitle() {
+ $ret = NULL;
+ if( isset( $this->mInfo['structure_path'][0]['title'] ) ) {
+ $ret = $this->mInfo['structure_path'][0]['title'];
+ }
+ return $ret;
+ }
+
+ // This is a utility function mainly used for upgrading sites.
+ function setTreeRoot( $pRootId, $pTree ) {
+ foreach( $pTree as $structRow ) {
+ $this->query( "UPDATE `".BIT_DB_PREFIX."tiki_structures` SET `root_structure_id`=? WHERE `structure_id`=?", array( $pRootId, $structRow["structure_id"] ) );
+ if( !empty( $structRow["sub"] ) ) {
+ $this->setTreeRoot( $pRootId, $structRow["sub"] );
+ }
+ }
+ }
+
+
+ function isValid() {
+ return( !empty( $this->mStructureId ) && is_numeric( $this->mStructureId ) );
+ }
+
+ function loadNavigation() {
+ if( $this->isValid() ) {
+ $this->mInfo["prev"] = null;
+ // Get structure info for this page
+ if( !$this->isRootNode() && ($prev_structure_id = $this->get_prev_page( $this->mStructureId )) ) {
+ $this->mInfo["prev"] = $this->getNode($prev_structure_id);
+ }
+ $next_structure_id = $this->get_next_page( $this->mStructureId );
+ $this->mInfo["next"] = null;
+ if (isset($next_structure_id)) {
+ $this->mInfo["next"] = $this->getNode( $next_structure_id) ;
+ }
+ $this->mInfo["parent"] = $this->s_get_parent_info( $this->mStructureId );
+ $this->mInfo["home"] = $this->getNode( $this->mStructureId );
+ }
+ return TRUE;
+ }
+
+ function loadPath() {
+ if( $this->isValid() ) {
+ $this->mInfo['structure_path'] = $this->getPath( $this->mStructureId );
+ }
+ return( !empty( $this->mInfo['structure_path'] ) );
+ }
+
+ /**
+ * This can be used to construct a path from the structure head to the requested page.
+ * @returns an array of page_info arrays.
+ */
+ function getPath( $pStructureId ) {
+ $structure_path = array();
+ $page_info = $this->getNode($pStructureId);
+
+ if ($page_info["parent_id"]) {
+ $structure_path = $this->getPath($page_info["parent_id"]);
+ }
+ $structure_path[] = $page_info;
+ return $structure_path;
+ }
+
+
+ function getSubTree( $pStructureId, $level = 0, $parent_pos = '' ) {
+ if( !empty( $pStructureId ) ) {
+ $ret = array();
+ $pos = 1;
+ //The structure page is used as a title
+ if ($level == 0) {
+ $struct_info = $this->getNode( $pStructureId );
+ $aux["first"] = true;
+ $aux["last"] = true;
+ $aux["pos"] = '';
+ $aux["structure_id"] = $struct_info["structure_id"];
+ $aux["title"] = $struct_info["title"];
+ $aux["page_alias"] = $struct_info["page_alias"];
+ $ret[] = $aux;
+ $level++;
+ }
+
+ //Get all child nodes for this structure_id
+ $query = "SELECT ts.`content_id`, ts.`structure_id`, ts.`page_alias`, tc.`title`
+ FROM `".BIT_DB_PREFIX."tiki_structures` ts, `".BIT_DB_PREFIX."tiki_content` tc
+ WHERE tc.`content_id` = ts.`content_id` AND `parent_id`=? ORDER BY `pos` asc";
+ $result = $this->query($query,array( $pStructureId ) );
+
+ $subs = array();
+ $row_max = $result->numRows();
+ while ($res = $result->fetchRow()) {
+ //Add
+ $aux = $res;
+ $aux["first"] = ($pos == 1);
+ $aux["last"] = false;
+ if (strlen($parent_pos) == 0) {
+ $aux["pos"] = "$pos";
+ }
+ else {
+ $aux["pos"] = $parent_pos . '.' . "$pos";
+ }
+ $ret[] = $aux;
+
+ //Recursively add any child nodes
+ $subs = $this->getSubTree($res["structure_id"], ($level + 1), $aux["pos"]);
+ if(isset($subs)) {
+ $ret = array_merge($ret, $subs);
+ }
+ // Insert a dummy entry to close table/list
+ if ($pos == $row_max) {
+ $aux["first"] = false;
+ $aux["last"] = true;
+ $ret[] = $aux;
+ }
+
+ $pos++;
+ }
+ }
+ return $ret;
+ }
+
+
+ function getList( &$pListHash ) {
+ global $gBitSystem;
+
+ $this->prepGetList( $pListHash );
+
+ if( !empty( $pListHash['find'] ) ) {
+ $findesc = '%' . $pListHash['find'] . '%';
+ $mid = " (`parent_id` is null or `parent_id`=0) and (tc.`title` like ?)";
+ $bindVars=array($findesc);
+ } else {
+ $mid = " (`parent_id` is null or `parent_id`=0) ";
+ $bindVars=array();
+ }
+
+ if( !empty( $pListHash['user_id'] ) ) {
+ $mid .= " AND tc.`user_id` = ? ";
+ array_push( $bindVars, $pListHash['user_id'] );
+ }
+
+ if( !empty( $pListHash['content_type_guid'] ) ) {
+ $mid .= " AND tc.`content_type_guid`=? ";
+ array_push( $bindVars, $pListHash['content_type_guid'] );
+ }
+ $query = "SELECT ts.`structure_id`, ts.`parent_id`, ts.`content_id`, `page_alias`, `pos`, tc.`title`, `hits`, `data`, `last_modified`, tc.`modifier_user_id`, `ip`, tc.`user_id` AS `creator_user_id`, uu.`login` AS `user`, uu.`real_name` , uu.`email`
+ FROM `".BIT_DB_PREFIX."tiki_structures` ts INNER JOIN `".BIT_DB_PREFIX."tiki_content` tc ON ( ts.`content_id` = tc.`content_id` ) INNER JOIN `".BIT_DB_PREFIX."users_users` uu ON ( tc.`user_id` = uu.`user_id` )
+ WHERE $mid
+ ORDER BY ".$this->convert_sortmode($pListHash['sort_mode']);
+ $query_cant = "SELECT count(*)
+ FROM `".BIT_DB_PREFIX."tiki_structures` ts INNER JOIN `".BIT_DB_PREFIX."tiki_content` tc ON ( ts.`content_id` = tc.`content_id` )
+ WHERE $mid";
+ $result = $this->query($query,$bindVars,$pListHash['max_records'],$pListHash['offset']);
+ $cant = $this->getOne($query_cant,$bindVars);
+ $ret = array();
+
+ while ($res = $result->fetchRow()) {
+ if( $gBitSystem->isPackageActive( 'bithelp' ) && file_exists(BITHELP_PKG_PATH.$res['title'].'/index.html')) {
+ $res['webhelp']='y';
+ } else {
+ $res['webhelp']='n';
+ }
+ $ret[] = $res;
+ }
+
+ $retval = array();
+ $retval["data"] = $ret;
+ $retval["cant"] = $cant;
+ return $retval;
+ }
+
+ function verifyNode( &$pParamHash ) {
+ if( empty( $pParamHash['content_id'] ) || !is_numeric( $pParamHash['content_id'] ) ) {
+ $this->mErrors['content'] = 'Could not store structure. Invalid content id. '.$pParamHash['content_id'];
+ } else {
+ if( empty( $pParamHash['parent_id'] ) || !is_numeric( $pParamHash['parent_id'] ) ) {
+ $pParamHash['parent_id'] = 0;
+ }
+ if( empty( $pParamHash['alias'] ) ) {
+ $pParamHash['alias'] = '';
+ }
+ if( isset( $pParamHash['after_ref_id'] ) ) {
+ $pParamHash['max'] = $this->getOne("select `pos` from `".BIT_DB_PREFIX."tiki_structures` where `structure_id`=?",array((int)$pParamHash['after_ref_id']));
+ } else {
+ $pParamHash['max'] = $this->getOne("select max(`pos`) from `".BIT_DB_PREFIX."tiki_structures` where `parent_id`=?",array((int)$pParamHash['parent_id']));
+ }
+ if( $pParamHash['max'] > 0 ) {
+ //If max is 5 then we are inserting after position 5 so we'll insert 5 and move all
+ // the others
+ $query = "update `".BIT_DB_PREFIX."tiki_structures` set `pos`=`pos`+1 where `pos`>? and `parent_id`=?";
+ $result = $this->query($query,array((int)$pParamHash['max'], (int)$pParamHash['parent_id']));
+ }
+ $pParamHash['max']++;
+ }
+ return( count( $this->mErrors ) == 0 );
+ }
+
+ /** Create a structure entry with the given name
+ * @param parent_id The parent entry to add this to. If NULL, create new structure.
+ * @param after_ref_id The entry to add this one after. If NULL, put it in position 0.
+ * @param name The wiki page to reference
+ * @param alias An alias for the wiki page name.
+ * @return the new entries structure_id or null if not created.
+ */
+ function storeNode( &$pParamHash ) {
+ $ret = null;
+ // If the page doesn't exist then create a new wiki page!
+ $now = date("U");
+// $created = $this->create_page($name, 0, '', $now, tra('created from structure'), 'system', '0.0.0.0', '');
+ // if were not trying to add a duplicate structure head
+ if ( $this->verifyNode( $pParamHash ) ) {
+ $this->mDb->StartTrans();
+
+ //Create a new structure entry
+ $pParamHash['structure_id'] = $this->GenID( 'tiki_structures_id_seq' );
+ if( empty( $pParamHash['root_structure_id'] ) || !is_numeric( $pParamHash['root_structure_id'] ) ) {
+ $pParamHash['root_structure_id'] = $pParamHash['structure_id'];
+ }
+ $query = "INSERT INTO `".BIT_DB_PREFIX."tiki_structures`( `structure_id`, `parent_id`,`content_id`, `root_structure_id`, `page_alias`, `pos` ) values(?,?,?,?,?,?)";
+ $result = $this->query( $query, array( $pParamHash['structure_id'], $pParamHash['parent_id'], (int)$pParamHash['content_id'], (int)$pParamHash['root_structure_id'], $pParamHash['alias'], $pParamHash['max'] ) );
+ $this->mDb->CompleteTrans();
+ $ret = $pParamHash['structure_id'];
+ } else {
+//vd( $this->mErrors );
+ }
+ return $ret;
+ }
+
+ function moveNodeWest() {
+ if( $this->isValid() ) {
+ //If there is a parent and the parent isnt the structure root node.
+ $this->mDb->StartTrans();
+ if( !empty( $this->mInfo["parent_id"] ) ) {
+ $parentNode = $this->getNode( $this->mInfo["parent_id"] );
+ if( !empty( $parentNode['parent_id'] ) ) {
+ //Make a space for the node after its parent
+ $query = "update `".BIT_DB_PREFIX."tiki_structures` set `pos`=`pos`+1 where `pos`>? and `parent_id`=?";
+ $this->query( $query, array( $parentNode['pos'], $parentNode['parent_id'] ) );
+ //Move the node up one level
+ $query = "update `".BIT_DB_PREFIX."tiki_structures` set `parent_id`=?, `pos`=(? + 1) where `structure_id`=?";
+ $this->query($query, array( $parentNode['parent_id'], $parentNode['pos'], $this->mStructureId ) );
+ }
+ }
+ $this->mDb->CompleteTrans();
+ }
+ }
+
+ function moveNodeEast() {
+ if( $this->isValid() ) {
+ $this->mDb->StartTrans();
+ $query = "select `structure_id`, `pos` from `".BIT_DB_PREFIX."tiki_structures` where `pos`<? and `parent_id`=? order by `pos` desc";
+ $result = $this->query($query,array($this->mInfo["pos"], (int)$this->mInfo["parent_id"]));
+ if ($previous = $result->fetchRow()) {
+ //Get last child nodes for previous sibling
+ $query = "select `pos` from `".BIT_DB_PREFIX."tiki_structures` where `parent_id`=? order by `pos` desc";
+ $result = $this->query($query,array((int)$previous["structure_id"]));
+ if ($res = $result->fetchRow()) {
+ $pos = $res["pos"];
+ } else{
+ $pos = 0;
+ }
+ $query = "update `".BIT_DB_PREFIX."tiki_structures` set `parent_id`=?, `pos`=(? + 1) where `structure_id`=?";
+ $this->query( $query, array((int)$previous["structure_id"], (int)$pos, (int)$this->mStructureId) );
+ //Move nodes up below that had previous parent and pos
+ $query = "update `".BIT_DB_PREFIX."tiki_structures` set `pos`=`pos`-1 where `pos`>? and `parent_id`=?";
+ $this->query( $query, array( $this->mInfo['pos'], $this->mInfo['parent_id'] ) );
+ }
+ $this->mDb->CompleteTrans();
+ }
+ }
+
+ function moveNodeSouth() {
+ if( $this->isValid() ) {
+ $this->mDb->StartTrans();
+ $query = "select `structure_id`, `pos` from `".BIT_DB_PREFIX."tiki_structures` where `pos`>? and `parent_id`=? order by `pos` asc";
+ $result = $this->query($query,array((int)$this->mInfo["pos"], (int)$this->mInfo["parent_id"]));
+ $res = $result->fetchRow();
+ if ($res) {
+ //Swap position values
+ $query = "update `".BIT_DB_PREFIX."tiki_structures` set `pos`=? where `structure_id`=?";
+ $this->query($query,array((int)$this->mInfo["pos"], (int)$res["structure_id"]) );
+ $this->query($query,array((int)$res["pos"], (int)$this->mInfo["structure_id"]) );
+ }
+ $this->mDb->CompleteTrans();
+ }
+ }
+
+ function moveNodeNorth() {
+ if( $this->isValid() ) {
+ $this->mDb->StartTrans();
+ $query = "select `structure_id`, `pos` from `".BIT_DB_PREFIX."tiki_structures` where `pos`<? and `parent_id`=? order by `pos` desc";
+ $result = $this->query($query,array((int)$this->mInfo["pos"], (int)$this->mInfo["parent_id"]));
+ $res = $result->fetchRow();
+ if ($res) {
+ //Swap position values
+ $query = "update `".BIT_DB_PREFIX."tiki_structures` set `pos`=? where `structure_id`=?";
+ $this->query($query,array((int)$res["pos"], (int)$this->mInfo["structure_id"]) );
+ $this->query($query,array((int)$this->mInfo["pos"], (int)$res["structure_id"]) );
+ }
+ $this->mDb->CompleteTrans();
+ }
+ }
+
+
+
+
+
+
+
+
+
+ // ============== OLD struct_lib STUFF
+
+
+
+
+
+
+
+ function s_export_structure($structure_id) {
+ global $exportlib, $bitdomain;
+
+ include_once( WIKI_PKG_PATH.'export_lib.php' );
+ include_once (BIT_PKG_PATH."util/tar.class.php");
+
+ $page_info = $this->s_get_structure_info($structure_id);
+ $title = $page_info["title"];
+ $zipname = $title . ".zip";
+ $tar = new tar();
+ $pages = $this->s_get_structure_pages($page_info["structure_id"]);
+
+ foreach ($pages as $page) {
+ $data = $exportlib->export_wiki_page($page["title"], 0);
+ $tar->addData($page["title"], $data, date("U"));
+ }
+ $tar->toTar("dump/$bitdomain" . $title . ".tar", FALSE);
+ header ("location: dump/$bitdomain" . $title . ".tar");
+ return '';
+ }
+
+ function s_export_structure_tree($structure_id, $level = 0) {
+ $structure_tree = $this->get_subtree($structure_id);
+
+ $level = 0;
+ $first = true;
+ foreach ( $structure_tree as $node ) {
+ //This special case indicates head of structure
+ if ($node["first"] and $node["last"]) {
+ print ("Use this tree to copy the structure: " . $node['title'] . "\n\n");
+ }
+ elseif ($node["first"] or !$node["last"]) {
+ if ($node["first"] and !$first) {
+ $level++;
+ }
+ $first = false;
+ for ($i = 0; $i < $level; $i++) {
+ print (" ");
+ }
+ print ($node['title']);
+ if (!empty($node['page_alias'])) {
+ print("->" . $node['page_alias']);
+ }
+ print("\n");
+ }
+ //node is a place holder for last in level
+ else {
+ $level--;
+ }
+ }
+ }
+
+ 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->query( $query,array( (int)$structure_id) );
+ //Iterate down through the child nodes
+ 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->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`=?";
+
+ $result = $this->query($query, array( (int)$structure_id) );
+ return true;
+ }
+ }
+
+ /*shared*/
+ function remove_from_structure($structure_id) {
+ // Now recursively remove
+ $query = "select `structure_id` ";
+ $query .= "from `".BIT_DB_PREFIX."tiki_structures` as ts, `".BIT_DB_PREFIX."tiki_pages` as tp ";
+ $query .= "where tp.`content_id`=ts.`content_id` and `parent_id`=?";
+ $result = $this->query($query, array( $structure_id ) );
+
+ while ($res = $result->fetchRow()) {
+ $this->remove_from_structure($res["structure_id"]);
+ }
+
+ $query = "delete from `".BIT_DB_PREFIX."tiki_structures` where `structure_id`=?";
+ $result = $this->query($query, array( $structure_id ) );
+ return true;
+ }
+
+ /**Returns an array of info about the parent
+ structure_id
+
+ See get_page_info for details of array
+ */
+ function s_get_parent_info($structure_id) {
+ // Try to get the parent of this page
+ $parent_id = $this->getOne("select `parent_id` from `".BIT_DB_PREFIX."tiki_structures` where `structure_id`=?",array((int)$structure_id));
+
+ if (!$parent_id)
+ return null;
+ return ($this->getNode($parent_id));
+ }
+
+ // gets an array of content_id's in order of the hierarchy.
+ 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";
+ $result = $this->query( $query, array( (int)$pStructureId ) );
+ while ( !$result->EOF ) {
+ array_push( $pToc, $result->fields['content_id'] );
+ $this->getContentIds( $result->fields['structure_id'], $pToc, ++$pLevel );
+ $result->MoveNext();
+ }
+ }
+
+ function getContentArray( $pStructureId, &$pToc, $pLevel=0 ) {
+ $query = "SELECT * from `".BIT_DB_PREFIX."tiki_structures` where `structure_id`=?";
+ $result = $this->query( $query, array( (int)$pStructureId ) );
+ if( !$result->EOF ) {
+ array_push( $pToc, $result->fields['content_id'] );
+ $this->getContentIds( $pStructureId, $pToc, $pLevel );
+ }
+ }
+
+ function exportHtml() {
+ $ret = array();
+ $toc = array();
+ $this->getContentArray( $this->mStructureId, $toc );
+ if( count( $toc ) ) {
+ foreach( $toc as $conId ) {
+ if( $viewContent = $this->getLibertyObject( $conId ) ) {
+ $ret[] = array( 'type' => $viewContent->mContentTypeGuid,
+ 'landscape' => FALSE,
+ 'url' => $viewContent->getDisplayUrl(),
+ 'content_id' => $viewContent->mContentId,
+ );
+ }
+ }
+ }
+ return $ret;
+ }
+
+ // that is intended to replace the get_subtree_toc and get_subtree_toc_slide
+ // it's used only in {toc} thing hardcoded in parse gBitSystem->parse -- (mose)
+ // the $tocPrefix can be used to Prefix a subtree as it would start from a given number (e.g. 2.1.3)
+ function build_subtree_toc($id,$slide=false,$order='asc',$tocPrefix='') {
+ $ret = array();
+ $cant = $this->getOne("select count(*) from `".BIT_DB_PREFIX."tiki_structures` where `parent_id`=?",array((int)$id));
+ if ($cant) {
+ $query = "SELECT `structure_id`, tc.`title`, `page_alias`
+ FROM `".BIT_DB_PREFIX."tiki_structures` ts INNER JOIN `".BIT_DB_PREFIX."tiki_content` tc ON ( tc.`content_id`=ts.`content_id` )
+ WHERE `parent_id`=?
+ ORDER BY ".$this->convert_sortmode("pos_".$order);
+ $result = $this->query($query,array((int)$id));
+ $prefix=1;
+ while ($res = $result->fetchRow()) {
+ $res['prefix']=($tocPrefix=='')?'':"$tocPrefix.";
+ $res['prefix'].=$prefix;
+ $prefix++;
+ if ($res['structure_id'] != $id) {
+ $sub = $this->build_subtree_toc($res['structure_id'],$slide,$order,$res['prefix']);
+ if (is_array($sub)) {
+ $res['sub'] = $sub;
+ }
+ }
+ $back[] = $res;
+ }
+ } else {
+ return false;
+ }
+ return $back;
+ }
+
+ function get_toc($pStructureId=NULL,$order='asc',$showdesc=false,$numbering=true,$numberPrefix='') {
+ if( empty( $pStructureId ) ) {
+ $pStructureId = $this->mStructureId;
+ }
+ $structure_tree = $this->build_subtree_toc($pStructureId,false,$order,$numberPrefix);
+ return $this->fetch_toc($structure_tree,$showdesc,$numbering);
+ }
+
+ function fetch_toc($structure_tree,$showdesc,$numbering) {
+ global $smarty;
+ $ret='';
+ if ($structure_tree != '') {
+ $smarty->verifyCompileDir();
+ $ret.=$smarty->fetch( "bitpackage:wiki/book_toc_startul.tpl");
+ foreach($structure_tree as $leaf) {
+ //echo "<br />";print_r($leaf);echo "<br />";
+ $smarty->assign_by_ref('structure_tree',$leaf);
+ $smarty->assign('showdesc',$showdesc);
+ $smarty->assign('numbering',$numbering);
+ $ret.=$smarty->fetch( "bitpackage:wiki/book_toc_leaf.tpl");
+ if(isset($leaf["sub"]) && is_array($leaf["sub"])) {
+ $ret.=$this->fetch_toc($leaf["sub"],$showdesc,$numbering);
+ }
+ }
+ $ret.=$smarty->fetch( "bitpackage:wiki/book_toc_endul.tpl");
+ }
+ return $ret;
+ }
+ // end of replacement
+
+
+/*
+ //Is this page the head page for a structure?
+ function get_struct_ref_if_head($title) {
+ $query = "SELECT `structure_id`
+ FROM `".BIT_DB_PREFIX."tiki_structures` ts, `".BIT_DB_PREFIX."tiki_pages` tp,`".BIT_DB_PREFIX."tiki_content` tc
+ WHERE tp.`content_id`=ts.`content_id` AND tc.`content_id` = tp.`content_id` AND (`parent_id` is null or `parent_id`=0) and tc.`title`=?";
+ $structure_id = $this->getOne($query,array($title));
+ return $structure_id;
+ }
+*/
+ function get_next_page($structure_id, $deep = true) {
+ // If we have children then get the first child
+ if ($deep) {
+ $query = "SELECT `structure_id`
+ FROM `".BIT_DB_PREFIX."tiki_structures` ts
+ WHERE `parent_id`=?
+ ORDER BY ".$this->convert_sortmode("pos_asc");
+ $result1 = $this->query($query,array((int)$structure_id));
+
+ if ($result1->numRows()) {
+ $res = $result1->fetchRow();
+ return $res["structure_id"];
+ }
+ }
+
+ // Try to get the next page with the same parent as this
+ $page_info = $this->getNode($structure_id);
+ $parent_id = $page_info["parent_id"];
+ $page_pos = $page_info["pos"];
+
+ if (!$parent_id)
+ return null;
+
+ $query = "SELECT `structure_id`
+ FROM `".BIT_DB_PREFIX."tiki_structures` ts
+ WHERE `parent_id`=? and `pos`>?
+ ORDER BY ".$this->convert_sortmode("pos_asc");
+ $result2 = $this->query($query,array((int)$parent_id, (int)$page_pos));
+
+ if ($result2->numRows()) {
+ $res = $result2->fetchRow();
+ return $res["structure_id"];
+ }
+ else {
+ return $this->get_next_page($parent_id, false);
+ }
+ }
+
+ function get_prev_page($structure_id, $deep = false) {
+
+ //Drill down to last child for this tree node
+ if ($deep) {
+ $query = "select `structure_id` ";
+ $query .= "from `".BIT_DB_PREFIX."tiki_structures` ts ";
+ $query .= "where `parent_id`=? ";
+ $query .= "order by ".$this->convert_sortmode("pos_desc");
+ $result = $this->query($query,array($structure_id));
+
+ if ($result->numRows()) {
+ //There are more children
+ $res = $result->fetchRow();
+ $structure_id = $this->get_prev_page($res["structure_id"], true);
+ }
+ return $structure_id;
+ }
+ // Try to get the previous page with the same parent as this
+ $page_info = $this->getNode($structure_id);
+ $parent_id = $page_info["parent_id"];
+ $pos = $page_info["pos"];
+
+ //At the top of the tree
+ if (!isset($parent_id))
+ return null;
+
+ $query = "select `structure_id` ";
+ $query .= "from `".BIT_DB_PREFIX."tiki_structures` ts ";
+ $query .= "where `parent_id`=? and `pos`<? ";
+ $query .= "order by ".$this->convert_sortmode("pos_desc");
+ $result = $this->query($query,array((int)$parent_id, (int)$pos));
+
+ if ($result->numRows()) {
+ //There is a previous sibling
+ $res = $result->fetchRow();
+ $structure_id = $this->get_prev_page($res["structure_id"], true);
+ }
+ else {
+ //No previous siblings, just the parent
+ $structure_id = $parent_id;
+ }
+ return $structure_id;
+ }
+
+ /** Return an array of subpages
+ Used by the 'After Page' select box
+ */
+ function s_get_pages($parent_id) {
+ $ret = array();
+ $query = "SELECT `pos`, `structure_id`, `parent_id`, ts.`content_id`, tc.`title`, `page_alias`
+ FROM `".BIT_DB_PREFIX."tiki_structures` ts, `".BIT_DB_PREFIX."tiki_content` tc
+ WHERE ts.`content_id` = tc.`content_id` AND `parent_id`=? ";
+ $query .= "order by ".$this->convert_sortmode("pos_asc");
+ $result = $this->query($query,array((int)$parent_id));
+ while ($res = $result->fetchRow()) {
+ //$ret[] = $this->populate_page_info($res);
+ $ret[] = $res;
+ }
+ return $ret;
+ }
+
+ function get_max_children($structure_id) {
+
+ $query = "select `structure_id` from `".BIT_DB_PREFIX."tiki_structures` where `parent_id`=?";
+ $result = $this->query($query,array((int)$structure_id));
+ if (!$result->numRows()) {
+ return '';
+ }
+ $res = $result->fetchRow();
+ return $res;
+ }
+
+ /** Return all the pages belonging to the structure
+ \return An array of page_info arrays
+ */
+ function s_get_structure_pages($structure_id) {
+ $ret = array();
+ // Add the structure page as well
+ $ret[] = $this->getNode($structure_id);
+ $ret2 = $this->_s_get_structure_pages($structure_id);
+ return array_merge($ret, $ret2);
+ }
+
+ /** Return a unique list of pages belonging to the structure
+ \return An array of page_info arrays
+ */
+ function s_get_structure_pages_unique($structure_id) {
+ $ret = array();
+ // Add the structure page as well
+ $ret[] = $this->getNode($structure_id);
+ $ret2 = $this->_s_get_structure_pages($structure_id);
+ return array_unique(array_merge($ret, $ret2));
+ }
+
+ /** Return all the pages belonging to a structure
+ \scope private
+ \return An array of page_info arrays
+ */
+ function _s_get_structure_pages($structure_id) {
+ $ret = array();
+ $query = "select `pos`, `structure_id`, `parent_id`, ts.`content_id`, tc.`title`, `page_alias`
+ FROM `".BIT_DB_PREFIX."tiki_structures` ts, `".BIT_DB_PREFIX."tiki_content` tc
+ WHERE tc.`content_id` = tp.`content_id` AND tp.`content_id`=ts.`content_id` AND `parent_id`=?
+ ORDER by ".$this->convert_sortmode("pos_asc");
+
+ $result = $this->query($query,array((int)$structure_id));
+ while ($res = $result->fetchRow()) {
+ //$ret[] = $this->populate_page_info($res);
+ $ret2 = $this->_s_get_structure_pages($res["structure_id"]);
+ $ret = array_merge($res, $ret2);
+ }
+ return $ret;
+ }
+
+ function get_page_alias($structure_id) {
+ $query = "select `page_alias` from `".BIT_DB_PREFIX."tiki_structures` where `structure_id`=?";
+ $res = $this->getOne($query, array((int)$structure_id));
+ return $res;
+ }
+
+ function set_page_alias($structure_id, $pageAlias) {
+ $query = "update `".BIT_DB_PREFIX."tiki_structures` set `page_alias`=? where `structure_id`=?";
+ $this->query($query, array($pageAlias, (int)$structure_id));
+ }
+
+
+
+ //This nifty function creates a static WebHelp version using a TikiStructure as
+ //the base.
+ function structure_to_webhelp($structure_id, $dir, $top) {
+ global $style_base;
+
+ //The first task is to convert the structure into an array with the
+ //proper format to produce a WebHelp project.
+ //We have to create something in the form
+ //$pages=Array('root'=>Array('pag1'=>'','pag2'=>'','page3'=>Array(...)));
+ //Where the name is the title|description and the other side is either ''
+ //when the page is a leaf or an Array of pages when the page is a folder
+ //Folders that are not BitPages are known for having only a name instead
+ //of name|description
+ $tree = '$tree=Array('.$this->structure_to_tree($structure_id).');';
+ eval($tree);
+ //Now we have the tree in $tree!
+ $menucode="foldersTree = gFld(\"Index\", \"pages/$top.html\")\n";
+ $menucode.=$this->traverse($tree);
+ $base = BITHELP_PKG_PATH.$dir;
+ copy(BITHELP_PKG_PATH."/menu/options.cfg","$base/menu/menuNodes.js");
+ $fw = fopen("$base/menu/menuNodes.js","a+");
+ fwrite($fw,$menucode);
+ fclose($fw);
+
+ $docs = Array();
+ $words = Array();
+ $index = Array();
+ $first=true;
+ $pages = $this->traverse2($tree);
+ // Now loop the pages
+ foreach($pages as $page)
+ {
+ $query = "SELECT *
+ FROM `".BIT_DB_PREFIX."tiki_pages` tp, `".BIT_DB_PREFIX."tiki_content` tc
+ WHERE tc.`content_id` = tp.`content_id` AND tc.`title`=?";
+ $result = $this->query($query,array($page));
+ $res = $result->fetchRow();
+ $docs[] = $res["title"];
+ if(empty($res["description"])) $res["description"]=$res["title"];
+ $title=$res["title"].'|'.$res["description"];
+ $dat = $this->parseData($res['data']);
+
+ //Now dump the page
+ $dat = preg_replace("/index.php\?page=([^\'\" ]+)/","$1.html",$dat);
+ $dat = str_replace('?nocache=1','',$dat);
+ $cs = '';
+ $data = "<html><head><script src=\"../js/highlight.js\"></script><link rel=\"StyleSheet\" href=\"../../../styles/$style_base.css\" type=\"text/css\" /><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /> <title>".$res["title"]."</title></head><body onLoad=\"doProc();\">$cs<div id='tiki-center'><div class='wikitext'>".$dat.'</div></div></body></html>';
+ $fw=fopen("$base/pages/".$res['title'].'.html','wb+');
+ fwrite($fw,$data);
+ fclose($fw);
+ unset($dat);
+
+ $page_words = split("[^A-Za-z0-9\-_]",$res["data"]);
+ foreach($page_words as $word) {
+ $word=strtolower($word);
+ if(strlen($word)>3 && preg_match("/^[A-Za-z][A-Za-z0-9\_\-]*[A-Za-z0-9]$/",$word)) {
+ if(!in_array($word,$words)) {
+ $words[] = $word;
+ $index[$word]=Array();
+ }
+ if(!in_array($res["title"].'|'.$res["description"],$index[$word])) {
+ $index[$word][] = $res["title"].'|'.$res["description"];
+ }
+ }
+ }
+ }
+ sort($words);
+ $i=0;
+ $fw = fopen("$base/js/searchdata.js","w");
+ fwrite($fw,"keywords = new Array();\n");
+ foreach($words as $word) {
+ fwrite($fw,"keywords[$i] = Array(\"$word\",Array(");
+ $first=true;
+ foreach($index[$word] as $doc) {
+ if(!$first) {fwrite($fw,",");} else {$first=false;}
+ fwrite($fw,'"'.$doc.'"');
+ }
+ fwrite($fw,"));\n");
+ $i++;
+ }
+ fclose($fw);
+
+ }
+
+ function structure_to_tree($structure_id) {
+ $query = "select * from `".BIT_DB_PREFIX."tiki_structures` ts,`".BIT_DB_PREFIX."tiki_pages` tp where tp.`content_id`=ts.`content_id` and `structure_id`=?";
+ $result = $this->query($query,array((int)$structure_id));
+ $res = $result->fetchRow();
+ if(empty($res['description'])) $res['description']=$res['title'];
+ $name = $res['description'].'|'.$res['title'];
+ $code = '';
+ $code.= "'$name'=>";
+ $query = "select * from `".BIT_DB_PREFIX."tiki_structures` ts, `".BIT_DB_PREFIX."tiki_pages` tp where tp.`content_id`=ts.`content_id` and `parent_id`=?";
+ $result = $this->query($query,array((int)$structure_id));
+ if($result->numRows()) {
+ $code.="Array(";
+ $first = true;
+ while($res=$result->fetchRow()) {
+ if(!$first) {
+ $code.=',';
+ } else {
+ $first = false;
+ }
+ $code.=$this->structure_to_tree($res['structure_id']);
+ }
+ $code.=')';
+ } else {
+ $code.="''";
+ }
+ return $code;
+ }
+
+ function traverse($tree,$parent='') {
+ $code='';
+ foreach($tree as $name => $node) {
+ list($name,$link) = explode('|',$name);
+ if(is_array($node)) {
+ //New folder node is parent++ folder parent is paren
+ $new = $parent . 'A';
+ $code.="foldersTree".$new."=insFld(foldersTree$parent,gFld(\"$name\",\"pages/$link.html\"));\n";
+ $code.=$this->traverse($node,$new);
+ } else {
+ $code.="insDoc(foldersTree$parent,gLnk(\"R\",\"$name\",\"pages/$link.html\"));\n";
+ }
+ }
+ return $code;
+ }
+
+ function traverse2($tree) {
+ $pages = Array();
+ foreach($tree as $name => $node) {
+ list($name,$link) = explode('|',$name);
+ if(is_array($node)) {
+ if(isset($name) && isset($link)) {
+ $title = $link;
+ $pages[] = $title;
+ }
+ $pages2 = $this->traverse2($node);
+ foreach($pages2 as $elem) {
+ $pages[] = $elem;
+ }
+ } else {
+ $pages[] = $link;
+ }
+ }
+ return $pages;
+ }
+}
+
+global $structlib;
+$structlib = new LibertyStructure();
+
+?>
diff --git a/LibertySystem.php b/LibertySystem.php
new file mode 100755
index 0000000..3ebe3a4
--- /dev/null
+++ b/LibertySystem.php
@@ -0,0 +1,303 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Authors: spider <spider@steelsun.com>
+// +----------------------------------------------------------------------+
+//
+// $Id: LibertySystem.php,v 1.1 2005/06/19 04:55:47 bitweaver Exp $
+
+/**
+* System class for handling the common package
+*
+* @abstract
+* @author spider <spider@steelsun.com>
+* @version $Revision: 1.1 $
+* @package Common
+*/
+
+define( 'STORAGE_PLUGIN', 'storage' );
+define( 'FORMAT_PLUGIN', 'format' );
+define( 'DATA_PLUGIN', 'data' );
+
+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>' );
+
+require_once( LIBERTY_PKG_PATH.'LibertyBase.php' );
+
+class LibertySystem extends LibertyBase {
+
+ var $mPlugins;
+ var $mDataTags;
+ var $mContentTypes;
+
+ function LibertySystem() {
+ LibertyBase::LibertyBase();
+ $this->mDataTags = array();
+ $this->loadPlugins();
+ $this->loadContentTypes();
+ }
+
+ function loadPlugins() {
+ $rs = $this->query( "SELECT * FROM `".BIT_DB_PREFIX."tiki_plugins`", NULL, BIT_QUERY_DEFAULT, BIT_QUERY_DEFAULT );
+ while( $rs && !$rs->EOF ) {
+ $this->mPlugins[$rs->fields['plugin_guid']] = $rs->fields;
+ $rs->MoveNext();
+ }
+ }
+
+ function scanPlugins() {
+ $pluginsPath = LIBERTY_PKG_PATH.'plugins/';
+ if( $pluginDir = opendir( $pluginsPath ) ) {
+ // Make two passes through the root - 1. to define the DEFINES, and 2. to include the $pScanFile's
+ while (false !== ($plugin = readdir($pluginDir))) {
+ if( preg_match( '/\.php$/', $plugin ) ) {
+ include_once( $pluginsPath.$plugin );
+ }
+ }
+ }
+ // match up storage_type_id to plugin_guids. this _id varies from install to install, but guids are the same
+ foreach( array_keys( $this->mPlugins ) as $guid ) {
+ $handler = &$this->mPlugins[$guid]; //shorthand var alias
+ if( !isset( $handler['verified'] ) && $handler['is_active'] =='y' ) {
+ // We are missing a plugin!
+ $sql = "UPDATE `".BIT_DB_PREFIX."tiki_plugins` SET `is_active`='x' WHERE `plugin_guid`=?";
+ $this->query( $sql, array( $guid ) );
+ $handler['is_active'] = 'n';
+ } elseif( !empty( $handler['verified'] ) && $handler['is_active'] =='x' ) {
+ //We found a formally missing plugin - re-enable it
+ $sql = "UPDATE `".BIT_DB_PREFIX."tiki_plugins` SET `is_active`='y' WHERE `plugin_guid`=?";
+ $this->query( $sql, array( $guid ) );
+ $handler['is_active'] = 'y';
+ } elseif( empty( $handler['verified'] ) && !isset( $handler['is_active'] ) ) {
+ //We found a missing plugin - insert it
+ $sql = "INSERT INTO `".BIT_DB_PREFIX."tiki_plugins` ( `plugin_guid`, `plugin_type`, `plugin_description`, `is_active` ) VALUES ( ?, ?, ?, 'y' )";
+ $this->query( $sql, array( $guid, $handler['plugin_type'], $handler['description'] ) );
+ $handler['is_active'] = 'y';
+ }
+ }
+ asort( $this->mPlugins );
+ }
+
+ function loadContentTypes( $pCacheTime=BIT_QUERY_CACHE_TIME ) {
+ $rs = $this->query( "SELECT * FROM `".BIT_DB_PREFIX."tiki_content_types`", NULL, BIT_QUERY_DEFAULT, BIT_QUERY_DEFAULT );
+ while( $rs && !$rs->EOF ) {
+ $this->mContentTypes[$rs->fields['content_type_guid']] = $rs->fields;
+ $rs->MoveNext();
+ }
+ }
+
+ function registerContentType( $pGuid, $pTypeParams ) {
+ if( !isset( $this->mContentTypes ) ) {
+ $this->loadContentTypes();
+ }
+ $pTypeParams['content_type_guid'] = $pGuid;
+ if( empty( $this->mContentTypes[$pGuid] ) && !empty( $pTypeParams ) ) {
+ $result = $this->associateInsert( BIT_DB_PREFIX."tiki_content_types", $pTypeParams );
+ // we just ran some SQL - let's flush the loadContentTypes query cache
+ $this->loadContentTypes( 0 );
+ } else {
+ if( $pTypeParams['handler_package'] != $this->mContentTypes[$pGuid]['handler_package'] || $pTypeParams['handler_file'] != $this->mContentTypes[$pGuid]['handler_file'] || $pTypeParams['handler_class'] != $this->mContentTypes[$pGuid]['handler_class'] ) {
+ $result = $this->associateUpdate( BIT_DB_PREFIX."tiki_content_types", $pTypeParams, array( 'name'=>'content_type_guid', 'value'=>$pGuid ) );
+ }
+ }
+ }
+
+ function isPluginActive( $pPluginGuid ) {
+ return( isset( $this->mPlugins[$pGuid] ) && ($this->mPlugins[$pGuid] == 'y') );
+ }
+
+ function registerDataTag( $pTag, $pPluginGuid ) {
+ $this->mDataTags[strtolower($pTag)] = $pPluginGuid;
+ }
+
+ function registerPlugin( $pGuid, $pPluginParams ) {
+ if( isset($this->mPlugins[$pGuid] ) ) {
+ $this->mPlugins[$pGuid]['verified'] = TRUE;
+ } else {
+ $this->mPlugins[$pGuid]['verified'] = FALSE;
+ }
+ $this->mPlugins[$pGuid] = array_merge( $this->mPlugins[$pGuid], $pPluginParams );
+ }
+
+ // @parameter pPluginGuids an array of all the plugin guids that are active. Any left out are *inactive*!
+ function setActivePlugins( $pPluginGuids ) {
+ if( is_array( $pPluginGuids ) ) {
+ $sql = "UPDATE `".BIT_DB_PREFIX."tiki_plugins` SET `is_active`='n' WHERE `is_active`!='x'";
+ $this->query( $sql );
+ foreach( array_keys( $this->mPlugins ) as $guid ) {
+ $this->mPlugins[$guid]['is_active'] = 'n';
+ }
+
+ foreach( array_keys( $pPluginGuids ) as $guid ) {
+ $sql = "UPDATE `".BIT_DB_PREFIX."tiki_plugins` SET `is_active`='y' WHERE `plugin_guid`=?";
+ $this->query( $sql, array( $guid ) );
+ $this->mPlugins[$guid]['is_active'] = 'y';
+ }
+ // we just ran some SQL - let's flush the loadPlugins query cache
+ $this->loadPlugins( 0 );
+ }
+ }
+
+ function getPluginInfo( $pGuid ) {
+ $ret = NULL;
+ if( !empty( $pGuid )
+ && !empty( $this->mPlugins[$pGuid] )
+ ) {
+ $ret = $this->mPlugins[$pGuid];
+ }
+ return $ret;
+ }
+
+ function getPluginFunction( $pGuid, $pFunctionName ) {
+ $ret = NULL;
+ if( !empty( $pGuid )
+ && !empty( $this->mPlugins[$pGuid] )
+ && !empty( $this->mPlugins[$pGuid][$pFunctionName] )
+ && function_exists( $this->mPlugins[$pGuid][$pFunctionName] )
+ ) {
+ $ret = $this->mPlugins[$pGuid][$pFunctionName];
+ }
+ return $ret;
+ }
+
+ // Get the URL to the icon for the mime type passed in. This should probably check for files of multiple image types instead of just jpg
+ function getMimeThumbnailURL($pMimeType) {
+ $ret = NULL;
+ $parts = split('/',$pMimeType);
+ if (count($parts) > 1) {
+ global $smarty;
+ require_once $smarty->_get_plugin_filepath('function','biticon');
+
+ $ext = $parts[1];
+ $biticon = array(
+ 'ipackage' => 'liberty',
+ 'ipath' => 'mime/',
+ 'iname' => $ext,
+ 'iexplain' => $ext,
+ 'url' => 'only',
+ );
+ if( !$ret = smarty_function_biticon( $biticon,$smarty ) ) {
+ $biticon['iname'] = 'generic';
+ $ret = smarty_function_biticon( $biticon,$smarty );
+ }
+ }
+ return $ret;
+
+ }
+
+
+}
+
+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);
+
+ 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) {
+ $plugin_start = $curlyTags[0][$i];
+ $plugin = $curlyTags[1][$i];
+ $pos = strpos( $data, $plugin_start ); // where plugin starts
+ $dataTag = strtolower( $plugin );
+ 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')))
+ && isset( $gLibertySystem->mDataTags[$dataTag] )
+ && ( $pluginInfo = $gLibertySystem->getPluginInfo( $gLibertySystem->mDataTags[$dataTag] ) )
+ && ( $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.'}') )
+ ) {
+
+ if( $pluginInfo['requires_pair'] ) {
+ $plugin_end = '{'.$plugin.'}';
+ $pos_end = strpos(strtolower( $data ), strtolower( $plugin_end ), $pos); // where plugin data ends
+ } else {
+ $pos_end = $pos + strlen( $curlyTags[0][$i] );
+ $plugin_end = '';
+ }
+
+//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 = 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('&gt;', '>', trim( $curlyTags[2][$i] ) );
+ if( preg_match( '/^\(.*=>.*\)$/', $paramString ) ) {
+ $paramString = preg_replace('/[\(\)]/', '', $paramString);
+ //we have the old style parms like {CODE (in=>1)}
+ $params = split(',', trim( $paramString ));
+
+ foreach ($params as $param) {
+ // the following str_replace line is to decode the &gt; 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]);
+ }
+ }
+ } else {
+ $paramString = trim( $curlyTags[2][$i], " \t()" );
+ $paramString = str_replace("&quot;", '"', $paramString);
+ $arguments = parse_xml_attributes( $paramString );
+ }
+
+ if( $ret = $loadFunc( $plugin_data, $arguments ) ) {
+ // temporarily replace end of lines so tables and other things render properly
+// $ret = preg_replace( "/\n/", '#EOL', $ret );
+ // Handle pre- & no-parse sections and plugins inserted by this plugin
+ if( is_object( $pParser ) ) {
+ // we were passed in a parser object, assume tikiwiki that has parse_first method
+ // SPIDERKILL - this was causing apache segfaults. ~np~'s are caught on the way out of parse_first anyway
+// $pParser->parse_pp_np( $ret, $preparsed, $noparsed );
+ } else {
+ // just nuke all np/pp for now in non tikiwiki formats
+ $ret = preg_replace( "/\~(\/?)[np]p\~/", '', $ret );
+
+ }
+ // Replace plugin section with its output in data
+ $data = substr_replace($data, $ret, $pos, $pos_end - $pos + strlen($plugin_end));
+ }
+ }
+ $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;
+
+ $code_first = false;
+ }
+ } // while
+ }
+}
+
+global $gLibertySystem;
+$gLibertySystem = new LibertySystem();
+$smarty->assign_by_ref( 'gLibertySystem', $gLibertySystem );
+
+?>
diff --git a/admin/admin_liberty_inc.php b/admin/admin_liberty_inc.php
new file mode 100644
index 0000000..827b1f5
--- /dev/null
+++ b/admin/admin_liberty_inc.php
@@ -0,0 +1,49 @@
+<?php
+$formLibertyFeatures = array(
+ "liberty_quota" => array(
+ 'label' => 'Quota Usage System',
+ 'note' => 'Limit users\' disk usage.',
+ 'page' => '',
+ ),
+ "liberty_auto_display_attachment_thumbs" => array(
+ 'label' => 'Auto-Display Attachment Thumbnails',
+ 'note' => 'This will automatically display thumbnails of all attachments of a given page (usually in the top right corner of the page). You can still display the items inline as well.',
+ 'page' => '',
+ )
+);
+if( $gBitSystem->isPackageActive( 'tinymce' ) ) {
+ $formLibertyFeatures["tinymce_ask"] = array(
+ 'label' => 'WYSIWYG confirmation',
+ 'note' => 'Ask before using the WYSIWYG editor tinymce when clicking on a textarea. If you disable this feature, we strongly suggest you enable HTML content format as the only content format and also disable quicktags.',
+ 'page' => '',
+ );
+}
+$smarty->assign('formLibertyFeatures', $formLibertyFeatures);
+//vd($_REQUEST);
+if (!empty($_REQUEST['change_prefs'])) {
+ $errors = array();
+ foreach( $formLibertyFeatures as $item => $data ) {
+ simple_set_toggle( $item );
+ }
+
+ if( $_REQUEST['approved_html_tags'] != DEFAULT_ACCEPTABLE_TAGS ) {
+ $tags = preg_replace( '/\s/', '', $_REQUEST['approved_html_tags'] );
+ $lastAngle = strrpos( $tags, '>' ) + 1;
+ if( strlen( $tags ) > 250 || ($lastAngle < strlen( $tags ) ) ) {
+ $tags = substr( $tags, 0, 250 );
+ $tags = substr( $tags, 0, $lastAngle );
+ $errors['warning'] = 'The approved tags list has been shortened. You can only have 250 characters for approved tags.';
+ }
+
+ $gBitSystem->storePreference('approved_html_tags', $tags , LIBERTY_PKG_NAME );
+ }
+ $smarty->assign_by_ref( 'errors', $errors );
+
+ $gBitSystem->storePreference('image_processor', (!empty( $_REQUEST['image_processor'] ) ? $_REQUEST['image_processor'] : NULL ) , LIBERTY_PKG_NAME );
+ $gBitSystem->storePreference('liberty_attachment_link_format', ( !empty( $_REQUEST['liberty_auto_display_attachment_thumbs'] ) ? $_REQUEST['liberty_auto_display_attachment_thumbs'] : NULL ), LIBERTY_PKG_NAME );
+}
+
+$tags = $gBitSystem->getPreference( 'approved_html_tags', DEFAULT_ACCEPTABLE_TAGS );
+
+$smarty->assign('approved_html_tags', $tags );
+?>
diff --git a/admin/plugins.php b/admin/plugins.php
new file mode 100644
index 0000000..045e932
--- /dev/null
+++ b/admin/plugins.php
@@ -0,0 +1,28 @@
+<?php
+require_once( '../../bit_setup_inc.php' );
+
+$gBitSystem->verifyPermission( 'bit_p_admin' );
+
+if( isset( $_REQUEST['pluginsave'] ) && !empty( $_REQUEST['pluginsave'] ) ) {
+ if( !empty( $_REQUEST['default_format'] ) && !empty( $_REQUEST['PLUGINS'][$_REQUEST['default_format']][0] ) ) {
+ $gLibertySystem->setActivePlugins( $_REQUEST['PLUGINS'] );
+ $gBitSystem->storePreference( 'default_format',$_REQUEST['default_format'] );
+ $smarty->assign( 'default_format',$_REQUEST['default_format'] );
+ } else {
+ $smarty->assign( 'errorMsg', 'You cannot disable the default format');
+ }
+}
+
+// Sort the plugins to avoild splitting tables
+foreach( $gLibertySystem->mPlugins as $key => $row ) {
+ $type[$key] = $row['plugin_type'];
+ $guid[$key] = $row['plugin_guid'];
+}
+array_multisort( $type, SORT_ASC, $guid, SORT_ASC, $gLibertySystem->mPlugins );
+
+$smarty->assign_by_ref( 'gLibertySystem', $gLibertySystem );
+
+//vd( $gLibertySystem->mPlugins );
+
+$gBitSystem->display( 'bitpackage:liberty/admin_plugins.tpl');
+?>
diff --git a/admin/schema_inc.php b/admin/schema_inc.php
new file mode 100644
index 0000000..cf1289d
--- /dev/null
+++ b/admin/schema_inc.php
@@ -0,0 +1,166 @@
+<?php
+
+// Common Content tables
+$tables = array(
+
+'tiki_plugins' => "
+ plugin_guid C(16) PRIMARY,
+ plugin_type C(16) NOTNULL,
+ is_active C(1) NOTNULL DEFAULT 'y',
+ plugin_description C(250),
+ maintainer_url C(250)
+",
+
+'tiki_content_types' => "
+ content_type_guid C(16) PRIMARY,
+ content_description C(250) NOTNULL,
+ maintainer_url C(250),
+ handler_class C(128),
+ handler_package C(128),
+ handler_file C(128)
+",
+
+'tiki_content' => "
+ content_id I4 PRIMARY,
+ user_id I4 NOTNULL,
+ modifier_user_id I4 NOTNULL,
+ created I8 NOTNULL,
+ last_modified I8 NOTNULL,
+ content_type_guid C(16) NOTNULL,
+ format_guid C(16) NOTNULL,
+ hits I4 NOTNULL DEFAULT 0,
+ language C(4),
+ title C(160),
+ ip C(39),
+ data X
+ CONSTRAINTS ', CONSTRAINT `tiki_content_type_ref` FOREIGN KEY (`content_type_guid`) REFERENCES `".BIT_DB_PREFIX."tiki_content_types`( `content_type_guid` )
+ , CONSTRAINT `tiki_content_guid_ref` FOREIGN KEY (`format_guid`) REFERENCES `".BIT_DB_PREFIX."tiki_plugins`( `plugin_guid` )'
+",
+
+'tiki_comments' => "
+ comment_id I4 PRIMARY,
+ content_id I4 NOTNULL,
+ parent_id I4 NOTNULL
+ CONSTRAINTS ', CONSTRAINT `tiki_comments_content_ref` FOREIGN KEY (`content_id`) REFERENCES `".BIT_DB_PREFIX."tiki_content`( `content_id` )
+ , CONSTRAINT `tiki_comments_parent_ref` FOREIGN KEY (`parent_id`) REFERENCES `".BIT_DB_PREFIX."tiki_content`( `content_id` )'
+",
+
+'tiki_link_cache' => "
+ cache_id I4 AUTO PRIMARY,
+ url C(250),
+ data B,
+ refresh I8
+",
+
+'tiki_attachments' => "
+ attachment_id I4 PRIMARY,
+ attachment_plugin_guid C(16) NOTNULL,
+ content_id I4 NOTNULL,
+ foreign_id I4 NOTNULL,
+ user_id I4 NOTNULL,
+ pos I4,
+ hits I4,
+ error_code I4,
+ caption C(250)
+ CONSTRAINTS ', CONSTRAINT `tiki_attachment_content_ref` FOREIGN KEY (`content_id`) REFERENCES `".BIT_DB_PREFIX."tiki_content`( `content_id` )
+ , CONSTRAINT `tiki_attachment_type_ref` FOREIGN KEY (`attachment_plugin_guid`) REFERENCES `".BIT_DB_PREFIX."tiki_plugins`( `plugin_guid` )'
+",
+
+'tiki_blobs' => '
+ blob_id I4 PRIMARY,
+ user_id I4 NOTNULL,
+ blob_size I8 NOTNULL,
+ blob_name C(250) NOTNULL,
+ blob_data_type C(100) NOTNULL,
+ blob_data B NOTNULL
+',
+
+'tiki_files' => "
+ file_id I4 PRIMARY,
+ user_id I4 NOTNULL,
+ storage_path C(250),
+ size I4,
+ mime_type C(64)
+",
+
+'tiki_structures' => "
+ structure_id I4 AUTO PRIMARY,
+ root_structure_id I4 NOTNULL,
+ content_id I4 NOTNULL,
+ level I1 NOTNULL DEFAULT 1,
+ pos I4,
+ page_alias C(240),
+ parent_id I4
+ CONSTRAINTS ', CONSTRAINT `tiki_root_structure_id_ref` FOREIGN KEY (`root_structure_id`) REFERENCES `".BIT_DB_PREFIX."tiki_structures`( `structure_id` )'
+"
+
+);
+
+global $gBitInstaller;
+
+foreach( array_keys( $tables ) AS $tableName ) {
+ $gBitInstaller->registerSchemaTable( LIBERTY_PKG_NAME, $tableName, $tables[$tableName], TRUE );
+}
+
+$gBitInstaller->registerPackageInfo( LIBERTY_PKG_NAME, array(
+ 'description' => "Liberty is an integral part and manages all content on your site.",
+ 'license' => '<a href="http://www.gnu.org/licenses/licenses.html#LGPL">LGPL</a>',
+ 'version' => '0.1',
+ 'state' => 'alpha',
+ 'dependencies' => '',
+) );
+
+// ### Indexes
+$indices = array (
+ 'tiki_content_title_idx' => array( 'table' => 'tiki_content', 'cols' => 'title', 'opts' => NULL ),
+ 'tiki_content_user_idx' => array( 'table' => 'tiki_content', 'cols' => 'user_id', 'opts' => NULL ),
+ 'tiki_content_moduser_idx' => array( 'table' => 'tiki_content', 'cols' => 'modifier_user_id', 'opts' => NULL ),
+ 'tiki_content_hits_idx' => array( 'table' => 'tiki_content', 'cols' => 'hits', 'opts' => NULL ),
+ 'tiki_comments_object_idx' => array( 'table' => 'tiki_comments', 'cols' => 'content_id', 'opts' => NULL ),
+ 'tiki_comments_parent_idx' => array( 'table' => 'tiki_comments', 'cols' => 'parent_id', 'opts' => NULL ),
+ 'tiki_attachments_hits_idx' => array( 'table' => 'tiki_attachments', 'cols' => 'hits', 'opts' => NULL ),
+ 'tiki_attachments_user_id_idx' => array( 'table' => 'tiki_attachments', 'cols' => 'user_id', 'opts' => NULL ),
+ 'tiki_attachments_content_id_idx' => array( 'table' => 'tiki_attachments', 'cols' => 'content_id', 'opts' => NULL ),
+ 'tiki_st_co_foreign_guid_idx' => array( 'table' => 'tiki_attachments', 'cols' => 'content_id, foreign_id, attachment_plugin_guid', 'opts' => array( 'UNIQUE' ) ),
+ 'tiki_plugins_guid_idx' => array( 'table' => 'tiki_plugins', 'cols' => 'plugin_guid', 'opts' => array( 'UNIQUE' ) ),
+ 'tiki_structures_root_idx' => array( 'table' => 'tiki_structures', 'cols' => 'root_structure_id', 'opts' => NULL),
+ 'tiki_structures_parent_idx' => array( 'table' => 'tiki_structures', 'cols' => 'parent_id', 'opts' => NULL),
+ 'tiki_structures_content_idx' => array( 'table' => 'tiki_structures', 'cols' => 'content_id', 'opts' => NULL )
+);
+$gBitInstaller->registerSchemaIndexes( LIBERTY_PKG_NAME, $indices );
+
+// ### Sequences
+$sequences = array (
+ 'tiki_content_id_seq' => array( 'start' => 1 ),
+ 'tiki_comments_comment_id_seq' => array( 'start' => 1 ),
+ 'tiki_files_file_id_seq' => array( 'start' => 1 ),
+ 'tiki_attachments_id_seq' => array( 'start' => 1 ),
+ 'tiki_structures_id_seq' => array( 'start' => 4 )
+);
+$gBitInstaller->registerSchemaSequences( LIBERTY_PKG_NAME, $sequences );
+
+// ### Default Preferences
+$gBitInstaller->registerPreferences( LIBERTY_PKG_NAME, array(
+ array('liberty', 'cacheimages','n'),
+ array('liberty', 'cachepages','n'),
+ array('liberty', 'default_format','tikiwiki'),
+ array('liberty', 'liberty_auto_display_attachment_thumbs', 'y'),
+// array('liberty', 'liberty_attachment_link_format', 'wiki') not needed anymore since we use js in the edit page now (depends on format of content)
+) );
+
+// ### Default UserPermissions
+$gBitInstaller->registerUserPermissions( LIBERTY_PKG_NAME, array(
+ array('bit_p_edit_html_style', 'Can include style information in HTML', 'editors', 'liberty'),
+ array('bit_p_post_comments', 'Can post new comments', 'registered', 'liberty'),
+ array('bit_p_read_comments', 'Can read comments', 'basic', 'liberty'),
+ array('bit_p_remove_comments', 'Can delete comments', 'editors', 'liberty'),
+ array('bit_p_vote_comments', 'Can vote comments', 'registered', 'liberty'),
+ array('bit_p_edit_comments', 'Can edit all comments', 'editors', 'liberty'),
+ array('bit_p_use_content_templates', 'Can use content templates', 'registered', 'liberty'),
+ array('bit_p_edit_content_templates', 'Can edit content templates', 'editors', 'liberty'),
+ array('bit_p_content_attachments', 'Can create content attachments', 'registered', 'liberty'),
+ array('bit_p_detach_attachment', 'Can detach content attachments', 'registered', 'liberty'),
+ array('bit_p_print', 'Can print content', 'basic', 'liberty'),
+) );
+
+?>
diff --git a/admin/upgrade_inc.php b/admin/upgrade_inc.php
new file mode 100644
index 0000000..fcab19a
--- /dev/null
+++ b/admin/upgrade_inc.php
@@ -0,0 +1,211 @@
+<?php
+
+global $gBitSystem, $gUpgradeFrom, $gUpgradeTo;
+
+$upgrades = array(
+
+'BONNIE' => array(
+ 'CLYDE' => array(
+
+// Step 0
+array( 'QUERY' =>
+array( 'PGSQL' => array(
+ "ALTER TABLE `".BIT_DB_PREFIX."tiki_files_pkey` RENAME TO `".BIT_DB_PREFIX."tiki_old_files_pkey`",
+)),
+),
+
+// Step 1
+array( 'DATADICT' => array(
+array( 'DROPTABLE' => array(
+ 'tiki_content'
+)),
+array( 'RENAMETABLE' => array(
+ 'tiki_files' => 'tiki_old_files',
+)),
+
+array( 'CREATE' => array (
+ 'tiki_plugins' => "
+ plugin_guid C(16) PRIMARY,
+ plugin_type C(16) NOTNULL,
+ is_active C(1) NOTNULL DEFAULT 'y',
+ plugin_description C(250),
+ maintainer_url C(250)
+ ",
+
+ 'tiki_content_types' => "
+ content_type_guid C(16) PRIMARY,
+ content_description C(250) NOTNULL,
+ maintainer_url C(250),
+ handler_class C(128),
+ handler_package C(128),
+ handler_file C(128)
+ ",
+
+ 'tiki_content' => "
+ content_id I4 PRIMARY,
+ user_id I4 NOTNULL,
+ modifier_user_id I4 NOTNULL,
+ created I8 NOTNULL,
+ last_modified I8 NOTNULL,
+ content_type_guid C(16) NOTNULL,
+ format_guid C(16) NOTNULL,
+ hits I4,
+ language C(4),
+ title C(160),
+ ip C(39),
+ data X
+ ",
+
+ 'tiki_attachments' => "
+ attachment_id I4 PRIMARY,
+ attachment_plugin_guid C(16) NOTNULL,
+ content_id I4 NOTNULL,
+ foreign_id I4 NOTNULL,
+ user_id I4 NOTNULL,
+ pos I4,
+ hits I4,
+ error_code I4,
+ caption C(250)
+ CONSTRAINTS ', CONSTRAINT `tiki_attachment_content_ref` FOREIGN KEY (`content_id`) REFERENCES `".BIT_DB_PREFIX."tiki_content`( `content_id` )
+ , CONSTRAINT `tiki_attachment_type_ref` FOREIGN KEY (`attachment_plugin_guid`) REFERENCES `".BIT_DB_PREFIX."tiki_plugins`( `plugin_guid` )'
+ ",
+
+ 'tiki_blobs' => "
+ blob_id I4 PRIMARY,
+ user_id I4 NOTNULL,
+ blob_size I8 NOTNULL,
+ blob_name C(250) NOTNULL,
+ blob_data_type C(100) NOTNULL,
+ blob_data B NOTNULL
+ ",
+
+ 'tiki_files' => "
+ file_id I4 PRIMARY,
+ user_id I4 NOTNULL,
+ storage_path C(250),
+ size I4,
+ mime_type C(64)
+ ",
+)),
+array( 'RENAMECOLUMN' => array(
+ 'tiki_structures' => array(
+ '`page_ref_id`' => 'structure_id I4 AUTO'
+ ),
+ 'tiki_link_cache' => array(
+ '`cacheId`' => 'cache_id I4 AUTO'
+ ),
+ 'tiki_comments' => array(
+ '`threadId`' => 'comment_id I4 AUTO',
+ '`parentId`' => 'parent_id I4',
+ )
+)),
+
+array( 'ALTER' => array(
+ 'tiki_structures' => array(
+ 'user_id' => array( 'user_id', 'I4' ),
+ 'content_id' => array( 'content_id', 'I4' ),
+ 'root_structure_id' => array( 'root_structure_id', 'I4' ),
+ ),
+ 'tiki_comments' => array(
+ 'content_id' => array( 'content_id', 'I4' ), // , 'NOTNULL' ),
+ ),
+
+)),
+)),
+
+// Step 2
+array( 'QUERY' =>
+array( 'SQL92' => array(
+ "UPDATE `".BIT_DB_PREFIX."tiki_structures` SET user_id=1",
+ "INSERT INTO `".BIT_DB_PREFIX."tiki_preferences` ( `name`, `value`, `package` ) VALUES ( 'liberty_auto_display_attachment_thumbs', 'y', 'liberty' )",
+ )),
+/*
+array( 'PGSQL' => array(
+ "ALTER TABLE `".BIT_DB_PREFIX."tiki_structures` ALTER user_id SET NOT NULL"
+ "ALTER TABLE `".BIT_DB_PREFIX."tiki_comments_content_ref` FOREIGN KEY (`content_id`) REFERENCES `".BIT_DB_PREFIX."tiki_content`( `content_id` )
+ "ALTER TABLE `".BIT_DB_PREFIX."tiki_comments_parent_ref` FOREIGN KEY (`parent_id`) REFERENCES `".BIT_DB_PREFIX."tiki_content`( `content_id` )'
+ "ALTER TABLE `".BIT_DB_PREFIX."tiki_content` ADD CONSTRAINT `tiki_content_guid_ref` FOREIGN KEY (`format_guid`) REFERENCES ".BIT_DB_PREFIX."tiki_plugins( `plugin_guid` )"
+ "ALTER TABLE `".BIT_DB_PREFIX."tiki_content` ADD CONSTRAINT `tiki_content_type_ref` FOREIGN KEY (`content_type_guid`) REFERENCES `".BIT_DB_PREFIX."tiki_content_types`( `content_type_guid` )" ),
+)),
+
+threadId
+object
+objectType
+parentId
+userName
+type
+points
+votes
+average
+hash
+summary
+smiley
+message_id
+in_reply_to
+comment_rating
+
+commentDate
+hits
+data
+title
+user_ip
+
+*/
+),
+
+// STEP 2
+array( 'PHP' => '
+ global $gBitSystem;
+ $gBitSystem->mDb->mDb->CreateSequence( "tiki_attachments_id_seq", 1 );
+ $gBitSystem->mDb->mDb->CreateSequence( "tiki_content_id_seq", 1 );
+ $gBitSystem->mDb->mDb->CreateSequence( "tiki_files_file_id_seq", 1 );
+ $max = $gBitSystem->GetOne( "SELECT MAX(`comment_id`) FROM `'.BIT_DB_PREFIX.'tiki_comments`" );
+ $gBitSystem->mDb->mDb->CreateSequence( "tiki_comments_comment_id_seq", $max + 1 );
+ $max = $gBitSystem->GetOne( "SELECT MAX(`structure_id`) FROM `'.BIT_DB_PREFIX.'tiki_structures`" );
+ $gBitSystem->mDb->mDb->CreateSequence( "tiki_structures_id_seq", $max + 1 );
+
+ $query = "SELECT `comment_id`, uu.`user_id`, uu.`user_id` AS `modifier_user_id`, `commentDate` AS `created`, `commentDate` AS `last_modified`, `hits`, `data`, `title`, `user_ip` AS `ip`
+ FROM `'.BIT_DB_PREFIX.'tiki_comments` tc INNER JOIN `'.BIT_DB_PREFIX.'users_users` uu ON( tc.`userName`=uu.`login` )";
+ if( $rs = $gBitSystem->query( $query ) ) {
+ while( !$rs->EOF ) {
+ $commentId = $rs->fields["comment_id"]; unset( $rs->fields["comment_id"] );
+ $conId = $gBitSystem->mDb->mDb->GenID( "tiki_content_id_seq" );
+ $rs->fields["content_id"] = $conId;
+ $rs->fields["content_type_guid"] = BITCOMMENT_CONTENT_TYPE_GUID;
+ $rs->fields["format_guid"] = PLUGIN_GUID_TIKIWIKI;
+ $gBitSystem->mDb->associateInsert( "tiki_content", $rs->fields );
+ $gBitSystem->query( "UPDATE `'.BIT_DB_PREFIX.'tiki_comments` SET `content_id`=? WHERE `comment_id`=?", array( $conId, $commentId ) );
+ $rs->MoveNext();
+ }
+ }
+
+
+' ),
+
+// STEP 3
+array( 'DATADICT' => array(
+ array( 'DROPCOLUMN' => array(
+ 'tiki_comments' => array( '`userName`', '`commentDate`','`hits`','`data`','`title`','`user_ip`' ),
+ )),
+ array( 'CREATEINDEX' => array(
+ 'tiki_content_title_idx' => array( 'tiki_content', '`title`', array() ),
+ 'tiki_content_user_idx' => array( 'tiki_content', '`user_id`', array() ),
+ 'tiki_content_moduser_idx' => array( 'tiki_content', '`modifier_user_id`', array() ),
+ 'tiki_content_hits_idx' => array( 'tiki_content', '`hits`', array() ),
+ 'tiki_comments_content_idx' => array( 'tiki_comments', '`content_id`', array() ),
+ 'tiki_struct_user_idx' => array( 'tiki_structures', '`user_id`', array() ),
+ 'tiki_struct_root_idx' => array( 'tiki_structures', '`root_structure_id`', array() ),
+ 'tiki_struct_content_idx' => array( 'tiki_structures', '`content_id`', array() ),
+ )),
+)),
+ )
+)
+
+);
+
+if( isset( $upgrades[$gUpgradeFrom][$gUpgradeTo] ) ) {
+ $gBitSystem->registerUpgrade( LIBERTY_PKG_NAME, $upgrades[$gUpgradeFrom][$gUpgradeTo] );
+}
+
+
+?>
diff --git a/attachment_browser.php b/attachment_browser.php
new file mode 100644
index 0000000..0ada330
--- /dev/null
+++ b/attachment_browser.php
@@ -0,0 +1,14 @@
+<?php
+include("../bit_setup_inc.php");
+
+$userAttachments = $gBitUser->getUserAttachments();
+$smarty->assign('userAttachments', $userAttachments);
+if (empty($gBitLoc['styleSheet'])) {
+ $gBitLoc['styleSheet'] = $gBitSystem->getStyleCss();
+}
+$gBitLoc['browserStyleSheet'] = $gBitSystem->getBrowserStyleCss();
+$gBitLoc['customStyleSheet'] = $gBitSystem->getCustomStyleCss();
+$gBitLoc['THEMES_STYLE_URL'] = $gBitSystem->getStyleUrl();
+//vd($userAttachments);
+$smarty->display('bitpackage:liberty/attachment_browser.tpl');
+?>
diff --git a/bit_setup_inc.php b/bit_setup_inc.php
new file mode 100644
index 0000000..d1fe3cb
--- /dev/null
+++ b/bit_setup_inc.php
@@ -0,0 +1,7 @@
+<?php
+global $gBitSystem, $gBitUser, $smarty;
+
+$gBitSystem->registerPackage( 'liberty', dirname( __FILE__).'/' );
+
+require_once( LIBERTY_PKG_PATH.'LibertySystem.php' );
+?>
diff --git a/comments_inc.php b/comments_inc.php
new file mode 100644
index 0000000..48506b2
--- /dev/null
+++ b/comments_inc.php
@@ -0,0 +1,121 @@
+<?php
+
+// $Header: /cvsroot/bitweaver/_bit_liberty/comments_inc.php,v 1.1 2005/06/19 04:55:47 bitweaver Exp $
+
+// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
+// All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
+
+// This file sets up the information needed to display
+// the comments preferences, post-comment box and the
+// list of comments. Finally it displays blog-comments.tpl
+// using this information
+
+// Setup URLS for the Comments next and prev buttons and use variables that
+// cannot be aliased by normal tiki variables.
+// Traverse each _REQUEST data adn put them in an array
+
+//this script may only be included - so its better to die if called directly.
+require_once (LIBERTY_PKG_PATH.'LibertyComment.php');
+
+global $commentsLib;
+global $smarty;
+
+$postComment = array();
+$formfeedback = array();
+$smarty->assign_by_ref('formfeedback', $formfeedback);
+
+if (!empty($_REQUEST['delete_comment_id'])) {
+ $deleteComment = new LibertyComment($_REQUEST['delete_comment_id']);
+ if (!empty ($deleteComment->mInfo['content_id'])) {
+ $deleteComment->deleteComment();
+ }
+}
+
+if (!empty($_REQUEST['post_comment_id'])) {
+ $post_comment_id = $_REQUEST['post_comment_id'];
+ $editComment = new LibertyComment($post_comment_id);
+ if ($editComment->mInfo['content_id']) {
+ if (!$editComment->userCanEdit()) {
+ $formfeedback['error'] = "You do not have permission to edit this comment.";
+ $editComment = NULL;
+ $post_comment_id = NULL;
+ } else {
+ $postComment['data'] = $editComment->mInfo['data'];
+ $postComment['title'] = $editComment->mInfo['title'];
+ }
+ } else {
+ $formfeedback['error'] = "Comment does not exist.";
+ $editComment = NULL;
+ $post_comment_id = NULL;
+ }
+} else {
+ $post_comment_id = NULL;
+ $editComment = NULL;
+}
+$smarty->assign('post_comment_id', $post_comment_id);
+
+// Store comment posts
+if (!empty($_REQUEST['post_comment_submit'])) {
+ $storeComment = new LibertyComment(!empty($editComment->mCommentId) ? $editComment->mCommentId : NULL);
+ $storeRow = array();
+ $storeRow['title'] = $_REQUEST['comment_title'];
+ $storeRow['edit'] = $_REQUEST['comment_data'];
+ $storeRow['parent_id'] = (!empty($storeComment->mInfo['parent_id']) ? $storeComment->mInfo['parent_id'] : (empty($_REQUEST['post_comment_reply_id']) ? $commentsParentId : $_REQUEST['post_comment_reply_id']));
+ $storeRow['content_id'] = (!empty($storeComment->mContentId) ? $storeComment->mContentId : NULL);
+ $storeComment->storeComment($storeRow);
+}
+
+// $post_comment_request is a flag indicating whether or not to display the comment input form
+if (empty($_REQUEST['post_comment_request'])) {
+ $post_comment_request = NULL;
+} elseif ($_REQUEST['post_comment_request']) {
+ $post_comment_request = TRUE;
+}
+$smarty->assign_by_ref('post_comment_request', $post_comment_request);
+
+// $post_comment_preview is a flag indicating that the user wants to preview their comment prior to saving it
+if( !empty( $_REQUEST['post_comment_preview'] ) ) {
+ $postComment['title'] = $_REQUEST['comment_title'];
+ $postComment['data'] = $_REQUEST['comment_data'];
+ $postComment['parsed_data'] = LibertyComment::parseData( $_REQUEST['comment_data'], 'tikiwiki' );
+ $smarty->assign('post_comment_preview', TRUE);
+}
+
+// $post_comment_reply_id is the content_id which a post is replying to
+if (!empty($_REQUEST['post_comment_reply_id'])) {
+ $post_comment_reply_id = $_REQUEST['post_comment_reply_id'];
+ $tmpComment = new LibertyComment(NULL, $post_comment_reply_id);
+ //$postComment['data'] = $commentsLib->quoteComment($tmpComment->mInfo['data']); // This is super-ugly, better to just not quote at all, the indented comment indicates what comment it is replying to
+ $postComment['title'] = tra('Re:')." ".$tmpComment->mInfo['title'];
+ $smarty->assign('post_comment_reply_id', $post_comment_reply_id);
+}
+
+$commentOffset = !empty( $_REQUEST['comment_page'] ) ? ($_REQUEST['comment_page'] - 1) * $maxComments : 0;
+
+$gComment = new LibertyComment( NULL, $gContent->mContentId );
+// $commentsParentId is the content_id which the comment tree is attached to
+if (empty($commentsParentId)) {
+ $comments = NULL;
+ $numComments = 0;
+} else {
+ $comments = $gComment->getComments($commentsParentId, $maxComments, $commentOffset );
+ $numComments = $gComment->getNumComments($commentsParentId);
+}
+$smarty->assign('comments', $comments);
+
+$numCommentPages = ceil( $numComments / $maxComments );
+$currentPage = !empty( $_REQUEST['comment_page'] ) ? $_REQUEST['comment_page'] : 1;
+
+$commentsPgnHash = array(
+ 'numPages' => $numCommentPages,
+ 'pgnName' => 'comment_page',
+ 'page' => $currentPage,
+ 'url' => $comments_return_url,
+);
+$smarty->assign( 'commentsPgnHash', $commentsPgnHash );
+$smarty->assign('postComment', $postComment);
+
+$smarty->assign('currentTimestamp', time());
+$smarty->assign('comments_return_url', $comments_return_url);
+?>
diff --git a/display_content_inc.php b/display_content_inc.php
new file mode 100644
index 0000000..ee1a635
--- /dev/null
+++ b/display_content_inc.php
@@ -0,0 +1,10 @@
+<?php
+
+ global $smarty, $gBitSystem, $gContent;
+
+// vd( $gContent->mInfo );
+ $smarty->assign_by_ref( 'pageInfo', $gContent->mInfo );
+
+ $gBitSystem->display( 'bitpackage:liberty/display_content.tpl' );
+
+?>
diff --git a/display_structure_inc.php b/display_structure_inc.php
new file mode 100644
index 0000000..cc48f3e
--- /dev/null
+++ b/display_structure_inc.php
@@ -0,0 +1,10 @@
+<?php
+ global $gContent;
+ include_once( LIBERTY_PKG_PATH.'lookup_content_inc.php' );
+ if( is_object( $gContent ) && $gContent->isValid() ) {
+ $gBitSystem->setBrowserTitle( $gStructure->getRootTitle().' : '.$gContent->getTitle() );
+ include $gContent->getRenderFile();
+ } else {
+ $gBitSystem->fatalError( 'Page cannot be found' );
+ }
+?>
diff --git a/edit_storage_inc.php b/edit_storage_inc.php
new file mode 100644
index 0000000..d4ae02c
--- /dev/null
+++ b/edit_storage_inc.php
@@ -0,0 +1,46 @@
+<?php
+/* This file is automatically included by edit_storage.tpl - All you need to do is include edit_storage.tpl
+ from your template file.
+*/
+
+// Calculate a base URL for the attachment deletion/removal icons to use
+global $smarty, $gContent, $gBitUser;
+$attachmentActionBaseURL = $_SERVER['PHP_SELF'].'?';
+$GETArgs = split('&',$_SERVER['QUERY_STRING']);
+
+$firstArg = TRUE;
+foreach ($GETArgs as $arg) {
+ $parts = split('=',$arg);
+ if ( ($parts[0] != 'deleteAttachment') && $parts[0] != 'detachAttachment' ) {
+ if (!$firstArg)
+ $attachmentActionBaseURL .= "&amp;";
+ else
+ $firstArg = FALSE;
+ $attachmentActionBaseURL .= $arg;
+ }
+}
+$smarty->assign('attachmentActionBaseURL', $attachmentActionBaseURL);
+
+if (!empty($_REQUEST['deleteAttachment'])) {
+ $attachmentId = $_REQUEST['deleteAttachment'];
+
+ $siblingAttachments = $gContent->getSiblingAttachments($attachmentId);
+ $attachmentInfo = $gContent->getAttachment($attachmentId);
+
+ if (count($siblingAttachments) > 0 || (!$gBitUser->isAdmin() && $gBitUser->mUserId != $attachmentInfo['user_id'] && $gBitUser->mPerms['bit_p_detach_attachment'] == 'y')) {
+ // Other tiki_attachment rows reference the same foreign_id so we should just detach
+ $gContent->detachAttachment($attachmentId);
+ } else {
+ $gContent->expungeAttachment($attachmentId);
+ }
+} elseif (!empty($_REQUEST['detachAttachment'])) {
+ $attachmentId = $_REQUEST['detachAttachment'];
+ $attachmentInfo = $gContent->getAttachment($attachmentId);
+
+ if ($gBitUser->isAdmin() || $gBitUser->mPerms['bit_p_detach_attachment'] == 'y' || $attachmentInfo['user_id'] == $gBitUser->mUserId) {
+ $gContent->detachAttachment($attachmentId);
+ }
+}
+
+
+?>
diff --git a/edit_structure_inc.php b/edit_structure_inc.php
new file mode 100644
index 0000000..45ff16b
--- /dev/null
+++ b/edit_structure_inc.php
@@ -0,0 +1,138 @@
+<?php
+// $Header: /cvsroot/bitweaver/_bit_liberty/edit_structure_inc.php,v 1.1 2005/06/19 04:55:47 bitweaver Exp $
+
+// Copyright (c) 2004, Christian Fowler, et. al.
+// All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
+
+// Initialization
+require_once( '../bit_setup_inc.php' );
+include_once( LIBERTY_PKG_PATH.'LibertyStructure.php');
+
+if( empty( $_REQUEST["structure_id"] ) ) {
+ $gBitSystem->fatalError( "No structure indicated" );
+} else {
+ global $gStructure;
+ $gStructure = new LibertyStructure( $_REQUEST["structure_id"] );
+ $gStructure->load();
+
+ // order matters for these conditionals
+ if( empty( $gStructure ) || !$gStructure->isValid() ) {
+ $gBitSystem->fatalError( 'Invalid structure' );
+ }
+
+ if( $gStructure->mInfo['root_structure_id'] == $gStructure->mInfo['structure_id'] ) {
+ $rootStructure = &$gStructure;
+ } else {
+ $rootStructure = new LibertyStructure( $gStructure->mInfo['root_structure_id'] );
+ $rootStructure->load();
+ $rootStructure->loadNavigation();
+ $rootStructure->loadPath();
+ }
+
+ if( ($gBitUser->mUserId!=$rootStructure->mInfo['user_id']) ) {
+ $gBitSystem->verifyPermission( 'bit_p_admin_books' );
+ }
+ $smarty->assign_by_ref( 'gStructure', $gStructure );
+ $smarty->assign('structureInfo', $gStructure->mInfo);
+
+ if (isset($_REQUEST["find_objects"])) {
+ $find_objects = $_REQUEST["find_objects"];
+ } else {
+ $find_objects = '';
+ }
+
+ // Store the actively stored structure name
+ $gBitUser->storePreference( 'edit_structure_name', $rootStructure->mInfo['title'] );
+ $gBitUser->storePreference( 'edit_structure_id', $rootStructure->mStructureId );
+
+ // Get all wiki pages for the dropdown menu
+ $contentSelect = !isset( $_REQUEST['content_type'] ) ? 'bitpage' : $_REQUEST['content_type'];
+if( empty( $gContent ) ) {
+ require_once( WIKI_PKG_PATH.'lookup_page_inc.php' );
+}
+
+ $listpages = $gContent->getContentList( $contentSelect, 0, 500, 'title_asc', $find_objects);
+ $smarty->assign_by_ref('listContent', $listpages["data"]);
+ $smarty->assign('contentSelect', $contentSelect);
+
+ $contentTypes = array();
+ foreach( $gLibertySystem->mContentTypes as $cType ) {
+ $contentTypes[$cType['content_type_guid']] = $cType['content_description'];
+ }
+ $smarty->assign_by_ref('contentTypes', $contentTypes);
+
+
+
+ $subpages = $gStructure->s_get_pages($_REQUEST["structure_id"]);
+ $max = count($subpages);
+ $smarty->assign_by_ref('subpages', $subpages);
+ if ($max != 0) {
+ $last_child = $subpages[$max - 1];
+ $smarty->assign('insert_after', $last_child["structure_id"]);
+ }
+ $smarty->assign('find_objects', $find_objects);
+
+ if( ( isset( $_REQUEST["action"] ) && ( $_REQUEST["action"] == 'remove' ) ) || isset( $_REQUEST["confirm"] ) ) {
+
+ if( isset( $_REQUEST["confirm"] ) ) {
+ if( $gStructure->s_remove_page( $_REQUEST["structure_id"], false ) ) {
+ header( "Location: ".$_SERVER['PHP_SELF'].'?structure_id='.$gStructure->mInfo["parent_id"] );
+ die;
+ } else {
+ vd( $gStructure->mErrors );
+ }
+ }
+ $gBitSystem->setBrowserTitle( 'Confirm removal of '.$gContent->getTitle() );
+ $formHash['remove'] = TRUE;
+ $formHash['structure_id'] = $_REQUEST['structure_id'];
+ $msgHash = array(
+ 'label' => 'Remove content from Structure',
+ 'confirm_item' => $gContent->getTitle().'<br />and any subitems',
+ 'warning' => 'This will remove the content from the structure but will <strong>not</strong> modify or remove the content itself.',
+ );
+ $gBitSystem->confirmDialog( $formHash,$msgHash );
+ } elseif (isset($_REQUEST["move_node"])) {
+ if ($_REQUEST["move_node"] == '1') {
+ $gStructure->moveNodeWest();
+ } elseif ($_REQUEST["move_node"] == '2') {
+ $gStructure->moveNodeNorth();
+ } elseif ($_REQUEST["move_node"] == '3') {
+ $gStructure->moveNodeSouth();
+ } elseif ($_REQUEST["move_node"] == '4') {
+ $gStructure->moveNodeEast();
+ }
+ header( "Location: ".$_SERVER['PHP_SELF'].'?structure_id='.$gStructure->mInfo["structure_id"] );
+ die;
+ } elseif (isset($_REQUEST["create"])) {
+
+ if (isset($_REQUEST["pageAlias"])) {
+ $gStructure->set_page_alias($_REQUEST["structure_id"], $_REQUEST["pageAlias"]);
+ }
+
+ $structureHash['root_structure_id'] = $rootStructure->mStructureId;
+ $structureHash['parent_id'] = $_REQUEST['structure_id'];
+
+ $after = null;
+ if (isset($_REQUEST['after_ref_id'])) {
+ $structureHash['after_ref_id'] = $_REQUEST['after_ref_id'];
+ }
+ if (!(empty($_REQUEST['name']))) {
+ $gStructure->s_create_page($_REQUEST["structure_id"], $after, $_REQUEST["name"], '');
+ $gBitUser->copy_object_permissions($page_info["page_name"], $_REQUEST["name"],'wiki page');
+
+ } elseif(!empty($_REQUEST['content'])) {
+ foreach ($_REQUEST['content'] as $conId ) {
+ $structureHash['content_id'] = $conId;
+ $new_structure_id = $gStructure->storeNode( $structureHash );
+ $structureHash['after_ref_id'] = $new_structure_id;
+ }
+ }
+ }
+
+ $smarty->assign( (!empty( $_REQUEST['tab'] ) ? $_REQUEST['tab'] : 'body').'TabSelect', 'tdefault' );
+ $smarty->assign('subtree', $rootStructure->getSubTree( $rootStructure->mStructureId ));
+
+}
+
+?>
diff --git a/get_content_list_inc.php b/get_content_list_inc.php
new file mode 100644
index 0000000..8e087d6
--- /dev/null
+++ b/get_content_list_inc.php
@@ -0,0 +1,19 @@
+<?php
+require_once( LIBERTY_PKG_PATH."LibertyContent.php" );
+global $gContent;
+global $gLibertySystem;
+
+if( empty( $gContent ) || !is_object( $gContent ) ) {
+ $gContent = new LibertyContent();
+}
+
+$contentSelect = empty( $_REQUEST['content_type'] ) ? NULL : $_REQUEST['content_type'];
+
+// get_content_list_inc doesn't use $_REQUEST parameters as it might not be the only list in the page that needs sorting and limiting
+$contentList = $gContent->getContentList( $contentSelect, isset( $offset_content ) ? $offset_content : 0, isset( $max_content ) ? $max_content : 500, isset( $content_sort_mode ) ? $content_sort_mode : 'title_asc', empty( $_REQUEST["find_objects"] ) ? NULL : $_REQUEST["find_objects"], isset( $_REQUEST['user_id'] ) ? $_REQUEST['user_id'] : NULL );
+
+$contentTypes = array();
+foreach( $gLibertySystem->mContentTypes as $cType ) {
+ $contentTypes[$cType['content_type_guid']] = $cType['content_description'];
+}
+?>
diff --git a/icons/Mind-Reader.swf b/icons/Mind-Reader.swf
new file mode 100644
index 0000000..c5e142c
--- /dev/null
+++ b/icons/Mind-Reader.swf
Binary files differ
diff --git a/icons/accept.png b/icons/accept.png
new file mode 100644
index 0000000..bca54b0
--- /dev/null
+++ b/icons/accept.png
Binary files differ
diff --git a/icons/active.png b/icons/active.png
new file mode 100644
index 0000000..32c0d59
--- /dev/null
+++ b/icons/active.png
Binary files differ
diff --git a/icons/administration.png b/icons/administration.png
new file mode 100644
index 0000000..785ec42
--- /dev/null
+++ b/icons/administration.png
Binary files differ
diff --git a/icons/assign.gif b/icons/assign.gif
new file mode 100644
index 0000000..3795953
--- /dev/null
+++ b/icons/assign.gif
Binary files differ
diff --git a/icons/back.gif b/icons/back.gif
new file mode 100644
index 0000000..7a11d89
--- /dev/null
+++ b/icons/back.gif
Binary files differ
diff --git a/icons/bithelp.png b/icons/bithelp.png
new file mode 100644
index 0000000..08e3da2
--- /dev/null
+++ b/icons/bithelp.png
Binary files differ
diff --git a/icons/bitweaver.gif b/icons/bitweaver.gif
new file mode 100644
index 0000000..66ec51a
--- /dev/null
+++ b/icons/bitweaver.gif
Binary files differ
diff --git a/icons/bitweaver/adodb.gif b/icons/bitweaver/adodb.gif
new file mode 100644
index 0000000..c5e8dfc
--- /dev/null
+++ b/icons/bitweaver/adodb.gif
Binary files differ
diff --git a/icons/bitweaver/bitweaver.gif b/icons/bitweaver/bitweaver.gif
new file mode 100644
index 0000000..4d86cbd
--- /dev/null
+++ b/icons/bitweaver/bitweaver.gif
Binary files differ
diff --git a/icons/bitweaver/smarty.gif b/icons/bitweaver/smarty.gif
new file mode 100644
index 0000000..225d03f
--- /dev/null
+++ b/icons/bitweaver/smarty.gif
Binary files differ
diff --git a/icons/close.png b/icons/close.png
new file mode 100644
index 0000000..667e10c
--- /dev/null
+++ b/icons/close.png
Binary files differ
diff --git a/icons/collapsed.gif b/icons/collapsed.gif
new file mode 100644
index 0000000..10c64e7
--- /dev/null
+++ b/icons/collapsed.gif
Binary files differ
diff --git a/icons/config.gif b/icons/config.gif
new file mode 100644
index 0000000..1ac6aaa
--- /dev/null
+++ b/icons/config.gif
Binary files differ
diff --git a/icons/copy.png b/icons/copy.png
new file mode 100644
index 0000000..f2f83e3
--- /dev/null
+++ b/icons/copy.png
Binary files differ
diff --git a/icons/copy_folder.png b/icons/copy_folder.png
new file mode 100644
index 0000000..e67381a
--- /dev/null
+++ b/icons/copy_folder.png
Binary files differ
diff --git a/icons/current.png b/icons/current.png
new file mode 100644
index 0000000..43e0925
--- /dev/null
+++ b/icons/current.png
Binary files differ
diff --git a/icons/delete.png b/icons/delete.png
new file mode 100644
index 0000000..af10be0
--- /dev/null
+++ b/icons/delete.png
Binary files differ
diff --git a/icons/delete_small.gif b/icons/delete_small.gif
new file mode 100644
index 0000000..a63970d
--- /dev/null
+++ b/icons/delete_small.gif
Binary files differ
diff --git a/icons/detach.png b/icons/detach.png
new file mode 100644
index 0000000..58da6a4
--- /dev/null
+++ b/icons/detach.png
Binary files differ
diff --git a/icons/edit.gif b/icons/edit.gif
new file mode 100644
index 0000000..169003b
--- /dev/null
+++ b/icons/edit.gif
Binary files differ
diff --git a/icons/edit_small.gif b/icons/edit_small.gif
new file mode 100644
index 0000000..c77db3e
--- /dev/null
+++ b/icons/edit_small.gif
Binary files differ
diff --git a/icons/error.png b/icons/error.png
new file mode 100644
index 0000000..4c485f7
--- /dev/null
+++ b/icons/error.png
Binary files differ
diff --git a/icons/expanded.gif b/icons/expanded.gif
new file mode 100644
index 0000000..1a3aeff
--- /dev/null
+++ b/icons/expanded.gif
Binary files differ
diff --git a/icons/export.gif b/icons/export.gif
new file mode 100644
index 0000000..61f75c4
--- /dev/null
+++ b/icons/export.gif
Binary files differ
diff --git a/icons/folder.png b/icons/folder.png
new file mode 100644
index 0000000..77033a8
--- /dev/null
+++ b/icons/folder.png
Binary files differ
diff --git a/icons/folder_open.png b/icons/folder_open.png
new file mode 100644
index 0000000..b1b22e5
--- /dev/null
+++ b/icons/folder_open.png
Binary files differ
diff --git a/icons/gd_logo.jpg b/icons/gd_logo.jpg
new file mode 100644
index 0000000..6b1bde3
--- /dev/null
+++ b/icons/gd_logo.jpg
Binary files differ
diff --git a/icons/help.png b/icons/help.png
new file mode 100644
index 0000000..88e438e
--- /dev/null
+++ b/icons/help.png
Binary files differ
diff --git a/icons/home.png b/icons/home.png
new file mode 100644
index 0000000..26f9863
--- /dev/null
+++ b/icons/home.png
Binary files differ
diff --git a/icons/imagick_logo.jpg b/icons/imagick_logo.jpg
new file mode 100644
index 0000000..9de6319
--- /dev/null
+++ b/icons/imagick_logo.jpg
Binary files differ
diff --git a/icons/inactive.png b/icons/inactive.png
new file mode 100644
index 0000000..878a671
--- /dev/null
+++ b/icons/inactive.png
Binary files differ
diff --git a/icons/index.php b/icons/index.php
new file mode 100644
index 0000000..3e305fe
--- /dev/null
+++ b/icons/index.php
@@ -0,0 +1,6 @@
+<?php
+
+ // This is not a package.
+ header ("location: ../index.php");
+
+?> \ No newline at end of file
diff --git a/icons/info.png b/icons/info.png
new file mode 100644
index 0000000..bbd5dba
--- /dev/null
+++ b/icons/info.png
Binary files differ
diff --git a/icons/list.png b/icons/list.png
new file mode 100644
index 0000000..d2da45b
--- /dev/null
+++ b/icons/list.png
Binary files differ
diff --git a/icons/lulu.gif b/icons/lulu.gif
new file mode 100644
index 0000000..b030c98
--- /dev/null
+++ b/icons/lulu.gif
Binary files differ
diff --git a/icons/mail_send.png b/icons/mail_send.png
new file mode 100644
index 0000000..47a60f8
--- /dev/null
+++ b/icons/mail_send.png
Binary files differ
diff --git a/icons/mime/css.png b/icons/mime/css.png
new file mode 100644
index 0000000..41cc592
--- /dev/null
+++ b/icons/mime/css.png
Binary files differ
diff --git a/icons/mime/generic.png b/icons/mime/generic.png
new file mode 100644
index 0000000..ec4d38e
--- /dev/null
+++ b/icons/mime/generic.png
Binary files differ
diff --git a/icons/mime/html.png b/icons/mime/html.png
new file mode 100644
index 0000000..63f3c95
--- /dev/null
+++ b/icons/mime/html.png
Binary files differ
diff --git a/icons/mime/mp3.png b/icons/mime/mp3.png
new file mode 100644
index 0000000..afb7e1b
--- /dev/null
+++ b/icons/mime/mp3.png
Binary files differ
diff --git a/icons/mime/mpg.png b/icons/mime/mpg.png
new file mode 100644
index 0000000..9c47e16
--- /dev/null
+++ b/icons/mime/mpg.png
Binary files differ
diff --git a/icons/mime/pdf.png b/icons/mime/pdf.png
new file mode 100644
index 0000000..4e4725c
--- /dev/null
+++ b/icons/mime/pdf.png
Binary files differ
diff --git a/icons/mime/plain.png b/icons/mime/plain.png
new file mode 100644
index 0000000..bfe4bad
--- /dev/null
+++ b/icons/mime/plain.png
Binary files differ
diff --git a/icons/mime/zip.png b/icons/mime/zip.png
new file mode 100644
index 0000000..1f08fe1
--- /dev/null
+++ b/icons/mime/zip.png
Binary files differ
diff --git a/icons/move.gif b/icons/move.gif
new file mode 100644
index 0000000..02129d9
--- /dev/null
+++ b/icons/move.gif
Binary files differ
diff --git a/icons/move_down.png b/icons/move_down.png
new file mode 100644
index 0000000..8d13da6
--- /dev/null
+++ b/icons/move_down.png
Binary files differ
diff --git a/icons/move_left.png b/icons/move_left.png
new file mode 100644
index 0000000..4313173
--- /dev/null
+++ b/icons/move_left.png
Binary files differ
diff --git a/icons/move_left_right.png b/icons/move_left_right.png
new file mode 100644
index 0000000..8450ccb
--- /dev/null
+++ b/icons/move_left_right.png
Binary files differ
diff --git a/icons/move_right.png b/icons/move_right.png
new file mode 100644
index 0000000..ba2fa18
--- /dev/null
+++ b/icons/move_right.png
Binary files differ
diff --git a/icons/move_up.png b/icons/move_up.png
new file mode 100644
index 0000000..d78a2ea
--- /dev/null
+++ b/icons/move_up.png
Binary files differ
diff --git a/icons/nav_down.gif b/icons/nav_down.gif
new file mode 100644
index 0000000..f2e6acd
--- /dev/null
+++ b/icons/nav_down.gif
Binary files differ
diff --git a/icons/nav_first.gif b/icons/nav_first.gif
new file mode 100644
index 0000000..f8d70d6
--- /dev/null
+++ b/icons/nav_first.gif
Binary files differ
diff --git a/icons/nav_last.gif b/icons/nav_last.gif
new file mode 100644
index 0000000..189d3d0
--- /dev/null
+++ b/icons/nav_last.gif
Binary files differ
diff --git a/icons/nav_next.gif b/icons/nav_next.gif
new file mode 100644
index 0000000..c3bb47f
--- /dev/null
+++ b/icons/nav_next.gif
Binary files differ
diff --git a/icons/nav_prev.gif b/icons/nav_prev.gif
new file mode 100644
index 0000000..7a11d89
--- /dev/null
+++ b/icons/nav_prev.gif
Binary files differ
diff --git a/icons/nav_up.gif b/icons/nav_up.gif
new file mode 100644
index 0000000..a853e51
--- /dev/null
+++ b/icons/nav_up.gif
Binary files differ
diff --git a/icons/new.png b/icons/new.png
new file mode 100644
index 0000000..eabd286
--- /dev/null
+++ b/icons/new.png
Binary files differ
diff --git a/icons/note.png b/icons/note.png
new file mode 100644
index 0000000..bbd5dba
--- /dev/null
+++ b/icons/note.png
Binary files differ
diff --git a/icons/pbase.gif b/icons/pbase.gif
new file mode 100644
index 0000000..c3566f8
--- /dev/null
+++ b/icons/pbase.gif
Binary files differ
diff --git a/icons/pdf.gif b/icons/pdf.gif
new file mode 100644
index 0000000..ee61db3
--- /dev/null
+++ b/icons/pdf.gif
Binary files differ
diff --git a/icons/permissions.gif b/icons/permissions.gif
new file mode 100644
index 0000000..8ffa80a
--- /dev/null
+++ b/icons/permissions.gif
Binary files differ
diff --git a/icons/permissions_set.gif b/icons/permissions_set.gif
new file mode 100644
index 0000000..c0da223
--- /dev/null
+++ b/icons/permissions_set.gif
Binary files differ
diff --git a/icons/pkg_global.png b/icons/pkg_global.png
new file mode 100644
index 0000000..88f22d3
--- /dev/null
+++ b/icons/pkg_global.png
Binary files differ
diff --git a/icons/pkg_liberty.png b/icons/pkg_liberty.png
new file mode 100644
index 0000000..8324eba
--- /dev/null
+++ b/icons/pkg_liberty.png
Binary files differ
diff --git a/icons/plugin.png b/icons/plugin.png
new file mode 100644
index 0000000..be7c3ae
--- /dev/null
+++ b/icons/plugin.png
Binary files differ
diff --git a/icons/post.gif b/icons/post.gif
new file mode 100644
index 0000000..169003b
--- /dev/null
+++ b/icons/post.gif
Binary files differ
diff --git a/icons/print.gif b/icons/print.gif
new file mode 100644
index 0000000..6a17792
--- /dev/null
+++ b/icons/print.gif
Binary files differ
diff --git a/icons/refresh.png b/icons/refresh.png
new file mode 100644
index 0000000..fa77268
--- /dev/null
+++ b/icons/refresh.png
Binary files differ
diff --git a/icons/reply.png b/icons/reply.png
new file mode 100644
index 0000000..8aa26b0
--- /dev/null
+++ b/icons/reply.png
Binary files differ
diff --git a/icons/save.gif b/icons/save.gif
new file mode 100644
index 0000000..ba8d32e
--- /dev/null
+++ b/icons/save.gif
Binary files differ
diff --git a/icons/settings.png b/icons/settings.png
new file mode 100644
index 0000000..2f8789d
--- /dev/null
+++ b/icons/settings.png
Binary files differ
diff --git a/icons/sort.png b/icons/sort.png
new file mode 100644
index 0000000..3378d99
--- /dev/null
+++ b/icons/sort.png
Binary files differ
diff --git a/icons/sort_asc.png b/icons/sort_asc.png
new file mode 100644
index 0000000..313b9e0
--- /dev/null
+++ b/icons/sort_asc.png
Binary files differ
diff --git a/icons/sort_desc.png b/icons/sort_desc.png
new file mode 100644
index 0000000..399ac9f
--- /dev/null
+++ b/icons/sort_desc.png
Binary files differ
diff --git a/icons/sort_none.png b/icons/sort_none.png
new file mode 100644
index 0000000..999c940
--- /dev/null
+++ b/icons/sort_none.png
Binary files differ
diff --git a/icons/spacer.gif b/icons/spacer.gif
new file mode 100644
index 0000000..45b7594
--- /dev/null
+++ b/icons/spacer.gif
Binary files differ
diff --git a/icons/spacer_small.gif b/icons/spacer_small.gif
new file mode 100644
index 0000000..b9f1859
--- /dev/null
+++ b/icons/spacer_small.gif
Binary files differ
diff --git a/icons/success.png b/icons/success.png
new file mode 100644
index 0000000..5e0c2b5
--- /dev/null
+++ b/icons/success.png
Binary files differ
diff --git a/icons/tree.gif b/icons/tree.gif
new file mode 100644
index 0000000..a063667
--- /dev/null
+++ b/icons/tree.gif
Binary files differ
diff --git a/icons/upload.png b/icons/upload.png
new file mode 100644
index 0000000..8c1e2ad
--- /dev/null
+++ b/icons/upload.png
Binary files differ
diff --git a/icons/view.gif b/icons/view.gif
new file mode 100644
index 0000000..e830b6e
--- /dev/null
+++ b/icons/view.gif
Binary files differ
diff --git a/icons/warning.png b/icons/warning.png
new file mode 100644
index 0000000..9a8c5bb
--- /dev/null
+++ b/icons/warning.png
Binary files differ
diff --git a/list_content.php b/list_content.php
new file mode 100644
index 0000000..5678aba
--- /dev/null
+++ b/list_content.php
@@ -0,0 +1,30 @@
+<?php
+require_once("../bit_setup_inc.php");
+
+// some content specific offsets and pagination settings
+if( !empty( $_REQUEST['sort_mode'] ) ) {
+ $content_sort_mode = $_REQUEST['sort_mode'];
+ $smarty->assign( 'sort_mode', $content_sort_mode );
+}
+
+$max_content = $gBitSystem->mPrefs['maxRecords'];
+$offset_content = !empty( $_REQUEST['offset'] ) ? $_REQUEST['offset'] : 0;
+$smarty->assign( 'user_id', !empty( $_REQUEST['user_id'] ) ? $_REQUEST['user_id'] : NULL );
+$smarty->assign( 'page', $page = !empty( $_REQUEST['page'] ) ? $_REQUEST['page'] : 1 );
+$offset_content = ( $page - 1 ) * $gBitSystem->mPrefs['maxRecords'];
+
+// now that we have all the offsets, we can get the content list
+include_once( LIBERTY_PKG_PATH.'get_content_list_inc.php' );
+
+// calculate page number
+$numPages = ceil( $contentList['cant'] / $gBitSystem->mPrefs['maxRecords'] );
+$smarty->assign( 'numPages', $numPages );
+
+//$smarty->assign_by_ref('offset', $offset);
+$smarty->assign( 'contentSelect', $contentSelect );
+$smarty->assign( 'contentTypes', $contentTypes );
+$smarty->assign( 'contentList', $contentList['data'] );
+
+$gBitSystem->setBrowserTitle( 'List Content' );
+$gBitSystem->display( 'bitpackage:liberty/list_content.tpl' );
+?>
diff --git a/lookup_content_inc.php b/lookup_content_inc.php
new file mode 100644
index 0000000..02d4840
--- /dev/null
+++ b/lookup_content_inc.php
@@ -0,0 +1,31 @@
+<?php
+ global $gContent;
+
+ if( !empty( $_REQUEST['structure_id'] ) ) {
+ require_once( LIBERTY_PKG_PATH.'LibertyStructure.php');
+ $gStructure = new LibertyStructure( $_REQUEST['structure_id'] );
+ if( $gStructure->load() ) {
+// vd( $gStructure->mInfo );
+ $gStructure->loadNavigation();
+ $gStructure->loadPath();
+ $smarty->assign( 'structureInfo', $gStructure->mInfo );
+ // $_REQUEST['page_id'] = $gStructure->mInfo['page_id'];
+ if( $viewContent = $gStructure->getLibertyObject( $gStructure->mInfo['content_id'], $gStructure->mInfo['content_type']['content_type_guid'] ) ) {
+ $viewContent->load();
+ $viewContent->setStructure( $_REQUEST['structure_id'] );
+ $smarty->assign_by_ref( 'pageInfo', $viewContent->mInfo );
+ $gContent = &$viewContent;
+ $smarty->assign_by_ref( 'gContent', $gContent );
+ }
+ }
+ } elseif( !empty( $_REQUEST['content_id'] ) ) {
+ require_once( LIBERTY_PKG_PATH.'LibertyBase.php');
+ if( $gContent = LibertyBase::getLibertyObject( $_REQUEST['content_id'] ) ) {
+ if( $gContent->load() ) {
+ $smarty->assign_by_ref( 'gContent', $gContent );
+ $smarty->assign_by_ref( 'pageInfo', $gContent->mInfo );
+ }
+ }
+ }
+
+?>
diff --git a/modules/help_mod_last_changes.tpl b/modules/help_mod_last_changes.tpl
new file mode 100644
index 0000000..bdec014
--- /dev/null
+++ b/modules/help_mod_last_changes.tpl
@@ -0,0 +1,18 @@
+{tr}<strong>Summary</strong>: Display the most recently changed content.{/tr}<br />
+<table class="data">
+ <tr>
+ <th style="width:20%;">{tr}Parameter{/tr}</th>
+ <th style="width:20%;">{tr}Value{/tr}</th>
+ <th style="width:60%;">{tr}Description{/tr}</th>
+ </tr>
+ <tr class="odd">
+ <td>content_type_guid</td>
+ <td>bitpage<br />bituser<br />...</td>
+ <td>{tr}Here you can specify what type of content you wish to show.{/tr}</td>
+ </tr>
+ <tr class="even">
+ <td>show_date</td>
+ <td>(boolean)</td>
+ <td>{tr}Specify if you want to display the date of the last modification.{/tr}</td>
+ </tr>
+</table>
diff --git a/modules/help_mod_top_authors.tpl b/modules/help_mod_top_authors.tpl
new file mode 100644
index 0000000..a466975
--- /dev/null
+++ b/modules/help_mod_top_authors.tpl
@@ -0,0 +1,13 @@
+{tr}<strong>Summary</strong>: Display the most popular authors based on page hits.{/tr}<br />
+<table class="data">
+ <tr>
+ <th style="width:20%;">{tr}Parameter{/tr}</th>
+ <th style="width:20%;">{tr}Value{/tr}</th>
+ <th style="width:60%;">{tr}Description{/tr}</th>
+ </tr>
+ <tr class="odd">
+ <td>content_type_guid</td>
+ <td>bitpage<br />bitblogpost<br />...</td>
+ <td>{tr}Specify what content the statistics should be based on. 'bituser' will give you ranking based on whose homepage has been hit most frequently.{/tr}</td>
+ </tr>
+</table>
diff --git a/modules/mod_last_changes.php b/modules/mod_last_changes.php
new file mode 100644
index 0000000..679103f
--- /dev/null
+++ b/modules/mod_last_changes.php
@@ -0,0 +1,34 @@
+<?php
+// $Header: /cvsroot/bitweaver/_bit_liberty/modules/mod_last_changes.php,v 1.1 2005/06/19 04:55:51 bitweaver Exp $
+/**
+* Params:
+* - content_type_guid : if set, show only those content_type_guid's
+* - show_date : if set, show date of last modification
+*/
+
+
+global $gQueryUser, $gBitUser, $module_rows, $module_params, $gLibertySystem, $module_title;
+
+
+$userId = NULL;
+if( !empty( $gQueryUser->mUserId ) ) {
+ $userId = $gQueryUser->mUserId;
+}
+
+if( empty( $module_title ) ) {
+ if( !empty( $module_params['content_type_guid'] ) && !empty( $gLibertySystem->mContentTypes[$module_params['content_type_guid']] ) ) {
+ $title = tra( "Last Changes" ).': '.tra( $gLibertySystem->mContentTypes[$module_params['content_type_guid']]['content_description'] );
+ } else {
+ $smarty->assign( 'showContentType', TRUE );
+ $title = tra( "Last Changes" );
+ }
+ $smarty->assign( 'moduleTitle', $title );
+}
+
+if( !empty( $module_params['show_date'] ) ) {
+ $smarty->assign( 'showDate' , TRUE );
+}
+
+$modLastContent = $gBitUser->getContentList( !empty( $module_params['content_type_guid'] ) ? $module_params['content_type_guid'] : NULL, 0, $module_rows, 'last_modified_desc', NULL, $userId );
+$smarty->assign_by_ref( 'modLastContent', $modLastContent['data'] );
+?>
diff --git a/modules/mod_last_changes.tpl b/modules/mod_last_changes.tpl
new file mode 100644
index 0000000..b1b52ce
--- /dev/null
+++ b/modules/mod_last_changes.tpl
@@ -0,0 +1,23 @@
+{* $Header: /cvsroot/bitweaver/_bit_liberty/modules/mod_last_changes.tpl,v 1.1 2005/06/19 04:55:51 bitweaver Exp $ *}
+{strip}
+{if $modLastContent}
+ {bitmodule title="$moduleTitle" name="last_changes"}
+ <ol>
+ {section name=ix loop=$modLastContent}
+ <li>
+ {if $showContentType }
+ <strong>{tr}{$modLastContent[ix].content_description}{/tr}: </strong>
+ {/if}
+ {$modLastContent[ix].display_link}
+ {if $showDate}
+ <br/><span class="date">{$modLastContent[ix].last_modified|bit_long_date}</span>
+ {/if}
+ </li>
+ {sectionelse}
+ <li></li>
+ {/section}
+ </ol>
+ <a href="{$gBitLoc.LIBERTY_PKG_URL}list_content.php?user_id={$gQueryUserId}&amp;sort_mode=last_modified_desc">{tr}View more{/tr}&hellip;</a>
+ {/bitmodule}
+{/if}
+{/strip}
diff --git a/modules/mod_structure_navigation.php b/modules/mod_structure_navigation.php
new file mode 100644
index 0000000..67c94a5
--- /dev/null
+++ b/modules/mod_structure_navigation.php
@@ -0,0 +1,2 @@
+<?php
+?> \ No newline at end of file
diff --git a/modules/mod_structure_navigation.tpl b/modules/mod_structure_navigation.tpl
new file mode 100644
index 0000000..677b38a
--- /dev/null
+++ b/modules/mod_structure_navigation.tpl
@@ -0,0 +1,5 @@
+{if $structureInfo}
+ {bitmodule title="$moduleTitle" name="structure_navigation"}
+ {include file="bitpackage:liberty/display_structure.tpl" wikibook_show_path='y' wikibook_show_navigation='y' wikibook_use_icons='y'}
+ {/bitmodule}
+{/if}
diff --git a/modules/mod_top_authors.php b/modules/mod_top_authors.php
new file mode 100644
index 0000000..f1c1d94
--- /dev/null
+++ b/modules/mod_top_authors.php
@@ -0,0 +1,31 @@
+<?php
+// $Header: /cvsroot/bitweaver/_bit_liberty/modules/mod_top_authors.php,v 1.1 2005/06/19 04:55:51 bitweaver Exp $
+/**
+* Params:
+* - content_type_guid : if set, show only those content_type_guid's
+*/
+
+
+global $gQueryUser, $gBitUser, $module_rows, $module_params, $module_title, $gLibertySystem;
+
+
+if( empty( $module_title ) ) {
+ if( !empty( $module_params['content_type_guid'] ) && !empty( $gLibertySystem->mContentTypes[$module_params['content_type_guid']] ) ) {
+ $title = tra( "Top Authors" ).': '.tra( $gLibertySystem->mContentTypes[$module_params['content_type_guid']]['content_description'] );
+ } else {
+ $smarty->assign( 'showContentType', TRUE );
+ $title = tra( "Top Authors" );
+ }
+ $smarty->assign( 'moduleTitle', $title );
+}
+
+
+$listHash = $_REQUEST;
+if( !empty( $module_params['content_type_guid'] ) ) {
+ $listHash['content_type_guid'] = $module_params['content_type_guid'];
+}
+$listHash['max_request'] = $module_rows;
+
+$modAuthors = $gBitUser->getAuthorList( $listHash );
+$smarty->assign_by_ref( 'modAuthors', $modAuthors );
+?>
diff --git a/modules/mod_top_authors.tpl b/modules/mod_top_authors.tpl
new file mode 100644
index 0000000..8bef14a
--- /dev/null
+++ b/modules/mod_top_authors.tpl
@@ -0,0 +1,17 @@
+{* $Header: /cvsroot/bitweaver/_bit_liberty/modules/mod_top_authors.tpl,v 1.1 2005/06/19 04:55:51 bitweaver Exp $ *}
+{strip}
+{if $modAuthors}
+ {bitmodule title="$moduleTitle" name="top_authors"}
+ <ol>
+ {section name=ix loop=$modAuthors}
+ <li>
+ {displayname hash=$modAuthors[ix]}
+ </li>
+ {sectionelse}
+ <li></li>
+ {/section}
+ </ol>
+{* <div style="text-align:center;"><a href="{$gBitLoc.LIBERTY_PKG_URL}list_content.php?user_id={$gQueryUserId}&sort_mode=last_modified_desc">{tr}View more{/tr}...</a></div> *}
+ {/bitmodule}
+{/if}
+{/strip}
diff --git a/plugins/data.addtabs.php b/plugins/data.addtabs.php
new file mode 100644
index 0000000..ee73185
--- /dev/null
+++ b/plugins/data.addtabs.php
@@ -0,0 +1,71 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Author: StarRider <starrrider@sbcglobal.net>
+// | Reworked from: wikiplugin_include.php - see deprecated code below
+// +----------------------------------------------------------------------+
+// $Id: data.addtabs.php,v 1.1 2005/06/19 04:55:47 bitweaver Exp $
+// Initialization
+define( 'PLUGIN_GUID_DATAADDTABS', 'dataaddtabs' );
+global $gLibertySystem;
+global $gContent;
+$pluginParams = array ( 'tag' => 'ADDTABS',
+ 'auto_activate' => FALSE,
+ 'requires_pair' => FALSE,
+ 'load_function' => 'data_addtabs',
+ 'title' => 'AddTabs',
+ 'description' => tra("Will join the contents from several sources in a Tabbed Interface."),
+ 'help_function' => 'data_addtabs_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/DataPluginAddtabs",
+ 'syntax' => "{addtabs tab1= tab2= tab3= . . . tab99= }",
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATAADDTABS, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAADDTABS );
+
+// Help Function
+function data_addtabs_help() {
+ $help =
+ '<table class="data help">'
+ .'<tr>'
+ .'<th>' . tra( "Key" ) . '</th>'
+ .'<th>' . tra( "Type" ) . '</th>'
+ .'<th>' . tra( "Comments" ) . '</th>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>tab1 - tab99</td>'
+ .'<td>' . tra( "numeric") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( 'Will create a Tab interface on a page. The name on each tab is the name given to the imported page.The value sent with the TabX parameter is a bitweaver Numeric Content Id. This allows blog posts, images, wiki pages...and more to be added<br /><strong>Note:</strong> The order used when the tabs are specified does not matter. The Tabname does - Tab1 is always first and Tab99 will always be last. Avaliable content can be viewed ') . '<a href="'.LIBERTY_PKG_URL.'list_content.php" title="Opens content browser in new window" onkeypress="popUpWin(this.href,\'standard\',600,400);" onclick="popUpWin(this.href,\'standard\',600,400);return false;">' . tra( "here" ) . '</a></td>'
+ .'</tr>'
+ .'</table>'
+ . tra("Example: ") . '{addtabs tab1=15 tab2=12 tab3=11}';
+ return $help;
+}
+
+function data_addtabs($data, $params) {
+ extract ($params);
+ $ret = "<div id='tab-system' class='tabsystem'>";
+ for ($i = 1; $i <= 99; $i++) {
+ if( isset( ${'tab'.$i} ) && is_numeric( ${'tab'.$i} ) ) {
+ $obj = LibertyBase::getLibertyObject( ${'tab'.$i} );
+ if( $obj->load() ) {
+ $ret .= "<div class='tabpage '><h3>" .$obj->getTitle() . "</h3><div class='contents'>" . $obj->parseData() . "</div></div><!-- end .tabpage -->";
+// $ret .= "<div class='tabpage '><h3>" . ${'tab'.$i} . "</h3><div class='contents'>" . $obj->parseData() . "</div></div><!-- end .tabpage -->";
+ $good=True;
+ }
+ }
+ }
+ $ret .= "</div>";
+ if( !$good ) {
+ $ret = "The Plugin AddTabs requires valid parameters. Numeric content id numbers can use the parameter names 'tab1' thru 'tab99'";
+ }
+ return $ret;
+}
+?>
diff --git a/plugins/data.agentinfo.php b/plugins/data.agentinfo.php
new file mode 100644
index 0000000..17d1ff3
--- /dev/null
+++ b/plugins/data.agentinfo.php
@@ -0,0 +1,95 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Author: StarRider <starrrider@sbcglobal.net>
+// | Reworked from: wikiplugin_agentinfo.php - see deprecated code below
+// +----------------------------------------------------------------------+
+// $Id: data.agentinfo.php,v 1.1 2005/06/19 04:55:47 bitweaver Exp $
+// Initialization
+define( 'PLUGIN_GUID_DATAAGENTINFO', 'dataagentinfo' );
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'AGENTINFO',
+ 'auto_activate' => TRUE,
+ 'requires_pair' => FALSE,
+ 'load_function' => 'data_agentinfo',
+ 'title' => 'AgentInfo',
+ 'description' => tra("This plugin will display the viewer's IP address, the Browser they are using, or the info about the site's Server software."),
+ 'help_function' => 'data_agentinfo_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/index.php", // Update this URL when a page on TP.O exists
+ 'syntax' => "{agentinfo info= }",
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATAAGENTINFO, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAAGENTINFO );
+
+// Help Function
+function data_agentinfo_help() {
+ $help =
+ '<table class="data help">'
+ .'<tr>'
+ .'<th>' . tra( "Key" ) . '</th>'
+ .'<th>' . tra( "Type" ) . '</th>'
+ .'<th>' . tra( "Comments" ) . '</th>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>info</td>'
+ .'<td>' . tra( "string") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "Show information about the Browser being used.") . '<br />'
+ .'<strong>ip</strong>: ' . tra( "To get the client\'s IP address (default)" ) . '<br />'
+ .'<strong>browser</strong>: ' . tra( "To get the clients Browser infromation." ) . '<br />'
+ .'<strong>server</strong>: ' . tra( "To get the site\'s server software" ) . '<br />'
+ .'</tr>'
+ .'</table>'
+ . tra("Example: ") . "{agentinfo info='browser'}";
+ return $help;
+}
+
+// Load Function
+function data_agentinfo($data, $params) {
+ $info = 'IP';
+ extract ($params);
+ switch (strtoupper ($info)) {
+ case 'SVRSW': // To maintain Pre-Clyde Parameters
+ case 'SERVER':
+ $ret = $_SERVER["SERVER_SOFTWARE"];
+ return $ret;
+ case 'BROWSER':
+ $ret = $_SERVER["HTTP_USER_AGENT"];
+ return $ret;
+ default:
+ $ret = $_SERVER["REMOTE_ADDR"];
+ return $ret;
+ }
+
+}
+/******************************************************************************
+The code below is from the deprecated AGENTINFO plugin. All comments and the help routines have been removed. - StarRider
+// Wiki plugin to display a browser client information
+// damian aka damosoft May 2004
+
+function wikiplugin_agentinfo($data, $params) {
+ extract ($params);
+ $ret = '';
+ if (!isset($info)) {
+ $info = 'IP';
+ }
+ if ($info == 'IP') {
+ $ret = $_SERVER["REMOTE_ADDR"];
+ }
+ if ($info == 'SVRSW') {
+ $ret = $_SERVER["SERVER_SOFTWARE"];
+ }
+ if ($info == 'BROWSER') {
+ $ret = $_SERVER["HTTP_USER_AGENT"];
+ }
+ return $ret;
+}
+*/
+?>
diff --git a/plugins/data.article.php b/plugins/data.article.php
new file mode 100644
index 0000000..8c8f268
--- /dev/null
+++ b/plugins/data.article.php
@@ -0,0 +1,90 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Author: StarRider <starrrider@sbcglobal.net>
+// | Reworked from: wikiplugin_article.php - see deprecated code below
+// +----------------------------------------------------------------------+
+// $Id: data.article.php,v 1.1 2005/06/19 04:55:47 bitweaver Exp $
+// Initialization
+global $gBitSystem;
+if( $gBitSystem->isPackageActive( 'articles' ) ) { // Do not include this Plugin if the Package is not active
+define( 'PLUGIN_GUID_DATAARTICLE', 'dataarticle' );
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'ARTICLE',
+ 'auto_activate' => FALSE,
+ 'requires_pair' => FALSE,
+ 'load_function' => 'data_article',
+ 'title' => 'Article<strong> - This plugin is not yet functional.</strong>', // Remove this line when the plugin
+// 'title' => 'Article', // and Remove the comment from the start of this line
+ 'description' => tra("This plugin will display the data from a single field in the specified Article."),
+ 'help_function' => 'data_article_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/index.php", // Update this URL when a page on TP.O exists
+ 'syntax' => "{article id= field=}",
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATAARTICLE, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAARTICLE );
+
+// Help Routine
+function data_article_help() {
+ $help =
+ '<table class="data help">'
+ .'<tr>'
+ .'<th>' . tra( "Key" ) . '</th>'
+ .'<th>' . tra( "Type" ) . '</th>'
+ .'<th>' . tra( "Comments" ) . '</th>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>id</td>'
+ .'<td>' . tra( "numeric") . '<br />' . tra("(required)") . '</td>'
+ .'<td>' . tra( "The Id number of the Article. This value can easily be found in the URL when the Article is displayed.") . '</td>'
+ .'</tr>'
+ .'<tr class="even">'
+ .'<td>field</td>'
+ .'<td>' . tra( "string") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "This can be any field found in the") . ' tiki_articles ' . tra("table.") . '<br />'
+ . tra("This includes (in order of usefulnes):") . '<strong>title, heading, body, author, size, reads, votes, points, type and rating</strong>' . '</td>'
+ .'</tr>'
+ .'</table>'
+ . tra("Example: ") . "{article id=14 field='heading'}";
+ return $help;
+}
+
+// Executable Routine
+function data_article($data, $params) { // No change in the parameters with Clyde
+// The next 2 lines allow access to the $pluginParams given above and may be removed when no longer needed
+ global $gLibertySystem;
+ $pluginParams = $gLibertySystem->mPlugins[PLUGIN_GUID_DATAARTICLE];
+ $ret = 'The plugin <strong>"' . $pluginParams['tag'] . '"</strong> has not been completed as yet. ';
+ return $ret;
+}
+}
+/******************************************************************************
+The code below is from the deprecated ARTICLE plugin. All comments and the help routines have been removed. - StarRider
+
+global $gBitSystem;
+if( $gBitSystem->isPackageActive( 'articles' ) ) {
+ include_once( ARTICLES_PKG_PATH . 'art_lib.php' );
+
+ function wikiplugin_article($data, $params) {
+ global $artlib;
+ extract ($params);
+ if (!isset($id)) {
+ return ("<b>The plugin Article needs an article ID to function.</b><br/>");
+ }
+ if (!isset($field)) {
+ $field = 'heading';
+ }
+ $article_data = $artlib->get_article($id);
+ return $article_data[$field];
+ }
+}
+*/
+?>
diff --git a/plugins/data.articles.php b/plugins/data.articles.php
new file mode 100644
index 0000000..2118b96
--- /dev/null
+++ b/plugins/data.articles.php
@@ -0,0 +1,115 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Author: StarRider <starrrider@sbcglobal.net>
+// | Reworked from: wikiplugin_articles.php - see deprecated code below
+// +----------------------------------------------------------------------+
+// $Id: data.articles.php,v 1.1 2005/06/19 04:55:48 bitweaver Exp $
+// Initialization
+global $gBitSystem;
+if( $gBitSystem->isPackageActive( 'articles' ) ) { // Do not include this Plugin if the Package is not active
+define( 'PLUGIN_GUID_DATAARTICLES', 'dataarticles' );
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'ARTICLES',
+ 'auto_activate' => FALSE,
+ 'requires_pair' => FALSE,
+ 'load_function' => 'data_articles',
+ 'title' => 'Articles<strong> - This plugin is not yet functional.</strong>', // Remove this line when the plugin becomes operational
+// 'title' => 'Articles', // and Remove the comment from the start of this line
+ 'description' => tra("This plugin will display several Articles."),
+ 'help_function' => 'data_articles_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/index.php", // Update this URL when a page on TP.O exists
+ 'syntax' => "{articles max= topic= type= }",
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATAARTICLES, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAARTICLES );
+
+// Help Routine
+function data_articles_help() {
+ $help =
+ '<table class="data help">'
+ .'<tr>'
+ .'<th>' . tra( "Key" ) . '</th>'
+ .'<th>' . tra( "Type" ) . '</th>'
+ .'<th>' . tra( "Comments" ) . '</th>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>max</td>'
+ .'<td>' . tra( "numeric") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "The number of Articles to be displayed. (Default = 3)") . '</td>'
+ .'</tr>'
+ .'<tr class="even">'
+ .'<td>topic</td>'
+ .'<td>' . tra( "topic name") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "Filters the Articles so that only the Topic specified is displayed") . '</td>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>type</td>'
+ .'<td>' . tra( "type name") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "Filters the Articles so that only the Type specified is displayed") . '</td>'
+ .'</tr>'
+ .'</table>'
+ . tra("Example: ") . "{articles max=5 topic='some_topic'}<br />"
+ . tra("Example: ") . "{articles max=5 type='some_type'}";
+ return $help;
+}
+
+// Executable Routine
+function data_articles($data, $params) { // No change in the parameters with Clyde
+// The next 2 lines allow access to the $pluginParams given above and may be removed when no longer needed
+ global $gLibertySystem;
+ $pluginParams = $gLibertySystem->mPlugins[PLUGIN_GUID_DATAARTICLES];
+ $ret = 'The plugin <strong>"' . $pluginParams['tag'] . '"</strong> has not been completed as yet. ';
+ return $ret;
+}
+}
+/******************************************************************************
+The code below is from the deprecated ARTICLES plugin. All comments and the help routines have been removed. - StarRider
+
+
+
+global $gBitSystem;
+if( $gBitSystem->isPackageActive( 'articles' ) ) {
+ include_once( ARTICLES_PKG_PATH . 'art_lib.php' );
+
+ function wikiplugin_articles($data,$params) {
+ global $smarty;
+ global $artlib;
+ global $feature_articles;
+ global $bit_p_read_article;
+ global $user;
+ extract($params);
+ if (($feature_articles != 'y') || (!$gBitUser->hasPermission( 'bit_p_read_article' ))) {
+ // the feature is disabled or the user can't read articles
+ return("");
+ }
+ if(!isset($max)) {$max='3';}
+ // Addes filtering by topic if topic is passed
+ if(!isset($topic)) {
+ $topic='';
+ } else {
+ $topic = $artlib->get_topic_id($topic);
+ }
+ $now = date("U");
+ $listpages = $artlib->list_articles(0, $max, 'publish_date_desc', '', $now, $user, '', $topic);
+ for ($i = 0; $i < count($listpages["data"]); $i++) {
+ $listpages["data"][$i]["parsed_heading"] = $artlib->parseData($listpages["data"][$i]["heading"]);
+ //print_r($listpages["data"][$i]['title']);
+ }
+ $topics = $artlib->list_topics();
+ $smarty->assign_by_ref('topics', $topics);
+ // If there're more records then assign next_offset
+ $smarty->assign_by_ref('listpages', $listpages["data"]);
+ return "~np~ ".$smarty->fetch('bitpackage:articles/center_list_articles.tpl')." ~/np~";
+ }
+}
+*/
+?>
diff --git a/plugins/data.attachment.php b/plugins/data.attachment.php
new file mode 100644
index 0000000..1641977
--- /dev/null
+++ b/plugins/data.attachment.php
@@ -0,0 +1,113 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Authors: drewslater <andrew@andrewslater.com>
+// +----------------------------------------------------------------------+
+// $Id: data.attachment.php,v 1.1 2005/06/19 04:55:47 bitweaver Exp $
+// Initialization
+global $gBitSystem;
+
+define( 'PLUGIN_GUID_DATAATTACHMENT', 'dataattachment' );
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'ATTACHMENT',
+ 'auto_activate' => TRUE,
+ 'requires_pair' => FALSE,
+ 'load_function' => 'data_attachment',
+ 'title' => 'Attachment',
+ 'description' => tra("Display attachment in content"),
+ 'help_function' => 'data_attachment_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/index.php", // Update this URL when a page on TP.O exists
+ 'syntax' => '{attachment id= size= align= }',
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATAATTACHMENT, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAATTACHMENT );
+
+
+function data_attachment_help() {
+ $help =
+ '<table class="data help">'
+ .'<tr>'
+ .'<th>' . tra( "Key" ) . '</th>'
+ .'<th>' . tra( "Type" ) . '</th>'
+ .'<th>' . tra( "Comments" ) . '</th>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>id</td>'
+ .'<td>' . tra( "numeric") . '<br />' . tra("(required)") . '</td>'
+ .'<td>' . tra( "Id number of Attachment to display inline.") . '</td>'
+ .'</tr>'
+ .'<tr class="even">'
+ .'<td>size</td>'
+ .'<td>' . tra( "key-words") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "If the Attachment is an image, you can specify the size of the thumbnail displayed. Possible values are:") . ' <strong>avatar, small, medium, large, original</strong> '
+ . tra("(Default = ") . '<strong>medium</strong>)</td>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>link</td>'
+ .'<td>' . tra( "string") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "Allows you to specify a relative or absolute URL the image will link to if clicked. If set to false, no link is inserted.")
+ . tra("(Default = ") . '<strong>'.tra( 'link to source image' ).'</strong>)</td>'
+ .'</tr>'
+ .'<tr class="even">'
+ .'<td>align</td>'
+ .'<td>' . tra( "key-words") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "Specifies how the Image / Attachment is to be alligned on the page. Possible values are:") . ' <strong>left, center, right</strong> '
+ . tra("(Default = ") . '<strong>'.tra( 'none - attachment is shown inline' ).'</strong>)</td>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>float</td>'
+ .'<td>' . tra( "key-words") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "Specifies how the Image / Attachment is to float on the page. Behaviour of float is different to align. Possible values are:") . ' <strong>left, right</strong> '
+ . tra("(Default = ") . '<strong>'.tra( 'none - attachment is shown inline' ).'</strong>)</td>'
+ .'</tr>'
+ .'</table>'
+ . tra("Example: ") . "{attachment id='13' size='small' align='center' link='http://www.google.com'}";
+ return $help;
+}
+
+function data_attachment($data, $params) { // NOTE: The original plugin had several parameters that have been dropped
+ // at a minimum, return blank string (not empty) so we still replace the tag
+ $ret = ' ';
+ if( empty( $params['id'] ) ) {
+ // The Manditory Parameter is missing. we are not gonna trow an error, and just return empty since
+ // many sites use the old style required second "closing" empty tag
+ return $ret;
+ }
+ $liba = new LibertyAttachable();
+ if( !$att = $liba->getAttachment( $params['id'] ) ) {
+ $ret = tra("__Error__ - The plugin") . " __~np~{ATTACHMENT}~/np~__ " . tra("was given the parameter") . " id=" . $params['id'] . tra(" which is not valid.\n");
+ return $ret;
+ }
+
+ // insert source url if we need the original file
+ if( !empty( $params['size'] ) && $params['size'] == 'original' ) {
+ $thumburl = $att['source_url'];
+ } else {
+ $thumburl = ( !empty( $params['size'] ) && !empty( $att['thumbnail_url'][$params['size']] ) ? $att['thumbnail_url'][$params['size']] : $att['thumbnail_url']['medium'] );
+ }
+
+ // use specified link as href. insert default link to source only when source not already displayed
+ if( !empty( $params['link'] ) && $params['link'] == 'false' ) {
+ $href = '';
+ } elseif( !empty( $params['link'] ) ) {
+ $href = ' href="'.$params['link'].'"';
+ } elseif( empty( $params['size'] ) || $params['size'] != 'original' ) {
+ $href = ' href="'.$att['source_url'].'"';
+ } else {
+ $href = '';
+ }
+
+ $aloat = ( !empty( $params['align'] ) ? '<div style="text-align:'.$params['align'].';">' : NULL );
+ $aloat = ( ( !empty( $params['float'] ) && empty( $aloat ) ) ? '<div style="float:'.$params['float'].';">' : NULL );
+ $ret = $aloat.'<a'.$href.'"><img src="'.$thumburl.'"/></a>'.(!empty($aloat)?'</div>':'');
+ return $ret;
+}
+?>
diff --git a/plugins/data.avatar.php b/plugins/data.avatar.php
new file mode 100644
index 0000000..0ed1f3e
--- /dev/null
+++ b/plugins/data.avatar.php
@@ -0,0 +1,96 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Author: StarRider <starrrider@sbcglobal.net>
+// | Reworked from: wikiplugin_avatar.php - see deprecated code below
+// +----------------------------------------------------------------------+
+// $Id: data.avatar.php,v 1.1 2005/06/19 04:55:48 bitweaver Exp $
+// Initialization
+global $gBitSystem;
+if( $gBitSystem->isPackageActive( 'wiki' ) ) { // Do not include this Plugin if the Package is not active
+define( 'PLUGIN_GUID_DATAAVATAR', 'dataavatar' );
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'AVATAR',
+ 'auto_activate' => TRUE,
+ 'requires_pair' => FALSE,
+ 'load_function' => 'data_avatar',
+ 'title' => 'Avatar<strong> - This plugin is not yet functional.</strong>', // Remove this line when the plugin becomes operational
+// 'title' => 'Avatar', // and Remove the comment from the start of this line
+ 'description' => tra("This plugin will display a User's Avatar as a Link to a page."),
+ 'help_function' => 'data_avatar_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/index.php", // Update this URL when a page on TP.O exists
+ 'syntax' => "{avatar user= page= float= }",
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATAAVATAR, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAAVATAR );
+
+// Help Function
+function data_avatar_help() {
+ $help =
+ '<table class="data help">'
+ .'<tr>'
+ .'<th>' . tra( "Key" ) . '</th>'
+ .'<th>' . tra( "Type" ) . '</th>'
+ .'<th>' . tra( "Comments" ) . '</th>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>user</td>'
+ .'<td>' . tra( "numeric") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "Name of the user who's avatar should be shown (Default = avatar of user accessing page).") . '</td>'
+ // Would somebody check the default - it would make more sence if it was the Author of the page instead of whoever is reading it
+ .'</tr>'
+ .'<tr class="even">'
+ .'<td>page</td>'
+ .'<td>' . tra( "page name") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "Used to make the Avatar a link to a specified page. (Default = Homepage of the Avatar's owner)") . '</td>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>float</td>'
+ .'<td>' . tra( "key-words") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "Specifies how the Avatar is to be alligned on the page. If NOT defined - the text will not wrap around the Avatar. Possible values are:")
+ . ' <strong>left or right</strong> ' . tra("(Default = ") . '<strong>NOT SET</strong>)</td>'
+ .'</tr>'
+ .'</table>'
+ . tra("Example: ") . "{include user='admin' page='home' float='right'}";
+ return $help;
+}
+
+// Load Function
+function data_avatar($data, $params) { // Pre-Clyde Changes
+// The Parameter user is new - the info was extracted from $data
+// The next 2 lines allow access to the $pluginParams given above and may be removed when no longer needed
+ global $gLibertySystem;
+ $pluginParams = $gLibertySystem->mPlugins[PLUGIN_GUID_DATAAVATAR];
+ $ret = 'The plugin <strong>"' . $pluginParams['tag'] . '"</strong> has not been completed as yet. ';
+ return $ret;
+}
+}
+/******************************************************************************
+The code below is from the deprecated AVATAR plugin. All comments and the help routines have been removed. - StarRider
+require_once( KERNEL_PKG_PATH.'BitBase.php' );
+
+function wikiplugin_avatar($data, $params) {
+ global $gBitSystem;
+ global $gBitUser;
+ extract ($params);
+ if (isset($float))
+ $avatar = $gBitSystem->get_user_avatar($data, $float);
+ else
+ $avatar = $gBitSystem->get_user_avatar($data);
+ if (isset($page)) {
+ $avatar = "<a href=\"".WIKI_PKG_URL."index.php?page=$page'>" . $avatar . '</a>';
+ } else if ($gBitUser->userExists( array( 'login' => $data ) ) && $gBitSystem->get_user_preference($data, 'user_information', 'public') == 'public') {
+ $avatar = "<a href=\"".USERS_PKG_URL."\"index.php?fHomepage=$data\">" . $avatar . '</a>';
+ }
+ return $avatar;
+}
+*/
+?>
diff --git a/plugins/data.backlinks.php b/plugins/data.backlinks.php
new file mode 100644
index 0000000..cccdd97
--- /dev/null
+++ b/plugins/data.backlinks.php
@@ -0,0 +1,163 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Author: StarRider <starrrider@sbcglobal.net>
+// | Reworked from: wikiplugin_backlinks.php - see deprecated code below
+// +----------------------------------------------------------------------+
+// $Id: data.backlinks.php,v 1.1 2005/06/19 04:55:48 bitweaver Exp $
+// Initialization
+global $gBitSystem;
+if( ( $gBitSystem->isPackageActive( 'wiki' ) ) && ( $gBitSystem->isFeatureActive('feature_backlinks') ) ) { // Do not include this Plugin if the Package or the Feature is not active
+define( 'PLUGIN_GUID_DATABACKLINKS', 'databacklinks' );
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'BACKLINKS',
+ 'auto_activate' => FALSE,
+ 'requires_pair' => FALSE,
+ 'load_function' => 'data_backlinks',
+ 'title' => 'BackLinks<strong> - This plugin is not yet functional.</strong>', // Remove this line when the plugin becomes operational
+// 'title' => 'BackLinks', // and Remove the comment from the start of this line
+ 'description' => tra("This plugin will list all Wiki pages which contains a link to the specified page."),
+ 'help_function' => 'data_backlinks_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/index.php", // Update this URL when a page on TP.O exists
+ 'syntax' => "{backlinks page= info= exclude= self= header= }",
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATABACKLINKS, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATABACKLINKS );
+
+// Help Function
+function data_backlinks_help() {
+ $help =
+ '<table class="data help">'
+ .'<tr>'
+ .'<th>' . tra( "Key" ) . '</th>'
+ .'<th>' . tra( "Type" ) . '</th>'
+ .'<th>' . tra( "Comments" ) . '</th>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>page</td>'
+ .'<td>' . tra( "page name") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( " Can be any wiki page. (Default = the current page)") . '</td>'
+ .'</tr>'
+ .'<tr class="even">'
+ .'<td>info</td>'
+ .'<td>' . tra( "key-words") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "Defines what is to be displayed. Multiple columns can be displayed if joined with the character |. Available choices are:")
+ .' <strong>hits, lastmodif, user, ip, len, comment, creator, version, flag, versions, links, backlinks</strong>. ' . tra("(Default = EVERYTHING)") . '</td>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>exclude</td>'
+ .'<td>' . tra( "page-name(s)") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "Can be any wiki page. Multiple pagenames will be excluded if joined with the character |. Like this:")
+ .' <strong>HomePage|SandBox</strong> ' . tra("(Default = EVERYTHING is displayed)") . '</td>'
+ .'</tr>'
+ .'<tr class="even">'
+ .'<td>self</td>'
+ .'<td>' . tra( "boolean") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "Determins if the page currently viewed is listed. Any value results in TRUE. (Default = FALSE)") . '</td>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>header</td>'
+ .'<td>' . tra( "boolean") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "Causes a heading to be displayed above the list. Any value results in TRUE. (Default = FALSE)") . '</td>'
+ .'</tr>'
+ .'</table>'
+ . tra("Example: ") . "{backlinks page='MyHomePage' info='hits|user' exclude='HomePage|SandBox'}<br />"
+ . tra("Example: ") . "{backlinks page='MyHomePage' info='hits|user' exclude='HomePage|SandBox' self='Yes' header='Yes'}";
+ return $help;
+}
+
+// Load Function
+function data_backlinks($data, $params) { // Pre-Clyde Changes
+// Renamed Parameters $include_self to $self & $noheader to $header
+// Changed $header so that any value passed to it makes it True
+ // Added testing to Maintain Pre-Clyde compatability
+ extract ($params);
+ if (isset ($include_self) && ($include_self) ) // Maintain Pre-Clyde compatability
+ $self = TRUE;
+ $self = isset($self) ? TRUE : FALSE; // Any value passed in this parameter makes it True
+ if (isset ($noheader) && ($noheader) ) // Maintain Pre-Clyde compatability
+ $header = TRUE;
+ $header = isset($header) ? TRUE : FALSE; // Any value passed in this parameter makes it True
+
+// The next 2 lines allow access to the $pluginParams given above and may be removed when no longer needed
+ global $gLibertySystem;
+ $pluginParams = $gLibertySystem->mPlugins[PLUGIN_GUID_DATABACKLINKS];
+ $ret = 'The plugin <strong>"' . $pluginParams['tag'] . '"</strong> has not been completed as yet. ';
+ return $ret;
+}
+}
+/******************************************************************************
+The code below is from the deprecated BACKLINKS plugin. All comments and the help routines have been removed. Also - this code was originally in object oriented format - StarRider
+ require_once( WIKI_PKG_PATH.'plugins_lib.php' );
+ function run ($data, $params) {
+ global $wikilib;
+ $params = $this->getParams($params, true);
+ $aInfoPreset = array_keys($this->aInfoPresetNames);
+ extract ($params);
+ /////////////////////////////////
+ // Create a valid list for $info
+ /////////////////////////////////
+ //
+ if ($info) {
+ $info_temp = array();
+ foreach($info as $sInfo) {
+ if (in_array(trim($sInfo), $aInfoPreset)) {
+ $info_temp[] = trim($sInfo);
+ }
+ $info = $info_temp?$info_temp:
+ false;
+ }
+ }
+ $sOutput = "";
+ // Verify if the page exists
+ if (!$wikilib->pageExists($page)) {
+ return $this->error(tra("Page cannot be found")." : <b>$page</b>");
+ }
+ //
+ /////////////////////////////////
+ // Process backlinks
+ /////////////////////////////////
+ //
+ $aBackRequest = array();
+ $aBackLinks = $wikilib->get_backlinks($page);
+ foreach($aBackLinks as $backlink) {
+ if (!in_array($backlink["from_page"], $exclude)) {
+ $aBackRequest[] = $backlink["from_page"];
+ }
+ }
+ if ($self) {
+ $aBackRequest[] = $page;
+ }
+ if (!$aBackRequest) {
+ return tra("No pages link to")." (($page))";
+ } else {
+ $aPages = $this->getList(0, -1, 'title_desc', $aBackRequest);
+ }
+ //
+ /////////////////////////////////
+ // Start of Output
+ /////////////////////////////////
+ //
+ if (!$noheader) {
+ // Create header
+ $count = $aPages["cant"];
+ if ($count == 1) {
+ $sOutput .= tra("One page links to")." (($page))";
+ } else {
+ $sOutput = "$count ".tra("pages link to")." (($page))";
+ }
+ $sOutput .= "\n";
+ }
+ $sOutput .= PluginsLibUtil::createTable($aPages["data"], $info);
+ return $sOutput;
+ }
+ */
+?>
diff --git a/plugins/data.category.php b/plugins/data.category.php
new file mode 100644
index 0000000..9e3dc77
--- /dev/null
+++ b/plugins/data.category.php
@@ -0,0 +1,241 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Author: StarRider <starrrider@sbcglobal.net>
+// | Reworked from: wikiplugin_category.php - see deprecated code below
+// +----------------------------------------------------------------------+
+// $Id: data.category.php,v 1.1 2005/06/19 04:55:48 bitweaver Exp $
+// Initialization
+global $gBitSystem;
+if( $gBitSystem->isPackageActive( 'categories' ) ) { // Do not include this Plugin if the Package is not active
+define( 'PLUGIN_GUID_DATACATEGORY', 'datacategory' );
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'CATEGORY',
+ 'auto_activate' => FALSE,
+ 'requires_pair' => FALSE,
+ 'load_function' => 'data_category',
+ 'title' => 'Category<strong> - This plugin is not yet functional.</strong>', // Remove this line when the plugin becomes operational
+// 'title' => 'Category', // and Remove the comment from the start of this line
+ 'description' => tra("This plugin insert a list of items for the current category or a given category."),
+ 'help_function' => 'data_category_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/index.php", // Update this URL when a page on TP.O exists
+ 'syntax' => "{category id= types= sort= sub= split= }",
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATACATEGORY, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATACATEGORY );
+
+// Help Function
+function data_category_help() {
+ $help =
+ '<table class="data help">'
+ .'<tr>'
+ .'<th>' . tra( "Key" ) . '</th>'
+ .'<th>' . tra( "Type" ) . '</th>'
+ .'<th>' . tra( "Comments" ) . '</th>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>id</td>'
+ .'<td>' . tra( "number(s)") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "A Category Id number or list of Id numbers. The easiest way to see a Category Id number is to open 'View Categories' and placing the mouse over the Category in question. The URL will be displayed by most browsers. The end of the URL contains an Id number like this: <strong>parent_id=9</strong>. Multiple Id numbers can be entered by joining them with the + character like this: <strong>1+2+3</strong>. Default = <strong>the Current Category Id Number </strong> if not defined.") . '</td>'
+ .'</tr>'
+ .'<tr class="even">'
+ .'<td>type</td>'
+ .'<td>' . tra( "key-word") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "A filter to limit which <strong>bitweaver</strong> Object will be displayed on the page. The key-words are:") . ' <strong>blog faq fgal igal newsletter poll quiz survey tracker & wiki</strong>. ' . tra("Multiple key-words can be entered by joining them with the + character like this:") . ' <strong>blog+wiki</strong>. ' . tra("The Default = ") . '<strong>ALL OBJECTS</strong></td>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>sort</td>'
+ .'<td>' . tra( "key-word") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "Specifies a Sort Order. The Sort Order may be by:") . '<strong> type, created, name, or hits. </strong>' . tra("A direction can be defined by adding either") . '<strong> _asc</strong> or <strong>_dec. </strong>' . tra("(The Default = ") . '<strong>name_asc</strong>)</td>'
+ .'</tr>'
+ .'<tr class="even">'
+ .'<td>sub</td>'
+ .'<td>' . tra( "boolean") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "Determins if any subcategory items are to be displayed. Passing any value in this parameter will make it <strong>FALSE</strong>. The Default = <strong>TRUE</strong> so subcategories are displayed.") . '</td>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>split</td>'
+ .'<td>' . tra( "boolean") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "Primarilly used when displaying multiple categories. Determins if the display will be split into more than one column. Passing any value in this parameter will make it <strong>FALSE</strong>. The Default = <strong>TRUE</strong> so multiple columns are displayed.") . '</td>'
+ .'</tr>'
+ .'</table>'
+ . tra("Example: ") . "{CATEGORY id='1+2+3' types='blog+faq' sort='type_asc'}<br />"
+ . tra("Example: ") . "{CATEGORY id='1+2+3' types='blog+faq+wiki' sort='name_asc' sub='No' split='No'}";
+ return $help;
+}
+
+// Load Function
+function data_category($data, $params) { // Pre-Clyde Changes
+// requires_pair was TRUE / No other changes were made to the Help
+// The next 2 lines allow access to the $pluginParams given above and may be removed when no longer needed
+ global $gLibertySystem;
+ $pluginParams = $gLibertySystem->mPlugins[PLUGIN_GUID_DATACATEGORY];
+ $ret = 'The plugin <strong>"' . $pluginParams['tag'] . '"</strong> has not been completed as yet. ';
+ return $ret;
+}
+}
+/******************************************************************************
+The code below is from the deprecated CATEGORY plugin. All comments and the help routines have been removed. - StarRider
+function in_multi_array($needle, $haystack) {
+ $in_multi_array = false;
+ if (in_array($needle, $haystack)) {
+ $in_multi_array = true;
+ } else {
+ while (list($tmpkey, $tmpval) = each($haystack)) {
+ if (is_array($haystack[$tmpkey])) {
+ if (in_multi_array($needle, $haystack[$tmpkey])) {
+ $in_multi_array = true;
+ break;
+ }
+ }
+ }
+ }
+ return $in_multi_array;
+}
+function wikiplugin_category($data, $params) {
+ global $smarty;
+ global $package_categories;
+ global $categlib;
+ if (!is_object($categlib)) {
+ require_once (CATEGORIES_PKG_PATH."categlib.php");
+ }
+ if ($package_categories != 'y') {
+ return "<span class='warn'>" . tra("Categories are disabled"). "</span>";
+ }
+ extract ($params);
+ // array for converting long type names (as in database) to short names (as used in plugin)
+ $typetokens = array(
+ "article" => "article",
+ "blog" => "blog",
+ "faq" => "faq",
+ "file gallery" => "fgal",
+ "image gallery" => "igal",
+ "newsletter" => "newsletter",
+ "poll" => "poll",
+ "quiz" => "quiz",
+ "survey" => "survey",
+ "tracker" => "tracker",
+ "wiki page" => "wiki"
+ );
+ // TODO: move this array to a lib
+ // array for converting long type names to translatable headers (same strings as in application menu)
+ $typetitles = array(
+ "article" => "Articles",
+ "blog" => "Blogs",
+ "directory" => "Directory",
+ "faq" => "FAQs",
+ "file gallery" => "File Galleries",
+ "forum" => "Forums",
+ "image gallery" => "Image Gals",
+ "newsletter" => "Newsletters",
+ "poll" => "Polls",
+ "quiz" => "Quizzes",
+ "survey" => "Surveys",
+ "tracker" => "Trackers",
+ "wiki page" => "Wiki"
+ );
+ // string given back to caller
+ $out = "";
+ // TODO: use categ name instead of id (alternative)
+ $id = (isset($id)) ? $id : 'current'; // use current category if none is given
+ if ($id == 'current') {
+ $obj_id = urldecode($_REQUEST['page']);
+ $catids = $categlib->get_object_categories('wiki page', $obj_id);
+ } else {
+ $catids = explode("+", $id); // create array of category ids to be displayed
+ }
+ // default setting for $split is 'yes'
+ if (!(isset($split))) {
+ $split = 'yes';
+ } elseif ($split != 'y' and $split != 'yes' and $split != 'n' and $split != 'no' and $split != 'true' and $split != 'false') {
+ $split = 'yes';
+ }
+ // array with items to be displayed
+ $listcat = array();
+ // title of categories
+ $title = '';
+ // TODO: allow 'find' and 'maxRecords'
+ $find = "";
+ $offset = 0;
+ $maxRecords = 500;
+ $count = 0;
+ $sort = (isset($sort)) ? $sort : "name_asc";
+ $types = (isset($types)) ? "+" . strtolower($types) : "*";
+ $typesallowed = split("\+", $types); // create array of types the user allowed to be displayed
+ foreach ($catids as $id) {
+ // get data of category
+ $cat = $categlib->get_category($id);
+ // store name of category
+ if ($count != 0) {
+ $title .= "| <a href=\"".CATEGORIES_PKG_URL."index.php?parent_id=" . $id . "\">" . $cat['name'] . "</a> ";
+ } else {
+ $title .= "<a href=\"".CATEGORIES_PKG_URL."index.php?parent_id=" . $id . "\">" . $cat['name'] . "</a> ";
+ }
+ // keep track of how many categories there are for split mode off
+ $count++;
+ // check if sub=>true and get sub category data
+ if (!(isset($sub))) {
+ $sub = true;
+ } elseif ($sub == 'no' or $sub == 'n' or $sub == 'false') {
+ $sub = false;
+ } else {
+ $sub = true;
+ }
+ $subcategs = array();
+ if ($sub) {
+ $subcategs = $categlib->get_category_descendants($id);
+ }
+ // array with objects in category
+ $objectcat = array();
+ if ($sub) {
+ // get all items for category and sub category
+ $objectcat = $categlib->list_category_objects_deep($id, $offset, $maxRecords, $sort, $find);
+ } else {
+ // get all items for category
+ $objectcat = $categlib->list_category_objects($id, $offset, $maxRecords, $sort, $find);
+ }
+ foreach ($objectcat["data"] as $obj) {
+ $type = $obj["type"];
+ // check if current type is in allowed type list: * = everything allowed
+ if (($types == '*') || array_search($typetokens[strtolower($type)], $typesallowed)) {
+ // remove duplicates in non-split mode
+ if ($split == 'n' or $split == 'no' or $split == 'false') {
+ if (!(in_multi_array($obj['name'], $listcat))) // TODO: check for name+type
+ {
+ $listcat[$typetitles["$type"]][] = $obj;
+ }
+ } else {
+ $listcat[$typetitles["$type"]][] = $obj;
+ }
+ }
+ }
+ // split mode: appending onto $out each time
+ if ($split == 'y' or $split == 'yes' or $split == 'true') {
+ $smarty->assign("title", $title);
+ $smarty->assign("listcat", $listcat);
+ $out .= $smarty->fetch("bitpackage:wiki/simple_plugin.tpl");
+ // reset array for next loop
+ $listcat = array();
+ // reset title
+ $title = '';
+ $count = 0;
+ }
+ }
+ // non-split mode
+ if ($split == 'n' or $split == 'no' or $split == 'false') {
+ $smarty->assign("title", $title);
+ $smarty->assign("listcat", $listcat);
+ $out = $smarty->fetch("bitpackage:wiki/simple_plugin.tpl");
+ }
+ return '~np~'.$out.'~/np~';
+}
+*/
+?>
diff --git a/plugins/data.catorphans.php b/plugins/data.catorphans.php
new file mode 100644
index 0000000..0bfa9fd
--- /dev/null
+++ b/plugins/data.catorphans.php
@@ -0,0 +1,131 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Author: StarRider <starrrider@sbcglobal.net>
+// | Reworked from: wikiplugin_catorphans.php - see deprecated code below
+// +----------------------------------------------------------------------+
+// $Id: data.catorphans.php,v 1.1 2005/06/19 04:55:47 bitweaver Exp $
+// Initialization
+global $gBitSystem;
+if( $gBitSystem->isPackageActive( 'categories' ) ) { // Do not include this Plugin if the Package is not active
+define( 'PLUGIN_GUID_DATACATORPHANS', 'datacatorphans' );
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'CATORPHANS',
+ 'auto_activate' => FALSE,
+ 'requires_pair' => FALSE,
+ 'load_function' => 'data_catorphans',
+ 'title' => 'CatOrphans<strong> - This plugin is not yet functional.</strong>', // Remove this line when the plugin becomes operational
+// 'title' => 'CatOrphans', // and Remove the comment from the start of this line
+ 'description' => tra("Creates a listing of bitweaver objects that have not been categorized."),
+ 'help_function' => 'data_catorphans_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/index.php", // Update this URL when a page on TP.O exists
+ 'syntax' => "{catorphans objects= }",
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATACATORPHANS, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATACATORPHANS );
+
+// Help Function
+function data_catorphans_help() {
+ $help =
+ '<table class="data help">'
+ .'<tr>'
+ .'<th>' . tra( "Key" ) . '</th>'
+ .'<th>' . tra( "Type" ) . '</th>'
+ .'<th>' . tra( "Comments" ) . '</th>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>object</td>'
+ .'<td>' . tra( "object(s)") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra("Most bitweaver Objects can be selected, including") . " <strong>article, blog, faq, fgal, igal, newsletter, poll, quiz, survey, tracker, & wiki</strong>. " . tra("Multiple objects can be entered bu using the character + between object names, like this") . " <strong>blog+faq</strong>. " . tra(". The default is <strong>wiki</strong> objects.") . '</td>'
+ .'</tr>'
+ .'</table>'
+ . tra("Example: ") . "{catorphans objects='wiki+blog+faq'}";
+ return $help;
+}
+
+// Load Function
+function data_catorphans($data, $params) { // Pre-Clyde Changes
+// requires_pair was TRUE / No other changes were made to the Help
+// The next 2 lines allow access to the $pluginParams given above and may be removed when no longer needed
+ global $gLibertySystem;
+ $pluginParams = $gLibertySystem->mPlugins[PLUGIN_GUID_DATACATORPHANS];
+ $ret = 'The plugin <strong>"' . $pluginParams['tag'] . '"</strong> has not been completed as yet. ';
+ return $ret;
+}
+}
+/******************************************************************************
+The code below is from the deprecated CATORPHANS plugin. All comments and the help routines have been removed. - StarRider
+
+Note: I changed the seperator from | to +
+
+require_once( WIKI_PKG_PATH.'BitPage.php' );
+function wikiplugin_catorphans($data, $params) {
+ global $smarty;
+ global $wikilib;
+ global $package_categories;
+ global $categlib;
+ if (!is_object($categlib)) {
+ require_once (CATEGORIES_PKG_PATH."categlib.php");
+ }
+ if ($package_categories != 'y') {
+ return "<span class='warn'>" . tra("Categories are disabled"). "</span>";
+ }
+ extract ($params);
+ // array for converting long type names (as in database) to short names (as used in plugin)
+ $typetokens = array(
+ "article" => "article",
+ "blog" => "blog",
+ "faq" => "faq",
+ "file gallery" => "fgal",
+ "image gallery" => "igal",
+ "newsletter" => "newsletter",
+ "poll" => "poll",
+ "quiz" => "quiz",
+ "survey" => "survey",
+ "tracker" => "tracker",
+ "wiki page" => "wiki"
+ );
+ // TODO: move this array to a lib
+ // array for converting long type names to translatable headers (same strings as in application menu)
+ $typetitles = array(
+ "article" => "Articles",
+ "blog" => "Blogs",
+ "directory" => "Directory",
+ "faq" => "FAQs",
+ "file gallery" => "File Galleries",
+ "forum" => "Forums",
+ "image gallery" => "Image Gals",
+ "newsletter" => "Newsletters",
+ "poll" => "Polls",
+ "quiz" => "Quizzes",
+ "survey" => "Surveys",
+ "tracker" => "Trackers",
+ "wiki page" => "Wiki"
+ );
+ // default object is 'wiki'
+ if (!isset($objects)or $objects != 'wiki') {
+ $objects = 'wiki';
+ }
+ $orphans = '';
+ // currently only supports display of wiki pages
+ if ($objects == 'wiki') {
+ $listpages = $wikilib->getList(0, -1, 'title_asc', '');
+ foreach ($listpages['data'] as $page) {
+ if (!$categlib->is_categorized('wiki page', $page['title'])) {
+ // $orphans .= '<a href="'.WIKI_PKG_URL.'index.php?page='.$page['title'].'">'.$page['title'].'</a><br />';
+ $orphans .= '((' . $page['title'] . '))<br />';
+ }
+ }
+ }
+ return $orphans;
+}
+*/
+?>
diff --git a/plugins/data.catpath.php b/plugins/data.catpath.php
new file mode 100644
index 0000000..b12bdc0
--- /dev/null
+++ b/plugins/data.catpath.php
@@ -0,0 +1,115 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Author: StarRider <starrrider@sbcglobal.net>
+// | Reworked from: wikiplugin_catpath.php - see deprecated code below
+// +----------------------------------------------------------------------+
+// $Id: data.catpath.php,v 1.1 2005/06/19 04:55:47 bitweaver Exp $
+// Initialization
+global $gBitSystem;
+if( $gBitSystem->isPackageActive( 'categories' ) ) { // Do not include this Plugin if the Package is not active
+define( 'PLUGIN_GUID_DATACATPATH', 'datacatpath' );
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'CATPATH',
+ 'auto_activate' => FALSE,
+ 'requires_pair' => FALSE,
+ 'load_function' => 'data_catpath',
+ 'title' => 'CatPath<strong> - This plugin is not yet functional.</strong>', // Remove this line when the plugin becomes operational
+// 'title' => 'CatPath', // and Remove the comment from the start of this line
+ 'description' => tra("This plugin insert the full category path for each category that the page belongs to."),
+ 'help_function' => 'data_catpath_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/index.php", // Update this URL when a page on TP.O exists
+ 'syntax' => "{CATPATH divider= top= }",
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATACATPATH, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATACATPATH );
+
+// Help Function
+function data_catpath_help() {
+ $help =
+ '<table class="data help">'
+ .'<tr>'
+ .'<th>' . tra( "Key" ) . '</th>'
+ .'<th>' . tra( "Type" ) . '</th>'
+ .'<th>' . tra( "Comments" ) . '</th>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>divider</td>'
+ .'<td>' . tra( "string") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra("A character or string used to separate the categories. The default is <strong>></strong>.") . '</td>'
+ .'</tr>'
+ .'<tr class="even">'
+ .'<td>top</td>'
+ .'<td>' . tra( "boolean") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "Determins if the TOP category is displayed or not. Passing any value in this parameter will make it <strong>TRUE</strong>. The Default = <strong>FALSE</strong> so the TOP category will not be displayed") . '</td>'
+ .'</tr>'
+ .'</table>'
+ . tra("Example: ") . "{catpath divider='->' top='yes' }";
+ return $help;
+}
+
+// Load Function
+function data_catpath($data, $params) { // Pre-Clyde Changes
+// requires_pair was TRUE / No other changes were made to the Help
+// The next 2 lines allow access to the $pluginParams given above and may be removed when no longer needed
+ global $gLibertySystem;
+ $pluginParams = $gLibertySystem->mPlugins[PLUGIN_GUID_DATACATPATH];
+ $ret = 'The plugin <strong>"' . $pluginParams['tag'] . '"</strong> has not been completed as yet. ';
+ return $ret;
+}
+}
+/******************************************************************************
+The code below is from the deprecated CATPATH plugin. All comments and the help routines have been removed. - StarRider
+function wikiplugin_catpath($data, $params) {
+ global $smarty;
+ global $gBitSystem;
+ global $package_categories;
+ global $categlib;
+ if (!is_object($categlib)) {
+ require_once (CATEGORIES_PKG_PATH."categlib.php");
+ }
+ if ($package_categories != 'y') {
+ return "<span class='warn'>" . tra("Categories are disabled"). "</span>";
+ }
+ extract ($params);
+ // default divider is '>'
+ if (!(isset($divider))) {
+ $divider = '>';
+ }
+ // default setting for top is 'no'
+ if (!(isset($top))) {
+ $top = 'no';
+ } elseif ($top != 'y' and $top != 'yes' and $top != 'n' and $top != 'no') {
+ $top = 'no';
+ }
+ $obj_id = urldecode($_REQUEST['page']);
+ $cats = $categlib->get_object_categories('wiki page', $obj_id);
+ $catpath = '';
+ foreach ($cats as $category_id) {
+ $catpath .= '<span class="categpath">';
+ // Display TOP on each line if wanted
+ if ($top == 'yes' or $top == 'y') {
+ $catpath .= '<a class="categpath" href="'.CATEGORIES_PKG_URL.'index.php?parent_id=0">TOP</a> ' . $divider . ' ';
+ }
+ $path = '';
+ $info = $categlib->get_category($category_id);
+ $path
+ = '<a class="categpath" href="'.CATEGORIES_PKG_URL.'index.php?parent_id=' . $info["category_id"] . '">' . $info["name"] . '</a>';
+ while ($info["parent_id"] != 0) {
+ $info = $categlib->get_category($info["parent_id"]);
+ $path = '<a class="categpath" href="'.CATEGORIES_PKG_URL.'.php?parent_id=' . $info["category_id"] . '">' . $info["name"] . '</a> ' . $divider . ' ' . $path;
+ }
+ $catpath .= $path . '</span><br/>';
+ }
+ return $catpath;
+}
+*/
+?>
diff --git a/plugins/data.code.php b/plugins/data.code.php
new file mode 100644
index 0000000..31c2fd1
--- /dev/null
+++ b/plugins/data.code.php
@@ -0,0 +1,200 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Author: StarRider <starrrider@sbcglobal.net>
+// | Reworked from: wikiplugin_code.php - see deprecated code below
+// +----------------------------------------------------------------------+
+// $Id: data.code.php,v 1.1 2005/06/19 04:55:47 bitweaver Exp $
+// Initialization
+define( 'PLUGIN_GUID_DATACODE', 'datacode' );
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'CODE',
+ 'auto_activate' => TRUE,
+ 'requires_pair' => TRUE,
+ 'load_function' => 'data_code',
+ 'title' => 'Code',
+ 'description' => tra("Displays the Source Code Snippet between {Code} blocks."),
+ 'help_function' => 'data_code_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/index.php", // Update this URL when a page on TP.O exists
+ 'syntax' => " {code source= num= }". tra("Sorce Code Snippet") . "{code}",
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATACODE, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATACODE );
+
+// Help Function
+function data_code_help() {
+ $help =
+ '<table class="data help">'
+ .'<tr>'
+ .'<th>' . tra( "Key" ) . '</th>'
+ .'<th>' . tra( "Type" ) . '</th>'
+ .'<th>' . tra( "Comments" ) . '</th>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>source</td>'
+ .'<td>' . tra( "key-word") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "Defines the format of the Source Code Snippet. Possible values are:") . ' <strong>HTML or PHP</strong>. '
+ . tra("The Default = ") . '<strong>HTML</strong></td>'
+ .'</tr>'
+ .'<tr class="even">'
+ .'<td>num</td>'
+ .'<td>' . tra( "boolean") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "Determins if line numbers are displayed. Passing") . ' <strong>TRUE, ON, or YES</strong> ' . tra("in this parameter will make it") . ' <strong>TRUE</strong>. ' . tra("Any ohter value will make it") . ' <strong>FALSE</strong>' . tra("The Default =") . ' <strong>FALSE</strong> ' . tra("so Line Numbers are not displayed.") . '</td>'
+ .'</tr>'
+ .'</table>'
+ . tra("Example: ") . "{code source='php' num='on' }" . tra("Sorce Code Snippet") . "{code}";
+ return $help;
+}
+
+function decodeHTML($string) {
+ $string = strtr($string, array_flip(get_html_translation_table(HTML_ENTITIES)));
+ $string = preg_replace("/&#([0-9]+);/me", "chr('\\1')", $string);
+ return $string;
+}
+
+// Load Function
+function data_code( $data, $params ) { // Pre-Clyde Changes
+// Parameters were $In & $Colors
+// Added testing to maintain Pre-Clyde compatability
+ $num = NULL;
+ extract ($params);
+ // This maintains Pre-Clyde Parameters
+ if (isset($colors) and ($colors == 'php') ) $source = 'HTML';
+ if (isset($in) ) $source = $in;
+ $source = isset($source) ? strtoupper($source) : 'HTML'; // if not specified the default is HTML
+ if (isset($in) and ($in == 1) ) $num = 'ON'; // This maintains Pre-Clyde Parameters
+ switch (strtoupper($num)) {
+ case 'TRUE': case 'ON': case 'YES':
+ $num = 1;
+ break;
+ default: // could have done FALSE/OFF/NO but we want any other value to be False
+ $num = 0;
+ break;
+ }
+ $code = ''; // Lets make it pretty by eliminating all empty lines
+ $lines = explode("\n", $data);
+ foreach ($lines as $line) {
+ if (strlen($line) > 1)
+ $code .= rtrim($line) . "\n"; // The Strings length is > 1
+ }
+ if( file_exists( UTIL_PKG_PATH.'geshi/geshi.php' ) ) {
+ // Include the GeSHi library
+ include_once( UTIL_PKG_PATH.'geshi/geshi.php' );
+ $geshi = new GeSHi($code, $source, UTIL_PKG_PATH.'geshi/geshi' );
+ if ($num) { // Line Numbering has been requested
+ $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
+ }
+ $code = $geshi->parse_code();
+ } else {
+ if ($num) { // Line Numbering has been requested
+ $lines = explode("\n", $code);
+ $code = '';
+ $i = 1; // The current line number
+ foreach ($lines as $line) {
+ if (strlen($line) > 1) {
+ $code .= sprintf("%3d", $i) . ": " . $line . "\n";
+ $i++;
+ }
+ }
+ }
+ 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;
+ }
+ // To Here
+ switch ($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
+ $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':
+ $code = highlight_string($code, true);
+ /*
+ SPIDERKILL this code was not properly checking and doing the right stuff. just removed for now
+ 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));
+ }
+ }
+ */
+ $convmap = array( // Replacement-map to replace Colors
+ '#000000">' => '#004A4A">', // The Default Color
+ '#006600">' => '#2020FF">', // Color for Functions/Variables/Numbers/&/Constants
+ '#0000CC">' => '#209020">', // Color for KeyWords
+ '#FF9900">' => '#BB4040">', // Color for Constants
+ '#CC0000">' => '#903030">' // Color for Strings
+ );// <-- # Assigned by HighLight_String / --> # Color to be Displayed
+ // NOTE: The colors assigned by HighLight_String have changed with different versions of PHP - these are for PHP 4.3.4
+ $code = strtr($code, $convmap); // Change the Colors
+ break;
+ default:
+ $code = highlight_string( $code, true );
+ break;
+ }
+ $code = "<pre>$code</pre>";
+ }
+ return "~np~<div class='codelisting'>".unhtmlentities( $code )."</div>~/np~";
+}
+
+function unhtmlentities($string) {
+ $trans_tbl = get_html_translation_table(HTML_ENTITIES);
+ $trans_tbl = array_flip($trans_tbl);
+ return strtr($string, $trans_tbl);
+}
+
+/******************************************************************************
+The code below is from the deprecated CODE plugin. All comments and the help routines have been removed. - StarRider
+
+function wikiplugin_code($data, $params) {
+ $code = $data;
+ extract ($params);
+ if (isset($colors) and ($colors == 'php')) {
+ $data = "<div class='codelisting'><pre>".highlight_string(decodeHTML($code),1)."</pre></div>";
+ } else {
+ if (isset($in) && $in == 1) {
+ $lines = explode("\n", $code);
+ $i = 1; // The current line number
+ $code = '';
+ // This will skip leading and trailing empty lines to make snippet look better :)
+ $fl = 0; // first code line printed' flag
+ $ae = '';
+ foreach ($lines as $line) {
+ $len = strlen($line);
+ if (!($len || $fl)) continue; // skip leading empty lines
+ if ($len) { // OK len >0
+ $code .= $ae . ($fl ? "\n" : '') . sprintf("%3d", $i). ': ' . $line;
+ $fl = 1; // first line already printed
+ $ae = '';
+ } else {
+ $ae .= "\n" . sprintf("%3d", $i). ': ' . $line;
+ }
+ $i++;
+ }
+ $code = rtrim($code);
+ }
+ $data = "<div class='codelisting'><pre>" . $code . "</pre></div>";
+ }
+ return $data;
+}
+*/
+?>
diff --git a/plugins/data.copyright.php b/plugins/data.copyright.php
new file mode 100644
index 0000000..6a25e2c
--- /dev/null
+++ b/plugins/data.copyright.php
@@ -0,0 +1,122 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Author: StarRider <starrrider@sbcglobal.net>
+// | Reworked from: wikiplugin_copyright.php - see deprecated code below
+// +----------------------------------------------------------------------+
+// $Id: data.copyright.php,v 1.1 2005/06/19 04:55:48 bitweaver Exp $
+// Initialization
+global $gBitSystem;
+if( ( $gBitSystem->isPackageActive( 'wiki' ) ) && ( $gBitSystem->isFeatureActive( 'wiki_feature_copyrights' ) ) ) { // Do not include this Plugin if this Package and Feature are not active
+
+define( 'PLUGIN_GUID_DATACOPYRIGHT', 'datacopyright' );
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'COPYRIGHT',
+ 'auto_activate' => FALSE,
+ 'requires_pair' => FALSE,
+ 'load_function' => 'data_copyright',
+ 'title' => 'CopyRight',
+ 'description' => tra("This plugin is used to insert CopyRight notices."),
+ 'help_function' => 'data_copyright_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/index.php", // Update this URL when a page on TP.O exists
+ 'syntax' => "{COPYRIGHT title= year= authors= }",
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATACOPYRIGHT, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATACOPYRIGHT );
+
+// Help Function
+function data_copyright_help() {
+ $help =
+ '<table class="data help">'
+ .'<tr>'
+ .'<th>' . tra( "Key" ) . '</th>'
+ .'<th>' . tra( "Type" ) . '</th>'
+ .'<th>' . tra( "Comments" ) . '</th>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>title</td>'
+ .'<td>' . tra( "string") . '<br />' . tra( "(optional)") . '</td>'
+ .'<td>' . tra( "The Title of the Publication. There is no default.") . '</td>'
+ .'</tr>'
+ .'<tr class="even">'
+ .'<td>year</td>'
+ .'<td>' . tra( "string") . '<br />' . tra( "(optional)") . '</td>'
+ .'<td>' . tra( "The Year of the Publication. There is no default.") . '</td>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>authors</td>'
+ .'<td>' . tra( "string") . '<br />' . tra( "(optional)") . '</td>'
+ .'<td>' . tra( "The Authors of the Publication. There is no default.") . '</td>'
+ .'</tr>'
+ .'</table>'
+ . tra("Example: ") . "{COPYRIGHT title='The Tiki Way' year='May 10, 2004' authors='StarRider' }";
+ return $help;
+}
+
+// Load Function
+function data_copyright($data, $params) { // Pre-Clyde Changes
+// This plugin did not use any parameters - The keywords ~Title~ ~year~ and ~authors~ were inbeded in $data like this
+// {COPYRIGHT()}~title~The Tiki Way~year~May 10, 2004~authors~StarRider{COPYRIGHT}
+// Changed this to use Parameters instead
+// Added testing to maintain Pre-Clyde compatability
+// The next 2 lines allow access to the $pluginParams given above and may be removed when no longer needed
+ global $gLibertySystem;
+ $pluginParams = $gLibertySystem->mPlugins[PLUGIN_GUID_DATACOPYRIGHT];
+ extract ($params);
+ // This maintains Pre-Clyde Parameters
+ if ( !empty( $data) ) { // The problem with this is that $authors HAS to be the last key-word
+ $pos1 = strpos( strtolower($data), '~title~') + 7;
+ $pos2 = strpos( strtolower($data), '~', $pos1 + 1 );
+ $title = substr( $data, $pos1, $pos2-$pos1);
+ $pos1 = strpos( strtolower($data), '~year~') + 6;
+ $pos2 = strpos( strtolower($data), '~', $pos1 + 1 );
+ $year = substr( $data, $pos1, $pos2-$pos1);
+ $pos1 = strpos( strtolower($data), '~authors~') + 9;
+ $pos2 = strlen($data) - $pos1;
+ $authors = substr( $data, $pos1, $pos2);
+ } else {
+ $title = isset( $title) ? $title : ' ';
+ $year = isset( $year) ? $year : ' ';
+ $authors = isset( $authors) ? $authors : ' ';
+ }
+ $ret = 'The plugin <strong>"' . $pluginParams['tag'] . '"</strong> has not been completed as yet. ';
+ return $ret;
+}
+}
+/******************************************************************************
+The code below is from the deprecated COPYRIGHT plugin. All comments and the help routines have been removed. - StarRider
+
+require_once( KERNEL_PKG_PATH.'BitBase.php' );
+require_once( WIKI_PKG_PATH.'copyrights_lib.php' );
+
+
+function wikiplugin_copyright($data, $params) {
+ $copyrightslib = new CopyrightsLib();
+ if (!isset($_REQUEST['copyrightpage'])) {
+ return '';
+ }
+ //extract($params);
+ $result = '';
+ $copyrights = $copyrightslib->list_copyrights($_REQUEST['copyrightpage']);
+ for ($i = 0; $i < $copyrights['cant']; $i++) {
+ $notice = str_replace("~title~", $copyrights['data'][$i]['title'], $data);
+ $notice = str_replace("~year~", $copyrights['data'][$i]['year'], $notice);
+ $notice = str_replace("~authors~", $copyrights['data'][$i]['authors'], $notice);
+ $result = $result . $notice;
+ }
+ global $bit_p_edit_copyrights;
+ if ((isset($bit_p_edit_copyrights)) && ($gBitUser->hasPermission( 'bit_p_edit_copyrights' ))) {
+ $result = $result . "\n<a href=\"copyrights.php?page=" . $_REQUEST['copyrightpage'] . "\">Edit copyrights</a> for ((" . $_REQUEST['copyrightpage'] . "))\n";
+ }
+ return $result;
+}
+*/
+?>
diff --git a/plugins/data.countdown.php b/plugins/data.countdown.php
new file mode 100644
index 0000000..c142973
--- /dev/null
+++ b/plugins/data.countdown.php
@@ -0,0 +1,117 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Author: StarRider <starrrider@sbcglobal.net>
+// | Reworked from: wikiplugin_countdown.php - see deprecated code below
+// +----------------------------------------------------------------------+
+// $Id: data.countdown.php,v 1.1 2005/06/19 04:55:47 bitweaver Exp $
+// Initialization
+define( 'PLUGIN_GUID_DATACOUNTDOWN', 'datacountdown' );
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'COUNTDOWN',
+ 'auto_activate' => TRUE,
+ 'requires_pair' => TRUE,
+ 'load_function' => 'data_countdown',
+ 'title' => 'CountDown',
+ 'description' => tra("Displays a Count-Down until a date:time is reached - then - negative numbers indicate how long it has been since that date. The Count-Down is displayed in the format of (X days, X hours, X minutes and X seconds)."),
+ 'help_function' => 'data_countdown_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/index.php", // Update this URL when a page on TP.O exists
+ 'syntax' => "{countdown enddate= localtime= }" . tra("Text") . "{countdown}",
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATACOUNTDOWN, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATACOUNTDOWN );
+
+// Help Function
+function data_countdown_help() {
+ $help =
+ '<table class="data help">'
+ .'<tr>'
+ .'<th>' . tra( "Key" ) . '</th>'
+ .'<th>' . tra( "Type" ) . '</th>'
+ .'<th>' . tra( "Comments" ) . '</th>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>enddate</td>'
+ .'<td>' . tra( "string") . '<br />' . tra("(Manditory)") . '</td>'
+ .'<td>' . tra( "A date used to compare to the present date. Several date formats are accepted, but spelling it out like this: <strong>May 10 2004</strong> is probably the simplest. A time can be include with the date like this: <strong>20:02:00 or 8:02pm</strong> . There is <strong>NO</strong> Default.") . '</td>'
+ .'</tr>'
+ .'<tr class="even">'
+ .'<td>localtime</td>'
+ .'<td>' . tra( "boolean") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "Determins if Local Time is displayed or not. Passing any value in this parameter will make it <strong>TRUE</strong>. The Default = <strong>FALSE</strong> so Local Time will not be displayed") . '</td>'
+ .'</tr>'
+ .'</table>'
+ . tra("Example: ") . "{countdown enddate='8:02pm May 10 2004' localtime='on'}" . tra(" - Time Passes So Slowly") . "{countdown}<br />"
+ . tra("Displays: <strong>82 days, 23 hours, 37 minutes and 31 seconds - Time Passes So Slowly</strong>");
+ return $help;
+}
+
+// Load Function
+function data_countdown($data, $params) {
+// The next 2 lines allow access to the $pluginParams given above
+ global $gLibertySystem;
+ $pluginParams = $gLibertySystem->mPlugins[PLUGIN_GUID_DATACOUNTDOWN];
+ extract ($params);
+ if (!isset($enddate) ) { // The Manditory Parameter is missing
+ $ret = tra("The required parameter ") . "<strong>enddate</strong>" . tra(" was missing from the plugin ") . '<strong>"' . $pluginParams['tag'] . '"</strong>';
+ $ret.= data_countdown_help();
+ return $ret;
+ }
+ $then = strtotime ($enddate);
+ if ($then == -1) { // strtotime failed so enddate was not a valid date
+ $ret = tra("__Error__ - The plugin ") . '<strong>"' . $pluginParams['tag'] . '"</strong>' . tra(" was not given a valid date. The date given was:\n") . "enddate=$enddate";
+ return $ret;
+ }
+ if (isset($localtime) && $localtime == 'on') {
+ $tz = $_COOKIE['tz_offset'];
+ } else {
+ $tz = 0;
+ }
+ $now = strtotime ("now") + $tz;
+ $difference = $then - $now;
+ $num = $difference/86400;
+ $days = intval($num);
+ $num2 = ($num - $days)*24;
+ $hours = intval($num2);
+ $num3 = ($num2 - $hours)*60;
+ $mins = intval($num3);
+ $num4 = ($num3 - $mins)*60;
+ $secs = intval($num4);
+ $ret = "$days ".tra("days").", $hours ".tra("hours").", $mins ".tra("minutes")." ".tra("and")." $secs ".tra("seconds")." $data";
+ return $ret;
+}
+/******************************************************************************
+The code below is from the deprecated COUNTDOWN plugin. All comments and the help routines have been removed. - StarRider
+function wikiplugin_countdown($data, $params) {
+ extract ($params);
+ if (!isset($enddate)) {
+ return ("<b>COUNTDOWN: Missing 'enddate' parameter for plugin</b><br/>");
+ }
+ if (isset($localtime) && $localtime == 'on')
+ $tz = $_COOKIE['tz_offset'];
+ else
+ $tz = 0;
+ $now = strtotime ("now") + $tz;
+ $then = strtotime ($enddate);
+ $difference = $then - $now;
+ $num = $difference/86400;
+ $days = intval($num);
+ $num2 = ($num - $days)*24;
+ $hours = intval($num2);
+ $num3 = ($num2 - $hours)*60;
+ $mins = intval($num3);
+ $num4 = ($num3 - $mins)*60;
+ $secs = intval($num4);
+ $ret = "$days ".tra("days").", $hours ".tra("hours").", $mins ".tra("minutes")." ".tra("and")." $secs ".tra("seconds")." $data";
+ return $ret;
+}
+*/
+?>
diff --git a/plugins/data.example.php b/plugins/data.example.php
new file mode 100644
index 0000000..3811602
--- /dev/null
+++ b/plugins/data.example.php
@@ -0,0 +1,129 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Author: StarRider <starrrider@sbcglobal.net>
+// +----------------------------------------------------------------------+
+// $Id: data.example.php,v 1.1 2005/06/19 04:55:47 bitweaver Exp $
+// Initialization
+define( 'PLUGIN_GUID_DATAEXAMPLE', 'dataexample' );
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'EXAMPLE',
+ 'auto_activate' => TRUE,
+ 'requires_pair' => FALSE, // Make this TRUE if the plugin needs to operate on free form text
+ 'load_function' => 'data_example', // Points to the Load Function
+ 'title' => 'Example', // Name of the Plugin
+ 'description' => tra("This plugin is an example to show how plugins operate. It can also function as a template for the creation of new plugins since it contains a lot of spare code and explanations about how - and when - they should be used."), // What it does
+ 'help_function' => 'data_example_help', // Points to the Help Function
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/index.php", // This is a URL to a page on bitweaver.Org for additional information about the plugin - if it exists
+ 'syntax' => "{EXAMPLE p1= p2= }", // A listing of parameters
+ 'plugin_type' => DATA_PLUGIN // Don't Touch
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATAEXAMPLE, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAEXAMPLE );
+
+// Help Function
+function data_example_help() { // Specified by $pluginParams['help_function']
+ $help =
+ '<table class="data help">'
+ .'<tr>'
+ .'<th>' . tra( "Key" ) . '</th>'
+ .'<th>' . tra( "Type" ) . '</th>'
+ .'<th>' . tra( "Comments" ) . '</th>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>p1</td>'
+ .'<td>' . tra( "anything") . '<br />' . tra("(Manditory)") . '</td>'
+ .'<td>' . tra( "The first parameter. There is no Default") . '</td>'
+ .'</tr>'
+ .'<tr class="even">'
+ .'<td>p2</td>'
+ .'<td>' . tra( "anything") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "The second parameter. There is no Default") . '</td>'
+ .'</tr>'
+ .'</table>'
+ . tra("Example: ") . "{EXAMPLE p1='7' p2='8' }<br />"
+ . tra("This will display - P1 was set to = 7 & P2 was set to = 8");
+ return $help;
+}
+
+// Load Function
+function data_example($data, $params) { // Specified by $pluginParams['load_function']
+ extract ($params);
+// Use this if you have a Manditory Parameter
+ if (!isset($p1) ) { // The Manditory Parameter is missing
+ $ret = tra("The parameter ") . "__p1__" . tra(" was missing from the plugin ") . "__~np~{EXAMPLE}~/np~__.";
+ $ret.= data_example_help();
+ return $ret;
+ }
+// Of course - any Manditory Parameter needs to be tested to see if it is valid - and provide an error message if it isn't
+ if( $p1 == 5) {
+ $ret = tra("__Error__ - The plugin ") . "__~np~{EXAMPLE}~/np~__" . tra(" was given the parameter ") . "p1=$p1" . tra(" which is not valid.");
+ return $ret;
+ }
+// Use this if the plugin needs to operate on text - the 'requires_pair' should be set to TRUE - so the text will be between {plugin()} Blocks {plugin}
+ if (!isset($data)) { // There is no data between the Plugin Blocks
+ $ret = tra("__Error__ - There was no data between the ") . "__~np~{EXAMPLE}~/np~__" . tra(" blocks for the plugin to operate on.");
+ return $ret;
+ }
+// There are several ways of testing to ensure that a parameter has a value
+ if (!isset($p1)) { // Always test each parameter to be sure it has a value before you use it.
+ $p1 = 5;
+ }
+// Of course - this is another way
+ $ret = isset($p1) ? "P1 was set to = $p1" : "This should never be seen - it should be caught by the test for the Manditory Parameter";
+ $ret = isset($p2) ? $ret." & P2 was set to = $p2" : $ret." & P2 was not set";
+ return $ret;
+
+// This is not seen by this plugin but it works - comment out the last 3 lines to see
+// There are many times when you have several possible values for a given key - a case statemenmt works wonders
+ switch (strtoupper ($p2)) {
+ case 'ABC':
+ $ret = "P2 was ABC";
+ return $ret;
+ case 'DEF':
+ $ret = "P2 was DEF";
+ return $ret;
+ default:
+ $ret = "P2 was Something Else";
+ return $ret;
+ }
+
+// Boolean values (with a default) can be handled like this
+ $p1 = FALSE; // Ensure that $p1 starts with your default value before the extract
+ extract ($params);
+ $ret = $p1 ? "P1 was TRUE = $p1" : "P1 was FALSE = $p1";
+ return $ret; // Parameter values can be False / True or 0=False / >0=True
+}
+/******************************************************************************
+This plugin was made to simplify the creation of new plugins.
+As an example - lets say I wanted to create a new plugin called DOGS (Hope you know what it will do because I don't)
+The first step would be to copy this file and rename it data.dogs.php in the same directory (Liberty\Plugins)
+Next - in your editor do 2 case sensitive search and replace - changing EXAMPLE to DOGS / AND / example to dogs
+The next changes are in the pluginParams array
+ Change the Title to "Dogs"
+ Change the description to briefly explain what your plugin will do
+ Decide on the number of parameters and parameter names to be passed to the plugin and place them in syntax.
+ The format we are currently using is {pluginname parameter='strings are OK'}
+ NOTE: If your plugin will operate on text that is entered at the same time the plugin is called - then you will probably want
+ to use the format {pluginname any-parameter-needed='3'} Text to be operated on {pluginname} - if this is the case - be sure
+ to change the requires_pair to TRUE
+Next - Change the Help Function so that all of the parameters are all listed / what each one does / and any default value it may
+have - be sure to mention if it is a Manditory Parameter or an Optional Parameter
+NOTE: The Help Function uses Wiki-Syntax to improve the appearance of the help message. By this point, you should be able to
+see your plugin in the Wiki Page Editor / Plugin Tab of Help - so make it look good.
+NOTE 2: Part of the reason the help routine looks as complex as it does is the fact that bitweaver is an international program. The
+tra( function is used to convert text from one language to another. Most of the text can be changed for clarity - but some like the name
+of the plugin / the parameter names and some specific values can not be change - so keep that in mind when adding to the Help -
+Function. This also applies to Error Messages.
+Finally - Change the Load Function so that it does what you want it to do
+NOTE: I added a bunch of simple tests to the Load Function that should help a novice - this is not all inclusive listing but it does
+show what I am using to standardize these plugins - use them or blow them away - as you will - StarRider
+*/
+?>
diff --git a/plugins/data.flash.php b/plugins/data.flash.php
new file mode 100644
index 0000000..28a46d1
--- /dev/null
+++ b/plugins/data.flash.php
@@ -0,0 +1,105 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Author: StarRider <starrrider@sbcglobal.net>
+// | Reworked from: wikiplugin_flash.php - see deprecated code below
+// +----------------------------------------------------------------------+
+// $Id: data.flash.php,v 1.1 2005/06/19 04:55:47 bitweaver Exp $
+// Initialization
+global $gBitSystem;
+if( $gBitSystem->isPackageActive( 'wiki' ) ) { // Do not include this Plugin if the Package is not active
+
+define( 'PLUGIN_GUID_DATAFLASH', 'dataflash' );
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'FLASH',
+ 'auto_activate' => TRUE,
+ 'requires_pair' => FALSE,
+ 'load_function' => 'data_flash',
+ 'title' => 'Flash',
+ 'description' => tra("This plugin allows a Flash SWF file to be displayed."),
+ 'help_function' => 'data_flash_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/index.php", // Update this URL when a page on TP.O exists
+ 'syntax' => "{FLASH movie= width= height= quality= }",
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATAFLASH, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAFLASH );
+
+// Help Function
+function data_flash_help() {
+ $help =
+ '<table class="data help">'
+ .'<tr>'
+ .'<th>' . tra( "Key" ) . '</th>'
+ .'<th>' . tra( "Type" ) . '</th>'
+ .'<th>' . tra( "Comments" ) . '</th>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>movie</td>'
+ .'<td>' . tra( "string") . '<br />' . tra("(manditory)") . '</td>'
+ .'<td>' . tra( "A location where the Flash SWF file can be found. This can be any URL or a site value. See Examples.")
+ .'</tr>'
+ .'<tr class="even">'
+ .'<td>width</td>'
+ .'<td>' . tra( "number or percentage") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "The width of the players window. This value can be given in pixels or as a percentage of available area. A pixel value is assumed so only a numeric value is needed. To specify a percentage - the character <strong>% MUST</strong> follow the value. The Default is taken from the SWF file if this parameter is not defined.") . '</td>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>height</td>'
+ .'<td>' . tra( "number or percentage") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "The height of the players window. This value can be given in pixels or as a percentage. A pixel value is assumed so only a numeric value is needed. To specify a percentage - the character <strong>% MUST</strong> follow the value. When a percentage is given - the value is defined by the SWF file with a maximum of 100%. <strong>Note:</strong> This is <strong>NOT</strong> a percentage of the available area. Experimentation seems to be the only option available with this parameter. If this parameter is not defined the Default value is taken from the SWF file <strong>(i.e. 100%)</strong>.") . '</td>'
+ .'</tr>'
+ .'<tr class="even">'
+ .'<td>quality</td>'
+ .'<td>' . tra( "key-word") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "Specifies the quality to display the picture. Possible values are unknown - except:") . ' <strong>high</strong> ' . tra("and probably") . ' <strong>low</strong> ' . tra("The Default = ") . '<strong>high</strong></td>'
+ .'</tr>'
+ .'</table>'
+ . tra("Example: ") . "{FLASH movie=../liberty/icons/Mind-Reader.swf }<br />"
+ . tra("Example: ") . "{{FLASH movie=http://www.bitweaver.org/liberty/icons/Mind-Reader.swf width='100%' height='600' quality='high' }<br />"
+ . tra('Both of these examples display "The Flash Mind Reader" by Andy Naughton. The first example is on your site and is not very large. The second example is located on the bitweaver.org site and takes the width of the center column with an appropriat height.');
+ return $help;
+}
+
+// Load Function
+function data_flash($data, $params) {
+ extract ($params);
+ $w = (isset($width)) ? $width : "";
+ $h = (isset($height)) ? $height : "";
+ $q = (isset($quality)) ? $quality : "high";
+
+ $asetup = "<OBJECT CLASSID=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" WIDTH=\"$w\" HEIGHT=\"$h\">";
+ $asetup .= "<PARAM NAME=\"movie\" VALUE=\"$movie\">";
+ $asetup .= "<PARAM NAME=\"quality\" VALUE=\$q\">";
+ $asetup .= "<embed src=\"$movie\" quality=\"$q\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"$w\" height=\"$h\"></embed></object>";
+
+ return $asetup;
+}
+}
+/******************************************************************************
+The code below is from the deprecated FLASH plugin. All comments and the help routines have been removed. - StarRider
+// Wiki plugin to display a SWF file - by damian aka damosoft 30 March 2004
+
+function wikiplugin_flash($data, $params) {
+
+ extract ($params);
+ $w = (isset($width)) ? $width : "";
+ $h = (isset($height)) ? $height : "";
+ $q = (isset($quality)) ? $quality : "high";
+
+ $asetup = "<OBJECT CLASSID=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" WIDTH=\"$w\" HEIGHT=\"$h\">";
+ $asetup .= "<PARAM NAME=\"movie\" VALUE=\"$movie\">";
+ $asetup .= "<PARAM NAME=\"quality\" VALUE=\$q\">";
+ $asetup .= "<embed src=\"$movie\" quality=\"$q\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"$w\" height=\"$h\"></embed></object>";
+
+ return $asetup;
+}
+*/
+?>
diff --git a/plugins/data.freemind.php b/plugins/data.freemind.php
new file mode 100644
index 0000000..3951c87
--- /dev/null
+++ b/plugins/data.freemind.php
@@ -0,0 +1,90 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Author: Spiderr
+// +----------------------------------------------------------------------+
+global $gLibertySystem;
+
+define( 'PLUGIN_GUID_FREEMIND', 'datafreemind' );
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'MM',
+ 'auto_activate' => TRUE,
+ 'requires_pair' => FALSE,
+ 'load_function' => 'data_freemind',
+ 'title' => 'FreeMind',
+ 'description' => tra("Displays a Freemind Mindmaps"),
+ 'help_function' => 'data_freemind_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/DataPluginFreeMind",
+ 'syntax' => "{MM src= height= width= }",
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_FREEMIND, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_FREEMIND );
+
+// Help Function
+function data_freemind_help() {
+ $help =
+ '<table class="data help">'
+ .'<tr>'
+ .'<th>' . tra( "Key" ) . '</th>'
+ .'<th>' . tra( "Type" ) . '</th>'
+ .'<th>' . tra( "Comments" ) . '</th>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>src</td>'
+ .'<td>' . tra( "string") . '<br />' . tra("(manditory)") . '</td>'
+ .'<td>' . tra( "Location where the Mindmap MM file can be found. This can be any URL or a site value. See Examples.") . '</td>'
+ .'</tr>'
+ .'<tr class="even">'
+ .'<td>width</td>'
+ .'<td>' . tra( "number or percentage") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "The width of the Mindmap window. This value can be given in pixels or as a percentage of available area. A pixel value is assumed so only a numeric value is needed. To specify a percentage - the character <strong>% MUST</strong> follow the value. The Default is taken from the Mindmap file if this parameter is not defined.") . '</td>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>height</td>'
+ .'<td>' . tra( "number or percentage") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "The height of the Mindmap window. This value can be given in pixels or as a percentage. A pixel value is assumed so only a numeric value is needed. To specify a percentage - the character <strong>% MUST</strong> follow the value. When a percentage is given - the value is defined by the Mindmap file with a maximum of 100%. <strong>Note:</strong> The Default is taken from the Mindmap file if this parameter is not defined.") . '</td>'
+ .'</tr>'
+ .'</table>'
+ . tra("Example: ") . "{MM src='http://www.bitweaver.org/examples/bitweaver.mm' width='100%' height='600' }";
+ return $help;
+}
+
+// Load Function
+function data_freemind( $data, $params ) {
+ $repl = '';
+ if( !empty( $params['src'] ) ) {
+ $height = !empty( $params['height'] ) ? $params['height'] : '600';
+ $width = !empty( $params['width'] ) ? $params['width'] : '100%';
+ $drvr = '../drivers/freemind.jar';
+ if (!file_exists($drvr)) {
+ $repl = tra("Error - the file") . '<strong> freemind.jar </strong>' . tra("does not exist in the site's <strong>drivers</strong> directory.");
+ } else {
+ $repl =
+ '<script language="JavaScript">'.
+ ' if(!navigator.javaEnabled()) {'.
+ ' document.write(\'Please install a <a href="http://www.java.com/">Java Runtime Environment</a> on your computer.\');'.
+ ' }'.
+ '</script>'.
+ '<applet code="freemind.main.FreeMindApplet.class" archive="../drivers/freemind.jar" '.
+ ' width="' . $width . '" height="' . $height .'" >'.
+ ' <param name="type" value="application/x-java-applet;version=1.4" >'.
+ ' <param name="scriptable" value="false" >'.
+ ' <param name="modes" value="freemind.modes.browsemode.BrowseMode" >'.
+ ' <param name="browsemode_initial_map" value="' . $params["src"] . '" >'.
+ ' <param name="initial_mode" value="Browse" >'.
+ '</applet>'.
+ '<br>'.
+ '<span class="">Download <a href="' . $params["src"] . '">this mind map</a> and use this application to edit it: <a href="http://freemind.sourceforge.net/">Freemind </a> </span>';
+ }
+ }
+ return $repl;
+}
+?>
diff --git a/plugins/data.gauge.php b/plugins/data.gauge.php
new file mode 100644
index 0000000..cfcee94
--- /dev/null
+++ b/plugins/data.gauge.php
@@ -0,0 +1,169 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Author: StarRider <starrrider@sbcglobal.net>
+// | Reworked from: wikiplugin_gauge.php - see deprecated code below
+// +----------------------------------------------------------------------+
+// $Id: data.gauge.php,v 1.1 2005/06/19 04:55:48 bitweaver Exp $
+// Initialization
+define( 'PLUGIN_GUID_DATAGAUGE', 'datagauge' );
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'GAUGE',
+ 'auto_activate' => TRUE,
+ 'requires_pair' => TRUE,
+ 'load_function' => 'data_gauge',
+ 'title' => 'Gauge',
+ 'description' => tra("This plugin displays a graphical GAUGE."),
+ 'help_function' => 'data_gauge_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/index.php", // Update this URL when a page on TP.O exists
+ 'syntax' => "{GAUGE color= bgcolor= max= value= size= perc= height= }" . tra("Description") . "{GAUGE}",
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATAGAUGE, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAGAUGE );
+
+// Help Function
+function data_gauge_help() {
+ $help =
+ '<table class="data help">'
+ .'<tr>'
+ .'<th>' . tra( "Key" ) . '</th>'
+ .'<th>' . tra( "Type" ) . '</th>'
+ .'<th>' . tra( "Comments" ) . '</th>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>color</td>'
+ .'<td>' . tra( "colorname or hex color") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "Specifies the color of the of the Bar in the Gauge. Colornames or HTML colors can be used. To specify HTML color the <strong>#</strong> character <strong>MUST</strong> be included like this: ( <strong>#RRGGBB </strong> ). If not specified - the <strong>Current Text Color</strong> will be used. See Note below for Colornames & HTML Colors Sources.") . '</td>'
+ .'</tr>'
+ .'<tr class="even">'
+ .'<td>bgcolor</td>'
+ .'<td>' . tra( "colorname or hex color") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "Specifies the color of the Gauges Background. Colornames or HTML colors can be used. To specify HTML color the <strong>#</strong> character <strong>MUST</strong> be included like this: ( <strong>#RRGGBB </strong> ). If not specified - the <strong>Current Background Color</strong> will be used. See Note below for Colornames & HTML Colors Sources.") . '</td>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>max</td>'
+ .'<td>' . tra( "numeric") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "The maximum possible value to be displayed. The Gauge was designed to be used with percentages - so the Default = ") . '<strong>100</strong></td>'
+ .'</tr>'
+ .'<tr class="even">'
+ .'<td>value</td>'
+ .'<td>' . tra( "numeric") . '<br />' . tra("(Required)") . '</td>'
+ .'<td>' . tra( "The current value that the Guage will display. There is") . ' <strong>NO</strong> ' . tra("Default value.") . '</td>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>size</td>'
+ .'<td>' . tra( "numeric") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "The width of the Bar in pixels. The Default = ") . '<strong>150</strong></td>'
+ .'</tr>'
+ .'<tr class="even">'
+ .'<td>height</td>'
+ .'<td>' . tra( "numeric") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "The height of the Bar in pixels. The Default = ") . '<strong>14</strong></td>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>perc</td>'
+ .'<td>' . tra( "boolean") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( "Determines if the <strong>%</strong> character is displayed after the value. Passing any value in this parameter will make it <strong>TRUE</strong>. The Default = <strong>FALSE</strong> so the <strong>%</strong> character will not be displayed") . '</td>'
+ .'</tr>'
+ .'<tr class="even">'
+ .'<td>Description</td>'
+ .'<td>' . tra( "boolean") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra("<strong>This is NOT a Parameter.</strong> Text can be place between the 2 code blocks ( in this case:") . ' <strong>{GUAGE}</strong> ' . tra(" ). If present the text will be displayed below the Guage.") . '</td>'
+ .'</tr>'
+ .'</table>'
+ . tra("Example: ") . "{GAUGE color='red' bgcolor='blue' value='25' perc='True' }A Simple Gauge{GAUGE}" . '<br />'
+ . tra("<strong>Note:</strong> Browser Safe Colornames are available on the ")
+ . "<a class='wiki' target=" . '"_blank"' . " http://www.bitweaver.org/wiki/index.php?page=Web-Safe+HTML+Colors'>" . tra("TiKiPro</a> Web Site. ")
+ . tra("A useful site for obtaining HTML colors is ") . "<a class='wiki' target=" . '"_blank"' . " href='http://www.pagetutor.com/pagetutor/makapage/picker/'>"
+ . tra("The Color Picker II</a>");
+ return $help;
+}
+
+// Load Function
+function data_gauge($data, $params) {
+ extract ($params);
+ if (!isset($max)) {
+ $max = 100;
+ }
+ if (!isset($value)) {
+ return tra("<b>ERROR</b> - Missing parameter. The ") . "__Gauge__" . tra(" plugin requires a value in the parameter ") . "__value__.";
+ }
+ if (!isset($size)) {
+ $size = 150;
+ }
+ if (!isset($bgcolor)) {
+ $bgcolor = '#0000FF';
+ }
+ if (!isset($color)) {
+ $color = '#FF0000';
+ }
+ if (!isset($perc)) {
+ $perc = false;
+ }
+ if ($perc) {
+ $perc = number_format($value / $max * 100, 2);
+ $perc = '&nbsp;&nbsp;' . $perc . '%';
+ } else {
+ $perc = '';
+ }
+ $h_size = floor($value / $max * $size);
+ if (!isset($height)) {
+ $height = 14;
+ }
+ $html = "<table border='0' cellpadding='0' cellspacing='0'><tr><td><table border='0' height='$height' cellpadding='0' cellspacing='0' width='$size' style='background-color:$bgcolor;'><tr><td style='background-color:$color;' width='$h_size'>&nbsp;</td><td>&nbsp;</td></tr></table></td><td>$perc</td></tr>";
+ if (!empty($data)) {
+ $html .= "<tr><td colspan='2'><small>$data</small></td></tr>";
+ }
+ $html .= "</table>";
+ return $html;
+}
+/******************************************************************************
+The code below is from the deprecated GAUGE plugin. All comments and the help routines have been removed. - StarRider
+
+function wikiplugin_gauge($data, $params) {
+ extract ($params);
+ if (!isset($max)) {
+ $max = 100;
+ }
+ if (!isset($value)) {
+ return tra("<b>ERROR</b> - Missing parameter. The ") . "__Gauge__" . tra(" plugin requires a value in the parameter ") . "__value__.";
+ }
+ if (!isset($size)) {
+ $size = 150;
+ }
+ if (!isset($bgcolor)) {
+ $bgcolor = '#0000FF';
+ }
+ if (!isset($color)) {
+ $color = '#FF0000';
+ }
+ if (!isset($perc)) {
+ $perc = false;
+ }
+ if ($perc) {
+ $perc = number_format($value / $max * 100, 2);
+ $perc = '&nbsp;&nbsp;' . $perc . '%';
+ } else {
+ $perc = '';
+ }
+ $h_size = floor($value / $max * $size);
+ if (!isset($height)) {
+ $height = 14;
+ }
+ $html = "<table border='0' cellpadding='0' cellspacing='0'><tr><td><table border='0' height='$height' cellpadding='0' cellspacing='0' width='$size' style='background-color:$bgcolor;'><tr><td style='background-color:$color;' width='$h_size'>&nbsp;</td><td>&nbsp;</td></tr></table></td><td>$perc</td></tr>";
+ if (!empty($data)) {
+ $html .= "<tr><td colspan='2'><small>$data</small></td></tr>";
+ }
+ $html .= "</table>";
+ return $html;
+}
+*/
+?>
diff --git a/plugins/data.include.php b/plugins/data.include.php
new file mode 100644
index 0000000..72b986e
--- /dev/null
+++ b/plugins/data.include.php
@@ -0,0 +1,85 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Author: StarRider <starrrider@sbcglobal.net>
+// | Reworked from: wikiplugin_include.php - see deprecated code below
+// +----------------------------------------------------------------------+
+// $Id: data.include.php,v 1.1 2005/06/19 04:55:48 bitweaver Exp $
+// Initialization
+define( 'PLUGIN_GUID_DATAINCLUDE', 'datainclude' );
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'INCLUDE',
+ 'auto_activate' => FALSE,
+ 'requires_pair' => FALSE,
+ 'load_function' => 'data_include',
+ 'title' => 'Include',
+ 'description' => tra("This plugin is used to include the contents of one Wiki page in another Wiki page."),
+ 'help_function' => 'data_include_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/index.php", // Update this URL when a page on TP.O exists
+ 'syntax' => "{INCLUDE content_id= }",
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATAINCLUDE, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAINCLUDE );
+
+// Help Function
+function data_include_help() {
+ $help = '
+ <table class="plugin help">
+ <tr>
+ <th>'.tra( 'key' ).'</th>
+ <th>'.tra( 'type' ).'</th>
+ <th>'.tra( 'comments' ).'</th>
+ </tr>
+ <tr class="odd">
+ <td>page_name</td>
+ <td>'.tra( 'string (optional)' ).'</td>
+ <td>'.tra( 'To include any wiki page you can use it\'s page name (this has to be a unique name. if it\'s not unique, use the page_id instead) (this method is deprecated).' ).'</td>
+ </tr>
+ <tr class="even">
+ <td>page_id</td>
+ <td>'.tra( 'numeric (optional)' ).'</td>
+ <td>'.tra( 'To include any wiki page you can use it\'s page_id number.' ).'</td>
+ </tr>
+ <tr class="odd">
+ <td>content_id</td>
+ <td>'.tra( 'numeric (optional)' ).'</td>
+ <td>'.tra( 'To include any content from tikipro insert the apprpropriate numeric content id. This can include blog posts, images, wiki texts...<br />
+ Avaliable content can be viewed <a href="'.LIBERTY_PKG_URL.'list_content.php">here</a>' ).'</td>
+ </tr>
+ </table>
+ Example: {include page_name=15}
+ Example: {include page_id=15}
+ Example: {include content_id=15}';
+ return $help;
+}
+
+function data_include($data, $params) {
+ $ret = "<p>Please enter a valid 'page_name', 'page_id' or 'content_id' to include in this page.</p>";
+ // load page by page_id
+ if( isset( $params['page_id'] ) && is_numeric( $params['page_id'] ) ) {
+ require_once( WIKI_PKG_PATH.'BitPage.php');
+ $wp = new BitPage( $params['page_id'] );
+ if( $wp->load() ) {
+ $ret = $wp->mInfo['data'];
+ }
+ // load page by content_id
+ } elseif( isset( $params['content_id'] ) && is_numeric( $params['content_id'] ) ) {
+ $obj = LibertyBase::getLibertyObject( $params['content_id'] );
+ if( $obj->load() ) {
+ $ret = $obj->parseData();
+ }
+ // load page by page_name
+ } elseif( isset( $params['page_name'] ) ) {
+ $ret = "page_name isn't working yet, please use page_id or content_id";
+ }
+ return $ret;
+}
+?>
diff --git a/plugins/data.lang.php b/plugins/data.lang.php
new file mode 100644
index 0000000..a8d36a4
--- /dev/null
+++ b/plugins/data.lang.php
@@ -0,0 +1,64 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Author: StarRider <starrrider@sbcglobal.net>
+// | Reworked from: wikiplugin_lang.php - see deprecated code below
+// +----------------------------------------------------------------------+
+// $Id: data.lang.php,v 1.1 2005/06/19 04:55:47 bitweaver Exp $
+// Initialization
+define( 'PLUGIN_GUID_DATALANG', 'datalang' );
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'LANG',
+ 'auto_activate' => TRUE,
+ 'requires_pair' => TRUE,
+ 'load_function' => 'data_lang',
+ 'title' => 'Lang<strong> - This plugin is not yet functional.</strong>', // Remove this line when the plugin becomes operational
+// 'title' => 'Lang', // and Remove the comment from the start of this line
+ 'description' => tra("This plugin will attempt to translate the text between the ") . "{LANG}" . tra(" blocks to the current language. If the translation fails - nothing is displayed."),
+ 'help_function' => 'data__lang_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/index.php", // Update this URL when a page on TP.O exists
+ 'syntax' => "{LANG lang= }" . tra("Text to be translated") . "{LANG}",
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATALANG, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATALANG );
+
+// Help Function
+function data_lang_help() {
+ $back = tra("^__Parameter Syntax:__ ") . "~np~{LANG" . tra("(key=>value)}~/np~\n");
+ $back.= tra("||__::key::__ | __::value::__ | __::Comments::__\n");
+ $back.= "::lang::" . tra(" | ::abreviation:: | the language of the text between the ") . "~np~{LANG}~/np~" . tra(" blocks. __Required__.\n");
+ $back.= tra("abreviations: Chinese (Simplified)=") . "__cn__" . tra(" / Chinese Traditional=") . "__tw__" . tra(" / Czech=") . "__cs__" . tra(" / Danish=") . "__da__" . tra(" / English=") . "__en__" . tra(" / French=") . "__fr__" . tra(" / German=") . "__de__" . tra(" / Hebrew=") . "__he__" . tra(" / Italian=") . "__it__" . tra(" / Japanese=") . "__ja__" . tra(" / Norwegian=") . "__no__" . tra(" / Polish=") . "__po__" . tra(" / Russian=") . "__ru__" . tra(" / Serbian=") . "__sr__" . tra(" / Slovak=") . "__sk__" . tra(" Spanish=") . "__es__" . tra(" Swedish=") . "__sv__.||^";
+ $back.= tra("^__Example:__ ") . "~np~{LANG(lang=>fr)}Bon appétit{LANG}~/np~^";
+ return $back;
+}
+
+// Load Function
+function data_lang($data, $params) {
+ global $gBitLanguage;
+ extract ($params);
+ if (!isset($lang) || $lang == $gBitLanguage->mLanguage)
+ return $data;
+ else
+ return "";
+}
+/******************************************************************************
+The code below is from the deprecated LANG plugin. All comments and the help routines have been removed. - StarRider
+
+function wikiplugin_lang($data, $params) {
+ global $gBitLanguage;
+ extract ($params);
+ if (!isset($lang) || $lang == $gBitLanguage->mLanguage)
+ return $data;
+ else
+ return "";
+}
+*/
+?>
diff --git a/plugins/data.maketoc.php b/plugins/data.maketoc.php
new file mode 100644
index 0000000..912ac5b
--- /dev/null
+++ b/plugins/data.maketoc.php
@@ -0,0 +1,202 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Author: xing <xing@synapse.plus.com>
+// +----------------------------------------------------------------------+
+// $Id: data.maketoc.php,v 1.1 2005/06/19 04:55:48 bitweaver Exp $
+// Initialization
+define( 'PLUGIN_GUID_DATAMAKETOC', 'datamaketoc' );
+global $gLibertySystem;
+global $gContent;
+$pluginParams = array ( 'tag' => 'MAKETOC',
+ 'auto_activate' => FALSE,
+ 'requires_pair' => FALSE,
+ 'load_function' => '',
+ 'title' => 'MakeTOC',
+ 'description' => tra("Will create a table of contents of the WikiPage based on the headings below."),
+ 'help_function' => 'data_maketoc_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/DataPluginMaketoc",
+ 'syntax' => "{maketoc}",
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATAMAKETOC, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAMAKETOC );
+
+// Help Function
+function data_maketoc_help() {
+ $help =
+ '<table class="data help">'
+ .'<tr>'
+ .'<th>' . tra( "Key" ) . '</th>'
+ .'<th>' . tra( "Type" ) . '</th>'
+ .'<th>' . tra( "Comments" ) . '</th>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>maxdepth</td>'
+ .'<td>' . tra( "numeric") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( 'if you specify 3 here, MakeTOC will only parse headings to the h3 level.' ) . '</td>'
+ .'</tr>'
+ .'<tr class="even">'
+ .'<td>include</td>'
+ .'<td>' . tra( "value") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( 'if you include <strong>' ).'all'.( '</strong>, it will print a list of the full list of contents, regardless of where in the page {maketoc} is.' ) . '</td>'
+ .'</tr>'
+ .'<tr class="odd">'
+ .'<td>backtotop</td>'
+ .'<td>' . tra( "boolean") . '<br />' . tra("(optional)") . '</td>'
+ .'<td>' . tra( 'if you set backtotop <strong>' ).'true'.( '</strong>, it will insert a "back to the top" link.' ) . '</td>'
+ .'</tr>'
+ .'</table>'
+ . tra("Example: ") . '{maketoc maxdepth=3 include=all backtotop=true}';
+ return $help;
+}
+
+function data_maketoc( $data ) {
+ preg_match_all( "/\{maketoc(.*?)\}/", $data, $maketocs );
+ // extract the parameters for maketoc
+ foreach( $maketocs[1] as $string ) {
+ $params[] = parse_xml_attributes( $string );
+ }
+
+ // get all headers into an array
+ preg_match_all( "/<h(\d).*?>.*?<\/h.>/i", $data, $headers );
+
+ // remove any html tags from the output text and generate link ids
+ foreach( $headers[0] as $output ) {
+ $output = preg_replace( "/<.*?>/", '', $output );
+ $outputs[] = $output;
+ $anchors[] = 'id'.microtime() * 1000000;
+ }
+
+ // insert the <a name> tags in the right places
+ foreach( $headers[0] as $k => $header ) {
+ $anchor = '<a name="'.$anchors[$k].'"></a>';
+ $data = preg_replace( "/".preg_quote( $header, "/" )."/", $anchor.$header, $data );
+ }
+
+ if( !empty( $outputs ) ) {
+ $tocHash = array(
+ 'outputs' => $outputs,
+ 'anchors' => $anchors,
+ 'levels' => $headers[1],
+ );
+
+ // (<br[ |\/]*>){0,1} removes up to one occurance of <br> | <br > | <br /> | <br/> or similar variants
+ $sections = preg_split( "/\{maketoc.*?\}(<br[ |\/]*>){0,1}/", $data );
+ // first section is before any {maketoc} entry, so we can ignore it
+ $ret = array_shift( $sections );
+
+ foreach( $sections as $k => $section ) {
+ // count headers in each section that we know where to begin and where to stop
+ preg_match_all( "/<h(.)>.*?<\/h.>/i", $section, $hs );
+ $tocHash['tocCounts'][] = count( $hs[0] );
+ $tocHash['tocKey'] = $k;
+ $ret .= maketoc_create_list( $tocHash, $params[$k] ).$section;
+ }
+ }
+
+ return isset( $ret ) ? $ret : $data;
+}
+
+function maketoc_create_list( $pTocHash, $pParams ) {
+ extract( $pTocHash );
+
+ // previous level
+ $prev = 0;
+ // array that is populated with the items that have to be closed eventually
+ $open = array();
+ // contains the actual depth we're at
+ $depth = 0;
+ // maximum header level output uses
+ $maxdepth = !empty( $pParams['maxdepth'] ) ? $pParams['maxdepth'] : 6;
+
+ $ignore = 0;
+ if( !isset( $pParams['include'] ) || $pParams['include'] != 'all' ) {
+ for( $i = 0; $i < $tocKey; $i++ ) {
+ $ignore += $tocCounts[$i];
+ }
+ }
+
+ $list = '';
+ // start with the generation of the nested <ul> list
+ foreach( $outputs as $k => $output ) {
+ if( $k >= $ignore ) {
+ $j = 0;
+
+ // open <ul> tags, store them in $open and set $depth
+ for( $i = $prev; $i < $levels[$k]; $i++ ) {
+ if( $j++ == 0 ) {
+ array_unshift( $open, $prev );
+ }
+ if( $depth < $maxdepth ) {
+ $list .= '<ul>';
+ }
+ $depth++;
+ }
+
+ // close the <ul> tags as appropriate and update $open and $depth
+ for( $i = $prev; $i > $levels[$k]; $i -= 1 ) {
+ // close any <li> tags if needed
+ if( $depth == $open[0] ) {
+ if( $depth <= $maxdepth ) {
+ $list .= '</li>';
+ }
+ array_shift( $open );
+ }
+ if( $depth <= $maxdepth ) {
+ $list .= '</ul>';
+ }
+ $depth -= 1;
+ }
+
+ // close any <li> items that haven't been dealt with above
+ if( $depth == $open[0] ) {
+ if( $depth <= $maxdepth ) {
+ $list .= '</li>';
+ }
+ array_shift( $open );
+ }
+
+ if( $depth <= $maxdepth ) {
+ $list .= '<li><a href="#'.$anchors[$k].'">'.$output.'</a>';
+ }
+ if( $levels[$k] >= @$levels[$k+1] ) {
+ if( $depth <= $maxdepth ) {
+ $list .= '</li>';
+ }
+ }
+ $prev = $levels[$k];
+ }
+ }
+
+ // close off any remaning tags
+ for( $i = $depth; $i > 0; $i -= 1 ) {
+ if( $i == $open[0] ) {
+ if( $depth <= $maxdepth ) {
+ $list .= '</li>';
+ }
+ array_shift( $open );
+ }
+ if( $depth <= $maxdepth ) {
+ $list .= '</ul>';
+ }
+ }
+
+ if( isset( $pParams['backtotop'] ) && $pParams['backtotop'] == 'true' ) {
+ $toplink = '<a href="#top">'.tra( 'back to top' ).'</a>';
+ } else {
+ $toplink = '';
+ }
+
+ $list = '<div class="tikitoc"><h3>'.( !empty( $pParams['title'] ) ? $pParams['title'] : tra( 'Page Contents' ) ).'</h3>'.$list.$toplink.'</div>';
+
+ return $list;
+}
+?>
diff --git a/plugins/data.module.php b/plugins/data.module.php
new file mode 100644
index 0000000..c3d1cb4
--- /dev/null
+++ b/plugins/data.module.php
@@ -0,0 +1,117 @@
+<?php
+/* $Id: data.module.php,v 1.1 2005/06/19 04:55:48 bitweaver Exp $
+Displays a module inlined in page
+Parameters
+module name : module=>lambda
+align : align=>(left|center|right)
+max : max=>20
+np : np=>(0|1) # (for non-parsed content)
+module args : arg=>value (depends on module)
+Example:
+{MODULE(module=>last_modified_pages,align=>left,max=>3,maxlen=>22)}
+{/MODULE}
+about module params : all params are passed in $module_params
+so if you need to use parmas just add them in MODULE()
+like the tracker_id in the above example.
+*/
+/**
+ * \warning zaufi: using cached module template is break the idea of
+ * having different (than system default) parameters for modules...
+ * so cache checking and maintaining currently commented out
+ * 'till another solution will be implemented :)
+ */
+
+define( 'PLUGIN_GUID_DATAMODULE', 'datamodule' );
+
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'MODULE',
+ 'auto_activate' => TRUE,
+ 'requires_pair' => FALSE,
+ 'load_function' => 'data_datamodule',
+ 'title' => 'Module',
+ 'description' => tra("Display a module block in content"),
+ 'help_function' => 'datamodule_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/index.php", // Update this URL when a page on TP.O exists
+ 'syntax' => '{MODULE module= align="right"}',
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATAMODULE, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAMODULE );
+
+function datamodule_help() {
+ $back = tra("^__Parameter Syntax:__ ") . "~np~{MODULE" . tra("(key=>value)}~/np~\n");
+ $back.= tra("||__::key::__ | __::value::__ | __::Comments::__\n");
+ $back.= "::module::" . tra(" | ::name:: | the name of the module to be displayed. __Required__\n");
+ $back.= "::align::" . tra(" | ::alignment:: | orientation of the module to the page. Can be ") . "left / center / right" . tra(". There default is ") . "__left__.\n";
+ $back.= "::max::" . tra(" | ::number:: | number of rows the module will be display in. There default is __10__.\n");
+ $back.= "::np::" . tra(" | ::boolean:: | if True (any value = True) the content will not be parsed. There default is __No__.\n");
+ $back.= "::args::" . tra(" | ::value:: | this depends on module - some modules require additional arguments passed to them.||^");
+ $back.= tra("^__Example:__ ") . "~np~{MODULE(module=>last_modified_pages,align=>left,max=>3,maxlen=>22)}{/MODULE}~/np~^";
+ $back.= tra("^__Note:__ Plugin's are __case sensitive__. The Name of the plugin __MUST__ be UPPERCASE. The Key(s) are __always__ lowercase. Some Values are mixed-case but most require lowercase. When in doubt - look at the Example.^");
+ return $back;
+}
+
+function data_datamodule($data, $params) {
+ global $modlib, $cache_time, $smarty, $feature_directory, $ranklib, $feature_trackers, $bitdomain, $user,
+ $feature_tasks, $feature_user_bookmarks, $bit_p_tasks, $bit_p_create_bookmarks, $imagegallib;
+ require_once( KERNEL_PKG_PATH.'mod_lib.php' );
+ $out = '';
+ extract ($params);
+ if (!isset($align)) {
+ $align = 'left';
+ }
+ if (!isset($max)) {
+ $max = '10';
+ }
+ if (!isset($np)) {
+ $np = '0';
+ }
+ if (!isset($module)) {
+ $out = '<form class="box" id="modulebox">';
+ $out .= '<br /><select name="choose">';
+ $out .= '<option value="">' . tra('Please choose a module'). '</option>';
+ $out .= '<option value="" style="background-color:#bebebe;">' . tra('to be used as argument'). '</option>';
+ $out .= '<option value="" style="background-color:#bebebe;">{MODULE(module=>name_of_module)}</option>';
+ $handle = opendir('modules');
+ while ($file = readdir($handle)) {
+ if ((substr($file, 0, 4) == "mod-") and (substr($file, -4, 4) == ".php")) {
+ $mod = substr(substr(basename($file), 4), 0, -4);
+ $out .= "<option value=\"$mod\">$mod</option>";
+ }
+ }
+ $out .= '</select></form>';
+ } else {
+ if (!isset($args)) {
+ $args = '';
+ }
+// if ((!file_exists($cachefile)) || (file_exists($nocache)) || ((time() - filemtime($cachefile)) > $cache_time)) {
+ $smarty->assign('no_module_controls', 'y');
+ if( $out = $smarty->fetch( $module ) ) {
+ } else {
+ if ($modlib->is_user_module($module)) {
+ $info = $modlib->get_user_module($module);
+ $smarty->assign_by_ref('user_title', $info["title"]);
+ $smarty->assign_by_ref('user_data', $info["data"]);
+ $out = $smarty->fetch('modules/user_module.tpl');
+ }
+ }
+ $smarty->clear_assign('no_module_controls');
+// } else {
+// $fp = fopen($cachefile, "r");
+// $out = fread($fp, filesize($cachefile));
+// fclose ($fp);
+// }
+ $out = eregi_replace("\n", "", $out);
+ }
+ if ($out) {
+ if ($np) {
+ $data = "<div style='float:$align;'>~np~$out~/np~</div>".$data;
+ } else {
+ $data = "<div style='float:$align;'>$out</div>" . $data;
+ }
+ } else {
+ $data = "<div style='error'>" . tra("Sorry no such module"). "<br/><b>$module</b></div>" . $data;
+ }
+ return $data;
+}
+?>
diff --git a/plugins/data.pluginhelp.php b/plugins/data.pluginhelp.php
new file mode 100644
index 0000000..c4a8cce
--- /dev/null
+++ b/plugins/data.pluginhelp.php
@@ -0,0 +1,71 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Author: StarRider <starrrider@sbcglobal.net>
+// | Reworked from: wikiplugin_pluginhelp.php - see deprecated code below
+// +----------------------------------------------------------------------+
+// $Id: data.pluginhelp.php,v 1.1 2005/06/19 04:55:48 bitweaver Exp $
+// Initialization
+define( 'PLUGIN_GUID_DATAPLUGINHELP', 'datapluginhelp' );
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'PLUGINHELP',
+ 'auto_activate' => TRUE,
+ 'requires_pair' => FALSE,
+ 'load_function' => 'data_pluginhelp',
+ 'title' => 'PluginHelp<strong> - This plugin is not yet functional.</strong>', // Remove this line when the plugin becomes operational
+// 'title' => 'PluginHelp', // and Remove the comment from the start of this line
+ 'description' => tra("This plugin will display the plugin's Help."),
+ 'help_function' => 'data__pluginhelp_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/index.php", // Update this URL when a page on TP.O exists
+ 'syntax' => "{PLUGINHELP plugin= }",
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATAPLUGINHELP, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAPLUGINHELP );
+
+// Help Function
+function data_pluginhelp_help() {
+ $back = tra("^__Parameter Syntax:__ ") . "~np~{PLUGINHELP(" . tra("key=> )}~/np~\n");
+ $back.= tra("||__::key: ::__ | __::value::__ | __::Comments::__\n");
+ $back.= "::plugin::" . tra(" | ::plugin name:: | the name of a plugin. Will display the Help and Extended Help - fairly much as they are seen here.||^");
+ $back.= tra("^__Example:__ ") . "~np~{PLUGINHELP(plugin=>pluginhelp)}{PLUGINHELP}~/np~^";
+ return $back;
+}
+
+// Load Function
+function data_pluginhelp($data, $params) {
+ $ret = "This plugin has not been completed as yet. ";
+ return $ret;
+}
+/******************************************************************************
+The code below is from the deprecated PLUGINHELP plugin. All comments and the help routines have been removed. - StarRider
+include_once( WIKI_PKG_PATH.'BitPage.php');
+function wikiplugin_pluginhelp($data, $params) {
+ global $wikilib;
+ extract ($params);
+ if (!isset($plugin)) {
+ return tra("The plugin <b>PluginHelp</b> needs the name of a plugin to function. Please seek Help.<br/>");
+ }
+ $file = "wikiplugin_" . $plugin . ".php";
+ $func_name = "wikiplugin_" . $plugin . "_help";
+
+ if (file_exists( PLUGINS_DIR . '/' . $file)) {
+ include_once( PLUGINS_DIR . '/' . $file );
+ $back = '<b>' . strtoupper($plugin) . ' - </b>';
+ if (function_exists($func_name)) { $back.= $func_name(); }
+ $func_name = "wikiplugin_" . $plugin . "_extended_help";
+ if (function_exists($func_name)) { $back.= $func_name(); }
+ } else {
+ $back = tra("Unable to locate the file named <b>") . $file . '</b> in the <b>' . PLUGINS_DIR . '/</b> ' . tra("directory");
+ }
+ return $back;
+}
+*/
+?>
diff --git a/plugins/data.rss.php b/plugins/data.rss.php
new file mode 100644
index 0000000..11368a5
--- /dev/null
+++ b/plugins/data.rss.php
@@ -0,0 +1,51 @@
+<?php
+global $gLibertySystem;
+
+define( 'PLUGIN_GUID_RSS', 'datarss' );
+
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'RSS',
+ 'auto_activate' => TRUE,
+ 'requires_pair' => FALSE,
+ 'load_function' => 'rss_parse_data',
+ 'title' => 'RSS Feed',
+ 'description' => tra("Display RSS Feeds"),
+ 'help_function' => 'rss_extended_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/index.php", // Update this URL when a page on TP.O exists
+ 'syntax' => "{RSS id= max= }",
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_RSS, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_RSS );
+
+function rss_extended_help() {
+ return 'NO HELP WRITTEN FOR {RSS}';
+}
+
+function rss_parse_data( $data, $params ) {
+ $repl = '';
+ if( !empty( $params['id'] ) ) {
+ global $rsslib;
+ require_once( RSS_PKG_PATH.'rss_lib.php' );
+
+ $max = !empty( $params['max'] ) ? $params['max'] : 99;
+
+ $rssdata = $rsslib->get_rss_module_content( $params['id'] );
+ $items = $rsslib->parse_rss_data( $rssdata, $params['id'] );
+
+ $repl = '<ul class="rsslist">';
+
+ for ($j = 1; $j < count($items) && $j < $max; $j++) {
+ $repl .= '<li><a href="' . $items[$j]["link"] . '">' . $items[$j]["title"] . '</a>';
+ if ($items[$j]["pubdate"] <> '') {
+ $repl .= ' <small>('.$items[$j]["pubdate"].')</small>';
+ }
+ $repl .= '</li>';
+ }
+
+ $repl .= '</ul>';
+ }
+ return $repl;
+}
+
+?>
diff --git a/plugins/data.sf.php b/plugins/data.sf.php
new file mode 100644
index 0000000..a769878
--- /dev/null
+++ b/plugins/data.sf.php
@@ -0,0 +1,175 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Author: StarRider <starrrider@sbcglobal.net>
+// | Reworked from: wikiplugin_sf.php - see deprecated code below
+// +----------------------------------------------------------------------+
+// $Id: data.sf.php,v 1.1 2005/06/19 04:55:47 bitweaver Exp $
+// Initialization
+define( 'PLUGIN_GUID_DATASF', 'datasf' );
+define('SF_CACHE',48); # in hours
+define('DEFAULT_TAG','bugs');
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'SF',
+ 'auto_activate' => TRUE,
+ 'requires_pair' => FALSE,
+ 'load_function' => 'data_sf',
+ 'title' => 'Sf',
+ 'description' => tra("This plugin automatically creates a link to the appropriate ))SourceForge(( object for ))bitweaver((."),
+ 'help_function' => 'data__sf_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/index.php", // Update this URL when a page on TP.O exists
+ 'syntax' => "{SF groupid= adit= aid= tag= }",
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATASF, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATASF );
+
+// Help Function
+function data_sf_help() {
+ $back = tra("^__Parameter Syntax:__ ") . "~np~{SF" . tra("(key=>value)}~/np~\n");
+ $back.= tra("||__::key::__ | __::value::__ | __::Comments::__\n");
+ $back.= "::groupid::" . tra(" | ::number:: | every ))SourceForge(( project has one. This identifies the project and can be found in the URL.\n");
+ $back.= "::adit::" . tra(" | ::number:: | is number identifies the section to be looked at. The choices are Bugs, Support, Patches & RFE's and are unique for each project.\n");
+ $back.= "::aid::" . tra(" | ::number:: | is the Tracker in question. For a bug report labled ~034~__~091~ 123456 ~093~ I'm a bug!__~034~ - the ") . "aid" . tra(" number is 123456\n");
+ $back.= "::tag::" . tra(" | ::name:: | is a short cut that allows the plugin to work automatically. The ") . "groupid & adit" . tra(" are supplied if these ") . "tags" . tra(" are used: ") . "__bugs / rfe / patches / support__" . tra(" are for ))bitweaver(( - ") . "__twbugs / twrfe / twpatches / twsupport__" . tra(" are for ))TikiWiki(( - ") . "__jgbugs / jgsupport / jgrfe__" . tra(" are for JGraph.||^");
+ $back.= tra("^__Example:__ ") . "~np~{SF(groupid=>101599,adit=>630083,aid=>928215)}~/np~\n";
+ $back.= tra("This is a ))bitweaver(( bug report named ~034~Lost in Space - errrr - bitweaver~034~^");
+ return $back;
+}
+
+function get_artifact_label($gid,$atid,$aid,$reload=false) {
+ $agent = $_SERVER['HTTP_USER_AGENT'];
+ $cachefile = TEMP_PKG_PATH."cache/".$bitdomain."sftrackers.cache.$gid.$atid.$aid";
+ $cachelimit = time() - 60*60*SF_CACHE;
+ $url = "http://sourceforge.net/tracker/index.php?func=detail&amp;aid=$aid&amp;group_id=$gid&amp;atid=$atid";
+ if (!is_file($cachefile)) $reload = true;
+ $back = false;
+ if ($reload or (filemtime($cachefile) < $cachelimit)) {
+ $ch = curl_init($url);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_USERAGENT, $agent);
+ curl_setopt($ch, CURLOPT_REFERER, $url);
+ $buffer = curl_exec ($ch);
+ curl_close ($ch);
+ if (preg_match("/<title>[^-]*-([^<]*)<\/title>/i",$buffer,$match)) {
+ $fp = fopen($cachefile,"wb");
+ fputs($fp,$match[1]);
+ fclose($fp);
+ } elseif (is_file($cachefile)) {
+ $fp = fopen($cachefile,"rb");
+ $back = fgets($fp);
+ fclose($fp);
+ }
+ } else {
+ $fp = fopen($cachefile,"rb");
+ $back = fgets($fp,4096);
+ fclose($fp);
+ }
+ return $back;
+}
+
+// Load Function
+function data_sf($data, $params) {
+ # customize that (or extract it in a db)
+ $sftags['bugs'] = array('101599','630083');
+ $sftags['rfe'] = array('101599','630086');
+ $sftags['patches'] = array('101599','630085');
+ $sftags['support'] = array('101599','630084');
+ $sftags['twbugs'] = array('64258','506846');
+ $sftags['twrfe'] = array('64258','506849');
+ $sftags['twpatches'] = array('64258','506848');
+ $sftags['twsupport'] = array('64258','506847');
+ $sftags['jgbugs'] = array('43118','435210');
+ $sftags['jgsupport'] = array('43118','435211');
+ $sftags['jgrfe'] = array('43118','435213');
+ extract ($params);
+ if (isset($tag) and isset($sftags["$tag"]) and is_array($sftags["$tag"])) {
+ list($sf_group_id,$sf_atid) = $sftags["$tag"];
+ } else {
+ $sf_group_id = (isset($groupid)) ? "$groupid" : $sftags[DEFAULT_TAG][0];
+ $sf_atid = (isset($atid)) ? "$atid" : $sftags[DEFAULT_TAG][1];
+ $tag = DEFAULT_TAG;
+ }
+ if (!isset($aid)) {
+ //return "__please use (aid=>xxx) as parameters__";
+ return "<b>please use (aid=>xxx) as parameters</b>";
+ }
+ $label = get_artifact_label($sf_group_id,$sf_atid,$aid);
+ //$back = "[http://sf.net/tracker/index.php?func=detail&amp;aid=$aid&amp;group_id=$sf_group_id&amp;atid=$sf_atid|$tag:#$aid: $label|nocache]";
+ $back = "<a href='http://sf.net/tracker/index.php?func=detail&amp;aid=$aid&amp;group_id=$sf_group_id&amp;atid=$sf_atid' target='_blank' title='$tag:#$aid' class='wiki'>$label</a>";
+ return $back;
+}
+/******************************************************************************
+The code below is from the deprecated SF plugin. All comments and the help routines have been removed. - StarRider
+define('SF_CACHE',48); # in hours
+define('DEFAULT_TAG','bugs');
+
+function get_artifact_label($gid,$atid,$aid,$reload=false) {
+ $agent = $_SERVER['HTTP_USER_AGENT'];
+ $cachefile = TEMP_PKG_PATH."cache/".$bitdomain."sftrackers.cache.$gid.$atid.$aid";
+ $cachelimit = time() - 60*60*SF_CACHE;
+ $url = "http://sourceforge.net/tracker/index.php?func=detail&amp;aid=$aid&amp;group_id=$gid&amp;atid=$atid";
+ if (!is_file($cachefile)) $reload = true;
+ $back = false;
+ if ($reload or (filemtime($cachefile) < $cachelimit)) {
+ $ch = curl_init($url);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_USERAGENT, $agent);
+ curl_setopt($ch, CURLOPT_REFERER, $url);
+ $buffer = curl_exec ($ch);
+ curl_close ($ch);
+ if (preg_match("/<title>[^-]*-([^<]*)<\/title>/i",$buffer,$match)) {
+ $fp = fopen($cachefile,"wb");
+ fputs($fp,$match[1]);
+ fclose($fp);
+ } elseif (is_file($cachefile)) {
+ $fp = fopen($cachefile,"rb");
+ $back = fgets($fp);
+ fclose($fp);
+ }
+ } else {
+ $fp = fopen($cachefile,"rb");
+ $back = fgets($fp,4096);
+ fclose($fp);
+ }
+ return $back;
+}
+function wikiplugin_sf($data, $params) {
+ # customize that (or extract it in a db)
+ $sftags['bugs'] = array('101599','630083');
+ $sftags['rfe'] = array('101599','630086');
+ $sftags['patches'] = array('101599','630085');
+ $sftags['support'] = array('101599','630084');
+ $sftags['twbugs'] = array('64258','506846');
+ $sftags['twrfe'] = array('64258','506849');
+ $sftags['twpatches'] = array('64258','506848');
+ $sftags['twsupport'] = array('64258','506847');
+ $sftags['jgbugs'] = array('43118','435210');
+ $sftags['jgsupport'] = array('43118','435211');
+ $sftags['jgrfe'] = array('43118','435213');
+ extract ($params);
+ if (isset($tag) and isset($sftags["$tag"]) and is_array($sftags["$tag"])) {
+ list($sf_group_id,$sf_atid) = $sftags["$tag"];
+ } else {
+ $sf_group_id = (isset($groupid)) ? "$groupid" : $sftags[DEFAULT_TAG][0];
+ $sf_atid = (isset($atid)) ? "$atid" : $sftags[DEFAULT_TAG][1];
+ $tag = DEFAULT_TAG;
+ }
+ if (!isset($aid)) {
+ //return "__please use (aid=>xxx) as parameters__";
+ return "<b>please use (aid=>xxx) as parameters</b>";
+ }
+ $label = get_artifact_label($sf_group_id,$sf_atid,$aid);
+ //$back = "[http://sf.net/tracker/index.php?func=detail&amp;aid=$aid&amp;group_id=$sf_group_id&amp;atid=$sf_atid|$tag:#$aid: $label|nocache]";
+ $back = "<a href='http://sf.net/tracker/index.php?func=detail&amp;aid=$aid&amp;group_id=$sf_group_id&amp;atid=$sf_atid' target='_blank' title='$tag:#$aid' class='wiki'>$label</a>";
+ return $back;
+}
+*/
+?>
diff --git a/plugins/data.sort.php b/plugins/data.sort.php
new file mode 100644
index 0000000..e5fc279
--- /dev/null
+++ b/plugins/data.sort.php
@@ -0,0 +1,91 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Author: StarRider <starrrider@sbcglobal.net>
+// | Reworked from: wikiplugin_sort.php - see deprecated code below
+// +----------------------------------------------------------------------+
+// $Id: data.sort.php,v 1.1 2005/06/19 04:55:48 bitweaver Exp $
+// Initialization
+define( 'PLUGIN_GUID_DATASORT', 'datasort' );
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'SORT',
+ 'auto_activate' => TRUE,
+ 'requires_pair' => TRUE,
+ 'load_function' => 'data_sort',
+ 'title' => 'Sort',
+ 'description' => tra("This plugin sorts operates on lines of text - not the text in the lines. Every line between the ") . "~np~{SORT}~/np~" . tra(" blocks - including the lines the blocks are on - is sorted."),
+ 'help_function' => 'data__sort_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/index.php", // Update this URL when a page on TP.O exists
+ 'syntax' => "{SORT sort= }" . tra("Lines to be sorted") . "{SORT}",
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATASORT, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATASORT );
+
+// Help Function
+function data_sort_help() {
+ $back = tra("^__Parameter Syntax:__ ") . "~np~{SORT" . tra("(key=>value)}~/np~\n");
+ $back.= tra("||__::key::__ | __::value::__ | __::Comments::__\n");
+ $back.= "::sort::" . tra(" | ::direction:: | will sort the lines in the desired direction. Choices are: ") . "__asc / desc / reverse / shuffle__" . tra(" The default is ") . "__asc__.||^";
+ $back.= tra("^__Example:__ ") . "~np~{SORT(sort=>shuffle)}".tra("Line 1 / Line 2 / Line 3")."{SORT}~/np~^";
+ $back.= tra("^__Note:__ Plugin's are __case sensitive__. The Name of the plugin __MUST__ be UPPERCASE. The Key(s) are __always__ lowercase. Some Values are mixed-case but most require lowercase. When in doubt - look at the Example.^");
+ return $back;
+}
+
+// Load Function
+function data_sort($data, $params) {
+ extract ($params);
+ $sort = (isset($sort)) ? $sort : "asc";
+ $lines = explode("\n", $data); // separate lines into array
+ // $lines = array_filter( $lines, "chop" ); // remove \n
+ srand ((float)microtime() * 1000000); // needed for shuffle;
+ if ($sort == "asc") {
+ sort ($lines);
+ } else if ($sort == "desc") {
+ rsort ($lines);
+ } else if ($sort == "reverse") {
+ $lines = array_reverse($lines);
+ } else if ($sort == "shuffle") {
+ shuffle ($lines);
+ }
+ reset ($lines);
+ if (is_array($lines)) {
+ $data = implode("\n", $lines);
+ }
+ $data = trim($data);
+ return $data;
+}
+/******************************************************************************
+The code below is from the deprecated SORT plugin. All comments and the help routines have been removed. - StarRider
+
+function wikiplugin_sort($data, $params) {
+ extract ($params);
+ $sort = (isset($sort)) ? $sort : "asc";
+ $lines = explode("\n", $data); // separate lines into array
+ // $lines = array_filter( $lines, "chop" ); // remove \n
+ srand ((float)microtime() * 1000000); // needed for shuffle;
+ if ($sort == "asc") {
+ sort ($lines);
+ } else if ($sort == "desc") {
+ rsort ($lines);
+ } else if ($sort == "reverse") {
+ $lines = array_reverse($lines);
+ } else if ($sort == "shuffle") {
+ shuffle ($lines);
+ }
+ reset ($lines);
+ if (is_array($lines)) {
+ $data = implode("\n", $lines);
+ }
+ $data = trim($data);
+ return $data;
+}
+*/
+?>
diff --git a/plugins/data.split.php b/plugins/data.split.php
new file mode 100644
index 0000000..3c40ad7
--- /dev/null
+++ b/plugins/data.split.php
@@ -0,0 +1,103 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Author: StarRider <starrrider@sbcglobal.net>
+// | Reworked from: wikiplugin_split.php - see deprecated code below
+// +----------------------------------------------------------------------+
+// $Id: data.split.php,v 1.1 2005/06/19 04:55:48 bitweaver Exp $
+// Initialization
+define( 'PLUGIN_GUID_DATASPLIT', 'datasplit' );
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'SPLIT',
+ 'auto_activate' => TRUE,
+ 'requires_pair' => TRUE,
+ 'load_function' => 'data_split',
+ 'title' => 'Split<strong> - This plugin is not yet functional.</strong>', // Remove this line when the plugin becomes operational
+// 'title' => 'Split', // and Remove the comment from the start of this line
+ 'description' => tra("This plugin is used to split a page in two or more columns using __-~045~-__ as a seperator."),
+ 'help_function' => 'data__split_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/index.php", // Update this URL when a page on TP.O exists
+ 'syntax' => "{SPLIT joincols= fixedsize= }{SPLIT}",
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATASPLIT, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATASPLIT );
+
+// Help Function
+function data_split_help() {
+ $back = tra("^__Parameter Syntax:__ ") . "~np~{SPLIT" . tra("(key=>value)}~/np~\n");
+ $back.= tra("||__::key::__ | __::value::__ | __::Comments::__\n");
+ $back.= "::joincols::" . tra(" | ::boolean:: | if True (any value = False) a colspan will be generated if the column is missed. The default is __True__.\n");
+ $back.= "::fixedsize::" . tra(" | ::boolean:: | if True (any value = False) a width attribute will be generated for Tables Row (~060~TD~062~). The default is __True__.||^");
+ $back.= tra("^__Example:__ ") . "~np~{SPLIT()}" . tra("::-=Hot Dogs=-:: 2 for a Dollar --- ::-=Corn Dogs=-:: 3 for a Dollar") . "{SPLIT}~/np~\n";
+ $back.= tra("This will display 2 boxes side by side with a Title Bar and text in each.^");
+ return $back;
+}
+
+// Load Function
+function data_split($data, $params) {
+ $ret = "This plugin has not been completed as yet. ";
+ return $ret;
+}
+/******************************************************************************
+The code below is from the deprecated SPLIT plugin. All comments and the help routines have been removed. - StarRider
+function wikiplugin_split($data, $params) {
+ global $gBitSystem;
+ global $replacement;
+ // Remove first <ENTER> if exists...
+ // it may be here if present after {SPLIT()} in original text
+ if (substr($data, 0, 1) == "\n") $data = substr($data, 1);
+ extract ($params);
+ $fixedsize = (!isset($fixedsize) ? true : false);
+ $joincols = (!isset($joincols) ? true : false);
+ // Split data by rows and cells
+// $sections = preg_split("/\@{3,}+/", $data);
+ $sections = preg_split("/@@@+/", $data);
+ $rows = array();
+ $maxcols = 0;
+ foreach ($sections as $i)
+ {
+// $rows[] = preg_split("/-{3,}+/", $i);
+ $rows[] = preg_split("/---+/", $i);
+ $maxcols = max($maxcols, count(end($rows)));
+ }
+ // Is there split sections present?
+ // Do not touch anything if no... even don't generate <table>
+ if (count($rows) <= 1 && count($rows[0]) <= 1)
+ return $data;
+ $columnSize = floor(100 / $maxcols);
+ $result = '<table border="0"'.($fixedsize ? ' width="100%"' : '').'>';
+ // Attention: Dont forget to remove leading empty line in section ...
+ // it should remain from previous '---' line...
+ // Attention: origianl text must be placed between \n's!!!
+ foreach ($rows as $r)
+ {
+ $result .= "<tr>";
+ $idx = 1;
+ foreach ($r as $i)
+ {
+ // Generate colspan for last element if needed
+ $colspan = ((count($r) == $idx) && (($maxcols - $idx) > 0) ? ' colspan="'.($maxcols - $idx + 1).'"' : '');
+ $idx++;
+ // Add cell to table
+ $result .= '<td valign="top"'.($fixedsize ? ' width="'.$columnSize.'%"' : '').$colspan.'>'
+ .preg_replace("/\\n/", "<br />", $i)
+// . ((substr($i, 0, 1) == "\n") || (substr($i, 0, 1) == "\r") ? $i : "\n".$i)
+// . ((substr($i, -1) == "\n") || (substr($i, -1) == "\r") ? '' : "\n")
+ . '</td>';
+ }
+ $result .= "</tr>";
+ }
+ // Close HTML table (no \n at end!)
+ $result .= "</table>";
+ return $result;
+}
+*/
+?>
diff --git a/plugins/data.titlesearch.php b/plugins/data.titlesearch.php
new file mode 100644
index 0000000..45fc07f
--- /dev/null
+++ b/plugins/data.titlesearch.php
@@ -0,0 +1,114 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Author: StarRider <starrrider@sbcglobal.net>
+// | Reworked from: wikiplugin_titlesearch.php - see deprecated code below
+// +----------------------------------------------------------------------+
+// $Id: data.titlesearch.php,v 1.1 2005/06/19 04:55:47 bitweaver Exp $
+// Initialization
+define( 'PLUGIN_GUID_DATATITLESEARCH', 'datatitlesearch' );
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'TITLESEARCH',
+ 'auto_activate' => TRUE,
+ 'requires_pair' => FALSE,
+ 'load_function' => 'data_titlesearch',
+ 'title' => 'TitleSearch<strong> - This plugin is not yet functional.</strong>', // Remove this line when the plugin becomes operational
+// 'title' => 'TitleSearch', // and Remove the comment from the start of this line
+ 'description' => tra("This plugin search the titles of all pages in this wiki."),
+ 'help_function' => 'data__titlesearch_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/index.php", // Update this URL when a page on TP.O exists
+ 'syntax' => "{TITLESEARCH search= info= exclude= noheader= }",
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATATITLESEARCH, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATATITLESEARCH );
+
+// Help Function
+function data_titlesearch_help() {
+ $back = tra("^__Parameter Syntax:__ ") . "~np~{TITLESEARCH" . tra("(key=>value)}~/np~\n");
+ $back.= tra("||__::key::__ | __::value::__ | __::Comments::__\n");
+ $back.= "::search::" . tra(" | ::string:: | __Required__ - So what do you want to search for?\n");
+ $back.= "::info::" . tra(" | ::value:: | defines which fields are to be displayed. Possible values are: ") . "__hits / lastModif / user / ip / len / comment / creator / version / flag / versions / links / backlinks__" . tra(" Multiple values can be given using the character ~124~. Example: ") . "__user~124~len~124~comment__" . tra(". The default shows __None__ of this information.\n");
+ $back.= "::exclude::" . tra(" | ::page names:: | pages to be excluded from the listing. Multiple names can be exclude using the character ~124~. Example: ") . "__HomePage~124~SandBox~124~~np~RecentChanges~/np~__." . tra(" By default - __Every__ page is displayed.\n");
+ $back.= "::noheader::" . tra(" | ::boolean:: | if True (any value = False) a header will be displayed. The default is __False__.||^");
+ $back.= tra("^__Example:__ ") . "~np~{TITLESEARCH(search=>Admin,info=>user,exclude=>HomePage|SandBox,noheader=>1)}{TITLESEARCH}~/np~^";
+ return $back;
+}
+
+// Load Function
+function data_titlesearch($data, $params) {
+ $ret = "This plugin has not been completed as yet. ";
+ return $ret;
+}
+/******************************************************************************
+The code below is from the deprecated TITLESEARCH plugin. All comments and the help routines have been removed. - StarRider
+ require_once( WIKI_PKG_PATH.'plugins_lib.php' );
+ include_once( WIKI_PKG_PATH.'BitPage.php');
+ function run ($data, $params) {
+ global $WikiLib;
+ $aInfoPreset = array_keys($this->aInfoPresetNames);
+ $params = $this->getParams($params, true);
+ extract ($params);
+ if (!$search) {
+ return $this->error("You have to define a search");
+ }
+ //
+ /////////////////////////////////
+ // Create a valid list for $info
+ /////////////////////////////////
+ //
+ if ($info) {
+ $info_temp = array();
+ foreach($info as $sInfo) {
+ if (in_array(trim($sInfo), $aInfoPreset)) {
+ $info_temp[] = trim($sInfo);
+ }
+ $info = $info_temp?$info_temp:
+ false;
+ }
+ } else {
+ $info = false;
+ }
+ //
+ /////////////////////////////////
+ // Process pages
+ /////////////////////////////////
+ //
+ $sOutput = "";
+ $aPages = $wikilib->getList(0, -1, 'title_desc', $search);
+ foreach($aPages["data"] as $idPage => $aPage) {
+ if (in_array($aPage["title"], $exclude)) {
+ unset($aPages["data"][$idPage]);
+ $aPages["cant"]--;
+ }
+ }
+ //
+ /////////////////////////////////
+ // Start of Output
+ /////////////////////////////////
+ //
+ if (!$noheader) {
+ // Create header
+ $count = $aPages["cant"];
+ if (!$count) {
+ $sOutput .= tra("No pages found for title search")." '__".$search."__'";
+ } elseif ($count == 1) {
+ $sOutput .= tra("One page found for title search")." '__".$search."__'";
+ } else {
+ $sOutput = "$count".tra(" pages found for title search")." '__".$search."__'";
+ }
+ $sOutput .= "\n";
+ }
+ $sOutput.=PluginsLibUtil::createTable($aPages["data"],$info);
+ return $sOutput;
+ }
+ }
+*/
+?>
diff --git a/plugins/data.toc.php b/plugins/data.toc.php
new file mode 100644
index 0000000..d6cee24
--- /dev/null
+++ b/plugins/data.toc.php
@@ -0,0 +1,50 @@
+<?php
+global $gLibertySystem;
+
+define( 'PLUGIN_GUID_TOC', 'datatoc' );
+
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'toc',
+ 'auto_activate' => TRUE,
+ 'requires_pair' => FALSE,
+ 'load_function' => 'toc_parse_data',
+ 'title' => 'Table Of Contents',
+ 'description' => tra("Display a Table Of Contents for Structures"),
+ 'help_function' => 'toc_extended_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/index.php", // Update this URL when a page on TP.O exists
+ 'syntax' => '{TOC sturcture_id= }',
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_TOC, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_TOC );
+
+function toc_extended_help() {
+ return 'NO HELP WRITTEN FOR {toc}';
+}
+
+function toc_parse_data( $data, $params ) {
+ $repl = '';
+ include_once( LIBERTY_PKG_PATH.'LibertyStructure.php' );
+ global $gStructure, $gContent;
+ $struct = NULL;
+ if( empty( $gStructure ) || !$gStructure->isValid() ) {
+ $structures = $gContent->getStructures();
+ // We take the first structure. not good, but works for now - spiderr
+ if( !empty( $structures[0] ) ) {
+ $struct = new LibertyStructure( $structures[0]['structure_id'] );
+ }
+ } else {
+ $struct = &$gStructure;
+ }
+ if( is_object( $struct ) && count( $struct->isValid() ) ) {
+ // maybe there is not toc to render?
+ if( !$repl = $struct->get_toc( $struct->mStructureId ) ) {
+ // return blank, *not* empty, so the {toc} tag gets replaced
+ $repl = ' ';
+ }
+ }
+
+ return $repl;
+}
+
+?>
diff --git a/plugins/data.tp.php b/plugins/data.tp.php
new file mode 100644
index 0000000..f268c4f
--- /dev/null
+++ b/plugins/data.tp.php
@@ -0,0 +1,53 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Author: StarRider <starrrider@sbcglobal.net>
+// +----------------------------------------------------------------------+
+//
+// $Id: data.tp.php,v 1.1 2005/06/19 04:55:47 bitweaver Exp $
+// Initialization
+global $gBitSystem;
+
+define( 'PLUGIN_GUID_DATATP', 'datatp' );
+
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'TP',
+ 'auto_activate' => TRUE,
+ 'requires_pair' => FALSE,
+ 'load_function' => 'datatp',
+ 'title' => 'TestParms',
+ 'description' => tra("This plugin will display the parameters passed to it."),
+ 'help_function' => 'datatp_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/index.php", // Update this URL when a page on TP.O exists
+ 'syntax' => "~np~{TP(p1= ,p2= ,p3= )}~/np~",
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATATP, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATATP );
+
+function datatp_help() {
+ $back = tra("^__Parameter Syntax:__ ") . "~np~{TP(Key=value)}~/np~\n";
+ $back.= tra("||__::key::__ | __::value::__ | __::Comments::__\n");
+ $back.= "::p1::" . tra(" | ::Anything:: | Any parameter. \n");
+ $back.= "::p2::" . tra(" | ::Anything:: | Any parameter. \n");
+ $back.= "::p3::" . tra(" | ::Anything:: | Any parameter. \n");
+ $back.= tra("^__Example:__ ") . "~np~{TP(p1=AAAA, p2=BBBB, p3=CCCC)}~/np~^";
+ return $back;
+}
+
+function datatp($data, $params) {
+ $p1='';
+ $p2='';
+ $p3='';
+ extract ($params);
+ $ret = "))TestParms Reporting:<br/> P1=" . $p1 . "<br/> P2=" . $p2 . "<br/> P3=" . $p3 . "\n((";
+ return $ret;
+}
+?>
diff --git a/plugins/data.translated.php b/plugins/data.translated.php
new file mode 100644
index 0000000..1755b8a
--- /dev/null
+++ b/plugins/data.translated.php
@@ -0,0 +1,105 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Author: StarRider <starrrider@sbcglobal.net>
+// | Reworked from: wikiplugin_translated.php - see deprecated code below
+// +----------------------------------------------------------------------+
+// $Id: data.translated.php,v 1.1 2005/06/19 04:55:47 bitweaver Exp $
+// Initialization
+define( 'PLUGIN_GUID_DATATRANSLATED', 'datatranslated' );
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'TRANSLATED',
+ 'auto_activate' => TRUE,
+ 'requires_pair' => FALSE,
+ 'load_function' => 'data_translated',
+ 'title' => 'Translated<strong> - This plugin is not yet functional.</strong>', // Remove this line when the plugin becomes operational
+// 'title' => 'Translated', // and Remove the comment from the start of this line
+ 'description' => tra("This plugin is used to create a link to a page that contains a translation. The link can be shown as an Icon for the country or as an abreviation for the language."),
+ 'help_function' => 'data__translated_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/index.php", // Update this URL when a page on TP.O exists
+ 'syntax' => "{TRANSLATED page= lang= flag= }",
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATATRANSLATED, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATATRANSLATED );
+
+// Help Function
+function data_translated_help() {
+ $back = tra("^__Parameter Syntax:__ ") . "~np~{TRANSLATED" . tra("(key=>value)}~/np~\n");
+ $back.= tra("||__::key::__ | __::value::__ | __::Comments::__\n");
+ $back.= "::page::" . tra(" | ::page name:: | __Manditory__ Is a valid url for the page which contains the translation. The page name can be in the formats [url] or ((wikiname)) or ((inter:interwiki))\n^");
+ $back.= "::lang::" . tra(" | ::abreviation:: | __Manditory__ Is a 2 letter code that specifies the language to use. See the Abreviations given below.\n");
+ $back.= "::flag::" . tra(" | ::flag name:: | __Optional__ Is an image file that can be used as the link. See the Flag Names given below\n");
+ $back.= "^__Flag Names:__ ~pp~American_Samoa / Angola / Antigua / Argentina / Armenia / Australia / Austria / Bahamas / Bahrain / Bangladesh / Barbados / Belgium / Bermuda / Bolivia / Brazil / Brunei / Canada / Cayman_Islands / Chile / China / Colombia / Cook_Islands / Costa_Rica / Croatia / Cuba / Cyprus / Czech_Republic / Denmark / Dominican_Republic / Ecuador / Egypt / El_Salvador / Estonia / Federated_States_of_Micronesia / Fiji / Finland / France / French_Polynesia / Germany / Greece / Guam / Guatemala / Haiti / Honduras / Hungary / Iceland / India / Indonesia / Iran / Iraq / Ireland / Israel / Italy / Jamaica / Japan / Jordan / Kazakstan / Kenya / Kiribati / Kuwait / Latvia / Lebanon / Lithuania / Malawi / Malaysia / Malta / Marshall_Islands / Mauritius / Mexico / Morocco / Mozambique / Nauru / Nepal / Netherlands / New_Caledonia / New_Zealand / Nicaragua / Nigeria / Niue / Norway / Pakistan / Panama / Papua_New_Guinea / Paraguay / Peru / Phillippines / Poland / Portugal / Puerto_Rico / Quatar / Romania / Russia / Samoa / Saudi_Arabia / Singapore / Slovakia / Slovenia / Solomon_Islands / Somalia / South_Africa / South_Korea / Spain / Sri_Lanka / St_Vincent_Grenadines / Surinam / Sweden / Switzerland / Taiwan / Thailand / Tonga / Trinidad_Tobago / Turkey / Tuvalu / Ukraine / United_Arab_Emirates / United_Kingdom / United_States / Uruguay / Vanuatu / Venezuela / Wales / Yugoslavia / Zambia / Zimbabwe~/pp~\n^";
+ $back.= tra("^ __Language Abreviations:__ Chinese (Simplified)=") . "__cn__" . tra(" / Chinese Traditional=") . "__tw__" . tra(" / Czech=") . "__cs__" . tra(" / Danish=") . "__da__" . tra(" / English=") . "__en__" . tra(" / French=") . "__fr__" . tra(" / German=") . "__de__" . tra(" / Hebrew=") . "__he__" . tra(" / Italian=") . "__it__" . tra(" / Japanese=") . "__ja__" . tra(" / Norwegian=") . "__no__" . tra(" / Polish=") . "__po__" . tra(" / Russian=") . "__ru__" . tra(" / Serbian=") . "__sr__" . tra(" / Slovak=") . "__sk__" . tra(" Spanish=") . "__es__" . tra(" Swedish=") . "__sv__.||^";
+ $back.= tra("^__Example:__ ") . "~np~{TRANSLATED(page=>Home Page,lang=>fr,flag=>France)}~/np~^";
+ return $back;
+}
+
+// Load Function
+function data_translated($data, $params) {
+ extract ($params);
+ if (!isset($page) ) { // A Manditory Parameter is missing
+ $ret = 'The __page__ parameter was missing from the __~np~{TRANSLATED}~/np~__ plugin.';
+ $ret.= data_translated_help();
+ return $ret;
+ }
+ if (!isset($lang) ) { // A Manditory Parameter is missing
+ $ret = 'The __lang__ parameter was missing from the __~np~{TRANSLATED}~/np~__ plugin.';
+ $ret.= data_translated_help();
+ return $ret;
+ }
+
+ $img = '';
+ $h = opendir(USERS_PKG_PATH . "icons/flags/");
+ while ($file = readdir($h)) { // Open the directory and read each filename
+ if (substr($file,0,1) != '.' and substr($file,-4,4) == '.gif') { // Operate only on gif files
+ $avflags[] = substr($file,0,strlen($file)-4);
+ }
+ }
+ if (isset($flag)) {
+ if (in_array($flag,$avflags)) {
+ $file = USERS_PKG_URL . "icons/flags/" . $flag . ".gif";
+ $img = "<img src='$file' width='18' height='13' vspace='0' hspace='3' alt='($lang)' align='baseline' />";
+ }
+ } else {
+ $img = "($lang) ";
+ }
+ $ret = $img . $page;
+ return $ret;
+}
+/******************************************************************************
+The code below is from the deprecated TRANSLATED plugin. All comments and the help routines have been removed. - StarRider
+function wikiplugin_translated($data, $params) {
+ extract ($params);
+ $img = '';
+ $h = opendir(USERS_PKG_URL . "icons/flags/");
+ while ($file = readdir($h)) {
+ if (substr($file,0,1) != '.' and substr($file,-4,4) == '.gif') {
+ $avflags[] = substr($file,0,strlen($file)-4);
+ }
+ }
+ if (isset($flag)) {
+ if (in_array($flag,$avflags)) {
+ $img = "<img src=IMG_PKG_URL.'flags/$flag.gif' width='18' height='13' vspace='0' hspace='3' alt='$lang' align='baseline' /> ";
+ }
+ }
+ if (!$img) {
+ $img = "( $lang ) ";
+ }
+ if (isset($data)) {
+ $back = $img.$data;
+ } else {
+ $back = "''no data''";
+ }
+ return $back;
+}
+*/
+?>
diff --git a/plugins/data.usercount.php b/plugins/data.usercount.php
new file mode 100644
index 0000000..6703fa3
--- /dev/null
+++ b/plugins/data.usercount.php
@@ -0,0 +1,57 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Author: StarRider <starrrider@sbcglobal.net>
+// | Reworked from: wikiplugin_usercount.php - see deprecated code below
+// +----------------------------------------------------------------------+
+// $Id: data.usercount.php,v 1.1 2005/06/19 04:55:47 bitweaver Exp $
+// Initialization
+define( 'PLUGIN_GUID_DATAUSERCOUNT', 'datausercount' );
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'USERCOUNT',
+ 'auto_activate' => FALSE,
+ 'requires_pair' => TRUE,
+ 'load_function' => 'data_usercount',
+ 'title' => 'UserCount<strong> - This plugin is not yet functional.</strong>', // Remove this line when the plugin becomes operational
+// 'title' => 'UserCount', // and Remove the comment from the start of this line
+ 'description' => tra("Will show the number of users. If a Group Name can be included to filter the Groups."),
+ 'help_function' => 'data__usercount_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/index.php", // Update this URL when a page on TP.O exists
+ 'syntax' => "{USERCOUNT}Group Name{USERCOUNT}",
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATAUSERCOUNT, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAUSERCOUNT );
+
+// Help Function
+function data_usercount_help() {
+ $back = tra("^__Parameter Syntax:__ ") . "~np~{USERCOUNT(key=>value)}~/np~\n";
+ $back.= tra("||__::key: ::__ | __::value::__ | __::Comments::__\n");
+ $back.= tra("::NONE:: | ::NONE:: | this plugin has no parameters.||^");
+ $back.= tra("^__Example:__ ") . "~np~{USERCOUNT()}Registered{USERCOUNT}~/np~^";
+ return $back;
+}
+
+// Load Function
+function data_usercount($data, $params) {
+ $ret = "This plugin has not been completed as yet. ";
+ return $ret;
+}
+/******************************************************************************
+The code below is from the deprecated USERCOUNT plugin. All comments and the help routines have been removed. - StarRider
+
+function wikiplugin_usercount($data, $params) {
+ global $gBitUser;
+ extract ($params);
+ $numusers = $gBitUser->count_users($data);
+ return $numusers;
+}
+*/
+?>
diff --git a/plugins/data.userlist.php b/plugins/data.userlist.php
new file mode 100644
index 0000000..3129df4
--- /dev/null
+++ b/plugins/data.userlist.php
@@ -0,0 +1,189 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Author: StarRider <starrrider@sbcglobal.net>
+// | Reworked from: wikiplugin_userlist.php - see deprecated code below
+// +----------------------------------------------------------------------+
+// $Id: data.userlist.php,v 1.1 2005/06/19 04:55:47 bitweaver Exp $
+// Initialization
+define( 'PLUGIN_GUID_DATAUSERLIST', 'datauserlist' );
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'USERLIST',
+ 'auto_activate' => FALSE,
+ 'requires_pair' => TRUE,
+ 'load_function' => 'data_userlist',
+ 'title' => 'UserList<strong> - This plugin is not yet functional.</strong>', // Remove this line when the plugin becomes operational
+// 'title' => 'UserList',, // and Remove the comment from the start of this line
+ 'description' => tra("This plugin will displays an alphabetically sorted list of registered users. A Group Name can be included to filter Groups to be listed."),
+ 'help_function' => 'data__userlist_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/index.php", // Update this URL when a page on TP.O exists
+ 'syntax' => "{USERLIST num= userspage= alpha= total= email= }GroupName{USERLIST}",
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATAUSERLIST, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAUSERLIST );
+
+// Help Function
+function data_userlist_help() {
+ $back = tra("^__Parameter Syntax:__ ") . "~np~{USERLIST" . tra("(key=>value)}~/np~\n");
+ $back.= tra("||__::key::__ | __::value::__ | __::Comments::__\n");
+ $back.= "::num::" . tra(" | ::boolean:: | if True then the listing is numbered. __Optional__ - can be omitted - the __Default = False__ (any value = True) .\n");
+ $back.= "::userspage::" . tra(" | ::boolean:: | if True then a link is provided to each user that has a personal userpage. __Optional__ - can be omitted - the __Default = True__ (any value = False).\n");
+ $back.= "::alpha::" . tra(" | ::boolean:: | if True then the listing is sectioned alphabetically - using the first letter in the users name. __Optional__ - can be omitted - the __Default = True__ (any value = False) .\n");
+ $back.= "::email::" . tra(" | ::boolean:: | shows the email address of each user - if their email address is public. __Optional__ - can be omitted - the __Default = False__ (any value = True).\n");
+ $back.= "::total::" . tra(" | ::boolean:: | shows the total number of users in list at the bottom of the listing. __Optional__ - can be omitted - the __Default = True__ (any value = False).||^");
+ $back.= tra("^__Example:__ ") . "~np~{USERLIST(num=>1,email=>1)}{USERLIST} ~/np~^";
+ return $back;
+}
+
+// Load Function
+function data_userlist($data, $params) {
+ $ret = "This plugin has not been completed as yet. ";
+ return $ret;
+}
+/******************************************************************************
+The code below is from the deprecated USERLIST plugin. All comments and the help routines have been removed. - StarRider
+
+include_once( WIKI_PKG_PATH.'BitPage.php');
+
+function wikiplugin_userprint($num,$user,$userspage,$email,$wp_user_count) {
+ global $wikilib,$gBitUser, $gBitSystem;
+ // alternate class of every row
+ if ($wp_user_count % 2) {
+ $class = 'even';
+ }
+ else {
+ $class = 'odd';
+ }
+ $ret = ('<tr class="'.$class.'">');
+
+ // get email address and check if it's public
+ $user_info = $gBitUser->getUserInfo( array( 'login' => $user ) );
+ $eml = scrambleEmail($user_info['email']);
+ $public = FALSE; // cheap hack from spiderr to get things working. $wikilib->get_user_preference($user,'email is public');
+
+ if ($num) {
+ $ret .= ('<td>__'.$wp_user_count.'__</td>');
+ }
+
+ if( $gBitSystem->isPackageActive( 'messu' ) ) {
+ $messu_img = ('<a class="wiki" href="'.MESSU_PKG_URL.'compose.php?to='.$user.'" title="'.tra('Send a message to').' '.$user.'"><img src="'.IMG_PKG_URL.'icons/icon_ultima.gif" width="20" height="10" border="0" alt="'.tra('Send message').'" /></a> ');
+ } else {
+ $messu_img = ('');
+ }
+ $ret .= ('<td>'.$messu_img.$user.'</td>');
+
+ // if you want to show all email addresses indstead of only public ones, uncomment following line
+ $public = 'y';
+
+ if ($email) {
+ if ($public == 'y' && $eml != '') {
+ $ret .= '<td>[mailto:'.$eml.'|'.$eml.']</td>';
+ }
+ else {
+ $ret .= '<td>&nbsp;</td>';
+ }
+ }
+
+ if ($userspage) {
+ if ($wikilib->pageExists('userPage'.$user)) {
+ $ret .= '<td>((userPage'.$user.'|'.$user.' Homepage))</td>';
+ }
+ else {
+ $ret .= '<td>&nbsp;</td>';
+ }
+ }
+
+ $ret .= ("</tr>\r");
+
+ return $ret;
+}
+
+// function used to sort an array - NOT case-sensitive
+function wikiplugin_compare_users($a, $b) {
+ return strcmp(strtolower($a), strtolower($b));
+}
+
+function wikiplugin_userlist($data, $params) {
+ global $gBitUser, $gBitSystem;
+
+ extract ($params);
+ $num = (isset($num)) ? True : False; // Default = False
+ $userspage = (!isset($userspage)) ? True : False; // Default = True
+ $alpha = (!isset($alpha)) ? True : False; // Default = True
+ $total = (!isset($total)) ? True : False; // Default = True
+ $email = (isset($email)) ? True : False; // Default = False
+
+ $colcount = 1;
+
+ $ret = '<table class="normal">';
+ $ret .= '<tr>';
+
+ if ($num) {
+ $ret .= '<th>&nbsp;</th>';
+ $colcount++;
+ }
+
+ $ret .= '<th>'.tra('__UserName__').'</th>';
+
+ if ($email) {
+ $ret .= '<th>'.tra('__email Address__').'</th>';
+ $colcount++;
+ }
+
+ if ($userspage) {
+ $ret .= '<th>'.tra('__UserPage__').'</th>';
+ $colcount++;
+ }
+
+ $ret .= '</tr>';
+
+ if (!$data) {
+ $userdata = $gBitUser->get_users(0);
+
+ foreach ($userdata['data'] as $usertemp) {
+ $users[] = $usertemp['login'];
+ }
+ } else {
+ $users = $gBitUser->get_group_users($data);
+ }
+
+ usort($users, 'wikiplugin_compare_users'); // sort the users
+
+ $wp_user_count = 0;
+ foreach ($users as $user) {
+ if ($wp_user_count >= 1) {
+ $prev_user = $users[$wp_user_count-1];
+ }
+ else {
+ $prev_user = 0;
+ }
+ $wp_user_count++;
+
+ if ($alpha) {
+ if (strtolower($prev_user[0]) != strtolower($user[0])) {
+ $ret .= ("<tr><th colspan='".$colcount."'>__::Section - ".strtoupper($user[0])."::__</th></tr>\r");
+ }
+ }
+
+ $ret .= (wikiplugin_userprint($num,$user,$userspage,$email,$wp_user_count));
+ }
+
+ if ($total) {
+ $ret .= ("<tr><td class='odd' colspan='".$colcount."'>&nbsp;</td></tr>\r");
+ $ret .= ("<tr><td class='odd' colspan='".$colcount."'>".tra('__Total number of users').": ".$wp_user_count."__</td></tr>\r");
+ }
+
+ $ret .= ('</table>');
+
+ return $ret;
+}
+*/
+?>
diff --git a/plugins/data.wikilist.php b/plugins/data.wikilist.php
new file mode 100644
index 0000000..fe32843
--- /dev/null
+++ b/plugins/data.wikilist.php
@@ -0,0 +1,154 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2004, bitweaver.org
+// +----------------------------------------------------------------------+
+// | All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+// |
+// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
+// | -> see http://phpdocu.sourceforge.net/
+// +----------------------------------------------------------------------+
+// | Author: StarRider <starrrider@sbcglobal.net>
+// | Reworked from: wikiplugin_wikilist.php - see deprecated code below
+// +----------------------------------------------------------------------+
+// $Id: data.wikilist.php,v 1.1 2005/06/19 04:55:47 bitweaver Exp $
+// Initialization
+define( 'PLUGIN_GUID_DATAWIKILIST', 'datawikilist' );
+global $gLibertySystem;
+$pluginParams = array ( 'tag' => 'WIKILIST',
+ 'auto_activate' => FALSE,
+ 'requires_pair' => TRUE,
+ 'load_function' => 'data_wikilist',
+ 'title' => 'WikiList<strong> - This plugin is not yet functional.</strong>', // Remove this line when the plugin becomes operational
+// 'title' => 'WikiList', // and Remove the comment from the start of this line
+ 'description' => tra("Displays an alphabetically sorted list of WikiPages"),
+ 'help_function' => 'data__wikilist_help',
+ 'tp_helppage' => "http://www.bitweaver.org/wiki/index.php", // Update this URL when a page on TP.O exists
+ 'syntax' => "{WIKILIST num= alpha= total= list= }Group Name{WIKILIST} ",
+ 'plugin_type' => DATA_PLUGIN
+ );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_DATAWIKILIST, $pluginParams );
+$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAWIKILIST );
+
+// Help Function
+function data_wikilist_help() {
+ $back = tra("^__Parameter Syntax:__ ") . "~np~{WIKILIST" . tra("(key=>value)}~/np~\n");
+ $back.= tra("||__::key::__ | __::value::__ | __::Comments::__\n");
+ $back.= "::num::" . tra(" | ::0 or 1:: | adds numbering to the list. Default = None (0).\n");
+ $back.= "::alpha::" . tra(" | ::0 or 1:: | sorts names aplhabetically and groups them by the beginning letter. Default = On (1).\n");
+ $back.= "::lists:: | ::all / userpages / wiki:: | " . tra("defines the type of pages to be shown. wiki & userpages will only show those type of pages. Default = all.\n");
+ $back.= "::total::" . tra(" | ::0 or 1:: | shows total number of users in list at the end. Default = On (1).\n");
+ $back.= "::GroupName::" . tra(" | ::Not a Parameter:: | Given between ~np~{WIKILIST}~np~ blocks. If no GroupName is given then All Users is assumed.\n");
+ return $back;
+}
+
+// Load Function
+function data_wikilist($data, $params) {
+ $ret = "This plugin has not been completed as yet. ";
+ return $ret;
+}
+/******************************************************************************
+The code below is from the deprecated WIKILIST plugin. All comments and the help routines have been removed. - StarRider
+
+// Displays an alphabetically sorted list of WikiPages
+// Use:
+// {WIKILIST(num=>1,alpha=>1,total=>1,list=>all)}{WIKILIST}
+// num=>1 --> writes a number in front of every name default = 0
+// alpha=>1 --> shows names in groups of beginning letters default = 1
+// list=> default = all
+// all --> shows the wiki list and appends the userPage list
+// userpages --> shows all userPages without showing the wiki list
+// wiki --> shows the wiki list without showing the userpages
+// total=>1 --> shows total number of users in list at the end default = 1
+//
+// If no groupname is given, plugin returns all users
+
+
+// function used to sort an array - NOT case-sensitive
+function wikiplugin_compare_wikipages($a, $b) {
+ return strcmp(strtolower($a), strtolower($b));
+}
+
+function wikiplugin_wikilist($data, $params) {
+ global $gBitSystem;
+ global $feature_hotwords;
+ // turn off $feature_hotwords to avoid conflicts
+ $feature_hotwords = 'n';
+
+ extract ($params);
+ if(!isset($alpha)) { $alpha = 1; }
+ if(!isset($userpages)) { $userpages = "all"; }
+ if(!isset($num)) { $num = 0; }
+ if(!isset($total)) { $total = 1; }
+
+ $ret = "";
+ $pagedata = $gBitSystem->list_pages(0);
+
+ foreach ($pagedata['data'] as $pagedata_temp) {
+ $wiki_pages_all[] = $pagedata_temp['pageName'];
+ }
+
+ // sort the pages
+ usort($wiki_pages_all, "wikiplugin_compare_wikipages");
+
+ // sort the userpages from the rest of the wikipages
+ foreach ($wiki_pages_all as $pagename) {
+ if(strstr($pagename,"userPage") == false){
+ $wiki_pages[] = $pagename;
+ }
+ else {
+ $user_pages[] = $pagename;
+ }
+ }
+
+ if ($list != "userpages") {
+ $wp_list_count = 0;
+ foreach ($wiki_pages as $pagename) {
+ if ($wp_list_count >= 1) {
+ $prev_pagename = $wiki_pages[$wp_list_count-1];
+ }
+ else {
+ $prev_pagename = 0;
+ }
+ $wp_list_count++;
+
+ if ($alpha != 0) {
+ if (strtolower($prev_pagename[0]) != strtolower($pagename[0])) {
+ $ret .= ("-=".strtoupper($pagename[0])."=-\n");
+ }
+ }
+
+ if ($num != 0) {
+ $ret .= ($wp_list_count." ");
+ }
+
+ $ret .= ("((".$pagename."))\n");
+ }
+
+ if ($total != 0) {
+ $ret .= ("<br />".tra("Total").": ".$wp_list_count."\n");
+ }
+ }
+
+ if ($list != "wiki") {
+ $ret .= ("-=userPages=-\n");
+
+ $wp_list_count = 0;
+ foreach ($user_pages as $user_title) {
+ $wp_list_count++;
+ if ($num != 0) {
+ $ret .= ($wp_list_count." ");
+ }
+
+ $ret .= ("((".$user_title."))\n");
+ }
+
+ if ($total != 0) {
+ $ret .= ("<br />".tra("Total").": ".$wp_list_count."\n");
+ }
+ }
+
+ return $ret;
+}
+*/
+?>
diff --git a/plugins/format.pearwiki.php b/plugins/format.pearwiki.php
new file mode 100644
index 0000000..66f7889
--- /dev/null
+++ b/plugins/format.pearwiki.php
@@ -0,0 +1,50 @@
+<?php
+if( @include_once( 'Text/Wiki.php' ) ) {
+ global $gLibertySystem;
+
+ define( 'PLUGIN_GUID_PEARWIKI', 'pearwiki' );
+
+ $pluginParams = array ( 'store_function' => 'pearwiki_save_data',
+ 'load_function' => 'pearwiki_parse_data',
+ 'verify_function' => 'pearwiki_verify_data',
+ 'auto_activate' => FALSE,
+ 'description' => 'Pear Wiki Syntax Format Parser. Requires Text_Wiki Pear extension. If you are running linux you can try running: su -c \'pear install Text_Wiki\'. More info <a href="http://wiki.ciaweb.net/yawiki/index.php?area=Text_Wiki&page=SamplePage">here</a>',
+ 'edit_label' => 'Pear Text_Wiki Syntax',
+ 'edit_field' => '<input type="radio" name="format_guid" value="'.PLUGIN_GUID_PEARWIKI.'"',
+ 'plugin_type' => FORMAT_PLUGIN
+ );
+
+ $gLibertySystem->registerPlugin( PLUGIN_GUID_PEARWIKI, $pluginParams );
+
+ function pearwiki_save_data( &$pParamHash ) {
+ static $parser;
+ require_once 'Text/Wiki.php';
+ if( empty( $parser ) ) {
+ $parser =& new Text_Wiki();
+ }
+ }
+
+ function pearwiki_verify_data( &$pParamHash ) {
+ $errorMsg = NULL;
+ $pParamHash['content_store']['data'] = $pParamHash['edit'];
+ return( $errorMsg );
+ }
+
+ function pearwiki_parse_data( &$pData, &$pCommonObject ) {
+ static $parser;
+ require_once 'Text/Wiki.php';
+ if( empty( $parser ) ) {
+ $parser =& new Text_Wiki();
+ }
+ $xhtml = $parser->transform($pData, 'Xhtml');
+
+ global $gLibertySystem;
+ // create a table of contents for this page
+ // this function is called manually, since it processes the HTML code
+ if( preg_match( "/\{maketoc.*?\}/", $xhtml ) && @$gLibertySystem->mPlugins['datamaketoc']['is_active'] == 'y' ) {
+ $xhtml= data_maketoc($xhtml);
+ }
+ return $xhtml;
+ }
+}
+?>
diff --git a/plugins/format.pearwiki_tiki.php b/plugins/format.pearwiki_tiki.php
new file mode 100644
index 0000000..b0ca442
--- /dev/null
+++ b/plugins/format.pearwiki_tiki.php
@@ -0,0 +1,59 @@
+<?php
+if( @include_once( 'Text/Wiki.php' ) ) {
+ global $gLibertySystem;
+
+ define( 'PLUGIN_GUID_PEARWIKI_TIKI', 'pearwiki_tiki' );
+
+ $pluginParams = array ( 'store_function' => 'pearwiki_tiki_save_data',
+ 'load_function' => 'pearwiki_tiki_parse_data',
+ 'verify_function' => 'pearwiki_tiki_verify_data',
+ 'auto_activate' => FALSE,
+ 'description' => 'Pear Wiki Parser for TikiWiki Syntax. Requires Text_Wiki Pear extension. More info <a href="http://wiki.ciaweb.net/yawiki/index.php?area=Text_Wiki&page=SamplePage">here</a>',
+ 'edit_label' => 'Tiki Wiki Syntax, parsed by Pear::Text_Wiki',
+ 'edit_field' => '<input type="radio" name="format_guid" value="'.PLUGIN_GUID_PEARWIKI_TIKI.'"',
+ 'plugin_type' => FORMAT_PLUGIN
+ );
+
+ $gLibertySystem->registerPlugin( PLUGIN_GUID_PEARWIKI_TIKI, $pluginParams );
+
+ function pearwiki_tiki_save_data( &$pParamHash ) {
+ }
+
+ function pearwiki_tiki_verify_data( &$pParamHash ) {
+ $errorMsg = NULL;
+ $pParamHash['content_store']['data'] = $pParamHash['edit'];
+ return( $errorMsg );
+ }
+
+ function pearwiki_tiki_parse_data( &$pData, &$pCommonObject ) {
+ static $parser;
+ if( empty( $parser ) ) {
+ define('PAGE_SEP', 'PAGE MARKER HERE*&^%$#^$%*PAGEMARKERHERE');
+
+ require_once(dirname(__FILE__).'/../../util/pear/Text/Wiki/Tiki.php');
+ $parser =& new Text_Wiki_Tiki();
+ $parser->setRenderConf('xhtml', 'wikilink', 'exists_callback', array(&$pCommonObject, 'pageExists'));
+ $parser->setRenderConf('xhtml', 'wikilink', 'view_url', 'index.php?page=');
+ $parser->setRenderConf('xhtml', 'wikilink', 'new_url', 'edit.php?page=');
+ $parser->setRenderConf('xhtml', 'table', 'css_table', 'wikitable');
+ $parser->setRenderConf('xhtml', 'table', 'css_td', 'wikicell');
+ //$parser->setFormatConf('Xhtml', 'translate', false);
+ /*$extwiki = array();
+ $extwikiSth = $this->query('SELECT `extwiki`, `name` FROM `tiki_extwiki`');
+ while ($rec = $extwikiSth->fetchRow()) {
+ $extwiki[$rec['name']] = str_replace('$page', '%s', $rec['extwiki']);
+ }
+ $parser->setRenderConf('xhtml', 'interwiki', 'sites', $extwiki);*/
+ }
+ $xhtml = $parser->transform($pData, 'Xhtml');
+
+ global $gLibertySystem;
+ // create a table of contents for this page
+ // this function is called manually, since it processes the HTML code
+ /*if( preg_match( "/\{maketoc.*?\}/", $xhtml ) && @$gLibertySystem->mPlugins['datamaketoc']['is_active'] == 'y' ) {
+ $xhtml= data_maketoc($xhtml);
+ }*/
+ return $xhtml;
+ }
+}
+?>
diff --git a/plugins/format.tikihtml.php b/plugins/format.tikihtml.php
new file mode 100644
index 0000000..e25a079
--- /dev/null
+++ b/plugins/format.tikihtml.php
@@ -0,0 +1,82 @@
+<?php
+global $gLibertySystem;
+
+define( 'PLUGIN_GUID_BITHTML', 'bithtml' );
+
+$pluginParams = array ( 'store_function' => 'bithtml_save_data',
+ 'load_function' => 'bithtml_parse_data',
+ 'verify_function' => 'bithtml_verify_data',
+ 'description' => 'HTML Syntax Format Parser',
+ 'edit_label' => 'HTML',
+ 'edit_field' => '<input type="radio" name="format_guid" value="'.PLUGIN_GUID_BITHTML.'"',
+ 'plugin_type' => FORMAT_PLUGIN
+ );
+
+$gLibertySystem->registerPlugin( PLUGIN_GUID_BITHTML, $pluginParams );
+
+function bithtml_verify_data( &$pParamHash ) {
+ $errorMsg = NULL;
+ $pParamHash['content_store']['data'] = purge_html( $pParamHash['edit'] );
+ return $errorMsg;
+}
+
+// This function is a menagerie of the techniques of the comments listed at
+// http://www.php.net/manual/en/function.strip-tags.php - spiderr
+function purge_html( $pText ) {
+ global $gBitSystem, $gBitUser;
+
+ // convert all HTML entites to catch people trying to sneak stuff by with things like &#123; etc..
+ if( function_exists( 'html_entity_decode' ) ) {
+ $text = html_entity_decode( $pText );
+ } else {
+ $trans_tbl = get_html_translation_table(HTML_ENTITIES);
+ $trans_tbl = array_flip($trans_tbl);
+ $text = strtr($pText, $trans_tbl);
+ }
+
+ // strip_tags() appears to become nauseated at the site of a <!DOCTYPE> declaration
+ $text = str_replace( '<!DOCTYPE', '<DOCTYPE', $text );
+
+ // Yank style - both tag and inline attributes
+ // strip_tags has doesn't recognize that css within the style tags are not document text. To fix this do something similar to the following:
+ if( !$gBitUser->hasPermission( 'bit_p_edit_html_style' ) ) {
+ $text = preg_replace( "/<style[^>]*>.*<\/style>/siU", '', $text );
+ }
+ $text = stripslashes($text);
+ if( !$gBitUser->hasPermission( 'bit_p_edit_html_style' ) ) {
+ $text = preg_replace( "/ (style|class)=[\"]?([^\"]*)[\"]?/i", '', $text);
+ }
+
+ // Strip all evil tags that remain
+ // this comes out of gBitSystem->getPreference() set in Liberty Admin
+ $acceptableTags = $gBitSystem->getPreference( 'approved_html_tags', DEFAULT_ACCEPTABLE_TAGS );
+
+ // Destroy all script code "manually" - strip_tags will leave code inline as plain text
+ if( !preg_match( '/\<script\>/', $acceptableTags ) ) {
+ $text = preg_replace( "/(\<script)(.*?)(script\>)/si", '', $text );
+ }
+
+ $text = strip_tags( $text, $acceptableTags );
+ $text = str_replace("<!--", "&lt;!--", $text);
+ $text = preg_replace("/(\<)(.*?)(--\>)/mi", "".nl2br("\\2")."", $text);
+
+ return( $text );
+}
+
+function bithtml_save_data( &$pParamHash ) {
+ static $parser;
+ if( empty( $parser ) ) {
+ $parser = new TikiWikiParser();
+ }
+ if( $pParamHash['edit'] ) {
+ $parser->storeLinks( $pParamHash );
+ }
+}
+
+function bithtml_parse_data( &$pData, &$pCommonObject ) {
+ parse_data_plugins( $pData, $foo, $bar, $empty );
+ // eventually we should strip tags, maybe tikilink, or other things.
+ return $pData;
+}
+
+?>
diff --git a/plugins/format.tikiwiki.php b/plugins/format.tikiwiki.php
new file mode 100644
index 0000000..9c384e7
--- /dev/null
+++ b/plugins/format.tikiwiki.php
@@ -0,0 +1,1329 @@
+<?php
+global $gLibertySystem;
+
+define( 'PLUGIN_GUID_TIKIWIKI', 'tikiwiki' );
+define( 'WIKI_WORDS_REGEX', '[A-z0-9]{2}[\w\d_\-]+[A-Z_][\w\d_\-]+[A-z0-9]+' );
+
+
+$pluginParams = array ( 'store_function' => 'tikiwiki_save_data',
+ 'load_function' => 'tikiwiki_parse_data',
+ 'verify_function' => 'tikiwiki_verify_data',
+ 'rename_function' => 'tikiwiki_rename',
+ 'expunge_function' => 'tikiwiki_expunge',
+ 'description' => 'TikiWiki Syntax Format Parser',
+ 'edit_label' => 'Tiki Wiki Syntax',
+ 'edit_field' => '<input type="radio" name="format_guid" value="'.PLUGIN_GUID_TIKIWIKI.'"',
+ 'plugin_type' => FORMAT_PLUGIN
+ );
+
+$gLibertySystem->registerPlugin( PLUGIN_GUID_TIKIWIKI, $pluginParams );
+
+function tikiwiki_save_data( &$pParamHash ) {
+ static $parser;
+ if( empty( $parser ) ) {
+ $parser = new TikiWikiParser();
+ }
+ if( $pParamHash['edit'] ) {
+ $parser->storeLinks( $pParamHash );
+ }
+}
+
+function tikiwiki_verify_data( &$pParamHash ) {
+ $errorMsg = NULL;
+
+ // Removed htmlspecialchars conversion as it permantenly modifies the orginal source. calling htmlentities on parse now.
+ $pParamHash['content_store']['data'] = $pParamHash['edit'];
+ return( $errorMsg );
+}
+
+function tikiwiki_expunge( $pContentId ) {
+ $parser = new TikiWikiParser();
+ $parser->expungeLinks( $pContentId );
+}
+
+function tikiwiki_rename( $pContentId, $pOldName, $pNewName, &$pCommonObject ) {
+ $query = "SELECT `from_content_id`, `data`
+ FROM `".BIT_DB_PREFIX."tiki_links` tl
+ INNER JOIN `".BIT_DB_PREFIX."tiki_content` tc ON( tl.`from_content_id`=tc.`content_id` )
+ WHERE `to_content_id` = ?";
+ if( $result = $pCommonObject->query($query, array( $pContentId ) ) ) {
+ while( !$result->EOF ) {
+ $data = preg_replace( '/(\W|\(\()('.$pOldName.')(\W|\)\))/', '\\1'.$pNewName.'\\3', $result->fields['data'] );
+ if( md5( $data ) != md5( $result->fields['data'] ) ) {
+ $query = "UPDATE `".BIT_DB_PREFIX."tiki_content` SET `data`=? WHERE `content_id`=?";
+ $pCommonObject->query($query, array( $data, $result->fields['from_content_id'] ) );
+ }
+ $result->MoveNext();
+ }
+ }
+}
+
+function tikiwiki_parse_data( &$pData, &$pCommonObject ) {
+ static $parser;
+ if( empty( $parser ) ) {
+ $parser = new TikiWikiParser();
+ }
+ return $parser->parse_data( $pData, $pCommonObject );
+}
+
+class TikiWikiParser extends BitBase {
+ var $mWikiWordRegex;
+ var $mUseWikiWords;
+ var $mPageLookup;
+ var $pre_handlers = array();
+ var $pos_handlers = array();
+
+ function TikiWikiParser () {
+ BitBase::BitBase();
+
+ global $gBitSystem;
+ $this->mUseWikiWords = $gBitSystem->getPreference( 'feature_wikiwords' ) == 'y';
+
+ // Setup the WikiWord regex
+ $wiki_page_regex = $gBitSystem->getPreference( 'wiki_page_regex', 'strict' );
+ // Please DO NOT modify any of the brackets in the regex(s).
+ // It may seem redundent but, really, they are ALL REQUIRED.
+ if ($wiki_page_regex == 'strict') {
+ $this->mWikiWordRegex = '([A-Za-z0-9_])([\.: A-Za-z0-9_\-])*([A-Za-z0-9_])';
+ } elseif ($wiki_page_regex == 'full') {
+ $this->mWikiWordRegex = '([A-Za-z0-9_]|[\x80-\xFF])([\.: A-Za-z0-9_\-]|[\x80-\xFF])*([A-Za-z0-9_]|[\x80-\xFF])';
+ } else {
+ // This is just evil. The middle section means "anything, as long
+ // as it's not a | and isn't followed by ))". -rlpowell
+ $this->mWikiWordRegex = '([^|\(\)])([^|](?!\)\)))*?([^|\(\)])';
+ }
+
+ }
+
+
+ function add_pre_handler($name) {
+ if (!in_array($name, $this->pre_handlers)) {
+ $this->pre_handlers[] = $name;
+ }
+ }
+
+ function add_pos_handler($name) {
+ if (!in_array($name, $this->pos_handlers)) {
+ $this->pos_handlers[] = $name;
+ }
+ }
+
+
+ function extractWikiWords( &$data ) {
+ if( $this->mUseWikiWords ) {
+ preg_match_all("/\(\(($this->mWikiWordRegex)\)\)/", $data, $words2);
+ preg_match_all("/\(\(($this->mWikiWordRegex)\|(.+?)\)\)/", $data, $words3);
+ preg_match_all( '/\b('.WIKI_WORDS_REGEX.')\b/', $data, $words );
+ $words = array_unique(array_merge($words[1], $words2[1], $words3[1]));
+ } else {
+ preg_match_all("/\(\(($this->mWikiWordRegex)\)\)/", $data, $words);
+ preg_match_all("/\(\(($this->mWikiWordRegex)\|(.+?)\)\)/", $data, $words2);
+ $words = array_unique(array_merge($words[1], $words2[1]));
+ }
+ return $words;
+ }
+
+
+ function storeLinks( &$pParamHash ) {
+ if( !empty( $pParamHash['content_id'] ) ) {
+ $query = "DELETE FROM `".BIT_DB_PREFIX."tiki_links` WHERE `from_content_id`=?";
+ $result = $this->query( $query, array( $pParamHash['content_id'] ) );
+
+ $linkPages = $this->extractWikiWords( $pParamHash['edit'] );
+ if( is_array( $linkPages ) && count( $linkPages ) ) {
+ foreach( $linkPages as $page ) {
+ if( !empty( $page ) ) {
+// SPIDERFKILL - this query is guaranteed to die - i forget where it came from and why it's here. will debug soon enough...
+ $query = "SELECT tp.`content_id` FROM `".BIT_DB_PREFIX."tiki_pages` tp INNER JOIN `".BIT_DB_PREFIX."tiki_content` tc ON (tc.`content_id` = tp.`content_id`) WHERE tc.`title`=?";
+ $result = $this->query( $query, array( $page ) );
+ if( $result->numRows() ) {
+ $res = $result->fetchRow();
+ $query = "insert into `".BIT_DB_PREFIX."tiki_links`(`from_content_id`,`to_content_id`) values(?, ?)";
+ $result = $this->query($query, array( $pParamHash['content_id'], $res['content_id'] ) );
+ }
+ }
+ }
+ }
+ }
+ }
+
+ function expungeLinks( $pContentId ) {
+ if( !empty( $pContentId ) ) {
+ $this->mDb->StartTrans();
+ $this->query( "DELETE FROM `".BIT_DB_PREFIX."tiki_links` WHERE from_content_id=? OR to_content_id=?", array( $pContentId, $pContentId ) );
+ $this->mDb->CompleteTrans();
+ }
+ }
+
+ // Use tiki_links to get all the existing links in a single query
+ function pageExists( $pTitle, $pContentId, $pCommonObject ) {
+ $pTitle = strtolower( $pTitle );
+ if( !empty( $pContentId ) ) {
+ if( empty( $this->mPageLookup ) ) {
+ $query = "SELECT LOWER( tc.`title` ) AS `hash_key`, `page_id`, tc.`content_id`, `description`, tc.`last_modified`, tc.`title`
+ FROM `".BIT_DB_PREFIX."tiki_links` tl
+ INNER JOIN `".BIT_DB_PREFIX."tiki_content` tc ON( tl.`to_content_id`=tc.`content_id` )
+ INNER JOIN `".BIT_DB_PREFIX."tiki_pages` tp ON( tp.`content_id`=tc.`content_id` )
+ WHERE tl.`from_content_id`=? ORDER BY tc.`title`";
+ if( $result = $this->query( $query, array( $pContentId ) ) ) {
+ $lastTitle = '';
+ while( !$result->EOF ) {
+ if( $result->fields['title'] == $lastTitle ) {
+// TODO - need to check ensure that tiki_links duplicate are properly inserted - spiderr
+ }
+ $this->mPageLookup[$result->fields['hash_key']][] = $result->fields;
+ $lastTitle = $result->fields['title'];
+ $result->MoveNext();
+ }
+ }
+ }
+ if( !isset( $this->mPageLookup[$pTitle] ) ) {
+ $this->mPageLookup[$pTitle] = $pCommonObject->pageExists( $pTitle );
+ if( !empty( $this->mPageLookup[$pTitle] ) && ( count( $this->mPageLookup[$pTitle] ) == 1 ) ) {
+// $this->query( "INSERT INTO `".BIT_DB_PREFIX."tiki_links` ( `from_content_id`, `to_content_id` ) VALUES ( ?, ? )" , array( $pContentId, $this->mPageLookup[$pTitle][0]['content_id'] ) );
+ }
+ }
+ }
+$this->debug(0);
+ return( !empty( $this->mPageLookup[$pTitle] ) ? $this->mPageLookup[$pTitle] : NULL );
+ }
+
+ function parse_data_raw($data) {
+ $data = $this->parseData($data);
+
+ $data = str_replace( WIKI_PKG_URL."index", WIKI_PKG_URL."index_raw", $data );
+ return $data;
+ }
+
+
+ // This recursive function handles pre- and no-parse sections and plugins
+ function parse_first(&$data, &$preparsed, &$noparsed) {
+ global $gLibertySystem;
+ // Handle pre- and no-parse sections
+ parse_data_plugins( $data, $preparsed, $noparsed, $this );
+ $this->parse_pp_np($data, $preparsed, $noparsed);
+ }
+
+
+ // AWC ADDITION
+ // This function replaces pre- and no-parsed sections with unique keys
+ // and saves the section contents for later reinsertion.
+ function parse_pp_np(&$data, &$preparsed, &$noparsed) {
+ // Find all sections delimited by ~pp~ ... ~/pp~
+ // and replace them in the data stream with a unique key
+ preg_match_all("/\~pp\~((.|\n)*?)\~\/pp\~/", $data, $preparse);
+ if( count( $preparse[0] ) ) {
+ foreach (array_unique($preparse[1])as $pp) {
+ $key = md5(BitSystem::genPass());
+
+ $aux["key"] = $key;
+ $aux["data"] = $pp;
+ $preparsed[] = $aux;
+ $data = str_replace("~pp~$pp~/pp~", $key, $data);
+ }
+
+ // Temporary remove <pre> tags too
+ // TODO: Is this a problem if user insert <PRE> but after parsing
+ // will get <pre> (lowercase)?? :)
+ preg_match_all("/(<[Pp][Rr][Ee]>)((.|\n)*?)(<\/[Pp][Rr][Ee]>)/", $data, $preparse);
+ $idx = 0;
+
+ foreach (array_unique($preparse[2])as $pp) {
+ $key = md5(BitSystem::genPass());
+
+ $aux["key"] = $key;
+ $aux["data"] = $pp;
+ $preparsed[] = $aux;
+ $data = str_replace($preparse[1][$idx] . $pp . $preparse[4][$idx], $key, $data);
+ $idx = $idx + 1;
+ }
+ }
+
+ if( preg_match("/\~np\~((.|\n)*?)\~\/np\~/", $data, $preparse) ) {
+ // Find all sections delimited by ~np~ ... ~/np~
+ $new_data = '';
+ $nopa = '';
+ $state = true;
+ $skip = false;
+
+ $dlength=strlen($data);
+ for ($i = 0; $i < $dlength; $i++) {
+ $tag5 = substr($data, $i, 5);
+ $tag4 = substr($tag5, 0, 4);
+ $tag1 = substr($tag4, 0, 1);
+
+ // Beginning of a noparse section found
+ if ($state && $tag4 == '~np~') {
+ $i += 3;
+ $state = false;
+ $skip = true;
+ }
+
+ // Termination of a noparse section found
+ if (!$state && ($tag5 == '~/np~')) {
+ $state = true;
+ $i += 4;
+ $skip = true;
+ $key = md5(BitSystem::genPass());
+ $new_data .= $key;
+ $aux["key"] = $key;
+ $aux["data"] = $nopa;
+ $noparsed[] = $aux;
+ $nopa = '';
+ }
+
+ if (!$skip) { // This character is not part of a noparse tag
+ if ($state) { // This character is not within a noparse section
+ $new_data .= $tag1;
+ } else { // This character is within a noparse section
+ $nopa .= $tag1;
+ }
+ } else { // Tag is now skipped over
+ $skip = false;
+ }
+ }
+ $data = $new_data;
+ }
+ }
+
+
+ // This function handles wiki codes for those special HTML characters
+ // that textarea won't leave alone.
+ function parse_htmlchar(&$data) {
+ // cleaning some user input
+ $data = preg_replace("/&(?!([a-z]{1,7};))/", "&amp;", $data);
+
+ // oft-used characters (case insensitive)
+ $data = preg_replace("/~bs~/i", "&#92;", $data);
+ $data = preg_replace("/~hs~/i", "&nbsp;", $data);
+ $data = preg_replace("/~amp~/i", "&amp;", $data);
+ $data = preg_replace("/~ldq~/i", "&ldquo;", $data);
+ $data = preg_replace("/~rdq~/i", "&rdquo;", $data);
+ $data = preg_replace("/~lsq~/i", "&lsquo;", $data);
+ $data = preg_replace("/~rsq~/i", "&rsquo;", $data);
+ $data = preg_replace("/~c~/i", "&copy;", $data);
+ $data = preg_replace("/~--~/", "&mdash;", $data);
+ $data = preg_replace("/ -- /", " &mdash; ", $data);
+ $data = preg_replace("/~lt~/i", "&lt;", $data);
+ $data = preg_replace("/~gt~/i", "&gt;", $data);
+
+ // HTML numeric character entities
+ $data = preg_replace("/~([0-9]+)~/", "&#$1;", $data);
+ }
+
+
+ function parse_smileys($data) {
+ global $gBitSystem;
+ if( defined("SMILEYS_PKG_URL") && $gBitSystem->getPreference('package_smileys') == 'y' ) {
+ $data = preg_replace("/\(:([^:]+):\)/", "<img alt=\"$1\" class=\"icon\" src=\"".SMILEYS_PKG_URL."icons/$1.gif\" />", $data);
+// TODO - biticon can't work cause this is post smarty parse $data = preg_replace("/\(:([^:]+):\)/", "{biticon ipackage=\"smileys\" iname=\"$1\" iexplain=\"{tr}$1{/tr}", $data);
+ }
+
+ return $data;
+ }
+
+ function parse_comment_data($data) {
+ // rel=\"nofollow\" is support fo Google's Preventing comment spam
+ // http://www.google.com/googleblog/2005/01/preventing-comment-spam.html
+ $data = preg_replace("/\[([^\|\]]+)\|([^\]]+)\]/", "<a rel=\"nofollow\" class=\"commentslink\" href=\"$1\">$2</a>", $data);
+
+ // Segundo intento reemplazar los [link] comunes
+ $data = preg_replace("/\[([^\]\|]+)\]/", "<a rel=\"nofollow\" class=\"commentslink\" href=\"$1\">$1</a>", $data);
+ // Llamar aqui a parse smileys
+ $data = $this->parse_smileys($data);
+ $data = preg_replace("/---/", "<hr/>", $data);
+ // Reemplazar --- por <hr/>
+ return $data;
+ }
+
+ function get_language($user = false) {
+ static $tikiLanguage = false;
+ global $gBitUser, $gBitSystem;
+
+ if( empty( $tikiLanguage ) ) {
+ if( $gBitUser->isValid() ) {
+ $tikiLanguage = $gBitUser->getPreference('tikiLanguage', 'en');
+ } else {
+ $tikiLanguage = $this->getPreference('tikiLanguage', 'en');
+ }
+ }
+
+ return $tikiLanguage;
+ }
+
+ function get_locale($user = false) {
+ # TODO move to admin preferences screen
+ static $locales = array(
+ 'cs' => 'cs_CZ',
+ 'de' => 'de_DE',
+ 'dk' => 'da_DK',
+ 'en' => 'en_US',
+ 'fr' => 'fr_FR',
+ 'he' => 'he_IL', # hebrew
+ 'it' => 'it_IT', # italian
+ 'pl' => 'pl_PL', # polish
+ 'po' => 'po',
+ 'ru' => 'ru_RU',
+ 'es' => 'es_ES',
+ 'sw' => 'sw_SW', # swahili
+ 'tw' => 'tw_TW',
+ );
+
+ if (!isset($locale) or !$locale) {
+ $locale = '';
+ if (isset($locales[$this->get_language($user)]))
+ $locale = $locales[$this->get_language($user)];
+ #print "<pre>get_locale(): locale=$locale\n</pre>";
+ }
+
+ return $locale;
+ }
+
+ function get_links($data) {
+ $links = array();
+
+ // Match things like [...], but ignore things like [[foo].
+ // -Robin
+ if (preg_match_all("/(?<!\[)\[([^\[\|\]]+)(\||\])/", $data, $r1)) {
+ $res = $r1[1];
+ $links = array_unique($res);
+ }
+
+ return $links;
+ }
+
+ function get_links_nocache($data) {
+ $links = array();
+
+ if (preg_match_all("/\[([^\]]+)/", $data, $r1)) {
+ $res = array();
+
+ foreach ($r1[1] as $alink) {
+ $parts = explode('|', $alink);
+
+ if (isset($parts[1]) && $parts[1] == 'nocache') {
+ $res[] = $parts[0];
+ } else {
+ if (isset($parts[2]) && $parts[2] == 'nocache') {
+ $res[] = $parts[0];
+ }
+ }
+ // avoid caching URLs with common binary file extensions
+ $extension = substr($parts[0], -4);
+ $binary = array(
+ '.arj',
+ '.asf',
+ '.avi',
+ '.bz2',
+ '.dat',
+ '.doc',
+ '.exe',
+ '.hqx',
+ '.mov',
+ '.mp3',
+ '.mpg',
+ '.ogg',
+ '.pdf',
+ '.ram',
+ '.rar',
+ '.rpm',
+ '.rtf',
+ '.sea',
+ '.sit',
+ '.tar',
+ '.tgz',
+ '.wav',
+ '.wmv',
+ '.xls',
+ '.zip',
+ 'ar.Z', // .tar.Z
+ 'r.gz' // .tar.gz
+ );
+ if (in_array($extension, $binary)) {
+ $res[] = $parts[0];
+ }
+
+ }
+
+ $links = array_unique($res);
+ }
+
+ return $links;
+ }
+
+ function cache_links($links, &$pCommonObject ) {
+ global $gBitSystem;
+ if( $gBitSystem->isFeatureActive( 'cachepages' ) ) {
+ foreach ($links as $link) {
+ if( !$pCommonObject->isCached( $link ) ) {
+ $pCommonObject->cacheUrl($link);
+ }
+ }
+ }
+ }
+
+
+ function how_many_at_start($str, $car) {
+ $cant = 0;
+ $i = 0;
+ while (($i < strlen($str)) && (isset($str{$i})) && ($str{$i}== $car)) {
+ $i++;
+ $cant++;
+ }
+ return $cant;
+ }
+
+
+ function parse_data( $data, &$pCommonObject ) {
+ global $gBitSystem;
+ global $gBitUser;
+ global $slidemode;
+ global $cachepages;
+ global $ownurl_father;
+ global $page;
+ global $gStructure;
+ global $rsslib;
+ global $structlib;
+ global $user;
+ global $bitdomain;
+ global $wikilib;
+ if( empty( $wikilib ) ) {
+ require_once( WIKI_PKG_PATH.'BitPage.php' );
+ global $wikilib;
+ }
+
+ // convert HTML to chars
+ $data = htmlspecialchars( $data, ENT_NOQUOTES, 'UTF-8' );
+
+ // Process pre_handlers here
+ foreach ($this->pre_handlers as $handler) {
+ $data = $handler($data);
+ }
+
+ $data = preg_replace( '/(\)\))('.WIKI_WORDS_REGEX.')(\(\()/', "~np~" . "$2" . "~/np~", $data);
+
+ // Handle pre- and no-parse sections and plugins
+ $preparsed = array();
+ $noparsed = array();
+ $this->parse_first($data, $preparsed, $noparsed);
+
+ // Extract [link] sections (to be re-inserted later)
+ $noparsedlinks = array();
+
+ // This section matches [...].
+ // Added handling for [[foo] sections. -rlpowell
+ preg_match_all("/(?<!\[)\[([^\[][^\]]+)\]/", $data, $noparseurl);
+
+ foreach (array_unique($noparseurl[1])as $np) {
+ $key = md5(BitSystem::genPass());
+
+ $aux["key"] = $key;
+ $aux["data"] = $np;
+ $noparsedlinks[] = $aux;
+ $data = str_replace("$np", $key, $data);
+ }
+
+ // Replace special characters
+ //done after url catching because otherwise urls of dyn. sites will be modified
+ $this->parse_htmlchar($data);
+
+ //$data = strip_tags($data);
+ // BiDi markers
+ $bidiCount = 0;
+ $bidiCount = preg_match_all("/(\{l2r\})/", $data, $pages);
+ $bidiCount += preg_match_all("/(\{r2l\})/", $data, $pages);
+
+ $data = preg_replace("/\{l2r\}/", "<div dir='ltr'>", $data);
+ $data = preg_replace("/\{r2l\}/", "<div dir='rtl'>", $data);
+ $data = preg_replace("/\{lm\}/", "&lrm;", $data);
+ $data = preg_replace("/\{rm\}/", "&rlm;", $data);
+ // smileys
+ $data = $this->parse_smileys($data);
+
+ // Replace links to slideshows
+ if ($gBitSystem->getPreference('feature_drawings') == 'y') {
+ // Replace drawings
+ // Replace rss modules
+ $pars = parse_url($_SERVER["REQUEST_URI"]);
+
+ $pars_parts = split('/', $pars["path"]);
+ $pars = array();
+
+ for ($i = 0; $i < count($pars_parts) - 1; $i++) {
+ $pars[] = $pars_parts[$i];
+ }
+
+ $pars = join('/', $pars);
+
+ if (preg_match_all("/\{draw +name=([A-Za-z_\-0-9]+) *\}/", $data, $draws)) {
+ //$this->invalidate_cache($page);
+ for ($i = 0; $i < count($draws[0]); $i++) {
+ $id = $draws[1][$i];
+
+ $repl = '';
+ $name = $id . '.gif';
+
+ if (file_exists("img/wiki/$bitdomain$name")) {
+ if ($gBitUser->hasPermission( 'bit_p_edit_drawings' ) || $gBitUser->hasPermission( 'bit_p_admin_drawings' )) {
+ $repl = "<a href='#' onClick=\"javascript:window.open('".DRAWINGS_PKG_URL."edit.php?page=" . urlencode($page). "&amp;path=$pars&amp;drawing={$id}','','menubar=no,width=252,height=25');\"><img border='0' src='img/wiki/$bitdomain$name' alt='click to edit' /></a>";
+ } else {
+ $repl = "<img border='0' src='img/wiki/$bitdomain$name' alt='a drawing' />";
+ }
+ } else {
+ if ($gBitUser->hasPermission( 'bit_p_edit_drawings' ) || $gBitUser->hasPermission( 'bit_p_admin_drawings' )) {
+ $repl = "<a href='".DRAWINGS_PKG_URL."edit.php?page=" . urlencode($page). "&amp;path=$pars&amp;drawing={$id}' onkeypress='popUpWin(this.href,'fullScreen',0,0);' onclick='popUpWin(this.href,'fullScreen',0,0);return false;','','menubar=no,width=252,height=25');\">click here to create draw $id</a>";
+ } else {
+ $repl = tra('drawing not found');
+ }
+ }
+ $data = str_replace($draws[0][$i], $repl, $data);
+ }
+ }
+ }
+
+ // Replace cookies
+ if (preg_match_all("/\{cookie\}/", $data, $rsss)) {
+ require_once( KERNEL_PKG_PATH.'tagline_lib.php' );
+ global $taglinelib;
+ for ($i = 0; $i < count($rsss[0]); $i++) {
+ $cookie = $taglinelib->pick_cookie();
+ $data = str_replace($rsss[0][$i], $cookie, $data);
+ }
+ }
+
+ // Replace dynamic variables
+ // Dynamic variables are similar to dynamic content but they are editable
+ // from the page directly, intended for short data, not long text but text
+ // will work too
+ // Now won't match HTML-style '%nn' letter codes.
+ if (preg_match_all("/%([^% 0-9][^% 0-9][^% ]*)%/",$data,$dvars)) {
+ // remove repeated elements
+ $dvars = array_unique($dvars[1]);
+ // Now replace each dynamic variable by a pair composed of the
+ // variable value and a text field to edit the variable. Each
+ foreach($dvars as $dvar) {
+ $query = "select `data` from `".BIT_DB_PREFIX."tiki_dynamic_variables` where `name`=?";
+ $result = $this->query($query,Array($dvar));
+ if($result->numRows()) {
+ $value = $result->fetchRow();
+ $value = $value["data"];
+ } else {
+ //Default value is NULL
+ $value = "NaV";
+ }
+ // Now build 2 divs
+ $id = 'dyn_'.$dvar;
+
+ if( $gBitUser->hasPermission( 'bit_p_edit_dynvar' ) ) {
+ $span1 = "<span style='display:inline;' id='dyn_".$dvar."_display'><a class='dynavar' onClick='javascript:toggle_dynamic_var(\"$dvar\");' title='".tra('Click to edit dynamic variable').": $dvar'>$value</a></span>";
+ $span2 = "<span style='display:none;' id='dyn_".$dvar."_edit'><input type='text' name='dyn_".$dvar."' value='".$value."' /></span>";
+ } else {
+ $span1 = "<span class='dynavar' style='display:inline;' id='dyn_".$dvar."_display'>$value</span>";
+ $span2 = '';
+ }
+ $html = $span1.$span2;
+ //It's important to replace only once
+ $dvar_preg = preg_quote( $dvar );
+ $data = preg_replace("+%$dvar_preg%+",$html,$data,1);
+ //Further replacements only with the value
+ $data = str_replace("%$dvar%",$value,$data);
+
+ }
+ //At the end put an update button
+ //<br /><div style="text-align:center"><input type="submit" name="dyn_update" value="'.tra('Update variables').'"/></div>
+ $data='<form method="post" name="dyn_vars">'.$data.'<div style="display:none;"><input type="submit" name="_dyn_update" value="'.tra('Update variables').'"/></div></form>';
+ }
+
+ // Replace dynamic content occurrences
+ if (preg_match_all("/\{content +id=([0-9]+)\}/", $data, $dcs)) {
+ for ($i = 0; $i < count($dcs[0]); $i++) {
+ $repl = $this->get_actual_content($dcs[1][$i]);
+
+ $data = str_replace($dcs[0][$i], $repl, $data);
+ }
+ }
+
+ // Replace Dynamic content with random selection
+ if (preg_match_all("/\{rcontent +id=([0-9]+)\}/", $data, $dcs)) {
+ for ($i = 0; $i < count($dcs[0]); $i++) {
+ $repl = $this->get_random_content($dcs[1][$i]);
+
+ $data = str_replace($dcs[0][$i], $repl, $data);
+ }
+ }
+
+ // Replace boxes
+ $data = preg_replace("/\^([^\^]+)\^/", "<div class=\"tikibox\">$1</div>", $data);
+ // Replace colors ~~color:text~~
+ $data = preg_replace("/\~\~([^\:]+):([^\~]+)\~\~/", "<span style=\"color:$1;\">$2</span>", $data);
+ // Replace background colors ++color:text++
+ $data = preg_replace("/\+\+([^\:]+):([^\+]+)\+\+/", "<span style=\"background:$1;\">$2</span>", $data);
+ // Underlined text
+ $data = preg_replace("/===([^\=]+)===/", "<span style=\"text-decoration:underline;\">$1</span>", $data);
+ // Center text
+ $data = preg_replace("/::(.+?)::/", "<div style=\"text-align:center;\">$1</div>", $data);
+
+ // New syntax for wiki pages ((name|desc)) Where desc can be anything
+ preg_match_all("/\(\(($this->mWikiWordRegex)\|(.+?)\)\)/", $data, $pages);
+
+ for ($i = 0; $i < count($pages[1]); $i++) {
+ $pattern = $pages[0][$i];
+
+ $pattern = preg_quote($pattern, "/");
+
+ $pattern = "/" . $pattern . "/";
+
+ // Replace links to external wikis
+ $repl2 = true;
+
+ if (strstr($pages[1][$i], ':')) {
+ $wexs = explode(':', $pages[1][$i]);
+
+ if (count($wexs) == 2) {
+ $wkname = $wexs[0];
+
+ if ($this->getOne("select count(*) from `".BIT_DB_PREFIX."tiki_extwiki` where `name`=?",array($wkname)) == 1) {
+ $wkurl = $this->getOne("select `extwiki` from `".BIT_DB_PREFIX."tiki_extwiki` where `name`=?",array($wkname));
+ $wkurl = '<a href="' . str_replace('$page', urlencode($wexs[1]), $wkurl). '">' . $wexs[1] . '</a>';
+ $data = preg_replace($pattern, "$wkurl", $data);
+ $repl2 = false;
+ }
+ }
+ }
+
+ if ($repl2) {
+ // 24-Jun-2003, by zaufi
+ // TODO: future optimize: get page description and modification time at once.
+
+ // text[0] = link description (previous format)
+ // text[1] = timeout in seconds (new field)
+ // text[2..N] = drop
+ $text = explode("|", $pages[5][$i]);
+
+ if( $exists = $this->pageExists( $pages[1][$i], $pCommonObject->mContentId, $pCommonObject ) ) {
+ $desc = count( $exists ) == 1 ? (isset( $exists['description'] ) ? $exists['description'] : '') : tra( 'multiple pages with this name' );
+ $modTime = count( $exists ) == 1 ? (isset( $exists['last_modified'] ) ? (int)$exists['last_modified'] : 0 ) : 0;
+ $uri_ref = WIKI_PKG_URL."index.php?page=" . urlencode($pages[1][$i]);
+
+ $repl = '<a title="'.$desc.'" href="'.$uri_ref.'">'.( (strlen(trim($text[0])) > 0 ? $text[0] : $pages[1][$i]) ).'</a>';
+
+ // Check is timeout expired?
+ if (isset($text[1]) && (time() - $modTime ) < intval($text[1])) {
+ // Append small 'new' image. TODO: possible 'updated' image more suitable...
+ $repl .= '&nbsp;<img src="img/icons/new.gif" border="0" alt="'.tra("new").'" />';
+ }
+ } else {
+ $uri_ref = WIKI_PKG_URL."edit.php?page=" . urlencode($pages[1][$i]);
+ $repl = ' <a class="create" href="'.$uri_ref.'">'.( (strlen(trim($text[0])) > 0 ? $text[0] : $pages[1][$i]) ).'</a>';
+ }
+
+ $data = preg_replace($pattern, "$repl", $data);
+ }
+ }
+
+ // New syntax for wiki pages ((name)) Where name can be anything
+ preg_match_all("/\(\(([^\)][^\)]+)\)\)/", $data, $pages);
+
+ foreach (array_unique($pages[1])as $page_parse) {
+ $repl2 = true;
+
+ if (strstr($page_parse, ':')) {
+ $wexs = explode(':', $page_parse);
+
+ if (count($wexs) == 2) {
+ $wkname = $wexs[0];
+
+ if ($this->getOne("select count(*) from `".BIT_DB_PREFIX."tiki_extwiki` where `name`=?",array($wkname)) == 1) {
+ $wkurl = $this->getOne("select `extwiki` from `".BIT_DB_PREFIX."tiki_extwiki` where `name`=?",array($wkname));
+
+ $wkurl = '<a href="' . str_replace('$page', urlencode($wexs[1]), $wkurl). '">' . $wexs[1] . '</a>';
+ $data = preg_replace("/\(\($page_parse\)\)/", "$wkurl", $data);
+ $repl2 = false;
+ }
+ }
+ }
+
+ if ($repl2) {
+ // This is a hack for now. page_exists_desc should not be needed here sicne blogs and articles use this function
+
+ $exists = $this->pageExists( $page_parse, $pCommonObject->mContentId, $pCommonObject );
+ $repl = BitPage::getDisplayLink( $page_parse, $exists );
+ $page_parse_pq = preg_quote($page_parse, "/");
+ $data = preg_replace("/\(\($page_parse_pq\)\)/", "$repl", $data);
+ }
+ }
+
+ if ($gBitSystem->isPackageActive( 'hotwords' ) ) {
+ if( empty( $hotwordlib ) ) {
+ include_once(HOTWORDS_PKG_PATH."hotword_lib.php");
+ global $hotwordlib;
+ $words = $hotwordlib->get_hotwords();
+ }
+ }
+
+ // Links to internal pages
+ // If they are parenthesized then don't treat as links
+ // Prevent ))PageName(( from being expanded \"\'
+ //[A-Z][a-z0-9_\-]+[A-Z][a-z0-9_\-]+[A-Za-z0-9\-_]*
+ if ($gBitSystem->getPreference('feature_wikiwords') == 'y') {
+ // The first part is now mandatory to prevent [Foo|MyPage] from being converted!
+ // the {2} is curious but seems to prevent things like "__Administration / Modules__" getting linked - spiderr
+ $pages = $this->extractWikiWords( $data );
+ foreach( $pages as $page_parse) {
+ if( empty( $words ) || !array_key_exists( $page_parse, $words ) ) {
+ if( $exists = $this->pageExists( $page_parse, $pCommonObject->mContentId, $pCommonObject ) ) {
+ $desc = count( $exists ) == 1 ? (isset( $exists['description'] ) ? $exists['description'] : '') : tra( 'multiple pages with this name' );
+ // call statically since $pCommonObject might be something like BitUser
+ $repl = BitPage::getDisplayLink( $page_parse, $exists );
+ } elseif( $gBitSystem->getPreference('feature_wiki_plurals') == 'y' && $this->get_locale() == 'en_US') {
+ // Link plural topic names to singular topic names if the plural
+ // doesn't exist, and the language is english
+ $plural_tmp = $page_parse;
+ // Plurals like policy / policies
+ $plural_tmp = preg_replace("/ies$/", "y", $plural_tmp);
+ // Plurals like address / addresses
+ $plural_tmp = preg_replace("/sses$/", "ss", $plural_tmp);
+ // Plurals like box / boxes
+ $plural_tmp = preg_replace("/([Xx])es$/", "$1", $plural_tmp);
+ // Others, excluding ending ss like address(es)
+ $plural_tmp = preg_replace("/([A-Za-rt-z])s$/", "$1", $plural_tmp);
+ // prevent redundant pageExists calls if plurals are on, and plural is same as original word
+ $exists = ( $plural_tmp != $page_parse ) ? $this->pageExists( $plural_tmp, $pCommonObject->mContentId, $pCommonObject ) : NULL;
+ $repl = BitPage::getDisplayLink( $page_parse, $exists );
+ } else {
+ $repl = BitPage::getDisplayLink( $page_parse, $exists );
+ }
+ $slashedParse = preg_replace( "/([\/\[\]\(\)])/", "\\\\$1", $page_parse );
+ $data = preg_replace("/([ \n\t\r\,\;]|^)".$slashedParse."($|[ \n\t\r\,\;\.])/", "$1"."$repl"."$2", $data);
+ //$data = str_replace($page_parse,$repl,$data);
+ }
+ }
+ }
+ // This protects ))word((, I think?
+ $data = preg_replace("/([ \n\t\r\,\;]|^)\)\)([^\(]+)\(\(($|[ \n\t\r\,\;\.])/", "$1" . "$2" . "$3", $data);
+
+ // reinsert hash-replaced links into page
+ foreach ($noparsedlinks as $np) {
+ $data = str_replace($np["key"], $np["data"], $data);
+ }
+
+ // TODO: I think this is 1. just wrong and 2. not needed here? remove it?
+ // Replace ))Words((
+ $data = preg_replace("/\(\(([^\)]+)\)\)/", "$1", $data);
+
+ // Images
+ preg_match_all("/(\{img [^\}]+})/i", $data, $pages);
+
+ foreach (array_unique($pages[1])as $page_parse) {
+ $parts = explode(" ", $page_parse);
+
+ $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);
+
+ if (strstr($part, '=')) {
+ $subs = explode("=", $part, 2);
+
+ $imgdata[$subs[0]] = $subs[1];
+ }
+ }
+
+ //print("todo el tag es: ".$page_parse."<br/>");
+ //print_r($imgdata);
+ $repl = '<img alt="' . tra('Image') . '" src="'.$imgdata["src"].'" style="border:0;" ';
+
+ if ($imgdata["width"])
+ $repl .= ' width="' . $imgdata["width"] . '"';
+
+ if ($imgdata["height"])
+ $repl .= ' height="' . $imgdata["height"] . '"';
+
+ if ($imgdata["align"]) {
+ $repl .= ' align="' . $imgdata["align"] . '"';
+ }
+
+ if ($imgdata["float"]) {
+ $repl .= ' style="float:' . $imgdata["float"] . ';"';
+ }
+
+ $repl .= ' />';
+
+ if ($imgdata["link"]) {
+ $repl = '<a href="' . $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>';
+ }
+
+
+ $data = str_replace($page_parse, $repl, $data);
+ }
+
+ $links = $this->get_links($data);
+
+ $notcachedlinks = $this->get_links_nocache($data);
+
+ $cachedlinks = array_diff($links, $notcachedlinks);
+
+ $this->cache_links($cachedlinks,$pCommonObject);
+
+ // Note that there're links that are replaced
+ foreach ($links as $link) {
+ if ((strstr($link, $_SERVER["SERVER_NAME"])) || (!strstr($link, '//'))) {
+ $class = '';
+ } else {
+ $class = 'class="external"';
+ }
+
+ // comments and anonymously created pages get nofollow
+ if( get_class( $pCommonObject ) == 'comments' || ( isset( $pCommonObject->mInfo['user_id'] ) && $pCommonObject->mInfo['user_id'] == ANONYMOUS_USER_ID ) ) {
+ $class .= ' rel="nofollow" ';
+ }
+
+ // The (?<!\[) stuff below is to give users an easy way to
+ // enter square brackets in their output; things like [[foo]
+ // get rendered as [foo]. -rlpowell
+
+ if( $gBitSystem->isFeatureActive( 'cachepages') && $pCommonObject->isCached( $link ) ) {
+ //use of urlencode for using cached versions of dynamic sites
+ $cosa = "<a class=\"tikicache\" href=\"".KERNEL_PKG_URL."view_cache.php?url=".urlencode($link)."\">(cache)</a>";
+
+ //$link2 = str_replace("/","\/",$link);
+ //$link2 = str_replace("?","\?",$link2);
+ //$link2 = str_replace("&","\&",$link2);
+ $link2 = str_replace("/", "\/", preg_quote($link));
+ $pattern = "/(?<!\[)\[$link2\|([^\]\|]+)\|([^\]]+)\]/";
+ $data = preg_replace($pattern, "<a $class href='$link'>$1</a>", $data);
+ $pattern = "/(?<!\[)\[$link2\|([^\]\|]+)\]/";
+ $data = preg_replace($pattern, "<a $class href='$link'>$1</a> $cosa", $data);
+ $pattern = "/(?<!\[)\[$link2\]/";
+ $data = preg_replace($pattern, "<a $class href='$link'>$link</a> $cosa", $data);
+ } else {
+ //$link2 = str_replace("/","\/",$link);
+ //$link2 = str_replace("?","\?",$link2);
+ //$link2 = str_replace("&","\&",$link2);
+ $link2 = str_replace("/", "\/", preg_quote($link));
+
+ $pattern = "/(?<!\[)\[$link2\|([^\]\|]+)([^\]])*\]/";
+ $data = preg_replace($pattern, "<a $class href='$link'>$1</a>", $data);
+ $pattern = "/(?<!\[)\[$link2\]/";
+ $data = preg_replace($pattern, "<a $class href='$link'>$link</a>", $data);
+ }
+ }
+
+ // Handle double square brackets. -rlpowell
+ $data = str_replace( "[[", "[", $data );
+
+ if ($gBitSystem->getPreference('feature_wiki_tables') != 'new') {
+ // New syntax for tables
+ if (preg_match_all("/\|\|(.*)\|\|/", $data, $tables)) {
+ $maxcols = 1;
+
+ $cols = array();
+
+ for ($i = 0; $i < count($tables[0]); $i++) {
+ $rows = explode('||', $tables[0][$i]);
+
+ $col[$i] = array();
+
+ for ($j = 0; $j < count($rows); $j++) {
+ $cols[$i][$j] = explode('|', $rows[$j]);
+
+ if (count($cols[$i][$j]) > $maxcols)
+ $maxcols = count($cols[$i][$j]);
+ }
+ }
+
+ for ($i = 0; $i < count($tables[0]); $i++) {
+ $repl = '<table class="tikitable">';
+
+ for ($j = 0; $j < count($cols[$i]); $j++) {
+ $ncols = count($cols[$i][$j]);
+
+ if ($ncols == 1 && !$cols[$i][$j][0])
+ continue;
+
+ $repl .= '<tr>';
+
+ for ($k = 0; $k < $ncols; $k++) {
+ $repl .= '<td ';
+
+ if ($k == $ncols - 1 && $ncols < $maxcols)
+ $repl .= ' colspan="' . ($maxcols - $k).'"';
+
+ $repl .= '>' . $cols[$i][$j][$k] . '</td>';
+ }
+
+ $repl .= '</tr>';
+ }
+
+ $repl .= '</table>';
+ $data = str_replace($tables[0][$i], $repl, $data);
+ }
+ }
+ } else {
+ // New syntax for tables
+ // REWRITE THIS CODE
+ if (preg_match_all("/\|\|(.*?)\|\|/s", $data, $tables)) {
+ $maxcols = 1;
+
+ $cols = array();
+
+ for ($i = 0; $i < count($tables[0]); $i++) {
+ $rows = split("\n|\<br\/\>", $tables[0][$i]);
+ $col[$i] = array();
+
+ for ($j = 0; $j < count($rows); $j++) {
+ $rows[$j] = str_replace('||', '', $rows[$j]);
+ $cols[$i][$j] = explode('|', $rows[$j]);
+ if (count($cols[$i][$j]) > $maxcols)
+ $maxcols = count($cols[$i][$j]);
+ }
+ }
+
+ for ($i = 0; $i < count($tables[0]); $i++) {
+ $repl = '<table class="tikitable">';
+
+ for ($j = 0; $j < count($cols[$i]); $j++) {
+ $ncols = count($cols[$i][$j]);
+
+ if ($ncols == 1 && !$cols[$i][$j][0])
+ continue;
+
+ $repl .= '<tr>';
+
+ for ($k = 0; $k < $ncols; $k++) {
+ $repl .= '<td ';
+
+ if ($k == $ncols - 1 && $ncols < $maxcols)
+ $repl .= ' colspan="' . ($maxcols - $k).'"';
+
+ $repl .= '>' . $cols[$i][$j][$k] . '</td>';
+ }
+
+ $repl .= '</tr>';
+ }
+
+ $repl .= '</table>';
+ $data = str_replace($tables[0][$i], $repl, $data);
+ }
+ }
+ }
+
+ // change back any end of lines that were temporarily removed in parse_data_plugins
+ $data = preg_replace( "/#EOL/", "\n", $data );
+
+ // 08-Jul-2003, by zaufi
+ // HotWords will be replace only in ordinal text
+ // It looks __realy__ goofy in Headers or Titles
+
+ // Get list of HotWords
+ if ( isset($hotwordlib) ) {
+ $words = $hotwordlib->get_hotwords();
+ } else {
+ $words = '';
+ }
+ // Now tokenize the expression and process the tokens
+ // Use tab and newline as tokenizing characters as well ////
+ $lines = explode("\n", $data);
+ $data = '';
+ $listbeg = array();
+ $divdepth = array();
+ $inTable = 0;
+
+ // loop: process all lines
+ foreach ($lines as $line) {
+
+ // bitweaver now ignores leading space because it is *VERY* disturbing to unaware users - spiderr
+ $line = trim( $line );
+ // Check for titlebars...
+ // NOTE: that title bar should be start from begining of line and
+ // be alone on that line to be autoaligned... else it is old styled
+ // styled title bar...
+ if (substr(ltrim($line), 0, 2) == '-=' && substr(rtrim($line), -2, 2) == '=-') {
+ // This is not list item -- must close lists currently opened
+ while (count($listbeg))
+ $data .= array_shift($listbeg);
+
+ //
+ $align_len = strlen($line) - strlen(ltrim($line));
+
+ // My textarea size is about 120 space chars.
+ //define('TEXTAREA_SZ', 120);
+
+ // NOTE: That strict math formula (split into 3 areas) gives
+ // bad visual effects...
+ // $align = ($align_len < (TEXTAREA_SZ / 3)) ? "left"
+ // : (($align_len > (2 * TEXTAREA_SZ / 3)) ? "right" : "center");
+ //
+ // Going to introduce some heuristic here :)
+ // Visualy (remember that space char is thin) center starts at 25 pos
+ // and 'right' from 60 (HALF of full width!) -- thats all :)
+ //
+ // NOTE: Guess align only if more than 10 spaces before -=title=-
+ if ($align_len > 10) {
+ $align = ($align_len < 25) ? "left" : (($align_len > 60) ? "right" : "center");
+ $align = ' style="text-align: ' . $align . ';"';
+ } else {
+ $align = '';
+ }
+ //
+ $line = trim($line);
+ $line = '<div class="tikibar"' . $align . '>' . substr($line, 2, strlen($line) - 4). '</div>';
+ $data .= $line;
+ // TODO: Case is handled ... no need to check other conditions
+ // (it is apriory known all they false, moreover sometimes
+ // check procedure need > O(0) of compexity)
+ // -- continue to next line...
+ // MUST replace all remaining parse blocks to the same logic...
+ continue;
+ }
+
+ // Replace old styled titlebars
+ if (strlen($line) != strlen($line = preg_replace("/-=(.+?)=-/", "<div class='tikibar'>$1</div>", $line))) {
+ $data .= $line;
+ continue;
+ }
+
+ // check if we are inside a table, if so, ignore monospaced and do
+ // not insert <br/>
+ $inTable += substr_count($line, "<table");
+ $inTable -= substr_count($line, "</table");
+
+ // If the first character is ' ' and we are not in pre then we are in pre
+ // bitweaver now ignores leading space because it is *VERY* disturbing to unaware users - spiderr
+ if (substr($line, 0, 1) == ' ' && $gBitSystem->getPreference('feature_wiki_monosp') == 'y' && $inTable == 0) {
+ // This is not list item -- must close lists currently opened
+ while (count($listbeg))
+ $data .= array_shift($listbeg);
+
+ // If the first character is space then
+ // change spaces for &nbsp;
+ $line = '<span style="font-family:monospace;">' . str_replace(' ', '&nbsp;', substr($line, 1)). '</span>';
+ }
+
+ // Replace Hotwords before begin
+ if ($gBitSystem->getPreference('package_hotwords') == 'y') {
+ $line = $hotwordlib->replace_hotwords($line, $words);
+ }
+
+ // Replace monospaced text
+ $line = preg_replace("/-\+(.*?)\+-/", "<code>$1</code>", $line);
+ // Replace bold text
+ $line = preg_replace("/__(.*?)__/", "<b>$1</b>", $line);
+ $line = preg_replace("/\'\'(.*?)\'\'/", "<i>$1</i>", $line);
+ // Replace definition lists
+ $line = preg_replace("/^;([^:]+):([^\n]+)/", "<dl><dt>$1</dt><dd>$2</dd></dl>", $line);
+
+ if (0) {
+ $line = preg_replace("/\[([^\|]+)\|([^\]]+)\]/", "<a $class href='$1'>$2</a>", $line);
+
+ // Segundo intento reemplazar los [link] comunes
+ $line = preg_replace("/\[([^\]]+)\]/", "<a $class href='$1'>$1</a>", $line);
+ $line = preg_replace("/\-\=([^=]+)\=\-/", "<div class='tikibar'>$1</div>", $line);
+ }
+
+ // This line is parseable then we have to see what we have
+ if (substr($line, 0, 3) == '---') {
+ // This is not list item -- must close lists currently opened
+ while (count($listbeg))
+ $data .= array_shift($listbeg);
+
+ $line = '<hr/>';
+ } else {
+ $litype = substr($line, 0, 1);
+
+ if ($litype == '*' || $litype == '#') {
+ $listlevel = $this->how_many_at_start($line, $litype);
+
+ $liclose = '</li>';
+ $addremove = 0;
+
+ if ($listlevel < count($listbeg)) {
+ while ($listlevel != count($listbeg))
+ $data .= array_shift($listbeg);
+
+ if (substr(current($listbeg), 0, 5) != '</li>')
+ $liclose = '';
+ } elseif ($listlevel > count($listbeg)) {
+ $listyle = '';
+
+ while ($listlevel != count($listbeg)) {
+ array_unshift($listbeg, ($litype == '*' ? '</ul>' : '</ol>'));
+
+ if ($listlevel == count($listbeg)) {
+ $listate = substr($line, $listlevel, 1);
+
+ if (($listate == '+' || $listate == '-') && !($litype == '*' && !strstr(current($listbeg), '</ul>') || $litype == '#' && !strstr(current($listbeg), '</ol>'))) {
+ $thisid = 'id' . microtime() * 1000000;
+
+ $data .= '<br/><a id="flipper' . $thisid . '" href="javascript:flipWithSign(\'' . $thisid . '\')">[' . ($listate == '-' ? '+' : '-') . ']</a>';
+ $listyle = ' id="' . $thisid . '" style="display:' . ($listate == '+' ? 'block' : 'none') . ';"';
+ $addremove = 1;
+ }
+ }
+
+ $data .= ($litype == '*' ? "<ul$listyle>" : "<ol$listyle>");
+ }
+
+ $liclose = '';
+ }
+
+ if ($litype == '*' && !strstr(current($listbeg), '</ul>') || $litype == '#' && !strstr(current($listbeg), '</ol>')) {
+ $data .= array_shift($listbeg);
+
+ $listyle = '';
+ $listate = substr($line, $listlevel, 1);
+
+ if (($listate == '+' || $listate == '-')) {
+ $thisid = 'id' . microtime() * 1000000;
+
+ $data .= '<br/><a id="flipper' . $thisid . '" href="javascript:flipWithSign(\'' . $thisid . '\')">[' . ($listate == '-' ? '+' : '-') . ']</a>';
+ $listyle = ' id="' . $thisid . '" style="display:' . ($listate == '+' ? 'block' : 'none') . ';"';
+ $addremove = 1;
+ }
+
+ $data .= ($litype == '*' ? "<ul$listyle>" : "<ol$listyle>");
+ $liclose = '';
+ array_unshift($listbeg, ($litype == '*' ? '</li></ul>' : '</li></ol>'));
+ }
+
+ $line = $liclose . '<li>' . substr($line, $listlevel + $addremove);
+
+ if (substr(current($listbeg), 0, 5) != '</li>')
+ array_unshift($listbeg, '</li>' . array_shift($listbeg));
+ } elseif ($litype == '+') {
+ // Must append paragraph for list item of given depth...
+ $listlevel = $this->how_many_at_start($line, $litype);
+
+ // Close lists down to requested level
+ while ($listlevel < count($listbeg))
+ $data .= array_shift($listbeg);
+
+ if (count($listbeg)) {
+ if (substr(current($listbeg), 0, 5) != '</li>') {
+ array_unshift($listbeg, '</li>' . array_shift($listbeg));
+
+ $liclose = '<li>';
+ } else
+ $liclose = '<br/>';
+ } else
+ $liclose = '';
+
+ $line = $liclose . substr($line, count($listbeg));
+ } else {
+ // This is not list item -- must close lists currently opened
+ while (count($listbeg))
+ $data .= array_shift($listbeg);
+
+ // Get count of (possible) header signs at start
+ $hdrlevel = $this->how_many_at_start($line, '!');
+
+ // If 1st char on line is '!' and its count less than 6 (max in HTML)
+ if ($litype == '!' && $hdrlevel > 0 && $hdrlevel <= 6) {
+ // Remove possible hotwords replaced :)
+ // Umm, *why*? Taking this out lets page
+ // links in headers work, which can be nice.
+ // -rlpowell
+ // $line = strip_tags($line);
+
+ // OK. Parse headers here...
+ $anchor = '';
+ $aclose = '';
+ $addremove = 0;
+
+ // Close lower level divs if opened
+ for (;current($divdepth) >= $hdrlevel; array_shift($divdepth))
+ $data .= '</div>';
+
+ // May be spesial signs present after '!'s?
+ $divstate = substr($line, $hdrlevel, 1);
+
+ if ($divstate == '+' || $divstate == '-') {
+ // OK. Must insert flipper after HEADER, and then open new div...
+ $thisid = 'id' . microtime() * 1000000;
+
+ $aclose = '<a id="flipper' . $thisid . '" href="javascript:flipWithSign(\'' . $thisid . '\')">[' . ($divstate == '-' ? '+' : '-') . ']</a>';
+ $aclose .= '<div id="' . $thisid . '" style="display:' . ($divstate == '+' ? 'block' : 'none') . ';">';
+ array_unshift($divdepth, $hdrlevel);
+ $addremove = 1;
+ }
+
+ $line = $anchor . "<h$hdrlevel>" . substr($line, $hdrlevel + $addremove). "</h$hdrlevel>" . $aclose;
+ } elseif (!strcmp($line, "...page...")) {
+ // Close lists and divs currently opened
+ while (count($listbeg))
+ $data .= array_shift($listbeg);
+
+ while (count($divdepth)) {
+ $data .= '</div>';
+
+ array_shift ($divdepth);
+ }
+
+ // Leave line unchanged... index.php will split wiki here
+ $line = "...page...";
+ } else {
+ // Usual paragraph.
+ if ($inTable == 0 && !preg_match("/\{maketoc.*?\}/i",$line)) {
+ $line .= '<br/>';
+ }
+ }
+ }
+ }
+
+ $data .= $line;
+ }
+
+ // Close lists may remains opened
+ while (count($listbeg)) {
+ $data .= array_shift($listbeg);
+ }
+
+ // Close header divs may remains opened
+ for ($i = 1; $i <= count($divdepth); $i++) {
+ $data .= '</div>';
+ }
+
+ // Close BiDi DIVs if any
+ for ($i = 0; $i < $bidiCount; $i++) {
+ $data .= "</div>";
+ }
+
+ foreach ($noparsed as $np) {
+ $data = str_replace($np["key"], $np["data"], $data);
+ }
+
+ foreach ($preparsed as $pp) {
+// $data = str_replace($pp["key"], "<pre>" . $pp["data"] . "</pre>", $data);
+ }
+
+ // Process pos_handlers here
+ foreach ($this->pos_handlers as $handler) {
+ $data = $handler($data);
+ }
+
+ global $gLibertySystem;
+ // create a table of contents for this page
+ // this function is called manually, since it processes the HTML code
+ if( preg_match( "/\{maketoc.*?\}/", $data ) && @$gLibertySystem->mPlugins['datamaketoc']['is_active'] == 'y' ) {
+ $data = data_maketoc($data);
+ }
+
+ return $data;
+ }
+}
+
+?>
diff --git a/plugins/storage.bitfile.php b/plugins/storage.bitfile.php
new file mode 100644
index 0000000..97b9a19
--- /dev/null
+++ b/plugins/storage.bitfile.php
@@ -0,0 +1,114 @@
+<?php
+global $gLibertySystem;
+
+define( 'PLUGIN_GUID_BIT_FILES', 'bitfile' );
+
+$pluginParams = array (
+ 'store_function' => 'bit_files_store',
+ 'verify_function' => 'bit_files_verify',
+ 'load_function' => 'bit_files_load',
+ 'expunge_function' => 'bit_files_expunge',
+ 'description' => 'Upload File To Server',
+ 'plugin_type' => STORAGE_PLUGIN,
+ 'edit_label' => 'Upload File',
+ 'edit_field' => '<input type="file" name="upload" size="40" />',
+ 'edit_help' => 'This file will be uploaded to your personal storage area.<br />After selecting the file you want to upload, please return to the edit area and click the save button.'
+);
+
+//$gLibertySystem->registerPlugin( STORAGE_TYPE_BIT_FILES, $pluginParams );
+$gLibertySystem->registerPlugin( PLUGIN_GUID_BIT_FILES, $pluginParams );
+
+
+function bit_files_verify( &$pStoreRow ) {
+ $pStoreRow['plugin_guid'] = PLUGIN_GUID_BIT_FILES;
+ $pStoreRow['foreign_id'] = NULL;
+ $pStoreRow['dest_base_name'] = substr( $pStoreRow['upload']['name'], 0, strrpos( $pStoreRow['upload']['name'], '.' ) );
+ $pStoreRow['source_file'] = $pStoreRow['upload']['tmp_name'];
+
+ return( TRUE );
+}
+
+function bit_files_store( &$pStoreRow ) {
+ global $gBitSystem, $gBitUser;
+ $ret = NULL;
+ $pref = $gBitSystem->getPreference('centralized_upload_dir');
+ if( isset( $pref ) ) {
+ if( !empty( $pStoreRow['foreign_id'] ) ) {
+ //$sql = "UPDATE tiki_attachment SET `binary_id`=NULL, `storage_path`=? WHERE `user_id`=? AND storage_id=?";
+ $sql = "UPDATE `".BIT_DB_PREFIX."tiki_files SET `storage_path`=?, `mime_type`=?, `size`=? WHERE `file_id` = ?";
+ $gBitSystem->query( $sql, array( $pStoreRow['dest_file_path'], $pStoreRow['type'], $pStoreRow['size'], $pStoreRow['foreign_id'] ) );
+ } else {
+ $pStoreRow['file_id'] = $gBitSystem->GenID( 'bit_files_file_id_seq' );
+ $sql = "INSERT INTO `".BIT_DB_PREFIX."tiki_files` ( `storage_path`, `file_id`, `mime_type`, `size`, `user_id` ) VALUES ( ?, ?, ?, ?, ? )";
+ $userId = !empty( $pStoreRow['upload']['user_id'] ) ? $pStoreRow['upload']['user_id'] : $gBitUser->mUserId;
+ $gBitSystem->query($sql, array( $pStoreRow['upload']['dest_path'].$pStoreRow['upload']['name'], $pStoreRow['file_id'], $pStoreRow['upload']['type'], $pStoreRow['upload']['size'], $userId ) );
+ }
+ $sql = "UPDATE `".BIT_DB_PREFIX."tiki_attachments` SET `foreign_id`=? WHERE `attachment_id` = ?";
+ $gBitSystem->query( $sql, array( $pStoreRow['file_id'], $pStoreRow['attachment_id'] ) );
+ }
+ return $ret;
+}
+
+function bit_files_load( $pRow ) {
+// this fuction broken, will fix soon - spiderr
+// I think its fixed now - no promises though! - drewslater
+ global $gBitSystem, $gLibertySystem;
+ $ret = NULL;
+ if( !empty( $pRow['foreign_id'] ) && is_numeric( $pRow['foreign_id'] )) {
+ $query = "SELECT *
+ FROM `".BIT_DB_PREFIX."tiki_attachments` ta INNER JOIN `".BIT_DB_PREFIX."tiki_files` tf ON (tf.`file_id` = ta.`foreign_id`)
+ WHERE ta.`foreign_id` = ? AND ta.`content_id` = ?";
+ if( $rs = $gBitSystem->query($query, array( $pRow['foreign_id'], $pRow['content_id'] )) ) {
+ $ret = $rs->fields;
+ if (preg_match ( '/image\//', $ret['mime_type'] )) {
+ $ret['thumbnail_url']['avatar'] = BIT_ROOT_URL.dirname( $ret['storage_path'] ).'/avatar.jpg';
+ $ret['thumbnail_url']['small'] = BIT_ROOT_URL.dirname( $ret['storage_path'] ).'/small.jpg';
+ $ret['thumbnail_url']['medium'] = BIT_ROOT_URL.dirname( $ret['storage_path'] ).'/medium.jpg';
+ $ret['thumbnail_url']['large'] = BIT_ROOT_URL.dirname( $ret['storage_path'] ).'/large.jpg';
+ } else {
+ $mime_thumbnail = $gLibertySystem->getMimeThumbnailURL($ret['mime_type']);
+ $ret['thumbnail_url']['avatar'] = $mime_thumbnail;
+ $ret['thumbnail_url']['small'] = $mime_thumbnail;
+ $ret['thumbnail_url']['medium'] = $mime_thumbnail;
+ $ret['thumbnail_url']['large'] = $mime_thumbnail;
+ }
+ $ret['filename'] = substr( $ret['storage_path'], strrpos($ret['storage_path'], '/')+1);
+ $ret['source_url'] = BIT_ROOT_URL.str_replace( '+', '%20', str_replace( '%2F', '/', urlencode( $ret['storage_path'] ) ) );
+ $ret['wiki_plugin_link'] = "{attachment id=".$ret['attachment_id']."}";
+ }
+ }
+ return( $ret );
+}
+
+function bit_files_expunge( $pStorageId ) {
+ global $gBitUser, $gBitSystem;
+ $ret = FALSE;
+
+ if (is_numeric($pStorageId)) {
+ $sql = "SELECT * FROM `".BIT_DB_PREFIX."tiki_attachments` WHERE `attachment_id` = ?";
+ $rs = $gBitSystem->query($sql, array($pStorageId));
+ $row = &$rs->fields;
+ if ($row) {
+ $sql = "SELECT * FROM `".BIT_DB_PREFIX."tiki_files` WHERE `file_id` = ?";
+ $fileRs = $gBitSystem->query($sql, array($row['foreign_id']) );
+ $fileRow = &$fileRs->fields;
+ if ($fileRow) {
+ $absolutePath = BIT_ROOT_PATH.'/'.$fileRow['storage_path'];
+
+ if ($gBitUser->isAdmin() || $gBitUser->mUserId == $row['user_id']) {
+ if (file_exists($absolutePath)) {
+ unlink($absolutePath);
+ }
+ $query = "DELETE FROM `".BIT_DB_PREFIX."tiki_attachments` WHERE `attachment_id` = ?";
+ $gBitSystem->query($query, array($pStorageId));
+ $query = "DELETE FROM `".BIT_DB_PREFIX."tiki_files` WHERE `file_id` = ?";
+ $gBitSystem->query($query, array($row['foreign_id']) );
+ $ret = TRUE;
+ }
+ }
+ }
+ }
+ return $ret;
+}
+
+?>
diff --git a/plugins/storage.lulu.php b/plugins/storage.lulu.php
new file mode 100644
index 0000000..3e2ff02
--- /dev/null
+++ b/plugins/storage.lulu.php
@@ -0,0 +1,60 @@
+<?php
+global $gLibertySystem;
+
+define( 'PLUGIN_GUID_LULU', 'lulu' );
+
+$pluginParams = array (
+ 'store_function' => 'lulu_store',
+ 'load_function' => 'lulu_load',
+ 'expunge_function' => 'lulu_expunge',
+ 'verify_function' => 'lulu_verify',
+ 'description' => 'Lulu Content ID',
+ 'plugin_type' => STORAGE_PLUGIN,
+ 'edit_label' => 'Enter <a href="http://www.lulu.com">Lulu</a> Content ID',
+ 'edit_field' => '<input type="text" name="STORAGE['.PLUGIN_GUID_LULU.']" size="40" />
+ <a href="http://www.lulu.com">{biticon ipackage=liberty iname=lulu iexplain=lulu}</a>',
+ 'edit_help' => 'Enter the ID of the Lulu item you would like to include.<br />The ID is the number that is displayed at the end of the URL in the browsers address bar, when viewing the image of choice.'
+);
+
+$gLibertySystem->registerPlugin( PLUGIN_GUID_LULU, $pluginParams );
+
+/*
+ the lulu plugin doesn't need to do anything extra besides store the lulu image_id
+ in tiki_attachment.foreign_id - which has already happened in LibertyAttachable::store().
+ So, we don't need to even define this function
+ function lulu_store() {
+ }
+*/
+ function lulu_verify( &$pStoreRow ) {
+ if( !empty( $pStoreRow['upload'] ) ) {
+ $pStoreRow['foreign_id'] = $pStoreRow['upload'];
+ }
+ return( !empty( $pStoreRow['foreign_id'] ) );
+ }
+
+ function lulu_expunge($pAttachmentId) {
+ global $gBitSystem;
+
+ $sql = "DELETE FROM `".BIT_DB_PREFIX."tiki_attachments` WHERE `attachment_id` = ?";
+ $gBitSystem->query($sql, array($pAttachmentId));
+
+ return TRUE;
+ }
+
+ function lulu_store() {
+ }
+
+ function lulu_load( $pRow ) {
+ $ret = array();
+ if( $pRow['foreign_id'] ) {
+ $cidGroup = ((int)($pRow['foreign_id'] / 1000)) * 1000;
+ $ret['source_url'] = 'http://www.lulu.com/content/'.$pRow['foreign_id'];
+ $ret['thumbnail_url']['small'] = 'http://www.lulu.com/items/'.$cidGroup.'/'.$pRow['foreign_id'].'/current/preview/detail_'.$pRow['foreign_id'].'.jpg';
+ $ret['thumbnail_url']['medium'] = 'http://www.lulu.com/items/'.$cidGroup.'/'.$pRow['foreign_id'].'/current/preview/320_'.$pRow['foreign_id'].'.jpg';
+ $ret['thumbnail_url']['large'] = 'http://www.lulu.com/items/'.$cidGroup.'/'.$pRow['foreign_id'].'/current/preview/zoom_'.$pRow['foreign_id'].'.jpg';
+ $ret['attachment_id'] = $pRow['attachment_id'];
+ $ret['wiki_plugin_link'] = "{ATTACHMENT(id=>".$ret['attachment_id'].")}{ATTACHMENT}";
+ }
+ return $ret;
+ }
+?>
diff --git a/plugins/storage.pbase.php b/plugins/storage.pbase.php
new file mode 100644
index 0000000..cfa5672
--- /dev/null
+++ b/plugins/storage.pbase.php
@@ -0,0 +1,55 @@
+<?php
+global $gLibertySystem;
+
+define( 'PLUGIN_GUID_PBASE', 'pbase' );
+
+$pluginParams = array (
+ 'store_function' => 'pbase_store',
+ 'load_function' => 'pbase_load',
+ 'verify_function' => 'pbase_verify',
+ 'expunge_function' => 'pbase_expunge',
+ 'description' => 'PBase Image ID',
+ 'plugin_type' => STORAGE_PLUGIN,
+ 'edit_label' => 'Enter <a href="http://www.pbase.com">PBase</a> Image ID',
+ 'edit_field' => '<input type="text" name="STORAGE['.PLUGIN_GUID_PBASE.']" size="40" />
+ <a href="http://www.pbase.com">{biticon ipackage=liberty iname=pbase iexplain=pbase}</a>',
+ 'edit_help' => 'Enter the ID of the image you would like to include.<br />The ID is the number that is displayed at the end of the URL in the browsers address bar, when viewing the image of choice.'
+);
+
+$gLibertySystem->registerPlugin( PLUGIN_GUID_PBASE, $pluginParams );
+
+/*
+ the pbase plugin doesn't need to do anything extra besides store the pbase image_id
+ in tiki_attachment.foreign_id - which has already happened in LibertyAttachable::store().
+ So, we don't need to even define this function
+ function pbase_store() {
+ }
+*/
+ function pbase_verify( &$pStoreRow ) {
+ if( !empty( $pStoreRow['upload'] ) ) {
+ $pStoreRow['foreign_id'] = $pStoreRow['upload'];
+ }
+ $pStoreRow['plugin_guid'] = PLUGIN_GUID_PBASE;
+ return( empty( $pStoreRow['foreign_id'] ) ? FALSE : TRUE );
+ }
+
+ function pbase_expunge() {
+ return TRUE;
+ }
+
+ function pbase_store() {
+ return TRUE;
+ }
+
+ function pbase_load( $pRow ) {
+ $ret = array();
+ if( $pRow['foreign_id'] ) {
+ $ret['source_url'] = 'http://www.pbase.com/image/'.$pRow['foreign_id'];
+ $ret['thumbnail_url']['small'] = 'http://www.pbase.com/image/'.$pRow['foreign_id'].'/small.jpg';
+ $ret['thumbnail_url']['medium'] = 'http://www.pbase.com/image/'.$pRow['foreign_id'].'/medium.jpg';
+ $ret['thumbnail_url']['large'] = 'http://www.pbase.com/image/'.$pRow['foreign_id'].'/large.jpg';
+ }
+ return $ret;
+ }
+
+?>
diff --git a/templates/admin_liberty.tpl b/templates/admin_liberty.tpl
new file mode 100644
index 0000000..5d26f56
--- /dev/null
+++ b/templates/admin_liberty.tpl
@@ -0,0 +1,72 @@
+{strip}
+{form}
+ {jstabs}
+ {jstab title="General Settings"}
+ {legend legend="General Settings"}
+ <div class="row">
+ {foreach from=$formLibertyFeatures key=item item=output}
+ <div class="row">
+ {formlabel label=`$output.label` for=$item}
+ {forminput}
+ {html_checkboxes name="$item" values="y" checked=`$gBitSystemPrefs.$item` labels=false id=$item}
+ {formhelp note=`$output.note` page=`$output.page`}
+ {/forminput}
+ </div>
+ {/foreach}
+ </div>
+
+ <div class="row">
+ {formlabel label="Acceptable HTML tags" for="approved_html_tags"}
+ {formfeedback warning=$errors.warning}
+ {forminput}
+ <input type="text" id="approved_html_tags" name="approved_html_tags" size="60" maxlength="250" value="{$approved_html_tags|escape}" />
+ {formhelp note="List of allowed HTML tags. All other tags will be stripped when users save content. This will affect all format plugins."}
+ {/forminput}
+ </div>
+ {/legend}
+ {/jstab}
+
+ {jstab title="Image Processing"}
+ {legend legend="Image Processing System"}
+ <input type="hidden" name="page" value="{$page}" />
+ {php}if( extension_loaded( 'gd' ) ) {{/php}{assign var=gdInstalled value=TRUE}{php}}{/php}
+ <div class="row">
+ {formlabel label="
+ <a href='http://www.boutell.com/gd/'>
+ <img class='icon' src=\"`$gBitLoc.LIBERTY_PKG_URL`icons/gd_logo.jpg\" alt='GD' />
+ </a>
+ "}
+ {forminput}
+ <label>
+ <input type="radio" name="image_processor" value="gd" {if !$gdInstalled}disabled="disabled"{/if} {if !$gBitSystemPrefs.image_processor || $gBitSystemPrefs.image_processor=='gd'}checked="checked"{/if} /> gdLibrary
+ </label>
+ {if !$gdInstalled}
+ {formfeedback warning='The GD library is not installed. For newer Linux systems (Fedora, etc.), you need to install the php-gd RPM with a command such as "yum install php-gd".'}
+ {/if}
+ {/forminput}
+ </div>
+
+ {php}if( extension_loaded( 'imagick' ) ) {{/php}{assign var=imagickInstalled value=TRUE}{php}}{/php}
+ <div class="row">
+ {formlabel label="
+ <a href='http://www.imagemagick.org/'>
+ <img class='icon' src=\"`$gBitLoc.LIBERTY_PKG_URL`icons/imagick_logo.jpg\" alt='ImageMagick' />
+ </a>
+ "}
+ {forminput}
+ <label>
+ <input type="radio" name="image_processor" value="imagick" {if !$imagickInstalled}disabled="disabled"{/if} {if $gBitSystemPrefs.image_processor=='imagick'}checked="checked"{/if}/> ImageMagick
+ </label>
+ {if !$imagickInstalled}
+ {formfeedback warning='To use <a href="http://www.imagemagick.org/www/download.html">ImageMagick</a>, you need to install the php-imagick extension. For Linux users, RPM files can be found at <a href="http://phprpms.sourceforge.net/imagick">PHPRPMs</a> (or compile a <a href="http://sourceforge.net/project/showfiles.php?group_id=112092&package_id=139307&release_id=292417">source rpm</a>). Windows users can try <a href="http://www.bitweaver.org/builds/php_imagick.dll">this dll</a> however it has not been tested well.'}
+ {/if}
+ {/forminput}
+ </div>
+ {/legend}
+ {/jstab}
+ {/jstabs}
+ <div class="row submit">
+ <input type="submit" name="change_prefs" value="{tr}Change preferences{/tr}" />
+ </div>
+{/form}
+{/strip}
diff --git a/templates/admin_plugins.tpl b/templates/admin_plugins.tpl
new file mode 100644
index 0000000..ed0b884
--- /dev/null
+++ b/templates/admin_plugins.tpl
@@ -0,0 +1,62 @@
+{strip}
+
+<div class="floaticon">{bithelp}</div>
+
+<div class="admin liberty">
+ <div class="header">
+ <h1>{tr}Admin Liberty Plugins{/tr}</h1>
+ </div>
+
+ <div class="body">
+ {form legend="Liberty Plugins"}
+ {formfeedback error=$errorMsg}
+
+ {foreach from=$gLibertySystem->mPlugins item=plugin key=guid}
+ {if $prev_type ne $plugin.plugin_type and $prev_type ne ''}
+ </table><!-- close all but last table -->
+ <br />
+ {/if}
+
+ {if $prev_type ne $plugin.plugin_type}
+ <!-- create new table on plugin_type change -->
+ <table class="panel">
+ <caption>{tr}Plugin Type: {$plugin.plugin_type}{/tr}</caption>
+ <tr>
+ <th style="width:70%;">{tr}Plugin{/tr}</th>
+ {if $plugin.plugin_type eq 'format'}
+ <th style="width:5%;">{tr}Default{/tr}</th>
+ {/if}
+ <th style="width:20%;">{tr}GUID{/tr}</th>
+ <th style="width:5%;">{tr}Active{/tr}</th>
+ </tr>
+ {/if}
+
+ {assign var=prev_type value=$plugin.plugin_type}
+ <tr class="{cycle values="odd,even"}">
+ <td><label for="{$guid}">{$plugin.plugin_description}</label></td>
+ {if $plugin.plugin_type eq 'format'}
+ <td align="center">{if $plugin.is_active == 'y'}{html_radios values=$guid name="default_format" checked=$default_format}{/if}</td>
+ {/if}
+ <td>{$guid}</td>
+ <td align="center">
+ {if $plugin.is_active=='x'}
+ Missing
+ {else}
+ {html_checkboxes name="PLUGINS[`$guid`]" values="y" checked=`$plugin.is_active` labels=false id=$guid}
+ {/if}
+ </td>
+ </tr>
+ {/foreach}
+
+ </table><!-- close last table -->
+
+ {formfeedback warning="If you disable a format, wiki pages using that format can no longer be edited. Disabling plugins will also disable them in wiki pages, if they are already in use."}
+
+ <div class="row submit">
+ <input type="submit" name="pluginsave" value="{tr}Save Plugin Settings{/tr}" />
+ </div>
+ {/form}
+ </div><!-- end .body -->
+</div><!-- end .liberty -->
+
+{/strip}
diff --git a/templates/attachment_browser.tpl b/templates/attachment_browser.tpl
new file mode 100644
index 0000000..156fd84
--- /dev/null
+++ b/templates/attachment_browser.tpl
@@ -0,0 +1,86 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>{tr}Attachment Browser{/tr}</title>
+
+ {if $gBitLoc.styleSheet}
+ <link rel="stylesheet" title="{$style}" type="text/css" href="{$gBitLoc.styleSheet}" media="all" />
+ {/if}
+ {if $gBitLoc.browserStyleSheet}
+ <link rel="stylesheet" title="{$style}" type="text/css" href="{$gBitLoc.browserStyleSheet}" media="all" />
+ {/if}
+ {if $gBitLoc.customStyleSheet}
+ <link rel="stylesheet" title="{$style}" type="text/css" href="{$gBitLoc.custumStyleSheet}" media="all" />
+ {/if}
+ {foreach from=$gBitLoc.altStyleSheets item=alt_path key=alt_name}
+ <link rel="alternate stylesheet" title="{$alt_name}" type="text/css" href="{$alt_path}" media="screen" />
+ {/foreach}
+
+ <script type="text/javascript"><!--
+ var tikiCookiePath = "{$gBitLoc.cookie_path}";
+ var tikiCookieDomain = "{$gBitLoc.cookie_domain}";
+ var tikiIconDir = "{$gBitLoc.LIBERTY_PKG_URL}icons";
+ var tikiRootUrl = "{$gBitLoc.BIT_ROOT_URL}";
+ --></script>
+ <script type="text/javascript" src="{$gBitLoc.KERNEL_PKG_URL}bitweaver.js"></script>
+
+ {literal}
+ <script type="text/javascript"><!--
+ function returnAttachmentId(attachmentId) {
+ self.opener.document.getElementById("existing_attachment_id_input").value = attachmentId;
+ self.close();
+ }
+ --></script>
+ {/literal}
+
+ <!--[if gte IE 5.5000]>
+ <script type="text/javascript" src="{$gBitLoc.THEMES_PKG_URL}pngfix.js"></script>
+ <![endif]-->
+
+{strip}
+</head>
+<body>
+ <div id="attbrowser">
+ <div class="display attbrowser">
+ <div class="header">
+ <h1>Attachment Browser</h1>
+ <h2>at some point this page should only show attachments that aren't already attached.</h2>
+ </div>
+
+ <div class="body">
+ {legend legend="Avalable attachments"}
+ <noscript>
+ <p>Since you don't seem to have javascript enabled, please hover your mouse over an attachment and use the number that appears to attach a given item to your page.
+ </p>
+ </noscript>
+
+ <table class="data">
+ {counter start=-1 name="cells" print=false}
+ {foreach from=$userAttachments item=attachment key=foo}
+ {counter name="cells" assign="cells" print=false}
+ {if $cells % 2 eq 0}
+ <tr class="{cycle values="odd,even"}">
+ {/if}
+ <td>
+ <a title="{tr}Attachment id: {$attachment.attachment_id}{/tr}" href="javascript:void();" style="cursor:hand;" onclick="returnAttachmentId({$attachment.attachment_id})">
+ <img src="{$attachment.thumbnail_url.small}" alt="{$attachment.filename}" />
+ <br />
+ {$attachment.filename}
+ </a>
+ </td>
+ {if $cells % 2 ne 0}
+ </tr>
+ {/if}
+ {/foreach}
+ {if $cells % 2 eq 0}
+ <td>&nbsp;</td></tr>
+ {/if}
+ </table>
+ {formhelp note="Clicking on an item will attach the item to your wiki page."}
+ {/legend}
+ </div><!-- end .body -->
+ </div><!-- end .attbrowser -->
+ </div><!-- end #attbrowser -->
+</body>
+</html>
+{/strip}
diff --git a/templates/comments.tpl b/templates/comments.tpl
new file mode 100644
index 0000000..7880f6f
--- /dev/null
+++ b/templates/comments.tpl
@@ -0,0 +1,73 @@
+{strip}
+<br />
+
+<div class="display comment">
+ <div class="header">
+ {if !( $post_comment_request || $post_comment_preview )}
+ <a name="bitcomments"></a>
+ {/if}
+ <h2>{tr}Comments{/tr}</h2>
+ </div>
+
+ <div class="body">
+ {formfeedback hash=$formfeedback}
+
+ {section name=ix loop=$comments}
+ {displaycomment comment="$comments[ix]"}
+ {/section}
+
+ {libertypagination hash=$commentsPgnHash}
+
+ {if $post_comment_preview}
+ <h2>{tr}Comments Preview{/tr}</h2>
+ <div class="preview">
+ {include file='bitpackage:liberty/display_comment.tpl' comment=$postComment}
+ </div><!-- end .preview -->
+ {/if}
+
+ {form action="`$comments_return_url`#bitcomments"}
+ {if $post_comment_request || $post_comment_preview}
+ <a name="bitcomments"></a>
+ {legend legend="Post Comment"}
+ <input type="hidden" name="post_comment_reply_id" value="{$post_comment_reply_id}" />
+ <input type="hidden" name="post_comment_id" value="{$post_comment_id}" />
+
+ <div class="row">
+ {formlabel label="Title" for="comments-title"}
+ {forminput}
+ <input type="text" size="50" name="comment_title" id="comments-title" value="{$postComment.title}" />
+ {formhelp note=""}
+ {/forminput}
+ </div>
+
+ {assign var=textarea_id value="commentpost"}
+ {if $gBitSystemPrefs.package_smileys eq 'y'}
+ {include file="bitpackage:smileys/smileys_full.tpl"}
+ {/if}
+
+ {if $gBitSystemPrefs.package_quicktags eq 'y'}
+ {include file="bitpackage:quicktags/quicktags_full.tpl" formId="commentpost"}
+ {/if}
+
+ <div class="row">
+ {formlabel label="Comment" for="commentpost"}
+ {forminput}
+ <textarea id="commentpost" name="comment_data" rows="10" cols="80">{$postComment.data}</textarea>
+ {formhelp note="Use [http://www.foo.com] or [http://www.foo.com|description] for links.<br />HTML tags are not allowed inside comments."}
+ {/forminput}
+ </div>
+
+ <div class="row submit">
+ <input type="submit" name="post_comment_preview" value="{tr}preview{/tr}"/>&nbsp;
+ <input type="submit" name="post_comment_submit" value="{tr}post{/tr}"/>
+ </div>
+ {/legend}
+ {else}
+ <div class="row">
+ <input type="submit" name="post_comment_request" value="{tr}Add Comment{/tr}" />
+ </div>
+ {/if}
+ {/form}
+ </div><!-- end .body -->
+</div><!-- end .comment -->
+{/strip}
diff --git a/templates/display_comment.tpl b/templates/display_comment.tpl
new file mode 100644
index 0000000..468c2ad
--- /dev/null
+++ b/templates/display_comment.tpl
@@ -0,0 +1,18 @@
+{strip}
+<div style="margin-left: {math equation="level * marginIncrement" level=$comment.level marginIncrement=20}px">
+
+ <div class="post">
+ <h3>{$comment.title}</h3>
+ <div class="date">{tr}by{/tr} {displayname hash=$comment} {tr}on{/tr} {$comment.last_modified|bit_long_datetime}</div>
+ <div class="content">
+ {$comment.parsed_data}
+ </div>
+ <div class="footer">
+ <a href="{$comments_return_url}&amp;post_comment_reply_id={$comment.content_id}&amp;post_comment_request=1" rel="nofollow">{biticon ipackage="liberty" iname="reply" iexplain="Reply to this comment"}</a>
+ {if $gBitUser->isAdmin() || ($gBitUser && $comment.user_id == $gBitUser->mInfo.user_id)}<a href="{$comments_return_url}&amp;post_comment_id={$comment.comment_id}&amp;post_comment_request=1" rel="nofollow">{biticon ipackage="liberty" iname="edit" iexplain="Edit"}</a>{/if}
+ {if $gBitUser->isAdmin()}<a href="{$comments_return_url}&amp;delete_comment_id={$comment.comment_id}" rel="nofollow">{biticon ipackage="liberty" iname="delete" iexplain="Remove"}</a> {/if}
+ </div>
+ </div><!-- end .commentpost -->
+
+</div><!-- end .left margin -->
+{/strip}
diff --git a/templates/display_content.tpl b/templates/display_content.tpl
new file mode 100644
index 0000000..318f321
--- /dev/null
+++ b/templates/display_content.tpl
@@ -0,0 +1,5 @@
+{include file="bitpackage:liberty/display_structure.tpl"}
+
+Generic Content display template.
+
+Title: {$pageInfo.title}
diff --git a/templates/display_structure.tpl b/templates/display_structure.tpl
new file mode 100644
index 0000000..0a252f5
--- /dev/null
+++ b/templates/display_structure.tpl
@@ -0,0 +1,45 @@
+{strip}
+{if $structureInfo}
+ <div class="structurebar">
+ {if $gBitSystem->isFeatureActive( 'wikibook_show_path' )}
+ <span class="path">
+ {section loop=$structureInfo.structure_path name=ix}
+ {if $structureInfo.structure_path[ix].parent_id} &raquo; {/if}
+ <a href="index.php?structure_id={$structureInfo.structure_path[ix].structure_id}">
+ {$structureInfo.structure_path[ix].title}
+ </a>
+ {/section}
+ </span>
+ {/if}
+
+ {if $gBitSystem->isFeatureActive( 'wikibook_show_navigation' )}
+ <span class="navigation">
+ <span class="left">
+ {if $structureInfo.prev and $structureInfo.prev.structure_id}
+ <a href="index.php?structure_id={$structureInfo.prev.structure_id}">
+ {if $wikibook_use_icons eq 'y'}
+ {biticon ipackage=liberty iname=nav_prev iexplain=previous}
+ {else}
+ &laquo;&nbsp;{$structureInfo.prev.title}
+ {/if}
+ </a>
+ {else}&nbsp;{/if}
+ </span>
+
+ <span class="right">
+ {if $structureInfo.next and $structureInfo.next.structure_id}
+ <a href="index.php?structure_id={$structureInfo.next.structure_id}">
+ {if $wikibook_use_icons eq 'y'}
+ {biticon ipackage=liberty iname=nav_next iexplain=previous}
+ {else}
+ {$structureInfo.next.title}&nbsp;&raquo;
+ {/if}
+ </a>
+ {else}&nbsp;{/if}
+ </span>
+ </span><!-- end .navigation -->
+ {/if}
+ <div class="clear"></div>
+ </div><!-- end .structure -->
+{/if} {* end structure *}
+{/strip}
diff --git a/templates/edit_format.tpl b/templates/edit_format.tpl
new file mode 100644
index 0000000..3338e15
--- /dev/null
+++ b/templates/edit_format.tpl
@@ -0,0 +1,40 @@
+{strip}
+
+<div class="row">
+ {formfeedback error=$errors.format}
+ {formlabel label="Content Format"}
+ {foreach name=formatPlugins from=$gLibertySystem->mPlugins item=plugin key=guid}
+ {if $plugin.is_active eq 'y' and $plugin.edit_field and $plugin.plugin_type eq 'format'}
+ {forminput}
+ <label>
+ {$plugin.edit_field}
+ {if $pageInfo.format_guid eq $plugin.plugin_guid}
+ checked="checked"
+ {elseif !$pageInfo.format_guid and $plugin.plugin_guid eq $default_format}
+ checked="checked"
+ {/if}
+ onclick="
+ {if $gBitSystem->isPackageActive('quicktags')}
+ {foreach from=$gLibertySystem->mPlugins item=tag key=guid}
+ {if $tag.is_active eq 'y' and $tag.edit_field and $tag.plugin_type eq 'format'}
+ {if $tag.plugin_guid eq $plugin.plugin_guid}
+ show
+ {else}
+ hide
+ {/if}
+ ('qt{$tag.plugin_guid}');
+ {/if}
+ {/foreach}
+ {/if}
+ "
+ /> {$plugin.edit_label}</label>
+ {formhelp note=`$plugin.edit_help`}
+ {/forminput}
+ {/if}
+ {/foreach}
+ {forminput}
+ {formhelp note="You can choose what kind of syntax you want to submit your data in. Some plugins can be used independently of format type. Please view the help at the bottom of the screen for more information."}
+ {/forminput}
+</div>
+
+{/strip}
diff --git a/templates/edit_help.tpl b/templates/edit_help.tpl
new file mode 100644
index 0000000..e8ce683
--- /dev/null
+++ b/templates/edit_help.tpl
@@ -0,0 +1,134 @@
+{* $Header: /cvsroot/bitweaver/_bit_liberty/templates/Attic/edit_help.tpl,v 1.1 2005/06/19 04:55:51 bitweaver Exp $ *}
+{* Show wiki syntax and plugins help *}
+{* TODO: Add links to add samples to edit form *}
+
+{if $gBitSystem->isFeatureActive( 'feature_wikihelp' )}
+
+{jstabs}
+ {jstab title="Help"}
+ {box title="Wiki Help" class="help box"}
+ For more information, please see <a href="http://www.bitweaver.org/wiki/WikiSyntax">WikiSyntax</a> on <a href="http://www.bitweaver.org">bitweaver.org</a>.
+ {/box}
+ {/jstab}
+
+ {if $gBitSystemPrefs.feature_drawings eq 'y'}
+ {jstab title="Drawings"}
+ {box title="Drawings" class="help box"}
+ {literal}{{/literal}draw name=foo} creates the editable drawing foo
+ {/box}
+ {/jstab}
+ {/if}
+
+ {jstab title="Format"}
+ {box title="Text Color" class="help box"}
+ {tr}Changing the color of text is easy. Before the text you want colored - insert 2 tildie (~) characters with the colors name followed by a colon. 2 additional tildie characters need to be added at the end of the colored text.{/tr}<br />
+ {tr}Example: ~~blue:Text to be colored~~ will produce <font color="blue">Text to be colored</font>{/tr}<br />
+ {tr}HTML Colors can also be specified by placing a # character with the HTML Color where the color name should be.{/tr}<br />
+ {tr}Example: ~~#FF0060:Text to be colored~~ will produce <font color="#FF0060">Text to be colored</font>.{/tr}<br />
+ {tr}For Web-Safe Color Names see <a class='wiki' target=_blank href='http://www.bitweaver.org/wiki/Browser+ColorNames'>bitweaver</a> or for HTML Color numbers see <a class='wiki' target=_blank href='http://www.pagetutor.com/pagetutor/makapage/picker/'>The Color Picker II</a>{/tr}
+ {/box}
+
+ {box title="Italics" class="help box"}
+ {tr}To <i>italicize</i> a word or phrase using Wiki syntax, simply surround it with two single quotes (apostrophes), like{/tr} ''<i>{tr}this{/tr}</i>''. {tr}If you wish to italicize an entire phrase, just{/tr} ''<i>{tr}surround the entire phrase{/tr}</i>''.
+ {tr}Note: insert note about italics not carrying over line breaks.{/tr}<br />
+ {tr}Syntax: ''italics''{/tr}<br />
+ {tr}Example: "My friend Jane was ''very'' excited to get her new car."{/tr}<br />
+ {tr}Displayed: "My friend Jane was <i>very</i> excited to get her new car."{/tr}
+ {/box}
+
+ {box title="Underlining" class="help box"}
+ <u>{tr}Underlining{/tr}</u> {tr}text is similar to{/tr} <i>{tr}italicizing{/tr}</i> text.
+ {tr}You can underline an entire phrase by{/tr} ===<u>{tr}surrounding it with three equals signs on either side{/tr}</u>===,
+ {tr}or just a single{/tr} ===<u>{tr}word{/tr}</u>===.<br />
+ {tr}Syntax: ===underlined==={/tr}<br />
+ {tr}Example: "My friend Scott is ===very=== nervous about his date on Friday."{/tr}<br />
+ Displayed: "My friend Scott is <u>very</u> nervous about his date on Friday."
+ {/box}
+
+ {box title="Bold" class="help box"}
+ {tr}<b>Bolding</b> text is very similiar to <i>italicizing</i> &amp; <u>underlining</u>. To make text bold, surround the __<b>word</b>__ or phrase with __<b>two underscores on either side</b>__.{/tr}
+ {tr}Syntax: __bold__{/tr}<br />
+ {tr}Example: "__When__ are we going to the movies?"{/tr}<br />
+ {tr}Displayed: "<b>When</b> are we going to the movies?"{/tr}
+ {/box}
+
+ {box title="Combinations of Tags" class="help box"}
+ {tr}Tikipro gives you even more choices by allowing you to simply combine tags to form different formatting combinations. For example, ''__<i><b>this text is both italicized &amp; bold</b></i>__''. __===<b><u>This text is both bold &amp; underlined</u></b>===__. ''__<i><u>This text is both italicized &amp; underlined</u></i>__''.{/tr}
+ {/box}
+ {/jstab}
+
+ {jstab title="Images"}
+ {box title="Images" class="help box"}
+ "img src=http://example.com/foo.jpg width=200 height=100 align=center link=http://www.yahoo.com desc=foo"
+ displays an image. height, width, desc, link, and alignment are optional
+ {/box}
+
+ {box title="Non-cacheable images" class="help box"}
+ img src=http://example.com/foo.jpg?nocache=1 width=200 height=100 align=center link=http://www.yahoo.com desc=foo
+ displays an image. height, width, desc, link, and align are optional
+ {/box}
+ {/jstab}
+
+ {jstab title="Links"}
+ {box title="WikiLinks" class="help box"}
+ (({tr}WikiPageName{/tr})) would automatically link to the wiki page called "WikiPageName" with the text of the link displayed as, "WikiPageName"
+ (({tr}WikiPageName|description{/tr})) would automatically create the link for the page called "WikiPageName"for wiki references
+ )){tr}SomeName{/tr}(( prevents referencing
+ {/box}
+
+ {box title="External links" class="help box"}
+ {tr}use square brackets for an external link{/tr}: [URL]
+ [URL|{tr}link_description{/tr}]
+ [URL|{tr}description{/tr}|nocache]
+ {/box}
+ {/jstab}
+
+ {jstab title="Miscellaneous"}
+ {box title="Lists" class="help box"}
+ * {tr}for bullet lists{/tr},<br />
+ # {tr}for numbered lists{/tr},<br />
+ ;{tr}term{/tr}:{tr}definition{/tr} {tr}for definiton lists{/tr}
+ {/box}
+
+ {box title="Tables" class="help box"}
+ {if $gBitSystemPrefs.feature_wiki_tables eq 'new'}
+ "||row1-col1|row1-col2|row1-col3<br />row2-col1|row2-col2col3||" creates a table
+ {else}
+ "||row1-col1|row1-col2|row1-col3||row2-col1|row2-col2col3||" {tr}creates a table{/tr}
+ {/if}
+ {/box}
+
+ {box title="Simple box" class="help box"}
+ ^{tr}Box content{/tr}^ Creates a box
+ {/box}
+
+ {box title="Other" class="help box"}
+ "!", "!!", "!!!" makes headings<br />
+ "---" makes a horizontal rule<br />
+ "-={tr}title{/tr}=-" creates a title bar<br />
+ use ...page... to separate pages<br />
+ Non parsed sections: "~np~ {tr}data{/tr} ~/np~" Prevents parsing data
+ {/box}
+
+ {box title="Dynamic Tags" class="help box"}
+ RSS feeds: rss id=n max=m displays rss feed with id=n maximum=m items<br />
+ Dynamic variables: "%{tr}name{/tr}%" Inserts an editable variable<br />
+ Dynamic content: content id=n Will be replaced by the actual value of the dynamic content block with id=n
+ {/box}
+ {/jstab}
+
+ {if count($plugins) ne 0}
+ {jstab title="Plugins"}
+ {foreach from=$plugins item=p}
+ {box title=`$p.name` class="help box"}
+ {if $p.help eq ''}{tr}No description available{/tr}{else}{$p.help}{/if}
+ {if $p.syntax}<br/><strong>{tr}Example Syntax{/tr}:</strong>{$p.syntax}<br/>{/if}
+ {if $p.exthelp ne ''}<a title="{tr}More Details{/tr}" href="javascript:flip('help-{$p.name}');">{tr}More Details{/tr}</a>
+ {if $p.tpopg}<br/>{tr}For additional information about this plugin - see bitweaver.Org or click <a class='wiki' target=_blank href='{$p.tpopg}'><strong>Here</strong></a> to visit.{/tr}<br/>{/if}
+ <div id="help-{$p.name}" style="display: none;">{tr}{$p.exthelp}{/tr}</div>{/if}
+ {/box}
+ {/foreach}
+ {/jstab}
+ {/if}
+{/jstabs}
+{/if}
diff --git a/templates/edit_storage.tpl b/templates/edit_storage.tpl
new file mode 100644
index 0000000..f0613c5
--- /dev/null
+++ b/templates/edit_storage.tpl
@@ -0,0 +1,56 @@
+{php}
+include (LIBERTY_PKG_PATH."edit_storage_inc.php");
+{/php}
+{strip}
+{if $gContent->hasUserPermission('bit_p_content_attachments')}
+ {foreach from=$gLibertySystem->mPlugins item=plugin key=guid}
+ {if $plugin.is_active eq 'y' and $plugin.edit_field and $plugin.plugin_type eq 'storage'}
+ <div class="row">
+ {formlabel label=`$plugin.edit_label`}
+ {forminput}
+ {eval var=$plugin.edit_field}
+ {formhelp note=`$plugin.edit_help`}
+ {/forminput}
+ </div>
+ {/if}
+ {/foreach}
+
+ <!-- Attach existing attachment -->
+ <div class="row">
+ {formlabel label="Existing Attachment ID"}
+ {forminput}
+ <input type="text" name="existing_attachment_id[]" id="existing_attachment_id_input" size="6"/><br />
+ <a href="{$gBitLoc.LIBERTY_PKG_URL}attachment_browser.php" title="{tr}Opens attachemnt browser in new window{/tr}" onkeypress="popUpWin(this.href,'standard',600,400);" onclick="popUpWin(this.href,'standard',600,400);return false;">{tr}Attachment Browser{/tr}</a>
+ {/forminput}
+ </div>
+
+ {if $gContent->mStorage}
+ <div class="row">
+ <table class="data" summary="List of attached files">
+ <tr>
+ <th scope="col">Thumbnail</th>
+ <th scope="col" title="File Properties"></th>
+ </tr>
+ {foreach from=$gContent->mStorage item=storage key=attachmentId}
+ <tr class="{cycle values="odd,even"}">
+ <td style="text-align:center;"><a href="{$storage.source_url}"><img src="{$storage.thumbnail_url.small}" alt="{$storage.filename}" /></a></td>
+ <td>
+ ID: {$attachmentId}
+ <br />
+ Filename: {$storage.filename}
+ <br />
+ Actions:
+ {if $gBitUser->isAdmin() || $bit_p_detach_attachment || $storage.user_id == $gBitUser->mUserId}
+ <a href="{$attachmentActionBaseURL}&amp;detachAttachment={$storage.attachment_id}">{biticon ipackage=liberty iname="detach" iexplain="detach"}</a>
+ {/if}
+ {if $gBitUser->isAdmin() || $storage.user_id == $gBitUser->mUserId}
+ <a href="{$attachmentActionBaseURL}&amp;deleteAttachment={$storage.attachment_id}">{biticon ipackage=liberty iname="delete" iexplain="delete"}</a>
+ {/if}
+ </td>
+ </tr>
+ {/foreach}
+ </table>
+ </div>
+ {/if}
+{/if}
+{/strip}
diff --git a/templates/edit_storage_list.tpl b/templates/edit_storage_list.tpl
new file mode 100644
index 0000000..93c046f
--- /dev/null
+++ b/templates/edit_storage_list.tpl
@@ -0,0 +1,27 @@
+{php}
+include (LIBERTY_PKG_PATH."edit_storage_inc.php");
+{/php}
+{strip}
+{if $gContent->mStorage}
+ <div class="row">
+ <table class="data">
+ <caption>{tr}Insert attached items{/tr}</caption>
+ <tr>
+ <th style="width:30%">Filename</th>
+ <th style="width:70%">Attachment Tag</th>
+ </tr>
+ {foreach from=$gContent->mStorage item=storage key=attachmentId}
+ <tr class="{cycle values="odd,even"}">
+ <td>{$storage.filename}</td>
+ <td style="text-align:right;">
+ <a title="{$storage.wiki_plugin_link}" href="javascript:insertAt('{$textarea_id}','{$storage.wiki_plugin_link|escape:"javascript"}');">{$storage.wiki_plugin_link}</a>
+ </td>
+ </tr>
+ {/foreach}
+ {if $textarea_id}
+ <tr><td colspan="2">{tr}Click on the Attachment Tag to insert it in the textarea{/tr}</td></tr>
+ {/if}
+ </table>
+ </div>
+{/if}
+{/strip}
diff --git a/templates/edit_structure.tpl b/templates/edit_structure.tpl
new file mode 100644
index 0000000..7012232
--- /dev/null
+++ b/templates/edit_structure.tpl
@@ -0,0 +1,58 @@
+{strip}
+
+{jstabs}
+ {jstab title="{tr}Edit{/tr} {tr}`$gStructure->mInfo.content_type.content_description`{/tr}"}
+
+ {*
+ * before editing and committing this template, please make sure it is XHMTL standard compliant on W3C
+ * this file is a real *itch to fix if messed up - XING
+ *}
+
+ <ul class="toc">
+ <li>
+ {section name=ix loop=$subtree}
+ {if $subtree[ix].pos eq ''}
+ {if $structureInfo.structure_id eq $subtree[ix].structure_id}<div class="highlight">{/if}
+ {biticon iforce=icon ipackage=liberty iname="spacer" iexplain="" style="float:right"}
+ <a href="{$PHP_SELF}?structure_id={$subtree[ix].structure_id}">{biticon iforce=icon ipackage=liberty iname="settings" iexplain="edit book" style="float:right"}</a>
+ <a href="{$gBitLoc.WIKI_PKG_URL}index.php?structure_id={$subtree[ix].structure_id}">{biticon iforce=icon ipackage=liberty iname="view" iexplain="view page" style="float:right"}</a>
+
+ {$subtree[ix].title} {if $subtree[ix].page_alias}({/if}{$subtree[ix].page_alias}{if $subtree[ix].page_alias}){/if}
+ {biticon iforce=icon ipackage=liberty iname="spacer" iexplain=""}
+ {if $structureInfo.structure_id eq $subtree[ix].structure_id}</div>{/if}
+ {else}
+ {if $subtree[ix].first}<ul>{else}</li>{/if}
+ {if $subtree[ix].last}</ul>{else}
+ <li>
+ {if $structureInfo.structure_id eq $subtree[ix].structure_id}<div class="highlight">{/if}
+ <a href="{$PHP_SELF}?structure_id={$subtree[ix].structure_id}&amp;action=remove">{biticon iforce=icon ipackage=liberty iname="delete" iexplain="remove page" style="float:right"}</a>
+ <a href="{$PHP_SELF}?structure_id={$subtree[ix].structure_id}&amp;action=edit">{biticon iforce=icon ipackage=liberty iname="settings" iexplain="edit book" style="float:right"}</a>
+ <a href="{$gBitLoc.WIKI_PKG_URL}index.php?structure_id={$subtree[ix].structure_id}">{biticon iforce=icon ipackage=liberty iname="view" iexplain="view page" style="float:right"}</a>
+ {biticon iforce=icon ipackage=liberty iname="spacer" iexplain="" style="float:right"}
+
+ <a href="{$PHP_SELF}?structure_id={$subtree[ix].structure_id}&amp;move_node=4">{biticon iforce=icon ipackage=liberty iname="nav_next" iexplain="move right" style="float:right"}</a>
+ <a href="{$PHP_SELF}?structure_id={$subtree[ix].structure_id}&amp;move_node=3">{biticon iforce=icon ipackage=liberty iname="nav_down" iexplain="move down" style="float:right"}</a>
+ <a href="{$PHP_SELF}?structure_id={$subtree[ix].structure_id}&amp;move_node=2">{biticon iforce=icon ipackage=liberty iname="nav_up" iexplain="move up" style="float:right"}</a>
+ <a href="{$PHP_SELF}?structure_id={$subtree[ix].structure_id}&amp;move_node=1">{biticon iforce=icon ipackage=liberty iname="nav_prev" iexplain="move left" style="float:right"}</a>
+
+ <strong>{$subtree[ix].pos}</strong> {$subtree[ix].title}{if $subtree[ix].page_alias} ({$subtree[ix].page_alias}){/if}
+ {biticon iforce=icon ipackage=liberty iname="spacer" iexplain=""}
+ {if $structureInfo.structure_id eq $subtree[ix].structure_id}</div>{/if}
+ {/if}
+ {/if}
+ {/section}
+ </li>
+ </ul><!-- end outermost .toc -->
+ {/jstab}
+
+ {jstab title="{tr}`$gStructure->mInfo.content_type.content_description`{/tr} {tr}Content{/tr}"}
+ {include file="bitpackage:liberty/edit_structure_content.tpl"}
+ {/jstab}
+
+{* removing alias stuff until we know what to do with it - XING
+ {jstab title="Update Alias"}
+ {include file="bitpackage:liberty/edit_structure_alias.tpl"}
+ {/jstab}
+*}
+{/jstabs}
+{/strip}
diff --git a/templates/edit_structure_alias.tpl b/templates/edit_structure_alias.tpl
new file mode 100644
index 0000000..1093968
--- /dev/null
+++ b/templates/edit_structure_alias.tpl
@@ -0,0 +1,45 @@
+{strip}
+<div>
+ {form legend="Update Page Alias"}
+ <input type="hidden" name="structure_id" value="{$structureInfo.structure_id}" />
+ <input type="hidden" name="tab" value="alias" />
+
+ <div class="row">
+ {formlabel label="Page Alias" for="pageAlias"}
+ {forminput}
+ <input type="text" name="pageAlias" id="pageAlias" value="{$structureInfo.page_alias}" size="30" maxlength="240"/>
+ {formhelp note=""}
+ {/forminput}
+ </div>
+
+ <div class="row submit">
+ <input type="submit" name="create" value="{tr}Update{/tr}"/>
+ </div>
+ {/form}
+</div>
+
+<div class="structuretoc">
+ <ul class="toc">
+ <li>
+ {section name=ix loop=$subtree}
+ {if $subtree[ix].pos eq ''}
+ {if $structureInfo.structure_id eq $subtree[ix].structure_id}<div class="highlight">{/if}
+ <a href="{$PHP_SELF}?structure_id={$subtree[ix].structure_id}&amp;tab=alias">{$subtree[ix].title}</a>
+ {if $structureInfo.structure_id eq $subtree[ix].structure_id}</div>{/if}
+ {else}
+ {if $subtree[ix].first}<ul>{else}</li>{/if}
+ {if $subtree[ix].last}</ul>{else}
+ <li>
+ {if $structureInfo.structure_id eq $subtree[ix].structure_id}<div class="highlight">{/if}
+ <strong>{$subtree[ix].pos}</strong>
+ <a href="{$PHP_SELF}?structure_id={$subtree[ix].structure_id}&amp;tab=alias">{$subtree[ix].title}</a>
+ {if $structureInfo.structure_id eq $subtree[ix].structure_id}</div>{/if}
+ {/if}
+ {/if}
+ {/section}
+ </li>
+ </ul><!-- end outermost .toc -->
+</div>
+<div class="clear"></div>
+
+{/strip}
diff --git a/templates/edit_structure_content.tpl b/templates/edit_structure_content.tpl
new file mode 100644
index 0000000..f7ebdcb
--- /dev/null
+++ b/templates/edit_structure_content.tpl
@@ -0,0 +1,79 @@
+{strip}
+<div class="structurecontent">
+ {form legend="Add Content"}
+ <input type="hidden" name="structure_id" value="{$structureInfo.structure_id}" />
+ <input type="hidden" name="tab" value="content" />
+
+ {if $subpages}
+ <div class="row">
+ {formlabel label="After page" for="after_ref_id"}
+ {forminput}
+ <select name="after_ref_id" id="after_ref_id">
+ {section name=iy loop=$subpages}
+ <option value="{$subpages[iy].structure_id}" {if $insert_after eq $subpages[iy].structure_id}selected="selected"{/if}>{$subpages[iy].title}</option>
+ {/section}
+ </select>
+ {formhelp note=""}
+ {/forminput}
+ </div>
+ {/if}
+
+ <div class="row">
+ {formlabel label="Add" for="content_type"}
+ {forminput}
+ <select name="content_type" id="content_type" onchange="submit();">
+ <option {if !$contentSelect}selected="selected"{/if} value="">All Content</option>
+ {foreach from=$contentTypes key=guid item=description}
+ <option value="{$guid}" {if $contentSelect == $guid}selected="selected"{assign var=selectDescription value=$description}{/if}>{$description}</option>
+ {/foreach}
+ </select>
+ {/forminput}
+
+ {forminput}
+ <select name="content[]" multiple="multiple" size="8">
+ {section name=list loop=$listContent}
+ {assign var=guid value=$listContent[list].content_type_guid}
+ <option value="{$listContent[list].content_id}">{$contentTypes.$guid} {$listContent[list].content_id}{if $listContent[list]}: "{$listContent[list].title|truncate:40:"(...)":true}"{/if}</option>
+ {sectionelse}
+ <option disabled="disabled">{tr}No {$selectDescription} content found{/tr}</option>
+ {/section}
+ </select>
+ {/forminput}
+
+ {forminput}
+ <input type="text" name="find_objects" />
+ <input type="submit" value="{tr}filter{/tr}" name="search_objects" />
+ {formhelp note=""}
+ {/forminput}
+ </div>
+
+ <div class="row submit">
+ <input type="submit" name="create" value="{tr}Add Content{/tr}" />
+ </div>
+ {/form}
+</div>
+
+<div class="structuretoc">
+ <ul class="toc">
+ <li>
+ {section name=ix loop=$subtree}
+ {if $subtree[ix].pos eq ''}
+ {if $structureInfo.structure_id eq $subtree[ix].structure_id}<div class="highlight">{/if}
+ <a href="{$PHP_SELF}?structure_id={$subtree[ix].structure_id}">{$subtree[ix].title}</a>
+ {if $structureInfo.structure_id eq $subtree[ix].structure_id}</div>{/if}
+ {else}
+ {if $subtree[ix].first}<ul>{else}</li>{/if}
+ {if $subtree[ix].last}</ul>{else}
+ <li>
+ {if $structureInfo.structure_id eq $subtree[ix].structure_id}<div class="highlight">{/if}
+ <strong>{$subtree[ix].pos}</strong>&nbsp;
+ <a href="{$PHP_SELF}?structure_id={$subtree[ix].structure_id}">{$subtree[ix].title}</a>
+ {if $structureInfo.structure_id eq $subtree[ix].structure_id}</div>{/if}
+ {/if}
+ {/if}
+ {/section}
+ </li>
+ </ul><!-- end outermost .toc -->
+</div>
+<div class="clear"></div>
+{/strip}
diff --git a/templates/libertypagination.tpl b/templates/libertypagination.tpl
new file mode 100644
index 0000000..b3ffa53
--- /dev/null
+++ b/templates/libertypagination.tpl
@@ -0,0 +1,34 @@
+{strip}
+<div class="pagination">
+ {if $page gt 1}
+ <a href="{$smarty.server.PHP_SELF}?{$pgnName}={$page-1}{$pgnVars}">&laquo;</a>&nbsp;
+ {else}
+ &nbsp;
+ {/if}
+
+ {tr}Page {$page} of {$numPages}{/tr}
+
+ {if $page lt $numPages}
+ &nbsp;<a href="{$smarty.server.PHP_SELF}?{$pgnName}={$page+1}{$pgnVars}">&raquo;</a>
+ {else}
+ &nbsp;
+ {/if}
+
+ <br />
+
+ {if $gBitSystemPrefs.direct_pagination eq 'y'}
+ {foreach from=$pgnPages item=link}
+ {$link}&nbsp;
+ {/foreach}
+ {else}
+ {form id="fPageSelect"}
+ <input type="hidden" name="find" value="{$find}" />
+ <input type="hidden" name="sort_mode" value="{$sort_mode}" />
+ {foreach from=$pgnHidden key=name item=value}
+ <input type="hidden" name="{$name}" value="{$value}" />
+ {/foreach}
+ {tr}Go to page{/tr} <input class="gotopage" type="text" size="3" maxlength="4" name="{$pgnName}" />
+ {/form}
+ {/if}
+</div><!-- end .pagination -->
+{/strip}
diff --git a/templates/list_content.tpl b/templates/list_content.tpl
new file mode 100644
index 0000000..d5732b4
--- /dev/null
+++ b/templates/list_content.tpl
@@ -0,0 +1,11 @@
+{strip}
+<div class="listing liberty">
+ <div class="header">
+ <h1>{tr}Content Listing{/tr}</h1>
+ </div>
+
+ <div class="body">
+ {include file="bitpackage:liberty/list_content_inc.tpl"}
+ </div><!-- end .body -->
+</div><!-- end .liberty -->
+{/strip}
diff --git a/templates/list_content_inc.tpl b/templates/list_content_inc.tpl
new file mode 100644
index 0000000..90ac80b
--- /dev/null
+++ b/templates/list_content_inc.tpl
@@ -0,0 +1,48 @@
+{strip}
+{form legend="Select Content Type"}
+ <div class="row">
+ {formlabel label="Restrict listing" for="content_type"}
+ {forminput}
+ <select name="content_type" id="content_type" onchange="submit();">
+ <option {if !$contentSelect}selected="selected"{/if} value="">All Content</option>
+ {foreach from=$contentTypes key=guid item=description}
+ <option value="{$guid}" {if $contentSelect eq $guid}selected="selected"{assign var=selectDescription value=$description}{/if}>{$description}</option>
+ {/foreach}
+ </select>
+ <noscript>
+ <div><input type="submit" name="content_switch" value="{tr}change content type{/tr}" /></div>
+ </noscript>
+ {/forminput}
+
+ {forminput}
+ <input type="text" name="find_objects" />
+ <input type="submit" value="{tr}filter{/tr}" name="search_objects" />
+ {formhelp note="You can restrict the content listing to a given content type or apply a filter."}
+ {/forminput}
+ </div>
+{/form}
+
+<table class="data">
+ <caption>{tr}Available Content{/tr}</caption>
+ <tr>
+{* <th style="width:1px;white-space:nowrap;"><a href="{$gBitLoc.LIBERTY_PKG_URL}list_content.php?page={$page}&amp;sort_mode={if $sort_mode eq 'content_id_asc'}content_id_desc{else}content_id_asc{/if}">{tr}Content ID{/tr}</a></th> *}
+ <th>{smartlink ititle="Title" isort=title page=$page idefault=1}</th>
+ <th>{smartlink ititle="Content Type" isort=content_type_guid page=$page}</th>
+ <th>{tr}Author{/tr}</th>
+ <th>{tr}Most Recent Editor{/tr}</th>
+ <th>&nbsp;</th>
+ </tr>
+ {foreach from=$contentList item=item}
+ <tr class="{cycle values='odd,even'}">
+{* <td style="text-align:right;">{$item.content_id}&nbsp;&nbsp;</td> *}
+ <td>{$item.display_link}</td>
+ <td>{assign var=content_type_guid value=`$item.content_type_guid`}{$contentTypes.$content_type_guid}</td>
+ <td>{displayname real_name=$item.creator_real_name user=$item.creator_user}</td>
+ <td>{displayname real_name=$item.modifier_real_name user=$item.modifier_user}</td>
+ <td>{$item.last_modified|bit_short_date}</td>
+ </tr>
+ {/foreach}
+</table>
+
+{libertypagination numPages=$numPages page=$page sort_mode=$sort_mode content_type=$contentSelect user_id=$user_id}
+{/strip}
diff --git a/templates/menu_liberty_admin.tpl b/templates/menu_liberty_admin.tpl
new file mode 100644
index 0000000..d3651b9
--- /dev/null
+++ b/templates/menu_liberty_admin.tpl
@@ -0,0 +1,18 @@
+{strip}
+<ul>
+ <li><a class="item" href="{$gBitLoc.KERNEL_PKG_URL}admin/index.php?page=liberty">{tr}Liberty Settings{/tr}</a></li>
+ <li><a class="item" href="{$gBitLoc.LIBERTY_PKG_URL}admin/plugins.php">{tr}Plugins{/tr}</a></li>
+ {if $gBitSystem->isPackageActive( 'pdf' ) }
+ <li><a class="item" href="{$gBitLoc.KERNEL_PKG_URL}admin/index.php?page=pdf">{tr}PDF Settings{/tr}</a></li>
+ {/if}
+ {if $gBitSystem->isPackageActive( 'quota' ) }
+ <li><a class="item" href="{$gBitLoc.KERNEL_PKG_URL}admin/index.php?page=quota">{tr}Quota Settings{/tr}</a></li>
+ {/if}
+ {if $gBitSystem->isPackageActive( 'quicktags' ) }
+ <li><a class="item" href="{$gBitLoc.QUICKTAGS_PKG_URL}admin/index.php">{tr}Quicktags{/tr}</a></li>
+ {/if}
+ {if $gBitSystem->isPackageActive( 'hotwords' ) }
+ <li><a class="item" href="{$gBitLoc.HOTWORDS_PKG_URL}admin/index.php">{tr}Hotwords{/tr}</a></li>
+ {/if}
+</ul>
+{/strip}
diff --git a/templates/storage_thumbs.tpl b/templates/storage_thumbs.tpl
new file mode 100644
index 0000000..738d87e
--- /dev/null
+++ b/templates/storage_thumbs.tpl
@@ -0,0 +1,17 @@
+{strip}
+{if $gContent->mStorage}
+ <div class="storage">
+ {foreach from=$gContent->mStorage item=attachment }
+ <div class="item">
+ {if $attachment.thumbnail_url.small}
+ {if $attachment.source_url}<a href="{$attachment.source_url}">{/if}
+ <img class="thumb" src="{$attachment.thumbnail_url.avatar}" alt="{$attachment.filename}" />
+ {if $attachment.source_url}</a>{/if}
+ {else}
+ {tr}No thumbnail for{/tr} {$attachment.source_url}
+ {/if}
+ </div>
+ {/foreach}
+ </div>
+{/if}
+{/strip}