/** * * * @param $Sender * @param $Args */ public function categoriesController_afterDiscussionLabels_handler($Sender, $Args) { if (c('Vanilla.Discussions.Layout') != 'table') { if (val('FirstUser', $Args)) { echo '<span class="MItem DiscussionAuthor">' . userAnchor(val('FirstUser', $Args)) . '</span>'; } } }
/** * * * @param $Sender * @param $Args */ public function categoriesController_afterDiscussionLabels_handler($Sender, $Args) { if (!$this->hasLayoutTables() || isMobile()) { if (val('FirstUser', $Args)) { echo '<span class="MItem DiscussionAuthor">' . userAnchor(val('FirstUser', $Args)) . '</span>'; } } }
/** * Post every new discussion to HipChat. * * @param PostController $sender * @param array $args */ public function discussionModel_afterSaveDiscussion_handler($sender, $args) { // Make sure we have a valid discussion. if (!$args['Discussion'] || !val('DiscussionID', $args['Discussion'])) { return; } // Only trigger for new discussions. if (!$args['Insert']) { return; } // Prep HipChat message. $author = Gdn::userModel()->getID(val('InsertUserID', $args['Discussion'])); $message = sprintf('%1$s: %2$s', userAnchor($author), anchor(val('Name', $args['Discussion']), discussionUrl($args['Discussion']))); // Say it. self::sayInHipChat($message); }
<h3><?php echo anchor(htmlspecialchars($Row['Title']), $Row['Url']); ?> </h3> <div class="Item-Body Media"> <?php $Photo = userPhoto($Row, array('LinkClass' => 'Img')); if ($Photo) { echo $Photo; } ?> <div class="Media-Body"> <div class="Meta"> <?php echo ' <span class="MItem-Author">' . sprintf(t('by %s'), userAnchor($Row)) . '</span>'; echo Bullet(' '); echo ' <span clsss="MItem-DateInserted">' . Gdn_Format::date($Row['DateInserted'], 'html') . '</span> '; if (isset($Row['Breadcrumbs'])) { echo Bullet(' '); echo ' <span class="MItem-Location">' . Gdn_Theme::Breadcrumbs($Row['Breadcrumbs'], false) . '</span> '; } if (isset($Row['Notes'])) { echo ' <span class="Aside Debug">debug(' . $Row['Notes'] . ')</span>'; } ?> </div> <div class="Summary"> <?php echo $Row['Summary']; ?>
<?php if (!defined('APPLICATION')) { exit; } ?> <h1><?php printf(t('Delete User: %s'), userAnchor($this->User)); ?> </h1> <?php echo $this->Form->open(array('class' => 'User')); echo $this->Form->errors(); ?> <div class="Messages Errors" style="margin-bottom: 20px;"> <ul> <li><?php printf(t("By clicking the button below, you will be deleting the user account for %s forever."), wrap(htmlspecialchars($this->User->Name), 'strong')); ?> </li> <li><?php if ($this->Method == 'keep') { echo t("The user content will remain untouched."); } else { if ($this->Method == 'wipe') { echo t("All of the user content will be replaced with a message stating the user has been deleted."); } else { echo t("The user content will be completely deleted."); } } ?>
"> <h2 class="H"><?php echo t("Add a Message"); ?> </h2> <div class="MessageFormWrap"> <div class="Form-HeaderWrap"> <div class="Form-Header"> <span class="Author"> <?php if (c('Vanilla.Comment.UserPhotoFirst', true)) { echo userPhoto($Session->User); echo userAnchor($Session->User, 'Username'); } else { echo userAnchor($Session->User, 'Username'); echo userPhoto($Session->User); } ?> </span> </div> </div> <div class="Form-BodyWrap"> <div class="Form-Body"> <div class="FormWrapper FormWrapper-Condensed"> <?php echo $this->Form->open(array('id' => 'Form_ConversationMessage', 'action' => url('/messages/addmessage/'))); echo $this->Form->errors(); // echo wrap($this->Form->textBox('Body', array('MultiLine' => true, 'class' => 'TextBox')), 'div', array('class' => 'TextBoxWrapper')); echo $this->Form->bodyBox('Body', array('Table' => 'ConversationMessage', 'FileUpload' => true, 'tabindex' => 1)); echo '<div class="Buttons">', $this->Form->button('Send Message', array('class' => 'Button Primary', 'tabindex' => 1)), '</div>';
/** * Writes a discussion in table row format. */ function writeDiscussionRow($Discussion, $Sender, $Session) { if (!property_exists($Sender, 'CanEditDiscussions')) { $Sender->CanEditDiscussions = val('PermsDiscussionsEdit', CategoryModel::categories($Discussion->CategoryID)) && c('Vanilla.AdminCheckboxes.Use'); } $CssClass = CssClass($Discussion); $DiscussionUrl = $Discussion->Url; if ($Session->UserID) { $DiscussionUrl .= '#latest'; } $Sender->EventArguments['DiscussionUrl'] =& $DiscussionUrl; $Sender->EventArguments['Discussion'] =& $Discussion; $Sender->EventArguments['CssClass'] =& $CssClass; $First = UserBuilder($Discussion, 'First'); if ($Discussion->LastUserID) { $Last = UserBuilder($Discussion, 'Last'); } else { $Last = $First; } $Sender->EventArguments['FirstUser'] =& $First; $Sender->EventArguments['LastUser'] =& $Last; $Sender->fireEvent('BeforeDiscussionName'); $DiscussionName = $Discussion->Name; // If there are no word character detected in the title treat it as if it is blank. if (!preg_match('/\\w/u', $DiscussionName)) { $DiscussionName = t('Blank Discussion Topic'); } $Sender->EventArguments['DiscussionName'] =& $DiscussionName; static $FirstDiscussion = true; if (!$FirstDiscussion) { $Sender->fireEvent('BetweenDiscussion'); } else { $FirstDiscussion = false; } $Discussion->CountPages = ceil($Discussion->CountComments / $Sender->CountCommentsPerPage); $FirstPageUrl = DiscussionUrl($Discussion, 1); $LastPageUrl = DiscussionUrl($Discussion, val('CountPages', $Discussion)) . '#latest'; ?> <tr id="Discussion_<?php echo $Discussion->DiscussionID; ?> " class="<?php echo $CssClass; ?> "> <?php $Sender->fireEvent('BeforeDiscussionContent'); ?> <?php echo AdminCheck($Discussion, array('<td class="CheckBoxColumn"><div class="Wrap">', '</div></td>')); ?> <td class="DiscussionName"> <div class="Wrap"> <span class="Options"> <?php echo OptionsList($Discussion); echo BookmarkButton($Discussion); ?> </span> <?php $Sender->fireEvent('BeforeDiscussionTitle'); echo anchor($DiscussionName, $DiscussionUrl, 'Title') . ' '; $Sender->fireEvent('AfterDiscussionTitle'); WriteMiniPager($Discussion); echo NewComments($Discussion); if ($Sender->data('_ShowCategoryLink', true)) { echo CategoryLink($Discussion, ' ' . t('in') . ' '); } // Other stuff that was in the standard view that you may want to display: echo '<div class="Meta Meta-Discussion">'; WriteTags($Discussion); echo '</div>'; // if ($Source = val('Source', $Discussion)) // echo ' '.sprintf(t('via %s'), t($Source.' Source', $Source)); // ?> </div> </td> <td class="BlockColumn BlockColumn-User FirstUser"> <div class="Block Wrap"> <?php echo userPhoto($First, array('Size' => 'Small')); echo userAnchor($First, 'UserLink BlockTitle'); echo '<div class="Meta">'; echo anchor(Gdn_Format::date($Discussion->FirstDate, 'html'), $FirstPageUrl, 'CommentDate MItem'); echo '</div>'; ?> </div> </td> <td class="BigCount CountComments"> <div class="Wrap"> <?php // Exact Number // echo number_format($Discussion->CountComments); // Round Number echo BigPlural($Discussion->CountComments, '%s comment'); ?> </div> </td> <td class="BigCount CountViews"> <div class="Wrap"> <?php // Exact Number // echo number_format($Discussion->CountViews); // Round Number echo BigPlural($Discussion->CountViews, '%s view'); ?> </div> </td> <td class="BlockColumn BlockColumn-User LastUser"> <div class="Block Wrap"> <?php if ($Last) { echo userPhoto($Last, array('Size' => 'Small')); echo userAnchor($Last, 'UserLink BlockTitle'); echo '<div class="Meta">'; echo anchor(Gdn_Format::date($Discussion->LastDate, 'html'), $LastPageUrl, 'CommentDate MItem'); echo '</div>'; } else { echo ' '; } ?> </div> </td> </tr> <?php }
function writeTableRow($Row, $Depth = 1) { $Children = $Row['Children']; $WriteChildren = FALSE; if (!empty($Children)) { if ($Depth + 1 >= c('Vanilla.Categories.MaxDisplayDepth')) { $WriteChildren = 'list'; } else { $WriteChildren = 'rows'; } } $H = 'h' . ($Depth + 1); ?> <tr class="<?php echo CssClass($Row); ?> "> <td class="CategoryName"> <div class="Wrap"> <?php echo GetOptions($Row); echo CategoryPhoto($Row); echo "<{$H}>"; echo anchor(htmlspecialchars($Row['Name']), $Row['Url']); Gdn::controller()->EventArguments['Category'] = $Row; Gdn::controller()->fireEvent('AfterCategoryTitle'); echo "</{$H}>"; ?> <div class="CategoryDescription"> <?php echo $Row['Description']; ?> </div> <?php if ($WriteChildren === 'list') { ?> <div class="ChildCategories"> <?php echo wrap(t('Child Categories') . ': ', 'b'); echo CategoryString($Children, $Depth + 1); ?> </div> <?php } ?> </div> </td> <td class="BigCount CountDiscussions"> <div class="Wrap"> <?php // echo "({$Row['CountDiscussions']})"; echo BigPlural($Row['CountAllDiscussions'], '%s discussion'); ?> </div> </td> <td class="BigCount CountComments"> <div class="Wrap"> <?php // echo "({$Row['CountComments']})"; echo BigPlural($Row['CountAllComments'], '%s comment'); ?> </div> </td> <td class="BlockColumn LatestPost"> <div class="Block Wrap"> <?php if ($Row['LastTitle']) { ?> <?php echo userPhoto($Row, array('Size' => 'Small', 'Px' => 'Last')); echo anchor(SliceString(Gdn_Format::text($Row['LastTitle']), 100), $Row['LastUrl'], 'BlockTitle LatestPostTitle', array('title' => html_entity_decode($Row['LastTitle']))); ?> <div class="Meta"> <?php echo userAnchor($Row, 'UserLink MItem', 'Last'); ?> <span class="Bullet">•</span> <?php echo anchor(Gdn_Format::date($Row['LastDateInserted'], 'html'), $Row['LastUrl'], 'CommentDate MItem'); if (isset($Row['LastCategoryID'])) { $LastCategory = CategoryModel::categories($Row['LastCategoryID']); echo ' <span>', sprintf('in %s', anchor($LastCategory['Name'], CategoryUrl($LastCategory, '', '//'))), '</span>'; } ?> </div> <?php } ?> </div> </td> </tr> <?php if ($WriteChildren === 'rows') { foreach ($Children as $ChildRow) { WriteTableRow($ChildRow, $Depth + 1); } } }
$Session = Gdn::session(); $Alt = FALSE; foreach ($this->InvitationData->Format('Text')->result() as $Invitation) { $Alt = $Alt == TRUE ? FALSE : TRUE; ?> <tr class="js-invitation" data-id="<?php echo $Invitation->InvitationID; ?> "> <td class="Alt"><?php if ($Invitation->AcceptedName == '') { echo $Invitation->Email; echo wrap(anchor(t('Uninvite'), "/profile/uninvite/{$Invitation->InvitationID}", 'Uninvite Hijack') . ' | ' . anchor(t('Send Again'), "/profile/sendinvite/{$Invitation->InvitationID}", 'SendAgain Hijack'), 'div'); } else { $User = Gdn::userModel()->getID($Invitation->AcceptedUserID); echo userAnchor($User); echo wrap(anchor(t('Remove'), "/profile/deleteinvitation/{$Invitation->InvitationID}", 'Delete Hijack'), 'div'); } if ($Invitation->AcceptedName == '') { } ?> </td> <td><?php echo Gdn_Format::date($Invitation->DateInserted, 'html'); ?> </td> <td class="Alt"><?php if ($Invitation->AcceptedName == '') { echo t('Pending'); } else { echo t('Accepted');
function writeDiscussion($Discussion, &$Sender, &$Session) { $CssClass = CssClass($Discussion); $DiscussionUrl = $Discussion->Url; $Category = CategoryModel::categories($Discussion->CategoryID); if ($Session->UserID) { $DiscussionUrl .= '#latest'; } $Sender->EventArguments['DiscussionUrl'] =& $DiscussionUrl; $Sender->EventArguments['Discussion'] =& $Discussion; $Sender->EventArguments['CssClass'] =& $CssClass; $First = UserBuilder($Discussion, 'First'); $Last = UserBuilder($Discussion, 'Last'); $Sender->EventArguments['FirstUser'] =& $First; $Sender->EventArguments['LastUser'] =& $Last; $Sender->fireEvent('BeforeDiscussionName'); $DiscussionName = $Discussion->Name; if ($DiscussionName == '') { $DiscussionName = t('Blank Discussion Topic'); } $Sender->EventArguments['DiscussionName'] =& $DiscussionName; static $FirstDiscussion = TRUE; if (!$FirstDiscussion) { $Sender->fireEvent('BetweenDiscussion'); } else { $FirstDiscussion = FALSE; } $Discussion->CountPages = ceil($Discussion->CountComments / $Sender->CountCommentsPerPage); ?> <li id="Discussion_<?php echo $Discussion->DiscussionID; ?> " class="<?php echo $CssClass; ?> "> <?php if (!property_exists($Sender, 'CanEditDiscussions')) { $Sender->CanEditDiscussions = val('PermsDiscussionsEdit', CategoryModel::categories($Discussion->CategoryID)) && c('Vanilla.AdminCheckboxes.Use'); } $Sender->fireEvent('BeforeDiscussionContent'); // WriteOptions($Discussion, $Sender, $Session); ?> <span class="Options"> <?php echo OptionsList($Discussion); echo BookmarkButton($Discussion); ?> </span> <div class="ItemContent Discussion"> <div class="Title"> <?php echo AdminCheck($Discussion, array('', ' ')) . anchor($DiscussionName, $DiscussionUrl); $Sender->fireEvent('AfterDiscussionTitle'); ?> </div> <div class="Meta Meta-Discussion"> <?php WriteTags($Discussion); ?> <span class="MItem MCount ViewCount"><?php printf(PluralTranslate($Discussion->CountViews, '%s view html', '%s views html', t('%s view'), t('%s views')), BigPlural($Discussion->CountViews, '%s view')); ?> </span> <span class="MItem MCount CommentCount"><?php printf(PluralTranslate($Discussion->CountComments, '%s comment html', '%s comments html', t('%s comment'), t('%s comments')), BigPlural($Discussion->CountComments, '%s comment')); ?> </span> <span class="MItem MCount DiscussionScore Hidden"><?php $Score = $Discussion->Score; if ($Score == '') { $Score = 0; } printf(Plural($Score, '%s point', '%s points', BigPlural($Score, '%s point'))); ?> </span> <?php echo NewComments($Discussion); $Sender->fireEvent('AfterCountMeta'); if ($Discussion->LastCommentID != '') { echo ' <span class="MItem LastCommentBy">' . sprintf(t('Most recent by %1$s'), userAnchor($Last)) . '</span> '; echo ' <span class="MItem LastCommentDate">' . Gdn_Format::date($Discussion->LastDate, 'html') . '</span>'; } else { echo ' <span class="MItem LastCommentBy">' . sprintf(t('Started by %1$s'), userAnchor($First)) . '</span> '; echo ' <span class="MItem LastCommentDate">' . Gdn_Format::date($Discussion->FirstDate, 'html'); if ($Source = val('Source', $Discussion)) { echo ' ' . sprintf(t('via %s'), t($Source . ' Source', $Source)); } echo '</span> '; } if ($Sender->data('_ShowCategoryLink', true) && c('Vanilla.Categories.Use') && $Category) { echo wrap(Anchor(htmlspecialchars($Discussion->Category), CategoryUrl($Discussion->CategoryUrlCode)), 'span', array('class' => 'MItem Category ' . $Category['CssClass'])); } $Sender->fireEvent('DiscussionMeta'); ?> </div> </div> <?php $Sender->fireEvent('AfterDiscussionContent'); ?> </li> <?php }
?> " class="Item"> <?php $this->fireEvent('BeforeItemContent'); ?> <div class="ItemContent"> <div class="Message"><?php echo SliceString(Gdn_Format::text(Gdn_Format::to($Comment->Body, $Comment->Format), false), 250); ?> </div> <div class="Meta"> <span class="MItem"><?php echo t('Comment in', 'in') . ' '; ?> <b><?php echo anchor(Gdn_Format::text($Comment->DiscussionName), $Permalink); ?> </b></span> <span class="MItem"><?php printf(t('Comment by %s'), userAnchor($User)); ?> </span> <span class="MItem"><?php echo anchor(Gdn_Format::date($Comment->DateInserted), $Permalink); ?> </span> </div> </div> </li> <?php }
<li id="Message_<?php echo $Message->MessageID; ?> "<?php echo $Class == '' ? '' : ' class="' . $Class . '"'; ?> > <div id="Item_<?php echo $CurrentOffset; ?> " class="ConversationMessage"> <div class="Meta"> <span class="Author"> <?php echo userPhoto($Author, 'Photo'); echo userAnchor($Author, 'Name'); ?> </span> <span class="MItem DateCreated"><?php echo Gdn_Format::date($Message->DateInserted, 'html'); ?> </span> <?php $this->fireEvent('AfterConversationMessageDate'); ?> </div> <div class="Message"> <?php $this->fireEvent('BeforeConversationMessageBody'); echo Gdn_Format::to($Message->Body, $Format); $this->EventArguments['Message'] =& $Message;
function writeActivityComment($Comment, $Activity) { $Session = Gdn::session(); $Author = UserBuilder($Comment, 'Insert'); $PhotoAnchor = userPhoto($Author, 'Photo'); $CssClass = 'Item ActivityComment ActivityComment'; if ($PhotoAnchor != '') { $CssClass .= ' HasPhoto'; } ?> <li id="ActivityComment_<?php echo $Comment['ActivityCommentID']; ?> " class="<?php echo $CssClass; ?> "> <?php if ($PhotoAnchor != '') { ?> <div class="Author Photo"><?php echo $PhotoAnchor; ?> </div> <?php } ?> <div class="ItemContent ActivityComment"> <?php echo userAnchor($Author, 'Title Name'); ?> <div class="Excerpt"><?php echo Gdn_Format::to($Comment['Body'], $Comment['Format']); ?> </div> <div class="Meta"> <span class="DateCreated"><?php echo Gdn_Format::date($Comment['DateInserted'], 'html'); ?> </span> <?php if (ActivityModel::canDelete($Activity)) { echo anchor(t('Delete'), "dashboard/activity/deletecomment?id={$Comment['ActivityCommentID']}&tk=" . $Session->TransientKey() . '&target=' . urlencode(Gdn_Url::Request()), 'DeleteComment'); } ?> </div> </div> </li> <?php }
echo OtherRecordsMeta($Row['Data']); echo '<div class="Meta-Container">'; echo '<span class="Tags">'; echo '<span class="Tag Tag-' . $Row['Operation'] . '">' . t($Row['Operation']) . '</span> '; echo '<span class="Tag Tag-' . $RecordLabel . '">' . anchor(t($RecordLabel), $Url) . '</span> '; echo '</span>'; if (checkPermission('Garden.PersonalInfo.View') && $Row['RecordIPAddress']) { echo ' <span class="Meta">', '<span class="Meta-Label">IP</span> ', IPAnchor($Row['RecordIPAddress'], 'Meta-Value'), '</span> '; } if ($Row['CountGroup'] > 1) { echo ' <span class="Meta">', '<span class="Meta-Label">' . t('Reported') . '</span> ', wrap(Plural($Row['CountGroup'], '%s time', '%s times'), 'span', 'Meta-Value'), '</span> '; // echo ' ', sprintf(t('%s times'), $Row['CountGroup']); } $RecordUser = Gdn::userModel()->getID($Row['RecordUserID'], DATASET_TYPE_ARRAY); if ($Row['RecordName']) { echo ' <span class="Meta">', '<span class="Meta-Label">' . sprintf(t('%s by'), t($RecordLabel)) . '</span> ', userAnchor($Row, 'Meta-Value', 'Record'); if ($RecordUser['Banned']) { echo ' <span class="Tag Tag-Ban">' . t('Banned') . '</span>'; } echo ' <span class="Count">' . plural($RecordUser['CountDiscussions'] + $RecordUser['CountComments'], '%s post', '%s posts') . '</span>'; echo '</span> '; } // Write custom meta information. $CustomMeta = valr('Data._Meta', $Row, false); if (is_array($CustomMeta)) { foreach ($CustomMeta as $Key => $Value) { echo ' <span class="Meta">', '<span class="Meta-Label">' . t($Key) . '</span> ', wrap(Gdn_Format::Html($Value), 'span', array('class' => 'Meta-Value')), '</span>'; } } echo '</div>'; ?>
<tr id="<?php echo "UserID_{$User->UserID}"; ?> "<?php echo $Alt ? ' class="Alt"' : ''; ?> data-userid="<?php echo $User->UserID; ?> "> <!-- <td class="CheckboxCell"><input type="checkbox" name="LogID[]" value="<?php echo $User->UserID; ?> " /></td>--> <td><strong><?php echo userAnchor($User, 'Username'); ?> </strong></td> <?php if ($ViewPersonalInfo) { ?> <td class="Alt"><?php echo Gdn_Format::Email($User->Email); ?> </td> <?php } ?> <td style="max-width: 200px;"> <?php $Roles = val('Roles', $User, array());
/** * Perform formatting against a string for the quote tag. * * @param Nbbc $bbcode Instance of Nbbc doing the parsing. * @param int $action Value of one of NBBC's defined constants. Typically, this will be BBCODE_CHECK. * @param string $name Name of the tag. * @param string $default Value of the _default parameter, from the $params array. * @param array $params A standard set parameters related to the tag. * @param string $content Value between the open and close tags, if any. * @return bool|string Formatted value. */ function doQuote($bbcode, $action, $name, $default, $params, $content) { if ($action == Nbbc::BBCODE_CHECK) { return true; } if (is_string($default)) { $defaultParts = explode(';', $default); // support vbulletin style quoting. $Url = array_pop($defaultParts); if (count($defaultParts) == 0) { $params['name'] = $Url; } else { $params['name'] = implode(';', $defaultParts); $params['url'] = $Url; } } $title = ''; if (isset($params['name'])) { $username = trim($params['name']); $username = html_entity_decode($username, ENT_QUOTES, 'UTF-8'); $User = Gdn::userModel()->getByUsername($username); if ($User) { $userAnchor = userAnchor($User); } else { $userAnchor = anchor(htmlspecialchars($username, null, 'UTF-8'), '/profile/' . rawurlencode($username)); } $title = concatSep(' ', $title, $userAnchor, t('Quote wrote', 'wrote')); } if (isset($params['date'])) { $title = concatSep(' ', $title, t('Quote on', 'on'), htmlspecialchars(trim($params['date']))); } if ($title) { $title = $title . ':'; } if (isset($params['url'])) { $url = trim($params['url']); if (preg_match('/(c|d)-(\\d+)/', strtolower($url), $matches)) { if ($matches[1] === 'd') { $url = "/discussion/{$matches[2]}"; } else { $url = "/discussion/comment/{$matches[2]}#Comment_{$matches[2]}"; } } elseif (is_numeric($url)) { $url = "/discussion/comment/{$url}#Comment_{$url}"; } elseif (!$bbcode->isValidURL($url)) { $url = ''; } if ($url) { $title = concatSep(' ', $title, anchor('<span class="ArrowLink">»</span>', $url, ['class' => 'QuoteLink'])); } } if ($title) { $title = "<div class=\"QuoteAuthor\">{$title}</div>"; } return "\n<blockquote class=\"Quote UserQuote\">\n{$title}\n<div class=\"QuoteText\">{$content}</div>\n</blockquote>\n"; }
<div class="ItemContent Category"><div class="Options">' . getOptions($Category, $this) . '</div>' . Gdn_Format::text($Category->Name) . '</div> </li>'; $Alt = FALSE; } else { $LastComment = UserBuilder($Category, 'Last'); $AltCss = $Alt ? ' Alt' : ''; $Alt = !$Alt; $CatList .= '<li id="Category_' . $CategoryID . '" class="' . $CssClass . '"> <div class="ItemContent Category">' . '<div class="Options">' . getOptions($Category, $this) . '</div>' . CategoryPhoto($Category) . '<div class="TitleWrap">' . anchor(Gdn_Format::text($Category->Name), CategoryUrl($Category), 'Title') . '</div> <div class="CategoryDescription">' . $Category->Description . '</div> <div class="Meta"> <span class="MItem RSS">' . anchor(img('applications/dashboard/design/images/rss.gif', array('alt' => T('RSS Feed'))), '/categories/' . $Category->UrlCode . '/feed.rss', '', array('title' => T('RSS Feed'))) . '</span> <span class="MItem DiscussionCount">' . sprintf(PluralTranslate($Category->CountDiscussions, '%s discussion html', '%s discussions html', t('%s discussion'), t('%s discussions')), BigPlural($Category->CountDiscussions, '%s discussion')) . '</span> <span class="MItem CommentCount">' . sprintf(PluralTranslate($Category->CountComments, '%s comment html', '%s comments html', t('%s comment'), t('%s comments')), BigPlural($Category->CountComments, '%s comment')) . '</span>'; if ($Category->LastTitle != '') { $CatList .= '<span class="MItem LastDiscussionTitle">' . sprintf(t('Most recent: %1$s by %2$s'), anchor(Gdn_Format::text(sliceString($Category->LastTitle, 40)), $Category->LastUrl), userAnchor($LastComment)) . '</span>' . '<span class="MItem LastCommentDate">' . Gdn_Format::date($Category->LastDateInserted) . '</span>'; } // If this category is one level above the max display depth, and it // has children, add a replacement string for them. if ($MaxDisplayDepth > 0 && $Category->Depth == $MaxDisplayDepth - 1 && $Category->TreeRight - $Category->TreeLeft > 1) { $CatList .= '{ChildCategories}'; } $CatList .= '</div> </div> </li>'; } } } } // If there are any remaining child categories that have been collected, do // the replacement one last time.
function writeCommentFormHeader() { $Session = Gdn::session(); if (c('Vanilla.Comment.UserPhotoFirst', true)) { echo userPhoto($Session->User); echo userAnchor($Session->User, 'Username'); } else { echo userAnchor($Session->User, 'Username'); echo userPhoto($Session->User); } }
/** * The callback helper for {@link formatString()}. * * @param array $Match Either the array of arguments or the regular expression match. * @param bool $SetArgs Whether this is a call to initialize the arguments or a matching callback. * @return mixed Returns the matching string or nothing when setting the arguments. * @access private */ function _formatStringCallback($Match, $SetArgs = false) { static $Args = array(), $ContextUserID = null; if ($SetArgs) { $Args = $Match; if (isset($Args['_ContextUserID'])) { $ContextUserID = $Args['_ContextUserID']; } else { $ContextUserID = Gdn::session() && Gdn::session()->isValid() ? Gdn::session()->UserID : null; } return ''; } $Match = $Match[1]; if ($Match == '{') { return $Match; } // Parse out the field and format. $Parts = explode(',', $Match); $Field = trim($Parts[0]); $Format = trim(val(1, $Parts, '')); $SubFormat = strtolower(trim(val(2, $Parts, ''))); $FormatArgs = val(3, $Parts, ''); if (in_array($Format, array('currency', 'integer', 'percent'))) { $FormatArgs = $SubFormat; $SubFormat = $Format; $Format = 'number'; } elseif (is_numeric($SubFormat)) { $FormatArgs = $SubFormat; $SubFormat = ''; } $Value = valr($Field, $Args, null); if ($Value === null && !in_array($Format, array('url', 'exurl', 'number', 'plural'))) { $Result = ''; } else { switch (strtolower($Format)) { case 'date': switch ($SubFormat) { case 'short': $Result = Gdn_Format::date($Value, '%d/%m/%Y'); break; case 'medium': $Result = Gdn_Format::date($Value, '%e %b %Y'); break; case 'long': $Result = Gdn_Format::date($Value, '%e %B %Y'); break; default: $Result = Gdn_Format::date($Value); break; } break; case 'html': case 'htmlspecialchars': $Result = htmlspecialchars($Value); break; case 'number': if (!is_numeric($Value)) { $Result = $Value; } else { switch ($SubFormat) { case 'currency': $Result = '$' . number_format($Value, is_numeric($FormatArgs) ? $FormatArgs : 2); break; case 'integer': $Result = (string) round($Value); if (is_numeric($FormatArgs) && strlen($Result) < $FormatArgs) { $Result = str_repeat('0', $FormatArgs - strlen($Result)) . $Result; } break; case 'percent': $Result = round($Value * 100, is_numeric($FormatArgs) ? $FormatArgs : 0); break; default: $Result = number_format($Value, is_numeric($FormatArgs) ? $FormatArgs : 0); break; } } break; case 'plural': if (is_array($Value)) { $Value = count($Value); } elseif (StringEndsWith($Field, 'UserID', true)) { $Value = 1; } if (!is_numeric($Value)) { $Result = $Value; } else { if (!$SubFormat) { $SubFormat = rtrim("%s {$Field}", 's'); } if (!$FormatArgs) { $FormatArgs = $SubFormat . 's'; } $Result = Plural($Value, $SubFormat, $FormatArgs); } break; case 'rawurlencode': $Result = rawurlencode($Value); break; case 'text': $Result = Gdn_Format::text($Value, false); break; case 'time': $Result = Gdn_Format::date($Value, '%l:%M%p'); break; case 'url': if (strpos($Field, '/') !== false) { $Value = $Field; } $Result = Url($Value, $SubFormat == 'domain'); break; case 'exurl': if (strpos($Field, '/') !== false) { $Value = $Field; } $Result = externalUrl($Value); break; case 'urlencode': $Result = urlencode($Value); break; case 'gender': // Format in the form of FieldName,gender,male,female,unknown[,plural] if (is_array($Value) && count($Value) == 1) { $Value = array_shift($Value); } $Gender = 'u'; if (!is_array($Value)) { $User = Gdn::userModel()->getID($Value); if ($User) { $Gender = $User->Gender; } } else { $Gender = 'p'; } switch ($Gender) { case 'm': $Result = $SubFormat; break; case 'f': $Result = $FormatArgs; break; case 'p': $Result = val(5, $Parts, val(4, $Parts)); break; case 'u': default: $Result = val(4, $Parts); } break; case 'user': case 'you': case 'his': case 'her': case 'your': // $Result = print_r($Value, true); $ArgsBak = $Args; if (is_array($Value) && count($Value) == 1) { $Value = array_shift($Value); } if (is_array($Value)) { if (isset($Value['UserID'])) { $User = $Value; $User['Name'] = formatUsername($User, $Format, $ContextUserID); $Result = userAnchor($User); } else { $Max = c('Garden.FormatUsername.Max', 5); // See if there is another count. $ExtraCount = valr($Field . '_Count', $Args, 0); $Count = count($Value); $Result = ''; for ($i = 0; $i < $Count; $i++) { if ($i >= $Max && $Count > $Max + 1) { $Others = $Count - $i + $ExtraCount; $Result .= ' ' . t('sep and', 'and') . ' ' . plural($Others, '%s other', '%s others'); break; } $ID = $Value[$i]; if (is_array($ID)) { continue; } if ($i == $Count - 1) { $Result .= ' ' . T('sep and', 'and') . ' '; } elseif ($i > 0) { $Result .= ', '; } $Special = array(-1 => T('everyone'), -2 => T('moderators'), -3 => T('administrators')); if (isset($Special[$ID])) { $Result .= $Special[$ID]; } else { $User = Gdn::userModel()->getID($ID); if ($User) { $User->Name = formatUsername($User, $Format, $ContextUserID); $Result .= userAnchor($User); } } } } } else { $User = Gdn::userModel()->getID($Value); if ($User) { // Store this name separately because of special 'You' case. $Name = formatUsername($User, $Format, $ContextUserID); // Manually build instead of using userAnchor() because of special 'You' case. $Result = anchor(htmlspecialchars($Name), userUrl($User)); } else { $Result = ''; } } $Args = $ArgsBak; break; default: $Result = $Value; break; } } return $Result; }
/** * Gets a nice title to represent the participants in a conversation. * * @param array|object $Conversation The conversation to get the participants for. * @param bool $Html Whether or not to return HTML. * @param int $Max The maximum number of participants to show in the list. * @return string Returns a title for the conversation. */ public static function participantTitle($Conversation, $Html = true, $Max = 3) { $Participants = val('Participants', $Conversation); $Total = (int) val('CountParticipants', $Conversation); $MyID = Gdn::session()->UserID; $FoundMe = false; // Try getting people that haven't left the conversation and aren't you. $Users = array(); $i = 0; foreach ($Participants as $Row) { if (val('UserID', $Row) == $MyID) { $FoundMe = true; continue; } if (val('Deleted', $Row)) { continue; } if ($Html) { $Users[] = userAnchor($Row); } else { $Users[] = val('Name', $Row); } $i++; if ($i > $Max || $Total > $Max && $i === $Max) { break; } } $Count = count($Users); if ($Count === 0) { if ($FoundMe) { $Result = t('Just you'); } elseif ($Total) { $Result = plural($Total, '%s person', '%s people'); } else { $Result = t('Nobody'); } } else { $Px = implode(', ', $Users); if ($Count + 1 === $Total && $FoundMe) { $Result = $Px; } elseif ($Total - $Count === 1) { $Result = sprintf(t('%s and 1 other'), $Px); } elseif ($Total > $Count) { $Result = sprintf(t('%s and %s others'), $Px, $Total - $Count); } else { $Result = $Px; } } return $Result; }
" class="<?php echo $CssClass; ?> " title="<?php echo $Title; ?> "> <td class="tag-name"> <?php echo anchor(htmlspecialchars($displayName), '/discussions/tagged/' . val('Name', $Tag)); ?> </td> <td class="created-by"> <?php echo userAnchor($createdBy); ?> </td> <td class="type"> <?php echo $type; ?> </td> <td class="date"> <?php echo $dateInserted; ?> </td> <td class="count"> <?php echo $count;
/** * Calculate any necessary values on an attachment row after it comes from the database. * * @param array $Row The attachment row. */ protected function calculateRow(&$Row) { if (isset($Row['Attributes']) && !empty($Row['Attributes'])) { if (is_array($Row['Attributes'])) { $Attributes = $Row['Attributes']; } else { $Attributes = dbdecode($Row['Attributes']); } if (is_array($Attributes)) { $Row = array_replace($Row, $Attributes); } } unset($Row['Attributes']); $InsertUser = Gdn::userModel()->getID($Row['InsertUserID']); $Row['InsertUser'] = array('Name' => $InsertUser->Name, 'ProfileLink' => userAnchor($InsertUser)); }
/** * * * @param $Type * @param $ID * @param $QuoteData * @param bool $Format */ protected function formatQuote($Type, $ID, &$QuoteData, $Format = false) { // Temporarily disable Emoji parsing (prevent double-parsing to HTML) $emojiEnabled = Emoji::instance()->enabled; Emoji::instance()->enabled = false; if (!$Format) { $Format = c('Garden.InputFormatter'); } $Type = strtolower($Type); $Model = false; switch ($Type) { case 'comment': $Model = new CommentModel(); break; case 'discussion': $Model = new DiscussionModel(); break; default: break; } //$QuoteData = array(); if ($Model) { $Data = $Model->getID($ID); $NewFormat = $Format; if ($NewFormat == 'Wysiwyg') { $NewFormat = 'Html'; } $QuoteFormat = $Data->Format; if ($QuoteFormat == 'Wysiwyg') { $QuoteFormat = 'Html'; } // Perform transcoding if possible $NewBody = $Data->Body; if ($QuoteFormat != $NewFormat) { if (in_array($NewFormat, array('Html', 'Wysiwyg'))) { $NewBody = Gdn_Format::to($NewBody, $QuoteFormat); } elseif ($QuoteFormat == 'Html' && $NewFormat == 'BBCode') { $NewBody = Gdn_Format::text($NewBody, false); } elseif ($QuoteFormat == 'Text' && $NewFormat == 'BBCode') { $NewBody = Gdn_Format::text($NewBody, false); } else { $NewBody = Gdn_Format::plainText($NewBody, $QuoteFormat); } if (!in_array($NewFormat, array('Html', 'Wysiwyg'))) { Gdn::controller()->informMessage(sprintf(t('The quote had to be converted from %s to %s.', 'The quote had to be converted from %s to %s. Some formatting may have been lost.'), htmlspecialchars($QuoteFormat), htmlspecialchars($NewFormat))); } } $Data->Body = $NewBody; // Format the quote according to the format. switch ($Format) { case 'Html': // HTML $Quote = '<blockquote class="Quote" rel="' . htmlspecialchars($Data->InsertName) . '">' . $Data->Body . '</blockquote>' . "\n"; break; case 'BBCode': $Author = htmlspecialchars($Data->InsertName); if ($ID) { $IDString = ';' . htmlspecialchars($ID); } $QuoteBody = $Data->Body; // TODO: Strip inner quotes... // $QuoteBody = trim(preg_replace('`(\[quote.*/quote\])`si', '', $QuoteBody)); $Quote = <<<BQ [quote="{$Author}{$IDString}"]{$QuoteBody}[/quote] BQ; break; case 'Markdown': case 'Display': case 'Text': $QuoteBody = $Data->Body; // Strip inner quotes and mentions... $QuoteBody = self::_stripMarkdownQuotes($QuoteBody); $QuoteBody = self::_stripMentions($QuoteBody); $Quote = '> ' . sprintf(t('%s said:'), '@' . $Data->InsertName) . "\n" . '> ' . str_replace("\n", "\n> ", $QuoteBody) . "\n"; break; case 'Wysiwyg': $Attribution = sprintf(t('%s said:'), userAnchor($Data, null, array('Px' => 'Insert'))); $QuoteBody = $Data->Body; // TODO: Strip inner quotes... // $QuoteBody = trim(preg_replace('`(<blockquote.*/blockquote>)`si', '', $QuoteBody)); $Quote = <<<BLOCKQUOTE <blockquote class="Quote"> <div class="QuoteAuthor">{$Attribution}</div> <div class="QuoteText">{$QuoteBody}</div> </blockquote> BLOCKQUOTE; break; } $QuoteData = array_merge($QuoteData, array('status' => 'success', 'body' => $Quote, 'format' => $Format, 'authorid' => $Data->InsertUserID, 'authorname' => $Data->InsertName, 'type' => $Type, 'typeid' => $ID)); } // Undo Emoji disable. Emoji::instance()->enabled = $emojiEnabled; }
echo 'Discussion_' . $Discussion->DiscussionID; ?> " class="<?php echo $CssClass; ?> "> <div class="Discussion"> <div class="Item-Header DiscussionHeader"> <div class="AuthorWrap"> <span class="Author"> <?php if ($UserPhotoFirst) { echo userPhoto($Author); echo userAnchor($Author, 'Username'); } else { echo userAnchor($Author, 'Username'); echo userPhoto($Author); } echo formatMeAction($Discussion); ?> </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')); $this->fireEvent('AuthorInfo'); ?> </span> </div> <div class="Meta DiscussionMeta"> <span class="MItem DateCreated">
/** * 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 }
?> </div> <span itemprop="name"><?php echo $this->data('Name'); ?> </span> <span itemprop="softwareVersion"><?php echo $this->data('Version'); ?> </span> </h1> <?php $addonID = $this->data('AddonID'); $ver = $this->data('Checked') ? '' : 'v1'; $ver2 = $this->data('Checked') || $this->data('Vanilla2') ? '' : 'v1'; $author = $this->data('Official') ? t('Vanilla Staff') : userAnchor($this->Data, null, array('Px' => 'Insert', 'Rel' => 'author')); $manager = checkPermission('Addons.Addon.Manage'); if ($session->UserID == $this->data('InsertUserID') || $manager) { echo '<div class="AddonOptions">'; echo anchor('Edit Details', "/addon/edit{$ver}/{$addonID}", 'Popup'); echo '|' . anchor('Upload New Version', "/addon/newversion{$ver2}/{$addonID}"); echo '|' . anchor('Upload Screenshot', '/addon/addpicture/' . $addonID); echo '|' . anchor('Upload Icon', '/addon/icon/' . $addonID); if ($manager) { $officialInverse = $this->data('Official') ? 'Unofficial' : 'Official'; echo '|' . anchor('Mark as ' . $officialInverse, '/addon/official/' . $addonID . '?TransientKey=' . urlencode(Gdn::session()->transientKey())); echo '|' . anchor('DELETE ADDON', '/addon/delete/' . $addonID . '?TransientKey=' . urlencode(Gdn::session()->transientKey()) . '&Target=/addon', 'Popup DeleteAddon Alert'); } $this->fireEvent('AddonOptions'); echo '</div>'; }