Repository navigation
Expand file tree
/
Copy pathlatest.php
More file actions
122 lines (109 loc) · 2.93 KB
/
Copy pathlatest.php
File metadata and controls
122 lines (109 loc) · 2.93 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
/**
* @package Joomla.Site
* @subpackage Com_api-plugins
*
* @copyright Copyright (C) 2009-2014 Techjoomla, Tekdi Technologies Pvt. Ltd. All rights reserved.
* @license GNU GPLv2 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
* @link http://techjoomla.com
* Work derived from the original RESTful API by Techjoomla (https://github.com/techjoomla/Joomla-REST-API)
* and the com_api extension by Brian Edgerton (http://www.edgewebworks.com)
*/
defined('_JEXEC') or die('Restricted access');
/**
* API class EasyblogApiResourceLatest
*
* @since 1.0
*/
class EasyblogApiResourceLatest extends ApiResource
{
/**
* Method to get the list of available logs on site
*
* @return ApiPlugin response object
*
* @since 1.0
*/
public function get()
{
$input = JFactory::getApplication()->input;
$search = $input->get('search', '', 'STRING');
$featuredRequested = $input->get('featured', 0, 'INT');
$tags = $input->get('tags', 0, 'INT');
$userId = $input->get('user_id', 0, 'INT');
$limitstart = $input->get('limitstart', 0, 'INT');
$limit = $input->get('limit', 10, 'INT');
/*
* @FIXME add proper paginagioon support once the stackideas support it
* for now it won't support limit if the limitstart is 0 and will take the limit from easyblog config
*/
$pagination = $limitstart . ' , ' . $limit;
$posts = array();
$model = EB::model('Blog');
$blogs = array();
$latestData = array();
$featured = $model->getFeaturedBlog('', EBLOG_MAX_FEATURED_POST);
$excludeIds = array();
if ($featuredRequested)
{
$blogs = $featured;
}
elseif ($tags)
{
// @TODO add limit support
$blogs = $model->getTaggedBlogs($tags);
}
elseif ($userId)
{
// @TODO Add ACL support
$blogs = $model->getBlogsBy('blogger', $userId, 'latest', $pagination, EBLOG_FILTER_PUBLISHED, $search, true, null, false, false, true, '', '',
null, 'listlength', false, '', '', false, '', '');
}
else
{
foreach ($featured as $item)
{
$excludeIds[] = $item->id;
}
$blogs = $model->getBlogsBy('', '', 'latest', $pagination, EBLOG_FILTER_PUBLISHED, $search, true, $excludeIds, false, false, true, '', '',
null, 'listlength', false, '', '', false, '', '');
}
$blogs = EB::formatter('list', $blogs, false);
$schemaObject = new EasyBlogSimpleSchema_Plg;
$model = EB::model('Ratings');
foreach ($blogs as $blog)
{
$item = $schemaObject->mapPost($blog, '', 100);
$ratingValue = $model->getRatingValues($item->postid, 'entry');
$item->rate = $ratingValue;
if ($item->rate->ratings == 0)
{
$item->rate->ratings = - 2;
}
$posts[] = $item;
}
$apiResponse = new stdClass;
$apiResponse->result = $posts;
$this->plugin->setResponse($apiResponse);
}
/**
* Method
*
* @return void
*
* @since 1.0
*/
public static function getName()
{
}
/**
* Method
*
* @return void
*
* @since 1.0
*/
public static function describe()
{
}
}