Source for file ArticleCommentView.inc
Documentation is available at ArticleCommentView.inc
require_once $config->get('sysRoot'). 'alpha/model/ArticleCommentObject.inc';
require_once $config->get('sysRoot'). 'alpha/model/PersonObject.inc';
require_once $config->get('sysRoot'). 'alpha/view/AlphaView.inc';
require_once $config->get('sysRoot'). 'alpha/util/MarkdownFacade.inc';
* The rendering class for the ArticleCommentObject class
* @author John Collins <dev@alphaframework.org>
* @version $Id: ArticleCommentView.inc 1341 2011-03-17 15:02:02Z johnc $
* @license http://www.opensource.org/licenses/bsd-license.php The BSD License
* @copyright Copyright (c) 2011, John Collins (founder of Alpha Framework).
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the
* following conditions are met:
* * Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other
* materials provided with the distribution.
* * Neither the name of the Alpha Framework nor the names
* of its contributors may be used to endorse or promote
* products derived from this software without specific
* prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* Method to generate the markdown HTML render of the ArticleComment content
$id = $this->BO->getCreatorID();
$author->load($id->getValue());
echo '<blockquote class="usercomment">';
$createTS = $this->BO->getCreateTS();
$updateTS = $this->BO->getUpdateTS();
echo '<p>Posted by '. ($author->get('URL') == ''? $author->get('displayname') : '<a href="'. $author->get('URL'). '" target="new window">'. $author->get('displayname'). '</a>'). ' at '. $createTS->getValue(). '.';
echo ' '. $author->get('displayname'). ' has posted ['. $author->getCommentCount(). '] comments on articles since joining.';
if($config->get('sysCMSCommentsAllowed') && isset ($_SESSION['currentUser']) && $_SESSION['currentUser']->getID() == $author->getID())
echo $markdown->getContent();
if($createTS->getValue() != $updateTS->getValue()) {
$id = $this->BO->getCreatorID();
$updator->load($id->getValue());
echo '<p>Updated by '. ($updator->get('URL') == ''? $updator->get('displayname') : '<a href="'. $updator->get('URL'). '" target="new window">'. $updator->get('displayname'). '</a>'). ' at '. $updateTS->getValue(). '.</p>';
* Renders the custom create view
* @param array $fields hash array of HTML fields to pass to the template
echo '<h2>Post a new comment:</h2>';
echo '<table cols="2" class="create_view">';
echo '<form action="'. $_SERVER['REQUEST_URI']. '" method="POST">';
$textBox = new textBox($this->BO->getPropObject('content'), $this->BO->getDataLabel('content'), 'content', '', 10);
echo '<input type="hidden" name="articleOID" value="'. $this->BO->get('articleOID'). '"/>';
echo '<tr><td colspan="2">';
$button = new button('submit', 'Post Comment', 'createBut');
echo '<p class="warning">Please note that any comment you post may be moderated for spam or offensive material.</p>';
* @param array $fields Hash array of HTML fields to pass to the template.
public function editView($fields= array()) {
echo '<table cols="2" class="edit_view" style="width:100%; margin:0px">';
echo '<form action="'. $_SERVER['REQUEST_URI']. '" method="POST">';
$textBox = new TextBox($this->BO->getPropObject('content'), $this->BO->getDataLabel('content'), 'content', '', 5, $this->BO->getID());
echo '<input type="hidden" name="version_num" value="'. $this->BO->getVersion(). '"/>';
echo '<input type="hidden" name="article_comment_id" value="'. $this->BO->getID(). '"/>';
// render special buttons for admins only
if ($_SESSION['currentUser']->inGroup('Admin') && strpos($_SERVER['REQUEST_URI'], '/tk/') !== false) {
echo '<tr><td colspan="2">';
$temp = new button('submit', 'Save', 'saveBut');
$js = "$('#dialogDiv').text('Are you sure you wish to delete this item?');
'OK': function(event, ui) {
$('#deleteOID').attr('value', '". $this->BO->getOID(). "');
$('#deleteForm').submit();
'Cancel': function(event, ui) {
$('#dialogDiv').dialog('open');
$temp = new Button($js, "Delete", "deleteBut");
echo '<div align="center">';
$temp = new button('submit', 'Update Your Comment', 'saveBut');
|