From 144b7ea64606dd1875b10ce87693250f84bea3f7 Mon Sep 17 00:00:00 2001 From: lsces Date: Fri, 29 Aug 2025 13:03:49 +0100 Subject: General code updated to PHP8.4 and namespace --- backlinks.php | 25 +++-- book_to_html.php | 18 ++-- books.php | 18 ++-- copyrights.php | 38 ++++--- edit.php | 285 ++++++++++++++++++++++++++++++-------------------- edit_book.php | 41 ++++---- export_wiki_pages.php | 12 +-- index.php | 22 ++-- like_pages.php | 17 +-- list_pages.php | 36 +++---- orphan_pages.php | 33 +++--- page_history.php | 25 ++--- page_loader.php | 6 +- page_watches.php | 21 ++-- print_multi_pages.php | 15 +-- print_pages.php | 35 +++---- rankings.php | 39 +++---- remove_page.php | 27 +++-- sitemap.php | 20 ++-- slideshow.php | 47 +++------ wiki_graph.php | 15 ++- wiki_rss.php | 26 ++--- 22 files changed, 424 insertions(+), 397 deletions(-) mode change 100644 => 100755 backlinks.php mode change 100644 => 100755 book_to_html.php mode change 100644 => 100755 books.php mode change 100644 => 100755 copyrights.php mode change 100644 => 100755 edit.php mode change 100644 => 100755 edit_book.php mode change 100644 => 100755 export_wiki_pages.php mode change 100644 => 100755 index.php mode change 100644 => 100755 like_pages.php mode change 100644 => 100755 list_pages.php mode change 100644 => 100755 orphan_pages.php mode change 100644 => 100755 page_history.php mode change 100644 => 100755 page_loader.php mode change 100644 => 100755 page_watches.php mode change 100644 => 100755 print_multi_pages.php mode change 100644 => 100755 print_pages.php mode change 100644 => 100755 rankings.php mode change 100644 => 100755 remove_page.php mode change 100644 => 100755 sitemap.php mode change 100644 => 100755 wiki_graph.php mode change 100644 => 100755 wiki_rss.php diff --git a/backlinks.php b/backlinks.php old mode 100644 new mode 100755 index f637de5..e4c3578 --- a/backlinks.php +++ b/backlinks.php @@ -12,31 +12,30 @@ /** * required setup */ -require_once( '../kernel/includes/setup_inc.php' ); -include_once( WIKI_PKG_INCLUDE_PATH.'lookup_page_inc.php'); +require_once '../kernel/includes/setup_inc.php'; +use Bitweaver\KernelTools; +include_once WIKI_PKG_INCLUDE_PATH.'lookup_page_inc.php'; $gBitSystem->verifyPackage( 'wiki' ); $gBitSystem->verifyFeature( 'wiki_backlinks' ); // Get the page from the request var or default it to HomePage -if (!isset($_REQUEST["page"])) { - $gBitSystem->fatalError(tra("No page indicated")); -} else { - $page = $_REQUEST["page"]; - $gBitSmarty->assignByRef('page', $_REQUEST["page"]); +if ( empty($gContent->mPageName) ) { } - // Now check permissions to access this page $gContent->verifyViewPermission(); // If the page doesn't exist then display an error -if( !$gContent->pageExists( $page )) { - $gBitSystem->fatalError(tra("The page could not be found")); +if( !$gContent->pageExists( $gContent->mPageName )) { + $gBitSystem->fatalError(KernelTools::tra("The page could not be found")); +} else { + $_REQUEST["page"] = $gContent->mPageName; + $gBitSmarty->assign('page', $_REQUEST["page"]); } + // Get the backlinks for the page "page" $backlinks = $gContent->getBacklinks(); -$gBitSmarty->assignByRef('backlinks', $backlinks); +$gBitSmarty->assign('backlinks', $backlinks); // Display the template -$gBitSystem->display( 'bitpackage:wiki/backlinks.tpl', NULL, array( 'display_mode' => 'display' )); -?> +$gBitSystem->display( 'bitpackage:wiki/backlinks.tpl', null, [ 'display_mode' => 'display' ] ); diff --git a/book_to_html.php b/book_to_html.php old mode 100644 new mode 100755 index a5c5802..1c00595 --- a/book_to_html.php +++ b/book_to_html.php @@ -13,9 +13,9 @@ /** * required setup */ -require_once( '../kernel/includes/setup_inc.php' ); +require_once '../kernel/includes/setup_inc.php'; -include_once( WIKI_PKG_CLASS_PATH.'BitBook.php'); +use Bitweaver\KernelTools; function copys($source,$dest) { @@ -48,22 +48,22 @@ function deldirfiles($dir){ $current_dir = opendir($dir); while($entryname = readdir($current_dir)){ if(is_dir("$dir/$entryname") and ($entryname != "." and $entryname!="..")){ - deldirfiles("${dir}/${entryname}"); + deldirfiles("{$dir}/{$entryname}"); }elseif($entryname != "." and $entryname!=".."){ - unlink("${dir}/${entryname}"); + unlink("{$dir}/{$entryname}"); } } closedir($current_dir); } if( !$gBitUser->isAdmin() ) { - $gBitSmarty->assign('msg', tra("You dont have permission to use this feature")); - $gBitSystem->display( 'error.tpl' , NULL, array( 'display_mode' => 'display' )); + $gBitSmarty->assign('msg', KernelTools::tra("You dont have permission to use this feature")); + $gBitSystem->display( 'error.tpl' , null, [ 'display_mode' => 'display' ] ); die; } $struct_info = $structlib->s_get_structure_info($_REQUEST['struct']); -$gBitSmarty->assignByRef('struct_info',$struct_info); +$gBitSmarty->assign('struct_info',$struct_info); $gBitSmarty->assign('generated','y'); if(isset($_REQUEST['create'])) { @@ -103,6 +103,4 @@ if(isset($_REQUEST['create'])) { } // Display the template -$gBitSystem->display( 'bitpackage:wiki/create_webhelp.tpl', NULL, array( 'display_mode' => 'display' )); - -?> +$gBitSystem->display( 'bitpackage:wiki/create_webhelp.tpl', null, array( 'display_mode' => 'display' )); diff --git a/books.php b/books.php old mode 100644 new mode 100755 index f1bdcb9..67acca1 --- a/books.php +++ b/books.php @@ -13,8 +13,8 @@ /** * required setup */ -require_once( '../kernel/includes/setup_inc.php' ); -include_once( WIKI_PKG_CLASS_PATH.'BitBook.php'); +require_once '../kernel/includes/setup_inc.php'; +use Bitweaver\Wiki\BitBook; // verify stuff $gBitSystem->verifyPackage( 'wiki' ); @@ -22,16 +22,16 @@ $gBitSystem->verifyPermission( 'p_wiki_list_pages' ); $book = new BitBook(); -$listHash = array(); +$listHash = []; $listHash['content_type_guid'] = BITBOOK_CONTENT_TYPE_GUID; $channels = $book->getList( $listHash ); $cant_pages = ceil($channels["cant"] / $listHash['max_records']); -$gBitSmarty->assignByRef('cant_pages', $cant_pages); -$gBitSmarty->assign('actual_page', 1 + ($listHash['offset'] / $listHash['max_records'])); +$gBitSmarty->assign('cant_pages', $cant_pages); +$gBitSmarty->assign('actual_page', 1 + $listHash['offset'] / $listHash['max_records'] ); if ($channels["cant"] > ($listHash['offset'] + $listHash['max_records'])) { - $gBitSmarty->assign('next_offset', $listHash['offset'] + $listHash['max_records']); + $gBitSmarty->assign('next_offset', $listHash['offset'] + $listHash['max_records'] ); } else { $gBitSmarty->assign('next_offset', -1); } @@ -43,8 +43,6 @@ if ($listHash['offset'] > 0) { $gBitSmarty->assign('prev_offset', -1); } -$gBitSmarty->assignByRef('channels', $channels["data"]); +$gBitSmarty->assign('channels', $channels["data"]); -$gBitSystem->display( 'bitpackage:wiki/list_books.tpl', NULL, array( 'display_mode' => 'display' )); - -?> +$gBitSystem->display( 'bitpackage:wiki/list_books.tpl', null, array( 'display_mode' => 'display' )); diff --git a/copyrights.php b/copyrights.php old mode 100644 new mode 100755 index c3a10dd..7eb663b --- a/copyrights.php +++ b/copyrights.php @@ -13,12 +13,13 @@ /** * required setup */ -require_once( '../kernel/includes/setup_inc.php' ); -$gBitSystem->isFeatureActive( 'wiki_copyrights', tra("The copyright management feature is not enabled.") ); +require_once '../kernel/includes/setup_inc.php'; +use Bitweaver\KernelTools; +$gBitSystem->isFeatureActive( 'wiki_copyrights', KernelTools::tra("The copyright management feature is not enabled.") ); $gBitUser->hasPermission( 'p_wiki_edit_copyright' ); -require_once( WIKI_PKG_INCLUDE_PATH.'copyrights_lib.php' ); -require_once( WIKI_PKG_INCLUDE_PATH.'lookup_page_inc.php' ); +require_once WIKI_PKG_INCLUDE_PATH.'copyrights_lib.php'; +require_once WIKI_PKG_INCLUDE_PATH.'lookup_page_inc.php'; if (isset($_REQUEST['addcopyright'])) { if ($gBitSystem->isFeatureActive( 'wiki_copyrights' ) && isset($_REQUEST['copyrightTitle']) && isset($_REQUEST['copyrightYear']) @@ -28,8 +29,8 @@ if (isset($_REQUEST['addcopyright'])) { $copyrightAuthors = $_REQUEST['copyrightAuthors']; $copyrightslib->add_copyright($gContent->mPageId, $copyrightTitle, $copyrightYear, $copyrightAuthors, $gBitUser->mUserId); } else { - $gBitSmarty->assign('msg', tra("You must supply all the information, including title and year.")); - $gBitSystem->display( 'error.tpl' , NULL, array( 'display_mode' => 'display' )); + $gBitSmarty->assign('msg', KernelTools::tra("You must supply all the information, including title and year.")); + $gBitSystem->display( 'error.tpl' , null, [ 'display_mode' => 'display' ]); die; } } @@ -42,22 +43,25 @@ if (isset($_REQUEST['editcopyright'])) { $copyrightAuthors = $_REQUEST['copyrightAuthors']; $copyrightslib->edit_copyright($copyright_id, $copyrightTitle, $copyrightYear, $copyrightAuthors, $gBitUser->mUserId); } else { - $gBitSmarty->assign('msg', tra("You must supply all the information, including title and year.")); - $gBitSystem->display( 'error.tpl' , NULL, array( 'display_mode' => 'display' )); + $gBitSmarty->assign('msg', KernelTools::tra("You must supply all the information, including title and year.")); + $gBitSystem->display( 'error.tpl' , null, array( 'display_mode' => 'display' )); die; } } -if (isset($_REQUEST['action']) && isset($_REQUEST['copyright_id'])) { - if ($_REQUEST['action'] == 'up') { - $copyrightslib->up_copyright($_REQUEST['copyright_id']); - } elseif ($_REQUEST['action'] == 'down') { - $copyrightslib->down_copyright($_REQUEST['copyright_id']); - } elseif ($_REQUEST['action'] == 'delete') { - $copyrightslib->remove_copyright($_REQUEST['copyright_id']); +if (isset($_REQUEST['action']) && isset($_REQUEST['copyright_id'] ) ) { + switch ($_REQUEST['action']) { + case 'up': + $copyrightslib->up_copyright($_REQUEST['copyright_id'] ); + break; + case 'down': + $copyrightslib->down_copyright($_REQUEST['copyright_id'] ); + break; + case 'delete': + $copyrightslib->remove_copyright($_REQUEST['copyright_id'] ); + break; } } $copyrights = $copyrightslib->list_copyrights( $gContent->mPageId ); $gBitSmarty->assign('copyrights', $copyrights["data"]); // Display the template -$gBitSystem->display( 'bitpackage:wiki/copyrights.tpl', NULL, array( 'display_mode' => 'display' )); -?> +$gBitSystem->display( 'bitpackage:wiki/copyrights.tpl', null, [ 'display_mode' => 'display' ] ); diff --git a/edit.php b/edit.php old mode 100644 new mode 100755 index aba7162..e17d9e6 --- a/edit.php +++ b/edit.php @@ -13,8 +13,12 @@ /** * required setup */ -require_once( '../kernel/includes/setup_inc.php' ); -include_once( WIKI_PKG_CLASS_PATH.'BitBook.php' ); +require_once '../kernel/includes/setup_inc.php'; +use Bitweaver\BitBase; +use Bitweaver\KernelTools; +use Bitweaver\Liberty\BitLinks; +use Bitweaver\Liberty\LibertyContent; +use Bitweaver\Liberty\LibertyComment; $gBitSystem->verifyPackage( 'wiki' ); @@ -22,7 +26,7 @@ $gBitSystem->verifyPackage( 'wiki' ); unset($_REQUEST['content_id']); // Disable parsing data if not asking to preview page $_REQUEST["parse"] = false; -include( WIKI_PKG_INCLUDE_PATH.'lookup_page_inc.php' ); +include WIKI_PKG_INCLUDE_PATH.'lookup_page_inc.php'; if( $gContent->isValid() ) { $gContent->verifyUpdatePermission(); @@ -32,7 +36,6 @@ if( $gContent->isValid() ) { //make comment count for this page available for templates if( $gBitSystem->isFeatureActive( 'wiki_comments' ) && !empty( $_REQUEST['page_id'] ) ) { - require_once( LIBERTY_PKG_CLASS_PATH.'LibertyComment.php' ); $gComment = new LibertyComment(); $numComments = $gComment->getNumComments($gContent->mContentId); $gBitSmarty->assign('comments_count', $numComments); @@ -47,7 +50,6 @@ if( $gContent->isLocked() ) { $gBitSystem->fatalError( 'Cannot edit page because it is locked' ); } - $gContent->invokeServices( 'content_edit_function' ); if( !empty( $gContent->mInfo ) ) { @@ -102,11 +104,7 @@ if( isset( $_REQUEST['title'] ) ) { if( isset( $_REQUEST["description"] ) ) { $formInfo['description'] = $_REQUEST["description"]; } -if( isset( $_REQUEST["edit_comment"] ) ) { - $formInfo['edit_comment'] = $_REQUEST["edit_comment"]; -} else { - $formInfo['edit_comment'] = ''; -} +$formInfo['edit_comment'] = $_REQUEST["edit_comment"] ?? ''; $cat_obj_type = BITPAGE_CONTENT_TYPE_GUID; @@ -125,7 +123,7 @@ if( $gBitSystem->isFeatureActive( 'wiki_copyrights' ) ) { // Pro // Check if the page has changed if( isset( $_REQUEST["fCancel"] ) ) { - if( @BitBase::verifyId( $gContent->mContentId ) ) { + if( BitBase::verifyId( $gContent->mContentId ) ) { header( "Location: ".$gContent->getDisplayUrl() ); } else { header( "Location: ".WIKI_PKG_URL ); @@ -142,28 +140,29 @@ if( isset( $_REQUEST["fCancel"] ) ) { && !empty( $_REQUEST['copyrightYear'] ) && !empty( $_REQUEST['copyrightTitle'] ) ) { - require_once( WIKI_PKG_INCLUDE_PATH.'copyrights_lib.php' ); + require_once WIKI_PKG_INCLUDE_PATH.'copyrights_lib.php'; $copyrightYear = $_REQUEST['copyrightYear']; $copyrightTitle = $_REQUEST['copyrightTitle']; $copyrightAuthors = $_REQUEST['copyrightAuthors']; $copyrightslib->add_copyright( $gContent->mPageId, $copyrightTitle, $copyrightYear, $copyrightAuthors, $gBitUser->mUserId ); } +// $sBitLinks = new BitLinks(); if( $gContent->mPageId ) { if( isset( $_REQUEST['isminor'] ) && $_REQUEST['isminor']=='on' ) { - $_REQUEST['minor']=true; + $_REQUEST['minor'] = true; } else { - $_REQUEST['minor']=false; -// $links = $gContent->get_links( $edit ); + $_REQUEST['minor'] = false; + $links = []; // $sBitLinks->get_links( $edit ); // $wikilib->cache_links( $links ); -// $gContent->storeLinks( $links ); +// $sBitLinks->storeLinks( $links ); } } else { -// $links = $gContent->get_links( $_REQUEST["edit"] ); -// $notcachedlinks = $gContent->get_links_nocache( $_REQUEST["edit"] ); + $links = []; // $sBitLinks->get_links( $_REQUEST["edit"] ); +// $notcachedlinks = $sBitLinks->get_links_nocache( $_REQUEST["edit"] ); // $cachedlinks = array_diff( $links, $notcachedlinks ); -// $gContent->cache_links( $cachedlinks ); -// $gContent->storeLinks( $cachedlinks ); +// $sBitLinks->cache_links( $cachedlinks ); +// $sBitLinks->storeLinks( $cachedlinks ); } $data_to_parse = $formInfo['edit']; @@ -178,7 +177,8 @@ if( isset( $_REQUEST["fCancel"] ) ) { $gBitUser->storeWatch( "wiki_page_changed", $gContent->mPageId, $gContent->mContentTypeGuid, $_REQUEST['title'], $gContent->getDisplayUrl() ); } - header( "Location: ".$gContent->getDisplayUrl( $gContent->mPageName ) ); + $return = [ 'title' => $gContent->mPageName ]; + header( "Location: ".$gContent->getDisplayUrlFromHash( $return ) ); die; } else { @@ -195,11 +195,12 @@ if( isset( $_REQUEST['format_guid'] ) && !isset( $gContent->mInfo['format_guid'] $formInfo['format_guid'] = $gContent->mInfo['format_guid'] = $_REQUEST['format_guid']; } +$preview = false; if( isset( $_REQUEST["preview"] ) ) { // Chrome does not like seeing the page source in the page itself. header("X-XSS-Protection: 0"); - $gBitSmarty->assign( 'preview',1 ); - $gBitSmarty->assign( 'title',!empty( $_REQUEST["title"] ) ? $_REQUEST["title"]:$gContent->mPageName ); + $preview = true; + $gBitSmarty->assign( 'title',!empty( $_REQUEST["title"] ) ? $_REQUEST["title"] : $gContent->mPageName ); if (!empty($formInfo['section'])) { $formInfo['edit_section'] = 1; @@ -212,7 +213,8 @@ if( isset( $_REQUEST["preview"] ) ) { $formInfo['parsed_data'] = LibertyContent::parseDataHash( $data_to_parse ); $gContent->invokeServices( 'content_preview_function' ); -} +} +$gBitSmarty->assign( 'preview',$preview ); if( $gContent->isInStructure() ) { $gBitSmarty->assign( 'showstructs', $gContent->getStructures() ); @@ -231,14 +233,14 @@ if( empty( $formInfo ) ) { // make original page title available for template $formInfo['original_title'] =( !empty( $gContent->mInfo['title'] ) ) ? $gContent->mInfo['title'] : "" ; -$gBitSmarty->assignByRef( 'pageInfo', $formInfo ); -$gBitSmarty->assignByRef( 'errors', $gContent->mErrors ); +$gBitSmarty->assign( 'pageInfo', $formInfo ); +$gBitSmarty->assign( 'errors', $gContent->mErrors ); if( $gBitSystem->isPackageActive( 'ckeditor' ) ) { // loadCkEditor(); } -$gBitSystem->display( 'bitpackage:wiki/edit_page.tpl', 'Edit: '.$gContent->getTitle() , array( 'display_mode' => 'edit' )); +$gBitSystem->display( 'bitpackage:wiki/edit_page.tpl', 'Edit: '.$gContent->getTitle() , [ 'display_mode' => 'edit' ] ); @@ -265,9 +267,9 @@ function parse_output( &$obj, &$parts,$i ) { case 'application/x-tikiwiki': $aux["body"] = $obj->body; $ccc=$obj->headers["content-type"]; - $items = split( ';',$ccc ); + $items = mb_split( ';',$ccc ); foreach( $items as $item ) { - $portions = split( '=',$item ); + $portions = mb_split( '=',$item ); if( isset( $portions[0] ) &&isset( $portions[1] ) ) { $aux[trim( $portions[0] )]=trim( $portions[1] ); } @@ -319,82 +321,145 @@ function compare_import_versions( $a1, $a2 ) { function walk_and_parse( &$c, &$src, &$p ) { for( $i=0; $i <= $c["contentpos"]; $i++ ) { // If content type 'text' output it to destination... - if( $c[$i]["type"] == "text" ) { - $src .= $c[$i]["data"]; - } elseif( $c[$i]["type"] == "tag" ) { - if( $c[$i]["data"]["type"] == "open" ) { - // Open tag type - switch( $c[$i]["data"]["name"] ) { - case "br": $src .= "\n"; break; - case "title": $src .= "\n!"; $p['stack'][] = array( 'tag' => 'title', 'string' => "\n" ); break; - case "p": $src .= "\n"; $p['stack'][] = array( 'tag' => 'p', 'string' => "\n" ); break; - case "b": $src .= '__'; $p['stack'][] = array( 'tag' => 'b', 'string' => '__' ); break; - case "i": $src .= "''"; $p['stack'][] = array( 'tag' => 'i', 'string' => "''" ); break; - case "u": $src .= "=="; $p['stack'][] = array( 'tag' => 'u', 'string' => "==" ); break; - case "center": $src .= '::'; $p['stack'][] = array( 'tag' => 'center', 'string' => '::' ); break; - case "code": $src .= '-+'; $p['stack'][] = array( 'tag' => 'code', 'string' => '+-' ); break; - // headers detection looks like real suxx code... - // but possible it run faster :) I don't know where is profiler in PHP... - case "h1": $src .= "\n!"; $p['stack'][] = array( 'tag' => 'h1', 'string' => "\n" ); break; - case "h2": $src .= "\n!!"; $p['stack'][] = array( 'tag' => 'h2', 'string' => "\n" ); break; - case "h3": $src .= "\n!!!"; $p['stack'][] = array( 'tag' => 'h3', 'string' => "\n" ); break; - case "h4": $src .= "\n!!!!"; $p['stack'][] = array( 'tag' => 'h4', 'string' => "\n" ); break; - case "h5": $src .= "\n!!!!!"; $p['stack'][] = array( 'tag' => 'h5', 'string' => "\n" ); break; - case "h6": $src .= "\n!!!!!!"; $p['stack'][] = array( 'tag' => 'h6', 'string' => "\n" ); break; - case "pre": $src .= '~pp~'; $p['stack'][] = array( 'tag' => 'pre', 'string' => '~/pp~' ); break; - // Table parser - case "table": $src .= '||'; $p['stack'][] = array( 'tag' => 'table', 'string' => '||' ); break; - case "tr": $p['first_td'] = true; break; - case "td": $src .= $p['first_td'] ? '' : '|'; $p['first_td'] = false; break; - // Lists parser - case "ul": $p['listack'][] = '*'; break; - case "ol": $p['listack'][] = '#'; break; - case "li": - // Generate wiki list item according to current list depth. - //( ensure '*/#' starts from begining of line ) - for( $l = ''; strlen( $l ) < count( $p['listack'] ); $l .= end( $p['listack'] ) ); - $src .= "\n$l "; - break; - case "font": - // If color attribute present in tag - if( isset( $c[$i]["pars"]["color"]["value"] ) ) { - $src .= '~~'.$c[$i]["pars"]["color"]["value"].':'; - $p['stack'][] = array( 'tag' => 'font', 'string' => '~~' ); - } - break; - case "img": - // If src attribute present in tag - if( isset( $c[$i]["pars"]["src"]["value"] ) ) { - // Note what it produce( img ) not {img}! Will fix this below... - $src .= '( img src='.$c[$i]["pars"]["src"]["value"].' )'; + switch ($c[$i]["type"]) { + case "text": + $src .= $c[$i]["data"]; + break; + case "tag": + switch ($c[$i]["data"]["type"]) { + case "open": + switch ($c[$i]["data"]["name"]) { + case "br": + $src .= "\n"; + break; + case "title": + $src .= "\n!"; + $p['stack'][] = [ 'tag' => 'title', 'string' => "\n" ]; + break; + case "p": + $src .= "\n"; + $p['stack'][] = [ 'tag' => 'p', 'string' => "\n" ]; + break; + case "b": + $src .= '__'; + $p['stack'][] = [ 'tag' => 'b', 'string' => '__' ]; + break; + case "i": + $src .= "''"; + $p['stack'][] = [ 'tag' => 'i', 'string' => "''" ]; + break; + case "u": + $src .= "=="; + $p['stack'][] = [ 'tag' => 'u', 'string' => "==" ]; + break; + case "center": + $src .= '::'; + $p['stack'][] = [ 'tag' => 'center', 'string' => '::' ]; + break; + case "code": + $src .= '-+'; + $p['stack'][] = [ 'tag' => 'code', 'string' => '+-' ]; + break; + // headers detection looks like real suxx code... + // but possible it run faster :) I don't know where is profiler in PHP... + case "h1": + $src .= "\n!"; + $p['stack'][] = [ 'tag' => 'h1', 'string' => "\n" ]; + break; + case "h2": + $src .= "\n!!"; + $p['stack'][] = [ 'tag' => 'h2', 'string' => "\n" ]; + break; + case "h3": + $src .= "\n!!!"; + $p['stack'][] = [ 'tag' => 'h3', 'string' => "\n" ]; + break; + case "h4": + $src .= "\n!!!!"; + $p['stack'][] = [ 'tag' => 'h4', 'string' => "\n" ]; + break; + case "h5": + $src .= "\n!!!!!"; + $p['stack'][] = [ 'tag' => 'h5', 'string' => "\n" ]; + break; + case "h6": + $src .= "\n!!!!!!"; + $p['stack'][] = [ 'tag' => 'h6', 'string' => "\n" ]; + break; + case "pre": + $src .= '~pp~'; + $p['stack'][] = [ 'tag' => 'pre', 'string' => '~/pp~' ]; + break; + // Table parser + case "table": + $src .= '||'; + $p['stack'][] = [ 'tag' => 'table', 'string' => '||' ]; + break; + case "tr": + $p['first_td'] = true; + break; + case "td": + $src .= $p['first_td'] ? '' : '|'; + $p['first_td'] = false; + break; + // Lists parser + case "ul": + $p['listack'][] = '*'; + break; + case "ol": + $p['listack'][] = '#'; + break; + case "li": + // Generate wiki list item according to current list depth. + //( ensure '*/#' starts from begining of line ) + for ( $l = ''; strlen( $l ) < count( $p['listack'] ); $l .= end( $p['listack'] ) ) + ; + $src .= "\n$l "; + break; + case "font": + // If color attribute present in tag + if (isset( $c[$i]["pars"]["color"]["value"] )) { + $src .= '~~' . $c[$i]["pars"]["color"]["value"] . ':'; + $p['stack'][] = [ 'tag' => 'font', 'string' => '~~' ]; + } + break; + case "img": + // If src attribute present in tag + if (isset( $c[$i]["pars"]["src"]["value"] )) { + // Note what it produce( img ) not {img}! Will fix this below... + $src .= '( img src=' . $c[$i]["pars"]["src"]["value"] . ' )'; + } + break; + case "a": + // If href attribute present in tag + if (isset( $c[$i]["pars"]["href"]["value"] )) { + $src .= '[' . $c[$i]["pars"]["href"]["value"] . '|'; + $p['stack'][] = [ 'tag' => 'a', 'string' => ']' ]; + } + break; } break; - case "a": - // If href attribute present in tag - if( isset( $c[$i]["pars"]["href"]["value"] ) ) { - $src .= '['.$c[$i]["pars"]["href"]["value"].'|'; - $p['stack'][] = array( 'tag' => 'a', 'string' => ']' ); + default: + switch ($c[$i]["data"]["name"]) { + case "ul": + if (end( $p['listack'] ) == '*') + array_pop( $p['listack'] ); + break; + case "ol": + if (end( $p['listack'] ) == '#') + array_pop( $p['listack'] ); + break; + default: + $e = end( $p['stack'] ); + if ($c[$i]["data"]["name"] == $e['tag']) { + $src .= $e['string']; + array_pop( $p['stack'] ); + } + break; } break; } - } else { - // This is close tag type. Is that smth we r waiting for? - switch( $c[$i]["data"]["name"] ) { - case "ul": - if( end( $p['listack'] ) == '*' ) array_pop( $p['listack'] ); - break; - case "ol": - if( end( $p['listack'] ) == '#' ) array_pop( $p['listack'] ); - break; - default: - $e = end( $p['stack'] ); - if( $c[$i]["data"]["name"] == $e['tag'] ) { - $src .= $e['string']; - array_pop( $p['stack'] ); - } - break; - } - } + break; } // Recursive call on tags with content... if( isset( $c[$i]["content"] ) ) { @@ -405,10 +470,10 @@ function walk_and_parse( &$c, &$src, &$p ) { } if( isset( $_REQUEST["suck_url"] ) ) { if( !$gBitSystem->isFeatureActive( 'wiki_url_import' ) ) { - $gBitSystem->fatalError( tra( "Importing remote URLs is disabled" )); + $gBitSystem->fatalError( KernelTools::tra( "Importing remote URLs is disabled" )); } // Suck another page and append to the end of current - require_once( UTIL_PKG_INCLUDE_PATH.'htmlparser/html_parser_inc.php' ); + require_once UTIL_PKG_INCLUDE_PATH.'htmlparser/html_parser_inc.php'; $suck_url = isset( $_REQUEST["suck_url"] ) ? $_REQUEST["suck_url"] : ''; $parsehtml = isset( $_REQUEST["parsehtml"] ) ? ( $_REQUEST["parsehtml"] == 'on' ? 'y' : 'n' ): 'n'; if( isset( $_REQUEST['do_suck'] ) && strlen( $suck_url ) > 0 ) { @@ -425,22 +490,22 @@ if( isset( $_REQUEST["suck_url"] ) ) { $parsed_url = parse_url($suck_url); //Disallow urls without schema (usually relative urls), or http(s) if(!isset($parsed_url['scheme']) || ($parsed_url['scheme']!='http' && $parsed_url['scheme']!='https')){ - $gBitSystem->fatalError( tra( "Invalid URL; not absolute or not HTTP" )); + $gBitSystem->fatalError( KernelTools::tra( "Invalid URL; not absolute or not HTTP" )); } //Make sure the passed host isn't local if(!isset($parsed_url['host']) || ($parsed_url['host']=='localhost') || strncmp($parsed_url['host'],"127.",4)==0){ - $gBitSystem->fatalError( tra( "The host specified is either empty or local." )); + $gBitSystem->fatalError( KernelTools::tra( "The host specified is either empty or local." )); } $sdta = @file_get_contents( $suck_url ); if( isset( $php_errormsg ) && strlen( $php_errormsg ) ) { - $gBitSystem->fatalError( tra( "Can't import remote HTML page" )); + $gBitSystem->fatalError( KernelTools::tra( "Can't import remote HTML page" )); } // Need to parse HTML? if( $parsehtml == 'y' ) { // Read compiled( serialized ) grammar $grammarfile = UTIL_PKG_INCLUDE_PATH.'htmlparser/htmlgrammar.cmp'; if( !$fp = @fopen( $grammarfile,'r' ) ) { - $gBitSystem->fatalError( tra( "Can't parse remote HTML page" )); + $gBitSystem->fatalError( KernelTools::tra( "Can't parse remote HTML page" )); } $grammar = unserialize( fread( $fp, filesize( $grammarfile ) ) ); fclose( $fp ); @@ -449,7 +514,7 @@ if( isset( $_REQUEST["suck_url"] ) ) { $htmlparser->Parse(); // Should I try to convert HTML to wiki? $parseddata = ''; - $p = array( 'stack' => array(), 'listack' => array(), 'first_td' => false ); + $p = [ 'stack' => [], 'listack' => [], 'first_td' => false ]; walk_and_parse( $htmlparser->content, $parseddata, $p ); // Is some tags still opened?( It can be if HTML not valid, but this is not reason // to produce invalid wiki : ) @@ -472,9 +537,3 @@ if( isset( $_REQUEST["suck_url"] ) ) { $_REQUEST['edit'] .= $sdta; } } - -//*************************************** - - - -?> diff --git a/edit_book.php b/edit_book.php old mode 100644 new mode 100755 index af7e1be..081f8bf --- a/edit_book.php +++ b/edit_book.php @@ -13,17 +13,17 @@ /** * required setup */ -require_once( '../kernel/includes/setup_inc.php' ); +require_once '../kernel/includes/setup_inc.php'; +use \Bitweaver\BitBase; +use \Bitweaver\Liberty\LibertyStructure; +use \Bitweaver\Wiki\BitBook; +use \Bitweaver\Wiki\BitPage; -if( isset( $_COOKIE['book_section'] ) && $_COOKIE['book_section'] == 'o' ) { - $book_section = 'block'; -} else { - $book_section = 'none'; -} -$gBitSmarty->assign( 'book_section',$book_section ); +$book_section = isset( $_COOKIE['book_section'] ) && $_COOKIE['book_section'] == 'o' + ? $book_section = 'block' + : 'none'; -include_once( LIBERTY_PKG_CLASS_PATH.'LibertyStructure.php'); -include_once( WIKI_PKG_CLASS_PATH.'BitBook.php'); +$gBitSmarty->assign( 'book_section',$book_section ); global $gStructure; @@ -33,15 +33,15 @@ global $gStructure; **/ // get a book instance global $gContent; -if( BitBase::verifyIdParameter( $_REQUEST, 'structure_id' ) || BitBase::verifyIdParameter( $_REQUEST, 'content_id' ) ) { - include_once( LIBERTY_PKG_INCLUDE_PATH.'lookup_content_inc.php' ); +if( BitBase::verifyId( $_REQUEST["structure_id"] ) || BitBase::verifyId( $_REQUEST["content_id"] ) ) { + include_once LIBERTY_PKG_INCLUDE_PATH.'lookup_content_inc.php'; if( empty( $gContent ) ){ $gBitSystem->fatalError( 'Error: Invalid structure id, the book you requested could not be found.' ); } elseif( empty( $_REQUEST["structure_id"] ) ) { // we were passed a valid content_id. Make sure the root node exists, and if not, create it. $newStructure = new LibertyStructure(); // alias => '' is a temporary setting until alias stuff has been removed - if( !$node = $newStructure->getNode( NULL, $gContent->mContentId ) ) { + if( !$node = $newStructure->getNode( -2, $gContent->mContentId ) ) { $structureHash = array( 'content_id' => $gContent->mContentId, 'alias' => '' ); $_REQUEST["structure_id"] = $newStructure->storeNode( $structureHash ); } else { @@ -71,7 +71,7 @@ if( $gContent->isValid() ){ if( isset($_REQUEST["createstructure"]) ) { if ((empty($_REQUEST['name']))) { $gBitSmarty->assign('msg', tra("You must specify a name.")); - $gBitSystem->display( 'error.tpl' , NULL, array( 'display_mode' => 'edit' )); + $gBitSystem->display( 'error.tpl' , null, array( 'display_mode' => 'edit' )); die; } @@ -95,7 +95,7 @@ if( isset($_REQUEST["createstructure"]) ) { //Cannot create a structure if a structure already exists if (!isset($structure_id)) { $gBitSmarty->assign('msg', $_REQUEST['name'] . " " . tra("page not added (Exists)")); - $gBitSystem->display( 'error.tpl' , NULL, array( 'display_mode' => 'edit' )); + $gBitSystem->display( 'error.tpl' , null, array( 'display_mode' => 'edit' )); die; } @@ -118,16 +118,16 @@ if( isset($_REQUEST["createstructure"]) ) { $params['title'] = trim($chapterName); $params['edit'] = ''; if( !$nodePage->store( $params ) ) { - $gBitSystem->fatalError( "There was an error storing the page: ".vc( $gContent->mErrors )); + $gBitSystem->fatalError( "There was an error storing the page: ".\Bitweaver\vc( $gContent->mErrors )); } } $nodeHash['content_id'] = $nodePage->mContentId; $nodeHash['after_ref_id'] = $gStructure->storeNode( $nodeHash ); } } - bit_redirect( WIKI_PKG_URL."edit_book.php?structure_id=".$structure_id ); + header( "location: ".WIKI_PKG_URL."edit_book.php?structure_id=".$structure_id ); } else { - $gBitSmarty->assignByRef( 'errors', $gContent->mErrors ); + $gBitSmarty->assign( 'errors', $gContent->mErrors ); $gBitSmarty->assign( 'name', $_REQUEST['name']); $gBitSmarty->assign( 'chapters', $_REQUEST['chapters']); $mid = 'bitpackage:wiki/create_book.tpl'; @@ -140,7 +140,7 @@ if( isset($_REQUEST["createstructure"]) ) { // set the correct display template $mid = 'bitpackage:wiki/edit_book.tpl'; - include_once( LIBERTY_PKG_INCLUDE_PATH.'structure_edit_inc.php'); + include_once LIBERTY_PKG_INCLUDE_PATH.'structure_edit_inc.php'; if( $gBitThemes->isAjaxRequest() ) { $gBitSmarty->display( 'bitpackage:kernel/feedback_inc.tpl' ); } @@ -149,7 +149,6 @@ if( isset($_REQUEST["createstructure"]) ) { $gBitSystem->setBrowserTitle( 'Create Wiki Book' ); $mid = 'bitpackage:wiki/create_book.tpl'; } -$gBitSystem->setBrowserTitle( !empty($gStructure) && $gStructure->isValid() ? 'Edit Wiki Book:'.$gStructure->getField( 'title' ) : NULL ); +$gBitSystem->setBrowserTitle( !empty($gStructure) && $gStructure->isValid() ? 'Edit Wiki Book:'.$gStructure->getField( 'title' ) : null ); // Display the template -$gBitSystem->display( $mid , NULL, array( 'display_mode' => 'edit' )); -?> +$gBitSystem->display( $mid , null, array( 'display_mode' => 'edit' )); \ No newline at end of file diff --git a/export_wiki_pages.php b/export_wiki_pages.php old mode 100644 new mode 100755 index cf78b56..e1a516a --- a/export_wiki_pages.php +++ b/export_wiki_pages.php @@ -13,9 +13,9 @@ /** * required setup */ -require_once( '../kernel/includes/setup_inc.php' ); -include_once( UTIL_PKG_INCLUDE_PATH.'zip_lib.php' ); -include_once( WIKI_PKG_INCLUDE_PATH.'export_lib.php' ); +require_once '../kernel/includes/setup_inc.php'; +include_once UTIL_PKG_INCLUDE_PATH.'zip_lib.php'; +include_once WIKI_PKG_INCLUDE_PATH.'export_lib.php'; if (!$gBitUser->hasPermission( 'p_wiki_admin' )) die; if (!isset($_REQUEST["page_id"])) { @@ -23,14 +23,10 @@ if (!isset($_REQUEST["page_id"])) { $exportlib->MakeWikiZip( TEMP_PKG_PATH.$exportName ); header ("location: ".TEMP_PKG_URL.$exportName ); } else { - if (isset($_REQUEST["all"])) - $all = 0; - else - $all = 1; + $all = isset($_REQUEST["all"]) ? 0 : 1; $data = $exportlib->export_wiki_page($_REQUEST["page_id"], $all); $pageId = $_REQUEST["page_id"]; header ("Content-type: application/unknown"); header ("Content-Disposition: inline; filename=$pageId"); echo $data; } -?> diff --git a/index.php b/index.php old mode 100644 new mode 100755 index 9cc8fd5..fb29a0c --- a/index.php +++ b/index.php @@ -13,19 +13,19 @@ /** * required setup */ -require_once( '../kernel/includes/setup_inc.php' ); +namespace Bitweaver\Wiki; +require_once '../kernel/includes/setup_inc.php'; $gBitSystem->verifyPackage( 'wiki' ); -require_once( WIKI_PKG_CLASS_PATH.'BitPage.php' ); if( !empty( $_REQUEST['structure_id'] ) ) { - include( LIBERTY_PKG_INCLUDE_PATH.'structure_display_inc.php' ); + include LIBERTY_PKG_INCLUDE_PATH.'structure_display_inc.php'; } else { - // if no page set + // if no page set if ( !isset( $_REQUEST['page'] ) and !isset( $_REQUEST['page_id'] ) ) { // if auto create home page disabled just get a list if( $gBitSystem->isFeatureActive( 'wiki_disable_auto_home' ) ){ - include( WIKI_PKG_PATH.'list_pages.php' ); + include WIKI_PKG_PATH.'list_pages.php'; die; } // auto fetch/create default home page @@ -35,17 +35,17 @@ if( !empty( $_REQUEST['structure_id'] ) ) { $gHome = new BitPage(); $wikiHome = $gBitSystem->getConfig( "wiki_home_page", 'HomePage' ); if( !($gHome->pageExists( $wikiHome ) ) ) { - $homeHash = array( - 'title' => ( isset( $wikiHome ) ? $wikiHome : 'HomePage' ), + $homeHash = [ + 'title' => $wikiHome ?? 'HomePage', 'creator_user_id' => ROOT_USER_ID, 'modifier_user_id' => ROOT_USER_ID, - 'edit' => 'Welcome to '.( $gBitSystem->getConfig( 'site_title', 'our site' ) ) ); + 'edit' => 'Welcome to '.( $gBitSystem->getConfig( 'site_title', 'our site' ) ) ]; $gHome->store( $homeHash ); } - - include( WIKI_PKG_INCLUDE_PATH.'lookup_page_inc.php' ); + + include WIKI_PKG_INCLUDE_PATH.'lookup_page_inc.php'; if( $gContent->isValid() ) { $gBitSystem->setCanonicalLink( $gContent->getDisplayUrl() ); } - include( WIKI_PKG_INCLUDE_PATH.'display_bitpage_inc.php' ); + include WIKI_PKG_INCLUDE_PATH.'display_bitpage_inc.php'; } diff --git a/like_pages.php b/like_pages.php old mode 100644 new mode 100755 index 2762e24..daf0af3 --- a/like_pages.php +++ b/like_pages.php @@ -13,21 +13,24 @@ /** * required setup */ -require_once( '../kernel/includes/setup_inc.php' ); -include_once( WIKI_PKG_CLASS_PATH.'BitPage.php'); -include_once( WIKI_PKG_INCLUDE_PATH.'lookup_page_inc.php' ); +namespace Bitweaver\Wiki; +use Bitweaver\KernelTools; + +require_once '../kernel/includes/setup_inc.php'; + +include_once WIKI_PKG_INCLUDE_PATH.'lookup_page_inc.php'; + $gBitSystem->verifyPackage( 'wiki' ); $gBitSystem->verifyFeature( 'wiki_like_pages' ); $gBitSystem->verifyPermission( 'p_wiki_list_pages' ); // Get the page from the request var or default it to HomePage if( !$gContent->isValid() ) { - $gBitSystem->fatalError( tra( "No page indicated" )); + $gBitSystem->fatalError( KernelTools::tra( "No page indicated" )); } $likepages = $gContent->getLikePages( $gContent->mInfo['title'] ); -$gBitSmarty->assignByRef( 'likepages', $likepages ); +$gBitSmarty->assign( 'likepages', $likepages ); // Display the template -$gBitSystem->display( 'bitpackage:wiki/like_pages.tpl', NULL, array( 'display_mode' => 'display' )); -?> +$gBitSystem->display( 'bitpackage:wiki/like_pages.tpl', null, array( 'display_mode' => 'display' )); \ No newline at end of file diff --git a/list_pages.php b/list_pages.php old mode 100644 new mode 100755 index d6dd9b8..cdf907f --- a/list_pages.php +++ b/list_pages.php @@ -7,8 +7,9 @@ /** * required setup */ -require_once( '../kernel/includes/setup_inc.php' ); -require_once( WIKI_PKG_CLASS_PATH.'BitPage.php' ); +require_once '../kernel/includes/setup_inc.php'; +use Bitweaver\Wiki\BitPage; +use Bitweaver\KernelTools; // verify stuff $gBitSystem->verifyPackage( 'wiki' ); @@ -32,23 +33,19 @@ if( isset( $_REQUEST["batch_submit"] ) && isset( $_REQUEST["checked"] ) && $_REQ if( !empty( $_REQUEST['cancel'] )) { // user cancelled - just continue on, doing nothing } elseif( empty( $_REQUEST['confirm'] )) { - $formHash['delete'] = TRUE; + $formHash['delete'] = true; $formHash['batch_submit'] = 'remove_pages'; foreach( $_REQUEST["checked"] as $del ) { $tmpPage = new BitPage( $del); - if( $tmpPage->load() && !empty( $tmpPage->mInfo['title'] )) { - $info = $tmpPage->mInfo['title']; - } else { - $info = $del; - } + $info = $tmpPage->load() && !empty( $tmpPage->mInfo['title'] ) ? $tmpPage->mInfo['title'] : $del; $formHash['input'][] = ''.$info; } $gBitSystem->confirmDialog( $formHash, - array( - 'warning' => tra('Are you sure you want to delete these pages?') . ' (' . tra('Count: ') . count( $_REQUEST["checked"] ) . ')', - 'error' => tra('This cannot be undone!'), - ) - ); + [ + 'warning' => KernelTools::tra('Are you sure you want to delete these pages?') . ' (' . KernelTools::tra('Count: ') . count( $_REQUEST["checked"] ) . ')', + 'error' => KernelTools::tra('This cannot be undone!'), + ] + ); } else { foreach( $_REQUEST["checked"] as $deletepage ) { $tmpPage = new BitPage( $deletepage ); @@ -57,18 +54,18 @@ if( isset( $_REQUEST["batch_submit"] ) && isset( $_REQUEST["checked"] ) && $_REQ } } if( !empty( $errors )) { - $gBitSmarty->assignByRef( 'errors', $errors ); + $gBitSmarty->assign( 'errors', $errors ); } } } -$gBitSmarty->assignByRef( "gContent", $gContent ); +$gBitSmarty->assign( "gContent", $gContent ); if( !empty( $_REQUEST['sort_mode'] )) { $listHash['sort_mode'] = preg_replace( '/^user_/', 'creator_user_', $_REQUEST['sort_mode'] ); } $listHash = $_REQUEST; -$listHash['extras'] = TRUE; +$listHash['extras'] = true; $listpages = $gContent->getList( $listHash ); // we will probably need a better way to do this @@ -77,9 +74,8 @@ $listHash['listInfo']['parameters']['find_author'] = !empty( $listHash['fin $listHash['listInfo']['parameters']['find_last_editor'] = !empty( $listHash['find_last_editor'] ) ? $listHash['find_last_editor'] : ''; $listHash['listInfo']['ihash']['content_type_guid'] = BITPAGE_CONTENT_TYPE_GUID; -$gBitSmarty->assignByRef( 'listpages', $listpages ); -$gBitSmarty->assignByRef( 'listInfo', $listHash['listInfo'] ); +$gBitSmarty->assign( 'listpages', $listpages ); +$gBitSmarty->assign( 'listInfo', $listHash['listInfo'] ); // Display the template -$gBitSystem->display( 'bitpackage:wiki/list_pages.tpl', tra( 'Wiki Pages' ), array( 'display_mode' => 'list' )); -?> +$gBitSystem->display( 'bitpackage:wiki/list_pages.tpl', KernelTools::tra( 'Wiki Pages' ), [ 'display_mode' => 'list' ] ); \ No newline at end of file diff --git a/orphan_pages.php b/orphan_pages.php old mode 100644 new mode 100755 index 7ba51be..cee77fe --- a/orphan_pages.php +++ b/orphan_pages.php @@ -7,8 +7,9 @@ /** * required setup */ -require_once( '../kernel/includes/setup_inc.php' ); -include_once( WIKI_PKG_CLASS_PATH.'BitPage.php' ); +require_once '../kernel/includes/setup_inc.php'; +use Bitweaver\Wiki\BitPage; +use Bitweaver\KernelTools; // verify stuff $gBitSystem->verifyPackage( 'wiki' ); @@ -32,21 +33,18 @@ if( isset( $_REQUEST["batch_submit"] ) && isset( $_REQUEST["checked"] ) && $_REQ if( !empty( $_REQUEST['cancel'] )) { // user cancelled - just continue on, doing nothing } elseif( empty( $_REQUEST['confirm'] )) { - $formHash['delete'] = TRUE; + $formHash['delete'] = true; $formHash['batch_submit'] = 'remove_pages'; foreach( $_REQUEST["checked"] as $del ) { $tmpPage = new BitPage( $del); - if( $tmpPage->load() && !empty( $tmpPage->mInfo['title'] )) { - $info = $tmpPage->mInfo['title']; - } else { - $info = $del; - } + $info = $tmpPage->load() && !empty( $tmpPage->mInfo['title'] ) ? $tmpPage->mInfo['title'] : $del; + $formHash['input'][] = ''.$info; } $gBitSystem->confirmDialog( $formHash, array( - 'warning' => tra('Are you sure you want to delete these pages?') . ' (' . tra('Count: ') . count( $_REQUEST["checked"] ) . ')', - 'error' => tra('This cannot be undone!'), + 'warning' => KernelTools::tra('Are you sure you want to delete these pages?') . ' (' . KernelTools::tra('Count: ') . count( $_REQUEST["checked"] ) . ')', + 'error' => KernelTools::tra('This cannot be undone!'), ) ); } else { @@ -57,20 +55,20 @@ if( isset( $_REQUEST["batch_submit"] ) && isset( $_REQUEST["checked"] ) && $_REQ } } if( !empty( $errors )) { - $gBitSmarty->assignByRef( 'errors', $errors ); + $gBitSmarty->assign( 'errors', $errors ); } } } $gContent = new BitPage(); -$gBitSmarty->assignByRef( "gContent", $gContent ); +$gBitSmarty->assign( "gContent", $gContent ); if( !empty( $_REQUEST['sort_mode'] )) { $listHash['sort_mode'] = preg_replace( '/^user_/', 'creator_user_', $_REQUEST['sort_mode'] ); } $listHash = $_REQUEST; -$listHash['extras'] = TRUE; -$listHash['orphans_only'] = TRUE; +$listHash['extras'] = true; +$listHash['orphans_only'] = true; $listpages = $gContent->getList( $listHash ); // we will probably need a better way to do this @@ -78,9 +76,8 @@ $listHash['listInfo']['parameters']['find_title'] = !empty( $listHash['fin $listHash['listInfo']['parameters']['find_author'] = !empty( $listHash['find_author'] ) ? $listHash['find_author'] : ''; $listHash['listInfo']['parameters']['find_last_editor'] = !empty( $listHash['find_last_editor'] ) ? $listHash['find_last_editor'] : ''; -$gBitSmarty->assignByRef( 'listpages', $listpages ); -$gBitSmarty->assignByRef( 'listInfo', $listHash['listInfo'] ); +$gBitSmarty->assign( 'listpages', $listpages ); +$gBitSmarty->assign( 'listInfo', $listHash['listInfo'] ); // Display the template -$gBitSystem->display( 'bitpackage:wiki/orphan_pages.tpl', tra( 'Orphan Pages' ), array( 'display_mode' => 'list' )); -?> +$gBitSystem->display( 'bitpackage:wiki/orphan_pages.tpl', KernelTools::tra( 'Orphan Pages' ), array( 'display_mode' => 'list' )); diff --git a/page_history.php b/page_history.php old mode 100644 new mode 100755 index 86f18fe..add60d5 --- a/page_history.php +++ b/page_history.php @@ -13,24 +13,25 @@ /** * required setup */ -require_once( '../kernel/includes/setup_inc.php' ); -require_once( WIKI_PKG_CLASS_PATH.'BitPage.php'); +require_once '../kernel/includes/setup_inc.php'; +use Bitweaver\Wiki\BitPage; +use Bitweaver\KernelTools; $gBitSystem->verifyPackage( 'wiki' ); $gBitSystem->verifyFeature( 'wiki_history' ); // Get the page from the request var or default it to HomePage -include( WIKI_PKG_INCLUDE_PATH.'lookup_page_inc.php' ); +include WIKI_PKG_INCLUDE_PATH.'lookup_page_inc.php'; //vd($gContent->mPageId);vd($gContent->mInfo); if( !$gContent->isValid() || empty( $gContent->mInfo ) ) { - $gBitSystem->fatalError( tra( "Unknown page" )); + $gBitSystem->fatalError( KernelTools::tra( "Unknown page" )); } $gContent->verifyViewPermission(); $gContent->verifyUserPermission( 'p_wiki_view_history' ); -$gBitSmarty->assignByRef( 'pageInfo', $gContent->mInfo ); +$gBitSmarty->assign( 'pageInfo', $gContent->mInfo ); if (!empty( $_REQUEST['rollback_preview'] )) { $gBitSmarty->assign( 'rollback_preview', $_REQUEST['rollback_preview']); @@ -39,7 +40,7 @@ if (!empty( $_REQUEST['rollback_preview'] )) { // set up stuff to get history working $smartyContentRef = 'pageInfo'; $rollbackPerm = 'p_wiki_rollback'; -include_once( LIBERTY_PKG_INCLUDE_PATH.'content_history_inc.php' ); +include_once LIBERTY_PKG_INCLUDE_PATH.'content_history_inc.php'; // pagination stuff $gBitSmarty->assign( 'page', $page = !empty( $_REQUEST['page'] ) ? $_REQUEST['page'] : 1 ); @@ -48,11 +49,11 @@ if( !empty( $_REQUEST['list_page'] )) { } $offset = ( $page - 1 ) * $gBitSystem->getConfig( 'max_records' ); -$history = $gContent->getHistory( NULL, NULL, $offset, $gBitSystem->getConfig( 'max_records' ) ); -$gBitSmarty->assignByRef( 'data', $history['data'] ); -$gBitSmarty->assignByRef( 'listInfo', $history['listInfo'] ); +$history = $gContent->getHistory( null, null, $offset, $gBitSystem->getConfig( 'max_records' ) ); +$gBitSmarty->assign( 'data', $history['data'] ); +$gBitSmarty->assign( 'listInfo', $history['listInfo'] ); // Display the template -$gBitSmarty->assignByRef( 'gContent', $gContent ); -$gBitSystem->display( 'bitpackage:wiki/page_history.tpl' , NULL, array( 'display_mode' => 'display' )); -?> +$gBitSmarty->assign( 'gContent', $gContent ); +$gBitSystem->display( 'bitpackage:wiki/page_history.tpl' , null, array( 'display_mode' => 'display' )); + diff --git a/page_loader.php b/page_loader.php old mode 100644 new mode 100755 index bcc9b33..0815d23 --- a/page_loader.php +++ b/page_loader.php @@ -13,8 +13,8 @@ /** * required setup */ -include_once( '../../kernel/includes/setup_inc.php' ); -include_once (HTML_PKG_INCLUDE_PATH.'htmlpages_lib.php'); +include_once '../../kernel/includes/setup_inc.php'; +include_once HTML_PKG_INCLUDE_PATH.'htmlpages_lib.php'; $refresh = 1000 * $_REQUEST["refresh"]; ?> @@ -22,7 +22,7 @@ $refresh = 1000 * $_REQUEST["refresh"];