Exemplo n.º 1
0
 public static function addCard(&$blog, $rawIntroText)
 {
     $cfg = EasyBlogHelper::getConfig();
     // @rule: Check if user really wants to append the opengraph tags on the headers.
     if (!$cfg->get('main_twitter_cards')) {
         return false;
     }
     // Get the absolute permalink for this blog item.
     $url = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $blog->id, false, true);
     // Get the image of the blog post.
     $image = self::getImage($blog, $rawIntroText);
     // @task: Get Joomla's document object.
     $doc = JFactory::getDocument();
     // Add card definition.
     $doc->addCustomTag('<meta property="twitter:card" content="summary" />');
     $doc->addCustomTag('<meta property="twitter:url" content="' . $url . '" />');
     $doc->addCustomTag('<meta property="twitter:title" content="' . $blog->title . '" />');
     $text = EasyBlogHelper::stripEmbedTags($rawIntroText);
     $text = strip_tags($text);
     $text = str_ireplace("\r\n", "", $text);
     // Remove any " in the content as this would mess up the headers.
     $text = str_ireplace('"', '', $text);
     $maxLength = 137;
     if (!empty($maxLength)) {
         $text = JString::strlen($text) > $maxLength ? JString::substr($text, 0, $maxLength) . '...' : $text;
     }
     $text = EasyBlogStringHelper::escape($text);
     $doc->addCustomTag('<meta property="twitter:description" content="' . $text . '" />');
     if ($image) {
         $doc->addCustomTag('<meta property="twitter:image" content="' . $image . '"/> ');
     }
     return true;
 }
Exemplo n.º 2
0
 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);
         }
     }
 }
Exemplo n.º 3
0
 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;
 }
Exemplo n.º 4
0
 function getName()
 {
     if ($this->id == 0) {
         return JText::_('COM_EASYBLOG_GUEST');
     }
     $config = EasyBlogHelper::getConfig();
     $displayname = $config->get('layout_nameformat');
     if (!$this->user) {
         $this->user = JFactory::getUser($this->id);
     }
     switch ($displayname) {
         case "name":
             $name = $this->user->name;
             break;
         case "username":
             $name = $this->user->username;
             break;
         case "nickname":
         default:
             $name = empty($this->nickname) ? $this->user->name : $this->nickname;
             break;
     }
     return EasyBlogStringHelper::escape($name);
 }
Exemplo n.º 5
0
    public function googleone()
    {
        $config = EasyBlogHelper::getConfig();
        $document = JFactory::getDocument();
        $frontpage = $this->isFrontend;
        $pos = $this->position;
        $googleone = !$frontpage && $config->get('main_googleone') || $frontpage && $config->get('main_googleone_frontpage', $config->get('social_show_frontpage')) && $config->get('main_googleone');
        $socialFrontEnd = $config->get('main_googleone_frontpage', 0);
        $html = '';
        if ($googleone) {
            $size = $config->get('main_googleone_layout');
            $dataURL = $this->_getDataURL();
            $dataTitle = $this->_getDataTitle();
            $buttonSize = 'social-button-';
            switch ($size) {
                case 'tall':
                    $buttonSize .= 'large';
                    break;
                case 'medium':
                default:
                    $buttonSize .= 'small';
                    break;
            }
            // Add snippet info into headers
            $document = JFactory::getDocument();
            $meta = EasyBlogHelper::getTable('Meta', 'Table');
            $meta->loadByType(META_TYPE_POST, $this->blog->id);
            $document->addCustomTag('<meta itemprop="name" content="' . $this->blog->title . '" />');
            if (!empty($meta->description)) {
                $meta->description = EasyBlogStringHelper::escape($meta->description);
                // Remove JFBConnect codes.
                $pattern = '/\\{JFBCLike(.*)\\}/i';
                $meta->description = preg_replace($pattern, '', $meta->description);
                $document->addCustomTag('<meta itemprop="description" content="' . $meta->description . '" />');
            } else {
                $maxContentLen = 350;
                $text = strip_tags($this->blog->intro . $this->blog->content);
                $text = JString::strlen($text) > $maxContentLen ? JString::substr($text, 0, $maxContentLen) . '...' : $text;
                // Remove JFBConnect codes.
                $pattern = '/\\{JFBCLike(.*)\\}/i';
                $text = preg_replace($pattern, '', $text);
                $text = EasyBlogStringHelper::escape($text);
                $document->addCustomTag('<meta itemprop="description" content="' . $text . '" />');
            }
            $image = EasyBlogHelper::getFirstImage($this->blog->intro . $this->blog->content);
            if ($image !== false) {
                $document->addCustomTag('<meta itemprop="image" content="' . $image . '" />');
            }
            $placeholder = 'sb-' . rand();
            $html .= '<div class="social-button ' . $buttonSize . ' google-plusone"><span id="' . $placeholder . '"></span></div>';
            // TODO: Verify $socialFrontEnd, what is it used for.
            // if( ! $socialFrontEnd )
            // $googleHTML	.= '<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>';
            // $googleHTML	.= '<g:plusone size="' . $size . '" href="' . $dataURL . '"></g:plusone>';
            if ($this->isBottom) {
                $html = '<div class="socialbutton-vertical align' . $pos . '">' . $html . '</div>';
            }
            $html .= EasyBlogHelper::addScriptDeclarationBookmarklet('$("#' . $placeholder . '").bookmarklet("googlePlusOne", {
				href: "' . $dataURL . '",
				size: "' . $size . '"
			});');
        }
        return $html;
    }
Exemplo n.º 6
0
 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);
         }
     }
 }
Exemplo n.º 7
0
 public static function setMeta($id, $type, $defaultViewDesc = '')
 {
     $config = EasyBlogHelper::getConfig();
     $db = EasyBlogHelper::db();
     $query = 'SELECT id, keywords, description, indexing FROM ' . $db->nameQuote('#__easyblog_meta') . ' WHERE content_id = ' . $db->Quote($id) . ' and type = ' . $db->Quote($type);
     $db->setQuery($query);
     $result = $db->loadObject();
     if (!$result) {
         $result = new stdClass();
     }
     // If the category was created without any meta, we need to automatically fill in the description
     if ($type == META_TYPE_CATEGORY && !$result) {
         $category = EasyBlogHelper::getTable('Category');
         $category->load($id);
         JFactory::getDocument()->setMetadata('description', strip_tags($category->description));
     }
     //auto fill meta keywords if the option is enable and the user did not set his own meta keywords.
     if ($type == META_TYPE_POST && ($config->get('main_meta_autofillkeywords') && empty($result->keywords) || $config->get('main_meta_autofilldescription'))) {
         $keywords = array();
         //set category into the meta keyword.
         $post = EasyBlogHelper::getTable('Blog', 'Table');
         $post->load($id);
         $post->intro = EasyBlogHelper::getHelper('Videos')->processVideos($post->intro, true);
         $post->content = EasyBlogHelper::getHelper('Videos')->processVideos($post->content, true);
         $category = EasyBlogHelper::getTable('Category', 'Table');
         $category->load($post->category_id);
         $keywords[] = $category->title;
         if ($config->get('main_meta_autofillkeywords') && empty($result->keywords)) {
             //set tags into the meta keyword.
             $modelPT = self::getModel('PostTag');
             $blogTags = $modelPT->getBlogTags($id);
             if (!empty($blogTags)) {
                 foreach ($blogTags as $tag) {
                     $keywords[] = $tag->title;
                 }
             }
             $result->keywords = implode(',', $keywords);
         }
         if ($config->get('main_meta_autofilldescription') && empty($result->description)) {
             $content = !empty($post->intro) ? strip_tags($post->intro) : strip_tags($post->content);
             $content = str_ireplace("\r\n", "", $content);
             $content = str_ireplace("&nbsp;", " ", $content);
             $content = trim($content);
             // @rule: Set description into meta headers
             $result->description = JString::substr($content, 0, $config->get('main_meta_autofilldescription_length'));
             $result->description = EasyBlogStringHelper::escape($result->description);
         }
         // Remove JFBConnect codes.
         if (isset($result->description)) {
             $pattern = '/\\{JFBCLike(.*)\\}/i';
             $result->description = preg_replace($pattern, '', $result->description);
         }
     }
     // check if the descriptin or keysword still empty or not. if yes, try to get from joomla menu.
     if (empty($result->description) && empty($result->keywords)) {
         $menu = JFactory::getApplication()->getMenu();
         $item = $menu->getActive();
         if (is_object($item)) {
             $params = EasyBlogHelper::getRegistry($item->params);
             $description = $params->get('menu-meta_description', '');
             $keywords = $params->get('menu-meta_keywords', '');
             if (!(empty($description) && empty($keywords))) {
                 $result = new stdClass();
                 $result->description = EasyBlogStringHelper::escape($description);
                 $result->keywords = $keywords;
             }
         }
     }
     if (!empty($result)) {
         $document = JFactory::getDocument();
         if (!empty($result->keywords)) {
             $document->setMetadata('keywords', $result->keywords);
         }
         if (!empty($result->description)) {
             $document->setMetadata('description', $result->description);
         } else {
             if (!empty($defaultViewDesc)) {
                 //get joomla default description.
                 $joomlaDesc = EasyBlogHelper::getJConfig()->get('MetaDesc');
                 $metaDesc = $defaultViewDesc . ' - ' . $joomlaDesc;
                 $metaDesc = EasyBlogStringHelper::escape($metaDesc);
                 $document->setMetadata('description', $metaDesc);
             }
         }
         // @task: Set the noindex if necessary.
         if (isset($result->indexing) && !$result->indexing) {
             $document->setMetadata('robots', 'noindex,follow');
         }
     }
 }
Exemplo n.º 8
0
 public function migrateK2($params, $migrateComments = false)
 {
     if (!is_array($params)) {
         $data = array('k2category' => $params);
     } else {
         $data = EasyBlogStringHelper::ejaxPostToArray($params);
     }
     $db = EasyBlogHelper::db();
     $jSession = JFactory::getSession();
     $ejax = new EJax();
     if (isset($data['migrate_k2_comments'])) {
         $migrateComments = true;
     }
     $migrateStat = $jSession->get('EBLOG_MIGRATOR_JOOMLA_STAT', '', 'EASYBLOG');
     if (empty($migrateStat)) {
         $migrateStat = new stdClass();
         $migrateStat->blog = 0;
         $migrateStat->category = 0;
         $migrateStat->user = array();
     }
     $k2Category = $data['k2category'];
     $query = 'SELECT * FROM `#__k2_items` AS a';
     $query .= ' WHERE NOT EXISTS (';
     $query .= ' SELECT content_id FROM `#__easyblog_migrate_content` AS b WHERE b.`content_id` = a.`id` and `component` = ' . $db->Quote('com_k2');
     $query .= ' )';
     $query .= ' AND a.`catid` = ' . $db->Quote($k2Category);
     $query .= ' ORDER BY a.`id` LIMIT 1';
     $db->setQuery($query);
     $row = $db->loadObject();
     if (is_null($row)) {
         //at here, we check whether there are any records processed. if yes,
         //show the statistic.
         $ejax->append('progress-status-k2', JText::_('COM_EASYBLOG_MIGRATOR_FINISHED'));
         $ejax->script("scrollToBottomK2();");
         //update statistic
         $stat = '========================================== <br />';
         $state .= JText::_('COM_EASYBLOG_MIGRATOR_TOTAL_BLOGS') . ' : ' . $migrateStat->blog . '<br />';
         $statUser = $migrateStat->user;
         if (!empty($statUser)) {
             $stat .= '<br />';
             $state .= JText::_('COM_EASYBLOG_MIGRATOR_TOTAL_USER_CONTRIBUTIONS') . ' : ' . count($statUser) . '<br />';
             foreach ($statUser as $eachUser) {
                 $state .= JText::_('COM_EASYBLOG_MIGRATOR_TOTAL_BLOG_USER' . ' \'', $eachUser->name) . ' : ' . $eachUser->blogcount . '<br />';
             }
         }
         $stat .= '<br />==========================================';
         $ejax->assign('stat-status-k2', $stat);
         $ejax->script("\$( '#migrator-submit-k2' ).html('" . JText::_('COM_EASYBLOG_MIGRATOR_MIGRATION_COMPLETE') . "');");
         $ejax->script("\$( '#migrator-submit-k2' ).attr('disabled' , '');");
         $ejax->script("\$( '#icon-wait-k2' ).css( 'display' , 'none' );");
     } else {
         // here we should process the migration
         // step 1 : create categery if not exist in eblog_categories
         // step 2 : create user if not exists in eblog_users - create user through profile jtable load method.
         $date = EB::date();
         $blogObj = new stdClass();
         //default
         $blogObj->category_id = 1;
         //assume 1 is the uncategorized id.
         if (!empty($row->catid)) {
             $joomlaCat = $this->_getK2Category($row->catid);
             $eCat = $this->_isEblogCategoryExists($joomlaCat);
             if ($eCat === false) {
                 $eCat = $this->_createEblogCategory($joomlaCat);
             }
             $blogObj->category_id = $eCat;
         }
         $profile = EB::user($row->created_by);
         $blog = EB::table('Blog');
         //assigning blog data
         $blogObj->created_by = $profile->id;
         $blogObj->created = !empty($row->created) ? $row->created : $date->toMySQL();
         $blogObj->modified = $date->toMySQL();
         $blogObj->title = $row->title;
         $blogObj->permalink = empty($row->alias) ? EasyBlogHelper::getPermalink($row->title) : $row->alias;
         if (empty($row->fulltext)) {
             $blogObj->intro = $row->introtext;
         } else {
             $blogObj->intro = $row->introtext;
             $blogObj->content = $row->fulltext;
         }
         //translating the article state into easyblog publish status.
         $blogState = '';
         // Since K2 does not have `state` column, we need to map it back.
         $row->state = $row->published;
         if (EasyBlogHelper::getJoomlaVersion() >= '1.6') {
             $blogState = $row->state == 2 || $row->state == -2 ? 0 : $row->state;
         } else {
             $blogState = $row->state == -1 ? 0 : $row->state;
         }
         $blogObj->published = $blogState;
         $blogObj->publish_up = !empty($row->publish_up) ? $row->publish_up : $date->toMySQL();
         $blogObj->publish_down = !empty($row->publish_down) ? $row->publish_down : $date->toMySQL();
         $blogObj->ordering = $row->ordering;
         $blogObj->hits = $row->hits;
         $blogObj->frontpage = 1;
         $blog->bind($blogObj);
         $this->_migrateK2Videos($row, $blog, $profile);
         // Migrate K2 Images
         $this->_migrateK2Images($row, $blog, $profile);
         $blog->store();
         //migrate meta description
         $this->_migrateContentMeta($row->metakey, $row->metadesc, $blog->id);
         // Map K2 tags into EasyBlog tags
         $query = 'SELECT a.* FROM #__k2_tags AS a ' . 'INNER JOIN #__k2_tags_xref AS b ' . 'ON a.`id`=b.`tagID` ' . 'WHERE b.`itemID`=' . $db->Quote($row->id);
         $db->setQuery($query);
         $k2Tags = $db->loadObjectList();
         if ($k2Tags) {
             foreach ($k2Tags as $item) {
                 $now = EB::date();
                 $tag = EB::table('Tag');
                 if ($tag->exists($item->name)) {
                     $tag->load($item->name, true);
                 } else {
                     // Create tag if necessary
                     $tagArr = array();
                     $tagArr['created_by'] = $this->_getSAUserId();
                     $tagArr['title'] = $item->name;
                     $tagArr['alias'] = $item->name;
                     $tagArr['published'] = '1';
                     $tagArr['created'] = $now->toMySQL();
                     $tag->bind($tagArr);
                     $tag->store();
                 }
                 $postTag = EB::table('PostTag');
                 $postTag->tag_id = $tag->id;
                 $postTag->post_id = $blog->id;
                 $postTag->created = $now->toMySQL();
                 $postTag->store();
             }
         }
         //update session value
         $migrateStat->blog++;
         $statUser = $migrateStat->user;
         $statUserObj = null;
         if (!isset($statUser[$profile->id])) {
             $statUserObj = new stdClass();
             $statUserObj->name = $profile->nickname;
             $statUserObj->blogcount = 0;
         } else {
             $statUserObj = $statUser[$profile->id];
         }
         $statUserObj->blogcount++;
         $statUser[$profile->id] = $statUserObj;
         $migrateStat->user = $statUser;
         $jSession->set('EBLOG_MIGRATOR_JOOMLA_STAT', $migrateStat, 'EASYBLOG');
         //log the entry into migrate table.
         $migrator = EB::table('Migrate');
         $migrator->content_id = $row->id;
         $migrator->post_id = $blog->id;
         $migrator->session_id = $jSession->getToken();
         $migrator->component = 'com_k2';
         $migrator->store();
         $ejax->script('$("#no-progress-k2").hide();');
         $ejax->append('progress-status-k2', JText::_('COM_EASYBLOG_MIGRATOR_MIGRATED_K2') . ': ' . $row->id . JText::_('COM_EASYBLOG_MIGRATOR_EASYBLOG') . ': ' . $blog->id . '<br />');
         if ($migrateComments) {
             $this->migrateK2Comments($row, $blog);
             $ejax->append('progress-status-k2', JText::_('COM_EASYBLOG_MIGRATOR_MIGRATED_K2_COMMENTS') . ': ' . $row->id . JText::_('COM_EASYBLOG_MIGRATOR_EASYBLOG_COMMENTS') . ': ' . $blog->id . '<br />');
             $return = array();
             $return['migrate_k2_comments'] = 1;
             $return['k2category'] = $k2Category;
             require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'json.php';
             $json = new Services_JSON();
             $return = $json->encode($return);
             $ejax->script("ejax.load('migrators','migrateK2','" . $k2Category . "' , '1');");
         } else {
             $ejax->script("ejax.load('migrators','migrateK2','" . $k2Category . "');");
         }
     }
     $ejax->send();
     exit;
 }
Exemplo n.º 9
0
 function import($feedObj, $maxItems = 0)
 {
     jimport('simplepie.simplepie');
     $config = EasyBlogHelper::getConfig();
     $itemMigrated = 0;
     $isDomSupported = false;
     $defaultAllowedHTML = '<img>,<a>,<br>,<table>,<tbody>,<th>,<tr>,<td>,<div>,<span>,<p>,<h1>,<h2>,<h3>,<h4>,<h5>,<h6>';
     if (class_exists('DomDocument')) {
         $isDomSupported = true;
         require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'readability' . DIRECTORY_SEPARATOR . 'Readability.php';
     }
     $params = EasyBlogHelper::getRegistry($feedObj->params);
     $maxItems = $maxItems ? $maxItems : $params->get('feedamount', 0);
     $feedURL = $feedObj->url;
     require_once EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'connectors.php';
     $connector = new EasyBlogConnectorsHelper();
     $connector->addUrl($feedURL);
     $connector->execute();
     $content = $connector->getResult($feedURL);
     // to ensure the leading no text before the <?xml> tag
     //$pattern	= '/(.*?)(?=<\?xml)/ims';
     $pattern = '/(.*?)<\\?xml version/is';
     $replacement = '<?xml version';
     $content = preg_replace($pattern, $replacement, $content, 1);
     if (strpos($content, '<?xml version') === false) {
         // look like the content missing the xml header. lets manually add in.
         $content = '<?xml version="1.0" encoding="utf-8"?>' . $content;
     }
     $parser = new SimplePie();
     $parser->strip_htmltags(false);
     $parser->set_raw_data($content);
     $parser->init();
     $items = '';
     $items = $parser->get_items();
     if (count($items) > 0) {
         //lets process the data insert
         $myCnt = 0;
         foreach ($items as $item) {
             @ini_set('max_execution_time', 180);
             if (!empty($maxItems) && $myCnt == $maxItems) {
                 break;
             }
             $timezoneSec = $item->get_date('Z');
             $itemdate = $item->get_date('U');
             $itemdate = $itemdate - $timezoneSec;
             $mydate = date('Y-m-d H:i:s', $itemdate);
             $feedUid = $item->get_id();
             $feedPath = $item->get_link();
             $feedHistory = EasyBlogHelper::getTable('FeedHistory');
             $newHistoryId = '';
             if ($feedHistory->isExists($feedObj->id, $feedUid)) {
                 continue;
             } else {
                 //log the feed item so that in future it will not process again.
                 $date = EasyBlogHelper::getDate();
                 $newHistory = EasyBlogHelper::getTable('FeedHistory');
                 $newHistory->feed_id = $feedObj->id;
                 $newHistory->uid = $feedUid;
                 $newHistory->created = $date->toMySQL();
                 $newHistory->store();
                 $newHistoryId = $newHistory->id;
             }
             $blogObj = new stdClass();
             // set the default setting from the feed configuration via backend.
             $blogObj->category_id = $feedObj->item_category;
             $blogObj->published = $feedObj->item_published;
             $blogObj->frontpage = $feedObj->item_frontpage;
             $blogObj->created_by = $feedObj->item_creator;
             $blogObj->allowcomment = $config->get('main_comment', 1);
             $blogObj->subscription = $config->get('main_subscription', 1);
             $blogObj->issitewide = '1';
             $text = $item->get_content();
             // @rule: Append copyright text
             $blogObj->copyrights = $params->get('copyrights', '');
             if ($feedObj->item_get_fulltext && $isDomSupported) {
                 $feedItemUrl = urldecode($item->get_link());
                 $fiConnector = new EasyBlogConnectorsHelper();
                 $fiConnector->addUrl($feedItemUrl);
                 $fiConnector->execute();
                 $fiContent = $fiConnector->getResult($feedItemUrl);
                 // to ensure the leading no text before the <?xml> tag
                 $pattern = '/(.*?)<html/is';
                 $replacement = '<html';
                 $fiContent = preg_replace($pattern, $replacement, $fiContent, 1);
                 if (!empty($fiContent)) {
                     $fiContent = EasyBlogHelper::getHelper('string')->forceUTF8($fiContent);
                     $readability = new Readability($fiContent);
                     $readability->debug = false;
                     $readability->convertLinksToFootnotes = false;
                     $result = $readability->init();
                     if ($result) {
                         $content = $readability->getContent()->innerHTML;
                         //$content	= EasyBlogHelper::getHelper( 'string' )->fixUTF8( $content );
                         $content = EasyBlogFeedsHelper::tidyContent($content);
                         if (stristr(html_entity_decode($content), '<!DOCTYPE html') === false) {
                             $text = $content;
                             $text = $this->_processRelLinktoAbs($text, $feedPath);
                         }
                     }
                 }
             }
             // strip un-allowed html tag.
             $text = strip_tags($text, $params->get('allowed', $defaultAllowedHTML));
             // Append original source link into article if necessary
             if ($params->get('sourceLinks')) {
                 JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT);
                 $text .= '<div><a href="' . $item->get_link() . '" target="_blank">' . JText::_('COM_EASYBLOG_FEEDS_ORIGINAL_LINK') . '</a></div>';
             }
             if ($feedObj->author) {
                 $feedAuthor = $item->get_author();
                 if (!empty($feedAuthor)) {
                     $authorName = $feedAuthor->get_name();
                     $authorEmail = $feedAuthor->get_email();
                     if (!empty($authorName)) {
                         // Store it as copyright column instead
                         $text .= '<div>' . JText::sprintf('COM_EASYBLOG_FEEDS_ORIGINAL_AUTHOR', $authorName) . '</div>';
                     } else {
                         if (!empty($authorEmail)) {
                             $authorArr = explode(' ', $authorEmail);
                             if (isset($authorArr[1])) {
                                 $authorName = $authorArr[1];
                                 $authorName = str_replace(array('(', ')'), '', $authorName);
                                 $text .= '<div>' . JText::sprintf('COM_EASYBLOG_FEEDS_ORIGINAL_AUTHOR', $authorName) . '</div>';
                             }
                         }
                     }
                 }
             }
             if ($feedObj->item_content == 'intro') {
                 $blogObj->intro = $text;
             } else {
                 $blogObj->content = $text;
             }
             $creationDate = $mydate;
             $blogObj->created = $mydate;
             $blogObj->modified = $mydate;
             $blogObj->title = $item->get_title();
             if (empty($blogObj->title)) {
                 $blogObj->title = $this->_getTitleFromLink($item->get_link());
             }
             $blogObj->title = EasyBlogStringHelper::unhtmlentities($blogObj->title);
             $blogObj->permalink = EasyBlogHelper::getPermalink($blogObj->title);
             $blogObj->publish_up = $mydate;
             $blogObj->isnew = !$feedObj->item_published ? true : false;
             $blog = EasyBlogHelper::getTable('blog');
             $blog->bind($blogObj);
             if ($feedObj->item_published) {
                 $blog->notify();
             }
             if ($blog->store()) {
                 $myCnt++;
                 //update the history with blog id
                 if (!empty($newHistoryId)) {
                     $tmpHistory = EasyBlogHelper::getTable('FeedHistory');
                     $tmpHistory->load($newHistoryId);
                     $tmpHistory->post_id = $blog->id;
                     $tmpHistory->store();
                 }
                 $itemMigrated++;
                 if ($feedObj->item_published) {
                     //insert activity here.
                     EasyBlogHelper::addJomSocialActivityBlog($blog, true, true);
                     // Determines if admin wants to auto post this item to the social sites.
                     if ($params->get('autopost')) {
                         $allowed = array(EBLOG_OAUTH_LINKEDIN, EBLOG_OAUTH_FACEBOOK, EBLOG_OAUTH_TWITTER);
                         // @rule: Process centralized options first
                         // See if there are any global postings enabled.
                         $blog->autopost($allowed, $allowed);
                     }
                 }
             }
             //end if
         }
     }
     return $itemMigrated;
 }
Exemplo n.º 10
0
 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);
         }
     }
 }
Exemplo n.º 11
0
 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);
         }
     }
 }
Exemplo n.º 12
0
 function escape($val)
 {
     return EasyBlogStringHelper::escape($val);
 }
Exemplo n.º 13
0
 public static function addOpenGraphTags(&$blog, $rawIntroText = '')
 {
     $cfg = EasyBlogHelper::getConfig();
     // @rule: Check if user really wants to append the opengraph tags on the headers.
     if (!$cfg->get('main_facebook_opengraph')) {
         return false;
     }
     // Get the absolute permalink for this blog item.
     $url = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $blog->id, false, true);
     // Get the image of the blog post.
     $image = self::getImage($blog, $rawIntroText);
     // @task: Get Joomla's document object.
     $doc = JFactory::getDocument();
     // Add the blog image.
     $doc->addCustomTag('<meta property="og:image" content="' . $image . '"/> ');
     if ($cfg->get('main_facebook_like')) {
         $doc->addCustomTag('<meta property="fb:app_id" content="' . $cfg->get('main_facebook_like_appid') . '"/> ');
         $doc->addCustomTag('<meta property="fb:admins" content="' . $cfg->get('main_facebook_like_admin') . '"/>');
     }
     $meta = EasyBlogHelper::getTable('Meta', 'Table');
     $meta->loadByType(META_TYPE_POST, $blog->id);
     $doc->addCustomTag('<meta property="og:title" content="' . $blog->title . '" />');
     // @task: Add description of the blog.
     if (!empty($meta->description)) {
         $meta->description = EasyBlogStringHelper::escape($meta->description);
         $doc->addCustomTag('<meta property="og:description" content="' . $meta->description . '" />');
     } else {
         $maxLength = $cfg->get('integrations_facebook_blogs_length');
         $text = EasyBlogHelper::stripEmbedTags($rawIntroText);
         $text = strip_tags($text);
         $text = str_ireplace("\r\n", "", $text);
         // Remove any " in the content as this would mess up the headers.
         $text = str_ireplace('"', '', $text);
         if (!empty($maxLength)) {
             $text = JString::strlen($text) > $maxLength ? JString::substr($text, 0, $maxLength) . '...' : $text;
         }
         $text = EasyBlogStringHelper::escape($text);
         $doc->addCustomTag('<meta property="og:description" content="' . $text . '" />');
     }
     $doc->addCustomTag('<meta property="og:type" content="article" />');
     $doc->addCustomTag('<meta property="og:url" content="' . $url . '" />');
     return true;
 }
Exemplo n.º 14
0
 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);
     }
 }
Exemplo n.º 15
0
 public static function fixUTF8($text)
 {
     if (is_array($text)) {
         foreach ($text as $k => $v) {
             $text[$k] = EasyBlogStringHelper::fixUTF8($v);
         }
         return $text;
     }
     $last = "";
     while ($last != $text) {
         $last = $text;
         $text = EasyBlogStringHelper::forceUTF8(utf8_decode(EasyBlogStringHelper::forceUTF8($text)));
     }
     return $text;
 }