public function get() { $input = JFactory::getApplication()->input; $model = EasyBlogHelper::getModel('Blog'); //$id = $input->get('id', null, 'INT'); $id = 0; $search = $input->get('search', '', '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::table('Blog'); $blog->load($id); $modelPT = EasyBlogHelper::getModel('PostTag'); 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 ); $rows = $model->getBlogsBy('', '', 'latest', 0, EBLOG_FILTER_PUBLISHED, null, true, array(), false, false, true, '', '', null, 'listlength', false); //$rows = EB::formatter('list', $rows, false); } } } $rows = EB::formatter('list', $rows, false); //data mapping foreach ($rows as $k => $v) { //$item = EB::helper( 'simpleschema' )->mapPost($v,'', 100, array('text')); $scm_obj = new EasyBlogSimpleSchema_plg(); $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); }
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::table('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; } //format data for get image using function $post = EB::post($blog->id); // $post->bind($row); $post = EB::formatter('entry', $post); $scm_obj = new EasyBlogSimpleSchema_plg(); $item = $scm_obj->mapPost($post, '<p><br><pre><a><blockquote><strong><h2><h3><em><ul><ol><li><iframe>'); //$item = EasyBlogHelper::getHelper( 'SimpleSchema' )->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 get() { $input = JFactory::getApplication()->input; $model = EasyBlogHelper::getModel('Blog'); $category = EasyBlogHelper::table('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; } //new code $category = EB::table('Category'); $category->load($id); //get the nested categories $category->childs = null; // Build nested childsets EB::buildNestedCategories($category->id, $category, false, true); $catIds = array(); $catIds[] = $category->id; EB::accessNestedCategoriesId($category, $catIds); // Get the category model $model = EB::model('Category'); // Get total posts in this category $category->cnt = $model->getTotalPostCount($category->id); // Get teamblog posts count // $teamBlogCount = $model->getTeamBlogCount($category->id); $limit = EB::call('Pagination', 'getLimit', array(EBLOG_PAGINATION_CATEGORIES)); // Get the posts in the category $data = $model->getPosts($catIds, $limit); $rows = EB::formatter('list', $data); //end foreach ($rows as $k => $v) { //$item = EasyBlogHelper::getHelper( 'SimpleSchema' )->mapPost($v, '', 100, array('text')); $scm_obj = new EasyBlogSimpleSchema_plg(); $item = $scm_obj->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); }