Beispiel #1
0
 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();
     if (!isset($id)) {
         $categoriesmodel = EasyBlogHelper::getModel('Categories');
         $categories = $categoriesmodel->getCategoryTree('ordering');
         $this->plugin->setResponse($categories);
         return;
     }
     $category->load($id);
     // private category shouldn't allow to access.
     $privacy = $category->checkPrivacy();
     if (!$category->id || !$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');
     $rows = $model->getBlogsBy('category', $catIds, $sorting, 0, EBLOG_FILTER_PUBLISHED, $search);
     foreach ($rows as $k => $v) {
         $scm_obj = new EasyBlogSimpleSchema_4();
         $item = $scm_obj->mapPost($v, '', 100, array('text'));
         //$item = EasyBlogHelper::getHelper( 'SimpleSchema' )->mapPost($v, '', 100, array('text'));
         $item->isowner = $v->created_by == $this->plugin->get('user')->id ? true : false;
         if ($v->blogpassword != '') {
             $item->ispassword = true;
         } else {
             $item->ispassword = false;
         }
         $item->blogpassword = $v->blogpassword;
         $model = EasyBlogHelper::getModel('Ratings');
         $ratingValue = $model->getRatingValues($item->postid, 'entry');
         $item->rate = $ratingValue;
         $item->isVoted = $model->hasVoted($item->postid, 'entry', $this->plugin->get('user')->id);
         if ($item->rate->ratings == 0) {
             $item->rate->ratings = -2;
         }
         $posts[] = $item;
     }
     $this->plugin->setResponse($posts);
 }
Beispiel #2
0
 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><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);
 }
Beispiel #3
0
 public function get()
 {
     $input = JFactory::getApplication()->input;
     $model = EasyBlogHelper::getModel('Blog');
     $id = $input->get('id', null, 'INT');
     $search = $input->get('search', null, 'STRING');
     $featured = $input->get('featured', 0, 'INT');
     $tags = $input->get('tags', 0, 'INT');
     $user_id = $input->get('user_id', 0, 'INT');
     $posts = array();
     // If we have an id try to fetch the user
     $blog = EasyBlogHelper::getTable('Blog');
     $blog->load($id);
     $modelPT = EasyBlogHelper::getModel('PostTag');
     //~ if ($id && !$tags) {
     //~ if(!$blog->id)
     //~ {
     //~ $this->plugin->setResponse( $this->getErrorResponse(404, 'Blog not found') );
     //~ return;
     //~ }
     //~ $this->plugin->setResponse( $blog );
     //~ }
     if ($tags) {
         $rows = $model->getTaggedBlogs($tags);
     } else {
         if ($featured) {
             $rows = $this->getfeature_Blog();
             $sorting = $this->plugin->params->get('sorting', 'featured');
         } else {
             if ($user_id) {
                 $blogs = EasyBlogHelper::getModel('Blog');
                 $rows = $blogs->getBlogsBy('blogger', $user_id, 'latest');
             } else {
                 //to get latest blog
                 $sorting = $this->plugin->params->get('sorting', 'latest');
                 $rows = $model->getBlogsBy($sorting, '', $sorting, 0, EBLOG_FILTER_PUBLISHED, $search);
             }
         }
     }
     //data mapping
     foreach ($rows as $k => $v) {
         $scm_obj = new EasyBlogSimpleSchema_4();
         $item = $scm_obj->mapPost($v, '', 100, array('text'));
         $item->tags = $modelPT->getBlogTags($item->postid);
         $item->isowner = $v->created_by == $this->plugin->get('user')->id ? true : false;
         if ($v->blogpassword != '') {
             $item->ispassword = true;
         } else {
             $item->ispassword = false;
         }
         $item->blogpassword = $v->blogpassword;
         $model = EasyBlogHelper::getModel('Ratings');
         $ratingValue = $model->getRatingValues($item->postid, 'entry');
         $item->rate = $ratingValue;
         $item->isVoted = $model->hasVoted($item->postid, 'entry', $this->plugin->get('user')->id);
         if ($item->rate->ratings == 0) {
             $item->rate->ratings = -2;
         }
         $posts[] = $item;
     }
     $this->plugin->setResponse($posts);
 }