Link.php 22.8 KB
Newer Older
1
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
<?PHP
/***************************************************************
 *  Copyright notice
 *
 *  (c) 2010 Glowbase GmbH <support@glowbase.com>
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
 *  free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  The GNU General Public License can be found at
 *  http://www.gnu.org/copyleft/gpl.html.
 *
 *  This script is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  This copyright notice MUST APPEAR in all copies of the script!
 ***************************************************************/

namespace qfq;

//use qfq;

require_once(__DIR__ . '/Define.php');
require_once(__DIR__ . '/Utils.php');
31
32
require_once(__DIR__ . '/../store/Store.php');
require_once(__DIR__ . '/../store/Sip.php');
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

/*
 * u:url
 * m:mailto
 * p:page
 * 
 * t:text
 * a:AltText
 * o:ToolTip
 * 
 * r:render   
 * g:target
 * c:class  [n|i|e]:<class>
 * q:question  <text>
 * e:encryption 0|1
 * 
 * E:edit
 * N:new
 * D:delete
 * H:Help
 * I:information
 * M:Magnifier
 * B:bullet
 * P:picture       [file]
 * C:checkbox    [name]
 * R:right 
 * h:hash  
60
 *
61
62
63
64
65
66
 * A:    A:[u:p:m]
 * G:    G:[N|..]
 */

class Link {

67
68
    private $mailto = "", $url = "", $image = "", $text = "", $altText = "", $imageTitle = "", $question = "", $target = "", $additionalUrlParams = "";
    private $toolTip = array(), $modeRender = 0, $picturePosition = "l", $modeHash = false, $encryption = 1;
69
70
    private $linkClass = "", $defaultLinkClass = "";
    private $linkClassSelector = array("i" => "internal", "e" => "external");
71
    private $renderControl, $link = "";
72

Carsten  Rose's avatar
Carsten Rose committed
73
    /**
74
     * @var Sip
Carsten  Rose's avatar
Carsten Rose committed
75
76
77
     */
    private $sip = null;

78
79
80
81
82
    /**
     * @var Store
     */
    private $store = null;

83
84
85
86
87
88
89
90
91
92
93
94
95
    // Simulate global variable: will be set much earlier in other functions. Will be shown in error messages.
    private $fr_error;

    private $exceptionBody = "";
    /**
     * @var Utils
     */
    private $utils;
    /**
     * @var string
     */
    private $pageAlias = '';

96
97
98
    private $cssLinkClassInternal = '';
    private $cssLinkClassExternal = '';

99
100
101
102
103
104
105
106
107
108
109
    /**
     * __construct
     *
     * @param string $fullLevel Recent processed level, f.e.: '10.20.sql'
     * @param string $sql Recent processed query, f.e.: SELECT p.name FROM person AS p
     * @param string $columnValue Definition of link
     * @param int $count
     * @param int $columnIndex
     * @param string $fr_error
     * @param string $dbAlias
     */
Carsten  Rose's avatar
Carsten Rose committed
110
    public function __construct($fullLevel, $sql, $columnValue, $count, $columnIndex, $fr_error, $dbAlias = '', $sip) {
111
112
113
        $this->exceptionBody = "Level: " . $fullLevel . ".sql = " . $sql . "\nRow: " . $count . " , Column: " . $columnIndex . " , Bad link: " . $columnValue . "\n";
        $this->fr_error = $fr_error;
        $this->dbAlias = $dbAlias;
Carsten  Rose's avatar
Carsten Rose committed
114
        $this->sip = $sip;
115
        $this->store = Store::getInstance();
Carsten  Rose's avatar
Carsten Rose committed
116

117
118
        $this->cssLinkClassInternal = $this->store->getVar(SYSTEM_CSS_LINK_CLASS_INTERNAL, STORE_SYSTEM);
        $this->cssLinkClassExternal = $this->store->getVar(SYSTEM_CSS_LINK_CLASS_EXTERNAL, STORE_SYSTEM);
119
120
        $this->initRenderControl();

121
    }
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140

    /**
     * Initializes RenderControl Array
     *
     * @param    void
     * @return    void
     */
    private function initRenderControl() {

        $this->utils = new Utils();

        /*
         * mode:
         * 0: no output
         * 1: text
         * 2: url
         * 3: <a href=url>url</a>
         * 4: <a href=url>Text</a>
         *
Carsten  Rose's avatar
Carsten Rose committed
141
         *  r=render mode, u=url, t:text and/or image.
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
         *
         *                  [r][u][t] = mode
         */

        $this->renderControl[0][0][0] = 0;
        $this->renderControl[0][0][1] = 0;
        $this->renderControl[0][1][0] = 3;
        $this->renderControl[0][1][1] = 4;

        $this->renderControl[1][0][0] = 0;
        $this->renderControl[1][0][1] = 1;
        $this->renderControl[1][1][0] = 3;
        $this->renderControl[1][1][1] = 4;

        $this->renderControl[2][0][0] = 0;
        $this->renderControl[2][0][1] = 0;
        $this->renderControl[2][1][0] = 0;
        $this->renderControl[2][1][1] = 4;

        $this->renderControl[3][0][0] = 0;
        $this->renderControl[3][0][1] = 1;
        $this->renderControl[3][1][0] = 2;
        $this->renderControl[3][1][1] = 1;

        $this->renderControl[4][0][0] = 0;
        $this->renderControl[4][0][1] = 1;
        $this->renderControl[4][1][0] = 2;
        $this->renderControl[4][1][1] = 2;

        $this->renderControl[5][0][0] = 0;
        $this->renderControl[5][0][1] = 0;
        $this->renderControl[5][1][0] = 0;
        $this->renderControl[5][1][1] = 0;
175
    }
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197

    /**
     * Build the whole link
     *
     * @param    string $str :  Qualifier with params. 'report'-syntax. F.e.:  A:u:www.example.com|G:P:home.gif|t:Home"
     * @param    string $count
     * @param    string &$hash hash used by the link, and maybe created for the link if count=1
     *
     * @return    string      The complete Link
     */
    public function renderLink($str, $count, &$hash) {

        // str="u:http://www.example.com|c:i|t:delete"
        $parm = explode("|", $str);

        // Parse all parameter, fill variables
        foreach ($parm as $item) {
            $arr = explode(":", $item, 2);
            $this->parseItem($arr[0], $arr[1]);
        }

        // if there is no url or mailto definition: ~global.pageId
198
        if (!$this->url && !$this->mailto) $this->url = "?" . $this->store->getVar(TYPO3_PAGE_ID, STORE_TYPO3);
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246

        $this->doCssClass();

        $htmlUrl = $this->doUrl($count, $hash);
        $htmlImage = $this->doImage();

        // One space distance
        if ($this->text) $distance = " ";

        // Compose Image & Text
        $distance = ' ';
        $this->text = ($this->picturePosition == "l") ? $htmlImage . $distance . $this->text : $this->text . $distance . $htmlImage;

        // ToolTip
        $extraSpan = array();
        if ($this->toolTip) {
            $extraSpan[0] = "<span " . $this->toolTip[0] . ">" . $this->toolTip[1];
            $extraSpan[1] = "</span>";
        }

        // Create 'fake' modes for encrypted 'mailto'
        $prefix = "";
        if ($this->mailto) {
            $prefix = "1";
            $this->url = "dummy";
        }
        // Create 'fake' mode for ajax delete
        if ($this->delete) {
            $prefix = "2";
        }
        // Compose URL
        // get Render Mode via Array renderControl
        $mode = $prefix . $this->renderControl[$this->modeRender][$this->url ? 1 : 0][$this->text ? 1 : 0];
        // 0-4 URL, plain email
        // 10-14 encrypted email
        switch ($mode) {
            // 0: No Output
            case '0':
            case '10':
            case '20':
                $this->link = "";
                break;

            // 1: 'text'
            case '1':
                $this->link = $extraSpan[0] . $this->text . $extraSpan[1];
                break;
            case '11':
247
                $this->link = $extraSpan[0] . $this->encryptMailtoJS($this->mailto, $this->text, $this->linkClass, false) . $extraSpan[1];
248
249
250
251
252
253
254
                break;

            // 2: 'url'
            case '2':
                $this->link = $extraSpan[0] . $this->url . $extraSpan[1];
                break;
            case '12':
255
                $this->link = $extraSpan[0] . $this->encryptMailtoJS($this->mailto, $this->text, $this->linkClass, false) . $extraSpan[1];
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
                break;

            // 3: <a href=url>url</a>
            case '3':
                $this->link = $htmlUrl . $this->url . '</a>' . $this->toolTip[1];
                break;
            case '13':
                $this->link = $this->encryptMailtoJS($this->mailto, $this->mailto, $this->linkClass, TRUE);
                break;

            // 4: <a href=url>Text</a>
            case '4':
                $this->link = $htmlUrl . $this->text . '</a>' . $this->toolTip[1];
                break;
            case '14':
                $this->link = $this->encryptMailtoJS($this->mailto, $this->text, $this->linkClass, TRUE);
                break;
            case '21':
            case '22':
            case '23':
            case '24':
                $this->link = "<a href=\"javascript: void(0);\" onClick=\"var del = new FR.Delete({recordId:'" . $count . "',hash:'" . $hash . "',forward:'" . $this->pageAlias . "'});\" " . $this->linkClass . ">" . $this->text . "</a>";
        }

        return $this->link;

282
    }
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297

    /**
     * Parse Item of link string, fill class global variables.
     *
     * @param    string $key :    F.e.: 'u'
     * @param    string $value :  F.e.: 'http://www.nzz.ch'
     * @throws SyntaxReportException
     */
    private function parseItem($key, $value) {

        switch ($key) {
            // URL
            case "u":
                if ($this->url || $this->mailto) throw new SyntaxReportException ("Multiple URL, PAGE or MAILTO defined : '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
                $this->url = $value;
298
                $this->defaultLinkClass = $this->cssLinkClassExternal;
299
300
301
302
                break;
            case "m":
                if ($this->url || $this->mailto) throw new SyntaxReportException ("Multiple URL, PAGE or MAILTO defined : '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
                $this->mailto = $value;
303
                $this->defaultLinkClass = $this->cssLinkClassExternal;
304
305
306
                break;
            case "p":
                if ($this->url || $this->mailto) throw new SyntaxReportException ("Multiple URL, PAGE or MAILTO defined : '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
307
                $this->pageAlias = $value ? $value : $this->store->getVar(TYPO3_PAGE_ID, STORE_TYPO3); // If no pageid|pagealias is defined, take current page
308
                $this->url = "?" . $this->pageAlias;
309
                $this->defaultLinkClass = $this->cssLinkClassInternal;
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
                break;
            // Text
            case "t":
                $this->text = $value;
                break;
            case "a":
                $this->altText = $value;
                break;
            case "o":
                $this->toolTip = $this->utils->createToolTip($value);
                break;

            // Image
            case "P":
                if ($this->image) throw new SyntaxReportException ("Multiple images defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
                $this->image = $value;
                $this->AltText = "Grafic: " . $value;
                $this->imageTitle = $value;
                break;
            case "B":
                if ($this->image) throw new SyntaxReportException ("Multiple images defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
                $this->image = PATH_ICONS . "bullet-" . ($value ? $value : "green") . '.gif';
                $this->defaultAltText = "Bullet: " . $value;
                $this->imageTitle = $value;
                break;
            case "C":
                if ($this->image) throw new SyntaxReportException ("Multiple images defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
                $this->image = PATH_ICONS . "checked-" . ($value ? $value : "green") . '.gif';
                $this->defaultAltText = "Checked: " . $value;
                $this->imageTitle = $value;
                break;
            case "D":
                if ($this->image) throw new SyntaxReportException ("Multiple images defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
                $this->image = PATH_ICONS . 'delete.gif';
                $this->defaultAltText = "Delete";
                $this->imageTitle = "Delete";
                $this->delete = true;
                // Include Extjs library
                $this->utils->loadJSlib($this->fr_error);
                break;
            case "E":
                if ($this->image) throw new SyntaxReportException ("Multiple images defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
                $this->image = PATH_ICONS . 'edit.gif';
                $this->defaultAltText = "Edit";
                $this->imageTitle = "Edit";
                break;
            case "H":
                if ($this->image) throw new SyntaxReportException ("Multiple images defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
                $this->image = PATH_ICONS . 'help.gif';
                $this->defaultAltText = "Help";
                $this->imageTitle = "Help";
                break;
            case "I":
                if ($this->image) throw new SyntaxReportException ("Multiple images defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
                $this->image = PATH_ICONS . 'info.gif';
                $this->defaultAltText = "Information";
                $this->imageTitle = "Information";
                break;
            case "N":
                if ($this->image) throw new SyntaxReportException ("Multiple images defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
                $this->image = PATH_ICONS . 'new.gif';
                $this->defaultAltText = "New";
                $this->imageTitle = "New";
                break;
            case "S":
                if ($this->image) throw new SyntaxReportException ("Multiple images defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
                $this->image = PATH_ICONS . 'show.gif';
                $this->defaultAltText = "Details";
                $this->imageTitle = "Details";
                break;

            // Misc
            case "r":
                if ($this->modeRender) throw new SyntaxReportException ("Multiple render modes defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
                $this->modeRender = $value;
                break;
            case "g":
                if ($this->target) throw new SyntaxReportException ("Multiple 'target' defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
                $this->target = $value;
                break;
            case "c":
                if ($this->linkClass) throw new SyntaxReportException ("Multiple linkClass defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
                $this->linkClass = $value;
                break;
            case "q":
                if ($this->question) throw new SyntaxReportException ("Multiple question defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
                $this->question = $value ? $value : "Please confirm";
                break;
            case "e":
                if ($this->encryption != 1) throw new SyntaxReportException ("Multiple encryption defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
                $this->encryption = $value ? $value : "1";
                break;
            case "h":
                if ($this->modeHash) throw new SyntaxReportException ("Multiple modeHash defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
                $this->modeHash = TRUE;
                break;
            case "U":    //if($this->additionalUrlParams) throw new syntaxException ( "Multiple additionalUrlParams defined: '$key'","",__FILE__,__LINE__, "Column: " . $fthis->r_error["columnIndex"], $this->fr_error);
407
                $this->additionalUrlParams = $value;
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
                break;
            case "R":
                if ($this->picturePosition != "l") throw new SyntaxReportException ("Multiple picturePosition defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
                $this->picturePosition = "r";
                break;

            // A,G
            case "G":
            case "A":
                $arr = explode(":", $value, 2);
                $this->parseItem($arr[0], $arr[1]);
                break;
            case "" :
                break;
            default:
                throw new SyntaxReportException ("Unknown link qualifier: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);

        }

427
    }
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448

    /**
     * Parse CSS Class Settings
     *
     * @param    void
     *
     * @return    void
     */
    private function doCssClass() {

        // class: i|e|n|<custom name>
        if ($this->linkClass != 'n') {
            if (!$this->linkClass) $this->linkClass = $this->defaultLinkClass;

            if ($this->linkClassSelector[$this->linkClass])
                $this->linkClass = $this->linkClassSelector[$this->linkClass];

            $this->linkClass = ' class="' . $this->linkClass . '"';
        } else {
            $this->linkClass = "";
        }
449
    }
450
451

    /**
452
453
454
455
     * Builds complete HTML anchor.
     * - <a href="mailto:info@example.com:>info@example.com</a>
     * - <a href="http://example.com:>http://example.com</a>
     * - If $this->modeHash is set, create a
456
457
     *
     * @return string
458
     * @throws SyntaxReportException
459
     */
460
    private function doUrl() {
461
462
463
464
465
466
467
        // build URL
        $htmlUrl = "";

        if ($this->url) {

            if ($this->modeHash) {

468
                $this->url = $this->sip->queryStringToSip($this->additionalUrlParams);
469

470
            } else {
471

472
473
474
475
476
477
478
                if ($this->additionalUrlParams) {
                    // Append '&' or '?' depending if there is already a '?'
                    $this->url .= (strpos($this->url, '?') >= 0) ? '&' : '?';
                    // Append all additional params.
                    $this->url .= $this->additionalUrlParams;
                }
            }
479
480
        }

481
482
        // If there is no encryption: handle the mailto as an ordinary URL
        if ($this->mailto) {
483

484
485
486
487
488
489
            if ($this->encryption == 0) {
                $this->url = "mailto:" . $this->mailto;
                $this->mailto = "";
            } else {
                throw new SyntaxReportException ("Oops, sorry: encrypted mail not implemented ...", "", __FILE__, __LINE__,
                    "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
490
491
492
            }
        }

493
494
        // target
        if ($this->target) $this->target = ' target="' . $this->target . '"';
495

496
497
498
499
500
501
502
        // question
        if ($this->question) $this->question = ' onclick="return confirm(\'' . $this->question . '\')"';

        $htmlUrl = '<a href="' . $this->url . '"' . $this->linkClass . $this->target . $this->question . $this->toolTip[0] . '>';

        return ($htmlUrl);
    }
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525

    /**
     * Create Image HTML Tag
     * @return string $htmlImage
     * @internal param $void
     *
     */
    private function doImage() {
        $htmlImage = "";

        // Build Image
        if ($this->image) {

            if ($this->altText) $this->altText = ' alttext="' . $this->altText . '"';

            if ($this->image) $this->image = ' src="' . $this->image . '"';

            if ($this->imageTitle) $this->imageTitle = ' title="' . $this->imageTitle . '"';

            $htmlImage = '<img' . $this->image . $this->altText . $this->imageTitle . ' />';
        }

        return ($htmlImage);
526
    }
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543

    /**
     *  Encrypt the mailto address via JS.
     *  Email address protected against email crawler (as long as they don't interpret JS).
     *
     *    <script language=javascript><!--
     *    var mm1 = name
     *    var mm2 = @domain.
     *    var ... = tld
     *    document.write("<a href=" + "mail" + "to:" + mm1 + mm2 + ... + ">" + name + "</a>")
     *    document.write("<a href=" + "mail" + "to:" + mm1 + mm2 + ... + ">" + @domain. + "</a>")
     *    document.write("<a href=" + "mail" + "to:" + mm1 + mm2 + ... + ">" + tld + "</a>")
     *    //--></script>';
     *
     * @param    string $mailto Email address to encrypt.
     * @param    string $text Text to wrap <a href..>, </a> around.
     * @param    string $class Optional class definition
544
     * @param    bool $href TRUE: create a '<a>',   false: just encrypt or show the email, no link.
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
     *
     * @return    string The complete Link
     */
    private function encryptMailtoJS($mailto, $text, $class = "", $href = TRUE) {

        // Prepare CSS Definition
        if ($class) $class = str_replace('"', "'", $class);

        // Split $mailto
        $tmp = $this->splitAndAddDelimter($mailto, "@");
        $arr = array_merge($this->splitAndAddDelimter($tmp[0], "."), $this->splitAndAddDelimter($tmp[1], "."));

        $tt = "<script language=javascript><!--" . chr(10);
        $ii = 0;
        if ($href) {
            $dw = 'document.write("<a href=" + "mail" + "to:"';
            foreach ($arr as $value) {
                // Setup JS Variables
                $tt .= 'var mm' . $ii . '= "' . $value . '"' . chr(10);
                // Compose $dw (documentwrite statement)
                $dw .= ' + mm' . $ii++;
            }
            $dw .= ' + "' . $class . str_replace('"', '\\"', $this->toolTip[0]) . '>"';
            $closeDw = '"</a>")';
        } else {
            $dw = 'document.write(';
            $closeDw = ')';
        }

        // Wrap mailto around text
        if ($mailto == $text) {
            // Text is an email: wrap every single part of mailto.
            $ii = 0;
            foreach ($arr as $value) {
                $tt .= $dw . " + mm" . $ii++ . ' + ' . $closeDw . chr(10);
            }
        } else {
            // Single wrap text
            $tt .= $dw . ' + "' . $text . '" + ' . $closeDw . chr(10);
        }

        $tt .= '//--></script>';
        if ($href) $tt .= $this->toolTip[1];

        return ($tt);
590
    }
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613

    /**
     * Split a string around the $delimiter.
     *
     * Append the delimiter to each part except the last one.
     *
     * @param $mailto
     * @param $delimiter
     * @return array
     */
    private function splitAndAddDelimter($mailto, $delimiter) {
        $value = '';

        $arr = explode($delimiter, $mailto);            // split string

        foreach ($arr as $key => $value) {
            $arr[$key] = $value . $delimiter;
        }

        if (isset($key))
            $arr[$key] = $value;

        return ($arr);
614
    }
615
}