diff options
| author | lsces <lester@lsces.co.uk> | 2025-08-27 15:26:05 +0100 |
|---|---|---|
| committer | lsces <lester@lsces.co.uk> | 2025-08-27 15:26:05 +0100 |
| commit | 2da9ac4036cbef4ce4cad3f99c9a359633840e53 (patch) | |
| tree | f0829724b386aa89c3a222b1094bde97183183a7 /includes | |
| parent | 9718d623a0b1d61144bb4779fd989baac08db35d (diff) | |
| download | liberty-2da9ac4036cbef4ce4cad3f99c9a359633840e53.tar.gz liberty-2da9ac4036cbef4ce4cad3f99c9a359633840e53.tar.bz2 liberty-2da9ac4036cbef4ce4cad3f99c9a359633840e53.zip | |
Remaining code changes to cover namespace and style changes for PHP8.4
Diffstat (limited to 'includes')
| -rwxr-xr-x[-rw-r--r--] | includes/bit_setup_inc.php | 35 | ||||
| -rwxr-xr-x[-rw-r--r--] | includes/calculate_max_upload_inc.php | 2 | ||||
| -rwxr-xr-x[-rw-r--r--] | includes/comments_inc.php | 190 | ||||
| -rwxr-xr-x[-rw-r--r--] | includes/content_history_inc.php | 39 | ||||
| -rwxr-xr-x[-rw-r--r--] | includes/display_content_inc.php | 7 | ||||
| -rwxr-xr-x[-rw-r--r--] | includes/edit_help_inc.php | 8 | ||||
| -rwxr-xr-x[-rw-r--r--] | includes/edit_storage_inc.php | 2 | ||||
| -rwxr-xr-x[-rw-r--r--] | includes/get_content_list_inc.php | 38 | ||||
| -rwxr-xr-x[-rw-r--r--] | includes/help_format_tikiwiki_inc.php | 186 | ||||
| -rwxr-xr-x[-rw-r--r--] | includes/liberty_lib.php | 254 | ||||
| -rwxr-xr-x[-rw-r--r--] | includes/lookup_content_inc.php | 24 | ||||
| -rwxr-xr-x[-rw-r--r--] | includes/structure_display_inc.php | 2 | ||||
| -rwxr-xr-x[-rw-r--r--] | includes/structure_edit_inc.php | 52 |
13 files changed, 409 insertions, 430 deletions
diff --git a/includes/bit_setup_inc.php b/includes/bit_setup_inc.php index 88238c7..1934883 100644..100755 --- a/includes/bit_setup_inc.php +++ b/includes/bit_setup_inc.php @@ -7,20 +7,24 @@ * @package liberty * @subpackage functions */ +namespace Bitweaver\Liberty; +use Bitweaver\BitBase; +use Bitweaver\KernelTools; -$registerHash = array( +$pRegisterHash = [ 'package_name' => 'liberty', 'package_path' => dirname( dirname( __FILE__ ) ).'/', - 'required_package'=> TRUE, -); -$gBitSystem->registerPackage( $registerHash ); + 'required_package'=> true, +]; +$gBitSystem->registerPackage( $pRegisterHash ); // initiate LibertySystem -require_once( LIBERTY_PKG_CLASS_PATH.'LibertySystem.php' ); + LibertySystem::loadSingleton(); -$gBitSmarty->assignByRef( 'gLibertySystem', $gLibertySystem ); +$gBitSmarty->assign( 'gLibertySystem', $gLibertySystem ); +global $gLibertySystem; -// We can't load this in liberty/bit_setup_inc.php becuase it's too soon in the process. +// We can't load this in liberty/bit_setup_inc.php because it's too soon in the process. // packages haven't been scanned yet making things like <pkg>_PKG_URL and similar // unavailable to the plugins that are kept in <pkg>/liberty_plugins/ $current_default_format_guid = $gBitSystem->getConfig( 'default_format' ); @@ -35,7 +39,7 @@ if( $gLibertySystem->mDb->isValid() ) { // install condition check $gLibertySystem->registerService( 'liberty', LIBERTY_PKG_NAME, - array( + [ 'content_edit_mini_tpl' => 'bitpackage:liberty/service_content_edit_mini_inc.tpl', 'content_edit_tab_tpl' => 'bitpackage:liberty/service_content_edit_tab_inc.tpl', 'content_icon_tpl' => 'bitpackage:liberty/service_content_icon_inc.tpl', @@ -47,20 +51,19 @@ $gLibertySystem->registerService( 'liberty', 'content_load_sql_function' => 'liberty_content_load_sql', 'content_list_sql_function' => 'liberty_content_list_sql', 'content_preview_function' => 'liberty_content_preview', - ), - array( - 'description' => tra( 'Provides core functionality, including enforcing some access control and dynamic layout components.' ), - 'required' => TRUE, - ) + ], + [ + 'description' => KernelTools::tra( 'Provides core functionality, including enforcing some access control and dynamic layout components.' ), + 'required' => true, + ] ); // delete cache file if requested if( !empty( $_REQUEST['refresh_liberty_cache'] ) && BitBase::verifyId( $_REQUEST['refresh_liberty_cache'] )) { - require_once( LIBERTY_PKG_CLASS_PATH.'LibertyContent.php' ); + require_once LIBERTY_PKG_CLASS_PATH.'LibertyContent.php'; LibertyContent::expungeCacheFile( $_REQUEST['refresh_liberty_cache'] ); } // make thumbnail sizes available to smarty global $gThumbSizes; -$gBitSmarty->assignByRef( 'gThumbSizes', $gThumbSizes ); -?> +$gBitSmarty->assign( 'gThumbSizes', $gThumbSizes );
\ No newline at end of file diff --git a/includes/calculate_max_upload_inc.php b/includes/calculate_max_upload_inc.php index ee86071..384ba93 100644..100755 --- a/includes/calculate_max_upload_inc.php +++ b/includes/calculate_max_upload_inc.php @@ -21,5 +21,5 @@ if( $gBitSystem->isPackageActive( 'quota' ) ) { require_once( QUOTA_PKG_INCLUDE_PATH.'calculate_quota_inc.php' ); } -$gBitSmarty->assignByRef( 'uploadMax', $uploadMax ); +$gBitSmarty->assign( 'uploadMax', $uploadMax ); ?> diff --git a/includes/comments_inc.php b/includes/comments_inc.php index 66da4fd..f2815e5 100644..100755 --- a/includes/comments_inc.php +++ b/includes/comments_inc.php @@ -23,6 +23,10 @@ // this script may only be included - so its better to die if called directly. +use Bitweaver\Boards\BitBoardTopic; +use Bitweaver\Liberty\LibertyComment; +use Bitweaver\BitBase; +use Bitweaver\KernelTools; /** * Parameters that need to be set when calling this file @@ -35,20 +39,20 @@ /** * required setup */ -require_once( LIBERTY_PKG_CLASS_PATH.'LibertyComment.php' ); +require_once LIBERTY_PKG_CLASS_PATH.'LibertyComment.php'; global $commentsLib, $gBitSmarty, $gBitSystem, $gBitThemes; -$postComment = array(); -$formfeedback = array( 'error' => array() ); -$gBitSmarty->assignByRef( 'formfeedback', $formfeedback ); +$postComment = []; +$formfeedback = [ 'error' => [] ]; +$gBitSmarty->assign( 'formfeedback', $formfeedback ); // make sure that we don't feed ajax comments if we don't have javascript enabled if( !$gBitThemes->isJavascriptEnabled() ) { $gBitSystem->setConfig( 'comments_ajax', 'n' ); } -if( BitBase::verifyIdParameter( $_REQUEST, 'delete_comment_id' )) { +if( BitBase::verifyId( $_REQUEST['delete_comment_id'] ?? 0 )) { $deleteComment = new LibertyComment($_REQUEST['delete_comment_id']); // make sure we're loaded up before we delete $deleteComment->loadComment(); @@ -58,13 +62,13 @@ if( BitBase::verifyIdParameter( $_REQUEST, 'delete_comment_id' )) { } } -if( BitBase::verifyIdParameter( $_REQUEST, 'post_comment_id' ) && $gContent->hasUserPermission( 'p_liberty_post_comments' )) { +if( BitBase::verifyId( $_REQUEST['post_comment_id'] ?? 0 ) && $gContent->hasUserPermission( 'p_liberty_post_comments' )) { $post_comment_id = $_REQUEST['post_comment_id']; $editComment = new LibertyComment( $post_comment_id ); //if we are passed a comment id but not going to store it then turn off ajax if( !isset( $_REQUEST['post_comment_submit'] ) && !isset( $_REQUEST['post_comment_cancel'] )){ //even if ajax is on - we force it off in this case - $gBitSmarty->assign( 'comments_ajax', FALSE ); + $gBitSmarty->assign( 'comments_ajax', false ); } if( $editComment->mInfo['content_id'] ) { @@ -73,17 +77,17 @@ if( BitBase::verifyIdParameter( $_REQUEST, 'post_comment_id' ) && $gContent->has $postComment['title'] = $editComment->mInfo['title']; } else { $formfeedback['error'][] = "You do not have permission to edit this comment."; - $editComment = NULL; - $post_comment_id = NULL; + $editComment = null; + $post_comment_id = null; } } else { $formfeedback['error'][] = "Comment does not exist."; - $editComment = NULL; - $post_comment_id = NULL; + $editComment = null; + $post_comment_id = null; } } else { - $post_comment_id = NULL; - $editComment = NULL; + $post_comment_id = null; + $editComment = null; } $gBitSmarty->assign('post_comment_id', $post_comment_id); @@ -106,7 +110,7 @@ if( !empty( $_REQUEST['post_comment_submit'] ) && $gContent->hasUserPermission( // there are references to it in LibertyComments::verifyComments as well $_REQUEST['comments_parent_id'] = $commentsParentId; - $storeComment = new LibertyComment( @BitBase::verifyId( $editComment->mCommentId ) ? $editComment->mCommentId : NULL ); + $storeComment = new LibertyComment( BitBase::verifyId( $editComment->mCommentId ) ? $editComment->mCommentId : null ); if( empty( $formfeedback['error'] ) && $storeComment->storeComment( $_REQUEST )) { // store successful @@ -115,12 +119,12 @@ if( !empty( $_REQUEST['post_comment_submit'] ) && $gContent->hasUserPermission( // A new comment, and we have switchboard to send notifications global $gSwitchboardSystem; // Draft the message: - $message['subject'] = tra( 'New comment on:' ).' '.$gContent->getTitle().' @ '.$gBitSystem->getConfig( 'site_title' ); - $message['message'] = tra('A new message was posted to ').' '.$gContent->getTitle()."<br/>\n".$gContent->getDisplayUri()."<br/>\n" - .'/----- '.tra('Here is the message')." -----/<br/>\n<br/>\n".'<h2>'.$storeComment->getTitle()."</h2>\n".tra('By').' '.$gBitUser->getDisplayName()."\n<p>".$storeComment->getParsedData().'</p>'; + $message['subject'] = KernelTools::tra( 'New comment on:' ).' '.$gContent->getTitle().' @ '.$gBitSystem->getConfig( 'site_title' ); + $message['message'] = KernelTools::tra('A new message was posted to ').' '.$gContent->getTitle()."<br/>\n".$gContent->getDisplayUri()."<br/>\n" + .'/----- '.KernelTools::tra('Here is the message')." -----/<br/>\n<br/>\n".'<h2>'.$storeComment->getTitle()."</h2>\n".KernelTools::tra('By').' '.$gBitUser->getDisplayName()."\n<p>".$storeComment->getParsedData().'</p>'; $gSwitchboardSystem->sendEvent('My Content', 'new comment', $gContent->mContentId, $message ); } - $postComment = NULL; + $postComment = null; } else { // store fails handle errors and preview $formfeedback['error']=array_merge( $formfeedback['error'], $storeComment->mErrors ); @@ -130,9 +134,9 @@ if( !empty( $_REQUEST['post_comment_submit'] ) && $gContent->hasUserPermission( $postComment['anon_name'] = $_REQUEST['comment_name']; } - $_REQUEST['post_comment_request'] = TRUE; + $_REQUEST['post_comment_request'] = true; //this is critical and triggers other settings if store fails - do not remove without looking at what preview effects - $_REQUEST['post_comment_preview'] = TRUE; + $_REQUEST['post_comment_preview'] = true; } } elseif(!empty($_REQUEST['post_comment_request']) && !$gContent->hasUserPermission( 'p_liberty_post_comments' )) { $formfeedback['warning']="You don't have permission to post comments."; @@ -140,9 +144,9 @@ if( !empty( $_REQUEST['post_comment_submit'] ) && $gContent->hasUserPermission( // $post_comment_request is a flag indicating whether or not to display the comment input form if( empty( $_REQUEST['post_comment_request'] ) && !$gBitSystem->isFeatureActive( 'comments_auto_show_form' ) ) { - $post_comment_request = NULL; + $post_comment_request = null; } elseif( $gContent->hasUserPermission( 'p_liberty_post_comments' ) ) { - $post_comment_request = TRUE; + $post_comment_request = true; // force off ajax attachments which does not work for comments attachments if( $gBitSystem->isFeatureActive( 'comments_allow_attachments' ) && $gBitSystem->getConfig( 'liberty_attachment_style') == 'ajax' ){ $gBitSystem->setConfig( 'liberty_attachment_style', 'standard' ); @@ -152,17 +156,17 @@ if( empty( $_REQUEST['post_comment_request'] ) && !$gBitSystem->isFeatureActive( // in anticipation of mainlining LCConfig package - enable comment format configuration // hack because comments does not have edit service -wjames5 if( $gBitSystem->isPackageActive( 'lcconfig' ) ){ - $spoofHash = array(); - lcconfig_content_edit( new LibertyComment(), $spoofHash ); + $spoofHash = []; +// lcconfig_content_edit( new LibertyComment(), $spoofHash ); } if( !empty( $_REQUEST['post_comment_request'] ) && $_REQUEST['post_comment_request'] == 'y' && !$gContent->hasUserPermission( 'p_liberty_post_comments' ) ) { $gBitSystem->fatalPermission( 'p_liberty_post_comments' ); } -$gBitSmarty->assignByRef('post_comment_request', $post_comment_request); +$gBitSmarty->assign('post_comment_request', $post_comment_request); if( !empty( $_REQUEST['post_comment_cancel'] ) ) { - $postComment = NULL; + $postComment = null; } // $post_comment_preview is a flag indicating that the user wants to preview their comment prior to saving it @@ -171,12 +175,12 @@ if( !empty( $_REQUEST['post_comment_preview'] )) { $no_js_preview = $_REQUEST['no_js_preview']; //even if ajax is on - we force it off in this case - $gBitSmarty->assign( 'comments_ajax', FALSE ); + $gBitSmarty->assign( 'comments_ajax', false ); } else { $no_js_preview = "n"; } - $gBitSmarty->assignByRef( 'no_js_preview', $no_js_preview ); + $gBitSmarty->assign( 'no_js_preview', $no_js_preview ); $postComment['user_id'] = $gBitUser->mUserId; $postComment['title'] = $_REQUEST['comment_title']; @@ -188,110 +192,89 @@ if( !empty( $_REQUEST['post_comment_preview'] )) { $postComment['parsed_data'] = LibertyComment::parseDataHash( $postComment ); $postComment['created'] = time(); $postComment['last_modified'] = time(); - $gBitSmarty->assign('post_comment_preview', TRUE); + $gBitSmarty->assign('post_comment_preview', true); } // $post_comment_reply_id is the content_id which a post is replying to -if( BitBase::verifyIdParameter( $_REQUEST, 'post_comment_reply_id' )) { +if( BitBase::verifyId( $_REQUEST['post_comment_reply_id'] ?? 0 )) { $post_comment_reply_id = $_REQUEST['post_comment_reply_id']; - $tmpComment = new LibertyComment( NULL, $post_comment_reply_id ); + $tmpComment = new LibertyComment( null, $post_comment_reply_id ); if( !empty( $_REQUEST['quote'] )) { $postComment['data'] = $tmpComment->getQuoted(); } - if( preg_match( '/^' . tra( 'Re:' ) . '/', $tmpComment->mInfo['title'] )) { - $comment_prefix = ''; - } else { - $comment_prefix = tra( 'Re:' ) . " "; - } + $comment_prefix = ( preg_match( '/^' . KernelTools::tra( 'Re:' ) . '/', $tmpComment->mInfo['title'] ) ) ? '' : KernelTools::tra( 'Re:' ) . " "; //this always overrides the title with "Re: Parent Title" -- not sure what it really should do so I put in this conditional for previews - if( !isset( $_REQUEST['comment_title'] )) { - $postComment['title'] = $comment_prefix.$tmpComment->mInfo['title']; + if (!isset( $_REQUEST['comment_title'] )) { + $postComment['title'] = $comment_prefix . $tmpComment->mInfo['title']; } $gBitSmarty->assign( 'post_comment_reply_id', $post_comment_reply_id ); } -if( $gContent->hasUserPermission( 'p_liberty_read_comments' )) { +if ($gContent->hasUserPermission( 'p_liberty_read_comments' )) { - if( !empty( $_SESSION['liberty_comments_per_page'] )) { - $maxComments = $_SESSION['liberty_comments_per_page']; - } else { - $maxComments = $gBitSystem->getConfig( 'comments_per_page', 10 ); - } + $maxComments = !empty( $_SESSION['liberty_comments_per_page'] ) ? $_SESSION['liberty_comments_per_page'] : $gBitSystem->getConfig( 'comments_per_page', 10 ); - if( !empty( $_REQUEST["comments_maxComments"] )) { + if (!empty( $_REQUEST["comments_maxComments"] )) { $maxComments = $_REQUEST["comments_maxComments"]; - $comments_at_top_of_page = 'y'; + $comments_at_top_of_page = true; $_SESSION['liberty_comments_per_page'] = $maxComments; } - if( !empty( $_SESSION['liberty_comments_ordering'] )) { - $comments_sort_mode = $_SESSION['liberty_comments_ordering']; - } else { - $comments_sort_mode = $gBitSystem->getConfig( 'comments_default_ordering', 'commentDate_desc' ); - } + $comments_sort_mode = ( !empty( $_SESSION['liberty_comments_ordering'] ) ) ? $_SESSION['liberty_comments_ordering'] : $gBitSystem->getConfig( 'comments_default_ordering', 'commentDate_desc' ); - if( !empty( $_REQUEST["comments_sort_mode"] )) { + if (!empty( $_REQUEST["comments_sort_mode"] )) { $comments_sort_mode = $_REQUEST["comments_sort_mode"]; - $comments_at_top_of_page = 'y'; + $comments_at_top_of_page = true; $_SESSION['liberty_comments_ordering'] = $comments_sort_mode; } - if( !empty( $_SESSION['liberty_comments_display_mode'] )) { - $comments_display_style = $_SESSION['liberty_comments_display_mode']; - } else { - $comments_display_style = $gBitSystem->getConfig( 'comments_default_display_mode', 'threaded' ); - } + $comments_display_style = ( !empty( $_SESSION['liberty_comments_display_mode'] ) ) ? $_SESSION['liberty_comments_display_mode'] : $gBitSystem->getConfig( 'comments_default_display_mode', 'threaded' ); - if( !empty( $_REQUEST["comments_style"] ) ) { + if (!empty( $_REQUEST["comments_style"] )) { $comments_display_style = $_REQUEST["comments_style"]; - $comments_at_top_of_page = 'y'; + $comments_at_top_of_page = true; $_SESSION['liberty_comments_display_mode'] = $comments_display_style; } - $currentPage = BitBase::verifyIdParameter( $_REQUEST, 'comment_page', 1 ); - - if( !empty( $_REQUEST['comment_page'] ) || !empty( $_REQUEST['post_comment_request'] ) ) { - $comments_at_top_of_page = 'y'; + if (!empty( $_REQUEST['comment_page'] ) || !empty( $_REQUEST['post_comment_request'] )) { + $comments_at_top_of_page = true; } - $commentOffset = ($currentPage - 1) * $maxComments; + $commentOffset = !empty( $_REQUEST['comment_page'] ) ? ( $_REQUEST['comment_page'] - 1 ) * $maxComments : 0; - if( empty( $gComment )) { + if (empty( $gComment )) { $gComment = new LibertyComment(); } - $currentPage = BitBase::verifyIdParameter( $_REQUEST, 'comment_page', 1 ); - if( $currentPage < 1 ) { + $currentPage = !empty( $_REQUEST['comment_page'] ) ? $_REQUEST['comment_page'] : 1; + if ($currentPage < 1) { $currentPage = 1; } # logic to support displaying a single comment -- used when we need a URL pointing to a comment - if( !empty( $_REQUEST['view_comment_id'] )) { + if (!empty( $_REQUEST['view_comment_id'] )) { $commentOffset = $gComment->getNumComments_upto( $_REQUEST['view_comment_id'] ); -# echo "commentOffset =$commentOffset= maxComments=$maxComments=\n"; + # echo "commentOffset =$commentOffset= maxComments=$maxComments=\n"; $comments_sort_mode = 'commentDate_asc'; $comments_display_style = 'flat'; - $comments_at_top_of_page = 'y'; + $comments_at_top_of_page = true; $maxComments = 1; $currentPage = ceil( $commentOffset + 1 / $maxComments ); - } else { + } + else { $commentOffset = ( $currentPage - 1 ) * $maxComments; } - // $commentsParentId is the content_id which the comment tree is attached to - if( !@BitBase::verifyId( $commentsParentId ) ) { - $comments = array(); + if (!BitBase::verifyId( $commentsParentId )) { + $comments = []; $numComments = 0; - } else { - if( !empty( $commentsParentIds ) ) { - $parents = $commentsParentIds; - } else { - $parents = $commentsParentId; - } + } + else { + $parents = ( BitBase::verifyId( $commentsParentIds ?? [] ) ) ? $commentsParentIds : $commentsParentId; // pass in a reference to the root object so that we can do proper permissions checks - if ( is_object( $gContent )) { + if (is_object( $gContent )) { $gComment->mRootObj = $gContent; } $numComments = $gComment->getNumComments( $commentsParentId ); @@ -305,7 +288,7 @@ if( $gContent->hasUserPermission( 'p_liberty_read_comments' )) { if( $comments_display_style == 'flat' ) { $commentsTree = $comments; } else { - $commentsTree = array(); + $commentsTree = []; foreach( $comments as $id => $node ){ if( !empty( $comments[ $node['parent_id'] ] )) { $comments[ $node['parent_id'] ]['children'][$id] = &$comments[$id]; @@ -317,46 +300,41 @@ if( $gContent->hasUserPermission( 'p_liberty_read_comments' )) { } } - $gBitSmarty->assignByRef( 'comments', $commentsTree ); + $gBitSmarty->assign( 'comments', $commentsTree ); $gBitSmarty->assign( 'maxComments', $maxComments ); $numCommentPages = ceil( $numComments / $maxComments ); - $comments_return_url = $comments_return_url.( !strpos( $comments_return_url, '?' ) ? '?' : '' ); + $comments_return_url .= !strpos( $comments_return_url, '?' ) ? '?' : ''; // libertypagination smarty function setup - $commentsPgnHash = array( - 'numPages' => $numCommentPages, - 'pgnName' => 'comment_page', - 'page' => $currentPage, - 'comment_page' => $currentPage, - 'url' => $comments_return_url, - 'comments_page' => ( empty( $comments_on_separate_page ) ? FALSE : $comments_on_separate_page ), - 'ianchor' => 'editcomments', - ); - $gBitSmarty->assignByRef( 'commentsPgnHash', $commentsPgnHash ); - $gBitSmarty->assignByRef( 'postComment', $postComment ); - $gBitSmarty->assignByRef( 'gComment', $gComment ); + $commentsPgnHash = [ + 'numPages' => $numCommentPages, + 'pgnName' => 'comment_page', + 'page' => $currentPage, + 'comment_page' => $currentPage, + 'url' => $comments_return_url, + 'comments_page' => ( empty( $comments_on_separate_page ) ? false : $comments_on_separate_page ), + 'ianchor' => 'editcomments', + ]; + $gBitSmarty->assign( 'commentsPgnHash', $commentsPgnHash ); + $gBitSmarty->assign( 'postComment', $postComment ); + $gBitSmarty->assign( 'gComment', $gComment ); $gBitSmarty->assign( 'currentTimestamp', time() ); $gBitSmarty->assign( 'comments_return_url', $comments_return_url ); - $gBitSmarty->assign( 'comments_at_top_of_page', ( isset( $comments_at_top_of_page ) && $gBitSystem->getConfig( 'comments_reorganise_page_layout', 'n' ) == 'y' ) ? $comments_at_top_of_page : NULL ); - $gBitSmarty->assign( 'comments_style', $comments_display_style ); + $gBitSmarty->assign( 'comments_at_top_of_page', ( isset( $comments_at_top_of_page ) && $gBitSystem->getConfig( 'comments_reorganise_page_layout', 'n' ) == 'y' ) ? $comments_at_top_of_page : false ); +// $comments_yelurneurl .= ( !strp,s(mments_dispye_urnsurl, '?' ) ? '?' : '' ) $gBitSmarty->assign( 'comments_sort_mode', $comments_sort_mode ); $gBitSmarty->assign( 'textarea_id', 'commentpost' ); $gBitSmarty->assign( 'comments_count', $numComments ); // @TODO get this shit out of here - boards and any other package ridding on comments should make use of services - if( $gBitSystem->isPackageActive( 'boards' )) { - require_once(BOARDS_PKG_CLASS_PATH.'BitBoardTopic.php'); - } - - // @TODO get this shit out of here - boards and any other package ridding on comments should make use of services // this clearly can go in an edit service, but need to be careful since comments currently does not call edit service - have to check what doing so might trigger. if( !empty( $_REQUEST['post_comment_request'] )) { if( $gBitSystem->isPackageActive( 'boards' ) && ( - BitBoardTopic::isLockedMsg( @BitBase::verifyId( $storeComment->mInfo['parent_id'] ) - ? $storeComment->mInfo['parent_id'] : ( !@BitBase::verifyId( $_REQUEST['post_comment_reply_id'] ) + BitBoardTopic::isLockedMsg( BitBase::verifyId( $storeComment->mInfo['parent_id'] ) + ? $storeComment->mInfo['parent_id'] : ( !BitBase::verifyId( $_REQUEST['post_comment_reply_id'] ) ? $commentsParentId : $_REQUEST['post_comment_reply_id'] )) ) ) { diff --git a/includes/content_history_inc.php b/includes/content_history_inc.php index 5b1da31..e7d833e 100644..100755 --- a/includes/content_history_inc.php +++ b/includes/content_history_inc.php @@ -5,10 +5,13 @@ * @subpackage functions */ +use Bitweaver\KernelTools; +use Bitweaver\Liberty\LibertyContent; +use Bitweaver\BitBase; $gBitSmarty->assign( 'source', 0 ); // If we have to include a preview please show it -$gBitSmarty->assign( 'preview', FALSE ); +$gBitSmarty->assign( 'preview', false ); $gBitSmarty->assign( 'compare', 'n' ); $gBitSmarty->assign( 'diff2', 'n' ); @@ -26,15 +29,15 @@ if( isset( $_REQUEST["delete"] ) && isset( $_REQUEST["hist"] )) { $gBitSmarty->assign( 'sourcev', nl2br( htmlentities( $version["data"][0]["data"] ))); } -} elseif( @BitBase::verifyId( $_REQUEST["preview"] )) { +} elseif( BitBase::verifyId( $_REQUEST["preview"] )) { if( $version = $gContent->getHistory( $_REQUEST["preview"] )) { - $version['data'][0]['no_cache'] = TRUE; + $version['data'][0]['no_cache'] = true; $version['data'][0]['parsed_data'] = LibertyContent::parseDataHash( $version["data"][0], $gContent ); - $gBitSmarty->assignByRef( $smartyContentRef, $version['data'][0] ); - $gBitSmarty->assignByRef( 'version', $_REQUEST["preview"] ); + $gBitSmarty->assign( $smartyContentRef, $version['data'][0] ); + $gBitSmarty->assign( 'version', $_REQUEST["preview"] ); } -} elseif( @BitBase::verifyId( $_REQUEST["diff2"] ) ) { +} elseif( BitBase::verifyId( $_REQUEST["diff2"] ) ) { $from_version = $_REQUEST["diff2"]; $from_page = $gContent->getHistory( $from_version ); $from_lines = explode( "\n",$from_page["data"][0]["data"] ); @@ -49,15 +52,15 @@ if( isset( $_REQUEST["delete"] ) && isset( $_REQUEST["hist"] )) { /** * run 'pear install Text_Diff' to install the library, */ - if( $gBitSystem->isFeatureActive( 'liberty_inline_diff' ) && @include_once( 'Text/Diff.php' )) { - include_once( 'Text/Diff/Renderer/inline.php' ); - $diff = new Text_Diff( $from_lines, $to_lines ); - $renderer = new Text_Diff_Renderer_inline(); + if( $gBitSystem->isFeatureActive( 'liberty_inline_diff' ) && @include_once 'Text/Diff.php') { + include_once 'Text/Diff/Renderer/inline.php'; + $diff = new \Text_Diff( $from_lines, $to_lines ); + $renderer = new \Text_Diff_Renderer_inline(); $html = $renderer->render( $diff ); } else { - include_once( UTIL_PKG_INCLUDE_PATH.'diff.php'); - $diffx = new WikiDiff( $from_lines,$to_lines ); - $fmt = new WikiUnifiedDiffFormatter; + include_once UTIL_PKG_INCLUDE_PATH.'diff.php'; + $diffx = new \WikiDiff( $from_lines,$to_lines ); + $fmt = new \WikiUnifiedDiffFormatter; $html = $fmt->format( $diffx, $from_lines ); } $gBitSmarty->assign( 'diffdata', $html ); @@ -65,22 +68,22 @@ if( isset( $_REQUEST["delete"] ) && isset( $_REQUEST["hist"] )) { $gBitSmarty->assign( 'version_from', $from_version ); $gBitSmarty->assign( 'version_to', $to_version ); -} elseif( @BitBase::verifyId( $_REQUEST["compare"] )) { +} elseif( BitBase::verifyId( $_REQUEST["compare"] )) { $from_version = $_REQUEST["compare"]; $from_page = $gContent->getHistory( $from_version ); - $from_page['data'][0]['no_cache'] = TRUE; + $from_page['data'][0]['no_cache'] = true; $gBitSmarty->assign( 'compare', 'y' ); $gBitSmarty->assign( 'diff_from', LibertyContent::parseDataHash( $from_page['data'][0], $gContent ) ); $gBitSmarty->assign( 'diff_to', $gContent->getParsedData() ); - $gBitSmarty->assignByRef( 'version_from', $from_version ); + $gBitSmarty->assign( 'version_from', $from_version ); -} elseif( @BitBase::verifyId( $_REQUEST["rollback"] )) { +} elseif( BitBase::verifyId( $_REQUEST["rollback"] )) { $gContent->verifyUserPermission( !empty( $rollbackPerm ) ? $rollbackPerm : $gContent->mUpdateContentPerm ); if( !isset( $_REQUEST["rollback_comment"] )) { $_REQUEST["rollback_comment"] = ''; } if( $gContent->rollbackVersion( $_REQUEST["rollback"], $_REQUEST["rollback_comment"] )) { - bit_redirect( $gContent->getDisplayUrl() ); + KernelTools::bit_redirect( $gContent->getDisplayUrl() ); } } diff --git a/includes/display_content_inc.php b/includes/display_content_inc.php index 9bc9b91..70ca2a5 100644..100755 --- a/includes/display_content_inc.php +++ b/includes/display_content_inc.php @@ -8,9 +8,8 @@ * @subpackage functions */ -global $gBitSmarty, $gBitSystem, $gContent; + global $gBitSmarty, $gBitSystem, $gContent; -$gBitSmarty->assignByRef( 'pageInfo', $gContent->mInfo ); - -$gBitSystem->display( 'bitpackage:liberty/display_content.tpl' , NULL, array( 'display_mode' => 'display' )); + $gBitSmarty->assign( 'pageInfo', $gContent->mInfo ); + $gBitSystem->display( 'bitpackage:liberty/display_content.tpl' , null, [ 'display_mode' => 'display' ]); diff --git a/includes/edit_help_inc.php b/includes/edit_help_inc.php index 1e31a4d..d8c7a41 100644..100755 --- a/includes/edit_help_inc.php +++ b/includes/edit_help_inc.php @@ -14,7 +14,7 @@ */ global $gLibertySystem, $gBitSmarty; -$inEditor = TRUE; // Required by PluginHelp to Determin Executed in an Editor +$inEditor = true; // Required by PluginHelp to Determin Executed in an Editor $dataplugins = array_merge( $gLibertySystem->getPluginsOfType( DATA_PLUGIN ), $gLibertySystem->getPluginsOfType( FILTER_PLUGIN )); $formatplugins = $gLibertySystem->getPluginsOfType( FORMAT_PLUGIN ); @@ -53,16 +53,16 @@ foreach( array_keys( $formatplugins ) as $guid ) { if( !empty( $formatplugins ) ) { usort( $formatplugins, 'usort_by_title' ); - $gBitSmarty->assignByRef( 'formatplugins', $formatplugins ); + $gBitSmarty->assign( 'formatplugins', $formatplugins ); } if( !empty( $mimeplugins ) ) { usort( $mimeplugins, 'usort_by_title' ); - $gBitSmarty->assignByRef( 'mimeplugins', $mimeplugins ); + $gBitSmarty->assign( 'mimeplugins', $mimeplugins ); } if( !empty( $dataplugins ) ) { usort( $dataplugins, 'usort_by_title' ); - $gBitSmarty->assignByRef( 'dataplugins', $dataplugins ); + $gBitSmarty->assign( 'dataplugins', $dataplugins ); } ?> diff --git a/includes/edit_storage_inc.php b/includes/edit_storage_inc.php index bba99ad..c961f0d 100644..100755 --- a/includes/edit_storage_inc.php +++ b/includes/edit_storage_inc.php @@ -50,6 +50,6 @@ if( !empty( $_REQUEST['deleteAttachment'] )) { // make sure js is being loaded if( $gBitSystem->getConfig( 'liberty_attachment_style' ) == 'ajax' ) { - $gBitThemes->loadJavascript( LIBERTY_PKG_PATH.'scripts/LibertyAttachment.js', TRUE ); + $gBitThemes->loadJavascript( LIBERTY_PKG_PATH.'scripts/LibertyAttachment.js', true ); } ?> diff --git a/includes/get_content_list_inc.php b/includes/get_content_list_inc.php index a5bab92..f89e1c6 100644..100755 --- a/includes/get_content_list_inc.php +++ b/includes/get_content_list_inc.php @@ -11,21 +11,18 @@ /** * required setup */ -require_once( LIBERTY_PKG_CLASS_PATH.'LibertyContent.php' ); -global $gContent; +use Bitweaver\BitBase; +use Bitweaver\KernelTools; +use Bitweaver\Liberty\LibertyContent; global $gLibertySystem; if( empty( $gContent ) || !is_object( $gContent ) ) { $gContent = new LibertyContent(); } -$contentTypeGuids = array(); +$contentTypeGuids = []; if( !empty( $_REQUEST['content_type_guid'] )) { - if( !is_array( $_REQUEST['content_type_guid'] )) { - $guids = explode( ",", $_REQUEST['content_type_guid'] ); - } else { - $guids = $_REQUEST['content_type_guid']; - } + $guids = ( !is_array( $_REQUEST['content_type_guid'] ) ) ? explode( ",", $_REQUEST['content_type_guid'] ) : $_REQUEST['content_type_guid']; /** * if an empty string was passed in an array (likely since it is used for ALL) then the user has requested all so return all * even if they have requested additional content types too - ALL is ALL @@ -38,27 +35,27 @@ if( !empty( $_REQUEST['content_type_guid'] )) { // 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 if( empty( $contentListHash ) ) { - $contentListHash = array( - 'content_type_guid' => $contentSelect = empty( $_REQUEST['content_type_guid'] ) ? NULL : $contentTypeGuids, + $contentListHash = [ + 'content_type_guid' => $contentSelect = empty( $_REQUEST['content_type_guid'] ) ? null : $contentTypeGuids, // pagination offset - 'offset' => !empty( $offset_content ) ? $offset_content : NULL, + 'offset' => !empty( $offset_content ) ? $offset_content : null, // maximum number of records displayed on a page 'max_records' => !empty( $max_content ) ? $max_content : ( !empty( $_REQUEST['max_records'] ) ? $_REQUEST['max_records'] : 100 ), // sort by this: <table column>_asc (or _desc) 'sort_mode' => !empty( $content_sort_mode ) ? $content_sort_mode : 'title_asc', // limit the result to this set - 'find' => !empty( $_REQUEST["find"] ) ? $_REQUEST["find"] : NULL, + 'find' => !empty( $_REQUEST["find"] ) ? $_REQUEST["find"] : null, // display this page number - replaces antiquated offset - 'page' => !empty( $_REQUEST["list_page"] ) ? $_REQUEST["list_page"] : NULL, + 'page' => !empty( $_REQUEST["list_page"] ) ? $_REQUEST["list_page"] : (!empty( $_REQUEST["page"] ) ? $_REQUEST["page"] : 1), // only display content by this user - 'user_id' => @BitBase::verifyId( $_REQUEST['user_id'] ) ? $_REQUEST['user_id'] : NULL, + 'user_id' => BitBase::verifyId( $_REQUEST['user_id'] ?? 0 ) ? $_REQUEST['user_id'] : null, // only display content modified more recently than this (UTC timestamp) - 'from_date' => !empty( $_REQUEST["from_date"] ) ? $_REQUEST["from_date"] : NULL, + 'from_date' => !empty( $_REQUEST["from_date"] ) ? $_REQUEST["from_date"] : null, // only display content modified before this (UTC timestamp) - 'until_date' => !empty( $_REQUEST["until_date"] ) ? $_REQUEST["until_date"] : NULL, + 'until_date' => !empty( $_REQUEST["until_date"] ) ? $_REQUEST["until_date"] : null, // get a thumbnail - off by default because it is expensive - 'thumbnail_size' => !empty( $_REQUEST["thumbnail_size"] ) ? $_REQUEST["thumbnail_size"] : NULL, - ); + 'thumbnail_size' => !empty( $_REQUEST["thumbnail_size"] ) ? $_REQUEST["thumbnail_size"] : null, + ]; if( !empty( $_REQUEST['output'] ) && ( $_REQUEST['output'] == 'json' || $_REQUEST['output'] == 'ajax' ) ) { foreach( $_REQUEST as $key => $value ) { @@ -77,9 +74,9 @@ if( empty( $contentListHash ) ) { $contentList = $gContent->getContentList( $contentListHash ); if( empty( $contentTypes ) ) { - $contentTypes = array( '' => tra( 'All Content' ) ); + $contentTypes = [ '' => KernelTools::tra( 'All Content' ) ]; foreach( $gLibertySystem->mContentTypes as $cType ) { - $contentTypes[$cType['content_type_guid']] = $gLibertySystem->getContentTypeName( $cType['content_type_guid'], TRUE ); + $contentTypes[$cType['content_type_guid']] = $gLibertySystem->getContentTypeName( $cType['content_type_guid'], true ); } asort( $contentTypes ); } @@ -90,4 +87,3 @@ if( $gBitSystem->isFeatureActive( 'liberty_display_status' ) && $gBitUser->hasP $contentStatuses['not_available'] = 'All but Available'; $gBitSmarty->assign( 'content_statuses', $contentStatuses ); } -?> diff --git a/includes/help_format_tikiwiki_inc.php b/includes/help_format_tikiwiki_inc.php index ad6598f..79fb029 100644..100755 --- a/includes/help_format_tikiwiki_inc.php +++ b/includes/help_format_tikiwiki_inc.php @@ -11,8 +11,11 @@ /** * required setup */ +use Bitweaver\BitCache; +use Bitweaver\Liberty\LibertyContent; + global $gBitSystem, $gBitSmarty; -require_once( KERNEL_PKG_CLASS_PATH.'BitCache.php' ); + $cache = new BitCache( 'liberty/help' ); // only regenerate this thing if it's not cached yet @@ -21,111 +24,111 @@ if( $cache->isCached( $cacheFile, filemtime( __FILE__ ))) { $examples = unserialize( $cache->readCacheFile( $cacheFile )); } else { // help for generic options - $tikiwiki = array( - 'Emphasis' => array( - 'Headings' => array( + $tikiwiki = [ + 'Emphasis' => [ + 'Headings' => [ 'data' => "! heading 1\n!! heading 2\n!!! heading 3", 'note' => "Number of ! correponds to heading level.", - ), - 'Italics' => array( + ], + 'Italics' => [ 'data' => "''text''", 'note' => "Two single quotes not one double quote", - ), - 'Underline' => array( + ], + 'Underline' => [ 'data' => "===text===", - ), - 'Coloured Background' => array( + ], + 'Coloured Background' => [ 'data' => "++yellow:text++", - ), - 'Coloured Text' => array( + ], + 'Coloured Text' => [ 'data' => "~~red:text~~", - ), - 'Bold' => array( + ], + 'Bold' => [ 'data' => "__text__", - ), - 'Centered Text' => array( + ], + 'Centered Text' => [ 'data' => "::text::", - ), - 'Combined' => array( + ], + 'Combined' => [ 'data' => "::__~~red:++yellow:text++~~__::", 'note' => "When you combine options make sure you open and close in the opposite order analogous to: {[(text)]}", - ), - ), - 'Lists' => array( - 'Unordered Lists' => array( + ], + ], + 'Lists' => [ + 'Unordered Lists' => [ 'data' => "* First item\n** First subitem\n** Second subitem\n* Second item", - ), - 'Ordered Lists' => array( + ], + 'Ordered Lists' => [ 'data' => "# First item\n## First subitem\n## Second subitem\n# Second item", - ), - 'Definition Lists' => array( + ], + 'Definition Lists' => [ 'data' => ";Term: Definition", - ), - ), - 'Links' => array( - 'Wiki Links' => array( - 'data' => "((Wiki Page))", + ], + ], + 'Links' => [ + 'Wiki Links' => [ + 'data' => "((Wiki Page))", 'result' => '<a href="#">Wiki Page</a>', - ), - 'Wiki Links + Description' => array( - 'data' => "((Wiki Page|Page Description))", + ], + 'Wiki Links + Description' => [ + 'data' => "((Wiki Page|Page Description))", 'result' => '<a href="#">Page Description</a>', - ), - 'Wiki Links + Anchor + Description' => array( - 'data' => "((Wiki Page#Anchor|Page Description))", + ], + 'Wiki Links + Anchor + Description' => [ + 'data' => "((Wiki Page#Anchor|Page Description))", 'result' => '<a href="#">Page Description</a>', - ), - 'External Link' => array( + ], + 'External Link' => [ 'data' => "[http://www.example.com]", - ), - 'External Link + Description' => array( + ], + 'External Link + Description' => [ 'data' => "[http://www.example.com|Description]", - ), - 'External Link + Anchor + Description' => array( + ], + 'External Link + Anchor + Description' => [ 'data' => "[http://www.example.com/Page#Anchor|Description]", - ), - ), - 'Miscellaneous' => array( - 'Horizontal Rule' => array( + ], + ], + 'Miscellaneous' => [ + 'Horizontal Rule' => [ 'data' => '---', - ), - 'Highlighted Bar' => array( + ], + 'Highlighted Bar' => [ 'data' => '-=text=-', - ), - 'Highlighted Box' => array( + ], + 'Highlighted Box' => [ 'data' => "^text\nmore text^", - ), - 'As is Text' => array( + ], + 'As is Text' => [ 'data' => "~np~~~yellow:yellow~~\nand\n__bold__ text~/np~", 'note' => "This text will not be parsed", - ), - 'Pre Parsed' => array( + ], + 'Pre Parsed' => [ 'data' => "~pp~~~yellow:yellow~~\nand\n__bold__ text~/pp~", 'note' => "This text will be treated like code and will not be altered and will be displayed using a monospace font. The same can be achieved by using <pre>text</pre>.", - ), - 'Monospaced Text' => array( + ], + 'Monospaced Text' => [ 'data' => "-+text+-", - ), - 'Right to Left' => array( + ], + 'Right to Left' => [ 'data' => "{r2l}this text is from\nright to left\n{l2r}and back to\nleft to right.", - ), - ), - 'Simple Tables' => array( - 'Simple Table' => array( + ], + ], + 'Simple Tables' => [ + 'Simple Table' => [ 'data' => "|| Row1-Col1 | Row1-Col2\nRow2-Col1 | Row2-Col2 ||", - ), - 'With Headers' => array( + ], + 'With Headers' => [ 'data' => "||~ Header1 | Header2\nRow1-Col1 | Row1-Col2\nRow2-Col1 | Row2-Col2 ||", - ), - ), - ); + ], + ], + ]; if( $gBitSystem->getConfig( 'wiki_tables' ) == 'old' ) { - $tikiwiki['Simple Tables'] = array( - 'Tables' => array( + $tikiwiki['Simple Tables'] = [ + 'Tables' => [ 'data' => "|| Row1-Col1 | Row1-Col2 || Row2-Col1 | Row2-Col2 ||", - ), - ); + ], + ]; } foreach( array_keys( $tikiwiki ) as $section ) { @@ -138,10 +141,10 @@ if( $cache->isCached( $cacheFile, filemtime( __FILE__ ))) { } // mediawiki type tables - $mediawiki = array( - 'Example 1' => array( + $mediawiki = [ + 'Example 1' => [ 'data' => -'{| class="table" + '{| class="table" |+A Simple Table |- ! Col 1 !! Col 2 !! Col 3 @@ -153,11 +156,11 @@ if( $cache->isCached( $cacheFile, filemtime( __FILE__ ))) { | Row2-Col3 |- | Row3-Col1 || Row3-Col2 || Row3-Col3 -|}' - ), - 'Example 2' => array( +|}', + ], + 'Example 2' => [ 'data' => -'{| class="table table-boardered" + '{| class="table table-boardered" |+Multiplication table |- ! X !! 1 !! 2 !! 3 @@ -176,11 +179,11 @@ if( $cache->isCached( $cacheFile, filemtime( __FILE__ ))) { |- ! 5 | 5 || 10 || 15 -|}' - ), - 'Example 3' => array( +|}', + ], + 'Example 3' => [ 'data' => -'{| class="table table-striped" + '{| class="table table-striped" |+ Table with alternating rows |- | one @@ -202,11 +205,11 @@ if( $cache->isCached( $cacheFile, filemtime( __FILE__ ))) { | colspan="2" | warning |- class="info" | colspan="2" | info -|}' - ), - 'Example 4' => array( +|}', + ], + 'Example 4' => [ 'data' => -'{| class="table" style="background:yellow;color:green" + '{| class="table" style="background:yellow;color:green" |+ Table with many colours |- | abc @@ -219,9 +222,9 @@ if( $cache->isCached( $cacheFile, filemtime( __FILE__ ))) { | style="font-weight:bold" | stu | style="background:silver" | vwx | yz -|}' - ), - ); +|}', + ], + ]; // parse tables foreach( $mediawiki as $title => $example ) { @@ -235,5 +238,4 @@ if( $cache->isCached( $cacheFile, filemtime( __FILE__ ))) { $examples['mediawiki'] = $mediawiki; $cache->writeCacheFile( $cacheFile, serialize( $examples )); } -$gBitSmarty->assign( 'examples', $examples ); -?> +$gBitSmarty->assign( 'examples', $examples );
\ No newline at end of file diff --git a/includes/liberty_lib.php b/includes/liberty_lib.php index 105e0d9..4abe70a 100644..100755 --- a/includes/liberty_lib.php +++ b/includes/liberty_lib.php @@ -13,6 +13,14 @@ * @access public * @return void */ + + /** + * required setup + */ +namespace Bitweaver\Liberty; +use Bitweaver\BitBase; +use Bitweaver\KernelTools; + function parse_data_plugins( &$pData, &$pReplace, $pCommonObject, $pParseHash ) { global $gLibertySystem, $gBitSystem; @@ -20,8 +28,8 @@ function parse_data_plugins( &$pData, &$pReplace, $pCommonObject, $pParseHash ) preg_match_all( "/\{\/?([A-Za-z0-9]+)([^\}]*)\}/", $pData, $curlyTags, PREG_OFFSET_CAPTURE ); if( count( $curlyTags[0] ) ) { - // if TRUE, replace only CODE plugin, if false, replace all other plugins - $code_first = TRUE; + // 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; @@ -36,23 +44,20 @@ function parse_data_plugins( &$pData, &$pReplace, $pCommonObject, $pParseHash ) $pos = strpos( $pData, $plugin_start ); $dataTag = strtolower( $plugin ); // hush up the return of this in case someone uses curly braces to enclose text - $pluginInfo = $gLibertySystem->getPluginInfo( @$gLibertySystem->mDataTags[$dataTag] ) ; + if( !empty( $gLibertySystem->mDataTags[$dataTag] ) ) { + $pluginInfo = $gLibertySystem->getPluginInfo( $gLibertySystem->mDataTags[$dataTag] ) ; - // only process a standalone unpaired tag or the start tag for a paired tag - if( empty( $paired_close_tag_seen[$dataTag] ) || $paired_close_tag_seen[$dataTag] == 0 ) { - $paired_close_tag_seen[$dataTag] = 1; - } else { - $paired_close_tag_seen[$dataTag] = 0; - } + // only process a standalone unpaired tag or the start tag for a paired tag + $paired_close_tag_seen[$dataTag] = empty( $paired_close_tag_seen[$dataTag] ) || $paired_close_tag_seen[$dataTag] == 0 ? 1 : 0; - $is_opening_tag = FALSE; - if(( empty( $pluginInfo['requires_pair'] ) && ( strtolower( $plugin_start ) != '{/'. $dataTag . '}' )) - || ( strpos( $plugin_start, ' ' ) > 0 ) - || ( strtolower( $plugin_start ) == '{'.$dataTag.'}' && !$paired_close_tag_seen[$dataTag] ) - ) { - $is_opening_tag = TRUE; + $is_opening_tag = false; + if(( empty( $pluginInfo['requires_pair'] ) && ( strtolower( $plugin_start ) != '{/'. $dataTag . '}' )) + || ( strpos( $plugin_start, ' ' ) > 0 ) + || ( strtolower( $plugin_start ) == '{'.$dataTag.'}' && !$paired_close_tag_seen[$dataTag] ) + ) { + $is_opening_tag = true; + } } - if( // when in CODE parsing mode, replace only CODE plugins ( ( $code_first && ( $dataTag == 'code' ) ) @@ -62,7 +67,7 @@ function parse_data_plugins( &$pData, &$pReplace, $pCommonObject, $pParseHash ) && !empty( $gLibertySystem->mDataTags[$dataTag] ) && !empty( $pluginInfo ) && ( $loadFunc = $gLibertySystem->getPluginFunction( $gLibertySystem->mDataTags[$dataTag], 'load_function' ) ) - && ( $is_opening_tag ) + && $is_opening_tag ) { if( $pluginInfo['requires_pair'] ) { @@ -71,7 +76,7 @@ function parse_data_plugins( &$pData, &$pReplace, $pCommonObject, $pParseHash ) $plugin_end2 = '{'.$plugin.'}'; $pos_end2 = strpos( strtolower( $pData ), strtolower( $plugin_end2 ), $pos + 1 ); // where plugin data ends - if( ( $pos_end2 > 0 && $pos_end2 > 0 && $pos_end2 < $pos_end ) || $pos_end === FALSE ) { + if( ( $pos_end2 > 0 && $pos_end2 > 0 && $pos_end2 < $pos_end ) || $pos_end === false ) { $pos_end = $pos_end2; $plugin_end = $plugin_end2; } @@ -84,7 +89,7 @@ function parse_data_plugins( &$pData, &$pReplace, $pCommonObject, $pParseHash ) $plugin_data_len = $pos_end - $pos - strlen( $curlyTags[0][$i][0] ); $plugin_data = substr( $pData, $pos + strlen( $plugin_start ), $plugin_data_len ); - $arguments = array(); + $arguments = []; // Construct argument list array $paramString = str_replace( '>', '>', trim( $curlyTags[2][$i][0] ) ); if( preg_match( '/^\(.*=>.*\)$/', $paramString ) ) { @@ -105,27 +110,27 @@ function parse_data_plugins( &$pData, &$pReplace, $pCommonObject, $pParseHash ) } else { $paramString = trim( $curlyTags[2][$i][0], " \t()" ); $paramString = str_replace(""", '"', $paramString); - $arguments = parse_xml_attributes( $paramString ); + $arguments = KernelTools::parse_xml_attributes( $paramString ); } if( $ret = $loadFunc( $plugin_data, $arguments, $pCommonObject, $pParseHash )) { $key = "parseprotect".md5( mt_rand() ); - $pReplace[] = array( + $pReplace[] = [ 'key' => $key, 'data' => $ret, - ); + ]; - // don't modify data if $pos is FALSE - if( $pos !== FALSE ) { + // don't modify data if $pos is false + if( $pos !== false ) { $pData = substr_replace( $pData, $key, $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 ) ) { + if( $code_first && ( $i < 0 ) ) { $i = count( $curlyTags[0] ) - 1; - $code_first = FALSE; + $code_first = false; } } // while } @@ -136,7 +141,7 @@ function parse_data_plugins( &$pData, &$pReplace, $pCommonObject, $pParseHash ) * saves the section contents for later reinsertion. It is needed by * parse_data_plugins() to extract sections that don't require parsing * - * @param array $pData data that might contain ~np~ or ~pp~ strings + * @param string $pData data that might contain ~np~ or ~pp~ strings * @param array $preparsed array that is updated by refrerence with key and data that needs to be substituted later * @param array $noparsed array that is updated by refrerence with key and data that needs to be substituted later * @access public @@ -184,12 +189,12 @@ function parse_protect( &$pData, &$pReplace ) { * * @param array $pParamHash * @access public - * @return hash full of styling goodies + * @return array hash full of styling goodies */ function liberty_plugins_wrapper_style( $pParamHash ) { global $gBitSystem; - $ret = array(); + $ret = []; $ret['style'] = $ret['description'] = ''; if( !empty( $pParamHash ) && is_array( $pParamHash )) { @@ -274,11 +279,11 @@ function liberty_plugins_wrapper_style( $pParamHash ) { * liberty_content_load_sql * * @access public - * @return content load sql + * @return string content load sql */ -function liberty_content_load_sql( $pObject, $pParamHash=NULL ) { +function liberty_content_load_sql( $pObject, $pParamHash=null ) { global $gBitSystem, $gBitUser; - $ret = array(); + $ret = ''; $hasPerm = ( is_object( $pObject ) && isset( $pObject->hasUserPermission )) ? $pObject->hasUserPermission( 'p_liberty_edit_all_status' ) : $gBitUser->hasPermission( 'p_liberty_edit_all_status' ); @@ -312,23 +317,23 @@ function liberty_content_load_sql( $pObject, $pParamHash=NULL ) { * @param array $pParamHash['max_status_id'] one more than the maximum status a content can have to be included * @param array $pParamHash['min_owner_status_id'] one less than the mimimum status a content can have to be included that is owned by the requester * @access public - * @return content list sql + * @return array content list sql */ -function liberty_content_list_sql( $pObject, $pParamHash=NULL ) { +function liberty_content_list_sql( $pObject, $pParamHash=null ) { global $gBitSystem, $gBitUser; - $ret = array(); + $ret = []; - $hasPerm = FALSE; + $hasPerm = false; // enforce_status will require the status limit on everyone including admin and thus we can ignore permission checks if( !isset( $pParamHash['enforce_status'] )) { - $hasPerm = ( is_object( $pObject ) && method_exists( $pObject, 'hasUserPermission' )) ? $pObject->hasUserPermission( 'p_liberty_edit_all_status', FALSE ) : $gBitUser->hasPermission( 'p_liberty_edit_all_status' ); + $hasPerm = ( is_object( $pObject ) && method_exists( $pObject, 'hasUserPermission' )) ? $pObject->hasUserPermission( 'p_liberty_edit_all_status', false ) : $gBitUser->hasPermission( 'p_liberty_edit_all_status' ); } // default show content with status between 0 and 100; - $min_status_id = isset( $pParamHash['min_status_id'] ) && ( @BitBase::verifyId( $pParamHash['min_status_id'] ) || $pParamHash['min_status_id'] === 0 ) ? $pParamHash['min_status_id'] : 0; - $max_status_id = isset( $pParamHash['max_status_id'] ) && ( @BitBase::verifyId( $pParamHash['max_status_id'] ) || $pParamHash['max_status_id'] === 0 ) ? $pParamHash['max_status_id'] : 100; + $min_status_id = BitBase::verifyId( $pParamHash['min_status_id'] ?? 0 ) ? $pParamHash['min_status_id'] : 0; + $max_status_id = BitBase::verifyId( $pParamHash['max_status_id'] ?? 0 ) ? $pParamHash['max_status_id'] : 100; // let owner see any of their own content with a status > -100 - $min_owner_status_id = isset( $pParamHash['min_owner_status_id'] ) && ( @BitBase::verifyId( $pParamHash['min_owner_status_id'] ) || $pParamHash['min_owner_status_id'] === 0 ) ? $pParamHash['min_owner_status_id'] : -100; + $min_owner_status_id = BitBase::verifyId( $pParamHash['min_owner_status_id'] ?? 0 ) ? $pParamHash['min_owner_status_id'] : -100; if( $gBitSystem->isFeatureActive('liberty_display_status') && !$hasPerm ) { if(( is_object( $pObject ) && !empty( $pObject->mType['content_type_guid'] ) && $pObject->mType['content_type_guid'] == 'bitcomment' ) @@ -359,7 +364,7 @@ function liberty_content_list_sql( $pObject, $pParamHash=NULL ) { /** * liberty_content_preview * - * @param array $pObject + * @param object $pObject * @access public * @return void */ @@ -367,21 +372,21 @@ function liberty_content_preview( $pObject ) { global $gBitSystem, $gBitUser; if( $gBitSystem->isFeatureActive( 'liberty_display_status' ) && ( $gBitUser->hasPermission( 'p_liberty_edit_content_status' ) || $gBitUser->hasPermission( 'p_libert_edit_all_status' )) - && @BitBase::verifyId( $_REQUEST['content_status_id'] )) { + && BitBase::verifyId( $_REQUEST['content_status_id'] )) { $pObject->mInfo['content_status_id'] = $_REQUEST['content_status_id']; } if( $gBitSystem->isFeatureActive( 'liberty_allow_change_owner' ) && $gBitUser->hasPermission( 'p_liberty_edit_content_owner' ) - && @BitBase::verifyId( $_REQUEST['owner_id'] )) { + && BitBase::verifyId( $_REQUEST['owner_id'] )) { $pObject->mInfo['owner_id'] = $_REQUEST['owner_id']; } - include_once( LIBERTY_PKG_INCLUDE_PATH.'edit_help_inc.php' ); + include_once LIBERTY_PKG_INCLUDE_PATH.'edit_help_inc.php'; } /** * liberty_content_display * - * @param array $pObject + * @param object $pObject * @param array $pParamHash * @access public * @return void @@ -406,8 +411,8 @@ function liberty_content_display( $pObject, &$pParamHash ) { * @return void */ function liberty_content_edit( $pObject ) { - include_once( LIBERTY_PKG_INCLUDE_PATH.'edit_help_inc.php' ); - include_once( LIBERTY_PKG_INCLUDE_PATH."edit_storage_inc.php" ); + include_once LIBERTY_PKG_INCLUDE_PATH.'edit_help_inc.php'; + include_once LIBERTY_PKG_INCLUDE_PATH."edit_storage_inc.php"; } @@ -421,25 +426,25 @@ function liberty_content_edit( $pObject ) { * @param array $pFileHash['type'] (required) Mime type of the file uploaded * @param array $pFileHash['dest_branch'] (required) Relative path where you want to store the file (trailing slash required) * @param array $pFileHash['tmp_name'] (required) Absolute path to file including file name - * @param boolean $pFileHash['thumbnail'] (optional) Set to FALSE if you don't want to generate thumbnails + * @param boolean $pFileHash['thumbnail'] (optional) Set to false if you don't want to generate thumbnails * @param array $pFileHash['thumbnail_sizes'] (optional) Decide what sizes thumbnails you want to create: icon, avatar, small, medium, large * @param boolean $pMoveFile (optional) specify if you want to move or copy the original file * @access public - * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure + * @return bool true on success, false on failure - mErrors will contain reason for failure */ -function liberty_process_upload( &$pFileHash, $pMoveFile = TRUE ) { +function liberty_process_upload( &$pFileHash, $pMoveFile = true ) { global $gBitSystem; // Check for evil file extensions that could be execed on the server if( preg_match( EVIL_EXTENSION_PATTERN, $pFileHash['name'] )) { $pFileHash['type'] = 'text/plain'; - $pFileHash['name'] = $pFileHash['name'].'.txt'; + $pFileHash['name'] .= '.txt'; } - if ( !is_windows() ) { + if ( !KernelTools::is_windows() ) { list( $pFileHash['name'], $pFileHash['type'] ) = $gBitSystem->verifyFileExtension( $pFileHash['tmp_name'], $pFileHash['name'] ); } else { - //$pFile['type'] = $gBitSystem->verifyMimeType( $pFile['tmp_name'] ); + $pFileHash['type'] = $gBitSystem->verifyMimeType( $pFileHash['tmp_name'] ); } $ext = strrpos( $pFileHash['name'], '.' ); @@ -454,11 +459,9 @@ function liberty_process_upload( &$pFileHash, $pMoveFile = TRUE ) { // Thumbs.db is a windows My Photos/ folder file, and seems to really piss off imagick $canThumbFunc = liberty_get_function( 'can_thumbnail' ); - if( !empty( $canThumbFunc ) && $canThumbFunc( $pFileHash['type'] ) && $pFileHash['name'] != 'Thumbs.db' ) { - $ret = liberty_process_image( $pFileHash, $pMoveFile ); - } else { - $ret = liberty_process_generic( $pFileHash, $pMoveFile ); - } + $ret = !empty( $canThumbFunc ) && $canThumbFunc( $pFileHash['type'] ) && $pFileHash['name'] != 'Thumbs.db' + ? liberty_process_image( $pFileHash, $pMoveFile ) + : liberty_process_generic( $pFileHash, $pMoveFile ); return $ret; } @@ -468,12 +471,12 @@ function liberty_process_upload( &$pFileHash, $pMoveFile = TRUE ) { * * @param array $pFileHash * @access public - * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure + * @return string|bool true on success, false on failure */ function liberty_process_archive( &$pFileHash ) { // sanity check: make sure tmp_name isn't empty. will scan / if it is if( !is_array( $pFileHash ) || empty( $pFileHash['tmp_name'] ) || empty( $pFileHash['name'] ) ) { - return FALSE; + return false; } $cwd = getcwd(); @@ -482,14 +485,14 @@ function liberty_process_archive( &$pFileHash ) { // we'll copy the file. in the case of xuploaded files, the files have been // processed but don't have to be copied if( empty( $pFileHash['preprocessed'] ) && !is_uploaded_file( $pFileHash['tmp_name'] ) && is_file( $pFileHash['tmp_name'] ) ) { - $tmpDir = get_temp_dir(); + $tmpDir = KernelTools::get_temp_dir(); $copyFile = tempnam( !empty( $tmpDir ) ? $tmpDir : '/tmp', $pFileHash['name'] ); copy( $pFileHash['tmp_name'], $copyFile ); $pFileHash['tmp_name'] = $copyFile; } $dir = dirname( $pFileHash['tmp_name'] ); - $upExt = strtolower( substr( $pFileHash['name'], ( strrpos( $pFileHash['name'], '.' ) + 1 ) ) ); + $upExt = strtolower( substr( $pFileHash['name'], strrpos( $pFileHash['name'], '.' ) + 1 ) ); $baseDir = $dir.'/'; if( is_file( $pFileHash['tmp_name'] ) ) { global $gBitUser; @@ -540,7 +543,7 @@ function liberty_process_archive( &$pFileHash ) { print( "unstuff -d=\"$destDir\" \"{$pFileHash['tmp_name']}\" " ); $shellResult = shell_exec( "unstuff -d=\"$destDir\" \"{$pFileHash['tmp_name']}\" " ); } else { - $destDir = NULL; + $destDir = null; } break; } @@ -553,9 +556,9 @@ function liberty_process_archive( &$pFileHash ) { @unlink( $copyFile ); } - if( preg_match( "!^/+$!", $destDir )) { + if( preg_match( "!^/+$!", $destDir || '' )) { // obviously something went horribly wrong - return FALSE; + return false; } else { return $destDir; } @@ -565,27 +568,25 @@ function liberty_process_archive( &$pFileHash ) { * liberty_process_generic * * @param array $pFileHash - * @param array $pMoveFile + * @param bool $pMoveFile * @access public - * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure + * @return bool true on success, false on failure - mErrors will contain reason for failure */ -function liberty_process_generic( &$pFileHash, $pMoveFile = TRUE ) { +function liberty_process_generic( &$pFileHash, $pMoveFile = true ) { global $gBitSystem; - $ret = NULL; + $ret = null; if( !empty( $pFileHash['dest_file'] ) ) { $destFile = $pFileHash['dest_file']; } else { - if( $gBitSystem->isFeatureActive( 'liberty_originalize_file_names' ) ) { - $destFile = STORAGE_PKG_PATH.$pFileHash['dest_branch'].liberty_mime_get_default_file_name( $pFileHash['name'], $pFileHash['type'] ); - } else { - $destFile = STORAGE_PKG_PATH.$pFileHash['dest_branch'].$pFileHash['name']; - } - if ( is_windows() ) { + $destFile = $gBitSystem->isFeatureActive( 'liberty_originalize_file_names' ) + ? STORAGE_PKG_PATH.$pFileHash['dest_branch'].liberty_mime_get_default_file_name( $pFileHash['name'], $pFileHash['type'] ) + : STORAGE_PKG_PATH.$pFileHash['dest_branch'].$pFileHash['name']; + if ( KernelTools::is_windows() ) { $destFile = str_replace( '//', '\\', str_replace( "\\", '\\', $destFile ) ); } } - mkdir_p( dirname( $destFile ) ); + KernelTools::mkdir_p( dirname( $destFile ) ); if( is_file( $pFileHash['source_file']) ) { if( $pFileHash['source_file'] == $destFile ) { @@ -612,11 +613,11 @@ function liberty_process_generic( &$pFileHash, $pMoveFile = TRUE ) { * * @param array $pFileHash * @access public - * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure + * @return bool true on success, false on failure - mErrors will contain reason for failure */ -function liberty_process_image( &$pFileHash, $pMoveFile = TRUE ) { +function liberty_process_image( &$pFileHash, $pMoveFile = true ) { global $gBitSystem; - $ret = NULL; + $ret = null; list($type, $ext) = explode( '/', strtolower( $pFileHash['type'] ) ); if( $resizePath = liberty_process_generic( $pFileHash, $pMoveFile )) { @@ -630,8 +631,8 @@ function liberty_process_image( &$pFileHash, $pMoveFile = TRUE ) { $sizeHold = $pFileHash['size']; $ret = $pFileHash['source_file']; - // do not thumbnail only if intentionally set to FALSE - if( !isset( $pFileHash['thumbnail'] ) || $pFileHash['thumbnail']==TRUE ) { + // do not thumbnail only if intentionally set to false + if( !isset( $pFileHash['thumbnail'] ) || $pFileHash['thumbnail']==true ) { liberty_generate_thumbnails( $pFileHash ); } $pFileHash['name'] = $nameHold; @@ -645,14 +646,14 @@ function liberty_process_image( &$pFileHash, $pMoveFile = TRUE ) { * * @param array $pFileHash['dest_branch'] should contain the path to the dir where we should remove thumbnails * @access public - * @return TRUE on success, FALSE on failure + * @return bool true on success, false on failure */ function liberty_clear_thumbnails( &$pFileHash ) { if( !empty( $pFileHash['dest_branch'] )) { - $thumbHash = array( + $thumbHash = [ 'source_file' => $pFileHash['dest_branch'], - 'mime_image' => FALSE, - ); + 'mime_image' => false, + ]; // get thumbnails we want to remove if( $thumbs = liberty_fetch_thumbnails( $thumbHash )) { @@ -668,21 +669,21 @@ function liberty_clear_thumbnails( &$pFileHash ) { } } } - return TRUE; + return true; } /** * liberty_get_function * - * @param array $pType + * @param string $pType * @access public - * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure + * @return string */ function liberty_get_function( $pType ) { global $gBitSystem; $processor = $gBitSystem->getConfig( 'image_processor', 'gd' ); - $ret = 'liberty_'.$processor.'_'.$pType.'_image'; - return( function_exists( $ret ) ? $ret : FALSE ); + $ret = "\\Bitweaver\\Liberty\\liberty_{$processor}_{$pType}_image"; + return function_exists( $ret ) ? $ret : false; } /** @@ -690,21 +691,19 @@ function liberty_get_function( $pType ) { * * @param array $pFileHash * @access public - * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure + * @return bool true on success, false on failure - mErrors will contain reason for failure */ function liberty_generate_thumbnails( $pFileHash ) { global $gBitSystem, $gThumbSizes; - $ret = FALSE; + $ret = false; if( $resizeFunc = liberty_get_function( 'resize' ) ) { // allow custom selection of thumbnail sizes if( empty( $pFileHash['thumbnail_sizes'] )) { - if( !empty( $gThumbSizes ) && is_array( $gThumbSizes )) { - $pFileHash['thumbnail_sizes'] = array_keys( $gThumbSizes ); - } else { - $pFileHash['thumbnail_sizes'] = array( 'large', 'medium', 'small', 'avatar', 'icon' ); - } + $pFileHash['thumbnail_sizes'] = !empty( $gThumbSizes ) && is_array( $gThumbSizes ) + ? array_keys( $gThumbSizes ) + : [ 'extra-large','large', 'medium', 'small', 'avatar', 'icon' ]; } if( ( !preg_match( '#image/(gif|jpe?g|png)#i', $pFileHash['type'] ) && $gBitSystem->isFeatureActive( 'liberty_jpeg_originals' )) || in_array( 'original', $pFileHash['thumbnail_sizes'] ) ) { @@ -714,7 +713,7 @@ function liberty_generate_thumbnails( $pFileHash ) { if( function_exists( 'liberty_rasterize_pdf' ) && $rasteredFile = liberty_rasterize_pdf( $pFileHash['source_file'] ) ) { $pFileHash['source_file'] = $rasteredFile; } else { - $magickWand = NewMagickWand(); +/* $magickWand = NewMagickWand(); if( !$pFileHash['error'] = liberty_magickwand_check_error( MagickReadImage( $magickWand, $pFileHash['source_file'] ), $magickWand )) { MagickSetFormat( $magickWand, 'JPG' ); if( MagickGetImageColorspace( $magickWand ) == MW_CMYKColorspace ) { @@ -732,6 +731,7 @@ function liberty_generate_thumbnails( $pFileHash ) { $pFileHash['source_file'] = $rasteredFile; } } +*/ } } else { $pFileHash['dest_base_name'] = 'original'; @@ -740,25 +740,20 @@ function liberty_generate_thumbnails( $pFileHash ) { $pFileHash['max_height'] = MAX_THUMBNAIL_DIMENSION; if( $convertedFile = $resizeFunc( $pFileHash )) { $pFileHash['source_file'] = $convertedFile; - $ret = TRUE; + $ret = true; } } $pFileHash['type'] = $gBitSystem->verifyMimeType( $pFileHash['source_file'] ); } - $mimeExt = ''; // override $mimeExt if we have a custom setting for it if( $gBitSystem->isFeatureActive( 'liberty_thumbnail_format' )) { $mimeExt = $gBitSystem->getConfig( 'liberty_thumbnail_format' ); - } elseif( !empty( $pFileHash['type'] ) ) { + } else { list( $type, $mimeExt ) = preg_split( '#/#', strtolower( $pFileHash['type'] )); } - if( preg_match( "!(png|gif)!", $mimeExt )) { - $destExt = '.'.$mimeExt; - } else { - $destExt = '.jpg'; - } + $destExt = preg_match( "!(png|gif)!", $mimeExt ) ? '.'.$mimeExt : '.jpg'; $initialDestPath = $pFileHash['dest_branch']; foreach( $pFileHash['thumbnail_sizes'] as $thumbSize ) { @@ -780,7 +775,7 @@ function liberty_generate_thumbnails( $pFileHash ) { $pFileHash['dest_branch'] = $initialDestPath.'thumbs/'; clearstatcache(); if( !is_dir( STORAGE_PKG_PATH.$pFileHash['dest_branch'] )) { - @mkdir( STORAGE_PKG_PATH.$pFileHash['dest_branch'], 0775, TRUE ); + @mkdir( STORAGE_PKG_PATH.$pFileHash['dest_branch'], 0775, true ); clearstatcache(); } } @@ -792,7 +787,7 @@ function liberty_generate_thumbnails( $pFileHash ) { unset( $pFileHash['max_height'] ); } if( $pFileHash['icon_thumb_path'] = $resizeFunc( $pFileHash )) { - $ret = TRUE; + $ret = true; // use the previous thumb as the source for the next, decreasingly smaller thumb as this GREATLY increases speed $pFileHash['source_file'] = $pFileHash['icon_thumb_path']; } @@ -816,7 +811,7 @@ function liberty_generate_thumbnails( $pFileHash ) { */ function liberty_fetch_thumbnails( $pParamHash ) { global $gBitSystem, $gThumbSizes; - $ret = array(); + $ret = []; if( !empty( $pParamHash['source_file'] )) { if( empty( $pParamHash['thumbnail_sizes'] )) { @@ -825,7 +820,7 @@ function liberty_fetch_thumbnails( $pParamHash ) { // liberty file processors automatically pick the best format for us. we can force a format though. // using array_unique will give us the best order in which to look for the thumbnails - $exts = array_unique( array( $gBitSystem->getConfig( 'liberty_thumbnail_format', 'jpg' ), 'jpg', 'png', 'gif', 'x-jpeg' )); + $exts = array_unique( [ $gBitSystem->getConfig( 'liberty_thumbnail_format', 'jpg' ), 'jpg', 'png', 'gif', 'x-jpeg' ]); // short hand $path = &$pParamHash['source_file']; @@ -837,17 +832,17 @@ function liberty_fetch_thumbnails( $pParamHash ) { // remove the filename if there is one (we can't just use dirname() becuase we might only have the path to the dir) $dir = substr( $path, 0, strrpos( $path, '/' ) + 1 ); // assume thumb sizes are from largest to smallest. reverse so smaller can be used if larger don't exist - $lastSize = NULL; + $lastSize = null; foreach( array_reverse( $pParamHash['thumbnail_sizes'] ) as $size ) { foreach( $exts as $ext ) { $image = $size.'.'.$ext; $thumbDir = is_dir( STORAGE_PKG_PATH.$dir.'thumbs/' ) ? $dir.'thumbs/' : $dir; if( is_readable( STORAGE_PKG_PATH.$thumbDir.$image )) { - $ret[$size] = (empty( $_REQUEST['uri_mode'] ) ? STORAGE_PKG_URL : STORAGE_PKG_URI).$thumbDir.$image; + $ret[$size] = (empty( $_REQUEST['uri_mode'] ) ? STORAGE_PKG_URL : STORAGE_BASE_URI).$thumbDir.$image; } } - // fetch mime image unless we set this to FALSE - if(( !isset( $pParamHash['mime_image'] ) || $pParamHash['mime_image'] === TRUE ) && empty( $ret[$size] )) { + // fetch mime image unless we set this to false + if(( !isset( $pParamHash['mime_image'] ) || $pParamHash['mime_image'] === true ) && empty( $ret[$size] )) { if( $lastSize && !empty( $ret[$lastSize] ) ) { $ret[$size] = $ret[$lastSize]; } @@ -862,7 +857,7 @@ function liberty_fetch_thumbnails( $pParamHash ) { $ret[$size] = $pParamHash['default_image']; } else { // we need to make sure we have an image name that we can look up the mime type - $path .= ( strrpos( $dir, '/' ) == strlen( $path ) ? 'dummy.jpg' : basename( $path )); + $path .= strrpos( $dir, '/' ) == strlen( $path ) ? 'dummy.jpg' : basename( $path ); $ret[$size] = LibertySystem::getMimeThumbnailURL( $gBitSystem->lookupMimeType( $path ), substr( $path, strrpos( $path, '.' ) + 1 )); } } @@ -873,7 +868,7 @@ function liberty_fetch_thumbnails( $pParamHash ) { } /** - * fetch a single available thumbnail for a given item. if no thumbnail is present, return NULL + * fetch a single available thumbnail for a given item. if no thumbnail is present, return null * * @param array $pParamHash Hash of all settings used to fetch thumbnails including: size, source_file, default_image, and mime_image * @access public @@ -886,28 +881,27 @@ function liberty_fetch_thumbnail_url( $pParamHash ) { $pParamHash['size'] = 'small'; } - $pParamHash['thumbnail_sizes'] = array( $pParamHash['size'] ); + $pParamHash['thumbnail_sizes'] = [ $pParamHash['size'] ]; $ret = liberty_fetch_thumbnails( $pParamHash ); - - return( !empty( $ret[$pParamHash['size']] ) ? $ret[$pParamHash['size']] : NULL ); } + return !empty( $ret[$pParamHash['size']] ) ? $ret[$pParamHash['size']] : null; } /** * get a set of image size options based on $gThumbSizes * - * @param string $pEmptyOption string to use as empty option - if set to FALSE no empty string is eincluded - Note that string is tra()'d + * @param string $pEmptyOption string to use as empty option - if set to false no empty string is eincluded - Note that string is KernelTools::tra()'d * @access public * @return array of image size options suitable for use in a form */ function get_image_size_options( $pEmptyOption = 'Disable this feature' ) { global $gThumbSizes; - $ret = array(); + $ret = []; if( !empty( $pEmptyOption )) { - $ret[''] = tra( $pEmptyOption ); + $ret[''] = KernelTools::tra( $pEmptyOption ); } foreach( $gThumbSizes as $key => $size ) { - $ret[$key] = tra( ucfirst( $key ))." ( ". ( empty( $size['width'] ) ? tra( 'unlimited' ) : $size['width'] ) ." x ". ( empty($size['height'] ) ? tra('unlimited') : $size['height'] ) ." ".tra( 'pixels' )." )"; + $ret[$key] = KernelTools::tra( ucfirst( $key ))." ( ". ( empty( $size['width'] ) ? KernelTools::tra( 'unlimited' ) : $size['width'] ) ." x ". ( empty($size['height'] ) ? KernelTools::tra('unlimited') : $size['height'] ) ." ".KernelTools::tra( 'pixels' )." )"; } return $ret; } @@ -917,11 +911,11 @@ function get_image_size_options( $pEmptyOption = 'Disable this feature' ) { * * @param string $pString string that should be checked for the delimiter * @access public - * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure + * @return string */ function get_leadtitle( $pString ) { global $gBitSystem; - return( substr( $pString, 0, strpos( $pString, $gBitSystem->getConfig( 'liberty_subtitle_delimiter', ':' )))); + return substr( $pString, 0, strpos( $pString, $gBitSystem->getConfig( 'liberty_subtitle_delimiter', ':' ))); } /** @@ -929,12 +923,12 @@ function get_leadtitle( $pString ) { * * @param string $pString string that should be checked for the delimiter * @access public - * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure + * @return string */ function get_subtitle( $pString ) { global $gBitSystem; - if(( $start = strpos( $pString, $gBitSystem->getConfig( 'liberty_subtitle_delimiter', ':' ))) !== FALSE ) { - return( substr( $pString, ( $start + 1 ))); + if(( $start = strpos( $pString, $gBitSystem->getConfig( 'liberty_subtitle_delimiter', ':' ))) !== false ) { + return substr( $pString, $start + 1 ); } -} -?> + return ''; +}
\ No newline at end of file diff --git a/includes/lookup_content_inc.php b/includes/lookup_content_inc.php index 1552a1b..352ffa8 100644..100755 --- a/includes/lookup_content_inc.php +++ b/includes/lookup_content_inc.php @@ -8,13 +8,15 @@ * @subpackage functions */ +/** + * required setup + */ +namespace Bitweaver\Liberty; +use Bitweaver\BitBase; + global $gContent; -if( BitBase::verifyIdParameter( $_REQUEST, 'structure_id' ) ) { - /** - * required setup - */ - require_once( LIBERTY_PKG_CLASS_PATH.'LibertyStructure.php'); +if( !empty($_REQUEST['structure_id']) && BitBase::verifyId( $_REQUEST['structure_id'] ) ) { $_REQUEST['structure_id'] = preg_replace( '/[\D]/', '', $_REQUEST['structure_id'] ); $gStructure = new LibertyStructure( $_REQUEST['structure_id'] ); if( $gStructure->load() ) { @@ -24,17 +26,17 @@ if( BitBase::verifyIdParameter( $_REQUEST, 'structure_id' ) ) { // $_REQUEST['page_id'] = $gStructure->mInfo['page_id']; if( $viewContent = LibertyBase::getLibertyObject( $gStructure->mInfo['content_id'], $gStructure->mInfo['content_type']['content_type_guid'] ) ) { $viewContent->setStructure( $_REQUEST['structure_id'] ); - $gBitSmarty->assignByRef( 'pageInfo', $viewContent->mInfo ); + $gBitSmarty->assign( 'pageInfo', $viewContent->mInfo ); $gContent = &$viewContent; - $gBitSmarty->assignByRef( 'gContent', $gContent ); + $gBitSmarty->assign( 'gContent', $gContent ); } } -} elseif( BitBase::verifyIdParameter( $_REQUEST, 'content_id' ) ) { +} elseif( !empty($_REQUEST['content_id']) && BitBase::verifyId( $_REQUEST['content_id'] ) ) { $_REQUEST['content_id'] = preg_replace( '/[\D]/', '', $_REQUEST['content_id'] ); - require_once( LIBERTY_PKG_CLASS_PATH.'LibertyBase.php'); + if( $gContent = LibertyBase::getLibertyObject( $_REQUEST['content_id'] ) ) { - $gBitSmarty->assignByRef( 'gContent', $gContent ); - $gBitSmarty->assignByRef( 'pageInfo', $gContent->mInfo ); + $gBitSmarty->assign( 'gContent', $gContent ); + $gBitSmarty->assign( 'pageInfo', $gContent->mInfo ); } } diff --git a/includes/structure_display_inc.php b/includes/structure_display_inc.php index f0d489f..026b4e8 100644..100755 --- a/includes/structure_display_inc.php +++ b/includes/structure_display_inc.php @@ -18,5 +18,5 @@ if( is_object( $gContent ) && $gContent->isValid() ) { $gBitSystem->setCanonicalLink( $gContent->getDisplayUrl() ); include $gContent->getRenderFile(); } else { - $gBitSystem->fatalError( tra( 'Page cannot be found' ), NULL, NULL, HttpStatusCodes::HTTP_GONE ); + $gBitSystem->fatalError( tra( 'Page cannot be found' ), null, null, HttpStatusCodes::HTTP_GONE ); } diff --git a/includes/structure_edit_inc.php b/includes/structure_edit_inc.php index 05179c6..e6244dc 100644..100755 --- a/includes/structure_edit_inc.php +++ b/includes/structure_edit_inc.php @@ -11,11 +11,15 @@ // All Rights Reserved. See below for details and a complete list of authors. // Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details. -require_once( '../kernel/includes/setup_inc.php' ); -include_once( LIBERTY_PKG_CLASS_PATH.'LibertyStructure.php'); +namespace Bitweaver\Liberty; +require_once '../kernel/includes/setup_inc.php'; +use Bitweaver\BitBase; +use Bitweaver\KernelTools; +use Bitweaver\Liberty\LibertyContent; +use Bitweaver\Liberty\LibertyStructure; -if( !@BitBase::verifyId( $_REQUEST["structure_id"] ) ) { - $gBitSystem->fatalError( tra( "No structure indicated" )); +if( !BitBase::verifyId( $_REQUEST["structure_id"] ) ) { + $gBitSystem->fatalError( KernelTools::tra( "No structure indicated" )); } else { global $gStructure; $gStructure = new LibertyStructure( $_REQUEST["structure_id"] ); @@ -23,7 +27,7 @@ if( !@BitBase::verifyId( $_REQUEST["structure_id"] ) ) { // order matters for these conditionals if( empty( $gStructure ) || !$gStructure->isValid() ) { - $gBitSystem->fatalError( tra( 'Invalid structure' )); + $gBitSystem->fatalError( KernelTools::tra( 'Invalid structure' )); } if( $gStructure->mInfo['root_structure_id'] == $gStructure->mInfo['structure_id'] ) { @@ -40,8 +44,8 @@ if( !@BitBase::verifyId( $_REQUEST["structure_id"] ) ) { $gContent->verifyUpdatePermission(); } - $gBitSmarty->assignByRef( 'gStructure', $gStructure ); - $gBitSmarty->assign( 'editingStructure', TRUE ); + $gBitSmarty->assign( 'gStructure', $gStructure ); + $gBitSmarty->assign( 'editingStructure', true ); $gBitSmarty->assign('structureInfo', $gStructure->mInfo); // Store the actively stored structure name @@ -54,24 +58,24 @@ if( !@BitBase::verifyId( $_REQUEST["structure_id"] ) ) { $gBitUser->verifyTicket(); if( $gStructure->removeStructureNode( $_REQUEST["structure_id"], false ) ) { if( $gBitThemes->isAjaxRequest() ) { - $feedback['success'] = tra( "removed from" ).' '.$gContent->getContentTypeName(); + $feedback['success'] = KernelTools::tra( "removed from" ).' '.$gContent->getContentTypeName(); } else { - bit_redirect( $_SERVER['SCRIPT_NAME'].'?structure_id='.$gStructure->mInfo["parent_id"] ); + KernelTools::bit_redirect( $_SERVER['SCRIPT_NAME'].'?structure_id='.$gStructure->mInfo["parent_id"] ); } } else { $feedback['error'] = $gStructure->mErrors; } - $gBitSmarty->assignByRef('feedback', $feedback); + $gBitSmarty->assign('feedback', $feedback); } elseif( $_REQUEST["action"] == 'remove' ) { - $gBitSystem->setBrowserTitle( tra('Confirm removal of ').$gContent->getTitle() ); + $gBitSystem->setBrowserTitle( KernelTools::tra('Confirm removal of ').$gContent->getTitle() ); $formHash['action'] = 'remove'; - $formHash['remove'] = TRUE; + $formHash['remove'] = true; $formHash['structure_id'] = $_REQUEST['structure_id']; - $msgHash = array( - 'label' => tra('Remove content from Structure'), - 'confirm_item' => $gContent->getTitle().tra('and any subitems'), - 'warning' => tra('This will remove the content from the structure but will <strong>not</strong> modify or remove the content itself.'), - ); + $msgHash = [ + 'label' => KernelTools::tra('Remove content from Structure'), + 'confirm_item' => $gContent->getTitle().KernelTools::tra('and any subitems'), + 'warning' => KernelTools::tra('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"])) { @@ -84,10 +88,10 @@ if( !@BitBase::verifyId( $_REQUEST["structure_id"] ) ) { } elseif ($_REQUEST["move_node"] == '4') { $gStructure->moveNodeEast(); } - bit_redirect( $_SERVER['SCRIPT_NAME'].'?structure_id='.$gStructure->mInfo["structure_id"] ); + KernelTools::bit_redirect( $_SERVER['SCRIPT_NAME'].'?structure_id='.$gStructure->mInfo["structure_id"] ); } elseif( !empty( $_REQUEST['submit_structure'] ) ) { if( $gStructure->storeStructure( $_REQUEST ) ) { - $feedback['success'] = tra( "Your changes were successfully saved." ); + $feedback['success'] = KernelTools::tra( "Your changes were successfully saved." ); } else { $feedback['error'] = $gStructure->mErrors; } @@ -100,13 +104,13 @@ if( !@BitBase::verifyId( $_REQUEST["structure_id"] ) ) { $structureHash['after_ref_id'] = $_REQUEST['after_ref_id']; } if (!(empty($_REQUEST['name']))) { - $gStructure->s_create_page($_REQUEST["structure_id"], $after, $_REQUEST["name"], ''); +// $gStructure->s_create_page($_REQUEST["structure_id"], $after, $_REQUEST["name"], ''); } elseif(!empty($_REQUEST['content'])) { foreach ($_REQUEST['content'] as $conId ) { $structureHash['content_id'] = $conId; if( $new_structure_id = $gStructure->storeNode( $structureHash ) ) { $structureHash['after_ref_id'] = $new_structure_id; - $feedback['success'] = tra( "added to" ).' '.$gContent->getContentTypeName(); + $feedback['success'] = KernelTools::tra( "added to" ).' '.$gContent->getContentTypeName(); } else { $feedback['failure'] = $gStructure->mErrors; } @@ -117,8 +121,6 @@ if( !@BitBase::verifyId( $_REQUEST["structure_id"] ) ) { $structureTocId = $rootStructure->mStructureId; $gBitSmarty->assign( 'structureToc', $rootStructure->getToc() ); $gBitSmarty->assign( 'structureTocId', $structureTocId ); - $gBitSmarty->assignByRef('feedback', $feedback); + $gBitSmarty->assign('feedback', $feedback); } - $gBitSmarty->assign( 'editingStructure', FALSE ); - -?> + $gBitSmarty->assign( 'editingStructure', false ); |
