本文整理汇总了PHP中JComments::getCommentsForm方法的典型用法代码示例。如果您正苦于以下问题:PHP JComments::getCommentsForm方法的具体用法?PHP JComments::getCommentsForm怎么用?PHP JComments::getCommentsForm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JComments
的用法示例。
在下文中一共展示了JComments::getCommentsForm方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: quoteComment
function quoteComment($id, $loadForm = 0)
{
if (JCommentsSecurity::badRequest() == 1) {
JCommentsSecurity::notAuth();
}
$db =& JCommentsFactory::getDBO();
$acl =& JCommentsFactory::getACL();
$config =& JCommentsFactory::getConfig();
$response =& JCommentsFactory::getAjaxResponse();
$comment = new JCommentsDB($db);
$id = (int) $id;
if ($comment->load($id)) {
$comment_name = JComments::getCommentAuthorName($comment);
$comment_text = JCommentsText::br2nl($comment->comment);
if ($config->getInt('enable_nested_quotes') == 0) {
$bbcode =& JCommentsFactory::getBBCode();
$comment_text = $bbcode->removeQuotes($comment_text);
}
if ($config->getInt('enable_custom_bbcode')) {
$customBBCode =& JCommentsFactory::getCustomBBCode();
$comment_text = $customBBCode->filter($comment_text, true);
}
if ($acl->getUserId() == 0) {
$bbcode =& JCommentsFactory::getBBCode();
$comment_text = $bbcode->removeHidden($comment_text);
}
if ($comment_text != '') {
if ($acl->check('enable_autocensor')) {
$comment_text = JCommentsText::censor($comment_text);
}
if (intval($loadForm) == 1) {
$form = JComments::getCommentsForm($comment->object_id, $comment->object_group, true);
$response->addAssign('comments-form-link', 'innerHTML', $form);
}
$comment_text = JCommentsText::jsEscape($comment_text);
$text = "[quote name=\"" . $comment_name . "\"]" . $comment_text . "[/quote]\\n";
$response->addScript("jcomments.insertText('" . $text . "');");
} else {
$response->addAlert(JText::_('ERROR_NOTHING_TO_QUOTE'));
}
}
unset($comment);
return $response;
}
示例2: show
function show($object_id, $object_group = 'com_content', $object_title = '', $search_text = '')
{
$object_id = (int) $object_id;
$object_group = trim($object_group);
$object_title = trim($object_title);
$acl =& JCommentsFactory::getACL();
$config =& JCommentsFactory::getConfig();
$JLMS_CONFIG =& JLMSFactory::getConfig();
$app =& JFactory::getApplication();
$tmpl =& JCommentsFactory::getTemplate($object_id, $object_group);
$tmpl->load('tpl_index');
if ($config->getInt('object_locked', 0) == 1) {
$config->set('enable_rss', 0);
$tmpl->addVar('tpl_index', 'comments-form-locked', 1);
}
if (JCOMMENTS_JVERSION == '1.5') {
$document =& JFactory::getDocument();
}
if (!defined('JCOMMENTS_CSS')) {
include_once JCOMMENTS_HELPERS . DS . 'system.php';
if ($app->isAdmin()) {
$tmpl->addVar('tpl_index', 'comments-css', 1);
} else {
$link = JCommentsSystemPluginHelper::getCSS();
$document->addStyleSheet($link);
}
}
if (!defined('JCOMMENTS_JS')) {
include_once JCOMMENTS_HELPERS . DS . 'system.php';
if ($config->getInt('gzip_js') == 1) {
$document->addScript(JCommentsSystemPluginHelper::getCompressedJS());
} else {
$document->addScript(JCommentsSystemPluginHelper::getCoreJS());
if (!defined('JOOMLATUNE_AJAX_JS')) {
$document->addScript(JCommentsSystemPluginHelper::getAjaxJS());
define('JOOMLATUNE_AJAX_JS', 1);
}
}
}
$tmpl->addVar('tpl_index', 'comments-form-captcha', $acl->check('enable_captcha'));
$tmpl->addVar('tpl_index', 'comments-form-link', $config->getInt('form_show') ? 0 : 1);
if ($config->getInt('enable_rss') == 1) {
$link = JCommentsFactory::getLink('rss', $object_id, $object_group);
$attribs = array('type' => 'application/rss+xml', 'title' => strip_tags($object_title));
$document->addHeadLink($link, 'alternate', 'rel', $attribs);
}
$cacheEnabled = intval($JLMS_CONFIG->get('caching')) == 1;
if ($cacheEnabled == 0) {
$jrecache = $JLMS_CONFIG->get('absolute_path') . DS . 'components' . DS . 'com_jrecache' . DS . 'jrecache.config.php';
if (is_file($jrecache)) {
$cfg = new _JRECache_Config();
$cacheEnabled = $cacheEnabled && $cfg->enable_cache;
}
}
$load_cached_comments = $config->getInt('load_cached_comments', 0);
if ($cacheEnabled) {
$tmpl->addVar('tpl_index', 'comments-anticache', 1);
}
if (!$cacheEnabled || $load_cached_comments === 1) {
if ($config->get('template_view') == 'tree' && !strlen($search_text)) {
$tmpl->addVar('tpl_index', 'comments-list', JLMS_JComments::getCommentsTree($object_id, $object_group, $search_text));
} else {
$tmpl->addVar('tpl_index', 'comments-list', JLMS_JComments::getCommentsList($object_id, $object_group, $search_text));
}
}
$needScrollToComment = $cacheEnabled || $config->getInt('comments_per_page') > 0;
$tmpl->addVar('tpl_index', 'comments-gotocomment', (int) $needScrollToComment);
$tmpl->addVar('tpl_index', 'comments-form', JComments::getCommentsForm($object_id, $object_group, $config->getInt('form_show') == 1));
$result = $tmpl->renderTemplate('tpl_index');
$tmpl->freeAllTemplates();
return $result;
}
示例3: show
public static function show($object_id, $object_group = 'com_content', $object_title = '')
{
// only one copy of JComments per page is allowed
if (defined('JCOMMENTS_SHOW')) {
return '';
}
$app = JFactory::getApplication('site');
$object_group = JCommentsSecurity::clearObjectGroup($object_group);
if ($object_group == '' || !isset($object_id) || $object_id == '') {
return '';
}
$object_id = (int) $object_id;
$object_title = trim($object_title);
$acl = JCommentsFactory::getACL();
$config = JCommentsFactory::getConfig();
$document = JFactory::getDocument();
$tmpl = JCommentsFactory::getTemplate($object_id, $object_group);
$tmpl->load('tpl_index');
if (!defined('JCOMMENTS_CSS')) {
include_once JCOMMENTS_HELPERS . '/system.php';
if ($app->isAdmin()) {
$tmpl->addVar('tpl_index', 'comments-css', 1);
} else {
$document->addStyleSheet(JCommentsSystemPluginHelper::getCSS());
$language = JFactory::getLanguage();
if ($language->isRTL()) {
$rtlCSS = JCommentsSystemPluginHelper::getCSS(true);
if ($rtlCSS != '') {
$document->addStyleSheet($rtlCSS);
}
}
}
}
if (!defined('JCOMMENTS_JS')) {
include_once JCOMMENTS_HELPERS . '/system.php';
$document->addScript(JCommentsSystemPluginHelper::getCoreJS());
define('JCOMMENTS_JS', 1);
if (!defined('JOOMLATUNE_AJAX_JS')) {
$document->addScript(JCommentsSystemPluginHelper::getAjaxJS());
define('JOOMLATUNE_AJAX_JS', 1);
}
}
$commentsCount = JComments::getCommentsCount($object_id, $object_group);
$commentsPerObject = $config->getInt('max_comments_per_object');
$showForm = $config->getInt('form_show') == 1 || $config->getInt('form_show') == 2 && $commentsCount == 0;
if ($commentsPerObject != 0 && $commentsCount >= $commentsPerObject) {
$config->set('comments_locked', 1);
}
if ($config->getInt('comments_locked', 0) == 1) {
$config->set('enable_rss', 0);
$tmpl->addVar('tpl_index', 'comments-form-locked', 1);
$acl->setCommentsLocked(true);
}
$tmpl->addVar('tpl_index', 'comments-form-captcha', $acl->check('enable_captcha'));
$tmpl->addVar('tpl_index', 'comments-form-link', $showForm ? 0 : 1);
if ($config->getInt('enable_rss') == 1) {
if ($document->getType() == 'html') {
$link = JCommentsFactory::getLink('rss', $object_id, $object_group);
$title = htmlspecialchars($object_title, ENT_COMPAT, 'UTF-8');
$attribs = array('type' => 'application/rss+xml', 'title' => $title);
$document->addHeadLink($link, 'alternate', 'rel', $attribs);
}
}
$cacheEnabled = intval($app->getCfg('caching')) != 0;
if ($cacheEnabled == 0) {
$jrecache = JPATH_ROOT . '/components/com_jrecache/jrecache.config.php';
if (is_file($jrecache)) {
$cfg = new _JRECache_Config();
$cacheEnabled = $cacheEnabled && $cfg->enable_cache;
}
}
$load_cached_comments = intval($config->getInt('load_cached_comments', 0) && $commentsCount > 0);
if ($cacheEnabled) {
$tmpl->addVar('tpl_index', 'comments-anticache', 1);
}
if (!$cacheEnabled || $load_cached_comments === 1) {
if ($config->get('template_view') == 'tree') {
$tmpl->addVar('tpl_index', 'comments-list', $commentsCount > 0 ? JComments::getCommentsTree($object_id, $object_group) : '');
} else {
$tmpl->addVar('tpl_index', 'comments-list', $commentsCount > 0 ? JComments::getCommentsList($object_id, $object_group) : '');
}
}
$needScrollToComment = ($cacheEnabled || $config->getInt('comments_per_page') > 0) && $commentsCount > 0;
$tmpl->addVar('tpl_index', 'comments-gotocomment', (int) $needScrollToComment);
$tmpl->addVar('tpl_index', 'comments-form', JComments::getCommentsForm($object_id, $object_group, $showForm));
$tmpl->addVar('tpl_index', 'comments-form-position', $config->getInt('form_position'));
$result = $tmpl->renderTemplate('tpl_index');
$tmpl->freeAllTemplates();
// send notifications
srand((double) microtime() * 10000000);
$randValue = intval(rand(0, 100));
if ($randValue <= 30) {
JCommentsNotificationHelper::send();
}
define('JCOMMENTS_SHOW', 1);
return $result;
}
示例4: show
function show($object_id, $object_group = 'com_content', $object_title = '')
{
global $mainframe;
// only one copy of JComments per page is allowed
if (defined('JCOMMENTS_SHOW')) {
return;
}
$object_id = (int) $object_id;
$object_group = trim(strip_tags($object_group));
$object_group = preg_replace('#[^0-9A-Za-z\\-\\_\\,\\.]#is', '', $object_group);
$object_title = trim($object_title);
$acl =& JCommentsFactory::getACL();
$config =& JCommentsFactory::getConfig();
$tmpl =& JCommentsFactory::getTemplate($object_id, $object_group);
$tmpl->load('tpl_index');
if ($config->getInt('comments_locked', 0) == 1) {
$config->set('enable_rss', 0);
$tmpl->addVar('tpl_index', 'comments-form-locked', 1);
}
if (JCOMMENTS_JVERSION == '1.5') {
$document =& JFactory::getDocument();
}
if (!defined('JCOMMENTS_CSS')) {
include_once JCOMMENTS_HELPERS . DS . 'system.php';
if ($mainframe->isAdmin()) {
$tmpl->addVar('tpl_index', 'comments-css', 1);
} else {
$link = JCommentsSystemPluginHelper::getCSS();
if (JCOMMENTS_JVERSION == '1.5') {
$document->addStyleSheet($link);
$language =& JFactory::getLanguage();
if ($language->isRTL()) {
$rtlCSS = JCommentsSystemPluginHelper::getCSS(true);
if ($rtlCSS != '') {
$document->addStyleSheet($rtlCSS);
}
}
} else {
$mainframe->addCustomHeadTag('<link href="' . $link . '" rel="stylesheet" type="text/css" />');
}
}
}
if (!defined('JCOMMENTS_JS')) {
include_once JCOMMENTS_HELPERS . DS . 'system.php';
if (JCOMMENTS_JVERSION == '1.5') {
$document->addScript(JCommentsSystemPluginHelper::getCoreJS());
} else {
$mainframe->addCustomHeadTag(JCommentsSystemPluginHelper::getCoreJS(true));
}
if (!defined('JOOMLATUNE_AJAX_JS')) {
if (JCOMMENTS_JVERSION == '1.5') {
$document->addScript(JCommentsSystemPluginHelper::getAjaxJS());
} else {
$mainframe->addCustomHeadTag(JCommentsSystemPluginHelper::getAjaxJS(true));
}
define('JOOMLATUNE_AJAX_JS', 1);
}
}
$commentsCount = JCommentsModel::getCommentsCount($object_id, $object_group);
$showForm = $config->getInt('form_show') == 1 || $config->getInt('form_show') == 2 && $commentsCount == 0;
$tmpl->addVar('tpl_index', 'comments-form-captcha', $acl->check('enable_captcha'));
$tmpl->addVar('tpl_index', 'comments-form-link', $showForm ? 0 : 1);
if ($config->getInt('enable_rss') == 1) {
$link = JCommentsFactory::getLink('rss', $object_id, $object_group);
if (JCOMMENTS_JVERSION == '1.5') {
$attribs = array('type' => 'application/rss+xml', 'title' => strip_tags($object_title));
$document->addHeadLink($link, 'alternate', 'rel', $attribs);
} else {
$html = '<link rel="alternate" type="application/rss+xml" title="' . strip_tags($object_title) . '" href="' . $link . '" />';
$mainframe->addCustomHeadTag($html);
}
}
$cacheEnabled = intval($mainframe->getCfg('caching')) == 1;
if ($cacheEnabled == 0) {
$jrecache = $mainframe->getCfg('absolute_path') . DS . 'components' . DS . 'com_jrecache' . DS . 'jrecache.config.php';
if (is_file($jrecache)) {
$cfg = new _JRECache_Config();
$cacheEnabled = $cacheEnabled && $cfg->enable_cache;
}
}
$load_cached_comments = intval($config->getInt('load_cached_comments', 0) && $commentsCount > 0);
if ($cacheEnabled && $commentsCount > 0) {
$tmpl->addVar('tpl_index', 'comments-anticache', 1);
}
if (!$cacheEnabled || $load_cached_comments === 1) {
if ($config->get('template_view') == 'tree') {
$tmpl->addVar('tpl_index', 'comments-list', $commentsCount > 0 ? JComments::getCommentsTree($object_id, $object_group) : '');
} else {
$tmpl->addVar('tpl_index', 'comments-list', $commentsCount > 0 ? JComments::getCommentsList($object_id, $object_group) : '');
}
}
$needScrollToComment = ($cacheEnabled || $config->getInt('comments_per_page') > 0) && $commentsCount > 0;
$tmpl->addVar('tpl_index', 'comments-gotocomment', (int) $needScrollToComment);
$tmpl->addVar('tpl_index', 'comments-form', JComments::getCommentsForm($object_id, $object_group, $showForm));
$result = $tmpl->renderTemplate('tpl_index');
$tmpl->freeAllTemplates();
define('JCOMMENTS_SHOW', 1);
return $result;
}