public function DiscussionController_Render_Before(&$Sender) { $Sender->Head->AddTag('meta', array('content' => Gdn_Format::Text($Sender->Discussion->Name), 'property' => 'og:title')); $Sender->Head->AddTag('meta', array('content' => Gdn_Url::Request(true, true, true), 'property' => 'og:url')); $Sender->Head->AddTag('meta', array('content' => C('Garden.Title'), 'property' => 'og:site_name')); $Sender->Head->AddTag('meta', array('content' => 'article', 'property' => 'og:type')); $Sender->addJsFile('http://connect.facebook.net/en_US/all.js#xfbml=1'); }
public function Index($Offset = 0, $Limit = NULL) { $this->AddJsFile('/js/library/jquery.gardenmorepager.js'); $this->AddJsFile('search.js'); $this->Title(T('Search')); if (!is_numeric($Limit)) { $Limit = Gdn::Config('Garden.Search.PerPage', 20); } $Search = $this->Form->GetFormValue('Search'); $ResultSet = $this->SearchModel->Search($Search, $Offset, $Limit); $this->SetData('SearchResults', $ResultSet, TRUE); $this->SetData('SearchTerm', Gdn_Format::Text($Search), TRUE); if ($ResultSet) { $NumResults = $ResultSet->NumRows(); } else { $NumResults = 0; } if ($NumResults == $Offset + $Limit) { $NumResults++; } // Build a pager $PagerFactory = new Gdn_PagerFactory(); $Pager = $PagerFactory->GetPager('MorePager', $this); $Pager->MoreCode = 'More Results'; $Pager->LessCode = 'Previous Results'; $Pager->ClientID = 'Pager'; $Pager->Configure($Offset, $Limit, $NumResults, 'dashboard/search/%1$s/%2$s/?Search=' . Gdn_Format::Url($Search)); $this->SetData('Pager', $Pager, TRUE); if ($this->_DeliveryType != DELIVERY_TYPE_ALL) { $this->SetJson('LessRow', $this->Pager->ToString('less')); $this->SetJson('MoreRow', $this->Pager->ToString('more')); $this->View = 'results'; } $this->Render(); }
function WriteModuleDiscussion($Discussion, $Px = 'Bookmark') { ?> <li id="<?php echo "{$Px}_{$Discussion->DiscussionID}"; ?> " class="<?php echo CssClass($Discussion); ?> "> <span class="Options"> <?php // echo OptionsList($Discussion); echo BookmarkButton($Discussion); ?> </span> <div class="Title"><?php echo Anchor(Gdn_Format::Text($Discussion->Name, FALSE), DiscussionUrl($Discussion) . ($Discussion->CountCommentWatch > 0 ? '#Item_' . $Discussion->CountCommentWatch : ''), 'DiscussionLink'); ?> </div> <div class="Meta"> <?php $Last = new stdClass(); $Last->UserID = $Discussion->LastUserID; $Last->Name = $Discussion->LastName; echo NewComments($Discussion); echo '<span class="MItem">' . Gdn_Format::Date($Discussion->LastDate, 'html') . UserAnchor($Last) . '</span>'; ?> </div> </li> <?php }
function WriteDiscussion($Discussion, &$Sender, &$Session, $Alt) { $CssClass = 'Item'; $CssClass .= $Discussion->Bookmarked == '1' ? ' Bookmarked' : ''; $CssClass .= $Alt . ' '; $CssClass .= $Discussion->Announce == '1' ? ' Announcement' : ''; $CssClass .= $Discussion->Closed == '1' ? ' Closed' : ''; $CssClass .= $Discussion->InsertUserID == $Session->UserID ? ' Mine' : ''; $CssClass .= $Discussion->CountUnreadComments > 0 && $Session->IsValid() ? ' New' : ''; $Sender->EventArguments['Discussion'] =& $Discussion; $Sender->FireEvent('BeforeDiscussionName'); $DiscussionName = Gdn_Format::Text($Discussion->Name); if ($DiscussionName == '') { $DiscussionName = T('Blank Discussion Topic'); } static $FirstDiscussion = TRUE; if (!$FirstDiscussion) { $Sender->FireEvent('BetweenDiscussion'); } else { $FirstDiscussion = FALSE; } ?> <li class="<?php echo $CssClass; ?> "> <?php if ($Discussion->FirstPhoto != '') { if (strtolower(substr($Discussion->FirstPhoto, 0, 7)) == 'http://' || strtolower(substr($Discussion->FirstPhoto, 0, 8)) == 'https://') { $PhotoUrl = $Discussion->FirstPhoto; } else { $PhotoUrl = 'uploads/' . ChangeBasename($Discussion->FirstPhoto, 'n%s'); } echo Img($PhotoUrl, array('alt' => $Discussion->FirstName)); } ?> <div class="ItemContent Discussion"> <?php echo Anchor($DiscussionName, '/discussion/' . $Discussion->DiscussionID . '/' . Gdn_Format::Url($Discussion->Name) . ($Discussion->CountCommentWatch > 0 && C('Vanilla.Comments.AutoOffset') ? '/#Item_' . $Discussion->CountCommentWatch : ''), 'Title'); ?> <?php $Sender->FireEvent('AfterDiscussionTitle'); ?> <div class="Meta"> <span class="Author"><?php echo $Discussion->FirstName; ?> </span> <?php echo '<span class="Counts' . ($Discussion->CountUnreadComments > 0 ? ' NewCounts' : '') . '">' . ($Discussion->CountUnreadComments > 0 ? $Discussion->CountUnreadComments . '/' : '') . $Discussion->CountComments . '</span>'; if ($Discussion->LastCommentID != '') { echo '<span class="LastCommentBy">' . sprintf(T('Latest %1$s'), $Discussion->LastName) . '</span> '; } echo '<span class="LastCommentDate">' . Gdn_Format::Date($Discussion->FirstDate) . '</span> '; ?> </div> </div> </li> <?php }
public function FormatKey($Key, $Data) { if (isset($Data['_New']) && isset($Data['_New'][$Key])) { $Old = Gdn_Format::Text(GetValue($Key, $Data, ''), FALSE); $New = Gdn_Format::Text($Data['_New'][$Key], FALSE); $Result = $this->FormatDiff($Old, $New); } else { $Result = Gdn_Format::Text(GetValue($Key, $Data, ''), FALSE); } return nl2br(trim(($Result))); }
function xHtml($String) { $HtmlFormatter = Gdn::Factory('HtmlFormatter'); if ($HtmlFormatter) { $String = $HtmlFormatter->Format($String); } else { $String = Gdn_Format::Text($String); } return $String; }
public function Index($Offset = 0, $Limit = NULL) { $this->AddJsFile('jquery.gardenmorepager.js'); $this->AddJsFile('search.js'); $this->Title(T('Search')); if(!is_numeric($Limit)) $Limit = Gdn::Config('Garden.Search.PerPage', 20); $Search = $this->Form->GetFormValue('Search'); $Mode = $this->Form->GetFormValue('Mode'); if ($Mode) $this->SearchModel->ForceSearchMode = $Mode; try { $ResultSet = $this->SearchModel->Search($Search, $Offset, $Limit); } catch (Gdn_UserException $Ex) { $this->Form->AddError($Ex); $ResultSet = array(); } catch (Exception $Ex) { $ResultSet = array(); } $this->SetData('SearchResults', $ResultSet, TRUE); $this->SetData('SearchTerm', Gdn_Format::Text($Search), TRUE); if($ResultSet) $NumResults = count($ResultSet); else $NumResults = 0; if ($NumResults == $Offset + $Limit) $NumResults++; // Build a pager $PagerFactory = new Gdn_PagerFactory(); $this->Pager = $PagerFactory->GetPager('MorePager', $this); $this->Pager->MoreCode = 'More Results'; $this->Pager->LessCode = 'Previous Results'; $this->Pager->ClientID = 'Pager'; $this->Pager->Configure( $Offset, $Limit, $NumResults, 'dashboard/search/%1$s/%2$s/?Search='.Gdn_Format::Url($Search) ); if ($this->_DeliveryType != DELIVERY_TYPE_ALL) { $this->SetJson('LessRow', $this->Pager->ToString('less')); $this->SetJson('MoreRow', $this->Pager->ToString('more')); $this->View = 'results'; } $this->CanonicalUrl(Url('search', TRUE)); $this->Render(); }
public function ToString() { echo '<div class="Box DonateBox">'; echo Wrap(T('Donation Box'), 'h4'); echo '<ul class="PanelInfo">'; echo '<p></p>'; echo T("Your Donations will help keep this forum afloat"); echo '<p></p>'; echo Anchor(Gdn_Format::Text("My donation link"), Gdn_Format::Url("/donations")); // edit the links above to the appropriate paypal or whatever donate links and image echo Wrap(T('Item 1'), 'li'); echo Wrap(T('Item 2'), 'li'); echo "</ul>"; echo "</div>"; }
function WriteDiscussionEvent($Discussion, $Prefix = null) { ?> <li class="<?php echo CssClass($Discussion); ?> "> <div class="Title"> <?php echo Anchor(Gdn_Format::Text($Discussion->Name, false), DiscussionUrl($Discussion) . ($Discussion->CountCommentWatch > 0 ? '#Item_' . $Discussion->CountCommentWatch : ''), 'DiscussionLink'); ?> </div><div class="Meta"><span class="MItem"> <?php echo Gdn_Format::Date($Discussion->DiscussionEventDate, 'html'); ?> </span></div> </li> <?php }
public function ProfileController_AfterUserInfo_Handler($Sender) { if (Gdn::Session()->CheckPermission('Garden.Moderation.Manage') || $Sender->User->UserID == Gdn::Session()->User->UserID) { $Warnings = Gdn::UserModel()->GetMeta($Sender->User->UserID, 'Warnings.%', 'Warnings.', array()); krsort($Warnings); $History = False; echo '<div class="Warnings">'; echo Wrap(T('Warning.Warnings', 'Warnings'), 'h2', array('class' => 'H')); foreach ($Warnings as $Date => $Warning) { $Warning = Gdn_Format::Unserialize($Warning); $Reason = ''; if (is_array($Warning)) { $Reason = $Warning['Reason']; $Warning = $Warning['Type']; } if ($History && $Warning != 'None') { $WarningClass = "{$Warning} Historical"; } else { $WarningClass = $Warning; } if (!$History && $Warning == 'None') { echo '<div class="NoWarning">' . T('Warning.NoWarnings', 'There are no current warnings for this user. ') . '</div>'; } echo '<div class="Warn ' . $WarningClass . '">' . T('Warning.Level.' . $Warning, $Warning) . '<span class="WarningDate">' . Gdn_Format::Date($Date) . '</span></div>'; if ($Reason) { echo '<div class="WarningReason ' . $WarningClass . '">' . Gdn_Format::Text($Reason) . '</div>'; } $History = True; } if (count($Warnings) == 0) { echo '<div class="NoWarning">' . T('Warning.NoWarnings', 'There are no current warnings for this user. ') . '</div>'; } if (count($Warnings) > 1) { echo '<a class="WarningTogggleHistory" href="#">' . T('Warning.ToggleHistory', 'Toggle History') . '</a>'; } echo '</div>'; } }
public function Search($Search, $Offset = 0, $Limit = 20) { // If there are no searches then return an empty array. if (trim($Search) == '') { return array(); } // Figure out the exact search mode. if ($this->ForceSearchMode) { $SearchMode = $this->ForceSearchMode; } else { $SearchMode = strtolower(C('Garden.Search.Mode', 'matchboolean')); } if ($SearchMode == 'matchboolean') { if (strpos($Search, '+') !== FALSE || strpos($Search, '-') !== FALSE) { $SearchMode = 'boolean'; } else { $SearchMode = 'match'; } } else { $this->_SearchMode = $SearchMode; } if ($ForceDatabaseEngine = C('Database.ForceStorageEngine')) { if (strcasecmp($ForceDatabaseEngine, 'myisam') != 0) { $SearchMode = 'like'; } } $this->_SearchMode = $SearchMode; $this->FireEvent('Search'); if (count($this->_SearchSql) == 0) { return array(); } // Perform the search by unioning all of the sql together. $Sql = $this->SQL->Select()->From('_TBL_ s')->OrderBy('s.DateInserted', 'desc')->Limit($Limit, $Offset)->GetSelect(); $Sql = str_replace($this->Database->DatabasePrefix . '_TBL_', "(\n" . implode("\nunion all\n", $this->_SearchSql) . "\n)", $Sql); $this->EventArguments['Search'] = $Search; $this->FireEvent('AfterBuildSearchQuery'); if ($this->_SearchMode == 'like') { $Search = '%' . $Search . '%'; } foreach ($this->_Parameters as $Key => $Value) { $this->_Parameters[$Key] = $Search; } $Parameters = $this->_Parameters; $this->Reset(); $this->SQL->Reset(); $Result = $this->Database->Query($Sql, $Parameters)->ResultArray(); foreach ($Result as $Key => $Value) { if (isset($Value['Summary'])) { $Value['Summary'] = Gdn_Format::Text(Gdn_Format::To($Value['Summary'], $Value['Format'])); $Result[$Key] = $Value; } } return $Result; }
public function Search($Search, $Offset = 0, $Limit = 20) { $AllSettings = SphinxFactory::BuildSettings(); $Settings = $AllSettings->GetAllSettings(); // if (($Settings['Status']->SearchdRunning == 1) && ($Settings['Status']->EnableSphinxSearch == 1)) if (true) { // Force this to be true while the sphinxsearch plugin is enabled! return FALSE; } else { // If there are no searches then return an empty array. if (trim($Search) == '') { return array(); } // Figure out the exact search mode. if ($this->ForceSearchMode) { $SearchMode = $this->ForceSearchMode; } else { $SearchMode = strtolower(C('Garden.Search.Mode', 'matchboolean')); } if ($SearchMode == 'matchboolean') { if (strpos($Search, '+') !== FALSE || strpos($Search, '-') !== FALSE) { $SearchMode = 'boolean'; } else { $SearchMode = 'match'; } } else { $this->_SearchMode = $SearchMode; } $this->_SearchMode = $SearchMode; $this->FireEvent('Search'); //print_r($this->_SearchSql); if (count($this->_SearchSql) == 0) { return array(); } // Perform the search by unioning all of the sql together. $Sql = $this->SQL->Select()->From('_TBL_ s')->OrderBy('s.DateInserted', 'desc')->Limit($Limit, $Offset)->GetSelect(); $Sql = str_replace($this->Database->DatabasePrefix . '_TBL_', "(\n" . implode("\nunion all\n", $this->_SearchSql) . "\n)", $Sql); $this->EventArguments['Search'] = $Search; $this->FireEvent('AfterBuildSearchQuery'); if ($this->_SearchMode == 'like') { $Search = '%' . $Search . '%'; } foreach ($this->_Parameters as $Key => $Value) { $this->_Parameters[$Key] = $Search; } $Result = $this->Database->Query($Sql, $this->_Parameters)->ResultArray(); $this->Reset(); $this->SQL->Reset(); foreach ($Result as $Key => $Value) { if (isset($Value['Summary'])) { $Value['Summary'] = Gdn_Format::Text(Gdn_Format::To($Value['Summary'], $Value['Format'])); $Result[$Key] = $Value; } } return $Result; } }
/** * Add a method to the ModerationController to handle splitting comments out to a new discussion. */ public function ModerationController_SplitComments_Create($Sender) { $Session = Gdn::Session(); $Sender->Form = new Gdn_Form(); $Sender->Title(T('Split Comments')); $Sender->Category = FALSE; $DiscussionID = GetValue('0', $Sender->RequestArgs, ''); if (!is_numeric($DiscussionID)) { return; } $DiscussionModel = new DiscussionModel(); $Discussion = $DiscussionModel->GetID($DiscussionID); if (!$Discussion) { return; } // Verify that the user has permission to perform the split $Sender->Permission('Vanilla.Discussions.Edit', TRUE, 'Category', $Discussion->PermissionCategoryID); $CheckedComments = Gdn::UserModel()->GetAttribute($Session->User->UserID, 'CheckedComments', array()); if (!is_array($CheckedComments)) { $CheckedComments = array(); } $CommentIDs = array(); foreach ($CheckedComments as $DiscID => $Comments) { foreach ($Comments as $Comment) { if ($DiscID == $DiscussionID) { $CommentIDs[] = str_replace('Comment_', '', $Comment); } } } // Load category data. $Sender->ShowCategorySelector = (bool) C('Vanilla.Categories.Use'); $CountCheckedComments = count($CommentIDs); $Sender->SetData('CountCheckedComments', $CountCheckedComments); // Perform the split if ($Sender->Form->AuthenticatedPostBack()) { // Create a new discussion record $Data = $Sender->Form->FormValues(); $Data['Body'] = sprintf(T('This discussion was created from comments split from: %s.'), Anchor(Gdn_Format::Text($Discussion->Name), 'discussion/' . $Discussion->DiscussionID . '/' . Gdn_Format::Url($Discussion->Name) . '/')); $Data['Format'] = 'Html'; $Data['Type'] = 'Discussion'; $NewDiscussionID = $DiscussionModel->Save($Data); $Sender->Form->SetValidationResults($DiscussionModel->ValidationResults()); if ($Sender->Form->ErrorCount() == 0 && $NewDiscussionID > 0) { // Re-assign the comments to the new discussion record $DiscussionModel->SQL->Update('Comment')->Set('DiscussionID', $NewDiscussionID)->WhereIn('CommentID', $CommentIDs)->Put(); // Update counts on both discussions $CommentModel = new CommentModel(); $CommentModel->UpdateCommentCount($DiscussionID); // $CommentModel->UpdateUserCommentCounts($DiscussionID); $CommentModel->UpdateCommentCount($NewDiscussionID); $CommentModel->RemovePageCache($DiscussionID, 1); // Clear selections unset($CheckedComments[$DiscussionID]); Gdn::UserModel()->SaveAttribute($Session->UserID, 'CheckedComments', $CheckedComments); ModerationController::InformCheckedComments($Sender); $Sender->RedirectUrl = Url('discussion/' . $NewDiscussionID . '/' . Gdn_Format::Url($Data['Name'])); } } else { $Sender->Form->SetValue('CategoryID', GetValue('CategoryID', $Discussion)); } $Sender->Render($this->GetView('splitcomments.php')); }
<?php if (!defined('APPLICATION')) { exit; } ?> <li class="SteamProfile"> <?php echo $Sender->Form->Label('Steam Profile'); // Do we happen to already have a Steam ID for our current user? if ($Sender->Data('SteamID64')) { // If so, we just output it. Nothing fancy. echo '<div>' . T('Steam ID') . ': ' . Gdn_Format::Text($Sender->Data('SteamID64')) . '</div>'; } else { // If not, we drop in a button and set the stage for OpenID magic. echo Anchor(Img('plugins/steamprofile/design/images/sits_small.png', array('alt' => 'Sign in through Steam')), $Sender->Data('SteamAuthenticationUrl'), '', array('title' => 'Sign in through Steam')); } ?> </li>
/** * Registration that requires approval. * * Events: RegistrationPending * * @access private * @since 2.0.0 */ private function RegisterApproval() { Gdn::UserModel()->AddPasswordStrength($this); // If the form has been posted back... if ($this->Form->IsPostBack()) { // Add validation rules that are not enforced by the model $this->UserModel->DefineSchema(); $this->UserModel->Validation->ApplyRule('Name', 'Username', $this->UsernameError); $this->UserModel->Validation->ApplyRule('TermsOfService', 'Required', T('You must agree to the terms of service.')); $this->UserModel->Validation->ApplyRule('Password', 'Required'); $this->UserModel->Validation->ApplyRule('Password', 'Strength'); $this->UserModel->Validation->ApplyRule('Password', 'Match'); $this->UserModel->Validation->ApplyRule('DiscoveryText', 'Required', 'Tell us why you want to join!'); // $this->UserModel->Validation->ApplyRule('DateOfBirth', 'MinimumAge'); $this->FireEvent('RegisterValidation'); try { $Values = $this->Form->FormValues(); unset($Values['Roles']); $AuthUserID = $this->UserModel->Register($Values); if (!$AuthUserID) { $this->Form->SetValidationResults($this->UserModel->ValidationResults()); } else { // The user has been created successfully, so sign in now. Gdn::Session()->Start($AuthUserID); if ($this->Form->GetFormValue('RememberMe')) { Gdn::Authenticator()->SetIdentity($AuthUserID, TRUE); } // Notification text $Label = T('NewApplicantEmail', 'New applicant:'); $Story = Anchor(Gdn_Format::Text($Label . ' ' . $Values['Name']), ExternalUrl('dashboard/user/applicants')); $this->EventArguments['AuthUserID'] = $AuthUserID; $this->EventArguments['Story'] =& $Story; $this->FireEvent('RegistrationPending'); $this->View = "RegisterThanks"; // Tell the user their application will be reviewed by an administrator. // Grab all of the users that need to be notified. $Data = Gdn::Database()->SQL()->GetWhere('UserMeta', array('Name' => 'Preferences.Email.Applicant'))->ResultArray(); $ActivityModel = new ActivityModel(); foreach ($Data as $Row) { $ActivityModel->Add($AuthUserID, 'Applicant', $Story, $Row['UserID'], '', '/dashboard/user/applicants', 'Only'); } } } catch (Exception $Ex) { $this->Form->AddError($Ex); } } $this->Render(); }
?> <ul class="PopList Conversations"> <li class="Item Title"> <?php echo Anchor(T('New Message'), 'messages/add'); echo Wrap(T('Inbox'), 'strong'); ?> </li> <?php if (count($this->Data('Conversations'))) { ?> <?php foreach ($this->Data('Conversations') as $Row) { $Subject = ''; if ($Row['Subject']) { $Subject = Gdn_Format::Text($Row['Subject']); } else { $Subject = ''; foreach ($Row['Participants'] as $User) { if (!isset($PhotoUser)) { $PhotoUser = $User; } $Subject = ConcatSep(', ', $Subject, FormatUsername($User, 'You')); } } if (!isset($PhotoUser)) { $PhotoUser = UserBuilder($Row, 'LastMessage'); } ?> <li class="Item" rel="<?php echo Url("/messages/{$Row['ConversationID']}#latest");
?> </div> </div> <?php if ($NumComplaintsInThread > 1) { echo '<div class="OtherComplaints">' . "\n"; } } else { ?> <div class="FlaggedOtherCell"> <div class="FlaggedItemInfo"><?php echo T('On') . ' ' . $Flag['DateInserted'] . ', <strong>' . Anchor($Flag['InsertName'], "profile/{$Flag['InsertUserID']}/{$Flag['InsertName']}") . '</strong> ' . T('said:'); ?> </div> <div class="FlaggedItemComment">"<?php echo Gdn_Format::Text($Flag['Comment']); ?> "</div> </div> <?php } } if ($NumComplaintsInThread > 1) { echo "</div>\n"; } ?> </div> <?php } } ?>
/** * Build the user profile: Set the page title, add data to page modules & add * modules to assets, Add tabs to tab menu. $this->User must be defined, * or this method will throw an exception. */ public function BuildProfile() { if (!is_object($this->User)) { throw new Exception(T('Cannot build profile information if user is not defined.')); } $Session = Gdn::Session(); $this->CssClass = 'Profile'; $this->Title(Gdn_Format::Text($this->User->Name)); if ($this->_DeliveryType != DELIVERY_TYPE_VIEW) { $UserInfoModule = new UserInfoModule($this); $UserInfoModule->User = $this->User; $UserInfoModule->Roles = $this->Roles; $this->AddModule($UserInfoModule); $this->AddJsFile('jquery.jcrop.pack.js'); $this->AddJsFile('profile.js'); $this->AddJsFile('activity.js'); $ActivityUrl = 'profile/activity/'; if ($this->User->UserID != $Session->UserID) { $ActivityUrl .= $this->User->UserID . '/' . Gdn_Format::Url($this->User->Name); } $this->AddProfileTab(T('Activity'), $ActivityUrl); if ($this->User->UserID == $Session->UserID) { $Notifications = T('Notifications'); $CountNotifications = $Session->User->CountNotifications; if (is_numeric($CountNotifications) && $CountNotifications > 0) { $Notifications .= '<span>' . $CountNotifications . '</span>'; } $this->AddProfileTab(array($Notifications => 'profile/notifications')); } $this->FireEvent('AddProfileTabs'); } return TRUE; }
function WriteTable($Results, $WriteText, $CssClass) { $String = ''; $Total = sizeof($Results); if ($Total == 0) { return $String; //return an empty string if no results } $Count = 0; //for toggling the message div if text ob_start(); ?> <div class="SphinxSearch Table"> <table> <thead> <tr> <th class="Title">Discussion</th> <th class="Starter">Starter</th> <th class="Forum">Forum</th> <th class="InfoCount">R / V</th> <th class="Latest">Latest</th> </tr> </thead> <tbody> <?php foreach ($Results as $Row) { ?> <?php $ID = 'T_' . $Count++; //unique identifer $OAuthor->Name = $Row->UserName; $OAuthor->UserID = $Row->UserID; //original author $LAuthor->Name = $Row->LastUserName; $LAuthor->UserID = $Row->LastUserID; //latest author $Row->CountCommentWatch = $Row->CountComments; //for discussion link $TitleURL = $Row->IsComment ? 'discussion/comment/' . $Row->CommentID . '/#Comment_' . $Row->CommentID : DiscussionLink($Row, FALSE); //if the comment is from the orignal discussion poster, simply link to the front page of that ?> <tr <?php echo Alternate(); ?> > <td class="Title"> <?php if ($WriteText) { ?> <span id="<?php echo $ID; ?> " class="PlusImage Toggle"></span> <?php } ?> <span class="Title"><?php echo Anchor($Row->Title . Wrap(htmlspecialchars(SliceString($Row->DiscussionBody, SS_PREVIEW_BODY_LIMIT)), 'span', array('class' => 'ToolTip')), $TitleURL, FALSE, array('class' => 'HasToolTip')); ?> </span> </td> <td class="Starter"> <?php echo UserAnchor($OAuthor); ?> <?php Anchor(Gdn_Format::Date($Row->DateInserted), $TitleURL); ?> </td> <td class="Forum"> <?php echo Anchor(Gdn_Format::Text($Row->CatName), 'categories/' . $Row->CatUrlCode); ?> </td> <td class="InfoCount"> <?php echo Gdn_Format::BigNumber($Row->CountComments); ?> / <?php echo Gdn_Format::BigNumber($Row->CountViews); ?> </td> <td class="Latest"> <?php echo UserAnchor($LAuthor) . ' on '; echo Anchor(Gdn_Format::Date($Row->DateInserted), DiscussionLink($Row, $Extended = TRUE)); ?> </td> </tr> <?php if ($WriteText) { ?> <tr id="<?php echo $ID . 'T'; ?> " style="display: none" class="ExpandText"> <td colspan="5"> <!-- Need this since this column will expand the width of the table !--> <div class="Message Excerpt"> <?php echo nl2br(SliceString($Row->Body, SS_BODY_LIMIT)); ?> </div> </td> </tr> <?php } ?> <?php } ?> </tbody> </table> <div style="clear: both"></div> </div> <?php $String = ob_get_contents(); @ob_end_clean(); return $String; }
echo Anchor('<span>*</span>', '/vanilla/discussion/bookmark/' . $this->Discussion->DiscussionID . '/' . $Session->TransientKey() . '?Target=' . urlencode($this->SelfUrl), 'Bookmark' . ($this->Discussion->Bookmarked == '1' ? ' Bookmarked' : ''), array('title' => T($this->Discussion->Bookmarked == '1' ? 'Unbookmark' : 'Bookmark'))); } ?> <div class="Tabs HeadingTabs DiscussionTabs"> <ul> <li><?php if (Gdn::Config('Vanilla.Categories.Use') === TRUE) { echo Anchor($this->Discussion->Category, 'categories/' . $this->Discussion->CategoryUrlCode); } else { echo Anchor(T('All Discussions'), 'discussions'); } ?> </li> </ul> <div class="SubTab"><?php $DiscussionName = Gdn_Format::Text($this->Discussion->Name); if ($DiscussionName == '') { $DiscussionName = T('Blank Discussion Topic'); } echo $DiscussionName; ?> </div> </div> <?php //echo $this->Pager->ToString('less'); echo $this->RenderAsset('DiscussionBefore'); ?> <ul class="MessageList Discussion"> <?php echo $this->FetchView('comments'); ?>
/** * Queue a notification for sending. * * @since 2.0.17 * @access public * @param int $ActivityID * @param string $Story * @param string $Position * @param bool $Force */ public function QueueNotification($ActivityID, $Story = '', $Position = 'last', $Force = FALSE) { $Activity = $this->GetID($ActivityID); if (!is_object($Activity)) { return; } $Story = Gdn_Format::Text($Story == '' ? $Activity->Story : $Story, FALSE); // If this is a comment on another activity, fudge the activity a bit so that everything appears properly. if (is_null($Activity->RegardingUserID) && $Activity->CommentActivityID > 0) { $CommentActivity = $this->GetID($Activity->CommentActivityID); $Activity->RegardingUserID = $CommentActivity->RegardingUserID; $Activity->Route = '/activity/item/' . $Activity->CommentActivityID; } $User = Gdn::UserModel()->GetID($Activity->RegardingUserID, DATASET_TYPE_OBJECT); //$this->SQL->Select('UserID, Name, Email, Preferences')->From('User')->Where('UserID', $Activity->RegardingUserID)->Get()->FirstRow(); if ($User) { if ($Force) { $Preference = $Force; } else { // $Preferences = Gdn_Format::Unserialize($User->Preferences); $ConfigPreference = C('Preferences.Email.' . $Activity->ActivityType, '0'); if ($ConfigPreference !== FALSE) { $Preference = GetValue('Email.' . $Activity->ActivityType, $User->Preferences, $ConfigPreference); } else { $Preference = FALSE; } } if ($Preference) { $ActivityHeadline = Gdn_Format::Text(Gdn_Format::ActivityHeadline($Activity, $Activity->ActivityUserID, $Activity->RegardingUserID), FALSE); $Email = new Gdn_Email(); $Email->Subject(sprintf(T('[%1$s] %2$s'), Gdn::Config('Garden.Title'), $ActivityHeadline)); $Email->To($User); $Message = sprintf($Story == '' ? T('EmailNotification', "%1\$s\n\n%2\$s") : T('EmailStoryNotification', "%3\$s\n\n%2\$s"), $ActivityHeadline, ExternalUrl($Activity->Route == '' ? '/' : $Activity->Route), $Story); $Email->Message($Message); if (!array_key_exists($User->UserID, $this->_NotificationQueue)) { $this->_NotificationQueue[$User->UserID] = array(); } $Notification = array('ActivityID' => $ActivityID, 'User' => $User, 'Email' => $Email, 'Route' => $Activity->Route, 'Story' => $Story, 'Headline' => $ActivityHeadline, 'Activity' => $Activity); if ($Position == 'first') { $this->_NotificationQueue[$User->UserID] = array_merge(array($Notification), $this->_NotificationQueue[$User->UserID]); } else { $this->_NotificationQueue[$User->UserID][] = $Notification; } } } }
<?php foreach ($this->Data('Conversations') as $Row) { ?> <li id="Conversation_<?php echo $Row['ConversationID']; ?> " class="Item"> <?php $JumpToItem = $Row['CountMessages'] - $Row['CountNewMessages']; $Url = "/messages/{$Row['ConversationID']}/#Item_{$JumpToItem}"; if ($SubjectsVisible && $Row['Subject']) { $Message = htmlspecialchars($Row['Title']); } elseif ($Row['Format'] == 'Text') { $Message = SliceString(Gdn_Format::To($Row['LastMessage'], $Conversation['Format']), 100); } else { $Message = SliceString(Gdn_Format::Text(Gdn_Format::To($Row['LastMessage'], $Row['Format']), FALSE), 100); } if (StringIsNullOrEmpty(trim($Message))) { $Message = T('Blank Message'); } echo Anchor($Message, $Url, 'ConversationLink'); ?> <div class="Meta"> <span class="MItem Participants"> <?php $First = TRUE; foreach ($Row['Participants'] as $User) { if ($First) { $First = FALSE; } else { echo ', ';
<div class="Note Closed"><?php echo T('This discussion has been closed.'); ?></div> </div> <?php } else { ?> <h3><?php echo T('Leave Comments'); ?></h3> <div class="MessageForm CommentForm"> <?php echo $this->Form->Open(); echo $this->Form->Errors(); echo Wrap($this->Form->TextBox('Body', array('MultiLine' => TRUE)), 'div', array('class' => 'TextBoxWrapper')); echo "<div class=\"Buttons\">\n"; if ($Session->IsValid()) { $AuthenticationUrl = Gdn::Authenticator()->SignOutUrl(Gdn::Request()->PathAndQuery()); echo Wrap( sprintf( T('Commenting as %1$s (%2$s)'), Gdn_Format::Text($Session->User->Name), Anchor(T('Sign Out'), $AuthenticationUrl, 'SignOut') ), 'div', array('class' => 'Author') ); echo $this->Form->Button('Post Comment', array('class' => 'Button CommentButton')); } else { $AuthenticationUrl = Gdn::Authenticator()->SignInUrl(Gdn::Request()->PathAndQuery()); echo Anchor(T('Comment As ...'), $AuthenticationUrl, 'SignInPopup Button Stash'); } echo "</div>\n"; echo $this->Form->Close(); ?> </div> <?php } ?>
public function RecordActivity($UserID, $DiscussionID, $DiscussionName) { // Report that the discussion was created AddActivity($UserID, 'NewDiscussion', Anchor(Gdn_Format::Text($DiscussionName), 'vanilla/discussion/' . $DiscussionID . '/' . Gdn_Format::Url($DiscussionName))); // Get the user's discussion count $Data = $this->SQL->Select('DiscussionID', 'count', 'CountDiscussions')->From('Discussion')->Where('InsertUserID', $UserID)->Get(); // Save the count to the user table $this->SQL->Update('User')->Set('CountDiscussions', $Data->NumRows() > 0 ? $Data->FirstRow()->CountDiscussions : 0)->Where('UserID', $UserID)->Put(); }
public static function JoinRecentPosts(&$Data) { $DiscussionIDs = array(); $CommentIDs = array(); $Joined = FALSE; foreach ($Data as &$Row) { if (isset($Row['LastTitle']) && $Row['LastTitle']) { continue; } if ($Row['LastDiscussionID']) { $DiscussionIDs[] = $Row['LastDiscussionID']; } if ($Row['LastCommentID']) { $CommentIDs[] = $Row['LastCommentID']; } $Joined = TRUE; } // Create a fresh copy of the Sql object so as not to pollute. $Sql = clone Gdn::SQL(); $Sql->Reset(); // Grab the discussions. if (count($DiscussionIDs) > 0) { $Discussions = $Sql->WhereIn('DiscussionID', $DiscussionIDs)->Get('Discussion')->ResultArray(); $Discussions = Gdn_DataSet::Index($Discussions, array('DiscussionID')); } if (count($CommentIDs) > 0) { $Comments = $Sql->WhereIn('CommentID', $CommentIDs)->Get('Comment')->ResultArray(); $Comments = Gdn_DataSet::Index($Comments, array('CommentID')); } foreach ($Data as &$Row) { $Discussion = GetValue($Row['LastDiscussionID'], $Discussions); $NameUrl = 'x'; if ($Discussion) { $Row['LastTitle'] = Gdn_Format::Text($Discussion['Name']); $Row['LastUserID'] = $Discussion['InsertUserID']; $Row['LastDateInserted'] = $Discussion['DateInserted']; $NameUrl = Gdn_Format::Text($Discussion['Name'], TRUE); $Row['LastUrl'] = DiscussionUrl($Discussion, FALSE, '//') . '#latest'; } $Comment = GetValue($Row['LastCommentID'], $Comments); if ($Comment) { $Row['LastUserID'] = $Comment['InsertUserID']; $Row['LastDateInserted'] = $Comment['DateInserted']; } else { $Row['NoComment'] = TRUE; } TouchValue('LastTitle', $Row, ''); TouchValue('LastUserID', $Row, NULL); TouchValue('LastDateInserted', $Row, NULL); TouchValue('LastUrl', $Row, NULL); } return $Joined; }
function WriteEmbedCommentForm() { $Session = Gdn::Session(); $Controller = Gdn::Controller(); $Discussion = $Controller->Data('Discussion'); if ($Discussion && $Discussion->Closed == '1') { ?> <div class="Foot Closed"> <div class="Note Closed"><?php echo T('This discussion has been closed.'); ?> </div> </div> <?php } else { ?> <h2><?php echo T('Leave a comment'); ?> </h2> <div class="MessageForm CommentForm EmbedCommentForm"> <?php echo $Controller->Form->Open(); echo $Controller->Form->Errors(); echo Wrap($Controller->Form->TextBox('Body', array('MultiLine' => TRUE)), 'div', array('class' => 'TextBoxWrapper')); echo "<div class=\"Buttons\">\n"; $AllowSigninPopup = C('Garden.SignIn.Popup'); $Attributes = array('tabindex' => '-1'); $ReturnUrl = Gdn::Request()->PathAndQuery(); if ($Session->IsValid()) { $AuthenticationUrl = Gdn::Authenticator()->SignOutUrl($ReturnUrl); echo Wrap(sprintf(T('Commenting as %1$s (%2$s)', 'Commenting as %1$s <span class="SignOutWrap">(%2$s)</span>'), Gdn_Format::Text($Session->User->Name), Anchor(T('Sign Out'), $AuthenticationUrl, 'SignOut', $Attributes)), 'div', array('class' => 'Author')); echo $Controller->Form->Button('Post Comment', array('class' => 'Button CommentButton')); } else { $AuthenticationUrl = SignInUrl($ReturnUrl); if ($AllowSigninPopup) { $CssClass = 'SignInPopup Button Stash'; } else { $CssClass = 'Button Stash'; } echo Anchor(T('Comment As ...'), $AuthenticationUrl, $CssClass, $Attributes); } echo "</div>\n"; echo $Controller->Form->Close(); ?> </div> <?php } }
function _FormatStringCallback($Match, $SetArgs = FALSE) { static $Args = array(); if ($SetArgs) { $Args = $Match; return; } $Match = $Match[1]; if ($Match == '{') { return $Match; } // Parse out the field and format. $Parts = explode(',', $Match); $Field = trim($Parts[0]); $Format = trim(GetValue(1, $Parts, '')); $SubFormat = strtolower(trim(GetValue(2, $Parts, ''))); $FormatArgs = GetValue(3, $Parts, ''); if (in_array($Format, array('currency', 'integer', 'percent'))) { $FormatArgs = $SubFormat; $SubFormat = $Format; $Format = 'number'; } elseif (is_numeric($SubFormat)) { $FormatArgs = $SubFormat; $SubFormat = ''; } $Value = GetValueR($Field, $Args, ''); if ($Value == '' && !in_array($Format, array('url', 'exurl'))) { $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); 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 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; } } switch ($Gender) { case 'm': $Result = $SubFormat; break; case 'f': $Result = $FormatArgs; break; default: $Result = GetValue(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)) { $Max = C('Garden.FormatUsername.Max', 5); $Count = count($Value); $Result = ''; for ($i = 0; $i < $Count; $i++) { if ($i >= $Max && $Count > $Max + 1) { $Others = $Count - $i; $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); $User->Name = FormatUsername($User, $Format, Gdn::Session()->UserID); $Result .= UserAnchor($User); } } } else { $User = Gdn::UserModel()->GetID($Value); $User->Name = FormatUsername($User, $Format, Gdn::Session()->UserID); $Result = UserAnchor($User); } $Args = $ArgsBak; break; default: $Result = $Value; break; } } return $Result; }
/** * Takes a mixed variable, formats it in the specified format type, and * returns it. * * @param mixed $Mixed An object, array, or string to be formatted. * @param string $FormatMethod The method with which the variable should be formatted. * @return mixed */ public static function To($Mixed, $FormatMethod) { if ($FormatMethod == '') { return $Mixed; } if (is_string($Mixed)) { if (method_exists('Gdn_Format', $FormatMethod)) { $Mixed = self::$FormatMethod($Mixed); } elseif (function_exists($FormatMethod)) { $Mixed = $FormatMethod($Mixed); } elseif ($Formatter = Gdn::Factory($FormatMethod . 'Formatter')) { $Mixed = $Formatter->Format($Mixed); } else { $Mixed = Gdn_Format::Text($Mixed); } } else { if (is_array($Mixed)) { foreach ($Mixed as $Key => $Val) { $Mixed[$Key] = self::To($Val, $FormatMethod); } } else { if (is_object($Mixed)) { foreach (get_object_vars($Mixed) as $Prop => $Val) { $Mixed->{$Prop} = self::To($Val, $FormatMethod); } } } } return $Mixed; }
public function RecordActivity($Discussion, $ActivityUserID, $CommentID, $SendEmail = '') { // Get the author of the discussion if ($Discussion->InsertUserID != $ActivityUserID) { AddActivity($ActivityUserID, 'DiscussionComment', Anchor(Gdn_Format::Text($Discussion->Name), 'discussion/comment/' . $CommentID . '/#Comment_' . $CommentID), $Discussion->InsertUserID, 'discussion/comment/' . $CommentID . '/#Comment_' . $CommentID, $SendEmail); } }
/** * Record advanced notifications for users. * * @param ActivityModel $ActivityModel * @param array $Discussion * @param int $CommentID * @param array $NotifiedUsers */ public function RecordAdvancedNotications($ActivityModel, $Discussion, $Comment, &$NotifiedUsers) { // Grab all of the users that need to be notified. $Data = $this->SQL->GetWhere('UserMeta', array('Name' => 'Preferences.Email.NewDiscussion'))->ResultArray(); // Grab all of their follow/unfollow preferences. $UserIDs = ConsolidateArrayValuesByKey($Data, 'UserID'); $CategoryID = GetValue('CategoryID', $Discussion); $UserPrefs = $this->SQL->Select('*')->From('UserCategory')->Where('CategoryID', $CategoryID)->WhereIn('UserID', $UserIDs)->Get()->ResultArray(); $UserPrefs = Gdn_DataSet::Index($UserPrefs, 'UserID'); $CommentID = $Comment['CommentID']; foreach ($UserIDs as $UserID) { // if ($UserID == $Comment['InsertUserID']) // continue; if (in_array($UserID, $NotifiedUsers)) { continue; } if (array_key_exists($UserID, $UserPrefs) && $UserPrefs[$UserID]['Unfollow']) { continue; } $ActivityID = AddActivity($Comment['InsertUserID'], 'NewComment', Gdn_Format::Text(Gdn_Format::To($Comment['Body'], $Comment['Format'])), $UserID, "/discussion/comment/{$CommentID}#Comment_{$CommentID}", TRUE); // $ActivityModel->QueueNotification($ActivityID); $NotifiedUsers[] = $UserID; } }