function display($tmpl = null) { $config = EasyBlogHelper::getConfig(); $jConfig = EasyBlogHelper::getJConfig(); if (!$config->get('main_rss')) { return; } $model = $this->getModel('Featured'); $data = $model->getFeaturedBlog(); $document = JFactory::getDocument(); $document->link = EasyBlogRouter::_('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)) { for ($i = 0; $i < count($data); $i++) { $row =& $data[$i]; $profile = EasyBlogHelper::getTable('Profile', 'Table'); $profile->load($row->created_by); $created = EasyBlogDateHelper::dateWithOffSet($row->created); $formatDate = true; if (EasyBlogHelper::getJoomlaVersion() >= '1.6') { $langCode = EasyBlogStringHelper::getLangCode(); if ($langCode != 'en-GB' || $langCode != 'en-US') { $formatDate = false; } } // $row->created = ( $formatDate ) ? $created->toFormat( $config->get('layout_dateformat', '%A, %d %B %Y') ) : $created->toFormat(); $row->created = $created->toMySQL(); if ($config->get('main_rss_content') == 'introtext') { $row->text = !empty($row->intro) ? $row->intro : $row->content; //read more for feed $row->text .= '<br /><a href=' . EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $row->id) . '>Read more</a>'; } else { $row->text = $row->intro . $row->content; } $row->text = EasyBlogHelper::getHelper('Videos')->strip($row->text); $row->text = EasyBlogGoogleAdsense::stripAdsenseCode($row->text); $category = EasyBlogHelper::getTable('Category', 'Table'); $category->load($row->category_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 = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $row->id); $item->description = $row->text; $item->date = $row->created; $item->category = $category->title; $item->author = $profile->getName(); if ($jConfig->get('feed_email') == 'author') { $item->authorEmail = $profile->user->email; } else { $item->authorEmail = $jConfig->get('mailfrom'); } $document->addItem($item); } } }
public function mapPost($row, $strip_tags = '', $text_length = 0, $skip = array()) { $config = EasyBlogHelper::getConfig(); $blog = EasyBlogHelper::getTable('Blog'); $blog->load($row->id); $profile = EasyBlogHelper::getTable('Profile', 'Table'); $profile->load($row->created_by); $created = EasyBlogDateHelper::dateWithOffSet($row->created); $formatDate = true; if (EasyBlogHelper::getJoomlaVersion() >= '1.6') { $langCode = EasyBlogStringHelper::getLangCode(); if ($langCode != 'en-GB' || $langCode != 'en-US') { $formatDate = false; } } $blog->created = $created->toMySQL(); $blog->text = $row->intro . $row->content; $config->set('max_video_width', 320); $config->set('max_video_width', 180); $blog->text = EasyBlogHelper::getHelper('Videos')->processVideos($blog->text); $blog->text = EasyBlogGoogleAdsense::stripAdsenseCode($blog->text); $category = EasyBlogHelper::getTable('Category', 'Table'); $category->load($row->category_id); $item = new PostSimpleSchema(); $item->textplain = $blog->text; // @TODO : Take care of a case when strip tags and length are used together if ($strip_tags) { $item->textplain = strip_tags($blog->text, $strip_tags); } if ($text_length > 0) { $pos = JString::strpos(strip_tags($item->textplain), ' ', $text_length); $item->textplain = JString::substr(strip_tags($blog->text), 0, $pos); } $image_data = json_decode($blog->image); $item->postid = $blog->id; $item->title = $blog->title; $item->text = $blog->text; $item->textplain = $this->sanitize($item->textplain); $item->image = $blog->getImage(); $item->image->url = $image_data->url; $item->created_date = $blog->created; $item->created_date_elapsed = EasyBlogDateHelper::getLapsedTime($blog->created); $item->author->name = $profile->nickname; $item->author->photo = JURI::root() . $profile->avatar; $item->category->categoryid = $category->id; $item->category->title = $category->title; $item->url = JURI::root() . trim(EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $blog->id), '/'); // Tags $modelPT = EasyBlogHelper::getModel('PostTag'); $item->tags = $modelPT->getBlogTags($blog->id); foreach ($skip as $v) { unset($item->{$v}); } return $item; }
function display($tmpl = null) { $config = EasyBlogHelper::getConfig(); $jConfig = EasyBlogHelper::getJConfig(); if (!$config->get('main_rss')) { return; } $mainframe = JFactory::getApplication(); $menuParams = $mainframe->getParams(); $date = EasyBlogHelper::getDate(); $sort = 'latest'; $model = $this->getModel('Archive'); $year = $model->getArchiveMinMaxYear(); $defaultYear = $menuParams->get('es_archieve_year', empty($year['maxyear']) ? $date->toFormat('%Y') : $year['maxyear']); $defaultMonth = $menuParams->get('es_archieve_month', $date->toFormat('%m')); $archiveYear = JRequest::getVar('archiveyear', $defaultYear, 'REQUEST'); $archiveMonth = JRequest::getVar('archivemonth', $defaultMonth, 'REQUEST'); $data = EasyBlogHelper::formatBlog($model->getArchive($archiveYear, $archiveMonth)); $pagination = $model->getPagination(); $params = $mainframe->getParams('com_easyblog'); $limitstart = JRequest::getVar('limitstart', 0, '', 'int'); $document = JFactory::getDocument(); $viewDate = EasyBlogHelper::getDate($archiveYear . '-' . $archiveMonth . '-01'); $document->link = EasyBlogRouter::_('index.php?option=com_easyblog&view=archive'); $document->setTitle(JText::sprintf('COM_EASYBLOG_FEEDS_ARCHIVE_TITLE', $viewDate->toFormat('%B %Y'))); $document->setDescription(JText::sprintf('COM_EASYBLOG_FEEDS_ARCHIVE_DESC', $viewDate->toFormat('%B %Y'))); if (!empty($data)) { for ($i = 0; $i < count($data); $i++) { $row =& $data[$i]; $blog = EasyBlogHelper::getTable('Blog'); $blog->load($row->id); $profile = EasyBlogHelper::getTable('Profile', 'Table'); $profile->load($row->created_by); $created = EasyBlogDateHelper::dateWithOffSet($row->created); $formatDate = true; if (EasyBlogHelper::getJoomlaVersion() >= '1.6') { $langCode = EasyBlogStringHelper::getLangCode(); if ($langCode != 'en-GB' || $langCode != 'en-US') { $formatDate = false; } } //$row->created = ( $formatDate ) ? $created->toFormat( $config->get('layout_dateformat', '%A, %d %B %Y') ) : $created->toFormat(); $row->created = $created->toMySQL(); if ($config->get('main_rss_content') == 'introtext') { $row->text = !empty($row->intro) ? $row->intro : $row->content; $row->text .= '<br /><a href=' . EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $row->id) . '>Read more</a>'; } else { $row->text = $row->intro . $row->content; } $row->text = EasyBlogHelper::getHelper('Videos')->strip($row->text); $row->text = EasyBlogGoogleAdsense::stripAdsenseCode($row->text); $image = ''; if ($blog->getImage()) { $image = '<img src="' . $blog->getImage()->getSource('frontpage') . '" />'; } $category = EasyBlogHelper::getTable('Category', 'Table'); $category->load($row->category_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 = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $row->id); $item->description = $image . $row->text; $item->date = $row->created; $item->category = $category->title; $item->author = $profile->getName(); if ($jConfig->get('feed_email') == 'author') { $item->authorEmail = $profile->user->email; } else { $item->authorEmail = $jConfig->get('mailfrom'); } $document->addItem($item); } } }
public static function processsAdsenseCode($content, $bloggerId) { if (empty($content)) { return $content; } if (empty($bloggerId)) { return $content; } //$content = 'sdfaa sdfsaf asdfafasf'; //$content = $content . ' ' . $content; $pattern = '/\\{eblogads.*\\}/i'; preg_match_all($pattern, $content, $matches); $adscode = $matches[0]; if (count($adscode) > 0) { foreach ($adscode as $code) { $codes = explode(' ', $code); $alignment = isset($codes[1]) ? $codes[1] : ''; $alignment = str_ireplace('}', '', $alignment); $html = EasyBlogGoogleAdsense::_getAdsenseTemplate($bloggerId, $alignment); $content = str_ireplace($code, $html, $content); } } return $content; }
public static function addJomSocialActivityBlog($blog, $isNew, $isFeed = false) { $jsCoreFile = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'core.php'; $config = EasyBlogHelper::getConfig(); $lang = JFactory::getLanguage(); $lang->load('com_easyblog', JPATH_ROOT); // We do not want to add activities if new blog activity is disabled. if ($isFeed) { if ($isNew && !$config->get('integrations_jomsocial_rss_import_activity')) { return false; } } else { if ($isNew && !$config->get('integrations_jomsocial_blog_new_activity')) { return false; } } // We do not want to add activities if update blog activity is disabled. if (!$isNew && !$config->get('integrations_jomsocial_blog_update_activity')) { return false; } if (JFile::exists($jsCoreFile)) { require_once $jsCoreFile; $blogCommand = $isNew ? 'easyblog.blog.add' : 'easyblog.blog.update'; $blogTitle = htmlspecialchars($blog->title); $maxTitleLength = $config->get('jomsocial_blog_title_length', 80); if (JString::strlen($blogTitle) > $maxTitleLength) { $blogTitle = JString::substr($blog->title, 0, $maxTitleLength) . '...'; } $category = EasyBlogHelper::getTable('Category', 'Table'); $category->load($blog->category_id); $easyBlogItemid = ''; $mainframe = JFactory::getApplication(); $blogLink = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $blog->id . $easyBlogItemid, false, true); $categoryLink = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=categories&layout=listings&id=' . $category->id . $easyBlogItemid, false, true); // If blog post is being posted from the back end and SH404 is installed, we should just use the raw urls. $sh404exists = EasyBlogRouter::isSh404Enabled(); if ($mainframe->isAdmin() && $sh404exists) { $easyBlogItemid = EasyBlogRouter::getItemId('latest'); $easyBlogItemid = '&Itemid=' . $easyBlogItemid; $blogLink = rtrim(JURI::root(), '/') . '/index.php?option=com_easyblog&view=entry&id=' . $blog->id . $easyBlogItemid; $categoryLink = rtrim(JURI::root(), '/') . '/index.php?option=com_easyblog&view=categories&layout=listings&id=' . $category->id . $easyBlogItemid; } $blogContent = ''; if ($config->get('integrations_jomsocial_submit_content')) { $requireVerification = false; if ($config->get('main_password_protect', true) && !empty($blog->blogpassword)) { $row->title = JText::sprintf('COM_EASYBLOG_PASSWORD_PROTECTED_BLOG_TITLE', $blog->title); $requireVerification = true; } $blogContent = ''; if ($requireVerification && !EasyBlogHelper::verifyBlogPassword($blog->blogpassword, $blog->id)) { $theme = new CodeThemes(); $theme->set('id', $blog->id); $theme->set('return', base64_encode($blogLink)); $blogContent = $theme->fetch('blog.protected.php'); } else { $blogContent = $blog->intro . $blog->content; // Get blog's image and use it as the cover photo. $image = ''; if ($blog->getImage()) { $imageSource = $blog->getImage()->getSource('frontpage'); if ($imageSource) { $image = '<a href="' . $blogLink . '"><img src="' . $imageSource . '" style="margin: 0 5px 5px 0;float: left; height: auto; width: 120px !important;"/></a>'; } } else { // Try to find for an image in the content. $pattern = '#<img[^>]*>#i'; preg_match($pattern, $blogContent, $matches); if ($matches) { $matches[0] = JString::str_ireplace('img ', 'img style="margin: 0 5px 5px 0;float: left; height: auto; width: 120px !important;"', $matches[0]); $image = '<a href="' . $blogLink . '">' . $matches[0] . '</a>'; } } // Strip unwanted data. $blogContent = EasyBlogHelper::getHelper('Videos')->strip($blogContent); $blogContent = EasyBlogGoogleAdsense::stripAdsenseCode($blogContent); $blogContent = JString::substr($blogContent, 0, $config->get('integrations_jomsocial_blogs_length', 250)) . ' ...'; // Remove all html tags from the content as we want to chop it down. $blogContent = strip_tags($blogContent); if (!empty($image)) { $blogContent = $image . $blogContent . '<div style="clear: both;"></div>'; } $blogContent .= '<div style="text-align: right;"><a href="' . $blogLink . '">' . JText::_('COM_EASYBLOG_CONTINUE_READING') . '</a></div>'; } } $title = $isNew ? JText::sprintf('COM_EASYBLOG_JS_ACTIVITY_BLOG_ADDED_NON_CATEGORY', $blogLink, $blogTitle) : JText::sprintf('COM_EASYBLOG_JS_ACTIVITY_BLOG_UPDATED_NON_CATEGORY', $blogLink, $blogTitle); if ($config->get('integrations_jomsocial_show_category')) { $title = $isNew ? JText::sprintf('COM_EASYBLOG_JS_ACTIVITY_BLOG_ADDED', $blogLink, $blogTitle, $categoryLink, JText::_($category->title)) : JText::sprintf('COM_EASYBLOG_JS_ACTIVITY_BLOG_UPDATED', $blogLink, $blogTitle, $categoryLink, JText::_($category->title)); } $obj = new stdClass(); $obj->access = $blog->private; $obj->title = $title; $obj->content = $blogContent; $obj->cmd = $blogCommand; if ($config->get('integrations_jomsocial_activity_likes')) { $obj->like_id = $blog->id; $obj->like_type = 'com_easyblog'; if (!$isNew) { $obj->comment_type = 'com_easyblog.update'; } } if ($config->get('integrations_jomsocial_activity_comments')) { $obj->comment_id = $blog->id; $obj->comment_type = 'com_easyblog'; if (!$isNew) { $obj->comment_type = 'com_easyblog.update'; } } $obj->actor = $blog->created_by; $obj->target = 0; $obj->app = 'easyblog'; $obj->cid = $blog->id; // add JomSocial activities CFactory::load('libraries', 'activities'); CActivityStream::add($obj); } }
/** * Shares a new content on Facebook **/ public function share($blog, $message = '', $oauth, $useSystem = false) { $config = EasyBlogHelper::getConfig(); $source = $config->get('integrations_facebook_source'); $content = isset($blog->{$source}) && !empty($blog->{$source}) ? $blog->{$source} : $blog->intro . $blog->content; $content = EasyBlogHelper::getHelper('Videos')->strip($content); $image = ''; // @rule: Ensure that only public posts are allowed if ($blog->private != 0) { return false; } // @rule: Try to get the blog image. if ($blog->getImage()) { $image = $blog->getImage()->getSource('frontpage'); } if (empty($image)) { // @rule: Match images from blog post $pattern = '/<\\s*img [^\\>]*src\\s*=\\s*[\\""\']?([^\\""\'\\s>]*)/i'; preg_match($pattern, $content, $matches); $image = ''; if ($matches) { $image = isset($matches[1]) ? $matches[1] : ''; if (JString::stristr($matches[1], 'https://') === false && JString::stristr($matches[1], 'http://') === false && !empty($image)) { $image = rtrim(JURI::root(), '/') . '/' . ltrim($image, '/'); } } } $maxContentLen = $config->get('integrations_facebook_blogs_length'); $text = strip_tags($content); if (!empty($maxContentLen)) { $text = JString::strlen($text) > $maxContentLen ? JString::substr($text, 0, $maxContentLen) . '...' : $text; } $url = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $blog->id, false, true); // If blog post is being posted from the back end and SH404 is installed, we should just use the raw urls. $sh404exists = EasyBlogRouter::isSh404Enabled(); $mainframe = JFactory::getApplication(); if ($mainframe->isAdmin() && $sh404exists) { $url = rtrim(JURI::root(), '/') . '/index.php?option=com_easyblog&view=entry&id=' . $blog->id; } preg_match('/expires=(.*)/i', $this->_access_token, $expires); if (isset($expires[1])) { $this->_access_token = str_ireplace('&expires=' . $expires[1], '', $this->_access_token); } // Remove adsense codes require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'adsense.php'; $text = EasyBlogGoogleAdsense::stripAdsenseCode($text); $jConfig = EasyBlogHelper::getJConfig(); $params = array('link' => $url, 'name' => $blog->title, 'description' => $text, 'message' => $blog->title, 'access_token' => $this->_access_token); if (empty($image)) { $params['picture'] = rtrim(JURI::root(), '/') . '/components/com_easyblog/assets/images/default_facebook.png'; $params['source'] = rtrim(JURI::root(), '/') . '/components/com_easyblog/assets/images/default_facebook.png'; } else { $params['picture'] = $image; $params['source'] = $image; } // @rule: For system messages, we need to see if there's any pages associated. if ($oauth->system && $useSystem) { if ($config->get('integrations_facebook_impersonate_page') || $config->get('integrations_facebook_impersonate_group')) { if ($config->get('integrations_facebook_impersonate_page')) { $pages = JString::trim($config->get('integrations_facebook_page_id')); $pages = explode(',', $pages); $total = count($pages); // @rule: Test if there are any pages at all the user can access $accounts = parent::api('/me/accounts', array('access_token' => $this->_access_token)); if (is_array($accounts) && isset($accounts['data'])) { for ($i = 0; $i < $total; $i++) { foreach ($accounts['data'] as $page) { if ($page['id'] == $pages[$i]) { $params['access_token'] = $page['access_token']; $query = parent::api('/' . $page['id'] . '/feed', 'post', $params); } } } } } if ($config->get('integrations_facebook_impersonate_group')) { $groupsId = JString::trim($config->get('integrations_facebook_group_id')); $groupsId = explode(',', $groupsId); $total = count($groupsId); // @rule: Test if there are any groups at all the user can access $accounts = parent::api('/me/groups', 'GET', array('access_token' => $this->_access_token)); $params['access_token'] = $this->_access_token; if (is_array($accounts) && isset($accounts['data'])) { for ($i = 0; $i < $total; $i++) { foreach ($accounts['data'] as $group) { if ($group['id'] == $groupsId[$i]) { $query = parent::api('/' . $group['id'] . '/feed', 'post', $params); } } } } } } else { // @rule: If this is just a normal posting, just post it on their page. $query = parent::api('/me/feed', 'post', $params); } } else { // @rule: If this is just a normal posting, just post it on their page. $query = parent::api('/me/feed', 'post', $params); } $success = isset($query['id']) ? true : false; return $success; }
function preview() { JPluginHelper::importPlugin('easyblog'); $dispatcher = JDispatcher::getInstance(); $mainframe = JFactory::getApplication(); $acl = EasyBlogACLHelper::getRuleSet(); $config = EasyBlogHelper::getConfig(); $document = JFactory::getDocument(); $my = JFactory::getUser(); $params = $mainframe->getParams('com_easyblog'); if (!EasyBlogHelper::isLoggedIn()) { EasyBlogHelper::showLogin(); return; } $draftId = JRequest::getVar('draftid', ''); $draft = EasyBlogHelper::getTable('Draft', 'Table'); $draft->load($draftId); $blog = EasyBlogHelper::getTable('Blog', 'Table'); $blog->bind($draft); $blogger = null; if ($blog->created_by != 0) { $blogger = EasyBlogHelper::getTable('Profile', 'Table'); $blogger->load($blog->created_by); } // @rule: Set the author object into the table. $blog->author = $blogger; $blog->blogger = $blogger; $blogId = empty($draft->entry_id) ? $draft->id : $draft->entry_id; $limitstart = '0'; $notice = ''; $team = ''; $blog->tags = empty($draft->tags) ? array() : $this->bindTags(explode(',', $draft->tags)); // metas $meta = new stdClass(); $meta->id = ''; $meta->keywords = $draft->metakey; $meta->description = $draft->metadesc; $pageTitle = EasyBlogHelper::getPageTitle($config->get('main_title')); $document->setTitle($blog->title . $pageTitle); // process the video here if nessary $blog->intro = EasyBlogHelper::getHelper('Videos')->processVideos($blog->intro); $blog->content = EasyBlogHelper::getHelper('Videos')->processVideos($blog->content); // @rule: Process audio files. $blog->intro = EasyBlogHelper::getHelper('Audio')->process($blog->intro); $blog->content = EasyBlogHelper::getHelper('Audio')->process($blog->content); // @rule: Before any trigger happens, try to replace the gallery first and append it at the bottom. $blog->intro = EasyBlogHelper::getHelper('Gallery')->process($blog->intro, $blog->created_by); $blog->content = EasyBlogHelper::getHelper('Gallery')->process($blog->content, $blog->created_by); // Process jomsocial album's. $blog->intro = EasyBlogHelper::getHelper('Album')->process($blog->intro, $blog->created_by); $blog->content = EasyBlogHelper::getHelper('Album')->process($blog->content, $blog->created_by); // @trigger: onEasyBlogPrepareContent EasyBlogHelper::triggerEvent('easyblog.prepareContent', $blog, $params, $limitstart); //onPrepareContent trigger start $blog->introtext = $blog->intro; $blog->text = $blog->intro . $blog->content; // @trigger: onEasyBlogPrepareContent EasyBlogHelper::triggerEvent('prepareContent', $blog, $params, $limitstart); $blog->intro = $blog->introtext; $blog->content = $blog->text; $isFeatured = false; //page setup $blogHtml = ''; $commentHtml = ''; $blogHeader = ''; $blogFooter = ''; $adsenseHtml = ''; $trackbackHtml = ''; $blogger = null; if ($blog->created_by != 0) { $blogger = EasyBlogHelper::getTable('Profile', 'Table'); $blogger->load($blog->created_by); } //onAfterDisplayTitle, onBeforeDisplayContent, onAfterDisplayContent trigger start $blog->event = new stdClass(); // @trigger: onAfterDisplayTitle / onContentAfterTitle $results = EasyBlogHelper::triggerEvent('afterDisplayTitle', $blog, $params, $limitstart); $blog->event->afterDisplayTitle = JString::trim(implode("\n", $results)); // @trigger: onBeforeDisplayContent / onContentBeforeDisplay $results = EasyBlogHelper::triggerEvent('beforeDisplayContent', $blog, $params, $limitstart); $blog->event->beforeDisplayContent = JString::trim(implode("\n", $results)); // @trigger: onAfterDisplayContent / onContentAfterDisplay EasyBlogHelper::triggerEvent('afterDisplayContent', $blog, $params, $limitstart); $blog->event->afterDisplayContent = JString::trim(implode("\n", $results)); if (!EasyBlogRouter::isCurrentActiveMenu('blogger', $blogger->id)) { $this->setPathway($blogger->getName(), $blogger->getLink()); } if (!EasyBlogRouter::isCurrentActiveMenu('entry', $blog->id)) { $this->setPathway($blog->title, ''); } $blog->totalComments = 0; // Facebook Like integrations require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'facebook.php'; $facebookLike = EasyBlogFacebookLikes::getLikeHTML($blog); $url = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $blog->id, false, true); //get blog navigation object $blogNav = EasyBlogHelper::getBlogNavigation($blog->id, $blog->created, $team, 'team'); //$team $prevLink = array(); if (!empty($blogNav['prev'])) { $prevLink['id'] = $blogNav['prev'][0]->id; $prevLink['title'] = JString::strlen($blogNav['prev'][0]->title) > 50 ? JString::substr($blogNav['prev'][0]->title, 0, 50) . '...' : $blogNav['prev'][0]->title; } $nextLink = array(); if (!empty($blogNav['next'])) { $nextLink['id'] = $blogNav['next'][0]->id; $nextLink['title'] = JString::strlen($blogNav['next'][0]->title) > 50 ? JString::substr($blogNav['next'][0]->title, 0, 50) . '...' : $blogNav['next'][0]->title; } // @rule: Hide introtext if necessary if ($config->get('main_hideintro_entryview')) { $blog->intro = ''; } //get social bookmark provider. require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'bookmark.php'; $bookmark = EasyBlogBookmark::getHTML(); $theme = new CodeThemes(); $theme->set('facebookLike', $facebookLike); $theme->set('notice', $notice); $theme->set('blog', $blog); $theme->set('tags', $blog->tags); $theme->set('blogger', $blogger); $theme->set('prevLink', $prevLink); $theme->set('nextLink', $nextLink); $theme->set('blogRelatedPost', ''); $theme->set('isFeatured', $isFeatured); $theme->set('isMineBlog', true); $theme->set('acl', $acl); $theme->set('url', $url); $theme->set('commentHTML', $commentHtml); $theme->set('bookmark', $bookmark); $theme->set('pdfLinkProperties', EasyBlogHelper::getPDFlinkProperties()); $theme->set('ispreview', true); // @task: trackbacks $trackbacks = ''; $theme->set('trackbackURL', EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=trackback&post_id=' . $blog->id, true, true)); $theme->set('trackbacks', $trackbacks); //google adsense require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'adsense.php'; $adsense = EasyBlogGoogleAdsense::getHTML($blogger->id); $blogHeader = $adsense->header; $blogFooter = $adsense->footer; $theme->set('adsenseHTML', $adsense->beforecomments); $blogHtml = $theme->fetch('blog.read.php'); echo $blogHeader; echo $blogHtml; echo $blogFooter; }
function display($tmpl = null) { $config = EasyBlogHelper::getConfig(); $jConfig = EasyBlogHelper::getJConfig(); if (!$config->get('main_rss')) { return; } $id = JRequest::getInt('id', 0); $blogger = EasyBlogHelper::getTable('Profile', 'Table'); $blogger->load($id); $model = $this->getModel('Blog'); $data = $model->getBlogsBy('blogger', $blogger->id); $document = JFactory::getDocument(); $document->link = EasyBlogRouter::_('index.php?option=com_easyblog&view=blogger&id=' . $id . '&layout=listings'); $document->setTitle(JText::sprintf('COM_EASYBLOG_FEEDS_BLOGGER_TITLE', $blogger->getName())); $document->setDescription(strip_tags($blogger->description)); if (!empty($data)) { $modelPT = $this->getModel('PostTag'); for ($i = 0; $i < count($data); $i++) { $row =& $data[$i]; $blog = EasyBlogHelper::getTable('Blog'); $blog->load($row->id); $profile = EasyBlogHelper::getTable('Profile', 'Table'); $user = JFactory::getUser($row->created_by); $profile->load($user->id); $created = EasyBlogHelper::getDate($row->created); $formatDate = true; if (EasyBlogHelper::getJoomlaVersion() >= '1.6') { $langCode = EasyBlogStringHelper::getLangCode(); if ($langCode != 'en-GB' || $langCode != 'en-US') { $formatDate = false; } } //$row->created = ( $formatDate ) ? $created->toFormat( $config->get('layout_dateformat', '%A, %d %B %Y') ) : $created->toFormat(); $row->created = $created->toMySQL(); if ($config->get('main_rss_content') == 'introtext') { $row->text = !empty($row->intro) ? $row->intro : $row->content; $row->text .= '<br /><a href=' . EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $row->id) . '>Read more</a>'; } else { $row->text = $row->intro . $row->content; } $row->text = EasyBlogHelper::getHelper('Videos')->strip($row->text); $row->text = EasyBlogGoogleAdsense::stripAdsenseCode($row->text); $image = ''; if ($blog->getImage()) { $image = '<img src="' . $blog->getImage()->getSource('frontpage') . '" />'; } $category = EasyBlogHelper::getTable('Category', 'Table'); $category->load($row->category_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 = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $row->id); $item->description = $image . $row->text; $item->date = $row->created; $item->category = $category->title; $item->author = $profile->getName(); if ($jConfig->get('feed_email') == 'author') { $item->authorEmail = $profile->user->email; } else { $item->authorEmail = $jConfig->get('mailfrom'); } $document->addItem($item); } } }
function display($tmpl = null) { $config = EasyBlogHelper::getConfig(); $jConfig = EasyBlogHelper::getJConfig(); if (!$config->get('main_rss')) { return; } 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'; $sort = JRequest::getCmd('sort', $config->get('layout_postorder')); $model = $this->getModel('Blog'); $data = $model->getBlogsBy('', '', $sort, 0, EBLOG_FILTER_PUBLISHED, null, true); $document = JFactory::getDocument(); $document->link = EasyBlogRouter::_('index.php?option=com_easyblog&view=latest'); $document->setTitle(JText::_('COM_EASYBLOG_FEEDS_LATEST_TITLE')); $document->setDescription(JText::sprintf('COM_EASYBLOG_FEEDS_LATEST_DESC', JURI::root())); if (!empty($data)) { $modelPT = $this->getModel('PostTag'); for ($i = 0; $i < count($data); $i++) { $row =& $data[$i]; $blog = EasyBlogHelper::getTable('Blog'); $blog->load($row->id); $user = JFactory::getUser($row->created_by); $profile = EasyBlogHelper::getTable('Profile', 'Table'); $profile->load($user->id); $created = EasyBlogDateHelper::dateWithOffSet($row->created); $formatDate = true; if (EasyBlogHelper::getJoomlaVersion() >= '1.6') { $langCode = EasyBlogStringHelper::getLangCode(); if ($langCode != 'en-GB' || $langCode != 'en-US') { $formatDate = false; } } //$row->created = ( $formatDate ) ? $created->toFormat( $config->get('layout_dateformat', '%A, %d %B %Y') ) : $created->toFormat(); $row->created = $created->toMySQL(); if ($config->get('main_rss_content') == 'introtext') { $row->text = !empty($row->intro) ? $row->intro : $row->content; $row->text .= '<br /><a href=' . EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $row->id) . '>' . JText::_('COM_EASYBLOG_READ_MORE') . '</a>'; } else { $row->text = $row->intro . $row->content; //add read more in feed } $row->text = EasyBlogHelper::getHelper('Videos')->strip($row->text); $row->text = EasyBlogGoogleAdsense::stripAdsenseCode($row->text); $category = EasyBlogHelper::getTable('Category', 'Table'); $category->load($row->category_id); // Assign to feed item $title = $this->escape($row->title); $title = html_entity_decode($title); $image = ''; if ($blog->getImage()) { $image = '<img src="' . $blog->getImage()->getSource('frontpage') . '" />'; } // load individual item creator class $item = new JFeedItem(); $item->title = $title; $item->link = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $row->id); $item->description = $image . $row->text; $item->date = $row->created; $item->category = $category->title; $item->author = $profile->getName(); if ($jConfig->get('feed_email') != 'none') { if ($jConfig->get('feed_email') == 'author') { $item->authorEmail = $user->email; } else { $item->authorEmail = $jConfig->get('mailfrom'); } } $document->addItem($item); } } }
// @rule: Process videos $row->intro = EasyBlogHelper::getHelper('Videos')->strip($row->intro); $row->content = EasyBlogHelper::getHelper('Videos')->strip($row->content); // @rule: Remove gallery codes $row->intro = EasyBlogHelper::getHelper('Gallery')->strip($row->intro); $row->content = EasyBlogHelper::getHelper('Gallery')->strip($row->content); // Process jomsocial albums $row->intro = EasyBlogHelper::getHelper('Album')->strip($row->intro); $row->content = EasyBlogHelper::getHelper('Album')->strip($row->content); //remove zemanta tags $row->intro = EasyBlogHelper::removeZemantaTags($row->intro); $row->content = EasyBlogHelper::removeZemantaTags($row->content); // Remove adsense codes require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'adsense.php'; $row->intro = EasyBlogGoogleAdsense::stripAdsenseCode($row->intro); $row->content = EasyBlogGoogleAdsense::stripAdsenseCode($row->content); JTable::addIncludePath(EBLOG_TABLES); $author = EasyBlogHelper::getTable('Profile', 'Table'); $author->load($row->created_by); $row->author = $author; $row->date = EasyBlogDateHelper::toFormat(EasyBlogHelper::getDate($row->created), $config->get('layout_dateformat', '%A, %d %B %Y')); $items[] = $row; } // If needed, shuffle the entries if ($params->get('autoshuffle')) { shuffle($items); } // Should we display the ratings. $disabled = $params->get('enableratings') ? false : true; $contentKey = $params->get('contentfrom', 'content'); require JModuleHelper::getLayoutPath('mod_showcase');
function display($tmpl = null) { $config = EasyBlogHelper::getConfig(); $jConfig = EasyBlogHelper::getJConfig(); if (!$config->get('main_rss')) { return; } $id = JRequest::getCmd('id', '0'); $category = EasyBlogHelper::getTable('Category', 'Table'); $category->load($id); // private category shouldn't allow to access. $privacy = $category->checkPrivacy(); if (!$privacy->allowed) { return; } if ($category->id == 0) { $category->title = JText::_('COM_EASYBLOG_UNCATEGORIZED'); } //get the nested categories $category->childs = null; EasyBlogHelper::buildNestedCategories($category->id, $category); $linkage = ''; EasyBlogHelper::accessNestedCategories($category, $linkage, '0', '', 'link', ', '); $catIds = array(); $catIds[] = $category->id; EasyBlogHelper::accessNestedCategoriesId($category, $catIds); $category->nestedLink = $linkage; $model = $this->getModel('Blog'); $sort = JRequest::getCmd('sort', $config->get('layout_postorder')); $data = $model->getBlogsBy('category', $catIds, $sort); $document = JFactory::getDocument(); $document->link = EasyBlogRouter::_('index.php?option=com_easyblog&view=categories&id=' . $id . '&layout=listings'); $document->setTitle($this->escape($category->title)); $document->setDescription(JText::sprintf('COM_EASYBLOG_FEEDS_CATEGORY_DESC', $this->escape($category->title))); if (empty($data)) { return; } for ($i = 0; $i < count($data); $i++) { $row =& $data[$i]; $blog = EasyBlogHelper::getTable('Blog'); $blog->load($row->id); $user = JFactory::getUser($row->created_by); $profile = EasyBlogHelper::getTable('Profile', 'Table'); $profile->load($user->id); $created = EasyBlogHelper::getDate($row->created); $formatDate = true; if (EasyBlogHelper::getJoomlaVersion() >= '1.6') { $langCode = EasyBlogStringHelper::getLangCode(); if ($langCode != 'en-GB' || $langCode != 'en-US') { $formatDate = false; } } //$row->created = ( $formatDate ) ? $created->toFormat( $config->get('layout_dateformat', '%A, %d %B %Y') ) : $created->toFormat(); $row->created = $created->toMySQL(); if ($config->get('main_rss_content') == 'introtext') { $row->text = !empty($row->intro) ? $row->intro : $row->content; } else { $row->text = $row->intro . $row->content; } $row->text = EasyBlogHelper::getHelper('Videos')->strip($row->text); $row->text = EasyBlogGoogleAdsense::stripAdsenseCode($row->text); $image = ''; if ($blog->getImage()) { $image = '<img src="' . $blog->getImage()->getSource('frontpage') . '" />'; } // load individual item creator class $item = new JFeedItem(); $item->title = html_entity_decode($this->escape($row->title)); $item->link = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $row->id); $item->description = $image . $row->text; $item->date = $row->created; $item->category = $category->title; $item->author = $profile->getName(); if ($jConfig->get('feed_email') == 'author') { $item->authorEmail = $profile->user->email; } else { $item->authorEmail = $jConfig->get('mailfrom'); } $document->addItem($item); } }
private function addStreamJomsocial($blog, $isNew, $key, $source) { $jsCoreFile = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'core.php'; $config = EasyBlogHelper::getConfig(); // Somehow the blog contribution is in an array. $key = $key[0]; JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT); if (!JFile::exists($jsCoreFile)) { return false; } require_once $jsCoreFile; $app = JFactory::getApplication(); $title = JString::substr($blog->title, 0, 30) . '...'; $easyBlogItemid = ''; if ($app->isAdmin()) { $easyBlogItemid = EasyBlogRouter::getItemId('latest'); $easyBlogItemid = '&Itemid=' . $easyBlogItemid; } $blogLink = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $blog->id . $easyBlogItemid, false, true); $my = JFactory::getUser(); $blogContent = $blog->intro . $blog->content; // Get blog's image and use it as the cover photo. $image = ''; if ($blog->getImage()) { $imageSource = $blog->getImage()->getSource('frontpage'); if ($imageSource) { $image = '<a href="' . $blogLink . '"><img src="' . $imageSource . '" style="margin: 0 5px 5px 0;float: left; height: auto; width: 120px !important;"/></a>'; } } else { // Try to find for an image in the content. $pattern = '#<img[^>]*>#i'; preg_match($pattern, $blogContent, $matches); if ($matches) { $matches[0] = JString::str_ireplace('img ', 'img style="margin: 0 5px 5px 0;float: left; height: auto; width: 120px !important;"', $matches[0]); $image = '<a href="' . $blogLink . '">' . $matches[0] . '</a>'; } } // Strip unwanted data. $blogContent = EasyBlogHelper::getHelper('Videos')->strip($blogContent); $blogContent = EasyBlogGoogleAdsense::stripAdsenseCode($blogContent); $blogContent = JString::substr($blogContent, 0, $config->get('integrations_jomsocial_blogs_length', 250)) . ' ...'; // Remove all html tags from the content as we want to chop it down. $blogContent = strip_tags($blogContent); if (!empty($image)) { $blogContent = $image . $blogContent . '<div style="clear: both;"></div>'; } $blogContent .= '<div style="text-align: right;"><a href="' . $blogLink . '">' . JText::_('COM_EASYBLOG_CONTINUE_READING') . '</a></div>'; $groupLink = CRoute::_('index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $key); JTable::addIncludePath(JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_community' . DIRECTORY_SEPARATOR . 'tables'); $group = JTable::getInstance('Group', 'CTable'); $group->load($key); $title = JText::sprintf('COM_EASYBLOG_JS_ACTIVITY_GROUP_BLOG_ADDED', $blogLink, $title, $groupLink, $group->name); $obj = new stdClass(); $obj->title = $title; $obj->content = $blogContent; $obj->cmd = 'group.blog.added'; if ($config->get('integrations_jomsocial_activity_likes')) { $obj->like_id = $blog->id; $obj->like_type = 'com_easyblog'; } if ($config->get('integrations_jomsocial_activity_comments')) { $obj->comment_id = $blog->id; $obj->comment_type = 'com_easyblog'; } $obj->group_access = $group->approvals; $obj->actor = $my->id; $obj->target = $key; $obj->app = 'easyblog'; $obj->cid = $key; $obj->groupid = $key; // add JomSocial activities CFactory::load('libraries', 'activities'); CActivityStream::add($obj); }