Overview

Packages

  • None
  • Yaga

Functions

  • ActionRow
  • AgeArray
  • RenderPerkConfigurationForm
  • RenderPerkPermissionForm
  • RenderReactionList
  • RenderReactionRecord
  • WriteModuleDiscussion
  • WritePromotedContent
  • Overview
  • Package
  • Function
  • Tree
  • Todo
  • Download
  1: <?php if (!defined('APPLICATION')) exit();
  2: /**
  3:  * A collection of hooks that are enabled when Yaga is.
  4:  * 
  5:  * @package Yaga
  6:  * @since 1.0
  7:  * @copyright (c) 2013-2014, Zachary Doll
  8:  */
  9: 
 10: /**
 11:  * Writes a discussion out for use in a module
 12:  * 
 13:  * @param stdClass $Discussion
 14:  * @param string $Px
 15:  */
 16: function WriteModuleDiscussion($Discussion, $Px = 'Bookmark') {
 17: ?>
 18: <li id="<?php echo "{$Px}_{$Discussion->DiscussionID}"; ?>" class="<?php echo CssClass($Discussion); ?>">
 19:    <span class="Options">
 20:       <?php
 21: //      echo OptionsList($Discussion);
 22:       echo BookmarkButton($Discussion);
 23:       ?>
 24:    </span>
 25:    <div class="Title"><?php
 26:       echo Anchor(Gdn_Format::Text($Discussion->Name, FALSE), DiscussionUrl($Discussion).($Discussion->CountCommentWatch > 0 ? '#Item_'.$Discussion->CountCommentWatch : ''), 'DiscussionLink');
 27:    ?></div>
 28:    <div class="Meta">
 29:       <?php
 30:          $Last = new stdClass();
 31:          $Last->UserID = $Discussion->LastUserID;
 32:          $Last->Name = $Discussion->LastName;
 33: 
 34:          echo NewComments($Discussion);
 35: 
 36:          echo '<span class="MItem">'.Gdn_Format::Date($Discussion->LastDate, 'html').UserAnchor($Last).'</span>';
 37:       ?>
 38:    </div>
 39: </li>
 40: <?php
 41: }
 42: 
 43: /**
 44:  * Writes a discussion or comment out for use in a module
 45:  * 
 46:  * @staticvar boolean $UserPhotoFirst
 47:  * @param array $Content
 48:  * @param mixed $Sender calling object.
 49:  */
 50: function WritePromotedContent($Content, $Sender) {
 51:    static $UserPhotoFirst = NULL;
 52:    if ($UserPhotoFirst === NULL) {
 53:       $UserPhotoFirst = C('Vanilla.Comment.UserPhotoFirst', TRUE);
 54:    }
 55: 
 56:    $ContentType = GetValue('ItemType', $Content);
 57:    $ContentID = GetValue("{$ContentType}ID", $Content);
 58:    $Author = GetValue('Author', $Content);
 59: 
 60:    switch (strtolower($ContentType)) {
 61:       case 'comment':
 62:          $ContentURL = CommentUrl($Content);
 63:          break;
 64:       case 'discussion':
 65:          $ContentURL = DiscussionUrl($Content);
 66:          break;
 67:    }
 68:    $Sender->EventArgs['Content'] = $Content;
 69:    $Sender->EventArgs['ContentUrl'] = $ContentURL;
 70: ?>
 71:    <div id="<?php echo "Promoted_{$ContentType}_{$ContentID}"; ?>" class="<?php echo CssClass($Content); ?>">
 72:       <div class="AuthorWrap">
 73:          <span class="Author">
 74:             <?php
 75:             if ($UserPhotoFirst) {
 76:                echo UserPhoto($Author);
 77:                echo UserAnchor($Author, 'Username');
 78:             } else {
 79:                echo UserAnchor($Author, 'Username');
 80:                echo UserPhoto($Author);
 81:             }
 82:             $Sender->FireEvent('AuthorPhoto');
 83:             ?>
 84:          </span>
 85:          <span class="AuthorInfo">
 86:             <?php
 87:             echo ' '.WrapIf(htmlspecialchars(GetValue('Title', $Author)), 'span', array('class' => 'MItem AuthorTitle'));
 88:             echo ' '.WrapIf(htmlspecialchars(GetValue('Location', $Author)), 'span', array('class' => 'MItem AuthorLocation'));
 89:             $Sender->FireEvent('AuthorInfo');
 90:             ?>
 91:          </span>
 92:       </div>
 93:       <div class="Meta CommentMeta CommentInfo">
 94:          <span class="MItem DateCreated">
 95:             <?php echo Anchor(Gdn_Format::Date($Content['DateInserted'], 'html'), $ContentURL, 'Permalink', array('rel' => 'nofollow')); ?>
 96:          </span>
 97:          <?php
 98:          // Include source if one was set
 99:          if ($Source = GetValue('Source', $Content)) {
100:             echo Wrap(sprintf(T('via %s'), T($Source.' Source', $Source)), 'span', array('class' => 'MItem Source'));
101:          }
102: 
103:          $Sender->FireEvent('ContentInfo');
104:          ?>
105:       </div>
106:       <div class="Title"><?php echo Anchor(Gdn_Format::Text($Content['Name'], FALSE), $ContentURL, 'DiscussionLink'); ?></div>
107:       <div class="Body">
108:       <?php
109:          echo Anchor(strip_tags(Gdn_Format::To($Content['Body'], $Content['Format'])), $ContentURL, 'BodyLink');
110:          $Sender->FireEvent('AfterBody'); // seperate event to account for less space.
111:       ?>
112:       </div>
113:    </div>
114: <?php
115: }
116: 
Yaga API documentation generated by ApiGen 2.8.0