-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
271 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
/** | ||
* @package API | ||
* @version 1.5 | ||
* @author Brian Edgerton | ||
* @link http://www.edgewebworks.com | ||
* @copyright Copyright (C) 2011 Edge Web Works, LLC. All rights reserved. | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php | ||
*/ | ||
|
||
defined('_JEXEC') or die( 'Restricted access' ); | ||
|
||
jimport('joomla.plugin.plugin'); | ||
|
||
class plgAPIEasyblog extends ApiPlugin | ||
{ | ||
public function __construct(&$subject, $config = array()) | ||
{ | ||
parent::__construct($subject, $config = array()); | ||
|
||
ApiResource::addIncludePath(dirname(__FILE__).'/easyblog'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<extension version="2.5.0" type="plugin" group="api" method="upgrade"> | ||
<name>Api - Easyblog</name> | ||
<version>1.0</version> | ||
<creationDate>July 2014</creationDate> | ||
<author>techjoomla</author> | ||
<authorEmail>[email protected]</authorEmail> | ||
<authorUrl>http://techjoomla.com</authorUrl> | ||
<copyright>Techjoomla</copyright> | ||
<license>GNU General Public License v2</license> | ||
<description>Easyblog APIs</description> | ||
|
||
<files> | ||
<filename plugin="easyblog">easyblog.php</filename> | ||
<folder>easyblog</folder> | ||
</files> | ||
</extension> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
defined('_JEXEC') or die( 'Restricted access' ); | ||
//error_reporting(E_ALL); | ||
//ini_set('display_errors', 1); | ||
|
||
jimport('joomla.user.user'); | ||
jimport( 'simpleschema.category' ); | ||
jimport( 'simpleschema.person' ); | ||
jimport( 'simpleschema.blog.post' ); | ||
|
||
require_once( JPATH_ROOT . '/components/com_easyblog/constants.php' ); | ||
require_once( EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'date.php' ); | ||
require_once( EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'helper.php' ); | ||
require_once( EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'string.php' ); | ||
require_once( EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'adsense.php' ); | ||
|
||
class EasyblogApiResourceBlog extends ApiResource | ||
{ | ||
|
||
public function __construct( &$ubject, $config = array()) { | ||
|
||
parent::__construct( $ubject, $config = array() ); | ||
$easyblog = JPATH_ROOT . '/administrator/components/com_easyblog/easyblog.php'; | ||
if (!JFile::exists($easyblog)) { | ||
$this->plugin->setResponse( $this->getErrorResponse(404, 'Easyblog not installed') ); | ||
return; | ||
} | ||
require_once( JPATH_ROOT . '/components/com_easyblog/helpers/helper.php' ); | ||
} | ||
public function delete() | ||
{ | ||
$this->plugin->setResponse( 'in delete' ); | ||
} | ||
|
||
public function post() | ||
{ | ||
$input = JFactory::getApplication()->input; | ||
$blog = EasyBlogHelper::getTable( 'Blog', 'Table' ); | ||
$post = $input->post->getArray(array()); | ||
|
||
$blog->bind($post); | ||
$blog->created_by = $this->plugin->getUser()->id; | ||
|
||
if (!$blog->store()) { | ||
$this->plugin->setResponse( $this->getErrorResponse(404, $blog->getError()) ); | ||
return; | ||
} | ||
|
||
$item = EasyBlogHelper::getHelper( 'SimpleSchema' )->mapPost($blog, '<p><br><pre><a><blockquote><strong><h2><h3><em><ul><ol><li>'); | ||
$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, 'Blog id cannot be blank') ); | ||
return; | ||
} | ||
|
||
if (!$blog->id) { | ||
$this->plugin->setResponse( $this->getErrorResponse(404, 'Blog not found') ); | ||
return; | ||
} | ||
|
||
$item = EasyBlogHelper::getHelper( 'SimpleSchema' )->mapPost($blog, '<p><br><pre><a><blockquote><strong><h2><h3><em><ul><ol><li>'); | ||
$this->plugin->setResponse( $config->get('comment_disqus_code') ); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
defined('_JEXEC') or die( 'Restricted access' ); | ||
//error_reporting(E_ALL); | ||
//ini_set('display_errors', 1); | ||
|
||
jimport('joomla.user.user'); | ||
jimport( 'simpleschema.category' ); | ||
jimport( 'simpleschema.person' ); | ||
jimport( 'simpleschema.blog.post' ); | ||
|
||
require_once( JPATH_ROOT . '/components/com_easyblog/constants.php' ); | ||
require_once( EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'date.php' ); | ||
require_once( EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'helper.php' ); | ||
require_once( EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'string.php' ); | ||
require_once( EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'adsense.php' ); | ||
|
||
class EasyblogApiResourceCategory extends ApiResource | ||
{ | ||
|
||
public function __construct( &$ubject, $config = array()) { | ||
|
||
parent::__construct( $ubject, $config = array() ); | ||
$easyblog = JPATH_ROOT . '/administrator/components/com_easyblog/easyblog.php'; | ||
if (!JFile::exists($easyblog)) { | ||
$this->plugin->setResponse( $this->getErrorResponse(404, 'Easyblog not installed') ); | ||
return; | ||
} | ||
require_once( JPATH_ROOT . '/components/com_easyblog/helpers/helper.php' ); | ||
} | ||
public function delete() | ||
{ | ||
$this->plugin->setResponse( 'in delete' ); | ||
} | ||
|
||
public function post() | ||
{ | ||
$this->plugin->setResponse( 'in post' ); | ||
} | ||
|
||
public function get() { | ||
$input = JFactory::getApplication()->input; | ||
$model = EasyBlogHelper::getModel( 'Blog' ); | ||
$category = EasyBlogHelper::getTable( 'Category', 'Table' ); | ||
$id = $input->get('id', null, 'INT'); | ||
$search = $input->get('search', null, 'STRING'); | ||
$posts = array(); | ||
|
||
$category->load($id); | ||
|
||
// private category shouldn't allow to access. | ||
$privacy = $category->checkPrivacy(); | ||
|
||
if(! $privacy->allowed ) | ||
{ | ||
$this->plugin->setResponse( $this->getErrorResponse(404, 'Category not found') ); | ||
return; | ||
} | ||
|
||
$catIds = array(); | ||
$catIds[] = $category->id; | ||
EasyBlogHelper::accessNestedCategoriesId($category, $catIds); | ||
|
||
$sorting = $this->plugin->params->get( 'sorting' , 'latest' ); | ||
$total = (int) $this->plugin->params->get( 'total' , 20 ); | ||
$rows = $model->getBlogsBy( 'category' , $catIds , $sorting , $total, EBLOG_FILTER_PUBLISHED, $search ); | ||
|
||
foreach ($rows as $k => $v) { | ||
$item = EasyBlogHelper::getHelper( 'SimpleSchema' )->mapPost($v, '', 100, array('text')); | ||
$posts[] = $item; | ||
} | ||
|
||
$this->plugin->setResponse( $posts ); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
defined('_JEXEC') or die( 'Restricted access' ); | ||
//error_reporting(E_ALL); | ||
//ini_set('display_errors', 1); | ||
|
||
jimport('joomla.user.user'); | ||
jimport( 'simpleschema.category' ); | ||
jimport( 'simpleschema.person' ); | ||
jimport( 'simpleschema.blog.post' ); | ||
|
||
require_once( JPATH_ROOT . '/components/com_easyblog/constants.php' ); | ||
require_once( EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'date.php' ); | ||
require_once( EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'helper.php' ); | ||
require_once( EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'string.php' ); | ||
require_once( EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'adsense.php' ); | ||
|
||
class EasyblogApiResourceLatest extends ApiResource | ||
{ | ||
|
||
public function __construct( &$ubject, $config = array()) { | ||
|
||
parent::__construct( $ubject, $config = array() ); | ||
$easyblog = JPATH_ROOT . '/administrator/components/com_easyblog/easyblog.php'; | ||
if (!JFile::exists($easyblog)) { | ||
$this->plugin->setResponse( $this->getErrorResponse(404, 'Easyblog not installed') ); | ||
return; | ||
} | ||
require_once( JPATH_ROOT . '/components/com_easyblog/helpers/helper.php' ); | ||
} | ||
public function delete() | ||
{ | ||
$this->plugin->setResponse( 'in delete' ); | ||
} | ||
|
||
public function post() | ||
{ | ||
$this->plugin->setResponse( 'in post' ); | ||
} | ||
|
||
public function get() { | ||
$input = JFactory::getApplication()->input; | ||
$model = EasyBlogHelper::getModel( 'Blog' ); | ||
$id = $input->get('id', null, 'INT'); | ||
$search = $input->get('search', null, 'STRING'); | ||
$posts = array(); | ||
|
||
// If we have an id try to fetch the user | ||
$blog = EasyBlogHelper::getTable( 'Blog' ); | ||
$blog->load( $id ); | ||
|
||
if ($id) { | ||
if(!$blog->id) { | ||
$this->plugin->setResponse( $this->getErrorResponse(404, 'Blog not found') ); | ||
return; | ||
} | ||
|
||
$this->plugin->setResponse( $blog ); | ||
} else { | ||
|
||
$sorting = $this->plugin->params->get( 'sorting' , 'latest' ); | ||
$total = (int) $this->plugin->params->get( 'total' , 20 ); | ||
$rows = $model->getBlogsBy( $sorting , '' , $sorting , $total, EBLOG_FILTER_PUBLISHED, $search ); | ||
|
||
foreach ($rows as $k => $v) { | ||
$item = EasyBlogHelper::getHelper( 'SimpleSchema' )->mapPost($v, '', 100, array('text')); | ||
$posts[] = $item; | ||
} | ||
|
||
$this->plugin->setResponse( $posts ); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.