summaryrefslogtreecommitdiff
path: root/modules/mod_articles.php
blob: 4b43baa80bf3858ce10d9d7181ccefb361a7a9b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/**
 * @version $Header$
 * @package articles
 * @subpackage modules
 */

/**
 * Initialization
 */
use Bitweaver\Articles\BitArticle;


extract( $moduleParams );

$articles = new BitArticle();
$stati = array( '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 = [
	"last_modified_asc",
	"last_modified_desc",
	"created_asc",
	"created_desc",
	"publish_date_desc",
	"publish_date_asc",
	"expire_date_desc",
	"expire_date_asc",
];
$sort_mode = ( !empty( $module_params['sort_mode'] ) && in_array( $module_params['sort_mode'], $sortOptions ) ) ? $module_params['sort_mode'] : 'last_modified_desc';

$getHash['status_id']     = $status_id;
$getHash['sort_mode']     = $sort_mode;
$getHash['max_records']   = !empty( $module_rows ) ? $module_rows : $gBitSystem->getConfig( 'articles_max_list' );
$getHash['topic_name']    = !empty( $module_params['topic_name'] ) ? $module_params['topic_name'] : NULL;
$getHash['topic_id']      = !empty( $module_params['topic_id'] ) ? $module_params['topic_id'] : NULL;
$articlelist = $articles->getList( $getHash );

if( ( !empty( $module_params['topic_id'] ) || !empty( $module_params['topic_name'] ) ) && empty($moduleParams['title']) && !empty( $articles ) ) {
	$gBitSmarty->assign( 'moduleTitle', $articlelist[0]['topic_name'] );
} elseif( !empty($moduleParams['title']) ) {
	$gBitSmarty->assign( 'moduleTitle', $moduleParams['title'] );
} else {
	$gBitSmarty->assign( 'moduleTitle', "Articles" );
}

$gBitSmarty->assign( 'params', !empty( $moduleParams['params'] ) );
$gBitSmarty->assign( 'listtype',  ( isset($module_params['list_type']) && (strncasecmp($module_params['list_type'], 'u', 1) == 0) ) ? 'ul' : 'ol' );
$gBitSmarty->assign( 'modArticles', $articlelist );