1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47:
48: class ArticleCommentView extends AlphaView {
49: 50: 51: 52: 53:
54: public function markdownView() {
55: global $config;
56:
57: $markdown = new MarkdownFacade($this->BO);
58: $author = new PersonObject();
59: $id = $this->BO->getCreatorID();
60: $author->load($id->getValue());
61:
62: echo '<blockquote class="usercomment">';
63:
64: $createTS = $this->BO->getCreateTS();
65: $updateTS = $this->BO->getUpdateTS();
66:
67: 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().'.';
68: echo ' '.$author->get('displayname').' has posted ['.$author->getCommentCount().'] comments on articles since joining.';
69: echo '</p>';
70: if($config->get('cms.comments.allowed') && isset($_SESSION['currentUser']) && $_SESSION['currentUser']->getID() == $author->getID())
71: $this->editView();
72: else
73: echo $markdown->getContent();
74:
75: if($createTS->getValue() != $updateTS->getValue()) {
76: $updator = new PersonObject();
77: $id = $this->BO->getCreatorID();
78: $updator->load($id->getValue());
79: 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>';
80: }
81: echo '</blockquote>';
82: }
83:
84: 85: 86: 87: 88: 89:
90: public function createView($fields=array()) {
91: echo '<h2>Post a new comment:</h2>';
92:
93: echo '<table cols="2" class="create_view">';
94: echo '<form action="'.$_SERVER['REQUEST_URI'].'" method="POST">';
95:
96: $textBox = new TextBox($this->BO->getPropObject('content'), $this->BO->getDataLabel('content'), 'content', '', 10);
97: echo $textBox->render();
98:
99: echo '<input type="hidden" name="articleOID" value="'.$this->BO->get('articleOID').'"/>';
100: echo '<tr><td colspan="2">';
101:
102: $button = new Button('submit', 'Post Comment', 'createBut');
103: echo $button->render();
104:
105: echo '</td></tr>';
106:
107: echo AlphaView::renderSecurityFields();
108:
109: echo '</form></table>';
110: echo '<p class="warning">Please note that any comment you post may be moderated for spam or offensive material.</p>';
111: }
112:
113: 114: 115: 116: 117: 118:
119: public function editView($fields=array()) {
120: global $config;
121:
122: echo '<table cols="2" class="edit_view" style="width:100%; margin:0px">';
123: echo '<form action="'.$_SERVER['REQUEST_URI'].'" method="POST">';
124:
125: $textBox = new TextBox($this->BO->getPropObject('content'), $this->BO->getDataLabel('content'), 'content', '', 5, $this->BO->getID());
126: echo $textBox->render();
127:
128: echo '<input type="hidden" name="version_num" value="'.$this->BO->getVersion().'"/>';
129: echo '<input type="hidden" name="article_comment_id" value="'.$this->BO->getID().'"/>';
130:
131:
132: if ($_SESSION['currentUser']->inGroup('Admin') && strpos($_SERVER['REQUEST_URI'], '/tk/') !== false) {
133: echo '<tr><td colspan="2">';
134:
135: $temp = new Button('submit', 'Save', 'saveBut');
136: echo $temp->render();
137: echo ' ';
138: $js = "$('#dialogDiv').text('Are you sure you wish to delete this item?');
139: $('#dialogDiv').dialog({
140: buttons: {
141: 'OK': function(event, ui) {
142: $('#deleteOID').attr('value', '".$this->BO->getOID()."');
143: $('#deleteForm').submit();
144: },
145: 'Cancel': function(event, ui) {
146: $(this).dialog('close');
147: }
148: }
149: })
150: $('#dialogDiv').dialog('open');
151: return false;";
152: $temp = new Button($js, "Delete", "deleteBut");
153: echo $temp->render();
154: echo ' ';
155: $temp = new Button("document.location = '".FrontController::generateSecureURL('act=ListAll&bo='.get_class($this->BO))."'",'Back to List','cancelBut');
156: echo $temp->render();
157: echo '</td></tr>';
158:
159: echo AlphaView::renderSecurityFields();
160:
161: echo '</form></table>';
162: }else{
163: echo '</table>';
164:
165: echo '<div align="center">';
166: $temp = new Button('submit', 'Update Your Comment', 'saveBut'.$this->BO->getID());
167: echo $temp->render();
168: echo '</div>';
169:
170: echo AlphaView::renderSecurityFields();
171:
172: echo '</form>';
173: }
174: }
175: }
176:
177: ?>