Example #1
0
 function closeTags($comment, $tag, $endTag)
 {
     if (substr_count(strtolower($comment), $tag) > substr_count(strtolower($comment), $endTag)) {
         $comment .= $endTag;
         $comment = PhocaGalleryComment::closeTags($comment, $tag, $endTag);
     }
     return $comment;
 }
Example #2
0
 function comment()
 {
     JRequest::checkToken() or jexit('Invalid Token');
     phocagalleryimport('phocagallery.comment.comment');
     phocagalleryimport('phocagallery.comment.commentimage');
     $app = JFactory::getApplication();
     $user =& JFactory::getUser();
     $view = JRequest::getVar('view', '', 'post', '', 0);
     $catid = JRequest::getVar('catid', '', 'post', 'string', 0);
     $id = JRequest::getVar('id', '', 'post', 'string', 0);
     $post['title'] = JRequest::getVar('phocagallerycommentstitle', '', 'post', 'string', 0);
     $post['comment'] = JRequest::getVar('phocagallerycommentseditor', '', 'post', 'string', 0);
     $Itemid = JRequest::getVar('Itemid', 0, '', 'int');
     $limitStart = JRequest::getVar('limitstart', 0, '', 'int');
     $tab = JRequest::getVar('tab', 0, '', 'int');
     $neededAccessLevels = PhocaGalleryAccess::getNeededAccessLevels();
     $access = PhocaGalleryAccess::isAccess($user->authorisedLevels(), $neededAccessLevels);
     $params =& $app->getParams();
     $detailWindow = $params->get('detail_window', 0);
     $maxCommentChar = $params->get('max_comment_char', 1000);
     $displayCommentNoPopup = $params->get('display_comment_nopup', 0);
     // Maximum of character, they will be saved in database
     $post['comment'] = substr($post['comment'], 0, (int) $maxCommentChar);
     if ($detailWindow == 7 || $displayCommentNoPopup == 1) {
         $tmplCom = '';
     } else {
         $tmplCom = '&tmpl=component';
     }
     // Close Tags
     $post['comment'] = PhocaGalleryComment::closeTags($post['comment'], '[u]', '[/u]');
     $post['comment'] = PhocaGalleryComment::closeTags($post['comment'], '[i]', '[/i]');
     $post['comment'] = PhocaGalleryComment::closeTags($post['comment'], '[b]', '[/b]');
     $post['imgid'] = (int) $id;
     $post['userid'] = $user->id;
     $catidAlias = $catid;
     $imgidAlias = $id;
     if ($view != 'comment') {
         $this->setRedirect(JRoute::_('index.php?option=com_phocagallery', false));
     }
     $model = $this->getModel('comment');
     $checkUserComment = PhocaGalleryCommentImage::checkUserComment($post['imgid'], $post['userid']);
     // User has already submitted a comment
     if ($checkUserComment) {
         $msg = JText::_('COM_PHOCAGALLERY_COMMENT_ALREADY_SUBMITTED');
     } else {
         // If javascript will not protect the empty form
         $msg = '';
         $emptyForm = 0;
         if ($post['title'] == '') {
             $msg .= JText::_('COM_PHOCAGALLERY_ERROR_COMMENT_TITLE') . ' ';
             $emtyForm = 1;
         }
         if ($post['comment'] == '') {
             $msg .= JText::_('COM_PHOCAGALLERY_ERROR_COMMENT_COMMENT');
             $emtyForm = 1;
         }
         if ($emptyForm == 0) {
             if ($access > 0 && $user->id > 0) {
                 if (!$model->comment($post)) {
                     $msg = JText::_('COM_PHOCAGALLERY_ERROR_COMMENT_SUBMITTING');
                 } else {
                     $msg = JText::_('COM_PHOCAGALLERY_SUCCESS_COMMENT_SUBMIT');
                 }
             } else {
                 $app->redirect(JRoute::_('index.php?option=com_users&view=login', false), JText::_('COM_PHOCAGALLERY_NOT_AUTHORISED_ACTION'));
                 exit;
             }
         }
     }
     $this->setRedirect(JRoute::_('index.php?option=com_phocagallery&view=comment&catid=' . $catidAlias . '&id=' . $imgidAlias . $tmplCom . '&Itemid=' . $Itemid, false), $msg);
 }
Example #3
0
 function comment()
 {
     JRequest::checkToken() or jexit('Invalid Token');
     phocagalleryimport('phocagallery.comment.comment');
     phocagalleryimport('phocagallery.comment.commentcategory');
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $catid = $this->input->get('catid', '', 'string');
     $post['title'] = $this->input->get('phocagallerycommentstitle', '', 'string');
     $post['comment'] = $this->input->get('phocagallerycommentseditor', '', 'string');
     $view = $this->input->get('view', '', 'string');
     $return = $this->input->get('return-url', null, 'base64');
     $format = $this->input->get('format', 'html', 'cmd');
     $viewBack = $this->input->get('viewback', '', 'string');
     $tab = $this->input->get('tab', 0, 'int');
     $rating = $this->input->get('rating', '', 'string');
     $Itemid = $this->input->get('Itemid', 0, 'int');
     $limitStart = $this->input->get('limitstart', 0, 'int');
     $neededAccessLevels = PhocaGalleryAccess::getNeededAccessLevels();
     $access = PhocaGalleryAccess::isAccess($user->getAuthorisedViewLevels(), $neededAccessLevels);
     $paramsC = JComponentHelper::getParams('com_phocagallery');
     $maxCommentChar = $paramsC->get('max_comment_char', 1000);
     // Maximum of character, they will be saved in database
     $post['comment'] = substr($post['comment'], 0, (int) $maxCommentChar);
     // Close Tags
     $post['comment'] = PhocaGalleryComment::closeTags($post['comment'], '[u]', '[/u]');
     $post['comment'] = PhocaGalleryComment::closeTags($post['comment'], '[i]', '[/i]');
     $post['comment'] = PhocaGalleryComment::closeTags($post['comment'], '[b]', '[/b]');
     $post['catid'] = (int) $catid;
     $post['userid'] = $user->id;
     $catidAlias = $catid;
     //Itemid
     if ($view != 'category') {
         $this->setRedirect(JRoute::_('index.php?option=com_phocagallery', false));
     }
     $model = $this->getModel('category');
     $checkUserComment = PhocaGalleryCommentCategory::checkUserComment($post['catid'], $post['userid']);
     // User has already submitted a comment
     if ($checkUserComment) {
         $msg = JText::_('COM_PHOCAGALLERY_COMMENT_ALREADY_SUBMITTED');
     } else {
         // If javascript will not protect the empty form
         $msg = '';
         $emptyForm = 0;
         if ($post['title'] == '') {
             $msg .= JText::_('COM_PHOCAGALLERY_ERROR_COMMENT_TITLE') . ' ';
             $emtyForm = 1;
         }
         if ($post['comment'] == '') {
             $msg .= JText::_('COM_PHOCAGALLERY_ERROR_COMMENT_COMMENT');
             $emtyForm = 1;
         }
         if ($emptyForm == 0) {
             if ($access > 0 && $user->id > 0) {
                 if (!$model->comment($post)) {
                     $msg = JText::_('COM_PHOCAGALLERY_ERROR_COMMENT_SUBMITTING');
                 } else {
                     $msg = JText::_('COM_PHOCAGALLERY_SUCCESS_COMMENT_SUBMIT');
                 }
             } else {
                 $app->enqueueMessage(JText::_('COM_PHOCAGALLERY_NOT_AUTHORISED_ACTION'));
                 $app->redirect(JRoute::_('index.php?option=com_users&view=login', false));
                 exit;
             }
         }
     }
     // Limit Start
     $countItem = $model->getCountItem((int) $catid);
     if ($countItem) {
         if ((int) $countItem[0] == $limitStart) {
             $limitStart = 0;
         }
     } else {
         $limitStart = 0;
     }
     if ($limitStart > 0) {
         $limitStartUrl = '&limitstart=' . $limitStart;
     } else {
         $limitStartUrl = '';
     }
     $app->enqueueMessage($msg);
     $this->setRedirect(JRoute::_('index.php?option=com_phocagallery&view=category&id=' . $catidAlias . '&tab=' . $tab . '&Itemid=' . $Itemid . $limitStartUrl, false));
 }
Example #4
0
<?php

defined('_JEXEC') or die('Restricted access');
echo '<div id="phocagallery-comments">' . "\n";
echo '<div class="ph-tabs-iefix">&nbsp;</div>';
//because of IE bug
if (!empty($this->commentitem)) {
    $userImage = JHtml::_('image', $this->tmpl['icon_path'] . 'icon-user.png', '');
    $smileys = PhocaGalleryComment::getSmileys();
    foreach ($this->commentitem as $itemValue) {
        $date = JHtml::_('date', $itemValue->date, JText::_('DATE_FORMAT_LC2'));
        $comment = $itemValue->comment;
        $comment = PhocaGalleryComment::bbCodeReplace($comment);
        foreach ($smileys as $smileyKey => $smileyValue) {
            $comment = str_replace($smileyKey, JHtml::_('image', $this->tmpl['icon_path'] . '' . $smileyValue . '.png', ''), $comment);
        }
        echo '<blockquote>' . '<h4>' . $userImage . '&nbsp;' . $itemValue->name . '</h4>' . '<p><strong>' . PhocaGalleryText::wordDelete($itemValue->title, 50, '...') . '</strong></p>' . '<p style="overflow:auto;width:' . $this->tmpl['commentwidth'] . 'px;">' . $comment . '</p>' . '<p style="text-align:right"><small>' . $date . '</small></p>' . '</blockquote>';
    }
}
echo '<h4>' . JText::_('COM_PHOCAGALLERY_ADD_COMMENT') . '</h4>';
if ($this->tmpl['already_commented']) {
    echo '<p>' . JText::_('COM_PHOCAGALLERY_COMMENT_ALREADY_SUBMITTED') . '</p>';
} else {
    if ($this->tmpl['not_registered']) {
        echo '<p>' . JText::_('COM_PHOCAGALLERY_COMMENT_ONLY_REGISTERED_LOGGED_SUBMIT_COMMENT') . '</p>';
    } else {
        ?>
		
	<form action="<?php 
        echo htmlspecialchars($this->tmpl['action']);
        ?>