summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--]includes/bit_setup_inc.php28
-rwxr-xr-x[-rw-r--r--]includes/copyrights_lib.php27
-rwxr-xr-x[-rw-r--r--]includes/display_bitpage_inc.php42
-rwxr-xr-x[-rw-r--r--]includes/export_lib.php19
-rwxr-xr-x[-rw-r--r--]includes/lookup_page_inc.php18
-rwxr-xr-x[-rw-r--r--]includes/plugins_lib.php18
6 files changed, 82 insertions, 70 deletions
diff --git a/includes/bit_setup_inc.php b/includes/bit_setup_inc.php
index 4b4b556..a9e3bbd 100644..100755
--- a/includes/bit_setup_inc.php
+++ b/includes/bit_setup_inc.php
@@ -1,25 +1,35 @@
<?php
+namespace Bitweaver\Wiki;
+use Bitweaver\KernelTools;
+
global $gBitSystem, $gBitUser;
-$registerHash = array(
+$pRegisterHash = [
'package_name' => 'wiki',
'package_path' => dirname( dirname( __FILE__ ) ).'/',
- 'homeable' => TRUE,
-);
-$gBitSystem->registerPackage( $registerHash );
+ 'homeable' => true,
+];
+// fix to quieten down VS Code which can't see the dynamic creation of these ...
+define( 'WIKI_PKG_NAME', $pRegisterHash['package_name'] );
+define( 'WIKI_PKG_URL', BIT_ROOT_URL . basename( $pRegisterHash['package_path'] ) . '/' );
+define( 'WIKI_PKG_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/' );
+define( 'WIKI_PKG_INCLUDE_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/');
+define( 'WIKI_PKG_CLASS_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/classes/');
+define( 'WIKI_PKG_ADMIN_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/admin/');
+
+$gBitSystem->registerPackage( $pRegisterHash );
define( 'BITPAGE_CONTENT_TYPE_GUID', 'bitpage' );
if( $gBitSystem->isPackageActive( 'wiki' )) {
if( $gBitUser->hasPermission( 'p_wiki_view_page' )) {
- $menuHash = array(
+ $menuHash = [
'package_name' => WIKI_PKG_NAME,
'index_url' => WIKI_PKG_URL.'index.php',
'menu_template' => 'bitpackage:wiki/menu_wiki.tpl',
- );
+ ];
$gBitSystem->registerAppMenu( $menuHash );
}
- $gBitSystem->registerNotifyEvent( array( "wiki_page_changes" => tra( "Any wiki page is changed" )));
-}
-?>
+ $gBitSystem->registerNotifyEvent( [ "wiki_page_changes" => KernelTools::tra( "Any wiki page is changed" ) ] );
+} \ No newline at end of file
diff --git a/includes/copyrights_lib.php b/includes/copyrights_lib.php
index ef8d1be..122506c 100644..100755
--- a/includes/copyrights_lib.php
+++ b/includes/copyrights_lib.php
@@ -13,28 +13,31 @@
* @package wiki
* @subpackage CopyrightsLib
*/
+namespace Bitweaver\Wiki;
+use Bitweaver\BitBase;
+
class CopyrightsLib extends BitBase {
function list_copyrights( $pPageId ) {
$query = "select * from `".BIT_DB_PREFIX."liberty_copyrights` WHERE `page_id`=? order by ".$this->mDb->convertSortmode( "copyright_order_asc" );
$query_cant = "select count(*) from `".BIT_DB_PREFIX."liberty_copyrights` WHERE `page_id`=?";
- $result = $this->mDb->query($query, array( $pPageId ));
- $cant = $this->mDb->getOne($query_cant, array( $pPageId ));
- $ret = array();
+ $result = $this->mDb->query($query, [ $pPageId ] );
+ $cant = $this->mDb->getOne($query_cant, [ $pPageId ] );
+ $ret = [];
while ($res = $result->fetchRow()) {
$ret[] = $res;
}
- $retval = array();
+ $retval = [];
$retval["data"] = $ret;
$retval["cant"] = $cant;
return $retval;
}
function top_copyright_order( $pPageId ) {
$query = "select MAX(`copyright_order`) from `".BIT_DB_PREFIX."liberty_copyrights` where `page_id` = ?";
- return $this->mDb->getOne($query, array( $pPageId ));
+ return $this->mDb->getOne($query, [ $pPageId ] );
}
function unique_copyright( $pPageId , $title) {
$query = "select `copyrightID` from `".BIT_DB_PREFIX."liberty_copyrights` where `page_id`=? and `title`=?";
- return $this->mDb->getOne($query, array( $pPageId ,$title));
+ return $this->mDb->getOne($query, [ $pPageId ,$title ] );
}
function add_copyright( $pPageId , $title, $year, $authors, $pUserId) {
//$unique = $this->unique_copyright( $pPageId ,$title);
@@ -46,32 +49,30 @@ class CopyrightsLib extends BitBase {
$top = $this->top_copyright_order( $pPageId );
$order = $top + 1;
$query = "insert into `".BIT_DB_PREFIX."liberty_copyrights` (`page_id`, `title`, `copyright_year`, `authors`, `copyright_order`, `user_id`) values (?,?,?,?,?,?)";
- $this->mDb->query($query,array( $pPageId ,$title,$year,$authors,$order,$pUserId));
+ $this->mDb->query($query,[ $pPageId ,$title,$year,$authors,$order,$pUserId ] );
return true;
}
function edit_copyright($id, $title, $year, $authors, $pUserId) {
$query = "update `".BIT_DB_PREFIX."liberty_copyrights` SET `copyright_year`=?, `title`=?, `authors`=?, `user_id`=? where `copyright_id`=?";
- $this->mDb->query($query,array($year,$title,$authors,$pUserId,(int)$id));
+ $this->mDb->query($query,[ $year,$title,$authors,$pUserId,(int)$id] );
return true;
}
function remove_copyright($id) {
$query = "delete from `".BIT_DB_PREFIX."liberty_copyrights` where `copyright_id`=?";
- $this->mDb->query($query,array((int)$id));
+ $this->mDb->query($query,[ (int)$id ] );
return true;
}
function up_copyright($id) {
$query = "update `".BIT_DB_PREFIX."liberty_copyrights` set `copyright_order`=`copyright_order`-1 where `copyright_id`=?";
- $result = $this->mDb->query($query,array((int)$id));
+ $result = $this->mDb->query($query,[ (int)$id ] );
return true;
}
function down_copyright($id) {
$query = "update `".BIT_DB_PREFIX."liberty_copyrights` set `copyright_order`=`copyright_order`+1 where `copyright_id`=?";
- $result = $this->mDb->query($query,array((int)$id));
+ $result = $this->mDb->query($query,[ (int)$id ] );
return true;
}
}
global $copyrightslib;
$copyrightslib = new CopyrightsLib();
-
-?>
diff --git a/includes/display_bitpage_inc.php b/includes/display_bitpage_inc.php
index e84a569..53d113f 100644..100755
--- a/includes/display_bitpage_inc.php
+++ b/includes/display_bitpage_inc.php
@@ -13,29 +13,32 @@
/**
* required setup
*/
-include_once( WIKI_PKG_CLASS_PATH.'BitBook.php');
+namespace Bitweaver\Wiki;
+use Bitweaver\KernelTools;
+use Bitweaver\Stickies\BitSticky;
+use Bitweaver\Liberty\LibertyContent;
$gBitSystem->verifyPackage( 'wiki' );
$gContent->verifyViewPermission();
// Check permissions to access this page
-if( !$gContent->isValid() || !is_a( $gContent, 'BitPage' ) ) {
- $gBitSystem->fatalError( tra( 'Page cannot be found' ), NULL, NULL, HttpStatusCodes::HTTP_GONE );
+if( !$gContent->isValid() || !is_a( $gContent, '\Bitweaver\Wiki\BitPage' ) ) {
+ $gBitSystem->fatalError( KernelTools::tra( 'Page cannot be found' ), null, null, \Bitweaver\HttpStatusCodes::HTTP_GONE );
}
-$displayHash = array( 'perm_name' => 'p_wiki_view_page' );
+$displayHash = [ 'perm_name' => 'p_wiki_view_page' ];
$gContent->invokeServices( 'content_display_function', $displayHash );
// Let creator set permissions
// does this work with setPreference()??? - xing - Tuesday Oct 07, 2008 17:51:38 CEST
if( $gBitSystem->isFeatureActive( 'wiki_creator_admin' ) && $gContent->isOwner() ) {
- $gBitUser->setPreference( 'p_wiki_admin', TRUE );
+ $gBitUser->setPreference( 'p_wiki_admin', true );
}
// doesn't seem to be used - xing - Tuesday Oct 07, 2008 17:52:42 CEST
//if( isset( $_REQUEST["copyrightpage"] )) {
-// $gBitSmarty->assignByRef( 'copyrightpage', $_REQUEST["copyrightpage"] );
+// $gBitSmarty->assign( 'copyrightpage', $_REQUEST["copyrightpage"] );
//}
// Get the backlinks for the page "page"
@@ -49,7 +52,7 @@ $gContent->addHit();
// Check if we have to lock / unlock this page
if( !empty( $_REQUEST["action"] ) && ( $_REQUEST["action"] == 'lock' || $_REQUEST["action"] == 'unlock' )
&& ( $gContent->hasAdminPermission() || ($gContent->hasUserPermission( 'p_wiki_lock_page' ) && $gBitSystem->isFeatureActive( 'wiki_usrlock' )) ) ) {
- $gContent->setLock( $_REQUEST["action"] == 'lock' ? 'L' : NULL );
+ $gContent->setLock( $_REQUEST["action"] == 'lock' ? 'L' : null );
}
// Process an undo here
@@ -60,7 +63,7 @@ if( !empty( $_REQUEST["undo"] ) && !$gContent->isLocked() && ( $gContent->hasUpd
// work out if this page has slides
if( $gBitSystem->isFeatureActive( 'wiki_uses_slides' )) {
- $slides = explode( "-=[^=]+=-", $gContent->mInfo["data"] );
+ $slides = mb_split( "-=[^=]+=-", $gContent->mInfo["data"] );
if( count( $slides ) <= 1 ) {
$slides = explode( defined( 'PAGE_SEP' ) ? PAGE_SEP : "...page...", $gContent->mInfo["data"] );
}
@@ -96,7 +99,7 @@ if( $pages > 1 ) {
// Comments engine!
if( $gBitSystem->isFeatureActive( 'wiki_comments' )) {
- $comments_vars = array( 'page' );
+ $comments_vars = [ 'page' ];
$comments_prefix_var = 'wiki page:';
$comments_object_var = 'page';
$commentsParentId = $gContent->mContentId;
@@ -110,7 +113,7 @@ if( $gBitSystem->isFeatureActive( 'wiki_comments' )) {
$comments_return_url .= '&amp;comments_maxComments=1';
}
}
- include_once( LIBERTY_PKG_INCLUDE_PATH.'comments_inc.php' );
+ include_once LIBERTY_PKG_INCLUDE_PATH.'comments_inc.php';
}
// Footnotes
@@ -122,7 +125,7 @@ if( $gBitSystem->isFeatureActive( 'wiki_footnotes' ) && $gBitUser->isValid() ) {
// Copyrights
if( $gBitSystem->isFeatureActive( 'wiki_copyrights' ) ) {
- require_once( WIKI_PKG_INCLUDE_PATH.'copyrights_lib.php' );
+ require_once WIKI_PKG_INCLUDE_PATH.'copyrights_lib.php';
$copyrights = $copyrightslib->list_copyrights( $gContent->mPageId );
$gBitSmarty->assign('pageCopyrights', $copyrights["data"]);
}
@@ -137,7 +140,7 @@ if( $gBitSystem->isFeatureActive( 'users_watches' ) ) {
$gBitUser->expungeWatch( $_REQUEST['watch_event'], $_REQUEST['watch_object'] );
}
} else {
- $gBitSystem->fatalError( tra( "This feature requires a registered user. ").": users_watches" );
+ $gBitSystem->fatalError( KernelTools::tra( "This feature requires a registered user. ").": users_watches" );
}
}
@@ -147,17 +150,18 @@ if( $gBitSystem->isFeatureActive( 'users_watches' ) ) {
}
if( $gContent->isValid() && $gBitSystem->isPackageActive( 'stickies' ) ) {
- require_once( STICKIES_PKG_CLASS_PATH.'BitSticky.php' );
global $gNote;
- $gNote = new BitSticky( NULL, NULL, $gContent->mContentId );
+ $gNote = new BitSticky();
+ $gNote->mNotatedContentId = $gContent->mContentId;
$gNote->load();
- $gBitSmarty->assignByRef( 'stickyInfo', $gNote->mInfo );
+ $gBitSmarty->assign( 'stickyInfo', $gNote->mInfo );
}
-$pageInfo = $gContent->mInfo;
-$pageInfo['title'] = $gContent->getTitle();
+$gContent->mInfo = $gContent->mInfo;
+$gContent->mInfo['title'] = $gContent->getTitle();
+$gContent->mInfo['parsed_data'] ??= $gContent->mInfo['data'];
// Display the Index Template
-$gBitSmarty->assignByRef( 'pageInfo', $pageInfo );
+$gBitSmarty->assign( 'pageInfo', $gContent->mInfo );
-$gBitSystem->display( 'bitpackage:wiki/show_page.tpl', $pageInfo['title'], array( 'display_mode' => 'display' ));
+$gBitSystem->display( 'bitpackage:wiki/show_page.tpl', $gContent->mInfo['title'], [ 'display_mode' => 'display' ]);
diff --git a/includes/export_lib.php b/includes/export_lib.php
index 264bc20..0146573 100644..100755
--- a/includes/export_lib.php
+++ b/includes/export_lib.php
@@ -12,27 +12,27 @@
/**
* required setup
*/
-require_once( KERNEL_PKG_CLASS_PATH.'BitBase.php' );
-require_once( WIKI_PKG_CLASS_PATH.'BitPage.php' );
+namespace Bitweaver\Wiki;
+
/**
* @package wiki
* @subpackage ExportLib
*/
-class ExportLib extends BitBase {
+class ExportLib extends \Bitweaver\BitBase {
function MakeWikiZip( $pExportFile ) {
global $gBitUser,$gBitSystem;
- include_once (UTIL_PKG_INCLUDE_PATH."tar.class.php");
+ include_once UTIL_PKG_INCLUDE_PATH."tar.class.php";
$tar = new tar();
$query = "SELECT wp.`page_id` from `".BIT_DB_PREFIX."wiki_pages` wp INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON (lc.`content_id` = wp.`content_id`)
ORDER BY lc.".$this->mDb->convertSortmode("title_asc");
- $result = $this->mDb->query($query,array());
+ $result = $this->mDb->query($query,[]);
while ($res = $result->fetchRow()) {
$page_id = $res["page_id"];
$content = $this->export_wiki_page($page_id, 0);
$tar->addData($page_id, $content, $gBitSystem->getUTCTime());
}
- $tar->toTar( $pExportFile, FALSE);
+ $tar->toTar( $pExportFile, false);
return '';
}
@@ -45,7 +45,7 @@ class ExportLib extends BitBase {
$gWikiPage = new BitPage( $page_id );
$gWikiPage->load();
$info = $gWikiPage->mInfo;
- $parts = array();
+ $parts = [];
$parts[] = MimeifyPageRevision($info);
if ($nversions > 1 || $nversions == 0) {
foreach ($iter as $revision) {
@@ -70,12 +70,11 @@ class ExportLib extends BitBase {
"INNER JOIN `".BIT_DB_PREFIX."users_users` uu ON (uu.`user_id` = th.`user_id`) " .
"WHERE wp.`page_id`=? order by th.".$this->mDb->convertSortmode("version_desc");
$result = $this->mDb->query($query,array($page_id));
- $ret = array();
+ $ret = [];
while ($res = $result->fetchRow()) {
array_push( $ret, $res );
}
return $ret;
}
}
-$exportlib = new ExportLib();
-?>
+$exportlib = new ExportLib(); \ No newline at end of file
diff --git a/includes/lookup_page_inc.php b/includes/lookup_page_inc.php
index e7eb19f..4d838b1 100644..100755
--- a/includes/lookup_page_inc.php
+++ b/includes/lookup_page_inc.php
@@ -13,10 +13,10 @@
/**
* required setup
*/
-require_once( WIKI_PKG_CLASS_PATH.'BitBook.php');
-
+namespace Bitweaver\Wiki;
+use Bitweaver\Liberty\LibertyStructure;
global $gContent;
-include_once( LIBERTY_PKG_INCLUDE_PATH.'lookup_content_inc.php' );
+include_once LIBERTY_PKG_INCLUDE_PATH.'lookup_content_inc.php';
// this is needed when the center module is applied to avoid abusing $_REQUEST
if( empty( $lookupHash )) {
@@ -46,7 +46,7 @@ if( empty( $gContent ) || !is_object( $gContent ) || strtolower( get_class( $gCo
// Display page so user can select which wiki page they want (there are multiple that share this name)
$gBitSmarty->assign( 'choose', $lookupHash['page'] );
$gBitSmarty->assign('dupePages', $existsInfo);
- $gBitSystem->display('bitpackage:wiki/page_select.tpl', NULL, array( 'display_mode' => 'display' ));
+ $gBitSystem->display('bitpackage:wiki/page_select.tpl', null, [ 'display_mode' => 'display' ]);
die;
} else {
$loadPageId = $existsInfo[0]['page_id'];
@@ -70,11 +70,8 @@ if( empty( $gContent ) || !is_object( $gContent ) || strtolower( get_class( $gCo
// we weren't passed a structure, but maybe this page belongs to one. let's check...
if( $gContent->isValid() && empty( $gStructure ) ) {
//Get the structures this page is a member of
- if( !empty($lookupHash['structure']) ) {
- $structure=$lookupHash['structure'];
- } else {
- $structure='';
- }
+ $structure = !empty($lookupHash['structure']) ? $structure=$lookupHash['structure'] : '';
+
if( $structs = $gContent->getStructures() ) {
$structId = $structs[0]['structure_id'];
if( count( $structs ) > 0 ) {
@@ -96,5 +93,4 @@ if( $gContent->isValid() && empty( $gStructure ) ) {
}
$gBitSmarty->clearAssign( 'gContent' );
-$gBitSmarty->assignByRef( 'gContent', $gContent );
-?>
+$gBitSmarty->assign( 'gContent', $gContent ); \ No newline at end of file
diff --git a/includes/plugins_lib.php b/includes/plugins_lib.php
index 61ffe41..cc8eafe 100644..100755
--- a/includes/plugins_lib.php
+++ b/includes/plugins_lib.php
@@ -27,7 +27,10 @@
* @author Claudio Bustos
* @version $Revision$
*/
- class PluginsLib extends BitBase {
+
+ namespace Bitweaver\Wiki;
+
+ class PluginsLib extends \Bitweaver\BitBase {
public $_errors;
public $_data;
public $_params;
@@ -35,7 +38,7 @@
* Array of params to be expanded as arrays. Explode the string with {@link $separator}
* @var array
*/
- public $expanded_params = array();
+ public $expanded_params = [];
/**
* Separator used to explote params listed on {@link $expanded_params}
* @var string
@@ -63,7 +66,7 @@
if ($defaults === false) {
$defaults = $this->getDefaultArguments();
}
- $args = array();
+ $args = [];
foreach ($defaults as $arg => $default_val) {
if (isset($params[$arg])) {
$args[$arg] = $params[$arg];
@@ -83,7 +86,7 @@
$args[$arg][$id]=trim($value);
}
} else {
- $args[$arg]=array();
+ $args[$arg]=[];
}
}
}
@@ -158,13 +161,13 @@
class PluginsLibUtil {
/**
* Create a table with information from pages
- * @param array key ["data"] from one of the functions that retrieve información about pages
+ * @param array key ["data"] from one of the functions that retrieve informaci�n about pages
* @param array list of keys to show.
* @param array definition of the principal field. By default:
* array("field"=>"title","name"=>"Page")
* @return string
*/
- function createTable($aData,$aInfo=false,$aPrincipalField=false) {
+ public function createTable($aData,$aInfo=false,$aPrincipalField=false) {
// contract
if (!$aPrincipalField or !is_array($aPrincipalField)) {
$aPrincipalField=array("field"=>"title","name"=>"Page");
@@ -204,5 +207,4 @@
}
return $sOutput;
}
- }
-?>
+ } \ No newline at end of file