All Data Structures Functions Variables Pages
ConversationDetailsView.php
1 <?php
2  /*********************************************************************************
3  * Zurmo is a customer relationship management program developed by
4  * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc.
5  *
6  * Zurmo is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  *
13  * Zurmo is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  *
23  * You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive
24  * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.
25  *
26  * The interactive user interfaces in original and modified versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  *
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the Zurmo
32  * logo and Zurmo copyright notice. If the display of the logo is not reasonably
33  * feasible for technical reasons, the Appropriate Legal Notices must display the words
34  * "Copyright Zurmo Inc. 2017. All rights reserved".
35  ********************************************************************************/
36 
38  {
39  public static function getDefaultMetadata()
40  {
41  $metadata = array(
42  'global' => array(
43  'toolbar' => array(
44  'elements' => array(
45  array('type' => 'EditLink'),
46  array('type' => 'ConversationDeleteLink'),
47  ),
48  ),
49  ),
50  );
51  return $metadata;
52  }
53 
54  protected function renderContent()
55  {
56  $content = '<div class="details-table">';
57  $content .= $this->renderTitleContent();
58  $content .= $this->resolveAndRenderActionElementMenu();
59  $leftContent = $this->renderBeforeFormLayoutForDetailsContent();
60  $leftContent .= $this->renderFormLayout();
61  $content .= ZurmoHtml::tag('div', array('class' => 'left-column'), $leftContent);
62  $content .= $this->renderRightSideContent();
63  $content .= $this->renderAfterFormLayoutForDetailsContent();
64  $content .= '</div>';
65  return $content;
66  }
67 
68  protected function renderTitleContent()
69  {
70  $starLink = StarredUtil::getToggleStarStatusLink($this->model, null);
71  $content = StringUtil::renderFluidContent($this->getTitle());
72  $content .= $starLink;
73  return ZurmoHtml::tag('h1', array(), $content);
74  }
75 
76  protected function renderFormLayout($form = null)
77  {
78  $content = $this->renderConversationContent();
79  $content .= $this->renderConversationCommentsContent();
80  $content .= $this->renderConversationCreateCommentContent();
81  $content = ZurmoHtml::tag('div', array('class' => 'left-column'), $content);
82  return $content;
83  }
84 
85  public function getTitle()
86  {
87  return strval($this->model);
88  }
89 
90  protected function renderRightSideContent($form = null)
91  {
92  assert('$form == null');
93  $content = null;
94  $content .= $this->renderConversationOpenCloseElement();
95  $content .= $this->renderConversationRelatedToAndAttachmentsContent();
96  $content .= "<h3>".Zurmo::t('ConversationsModule', 'Participants') . '</h3>';
97  $content .= $this->renderConversationParticipantsContent();
98  $content = ZurmoHtml::tag('div', array('class' => 'right-side-edit-view-panel thread-info'), $content);
99  $content = ZurmoHtml::tag('div', array('class' => 'right-column'), $content);
100  return $content;
101  }
102 
103  protected function renderConversationOpenCloseElement()
104  {
105  $element = new ConversationOpenCloseElement($this->model, 'isClosed');
106  $content = $element->render();
107  return $content;
108  }
109 
110  protected function renderConversationParticipantsContent()
111  {
112  $clipWidget = new ClipWidget();
113  list($form, $formStart) = $clipWidget->renderBeginWidget(
114  'ZurmoActiveForm',
115  array_merge(
116  array('id' => 'participants-edit-form')
117  )
118  );
119  $params = array('formName' => 'participants-edit-form');
120  $content = $formStart;
121  $element = new OnChangeProcessMultiplePeopleForConversationElement($this->model, null, $form, $params);
122  $element->editableTemplate = '{content}{error}';
123  $content .= $element->render();
124  $formEnd = $clipWidget->renderEndWidget();
125  $content .= $formEnd;
126  return $content;
127  }
128 
129  protected function renderConversationRelatedToAndAttachmentsContent()
130  {
131  $element = new ConversationItemsElement($this->model, 'null');
132  $element->nonEditableTemplate = '<td colspan="{colspan}">{content}</td>';
133  $contentForTable = $element->render();
134  if ($this->model->files->count() > 0)
135  {
136  $element = new FilesElement($this->model, 'null');
137  $element->nonEditableTemplate = '<td colspan="{colspan}" class="conversation-related-Attachments">{content}</td>';
138  $contentForTable .= $element->render();
139  }
140  $content = ZurmoHtml::tag('table', array('class' => 'thread-details'), $contentForTable);
141  return $content;
142  }
143 
144  protected function renderConversationContent()
145  {
146  $userUrl = Yii::app()->createUrl('/users/default/details', array('id' => $this->model->createdByUser->id));
147  $content = '<div class="comment model-details-summary clearfix">';
148  $content .= ZurmoHtml::link($this->model->createdByUser->getAvatarImage(100), $userUrl);
149  $content .= '<span class="user-details">';
150  $content .= ZurmoHtml::link(strval($this->model->createdByUser), $userUrl, array('class' => 'user-link'));
151  $content .= '</span>';
152 
153  if ($this->model->description == null)
154  {
155  $element = new TextElement($this->model, 'subject');
156  }
157  else
158  {
159  $element = new ConversationLinkableTextAreaElement($this->model, 'description');
160  }
161  $element->nonEditableTemplate = '<div class="comment-content">{content}</div>';
162  $content .= $element->render();
163 
164  $date = '<span class="comment-details"><strong>'. DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay(
165  $this->model->createdDateTime, 'long', null) . '</strong></span>';
166  $content .= $date;
167  $content .= '</div>';
168  return ZurmoHtml::tag('div', array('id' => 'ModelDetailsSummaryView'), $content);
169  }
170 
171  protected function renderConversationCommentsContent()
172  {
173  $getParams = array('relatedModelId' => $this->model->id,
174  'relatedModelClassName' => get_class($this->model),
175  'relatedModelRelationName' => 'comments');
176  $pageSize = 5;
177  $commentsData = Comment::getCommentsByRelatedModelTypeIdAndPageSize(get_class($this->model),
178  $this->modelId, ($pageSize + 1));
179  $view = new CommentsForRelatedModelView('default', 'comments', $commentsData, $this->model, $pageSize, $getParams);
180  $content = $view->render();
181  $wrappingCssClass = $this->getCommentsWrappingCssClass();
182  $content = ZurmoHtml::tag('div', array('class' => $wrappingCssClass), $content);
183  return $content;
184  }
185 
186  protected function renderConversationCreateCommentContent()
187  {
188  $content = ZurmoHtml::tag('h2', array(), Zurmo::t('CommentsModule', 'Add Comment'));
189  $comment = new Comment();
190  $uniquePageId = 'CommentInlineEditForModelView';
191  $redirectUrl = Yii::app()->createUrl('/conversations/default/inlineCreateCommentFromAjax',
192  array('id' => $this->model->id,
193  'uniquePageId' => $uniquePageId));
194  $urlParameters = array('relatedModelId' => $this->model->id,
195  'relatedModelClassName' => 'Conversation',
196  'relatedModelRelationName' => 'comments',
197  'redirectUrl' => $redirectUrl); //After save, the url to go to.
198 
199  $inlineView = new CommentInlineEditView($comment, 'default', 'comments', 'inlineCreateSave',
200  $urlParameters, $uniquePageId);
201  $content .= $inlineView->render();
202  $htmlOptions = array('id' => 'CommentInlineEditForModelView');
203  if ($this->model->isClosed)
204  {
205  $htmlOptions['style'] = 'display: none;';
206  }
207  return ZurmoHtml::tag('div', $htmlOptions, $content);
208  }
209 
210  protected function getPortletDetailsUrl()
211  {
212  return Yii::app()->createUrl('/conversations/default/inlineCreateComment');
213  }
214 
220  {
221  }
222 
223  protected function getCommentsWrappingCssClass()
224  {
225  return 'comments-activity';
226  }
227  }
228 ?>
static getCommentsByRelatedModelTypeIdAndPageSize($type, $relatedId, $pageSize)
Definition: Comment.php:76
Generated on Tue Jun 2 2020 07:10:30