Beispiel #1
0
 function display($tmpl = null)
 {
     $my = JFactory::getUser();
     if ($my->id < 1) {
         EasyBlogHelper::showLogin();
         return;
     }
     JPluginHelper::importPlugin('easyblog');
     $dispatcher = JDispatcher::getInstance();
     $mainframe = JFactory::getApplication();
     $document = JFactory::getDocument();
     $acl = EasyBlogACLHelper::getRuleSet();
     $config = EasyBlogHelper::getConfig();
     $sort = JRequest::getCmd('sort', $config->get('layout_postorder'));
     $blogger = EasyBlogHelper::getTable('Profile', 'Table');
     $blogger->load($my->id);
     // set meta tags for blogger
     EasyBlogHelper::setMeta($my->id, META_ID_BLOGGERS);
     if (!EasyBlogRouter::isCurrentActiveMenu('myblog', $my->id)) {
         $this->setPathway(JText::_('COM_EASYBLOG_BLOGGERS_BREADCRUMB'), EasyBlogRouter::_('index.php?option=com_easyblog&view=blogger'));
         $this->setPathway($blogger->getName());
     }
     $model = $this->getModel('Blog');
     $data = $model->getBlogsBy('blogger', $blogger->id, $sort);
     $pagination = $model->getPagination();
     $pageNumber = $pagination->get('pages.current');
     $pageText = $pageNumber == 1 ? '' : ' - ' . JText::sprintf('COM_EASYBLOG_PAGE_NUMBER', $pageNumber);
     $document->setTitle($blogger->getName() . $pageText . EasyBlogHelper::getPageTitle(JText::_('COM_EASYBLOG_MY_BLOG_PAGE_TITLE')));
     $data = EasyBlogHelper::formatBlog($data, false, true, true, true);
     if ($config->get('layout_showcomment', false)) {
         for ($i = 0; $i < count($data); $i++) {
             $row =& $data[$i];
             $maxComment = $config->get('layout_showcommentcount', 3);
             $comments = EasyBlogHelper::getHelper('Comment')->getBlogComment($row->id, $maxComment, 'desc');
             $comments = EasyBlogHelper::formatBlogCommentsLite($comments);
             $row->comments = $comments;
         }
     }
     $rssURL = EasyBlogRouter::_('index.php?option=com_easyblog&view=blogger&task=rss');
     //twitter follow me link
     $twitterFollowMelink = EasyBlogSocialShareHelper::getLink('twitter', $blogger->id);
     $theme = new CodeThemes();
     $theme->set('rssURL', $rssURL);
     $theme->set('blogger', $blogger);
     $theme->set('sort', $sort);
     $theme->set('blogs', $data);
     $theme->set('currentURL', 'index.php?option=com_easyblog&view=latest');
     $theme->set('pagination', $pagination->getPagesLinks());
     $theme->set('twitterFollowMelink', $twitterFollowMelink);
     $theme->set('my', $my);
     $theme->set('acl', $acl);
     echo $theme->fetch('blog.blogger.php');
 }
Beispiel #2
0
 public function autopost()
 {
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     // @task: Check for acl rules.
     $this->checkAccess('blog');
     $type = JRequest::getWord('autopost_type');
     $config = EasyBlogHelper::getConfig();
     $my = JFactory::getUser();
     $app = JFactory::getApplication();
     $oauth = EasyBlogHelper::getTable('OAuth');
     $oauth->loadSystemByType($type);
     if (!$oauth->id) {
         $app->redirect('index.php?option=com_easyblog&view=blogs', JText::_('COM_EASYBLOG_AUTOPOST_UNABLE_TO_LOAD_TYPE'), 'error');
         $app->close();
     }
     if (!$config->get('integrations_' . $oauth->type)) {
         $app->redirect('index.php?option=com_easyblog&view=blogs', JText::sprintf('COM_EASYBLOG_AUTOPOST_SITE_IS_NOT_ENABLED', ucfirst($type)), 'error');
         $app->close();
     }
     $id = JRequest::getInt('autopost_selected');
     $blog = EasyBlogHelper::getTable('Blog');
     $blog->load($id);
     // @task: Test if the blog post is unpublished.
     if ($blog->published != POST_ID_PUBLISHED) {
         $app->redirect('index.php?option=com_easyblog&view=blogs', JText::_('COM_EASYBLOG_AUTOPOST_PLEASE_PUBLISH_BLOG'), 'error');
         $app->close();
     }
     // @task: Test if the api key and secret is valid.
     $key = $config->get('integrations_' . $oauth->type . '_api_key');
     $secret = $config->get('integrations_' . $oauth->type . '_secret_key');
     if (empty($key) || empty($secret)) {
         $app->redirect('index.php?option=com_easyblog&view=blogs', JText::sprintf('COM_EASYBLOG_AUTOPOST_KEYS_INVALID', ucfirst($type)), 'error');
         $app->close();
     }
     if (!EasyBlogSocialShareHelper::share($blog, $oauth->type, true)) {
         $app->redirect('index.php?option=com_easyblog&view=blogs', JText::sprintf('COM_EASYBLOG_AUTOPOST_SUBMIT_ERROR', ucfirst($oauth->type)), 'error');
         $app->close();
     }
     $app->redirect('index.php?option=com_easyblog&view=blogs', JText::sprintf('COM_EASYBLOG_AUTOPOST_SUBMIT_SUCCESS', ucfirst($oauth->type)), 'success');
 }
Beispiel #3
0
 function statistic()
 {
     JPluginHelper::importPlugin('easyblog');
     $dispatcher = JDispatcher::getInstance();
     $mainframe = JFactory::getApplication();
     $document = JFactory::getDocument();
     $config = EasyBlogHelper::getConfig();
     $my = JFactory::getUser();
     $acl = EasyBlogACLHelper::getRuleSet();
     // Add noindex for tags view by default.
     $document->setMetadata('robots', 'noindex,follow');
     $sort = JRequest::getCmd('sort', $config->get('layout_postorder'));
     $bId = JRequest::getCmd('id', '0');
     //stats type
     $statType = JRequest::getString('stat', '');
     $statId = $statType == 'tag' ? JRequest::getString('tagid', '') : JRequest::getString('catid', '');
     $statObject = null;
     if ($statType == 'category') {
         $statObject = EasyBlogHelper::getTable('Category', 'Table');
         $statObject->load($statId);
     } else {
         JTable::addIncludePath(EBLOG_TABLES);
         $statObject = EasyBlogHelper::getTable('Tag', 'Table');
         $statObject->load($statId);
     }
     $blogger = EasyBlogHelper::getTable('Profile', 'Table');
     $blogger->load($bId);
     // set meta tags for blogger
     if ($acl->rules->allow_seo) {
         EasyBlogHelper::setMeta($blogger->id, META_TYPE_BLOGGER, true);
     }
     if (!EasyBlogRouter::isCurrentActiveMenu('blogger')) {
         $this->setPathway(JText::_('COM_EASYBLOG_BLOGGERS'), EasyBlogRouter::_('index.php?option=com_easyblog&view=blogger'));
     }
     if (!EasyBlogRouter::isCurrentActiveMenu('blogger', $blogger->id)) {
         $this->setPathway($blogger->getName());
     }
     $model = $this->getModel('Blog');
     $data = $model->getBlogsBy('blogger', $blogger->id, $sort);
     $pagination = $model->getPagination();
     $data = EasyBlogHelper::formatBlog($data);
     $rssURL = EasyBlogRouter::_('index.php?option=com_easyblog&view=blogger&task=rss');
     if ($config->get('layout_showcomment', false)) {
         for ($i = 0; $i < count($data); $i++) {
             $row =& $data[$i];
             $maxComment = $config->get('layout_showcommentcount', 3);
             $comments = EasyBlogHelper::getHelper('Comment')->getBlogComment($row->id, $maxComment, 'desc');
             $comments = EasyBlogHelper::formatBlogCommentsLite($comments);
             $row->comments = $comments;
         }
     }
     $twitterFollowMelink = EasyBlogSocialShareHelper::getLink('twitter', $blogger->id);
     if ($config->get('main_rss')) {
         if ($config->get('main_feedburner') && $config->get('main_feedburnerblogger')) {
             $document->addHeadLink($blogger->getRSS(), 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'));
         } else {
             // Add rss feed link
             $document->addHeadLink($blogger->getRSS(), 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'));
             $document->addHeadLink($blogger->getAtom(), 'alternate', 'rel', array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'));
         }
     }
     $pageTitle = EasyBlogHelper::getPageTitle($config->get('main_title'));
     $pageNumber = $pagination->get('pages.current');
     $pageText = $pageNumber == 1 ? '' : ' - ' . JText::sprintf('COM_EASYBLOG_PAGE_NUMBER', $pageNumber);
     $statTitle = '';
     if (isset($statType)) {
         if ($statType == 'tag') {
             $statTitle = ' - ' . JText::sprintf('COM_EASYBLOG_BLOGGER_STAT_TAG', $statObject->title);
         } else {
             $statTitle = ' - ' . JText::sprintf('COM_EASYBLOG_BLOGGER_STAT_CATEGORY', $statObject->title);
         }
     }
     $document->setTitle($blogger->getName() . $statTitle . $pageText . $pageTitle);
     $tpl = new CodeThemes();
     $tpl->set('blogger', $blogger);
     $tpl->set('sort', $sort);
     $tpl->set('blogs', $data);
     $tpl->set('config', $config);
     $tpl->set('siteadmin', EasyBlogHelper::isSiteAdmin());
     $tpl->set('pagination', $pagination->getPagesLinks());
     $tpl->set('twitterFollowMelink', $twitterFollowMelink);
     $tpl->set('my', $my);
     $tpl->set('acl', $acl);
     $tpl->set('currentURL', ltrim('/', JRequest::getURI()));
     $tpl->set('statType', $statType);
     $tpl->set('statObject', $statObject);
     echo $tpl->fetch('blog.blogger.php');
 }
Beispiel #4
0
 public function autopost($userSites, $centralizedSites = array())
 {
     $config = EasyBlogHelper::getConfig();
     $allowed = array(EBLOG_OAUTH_LINKEDIN, EBLOG_OAUTH_FACEBOOK, EBLOG_OAUTH_TWITTER);
     // @rule: Process centralized options first
     // See if there are any global postings enabled.
     if (!empty($centralizedSites)) {
         foreach ($centralizedSites as $item) {
             if ($config->get('integrations_' . $item . '_centralized')) {
                 EasyBlogSocialShareHelper::share($this, constant('EBLOG_OAUTH_' . JString::strtoupper($item)), true);
             }
         }
     }
     if (!empty($userSites)) {
         foreach ($userSites as $site) {
             if (in_array($site, $allowed) && $config->get('integrations_' . $site)) {
                 EasyBlogSocialShareHelper::share($this, constant('EBLOG_OAUTH_' . JString::strtoupper($site)));
             }
         }
     }
 }
Beispiel #5
0
 /**
  * Ajax method to share content to social networks
  *
  * @param	int		$blogId		The blog's id.
  * @param	int		$oauthId	The oauth id.
  **/
 function ajaxSocialShare($blogId, $type)
 {
     $ajax = new Ejax();
     $config = EasyBlogHelper::getConfig();
     $my = JFactory::getUser();
     $userId = $my->id;
     $oauth = EasyBlogHelper::getTable('Oauth', 'Table');
     $oauth->loadByUser($userId, $type);
     if (!$oauth->id) {
         $ajax->script('eblog.spinner.publish(\'' . $blogId . '\', 0);');
         $ajax->alert(JText::_('COM_EASYBLOG_OAUTH_INVALID_ID'), JText::_('COM_EASYBLOG_INFO'), 450, 'auto');
         $ajax->send();
         return;
     }
     if (!$config->get('integrations_' . $oauth->type)) {
         $ajax->script('eblog.spinner.publish(\'' . $blogId . '\', 0);');
         $ajax->alert(JText::sprintf('COM_EASYBLOG_OAUTH_TYPE_DISABLED', ucfirst($oauth->type)), JText::_('COM_EASYBLOG_INFO'), 450, 'auto');
         $ajax->send();
         return;
     }
     $blog = EasyBlogHelper::getTable('blog', 'Table');
     $blog->load($blogId);
     if ($blog->published != POST_ID_PUBLISHED) {
         $ajax->script('eblog.spinner.publish(\'' . $blogId . '\', 0);');
         $ajax->alert(JText::_('COM_EASYBLOG_DASHBOARD_ENTRIES_NOT_ABLE_TO_SOCIAL_SHARE'), JText::_('COM_EASYBLOG_INFO'), 450, 'auto');
         $ajax->send();
         return;
     }
     $key = $config->get('integrations_' . $oauth->type . '_api_key');
     $secret = $config->get('integrations_' . $oauth->type . '_secret_key');
     if (empty($key) || empty($secret)) {
         $ajax->script('eblog.spinner.publish("' . $blogId . '", 0);');
         $ajax->alert(JText::_('COM_EASYBLOG_OAUTH_KEY_INVALID'), JText::_('COM_EASYBLOG_INFO'), 450, 'auto');
         $ajax->send();
         return;
     }
     $callback = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&controller=oauth&task=grant&type=' . $oauth->type, false, true);
     require_once EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'oauth.php';
     $consumer = EasyBlogOauthHelper::getConsumer($oauth->type, $key, $secret, $callback);
     $consumer->setAccess($oauth->access_token);
     if (!EasyBlogSocialShareHelper::share($blog, $oauth->type)) {
         $ajax->script('eblog.spinner.publish("' . $blogId . '", 0);');
         $ajax->alert(JText::_('COM_EASYBLOG_OAUTH_ERROR_POSTING'), JText::_('COM_EASYBLOG_INFO'), 450, 'auto');
         $ajax->send();
         return;
     }
     // @todo: mark this as sent!
     $oauthPost = EasyBlogHelper::getTable('OauthPost', 'Table');
     $oauthPost->loadByOauthId($blog->id, $oauth->id);
     $date = EasyBlogHelper::getDate();
     $oauthPost->post_id = $blog->id;
     $oauthPost->oauth_id = $oauth->id;
     $oauthPost->created = $date->toMySQL();
     $oauthPost->modified = $date->toMySQL();
     $oauthPost->sent = $date->toMySQL();
     $oauthPost->store();
     // Update message
     $img = JURI::root() . '/components/com_easyblog/assets/icons/socialshare/' . JString::strtolower($oauth->type) . '.png';
     $ajax->script('$("#oauth_img_' . $oauth->type . '_' . $blog->id . '").attr("src", "' . $img . '");');
     $ajax->script('eblog.spinner.publish(\'' . $blog->id . '\', 0);');
     $ajax->alert(JText::sprintf('COM_EASYBLOG_OAUTH_POST_SUCCESS', ucfirst($oauth->type)), JText::_('COM_EASYBLOG_INFO'), 450, 'auto');
     $ajax->send();
 }