-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathblog.php
More file actions
146 lines (120 loc) · 4.49 KB
/
Copy pathblog.php
File metadata and controls
146 lines (120 loc) · 4.49 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?php
/**
* @package 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://www.techjoomla.com
*/
defined('_JEXEC') or die( 'Restricted access' );
jimport('joomla.user.user');
jimport( 'simpleschema.easyblog.category' );
jimport( 'simpleschema.easyblog.person' );
jimport( 'simpleschema.easyblog.blog.post' );
require_once( EBLOG_HELPERS . '/date.php' );
require_once( EBLOG_HELPERS . '/string.php' );
require_once( EBLOG_CLASSES . '/adsense.php' );
//for image upload
require_once( EBLOG_CLASSES . '/mediamanager.php' );
require_once( EBLOG_HELPERS . '/image.php' );
require_once( EBLOG_CLASSES . '/easysimpleimage.php' );
require_once( EBLOG_CLASSES . '/mediamanager/local.php' );
require_once( EBLOG_CLASSES . '/mediamanager/types/image.php' );
class EasyblogApiResourceBlog extends ApiResource
{
public function __construct( &$ubject, $config = array()) {
parent::__construct( $ubject, $config = array() );
}
public function delete()
{
$this->plugin->setResponse($this->delete_blog());
}
public function post()
{
$input = JFactory::getApplication()->input;
$blog = EasyBlogHelper::getTable( 'Blog', 'Table' );
$post = $input->post->getArray(array());
$log_user = $this->plugin->get('user')->id;
$createTag = array();
$res = new stdClass;
//code for upload
$blog->bind($post,true);
$blog->permalink = str_replace('+','-',$blog->title);
//for publish unpublish blog.
$blog->published = $post['published'];
//create tags for blog
$createTag = $post['tags'];
//$blog->write_content = 1;
//$blog->write_content_hidden = 1;
$blog->created_by = $log_user;
$blog->created = date("Y-m-d h:i:s");
$blog->publish_up = date("Y-m-d h:i:s");
//$blog->created = EasyBlogHelper::getDate();
//get date from app
//$blog->publish_up = EasyBlogHelper::getDate();
$blog->created_by = $this->plugin->getUser()->id;
if (!$blog->store()) {
$this->plugin->setResponse( $this->getErrorResponse(404, $blog->getError()) );
return;
}
//create tags for blog called the function
$blog->processTags( $createTag, 1 );
$blog->processTrackbacks();
//$item = EasyBlogHelper::getHelper( 'SimpleSchema' )->mapPost($blog, '<p><br><pre><a><blockquote><strong><h2><h3><em><ul><ol><li>');
$scm_obj = new EasyBlogSimpleSchema_4();
$item = $scm_obj->mapPost($v,'', 100, array('text'));
$this->plugin->setResponse( $item );
}
public function get() {
$input = JFactory::getApplication()->input;
$model = EasyBlogHelper::getModel( 'Blog' );
$config = EasyBlogHelper::getConfig();
$id = $input->get('id', null, 'INT');
// If we have an id try to fetch the user
$blog = EasyBlogHelper::getTable( 'Blog' );
$blog->load( $id );
if (!$id)
{
$this->plugin->setResponse( $this->getErrorResponse(404, JText::_( 'PLG_API_EASYBLOG_BLOG_ID_MESSAGE' )) );
return;
}
if (!$blog->id)
{
$this->plugin->setResponse( $this->getErrorResponse(404, JText::_( 'PLG_API_EASYBLOG_BLOG_NOT_FOUND_MESSAGE' )) );
return;
}
//$item = EasyBlogHelper::getHelper( 'SimpleSchema' )->mapPost($blog, '<p><br><pre><a><blockquote><strong><h2><h3><em><ul><ol><li><iframe>');
$scm_obj = new EasyBlogSimpleSchema_4();
$item = $scm_obj->mapPost($blog, '<p><br><pre><a><blockquote><strong><h2><h3><em><ul><ol><li><iframe>');
$item->isowner = ( $blog->created_by == $this->plugin->get('user')->id )?true:false;
$item->allowcomment = $blog->allowcomment;
$item->allowsubscribe = $blog->subscription;
// Tags
$modelPT = EasyBlogHelper::getModel( 'PostTag' );
$item->tags = $modelPT->getBlogTags($blog->id);
//created by vishal - for show extra images
//$item->text = preg_replace('/"images/i', '"'.JURI::root().'images', $item->text );
$item->text = str_replace('href="','href="'.JURI::root(),$item->text);
$item->text = str_replace('src="','src="'.JURI::root(),$item->text);
$this->plugin->setResponse( $item );
}
public function delete_blog()
{
$app = JFactory::getApplication();
$id = $app->input->get('id',0,'INT');
$blog = EasyBlogHelper::getTable( 'Blog', 'Table' );
$blog->load( $id );
if(!$blog->id || !$id)
{
$res->status =0;
$res->message=JText::_( 'PLG_API_EASYBLOG_BLOG_NOT_EXISTS_MESSAGE' );
return $res;
}
else
{
$val = $blog->delete($id);
$re->status = $val;
$res->message=JText::_( 'PLG_API_EASYBLOG_DELETE_MESSAGE' );
return $res;
}
}
}