Пример #1
0
 /**
  * Renders the comment count for Ccomment
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return	
  */
 public function getCount(EasyBlogPost $post)
 {
     if (!$this->exists()) {
         return;
     }
     $plugin = $this->getPlugin($post);
     $count = ccommentHelperUtils::getCommentCount($plugin, 'com_easyblog');
     return $count;
 }
Пример #2
0
 public static function getCommentHTML($blog, $comments = array(), $pagination = '')
 {
     $config = EasyBlogHelper::getConfig();
     $path = EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'comments';
     $registration = $config->get('comment_registeroncomment');
     $commentSystems = array();
     // Double check this with Joomla's registration component
     if ($registration) {
         $params = JComponentHelper::getParams('com_users');
         $registration = $params->get('allowUserRegistration') == '0' ? false : $registration;
     }
     if ($config->get('comment_facebook')) {
         require_once $path . DIRECTORY_SEPARATOR . 'facebook.php';
         $commentSystems['FACEBOOK'] = EasyBlogCommentFacebook::getHTML($blog);
         if (!$config->get('main_comment_multiple')) {
             return $commentSystems['FACEBOOK'];
         }
     }
     $easysocial = EasyBlogHelper::getHelper('EasySocial');
     if ($config->get('comment_easysocial') && $easysocial->exists()) {
         $easysocial->init();
         $commentSystems['EASYSOCIAL'] = $easysocial->getCommentHTML($blog);
         if (!$config->get('main_comment_multiple')) {
             return $commentSystems['EASYSOCIAL'];
         }
     }
     if ($config->get('comment_compojoom')) {
         $file = JPATH_ROOT . '/administrator/components/com_comment/plugin/com_easyblog/josc_com_easyblog.php';
         if (JFile::exists($file)) {
             require_once $file;
             $commentSystems['COMPOJOOM'] = CommentEasyBlog::output($blog, array());
         }
         $file = JPATH_ROOT . '/components/com_comment/helpers/utils.php';
         if (JFile::exists($file)) {
             JLoader::discover('ccommentHelper', JPATH_ROOT . '/components/com_comment/helpers');
             $commentSystems['COMPOJOOM'] = ccommentHelperUtils::commentInit('com_easyblog', $blog);
         }
         if (!$config->get('main_comment_multiple')) {
             return $commentSystems['COMPOJOOM'];
         }
     }
     if ($config->get('comment_intensedebate')) {
         require_once $path . DIRECTORY_SEPARATOR . 'intensedebate.php';
         $commentSystems['INTENSEDEBATE'] = EasyBlogCommentIntenseDebate::getHTML($blog);
         if (!$config->get('main_comment_multiple')) {
             return $commentSystems['INTENSEDEBATE'];
         }
     }
     if ($config->get('comment_disqus')) {
         require_once $path . DIRECTORY_SEPARATOR . 'disqus.php';
         $commentSystems['DISQUS'] = EasyBlogCommentDisqus::getHTML($blog);
         if (!$config->get('main_comment_multiple')) {
             return $commentSystems['DISQUS'];
         }
     }
     if ($config->get('comment_jomcomment')) {
         $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_jomcomment' . DIRECTORY_SEPARATOR . 'jomcomment.php';
         // Test if jomcomment exists.
         if (JFile::exists($file)) {
             require_once $path . DIRECTORY_SEPARATOR . 'jomcomment.php';
             $commentSystems['JOMCOMMENT'] = EasyBlogCommentJomComment::getHTML($blog);
             if (!$config->get('main_comment_multiple')) {
                 return $commentSystems['JOMCOMMENT'];
             }
         }
     }
     if ($config->get('comment_livefyre')) {
         require_once $path . DIRECTORY_SEPARATOR . 'livefyre.php';
         $commentSystems['LIVEFYRE'] = EasyBlogCommentLiveFyre::getHTML($blog);
         if (!$config->get('main_comment_multiple')) {
             return $commentSystems['LIVEFYRE'];
         }
     }
     if ($config->get('comment_jcomments')) {
         $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_jcomments' . DIRECTORY_SEPARATOR . 'jcomments.php';
         if (JFile::exists($file)) {
             require_once $path . DIRECTORY_SEPARATOR . 'jcomments.php';
             $commentSystems['JCOMMENTS'] = EasyBlogCommentJComments::getHTML($blog);
             if (!$config->get('main_comment_multiple')) {
                 return $commentSystems['JCOMMENTS'];
             }
         }
     }
     if ($config->get('comment_rscomments')) {
         $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_rscomments' . DIRECTORY_SEPARATOR . 'rscomments.php';
         if (JFile::exists($file)) {
             include_once $path . DIRECTORY_SEPARATOR . 'rscomments.php';
             $commentSystems['RSCOMMENTS'] = EasyBlogCommentRSComments::getHTML($blog);
             if (!$config->get('main_comment_multiple')) {
                 return $commentSystems['RSCOMMENTS'];
             }
         }
     }
     if ($config->get('comment_easydiscuss')) {
         $enabled = JPluginHelper::isEnabled('content', 'easydiscuss');
         if ($enabled) {
             JPluginHelper::importPlugin('content', 'easydiscuss');
             $articleParams = new stdClass();
             $result = JFactory::getApplication()->triggerEvent('onDisplayComments', array(&$blog, &$articleParams));
             if (isset($result[0]) || isset($result[1])) {
                 // There could be komento running on the site
                 if (isset($result[1]) && $result[1]) {
                     $commentSystems['EASYDISCUSS'] = $result[1];
                 } else {
                     $commentSystems['EASYDISCUSS'] = $result[0];
                 }
                 if (!$config->get('main_comment_multiple')) {
                     return $commentSystems['EASYDISCUSS'];
                 }
             }
         }
     }
     if ($config->get('comment_komento')) {
         $file = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_komento' . DIRECTORY_SEPARATOR . 'bootstrap.php';
         if (JFile::exists($file)) {
             include_once $file;
             $commentSystems['KOMENTO'] = Komento::commentify('com_easyblog', $blog, array('trigger' => 'onDisplayComments'));
             if (!$config->get('main_comment_multiple')) {
                 return $commentSystems['KOMENTO'];
             }
         }
     }
     if (!$config->get('main_comment_multiple') || $config->get('comment_easyblog')) {
         //check if bbcode enabled or not.
         if ($config->get('comment_bbcode')) {
             EasyBlogCommentHelper::loadBBCode();
         }
         // If all else fail, try to use the default comment system
         $theme = new CodeThemes();
         // setup my own info to show in comment form area
         $my = JFactory::getUser();
         $profile = EasyBlogHelper::getTable('Profile', 'Table');
         $profile->load($my->id);
         $my->avatar = $profile->getAvatar();
         $my->displayName = $profile->getName();
         $my->url = $profile->url;
         $blogURL = base64_encode(EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $blog->id, false));
         $loginURL = EasyBlogHelper::getLoginLink($blogURL);
         $enableRecaptcha = $config->get('comment_recaptcha');
         $publicKey = $config->get('comment_recaptcha_public');
         // check if the user has subcribed to this thread
         $subscriptionId = false;
         if ($my->id > 0) {
             $blogModel = EasyblogHelper::getModel('Blog');
             $subscriptionId = $blogModel->isBlogSubscribedUser($blog->id, $my->id, $my->email);
             $subscriptionId = is_null($subscriptionId) ? false : $subscriptionId;
         }
         $theme->set('loginURL', $loginURL);
         $theme->set('blog', $blog);
         $theme->set('my', $my);
         $theme->set('config', $config);
         $theme->set('blogComments', $comments);
         $theme->set('pagination', $pagination);
         $theme->set('allowComment', true);
         $theme->set('canRegister', $registration);
         $theme->set('acl', EasyBlogACLHelper::getRuleSet());
         $theme->set('subscriptionId', $subscriptionId);
         $commentSystems['EASYBLOGCOMMENTS'] = $theme->fetch('blog.comment.box.php');
     }
     if (!$config->get('main_comment_multiple')) {
         return $commentSystems['EASYBLOGCOMMENTS'];
     }
     // If there's 1 system only, there's no point loading the tabs.
     if (count($commentSystems) == 1) {
         return $commentSystems[key($commentSystems)];
     }
     unset($theme);
     // Reverse the comment systems array so that easyblog comments are always the first item.
     $commentSystems = array_reverse($commentSystems);
     $theme = new CodeThemes();
     $theme->set('commentSystems', $commentSystems);
     return $theme->fetch('blog.comment.multiple.php');
 }
Пример #3
0
    /**
     * Loads the comments from the installed/selected comment system. The comment system <code>type</code> should tell which comment system need to be used to load the comments from. The possible values are:<br><br>
     * jcomment - JComments (id and title are required) <br>
     * fbcomment - Facebook comment system (url is required)<br>
     * disqus - Disqus comment system (id, title, identifier and url are required)<br>
     * intensedebate - Intense Debate comment system (id, title, identifier and url are required)<br>
     * jacomment - JAComment system (id and title are required)<br>
     * jomcomment - JomComment (id is required)<br><br>
     * Passing any other value will silently skips the code. In all the above cases, <code>type</code> and <code>app_name</code> are required parameters. 
     * While <code>type</code> specifies the comment system to be used, <code>app_name</code> is the Joomla extension name (ex: com_appname) which is loading the comments for its content.
     *  
     * @param string $type comment system type
     * @param string $app_name extension name
     * @param int $id id of the content for which the comments are being loaded
     * @param string $title title of the content
     * @param string $url page url in case of facebook/disqus/intensedebate comment system.
     * @param string $identifier disqus username in case of disqus/intensedebate comment system.
     * @param object $item the item object for kommento
     * 
     * @return string the code to render the comments.
     */
    public static function load_comments($type, $app_name, $id = 0, $title = '', $url = '', $identifier = '', $item = null)
    {
        switch ($type) {
            case 'jcomment':
                $app = JFactory::getApplication();
                $path = JPATH_ROOT . DS . 'components' . DS . 'com_jcomments' . DS . 'jcomments.php';
                if (file_exists($path)) {
                    require_once $path;
                    return JComments::showComments($id, $app_name, $title);
                }
                break;
            case 'fbcomment':
                return '
					<div id="fb-root"></div>
					<script type="text/javascript">
						(function(d, s, id) {
							var js, fjs = d.getElementsByTagName(s)[0]; 
							if (d.getElementById(id)) return; 
							js = d.createElement(s); 
							js.id = id;
							js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.3";
							fjs.parentNode.insertBefore(js, fjs); 
						}(document, "script", "facebook-jssdk"));
					</script>
					<div class="fb-comments" data-href="' . $url . '" data-num-posts="5" data-width="640"></div>';
            case 'disqus':
                return '
					<div id="disqus_thread"></div>
					<script type="text/javascript">
						var disqus_shortname = "' . $identifier . '";
// 						var disqus_developer = 1;
						var disqus_identifier = "' . $id . '";
						var disqus_url = "' . $url . '";
						var disqus_title = "' . $title . '";
						(function() {
							var dsq = document.createElement("script"); 
							dsq.type = "text/javascript"; 
							dsq.async = true;
							dsq.src = "http://" + disqus_shortname + ".disqus.com/embed.js";
							(document.getElementsByTagName("head")[0] || document.getElementsByTagName("body")[0]).appendChild(dsq);
						})();
					</script>
					<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>';
            case 'intensedebate':
                return '
					<script>
						var idcomments_acct = "' . $identifier . '";
						var idcomments_post_id = "' . $id . '";
						var idcomments_post_url = "' . $url . '";
					</script>
					<span id="IDCommentsPostTitle" style="display:none"></span>
					<script type="text/javascript" src="http://www.intensedebate.com/js/genericCommentWrapperV2.js"></script>';
                break;
            case 'jacomment':
                if (!JRequest::getInt('print') && file_exists(JPATH_SITE . DS . 'components' . DS . 'com_jacomment' . DS . 'jacomment.php') && file_exists(JPATH_SITE . DS . 'plugins' . DS . 'system' . DS . 'jacomment.php')) {
                    $_jacCode = "#{jacomment(.*?) contentid=(.*?) option=(.*?) contenttitle=(.*?)}#i";
                    $_jacCodeDisableid = "#{jacomment(\\s)off.*}#i";
                    $_jacCodeDisable = "#{jacomment(\\s)off}#i";
                    if (!preg_match($_jacCode, $title) && !preg_match($_jacCodeDisable, $title) && !preg_match($_jacCodeDisableid, $title)) {
                        return '{jacomment contentid=' . $id . ' option=' . $app_name . ' contenttitle=' . $title . '}';
                    }
                }
                break;
            case 'jomcomment':
                $path = JPATH_PLUGINS . DS . 'content' . DS . 'jom_comment_bot.php';
                if (file_exists($path)) {
                    include_once $path;
                    return jomcomment($id, $app_name);
                }
                break;
            case 'kommento':
                $api = JPATH_ROOT . DS . 'components' . DS . 'com_komento' . DS . 'bootstrap.php';
                if (file_exists($api)) {
                    require_once $api;
                    $item->text = $item->introtext = !empty($item->description) ? $item->description : '';
                    return Komento::commentify($app_name, $item);
                }
                break;
            case 'ccomment':
                $utils = JPATH_ROOT . '/components/com_comment/helpers/utils.php';
                if (file_exists($utils)) {
                    JLoader::discover('ccommentHelper', JPATH_ROOT . '/components/com_comment/helpers');
                    return ccommentHelperUtils::commentInit($app_name, $item);
                }
                break;
        }
    }