Example #1
0
 /**
  * Returns a reference to the global {@link JoomlaTuneTemplateRender} object,
  * only creating it if it doesn't already exist.
  *
  * @param int $object_id
  * @param string $object_group
  * @param bool $needThisUrl
  * @return JoomlaTuneTemplateRender
  */
 public static function getTemplate($object_id = 0, $object_group = 'com_content', $needThisUrl = true)
 {
     global $Itemid;
     ob_start();
     $app = JCommentsFactory::getApplication();
     $config = JCommentsFactory::getConfig();
     $templateName = $config->get('template');
     if (empty($templateName)) {
         $templateName = 'default';
         $config->set('template', $templateName);
     }
     include_once JCOMMENTS_LIBRARIES . '/joomlatune/template.php';
     $templateDefaultDirectory = JCOMMENTS_BASE . '/tpl/' . $templateName;
     $templateDirectory = $templateDefaultDirectory;
     $templateUrl = $app->getCfg('live_site') . '/components/com_jcomments/tpl/' . $templateName;
     if (JCOMMENTS_JVERSION != '1.0') {
         $templateOverride = JPATH_SITE . '/templates/' . $app->getTemplate() . '/html/com_jcomments/' . $templateName;
         if (is_dir($templateOverride)) {
             $templateDirectory = $templateOverride;
             $templateUrl = JURI::root() . 'templates/' . $app->getTemplate() . '/html/com_jcomments/' . $templateName;
         }
     }
     $tmpl = JoomlaTuneTemplateRender::getInstance();
     $tmpl->setRoot($templateDirectory);
     $tmpl->setDefaultRoot($templateDefaultDirectory);
     $tmpl->setBaseURI($templateUrl);
     $tmpl->addGlobalVar('siteurl', $app->getCfg('live_site'));
     $tmpl->addGlobalVar('charset', strtolower(preg_replace('/charset=/', '', _ISO)));
     $tmpl->addGlobalVar('ajaxurl', JCommentsFactory::getLink('ajax', $object_id, $object_group));
     $tmpl->addGlobalVar('smilesurl', JCommentsFactory::getLink('smiles', $object_id, $object_group));
     if ($config->getInt('enable_rss') == 1) {
         $tmpl->addGlobalVar('rssurl', JCommentsFactory::getLink('rss', $object_id, $object_group));
     }
     $tmpl->addGlobalVar('template', $templateName);
     $tmpl->addGlobalVar('template_url', $templateUrl);
     $tmpl->addGlobalVar('itemid', $Itemid ? $Itemid : 1);
     if (JCOMMENTS_JVERSION == '1.0') {
         $tmpl->addGlobalVar('direction', 'ltr');
     } else {
         $language = JFactory::getLanguage();
         $tmpl->addGlobalVar('direction', $language->isRTL() ? 'rtl' : 'ltr');
     }
     $lang = $app->getCfg('lang');
     if ($lang == 'russian' || $lang == 'ukrainian' || $lang == 'belorussian' || $lang == 'ru-RU' || $lang == 'uk-UA' || $lang == 'be-BY') {
         $tmpl->addGlobalVar('support', base64_decode('PGEgaHJlZj0iaHR0cDovL3d3dy5qb29tbGF0dW5lLnJ1IiB0aXRsZT0iSkNvbW1lbnRzIiB0YXJnZXQ9Il9ibGFuayI+SkNvbW1lbnRzPC9hPg=='));
     } else {
         $tmpl->addGlobalVar('support', base64_decode('PGEgaHJlZj0iaHR0cDovL3d3dy5qb29tbGF0dW5lLmNvbSIgdGl0bGU9IkpDb21tZW50cyIgdGFyZ2V0PSJfYmxhbmsiPkpDb21tZW50czwvYT4='));
     }
     $tmpl->addGlobalVar('comment-object_id', $object_id);
     $tmpl->addGlobalVar('comment-object_group', $object_group);
     if ($needThisUrl == true) {
         $tmpl->addGlobalVar('thisurl', JCommentsObjectHelper::getLink($object_id, $object_group));
     }
     ob_end_clean();
     return $tmpl;
 }
Example #2
0
 /**
  * Returns a reference to the global {@link JoomlaTuneTemplateRender} object, only creating it if it does not already exist.
  *
  * @param int $object_id
  * @param string $object_group
  * @param bool $needThisUrl
  *
  * @return JoomlaTuneTemplateRender
  */
 public static function getTemplate($object_id = 0, $object_group = 'com_content', $needThisUrl = true)
 {
     global $Itemid;
     ob_start();
     $app = JFactory::getApplication();
     $language = JFactory::getLanguage();
     $config = JCommentsFactory::getConfig();
     $templateName = $config->get('template');
     if (empty($templateName)) {
         $templateName = 'default';
         $config->set('template', $templateName);
     }
     include_once JCOMMENTS_LIBRARIES . '/joomlatune/template.php';
     $templateDefaultDirectory = JCOMMENTS_SITE . '/tpl/' . $templateName;
     $templateDirectory = $templateDefaultDirectory;
     $templateUrl = JURI::root() . 'components/com_jcomments/tpl/' . $templateName;
     $templateOverride = JPATH_SITE . '/templates/' . $app->getTemplate() . '/html/com_jcomments/' . $templateName;
     if (is_dir($templateOverride)) {
         $templateDirectory = $templateOverride;
         $templateUrl = JURI::root() . 'templates/' . $app->getTemplate() . '/html/com_jcomments/' . $templateName;
     }
     $tmpl = JoomlaTuneTemplateRender::getInstance();
     $tmpl->setRoot($templateDirectory);
     $tmpl->setDefaultRoot($templateDefaultDirectory);
     $tmpl->setBaseURI($templateUrl);
     $tmpl->addGlobalVar('siteurl', JURI::root());
     $tmpl->addGlobalVar('charset', 'utf-8');
     $tmpl->addGlobalVar('ajaxurl', JCommentsFactory::getLink('ajax', $object_id, $object_group));
     $tmpl->addGlobalVar('smilesurl', JCommentsFactory::getLink('smilies', $object_id, $object_group));
     if ($config->getInt('enable_rss') == 1) {
         $tmpl->addGlobalVar('rssurl', JCommentsFactory::getLink('rss', $object_id, $object_group));
     }
     $tmpl->addGlobalVar('template', $templateName);
     $tmpl->addGlobalVar('template_url', $templateUrl);
     $tmpl->addGlobalVar('itemid', $Itemid ? $Itemid : 1);
     $tmpl->addGlobalVar('direction', $language->isRTL() ? 'rtl' : 'ltr');
     $lang = $language->getTag();
     $domain = $lang == 'ru-RU' || $lang == 'uk-UA' || $lang == 'be-BY' ? 'ru' : 'com';
     $tmpl->addGlobalVar('comment-object_id', $object_id);
     $tmpl->addGlobalVar('comment-object_group', $object_group);
     if ($needThisUrl == true) {
         $tmpl->addGlobalVar('thisurl', JCommentsObjectHelper::getLink($object_id, $object_group, $lang));
     }
     ob_end_clean();
     return $tmpl;
 }