summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorlsces <lester@lsces.co.uk>2026-02-01 17:57:53 +0000
committerlsces <lester@lsces.co.uk>2026-02-01 17:57:53 +0000
commit0b7bc39d45c39f36e13e704ac126f9246a9be62f (patch)
treebed4210bdc7e2c43716ca3d42a44e9cbbc58780d /includes
parente75480ed0929f12c69465d63aba1615db7b9436a (diff)
downloadarticles-0b7bc39d45c39f36e13e704ac126f9246a9be62f.tar.gz
articles-0b7bc39d45c39f36e13e704ac126f9246a9be62f.tar.bz2
articles-0b7bc39d45c39f36e13e704ac126f9246a9be62f.zip
Major refactor for namespace, php8.4 and smarty5
Diffstat (limited to 'includes')
-rwxr-xr-x[-rw-r--r--]includes/article_filter_inc.php3
-rwxr-xr-xincludes/bit_setup_inc.php43
-rwxr-xr-x[-rw-r--r--]includes/classes/BitArticle.php167
-rwxr-xr-x[-rw-r--r--]includes/classes/BitArticleTopic.php261
-rwxr-xr-x[-rw-r--r--]includes/classes/BitArticleType.php34
-rwxr-xr-x[-rw-r--r--]includes/display_article_inc.php11
-rwxr-xr-x[-rw-r--r--]includes/lookup_article_inc.php3
-rwxr-xr-x[-rw-r--r--]includes/lookup_article_topic_inc.php11
8 files changed, 293 insertions, 240 deletions
diff --git a/includes/article_filter_inc.php b/includes/article_filter_inc.php
index 8635c12..24dbbbd 100644..100755
--- a/includes/article_filter_inc.php
+++ b/includes/article_filter_inc.php
@@ -4,6 +4,9 @@
* @package articles
* @subpackage functions
*/
+use Bitweaver\Articles\BitArticle;
+use Bitweaver\Articles\BitArticleTopic;
+use Bitweaver\Articles\BitArticleType;
if( $gBitSystem->isFeatureActive( 'articles_display_filter_bar' ) && ( $gBitUser->isAdmin() || $gBitUser->hasPermission( 'p_articles_admin' ) ) ) {
$filter['topic'][] = '';
diff --git a/includes/bit_setup_inc.php b/includes/bit_setup_inc.php
new file mode 100755
index 0000000..0c9fdd8
--- /dev/null
+++ b/includes/bit_setup_inc.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * @package articles
+ */
+namespace Bitweaver\Articles;
+use Bitweaver\KernelTools;
+global $gBitSystem, $gBitUser, $gBitSmarty;
+$pRegisterHash = [
+ 'package_name' => 'articles',
+ 'package_path' => dirname( dirname( __FILE__ ) ).'/',
+ 'homeable' => true,
+];
+
+// fix to quieten down VS Code which can't see the dynamic creation of these ...
+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_CLASS_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/classes/');
+define( 'ARTICLES_PKG_ADMIN_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/admin/');
+
+$gBitSystem->registerPackage( $pRegisterHash );
+
+if( $gBitSystem->isPackageActive( 'articles' ) ) {
+
+ define( 'ARTICLE_STATUS_DENIED', 0 );
+ define( 'ARTICLE_STATUS_DRAFT', 100 );
+ define( 'ARTICLE_STATUS_PENDING', 200 );
+ define( 'ARTICLE_STATUS_APPROVED', 300 );
+ define( 'ARTICLE_STATUS_RETIRED', 400 );
+
+ if( $gBitUser->hasPermission( 'p_articles_read' )) {
+ $menuHash = array(
+ '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" ) ) );
+}
diff --git a/includes/classes/BitArticle.php b/includes/classes/BitArticle.php
index 6b9a4e3..7b1a285 100644..100755
--- a/includes/classes/BitArticle.php
+++ b/includes/classes/BitArticle.php
@@ -21,10 +21,13 @@
/**
* Required setup
*/
-require_once( ARTICLES_PKG_CLASS_PATH.'BitArticleTopic.php' );
-require_once( ARTICLES_PKG_CLASS_PATH.'BitArticleType.php' );
-require_once( LIBERTY_PKG_CLASS_PATH.'LibertyMime.php' );
-require_once( LIBERTY_PKG_CLASS_PATH.'LibertyComment.php' );
+namespace Bitweaver\Articles;
+use Bitweaver\BitBase;
+use Bitweaver\BitDate;
+use Bitweaver\Liberty\LibertyContent;
+use Bitweaver\Liberty\LibertyMime;
+use Bitweaver\Liberty\LibertyComment;
+use function in_array;
define( 'BITARTICLE_CONTENT_TYPE_GUID', 'bitarticle' );
@@ -39,6 +42,7 @@ class BitArticle extends LibertyMime
public $mArticleId;
public $mTypeId;
public $mTopicId;
+ public $mDate;
/**
* Initiate the articles class
@@ -55,7 +59,7 @@ class BitArticle extends LibertyMime
'content_name' => 'Article',
'handler_class' => 'BitArticle',
'handler_package' => 'articles',
- 'handler_file' => 'includes/classes/BitArticle.php',
+ 'handler_file' => 'BitArticle.php',
'maintainer_url' => 'http://www.bitweaver.org'
));
$this->mContentId = $pContentId;
@@ -133,7 +137,7 @@ class BitArticle extends LibertyMime
$this->mInfo['primary_attachment'] = &$this->mStorage[$this->mInfo['primary_attachment_id']];
}
- $this->mInfo['parsed'] = $this->parseData();
+ $this->parseData();
} else {
$this->mArticleId = NULL;
}
@@ -148,7 +152,7 @@ class BitArticle extends LibertyMime
* @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why
* @access public
**/
- public function store(&$pParamHash)
+ public function store(&$pParamHash): bool
{
global $gBitSystem;
$this->StartTrans();
@@ -159,12 +163,7 @@ class BitArticle extends LibertyMime
$result = $this->mDb->associateUpdate( $table, $pParamHash['article_store'], array( "article_id" => $this->mArticleId ));
} else {
$pParamHash['article_store']['content_id'] = $pParamHash['content_id'];
- if ( isset( $pParamHash['article_id'] )&& is_numeric( $pParamHash['article_id'] ) ) {
- // if pParamHash['article_id'] is set, someone is requesting a particular article_id. Use with caution!
- $pParamHash['article_store']['article_id'] = $pParamHash['article_id'];
- } else {
- $pParamHash['article_store']['article_id'] = $this->mDb->GenID( 'articles_article_id_seq' );
- }
+ $pParamHash['article_store']['article_id'] = ( isset( $pParamHash['article_id'] ) && is_numeric( $pParamHash['article_id'] ) ) ? $pParamHash['article_id'] : $this->mDb->GenID( 'articles_article_id_seq' );
$this->mArticleId = $pParamHash['article_store']['article_id'];
$result = $this->mDb->associateInsert( $table, $pParamHash['article_store'] );
}
@@ -176,80 +175,82 @@ class BitArticle extends LibertyMime
}
/**
- * Make sure the data is safe to store
- * @param pParamHash be sure to pass by reference in case we need to make modifcations to the hash
- * @param array pParams reference to hash of values that will be used to store the page, they will be modified where necessary
- * @return bool TRUE on success, FALSE if verify failed. If FALSE, $this->mErrors will have reason why
- * @access private
- **/
- public function verify(&$pParamHash)
+ * 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
+ * @param array pParams reference to hash of values that will be used to store the page, they will be modified where necessary
+ * @return bool TRUE on success, FALSE if verify failed. If FALSE, $this->mErrors will have reason why
+ **/
+ public function verify( &$pParamHash ): bool
{
global $gBitUser, $gBitSystem;
// make sure we're all loaded up of we have a mArticleId
- if ( $this->mArticleId && empty( $this->mInfo ) ) {
+ if ($this->mArticleId && empty( $this->mInfo )) {
$this->load();
}
- if ( @$this->verifyId( $this->mInfo['content_id'] ) ) {
+ if (@$this->verifyId( $this->mInfo['content_id'] )) {
$pParamHash['content_id'] = $this->mInfo['content_id'];
}
// It is possible a derived class set this to something different
- if ( empty( $pParamHash['content_type_guid'] )&& !empty( $this->mContentTypeGuid ) ) {
+ if (empty( $pParamHash['content_type_guid'] ) && !empty( $this->mContentTypeGuid )) {
$pParamHash['content_type_guid'] = $this->mContentTypeGuid;
}
- if ( @$this->verifyId( $pParamHash['content_id'] ) ) {
+ if (@$this->verifyId( $pParamHash['content_id'] )) {
$pParamHash['article_store']['content_id'] = $pParamHash['content_id'];
}
- if ( !empty( $pParamHash['author_name'] ) ) {
+ if (!empty( $pParamHash['author_name'] )) {
$pParamHash['article_store']['author_name'] = $pParamHash['author_name'];
}
- if ( @$this->verifyId( $pParamHash['topic_id'] ) ) {
- $pParamHash['article_store']['topic_id'] =(int) $pParamHash['topic_id'];
+ if (@$this->verifyId( $pParamHash['topic_id'] )) {
+ $pParamHash['article_store']['topic_id'] = (int) $pParamHash['topic_id'];
}
- if ( @$this->verifyId( $pParamHash['article_type_id'] ) ) {
- $pParamHash['article_store']['article_type_id'] =(int) $pParamHash['article_type_id'];
+ if (@$this->verifyId( $pParamHash['article_type_id'] )) {
+ $pParamHash['article_store']['article_type_id'] = (int) $pParamHash['article_type_id'];
}
- if ( !empty( $pParamHash['format_guid'] ) ) {
+ if (!empty( $pParamHash['format_guid'] )) {
$pParamHash['content_store']['format_guid'] = $pParamHash['format_guid'];
}
// we do the substr on load. otherwise we need to store the same data twice.
- if ( !empty( $pParamHash['edit'] ) ) {
+ if (!empty( $pParamHash['edit'] )) {
$pParamHash['content_store']['data'] = $pParamHash['edit'];
}
- if ( !empty( $pParamHash['rating'] ) ) {
- $pParamHash['article_store']['rating'] =(int) ( $pParamHash['rating'] );
+ if (!empty( $pParamHash['rating'] )) {
+ $pParamHash['article_store']['rating'] = (int) ( $pParamHash['rating'] );
}
// check for name issues, first truncate length if too long
- if ( !empty( $pParamHash['title'] ) ) {
- if ( !$this->isValid() ) {
- if ( empty( $pParamHash['title'] ) ) {
+ if (!empty( $pParamHash['title'] )) {
+ if (!$this->isValid()) {
+ if (empty( $pParamHash['title'] )) {
$this->mErrors['title'] = 'You must specify a title.';
- } else {
+ }
+ else {
$pParamHash['content_store']['title'] = substr( $pParamHash['title'], 0, BIT_CONTENT_MAX_TITLE_LEN );
}
- } else {
- $pParamHash['content_store']['title'] =( isset( $pParamHash['title'] ))? substr( $pParamHash['title'], 0, BIT_CONTENT_MAX_TITLE_LEN ): '';
}
- } elseif ( empty( $pParamHash['title'] ) ) {
+ else {
+ $pParamHash['content_store']['title'] = ( isset( $pParamHash['title'] ) ) ? substr( $pParamHash['title'], 0, BIT_CONTENT_MAX_TITLE_LEN ) : '';
+ }
+ }
+ elseif (empty( $pParamHash['title'] )) {
// no name specified
$this->mErrors['title'] = 'You must specify a title';
}
- if ( !empty( $pParamHash['publish_Month'] ) ) {
+ if (!empty( $pParamHash['publish_Month'] )) {
$dateString = $this->mDate->gmmktime(
$pParamHash['publish_Hour'],
$pParamHash['publish_Minute'],
- isset($pParamHash['publish_Second']) ? $pParamHash['publish_Second'] : 0,
+ isset( $pParamHash['publish_Second'] ) ? $pParamHash['publish_Second'] : 0,
$pParamHash['publish_Month'],
$pParamHash['publish_Day'],
$pParamHash['publish_Year']
@@ -260,15 +261,15 @@ class BitArticle extends LibertyMime
$pParamHash['publish_date'] = $timestamp;
}
}
- if ( !empty( $pParamHash['publish_date'] ) ) {
+ if (!empty( $pParamHash['publish_date'] )) {
$pParamHash['article_store']['publish_date'] = $pParamHash['publish_date'];
}
- if ( !empty( $pParamHash['expire_Month'] ) ) {
+ if (!empty( $pParamHash['expire_Month'] )) {
$dateString = $this->mDate->gmmktime(
$pParamHash['expire_Hour'],
$pParamHash['expire_Minute'],
- isset($pParamHash['expire_Second']) ? $pParamHash['expire_Second'] : 0,
+ isset( $pParamHash['expire_Second'] ) ? $pParamHash['expire_Second'] : 0,
$pParamHash['expire_Month'],
$pParamHash['expire_Day'],
$pParamHash['expire_Year']
@@ -279,50 +280,36 @@ class BitArticle extends LibertyMime
$pParamHash['expire_date'] = $timestamp;
}
}
- if ( !empty( $pParamHash['expire_date'] ) ) {
+ if (!empty( $pParamHash['expire_date'] )) {
$pParamHash['article_store']['expire_date'] = $pParamHash['expire_date'];
}
- if ( @$this->verifyId( $pParamHash['status_id'] ) ) {
- if ($pParamHash['status_id'] > ARTICLE_STATUS_PENDING) {
- if ( $gBitUser->hasPermission( 'p_articles_approve_submission' )) {
- $pParamHash['article_store']['status_id'] =(int) ( $pParamHash['status_id'] );
- } else {
- $pParamHash['article_store']['status_id'] = ARTICLE_STATUS_PENDING;
- }
- } else {
- $pParamHash['article_store']['status_id'] =(int) ( $pParamHash['status_id'] );
- }
- } elseif ( @$this->verifyId( $this->mInfo['status_id'] ) ) {
+ if (@$this->verifyId( $pParamHash['status_id'] )) {
+ $pParamHash['article_store']['status_id'] = ( $pParamHash['status_id'] > ARTICLE_STATUS_PENDING ) ? ( $gBitUser->hasPermission( 'p_articles_approve_submission' ) ) ? (int) ( $pParamHash['status_id'] ) : ARTICLE_STATUS_PENDING : (int) ( $pParamHash['status_id'] );
+ }
+ elseif (@$this->verifyId( $this->mInfo['status_id'] )) {
$pParamHash['article_store']['status_id'] = $this->mInfo['status_id'];
- } else {
- if ( $gBitUser->hasPermission( 'p_articles_approve_submission' ) || $gBitUser->hasPermission( 'p_articles_auto_approve' ) ) {
- $pParamHash['article_store']['status_id'] = ARTICLE_STATUS_APPROVED;
- } else {
- $pParamHash['article_store']['status_id'] = ARTICLE_STATUS_PENDING; // Default status
- }
+ }
+ else {
+ $pParamHash['article_store']['status_id'] = ( $gBitUser->hasPermission( 'p_articles_approve_submission' ) || $gBitUser->hasPermission( 'p_articles_auto_approve' ) ) ? ARTICLE_STATUS_APPROVED : ARTICLE_STATUS_PENDING;
}
// content preferences
$prefs = array();
- if ( $gBitUser->hasPermission( 'p_liberty_enter_html' ) ) {
+ if ($gBitUser->hasPermission( 'p_liberty_enter_html' )) {
$prefs[] = 'content_enter_html';
}
- foreach ($prefs as $pref) {
- if ( !empty( $pParamHash['preferences'][$pref] ) ) {
- $pParamHash['preferences_store'][$pref] = $pParamHash['preferences'][$pref];
- } else {
- $pParamHash['preferences_store'][$pref] = NULL;
- }
+ foreach ( $prefs as $pref ) {
+ $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 ) ) ) {
- $this->mInfo["no_index"] = true ;
+ if (array_search( $pParamHash['article_store']['status_id'], array( ARTICLE_STATUS_DENIED, ARTICLE_STATUS_DRAFT, ARTICLE_STATUS_PENDING ) )) {
+ $this->mInfo["no_index"] = true;
}
// if we have an error we get them all by checking parent classes for additional errors
- if ( count( $this->mErrors ) > 0 ) {
+ if (count( $this->mErrors ) > 0) {
parent::verify( $pParamHash );
}
@@ -366,7 +353,7 @@ class BitArticle extends LibertyMime
if ( empty( $data['parsed'] ) ) {
$data['no_cache'] = TRUE;
- $data['parsed'] = $this->parseData( $data );
+ $data['parsed'] = self::parseDataHash( $data );
// replace the split syntax with a horizontal rule
$data['parsed'] = preg_replace( LIBERTY_SPLIT_REGEX, "<hr />", $data['parsed'] );
}
@@ -381,7 +368,7 @@ class BitArticle extends LibertyMime
/**
* Get the URL for any given article image
* @param $pParamHash pass in full set of data returned from article query
- * @return url to image
+ * @return string url to image
* @access public
**/
public static function getImageThumbnails($pParamHash)
@@ -392,11 +379,10 @@ class BitArticle extends LibertyMime
$thumbHash['mime_image'] = FALSE;
if ( !empty( $pParamHash['image_attachment_path'] )) {
$thumbHash['source_file'] = $pParamHash['image_attachment_path'];
- $ret = liberty_fetch_thumbnails( $thumbHash );
+ $ret = \Bitweaver\Liberty\liberty_fetch_thumbnails( $thumbHash );
} elseif ( !empty( $pParamHash['has_topic_image'] ) && $pParamHash['has_topic_image'] == 'y' ) {
-return BitArticleTopic::getTopicImageStorageUrl( $pParamHash['topic_id'] );
$thumbHash['source_file'] = preg_replace( "#^/+#", "", BitArticleTopic::getTopicImageStorageUrl( $pParamHash['topic_id'] ));
- $ret = liberty_fetch_thumbnails( $thumbHash );
+ $ret = \Bitweaver\Liberty\liberty_fetch_thumbnails( $thumbHash );
}
return $ret;
@@ -407,7 +393,7 @@ return BitArticleTopic::getTopicImageStorageUrl( $pParamHash['topic_id'] );
* @return bool TRUE on success, FALSE on failure
* @access public
**/
- public function expunge()
+ public function expunge(): bool
{
$ret = FALSE;
if ( $this->isValid() ) {
@@ -588,11 +574,11 @@ return BitArticleTopic::getTopicImageStorageUrl( $pParamHash['topic_id'] );
/**
* Returns include file that will setup vars for display
- * @return the fully specified path to file to be included
+ * @return string the fully specified path to file to be included
*/
public function getRenderFile()
{
- return ARTICLES_PKG_INCLUDE_PATH.'display_article_inc.php';
+ return ARTICLES_PKG_PATH."display_article_inc.php";
}
/**
@@ -623,13 +609,13 @@ return BitArticleTopic::getTopicImageStorageUrl( $pParamHash['topic_id'] );
/**
* Generates the URL to the article
- * @return the link to the full article
+ * @return string the link to the full article
*/
public static function getDisplayUrlFromHash(&$pParamHash)
{
global $gBitSystem;
- $ret = NULL;
+ $ret = '';
if ( @BitBase::verifyId( $pParamHash['article_id'] ) ) {
if ( $gBitSystem->isFeatureActive( 'pretty_urls_extended' ) ) {
@@ -647,7 +633,7 @@ return BitArticleTopic::getTopicImageStorageUrl( $pParamHash['topic_id'] );
/**
* Function that returns link to display an image
- * @return the url to display the gallery.
+ * @return string the url to display the gallery.
*/
public function getDisplayUrl()
{
@@ -657,10 +643,10 @@ return BitArticleTopic::getTopicImageStorageUrl( $pParamHash['topic_id'] );
/**
* get a list of all available statuses
- * @return an array of available statuses
+ * @return array of available statuses
* @access public
**/
- public function getStatusList()
+ public static function getStatusList()
{
global $gBitSystem;
$query = "SELECT * FROM `".BIT_DB_PREFIX."article_status`";
@@ -672,13 +658,13 @@ return BitArticleTopic::getTopicImageStorageUrl( $pParamHash['topic_id'] );
* set the status of an article
* @param $pStatusId new status id of the article
* @param $pArticleId of the article that is being changed - if not set, it will attemtp to change the currently loaded article
- * @return new status of article on success - else returns NULL
+ * @return int new status of article on success - else returns NULL
* @access public
**/
public function setStatus($pStatusId, $pArticleId = NULL, $pContentId = NULL)
{
global $gBitSystem;
- $validStatuses = array( ARTICLE_STATUS_DENIED, ARTICLE_STATUS_DRAFT, ARTICLE_STATUS_PENDING, ARTICLE_STATUS_APPROVED, ARTICLE_STATUS_RETIRED );
+ $validStatuses = [ ARTICLE_STATUS_DENIED, ARTICLE_STATUS_DRAFT, ARTICLE_STATUS_PENDING, ARTICLE_STATUS_APPROVED, ARTICLE_STATUS_RETIRED ];
if ( !in_array( $pStatusId, $validStatuses ) ) {
$this->mErrors[] = "Invalid article status";
@@ -701,12 +687,13 @@ return BitArticleTopic::getTopicImageStorageUrl( $pParamHash['topic_id'] );
if ( $gBitSystem->isPackageActive( 'search' ) ) {
include_once( SEARCH_PKG_PATH.'refresh_functions.php' );
if ($pStatusId == ARTICLE_STATUS_APPROVED) {
- refresh_index($this);
+ \Bitweaver\Liberty\refresh_index($this);
} elseif (!$pStatusId == ARTICLE_STATUS_RETIRED) {
- delete_index($pContentId); // delete it from the search index unless retired ...
+ \Bitweaver\Liberty\delete_index($pContentId); // delete it from the search index unless retired ...
}
}
return $pStatusId;
}
+ return false;
}
}
diff --git a/includes/classes/BitArticleTopic.php b/includes/classes/BitArticleTopic.php
index 1422508..c651dee 100644..100755
--- a/includes/classes/BitArticleTopic.php
+++ b/includes/classes/BitArticleTopic.php
@@ -11,35 +11,40 @@
/**
* Required setup
*/
-global $gBitSystem;
-require_once( KERNEL_PKG_CLASS_PATH.'BitBase.php' );
-require_once( ARTICLES_PKG_CLASS_PATH.'BitArticle.php' );
+namespace Bitweaver\Articles;
+use Bitweaver\BitBase;
+use Bitweaver\KernelTools;
/**
* @package articles
*/
-class BitArticleTopic extends BitBase {
- var $mTopicId;
+class BitArticleTopic extends BitBase
+{
+ public $mTopicId;
+ public $mArticleId;
- function __construct($iTopicId = NULL, $iTopicName = NULL) {
+ public function __construct($iTopicId = NULL, $iTopicName = NULL)
+ {
$this->mTopicId = NULL;
parent::__construct();
if ($iTopicId || $iTopicName) {
- $this->loadTopic(array('topic_id'=>$iTopicId, 'topic_name'=>$iTopicName));
+ $this->loadTopic( [ 'topic_id' => $iTopicId, 'topic_name' => $iTopicName ]);
}
}
- function isValid() {
+ public function isValid()
+ {
return ($this->verifyId($this->mTopicId));
}
- function loadTopic($iParamHash = NULL) {
+ public function loadTopic($iParamHash = NULL)
+ {
$whereSQL = ' WHERE artt.';
$ret = NULL;
if (@$this->verifyId($iParamHash['topic_id']) || !empty($iParamHash['topic_name'])) {
$whereSQL .= "`".((@$this->verifyId($iParamHash['topic_id']) || $this->mTopicId) ? 'topic_id' : 'topic_name')."` = ?";
- $bindVars = array((@$this->verifyId($iParamHash['topic_id']) ? (int)$iParamHash['topic_id'] : ($this->mTopicId ? $this->mTopicId : $iParamHash['topic_name'])) );
+ $bindVars = [ ( @$this->verifyId( $iParamHash['topic_id'] ) ? (int) $iParamHash['topic_id'] : ( $this->mTopicId ?: $iParamHash['topic_name'] ) ) ];
$sql = "SELECT artt.*".
"FROM `".BIT_DB_PREFIX."article_topics` artt ".
@@ -49,49 +54,35 @@ class BitArticleTopic extends BitBase {
if( !empty( $this->mInfo['topic_id'] ) ) {
$this->mTopicId = $this->mInfo['topic_id'];
- if ($this->mInfo['has_topic_image']) {
- $this->mInfo['topic_image_url'] = static::getTopicImageStorageUrl($this->mTopicId, FALSE, TRUE);
- } else {
- $this->mInfo['topic_image_url'] = NULL;
- }
+ $this->mInfo['topic_image_url'] = ( $this->mInfo['has_topic_image'] ) ? $this->getTopicImageStorageUrl( null, false, true ) : null;
}
}
return $ret;
}
- function verify(&$iParamHash) {
+ public function verify(&$iParamHash)
+ {
// Validate the (optional) topic_id parameter
- if (@$this->verifyId($iParamHash['topic_id'])) {
- $cleanHash['topic_id'] = (int)$iParamHash['topic_id'];
- } else {
- $cleanHash['topic_id'] = NULL;
- }
+ $cleanHash['topic_id'] = ( @$this->verifyId( $iParamHash['topic_id'] ) ) ? (int) $iParamHash['topic_id'] : null;
// Was an acceptable name given?
if (empty($iParamHash['topic_name']) || ($iParamHash['topic_name'] == '')) {
- $this->mErrors['topic_name'] = tra("Invalid or blank topic name supplied");
- } else if (empty($iParamHash['topic_id'])) {
- $ret = $this->getTopicList( array( 'topic_name' => $iParamHash['topic_name'] ) );
+ $this->mErrors['topic_name'] = KernelTools::tra("Invalid or blank topic name supplied");
+ } elseif (empty($iParamHash['topic_id'])) {
+ $ret = $this->getTopicList( [ 'topic_name' => $iParamHash['topic_name'] ] );
if ( sizeof( $ret ) ) {
$this->mErrors['topic_name'] = 'Topic "'.$iParamHash['topic_name'].'" already exists. Please choose a different name.';
} else {
$cleanHash['topic_name'] = $iParamHash['topic_name'];
}
- }
- else {
+ } else {
$cleanHash['topic_name'] = $iParamHash['topic_name'];
}
-
// Whether the topic is active or not
if ( empty($iParamHash['active_topic']) || (strtoupper($iParamHash['active_topic']) != 'CHECKED' && strtoupper($iParamHash['active_topic']) != 'ON' && strtoupper($iParamHash['active_topic']) != 'Y')) {
- if (@$this->verifyId($cleanHash['topic_id'])) {
- $cleanHash['active_topic'] = 'n';
- } else {
- // Probably a new topic so lets go ahead and enable it
- $cleanHash['active_topic'] = 'y';
- }
+ $cleanHash['active_topic'] = ( @$this->verifyId( $cleanHash['topic_id'] ) ) ? 'n' : 'y';
} else {
$cleanHash['active_topic'] = 'y';
}
@@ -106,28 +97,25 @@ class BitArticleTopic extends BitBase {
return(count($this->mErrors) == 0);
}
- function storeTopic($iParamHash = NULL) {
+ public function storeTopic($iParamHash = NULL)
+ {
global $gLibertySystem;
global $gBitUser;
if ($this->verify($iParamHash)) {
- if (!$iParamHash['topic_id']) {
- $topicId = $this->mDb->GenID('article_topics_id_seq');
- } else {
- $topicId = $this->mTopicId;
- }
+ $topicId = ( !$iParamHash['topic_id'] ) ? $this->mDb->GenID( 'article_topics_id_seq' ) : $this->mTopicId;
if( !empty( $_FILES['upload'] ) && $_FILES['upload']['tmp_name'] ) {
- $checkFunc = liberty_get_function( 'can_thumbnail' );
+ $checkFunc = \Bitweaver\Liberty\liberty_get_function( 'can_thumbnail' );
if( $checkFunc( $_FILES['upload']['type'] )) {
$fileHash = $_FILES['upload'];
$fileHash['dest_branch'] = $this->getTopicImageBaseUrl( $topicId );
$fileHash['source_file'] = $fileHash['tmp_name'];
- liberty_clear_thumbnails( $fileHash );
- liberty_generate_thumbnails( $fileHash );
+ \Bitweaver\Liberty\liberty_clear_thumbnails( $fileHash );
+ \Bitweaver\Liberty\liberty_generate_thumbnails( $fileHash );
$iParamHash['has_topic_image'] = 'y';
} else {
- $this->mErrors = tra( "The file you uploaded doesn't appear to be a valid image. The reported mime type is" ).": ".$_FILES['upload']['type'];
+ $this->mErrors = KernelTools::tra( "The file you uploaded doesn't appear to be a valid image. The reported mime type is" ).": ".$_FILES['upload']['type'];
}
}
@@ -145,17 +133,18 @@ class BitArticleTopic extends BitBase {
* Work out the path to the image for this article
* @param $pTopicId id of the article we need the image path for
* @param $pBasePathOnly bool TRUE / FALSE - specify whether you want full path or just base path
- * @return path on success, FALSE on failure
+ * @return string on success, FALSE on failure
* @access public
**/
- function getTopicImageBaseUrl( $pTopicId = NULL ) {
+ public function getTopicImageBaseUrl($pTopicId = NULL)
+ {
$ret = FALSE;
- if( !@BitBase::verifyId( $pTopicId ) && $this->isValid() ) {
+ if ( !@BitBase::verifyId( $pTopicId ) && $this->isValid() ) {
$pTopicId = $this->mTopicId;
}
if( @BitBase::verifyId( $pTopicId )) {
- $ret = LibertyMime::getStorageUrl( 'topics/'.$pTopicId );
+ $ret = \Bitweaver\Liberty\liberty_mime_get_storage_branch( 'topics/'.$pTopicId );
}
return $ret;
}
@@ -165,22 +154,32 @@ class BitArticleTopic extends BitBase {
*
* @param numeric $pTopicId Topic ID of topic in question
* @access public
- * @return Path to thumbnail, FALSE on failure
+ * @return string Path to thumbnail, FALSE on failure
*/
- public static function getTopicImageThumbUrl( $pTopicId ) {
+ public function getTopicImageThumbUrl($pTopicId = NULL)
+ {
+ global $gBitSystem;
$ret = FALSE;
- if( @BitBase::verifyId( $pTopicId )) {
- $ret = STORAGE_PKG_URL.ARTICLES_PKG_NAME.'/topic_'.$pTopicId.'.jpg';
+ if ( !@BitBase::verifyId( $pTopicId ) && $this->isValid() ) {
+ $pTopicId = $this->mTopicId;
+ }
+
+ if ( @BitBase::verifyId( $pTopicId )) {
+ $ret = \Bitweaver\Liberty\liberty_fetch_thumbnail_url( [
+ 'source_file' => BitArticleTopic::getTopicImageBaseUrl( $pTopicId ),
+ 'default_image' => $gBitSystem->getConfig( 'articles_image_size', 'small' ),
+ ]);
}
return $ret;
}
- public static function getTopicList( $pOptionHash=NULL ) {
+ public static function getTopicList($pOptionHash=NULL)
+ {
global $gBitSystem;
$where = '';
- $bindVars = array();
- if( !empty( $pOptionHash['active_topic'] ) ) {
+ $bindVars = [];
+ if ( !empty( $pOptionHash['active_topic'] ) ) {
$where = " WHERE artt.`active_topic` = 'y' ";
}
if ( !empty( $pOptionHash['topic_name'] ) ) {
@@ -194,12 +193,12 @@ class BitArticleTopic extends BitBase {
$result = $gBitSystem->mDb->query( $query, $bindVars );
- $ret = array();
+ $ret = [];
- while( $res = $result->fetchRow() ) {
- $res["num_articles"] = $gBitSystem->mDb->getOne( "SELECT COUNT(*) FROM `".BIT_DB_PREFIX."articles` WHERE `topic_id`= ?", array( $res["topic_id"] ) );
- if( empty( $res['topic_image_url'] ) && $res['has_topic_image'] == 'y' ) {
- $res['topic_image_url'] = static::getTopicImageStorageUrl( $res['topic_id'] );
+ 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;
@@ -208,9 +207,10 @@ class BitArticleTopic extends BitBase {
return $ret;
}
- function removeTopicImage() {
- if( $this->mTopicId ) {
- if( file_exists($this->getTopicImageStoragePath() ) ) {
+ public function removeTopicImage()
+ {
+ if ($this->mTopicId) {
+ if ( file_exists($this->getTopicImageStoragePath() ) ) {
@unlink( $this->getTopicImageStoragePath() );
}
$sql = "UPDATE `".BIT_DB_PREFIX."article_topics` SET `has_topic_image` = 'n' WHERE `topic_id` = ?";
@@ -219,29 +219,33 @@ class BitArticleTopic extends BitBase {
}
}
- function activateTopic() {
+ public function activateTopic()
+ {
$this->setActivation(TRUE);
}
- function deactivateTopic() {
+ public function deactivateTopic()
+ {
$this->setActivation(FALSE);
}
- function setActivation($iIsActive = FALSE) {
+ 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));
$this->mInfo['active_topic'] = ($iIsActive ? 'y' : 'n');
}
- function getTopicArticles() {
+ public function getTopicArticles()
+ {
if (!$this->mTopicId) {
- return NULL;
+ return [];
}
$sql = "SELECT `article_id` FROM `".BIT_DB_PREFIX."articles` WHERE `topic_id` = ?";
- $rs = $this->mDb->query($sql, array($this->mTopicId));
+ $rs = $this->mDb->query($sql, [ $this->mTopicId ]);
- $ret = array();
+ $ret = [];
while ($row = $rs->fetchRow()) {
$tmpArticle = new BitArticle($row['article_id']);
$tmpArticle->load();
@@ -249,7 +253,8 @@ class BitArticleTopic extends BitBase {
}
}
- function removeTopic($iRemoveArticles = FALSE) {
+ public function removeTopic($iRemoveArticles = FALSE)
+ {
if (!$this->mTopicId) {
return NULL;
}
@@ -263,11 +268,11 @@ class BitArticleTopic extends BitBase {
}
} else {
$sql = "UPDATE `".BIT_DB_PREFIX."articles` SET `topic_id` = ? WHERE `topic_id` = ?";
- $rs = $this->mDb->query($sql, array(NULL, $this->mTopicId));
+ $rs = $this->mDb->query($sql, [ null, $this->mTopicId ]);
}
$sql = "DELETE FROM `".BIT_DB_PREFIX."article_topics` WHERE `topic_id` = ?";
- $rs = $this->mDb->query($sql, array($this->mTopicId));
+ $rs = $this->mDb->query($sql, [ $this->mTopicId ]);
}
@@ -284,14 +289,15 @@ class BitArticleTopic extends BitBase {
*
* @param array $pTopicId article id
* @access public
- * @return TRUE on success, FALSE on failure
+ * @return string on success
*/
- function getTopicImageStorageName( $pTopicId = NULL ) {
- if( !@BitBase::verifyId( $pTopicId ) ) {
- if( $this->isValid() ) {
+ public function getTopicImageStorageName($pTopicId = NULL)
+ {
+ if ( !@BitBase::verifyId( $pTopicId ) ) {
+ if ( $this->isValid() ) {
$pTopicId = $this->mTopicId;
} else {
- return NULL;
+ return '';
}
}
@@ -303,28 +309,29 @@ class BitArticleTopic extends BitBase {
* Work out the path to the image for this article
* @param $pTopicId id of the article we need the image path for
* @param $pBasePathOnly bool TRUE / FALSE - specify whether you want full path or just base path
- * @return path on success, FALSE on failure
+ * @return string path on success, FALSE on failure
* @access public
**/
- function getTopicImageStoragePath( $pTopicId = NULL, $pBasePathOnly = FALSE ) {
- $path = static::getArticleImageStoragePath( NULL, TRUE );
+ public function getTopicImageStoragePath($pTopicId = NULL, $pBasePathOnly = FALSE)
+ {
+ $path = BitArticleTopic::getArticleImageStoragePath( NULL, TRUE );
- if( $pBasePathOnly ) {
+ if ($pBasePathOnly) {
return $path;
}
- if( !@BitBase::verifyId( $pTopicId ) ) {
+ if ( !@BitBase::verifyId( $pTopicId ) ) {
if( $this->isValid() ) {
$pTopicId = $this->mTopicId;
} else {
- return NULL;
+ return '';
}
}
- if( !empty( $pTopicId ) ) {
- return $path.static::getTopicImageStorageName( $pTopicId );
+ if ( !empty( $pTopicId ) ) {
+ return $path.BitArticleTopic::getTopicImageStorageName( $pTopicId );
} else {
- return FALSE;
+ return '';
}
}
@@ -332,22 +339,31 @@ class BitArticleTopic extends BitBase {
* Work out the URL to the image for this article
* @param $pTopicId id of the article we need the image path for
* @param $pBasePathOnly bool TRUE / FALSE - specify whether you want full path or just base path
- * @return URL on success, FALSE on failure
+ * @return string URL on success, FALSE on failure
* @access public
**/
- public static function getTopicImageStorageUrl( $pTopicId, $pBasePathOnly = FALSE, $pForceRefresh = FALSE ) {
+ public function getTopicImageStorageUrl($pTopicId = NULL, $pBasePathOnly = FALSE, $pForceRefresh = FALSE)
+ {
global $gBitSystem;
- $ret = FALSE;
+ $ret = false;
// first we check to see if this is a new type thumbnail. if that fails we'll use the old method
- if( !( $ret = static::getTopicImageThumbUrl( $pTopicId ))) {
- $url = static::getArticleImageStorageUrl( $this->mArticleId, NULL, TRUE );
- if( $pBasePathOnly ) {
+ if ( !( $ret = BitArticleTopic::getTopicImageThumbUrl( $pTopicId ))) {
+ $url = BitArticleTopic::getArticleImageStorageUrl( NULL, TRUE );
+ if ($pBasePathOnly) {
return $url;
}
- if( is_file( static::getTopicImageStoragePath( NULL, TRUE ).static::getTopicImageStorageName( $pTopicId ))) {
- $ret = $url.static::getTopicImageStorageName( $pTopicId ).( $pForceRefresh ? "?".$gBitSystem->getUTCTime() : '' );
+ if ( !@BitBase::verifyId( $pTopicId ) ) {
+ if ( $this->isValid() ) {
+ $pTopicId = $this->mTopicId;
+ } else {
+ return false;
+ }
+ }
+
+ if ( is_file( BitArticleTopic::getTopicImageStoragePath( NULL, TRUE ).BitArticleTopic::getTopicImageStorageName( $pTopicId ))) {
+ $ret = $url.BitArticleTopic::getTopicImageStorageName( $pTopicId ).( $pForceRefresh ? "?".$gBitSystem->getUTCTime() : '' );
}
}
@@ -373,30 +389,36 @@ class BitArticleTopic extends BitBase {
*
* @param array $pArticleId article id
* @access public
- * @return TRUE on success, FALSE on failure
+ * @return string on success, FALSE on failure
*/
- public function getArticleImageStorageName( $pArticleId ) {
- $ret = FALSE;
- if( BitBase::verifyId( $pArticleId ) ) {
- $ret = "article_$pArticleId.jpg";
+ public function getArticleImageStorageName($pArticleId = NULL)
+ {
+ if ( !@BitBase::verifyId( $pArticleId ) ) {
+ if ( $this->isValid() ) {
+ $pArticleId = $this->mArticleId;
+ } else {
+ return NULL;
+ }
}
- return $ret;
+
+ return "article_$pArticleId.jpg";
}
/**
* Work out the path to the image for this article
* @param $pArticleId id of the article we need the image path for
* @param $pBasePathOnly bool TRUE / FALSE - specify whether you want full path or just base path
- * @return path on success, FALSE on failure
+ * @return string path on success, FALSE on failure
* @access public
**/
- function getArticleImageStoragePath( $pArticleId = NULL, $pBasePathOnly = FALSE ) {
+ public function getArticleImageStoragePath($pArticleId = NULL, $pBasePathOnly = FALSE)
+ {
$path = STORAGE_PKG_PATH.ARTICLES_PKG_NAME.'/';
- if( !is_dir( $path ) ) {
- mkdir_p( $path );
+ if ( !is_dir( $path ) ) {
+ KernelTools::mkdir_p( $path );
}
- if( $pBasePathOnly ) {
+ if ($pBasePathOnly) {
return $path;
}
@@ -408,8 +430,8 @@ class BitArticleTopic extends BitBase {
}
}
- if( !empty( $pArticleId ) ) {
- return $path.static::getArticleImageStorageName( $pArticleId );
+ if ( !empty( $pArticleId ) ) {
+ return $path.BitArticleTopic::getArticleImageStorageName( $pArticleId );
} else {
return FALSE;
}
@@ -419,24 +441,29 @@ class BitArticleTopic extends BitBase {
* Work out the URL to the image for this article
* @param $pArticleId id of the article we need the image path for
* @param $pBasePathOnly bool TRUE / FALSE - specify whether you want full path or just base path
- * @return URL on success, FALSE on failure
+ * @return string URL on success, FALSE on failure
* @access public
**/
- public static function getArticleImageStorageUrl( $pArticleId = NULL, $pBasePathOnly = FALSE, $pForceRefresh = FALSE ) {
+ public function getArticleImageStorageUrl($pArticleId = NULL, $pBasePathOnly = FALSE, $pForceRefresh = FALSE)
+ {
global $gBitSystem;
-
- $ret = FALSE;
$url = STORAGE_PKG_URL.ARTICLES_PKG_NAME.'/';
- if( $pBasePathOnly ) {
+ if ($pBasePathOnly) {
return $url;
}
- if( BitBase::verifyId( $pArticleId ) ) {
- if( is_file( static::getArticleImageStoragePath( NULL, TRUE ).static::getArticleImageStorageName( $pArticleId ) ) ) {
- $ret = $url.static::getArticleImageStorageName( $pArticleId ).( $pForceRefresh ? "?".$gBitSystem->getUTCTime() : '' );
+ if( !@BitBase::verifyId( $pArticleId ) ) {
+ if( $this->isValid() ) {
+ $pArticleId = $this->mArticleId;
+ } else {
+ return NULL;
}
}
- return $ret;
+
+ if ( is_file( BitArticleTopic::getArticleImageStoragePath( NULL, TRUE ).BitArticleTopic::getArticleImageStorageName( $pArticleId ) ) ) {
+ return $url.BitArticleTopic::getArticleImageStorageName( $pArticleId ).( $pForceRefresh ? "?".$gBitSystem->getUTCTime() : '' );
+ } else {
+ return FALSE;
+ }
}
}
-
diff --git a/includes/classes/BitArticleType.php b/includes/classes/BitArticleType.php
index 42fa209..ac45427 100644..100755
--- a/includes/classes/BitArticleType.php
+++ b/includes/classes/BitArticleType.php
@@ -11,8 +11,9 @@
/**
* Required setup
*/
-require_once( KERNEL_PKG_CLASS_PATH.'BitBase.php' );
-require_once( ARTICLES_PKG_CLASS_PATH.'BitArticle.php' );
+namespace Bitweaver\Articles;
+use Bitweaver\BitBase;
+use Bitweaver\KernelTools;
/**
* @package articles
@@ -20,6 +21,7 @@ require_once( ARTICLES_PKG_CLASS_PATH.'BitArticle.php' );
class BitArticleType extends BitBase
{
public $mTypeId;
+ public $mTopicId;
public function __construct($iTypeId = NULL)
{
@@ -46,8 +48,8 @@ class BitArticleType extends BitBase
if ($this->mTypeId) {
$sql = "SELECT * FROM `".BIT_DB_PREFIX."article_types` WHERE `article_type_id` = ?";
- if( $ret = $this->mDb->getRow( $sql, array( $this->mTypeId ) ) ) {
- $ret['num_articles'] = $this->mDb->getOne('SELECT COUNT(*) FROM `'.BIT_DB_PREFIX.'articles` WHERE `article_type_id` = ?', array($ret['article_type_id']));
+ if( $ret = $this->mDb->getRow( $sql, [ $this->mTypeId ] ) ) {
+ $ret['num_articles'] = $this->mDb->getOne('SELECT COUNT(*) FROM `'.BIT_DB_PREFIX.'articles` WHERE `article_type_id` = ?', [ $ret['article_type_id'] ] );
}
}
$this->mInfo = $ret;
@@ -86,7 +88,7 @@ class BitArticleType extends BitBase
} else {
// Was an acceptable name given?
if (empty($iParamHash['type_name']) || ($iParamHash['type_name'] == '')) {
- $this->mErrors['type_name'] = tra("Invalid or blank article type name supplied");
+ $this->mErrors['type_name'] = KernelTools::tra("Invalid or blank article type name supplied");
} else {
$cleanHash['type_name'] = $iParamHash['type_name'];
}
@@ -102,18 +104,10 @@ class BitArticleType extends BitBase
global $gBitUser;
if ($this->verify($iParamHash)) {
- if (!$iParamHash['article_type_id']) {
- if (empty($this->mTopicId)) {
- $typeId = $this->mDb->GenID('article_types_id_seq');
- } else {
- $typeId = $this->mTopicId;
- }
- } else {
- $typeId = $iParamHash['article_type_id'];
- }
+ $typeId = ( !$iParamHash['article_type_id'] ) ? ( empty( $this->mTopicId ) ) ? $this->mDb->GenID( 'article_types_id_seq' ) : $this->mTopicId : $iParamHash['article_type_id'];
if ($iParamHash['article_type_id']) {
- $this->mDb->associateUpdate(BIT_DB_PREFIX."article_types", $iParamHash, array( 'article_type_id'=> $iParamHash['article_type_id']));
+ $this->mDb->associateUpdate(BIT_DB_PREFIX."article_types", $iParamHash, [ 'article_type_id'=> $iParamHash['article_type_id'] ] );
} else {
$iParamHash['article_type_id'] = $typeId;
$this->mDb->associateInsert(BIT_DB_PREFIX."article_types", $iParamHash);
@@ -126,7 +120,7 @@ class BitArticleType extends BitBase
{
if (!$iTypeId) {
if (!$this->mTypeId) {
- $this->mErrors[] = tra("Invalid type id given");
+ $this->mErrors[] = KernelTools::tra("Invalid type id given");
return NULL;
} else {
$iTypeId = $this->mTypeId;
@@ -136,7 +130,7 @@ class BitArticleType extends BitBase
}
$sql = "DELETE FROM `".BIT_DB_PREFIX."article_types` WHERE `article_type_id` = ?";
- $rs = $this->mDb->query($sql, array($iTypeId));
+ $rs = $this->mDb->query($sql, [$iTypeId]);
}
public static function getTypeList()
@@ -144,11 +138,11 @@ class BitArticleType extends BitBase
global $gBitSystem;
$query = "SELECT * FROM `" . BIT_DB_PREFIX . "article_types`";
- $result = $gBitSystem->mDb->query( $query, array() );
- $ret = array();
+ $result = $gBitSystem->mDb->query( $query, [] );
+ $ret = [];
while ( $res = $result->fetchRow() ) {
- $res['article_cnt'] = $gBitSystem->mDb->getOne( "select count(*) from `" . BIT_DB_PREFIX . "articles` where `article_type_id` = ?", array( $res['article_type_id'] ) );
+ $res['article_cnt'] = $gBitSystem->mDb->getOne( "select count(*) from `" . BIT_DB_PREFIX . "articles` where `article_type_id` = ?", [ $res['article_type_id'] ] );
$ret[] = $res;
}
diff --git a/includes/display_article_inc.php b/includes/display_article_inc.php
index 3a884bf..7f73f59 100644..100755
--- a/includes/display_article_inc.php
+++ b/includes/display_article_inc.php
@@ -8,18 +8,19 @@
/**
* Initialization
*/
-$gBitSmarty->assignByRef( 'article', $gContent->mInfo );
+ use Bitweaver\Articles\BitArticleTopic;
+$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();
-$gBitSmarty->assignByRef( 'topics', $topics );
+$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;
@@ -28,4 +29,4 @@ if( @$gContent->mInfo['allow_comments'] == 'y' ) {
}
// Display the Index Template
-$gBitSystem->display( 'bitpackage:articles/read_article.tpl', @$gContent->mInfo['title'] , array( 'display_mode' => 'display' ));
+$gBitSystem->display( 'bitpackage:articles/read_article.tpl', @$gContent->mInfo['title'] , [ 'display_mode' => 'display' ]);
diff --git a/includes/lookup_article_inc.php b/includes/lookup_article_inc.php
index 75dfb92..cdd5902 100644..100755
--- a/includes/lookup_article_inc.php
+++ b/includes/lookup_article_inc.php
@@ -8,7 +8,8 @@
/**
* Initialization
*/
-require_once( ARTICLES_PKG_CLASS_PATH.'BitArticle.php');
+use Bitweaver\Articles\BitArticle;
+use Bitweaver\BitBase;
require_once( LIBERTY_PKG_INCLUDE_PATH.'lookup_content_inc.php' );
// if we already have a gContent, we assume someone else created it for us, and has properly loaded everything up.
diff --git a/includes/lookup_article_topic_inc.php b/includes/lookup_article_topic_inc.php
index 373164c..08b55fc 100644..100755
--- a/includes/lookup_article_topic_inc.php
+++ b/includes/lookup_article_topic_inc.php
@@ -9,20 +9,17 @@
* Initialization
*/
global $gContent;
- require_once( ARTICLES_PKG_CLASS_PATH.'BitArticle.php');
+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 ) ) {
- if (!empty($_REQUEST['topic_id']) && is_numeric($_REQUEST['topic_id'])) {
- $gContent = new BitArticleTopic( $_REQUEST['topic_id'] );
- } else {
- $gContent = new BitArticleTopic();
- }
+ $gContent = ( !empty( $_REQUEST['topic_id'] ) && is_numeric( $_REQUEST['topic_id'] ) ) ? new BitArticleTopic( $_REQUEST['topic_id'] ) : new BitArticleTopic();
if( empty( $gContent->mTopicId ) ) {
//handle legacy forms that use plain 'article' form variable name
} else {
$gContent->loadTopic();
}
- $gBitSmarty->assignByRef( 'gContent', $gContent );
+ $gBitSmarty->assign( 'gContent', $gContent );
}