Exemple #1
0
 public function display($tpl = null)
 {
     // Check for access
     $this->checkAccess('easyblog.manage.subscription');
     $layout = $this->getLayout();
     if (method_exists($this, $layout)) {
         return $this->{$layout}();
     }
     // Set the page heading
     $this->setHeading('COM_EASYBLOG_TITLE_SUBSCRIPTIONS', '', 'fa-bell');
     $filter = $this->app->getUserStateFromRequest('com_easyblog.subscriptions.filter', 'filter', 'site', 'word');
     $search = $this->app->getUserStateFromRequest('com_easyblog.subscriptions.search', 'search', '', 'string');
     $search = trim(JString::strtolower($search));
     $order = $this->app->getUserStateFromRequest('com_easyblog.subscriptions.filter_order', 'filter_order', 'bname', 'cmd');
     $orderDirection = $this->app->getUserStateFromRequest('com_easyblog.subscriptions.filter_order_Dir', 'filter_order_Dir', '', 'word');
     //Get data from the model
     $model = EB::model('Subscriptions');
     $subscriptions = $model->getSubscriptions();
     $pagination = $model->getPagination();
     $this->set('subscriptions', $subscriptions);
     $this->set('pagination', $pagination);
     $this->set('filter', $filter);
     $this->set('filterList', $this->getFilter($filter));
     $this->set('search', $search);
     $this->set('order', $order);
     $this->set('orderDirection', $orderDirection);
     parent::display('subscriptions/default');
 }
Exemple #2
0
 /**
  * Displays the blocks listings
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function display($tpl = null)
 {
     // Check for access
     $this->checkAccess('easyblog.manage.blocks');
     $layout = $this->getLayout();
     if (method_exists($this, $layout)) {
         return $this->{$layout}();
     }
     // Get the filters
     $search = $this->input->get('search', '', 'word');
     $filterGroup = $this->input->get('filter_group', '', 'word');
     $filterState = $this->input->get('filter_state', 'all', 'default');
     $filterState = $filterState == 'all' ? 'all' : (int) $filterState;
     $options = array('filter_state' => $filterState, 'search' => $search, 'filter_group' => $filterGroup);
     // Set the heading
     $this->setHeading('COM_EASYBLOG_TITLE_BLOCKS', '', 'fa-cubes');
     $model = EB::model('Blocks');
     $blocks = $model->getBlocks($options);
     $groups = $model->getGroups();
     $pagination = $model->getPagination($options);
     $this->set('filterState', $filterState);
     $this->set('filterGroup', $filterGroup);
     $this->set('groups', $groups);
     $this->set('pagination', $pagination);
     $this->set('blocks', $blocks);
     $this->set('search', $search);
     parent::display('blocks/default');
 }
Exemple #3
0
 /**
  * Method to update ordering before a comment is saved.
  **/
 public function updateOrdering()
 {
     $model = EB::model('Comment');
     $latestComment = $model->getLatestComment($this->post_id, $this->parent_id);
     // @rule: Processing child comments
     if ($this->parent_id != 0) {
         $parentComment = EB::table('Comment');
         $parentComment->load($this->parent_id);
         $left = $parentComment->lft + 1;
         $right = $parentComment->lft + 2;
         $nodeVal = $parentComment->lft;
         if (!empty($latestComment)) {
             $left = $latestComment->rgt + 1;
             $right = $latestComment->rgt + 2;
             $nodeVal = $latestComment->rgt;
         }
         $model->updateCommentSibling($this->post_id, $nodeVal);
         $this->lft = $left;
         $this->rgt = $right;
         return true;
     }
     // @rule: Processing new comments
     $left = 1;
     $right = 2;
     if (!empty($latestComment)) {
         $left = $latestComment->rgt + 1;
         $right = $latestComment->rgt + 2;
         $model->updateCommentSibling($this->post_id, $latestComment->rgt);
     }
     $this->lft = $left;
     $this->rgt = $right;
     return true;
 }
Exemple #4
0
 /**
  * Discovery of language files
  *
  * @since   5.0
  * @access  public
  * @param   string
  * @return  
  */
 public function discover()
 {
     $model = EB::model('Languages');
     $result = $model->discover();
     $this->info->set(JText::_('COM_EASYBLOG_LANGUAGE_DISCOVERED_SUCCESSFULLY'), 'success');
     return $this->app->redirect('index.php?option=com_easyblog&view=languages');
 }
Exemple #5
0
 /**
  * Default user listings page.
  *
  * @since	1.0
  * @access	public
  * @param	null
  * @return	null
  */
 public function display($tpl = null)
 {
     $this->checkAccess('easyblog.manage.languages');
     $this->setHeading('COM_EASYBLOG_HEADING_LANGUAGES', '', 'fa-language');
     // Get configuration
     $config = EB::config();
     // Get the api key from the config
     $key = $config->get('main_apikey');
     // Add Joomla buttons
     JToolbarHelper::title(JText::_('COM_EASYBLOG_HEADING_LANGUAGES'));
     if (!$key) {
         JToolbarHelper::custom('savekey', 'save', '', JText::_('COM_EASYBLOG_SAVE_APIKEY_BUTTON'), false);
         $return = base64_encode('index.php?option=com_easyblog&view=languages');
         $this->set('return', $return);
         return parent::display('languages/key');
     }
     JToolbarHelper::custom('languages.discover', 'refresh', '', JText::_('COM_EASYBLOG_TOOLBAR_BUTTON_FIND_UPDATES'), false);
     JToolbarHelper::custom('languages.install', 'upload', '', JText::_('COM_EASYBLOG_TOOLBAR_BUTTON_INSTALL_OR_UPDATE'));
     JToolbarHelper::custom('languages.purge', 'purge', '', JText::_('COM_EASYBLOG_TOOLBAR_BUTTON_PURGE_CACHE'), false);
     // Get the languages that are already stored on the db
     $model = EB::model('Languages');
     $initialized = $model->initialized();
     if (!$initialized) {
         $this->set('key', $key);
         return parent::display('languages/initialize');
     }
     // Get languages
     $languages = $model->getLanguages();
     foreach ($languages as &$language) {
         $translators = json_decode($language->translator);
         $language->translator = $translators;
     }
     $this->set("languages", $languages);
     parent::display('languages/default');
 }
Exemple #6
0
 /**
  * Displays a list of reports
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function display($tpl = null)
 {
     // Test for user access if on 1.6 and above
     $this->checkAccess('easyblog.manage.report');
     $this->setHeading('COM_EASYBLOG_TITLE_REPORTS', '', 'fa-exclamation-triangle');
     $order = $this->app->getUserStateFromRequest('com_easyblog.reports.filter_order', 'filter_order', 'a.created', 'cmd');
     $orderDirection = $this->app->getUserStateFromRequest('com_easyblog.reports.filter_order_Dir', 'filter_order_Dir', 'asc', 'word');
     // Get reports
     $model = EB::model('Reports');
     $result = $model->getData();
     $pagination = $model->getPagination();
     $reports = array();
     if ($result) {
         foreach ($result as $row) {
             $report = EB::table('Report');
             $report->bind($row);
             $blog = EB::table('Blog');
             $blog->load($report->obj_id);
             $report->blog = $blog;
             $reports[] = $report;
         }
     }
     $this->set('pagination', $pagination);
     $this->set('reports', $reports);
     $this->set('order', $order);
     $this->set('orderDirection', $orderDirection);
     parent::display('reports/default');
 }
Exemple #7
0
 /**
  * Retrieves a list of items from a given uri
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function getItems($uri, $includeVariations = false)
 {
     // List down posts from the site
     $model = EB::model('MediaManager');
     $posts = $model->getPosts();
     // Get path and folder
     $folder = $this->getFolderItem($uri);
     // Get the absolute path to the main "articles" folder
     $folderPath = EasyBlogMediaManager::getPath($folder->uri);
     if (!$posts) {
         return $folder;
     }
     // Filegroup is the array where files are stored.
     // Sort arrays are used to speed up file sorting.
     $filegroup = EasyBlogMediaManager::filegroup();
     // The strategy used here is to use a single loop that build:
     // - data that is ready-to-use
     // - sort arrays so sorting becomes cheap.
     // - variations
     $variations = array();
     $total = 0;
     foreach ($posts as $post) {
         // Get the folder path of the article
         $articlePath = $folderPath . '/' . $post->id;
         // Get the uri for the article
         $uri = 'post:' . $post->id;
         $items = parent::getItems($uri);
         $filegroup['folder'][] = $items;
         $total++;
     }
     // Set the folder contents
     $folder->contents = $filegroup;
     $folder->total = $total;
     return $folder;
 }
 public function display($tmpl = null)
 {
     // Checks if rss is enabled
     if (!$this->config->get('main_rss')) {
         return;
     }
     // Get the archives model
     $model = EB::model('Archive');
     // Get a list of posts
     $posts = $model->getPosts();
     // Format the posts
     $posts = EB::formatter('list', $posts);
     // Set the link for this feed
     $this->doc->link = EBR::_('index.php?option=com_easyblog&view=archive');
     $this->doc->setTitle(JText::_('COM_EASYBLOG_ARCHIVED_POSTS'));
     $this->doc->setDescription(JText::_('COM_EASYBLOG_ARCHIVED_POSTS_DESC'));
     if (!$posts) {
         return;
     }
     foreach ($posts as $post) {
         $image = '';
         if ($post->getImage('medium', true, true)) {
             $image = '<img src=' . $post->getImage('medium', true, true) . '" alt="' . $post->title . '" />';
         }
         $item = new JFeedItem();
         $item->title = $post->title;
         $item->link = $post->getPermalink();
         $item->description = $image . $post->getIntro();
         $item->date = $post->getCreationDate()->format();
         $item->category = $post->getPrimaryCategory()->getTitle();
         $item->author = $post->author->getName();
         $item->authorEmail = $this->getRssEmail($post->author);
         $this->doc->addItem($item);
     }
 }
 /**
  * Auto post to social network sites
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return	
  */
 public function shareSystem(EasyBlogPost &$post, $force = false)
 {
     // Determines if the primary category of this post requires auto posting or not
     $category = $post->getPrimaryCategory();
     if (!$category->autopost) {
         return;
     }
     // Get a list of system oauth clients.
     $model = EB::model('Oauth');
     $clients = $model->getSystemClients();
     foreach ($clients as $client) {
         // If this is a new post, ensure that it respects the settings before auto posting
         if ($post->isNew() && !$this->config->get('integrations_' . $client->type . '_centralized_auto_post') && !$force) {
             continue;
         }
         // If the post is updated, ensure that it respects the settings before auto posting
         if (!$post->isNew() && !$this->config->get('integrations_' . $client->type . '_centralized_send_updates') && !$force) {
             continue;
         }
         $table = EB::table('OAuth');
         $table->bind($client);
         // Push the item now
         $table->push($post);
     }
 }
 public function display($tpl = null)
 {
     // Check for access
     $this->checkAccess('easyblog.manage.feeds');
     $layout = $this->getLayout();
     if (method_exists($this, $layout)) {
         return $this->{$layout}();
     }
     $this->setHeading('COM_EASYBLOG_BLOGS_FEEDS_TITLE', '', 'fa-rss-square');
     $model = EB::model('Feeds');
     $feeds = $model->getData();
     $pagination = $model->getPagination();
     if ($feeds) {
         foreach ($feeds as &$feed) {
             if ($feed->last_import == '0000-00-00 00:00:00') {
                 $feed->import_text = JText::_('COM_EASYBLOG_NEVER');
             } else {
                 $feed->import_text = $feed->last_import;
             }
         }
     }
     $filter_state = $this->app->getUserStateFromRequest('com_easyblog.feeds.filter_state', 'filter_state', '*', 'word');
     $search = $this->app->getUserStateFromRequest('com_easyblog.feeds.search', 'search', '', 'string');
     $search = trim(JString::strtolower($search));
     $this->set('state', JHTML::_('grid.state', $filter_state));
     $this->set('search', $search);
     $this->set('feeds', $feeds);
     $this->set('pagination', $pagination);
     parent::display('feeds/default');
 }
Exemple #11
0
 public static function getData(&$params, $id, $count = 0)
 {
     $model = EB::model('Blog');
     $entries = $model->getRelatedPosts($id, $count);
     $entries = EB::modules()->processItems($entries, $params);
     return $entries;
 }
 public function display($tmpl = null)
 {
     // Ensure that the user is logged in.
     EB::requireLogin();
     // null = new post
     // 63   = post 63 from post table
     // 63.2 = post 63, revision 2 from history table
     $uid = $this->input->getVar('uid', null);
     // If no id given, create a new post.
     $post = EB::post($uid);
     // Verify access (see function manager())
     if (!$post->canCreate() && !$post->canEdit()) {
         // Do not allow user to access this page if he doesn't have access
         JError::raiseError(500, JText::_('COM_EASYBLOG_NOT_ALLOWED_ACCESS_IN_THIS_SECTION'));
         return;
     }
     // If there's no id provided, we will need to create the initial revision for the post.
     if (!$uid) {
         $post->create();
         $uid = $post->uid;
     }
     // Determines if we should show the sidebars by default
     $templateId = $this->input->get('block_template', 0, 'int');
     if (!$post->title) {
         $this->doc->setTitle(JText::_('COM_EASYBLOG_COMPOSER_POST_UNTITLED'));
     }
     $composer = EB::composer();
     // Render default post templates
     $postTemplatesModel = EB::model('Templates');
     $postTemplates = $postTemplatesModel->getPostTemplates($this->my->id);
     $this->set('postTemplates', $postTemplates);
     $this->set('composer', $composer);
     $this->set('post', $post);
     return parent::display('composer/default');
 }
Exemple #13
0
 public function form($tpl = null)
 {
     $cids = $this->input->get('cid', array(), 'var');
     $scripts = EB::model('Maintenance')->getItemByKeys($cids);
     $this->set('scripts', $scripts);
     parent::display('maintenance/form');
 }
Exemple #14
0
 /**
  * Default display method for featured listings
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return	
  */
 public function display($tmpl = null)
 {
     // Set the meta tags for this page
     EB::setMeta(META_ID_FEATURED, META_TYPE_VIEW);
     // Add the RSS headers on the page
     EB::feeds()->addHeaders('index.php?option=com_easyblog&view=featured');
     // Add breadcrumbs on the site menu.
     $this->setPathway('COM_EASYBLOG_FEATURED_BREADCRUMB');
     // Get the model
     $model = EB::model('Featured');
     // Get a list of featured posts
     $posts = $model->getPosts();
     // Get the pagination
     $pagination = $model->getPagination();
     // Format the posts
     $posts = EB::formatter('list', $posts);
     // Set the page title
     $title = EB::getPageTitle(JText::_('COM_EASYBLOG_FEATURED_PAGE_TITLE'));
     $this->setPageTitle($title, $pagination, $this->config->get('main_pagetitle_autoappend'));
     // Get the current url
     $return = EBR::_('index.php?option=com_easyblog', false);
     $this->set('return', $return);
     $this->set('posts', $posts);
     $this->set('pagination', $pagination);
     parent::display('blogs/featured/default');
 }
Exemple #15
0
 /**
  * Override the parent's store behavior
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function store($updateNulls = false)
 {
     // @task: Load language file from the front end.
     JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT);
     // Clear any previous messages
     $model = EB::model('PostReject');
     $model->clear($this->post_id);
     return parent::store();
 }
Exemple #16
0
 public function display($tmpl = null)
 {
     // Get the model
     $model = EB::model('Search');
     $posts = $model->getData();
     $posts = EB::formatter('list', $posts);
     $this->set('posts', $posts);
     return parent::display();
 }
Exemple #17
0
 /**
  * Allows tagging suggestion which is used by the composer
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return	
  */
 public function suggest()
 {
     // Only logged in users are allowed here
     EB::requireLogin();
     $keyword = $this->input->get('search', '', 'default');
     $model = EB::model('Tags');
     $suggestions = $model->suggest($keyword);
     return $this->ajax->resolve($suggestions);
 }
Exemple #18
0
 /**
  * Default feed display method
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function display($tmpl = null)
 {
     // Ensure that rss is enabled
     if (!$this->config->get('main_rss')) {
         return JError::raiseError(404, JText::_('COM_EASYBLOG_FEEDS_DISABLED'));
     }
     $id = $this->input->get('id', '', 'cmd');
     $category = EB::table('Category');
     $category->load($id);
     // Private category shouldn't allow to access.
     $privacy = $category->checkPrivacy();
     if (!$privacy->allowed) {
         return JError::raiseError(500, JText::_('COM_EASYBLOG_NOT_ALLOWED_HERE'));
     }
     // Get the nested categories
     $category->childs = null;
     EB::buildNestedCategories($category->id, $category);
     $linkage = '';
     EB::accessNestedCategories($category, $linkage, '0', '', 'link', ', ');
     $catIds = array();
     $catIds[] = $category->id;
     EB::accessNestedCategoriesId($category, $catIds);
     $category->nestedLink = $linkage;
     $model = EB::model('Blog');
     $sort = $this->input->get('sort', $this->config->get('layout_postorder'), 'cmd');
     $posts = $model->getBlogsBy('category', $catIds, $sort);
     $posts = EB::formatter('list', $posts);
     $this->doc->link = EBR::_('index.php?option=com_easyblog&view=categories&id=' . $id . '&layout=listings');
     $this->doc->setTitle($this->escape($category->getTitle()));
     $this->doc->setDescription(JText::sprintf('COM_EASYBLOG_FEEDS_CATEGORY_DESC', $this->escape($category->getTitle())));
     if (!$posts) {
         return;
     }
     $uri = JURI::getInstance();
     $scheme = $uri->toString(array('scheme'));
     $scheme = str_replace('://', ':', $scheme);
     foreach ($posts as $post) {
         $image = '';
         if ($post->hasImage()) {
             $image = '<img src="' . $post->getImage('medium', true, true) . '" width="250" align="left" />';
         }
         $item = new JFeedItem();
         $item->title = $this->escape($post->title);
         $item->link = $post->getPermalink();
         $item->description = $image . $post->getIntro();
         // replace the image source to proper format so that feed reader can view the image correctly.
         $item->description = str_replace('src="//', 'src="' . $scheme . '//', $item->description);
         $item->description = str_replace('href="//', 'href="' . $scheme . '//', $item->description);
         $item->date = $post->getCreationDate()->toSql();
         $item->category = $post->getPrimaryCategory()->getTitle();
         $item->author = $post->author->getName();
         $item->authorEmail = $this->getRssEmail($post->author);
         $this->doc->addItem($item);
     }
     // exit;
 }
Exemple #19
0
 public function execute()
 {
     if ($this->cache) {
         // Cache data and preload posts
         EB::cache()->insert($this->items);
     }
     // For list items we wouldn't want to process comments
     $comment = true;
     // For list items we do not want to load videos
     $video = false;
     // For list items we do not want to process gallery
     $gallery = false;
     // Result
     $result = array();
     // Load up the tags model
     $tagsModel = EB::model('PostTag');
     foreach ($this->items as $item) {
         $post = EB::post($item->id);
         $blog = new stdClass();
         // Post details
         $blog->id = $post->id;
         $blog->title = $post->title;
         $blog->intro = $post->getIntro();
         $blog->content = $post->getContent();
         $blog->content_plain = $this->sanitize($blog->content);
         $blog->image = $post->getImage('thumbnail');
         $blog->created = $post->created;
         $blog->hits = $post->hits;
         $blog->permalink = $post->getPermalink(true, true, 'json');
         // Get the author details
         $author = $post->getAuthor();
         $blog->author = new stdClass();
         $blog->author->name = $author->getName();
         $blog->author->avatar = $author->getAvatar();
         // Get the tags for this post
         $tags = $post->getTags();
         $blog->tags = array();
         if ($tags) {
             foreach ($tags as $tag) {
                 $item = new stdClass();
                 $item->title = $tag->getTitle();
                 $item->permalink = $tag->getExternalPermalink('json');
                 $blog->tags[] = $item;
             }
         }
         // Get the category details
         $category = $post->getPrimaryCategory();
         $blog->category = new stdClass();
         $blog->category->id = $category->id;
         $blog->category->title = $category->getTitle();
         $blog->category->avatar = $category->getAvatar();
         $blog->category->permalink = $category->getExternalPermalink('json');
         $result[] = $blog;
     }
     return $result;
 }
Exemple #20
0
 /**
  * Default method to render listings in json format.
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return	
  */
 public function display($tmpl = null)
 {
     // Get the sorting options
     $sort = $this->input->get('sort', $this->config->get('layout_postorder'));
     $model = EB::model('Blog');
     $posts = $model->getBlogsBy('', '', $sort, 0, EBLOG_FILTER_PUBLISHED, null, true);
     // Format the posts
     $posts = EB::formatter('list', $posts);
     $this->set('posts', $posts);
     return parent::display();
 }
Exemple #21
0
 function display($tmpl = null)
 {
     if (!$this->config->get('main_rss')) {
         return;
     }
     $model = EB::model('Blog');
     $data = $model->getFeaturedBlog();
     $document = JFactory::getDocument();
     $document->link = EBR::_('index.php?option=com_easyblog&view=featured');
     $document->setTitle(JText::_('COM_EASYBLOG_FEEDS_FEATURED_TITLE'));
     $document->setDescription(JText::sprintf('COM_EASYBLOG_FEEDS_FEATURED_DESC', JURI::root()));
     if (empty($data)) {
         return;
     }
     $uri = JURI::getInstance();
     $scheme = $uri->toString(array('scheme'));
     $scheme = str_replace('://', ':', $scheme);
     foreach ($data as $row) {
         $blog = EB::table('Blog');
         $blog->load($row->id);
         $profile = EB::user($row->created_by);
         $created = EB::date($row->created);
         $row->created = $created->toSql();
         if ($this->config->get('main_rss_content') == 'introtext') {
             $row->text = !empty($row->intro) ? $row->intro : $row->content;
             //read more for feed
             $row->text .= '<br /><a href=' . EBR::_('index.php?option=com_easyblog&view=entry&id=' . $row->id) . '>Read more</a>';
         } else {
             $row->text = $row->intro . $row->content;
         }
         $row->text = EB::videos()->strip($row->text);
         $row->text = EB::adsense()->stripAdsenseCode($row->text);
         $category = EB::table('Category');
         // Get primary category
         $primaryCategory = $blog->getPrimaryCategory();
         $category->load($primaryCategory->id);
         // Assign to feed item
         $title = $this->escape($row->title);
         $title = html_entity_decode($title);
         // load individual item creator class
         $item = new JFeedItem();
         $item->title = $title;
         $item->link = EBR::_('index.php?option=com_easyblog&view=entry&id=' . $row->id);
         $item->description = $row->text;
         // replace the image source to proper format so that feed reader can view the image correctly.
         $item->description = str_replace('src="//', 'src="' . $scheme . '//', $item->description);
         $item->description = str_replace('href="//', 'href="' . $scheme . '//', $item->description);
         $item->date = $row->created;
         $item->category = $category->getTitle();
         $item->author = $profile->getName();
         $item->authorEmail = $this->getRssEmail($profile);
         $document->addItem($item);
     }
 }
Exemple #22
0
 /**
  * Purge Sent items
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function purgeSent()
 {
     // Check for request forgeries
     EB::checkToken();
     // Check for acl
     $this->checkAccess('mail');
     $model = EB::model('Spools');
     $model->purge('sent');
     $this->info->set('COM_EASYBLOG_SENT_MAILS_PURGED', 'success');
     return $this->app->redirect('index.php?option=com_easyblog&view=spools');
 }
Exemple #23
0
 public static function getPosts(&$params)
 {
     $config = EB::config();
     $count = (int) $params->get('count', 0);
     // Retrieve the model from the component.
     $model = EB::model('Blog');
     $categories = trim($params->get('catid'));
     $type = !empty($categories) ? 'category' : '';
     if (!empty($categories)) {
         $categories = explode(',', $categories);
     }
     $sorting = array();
     $sorting[] = $params->get('sorting', 'latest');
     $sorting[] = $params->get('ordering', 'desc');
     $rows = $model->getBlogsBy($type, $categories, $sorting, $count, EBLOG_FILTER_PUBLISHED, null, false);
     $posts = array();
     // Retreive settings from params
     $maxWidth = $params->get('imagewidth', 300);
     $maxHeight = $params->get('imageheight', 200);
     foreach ($rows as $data) {
         $row = EB::post($data->id);
         $row->bind($data);
         $row->media = '';
         //var_dump($row->image);
         if (!empty($row->image)) {
             $media = $row->getImage('thumbnail');
             $imgHtml = $media;
             $row->media = $imgHtml;
         } else {
             $image = self::getImage($row->intro . $row->content);
             if ($image !== false) {
                 // TODO: Here's where we need to crop the image based on the cropping ratio provided in the params.
                 // Currently this is just a lame hack to fix the width and height
                 $pattern = '/<\\s*img [^\\>]*src\\s*=\\s*[\\""\']?([^\\""\'>]*)/i';
                 preg_match($pattern, $image, $matches);
                 $imageurl = '';
                 if ($matches) {
                     $imageurl = isset($matches[1]) ? $matches[1] : '';
                 }
                 if (!empty($imageurl)) {
                     // $imgHtml = '<img title="'.$row->title.'" src="' . $imageurl . '" style="width: '. $maxWidth . 'px !important;height: '. $maxHeight . 'px !important;" />';
                     $imgHtml = $imageurl;
                     $row->media = $imgHtml;
                 } else {
                     $row->media = $image;
                 }
             }
         }
         if (!empty($row->media)) {
             $posts[] = $row;
         }
     }
     return $posts;
 }
Exemple #24
0
 /**
  * Displays a list of blog posts from a specific team
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function listings()
 {
     // Get the team id that is being accessed now
     $id = $this->input->get('id', 0, 'int');
     $team = EB::table('TeamBlog');
     $team->load($id);
     if (!$id || !$team->id) {
         return JError::raiseError(404, JText::_('COM_EASYBLOG_TEAMBLOG_INVALID_ID'));
     }
     // set meta tags for teamblog view
     EB::setMeta($id, META_TYPE_TEAM);
     $gid = EB::getUserGids();
     $isMember = $team->isMember($this->my->id, $gid);
     $team->isMember = $isMember;
     $team->isActualMember = $team->isMember($this->my->id, $gid, false);
     // Add rss feed link
     if ($team->access == EBLOG_TEAMBLOG_ACCESS_EVERYONE || $team->isMember) {
         $this->doc->addHeadLink($team->getRSS(), 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'));
         $this->doc->addHeadLink($team->getAtom(), 'alternate', 'rel', array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'));
     }
     // check if team description is emtpy or not. if yes, show default message.
     if (empty($team->description)) {
         $team->description = JText::_('COM_EASYBLOG_TEAMBLOG_NO_DESCRIPTION');
     }
     // Set the breadcrumbs for this view
     $this->setViewBreadcrumb('teamblog');
     $this->setPathway($team->getTitle());
     $limit = EB::call('Pagination', 'getLimit', array(EBLOG_PAGINATION_TEAMBLOGS));
     // Retrieve the model
     $model = EB::model('TeamBlogs');
     $posts = $model->getPosts($team->id, $limit);
     $posts = EB::formatter('list', $posts);
     // Get the pagination
     $pagination = $model->getPagination();
     // Retrieve team's information
     $members = $model->getTeamMembers($team->id);
     // Determines if the team blog is featured
     $team->isFeatured = EB::isFeatured('teamblog', $team->id);
     // Set the page title
     $title = EB::getPageTitle($team->title);
     $this->setPageTitle($title, $pagination, $this->config->get('main_pagetitle_autoappend'));
     // Check if subscribed
     $isTeamSubscribed = $model->isTeamSubscribedEmail($team->id, $this->my->email);
     // Get the current url
     $return = $team->getPermalink();
     $this->set('return', $return);
     $this->set('team', $team);
     $this->set('members', $members);
     $this->set('pagination', $pagination->getPagesLinks());
     $this->set('posts', $posts);
     $this->set('isTeamSubscribed', $isTeamSubscribed);
     parent::display('teamblogs/item');
 }
Exemple #25
0
 /**
  * Saves an acl
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function save()
 {
     // Check for request forgeries
     EB::checkToken();
     // @task: Check for acl rules.
     $this->checkAccess('acl');
     // get current task name.
     $task = $this->getTask();
     $id = $this->input->get('id', 0, 'int');
     $name = $this->input->get('name', '', 'cmd');
     // Ensure that the composite keys are provided.
     if (empty($id)) {
         $this->info->set('COM_EASYBLOG_ACL_INVALID_ID_ERROR', 'error');
         return $this->app->redirect('index.php?option=com_easyblog&view=acls&layout=form&id=' . $id);
     }
     // Get the data from the post
     $data = $this->input->getArray('post');
     // Get the text filters first.
     $filter = EB::table('ACLFilter');
     $state = $filter->load($id);
     if (!$state) {
         $filter->content_id = $id;
         $filter->type = 'group';
     }
     // Set the disallowed tags
     $filter->disallow_tags = $data['disallow_tags'];
     $filter->disallow_attributes = $data['disallow_attributes'];
     $filter->store();
     // Load the acl model
     $model = EB::model('ACL');
     // Delete all existing rule set
     $state = $model->deleteRuleset($id);
     // Unset unecessary data form the post
     unset($data['task']);
     unset($data['option']);
     unset($data['c']);
     unset($data['id']);
     unset($data['name']);
     unset($data['disallow_tags']);
     unset($data['disallow_attributes']);
     // Insert new rules
     $state = $model->insertRuleset($id, $data);
     if (!$state) {
         $this->info->set('COM_EASYBLOG_ACL_ERROR_SAVING_ACL', 'error');
         return $this->app->redirect('index.php?option=com_easyblog&view=acls&layout=form&id=' . $id);
     }
     $url = 'index.php?option=com_easyblog&view=acls';
     if ($task == 'apply') {
         $url = 'index.php?option=com_easyblog&view=acls&layout=form&id=' . $id;
     }
     $this->info->set('COM_EASYBLOG_ACL_SAVE_SUCCESS', 'success');
     return $this->app->redirect($url);
 }
Exemple #26
0
 /**
  * Lists down blog templates created by the author.
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function listTemplates()
 {
     $model = EB::model('Blog');
     $result = $model->getTemplates($this->my->id);
     $templates = array();
     if ($result) {
         foreach ($result as $table) {
             $templates[] = $table->export();
         }
     }
     return $this->ajax->resolve($templates);
 }
Exemple #27
0
 public function execute()
 {
     if (!$this->items) {
         return $this->items;
     }
     // cache teamblogs
     EB::cache()->insertTeams($this->items);
     $teams = array();
     // Load up the blogs model
     $model = EB::model('TeamBlogs');
     // Get the current user's group id's
     $gid = EB::getUserGids();
     foreach ($this->items as $item) {
         $team = EB::table('TeamBlog');
         $team->load($item->id);
         // Check if the logged in user is a member of the group
         $team->isMember = $team->isMember($this->my->id, $gid);
         $team->isActualMember = $team->isMember($this->my->id, $gid, false);
         $team->members = $model->getAllMembers($team->id, 5);
         // total member count ( including actual members and users from asociated joomla group.)
         $team->memberCount = $team->getAllMembersCount();
         // post count associated with this teamblog.
         $team->postCount = $team->getPostCount();
         // Get the list of blog posts form this team
         $blogs = array();
         if ($team->access != EBLOG_TEAMBLOG_ACCESS_MEMBER || $team->isMember || EB::isSiteAdmin()) {
             $blogs = $model->getPosts($team->id, EASYBLOG_TEAMBLOG_LISTING_NO_POST);
             $blogs = EB::formatter('list', $blogs);
         }
         $team->blogs = $blogs;
         // Get the list of tags
         // $team->tags = $team->getTags();
         // Get categories used in this team
         // $team->categories = $team->getCategories();
         // Determines if the team is featured
         if (isset($item->isfeatured)) {
             $team->isFeatured = $item->isfeatured;
         } else {
             $team->isFeatured = EB::isFeatured('teamblog', $team->id);
         }
         // check if team description is emtpy or not. if yes, show default message.
         if (empty($team->description)) {
             $team->description = JText::_('COM_EASYBLOG_TEAMBLOG_NO_DESCRIPTION');
         }
         // Determines if the viewer is subscribed to this team
         $team->isTeamSubscribed = $model->isTeamSubscribedEmail($team->id, $this->my->email);
         // If the user is subscribed, we need to get his subscription id
         $team->subscription_id = $team->isTeamSubscribed;
         $teams[] = $team;
     }
     return $teams;
 }
 /**
  * Retrieves a list of known languages
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function getLanguages()
 {
     $model = EB::model('Languages');
     $result = $model->discover();
     if ($result !== true) {
         $return = base64_encode('index.php?option=com_easyblog&view=languages');
         $template = EB::template();
         $template->set('return', $return);
         $output = $template->output('admin/languages/invalid');
         return $this->ajax->reject($output, $result->message);
     }
     return $this->ajax->resolve();
 }
Exemple #29
0
 /**
  * Retrieve the value for this field
  *
  * @since   4.0
  * @access  public
  * @param   string
  * @return
  */
 public function getValue(EasyBlogTableField &$field, EasyBlogPost &$post)
 {
     $singleItemType = array('text', 'textarea', 'date', 'radio');
     $model = EB::model('Fields');
     $values = $model->getFieldValues($field->id, $post->id);
     if (!$values) {
         return false;
     }
     if (count($values) == 1 && in_array($field->type, $singleItemType)) {
         return $values[0];
     }
     return $values;
 }
Exemple #30
0
 public static function getItems($params)
 {
     $model = EB::model('Blog');
     // Determines if we should display featured or latest entries
     $type = $params->get('showposttype', 'featured');
     // Determines if we should filter by category
     $categoryId = $params->get('catid');
     $result = array();
     if ($categoryId) {
         $categoryId = (int) $categoryId;
     }
     if ($type == 'latest' && !$categoryId) {
         $result = $model->getBlogsBy('', '', 'latest', $params->get('count'), EBLOG_FILTER_PUBLISHED, null, true, array(), false, false, false);
     }
     if ($type == 'latest' && $categoryId) {
         $result = $model->getBlogsBy('category', $categoryId, 'latest', $params->get('count'), EBLOG_FILTER_PUBLISHED, null, true, array(), false, false, false);
     }
     // If not latest posttype, show featured post.
     if ($type == 'featured') {
         if ($categoryId == 0) {
             $categoryId = '';
         }
         $result = $model->getFeaturedBlog($categoryId);
     }
     // If there's nothing to show at all, don't display anything
     if (!$result) {
         return $result;
     }
     $results = EB::formatter('list', $result);
     // Randomize items
     if ($params->get('autoshuffle')) {
         shuffle($results);
     }
     $contentKey = $params->get('contentfrom', 'content');
     $textcount = $params->get('textlimit', '200');
     $posts = array();
     foreach ($results as $result) {
         $content = $result->getContent();
         // Get the content from the selected source
         if ($contentKey == 'intro') {
             $content = $result->getIntro(true);
         }
         // Truncate the content
         if (JString::strlen(strip_tags($content)) > $textcount) {
             $content = JString::substr(strip_tags($content), 0, $textcount) . '...';
         }
         $result->content = $content;
         $posts[] = $result;
     }
     return $posts;
 }