Permalink
Browse files

Merge branch 'develop' of github.com:vanillaforums/Garden into develop

Conflicts:
	applications/vanilla/views/discussion/embed.php
	js/embed.js
  • Loading branch information...
2 parents 6aab2e1 + 3de8451 commit 11503c911da240693ada274b0619f5b4c459c74b @tburry tburry committed Apr 24, 2012
View
@@ -12,7 +12,7 @@ The *master* branch of the vanillaforums repository will always contain our late
## develop
-All of our unreleased development work ends up in the *develop* branch. Sometimes it is committed directly, other times it comes from merged hotfixes again a release, and other times it comes from a merged feature branch. This branch will always contain the most bleeding edge vanillaforums code, so it sometimes has bugs and unfinished features. Use this at your own risk, and avoid deploying it in production.
+All of our unreleased development work ends up in the *develop* branch. Sometimes it is committed directly, other times it comes from merged hotfixes against a release, and other times it comes from a merged feature branch. This branch will always contain the most bleeding edge vanillaforums code, so it sometimes has bugs and unfinished features. Use this at your own risk, and avoid deploying it in production.
## release
@@ -24,4 +24,4 @@ Feature branches are work-in-progress branches that contain large chunks of new
## hotfix/x
-Hotfixes are branched from master and exist to fix small bugs that are detected in a release after it has been tagged in *master*. These branches are usually small and concise, and are merged back into *master* and *develop* once they are completed. They should never be new features.
+Hotfixes are branched from *master* and exist to fix small bugs that are detected in a release after it has been tagged in *master*. These branches are usually small and concise, and are merged back into *master* and *develop* once they are completed. They should never be new features.
@@ -99,11 +99,6 @@ jQuery(document).ready(function($) {
).autogrow();
});
- // Set up paging
- $('.MorePager').morepager({
- pageContainerSelector: 'ul.Conversations, ul.Conversation'
- });
-
$('#Form_AddPeople :submit').click(function() {
var btn = this;
$(btn).hide();
@@ -50,7 +50,20 @@ public function Comments($Toggle = '', $TransientKey = '') {
}
$this->AddSideMenu('dashboard/embed/comments');
- $this->Permission('Garden.Settings.Manage');
+ $this->Form = new Gdn_Form();
+ $Validation = new Gdn_Validation();
+ $ConfigurationModel = new Gdn_ConfigurationModel($Validation);
+ $ConfigurationModel->SetField(array('Garden.Embed.CommentsPerPage', 'Garden.Embed.SortComments', 'Garden.Embed.PageToForum'));
+
+ $this->Form->SetModel($ConfigurationModel);
+ if ($this->Form->AuthenticatedPostBack() === FALSE) {
+ // Apply the config settings to the form.
+ $this->Form->SetData($ConfigurationModel->Data);
+ } else {
+ if ($this->Form->Save() !== FALSE)
+ $this->InformMessage(T("Your settings have been saved."));
+ }
+
$this->Title(T('Blog Comments'));
$this->Render();
}
@@ -2071,6 +2071,8 @@ span.Incorrect {
}
.MultipleEntryMethods .MainForm {
float: left;
+ /* Fix mainform from shoving the other entry methods down when an error occurs during login */
+ width: 300px;
}
.MultipleEntryMethods .Methods {
padding: 0 15px 5px;
@@ -2137,7 +2137,7 @@ public function Delete($UserID, $Options = array()) {
// Remove the user's information
$this->SQL->Update('User')
->Set(array(
- 'Name' => '[Deleted User]',
+ 'Name' => T('[Deleted User]'),
'Photo' => null,
'Password' => RandomString('10'),
'About' => '',
@@ -229,4 +229,12 @@ public function ToString($Type = 'more') {
else
return sprintf($this->Wrapper, Attribute(array('id' => $ClientID, 'class' => $this->CssClass)), $Pager);
}
+
+ /**
+ * Are there more pages after the current one?
+ */
+ public function HasMorePages() {
+ return $this->TotalRecords > $this->Offset + $this->Limit;
+ }
+
}
@@ -440,4 +440,11 @@ public static function Write($Options = array()) {
private function _GetCssClass($ThisPage, $HighlightPage) {
return $ThisPage == $HighlightPage ? 'Highlight' : FALSE;
}
+
+ /**
+ * Are there more pages after the current one?
+ */
+ public function HasMorePages() {
+ return $this->TotalRecords > $this->Offset + $this->Limit;
+ }
}
@@ -36,6 +36,7 @@
<ul>
<li<?php echo $this->EmbedType == 'wordpress' ? ' class="Active"' : ''; ?>><?php echo Anchor(T('WordPress Plugin'), 'embed/comments/wordpress'); ?></li>
<li<?php echo $this->EmbedType == 'universal' ? ' class="Active"' : ''; ?>><?php echo Anchor(T('Universal Code'), 'embed/comments/universal'); ?></li>
+ <li<?php echo $this->EmbedType == 'settings' ? ' class="Active"' : ''; ?>><?php echo Anchor(T('Comment Settings'), 'embed/comments/settings'); ?></li>
<li<?php echo $this->EmbedType == 'advanced' ? ' class="Active"' : ''; ?>><?php echo Anchor(T('Advanced Settings'), 'embed/advanced'); ?></li>
</ul>
</div>
@@ -50,7 +51,49 @@
<h2>Not Using WordPress?</h2>
<p>If you are not using WordPress, you can <?php echo Anchor('use the universal code', 'embed/comments/universal'); ?> for embedding Vanilla Comments.</p>
</div>
-<?php } else { ?>
+<?php } else if ($this->EmbedType == 'settings') { ?>
+ <style type="text/css">
+.WarningMessage {
+ padding: 8px 10px;
+ max-width: 500px;
+}
+ </style>
+ <h1><?php echo T('Comment Settings'); ?></h1>
+<?php
+echo $this->Form->Open();
+echo $this->Form->Errors();
+?>
+<ul>
+ <li>
+ <?php
+ $Options = array('10' => '10', '15' => '15', '20' => '20', '25' => '25', '30' => '30', '40' => '40', '50' => '50', '100' => '100');
+ $Fields = array('TextField' => 'Code', 'ValueField' => 'Code');
+ echo $this->Form->Label('Comments per Page', 'Garden.Embed.CommentsPerPage');
+ echo $this->Form->DropDown('Garden.Embed.CommentsPerPage', $Options, $Fields);
+ ?>
+ </li>
+ <li>
+ <?php
+ $Options = array('desc' => 'Most recent first / comment form at top of list', 'asc' => 'Most recent last / comment form at bottom of list');
+ $Fields = array('TextField' => 'Text', 'ValueField' => 'Code');
+ echo $this->Form->Label('Sort blog comments in the following order:', 'Garden.Embed.SortComments');
+ echo $this->Form->DropDown('Garden.Embed.SortComments', $Options, $Fields);
+ ?>
+ </li>
+ <li>
+ <p class="WarningMessage">
+ <?php
+ echo $this->Form->CheckBox('Garden.Embed.PageToForum', "Send users to forum after the first page of comments.");
+ ?>
+ <strong>Recommended:</strong> When there is more than one page of comments on a blog post, send users to the forum when they click to see another page of comments. This is a great way of driving users into your community.
+ </p>
+ </li>
+</ul>
+<?php
+echo $this->Form->Close('Save');
+
+} else {
+?>
<style type="text/css">
.CopyBox {
font-family: 'Inconsolata', Courier, monospace;
@@ -690,6 +690,10 @@ public function Embed($DiscussionID = '', $DiscussionStub = '', $Offset = '', $L
$Offset = GetIncomingValue('Offset', $Offset);
$Limit = GetIncomingValue('Limit', $Limit);
$vanilla_identifier = GetIncomingValue('vanilla_identifier', '');
+ // Only allow vanilla identifiers of 32 chars or less - md5 if larger
+ if (strlen($vanilla_identifier) > 32) {
+ $vanilla_identifier = md5($vanilla_identifier);
+ }
$vanilla_type = GetIncomingValue('vanilla_type', 'blog');
$vanilla_url = GetIncomingValue('vanilla_url', '');
$vanilla_category_id = GetIncomingValue('vanilla_category_id', '');
@@ -718,7 +722,7 @@ public function Embed($DiscussionID = '', $DiscussionStub = '', $Offset = '', $L
$ActualResponses = $this->Discussion->CountComments - 1;
// Define the query offset & limit
if (!is_numeric($Limit) || $Limit < 0)
- $Limit = C('Vanilla.Comments.PerPage', 30);
+ $Limit = C('Garden.Embed.CommentsPerPage', 30);
$OffsetProvided = $Offset != '';
list($Offset, $Limit) = OffsetLimit($Offset, $Limit);
@@ -739,9 +743,11 @@ public function Embed($DiscussionID = '', $DiscussionStub = '', $Offset = '', $L
$this->CanonicalUrl(DiscussionUrl($Discussion, PageNumber($this->Offset, $Limit)));
// Load the comments
+ $SortComments = C('Garden.Embed.SortComments') == 'desc' ? 'desc' : 'asc';
+ $this->SetData('SortComments', $SortComments);
$CurrentOrderBy = $this->CommentModel->OrderBy();
if (StringBeginsWith(GetValueR('0.0', $CurrentOrderBy), 'c.DateInserted'))
- $this->CommentModel->OrderBy('c.DateInserted desc'); // allow custom sort
+ $this->CommentModel->OrderBy('c.DateInserted '.$SortComments); // allow custom sort
$this->SetData('CommentData', $this->CommentModel->Get($this->Discussion->DiscussionID, $Limit, $this->Offset), TRUE);
@@ -796,7 +802,7 @@ public function Embed($DiscussionID = '', $DiscussionStub = '', $Offset = '', $L
$this->Form->SetFormValue('Body', $Draft->Body);
else {
// Look in the session stash for a comment
- $StashComment = $Session->Stash('CommentForForeignID_'.$ForeignSource['vanilla_identifier'], '', FALSE);
+ $StashComment = $Session->Stash('CommentForForeignID_'.$ForeignSource['vanilla_identifier'], '', FALSE);
if ($StashComment)
$this->Form->SetFormValue('Body', $StashComment);
}
@@ -810,7 +816,9 @@ public function Embed($DiscussionID = '', $DiscussionStub = '', $Offset = '', $L
$this->View = 'comments';
}
- $this->AddDefinition('PrependNewComments', '1');
+ if ($SortComments == 'desc')
+ $this->AddDefinition('PrependNewComments', '1');
+
// Report the discussion id so js can use it.
if ($Discussion)
$this->AddDefinition('DiscussionID', $Discussion->DiscussionID);
@@ -298,10 +298,16 @@ public function Comment($DiscussionID = '') {
$this->Discussion = $Discussion = $this->DiscussionModel->GetID($DiscussionID);
// Is this an embedded comment being posted to a discussion that doesn't exist yet?
- $vanilla_identifier = $this->Form->GetFormValue('vanilla_identifier', '');
$vanilla_type = $this->Form->GetFormValue('vanilla_type', '');
$vanilla_url = $this->Form->GetFormValue('vanilla_url', '');
$vanilla_category_id = $this->Form->GetFormValue('vanilla_category_id', '');
+ $Attributes = array('ForeignUrl' => $vanilla_url);
+ $vanilla_identifier = $this->Form->GetFormValue('vanilla_identifier', '');
+ // Only allow vanilla identifiers of 32 chars or less - md5 if larger
+ if (strlen($vanilla_identifier) > 32) {
+ $Attributes['vanilla_identifier'] = $vanilla_identifier;
+ $vanilla_identifier = md5($vanilla_identifier);
+ }
if (!$Discussion && $vanilla_url != '' && $vanilla_identifier != '') {
$Discussion = $this->DiscussionModel->GetWhere(array(
@@ -371,7 +377,7 @@ public function Comment($DiscussionID = '') {
'Name' => $Title,
'Body' => $Body,
'Format' => 'Html',
- 'Attributes' => serialize(array('ForeignUrl' => $vanilla_url))
+ 'Attributes' => serialize($Attributes)
);
$this->EventArguments['Discussion'] = $EmbeddedDiscussionData;
$this->FireEvent('BeforeEmbedDiscussion');
@@ -672,7 +672,10 @@ public function Save2($CommentID, $Insert, $CheckExisting = TRUE, $IncUser = FAL
$Fields = $this->GetID($CommentID, DATASET_TYPE_ARRAY);
// Clear any session stashes related to this discussion
- $Session->Stash('CommentForDiscussionID_'.GetValue('DiscussionID', $Fields));
+ $DiscussionModel = new DiscussionModel();
+ $DiscussionID = GetValue('DiscussionID', $Fields);
+ $Discussion = $DiscussionModel->GetID($DiscussionID);
+ $Session->Stash('CommentForForeignID_'.GetValue('ForeignID', $Discussion));
// Make a quick check so that only the user making the comment can make the notification.
// This check may be used in the future so should not be depended on later in the method.
@@ -686,10 +689,6 @@ public function Save2($CommentID, $Insert, $CheckExisting = TRUE, $IncUser = FAL
$this->UpdateUser($Session->UserID, $IncUser && $Insert);
if ($Insert) {
- $DiscussionModel = new DiscussionModel();
- $DiscussionID = GetValue('DiscussionID', $Fields);
- $Discussion = $DiscussionModel->GetID($DiscussionID);
-
// UPDATE COUNT AND LAST COMMENT ON CATEGORY TABLE
if ($Discussion->CategoryID > 0) {
$CountComments = $this->SQL
@@ -614,6 +614,7 @@ public function GetCount($Wheres = '', $ForceNoAnnouncements = FALSE) {
* @return object SQL result.
*/
public function GetForeignID($ForeignID, $Type = '') {
+ $Hash = strlen($ForeignID) > 32 ? md5($ForeignID) : $ForeignID;
$Session = Gdn::Session();
$this->FireEvent('BeforeGetForeignID');
$this->SQL
@@ -634,7 +635,7 @@ public function GetForeignID($ForeignID, $Type = '') {
->Join('User iu', 'd.InsertUserID = iu.UserID', 'left') // Insert user
->Join('Comment lc', 'd.LastCommentID = lc.CommentID', 'left') // Last comment
->Join('User lcu', 'lc.InsertUserID = lcu.UserID', 'left') // Last comment user
- ->Where('d.ForeignID', $ForeignID);
+ ->Where('d.ForeignID', $Hash);
if ($Type != '')
$this->SQL->Where('d.Type', $Type);
@@ -1,6 +1,7 @@
<?php if (!defined('APPLICATION')) exit();
-$Discussion = property_exists($this, 'Discussion') ? $this->Discussion : FALSE;
+$Discussion = $this->Data('Discussion');
$ForeignSource = $this->Data('ForeignSource');
+$SortComments = $this->Data('SortComments');
$HasCommentData = property_exists($this, 'CommentData');
$Session = Gdn::Session();
if (!function_exists('WriteComment'))
@@ -12,59 +13,13 @@
echo '<span class="BeforeCommentHeading">';
$this->FireEvent('CommentHeading');
echo '</span>';
-?>
-
-<?php 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 $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";
-
- $AllowSigninPopup = C('Garden.SignIn.Popup');
- $Attributes = array('tabindex' => '-1');
-// Don't force to top!
-// if (!$AllowSigninPopup)
-// $Attributes['target'] = '_parent';
-
- $ReturnUrl = Gdn::Request()->PathAndQuery();
- if ($Session->IsValid()) {
$AuthenticationUrl = SignOutUrl($ReturnUrl);
-
- echo Wrap(
- sprintf(
- T('Commenting as %1$s (%2$s)'),
- Gdn_Format::Text($Session->User->Name),
- Anchor(T('Sign Out'), $AuthenticationUrl, 'SignOut', $Attributes)
- ),
- 'div',
- array('class' => 'Author')
- );
- echo $this->Form->Button('Post Comment', array('class' => 'Button CommentButton'));
- } else {
- // Must use the "top" url in case the user needs to register, which goes to top.
- // Javascript will ensure that the target is set properly if they use any in-page popup forms.
- $AuthenticationUrl = SignInUrl(GetValue('vanilla_url', $ForeignSource, $ReturnUrl));
-
- if ($AllowSigninPopup) {
- $CssClass = 'SignInPopup Button Stash';
- } else {
- $CssClass = 'Button Stash';
- }
-
- echo Anchor(T('Comment As ...'), $AuthenticationUrl, $CssClass, $Attributes);
- }
- echo "</div>\n";
- echo $this->Form->Close();
- ?>
- </div>
-<?php } ?>
+
+if ($SortComments == 'desc')
+ WriteEmbedCommentForm();
+else if ($HasCommentData && $this->CommentData->NumRows() > 0)
+ echo Wrap(T('Comments'), 'h2');
+?>
<ul class="DataList MessageList Comments">
<?php
if ($HasCommentData) {
@@ -87,7 +42,19 @@
$this->AddDefinition('LastCommentID', (int)$this->Data['Discussion']->LastCommentID);
$this->AddDefinition('Vanilla_Comments_AutoRefresh', Gdn::Config('Vanilla.Comments.AutoRefresh', 0));
}
- echo $this->Pager->ToString('more');
+
+ // Send the user to the discussion in the forum when paging
+ if (C('Garden.Embed.PageToForum') && $this->Pager->HasMorePages()) {
+ $DiscussionUrl = DiscussionUrl($Discussion).'#latest';
+ echo '<div class="PageToForum Foot">';
+ echo Anchor(T('More Comments'), $DiscussionUrl);
+ echo '</div>';
+ } else
+ echo $this->Pager->ToString('more');
}
+
+if ($SortComments != 'desc')
+ WriteEmbedCommentForm();
+
?>
</div>
Oops, something went wrong.

0 comments on commit 11503c9

Please sign in to comment.