-
Notifications
You must be signed in to change notification settings - Fork 9
Add comment sorting configuration #122
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
/*========================================================================= | ||
Midas Server | ||
Copyright Kitware SAS, 26 rue Louis Guérin, 69100 Villeurbanne, France. | ||
All rights reserved. | ||
For more information visit http://www.kitware.com/. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0.txt | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
=========================================================================*/ | ||
|
||
|
||
define("OLDEST_FIRST",0); | ||
define("NEWEST_FIRST",1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. define('COMMENTS_OLDEST_FIRST', 0);
define('COMMENTS_NEWEST_FIRST', 1); Propagate change throughout. |
||
|
||
?> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete closing tag and extra newline. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should actually be called |
||
/*========================================================================= | ||
Midas Server | ||
Copyright Kitware SAS, 26 rue Louis Guérin, 69100 Villeurbanne, France. | ||
All rights reserved. | ||
For more information visit http://www.kitware.com/. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0.txt | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
=========================================================================*/ | ||
|
||
/** | ||
* Config controller for the comments module. | ||
*/ | ||
class Comments_ConfigController extends Comments_AppController | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. /** Admin controller ... */`
class Comments_AdminController extends Comments_AppController |
||
{ | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete newlines. |
||
public $_models = array('Setting','User'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the user model being used? |
||
|
||
public function indexAction() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
{ | ||
$this->requireAdminPrivileges(); | ||
if($this->_request->isPost()) | ||
{ | ||
$this->view->commentOrder = $_POST['commentOrder']; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use Zend_Controller_Request_Http::getPost |
||
MidasLoader::loadModel("Setting")->setConfig('commentOrder',$this->view->commentOrder,"comments"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}; | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete one newline. |
||
session_start(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,8 +28,20 @@ class Comments_ItemcommentModel extends Comments_ItemcommentModelBase | |
*/ | ||
public function getComments($item, $limit = 10, $offset = 0) | ||
{ | ||
/* | ||
* Change the order of the retrieval based upon the user setting. This changes the display | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One space between sentences. |
||
* order of the comments | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete newlines. |
||
* 'ASC' shows the oldest comment first, 'DESC' shows the newest first | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
*/ | ||
if( MidasLoader::loadModel("Setting")->getValueByName("commentOrder","comments") == OLDEST_FIRST) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This would be a global setting for all users. Is that what you meant? |
||
$commentSort = "ASC"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
else { | ||
$commentSort = "DESC"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
$sql = $this->database->select()->where('item_id = ?', $item->getKey())->limit($limit, $offset)->order( | ||
'date ASC' | ||
'date ' . $commentSort | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'date'.$commentSort |
||
); | ||
|
||
$rowset = $this->database->fetchAll($sql); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
/*========================================================================= | ||
Midas Server | ||
Copyright Kitware SAS, 26 rue Louis Guérin, 69100 Villeurbanne, France. | ||
All rights reserved. | ||
For more information visit http://www.kitware.com/. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0.txt | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
=========================================================================*/ | ||
|
||
$this->declareVars('form', 'pageTitle'); | ||
$this->headTitle($this->escape($this->pageTitle)); | ||
?> | ||
|
||
<div class="viewMain"> | ||
<h1><?php ?></h1> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix or delete. |
||
<div> | ||
<form class='genericform' id='configForm' method='POST' action=''> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
<h3> Comment Module Configuration </h3> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
<p>Currently sorting comments by <b><?php if( MidasLoader::loadModel("Setting")->getValueByName("commentOrder","comments") ==0) { echo "OLDEST";} else { echo "NEWEST";};?></b> first.</p> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Put logic in the controller. Also |
||
<label for"'commentOrder'>Order comments by</label> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete. Use |
||
<select name='commentOrder'> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete. Use |
||
<option value="<?php echo OLDEST_FIRST ?>">Oldest First</option> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete. Use |
||
<option value="<?php echo NEWEST_FIRST ?>">Newest First</option> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete. Use |
||
</form> | ||
</div> | ||
<div> | ||
<input type='submit' value='Save Configuration'/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete. Use |
||
</div> | ||
</div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indents should be multiples of four. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete one newline.