Link.php 23.5 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
require_once(__DIR__ . '/../exceptions/UserReportExtension.php');
34
35
36
37
38
39
40
41
42
43
44
45

/*
 * u:url
 * m:mailto
 * p:page
 * 
 * t:text
 * a:AltText
 * o:ToolTip
 * 
 * r:render   
 * g:target
46
 * c:class  [n|i|e|<class>]
47
48
49
50
51
52
53
54
55
56
57
58
59
60
 * 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  
61
 *
62
63
64
65
 * A:    A:[u:p:m]
 * G:    G:[N|..]
 */

66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

const NAME_URL = 'url';
const NAME_MAIL = 'mail';
const NAME_PAGE = 'page';
const NAME_TEXT = 'text';
const NAME_ALT_TEXT = 'altText';
const NAME_TOOL_TIP = 'toolTip';
const NAME_IMAGE = 'image';
const NAME_IMAGE_TITLE = 'imageTitle';
const NAME_DELETE = 'delete';
const NAME_RENDER = 'render';
const NAME_TARGET = 'target';
const NAME_LINK_CLASS = 'linkClass';
const NAME_LINK_CLASS_DEFAULT = 'linkClassDefault';
const NAME_QUESTION = 'question';
const NAME_ENCRYPTION = 'encryption';
const NAME_HASH = 'hash';
const NAME_URL_PARAM = 'param';
const NAME_RIGHT_PICTURE_POSITION = 'picturePosition';

/**
 * Class Link
 * @package qfq
 */
90
91
class Link {

92
93
94
    //TODO: delete muss noch implementiert werden
    private $delete = '';

Carsten  Rose's avatar
Carsten Rose committed
95
    /**
96
     * @var Sip
Carsten  Rose's avatar
Carsten Rose committed
97
98
99
     */
    private $sip = null;

100
101
102
103
104
    /**
     * @var Store
     */
    private $store = null;

105
106
107
108
109
110
111
112
    // Simulate global variable: will be set much earlier in other functions. Will be shown in error messages.
    private $fr_error;

    /**
     * @var Utils
     */
    private $utils;
    /**
113
     * @var array
114
     */
115
116
117
118
    private $renderControl = array();
    private $linkClassSelector = array("i" => "internal", "e" => "external");
    private $cssLinkClassInternal = '';
    private $cssLinkClassExternal = '';
119

120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
    private $callTable = [
        'u' => 'buildUrl',
        'm' => 'buildMail',
        'p' => 'buildPage',
        'P' => 'buildPicture',
        'B' => 'buildBullet',
        'C' => 'buildCheck',
        'D' => 'buildDelete',
        'E' => 'buildEdit',
        'H' => 'buildHelp',
        'I' => 'buildInfo',
        'N' => 'buildNew',
        'S' => 'buildShow',
    ];

135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
    private $tableVarName = [
        'u' => NAME_URL,
        'm' => NAME_MAIL,
        'p' => NAME_PAGE,
        't' => NAME_TEXT,
        'a' => NAME_ALT_TEXT,
        'o' => NAME_TOOL_TIP,
        'P' => NAME_IMAGE,
        'B' => NAME_IMAGE,
        'C' => NAME_IMAGE,
        'D' => NAME_IMAGE,
        'E' => NAME_IMAGE,
        'H' => NAME_IMAGE,
        'I' => NAME_IMAGE,
        'N' => NAME_IMAGE,
        'S' => NAME_IMAGE,
        'r' => NAME_RENDER,
        'g' => NAME_TARGET,
        'c' => NAME_LINK_CLASS,
        'q' => NAME_QUESTION,
        'e' => NAME_ENCRYPTION,
        'h' => NAME_HASH,
        'U' => NAME_URL_PARAM,
        'R' => NAME_RIGHT_PICTURE_POSITION,
    ];

    private $varsDefault = array();

163
164
165
    /**
     * __construct
     *
166
167
     * @param $fr_error
     * @param Sip $sip
168
     * @param bool $phpUnit
169
     */
Carsten  Rose's avatar
Carsten Rose committed
170
    public function __construct($fr_error, Sip $sip, $phpUnit = false) {
171
        $this->fr_error = $fr_error;
Carsten  Rose's avatar
Carsten Rose committed
172
        $this->sip = $sip;
Carsten  Rose's avatar
Carsten Rose committed
173
        $this->store = Store::getInstance('', $phpUnit);
174
175
        $this->cssLinkClassInternal = $this->store->getVar(SYSTEM_CSS_LINK_CLASS_INTERNAL, STORE_SYSTEM);
        $this->cssLinkClassExternal = $this->store->getVar(SYSTEM_CSS_LINK_CLASS_EXTERNAL, STORE_SYSTEM);
176
177
        $this->utils = new Utils();

178
179
180
181
182
183
184
        $this->varsDefault[NAME_QUESTION] = 'Please confirm';
        $this->varsDefault[NAME_PAGE] = $this->store->getVar(TYPO3_PAGE_ID, STORE_TYPO3);
        $this->varsDefault[NAME_ENCRYPTION] = '0';
        $this->varsDefault[NAME_RIGHT_PICTURE_POSITION] = 'l';
        $this->varsDefault[NAME_RENDER] = 0;
        $this->varsDefault[NAME_HASH] = 0;

185
186
187
188
189
190
191
192
        /*
         * 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
193
         *  r=render mode, u=url, t:text and/or image.
194
195
196
197
198
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
         *
         *                  [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;
227

228
    }
229
230
231
232

    /**
     * Build the whole link
     *
233
234
     * @param string $str Qualifier with params. 'report'-syntax. F.e.:  A:u:www.example.com|G:P:home.gif|t:Home"
     * @return string     The complete HTML encoded Link like <a href='http://example.com' class='external'><img src='iconf.gif' title='help text'>Description</a>
235
     * @throws UserReportException
236
     */
237
    public function renderLink($str) {
238
239
        $link = '';

240
        $vars = $this->initVars();
241
242

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

        // Parse all parameter, fill variables
246
247
        foreach ($param as $item) {

248
249
250
251
            if ($item == '') {
                continue;
            }

252
            // set class defaults
253
            $this->parseItem($vars, $item);
254
255
        }

256
257
258
259
260
261
262
263
        $necessaryDefaults = [NAME_RENDER, NAME_RIGHT_PICTURE_POSITION, NAME_HASH, NAME_ENCRYPTION];
        foreach ($necessaryDefaults AS $keyName) {
            if ($vars[$keyName] == '') {
                $vars[$keyName] = $this->varsDefault[$keyName];
            }
        }


264
        // if there is no url or mailto definition: {{global.pageId}}
265
266
//        if ($vars[NAME_URL] == '' && $vars[NAME_MAIL] == '') {
//            $vars[NAME_URL] = "?" . $this->store->getVar(TYPO3_PAGE_ID, STORE_TYPO3);
267
//        }
268

269
        $this->doCssClass($vars);
270

271
272
        $htmlUrl = $this->doHtmlUrl($vars);
        $htmlImage = $this->doHtmlImage($vars);
273

274
// Compose Image & Text
275
276
        if ($htmlImage != '') {
            $distance = ' ';
277
            $vars[NAME_TEXT] = ($vars[NAME_RIGHT_PICTURE_POSITION] == "l") ? $htmlImage . $distance . $vars[NAME_TEXT] : $vars[NAME_TEXT] . $distance . $htmlImage;
278
        }
279

280
281
// ToolTip
        $extraSpan = ['', ''];
282
283
        if ($vars[NAME_TOOL_TIP]) {
            $extraSpan[0] = "<span " . $vars[NAME_TOOL_TIP][0] . ">" . $vars[NAME_TOOL_TIP][1];
284
285
286
            $extraSpan[1] = "</span>";
        }

287
// Create 'fake' modes for encrypted 'mailto'
288
        $prefix = "";
289
        if ($vars[NAME_MAIL] != '') {
290
            $prefix = "1";
291
            $vars[NAME_URL] = "dummy";
292
        }
293
// Create 'fake' mode for ajax delete
294
        if ($vars[NAME_DELETE]) {
295
296
            $prefix = "2";
        }
297
298
// Compose URL
// get Render Mode via Array renderControl
299
300
301
        $modeRender = $vars[NAME_RENDER];
        $modeUrl = $vars[NAME_URL] ? 1 : 0;
        $modeText = $vars[NAME_TEXT] ? 1 : 0;
302
303
304
305

        if (isset($this->renderControl[$modeRender][$modeUrl][$modeText])) {
            $mode = $prefix . $this->renderControl[$modeRender][$modeUrl][$modeText];
        } else {
306
307
            throw new UserReportException ("Undefined combination of 'rendering mode' / 'url' / 'text': " .
                $modeRender . ' / ' . $modeUrl . ' / ' . $modeText, ERROR_UNDEFINED_RENDER_CONTROL_COMBINATION);
308
309
        }

310
311
// 0-4 URL, plain email
// 10-14 encrypted email
312
313
314
315
316
        switch ($mode) {
            // 0: No Output
            case '0':
            case '10':
            case '20':
317
            $link = "";
318
319
320
321
                break;

            // 1: 'text'
            case '1':
322
                $link = $extraSpan[0] . $vars[NAME_TEXT] . $extraSpan[1];
323
324
                break;
            case '11':
325
                $link = $extraSpan[0] . $this->encryptMailtoJS($vars, false) . $extraSpan[1];
326
327
328
329
                break;

            // 2: 'url'
            case '2':
330
                $link = $extraSpan[0] . $vars[NAME_URL] . $extraSpan[1];
331
332
                break;
            case '12':
333
                $link = $extraSpan[0] . $this->encryptMailtoJS($vars, false) . $extraSpan[1];
334
335
336
337
                break;

            // 3: <a href=url>url</a>
            case '3':
338
                $link = $htmlUrl . $vars[NAME_URL] . '</a>' . $vars[NAME_TOOL_TIP][1];
339
340
                break;
            case '13':
341
                $vars[NAME_TEXT] = $vars[NAME_MAIL];
342
                $link = $this->encryptMailtoJS($vars, TRUE);
343
344
345
346
                break;

            // 4: <a href=url>Text</a>
            case '4':
347
                $link = $htmlUrl . $vars[NAME_TEXT] . '</a>' . $vars[NAME_TOOL_TIP][1];
348
349
                break;
            case '14':
350
                $link = $this->encryptMailtoJS($vars, TRUE);
351
352
353
354
355
                break;
            case '21':
            case '22':
            case '23':
            case '24':
356
            //TODO: Alter Code, umstellen auf JS Client von RO. Vorlage koennte 'Delete' in Subrecord sein.
357
            $link = "<a href=\"javascript: void(0);\" onClick=\"var del = new FR.Delete({recordId:'',hash:'',forward:'" .
358
                $vars[NAME_PAGE] . "'});\" " . $vars[NAME_LINK_CLASS] . ">" . $vars[NAME_TEXT] . "</a>";
359
360
        }

361
362
363
364
        return $link;

    }

365
366
367
    /**
     * Cleans the standard vars used every time to render a link.
     *
368
     * @return array
369
     */
370
    private function initVars() {
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
        $vars = array();

        $vars[NAME_MAIL] = '';
        $vars[NAME_URL] = '';
        $vars[NAME_PAGE] = '';

        $vars[NAME_IMAGE] = '';
        $vars[NAME_TEXT] = '';
        $vars[NAME_ALT_TEXT] = '';
        $vars[NAME_IMAGE_TITLE] = '';
        $vars[NAME_QUESTION] = '';
        $vars[NAME_TARGET] = '';
        $vars[NAME_TOOL_TIP] = ['', ''];
        $vars[NAME_URL_PARAM] = '';

        $vars[NAME_RENDER] = '';
        $vars[NAME_RIGHT_PICTURE_POSITION] = '';
        $vars[NAME_HASH] = '';
        $vars[NAME_ENCRYPTION] = '';
        $vars[NAME_DELETE] = '';

        $vars[NAME_LINK_CLASS] = ''; // class name
        $vars[NAME_LINK_CLASS_DEFAULT] = ''; // Depending of 'as page' or 'as url'. Only used if class is not explizit set.

        return $vars;
397
    }
398
399
400
401

    /**
     * Parse Item of link string, fill class global variables.
     *
402
403
404
     * @param array $vars
     * @param $item
     * @throws CodeException
405
     * @throws UserReportException
406
     */
407
    private function parseItem(array &$vars, $item) {
408
409

        $arr = explode(":", $item, 2);
410
411
412
        $key = isset($arr[0]) ? $arr[0] : '';
        $value = isset($arr[1]) ? $arr[1] : '';

413
414
415
416
417
418
419
        // Superclass
        if ($key === 'A' || $key === 'G') {
            $this->parseItem($vars, $value);
            return;
        }

        if (!isset($this->tableVarName[$key])) {
420
            throw new UserReportException ("Unknown link qualifier: '$key'", ERROR_UNKNOWN_LINK_QUALIFIER);
421
        }
422

423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
        $keyName = $this->tableVarName[$key];

        // A few keys do not have necessarily a value: fake the definition by manual assigning the default
        if ($value == '') {
            switch ($key) {
                case 'R':
                    $value = 'r';
                    break;
                case 'h':
                    $value = '1';
                    break;
                case 'p':
                    $value = $this->store->getVar(TYPO3_PAGE_ID, STORE_TYPO3); // If no pageid|pagealias is defined, take current page
                    break;
                case 'E':
                case 'N':
                case 'D':
                case 'H':
                case 'I':
                case 'S':
                    $value = '1';
                    break;
                default:
                    break;
            }
        }

        // Take defaults
        if ($value === '' && isset($this->varsDefault[$keyName])) {
            $value = $this->varsDefault[$keyName];
        }

        //  Check for empty values
        if ($key !== 'u' && $value === '') {
            throw new UserReportException ("Missing value for '$key'", ERROR_MISSING_VALUE);
        }

        // Value already defined?
        if ($vars[$keyName] !== '') {
            throw new UserReportException ("Multiple definitions for key '$key'", ERROR_MULTIPLE_DEFINITION);
        }

        // Store value
        $vars[$keyName] = $value;

        if ($vars[NAME_URL] && $vars[NAME_MAIL]) {
            throw new UserReportException ("Multiple URL / PAGE and MAILTO definition", ERROR_MULTIPLE_URL_PAGE_MAILTO_DEFINITION);
        }
471

472
473
474
475
476
        // Call special function
        if (isset($this->callTable[$key])) {
            $call = $this->callTable[$key];
            $this->$call($vars, $keyName, $value);
        }
477
    }
478
479
480
481

    /**
     * Parse CSS Class Settings
     *
482
     * @param array $vars
483
484
     * @return    void
     */
485
    private function doCssClass(array &$vars) {
486
        $class = '';
487

488
        switch ($vars[NAME_LINK_CLASS]) {
489
            case 'n':
490
                $vars[NAME_LINK_CLASS] = '';
491
492
493
                break;
            case 'i':
            case 'e':
494
            $vars[NAME_LINK_CLASS] = $this->linkClassSelector[$vars[NAME_LINK_CLASS]];
495
496
                break;
            default:
497
                $vars[NAME_LINK_CLASS] = ($vars[NAME_LINK_CLASS] == '') ? $vars[NAME_LINK_CLASS_DEFAULT] : $vars[NAME_LINK_CLASS];
498
                break;
499
        }
500
    }
501
502

    /**
503
504
505
506
     * 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
507
     *
508
     * @param array $vars
509
     * @return string
510
     * @throws UserReportException
511
     */
512
    private function doHtmlUrl(array &$vars) {
Carsten  Rose's avatar
Carsten Rose committed
513
        $tags = '';
514
515
516
        // build URL
        $htmlUrl = "";

517
        if ($vars[NAME_URL] !== '') {
518

519
            if ($vars[NAME_HASH] === "1") {
520

521
                $vars[NAME_URL] = $this->sip->queryStringToSip($vars[NAME_PAGE] . '&' . $vars[NAME_URL_PARAM]);
522

523
            } else {
524

525
                if ($vars[NAME_URL_PARAM] != '') {
526
                    // Append '&' or '?' depending if there is already a '?'
527
                    $vars[NAME_URL] .= (strpos($vars[NAME_URL], '?') >= 0) ? '&' : '?';
528
                    // Append all additional params.
529
                    $vars[NAME_URL] .= $vars[NAME_URL_PARAM];
530
531
                }
            }
532
533
        }

534
        // If there is no encryption: handle the mailto as an ordinary URL
535
        if ($vars[NAME_MAIL] !== '') {
536

537
538
539
            if ($vars[NAME_ENCRYPTION] === '0') {
                $vars[NAME_URL] = "mailto:" . $vars[NAME_MAIL];
                $vars[NAME_MAIL] = "";
540
            } else {
541
                throw new UserReportException ("Oops, sorry: encrypted mail not implemented ...", ERROR_NOT_IMPLEMENTED);
542
543
544
            }
        }

545
546
547
548
549
        $tags .= Support::doAttribute('href', $vars[NAME_URL]);
        $tags .= Support::doAttribute('class', $vars[NAME_LINK_CLASS]);
        $tags .= Support::doAttribute('target', $vars[NAME_TARGET]);
        if ($vars[NAME_QUESTION]) {
            $tags .= Support::doAttribute('onclick', 'confirm(\'' . $vars[NAME_QUESTION] . '\')');
Carsten  Rose's avatar
Carsten Rose committed
550
        }
551

552
        $htmlUrl = '<a ' . $tags . $vars[NAME_TOOL_TIP][0] . '>';
553
554
555

        return ($htmlUrl);
    }
556
557
558
559
560
561
562

    /**
     * Create Image HTML Tag
     * @return string $htmlImage
     * @internal param $void
     *
     */
563
    private function doHtmlImage(array $vars) {
564
        $tags = '';
565
566

        // Build Image
567
568
569
570
        if ($vars[NAME_IMAGE] != '') {
            $tags .= Support::doAttribute('alt', $vars[NAME_ALT_TEXT]);
            $tags .= Support::doAttribute('src', $vars[NAME_IMAGE]);
            $tags .= Support::doAttribute('title', $vars[NAME_IMAGE_TITLE]);
571
572
        }

573
        return $tags == '' ? '' : '<img ' . $tags . '>';
574
    }
575
576
577
578
579
580
581
582
583
584
585
586
587
588

    /**
     *  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>';
     *
589
590
591
     * @param array $vars
     * @param bool|TRUE $href TRUE: create a '<a>',   false: just encrypt or show the email, no link.
     * @return string
592
     */
593
    private function encryptMailtoJS(array $vars, $href = TRUE) {
594
595

        // Split $mailto
596
        $tmp = $this->splitAndAddDelimter($vars[NAME_MAIL], "@");
597
598
599
600
601
602
603
604
605
606
607
608
        $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++;
            }
609
            $dw .= ' + "' . $vars[NAME_LINK_CLASS] . str_replace('"', '\\"', $vars[NAME_TOOL_TIP][0]) . '>"';
610
611
612
613
614
615
616
            $closeDw = '"</a>")';
        } else {
            $dw = 'document.write(';
            $closeDw = ')';
        }

        // Wrap mailto around text
617
        if ($vars[NAME_MAIL] == $vars[NAME_TEXT]) {
618
619
620
621
622
623
624
            // 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
625
            $tt .= $dw . ' + "' . $vars[NAME_TEXT] . '" + ' . $closeDw . chr(10);
626
627
628
        }

        $tt .= '//--></script>';
629
        if ($href) $tt .= $vars[NAME_TOOL_TIP][1];
630
631

        return ($tt);
632
    }
633
634
635
636
637
638
639
640
641
642

    /**
     * Split a string around the $delimiter.
     *
     * Append the delimiter to each part except the last one.
     *
     * @param $mailto
     * @param $delimiter
     * @return array
     */
643
644
    private function splitAndAddDelimter($mailto, $delimiter) {
        //TODO: Ich verstehe die Funktion nicht - funktioniert das hier wirklich?
645
646
647
648
649
650
651
652
653
654
655
656
        $value = '';

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

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

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

        return ($arr);
657
    }
658
659

    /**
660
661
     * Called by $this->callTable
     *
662
663
664
665
666
     * @param $vars
     * @param $key
     * @param $value
     */
    private function buildUrl(&$vars, $key, $value) {
667
        $vars[NAME_LINK_CLASS_DEFAULT] = $this->cssLinkClassExternal;
668
669
670
    }

    /**
671
672
     * Called by $this->callTable
     *
673
674
675
676
677
     * @param $vars
     * @param $key
     * @param $value
     */
    private function buildMail(&$vars, $key, $value) {
678
        $vars[NAME_LINK_CLASS_DEFAULT] = $this->cssLinkClassExternal;
679
680
681
    }

    /**
682
683
     * Called by $this->callTable
     *
684
685
686
     * @param $vars
     * @param $key
     * @param $value
687
     * @throws UserReportException
688
689
690
     */
    private function buildPage(&$vars, $key, $value) {

691
692
693
        if ($vars[NAME_URL] != '') {
            throw new UserReportException ("Multiple definitions for key 'p'", ERROR_MULTIPLE_DEFINITION);
        }
694

695
696
697
        if (substr($value, 0, 3) !== 'id=') {
            $value = 'id=' . $value;
        }
698

699
700
        $vars[NAME_URL] = "?" . $value;
        $vars[NAME_LINK_CLASS_DEFAULT] = $this->cssLinkClassInternal;
701
702
703
    }

    /**
704
705
     * Called by $this->callTable
     *
706
707
708
709
710
     * @param $vars
     * @param $key
     * @param $value
     */
    private function buildPicture(&$vars, $key, $value) {
711
712
        $vars[NAME_ALT_TEXT] = "Grafic: " . $value;
        $vars[NAME_IMAGE_TITLE] = $value;
713
714
715
    }

    /**
716
717
     * Called by $this->callTable
     *
718
719
720
721
722
     * @param $vars
     * @param $key
     * @param $value
     */
    private function buildBullet(&$vars, $key, $value) {
723
724
        $vars[NAME_IMAGE] = PATH_ICONS . "bullet-" . $value . '.gif';
        $vars[NAME_IMAGE_TITLE] = $value;
725
726
727
    }

    /**
728
729
     * Called by $this->callTable
     *
730
731
732
733
734
     * @param $vars
     * @param $key
     * @param $value
     */
    private function buildCheck(&$vars, $key, $value) {
735
736
        $vars[NAME_IMAGE] = PATH_ICONS . "checked-" . $value . '.gif';
        $vars[NAME_IMAGE_TITLE] = $value;
737
738
739
    }

    /**
740
741
     * Called by $this->callTable
     *
742
743
744
745
746
     * @param $vars
     * @param $key
     * @param $value
     */
    private function buildDelete(&$vars, $key, $value) {
747
748
749
        $vars[NAME_IMAGE] = PATH_ICONS . 'delete.gif';
        $vars[NAME_IMAGE_TITLE] = "Delete";
        $vars[NAME_DELETE] = true;
750
751
752
753
754
        // Include Extjs library
        $this->utils->loadJSlib($this->fr_error);
    }

    /**
755
756
     * Called by $this->callTable
     *
757
758
759
760
761
     * @param $vars
     * @param $key
     * @param $value
     */
    private function buildEdit(&$vars, $key, $value) {
762
763
        $vars[NAME_IMAGE] = PATH_ICONS . 'edit.gif';
        $vars[NAME_IMAGE_TITLE] = "Edit";
764
765
766
    }

    /**
767
768
     * Called by $this->callTable
     *
769
770
771
772
773
     * @param $vars
     * @param $key
     * @param $value
     */
    private function buildHelp(&$vars, $key, $value) {
774
775
        $vars[NAME_IMAGE] = PATH_ICONS . 'help.gif';
        $vars[NAME_IMAGE_TITLE] = "Help";
776
777
778
    }

    /**
779
780
     * Called by $this->callTable
     *
781
782
783
784
785
     * @param $vars
     * @param $key
     * @param $value
     */
    private function buildInfo(&$vars, $key, $value) {
786
787
        $vars[NAME_IMAGE] = PATH_ICONS . 'info.gif';
        $vars[NAME_IMAGE_TITLE] = "Information";
788
789
790
    }

    /**
791
792
     * Called by $this->callTable
     *
793
794
795
796
797
     * @param $vars
     * @param $key
     * @param $value
     */
    private function buildNew(&$vars, $key, $value) {
798
799
        $vars[NAME_IMAGE] = PATH_ICONS . 'new.gif';
        $vars[NAME_IMAGE_TITLE] = "New";
800
801
802
    }

    /**
803
804
     * Called by $this->callTable
     *
805
806
807
808
809
     * @param $vars
     * @param $key
     * @param $value
     */
    private function buildShow(&$vars, $key, $value) {
810
811
        $vars[NAME_IMAGE] = PATH_ICONS . 'show.gif';
        $vars[NAME_IMAGE_TITLE] = "Details";
812
    }
813
}