Link.php 27.6 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

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';
73
const NAME_TOOL_TIP_JS = 'toolTipJs';
74
75
const NAME_IMAGE = 'image';
const NAME_IMAGE_TITLE = 'imageTitle';
76
77
const NAME_GLYPH = 'glyph';
const NAME_GLYPH_TITLE = 'glyphTitle';
78
79
80
81
82
83
84
85
86
87
88
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';

89
90
const NO_CLASS = 'no_class';

91
92
93
94
/**
 * Class Link
 * @package qfq
 */
95
96
class Link {

97
98
99
    //TODO: delete muss noch implementiert werden
    private $delete = '';

Carsten  Rose's avatar
Carsten Rose committed
100
    /**
101
     * @var Sip
Carsten  Rose's avatar
Carsten Rose committed
102
103
104
     */
    private $sip = null;

105
106
107
108
109
    /**
     * @var Store
     */
    private $store = null;

110
111
112
113
114
115
116
117
    // Simulate global variable: will be set much earlier in other functions. Will be shown in error messages.
    private $fr_error;

    /**
     * @var Utils
     */
    private $utils;
    /**
118
     * @var array
119
     */
120
121
122
123
    private $renderControl = array();
    private $linkClassSelector = array("i" => "internal", "e" => "external");
    private $cssLinkClassInternal = '';
    private $cssLinkClassExternal = '';
124

125
126
127
128
    private $callTable = [
        'u' => 'buildUrl',
        'm' => 'buildMail',
        'p' => 'buildPage',
129
        'o' => 'buildToolTip',
130
131
132
133
134
135
136
137
138
139
140
        'P' => 'buildPicture',
        'B' => 'buildBullet',
        'C' => 'buildCheck',
        'D' => 'buildDelete',
        'E' => 'buildEdit',
        'H' => 'buildHelp',
        'I' => 'buildInfo',
        'N' => 'buildNew',
        'S' => 'buildShow',
    ];

141
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
    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();

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

184
        $this->varsDefault[NAME_QUESTION] = 'Please confirm';
185
//        $this->varsDefault[NAME_PAGE] = $this->store->getVar(TYPO3_PAGE_ID, STORE_TYPO3);
186
187
188
189
190
        $this->varsDefault[NAME_ENCRYPTION] = '0';
        $this->varsDefault[NAME_RIGHT_PICTURE_POSITION] = 'l';
        $this->varsDefault[NAME_RENDER] = 0;
        $this->varsDefault[NAME_HASH] = 0;

191
192
193
194
195
196
197
198
        /*
         * 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
199
         *  r=render mode, u=url, t:text and/or image.
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
         *
         *                  [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;
233

234
    }
235
236
237
238

    /**
     * Build the whole link
     *
239
240
     * @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>
241
     * @throws UserReportException
242
     */
243
    public function renderLink($str) {
244
245
        $link = '';

246
        $vars = $this->initVars();
247
248

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

        // Parse all parameter, fill variables
252
253
        foreach ($param as $item) {

254
255
256
257
            if ($item == '') {
                continue;
            }

258
            // set class defaults
259
            $this->parseItem($vars, $item);
260
261
        }

262
263
264
265
266
267
268
269
        $necessaryDefaults = [NAME_RENDER, NAME_RIGHT_PICTURE_POSITION, NAME_HASH, NAME_ENCRYPTION];
        foreach ($necessaryDefaults AS $keyName) {
            if ($vars[$keyName] == '') {
                $vars[$keyName] = $this->varsDefault[$keyName];
            }
        }


270
        // if there is no url or mailto definition: {{global.pageId}}
271
272
//        if ($vars[NAME_URL] == '' && $vars[NAME_MAIL] == '') {
//            $vars[NAME_URL] = "?" . $this->store->getVar(TYPO3_PAGE_ID, STORE_TYPO3);
273
//        }
274

275
        $this->doCssClass($vars);
276

277
278
279
280
281
        // Set default tooltip
        if ($vars[NAME_TOOL_TIP] == '' && $vars[NAME_GLYPH_TITLE] !== '') {
            $vars[NAME_TOOL_TIP] = $vars[NAME_GLYPH_TITLE];
        }

282
        $htmlUrl = $this->doAnchor($vars);
283
        $htmlImage = $this->doHtmlImageGlyph($vars);
284

285
// Compose Image & Text
286
287
        if ($htmlImage != '') {
            $distance = ' ';
288
            $vars[NAME_TEXT] = ($vars[NAME_RIGHT_PICTURE_POSITION] == "l") ? $htmlImage . $distance . $vars[NAME_TEXT] : $vars[NAME_TEXT] . $distance . $htmlImage;
289
        }
290

291
292
// ToolTip
        $extraSpan = ['', ''];
293
294
        if ($vars[NAME_TOOL_TIP] !== '') {
            $extraSpan[0] = "<span " . $vars[NAME_TOOL_TIP_JS][0] . ">" . $vars[NAME_TOOL_TIP_JS][1];
295
296
297
            $extraSpan[1] = "</span>";
        }

298
// Create 'fake' modes for encrypted 'mailto'
299
        $prefix = "";
300
        if ($vars[NAME_MAIL] != '') {
301
            $prefix = "1";
302
            $vars[NAME_URL] = "dummy";
303
        }
304
// Create 'fake' mode for ajax delete
305
        if ($vars[NAME_DELETE]) {
306
307
            $prefix = "2";
        }
308
309
// Compose URL
// get Render Mode via Array renderControl
310
311
312
        $modeRender = $vars[NAME_RENDER];
        $modeUrl = $vars[NAME_URL] ? 1 : 0;
        $modeText = $vars[NAME_TEXT] ? 1 : 0;
313
314
315
316

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

321
322
// 0-4 URL, plain email
// 10-14 encrypted email
323
324
325
326
327
        switch ($mode) {
            // 0: No Output
            case '0':
            case '10':
            case '20':
328
            $link = "";
329
330
331
332
                break;

            // 1: 'text'
            case '1':
333
                $link = $extraSpan[0] . $vars[NAME_TEXT] . $extraSpan[1];
334
335
                break;
            case '11':
336
                $link = $extraSpan[0] . $this->encryptMailtoJS($vars, false) . $extraSpan[1];
337
338
339
340
                break;

            // 2: 'url'
            case '2':
341
                $link = $extraSpan[0] . $vars[NAME_URL] . $extraSpan[1];
342
343
                break;
            case '12':
344
                $link = $extraSpan[0] . $this->encryptMailtoJS($vars, false) . $extraSpan[1];
345
346
347
348
                break;

            // 3: <a href=url>url</a>
            case '3':
349
                $link = $htmlUrl . $vars[NAME_URL] . '</a>' . $vars[NAME_TOOL_TIP_JS][1];
350
351
                break;
            case '13':
352
                $vars[NAME_TEXT] = $vars[NAME_MAIL];
353
                $link = $this->encryptMailtoJS($vars, TRUE);
354
355
356
357
                break;

            // 4: <a href=url>Text</a>
            case '4':
358
                $link = $htmlUrl . $vars[NAME_TEXT] . '</a>' . $vars[NAME_TOOL_TIP_JS][1];
359
360
                break;
            case '14':
361
                $link = $this->encryptMailtoJS($vars, TRUE);
362
363
364
365
366
                break;
            case '21':
            case '22':
            case '23':
            case '24':
367
            //TODO: Alter Code, umstellen auf JS Client von RO. Vorlage koennte 'Delete' in Subrecord sein.
368
            $link = "<a href=\"javascript: void(0);\" onClick=\"var del = new FR.Delete({recordId:'',hash:'',forward:'" .
369
                $vars[NAME_PAGE] . "'});\" " . $vars[NAME_LINK_CLASS] . ">" . $vars[NAME_TEXT] . "</a>";
370
371
        }

372
373
374
375
        return $link;

    }

376
377
378
    /**
     * Cleans the standard vars used every time to render a link.
     *
379
     * @return array
380
     */
381
    private function initVars() {
382

383
384
385
386
387
388
389
390
        $vars = array();

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

        $vars[NAME_TEXT] = '';
        $vars[NAME_ALT_TEXT] = '';
391
        $vars[NAME_IMAGE] = '';
392
        $vars[NAME_IMAGE_TITLE] = '';
393
394
        $vars[NAME_GLYPH] = '';
        $vars[NAME_GLYPH_TITLE] = '';
395
396
        $vars[NAME_QUESTION] = '';
        $vars[NAME_TARGET] = '';
397
398
        $vars[NAME_TOOL_TIP] = '';
        $vars[NAME_TOOL_TIP_JS] = ['', ''];
399
400
401
402
403
404
405
406
407
408
409
410
        $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;
411
    }
412
413
414
415

    /**
     * Parse Item of link string, fill class global variables.
     *
416
417
418
     * @param array $vars
     * @param $item
     * @throws CodeException
419
     * @throws UserReportException
420
     */
421
    private function parseItem(array &$vars, $item) {
422
423

        $arr = explode(":", $item, 2);
424
425
426
        $key = isset($arr[0]) ? $arr[0] : '';
        $value = isset($arr[1]) ? $arr[1] : '';

427
428
429
430
431
432
433
        // Superclass
        if ($key === 'A' || $key === 'G') {
            $this->parseItem($vars, $value);
            return;
        }

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

437
438
        $keyName = $this->tableVarName[$key];

439
        // A few keys do not have necessarily a value: fake the definition by manual creating a value.
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
        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;
                default:
                    break;
            }
        }

456
        // Defaults
457
458
459
460
        if ($value === '' && isset($this->varsDefault[$keyName])) {
            $value = $this->varsDefault[$keyName];
        }

461
        //  Check for empty values. Respect: some keys are allowed to be empty.
462
        if ($value === '' && strpos('uENDHIS', $key) === false) {
463
464
465
466
467
468
469
470
471
472
473
474
475
476
            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);
        }
477

478
479
480
481
482
        // Call special function
        if (isset($this->callTable[$key])) {
            $call = $this->callTable[$key];
            $this->$call($vars, $keyName, $value);
        }
483
    }
484
485
486
487

    /**
     * Parse CSS Class Settings
     *
488
     * @param array $vars
489
490
     * @return    void
     */
491
    private function doCssClass(array &$vars) {
492
        $class = '';
493

494
        switch ($vars[NAME_LINK_CLASS]) {
495
            case 'n':
496
                $vars[NAME_LINK_CLASS] = '';
497
498
499
                break;
            case 'i':
            case 'e':
500
            $vars[NAME_LINK_CLASS] = $this->linkClassSelector[$vars[NAME_LINK_CLASS]];
501
502
                break;
            default:
503
                $vars[NAME_LINK_CLASS] = ($vars[NAME_LINK_CLASS] == '') ? $vars[NAME_LINK_CLASS_DEFAULT] : $vars[NAME_LINK_CLASS];
504
                break;
505
        }
506
507
508
509

        if ($vars[NAME_LINK_CLASS] === NO_CLASS) {
            $vars[NAME_LINK_CLASS] = '';
        }
510
    }
511
512

    /**
513
514
515
516
     * Create the HTML anchor.
     * - <a href="mailto:info@example.com" title=".." class="..">
     * - <a href="http://example.com" title=".." class="..">
     * - If $this->modeHash is set, create a hash (sip)
517
     *
518
     * @param array $vars
519
     * @return string
520
     * @throws UserReportException
521
     */
522
523
    private function doAnchor(array &$vars) {
        $attributes = '';
524
        // build URL
525
        $anchorTitle = '';
526

527
        // Link: URL
528
        if ($vars[NAME_URL] !== '') {
529

530
            if ($vars[NAME_HASH] === "1") {
531

532
533
                $paramArray = $this->sip->queryStringToSip(Support::concatUrlParam($vars[NAME_URL], $vars[NAME_URL_PARAM]), RETURN_ARRAY);
                $vars[NAME_URL] = $paramArray['_url'];
534
535
                if ($this->store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM) === 'yes') {

536
537
                    $vars[NAME_TOOL_TIP] .= PHP_EOL . PHP_EOL . OnArray::toString($paramArray, ' = ', PHP_EOL, "'");
                    $this->buildToolTip($vars, 'o', $vars[NAME_TOOL_TIP]);
538
                }
539

540
            } else {
541

542
                if ($vars[NAME_URL_PARAM] != '') {
543
                    $vars[NAME_URL] = Support::concatUrlParam($vars[NAME_URL], $vars[NAME_URL_PARAM]);
544
545
                }
            }
546
547
        }

548
        // Link: MAILTO
549
        if ($vars[NAME_MAIL] !== '') {
550

551
            // If there is no encryption: handle the mailto as an ordinary URL
552
553
554
            if ($vars[NAME_ENCRYPTION] === '0') {
                $vars[NAME_URL] = "mailto:" . $vars[NAME_MAIL];
                $vars[NAME_MAIL] = "";
555
            } else {
556
                throw new UserReportException ("Oops, sorry: encrypted mail not implemented ...", ERROR_NOT_IMPLEMENTED);
557
558
559
            }
        }

560
561
562
        if ($vars[NAME_GLYPH] !== '') {
            $vars[NAME_LINK_CLASS] .= ' btn btn-default ';

563
564
565
//            if ($vars[NAME_GLYPH_TITLE] !== '') {
//                $anchorTitle = $vars[NAME_GLYPH_TITLE];
//            }
566
567
        }

568
569
570
        $attributes .= Support::doAttribute('href', $vars[NAME_URL]);
        $attributes .= Support::doAttribute('class', $vars[NAME_LINK_CLASS]);
        $attributes .= Support::doAttribute('target', $vars[NAME_TARGET]);
571
572
//        $attributes .= Support::doAttribute('title', $anchorTitle);
        $attributes .= Support::doAttribute('title', $vars[NAME_TOOL_TIP]);
573

574
        if ($vars[NAME_QUESTION]) {
575
            $attributes .= Support::doAttribute('onclick', 'confirm(\'' . $vars[NAME_QUESTION] . '\')');
Carsten  Rose's avatar
Carsten Rose committed
576
        }
577

578
579
//        $anchor = '<a ' . $attributes . $vars[NAME_TOOL_TIP_JS][0] . '>';
        $anchor = '<a ' . $attributes . '>';
580

581
        return ($anchor);
582
    }
583

584
585
586
587
588
589
590
591
592
    //
//<a class="btn btn-default" href="index.php?id=2&s=56fbdd30a0cd2" title='comment'>
//   <span class='glyphicon glyphicon-plus'></span>
//</a>
//
//<a href="index.php?id=2&s=56fb7f7703692" class="internal" >
//  <img src="typo3conf/ext/qfq/Resources/Public/icons/edit.gif" title="Edit" >
//</a>

593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
    /**
     * Create a ToolTip: $toolTip[0] and $toolTip[1] have to inserted in HTML code accordingly.
     * $vars[NAME_TOOL_TIP_JS][0]: JS to show '$toolTip[1]'.
     * $vars[NAME_TOOL_TIP_JS][1]: '<span>...</span>' with the tooltip text.
     *
     * @param $vars
     * @param $key
     * @param $value
     */
    private function buildToolTip(&$vars, $key, $value) {
        static $count = 0;

        $toolTipIndex = 'tooltip.' . $GLOBALS["TSFE"]->currentRecord . '.' . ++$count;
        $vars[NAME_TOOL_TIP_JS] = array();

        // Expample: <img src="fileadmin/icons/bullet-gray.gif" onmouseover="document.getElementById('gm167979').style.
        // display='block';" onmouseout="document.getElementById('gm167979').style.display='none';" />
        $vars[NAME_TOOL_TIP_JS][0] = " onmouseover=\"document.getElementById('" . $toolTipIndex .
            "').style.display='block';\" onmouseout=\"document.getElementById('" . $toolTipIndex . "').style.display='none';\"";

        // Example: <span id="gm167979" style="display:none; position:absolute; border:solid 1px black; background-color:#F9F3D0;
        // padding:3px;">My pesonal tooltip</span>
        $vars[NAME_TOOL_TIP_JS][1] = '<span id="' . $toolTipIndex .
            '" style="display:none; position:absolute; border:solid 1px black; background-color:#F9F3D0; padding:3px;">' .
            $value . '</span>';

        return;
    }
621

622
623
624
    /**
     * Create Image HTML Tag
     *
625
626
     * @param array $vars
     * @return string
627
     */
628
    private function doHtmlImageGlyph(array $vars) {
629
        $tags = '';
630
        $html = '';
631
632

        // Build Image
633
        if ($vars[NAME_IMAGE] !== '') {
634
635
636
            $tags .= Support::doAttribute('alt', $vars[NAME_ALT_TEXT]);
            $tags .= Support::doAttribute('src', $vars[NAME_IMAGE]);
            $tags .= Support::doAttribute('title', $vars[NAME_IMAGE_TITLE]);
637
            $html .= '<img ' . $tags . '>';
638
639
        }

640
641
642
643
644
645
        if ($vars[NAME_GLYPH] !== '') {
            $tags = Support::doAttribute('class', 'glyphicon ' . $vars[NAME_GLYPH]);
            $html .= Support::wrapTag('<span ' . $tags . '>', '', false);
        }

        return $html;
646
    }
647
648
649
650
651
652
653
654
655
656
657
658
659
660

    /**
     *  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>';
     *
661
662
663
     * @param array $vars
     * @param bool|TRUE $href TRUE: create a '<a>',   false: just encrypt or show the email, no link.
     * @return string
664
     */
665
    private function encryptMailtoJS(array $vars, $href = TRUE) {
666
667

        // Split $mailto
668
        $tmp = $this->splitAndAddDelimter($vars[NAME_MAIL], "@");
669
670
671
672
673
674
675
676
677
678
679
680
        $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++;
            }
681
            $dw .= ' + "' . $vars[NAME_LINK_CLASS] . str_replace('"', '\\"', $vars[NAME_TOOL_TIP_JS][0]) . '>"';
682
683
684
685
686
687
688
            $closeDw = '"</a>")';
        } else {
            $dw = 'document.write(';
            $closeDw = ')';
        }

        // Wrap mailto around text
689
        if ($vars[NAME_MAIL] == $vars[NAME_TEXT]) {
690
691
692
693
694
695
696
            // 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
697
            $tt .= $dw . ' + "' . $vars[NAME_TEXT] . '" + ' . $closeDw . chr(10);
698
699
700
        }

        $tt .= '//--></script>';
701
        if ($href) $tt .= $vars[NAME_TOOL_TIP_JS][1];
702
703

        return ($tt);
704
    }
705
706
707
708
709
710
711
712
713
714

    /**
     * Split a string around the $delimiter.
     *
     * Append the delimiter to each part except the last one.
     *
     * @param $mailto
     * @param $delimiter
     * @return array
     */
715
716
    private function splitAndAddDelimter($mailto, $delimiter) {
        //TODO: Ich verstehe die Funktion nicht - funktioniert das hier wirklich?
717
718
719
720
721
722
723
724
725
726
727
728
        $value = '';

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

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

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

        return ($arr);
729
    }
730
731

    /**
732
733
     * Called by $this->callTable
     *
734
735
736
737
738
     * @param $vars
     * @param $key
     * @param $value
     */
    private function buildUrl(&$vars, $key, $value) {
739
        $vars[NAME_LINK_CLASS_DEFAULT] = $this->cssLinkClassExternal;
740
741
742
    }

    /**
743
744
     * Called by $this->callTable
     *
745
746
747
748
749
     * @param $vars
     * @param $key
     * @param $value
     */
    private function buildMail(&$vars, $key, $value) {
750
        $vars[NAME_LINK_CLASS_DEFAULT] = $this->cssLinkClassExternal;
751
        $vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS;
752
753
754
    }

    /**
755
756
     * Called by $this->callTable
     *
757
758
759
     * @param $vars
     * @param $key
     * @param $value
760
     * @throws UserReportException
761
762
763
     */
    private function buildPage(&$vars, $key, $value) {

764
765
766
        if ($vars[NAME_URL] != '') {
            throw new UserReportException ("Multiple definitions for key 'p'", ERROR_MULTIPLE_DEFINITION);
        }
767

768
769
770
        if (substr($value, 0, 3) !== 'id=') {
            $value = 'id=' . $value;
        }
771

772
773
        $vars[NAME_URL] = "?" . $value;
        $vars[NAME_LINK_CLASS_DEFAULT] = $this->cssLinkClassInternal;
774
775
776
    }

    /**
777
778
     * Called by $this->callTable
     *
779
780
781
782
783
     * @param $vars
     * @param $key
     * @param $value
     */
    private function buildPicture(&$vars, $key, $value) {
784
785
        $vars[NAME_ALT_TEXT] = "Grafic: " . $value;
        $vars[NAME_IMAGE_TITLE] = $value;
786
        $vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS;
787
788
789
    }

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

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

    /**
816
817
     * Called by $this->callTable
     *
818
819
820
821
822
     * @param $vars
     * @param $key
     * @param $value
     */
    private function buildDelete(&$vars, $key, $value) {
823
824
//        $vars[NAME_IMAGE] = PATH_ICONS . 'delete.gif';
//        $vars[NAME_IMAGE_TITLE] = "Delete";
825
        $vars[NAME_DELETE] = true;
826
827
828

        $vars[NAME_GLYPH] = GLYPH_ICON_DELETE;
        $vars[NAME_GLYPH_TITLE] = "Delete";
829
        $vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS;
830

831
832
833
834
835
        // Include Extjs library
        $this->utils->loadJSlib($this->fr_error);
    }

    /**
836
837
     * Called by $this->callTable
     *
838
839
840
841
842
     * @param $vars
     * @param $key
     * @param $value
     */
    private function buildEdit(&$vars, $key, $value) {
843
844
845
846
//        $vars[NAME_IMAGE] = PATH_ICONS . 'edit.gif';
//        $vars[NAME_IMAGE_TITLE] = "Edit";
        $vars[NAME_GLYPH] = GLYPH_ICON_EDIT;
        $vars[NAME_GLYPH_TITLE] = "Edit";
847
        $vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS;
848
849
850
    }

    /**
851
852
     * Called by $this->callTable
     *
853
854
855
856
857
     * @param $vars
     * @param $key
     * @param $value
     */
    private function buildHelp(&$vars, $key, $value) {
858
859
860
861
//        $vars[NAME_IMAGE] = PATH_ICONS . 'help.gif';
//        $vars[NAME_IMAGE_TITLE] = "Help";
        $vars[NAME_GLYPH] = GLYPH_ICON_HELP;
        $vars[NAME_GLYPH_TITLE] = "Help";
862
863
        $vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS;

864
865
866
    }

    /**
867
868
     * Called by $this->callTable
     *
869
870
871
872
873
     * @param $vars
     * @param $key
     * @param $value
     */
    private function buildInfo(&$vars, $key, $value) {
874
875
876
877
878
//        $vars[NAME_IMAGE] = PATH_ICONS . 'info.gif';
//        $vars[NAME_IMAGE_TITLE] = "Information";

        $vars[NAME_GLYPH] = GLYPH_ICON_INFO;
        $vars[NAME_GLYPH_TITLE] = "Information";
879
        $vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS;
880

881
882
883
    }

    /**
884
885
     * Called by $this->callTable
     *
886
887
888
889
890
     * @param $vars
     * @param $key
     * @param $value
     */
    private function buildNew(&$vars, $key, $value) {
891
892
893
894
895
//        $vars[NAME_IMAGE] = PATH_ICONS . 'new.gif';
//        $vars[NAME_IMAGE_TITLE] = "New";

        $vars[NAME_GLYPH] = GLYPH_ICON_NEW;
        $vars[NAME_GLYPH_TITLE] = "New";
896
        $vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS;
897

898
899
900
    }

    /**
901
902
     * Called by $this->callTable
     *
903
904
905
906
907
     * @param $vars
     * @param $key
     * @param $value
     */
    private function buildShow(&$vars, $key, $value) {
908
909
910
911
912
//        $vars[NAME_IMAGE] = PATH_ICONS . 'show.gif';
//        $vars[NAME_IMAGE_TITLE] = "Details";

        $vars[NAME_GLYPH] = GLYPH_ICON_SHOW;
        $vars[NAME_GLYPH_TITLE] = "Details";
913
        $vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS;
914

915
    }
916

917
}