/** * Returns a reference to a language object. * * @param string $language The language to use. * @param string $component The component name. * @return JCommentsCfg */ public static function getInstance($language = '', $component = '') { static $instance = null; $app = JCommentsFactory::getApplication(); if (JCOMMENTS_JVERSION == '1.7') { $multilingual_support = $app->isSite() && $app->getLanguageFilter(); } else { $multilingual_support = $app->getCfg('multilingual_support') == 1; } if (!is_object($instance)) { $instance = new JCommentsCfg(); if ($language == '') { $language = $multilingual_support ? JCommentsMultilingual::getLanguage() : ''; } $instance->load($language, $component); } else { if ($language != $instance->_current && $instance->_current == '') { if ($language != '') { $instance->load($language, $component); } else { $language = $multilingual_support ? JCommentsMultilingual::getLanguage() : ''; if ($language != '') { $instance->load($language, $component); } } } } return $instance; }
function getObjectLink($id) { $app = JCommentsFactory::getApplication(); $myBlogFunctions = $app->getCfg('absolute_path') . DS . 'components' . DS . 'com_myblog' . DS . 'functions.myblog.php'; if (is_file($myBlogFunctions)) { require_once $myBlogFunctions; $_Itemid = myGetItemId(); } else { $_Itemid = self::getItemid('com_myblog'); } $db = JCommentsFactory::getDBO(); $db->setQuery('SELECT permalink FROM #__myblog_permalinks WHERE contentid=' . $id); $permalink = $db->loadResult(); $link = JoomlaTuneRoute::_('index.php?option=com_myblog&show=' . $permalink . '&Itemid=' . $_Itemid); return $link; }
public static function show() { $app = JCommentsFactory::getApplication('administrator'); $config = JCommentsFactory::getConfig(); if ($config->getInt('enable_blacklist') == 0) { if (JCOMMENTS_JVERSION != '1.0') { JError::raiseWarning(500, JText::_('A_BLACKLIST_WARNING_BLACKLIST_IS_DISABLED')); } } $context = 'com_jcomments.blacklist.'; $limit = intval($app->getUserStateFromRequest($context . 'limit', 'limit', $app->getCfg('list_limit'))); $limitstart = intval($app->getUserStateFromRequest($context . 'limitstart', 'limitstart', 0)); $filter_order = $app->getUserStateFromRequest($context . 'filter_order', 'filter_order', 'bl.created'); $filter_order_Dir = $app->getUserStateFromRequest($context . 'filter_order_Dir', 'filter_order_Dir', 'desc'); $search = trim($app->getUserStateFromRequest($context . 'search', 'search', '')); if (JCOMMENTS_JVERSION == '1.0') { $search = strtolower($search); } else { $search = JString::strtolower($search); } if ($filter_order == '') { $filter_order = 'bl.created'; } if ($filter_order_Dir == '') { $filter_order_Dir = 'desc'; } $lists['order'] = $filter_order; $lists['order_Dir'] = $filter_order_Dir; $lists['search'] = $search; $db = JCommentsFactory::getDBO(); $where = array(); if ($search != '') { $where[] = '(LOWER(bl.ip) like "%' . $db->getEscaped($search, true) . '%")' . ' OR LOWER(bl.reason) like "%' . $db->getEscaped($search, true) . '%"' . ' OR LOWER(bl.notes) like "%' . $db->getEscaped($search, true) . '%"'; } $query = "SELECT COUNT(*)" . " FROM #__jcomments_blacklist AS bl" . (count($where) ? " WHERE " . implode(' AND ', $where) : ""); $db->setQuery($query); $total = $db->loadResult(); $lists['pageNav'] = JCommentsAdmin::getPagination($total, $limitstart, $limit); $query = "SELECT bl.*, u.name AS editor" . " FROM #__jcomments_blacklist AS bl" . " LEFT JOIN #__users AS u ON u.id = bl.checked_out" . (count($where) ? " WHERE " . implode(' AND ', $where) : "") . " ORDER BY " . $filter_order . ' ' . $filter_order_Dir; $db->setQuery($query, $lists['pageNav']->limitstart, $lists['pageNav']->limit); $lists['rows'] = $db->loadObjectList(); HTML_JCommentsAdminBlacklistManager::show($lists); }
function getObjectInfo($id, $language = null) { $info = new JCommentsObjectInfo(); $app = JCommentsFactory::getApplication(); if (!$app->isAdmin()) { $db = JFactory::getDBO(); $query = "SELECT o.id, o.name, o.owner, o.parent, fd.baseData" . " FROM #__sobipro_object as o" . " LEFT JOIN #__sobipro_field_data AS fd ON o.id = fd.sid" . " JOIN #__sobipro_field AS f ON fd.fid = f.fid AND f.nid = 'field_name'" . " WHERE o.id = " . $id . " AND o.oType = 'entry'"; $db->setQuery($query); $row = $db->loadObject(); if (!empty($row)) { $sobiCore = JPATH_SITE . '/components/com_sobipro/lib/base/fs/loader.php'; if (is_file($sobiCore)) { if (!defined('SOBIPRO')) { $ver = new JVersion(); $ver = str_replace('.', null, $ver->RELEASE); define('SOBI_CMS', 'joomla' . $ver); define('SOBIPRO', true); define('SOBI_TASK', 'task'); define('SOBI_DEFLANG', JFactory::getLanguage()->getDefault()); define('SOBI_ACL', 'front'); define('SOBI_ROOT', JPATH_ROOT); define('SOBI_MEDIA', implode(DS, array(JPATH_ROOT, 'media', 'sobipro'))); define('SOBI_MEDIA_LIVE', JURI::root() . '/media/sobipro'); define('SOBI_PATH', JPATH_ROOT . '/components/com_sobipro'); define('SOBI_LIVE_PATH', 'components/com_sobipro'); require_once JPATH_ROOT . '/components/com_sobipro/lib/base/fs/loader.php'; } SPLoader::loadClass('cms.base.lang'); SPLoader::loadClass('base.factory'); SPLoader::loadClass('base.request'); SPLoader::loadClass('base.object'); SPLoader::loadClass('sobi'); $info->title = empty($row->name) ? isset($row->baseData) ? $row->baseData : '' : $row->name; $info->access = NULL; $info->userid = $row->owner; $info->link = Sobi::Url(array('title' => $row->name, 'pid' => $row->parent, 'sid' => $row->id)); } } } return $info; }
public static function getCSS($isRTL = false, $template = '') { if (empty($template)) { $config = JCommentsCfg::getInstance(); $template = $config->get('template'); } $cssName = $isRTL ? 'style_rtl.css' : 'style.css'; $cssFile = $cssName . '?v=21'; if (JCOMMENTS_JVERSION == '1.0') { $cssUrl = JCommentsSystemPluginHelper::getBaseUrl() . '/components/com_jcomments/tpl/' . $template . '/' . $cssFile; } else { $app = JCommentsFactory::getApplication('site'); $cssPath = JPATH_SITE . '/templates/' . $app->getTemplate() . '/html/com_jcomments/' . $template . '/' . $cssName; $cssUrl = JURI::root(true) . '/templates/' . $app->getTemplate() . '/html/com_jcomments/' . $template . '/' . $cssFile; if (!is_file($cssPath)) { $cssPath = JPATH_SITE . '/components/com_jcomments/tpl/' . $template . '/' . $cssName; $cssUrl = JURI::root(true) . '/components/com_jcomments/tpl/' . $template . '/' . $cssFile; if ($isRTL && !is_file($cssPath)) { $cssUrl = ''; } } } return $cssUrl; }
public static function showImport($CommentSystems = array()) { $app = JCommentsFactory::getApplication('administrator'); $db = JCommentsFactory::getDBO(); $db->setQuery("SHOW TABLES"); $tables = $db->loadResultArray(); foreach ($tables as $tableName) { for ($i = 0, $n = count($CommentSystems); $i < $n; $i++) { $tableMask = str_replace('#__', $app->getCfg('dbprefix'), $CommentSystems[$i]->table); if (preg_match('/' . $tableMask . '$/i', $tableName)) { $CommentSystems[$i]->found = true; $CommentSystems[$i]->UpdateCount(); } } } $languages = JCommentsMultilingual::getLanguages(); if (JCOMMENTS_JVERSION == '1.0') { $lang = JCommentsMultilingual::getLanguage(); } else { $params = JComponentHelper::getParams('com_languages'); $lang = $params->get("site", 'en-GB'); } $ajaxUrl = JCommentsFactory::getLink('ajax-backend'); ?> <link rel="stylesheet" href="<?php echo $app->getCfg('live_site'); ?> /administrator/components/com_jcomments/assets/style.css" type="text/css" /> <script type="text/javascript" src="<?php echo $app->getCfg('live_site'); ?> /components/com_jcomments/libraries/joomlatune/ajax.js?v=2"></script> <script type="text/javascript" src="<?php echo $app->getCfg('live_site'); ?> /administrator/components/com_jcomments/assets/jcomments-backend-v2.1.js"></script> <script type="text/javascript"> <!-- function JCommentsImportCommentsAJAX(source, language, start) { try { jtajax.setup({url:'<?php echo $ajaxUrl; ?> '}); return jtajax.call('JCommentsImportCommentsAjax', arguments, 'post'); } catch (e) { return false; } } function startCommentsImport(source) { var language = ''; var e=document.getElementById(source.toLowerCase() + '_lang'); if (e){for (var i=0;i<e.length;i++) {if (e.options[i].selected){language=e.options[i].value;break;}}} var b = document.getElementById('btnImport' + source); if (b) {b.disabled = true;} JCommentsImportCommentsAJAX(source, language, 0); } function finishCommentsImport(source) { var b=document.getElementById('btnImport'+source);if(b){b.disabled=false;} } <?php if (JCOMMENTS_JVERSION == '1.7') { ?> Joomla.submitbutton = function (task) { Joomla.submitform(task, document.getElementById('adminForm')); }; <?php } else { ?> function submitbutton(task) { submitform(task); } <?php } ?> //--> </script> <script type="text/javascript"> <!-- var jc_comments = new Array( <?php $jsArray = array(); foreach ($CommentSystems as $CommentSystem) { if ($CommentSystem->found) { $jsArray[] = $CommentSystem->code; } } echo "'" . implode("', '", $jsArray) . "'"; ?> ); function importMode( mode ) { if(document.getElementById) { for(var i=0;i<jc_comments.length;i++) { if (mode == jc_comments[i]) { document.getElementById('import' + jc_comments[i]).checked = true; document.getElementById('import' + jc_comments[i]+'Info').style.display = ''; } else { document.getElementById('import' + jc_comments[i]).checked = false; document.getElementById('import' + jc_comments[i]+'Info').style.display = 'none'; } } } } //--> </script> <style type="text/css"> #jcomments-message {padding: 0 0 0 25px;margin: 0; width: auto; float: right; font-size: 14px; font-weight: bold;} .jcomments-message-error {background: transparent url(components/com_jcomments/assets/error.gif) no-repeat 4px 50%; color: red;} .jcomments-message-info {background: transparent url(components/com_jcomments/assets/info.gif) no-repeat 4px 50%; color: green;} .jcomments-message-wait {background: transparent url(components/com_jcomments/assets/wait.gif) no-repeat 4px 50%; color: green;} .adminform fieldset { border: 1px #999 solid; } .adminform fieldset input, fieldset select { float: none; } .adminform span.note { color: #777; } table.componentinfo td { color: #777; padding: 0; } </style> <div> <form action="<?php echo JCOMMENTS_INDEX; ?> " method="post" name="adminForm" id="adminForm"> <input type="hidden" name="option" value="com_jcomments" /> <input type="hidden" name="task" value="" /> <?php if (JCOMMENTS_JVERSION == '1.0') { ?> <table class="adminheading"> <tr> <th style="background-image: none; padding: 0;"><img src="components/com_jcomments/assets/icon-48-import.png" width="48" height="48" align="middle" alt="<?php echo JText::_('A_IMPORT'); ?> "> <?php echo JText::_('A_IMPORT'); ?> </th> </tr> </table> <?php } ?> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr valign="top"> <td align="right"> </td> <td width="50%" align="right"><div id="jcomments-message-holder"></div></td> </tr> </table> <table width="100%" border="0" cellpadding="4" cellspacing="2" class="adminform"> <tr> <td> <fieldset> <legend><?php echo JText::_('A_IMPORT_SELECT_SOURCE'); ?> </legend> <table cellpadding="1" cellspacing="1" border="0"> <?php $foundSources = 0; foreach ($CommentSystems as $CommentSystem) { if ($CommentSystem->found) { $foundSources++; ?> <tr valign="top" align="left"> <td><input type="radio" id="import<?php echo $CommentSystem->code; ?> " name="vars[import]" value="<?php echo $CommentSystem->code; ?> " onclick="importMode('<?php echo $CommentSystem->code; ?> ')" <?php echo $CommentSystem->found ? '' : 'disabled'; ?> /></td> <td><label for="import<?php echo $CommentSystem->code; ?> "><?php echo $CommentSystem->name; ?> </label></td> <td><div id="jcomments-message-<?php echo strtolower($CommentSystem->code); ?> "></div></td> </tr> <tr id="import<?php echo $CommentSystem->code; ?> Info" style="display: none;"> <td> </td> <td> <table cellpadding="0" cellspacing="0" border="0" class="componentinfo"> <tr> <td width="150px"><?php echo JText::_('A_IMPORT_COMPONENT_AUTHOR'); ?> </td> <td><?php echo $CommentSystem->author; ?> </td> </tr> <tr> <td><?php echo JText::_('A_IMPORT_COMPONENT_HOMEPAGE'); ?> </td> <td><a href="<?php echo $CommentSystem->homepage; ?> " target="_blank"><?php echo str_replace('http://', '', $CommentSystem->homepage); ?> </a></td> </tr> <tr> <td><?php echo JText::_('A_IMPORT_COMPONENT_LICENSE'); ?> </td> <td> <?php if ($CommentSystem->license_url != '') { ?> <a href="<?php echo $CommentSystem->license_url; ?> " target="_blank"><?php echo $CommentSystem->license; ?> </a> <?php } else { ?> <?php echo $CommentSystem->license; } ?> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr valign="top" align="left"> <td> <?php echo JText::_('A_IMPORT_COMPONENT_COMMENTS_COUNT'); ?> </td> <td> <label for="import<?php echo $CommentSystem->code; ?> "><?php echo $CommentSystem->count; ?> </label> </td> </tr> <tr valign="top" align="left"> <td> </td> <td> <?php if (count($languages)) { echo JCommentsHTML::selectList($languages, strtolower($CommentSystem->code) . '_lang', 'class="inputbox" size="1"', 'value', 'name', $lang) . ' '; } ?> <input type="button" id="btnImport<?php echo $CommentSystem->code; ?> " name="btnImport<?php echo $CommentSystem->code; ?> " value="<?php echo JText::_('A_IMPORT_BUTTON_IMPORT'); ?> " onclick="startCommentsImport('<?php echo $CommentSystem->code; ?> ')" <?php echo $CommentSystem->count ? '' : 'disabled'; ?> /> </td> </tr> <tr> <td colspan="2"> </td> </tr> </table> </td> </tr> <?php } } if ($foundSources == 0) { ?> <tr> <td><?php echo JText::_('A_IMPORT_NO_SOURCES'); ?> </td> </tr> <?php } ?> </table> </fieldset> </td> </tr> </table> <?php echo JCommentsSecurity::formToken(); ?> </form> </div> <?php }
public static function show() { $app = JCommentsFactory::getApplication('administrator'); $context = 'com_jcomments.subscriptions.'; $object_group = trim($app->getUserStateFromRequest($context . 'fog', 'fog', '')); $object_id = intval($app->getUserStateFromRequest($context . 'foid', 'foid', 0)); $flang = trim($app->getUserStateFromRequest($context . 'flang', 'flang', '-1')); $fauthor = trim($app->getUserStateFromRequest($context . 'fauthor', 'fauthor', '')); $fstate = trim($app->getUserStateFromRequest($context . 'fstate', 'fstate', '-1')); $limit = intval($app->getUserStateFromRequest($context . 'limit', 'limit', $app->getCfg('list_limit'))); $limitstart = intval($app->getUserStateFromRequest($context . 'limitstart', 'limitstart', 0)); $filter_order = $app->getUserStateFromRequest($context . 'filter_order', 'filter_order', 'js.name'); $filter_order_Dir = $app->getUserStateFromRequest($context . 'filter_order_Dir', 'filter_order_Dir', 'asc'); $search = trim($app->getUserStateFromRequest($context . 'search', 'search', '')); if (JCOMMENTS_JVERSION == '1.0') { $search = strtolower($search); } else { $search = JString::strtolower($search); } if ($filter_order == '') { $filter_order = 'js.name'; } if ($filter_order_Dir == '') { $filter_order_Dir = 'asc'; } $lists['order'] = $filter_order; $lists['order_Dir'] = $filter_order_Dir; $lists['search'] = $search; $db = JCommentsFactory::getDBO(); $where = array(); if ($object_group != '') { $where[] = 'js.object_group = "' . $db->getEscaped($object_group, true) . '"'; } if ($object_id != 0) { $where[] = 'js.object_id = ' . intval($object_id); } if ($flang != '-1') { $where[] = 'js.lang = "' . $db->getEscaped($flang, true) . '"'; } if ($fauthor != '') { $where[] = 'js.name = "' . $db->getEscaped($fauthor, true) . '"'; } if ($fstate != '' && $fstate != '-1') { $where[] = 'js.published = ' . intval($fstate); } if ($search != '') { $where[] = '(js.name like "%' . $db->getEscaped($search, true) . '%" OR js.email like "%' . $db->getEscaped($search, true) . '%")'; } $query = "SELECT COUNT(*)" . " FROM #__jcomments_subscriptions AS js" . (count($where) ? "\nWHERE " . implode(' AND ', $where) : ""); $db->setQuery($query); $total = $db->loadResult(); $lists['pageNav'] = JCommentsAdmin::getPagination($total, $limitstart, $limit); $query = "SELECT js.*, u.name AS editor" . " FROM #__jcomments_subscriptions AS js" . " LEFT JOIN #__users AS u ON u.id = js.userid" . (count($where) ? " WHERE " . implode(' AND ', $where) : "") . " ORDER BY " . $filter_order . ' ' . $filter_order_Dir; $db->setQuery($query, $lists['pageNav']->limitstart, $lists['pageNav']->limit); $lists['rows'] = $db->loadObjectList(); // Filter by object_group (component) $query = "SELECT DISTINCT(object_group) AS name, object_group AS value " . " FROM #__jcomments_subscriptions" . " ORDER BY name"; $db->setQuery($query); $rows = $db->loadObjectList(); $cnt = count($rows); if ($cnt > 1 || $cnt == 1 && $total == 0) { array_unshift($rows, JCommentsHTML::makeOption('', JText::_('A_FILTER_COMPONENT'), 'name', 'value')); $lists['fog'] = JCommentsHTML::selectList($rows, 'fog', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'name', 'value', $object_group); } else { if ($cnt == 1) { if ($object_group == '') { $object_group = $rows[0]->name; } } } unset($rows); if ($object_group != '') { $query = "SELECT DISTINCT object_id AS value, lang " . " FROM #__jcomments_subscriptions " . " WHERE object_group = " . $db->Quote($object_group) . ($flang != '-1' ? " AND lang = " . $db->Quote($flang) : ""); $db->setQuery($query); $rows = $db->loadObjectList(); for ($i = 0, $n = count($rows); $i < $n; $i++) { $rows[$i]->name = JCommentsObjectHelper::getTitle($rows[$i]->value, $object_group, $rows[$i]->lang); if ($rows[$i]->name == '') { $rows[$i]->name = 'Untitled' . $rows[$i]->value; } } // Don't show filter if we have more than 100 objects if (count($rows) > 1 && count($rows) < 100) { usort($rows, create_function('$a, $b', 'return strcasecmp( $a->name, $b->name);')); array_unshift($rows, JCommentsHTML::makeOption('', JText::_('A_FILTER_OBJECT'), 'value', 'name')); $lists['foid'] = JCommentsHTML::selectList($rows, 'foid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'name', $object_id); unset($rows); } } // Filter by language $query = "SELECT DISTINCT(lang) AS text, lang AS value " . " FROM #__jcomments_subscriptions" . " ORDER BY lang"; $db->setQuery($query); $rows = $db->loadObjectList(); if (count($rows) > 1) { array_unshift($rows, JCommentsHTML::makeOption('-1', JText::_('A_FILTER_LANGUAGE'), 'text', 'value')); $lists['flang'] = JCommentsHTML::selectList($rows, 'flang', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'text', 'value', $flang); } unset($rows); // Filter by published state $stateOptions = array(); $stateOptions[] = JCommentsHTML::makeOption('-1', JText::_('A_FILTER_STATE'), 'text', 'value'); $stateOptions[] = JCommentsHTML::makeOption('', JText::_('A_FILTER_STATE_ALL'), 'text', 'value'); $stateOptions[] = JCommentsHTML::makeOption('1', JText::_('A_FILTER_STATE_PUBLISHED'), 'text', 'value'); $stateOptions[] = JCommentsHTML::makeOption('0', JText::_('A_FILTER_STATE_UNPUBLISHED'), 'text', 'value'); $lists['fstate'] = JCommentsHTML::selectList($stateOptions, 'fstate', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'text', 'value', $fstate); unset($stateOptions); // Filter by author $lists['fauthor'] = ''; $db->setQuery("SELECT COUNT(DISTINCT(name)) FROM #__jcomments_subscriptions;"); $usersCount = $db->loadResult(); // Don't show filter if we have more than 100 comments' authors if ($usersCount > 0 && $usersCount < 100) { $query = "SELECT DISTINCT(name) AS author, name AS value " . " FROM #__jcomments_subscriptions" . " ORDER BY name"; $db->setQuery($query); $rows = $db->loadObjectList(); if (count($rows) > 1) { array_unshift($rows, JCommentsHTML::makeOption('', JText::_('A_FILTER_AUTHOR'), 'author', 'value')); $lists['fauthor'] = JCommentsHTML::selectList($rows, 'fauthor', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'author', 'value', $fauthor); } unset($rows); } HTML_JCommentsAdminSubscriptionManager::show($lists); }
public static function isEnabled() { static $enabled = null; if (!isset($enabled)) { $app = JCommentsFactory::getApplication(); $enabled = $app->getCfg('multilingual_support') == 1; if (JCOMMENTS_JVERSION == '1.7') { if ($app->isSite()) { $enabled = $app->getLanguageFilter(); } else { $db = JFactory::getDBO(); $db->setQuery("SELECT COUNT(*) FROM `#__extensions` WHERE `element` = 'languagefilter' AND `enabled` = 1"); $enabled = $db->loadResult() > 0; } } // check if multilingual_support if ($enabled) { $config = JCommentsFactory::getConfig(); $enabled = $config->get('multilingual_support', $enabled); } } return $enabled; }
public static function getPagination($total, $limitstart, $limit) { if (JCOMMENTS_JVERSION == '1.0') { $app = JCommentsFactory::getApplication(); require_once $app->getCfg('absolute_path') . '/administrator/includes/pageNavigation.php'; $pagination = new mosPageNav($total, $limitstart, $limit); } else { jimport('joomla.html.pagination'); $pagination = new JPagination($total, $limitstart, $limit); } return $pagination; }
public static function redirectToObject() { $app = JCommentsFactory::getApplication('site'); $object_id = (int) JCommentsInput::getVar('object_id', 0); $object_group = trim(strip_tags(JCommentsInput::getVar('object_group', 'com_content'))); $lang = trim(strip_tags(JCommentsInput::getVar('lang'))); if ($object_id != 0 && $object_group != '') { $link = JCommentsObjectHelper::getLink($object_id, $object_group, $lang); $link = str_replace('amp;', '', $link); if ($link == '') { $link = $app->getCfg('live_site'); } } else { $link = $app->getCfg('live_site'); } JCommentsRedirect($link); }
public static function RefreshObjects($hash, $step = 0, $object_group = '', $lang = '') { if (JCommentsSecurity::badRequest() == 1) { JCommentsSecurity::notAuth(); } $response = JCommentsFactory::getAjaxResponse(); $app = JCommentsFactory::getApplication(); $count = 50; if ($hash === md5($app->getCfg('secret'))) { $db = JCommentsFactory::getDBO(); if ($step == 0) { $db->setQuery('DELETE FROM #__jcomments_objects WHERE 1=1'); $db->query(); } $where = array(); $where[] = 'IFNULL(c.lang, "") <> ""'; if (!empty($object_group)) { $where[] = 'c.object_group = ' . $db->Quote($object_group); } // count objects without information $query = "SELECT COUNT(DISTINCT c.object_id, c.object_group, c.lang)" . " FROM #__jcomments AS c" . (count($where) ? "\nWHERE " . implode(' AND ', $where) : ""); $db->setQuery($query); $objectsCount = (int) $db->loadResult(); $where[] = 'NOT EXISTS (SELECT o.id FROM #__jcomments_objects AS o WHERE o.object_id = c.object_id AND o.object_group = c.object_group AND o.lang = c.lang)'; // get list of first objects without information $query = "SELECT DISTINCT c.object_id, c.object_group, c.lang" . " FROM #__jcomments AS c" . (count($where) ? "\nWHERE " . implode(' AND ', $where) : "") . " ORDER BY c.object_group, c.lang"; $db->setQuery($query, 0, $count); $rows = $db->loadObjectList(); $i = 0; $multilanguage = JCommentsMultilingual::isEnabled(); $nextLanguage = $lang; if (count($rows)) { foreach ($rows as $row) { if ($nextLanguage != $row->lang && $multilanguage) { $nextLanguage = $row->lang; break; } // retrieve and store object information JCommentsObjectHelper::storeObjectInfo($row->object_id, $row->object_group, $row->lang, false, true); $i++; } } $objectsRefreshed = 0; if ($i > 0) { $db->setQuery("SELECT COUNT(*) FROM #__jcomments_objects"); $objectsRefreshed = (int) $db->loadResult(); $response->addScript("JCommentsRefreshObjectsProgress({$objectsRefreshed}, {$objectsCount});"); } if ($objectsCount > $objectsRefreshed && ($i > 0 || $lang != $nextLanguage)) { // we need continue refresh $step++; $response->addScript("JCommentsRefreshObjectsAJAX('{$hash}', '{$step}', '', '{$nextLanguage}');"); } else { $response->addScript("JCommentsRefreshObjectsProgress({$objectsCount}, {$objectsCount});"); if ($app->getCfg('caching')) { // clean cache for all object groups $db->setQuery('SELECT DISTINCT object_group FROM #__jcomments_objects'); $rows = $db->loadResultArray(); foreach ($rows as $row) { $cache = JCommentsFactory::getCache('com_jcomments_objects_' . strtolower($row)); $cache->clean(); } } } } return $response; }
public static function showUserComments() { $config = JCommentsFactory::getConfig(); if ($config->get('enable_rss') == '1') { $app = JCommentsFactory::getApplication('site'); $acl = JCommentsFactory::getACL(); $userid = (int) JCommentsInput::getVar('userid', 0); $limit = (int) JCommentsInput::getVar('limit', $config->getInt('feed_limit', 100)); $user = JCommentsFactory::getUser($userid); if (!isset($user->id)) { self::showNotFound(); return; } if (JCOMMENTS_JVERSION == '1.0') { $offset = $app->getCfg('offset') + date('O') / 100; } else { $offset = $app->getCfg('offset'); } $lm = $limit != $config->getInt('feed_limit') ? '&limit=' . $limit : ''; if (JCommentsMultilingual::isEnabled()) { $language = JCommentsMultilingual::getLanguage(); $lp = '&lang=' . $language; } else { $language = null; $lp = ''; } if (JCOMMENTS_JVERSION == '1.0') { $syndicationURL = $app->getCfg('live_site') . '/index2.php?option=com_jcomments&task=rss_user&userid=' . $userid . $lm . $lp . '&no_html=1'; } else { $liveSite = str_replace(JURI::root(true), '', $app->getCfg('live_site')); $syndicationURL = $liveSite . JRoute::_('index.php?option=com_jcomments&task=rss_user&userid=' . $userid . $lm . $lp . '&tmpl=raw'); } $user->userid = $user->id; $username = JComments::getCommentAuthorName($user); $rss = new JoomlaTuneFeed(); $rss->setOffset($offset); $rss->encoding = JCOMMENTS_ENCODING; $rss->title = JText::sprintf('USER_FEED_TITLE', $username); $rss->link = $app->getCfg('live_site'); $rss->syndicationURL = $syndicationURL; $rss->description = JText::sprintf('USER_FEED_DESCRIPTION', $username); $options = array(); $options['lang'] = $language; $options['userid'] = $userid; $options['published'] = 1; $options['filter'] = 'c.deleted = 0'; $options['orderBy'] = 'c.date DESC'; $options['votes'] = false; $options['limit'] = $limit; $options['limitStart'] = 0; $options['objectinfo'] = true; $options['access'] = $acl->getUserAccess(); $rows = JCommentsModel::getCommentsList($options); $word_maxlength = $config->getInt('word_maxlength'); $lang = JCommentsMultilingual::isEnabled() ? JCommentsMultilingual::getLanguage() : null; foreach ($rows as $row) { $comment = JCommentsText::cleanText($row->comment); if ($comment != '') { // getting object's information (title and link) $object_title = empty($row->object_title) ? JCommentsObjectHelper::getTitle($row->object_id, $row->object_group, $lang) : $row->object_title; $object_link = empty($row->object_link) ? JCommentsObjectHelper::getLink($row->object_id, $row->object_group, $lang) : $row->object_link; $object_link = JCommentsFactory::getAbsLink(str_replace('amp;', '', $object_link)); // apply censor filter $object_title = JCommentsText::censor($object_title); $comment = JCommentsText::censor($comment); // fix long words problem if ($word_maxlength > 0) { $comment = JCommentsText::fixLongWords($comment, $word_maxlength, ' '); if ($object_title != '') { $object_title = JCommentsText::fixLongWords($object_title, $word_maxlength, ' '); } } $author = JComments::getCommentAuthorName($row); $item = new JoomlaTuneFeedItem(); $item->title = $object_title; $item->link = $object_link . '#comment-' . $row->id; $item->description = JText::sprintf('USER_FEED_ITEM_DESCRIPTION', $author, $comment); $item->source = $object_link; if (JCOMMENTS_JVERSION == '1.0') { $date = strtotime((string) $row->date) - $offset * 3600; $item->pubDate = date('Y-m-d H:i:s', $date); } else { $item->pubDate = $row->date; } $item->author = $author; $rss->addItem($item); } } $rss->display(); unset($rows, $rss); exit; } }
/** * Returns URI for given object * * @param int $object_id * @param string $object_group * @param string $language * @return string */ public static function getLink($object_id, $object_group = 'com_content', $language = null) { $app = JCommentsFactory::getApplication(); return $app->getCfg('live_site') . '/' . JCOMMENTS_INDEX . '?option=com_jcomments&task=go2object&object_id=' . $object_id . '&object_group=' . $object_group . '&lang=' . $language . (JCOMMENTS_JVERSION == '1.0' ? '&no_html=1' : '&tmpl=raw'); }
function showInstallLog() { $app = JCommentsFactory::getApplication('administrator'); require_once dirname(__FILE__) . DS . 'version.php'; $version = new JCommentsVersion(); if (version_compare(phpversion(), '5.1.0') >= 0) { date_default_timezone_set('UTC'); } if (JCOMMENTS_JVERSION == '1.7') { JHtml::_('behavior.framework'); } ?> <script type="text/javascript"> <!-- <?php if (JCOMMENTS_JVERSION == '1.7') { ?> Joomla.submitbutton = function (task) { Joomla.submitform(task, document.getElementById('adminForm')); }; <?php } else { ?> function submitbutton(task) { submitform(task); } <?php } ?> //--> </script> <link rel="stylesheet" href="<?php echo $app->getCfg('live_site'); ?> /administrator/components/com_jcomments/assets/style.css?v=<?php echo $version->getVersion(); ?> " type="text/css" /> <div id="jc"> <div class="jcomments-box"> <div class="m"> <table width="95%" cellpadding="0" cellspacing="0"> <tr> <td width="50px"><img src="<?php echo $app->getCfg('live_site'); ?> /administrator/components/com_jcomments/assets/icon-48-jcomments.png" border="0" alt="" /></td> <td><span class="componentname"><?php echo $version->getLongVersion(); ?> </span> <span class="componentdate">[<?php echo $version->getReleaseDate(); ?> ]</span><br /> <span class="copyright">© 2006-<?php echo date('Y'); ?> smart (<a href="http://www.joomlatune.ru" target="_blank">JoomlaTune.ru</a> | <a href="http://www.joomlatune.com" target="_blank">JoomlaTune.com</a>). <?php echo JText::_('A_ABOUT_COPYRIGHT'); ?> <br /></span></td> </tr> <tr> <td> </td> <td> </td> </tr> <?php if (count($this->messages)) { ?> <tr> <td> </td> <td><span class="installheader"><?php echo JText::_('A_INSTALL_LOG'); ?> </span> </td> </tr> <tr> <td> </td> <td> <ul> <?php foreach ($this->messages as $message) { $class = $message['status'] ? 'status-ok' : 'status-error'; $text = $message['status'] ? JText::_('A_INSTALL_STATE_OK') : JText::_('A_INSTALL_STATE_ERROR'); ?> <li><?php echo $message['text']; ?> : <span class="<?php echo $class; ?> "><?php echo $text; ?> </span></li> <?php } ?> <li><span class="status-ok"><strong><?php echo JText::_('A_INSTALL_COMPLETE'); ?> </strong></span></li> </ul> </td> </tr> <tr> <td></td> <td align="center" style="text-align: right;"> <div class="button-left"><div class="next"><a href="<?php echo $app->getCfg('live_site'); ?> /administrator/<?php echo JCOMMENTS_INDEX; ?> ?option=com_jcomments&task=settings"><?php echo JText::_('A_INSTALL_BUTTON_NEXT'); ?> </a></div></div> </td> </tr> <?php } ?> </table> </div> </div> <form action="<?php echo JCOMMENTS_INDEX; ?> " method="post" name="adminForm" id="adminForm"> <input type="hidden" name="option" value="com_jcomments" /> <input type="hidden" name="task" value="" /> </form> <?php }
public static function show($lists) { $app = JCommentsFactory::getApplication('administrator'); include_once JCOMMENTS_HELPERS . DS . 'system.php'; $link = JCommentsSystemPluginHelper::getCSS(); if (JCOMMENTS_JVERSION == '1.0') { $app->addCustomHeadTag('<link href="' . $link . '" rel="stylesheet" type="text/css" />'); } else { $document = JFactory::getDocument(); $document->addStyleSheet($link); } ?> <form action="<?php echo JCOMMENTS_INDEX; ?> " method="post" name="adminForm" id="adminForm"> <table class="adminheading"> <tr> <?php if (JCOMMENTS_JVERSION == '1.0') { ?> <th style="background-image: none; padding: 0;"><img src="components/com_jcomments/assets/icon-48-custombbcodes.png" width="48" height="48" align="middle" alt="<?php echo JText::_('A_CUSTOM_BBCODE'); ?> " /> <?php echo JText::_('A_CUSTOM_BBCODE'); ?> </th> <?php } ?> <td nowrap="nowrap" align="right"></td> </tr> </table> <table id="jc" class="adminlist" cellspacing="1"> <thead> <tr> <th width="1%"><input type="checkbox" id="toggle" name="toggle" value="" onclick="checkAll(<?php echo count($lists['rows']); ?> );" /></th> <th width="30%" align="left" nowrap="nowrap"><?php echo JText::_('A_CUSTOM_BBCODE_NAME'); ?> </th> <th width="50%" class="title"><?php echo JText::_('A_CUSTOM_BBCODE_PATTERN'); ?> </th> <th width="16" align="center"><?php echo JText::_('A_CUSTOM_BBCODE_BUTTON_ICON'); ?> </th> <th width="4%"><?php echo JText::_('A_ORDERING'); ?> </th> <th width="5%"><?php echo JText::_('A_CUSTOM_BBCODE_BUTTON'); ?> </th> <th width="5%"><?php echo JText::_('A_PUBLISHING'); ?> </th> </tr> </thead> <tbody> <?php for ($i = 0, $k = 0, $n = count($lists['rows']); $i < $n; $i++) { $row =& $lists['rows'][$i]; $buttonStateTask = $row->button_enabled ? 'custombbcodes.disable_button' : 'custombbcodes.enable_button'; if (JCOMMENTS_JVERSION == '1.7') { $buttonStateClass = $row->button_enabled ? 'publish' : 'unpublish'; $buttonStateText = $row->button_enabled ? JText::_('JENABLED') : JText::_('JDISABLED'); $buttonStateTitle = addslashes(htmlspecialchars($buttonStateText, ENT_COMPAT, 'UTF-8')); $buttonState = '<span class="state ' . $buttonStateClass . '"><span class="text">' . $buttonStateText . '</span></span>'; } else { $buttonStateTitle = $row->button_enabled ? JText::_('A_DISABLE') : JText::_('A_ENABLE'); $buttonState = '<img src="images/' . ($row->button_enabled ? 'tick.png' : 'publish_x.png') . '" border="0" alt="' . $buttonStateTitle . '" />'; } $icon = ''; if ($row->button_image != '') { $icon = '<img src="' . $app->getCfg('live_site') . '/' . $row->button_image . '" alt="' . $row->name . '" />'; } else { if ($row->button_css != '') { $icon = '<span class="bbcode" style="width: 23px;"><a href="#" onclick="return false;" class="' . $row->button_css . '"></a></span>'; } } $link = JCOMMENTS_INDEX . '?option=com_jcomments&task=custombbcodes.edit&hidemainmenu=1&cid=' . $row->id; ?> <tr valign="middle" class="<?php echo "row{$k}"; ?> "> <td align="center"><?php echo JCommentsHTML::_('grid.id', $row, $i); ?> </td> <td align="left"><a href="<?php echo $link; ?> " title="<?php echo JText::_('A_EDIT'); ?> "><?php echo $row->name; ?> </a></td> <td align="left"><?php echo $row->simple_pattern; ?> </td> <td align="center"><?php echo $icon; ?> </td> <td class="order" align="center"> <span><?php echo $lists['pageNav']->orderUpIcon($i, true, 'custombbcodes.orderup'); ?> </span> <span><?php echo $lists['pageNav']->orderDownIcon($i, $n, true, 'custombbcodes.orderdown'); ?> </span> </td> <td align="center"><a class="jgrid" href="javascript: void(0);" onclick="return listItemTask('cb<?php echo $i; ?> ','<?php echo $buttonStateTask; ?> ')" title="<?php echo $buttonStateTitle; ?> "><?php echo $buttonState; ?> </a></td> <td align="center"><?php echo JCommentsHTML::_('grid.published', $row, $i, 'custombbcodes.'); ?> </td> </tr> <?php $k = 1 - $k; } ?> </tbody> <tfoot> <tr> <td colspan="15"><?php echo $lists['pageNav']->getListFooter(); ?> </td> </tr> </tfoot> </table> <input type="hidden" name="option" value="com_jcomments" /> <input type="hidden" name="task" value="custombbcodes" /> <input type="hidden" name="boxchecked" value="0" /> <input type="hidden" name="hidemainmenu" value="0" /> <?php echo JCommentsSecurity::formToken(); ?> </form> <?php }