diff options
31 files changed, 169 insertions, 182 deletions
diff --git a/admin/admin_blogs_inc.php b/admin/admin_blogs_inc.php index df116c6..5b92bd9 100755 --- a/admin/admin_blogs_inc.php +++ b/admin/admin_blogs_inc.php @@ -5,6 +5,7 @@ * required setup */ namespace Bitweaver\Blogs; + use Bitweaver\BitBase; // get a list of blogs for the selection of the home blog @@ -77,7 +78,7 @@ $formBlogFeatures = [ ], "blog_hide_empty_usr_list" => [ 'label' => 'Hide empty blog message on user pages', - 'note' => 'Enable to hide the "No Records Found" on user\'s blog rolls', + 'note' => 'Enable to hide the "No Records Found" on user\'s blog rolls', ], ]; $gBitSmarty->assign( 'formBlogFeatures',$formBlogFeatures ); @@ -104,8 +105,8 @@ if( $processForm ) { $gBitSystem->storeConfig("blog_posts_comments", isset( $_REQUEST["blog_posts_comments"] ) ? 'y' : 'n', BLOGS_PKG_NAME ); $gBitSystem->storeConfig("blog_list_order", $_REQUEST["blog_list_order"], BLOGS_PKG_NAME ); $gBitSystem->storeConfig("blog_list_user_as", $_REQUEST["blog_list_user_as"], BLOGS_PKG_NAME ); - $gBitSystem->storeConfig("blog_posts_description_length", $_REQUEST["blog_posts_description_length"], BLOGS_PKG_NAME ); - $gBitSystem->storeConfig("blog_posts_autosplit", isset( $_REQUEST["blog_posts_autosplit"] ) ? 'y' : 'n', BLOGS_PKG_NAME ); + $gBitSystem->storeConfig("blog_posts_description_length", $_REQUEST["blog_posts_description_length"], BLOGS_PKG_NAME ); + $gBitSystem->storeConfig("blog_posts_autosplit", isset( $_REQUEST["blog_posts_autosplit"] ) ? 'y' : 'n', BLOGS_PKG_NAME ); $gBitSmarty->assign('blog_list_order', $_REQUEST["blog_list_order"]); $gBitSmarty->assign('blog_list_user_as', $_REQUEST['blog_list_user_as']); } diff --git a/admin/index.php b/admin/index.php index 1e6de35..30a5490 100755 --- a/admin/index.php +++ b/admin/index.php @@ -1,4 +1,4 @@ -<?php +<?php // This is not a package. header ("location: ../index.php"); diff --git a/admin/pump_blogs_inc.php b/admin/pump_blogs_inc.php index f615c52..2664afb 100755 --- a/admin/pump_blogs_inc.php +++ b/admin/pump_blogs_inc.php @@ -18,7 +18,7 @@ $pageHash = [ 'edit' => 'Sample Blog added during the installation process', 'use_title' => 'y', 'max_posts' => '10', - 'use_find' => 'on', + 'use_find' => 'on', 'allow_comments' => 'on', ]; @@ -36,7 +36,7 @@ if( $gBlog->store( $pageHash ) ) { Nulla blandit. Vestibulum tempor ullamcorper nulla. Pellentesque varius lectus nec urna. Proin volutpat pede in eros. Mauris sit amet pede in neque nonummy congue. Ut vitae felis. Nunc lacinia. Fusce placerat faucibus orci. Ut vel libero et nisl hendrerit pretium. Sed quis quam id augue porta tempus. Nullam ante risus, blandit sed, eleifend eget, imperdiet a, sapien. Vestibulum libero. Phasellus viverra nonummy dui. In ultrices. Pellentesque imperdiet eros vel urna. Maecenas fringilla rutrum sem. Nullam lacinia, ipsum ut euismod scelerisque, mi dolor faucibus eros, in semper magna lorem non risus. Cras nec elit. Etiam egestas. Praesent placerat diam. Donec nec velit. Mauris scelerisque vestibulum ante. Nulla congue commodo lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Aenean posuere, magna sit amet pharetra consectetuer, erat sapien ultricies elit, sit amet sollicitudin sem nibh vitae erat. Proin commodo feugiat nunc. Proin in eros. Fusce nec ante. Nulla convallis mi quis arcu. Duis quam. Cras arcu sem, posuere ut, sodales sit amet, blandit eu, orci. Sed tincidunt egestas est. Curabitur tempus, ipsum ut blandit accumsan, odio tellus egestas ipsum, sit amet cursus lacus velit et est. Nulla at sem. Aliquam quam purus, bibendum ut, tristique sollicitudin, interdum eget, ante. Nulla a ligula. Mauris scelerisque sem a odio. Quisque a nunc sed risus eleifend rutrum. Maecenas vitae lacus. - '], + ', ], [ 'fSavePage' => true, 'format_guid' => 'tikiwiki', @@ -46,7 +46,7 @@ if( $gBlog->store( $pageHash ) ) { 'edit' => 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vestibulum molestie lectus quis elit. Suspendisse scelerisque augue vitae ipsum. Maecenas quis enim. Suspendisse at turpis sed sem ullamcorper aliquam. Aliquam pede ligula, auctor vitae, interdum eget, aliquam vitae, magna. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Etiam varius feugiat neque. Pellentesque varius. Fusce a mi in nulla porta aliquam. Morbi scelerisque, turpis quis sodales blandit, libero lorem faucibus dui, sit amet lacinia sem pede in quam. Pellentesque tempor suscipit sem. Nam sed augue. Nulla blandit. Vestibulum tempor ullamcorper nulla. Pellentesque varius lectus nec urna. Proin volutpat pede in eros. Mauris sit amet pede in neque nonummy congue. Ut vitae felis. Nunc lacinia. Fusce placerat faucibus orci. Ut vel libero et nisl hendrerit pretium. Sed quis quam id augue porta tempus. Nullam ante risus, blandit sed, eleifend eget, imperdiet a, sapien. Vestibulum libero. Phasellus viverra nonummy dui. In ultrices. Pellentesque imperdiet eros vel urna. Maecenas fringilla rutrum sem. Nullam lacinia, ipsum ut euismod scelerisque, mi dolor faucibus eros, in semper magna lorem non risus. Cras nec elit. Etiam egestas. Praesent placerat diam. - '], + ', ], [ 'fSavePage' => true, 'format_guid' => 'tikiwiki', @@ -56,7 +56,7 @@ if( $gBlog->store( $pageHash ) ) { 'edit' => 'This is the blogs package of bitweaver. A blog is short for __web log__ and is basically a journal that is available on the web. The activity of updating a blog is "blogging" and someone who keeps a blog is a "blogger." Blogs are typically updated daily using software that allows people with little or no technical background to update and maintain the blog. Postings on a blog are almost always arranged in cronological order with the most recent additions featured most prominantly. If you have added the __Package Wiki__ to your isntallation and added the wiki sample data, you will notice that it is possible to link to those pages using simple wiki words such as bitweaverGlossary. - '], + ', ], ]; foreach( $blogPostHash as $blogPost ) { diff --git a/admin/schema_inc.php b/admin/schema_inc.php index 21699b4..269d840 100755 --- a/admin/schema_inc.php +++ b/admin/schema_inc.php @@ -63,12 +63,12 @@ $gBitInstaller->registerSchemaIndexes( BLOGS_PKG_NAME, $indices ); // ### Sequences $sequences = [ 'blogs_blog_id_seq' => [ 'start' => 1 ], - 'blog_posts_post_id_seq' => [ 'start' => 1 ] + 'blog_posts_post_id_seq' => [ 'start' => 1 ], ]; $gBitInstaller->registerSchemaSequences( BLOGS_PKG_NAME, $sequences ); // ### Default UserPermissions -$gBitInstaller->registerUserPermissions( BLOGS_PKG_NAME, [ +$gBitInstaller->registerUserPermissions( BLOGS_PKG_NAME, [ [ 'p_blogs_create', 'Can create a blog', 'registered', BLOGS_PKG_NAME ], [ 'p_blogs_create_is_public', 'Can create a public blog', 'editors', BLOGS_PKG_NAME ], [ 'p_blogs_post', 'Can create a blog post', 'registered', BLOGS_PKG_NAME ], @@ -77,7 +77,7 @@ $gBitInstaller->registerUserPermissions( BLOGS_PKG_NAME, [ [ 'p_blogs_admin', 'Can admin blogs', 'editors', BLOGS_PKG_NAME ], [ 'p_blogs_view', 'Can read blogs', 'basic', BLOGS_PKG_NAME ], [ 'p_blog_posts_read_future', 'Can view future dated posts', 'editors', BLOGS_PKG_NAME ], - [ 'p_blog_posts_read_expired', 'Can view expired posts', 'editors', BLOGS_PKG_NAME ] + [ 'p_blog_posts_read_expired', 'Can view expired posts', 'editors', BLOGS_PKG_NAME ], ] ); // ### Default Preferences @@ -115,7 +115,7 @@ $gBitInstaller->registerPreferences( BLOGS_PKG_NAME, [ **/ if(defined('RSS_PKG_NAME')) { - $gBitInstaller->registerPreferences( BLOGS_PKG_NAME, [ + $gBitInstaller->registerPreferences( BLOGS_PKG_NAME, [ [ RSS_PKG_NAME, BLOGS_PKG_NAME.'_rss', 'y' ], ]); } @@ -123,11 +123,11 @@ if(defined('RSS_PKG_NAME')) { // ### Register content types $gBitInstaller->registerContentObjects( BLOGS_PKG_NAME, [ 'BitBlog'=>BLOGS_PKG_CLASS_PATH.'BitBlog.php', - 'BitBlogPost'=>BLOGS_PKG_CLASS_PATH.'BitBlogPost.php' + 'BitBlogPost'=>BLOGS_PKG_CLASS_PATH.'BitBlogPost.php', ] ); // Requirements -$gBitInstaller->registerRequirements( BLOGS_PKG_NAME, [ +$gBitInstaller->registerRequirements( BLOGS_PKG_NAME, [ 'liberty' => [ 'min' => '5.0.0' ], ] ); diff --git a/admin/wp-migrate.php b/admin/wp-migrate.php index 8aa2ae7..647de6a 100755 --- a/admin/wp-migrate.php +++ b/admin/wp-migrate.php @@ -18,6 +18,7 @@ */ namespace Bitweaver\Blogs; + require_once '../../kernel/includes/setup_inc.php'; use Bitweaver\KernelTools; use Bitweaver\Liberty\LibertyComment; @@ -43,7 +44,7 @@ if (isset($_REQUEST['wp_config'])) { } $gBitSmarty->assign('wp_config', $_REQUEST['wp_config']); } -$gBitSystem->display("bitpackage:blogs/wp-migrate.tpl", KernelTools::tra("WordPress Migrate"), array( 'display_mode' => 'admin' )); +$gBitSystem->display("bitpackage:blogs/wp-migrate.tpl", KernelTools::tra("WordPress Migrate"), [ 'display_mode' => 'admin' ]); die; function migrate_wp() { @@ -73,12 +74,12 @@ function setup_migration() { global $gBitSystem, $gUserMap, $gBlogMap, $gPostMap, $gCommentMap, $gMaxUser, $gMaxBlog, $gMaxPost, $gMaxComment; if ($gBitSystem->getConfig('blogs_wp_migration', 'n') == 'n') { - $tables = array( + $tables = [ 'blogs_wp_users' => "wp_id INT PRIMARY, user_id INT NOTNULL", 'blogs_wp_blogs' => "wp_id INT PRIMARY, blog_id INT NOTNULL", 'blogs_wp_posts' => "wp_id INT PRIMARY, post_id INT NOTNULL", 'blogs_wp_comments' => "wp_id INT PRIMARY, comment_id INT NOTNULL", - ); + ]; $gBitSystem->mDb->createTables($tables); $gUserMap = []; $gBlogMap = []; @@ -155,9 +156,9 @@ function migrate_wp_users() { if (empty($bu->mErrors)) { // vd($bu->mUserId); $gUserMap[$data->ID] = $bu->mUserId; - $gBitSystem->mDb->query("UPDATE `".BIT_DB_PREFIX."users_users` SET hash = ? where user_id = ?", array($pParamHash['hash'], $bu->mUserId)); + $gBitSystem->mDb->query("UPDATE `".BIT_DB_PREFIX."users_users` SET hash = ? where user_id = ?", [$pParamHash['hash'], $bu->mUserId]); } else { - $gErrorMap[] = array('error' => "User ID: ".$pParamHash['login']." : ".implode(', ', $bu->mErrors)); + $gErrorMap[] = ['error' => "User ID: ".$pParamHash['login']." : ".implode(', ', $bu->mErrors)]; // vd($bu->mErrors); } } @@ -167,7 +168,7 @@ function migrate_wp_users() { $sql = "INSERT INTO `".BIT_DB_PREFIX."blogs_wp_users` (`wp_id`, `user_id`) VALUES (?, ?)"; foreach($gUserMap as $wp_id => $user_id) { if ($wp_id > $gMaxUser) { - $gBitSystem->mDb->query($sql, array($wp_id, $user_id)); + $gBitSystem->mDb->query($sql, [$wp_id, $user_id]); } } } @@ -208,7 +209,7 @@ function migrate_wp_categories() { $sql = "INSERT INTO `".BIT_DB_PREFIX."blogs_wp_blogs` (`wp_id`, `blog_id`) VALUES (?, ?)"; foreach($gBlogMap as $wp_id => $blog_id) { if ($wp_id > $gMaxBlog) { - $gBitSystem->mDb->query($sql, array($wp_id, $blog_id)); + $gBitSystem->mDb->query($sql, [$wp_id, $blog_id]); } } } @@ -245,7 +246,7 @@ function migrate_wp_posts() { if (empty($bp->mErrors)) { $gPostMap[$post->ID] = $bp->mContentId; $query = "UPDATE liberty_content SET created = ? WHERE content_id = ?"; - $gBitSystem->mDb->query($query, array($pParamHash['publish_date'], $bp->mContentId)); + $gBitSystem->mDb->query($query, [$pParamHash['publish_date'], $bp->mContentId]); } else { $pErrorMap[]['error'] = "Blog Post: " . $pParamHash['title'] . " had errors " . implode(", ", $bp->mErrors); } @@ -255,7 +256,7 @@ function migrate_wp_posts() { $sql = "INSERT INTO `".BIT_DB_PREFIX."blogs_wp_posts` (`wp_id`, `post_id`) VALUES (?, ?)"; foreach($gPostMap as $wp_id => $post_id) { if ($wp_id > $gMaxPost) { - $gBitSystem->mDb->query($sql, array($wp_id, $post_id)); + $gBitSystem->mDb->query($sql, [$wp_id, $post_id]); } } } @@ -330,7 +331,7 @@ function migrate_wp_comments() { if (!empty($c->mContentId)) { $gCommentMap[$comment->comment_ID] = $c->mContentId; $query = "UPDATE liberty_content set IP = ?, created = ? WHERE content_id = ?"; - $gBitSystem->mDb->query($query, array($comment->comment_author_IP, $pParamHash['last_modified'], $c->mContentId)); + $gBitSystem->mDb->query($query, [$comment->comment_author_IP, $pParamHash['last_modified'], $c->mContentId]); } else { $gErrorMap[]['error'] = "Coment: Unable to store: " . $comment->comment_ID . " : " . implode(", ", $c->mErrors); } @@ -341,7 +342,7 @@ function migrate_wp_comments() { $sql = "INSERT INTO `".BIT_DB_PREFIX."blogs_wp_comments` (`wp_id`, `comment_id`) VALUES (?, ?)"; foreach($gCommentMap as $wp_id => $comment_id) { if ($wp_id > $gMaxComment) { - $gBitSystem->mDb->query($sql, array($wp_id, $comment_id)); + $gBitSystem->mDb->query($sql, [$wp_id, $comment_id]); } } } diff --git a/blogs_rss.php b/blogs_rss.php index 76008a1..a6f2da9 100755 --- a/blogs_rss.php +++ b/blogs_rss.php @@ -44,7 +44,7 @@ if( !$gBitUser->hasPermission( 'p_blogs_view' ) ) { $listHash['full_data'] = true; if( !empty( $_REQUEST['user_id'] ) ) { $blogUser = $gBitSystem->getConfig( 'user_class', 'BitPermUser' ) == 'RolePermUser' ? new RoleUser() : new BitUser(); - + $userData = $blogUser->getUserInfo( [ 'user_id' => $_REQUEST['user_id'] ] ); // dont try and fool me if (!empty($userData)) { diff --git a/crosspost.php b/crosspost.php index bf34fad..122210e 100755 --- a/crosspost.php +++ b/crosspost.php @@ -13,11 +13,12 @@ * required setup */ namespace Bitweaver\Blogs; + require_once '../kernel/includes/setup_inc.php'; use Bitweaver\KernelTools; $gBitSystem->verifyPackage( 'blogs' ); -$gBitSystem->verifyPermission( 'p_blogs_admin' ); +$gBitSystem->verifyPermission( 'p_blogs_admin' ); require_once BLOGS_PKG_INCLUDE_PATH.'lookup_post_inc.php'; @@ -27,7 +28,7 @@ $gBitUser->verifyTicket(); //if crosspost save store it and send us to the post's page if( isset( $_REQUEST['crosspost_post']) || isset($_REQUEST['save_post_exit'] ) ) { - $crosspost_note = isset( $_REQUEST['crosspost_note'] )? $_REQUEST['crosspost_note']:null; + $crosspost_note = $_REQUEST['crosspost_note']??null; if( $gContent->isValid() && $gContent->storePostMap( $gContent->mInfo, $_REQUEST['blog_content_id'], $crosspost_note ) ) { $gContent->load(); KernelTools::bit_redirect( $gContent->getDisplayUrl() ); @@ -39,7 +40,7 @@ if( !empty( $_REQUEST['action']) && ($_REQUEST['action'] == 'remove') && $gConte // confirm first if( isset( $_REQUEST["confirm"] ) ) { //remove it, then relaod the crossposting form - if ( $gContent->expungePostMap( $gContent->mInfo['content_id'], array( $_REQUEST["blog_content_id"] ) ) ){ + if ( $gContent->expungePostMap( $gContent->mInfo['content_id'], [ $_REQUEST["blog_content_id"] ] ) ){ $gContent->load(); }else{ $feedback['error'] = $gContent->mErrors; @@ -50,12 +51,12 @@ if( !empty( $_REQUEST['action']) && ($_REQUEST['action'] == 'remove') && $gConte $formHash['action'] = 'remove'; $formHash['post_id'] = $_REQUEST['post_id']; $formHash['blog_content_id'] = $_REQUEST['blog_content_id']; - $msgHash = array( + $msgHash = [ 'label' => 'Remove Crossposting of Blog Post:', 'confirm_item' => $gContent->getTitle(), 'warning' => KernelTools::tra('This will remove the crossposting of the above blog post.'), // from the blog \''.'addblognamehere'.'\'), 'error' => KernelTools::tra('This cannot be undone!'), - ); + ]; $gBitSystem->confirmDialog( $formHash, $msgHash ); } }elseif( isset( $_REQUEST["blog_content_id"] )){ @@ -88,4 +89,4 @@ $gBitSmarty->assign( 'availableBlogs', $availableBlogs ); $gBitSmarty->assign('blogs', $blogs['data']); -$gBitSystem->display( 'bitpackage:blogs/crosspost.tpl', KernelTools::tra("Crosspost Blog Post") , array( 'display_mode' => 'display' )); +$gBitSystem->display( 'bitpackage:blogs/crosspost.tpl', KernelTools::tra("Crosspost Blog Post") , [ 'display_mode' => 'display' ]); @@ -13,6 +13,7 @@ * required setup */ namespace Bitweaver\Blogs; + require_once '../kernel/includes/setup_inc.php'; use Bitweaver\KernelTools; use Bitweaver\Liberty\LibertyContent; @@ -59,4 +60,4 @@ $gBitSystem->setBrowserTitle( KernelTools::tra( 'Edit Blog' ).' - '.$gContent->g $gBitSmarty->assign( 'textarea_label', 'Blog Description' ); $gBitSmarty->assign('gContent', $gContent); -$gBitSystem->display( 'bitpackage:blogs/edit_blog.tpl', null, array( 'display_mode' => 'edit' )); +$gBitSystem->display( 'bitpackage:blogs/edit_blog.tpl', null, [ 'display_mode' => 'edit' ]); diff --git a/icons/pkg_blogs.gif b/icons/pkg_blogs.gif Binary files differindex f57c7a6..f57c7a6 100644..100755 --- a/icons/pkg_blogs.gif +++ b/icons/pkg_blogs.gif diff --git a/icons/pkg_blogs.png b/icons/pkg_blogs.png Binary files differindex e97db6d..e97db6d 100644..100755 --- a/icons/pkg_blogs.png +++ b/icons/pkg_blogs.png diff --git a/includes/bit_setup_inc.php b/includes/bit_setup_inc.php index 66dc8e0..b9c736f 100755 --- a/includes/bit_setup_inc.php +++ b/includes/bit_setup_inc.php @@ -3,6 +3,7 @@ * @package blogs */ namespace Bitweaver\Blogs; + use Bitweaver\KernelTools; global $gBitSystem, $gBitUser, $gBitSmarty; @@ -18,9 +19,9 @@ $pRegisterHash = [ define( 'BLOGS_PKG_NAME', $pRegisterHash['package_name'] ); define( 'BLOGS_PKG_URL', BIT_ROOT_URL . basename( $pRegisterHash['package_path'] ) . '/' ); define( 'BLOGS_PKG_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/' ); -define( 'BLOGS_PKG_INCLUDE_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/'); +define( 'BLOGS_PKG_INCLUDE_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/'); define( 'BLOGS_PKG_CLASS_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/classes/'); -define( 'BLOGS_PKG_ADMIN_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/admin/'); +define( 'BLOGS_PKG_ADMIN_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/admin/'); $gBitSystem->registerPackage( $pRegisterHash ); @@ -35,14 +36,14 @@ if( $gBitSystem->isPackageActive( 'blogs' ) ) { ]; $gBitSystem->registerAppMenu( $menuHash ); - $gLibertySystem->registerService( - LIBERTY_SERVICE_BLOGS, - BLOGS_PKG_NAME, - [ 'module_display_function' => 'blogs_module_display', ], - [ + $gLibertySystem->registerService( + LIBERTY_SERVICE_BLOGS, + BLOGS_PKG_NAME, + [ 'module_display_function' => 'blogs_module_display', ], + [ 'description' => KernelTools::tra( 'A module display service which helps hook in javascript necessary when using the center module on other pages. This is a temporary fix to address a limitation of the rendering order in BitThemes and only applies to blog content.' ), 'required' => true, - ] + ], ); } diff --git a/includes/classes/BitBlog.php b/includes/classes/BitBlog.php index f3cc0be..9948257 100755 --- a/includes/classes/BitBlog.php +++ b/includes/classes/BitBlog.php @@ -9,10 +9,10 @@ * required setup */ namespace Bitweaver\Blogs; + use Bitweaver\BitBase; use Bitweaver\Liberty\LibertyContent; use Bitweaver\Liberty\LibertyMime; -use Bitweaver\Users\RolePermUser; define( 'BITBLOG_CONTENT_TYPE_GUID', 'bitblog' ); @@ -30,7 +30,7 @@ class BitBlog extends LibertyMime { } else { $this->mBlogId = $this->verifyId( $pBlogId ) ? $pBlogId : 0; } - + parent::__construct(); $this->registerContentType( BITBLOG_CONTENT_TYPE_GUID, [ 'content_type_guid' => BITBLOG_CONTENT_TYPE_GUID, @@ -38,7 +38,7 @@ class BitBlog extends LibertyMime { 'handler_class' => 'BitBlog', 'handler_package' => 'blogs', 'handler_file' => 'BitBlog.php', - 'maintainer_url' => 'https://www.bitweaver.org' + 'maintainer_url' => 'https://www.bitweaver.org', ] ); $this->mContentId = $pContentId; $this->mContentTypeGuid = BITBLOG_CONTENT_TYPE_GUID; @@ -103,7 +103,6 @@ class BitBlog extends LibertyMime { return true; } - /*shared*/ public function getBlog( $pBlogId, $pContentId = null ) { global $gBitSystem; @@ -176,7 +175,7 @@ class BitBlog extends LibertyMime { //$pParamHash['blog_store']['posts'] = 0; $pParamHash['blog_store']['content_id'] = $this->mContentId; // if pParamHash['blog_id'] is set, someone is requesting a particular blog_id. Use with caution! - $pParamHash['blog_store']['blog_id'] = isset( $pParamHash['blog_id'] ) && is_numeric( $pParamHash['blog_id'] ) + $pParamHash['blog_store']['blog_id'] = isset( $pParamHash['blog_id'] ) && is_numeric( $pParamHash['blog_id'] ) ? $pParamHash['blog_id'] : $this->mDb->GenID( 'blogs_blog_id_seq' ); $this->mBlogId = $pParamHash['blog_store']['blog_id']; @@ -277,7 +276,6 @@ class BitBlog extends LibertyMime { $whereSql = preg_replace( '/^[\s]*AND/', ' WHERE ', $whereSql ); } - $ret = []; // Return a data array, even if empty @@ -400,7 +398,7 @@ class BitBlog extends LibertyMime { public function getAvailableContentStatuses( $pUserMinimum=-100, $pUserMaximum=100 ) { global $gBitUser; $ret = null; - // return null for all but admins + // return null for all but admins if( $gBitUser->hasPermission( 'p_liberty_edit_all_status' )) { $ret = LibertyMime::getAvailableContentStatuses(); } diff --git a/includes/classes/BitBlogPost.php b/includes/classes/BitBlogPost.php index 7f19413..81f41c7 100755 --- a/includes/classes/BitBlogPost.php +++ b/includes/classes/BitBlogPost.php @@ -21,6 +21,7 @@ * required setup */ namespace Bitweaver\Blogs; + use Bitweaver\BitBase; use Bitweaver\KernelTools; use Bitweaver\BitDate; @@ -45,14 +46,14 @@ class BitBlogPost extends LibertyMime { public function __construct( $pPostId=null, $pContentId=null ) { parent::__construct(); - $this->registerContentType( BITBLOGPOST_CONTENT_TYPE_GUID, array( + $this->registerContentType( BITBLOGPOST_CONTENT_TYPE_GUID, [ 'content_type_guid' => BITBLOGPOST_CONTENT_TYPE_GUID, 'content_name' => 'Blog Post', 'handler_class' => 'BitBlogPost', 'handler_package' => 'blogs', 'handler_file' => 'BitBlogPost.php', - 'maintainer_url' => 'https://www.bitweaver.org' - ) ); + 'maintainer_url' => 'https://www.bitweaver.org', + ] ); $this->mPostId = (int)$pPostId; $this->mContentId = (int)$pContentId; $this->mContentTypeGuid = BITBLOGPOST_CONTENT_TYPE_GUID; @@ -103,11 +104,11 @@ class BitBlogPost extends LibertyMime { // we should remove this now that display_url is added $this->mInfo['url'] = BitBlogPost::getDisplayUrlFromHash( $this->mInfo ); $this->mInfo['display_url'] = BitBlogPost::getDisplayUrlFromHash( $this->mInfo ); - foreach( array( 'avatar', 'image' ) as $img ) { + foreach( [ 'avatar', 'image' ] as $img ) { if( !empty( $this->mInfo[$img.'_file_name'] ) ) { - $this->mInfo[$img] = \Bitweaver\Liberty\liberty_fetch_thumbnails( array( - 'source_file' => $this->getSourceFile( array( 'user_id'=>$this->getField( 'user_id' ), 'package'=>\Bitweaver\Liberty\liberty_mime_get_storage_sub_dir_name( array( 'mime_type' => $this->getField( $img.'_mime_type' ), 'name' => $this->getField( $img.'_file_name' ) ) ), 'file_name' => basename( $this->mInfo[$img.'_file_name'] ?? '' ), 'sub_dir' => $this->getField( $img.'_attachment_id' ) ) ) - )); + $this->mInfo[$img] = \Bitweaver\Liberty\liberty_fetch_thumbnails( [ + 'source_file' => $this->getSourceFile( [ 'user_id'=>$this->getField( 'user_id' ), 'package'=>\Bitweaver\Liberty\liberty_mime_get_storage_sub_dir_name( [ 'mime_type' => $this->getField( $img.'_mime_type' ), 'name' => $this->getField( $img.'_file_name' ) ] ), 'file_name' => basename( $this->mInfo[$img.'_file_name'] ?? '' ), 'sub_dir' => $this->getField( $img.'_attachment_id' ) ] ), + ]); } } @@ -117,12 +118,12 @@ class BitBlogPost extends LibertyMime { $format = $this->mInfo['format_guid']; $linebreak = $gLibertySystem->mPlugins[$format]['linebreak']; - $parts = preg_match( "/\.[3]split\.[3](".preg_quote( $linebreak, "/" ).")[2]/i", $this->mInfo['raw'] ) - ? preg_split( "/\.[3]split\.[3](".preg_quote( $linebreak, "/" ).")[2]/i", $this->mInfo['raw'] ) + $parts = preg_match( "/\.[3]split\.[3](".preg_quote( $linebreak, "/" ).")[2]/i", $this->mInfo['raw'] ) + ? preg_split( "/\.[3]split\.[3](".preg_quote( $linebreak, "/" ).")[2]/i", $this->mInfo['raw'] ) : preg_split( "/\.[3]split\.[3]/i", $this->mInfo['raw'] ); - - $this->mInfo['raw'] = isset( $parts[0] )? $parts[0] : $this->mInfo['raw']; - $this->mInfo['raw_more'] = isset( $parts[1] )? $parts[1] : null ; + + $this->mInfo['raw'] = $parts[0] ?? $this->mInfo['raw']; + $this->mInfo['raw_more'] = $parts[1] ?? null ; } $this->mInfo['data'] = preg_replace( LIBERTY_SPLIT_REGEX, "", $this->mInfo['data'] ); @@ -190,7 +191,7 @@ class BitBlogPost extends LibertyMime { global $gBitSystem; $ret = null; if( @$this->verifyId( $pPostContentId ) ) { - $bindVars = array( (int)$pPostContentId ); + $bindVars = [ (int)$pPostContentId ]; $query = "SELECT b.`content_id` AS hash_key, bpm.*, b.*, lc.* FROM `".BIT_DB_PREFIX."blogs_posts_map` bpm INNER JOIN `".BIT_DB_PREFIX."blogs` b ON b.`content_id` = bpm.`blog_content_id` @@ -218,10 +219,10 @@ class BitBlogPost extends LibertyMime { global $gBitSystem, $gThumbSizes; $ret = null; if( !empty( $pParamHash['image_file_name'] )) { - $thumbHash = array( + $thumbHash = [ 'mime_image' => false, - 'source_file' => $pParamHash['image_file_name'] - ); + 'source_file' => $pParamHash['image_file_name'], + ]; $ret = \Bitweaver\Liberty\liberty_fetch_thumbnails( $thumbHash ); $ret['original'] = BIT_ROOT_URL.$pParamHash['image_file_name']; } @@ -281,8 +282,6 @@ class BitBlogPost extends LibertyMime { return $data; } - - /** * Make sure the data is safe to store * @param array pParamHash be sure to pass by reference in case we need to make modifcations to the hash @@ -337,10 +336,10 @@ class BitBlogPost extends LibertyMime { $dateString = $this->mDate->gmmktime( $pParamHash['publish_Hour'], $pParamHash['publish_Minute'], - isset($pParamHash['publish_Second']) ? $pParamHash['publish_Second'] : 0, + $pParamHash['publish_Second'] ?? 0, $pParamHash['publish_Month'], $pParamHash['publish_Day'], - $pParamHash['publish_Year'] + $pParamHash['publish_Year'], ); $timestamp = $this->mDate->getUTCFromDisplayDate( $dateString ); @@ -363,10 +362,10 @@ class BitBlogPost extends LibertyMime { $dateString = $this->mDate->gmmktime( $pParamHash['expire_Hour'], $pParamHash['expire_Minute'], - isset($pParamHash['expire_Second']) ? $pParamHash['expire_Second'] : 0, + $pParamHash['expire_Second'] ?? 0, $pParamHash['expire_Month'], $pParamHash['expire_Day'], - $pParamHash['expire_Year'] + $pParamHash['expire_Year'], ); $timestamp = $this->mDate->getUTCFromDisplayDate( $dateString ); @@ -397,7 +396,7 @@ class BitBlogPost extends LibertyMime { /** * Check if the current user is the blog owner */ - public function isBlogOwner( $pUserId=null ) { + public function isBlogOwner( $pUserId=null ) { $ret = false; global $gBitUser; if( empty( $pUserId ) && $gBitUser->isValid() ) { @@ -409,7 +408,6 @@ class BitBlogPost extends LibertyMime { return $ret; } - /** * Check if the current post can have comments attached to it */ @@ -504,12 +502,11 @@ class BitBlogPost extends LibertyMime { return count( $this->mErrors ) == 0; } - public function loadPostMap( $pPostContentId, $pBlogContentId){ $ret = null; if( BitBase::verifyId( $pPostContentId ) ){ $this->StartTrans(); - $result = $this->mDb->getRow( "SELECT * FROM `".BIT_DB_PREFIX."blogs_posts_map` WHERE `post_content_id`=? AND `blog_content_id`=?", array( $pPostContentId, $pBlogContentId ) ); + $result = $this->mDb->getRow( "SELECT * FROM `".BIT_DB_PREFIX."blogs_posts_map` WHERE `post_content_id`=? AND `blog_content_id`=?", [ $pPostContentId, $pBlogContentId ] ); $this->CompleteTrans(); if ( !empty( $result ) ){ $ret = $result; @@ -542,11 +539,11 @@ class BitBlogPost extends LibertyMime { }elseif ( is_array( $pBlogMixed ) ) { $blogIds = $pBlogMixed; }elseif ( is_numeric( $pBlogMixed ) ) { - $blogIds = array( $pBlogMixed ); + $blogIds = [ $pBlogMixed ]; } } $currentMappings = []; - if( $allMappings = $this->mDb->getCol( "SELECT `blog_content_id` FROM `".BIT_DB_PREFIX."blogs_posts_map` WHERE `post_content_id`=?", array( $postContentId ) ) ) { + if( $allMappings = $this->mDb->getCol( "SELECT `blog_content_id` FROM `".BIT_DB_PREFIX."blogs_posts_map` WHERE `post_content_id`=?", [ $postContentId ] ) ) { // whiddle down all mappings to just those we have perm to foreach( $allMappings as $blogContentId ) { if( $this->checkContentPermission( [ 'user_id' => $gBitUser->mUserId, 'perm_name'=>'p_blogs_post', 'content_id'=>$blogContentId ] ) ) { @@ -558,13 +555,13 @@ class BitBlogPost extends LibertyMime { // Add new mappings for this post $newBlogIds = array_diff( $blogIds, $currentMappings ); foreach( $newBlogIds as $blogContentId ) { - if( $this->verifyId( $blogContentId ) && $this->checkContentPermission( array( 'user_id' => $gBitUser->mUserId, 'perm_name'=>'p_blogs_post', 'content_id'=>$blogContentId ) ) ) { - $result = $this->mDb->associateInsert( BIT_DB_PREFIX."blogs_posts_map", array( + if( $this->verifyId( $blogContentId ) && $this->checkContentPermission( [ 'user_id' => $gBitUser->mUserId, 'perm_name'=>'p_blogs_post', 'content_id'=>$blogContentId ] ) ) { + $result = $this->mDb->associateInsert( BIT_DB_PREFIX."blogs_posts_map", [ 'post_content_id' => $postContentId, 'blog_content_id' => (int)$blogContentId, 'date_added' => $timeStamp, 'crosspost_note' => $pCrosspostNote, - )); + ]); } } @@ -576,13 +573,13 @@ class BitBlogPost extends LibertyMime { // Update existing mappings $updateBlogIds = array_intersect( $blogIds, $currentMappings ); foreach( $updateBlogIds as $blogContentId ) { - if( $this->verifyId( $blogContentId ) && $this->checkContentPermission( array( 'user_id' => $gBitUser->mUserId, 'perm_name'=>'p_blogs_post', 'content_id'=>$blogContentId ) ) ) { - $result = $this->mDb->associateUpdate( BIT_DB_PREFIX."blogs_posts_map", array( + if( $this->verifyId( $blogContentId ) && $this->checkContentPermission( [ 'user_id' => $gBitUser->mUserId, 'perm_name'=>'p_blogs_post', 'content_id'=>$blogContentId ] ) ) { + $result = $this->mDb->associateUpdate( BIT_DB_PREFIX."blogs_posts_map", [ 'crosspost_note' => $pCrosspostNote, - ), array( + ], [ 'post_content_id' => $postContentId, 'blog_content_id' => (int)$blogContentId, - )); + ]); } } } @@ -607,7 +604,7 @@ class BitBlogPost extends LibertyMime { $this->StartTrans(); if ( !empty($pBlogContentIds) ){ foreach( $pBlogContentIds as $blogContentId ) { - $this->mDb->query( "DELETE FROM `".BIT_DB_PREFIX."blogs_posts_map` WHERE `blog_content_id`=? AND `post_content_id`=?", array( $blogContentId, $pPostContentId ) ); + $this->mDb->query( "DELETE FROM `".BIT_DB_PREFIX."blogs_posts_map` WHERE `blog_content_id`=? AND `post_content_id`=?", [ $blogContentId, $pPostContentId ] ); } } $this->CompleteTrans(); @@ -651,7 +648,6 @@ class BitBlogPost extends LibertyMime { return $ret; } - /** * Generate a valid url for the Blog * @@ -698,10 +694,10 @@ class BitBlogPost extends LibertyMime { return $ret; } - /** - * Returns include file that will - * @return string the fully specified path to file to be included - */ + /** + * Returns include file that will + * @return string the fully specified path to file to be included + */ public function getRenderFile() { return BLOGS_PKG_INCLUDE_PATH.'display_bitblogpost_inc.php'; } @@ -715,7 +711,7 @@ class BitBlogPost extends LibertyMime { //Build uri for post $parts = parse_url($_SERVER['REQUEST_URI']); $uri = KernelTools::httpPrefix(). str_replace('post', - 'view_post', $parts['path']). '?post_id=' . $this->mPostId . '&blog_id=' . $this->mInfo['blog_id']; + 'view_post', $parts['path'], ). '?post_id=' . $this->mPostId . '&blog_id=' . $this->mInfo['blog_id']; include_once UTIL_PKG_INCLUDE_PATH.'Snoopy/Snoopy.class.php'; $snoopy = new \Snoopy; @@ -809,7 +805,7 @@ class BitBlogPost extends LibertyMime { if( $pListHash['find'] ) { $findesc = '%' . strtoupper( $pListHash['find'] ) . '%'; - $whereSql .= "AND (UPPER(lc.`data`) like ?) "; + $whereSql .= "AND (UPPER(lc.`data`) like ?) "; $bindVars[] =$findesc; } @@ -934,7 +930,6 @@ class BitBlogPost extends LibertyMime { $pListHash['offset'] = $pListHash['max_records'] * $lastPageNumber; } - $result = $this->mDb->query($query,$bindVars,$pListHash['max_records'],$pListHash['offset']); $ret = []; @@ -943,10 +938,10 @@ class BitBlogPost extends LibertyMime { $res['no_fatal'] = true; $accessError = $this->invokeServices( 'content_verify_access', $res ); if( empty( $accessError ) ) { - foreach( array( 'avatar', 'image' ) as $img ) { - $res[$img] = \Bitweaver\Liberty\liberty_fetch_thumbnails( array( - 'source_file' => \Bitweaver\Liberty\liberty_mime_get_source_file( array( 'user_id'=>$res['user_id'], 'package'=>\Bitweaver\Liberty\liberty_mime_get_storage_sub_dir_name( array( 'mime_type' => $res[$img.'_mime_type'], 'name'=>$res[$img.'_file_name'] ) ), 'file_name'=>basename( $res[$img.'_file_name'] ?? '' ), 'sub_dir'=>$res[$img.'_attachment_id'] ) ) - )); + foreach( [ 'avatar', 'image' ] as $img ) { + $res[$img] = \Bitweaver\Liberty\liberty_fetch_thumbnails( [ + 'source_file' => \Bitweaver\Liberty\liberty_mime_get_source_file( [ 'user_id'=>$res['user_id'], 'package'=>\Bitweaver\Liberty\liberty_mime_get_storage_sub_dir_name( [ 'mime_type' => $res[$img.'_mime_type'], 'name'=>$res[$img.'_file_name'] ] ), 'file_name'=>basename( $res[$img.'_file_name'] ?? '' ), 'sub_dir'=>$res[$img.'_attachment_id'] ] ), + ]); } $res['thumbnail_url'] = BitBlogPost::getImageThumbnails( $res ); $res['num_comments'] = $comment->getNumComments( $res['content_id'] ); @@ -1007,8 +1002,8 @@ class BitBlogPost extends LibertyMime { $res["parsed_data"] = $accessError['access_control']; $ret[] = $res; } - } else { } + } LibertyContent::postGetList( $pListHash ); @@ -1061,7 +1056,6 @@ class BitBlogPost extends LibertyMime { return $this->getList( $pParamHash ); } - /** * Get list of posts that have expired and are not displayed on the site anymore * @@ -1074,7 +1068,6 @@ class BitBlogPost extends LibertyMime { return $this->getList( $pParamHash ); } - /** * */ @@ -1084,13 +1077,13 @@ class BitBlogPost extends LibertyMime { $aux = [ 'title' => $title, 'excerpt' => $excerpt, - 'blog_name' => $blog_name + 'blog_name' => $blog_name, ]; $tbs[$url] = $aux; $st = serialize($tbs); $query = "update `".BIT_DB_PREFIX."blog_posts` set `trackbacks_from`=? where `post_id`=?"; - $this->mDb->query( $query, array( $st, $this->mPostId ) ); + $this->mDb->query( $query, [ $st, $this->mPostId ] ); return true; } } @@ -1122,7 +1115,7 @@ class BitBlogPost extends LibertyMime { if( $this->isValid() ) { $empty = serialize([]); $query = "update `".BIT_DB_PREFIX."blog_posts` set `trackbacks_from` = ? where `post_id`=?"; - $this->mDb->query( $query, array( $empty, $this->mPostId ) ); + $this->mDb->query( $query, [ $empty, $this->mPostId ] ); } } @@ -1130,10 +1123,10 @@ class BitBlogPost extends LibertyMime { * */ public function clearTrackbacksTo() { - if( $this->isValid() ) { - $empty = serialize([]); + if( $this->isValid() ) { + $empty = serialize([]); $query = "update `".BIT_DB_PREFIX."blog_posts` set `trackbacks_to` = ? where `post_id`=?"; - $this->mDb->query( $query, array( $empty, $this->mPostId ) ); + $this->mDb->query( $query, [ $empty, $this->mPostId ] ); } } diff --git a/includes/display_bitblog_inc.php b/includes/display_bitblog_inc.php index a806fc9..5f2b249 100755 --- a/includes/display_bitblog_inc.php +++ b/includes/display_bitblog_inc.php @@ -14,13 +14,14 @@ */ namespace Bitweaver\Liberty; + use Bitweaver\KernelTools; use Bitweaver\Blogs\BitBlogPost; require_once BLOGS_PKG_INCLUDE_PATH.'lookup_blog_inc.php'; $gBitSystem->verifyPackage( 'blogs' ); -$displayHash = array( 'perm_name' => $gContent->mViewContentPerm ); +$displayHash = [ 'perm_name' => $gContent->mViewContentPerm ]; $gContent->invokeServices( 'content_display_function', $displayHash ); if( isset($_REQUEST['user_id']) && !isset( $_REQUEST['blog_id'] ) ) { diff --git a/includes/display_bitblogpost_inc.php b/includes/display_bitblogpost_inc.php index 08bd0a6..4844b6e 100755 --- a/includes/display_bitblogpost_inc.php +++ b/includes/display_bitblogpost_inc.php @@ -7,7 +7,6 @@ /** * required setup */ -use Bitweaver\Blogs\BitBlog; use Bitweaver\KernelTools; use \Bitweaver\Liberty\LibertyContent; @@ -25,10 +24,10 @@ if (!isset($gContent->mPostId)) { if (isset($_REQUEST['url'])) { // Add a trackback ping to the list of trackback_from - $title = isset($_REQUEST['title']) ? $_REQUEST['title'] : ''; + $title = $_REQUEST['title'] ?? ''; - $excerpt = isset($_REQUEST['excerpt']) ? $_REQUEST['excerpt'] : ''; - $blog_name = isset($_REQUEST['blog_name']) ? $_REQUEST['blog_name'] : ''; + $excerpt = $_REQUEST['excerpt'] ?? ''; + $blog_name = $_REQUEST['blog_name'] ?? ''; if ($gContent->addTrackbackFrom( $_REQUEST['url'], $title, $excerpt, $blog_name ) ) { print '<?xml version="1.0" encoding="iso-8859-1"?>'; @@ -78,14 +77,14 @@ if ( empty( $_REQUEST['format'] ) || $_REQUEST['format'] == "full" || $_REQUEST[ } else { // if the format requested is not the full post or the readmore data we default to just the first half of the post $parseHash['data'] = preg_replace( LIBERTY_SPLIT_REGEX, "", ( $_REQUEST['format'] != "more" )?$gContent->mInfo['raw']:$gContent->mInfo['raw_more']); - $parsed_data = LibertyContent::parseDataHash( $parseHash, $gContent ); + $parsed_data = LibertyContent::parseDataHash( $parseHash, $gContent ); } $gBitSmarty->assign('parsed_data', $parsed_data); $gBitSmarty->assign('post_info', $gContent->mInfo ); // Display the template -if ( isset( $_REQUEST['output'] ) && $_REQUEST['output']="ajax"){ +if ( isset( $_REQUEST['output'] ) && $_REQUEST['output']="ajax"){ $gBitSystem->display( 'bitpackage:blogs/view_blog_post_xml.tpl', null, [ 'format' => 'center_only', 'display_mode' => 'display' ] ); }else{ $gBitSystem->display( 'bitpackage:blogs/view_blog_post.tpl' , null, [ 'display_mode' => 'display' ] ); diff --git a/includes/lookup_post_inc.php b/includes/lookup_post_inc.php index efa3f90..f5475b0 100755 --- a/includes/lookup_post_inc.php +++ b/includes/lookup_post_inc.php @@ -7,17 +7,17 @@ /** * Initial Setup */ -global $gContent; +global $gContent; use Bitweaver\Blogs\BitBlogPost; use Bitweaver\BitBase; require_once LIBERTY_PKG_INCLUDE_PATH.'lookup_content_inc.php'; if( empty( $gContent ) || !is_object( $gContent ) || !$gContent->isValid() ) { // if blog_id supplied, use that - if( BitBase::verifyId( $_REQUEST['post_id'] ?? 0 ) ) { + if( BitBase::verifyId( $_REQUEST['post_id'] ?? 0 ) ) { $gContent = new BitBlogPost( $_REQUEST['post_id'] ); $gContent->load(); - } elseif( BitBase::verifyId( $_REQUEST['content_id'] ?? 0 ) ) { + } elseif( BitBase::verifyId( $_REQUEST['content_id'] ?? 0 ) ) { $gContent = new BitBlogPost( null, $_REQUEST['content_id'] ); $gContent->load(); } else { @@ -2,11 +2,12 @@ /** * @version $Header$ */ - + /** * required setup */ namespace Bitweaver\Blogs; + use Bitweaver\BitBase; require_once '../kernel/includes/setup_inc.php'; diff --git a/liberty_plugins/data.blog.php b/liberty_plugins/data.blog.php index 568285a..64c4d05 100755 --- a/liberty_plugins/data.blog.php +++ b/liberty_plugins/data.blog.php @@ -24,6 +24,7 @@ * definitions */ namespace Bitweaver\Liberty; + use Bitweaver\Users\RoleUser; use Bitweaver\Blogs\BitBlogPost; use Bitweaver\KernelTools; @@ -43,7 +44,7 @@ $pluginParams = [ 'help_page' => 'DataPluginBlog', 'description' => KernelTools::tra( "This plugin will display several posts from a blog." ), 'syntax' => "{BLOG id= user= max= format= }", - 'plugin_type' => DATA_PLUGIN + 'plugin_type' => DATA_PLUGIN, ]; $gLibertySystem->registerPlugin( PLUGIN_GUID_DATABLOG, $pluginParams ); $gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATABLOG ); @@ -91,18 +92,18 @@ function data_blog($data, $params) { // No change in the parameters with Clyde if ($gBitSystem->isPackageActive('blogs') && $gBitUser->hasPermission( 'p_blogs_view')) { // The next 2 lines allow access to the $pluginParams given above and may be removed when no longer needed $pluginParams = $gLibertySystem->mPlugins[PLUGIN_GUID_DATABLOG]; - + require_once BLOGS_PKG_CLASS_PATH.'BitBlog.php'; require_once LIBERTY_PKG_INCLUDE_PATH.'lookup_content_inc.php'; - + $module_params = $params; - + if (isset($module_params['id'])) { $gBitSmarty->assign('blog_id', $module_params['id']); } - + $blogPost = new BitBlogPost(); - + $sortOptions = [ "publish_date_desc", "publish_date_asc", @@ -115,14 +116,14 @@ function data_blog($data, $params) { // No change in the parameters with Clyde $sort_mode = !empty( $module_params['sort_mode'] ) && in_array( $module_params['sort_mode'], $sortOptions ) ? $module_params['sort_mode'] : 'publish_date_desc'; - + $getHash = []; - + if ( isset($module_params['user']) ){ $getHash['user'] = $module_params['user']; } if ( isset($module_params['id']) ){ $getHash['blog_id'] = $module_params['id'];} if ( isset($module_params['group_id']) ){ $getHash['group_id'] = $module_params['group_id'];} if ( isset($module_params['role_id']) ){ $getHash['role_id'] = $module_params['role_id'];} - + // handle draft posts $getHash['enforce_status'] = true; // @TODO enable lists that include draft posts @@ -131,7 +132,7 @@ function data_blog($data, $params) { // No change in the parameters with Clyde // if the object reference problem in the above mentions tpl is patched then use this if to enable drafts // if ( !empty( $module_params['status'] ) && $module_params['status'] = "draft" && isset( $gBitUser->mUserId ) ){ if ( false ) { - // if we are getting drafts then get future posts too + // if we are getting drafts then get future posts too $getHash['show_future'] = true; $getHash['min_status_id'] = -6; $getHash['max_status_id'] = -4; @@ -149,12 +150,12 @@ function data_blog($data, $params) { // No change in the parameters with Clyde $getHash['page'] = !empty($module_params['page']) ? $module_params['page'] : 1; $getHash['offset'] = !empty($module_params['offset']) ? $module_params['offset'] : 0; $blogPosts = $blogPost->getList( $getHash ); - + $display_format = empty($module_params['format']) ? 'simple_title_list' : $module_params['format']; - + switch( $display_format ) { case 'full': - $display_result = '<div class="blogs">'; + $display_result = '<div class="blogs">'; if ( $gBitSystem->isPackageActive( 'rss' ) ){ if ( isset($module_params['user']) ){ $rssUser = new RoleUser(); @@ -175,7 +176,7 @@ function data_blog($data, $params) { // No change in the parameters with Clyde } $gBitSmarty->assign( 'showDescriptionsOnly', true ); - + foreach( $blogPosts['data'] as $aPost ) { $gBitSmarty->assign('aPost', $aPost); $display_result .= $gBitSmarty->fetch( 'bitpackage:blogs/blog_list_post.tpl' ); diff --git a/list_blogs.php b/list_blogs.php index d5753dc..2b38aa1 100755 --- a/list_blogs.php +++ b/list_blogs.php @@ -33,11 +33,11 @@ if( $gContent->isValid() && isset($_REQUEST["remove"])) { } elseif( empty( $_REQUEST['confirm'] ) ) { $formHash['remove'] = $_REQUEST["remove"]; $formHash['blog_id'] = $gContent->mBlogId; - $gBitSystem->confirmDialog( $formHash, - array( - 'warning' => KernelTools::tra('Are you sure you want to delete this blog?') . ' ' . $gContent->getTitle(), + $gBitSystem->confirmDialog( $formHash, + [ + 'warning' => KernelTools::tra('Are you sure you want to delete this blog?') . ' ' . $gContent->getTitle(), 'error' => KernelTools::tra('This cannot be undone!'), - ) + ], ); } else { $gContent->expunge(); @@ -53,4 +53,4 @@ if( defined(ROLE_MODEL) ) { $gBitSmarty->assign( 'role_model', true ); } // Display the template -$gBitSystem->display( 'bitpackage:blogs/list_blogs.tpl', null, array( 'display_mode' => 'list' )); +$gBitSystem->display( 'bitpackage:blogs/list_blogs.tpl', null, [ 'display_mode' => 'list' ]); diff --git a/modules/index.php b/modules/index.php index 3e305fe..c0437d0 100755 --- a/modules/index.php +++ b/modules/index.php @@ -1,4 +1,4 @@ -<?php +<?php // This is not a package. header ("location: ../index.php"); diff --git a/modules/lastblogposts/mod_last_blog_posts.php b/modules/lastblogposts/mod_last_blog_posts.php index d53652e..b371319 100755 --- a/modules/lastblogposts/mod_last_blog_posts.php +++ b/modules/lastblogposts/mod_last_blog_posts.php @@ -19,7 +19,7 @@ if( !empty($module_params['date_start_offset']) ){ $date_start = time() - ( $module_params['date_start_offset'] * 3600 ); } -$defaultsHash = array( +$defaultsHash = [ 'sort_mode' => ( !empty( $module_params['sort_mode'] ) ? $module_params['sort_mode'] : 'publish_date_desc' ), 'max_records' => $module_rows, 'parse_data' => true, @@ -29,7 +29,7 @@ $defaultsHash = array( 'role_id' => ( BitBase::verifyId( $module_params['role_id'] ) ? $module_params['role_id'] : null ), 'date_start' => $date_start, 'offset' => ( !empty( $module_params['offset'] ) ? $module_params['offset'] : 0 ), -); +]; $listHash = array_merge($module_params, $defaultsHash); @@ -46,7 +46,7 @@ $listHash['enforce_status'] = true; if ( !empty( $module_params['status'] ) && $module_params['status'] = "draft" && isset( $gBitUser->mUserId ) ){ // if we are getting drafts then get future posts too - $listHash['show_future'] = true; + $listHash['show_future'] = true; $listHash['min_status_id'] = -6; $listHash['max_status_id'] = -4; $listHash['min_owner_status_id'] = -6; @@ -56,7 +56,6 @@ if ( !empty( $module_params['status'] ) && $module_params['status'] = "draft" && $listHash['min_owner_status_id'] = 0; } - $blogPost = new BitBlogPost(); $blogPosts = $blogPost->getList( $listHash ); diff --git a/modules/mod_blog_roll.php b/modules/mod_blog_roll.php index c66bca2..8bf91c0 100755 --- a/modules/mod_blog_roll.php +++ b/modules/mod_blog_roll.php @@ -20,7 +20,7 @@ RoleUser::userCollection( $moduleParams->value['module_params'] ?? null, $listHa $blog = new BitBlog(); if( $modBlogs = $blog->getList( $listHash ) ) { foreach( array_keys( $modBlogs ) as $b ) { - $modBlogs[$b]['post'] = $blog->getPost( [ 'blog_id' => $modBlogs[$b]['blog_id'] ] ); + $modBlogs[$b]['post'] = $blog->getPost( [ 'blog_id' => $modBlogs[$b]['blog_id'] ] ); } $gBitSmarty->assign( 'modBlogs', $modBlogs ); } diff --git a/modules/mod_last_blog_posts.php b/modules/mod_last_blog_posts.php index cb083a2..50def16 100755 --- a/modules/mod_last_blog_posts.php +++ b/modules/mod_last_blog_posts.php @@ -19,7 +19,7 @@ if( !empty($module_params['date_start_offset']) ){ $date_start = time() - ( $module_params['date_start_offset'] * 3600 ); } -$defaultsHash = array( +$defaultsHash = [ 'sort_mode' => ( !empty( $module_params['sort_mode'] ) ? $module_params['sort_mode'] : 'publish_date_desc' ), 'max_records' => $module_rows, 'parse_data' => true, @@ -29,7 +29,7 @@ $defaultsHash = array( 'group_id' => ( BitBase::verifyId( $module_params['group_id'] ) ? $module_params['group_id'] : null ), 'date_start' => $date_start, 'offset' => ( !empty( $module_params['offset'] ) ? $module_params['offset'] : 0 ), -); +]; $listHash = array_merge($module_params, $defaultsHash); @@ -46,7 +46,7 @@ $listHash['enforce_status'] = true; if ( !empty( $module_params['status'] ) && $module_params['status'] = "draft" && isset( $gBitUser->mUserId ) ){ // if we are getting drafts then get future posts too - $listHash['show_future'] = true; + $listHash['show_future'] = true; $listHash['min_status_id'] = -6; $listHash['max_status_id'] = -4; $listHash['min_owner_status_id'] = -6; @@ -56,7 +56,6 @@ if ( !empty( $module_params['status'] ) && $module_params['status'] = "draft" && $listHash['min_owner_status_id'] = 0; } - $blogPost = new BitBlogPost(); $blogPosts = $blogPost->getList( $listHash ); $descriptionLength = ( !empty( $module_params['max_preview_length'] ) ? $module_params['max_preview_length'] : 500 ); @@ -14,16 +14,14 @@ * required setup */ namespace Bitweaver; + require_once '../kernel/includes/setup_inc.php'; use Bitweaver\Blogs\BitBlog; -use Bitweaver\KernelTools; $gBitSystem->verifyPackage( 'blogs' ); - require_once BLOGS_PKG_INCLUDE_PATH.'lookup_post_inc.php'; - if ( isset( $_REQUEST["blog_id"] ) && $_REQUEST["blog_id"] > 0 ) { #setup so we know what the default target blog is in the template $gBlog = new BitBlog($_REQUEST["blog_id"]); @@ -35,7 +33,7 @@ if ( isset( $_REQUEST["blog_id"] ) && $_REQUEST["blog_id"] > 0 ) { } else { $gBlog = new BitBlog(); $_REQUEST["blog_id"] = 0; -} +} //must be owner or admin to edit an existing post if( $gContent->isValid() ) { @@ -44,7 +42,6 @@ if( $gContent->isValid() ) { $gContent->verifyCreatePermission(); } - // nuke post if requested if( !empty( $_REQUEST['action'] ) ) { if( $_REQUEST['action'] == 'remove' && $gContent->isValid() ) { @@ -57,7 +54,7 @@ if( !empty( $_REQUEST['action'] ) ) { $feedback['error'] = $gContent->mErrors; } } - $gBitSystem->setBrowserTitle( 'Confirm removal of '.$gContent->getTitle() ); + $gBitSystem->setBrowserTitle( 'Confirm removal of '.$gContent->getTitle() ); $formHash['remove'] = true; $formHash['action'] = 'remove'; $formHash['post_id'] = $_REQUEST['post_id']; @@ -76,7 +73,7 @@ if (isset($_REQUEST['remove_image'])) { } if( isset( $_REQUEST['format_guid'] ) && !isset( $gContent->mInfo['format_guid'] ) ) { - $formInfo['format_guid'] = $gContent->mInfo['format_guid'] = $_REQUEST['format_guid']; + $formInfo['format_guid'] = $gContent->mInfo['format_guid'] = $_REQUEST['format_guid']; } if (isset($_REQUEST["preview"])) { @@ -88,12 +85,12 @@ if (isset($_REQUEST["preview"])) { * this can eventually be removed with a change to the tpl to use post_info['parsed_data'] * but requires clean up in a few places. */ - $gBitSmarty->assign('parsed_data', $post['parsed_data']); + $gBitSmarty->assign('parsed_data', $post['parsed_data']); } elseif (isset($_REQUEST['save_post']) || isset($_REQUEST['save_post_exit'])) { // Editing page needs general ticket verification // $gBitUser->verifyTicket(); - // preserve a copy of the request data because if store fails we need to reprocess + // preserve a copy of the request data because if store fails we need to reprocess $requestCopy = $_REQUEST; if( $gContent->store( $_REQUEST ) ) { @@ -104,7 +101,7 @@ if (isset($_REQUEST["preview"])) { header ("location: ".BLOGS_PKG_URL."view_post.php?post_id=$postid"); die; } - + $parsed_data = $gContent->getParsedData(); $gBitSmarty->assign( 'title', $gContent->getTitle() ); @@ -114,7 +111,7 @@ if (isset($_REQUEST["preview"])) { $post = $gContent->preparePreview( $requestCopy ); $gContent->invokeServices( 'content_preview_function' ); $gBitSmarty->assign( 'post_info', $post ); - $gBitSmarty->assign('parsed_data', $post['parsed_data']); + $gBitSmarty->assign('parsed_data', $post['parsed_data']); } } elseif( !empty( $_REQUEST['edit'] ) ) { } else { @@ -124,7 +121,7 @@ if (isset($_REQUEST["preview"])) { * then we automatically move the publish date up to NOW to help users from publishing in the past. * if they set it backward and preview or save the back date will be preserved. */ - $gContent->mInfo['publish_date'] = $gBitSystem->getUTCTime(); + $gContent->mInfo['publish_date'] = $gBitSystem->getUTCTime(); } $gBitSmarty->assign('post_info', $gContent->mInfo); } diff --git a/print_blog_post.php b/print_blog_post.php index 9fcaf45..f389489 100755 --- a/print_blog_post.php +++ b/print_blog_post.php @@ -1,5 +1,4 @@ <?php -use Bitweaver\Blogs\BitBlogPost; use Bitweaver\KernelTools; /** @@ -60,7 +59,6 @@ if ($gBitSystem->isFeatureActive( 'blog_posts_comments' )) { include_once LIBERTY_PKG_INCLUDE_PATH.'comments_inc.php'; } - $gBitSystem->setBrowserTitle( $gContent->mInfo['title'] ); // Display the template $gBitSmarty->display("bitpackage:blogs/print_blog_post.tpl");
\ No newline at end of file diff --git a/rankings.php b/rankings.php index a129df0..11bc2f8 100755 --- a/rankings.php +++ b/rankings.php @@ -14,6 +14,7 @@ * required setup */ namespace Bitweaver\Blogs; + require_once '../kernel/includes/setup_inc.php'; use Bitweaver\KernelTools; use BitWeaver\Liberty\LibertyContent; @@ -25,15 +26,15 @@ $gBitSystem->verifyPermission( 'p_blogs_view' ); $rankingOptions = [ [ 'output' => KernelTools::tra( 'Most Often Viewed' ), - 'value' => 'hits_desc' + 'value' => 'hits_desc', ], [ 'output' => KernelTools::tra( 'Most Recently Modified' ), - 'value' => 'last_modified_desc' + 'value' => 'last_modified_desc', ], [ 'output' => KernelTools::tra( 'Most Active Authors' ), - 'value' => 'top_authors' + 'value' => 'top_authors', ], ]; $gBitSmarty->assign( 'rankingOptions', $rankingOptions ); @@ -68,10 +69,7 @@ if( empty( $gContent ) ) { $rankList = $gContent->getContentRanking( $_REQUEST ); $gBitSmarty->assign( 'rankList', $rankList ); -$gBitSystem->display( 'bitpackage:liberty/rankings.tpl', KernelTools::tra( "Blog Post Rankings" ) , array( 'display_mode' => 'display' )); - - - +$gBitSystem->display( 'bitpackage:liberty/rankings.tpl', KernelTools::tra( "Blog Post Rankings" ) , [ 'display_mode' => 'display' ]); /* ---- below is what blog rankings was - might want to canabalize some of it eventually ---- */ /* @@ -161,7 +159,7 @@ function blog_ranking_top_blogs($limit) { } /** TODO: This should be changed when we start using activity in the blog. - We should check TW 1.9 for code for that field in the blog. */ + We should check TW 1.9 for code for that field in the blog. */ /* function blog_ranking_top_active_blogs($limit) { global $gBitSystem; @@ -201,12 +199,12 @@ function blog_ranking_last_posts($limit) { $list['data'] = []; // Reorganize blogs by id foreach($blogs['data'] as $key => $blog) { - $list['data'][$blog['blog_id']] = $blog; + $list['data'][$blog['blog_id']] = $blog; } // And merge in posts foreach($posts['data'] as $key => $post) { - $post['post_url'] = $bp->getDisplayUrl($post['content_id']); - $list['data'][$post['blog_id']]['post_array'][] = $post; + $post['post_url'] = $bp->getDisplayUrl($post['content_id']); + $list['data'][$post['blog_id']]['post_array'][] = $post; } } $list['title'] = 'Last Posts'; diff --git a/recent_posts.php b/recent_posts.php index 3fea3c4..ce8a827 100755 --- a/recent_posts.php +++ b/recent_posts.php @@ -5,7 +5,7 @@ * @package blogs * @subpackage functions */ - + /** * Initial Setup */ diff --git a/send_post.php b/send_post.php index 8c5f525..9a8c3bb 100755 --- a/send_post.php +++ b/send_post.php @@ -79,7 +79,7 @@ if (isset($_REQUEST['send'])) { $gBitSmarty->assign('mail_machine', $machine); $mail_data = $gBitSmarty->fetch('bitpackage:blogs/blogs_send_link.tpl'); @mail($email, KernelTools::tra('Post recommendation at'). ' ' . $_SERVER["SERVER_NAME"], $mail_data, - "From: ".$gBitSystem->getConfig( 'site_sender_email' )."\r\nContent-type: text/plain;charset=utf-8\r\n"); + "From: ".$gBitSystem->getConfig( 'site_sender_email' )."\r\nContent-type: text/plain;charset=utf-8\r\n", ); } $gBitSmarty->assign('sent', 'y'); @@ -87,4 +87,4 @@ if (isset($_REQUEST['send'])) { $gBitSystem->setBrowserTitle("Send Blog Post: ".$gContent->mInfo['title']); // Display the template -$gBitSystem->display( 'bitpackage:blogs/send_blog_post.tpl', null, array( 'display_mode' => 'display' ));
\ No newline at end of file +$gBitSystem->display( 'bitpackage:blogs/send_blog_post.tpl', null, [ 'display_mode' => 'display' ]);
\ No newline at end of file diff --git a/templates/center_list_blog_posts.php b/templates/center_list_blog_posts.php index 550ce4b..25f6a2c 100755 --- a/templates/center_list_blog_posts.php +++ b/templates/center_list_blog_posts.php @@ -17,8 +17,8 @@ if( empty( $gContent )) { if( $gBitUser->hasPermission( 'p_blog_posts_read_future' ) || $gBitUser->isAdmin() ) { $futuresHash = []; - $futuresHash['max_records'] = !empty( $_REQUEST['max_records'] ) ? $_REQUEST['max_records'] : $gBitSystem->getConfig( 'blog_posts_max_list' ); - $futuresHash['get_future'] = true; + $futuresHash['max_records'] = !empty( $_REQUEST['max_records'] ) ? $_REQUEST['max_records'] : $gBitSystem->getConfig( 'blog_posts_max_list' ); + $futuresHash['get_future'] = true; if( empty( $futuresHash['user_id'] )) { if( !empty( $gQueryUserId )) { $futuresHash['user_id'] = $gQueryUserId; @@ -29,10 +29,10 @@ if( $gBitUser->hasPermission( 'p_blog_posts_read_future' ) || $gBitUser->isAdmin // prevent anything lower than publicly visible be displayed in blog roll $futuresHash['enforce_status'] = true; $futuresHash['min_owner_status_id'] = 0; - $futures = $blogPost->getFutureList( $futuresHash ); - $gBitSmarty->assign( 'futures', $futures['data'] ?? []); + $futures = $blogPost->getFutureList( $futuresHash ); + $gBitSmarty->assign( 'futures', $futures['data'] ?? []); } else { - $_REQUEST['max_records'] = $gBitSystem->getConfig( 'blog_posts_max_list' ); + $_REQUEST['max_records'] = $gBitSystem->getConfig( 'blog_posts_max_list' ); } // various options might be set in module_params @@ -52,7 +52,7 @@ if( !empty( $moduleParams->values )) { //$listHash['parse_data'] = true; //$listHash['load_comments'] = true; } else { - $listHash = $_REQUEST; + $listHash = $_REQUEST; } RoleUser::userCollection( $_REQUEST, $listHash ); @@ -65,7 +65,6 @@ if( !$gBitUser->hasPermission( 'p_blogs_admin' )) { $listHash['content_perm_name'] = 'p_blogs_view'; } - $paginationPath = BLOGS_PKG_URL.'index.php'; /* if a blog_id is passed from the modle settings then diff --git a/templates/index.php b/templates/index.php index 3e305fe..c0437d0 100755 --- a/templates/index.php +++ b/templates/index.php @@ -1,4 +1,4 @@ -<?php +<?php // This is not a package. header ("location: ../index.php"); diff --git a/view_post.php b/view_post.php index 63bc730..1e60a8d 100755 --- a/view_post.php +++ b/view_post.php @@ -14,7 +14,6 @@ * required setup */ require_once '../kernel/includes/setup_inc.php'; -use Bitweaver\Blogs\BitBlogPost; $gBitSystem->verifyPackage( 'blogs' ); |
