예제 #1
0
 function onAfterRoute()
 {
     include_once JPATH_ROOT . DS . 'components' . DS . 'com_jcomments' . DS . 'jcomments.legacy.php';
     $mainframe =& JFactory::getApplication('site');
     $mainframe->getRouter();
     $document =& JFactory::getDocument();
     if ($document->getType() == 'pdf') {
         return;
     }
     if ($mainframe->isAdmin()) {
         $document->addStyleSheet(JURI::base() . 'components/com_jcomments/assets/icon.css?v=2');
         $option = JAdministratorHelper::findOption();
         $task = JRequest::getCmd('task');
         $type = JRequest::getCmd('type', '', 'post');
         // remove comments if content item deleted from trash
         if ($option == 'com_trash' && $task == 'delete' && $type == 'content') {
             $cid = JRequest::getVar('cid', array(0), 'post', 'array');
             JArrayHelper::toInteger($cid, array(0));
             include_once JPATH_ROOT . DS . 'components' . DS . 'com_jcomments' . DS . 'jcomments.php';
             JComments::deleteComments($cid, 'com_content');
         }
     } else {
         $option = JRequest::getCmd('option');
         if ($option == 'com_content' || $option == 'com_alphacontent') {
             include_once JCOMMENTS_BASE . DS . 'jcomments.class.php';
             include_once JCOMMENTS_BASE . DS . 'jcomments.config.php';
             include_once JCOMMENTS_HELPERS . DS . 'system.php';
             // include JComments CSS
             if ($this->params->get('disable_template_css', 0) == 0) {
                 $document->addStyleSheet(JCommentsSystemPluginHelper::getCSS());
                 $language =& JFactory::getLanguage();
                 if ($language->isRTL()) {
                     $rtlCSS = JCommentsSystemPluginHelper::getCSS(true);
                     if ($rtlCSS != '') {
                         $document->addStyleSheet($rtlCSS);
                     }
                 }
             }
             if (!defined('JCOMMENTS_CSS')) {
                 define('JCOMMENTS_CSS', 1);
             }
             $config =& JCommentsCfg::getInstance();
             // include JComments JavaScript library
             $document->addScript(JCommentsSystemPluginHelper::getCoreJS());
             if (!defined('JOOMLATUNE_AJAX_JS')) {
                 $document->addScript(JCommentsSystemPluginHelper::getAjaxJS());
                 define('JOOMLATUNE_AJAX_JS', 1);
             }
             if (!defined('JCOMMENTS_JS')) {
                 define('JCOMMENTS_JS', 1);
             }
         }
     }
 }