@@ -55,7 +55,7 @@ function getTemplateLinks($content)
5555
5656if (!empty ($ _POST ['action ' ]) && $ _POST ['action ' ] == 'addimages ' ) {
5757 if (!$ id ) {
58- $ msg = $ GLOBALS [ ' I18N ' ]-> get ('No such template ' );
58+ $ msg = s ('No such template ' );
5959 } else {
6060 $ content_req = Sql_Fetch_Row_Query ("select template from {$ tables ['template ' ]} where id = $ id " );
6161 $ images = getTemplateImages ($ content_req [0 ]);
@@ -67,9 +67,9 @@ function getTemplateLinks($content)
6767 // printf('Image name: <b>%s</b> (%d times used)<br />',$key,$val);
6868 $ image ->uploadImage ($ key , $ id );
6969 }
70- $ msg = $ GLOBALS [ ' I18N ' ]-> get ('Images stored ' );
70+ $ msg = s ('Images stored ' );
7171 } else {
72- $ msg = $ GLOBALS [ ' I18N ' ]-> get ('No images found ' );
72+ $ msg = s ('No images found ' );
7373 }
7474 }
7575 $ _SESSION ['action_result ' ] = $ msg .'<br/> ' .s ('Template saved and ready for use in campaigns ' );
@@ -81,7 +81,14 @@ function getTemplateLinks($content)
8181} elseif (!empty ($ _POST ['save ' ]) || !empty ($ _POST ['sendtest ' ])) { //# let's save when sending a test
8282 $ templateok = 1 ;
8383 $ title = $ _POST ['title ' ];
84- if (!empty ($ title ) && strpos ($ content , '[CONTENT] ' ) !== false ) {
84+ $ req = Sql_Query (sprintf ('select * from %s where title = "%s" ' ,$ tables ['template ' ], sql_escape ($ title )));
85+ if (Sql_Affected_Rows ()){
86+ $ titleExists = true ;
87+ }else {
88+ $ titleExists = false ;
89+ }
90+
91+ if (!empty ($ title ) && strpos ($ content , '[CONTENT] ' ) !== false && !$ titleExists ) {
8592 $ images = getTemplateImages ($ content );
8693
8794 // var_dump($images);
@@ -90,14 +97,14 @@ function getTemplateLinks($content)
9097 foreach ($ images as $ key => $ val ) {
9198 if (!preg_match ('#^https?://#i ' , $ key )) {
9299 if ($ checkfullimages ) {
93- $ actionresult .= $ GLOBALS [ ' I18N ' ]-> get ('Image ' )." $ key => " .$ GLOBALS [ ' I18N ' ]-> get ('"not full URL ' )."<br/> \n" ;
100+ $ actionresult .= s ('Image ' )." $ key => " .s ('"not full URL ' )."<br/> \n" ;
94101 $ templateok = 0 ;
95102 }
96103 } else {
97104 if ($ checkimagesexist ) {
98105 $ imageFound = testUrl ($ key );
99106 if ($ imageFound != 200 ) {
100- $ actionresult .= $ GLOBALS [ ' I18N ' ]-> get ('Image ' )." $ key => " .$ GLOBALS [ ' I18N ' ]-> get ('does not exist ' )."<br/> \n" ;
107+ $ actionresult .= s ('Image ' )." $ key => " .s ('does not exist ' )."<br/> \n" ;
101108 $ templateok = 0 ;
102109 }
103110 }
@@ -110,16 +117,18 @@ function getTemplateLinks($content)
110117 if (!preg_match ('#^https?://#i ' , $ val ) && !preg_match ('#^mailto:#i ' , $ val )
111118 && !(strtoupper ($ val ) == '[PREFERENCESURL] ' || strtoupper ($ val ) == '[UNSUBSCRIBEURL] ' || strtoupper ($ val ) == '[BLACKLISTURL] ' || strtoupper ($ val ) == '[FORWARDURL] ' || strtoupper ($ val ) == '[CONFIRMATIONURL] ' )
112119 ) {
113- $ actionresult .= $ GLOBALS [ ' I18N ' ]-> get ('Not a full URL ' ).": $ val<br/> \n" ;
120+ $ actionresult .= s ('Not a full URL ' ).": $ val<br/> \n" ;
114121 $ templateok = 0 ;
115122 }
116123 }
117124 }
118125 } else {
119126 if (!$ title ) {
120- $ actionresult .= $ GLOBALS ['I18N ' ]->get ('No Title ' ).'<br/> ' ;
127+ $ actionresult .= s ('No Title ' ).'<br/> ' ;
128+ }elseif ($ titleExists ){
129+ $ actionresult .= s ('The title of the template exists. ' ).'<br/> ' ;
121130 } else {
122- $ actionresult .= $ GLOBALS [ ' I18N ' ]-> get ('Template does not contain the [CONTENT] placeholder ' ).'<br/> ' ;
131+ $ actionresult .= s ('Template does not contain the [CONTENT] placeholder ' ).'<br/> ' ;
123132 }
124133 $ templateok = 0 ;
125134 }
@@ -158,8 +167,8 @@ function getTemplateLinks($content)
158167 if (count ($ missingImages ) && empty ($ _POST ['sendtest ' ])) {
159168 include dirname (__FILE__ ).'/class.image.inc ' ;
160169 $ image = new imageUpload ();
161- echo '<h3> ' .$ GLOBALS [ ' I18N ' ]-> get ('Images ' ).'</h3><p class="information"> ' .$ GLOBALS [ ' I18N ' ]-> get ('Below is the list of images used in your template. If an image is currently unavailable, please upload it to the database. ' ).'</p> ' ;
162- echo '<p class="information"> ' .$ GLOBALS [ ' I18N ' ]-> get ('This includes all images, also fully referenced ones, so you may choose not to upload some. If you upload images, they will be included in the campaigns that use this template. ' ).'</p> ' ;
170+ echo '<h3> ' .s ('Images ' ).'</h3><p class="information"> ' .s ('Below is the list of images used in your template. If an image is currently unavailable, please upload it to the database. ' ).'</p> ' ;
171+ echo '<p class="information"> ' .s ('This includes all images, also fully referenced ones, so you may choose not to upload some. If you upload images, they will be included in the campaigns that use this template. ' ).'</p> ' ;
163172 echo formStart ('enctype="multipart/form-data" class="template1" ' );
164173 echo '<input type="hidden" name="id" value=" ' .$ id .'" /> ' ;
165174 ksort ($ images );
@@ -170,26 +179,26 @@ function getTemplateLinks($content)
170179 $ missingImage = true ;
171180 $ imageFound = testUrl ($ key );
172181 if ($ imageFound != 200 ) {
173- printf ($ GLOBALS [ ' I18N ' ]-> get ('Image name: ' ).' <b>%s</b> ( ' .$ GLOBALS [ ' I18N ' ]-> get ('%d times used ' ).')<br/> ' ,
182+ printf (s ('Image name: ' ).' <b>%s</b> ( ' .s ('%d times used ' ).')<br/> ' ,
174183 $ key , $ val );
175184 echo $ image ->showInput ($ key , $ val , $ id );
176185 }
177186 } else {
178- printf ($ GLOBALS [ ' I18N ' ]-> get ('Image name: ' ).' <b>%s</b> ( ' .$ GLOBALS [ ' I18N ' ]-> get ('%d times used ' ).')<br/> ' ,
187+ printf (s ('Image name: ' ).' <b>%s</b> ( ' .s ('%d times used ' ).')<br/> ' ,
179188 $ key , $ val );
180189 echo $ image ->showInput ($ key , $ val , $ id );
181190 }
182191 }
183192
184193 echo '<input type="hidden" name="id" value=" ' .$ id .'" /><input type="hidden" name="action" value="addimages" />
185- <input class="submit" type="submit" name="addimages" value=" ' .$ GLOBALS [ ' I18N ' ]-> get ('Save Images ' ).'" /></form> ' ;
194+ <input class="submit" type="submit" name="addimages" value=" ' .s ('Save Images ' ).'" /></form> ' ;
186195 if (empty ($ _POST ['sendtest ' ])) {
187196 return ;
188197 }
189198 // return;
190199 } else {
191200 $ _SESSION ['action_result ' ] = s ('Template was successfully saved ' );
192- // print '<p class="information">'.$GLOBALS['I18N']->get ('Template does not contain local images')."</p>";
201+ // print '<p class="information">'.s ('Template does not contain local images')."</p>";
193202 if (empty ($ _POST ['sendtest ' ])) {
194203 Redirect ('templates ' );
195204
@@ -198,7 +207,7 @@ function getTemplateLinks($content)
198207 // return;
199208 }
200209 } else {
201- $ actionresult .= $ GLOBALS [ ' I18N ' ]-> get ('Some errors were found, template NOT saved! ' );
210+ $ actionresult .= s ('Some errors were found, template NOT saved! ' );
202211 $ data ['title ' ] = $ title ;
203212 $ data ['template ' ] = $ content ;
204213 }
@@ -209,32 +218,32 @@ function getTemplateLinks($content)
209218 $ testtarget = '' ;
210219
211220 if ($ id == $ systemTemplateID ) {
212- $ actionresult .= '<h3> ' .$ GLOBALS [ ' I18N ' ]-> get ('Sending test ' ).'</h3> ' ;
221+ $ actionresult .= '<h3> ' .s ('Sending test ' ).'</h3> ' ;
213222 foreach ($ targetEmails as $ email ) {
214223 if (validateEmail ($ email )) {
215224 $ testtarget .= $ email .', ' ;
216- $ actionresult .= $ GLOBALS [ ' I18N ' ]-> get ('Sending test "Request for confirmation" to ' ).' ' .$ email .' ' ;
225+ $ actionresult .= s ('Sending test "Request for confirmation" to ' ).' ' .$ email .' ' ;
217226 if (sendMail ($ email , getConfig ('subscribesubject ' ), getConfig ('subscribemessage ' ))) {
218227 $ actionresult .= s ('OK ' );
219228 } else {
220229 $ actionresult .= s ('FAILED ' );
221230 }
222231 $ actionresult .= '<br/> ' ;
223- $ actionresult .= $ GLOBALS [ ' I18N ' ]-> get ('Sending test "Welcome" to ' ).' ' .$ email .' ' ;
232+ $ actionresult .= s ('Sending test "Welcome" to ' ).' ' .$ email .' ' ;
224233 if (sendMail ($ email , getConfig ('confirmationsubject ' ), getConfig ('confirmationmessage ' ))) {
225234 $ actionresult .= s ('OK ' );
226235 } else {
227236 $ actionresult .= s ('FAILED ' );
228237 }
229238 $ actionresult .= '<br/> ' ;
230- $ actionresult .= $ GLOBALS [ ' I18N ' ]-> get ('Sending test "Unsubscribe confirmation" to ' ).' ' .$ email .' ' ;
239+ $ actionresult .= s ('Sending test "Unsubscribe confirmation" to ' ).' ' .$ email .' ' ;
231240 if (sendMail ($ email , getConfig ('unsubscribesubject ' ), getConfig ('unsubscribemessage ' ))) {
232241 $ actionresult .= s ('OK ' );
233242 } else {
234243 $ actionresult .= s ('FAILED ' );
235244 }
236245 } elseif (trim ($ email ) != '' ) {
237- $ actionresult .= '<p> ' .$ GLOBALS [ ' I18N ' ]-> get ('Error sending test messages to ' ).' ' .htmlspecialchars ($ email ).'</p> ' ;
246+ $ actionresult .= '<p> ' .s ('Error sending test messages to ' ).' ' .htmlspecialchars ($ email ).'</p> ' ;
238247 }
239248 }
240249 } else {
@@ -269,15 +278,15 @@ function getTemplateLinks($content)
269278?>
270279
271280<p class="information"><?php echo $ msg ?> </p>
272- <?php echo '<p class="button pull-right"> ' .PageLink2 ('templates ' , $ GLOBALS [ ' I18N ' ]-> get ('List of Templates ' )).'</p><div class="clearfix"></div> ' ; ?>
281+ <?php echo '<p class="button pull-right"> ' .PageLink2 ('templates ' , s ('List of Templates ' )).'</p><div class="clearfix"></div> ' ; ?>
273282
274283<?php echo formStart (' enctype="multipart/form-data" class="template2" ' ) ?>
275284<input type="hidden" name="id" value="<?php echo $ id ?> "/>
276285<div class="panel"><div class="content">
277286 <table class="templateForm">
278287 <tr>
279288
280- <td><?php echo $ GLOBALS [ ' I18N ' ]-> get ('Title of this template ' ) ?> </td>
289+ <td><?php echo s ('Title of this template ' ) ?> </td>
281290 <td><input type="text" name="title" value="<?php echo stripslashes (htmlspecialchars ($ data ['title ' ])) ?> "
282291 size="30"/></td>
283292 </tr>
@@ -311,20 +320,20 @@ function getTemplateLinks($content)
311320 <td><input type="text" name="baseurl" size="40" value="<?php echo htmlspecialchars ($ baseurl ) ?> " /></td>
312321</tr-->
313322 <tr>
314- <td><?php echo $ GLOBALS [ ' I18N ' ]-> get ('Check that all links have a full URL ' ) ?> </td>
323+ <td><?php echo s ('Check that all links have a full URL ' ) ?> </td>
315324 <td><input type="checkbox" name="checkfulllinks" <?php echo $ checkfulllinks ? 'checked="checked" ' : '' ?> />
316325 </td>
317326 </tr>
318327 <tr>
319- <td><?php echo $ GLOBALS [ ' I18N ' ]-> get ('Check that all images have a full URL ' ) ?> </td>
328+ <td><?php echo s ('Check that all images have a full URL ' ) ?> </td>
320329 <td><input type="checkbox"
321330 name="checkfullimages" <?php echo $ checkfullimages ? 'checked="checked" ' : '' ?> /></td>
322331 </tr>
323332
324333 <?php if ($ GLOBALS ['can_fetchUrl ' ]) {
325334 ?>
326335 <tr>
327- <td><?php echo $ GLOBALS [ ' I18N ' ]-> get ('Check that all external images exist ' ) ?> </td>
336+ <td><?php echo s ('Check that all external images exist ' ) ?> </td>
328337 <td><input type="checkbox"
329338 name="checkimagesexist" <?php echo $ checkimagesexist ? 'checked="checked" ' : '' ?> /></td>
330339 </tr>
@@ -333,7 +342,7 @@ function getTemplateLinks($content)
333342 } ?>
334343 <tr>
335344 <td colspan="2"><input class="submit" type="submit" name="save"
336- value="<?php echo $ GLOBALS [ ' I18N ' ]-> get ('Save Changes ' ) ?> "/></td>
345+ value="<?php echo s ('Save Changes ' ) ?> "/></td>
337346 </tr>
338347 </table>
339348</div></div>
@@ -342,9 +351,9 @@ function getTemplateLinks($content)
342351 <input class="submit" type="submit" name="sendtest" value="%s"/> %s:
343352 <input type="text" name="testtarget" size="40" value=" ' .htmlspecialchars ($ testtarget ).'"/><br />%s
344353 </div> ' ,
345- $ GLOBALS [ ' I18N ' ]-> get ('Send test message ' ), $ GLOBALS [ ' I18N ' ]-> get ('to email addresses ' ),
346- $ GLOBALS [ ' I18N ' ]-> get ('(comma separate addresses - all must be existing subscribers) ' ));
347- $ testpanel = new UIPanel ($ GLOBALS [ ' I18N ' ]-> get ('Send Test ' ), $ sendtest_content );
354+ s ('Send test message ' ), s ('to email addresses ' ),
355+ s ('(comma separate addresses - all must be existing subscribers) ' ));
356+ $ testpanel = new UIPanel (s ('Send Test ' ), $ sendtest_content );
348357$ testpanel ->setID ('testpanel ' );
349358 if ($ systemTemplateID == $ id ) { ## for now, testing only for system message templates
350359echo $ testpanel ->display ();
0 commit comments