Exemplo n.º 1
0
$objComment->getFromRequest();
$objComment->load();
$objPicture = new clsPicture();
$objPicture->getFromRequest();
$objPicture->load();
$objAlbum = new clsAlbum($objPicture->get('album_id'));
if ($strSubAction == 'edit') {
    if ($objComment->isNew() && !$objAlbum->canPostComment($objUser)) {
        throw new Exception('exception_accessdenied');
    }
    if (!$objComment->canEdit($objUser)) {
        throw new Exception('exception_accessdenied');
    }
    $objAlbum->addBreadcrumbs($objBreadcrumbs);
    $objBreadcrumbs->add($objPicture->get('name'), 'index.php?action=picture&' . $objPicture->getIDPair());
    $objBreadcrumbs->add('Post comment', 'comment.php?action=edit&' . $objPicture->getIDPair() . '&' . $objComment->getIDPair());
    $objCommentTemplate = new clsTemplate('editcomment');
    $objCommentTemplate->setText('HIDDEN', $objComment->getHiddenField('id'));
    $objCommentTemplate->setText('HIDDEN', $objPicture->getHiddenField('id'));
    $objCommentTemplate->setText('HIDDEN', "<input type='hidden' name='action' value='comment'>");
    $objCommentTemplate->setText('HIDDEN', "<input type='hidden' name='subaction' value='save'>");
    if ($objUser) {
        $objCommentTemplate->setText('NAME', '<strong>' . $objUser->get('username') . '</strong>');
    } else {
        $objCommentTemplate->setText('NAME', $objComment->getTextField('username'));
    }
    /* Set a default title if it's not present. */
    if (!$objComment->exists('title')) {
        $objComment->set('title', 'Re: ' . $objPicture->get('title'), false);
    }
    $objCommentTemplate->setText('TITLE', $objComment->getTextField('title'));
Exemplo n.º 2
0
 } else {
     if (clsVote::getVoteCount($objPicture)) {
         $objPictureTemplate->setText('RATING', "Ranked <span class='rating'>" . clsVote::getRating($objPicture) . "</span> / " . clsVote::getMaxRating() . " (" . clsVote::getVoteCount($objPicture) . " votes)");
     }
 }
 /* Commenting code. */
 $arrComments = $objPicture->getComments();
 foreach ($arrComments as $objComment) {
     $objComment = new clsComment($objComment->get('id'));
     $objCommentTemplate = new clsTemplate('comment');
     $objCommentTemplate->setText('TITLE', $objComment->get('title') . ' ' . $objComment->getNewIcon($objUser));
     $objCommentTemplate->setText('USERNAME', $objComment->getUsername());
     $objCommentTemplate->setText('DATE', time_to_text(strtotime($objComment->get('date'))));
     $objCommentTemplate->setText('TEXT', bbcode_format($objComment->get('text')));
     if ($objComment->canEdit($objUser)) {
         $objCommentTemplate->setText('TITLE', "<span class='editdelete'> [<a href='index.php?action=comment&subaction=edit&" . $objPicture->getIDPair() . "&" . $objComment->getIDPair() . "'>edit</a>]</span>");
     }
     if ($objComment->canDelete($objUser)) {
         $objCommentTemplate->setText('TITLE', "<span class='editdelete'> [<a href='index.php?action=comment&subaction=delete&" . $objPicture->getIDPair() . "&" . $objComment->getIDPair() . "'>delete</a>]</span>");
     }
     $objPictureTemplate->setText('COMMENTS', $objCommentTemplate->get());
     /* Mark the comment as viewed */
     $objComment->setViewed($objUser);
 }
 if ($objAlbum->canPostComment($objUser)) {
     $objPictureTemplate->setText('POSTCOMMENT1', "<a href='index.php?action=comment&subaction=edit&" . $objPicture->getIDPair() . "' class='smalllink'>Post Comment</a>");
     if (sizeof($arrComments) != 0) {
         $objPictureTemplate->setText('POSTCOMMENT2', "<a href='index.php?action=comment&subaction=edit&" . $objPicture->getIDPair() . "' class='smalllink'>Post Comment</a>");
     }
 }
 if (sizeof($arrComments) == 0) {