/** * Endpoint for the PromotedContentModule's data. * * Parameters & values must be lowercase and via GET. * * @see PromotedContentModule */ public function promoted() { // Create module & set data. $PromotedModule = new PromotedContentModule(); $Status = $PromotedModule->Load(Gdn::request()->get()); if ($Status === true) { // Good parameters. $PromotedModule->GetData(); $this->setData('Content', $PromotedModule->data('Content')); $this->setData('Title', t('Promoted Content')); $this->setData('View', c('Vanilla.Discussions.Layout')); $this->setData('EmptyMessage', t('No discussions were found.')); // Pass display properties to the view. $this->Group = $PromotedModule->Group; $this->TitleLimit = $PromotedModule->TitleLimit; $this->BodyLimit = $PromotedModule->BodyLimit; } else { $this->setData('Errors', $Status); } $this->deliveryMethod(); Gdn_Theme::section('PromotedContent'); $this->render('promoted', 'modules', 'vanilla'); }
/** * Generates html output of $Content array * * @param array|object $Content * @param PromotedContentModule $Sender */ function writePromotedContent($Content, $Sender) { static $UserPhotoFirst = NULL; if ($UserPhotoFirst === null) { $UserPhotoFirst = c('Vanilla.Comment.UserPhotoFirst', true); } $ContentType = val('RecordType', $Content); $ContentID = val("{$ContentType}ID", $Content); $Author = val('Author', $Content); $ContentURL = val('Url', $Content); $Sender->EventArguments['Content'] =& $Content; $Sender->EventArguments['ContentUrl'] =& $ContentURL; ?> <div id="<?php echo "Promoted_{$ContentType}_{$ContentID}"; ?> " class="<?php echo CssClass($Content); ?> "> <div class="AuthorWrap"> <span class="Author"> <?php if ($UserPhotoFirst) { echo userPhoto($Author); echo userAnchor($Author, 'Username'); } else { echo userAnchor($Author, 'Username'); echo userPhoto($Author); } $Sender->fireEvent('AuthorPhoto'); ?> </span> <span class="AuthorInfo"> <?php echo ' ' . WrapIf(htmlspecialchars(val('Title', $Author)), 'span', array('class' => 'MItem AuthorTitle')); echo ' ' . WrapIf(htmlspecialchars(val('Location', $Author)), 'span', array('class' => 'MItem AuthorLocation')); $Sender->fireEvent('AuthorInfo'); ?> </span> </div> <div class="Meta CommentMeta CommentInfo"> <span class="MItem DateCreated"> <?php echo anchor(Gdn_Format::date($Content['DateInserted'], 'html'), $ContentURL, 'Permalink', array('rel' => 'nofollow')); ?> </span> <?php // Include source if one was set if ($Source = val('Source', $Content)) { echo wrap(sprintf(t('via %s'), t($Source . ' Source', $Source)), 'span', array('class' => 'MItem Source')); } $Sender->fireEvent('ContentInfo'); ?> </div> <div class="Title"><?php echo anchor(Gdn_Format::text(sliceString($Content['Name'], $Sender->TitleLimit), false), $ContentURL, 'DiscussionLink'); ?> </div> <div class="Body"> <?php echo anchor(htmlspecialchars(sliceString(Gdn_Format::plainText($Content['Body'], $Content['Format']), $Sender->BodyLimit)), $ContentURL, 'BodyLink'); $Sender->fireEvent('AfterPromotedBody'); // separate event to account for less space. ?> </div> </div> <?php }
/** * Generates html output of $Content array * * @param array|object $Content * @param PromotedContentModule $Sender */ function WritePromotedContent($Content, $Sender) { static $UserPhotoFirst = NULL; if ($UserPhotoFirst === NULL) { $UserPhotoFirst = C('Vanilla.Comment.UserPhotoFirst', TRUE); } $ContentType = GetValue('ItemType', $Content); $ContentID = GetValue("{$ContentType}ID", $Content); $Author = GetValue('Author', $Content); switch (strtolower($ContentType)) { case 'comment': $ContentURL = CommentUrl($Content); break; case 'discussion': $ContentURL = DiscussionUrl($Content); break; } $Sender->EventArgs['Content'] = $Content; $Sender->EventArgs['ContentUrl'] = $ContentURL; ?> <div id="<?php echo "Promoted_{$ContentType}_{$ContentID}"; ?> " class="<?php echo CssClass($Content); ?> "> <div class="AuthorWrap"> <span class="Author"> <?php if ($UserPhotoFirst) { echo UserPhoto($Author); echo UserAnchor($Author, 'Username'); } else { echo UserAnchor($Author, 'Username'); echo UserPhoto($Author); } $Sender->FireEvent('AuthorPhoto'); ?> </span> <span class="AuthorInfo"> <?php echo ' ' . WrapIf(htmlspecialchars(GetValue('Title', $Author)), 'span', array('class' => 'MItem AuthorTitle')); echo ' ' . WrapIf(htmlspecialchars(GetValue('Location', $Author)), 'span', array('class' => 'MItem AuthorLocation')); $Sender->FireEvent('AuthorInfo'); ?> </span> </div> <div class="Meta CommentMeta CommentInfo"> <span class="MItem DateCreated"> <?php echo Anchor(Gdn_Format::Date($Content['DateInserted'], 'html'), $ContentURL, 'Permalink', array('rel' => 'nofollow')); ?> </span> <?php // Include source if one was set if ($Source = GetValue('Source', $Content)) { echo Wrap(sprintf(T('via %s'), T($Source . ' Source', $Source)), 'span', array('class' => 'MItem Source')); } $Sender->FireEvent('ContentInfo'); ?> </div> <div class="Title"><?php echo Anchor(Gdn_Format::Text(SliceString($Content['Name'], $Sender->TitleLimit), FALSE), $ContentURL, 'DiscussionLink'); ?> </div> <div class="Body"> <?php echo Anchor(strip_tags(Gdn_Format::To(SliceString($Content['Body'], $Sender->BodyLimit), $Content['Format'])), $ContentURL, 'BodyLink'); $Sender->FireEvent('AfterBody'); // seperate event to account for less space. ?> </div> </div> <?php }