summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BitArticle.php235
-rw-r--r--BitArticleTopic.php146
-rw-r--r--BitArticleType.php25
3 files changed, 221 insertions, 185 deletions
diff --git a/BitArticle.php b/BitArticle.php
index 55910fe..ebb2988 100644
--- a/BitArticle.php
+++ b/BitArticle.php
@@ -32,14 +32,14 @@ define( 'BITARTICLE_CONTENT_TYPE_GUID', 'bitarticle' );
/**
* @package articles
*/
-class BitArticle extends LibertyMime {
+class BitArticle extends LibertyMime
+{
/**
* Primary key for articles
- * @access public
*/
- var $mArticleId;
- var $mTypeId;
- var $mTopicId;
+ public $mArticleId;
+ public $mTypeId;
+ public $mTopicId;
/**
* Initiate the articles class
@@ -47,7 +47,8 @@ class BitArticle extends LibertyMime {
* @param $pContentId content id of the article we want to view
* @access private
**/
- function BitArticle( $pArticleId=NULL, $pContentId=NULL ) {
+ public function BitArticle($pArticleId=NULL, $pContentId=NULL)
+ {
parent::__construct();
$this->registerContentType(
BITARTICLE_CONTENT_TYPE_GUID, array(
@@ -77,8 +78,9 @@ class BitArticle extends LibertyMime {
* Load the data from the database
* @access public
**/
- function load( $pContentId = NULL, $pPluginParams = NULL ) {
- if( @$this->verifyId( $this->mArticleId ) || @$this->verifyId( $this->mContentId ) ) {
+ public function load($pContentId = NULL, $pPluginParams = NULL)
+ {
+ if ( @$this->verifyId( $this->mArticleId ) || @$this->verifyId( $this->mContentId ) ) {
// LibertyContent::load()assumes you have joined already, and will not execute any sql!
// This is a significant performance optimization
$lookupColumn = @$this->verifyId( $this->mArticleId ) ? 'article_id' : 'content_id';
@@ -103,7 +105,7 @@ class BitArticle extends LibertyMime {
$result = $this->mDb->query( $query, $bindVars );
global $gBitSystem;
- if( $result && $result->numRows() ) {
+ if ( $result && $result->numRows() ) {
$this->mInfo = $result->fetchRow();
// if a custom image for the article exists, use that, then use an attachment, then use the topic image
@@ -128,7 +130,7 @@ class BitArticle extends LibertyMime {
LibertyMime::load();
- if( !empty( $this->mInfo['primary_attachment_id'] ) && !empty( $this->mStorage[$this->mInfo['primary_attachment_id']] )) {
+ if ( !empty( $this->mInfo['primary_attachment_id'] ) && !empty( $this->mStorage[$this->mInfo['primary_attachment_id']] )) {
$this->mInfo['primary_attachment'] = &$this->mStorage[$this->mInfo['primary_attachment_id']];
}
@@ -147,17 +149,18 @@ 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
**/
- function store( &$pParamHash ) {
+ public function store(&$pParamHash)
+ {
global $gBitSystem;
$this->mDb->StartTrans();
- if( $this->verify( $pParamHash )&& LibertyMime::store( $pParamHash ) ) {
+ if ( $this->verify( $pParamHash )&& LibertyMime::store( $pParamHash ) ) {
$table = BIT_DB_PREFIX."articles";
- if( $this->isValid() ) {
+ if ( $this->isValid() ) {
$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 ( 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 {
@@ -180,56 +183,57 @@ class BitArticle extends LibertyMime {
* @return bool TRUE on success, FALSE if verify failed. If FALSE, $this->mErrors will have reason why
* @access private
**/
- function verify( &$pParamHash ) {
+ public function verify(&$pParamHash)
+ {
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 {
$pParamHash['content_store']['title'] = substr( $pParamHash['title'], 0, BIT_CONTENT_MAX_TITLE_LEN );
@@ -237,12 +241,12 @@ class BitArticle extends LibertyMime {
} else {
$pParamHash['content_store']['title'] =( isset( $pParamHash['title'] ))? substr( $pParamHash['title'], 0, BIT_CONTENT_MAX_TITLE_LEN ): '';
}
- } else if( empty( $pParamHash['title'] ) ) {
+ } 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'],
@@ -253,15 +257,15 @@ class BitArticle extends LibertyMime {
);
$timestamp = $this->mDate->getUTCFromDisplayDate( $dateString );
- if( $timestamp !== -1 ) {
+ if ($timestamp !== -1) {
$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'],
@@ -272,28 +276,28 @@ class BitArticle extends LibertyMime {
);
$timestamp = $this->mDate->getUTCFromDisplayDate( $dateString );
- if( $timestamp !== -1 ) {
+ if ($timestamp !== -1) {
$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'] );
+ 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'] );
+ $pParamHash['article_store']['status_id'] =(int) ( $pParamHash['status_id'] );
}
- } elseif( @$this->verifyId( $this->mInfo['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' ) ) {
+ 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
@@ -302,12 +306,12 @@ class BitArticle extends LibertyMime {
// 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] ) ) {
+ foreach ($prefs as $pref) {
+ if ( !empty( $pParamHash['preferences'][$pref] ) ) {
$pParamHash['preferences_store'][$pref] = $pParamHash['preferences'][$pref];
} else {
$pParamHash['preferences_store'][$pref] = NULL;
@@ -319,7 +323,7 @@ class BitArticle extends LibertyMime {
}
// 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 );
}
@@ -332,7 +336,8 @@ class BitArticle extends LibertyMime {
* @return array of data compatible with article form
* @access public
**/
- function preparePreview( $pParamHash ) {
+ public function preparePreview($pParamHash)
+ {
global $gBitSystem, $gBitUser;
$data = $pParamHash;
@@ -340,27 +345,27 @@ class BitArticle extends LibertyMime {
$data = array_merge( $pParamHash, $data['content_store'], $data['article_store'] );
$data['raw'] = $data['edit'];
- if( empty( $data['user_id'] ) ) {
+ if ( empty( $data['user_id'] ) ) {
$data['user_id'] = $gBitUser->mUserId;
}
- if( empty( $data['hits'] ) ) {
+ if ( empty( $data['hits'] ) ) {
$data['hits'] = 0;
}
- if( empty( $data['publish_date'] ) ) {
+ if ( empty( $data['publish_date'] ) ) {
$data['publish_date'] = $gBitSystem->getUTCTime();
}
- if( empty( $data['article_type_id'] ) ) {
+ if ( empty( $data['article_type_id'] ) ) {
$data['article_type_id'] = 1;
}
- if( empty( $data['topic_id'] ) ) {
+ if ( empty( $data['topic_id'] ) ) {
$data['topic_id'] = 1;
}
- if( empty( $data['parsed'] ) ) {
+ if ( empty( $data['parsed'] ) ) {
$data['no_cache'] = TRUE;
$data['parsed'] = $this->parseData( $data );
// replace the split syntax with a horizontal rule
@@ -380,21 +385,18 @@ class BitArticle extends LibertyMime {
* @return url to image
* @access public
**/
- function getImageThumbnails( $pParamHash ) {
+ public function getImageThumbnails($pParamHash)
+ {
global $gBitSystem, $gThumbSizes;
$ret = NULL;
$thumbHash['mime_image'] = FALSE;
- if( !empty( $pParamHash['image_attachment_path'] )) {
+ if ( !empty( $pParamHash['image_attachment_path'] )) {
$thumbHash['source_file'] = $pParamHash['image_attachment_path'];
$ret = liberty_fetch_thumbnails( $thumbHash );
- } elseif( !empty( $pParamHash['has_topic_image'] ) && $pParamHash['has_topic_image'] == 'y' ) {
- if( $topicImage = BitArticleTopic::getTopicImageStorageUrl( $pParamHash['topic_id'] ) ) {
- global $gThumbSizes;
- foreach( array_keys( $gThumbSizes ) as $size ) {
- $ret[$size] = $topicImage;
- }
- }
+ } elseif ( !empty( $pParamHash['has_topic_image'] ) && $pParamHash['has_topic_image'] == 'y' ) {
+ $thumbHash['source_file'] = preg_replace( "#^/+#", "", BitArticleTopic::getTopicImageStorageUrl( $pParamHash['topic_id'] ));
+ $ret = liberty_fetch_thumbnails( $thumbHash );
}
return $ret;
@@ -405,13 +407,14 @@ class BitArticle extends LibertyMime {
* @return bool TRUE on success, FALSE on failure
* @access public
**/
- function expunge() {
+ public function expunge()
+ {
$ret = FALSE;
- if( $this->isValid() ) {
+ if ( $this->isValid() ) {
$this->mDb->StartTrans();
$query = "DELETE FROM `".BIT_DB_PREFIX."articles` WHERE `content_id` = ?";
$result = $this->mDb->query( $query, array( $this->mContentId ) );
- if( LibertyMime::expunge() ) {
+ if ( LibertyMime::expunge() ) {
$ret = TRUE;
$this->mDb->CompleteTrans();
} else {
@@ -426,7 +429,8 @@ class BitArticle extends LibertyMime {
* @return bool TRUE on success, FALSE on failure
* @access public
**/
- function isValid() {
+ public function isValid()
+ {
return( $this->verifyId( $this->mArticleId ) && $this->verifyId( $this->mContentId ) );
}
@@ -436,10 +440,11 @@ class BitArticle extends LibertyMime {
* @return array of articles
* @access public
**/
- function getList( &$pParamHash ) {
+ public function getList(&$pParamHash)
+ {
global $gBitSystem, $gBitUser, $gLibertySystem;
- if( empty( $pParamHash['sort_mode'] ) ) {
+ if ( empty( $pParamHash['sort_mode'] ) ) {
// no idea what this is supposed to do
//$pParamHash['sort_mode'] = $gBitSystem->isFeatureActive('articles_auto_approve') ? 'order_key_desc' : 'publish_date_desc';
$pParamHash['sort_mode'] = 'publish_date_desc';
@@ -454,75 +459,75 @@ class BitArticle extends LibertyMime {
$this->getServicesSql( 'content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars, NULL, $pParamHash );
$find = $pParamHash['find'];
- if( is_array( $find ) ) {
+ if ( is_array( $find ) ) {
// you can use an array of articles
$whereSql .= " AND lc.`title` IN( ".implode( ',',array_fill( 0, count( $find ),'?' ) )." )";
$bindVars = array_merge( $bindVars, $find );
- } elseif( is_string( $find ) ) {
+ } elseif ( is_string( $find ) ) {
// or a string
$whereSql .= " AND UPPER( lc.`title` ) LIKE ? ";
$bindVars[] = '%'.strtoupper( $find ).'%';
- } elseif( @$this->verifyId( $pParamHash['user_id'] ) ) {
+ } elseif ( @$this->verifyId( $pParamHash['user_id'] ) ) {
// or gate on a user
$whereSql .= " AND lc.`user_id` = ? ";
- $bindVars[] = (int)$pParamHash['user_id'];
+ $bindVars[] = (int) $pParamHash['user_id'];
}
- if( @$this->verifyId( $pParamHash['status_id'] ) ) {
+ if ( @$this->verifyId( $pParamHash['status_id'] ) ) {
$whereSql .= " AND a.`status_id` = ? ";
$bindVars[] = $pParamHash['status_id'];
}
- if( @$this->verifyId( $pParamHash['type_id'] ) ) {
+ if ( @$this->verifyId( $pParamHash['type_id'] ) ) {
$whereSql .= " AND a.`article_type_id` = ? ";
- $bindVars[] = ( int )$pParamHash['type_id'];
+ $bindVars[] = (int) $pParamHash['type_id'];
}
// TODO: we need to check if the article wants to be viewed before / after respective dates
// someone better at SQL please get this working without an additional db call - xing
$now = $gBitSystem->getUTCTime();
- if( !empty( $pParamHash['show_future'] ) && !empty( $pParamHash['show_expired'] ) && $gBitUser->hasPermission( 'p_articles_admin' )) {
+ if ( !empty( $pParamHash['show_future'] ) && !empty( $pParamHash['show_expired'] ) && $gBitUser->hasPermission( 'p_articles_admin' )) {
// this will show all articles at once - future, current and expired
- } elseif( !empty( $pParamHash['show_future'] ) && $gBitUser->hasPermission( 'p_articles_admin' )) {
+ } elseif ( !empty( $pParamHash['show_future'] ) && $gBitUser->hasPermission( 'p_articles_admin' )) {
// hide expired articles
$whereSql .= " AND ( a.`expire_date` > ? OR atype.`show_post_expire` = ? ) ";
- $bindVars[] = ( int )$now;
+ $bindVars[] = (int) $now;
$bindVars[] = 'y';
- } elseif( !empty( $pParamHash['show_expired'] ) && $gBitUser->hasPermission( 'p_articles_admin' )) {
+ } elseif ( !empty( $pParamHash['show_expired'] ) && $gBitUser->hasPermission( 'p_articles_admin' )) {
// hide future articles
$whereSql .= " AND ( a.`publish_date` < ? OR atype.`show_pre_publ` = ? ) ";
- $bindVars[] = ( int )$now;
+ $bindVars[] = (int) $now;
$bindVars[] = 'y';
- } elseif( !empty( $pParamHash['get_future'] )) {
+ } elseif ( !empty( $pParamHash['get_future'] )) {
// 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' )) {
+ if ( !$gBitUser->hasPermission( 'p_articles_admin' )) {
return array();
}
$whereSql .= " AND a.`publish_date` > ?";
- $bindVars[] = ( int )$now;
- } elseif( !empty( $pParamHash['get_expired'] )) {
+ $bindVars[] = (int) $now;
+ } elseif ( !empty( $pParamHash['get_expired'] )) {
// 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' )) {
+ if ( !$gBitUser->hasPermission( 'p_articles_admin' )) {
return array();
}
$whereSql .= " AND a.`expire_date` < ? ";
- $bindVars[] = ( int )$now;
+ $bindVars[] = (int) $now;
} else {
// hide future and expired articles - this is the default behaviour
// we need all these AND and ORs to ensure that other conditions such as status_id are respected as well
$whereSql .= " AND (( a.`publish_date` > a.`expire_date` ) OR (( a.`publish_date` < ? OR atype.`show_pre_publ` = ? ) AND ( a.`expire_date` > ? OR atype.`show_post_expire` = ? ))) ";
- $bindVars[] = ( int )$now;
+ $bindVars[] = (int) $now;
$bindVars[] = 'y';
- $bindVars[] = ( int )$now;
+ $bindVars[] = (int) $now;
$bindVars[] = 'y';
}
- if( @$this->verifyId( $pParamHash['topic_id'] ) ) {
+ if ( @$this->verifyId( $pParamHash['topic_id'] ) ) {
$whereSql .= " AND a.`topic_id` = ? ";
- $bindVars[] = ( int )$pParamHash['topic_id'];
- } elseif( !empty( $pParamHash['topic'] ) ) {
+ $bindVars[] = (int) $pParamHash['topic_id'];
+ } elseif ( !empty( $pParamHash['topic'] ) ) {
$whereSql .= " AND UPPER( atopic.`topic_name` ) = ? ";
$bindVars[] = strtoupper( $pParamHash['topic'] );
} else {
@@ -536,11 +541,10 @@ class BitArticle extends LibertyMime {
a.`article_id`, a.`description`, a.`author_name`, a.`publish_date`, a.`expire_date`, a.`rating`,
atopic.`topic_id`, atopic.`topic_name`, atopic.`has_topic_image`, atopic.`active_topic`,
astatus.`status_id`, astatus.`status_name`,
- lch.`hits`, uu.`login`,
+ lch.`hits`,
atype.*, lc.*, la.`attachment_id` AS `primary_attachment_id`, lf.`file_name` AS `image_attachment_path` $selectSql
FROM `".BIT_DB_PREFIX."articles` a
INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON( lc.`content_id` = a.`content_id` )
- INNER JOIN `".BIT_DB_PREFIX."users_users` uu ON( uu.`user_id` = lc.`user_id` )
INNER JOIN `".BIT_DB_PREFIX."article_status` astatus ON( astatus.`status_id` = a.`status_id` )
LEFT OUTER JOIN `".BIT_DB_PREFIX."liberty_content_hits` lch ON( lc.`content_id` = lch.`content_id` )
LEFT OUTER JOIN `".BIT_DB_PREFIX."article_topics` atopic ON( atopic.`topic_id` = a.`topic_id` )
@@ -560,7 +564,7 @@ class BitArticle extends LibertyMime {
$result = $this->mDb->query( $query, $bindVars, $pParamHash['max_records'], $pParamHash['offset'] );
$ret = array();
$comment = new LibertyComment();
- while( $res = $result->fetchRow() ) {
+ while ( $res = $result->fetchRow() ) {
// get this stuff parsed
$res = array_merge( $this->parseSplit( $res, $gBitSystem->getConfig( 'articles_description_length', 500 )), $res );
@@ -586,7 +590,8 @@ class BitArticle extends LibertyMime {
* Returns include file that will setup vars for display
* @return the fully specified path to file to be included
*/
- function getRenderFile() {
+ public function getRenderFile()
+ {
return ARTICLES_PKG_PATH."display_article_inc.php";
}
@@ -597,7 +602,8 @@ class BitArticle extends LibertyMime {
* @access public
* @return array of articles
*/
- function getFutureList( &$pParamHash ) {
+ public function getFutureList(&$pParamHash)
+ {
$pParamHash['get_future'] = TRUE;
return( $this->getList( $pParamHash ));
}
@@ -609,7 +615,8 @@ class BitArticle extends LibertyMime {
* @access public
* @return array of articles
*/
- function getExpiredList( &$pParamHash ) {
+ public function getExpiredList(&$pParamHash)
+ {
$pParamHash['get_expired'] = TRUE;
return( $this->getList( $pParamHash ));
}
@@ -618,16 +625,17 @@ class BitArticle extends LibertyMime {
* Generates the URL to the article
* @return the link to the full article
*/
- public static function getDisplayUrlFromHash( &$pParamHash ) {
+ public static function getDisplayUrlFromHash(&$pParamHash)
+ {
global $gBitSystem;
$ret = NULL;
- if( @BitBase::verifyId( $pParamHash['article_id'] ) ) {
- if( $gBitSystem->isFeatureActive( 'pretty_urls_extended' ) ) {
+ if ( @BitBase::verifyId( $pParamHash['article_id'] ) ) {
+ if ( $gBitSystem->isFeatureActive( 'pretty_urls_extended' ) ) {
// Not needed since it's a number: $ret = ARTICLES_PKG_URL."view/".$this->mArticleId;
$ret = ARTICLES_PKG_URL.$pParamHash['article_id'];
- } else if( $gBitSystem->isFeatureActive( 'pretty_urls' ) ) {
+ } elseif ( $gBitSystem->isFeatureActive( 'pretty_urls' ) ) {
$ret = ARTICLES_PKG_URL.$pParamHash['article_id'];
} else {
$ret = ARTICLES_PKG_URL."read.php?article_id=".$pParamHash['article_id'];
@@ -641,7 +649,8 @@ class BitArticle extends LibertyMime {
* Function that returns link to display an image
* @return the url to display the gallery.
*/
- public function getDisplayUrl() {
+ public function getDisplayUrl()
+ {
$info = array( 'article_id' => $this->mArticleId );
return self::getDisplayUrlFromHash( $info );
}
@@ -651,7 +660,8 @@ class BitArticle extends LibertyMime {
* @return an array of available statuses
* @access public
**/
- function getStatusList() {
+ public function getStatusList()
+ {
global $gBitSystem;
$query = "SELECT * FROM `".BIT_DB_PREFIX."article_status`";
$result = $gBitSystem->mDb->query( $query );
@@ -665,11 +675,12 @@ class BitArticle extends LibertyMime {
* @return new status of article on success - else returns NULL
* @access public
**/
- function setStatus( $pStatusId, $pArticleId = NULL, $pContentId = NULL ) {
+ 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 );
- if( !in_array( $pStatusId, $validStatuses ) ) {
+ if ( !in_array( $pStatusId, $validStatuses ) ) {
$this->mErrors[] = "Invalid article status";
return FALSE;
}
@@ -679,15 +690,15 @@ class BitArticle extends LibertyMime {
if( !empty( $pContentId ) and !$this->isValid()) $this->mContentId = $pContentId ;
if( !empty( $pArticleId ) and !$this->isValid()) $this->mArticleId = $pArticleId ;
- if( empty( $pArticleId ) && $this->isValid() ) {
+ if ( empty( $pArticleId ) && $this->isValid() ) {
$pArticleId = $this->mArticleId;
}
- if( @$this->verifyId( $pArticleId ) ) {
+ if ( @$this->verifyId( $pArticleId ) ) {
$sql = "UPDATE `".BIT_DB_PREFIX."articles` SET `status_id` = ? WHERE `article_id` = ?";
$rs = $this->mDb->query( $sql, array( $pStatusId, $pArticleId ));
// Calling the index function for approved articles ...
- if( $gBitSystem->isPackageActive( 'search' ) ) {
+ if ( $gBitSystem->isPackageActive( 'search' ) ) {
include_once( SEARCH_PKG_PATH.'refresh_functions.php' );
if ($pStatusId == ARTICLE_STATUS_APPROVED) {
refresh_index($this);
@@ -699,5 +710,3 @@ class BitArticle extends LibertyMime {
}
}
}
-
-?>
diff --git a/BitArticleTopic.php b/BitArticleTopic.php
index 8fd2f4e..466b604 100644
--- a/BitArticleTopic.php
+++ b/BitArticleTopic.php
@@ -18,10 +18,12 @@ require_once( ARTICLES_PKG_PATH.'BitArticle.php' );
/**
* @package articles
*/
-class BitArticleTopic extends BitBase {
- var $mTopicId;
+class BitArticleTopic extends BitBase
+{
+ public $mTopicId;
- function __construct($iTopicId = NULL, $iTopicName = NULL) {
+ public function __construct($iTopicId = NULL, $iTopicName = NULL)
+ {
$this->mTopicId = NULL;
parent::__construct();
if ($iTopicId || $iTopicName) {
@@ -29,17 +31,19 @@ class BitArticleTopic extends BitBase {
}
}
- 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 = array((@$this->verifyId($iParamHash['topic_id']) ? (int) $iParamHash['topic_id'] : ($this->mTopicId ? $this->mTopicId : $iParamHash['topic_name'])) );
$sql = "SELECT artt.*".
"FROM `".BIT_DB_PREFIX."article_topics` artt ".
@@ -60,10 +64,11 @@ class BitArticleTopic extends BitBase {
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'];
+ $cleanHash['topic_id'] = (int) $iParamHash['topic_id'];
} else {
$cleanHash['topic_id'] = NULL;
}
@@ -71,19 +76,17 @@ class BitArticleTopic extends BitBase {
// 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'])) {
+ } elseif (empty($iParamHash['topic_id'])) {
$ret = $this->getTopicList( array( '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'])) {
@@ -106,7 +109,8 @@ class BitArticleTopic extends BitBase {
return(count($this->mErrors) == 0);
}
- function storeTopic($iParamHash = NULL) {
+ public function storeTopic($iParamHash = NULL)
+ {
global $gLibertySystem;
global $gBitUser;
@@ -148,9 +152,10 @@ class BitArticleTopic extends BitBase {
* @return path 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;
}
@@ -167,25 +172,30 @@ class BitArticleTopic extends BitBase {
* @access public
* @return Path to thumbnail, FALSE on failure
*/
- function getTopicImageThumbUrl( $pTopicId = NULL ) {
+ public function getTopicImageThumbUrl($pTopicId = NULL)
+ {
global $gBitSystem;
$ret = FALSE;
- if( !@BitBase::verifyId( $pTopicId ) && $this->isValid() ) {
+ if ( !@BitBase::verifyId( $pTopicId ) && $this->isValid() ) {
$pTopicId = $this->mTopicId;
}
- if( @BitBase::verifyId( $pTopicId )) {
- $ret = STORAGE_PKG_URL.ARTICLES_PKG_NAME.'/topic_'.$pTopicId.'.jpg';
+ if ( @BitBase::verifyId( $pTopicId )) {
+ $ret = liberty_fetch_thumbnail_url( array(
+ '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'] ) ) {
+ if ( !empty( $pOptionHash['active_topic'] ) ) {
$where = " WHERE artt.`active_topic` = 'y' ";
}
if ( !empty( $pOptionHash['topic_name'] ) ) {
@@ -201,10 +211,10 @@ class BitArticleTopic extends BitBase {
$ret = array();
- while( $res = $result->fetchRow() ) {
+ 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'] = self::getTopicImageStorageUrl( $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;
@@ -213,9 +223,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` = ?";
@@ -224,21 +235,25 @@ 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;
}
@@ -254,7 +269,8 @@ class BitArticleTopic extends BitBase {
}
}
- function removeTopic($iRemoveArticles = FALSE) {
+ public function removeTopic($iRemoveArticles = FALSE)
+ {
if (!$this->mTopicId) {
return NULL;
}
@@ -291,9 +307,10 @@ class BitArticleTopic extends BitBase {
* @access public
* @return TRUE on success, FALSE on failure
*/
- 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;
@@ -311,14 +328,15 @@ class BitArticleTopic extends BitBase {
* @return path on success, FALSE on failure
* @access public
**/
- function getTopicImageStoragePath( $pTopicId = NULL, $pBasePathOnly = FALSE ) {
- $path = self::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 {
@@ -326,8 +344,8 @@ class BitArticleTopic extends BitBase {
}
}
- if( !empty( $pTopicId ) ) {
- return $path.self::getTopicImageStorageName( $pTopicId );
+ if ( !empty( $pTopicId ) ) {
+ return $path.BitArticleTopic::getTopicImageStorageName( $pTopicId );
} else {
return FALSE;
}
@@ -340,27 +358,28 @@ class BitArticleTopic extends BitBase {
* @return URL on success, FALSE on failure
* @access public
**/
- function getTopicImageStorageUrl( $pTopicId = NULL, $pBasePathOnly = FALSE, $pForceRefresh = FALSE ) {
+ public function getTopicImageStorageUrl($pTopicId = NULL, $pBasePathOnly = FALSE, $pForceRefresh = FALSE)
+ {
global $gBitSystem;
$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 = self::getTopicImageThumbUrl( $pTopicId ))) {
- $url = self::getArticleImageStorageUrl( NULL, TRUE );
- if( $pBasePathOnly ) {
+ if ( !( $ret = BitArticleTopic::getTopicImageThumbUrl( $pTopicId ))) {
+ $url = BitArticleTopic::getArticleImageStorageUrl( NULL, TRUE );
+ if ($pBasePathOnly) {
return $url;
}
- if( !@BitBase::verifyId( $pTopicId ) ) {
- if( $this->isValid() ) {
+ if ( !@BitBase::verifyId( $pTopicId ) ) {
+ if ( $this->isValid() ) {
$pTopicId = $this->mTopicId;
} else {
return NULL;
}
}
- if( is_file( self::getTopicImageStoragePath( NULL, TRUE ).self::getTopicImageStorageName( $pTopicId ))) {
- $ret = $url.self::getTopicImageStorageName( $pTopicId ).( $pForceRefresh ? "?".$gBitSystem->getUTCTime() : '' );
+ if ( is_file( BitArticleTopic::getTopicImageStoragePath( NULL, TRUE ).BitArticleTopic::getTopicImageStorageName( $pTopicId ))) {
+ $ret = $url.BitArticleTopic::getTopicImageStorageName( $pTopicId ).( $pForceRefresh ? "?".$gBitSystem->getUTCTime() : '' );
}
}
@@ -388,9 +407,10 @@ class BitArticleTopic extends BitBase {
* @access public
* @return TRUE on success, FALSE on failure
*/
- function getArticleImageStorageName( $pArticleId = NULL ) {
- if( !@BitBase::verifyId( $pArticleId ) ) {
- if( $this->isValid() ) {
+ public function getArticleImageStorageName($pArticleId = NULL)
+ {
+ if ( !@BitBase::verifyId( $pArticleId ) ) {
+ if ( $this->isValid() ) {
$pArticleId = $this->mArticleId;
} else {
return NULL;
@@ -407,13 +427,14 @@ class BitArticleTopic extends BitBase {
* @return 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 ) ) {
+ if ( !is_dir( $path ) ) {
mkdir_p( $path );
}
- if( $pBasePathOnly ) {
+ if ($pBasePathOnly) {
return $path;
}
@@ -425,8 +446,8 @@ class BitArticleTopic extends BitBase {
}
}
- if( !empty( $pArticleId ) ) {
- return $path.self::getArticleImageStorageName( $pArticleId );
+ if ( !empty( $pArticleId ) ) {
+ return $path.BitArticleTopic::getArticleImageStorageName( $pArticleId );
} else {
return FALSE;
}
@@ -439,10 +460,11 @@ class BitArticleTopic extends BitBase {
* @return URL on success, FALSE on failure
* @access public
**/
- function getArticleImageStorageUrl( $pArticleId = NULL, $pBasePathOnly = FALSE, $pForceRefresh = FALSE ) {
+ public function getArticleImageStorageUrl($pArticleId = NULL, $pBasePathOnly = FALSE, $pForceRefresh = FALSE)
+ {
global $gBitSystem;
$url = STORAGE_PKG_URL.ARTICLES_PKG_NAME.'/';
- if( $pBasePathOnly ) {
+ if ($pBasePathOnly) {
return $url;
}
@@ -454,12 +476,10 @@ class BitArticleTopic extends BitBase {
}
}
- if( is_file( self::getArticleImageStoragePath( NULL, TRUE ).self::getArticleImageStorageName( $pArticleId ) ) ) {
- return $url.self::getArticleImageStorageName( $pArticleId ).( $pForceRefresh ? "?".$gBitSystem->getUTCTime() : '' );
+ if ( is_file( BitArticleTopic::getArticleImageStoragePath( NULL, TRUE ).BitArticleTopic::getArticleImageStorageName( $pArticleId ) ) ) {
+ return $url.BitArticleTopic::getArticleImageStorageName( $pArticleId ).( $pForceRefresh ? "?".$gBitSystem->getUTCTime() : '' );
} else {
return FALSE;
}
}
}
-
-?>
diff --git a/BitArticleType.php b/BitArticleType.php
index 935458f..025d405 100644
--- a/BitArticleType.php
+++ b/BitArticleType.php
@@ -19,9 +19,10 @@ require_once(ARTICLES_PKG_PATH.'BitArticle.php');
*/
class BitArticleType extends BitBase
{
- var $mTypeId;
+ public $mTypeId;
- function __construct($iTypeId = NULL) {
+ public function __construct($iTypeId = NULL)
+ {
$this->mTypeId = NULL;
parent::__construct();
if ($iTypeId) {
@@ -29,11 +30,13 @@ class BitArticleType extends BitBase
}
}
- function isValid() {
+ public function isValid()
+ {
return (@BitBase::verifyId($this->mTypeId));
}
- function loadType($iTypeId) {
+ public function loadType($iTypeId)
+ {
$ret = NULL;
if (!$this->mTypeId) {
@@ -52,12 +55,13 @@ class BitArticleType extends BitBase
return $ret;
}
- function verify(&$iParamHash) {
+ public function verify(&$iParamHash)
+ {
$isNewType = FALSE;
// Validate the (optional) topic_id parameter
if (@BitBase::verifyId($iParamHash['article_type_id'])) {
- $cleanHash['article_type_id'] = (int)$iParamHash['article_type_id'];
+ $cleanHash['article_type_id'] = (int) $iParamHash['article_type_id'];
} else {
$isNewType = TRUE;
$cleanHash['article_type_id'] = NULL;
@@ -92,7 +96,8 @@ class BitArticleType extends BitBase
return(count($this->mErrors) == 0);
}
- function storeType(&$iParamHash) {
+ public function storeType(&$iParamHash)
+ {
global $gLibertySystem;
global $gBitUser;
@@ -117,7 +122,8 @@ class BitArticleType extends BitBase
$this->mTypeId = $iParamHash['article_type_id'];
}
- function removeType($iTypeId = NULL) {
+ public function removeType($iTypeId = NULL)
+ {
if (!$iTypeId) {
if (!$this->mTypeId) {
$this->mErrors[] = tra("Invalid type id given");
@@ -133,7 +139,8 @@ class BitArticleType extends BitBase
$rs = $this->mDb->query($sql, array($iTypeId));
}
- public static function getTypeList() {
+ public static function getTypeList()
+ {
global $gBitSystem;
$query = "SELECT * FROM `" . BIT_DB_PREFIX . "article_types`";