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: $fieldname = ($config->get('security.encrypt.http.fieldnames') ? base64_encode(AlphaSecurityUtils::encrypt('version_num')) : 'version_num');
129: echo '<input type="hidden" name="'.$fieldname.'" value="'.$this->BO->getVersion().'"/>';
130: $fieldname = ($config->get('security.encrypt.http.fieldnames') ? base64_encode(AlphaSecurityUtils::encrypt('article_comment_id')) : 'article_comment_id');
131: echo '<input type="hidden" name="'.$fieldname.'" value="'.$this->BO->getID().'"/>';
132:
133:
134: if ($_SESSION['currentUser']->inGroup('Admin') && strpos($_SERVER['REQUEST_URI'], '/tk/') !== false) {
135: echo '<tr><td colspan="2">';
136:
137: $fieldname = ($config->get('security.encrypt.http.fieldnames') ? base64_encode(AlphaSecurityUtils::encrypt('saveBut')) : 'saveBut');
138: $temp = new Button('submit', 'Save', $fieldname);
139: echo $temp->render();
140: echo ' ';
141: $js = "$('#dialogDiv').text('Are you sure you wish to delete this item?');
142: $('#dialogDiv').dialog({
143: buttons: {
144: 'OK': function(event, ui) {
145: $('[id=\"".($config->get('security.encrypt.http.fieldnames') ? base64_encode(AlphaSecurityUtils::encrypt('deleteOID')) : 'deleteOID')."\"]').attr('value', '".$this->BO->getOID()."');
146: $('#deleteForm').submit();
147: },
148: 'Cancel': function(event, ui) {
149: $(this).dialog('close');
150: }
151: }
152: })
153: $('#dialogDiv').dialog('open');
154: return false;";
155: $temp = new Button($js, "Delete", "deleteBut");
156: echo $temp->render();
157: echo ' ';
158: $temp = new Button("document.location = '".FrontController::generateSecureURL('act=ListAll&bo='.get_class($this->BO))."'",'Back to List','cancelBut');
159: echo $temp->render();
160: echo '</td></tr>';
161:
162: echo AlphaView::renderSecurityFields();
163:
164: echo '</form></table>';
165: }else{
166: echo '</table>';
167:
168: echo '<div align="center">';
169: $temp = new Button('submit', 'Update Your Comment', 'saveBut'.$this->BO->getID());
170: echo $temp->render();
171: echo '</div>';
172:
173: echo AlphaView::renderSecurityFields();
174:
175: echo '</form>';
176: }
177: }
178: }
179:
180: ?>