From 3cb0ce6c7e88d2b46847ad101c32969a50226739 Mon Sep 17 00:00:00 2001 From: Lester Caine Date: Thu, 14 May 2026 09:28:52 +0100 Subject: php-cs-fixer updates to php8.5 style --- admin/admin_types.php | 12 ++--- admin/schema_inc.php | 11 ++-- article_history.php | 5 +- articles_rss.php | 4 +- edit.php | 4 +- edit_topic.php | 5 +- includes/bit_setup_inc.php | 11 ++-- includes/classes/BitArticle.php | 49 +++++++++--------- includes/classes/BitArticleTopic.php | 39 ++++++-------- includes/lookup_article_topic_inc.php | 3 +- index.php | 3 +- liberty_plugins/data.articles.php | 12 ++--- list.php | 6 +-- list_topics.php | 5 +- modules/mod_articles.php | 3 +- print.php | 90 ++++++++++++++++---------------- rankings.php | 3 +- read.php | 4 +- templates/center_list_articles.php | 3 +- test/TestTikiArticle.php | 98 +++++++++++++++++------------------ 20 files changed, 180 insertions(+), 190 deletions(-) diff --git a/admin/admin_types.php b/admin/admin_types.php index 44e4a31..6bc2629 100755 --- a/admin/admin_types.php +++ b/admin/admin_types.php @@ -41,10 +41,10 @@ $artTypes = [ 'name' => KernelTools::tra( 'Show avatar' ), 'desc' => KernelTools::tra( 'Show author\'s avatar' ), ], - 'show_author' => array( + 'show_author' => [ 'name' => KernelTools::tra( 'Show author' ), 'desc' => KernelTools::tra( 'Show author\'s name' ), - ), + ], 'show_pubdate' => [ 'name' => KernelTools::tra( 'Show publish date' ), 'desc' => KernelTools::tra( 'Show publication date' ), @@ -71,9 +71,9 @@ $gBitSmarty->assign( 'artTypes', $artTypes ); $gContent = new BitArticleType( !empty( $_REQUEST['article_type_id'] ) ? $_REQUEST['article_type_id'] : NULL ); if( isset( $_REQUEST["add_type"] ) ) { - $gContent->storeType( $_REQUEST ); + $gContent->storeType( $_REQUEST ); } elseif( isset( $_REQUEST["remove_type"] ) ) { - $gContent->removeType( $_REQUEST['remove_type'] ); + $gContent->removeType( $_REQUEST['remove_type'] ); } elseif( isset( $_REQUEST["update_type"] ) ) { foreach( array_keys( $_REQUEST["type_array"] ) as $this_type ) { $storeHash['article_type_id'] = $this_type; @@ -81,8 +81,8 @@ if( isset( $_REQUEST["add_type"] ) ) { $storeHash[$option] = !empty( $_REQUEST[$option][$this_type] ) ? 'y' : 'n'; } $storeHash['type_name'] = $_REQUEST['type_name'][$this_type]; - $gContent->storeType( $storeHash ); - } + $gContent->storeType( $storeHash ); + } } $types = BitArticleType::getTypeList(); diff --git a/admin/schema_inc.php b/admin/schema_inc.php index f036298..ce6f2e0 100755 --- a/admin/schema_inc.php +++ b/admin/schema_inc.php @@ -62,10 +62,10 @@ foreach( array_keys( $tables ) AS $tableName ) { $gBitInstaller->registerSchemaTable( ARTICLES_PKG_NAME, $tableName, $tables[$tableName] ); } -$gBitInstaller->registerPackageInfo( ARTICLES_PKG_NAME, array( +$gBitInstaller->registerPackageInfo( ARTICLES_PKG_NAME, [ 'description' => "This package manages news articles to create a slashdot-like news site.", 'license' => 'LGPL', -) ); +] ); // these sequences are automatically generated, but Firebird and MSSQL prefers they exist // Starting the numbering off at 5 for types to allow room for the INSERTs later. @@ -76,7 +76,6 @@ $sequences = [ ]; $gBitInstaller->registerSchemaSequences( ARTICLES_PKG_NAME, $sequences ); - // $indices = array(); // $gBitInstaller->registerSchemaIndexes( ARTICLES_PKG_NAME, $indices ); @@ -89,7 +88,7 @@ $gBitInstaller->registerSchemaDefault( ARTICLES_PKG_NAME, [ "INSERT INTO `" . BIT_DB_PREFIX . "article_status` (`status_id`, `status_name`) VALUES (100, 'Draft') ", "INSERT INTO `" . BIT_DB_PREFIX . "article_status` (`status_id`, `status_name`) VALUES (200, 'Pending Approval') ", "INSERT INTO `" . BIT_DB_PREFIX . "article_status` (`status_id`, `status_name`) VALUES (300, 'Approved') ", - "INSERT INTO `" . BIT_DB_PREFIX . "article_status` (`status_id`, `status_name`) VALUES (400, 'Retired') " + "INSERT INTO `" . BIT_DB_PREFIX . "article_status` (`status_id`, `status_name`) VALUES (400, 'Retired') ", ] ); // ### Default UserPermissions @@ -128,9 +127,9 @@ $gBitInstaller->registerPreferences( ARTICLES_PKG_NAME, [ ] ); if( defined( 'RSS_PKG_NAME' )) { - $gBitInstaller->registerPreferences( ARTICLES_PKG_NAME, array( + $gBitInstaller->registerPreferences( ARTICLES_PKG_NAME, [ [ RSS_PKG_NAME, ARTICLES_PKG_NAME . '_rss', 'y' ], - )); + ]); } // ### Register content types diff --git a/article_history.php b/article_history.php index cf1b040..542d958 100755 --- a/article_history.php +++ b/article_history.php @@ -17,7 +17,6 @@ * required setup */ require_once '../kernel/includes/setup_inc.php'; -use Bitweaver\Articles\BitArticle; use Bitweaver\KernelTools; $gBitSystem->verifyPackage( 'articles' ); @@ -38,7 +37,7 @@ if( !$gContent->isValid() || empty( $gContent->mInfo ) ) { // additionally we need to check if this article is a submission and see if user has perms to view it. if( $gContent->getField( 'status_id' ) != ARTICLE_STATUS_APPROVED && !( $gContent->hasUserPermission( 'p_articles_update_submission' ) || $gBitUser->isAdmin() ) ) { $gBitSmarty->assign( 'msg', KernelTools::tra( "Permission denied you cannot view this article" ) ); - $gBitSystem->display( "error.tpl" , NULL, array( 'display_mode' => 'display' )); + $gBitSystem->display( "error.tpl" , NULL, [ 'display_mode' => 'display' ]); die; } @@ -59,4 +58,4 @@ $gBitSmarty->assign( 'numPages', $numPages ); // Display the template $gBitSmarty->assign( 'gContent', $gContent ); -$gBitSystem->display( 'bitpackage:articles/article_history.tpl', NULL, array( 'display_mode' => 'display' )); +$gBitSystem->display( 'bitpackage:articles/article_history.tpl', NULL, [ 'display_mode' => 'display' ]); diff --git a/articles_rss.php b/articles_rss.php index 611438c..02f796e 100755 --- a/articles_rss.php +++ b/articles_rss.php @@ -32,11 +32,11 @@ if( !$gBitUser->hasPermission( 'p_articles_read' ) ) { $rss->useCached( $rss_version_name, $cacheFile, $gBitSystem->getConfig( 'rssfeed_cache_time' )); $articles = new BitArticle(); - $listHash = array( + $listHash = [ 'status_id' => ARTICLE_STATUS_APPROVED, 'sort_mode' => 'publish_date_desc', 'max_records' => $gBitSystem->getConfig( 'articles_rss_max_records', 10 ), - ); + ]; $feeds = $articles->getList( $listHash ); // set the rss link diff --git a/edit.php b/edit.php index d0baabd..cb86263 100755 --- a/edit.php +++ b/edit.php @@ -72,7 +72,7 @@ if( !empty( $_REQUEST['save'] ) ) { } // Get a topic list -$topics = BitArticleTopic::getTopicList( array( 'active_topic' => TRUE ) ); +$topics = BitArticleTopic::getTopicList( [ 'active_topic' => TRUE ] ); $gBitSmarty->assign( 'topics', $topics ); if ( !empty( $_REQUEST['topic'] ) ) { $gBitSmarty->assign( 'topic', $_REQUEST['topic'] ); @@ -91,4 +91,4 @@ $gBitSmarty->assign( 'feedback', ( !empty( $feedback ) ? $feedback : NULL ) ); // Display the Index Template $gBitSmarty->assign( 'show_page_bar', 'n' ); -$gBitSystem->display( 'bitpackage:articles/edit_article.tpl', KernelTools::tra( "Articles" ) , array( 'display_mode' => 'edit' )); +$gBitSystem->display( 'bitpackage:articles/edit_article.tpl', KernelTools::tra( "Articles" ) , [ 'display_mode' => 'edit' ]); diff --git a/edit_topic.php b/edit_topic.php index 3290f05..e349e31 100755 --- a/edit_topic.php +++ b/edit_topic.php @@ -9,7 +9,6 @@ * Initialization */ require_once '../kernel/includes/setup_inc.php'; -use Bitweaver\Articles\BitArticle; use Bitweaver\KernelTools; include_once( ARTICLES_PKG_INCLUDE_PATH.'lookup_article_topic_inc.php' ); @@ -29,9 +28,9 @@ if( !$gContent->isValid() ) { $gBitSmarty->assign( 'topic_info', $gContent->mInfo); if( isset( $_REQUEST["fSubmitSaveTopic"] ) ) { - $gContent->storeTopic( $_REQUEST ); + $gContent->storeTopic( $_REQUEST ); $gContent->loadTopic(); - KernelTools::bit_redirect( ARTICLES_PKG_URL . "admin/admin_topics.php" ); + KernelTools::bit_redirect( ARTICLES_PKG_URL . "admin/admin_topics.php" ); } elseif( isset( $_REQUEST['fRemoveTopicImage'] ) ) { $gContent->removeTopicImage(); } diff --git a/includes/bit_setup_inc.php b/includes/bit_setup_inc.php index 0c9fdd8..1f40c41 100755 --- a/includes/bit_setup_inc.php +++ b/includes/bit_setup_inc.php @@ -3,6 +3,7 @@ * @package articles */ namespace Bitweaver\Articles; + use Bitweaver\KernelTools; global $gBitSystem, $gBitUser, $gBitSmarty; $pRegisterHash = [ @@ -15,9 +16,9 @@ $pRegisterHash = [ define( 'ARTICLES_PKG_NAME', $pRegisterHash['package_name'] ); define( 'ARTICLES_PKG_URL', BIT_ROOT_URL . basename( $pRegisterHash['package_path'] ) . '/' ); define( 'ARTICLES_PKG_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/' ); -define( 'ARTICLES_PKG_INCLUDE_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/'); +define( 'ARTICLES_PKG_INCLUDE_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/'); define( 'ARTICLES_PKG_CLASS_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/classes/'); -define( 'ARTICLES_PKG_ADMIN_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/admin/'); +define( 'ARTICLES_PKG_ADMIN_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/admin/'); $gBitSystem->registerPackage( $pRegisterHash ); @@ -30,14 +31,14 @@ if( $gBitSystem->isPackageActive( 'articles' ) ) { define( 'ARTICLE_STATUS_RETIRED', 400 ); if( $gBitUser->hasPermission( 'p_articles_read' )) { - $menuHash = array( + $menuHash = [ 'package_name' => ARTICLES_PKG_NAME, 'index_url' => ARTICLES_PKG_URL.'index.php', 'menu_template' => 'bitpackage:articles/menu_articles.tpl', 'admin_comments_url' => ARTICLES_PKG_URL.'admin/admin_types.php', - ); + ]; $gBitSystem->registerAppMenu( $menuHash ); } - $gBitSystem->registerNotifyEvent( array( "article_submitted" => KernelTools::tra( "A user submits an article" ) ) ); + $gBitSystem->registerNotifyEvent( [ "article_submitted" => KernelTools::tra( "A user submits an article" ) ] ); } diff --git a/includes/classes/BitArticle.php b/includes/classes/BitArticle.php index 5cce917..fc4ce0e 100755 --- a/includes/classes/BitArticle.php +++ b/includes/classes/BitArticle.php @@ -22,6 +22,7 @@ * Required setup */ namespace Bitweaver\Articles; + use Bitweaver\BitBase; use Bitweaver\BitDate; use Bitweaver\Liberty\LibertyContent; @@ -54,14 +55,14 @@ class BitArticle extends LibertyMime { parent::__construct(); $this->registerContentType( - BITARTICLE_CONTENT_TYPE_GUID, array( + BITARTICLE_CONTENT_TYPE_GUID, [ 'content_type_guid' => BITARTICLE_CONTENT_TYPE_GUID, 'content_name' => 'Article', 'handler_class' => 'BitArticle', 'handler_package' => 'articles', 'handler_file' => 'BitArticle.php', - 'maintainer_url' => 'https://www.bitweaver.org' - )); + 'maintainer_url' => 'https://www.bitweaver.org', + ], ); $this->mContentId = $pContentId; $this->mArticleId = $pArticleId; $this->mTypeId = NULL; @@ -160,7 +161,7 @@ class BitArticle extends LibertyMime $table = BIT_DB_PREFIX."articles"; if ( $this->isValid() ) { - $result = $this->mDb->associateUpdate( $table, $pParamHash['article_store'], array( "article_id" => $this->mArticleId )); + $result = $this->mDb->associateUpdate( $table, $pParamHash['article_store'], [ "article_id" => $this->mArticleId ]); } else { $pParamHash['article_store']['content_id'] = $pParamHash['content_id']; $pParamHash['article_store']['article_id'] = ( isset( $pParamHash['article_id'] ) && is_numeric( $pParamHash['article_id'] ) ) ? $pParamHash['article_id'] : $this->mDb->GenID( 'articles_article_id_seq' ); @@ -250,10 +251,10 @@ class BitArticle 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 ); @@ -269,10 +270,10 @@ class BitArticle 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 ); @@ -295,7 +296,7 @@ class BitArticle extends LibertyMime } // content preferences - $prefs = array(); + $prefs = []; if ($gBitUser->hasPermission( 'p_liberty_enter_html' )) { $prefs[] = 'content_enter_html'; } @@ -304,7 +305,7 @@ class BitArticle extends LibertyMime $pParamHash['preferences_store'][$pref] = ( !empty( $pParamHash['preferences'][$pref] ) ) ? $pParamHash['preferences'][$pref] : null; } - if (array_search( $pParamHash['article_store']['status_id'], array( ARTICLE_STATUS_DENIED, ARTICLE_STATUS_DRAFT, ARTICLE_STATUS_PENDING ) )) { + if (array_search( $pParamHash['article_store']['status_id'], [ ARTICLE_STATUS_DENIED, ARTICLE_STATUS_DRAFT, ARTICLE_STATUS_PENDING ] )) { $this->mInfo["no_index"] = true; } @@ -399,7 +400,7 @@ class BitArticle extends LibertyMime if ( $this->isValid() ) { $this->StartTrans(); $query = "DELETE FROM `".BIT_DB_PREFIX."articles` WHERE `content_id` = ?"; - $result = $this->mDb->query( $query, array( $this->mContentId ) ); + $result = $this->mDb->query( $query, [ $this->mContentId ] ); if ( LibertyMime::expunge() ) { $ret = TRUE; $this->CompleteTrans(); @@ -440,7 +441,7 @@ class BitArticle extends LibertyMime $joinSql = ''; $selectSql = ''; - $bindVars = array(); + $bindVars = []; array_push( $bindVars, $this->mContentTypeGuid ); $this->getServicesSql( 'content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars, NULL, $pParamHash ); @@ -488,7 +489,7 @@ class BitArticle extends LibertyMime // show only future // if we're trying to view these articles, we better have the perms to do so if ( !$gBitUser->hasPermission( 'p_articles_admin' )) { - return array(); + return []; } $whereSql .= " AND a.`publish_date` > ?"; $bindVars[] = (int) $now; @@ -496,7 +497,7 @@ class BitArticle extends LibertyMime // show only expired articles // if we're trying to view these articles, we better have the perms to do so if ( !$gBitUser->hasPermission( 'p_articles_admin' )) { - return array(); + return []; } $whereSql .= " AND a.`expire_date` < ? "; $bindVars[] = (int) $now; @@ -548,7 +549,7 @@ class BitArticle extends LibertyMime WHERE lc.`content_type_guid` = ? $whereSql"; $result = $this->mDb->query( $query, $bindVars, $pParamHash['max_records'], $pParamHash['offset'] ); - $ret = array(); + $ret = []; $comment = new LibertyComment(); while ( $res = $result->fetchRow() ) { // get this stuff parsed @@ -572,10 +573,10 @@ class BitArticle extends LibertyMime return $ret; } - /** - * Returns include file that will setup vars for display - * @return string the fully specified path to file to be included - */ + /** + * Returns include file that will setup vars for display + * @return string the fully specified path to file to be included + */ public function getRenderFile() { return ARTICLES_PKG_PATH."display_article_inc.php"; @@ -631,13 +632,13 @@ class BitArticle extends LibertyMime return $ret; } - /** - * Function that returns link to display an image - * @return string the url to display the gallery. - */ + /** + * Function that returns link to display an image + * @return string the url to display the gallery. + */ public function getDisplayUrl() { - $info = array( 'article_id' => $this->mArticleId ); + $info = [ 'article_id' => $this->mArticleId ]; return self::getDisplayUrlFromHash( $info ); } diff --git a/includes/classes/BitArticleTopic.php b/includes/classes/BitArticleTopic.php index c651dee..8151138 100755 --- a/includes/classes/BitArticleTopic.php +++ b/includes/classes/BitArticleTopic.php @@ -12,6 +12,7 @@ * Required setup */ namespace Bitweaver\Articles; + use Bitweaver\BitBase; use Bitweaver\KernelTools; @@ -48,7 +49,7 @@ class BitArticleTopic extends BitBase $sql = "SELECT artt.*". "FROM `".BIT_DB_PREFIX."article_topics` artt ". - $whereSQL; + $whereSQL; $this->mInfo = $this->mDb->getRow($sql, $bindVars); if( !empty( $this->mInfo['topic_id'] ) ) { @@ -120,7 +121,7 @@ class BitArticleTopic extends BitBase } if( $iParamHash['topic_id'] ) { - $this->mDb->associateUpdate( BIT_DB_PREFIX."article_topics", $iParamHash, array( 'topic_id' => $iParamHash['topic_id'] ) ); + $this->mDb->associateUpdate( BIT_DB_PREFIX."article_topics", $iParamHash, [ 'topic_id' => $iParamHash['topic_id'] ] ); } else { $iParamHash['topic_id'] = $topicId; $this->mDb->associateInsert( BIT_DB_PREFIX."article_topics", $iParamHash ); @@ -193,19 +194,19 @@ class BitArticleTopic extends BitBase $result = $gBitSystem->mDb->query( $query, $bindVars ); - $ret = []; + $ret = []; - while ( $res = $result->fetchRow() ) { + while ( $res = $result->fetchRow() ) { $res["num_articles"] = $gBitSystem->mDb->getOne( "SELECT COUNT(*) FROM `".BIT_DB_PREFIX."articles` WHERE `topic_id`= ?", [ $res["topic_id"] ] ); if ( empty( $res['topic_image_url'] ) && $res['has_topic_image'] == 'y' ) { $res['topic_image_url'] = BitArticleTopic::getTopicImageStorageUrl( $res['topic_id'] ); } - $ret[] = $res; - } + $ret[] = $res; + } - return $ret; - } + return $ret; + } public function removeTopicImage() { @@ -214,7 +215,7 @@ class BitArticleTopic extends BitBase @unlink( $this->getTopicImageStoragePath() ); } $sql = "UPDATE `".BIT_DB_PREFIX."article_topics` SET `has_topic_image` = 'n' WHERE `topic_id` = ?"; - $rs = $this->mDb->query($sql, array($this->mTopicId)); + $rs = $this->mDb->query($sql, [$this->mTopicId]); $this->mInfo['has_topic_image'] = 'n'; } } @@ -232,7 +233,7 @@ class BitArticleTopic extends BitBase public function setActivation($iIsActive = FALSE) { $sql = "UPDATE `".BIT_DB_PREFIX."article_topics` SET `active_topic` = '".($iIsActive ? 'y' : 'n')."' WHERE `topic_id` = ?"; - $rs = $this->mDb->query($sql, array($this->mTopicId)); + $rs = $this->mDb->query($sql, [$this->mTopicId]); $this->mInfo['active_topic'] = ($iIsActive ? 'y' : 'n'); } @@ -275,9 +276,6 @@ class BitArticleTopic extends BitBase $rs = $this->mDb->query($sql, [ $this->mTopicId ]); } - - - /***************************************************************************** * Image functions needed for backward compatability - these are needed to * * handle old article image style images that are not attachments. generally * @@ -330,9 +328,9 @@ class BitArticleTopic extends BitBase if ( !empty( $pTopicId ) ) { return $path.BitArticleTopic::getTopicImageStorageName( $pTopicId ); - } else { - return ''; } + return ''; + } /** @@ -370,9 +368,6 @@ class BitArticleTopic extends BitBase return str_replace( "//", "/", $ret ); } - - - /***************************************************************************** * Image functions needed for backward compatability - these are needed to * * handle old article image style images that are not attachments. generally * @@ -432,9 +427,9 @@ class BitArticleTopic extends BitBase if ( !empty( $pArticleId ) ) { return $path.BitArticleTopic::getArticleImageStorageName( $pArticleId ); - } else { - return FALSE; } + return FALSE; + } /** @@ -462,8 +457,8 @@ class BitArticleTopic extends BitBase if ( is_file( BitArticleTopic::getArticleImageStoragePath( NULL, TRUE ).BitArticleTopic::getArticleImageStorageName( $pArticleId ) ) ) { return $url.BitArticleTopic::getArticleImageStorageName( $pArticleId ).( $pForceRefresh ? "?".$gBitSystem->getUTCTime() : '' ); - } else { - return FALSE; } + return FALSE; + } } diff --git a/includes/lookup_article_topic_inc.php b/includes/lookup_article_topic_inc.php index 08b55fc..c630030 100755 --- a/includes/lookup_article_topic_inc.php +++ b/includes/lookup_article_topic_inc.php @@ -9,9 +9,8 @@ * Initialization */ global $gContent; -use Bitweaver\Articles\BitArticle; use Bitweaver\Articles\BitArticleTopic; - + // if we already have a gContent, we assume someone else created it for us, and has properly loaded everything up. if( empty( $gContent ) || !is_object( $gContent ) ) { $gContent = ( !empty( $_REQUEST['topic_id'] ) && is_numeric( $_REQUEST['topic_id'] ) ) ? new BitArticleTopic( $_REQUEST['topic_id'] ) : new BitArticleTopic(); diff --git a/index.php b/index.php index 41baab2..06facbe 100755 --- a/index.php +++ b/index.php @@ -8,6 +8,7 @@ * required setup */ namespace Bitweaver\Articles; + use Bitweaver\KernelTools; require_once '../kernel/includes/setup_inc.php'; @@ -28,4 +29,4 @@ $gDefaultCenter = 'bitpackage:articles/center_list_articles.tpl'; $gBitSmarty->assign( 'gDefaultCenter', $gDefaultCenter ); // Display the template -$gBitSystem->display( 'bitpackage:kernel/dynamic.tpl', KernelTools::tra( 'Articles' ) , array( 'display_mode' => 'display' )); +$gBitSystem->display( 'bitpackage:kernel/dynamic.tpl', KernelTools::tra( 'Articles' ) , [ 'display_mode' => 'display' ]); diff --git a/liberty_plugins/data.articles.php b/liberty_plugins/data.articles.php index bcbf334..f9b7591 100755 --- a/liberty_plugins/data.articles.php +++ b/liberty_plugins/data.articles.php @@ -89,19 +89,19 @@ function data_articles($data, $params) { // No change in the parameters with Cly $module_params = $params; $articlesObject = new BitArticle(); - $stati = array( 'pending', 'approved' ); + $stati = [ 'pending', 'approved' ]; $status_id = ( !empty( $module_params['status'] ) && in_array( $module_params['status'], $stati ) ) ? constant( 'ARTICLE_STATUS_' . strtoupper( $module_params['status'] ) ) : ARTICLE_STATUS_APPROVED; - $sortOptions = array( + $sortOptions = [ "last_modified_asc", "last_modified_desc", "created_asc", "created_desc", "random", - ); + ]; $sort_mode = ( !empty( $module_params['sort_mode'] ) && in_array( $module_params['sort_mode'], $sortOptions ) ) ? $module_params['sort_mode'] : 'last_modified_desc'; - $getHash = Array(); + $getHash = []; $getHash['status_id'] = $status_id; $getHash['sort_mode'] = $sort_mode; $getHash['max_records'] = empty( $module_params['max'] ) ? 1 : $module_params['max']; @@ -139,7 +139,7 @@ function data_articles($data, $params) { // No change in the parameters with Cly break; } return $display_result; - } else { - return "
The articles package is not active.
"; } + return "
The articles package is not active.
"; + } diff --git a/list.php b/list.php index c7e0d83..04dc1e1 100755 --- a/list.php +++ b/list.php @@ -50,12 +50,12 @@ if( !empty( $_REQUEST['action'] ) ) { $formHash['action'] = 'remove'; $formHash['status_id'] = ( !empty( $_REQUEST['status_id'] ) ? $_REQUEST['status_id'] : '' ); $formHash['remove_article_id'] = $_REQUEST['remove_article_id']; - $msgHash = array( + $msgHash = [ 'label' => KernelTools::tra('Remove Article'), 'confirm_item' => $tmpArt->mInfo['title'], 'warning' => KernelTools::tra('Remove the above article.'), 'error' => KernelTools::tra('This cannot be undone!'), - ); + ]; $gBitSystem->confirmDialog( $formHash, $msgHash ); } } @@ -83,4 +83,4 @@ $gBitSmarty->assign( 'listInfo', $_REQUEST['listInfo'] ); $gBitSmarty->assign( 'listpages', $listArticles ); // Display the template -$gBitSystem->display( 'bitpackage:articles/list_articles.tpl', KernelTools::tra( "Articles" ), array( 'display_mode' => 'list' )); +$gBitSystem->display( 'bitpackage:articles/list_articles.tpl', KernelTools::tra( "Articles" ), [ 'display_mode' => 'list' ]); diff --git a/list_topics.php b/list_topics.php index c7c4800..ccd767d 100755 --- a/list_topics.php +++ b/list_topics.php @@ -1,4 +1,4 @@ -assign( 'topics', $topics ); -$gBitSystem->display( 'bitpackage:articles/list_topics.tpl', KernelTools::tra( 'List Topics' ) , array( 'display_mode' => 'list' )); +$gBitSystem->display( 'bitpackage:articles/list_topics.tpl', KernelTools::tra( 'List Topics' ) , [ 'display_mode' => 'list' ]); diff --git a/modules/mod_articles.php b/modules/mod_articles.php index 4b43baa..41ab3a2 100755 --- a/modules/mod_articles.php +++ b/modules/mod_articles.php @@ -10,11 +10,10 @@ */ use Bitweaver\Articles\BitArticle; - extract( $moduleParams ); $articles = new BitArticle(); -$stati = array( 'pending', 'approved' ); +$stati = [ 'pending', 'approved' ]; $status_id = ( !empty( $module_params['status'] ) && in_array( $module_params['status'], $stati ) ) ? constant( 'ARTICLE_STATUS_' . strtoupper( $module_params['status'] ) ) : ARTICLE_STATUS_APPROVED; $sortOptions = [ diff --git a/print.php b/print.php index c524f9d..0bdfc06 100755 --- a/print.php +++ b/print.php @@ -1,4 +1,4 @@ -assign( 'msg', KernelTools::tra( "No article indicated" ) ); + $gBitSmarty->assign( 'msg', KernelTools::tra( "No article indicated" ) ); - $gBitSmarty->display( "error.tpl" ); - die; -} + $gBitSmarty->display( "error.tpl" ); + die; +} if ( isset( $_REQUEST["article_id"] ) ) { - $artlib->add_article_hit( $_REQUEST["article_id"] ); + $artlib->add_article_hit( $_REQUEST["article_id"] ); - $gBitSmarty->assign( 'article_id', $_REQUEST["article_id"] ); - $article_data = $artlib->get_article( $_REQUEST["article_id"] ); + $gBitSmarty->assign( 'article_id', $_REQUEST["article_id"] ); + $article_data = $artlib->get_article( $_REQUEST["article_id"] ); - if ( !$article_data ) { - $gBitSmarty->assign( 'msg', KernelTools::tra( "Article not found" ) ); + if ( !$article_data ) { + $gBitSmarty->assign( 'msg', KernelTools::tra( "Article not found" ) ); - $gBitSmarty->display( "error.tpl" ); - die; - } + $gBitSmarty->display( "error.tpl" ); + die; + } if ( ( $article_data["publish_date"] > date( "U" ) ) && ( !$gBitUser->isAdmin() ) ) { - $gBitSmarty->assign( 'msg', KernelTools::tra( "Article is not published yet" ) ); - - $gBitSmarty->display( "error.tpl" ); - die; - } - - $gBitSmarty->assign( 'title', $article_data["title"] ); - $gBitSmarty->assign( 'author_name', $article_data["author_name"] ); - $gBitSmarty->assign( 'topic_id', $article_data["topic_id"] ); - $gBitSmarty->assign( 'use_image', $article_data["use_image"] ); - $gBitSmarty->assign( 'image_name', $article_data["image_name"] ); - $gBitSmarty->assign( 'image_type', $article_data["image_type"] ); - $gBitSmarty->assign( 'image_size', $article_data["image_size"] ); - $gBitSmarty->assign( 'image_data', urlencode( $article_data["image_data"] ) ); - $gBitSmarty->assign( 'reads', $article_data["hits"] ); - $gBitSmarty->assign( 'size', $article_data["size"] ); - - if ( strlen( $article_data["image_data"] ) > 0 ) { - $gBitSmarty->assign( 'hasImage', 'y' ); - - $hasImage = 'y'; - } - - $gBitSmarty->assign( 'heading', $article_data["heading"] ); - $gBitSmarty->assign( 'body', $article_data["body"] ); - $gBitSmarty->assign( 'publish_date', $article_data["publish_date"] ); - $gBitSmarty->assign( 'edit_data', 'y' ); - - $body = $article_data["body"]; - $heading = $article_data["heading"]; - $gBitSmarty->assign( 'parsed_body', $tikilib->parse_data( $body ) ); - $gBitSmarty->assign( 'parsed_heading', $tikilib->parse_data( $heading ) ); + $gBitSmarty->assign( 'msg', KernelTools::tra( "Article is not published yet" ) ); + + $gBitSmarty->display( "error.tpl" ); + die; + } + + $gBitSmarty->assign( 'title', $article_data["title"] ); + $gBitSmarty->assign( 'author_name', $article_data["author_name"] ); + $gBitSmarty->assign( 'topic_id', $article_data["topic_id"] ); + $gBitSmarty->assign( 'use_image', $article_data["use_image"] ); + $gBitSmarty->assign( 'image_name', $article_data["image_name"] ); + $gBitSmarty->assign( 'image_type', $article_data["image_type"] ); + $gBitSmarty->assign( 'image_size', $article_data["image_size"] ); + $gBitSmarty->assign( 'image_data', urlencode( $article_data["image_data"] ) ); + $gBitSmarty->assign( 'reads', $article_data["hits"] ); + $gBitSmarty->assign( 'size', $article_data["size"] ); + + if ( strlen( $article_data["image_data"] ) > 0 ) { + $gBitSmarty->assign( 'hasImage', 'y' ); + + $hasImage = 'y'; + } + + $gBitSmarty->assign( 'heading', $article_data["heading"] ); + $gBitSmarty->assign( 'body', $article_data["body"] ); + $gBitSmarty->assign( 'publish_date', $article_data["publish_date"] ); + $gBitSmarty->assign( 'edit_data', 'y' ); + + $body = $article_data["body"]; + $heading = $article_data["heading"]; + $gBitSmarty->assign( 'parsed_body', $tikilib->parse_data( $body ) ); + $gBitSmarty->assign( 'parsed_heading', $tikilib->parse_data( $heading ) ); } $gBitSmarty->display( "bitpackage:articles/print_article.tpl" ); diff --git a/rankings.php b/rankings.php index e1153bb..fe706a4 100755 --- a/rankings.php +++ b/rankings.php @@ -1,4 +1,4 @@ -isPackageActive( 'articles' ); $gBitSystem->isFeatureActive( 'articles_rankings' ); diff --git a/read.php b/read.php index 53f10f9..6f6ddd1 100755 --- a/read.php +++ b/read.php @@ -46,7 +46,7 @@ $gContent->addHit(); $gBitSmarty->assign( 'article', $gContent->mInfo ); // get all the services that want to display something on this page -$displayHash = array( 'perm_name' => 'p_articles_read' ); +$displayHash = [ 'perm_name' => 'p_articles_read' ]; $gContent->invokeServices( 'content_display_function', $displayHash ); $topics = BitArticleTopic::getTopicList(); @@ -54,7 +54,7 @@ $gBitSmarty->assign( 'topics', $topics ); // Comments engine! if( @$gContent->mInfo['allow_comments'] == 'y' ) { - $comments_vars = Array( 'article' ); + $comments_vars = [ 'article' ]; $comments_prefix_var='article:'; $comments_object_var='article'; $commentsParentId = $gContent->mContentId; diff --git a/templates/center_list_articles.php b/templates/center_list_articles.php index 51c0607..f49fe9f 100755 --- a/templates/center_list_articles.php +++ b/templates/center_list_articles.php @@ -6,7 +6,6 @@ global $gBitSmarty, $gBitSystem, $gQueryUserId, $moduleParams, $gContent; // extract( $moduleParams->value ); //} - include_once( ARTICLES_PKG_INCLUDE_PATH.'lookup_article_inc.php' ); include_once( ARTICLES_PKG_INCLUDE_PATH.'article_filter_inc.php' ); @@ -48,7 +47,7 @@ $gBitSmarty->assign( 'showDescriptionsOnly', TRUE ); // display submissions if we have the perm to approve them if ( $gBitUser->hasPermission( 'p_articles_approve_submission' ) || ( $gBitSystem->isFeatureActive( 'articles_auto_approve' ) && $gBitUser->isRegistered() )) { - $listHash = array( 'status_id' => ARTICLE_STATUS_PENDING ); + $listHash = [ 'status_id' => ARTICLE_STATUS_PENDING ]; $submissions = $gContent->getList( $listHash ); $gBitSmarty->assign( 'submissions', $submissions ); } diff --git a/test/TestTikiArticle.php b/test/TestTikiArticle.php index 89eb857..b63cb94 100755 --- a/test/TestTikiArticle.php +++ b/test/TestTikiArticle.php @@ -4,27 +4,27 @@ use Bitweaver\Articles\BitArticle; class TestBitArticle extends Test { - public $test; - public $id; - public $count; + public $test; + public $id; + public $count; - public function TestBitArticle() - { - $this->test = new BitArticle(); - Assert::equalsTrue($this->test != NULL, 'Error during initialisation'); - } + public function TestBitArticle() + { + $this->test = new BitArticle(); + Assert::equalsTrue($this->test != NULL, 'Error during initialisation'); + } - public function testGetItems() - { - $filter = array(); - $list = $this->test->getList($filter); - $this->count = count($list); - Assert::equalsTrue(is_array($list)); - } + public function testGetItems() + { + $filter = []; + $list = $this->test->getList($filter); + $this->count = count($list); + Assert::equalsTrue(is_array($list)); + } - public function testStoreItem() - { - $newItemHash = array( + public function testStoreItem() + { + $newItemHash = [ "title" => "Test Title", "description" => "Test Description", "data" => "Test Text", @@ -43,43 +43,43 @@ class TestBitArticle extends Test "hash" => NULL, "type" => NULL, "isfloat" => NULL, - ); - Assert::equalsTrue($this->test->store($newItemHash)); - } + ]; + Assert::equalsTrue($this->test->store($newItemHash)); + } - public function testIsValidItem() - { - Assert::equalsTrue($this->test->isValid()); - } + public function testIsValidItem() + { + Assert::equalsTrue($this->test->isValid()); + } - public function testNullItem() - { + public function testNullItem() + { $this->id = $this->test->mArticleId; - $this->test = NULL; - Assert::equals($this->test, NULL); - } + $this->test = NULL; + Assert::equals($this->test, NULL); + } - public function testLoadItem() - { - $this->test = new BitArticle($this->id); - Assert::equals($this->test->load(), 37); - } + public function testLoadItem() + { + $this->test = new BitArticle($this->id); + Assert::equals($this->test->load(), 37); + } - public function testUrlItem() - { - Assert::equalsTrue($this->test->getDisplayUrl() != ""); - } + public function testUrlItem() + { + Assert::equalsTrue($this->test->getDisplayUrl() != ""); + } - public function testExpungeItem() - { - Assert::equalsTrue($this->test->expunge()); - } + public function testExpungeItem() + { + Assert::equalsTrue($this->test->expunge()); + } - public function testCountItems() - { - $filter = array(); - $count = count($this->test->getList($filter)); - Assert::equals($this->count, $count); - } + public function testCountItems() + { + $filter = []; + $count = count($this->test->getList($filter)); + Assert::equals($this->count, $count); + } } -- cgit v1.3