-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper.php
44 lines (36 loc) · 1.05 KB
/
helper.php
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
<?php
/**
* @module JM News Ticker
* @copyright Copyright (C) 2016 John McCabe
* @license GPL
*/
defined ( '_JEXEC' ) or die ( 'Restricted access' );
abstract class mod_jmnewstickerHelper {
static function getList($params) {
$db = JFactory::getDbo ();
$query = $db->getQuery ( true );
$query->select ( '*' );
$query->from ( '#__content' );
$category = $params->get ( 'category', '' );
$category = intval ( $category );
if (isset ( $category ) && $category) {
$query->where ( 'catid = ' . $category . ' AND state = 1 AND ((now() >= publish_up OR publish_up = 0) AND (now() <= publish_down OR publish_down = 0))' );
}
$showItems = $params->get ( 'showItems', '' );
if ($showItems) {
$query->setLimit ( $showItems );
}
$query->order ( 'created DESC' );
$db->setQuery ( $query );
try {
$results = $db->loadObjectList ();
} catch ( RuntimeException $e ) {
JError::raiseError ( 500, $e->getMessage () );
return false;
}
foreach ( $items as &$item ) {
echo $item->title;
}
return $results;
}
}