All Data Structures Functions Variables Pages
MergeTagGuideView.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 
37  class MergeTagGuideView extends View
38  {
39  protected function renderContent()
40  {
41  // TODO: @shoaibi: Critical: Use MergeTagsUtil::resolve resolveAttributeStringToMergeTagString
42  $syntaxContent = $this->renderSyntaxContent();
43  $examplesContent = $this->renderExamplesContent();
44  $specialTagsContent = $this->renderSpecialTagsContent();
45  $content = Zurmo::t('EmailTemplatesModule', 'Merge tags are a quick way to introduce ' .
46  'reader-specific dynamic information into emails.');
47  $content .= $syntaxContent;
48  $content .= $examplesContent;
49  $content .= $specialTagsContent;
50  $content = ZurmoHtml::tag('div', array('id' => 'mergetag-guide-modal-content',
51  'class' => 'mergetag-guide-modal'),
52  $content);
53  return $content;
54  }
55 
56  protected function renderSyntaxContent()
57  {
58  $content = ZurmoHtml::tag('h4', array(), 'Syntax');
59  $content = ZurmoHtml::tag('div', array('id' => 'mergetag-syntax-head'), $content);
60  $syntaxContent = null;
61  $syntaxItems = array();
62  $syntaxItems[] = Zurmo::t('EmailTemplatesModule', 'A merge tag starts with: {tagPrefix} and ends with {tagSuffix}.',
63  array('{tagPrefix}' => MergeTagsUtil::TAG_PREFIX, '{tagSuffix}' => MergeTagsUtil::TAG_SUFFIX));
64  $syntaxItems[] = Zurmo::t('EmailTemplatesModule', 'Between starting and closing tags it can have field ' .
65  'names. These names are written in all caps regardless of actual field name case.');
66  $syntaxItems[] = Zurmo::t('EmailTemplatesModule', 'Fields that contain more than one word are named ' .
67  'using camel case in the system and to address that in merge tags, use the prefix ' .
68  '{capitalDelimiter} before the letter that should be capitalize when converted.',
69  array('{capitalDelimiter}' => MergeTagsUtil::CAPITAL_DELIMITER));
70  $syntaxItems[] = Zurmo::t('EmailTemplatesModule', 'To access a related field, use the following prefix: {propertyDelimiter}',
71  array('{propertyDelimiter}' => MergeTagsUtil::PROPERTY_DELIMITER));
72  $syntaxItems[] = Zurmo::t('EmailTemplatesModule', 'To access a previous value of a field (only supported ' .
73  'in workflow type templates) prefix the field name with: {wasTag}. ' .
74  'If there is no previous value, the current value will be used. If the attached ' .
75  'module does not support storing previous values an error will be thrown ' .
76  'when saving the template.', array('{wasTag}' => 'WAS' . MergeTagsUtil::TIME_DELIMITER));
77  foreach ($syntaxItems as $syntaxItem)
78  {
79  $syntaxContent .= ZurmoHtml::tag('li', array(), $syntaxItem);
80  }
81  $syntaxContent = ZurmoHtml::tag('ul', array(), $syntaxContent);
82  $syntaxContent = ZurmoHtml::tag('div', array('id' => 'mergetag-syntax-body'), $syntaxContent);
83  $content .= $syntaxContent;
84  $content = ZurmoHtml::tag('div', array('id' => 'mergetag-syntax'), $content);
85  return $content;
86  }
87 
88  protected function renderExamplesContent()
89  {
90  $content = ZurmoHtml::tag('h4', array(), 'Examples');
91  $content = ZurmoHtml::tag('div', array('id' => 'mergetag-examples-head'), $content);
92  $examplesContent = null;
93  $exampleItems = array();
94  $exampleItems[] = "Adding a contact's First Name (firstName): " .
95  $this->renderBoldMergeTag(MergeTagsUtil::TAG_PREFIX . "FIRST". MergeTagsUtil::CAPITAL_DELIMITER .
96  "NAME" . MergeTagsUtil::TAG_SUFFIX);
97  $exampleItems[] = "Adding a contact's city (primaryAddress->city): " .
98  $this->renderBoldMergeTag(MergeTagsUtil::TAG_PREFIX .
99  "PRIMARY" . MergeTagsUtil::CAPITAL_DELIMITER . "ADDRESS" .
100  MergeTagsUtil::PROPERTY_DELIMITER . "CITY" . MergeTagsUtil::TAG_SUFFIX);
101  $exampleItems[] = "Adding a user's previous primary email address: " .
102  $this->renderBoldMergeTag(MergeTagsUtil::TAG_PREFIX . "WAS" . MergeTagsUtil::TIME_DELIMITER . "PRIMARY" .
103  MergeTagsUtil::CAPITAL_DELIMITER . "EMAIL" . MergeTagsUtil::PROPERTY_DELIMITER .
104  "EMAIL" . MergeTagsUtil::CAPITAL_DELIMITER . "ADDRESS" . MergeTagsUtil::TAG_SUFFIX);
105  foreach ($exampleItems as $exampleItem)
106  {
107  $examplesContent .= ZurmoHtml::tag('li', array(), $exampleItem);
108  }
109  $examplesContent = ZurmoHtml::tag('ul', array(), $examplesContent);
110  $examplesContent = ZurmoHtml::tag('div', array('id' => 'mergetag-examples-body'), $examplesContent);
111  $content .= $examplesContent;
112  $content = ZurmoHtml::tag('div', array('id' => 'mergetag-examples'), $content);
113  return $content;
114  }
115 
116  protected function renderSpecialTagsContent()
117  {
118  $content = ZurmoHtml::tag('h4', array(), 'Special Tags');
119  $content = ZurmoHtml::tag('div', array('id' => 'mergetag-special-tags-head'), $content);
120  $specialTagsContent = null;
121  $specialTagsItems = array();
122  $specialTagsItems[] = $this->renderBoldMergeTag(MergeTagsUtil::TAG_PREFIX . "MODEL" .
123  MergeTagsUtil::CAPITAL_DELIMITER . "URL" . MergeTagsUtil::TAG_SUFFIX) .
124  " : prints absolute url to the current model attached to template.";
125  $specialTagsItems[] = $this->renderBoldMergeTag(MergeTagsUtil::TAG_PREFIX . "BASE" .
126  MergeTagsUtil::CAPITAL_DELIMITER . "URL" . MergeTagsUtil::TAG_SUFFIX) .
127  " : prints absolute url to the current install without trailing slash.";
128  $specialTagsItems[] = $this->renderBoldMergeTag(MergeTagsUtil::TAG_PREFIX . "APPLICATION" .
129  MergeTagsUtil::CAPITAL_DELIMITER . "NAME" . MergeTagsUtil::TAG_SUFFIX) .
130  " : prints application name as set in global settings > application name.";
131  $specialTagsItems[] = $this->renderBoldMergeTag(MergeTagsUtil::TAG_PREFIX . "CURRENT" .
132  MergeTagsUtil::CAPITAL_DELIMITER . "YEAR" . MergeTagsUtil::TAG_SUFFIX) .
133  " : prints current year.";
134  $specialTagsItems[] = $this->renderBoldMergeTag(MergeTagsUtil::TAG_PREFIX . "LAST" .
135  MergeTagsUtil::CAPITAL_DELIMITER . "YEAR" . MergeTagsUtil::TAG_SUFFIX) .
136  " : prints last year.";
137 
138  $specialTagsItems[] = $this->renderBoldMergeTag(MergeTagsUtil::TAG_PREFIX .'OWNERS' .
139  MergeTagsUtil::CAPITAL_DELIMITER . 'AVATAR' .
140  MergeTagsUtil::CAPITAL_DELIMITER . 'SMALL' .
141  MergeTagsUtil::TAG_SUFFIX) .
142  " : prints the owner's small avatar image (32x32).";
143  $specialTagsItems[] = $this->renderBoldMergeTag(MergeTagsUtil::TAG_PREFIX .'OWNERS' .
144  MergeTagsUtil::CAPITAL_DELIMITER . 'AVATAR' .
145  MergeTagsUtil::CAPITAL_DELIMITER . 'MEDIUM ' .
146  MergeTagsUtil::TAG_SUFFIX) .
147  " : prints the owner's medium avatar image (64x64).";
148  $specialTagsItems[] = $this->renderBoldMergeTag(MergeTagsUtil::TAG_PREFIX .'OWNERS' .
149  MergeTagsUtil::CAPITAL_DELIMITER . 'AVATAR' .
150  MergeTagsUtil::CAPITAL_DELIMITER . 'LARGE' .
151  MergeTagsUtil::TAG_SUFFIX) .
152  " : prints the owner's large avatar image (128x128).";
153  $specialTagsItems[] = $this->renderBoldMergeTag(MergeTagsUtil::TAG_PREFIX .'OWNERS' .
154  MergeTagsUtil::CAPITAL_DELIMITER . 'EMAIL' .
155  MergeTagsUtil::CAPITAL_DELIMITER . 'SIGNATURE' .
156  MergeTagsUtil::TAG_SUFFIX) .
157  " : prints the owner's email signature.";
158  $specialTagsItems[] = $this->renderBoldMergeTag(MergeTagsUtil::TAG_PREFIX .
159  'GLOBAL' .
160  MergeTagsUtil::CAPITAL_DELIMITER . 'MARKETING' .
161  MergeTagsUtil::CAPITAL_DELIMITER . 'FOOTER' .
162  MergeTagsUtil::CAPITAL_DELIMITER . 'PLAIN' .
163  MergeTagsUtil::CAPITAL_DELIMITER . 'TEXT' .
164  MergeTagsUtil::TAG_SUFFIX) .
165  " : prints the Global Marketing Footer(Plain Text).";
166  $specialTagsItems[] = $this->renderBoldMergeTag(MergeTagsUtil::TAG_PREFIX .'GLOBAL' .
167  MergeTagsUtil::CAPITAL_DELIMITER . 'MARKETING' .
168  MergeTagsUtil::CAPITAL_DELIMITER . 'FOOTER' .
169  MergeTagsUtil::CAPITAL_DELIMITER . 'HTML' .
170  MergeTagsUtil::TAG_SUFFIX) .
171  " : prints the Global Marketing Footer(Rich Text).";
172  $specialTagsItems[] = $this->renderBoldMergeTag(GlobalMarketingFooterUtil::resolveUnsubscribeUrlMergeTag()) .
173  " : prints unsubscribe url.";
174  $specialTagsItems[] = $this->renderBoldMergeTag(GlobalMarketingFooterUtil::resolveManageSubscriptionsMergeTag()) .
175  " : prints manage subscriptions url.";
176  foreach ($specialTagsItems as $specialTagsItem)
177  {
178  $specialTagsContent .= ZurmoHtml::tag('li', array(), $specialTagsItem);
179  }
180  $specialTagsContent = ZurmoHtml::tag('ul', array(), $specialTagsContent);
181  $specialTagsContent = ZurmoHtml::tag('div', array('id' => 'mergetag-special-tags-body'), $specialTagsContent);
182  $content .= $specialTagsContent;
183  $content = ZurmoHtml::tag('div', array('id' => 'mergetag-special-tags'), $content);
184  return $content;
185  }
186 
187  protected function renderBoldMergeTag($tag)
188  {
189  return ZurmoHtml::tag('strong', array(), $tag);
190  }
191  }
192 ?>
Definition: View.php:43
Generated on Fri Jun 5 2020 07:10:31