Skip to content

Commit f67f693

Browse files
author
Aparna
committed
commited easyblog API changes
1 parent 8373bac commit f67f693

3 files changed

Lines changed: 80 additions & 45 deletions

File tree

easyblog/easyblog/blog.php

100644100755
Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
class EasyblogApiResourceBlog extends ApiResource
2121
{
2222

23-
public $default_retain_tags = '<p><br><pre><a><blockquote><strong><h2><h3><em><ul><ol><li><iframe><img>';
24-
public $disallowed_tags = array('script','style');
25-
2623
public function __construct( &$ubject, $config = array()) {
2724
parent::__construct( $ubject, $config = array() );
2825
}
@@ -41,49 +38,37 @@ public function post()
4138
return;
4239
}
4340

44-
$item = EasyBlogHelper::getHelper( 'SimpleSchema' )->mapPost($blog, $this->getRetainedTags());
41+
$item = EasyBlogHelper::getHelper( 'SimpleSchema' )->mapPost($blog, '<p><br><pre><a><blockquote><strong><h2><h3><em><ul><ol><li>');
4542
$this->plugin->setResponse( $item );
4643

4744
}
4845

49-
public function get() {
46+
public function get()
47+
{
5048
$input = JFactory::getApplication()->input;
5149
$model = EasyBlogHelper::getModel( 'Blog' );
5250
$config = EasyBlogHelper::getConfig();
5351
$id = $input->get('id', null, 'INT');
54-
5552
// If we have an id try to fetch the user
56-
$blog = EasyBlogHelper::getTable( 'Blog' );
53+
$blog = EasyBlogHelper::getTable( 'Blog' );
5754
$blog->load( $id );
5855

59-
if (!$id) {
56+
if (!$id)
57+
{
6058
$this->plugin->setResponse( $this->getErrorResponse(404, 'Blog id cannot be blank') );
6159
return;
6260
}
6361

64-
if (!$blog->id) {
62+
if (!$blog->id)
63+
{
6564
$this->plugin->setResponse( $this->getErrorResponse(404, 'Blog not found') );
6665
return;
6766
}
68-
69-
$item = EasyBlogHelper::getHelper( 'SimpleSchema' )->mapPost($blog, $this->getRetainedTags());
67+
$item = EasyBlogHelper::getHelper( 'SimpleSchema' )->mapPost($blog, '<p><br><pre><a><blockquote><strong><h2><h3><em><ul><ol><li><iframe>');
68+
// Tags
69+
$modelPT = EasyBlogHelper::getModel( 'PostTag' );
70+
$item->tags = $modelPT->getBlogTags($blog->id);
7071
$this->plugin->setResponse( $item );
7172
}
7273

73-
public function getRetainedTags() {
74-
$plugin = JPluginHelper::getPlugin('api', 'easyblog');
75-
$params = new JRegistry($plugin->params);
76-
77-
$tags = explode(',', $params->get('retain_tags'));
78-
$trimmed_array = array_map('trim', $tags);
79-
$retain_tags = array_diff($trimmed_array, $this->disallowed_tags);
80-
81-
if (!count($retain_tags))
82-
{
83-
return $default_retain_tags;
84-
}
85-
86-
return '<' . implode('><', $retain_tags) . '>';
87-
}
88-
8974
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
/**
3+
* @package K2 API plugin
4+
* @version 1.0
5+
* @author Rafael Corral
6+
* @link http://www.rafaelcorral.com
7+
* @copyright Copyright (C) 2011 Rafael Corral. All rights reserved.
8+
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
9+
*/
10+
11+
defined('_JEXEC') or die( 'Restricted access' );
12+
13+
jimport('joomla.plugin.plugin');
14+
jimport('joomla.html.html');
15+
jimport('joomla.application.component.controller');
16+
jimport('joomla.application.component.model');
17+
jimport('joomla.user.helper');
18+
jimport('joomla.user.user');
19+
jimport('joomla.application.component.helper');
20+
jimport( 'simpleschema.blog.post' );
21+
jimport( 'simpleschema.category' );
22+
jimport( 'simpleschema.person' );
23+
24+
JModelLegacy::addIncludePath(JPATH_SITE.'components/com_api/models');
25+
require_once JPATH_SITE.'/components/com_easyblog/models/users.php';
26+
require_once JPATH_SITE.'/components/com_easyblog/models/blogger.php';
27+
//~ require_once JPATH_SITE.'/plugins/api/easyblog/libraries/simpleschema/bloggers.php';
28+
29+
class EasyblogApiResourceEasyblog_users extends ApiResource
30+
{
31+
public function get()
32+
{
33+
$this->plugin->setResponse($this->getEasyBlog_user());
34+
}
35+
public function post()
36+
{
37+
$this->plugin->setResponse();
38+
}
39+
public function getEasyBlog_user()
40+
{
41+
$ob1 = new EasyBlogModelBlogger();
42+
$var1 = $ob1->getAllBloggers();
43+
return $var1;
44+
}
45+
}

easyblog/easyblog/latest.php

100644100755
Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* @link http://www.techjoomla.com
77
*/
88
defined('_JEXEC') or die( 'Restricted access' );
9-
109
jimport('joomla.user.user');
1110
jimport( 'simpleschema.category' );
1211
jimport( 'simpleschema.person' );
@@ -26,34 +25,40 @@ public function __construct( &$ubject, $config = array()) {
2625

2726
public function get() {
2827
$input = JFactory::getApplication()->input;
29-
$model = EasyBlogHelper::getModel( 'Blog' );
30-
$id = $input->get('id', null, 'INT');
28+
$model = EasyBlogHelper::getModel( 'Blog' );
29+
//$id = $input->get('id', null, 'INT');
3130
$search = $input->get('search', null, 'STRING');
31+
$tags = $input->get('tags',0,'INT');
3232
$posts = array();
33-
3433
// If we have an id try to fetch the user
3534
$blog = EasyBlogHelper::getTable( 'Blog' );
3635
$blog->load( $id );
36+
$modelPT = EasyBlogHelper::getModel( 'PostTag' );
3737

38-
if ($id) {
39-
if(!$blog->id) {
40-
$this->plugin->setResponse( $this->getErrorResponse(404, 'Blog not found') );
41-
return;
42-
}
43-
44-
$this->plugin->setResponse( $blog );
45-
} else {
46-
38+
//~ if ($id && !$tags) {
39+
//~ if(!$blog->id)
40+
//~ {
41+
//~ $this->plugin->setResponse( $this->getErrorResponse(404, 'Blog not found') );
42+
//~ return;
43+
//~ }
44+
//~ $this->plugin->setResponse( $blog );
45+
//~ }
46+
if($tags)
47+
{
48+
$rows = $model->getTaggedBlogs( $tags );
49+
}
50+
else
51+
{
4752
$sorting = $this->plugin->params->get( 'sorting' , 'latest' );
4853
$rows = $model->getBlogsBy( $sorting , '' , $sorting , 0, EBLOG_FILTER_PUBLISHED, $search );
49-
50-
foreach ($rows as $k => $v) {
51-
$item = EasyBlogHelper::getHelper( 'SimpleSchema' )->mapPost($v, '', 100, array('text'));
54+
}
55+
foreach ($rows as $k => $v)
56+
{
57+
$item = EasyBlogHelper::getHelper( 'SimpleSchema' )->mapPost($v,'', 100, array('text'));
58+
$item->tags = $modelPT->getBlogTags($item->postid);
5259
$posts[] = $item;
5360
}
54-
5561
$this->plugin->setResponse( $posts );
56-
}
5762
}
5863

5964
public static function getName() {

0 commit comments

Comments
 (0)