Completed
Push — development ( 5025e7...b32421 )
by Torben
04:56
created

Banner::getDescription()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
ccs 2
cts 2
cp 1
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
namespace DERHANSEN\SfBanners\Domain\Model;
3
4
/*
5
 * This file is part of the TYPO3 CMS project.
6
 *
7
 * It is free software; you can redistribute it and/or modify it under
8
 * the terms of the GNU General Public License, either version 2
9
 * of the License, or any later version.
10
 *
11
 * For the full copyright and license information, please read the
12
 * LICENSE.txt file that was distributed with this source code.
13
 *
14
 * The TYPO3 project - inspiring people to share!
15
 */
16
17
use TYPO3\CMS\Core\Utility\GeneralUtility;
18
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
19
20
/**
21
 * Banner domain model
22
 *
23
 * @author Torben Hansen <[email protected]>
24
 */
25
class Banner extends AbstractEntity
26
{
27
28
    /**
29
     * Title
30
     *
31
     * @var string
32
     * @validate NotEmpty
33
     */
34
    protected $title;
35
36
    /**
37
     * Description
38
     *
39
     * @var string
40
     */
41
    protected $description;
42
43
    /**
44
     * Type
45
     *
46
     * @var integer
47
     * @validate NotEmpty
48
     */
49
    protected $type;
50
51
    /**
52
     * Category
53
     *
54
     * @lazy
55
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<DERHANSEN\SfBanners\Domain\Model\Category>
56
     */
57
    protected $category;
58
59
    /**
60
     * Image
61
     *
62
     * @var string
63
     */
64
    protected $image;
65
66
    /**
67
     * Margin top
68
     *
69
     * @var integer
70
     */
71
    protected $marginTop;
72
73
    /**
74
     * Margin right
75
     *
76
     * @var integer
77
     */
78
    protected $marginRight;
79
80
    /**
81
     * Margin bottom
82
     *
83
     * @var integer
84
     */
85
    protected $marginBottom;
86
87
    /**
88
     * Margin top
89
     *
90
     * @var integer
91
     */
92
    protected $marginLeft;
93
94
    /**
95
     * Alttext
96
     *
97
     * @var string
98
     */
99
    protected $alttext;
100
101
    /**
102
     * Link
103
     *
104
     * @var string
105
     */
106
    protected $link;
107
108
    /**
109
     * HTML
110
     *
111
     * @var string
112
     */
113
    protected $html;
114
115
    /**
116
     * Flash
117
     *
118
     * @var string
119
     */
120
    protected $flash;
121
122
    /**
123
     * Flash width
124
     *
125
     * @var integer
126
     */
127
    protected $flashWidth;
128
129
    /**
130
     * Flash height
131
     *
132
     * @var integer
133
     */
134
    protected $flashHeight;
135
136
    /**
137
     * Max impressions
138
     *
139
     * @var integer
140
     */
141
    protected $impressionsMax;
142
143
    /**
144
     * Max clicks
145
     *
146
     * @var integer
147
     */
148
    protected $clicksMax;
149
150
    /**
151
     * Total impressions
152
     *
153
     * @var integer
154
     */
155
    protected $impressions;
156
157
    /**
158
     * Total clicks
159
     *
160
     * @var integer
161
     */
162
    protected $clicks;
163
164
    /**
165
     * Do not display on pages
166
     * @lazy
167
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\DERHANSEN\SfBanners\Domain\Model\Page>
168
     */
169
    protected $excludepages;
170
171
    /**
172
     * Recursively use excludepages
173
     * @var bool
174
     */
175
    protected $recursive;
176
177
    /**
178
     * AllowScriptAccess for flash banners
179
     *
180
     * @var string
181
     */
182
    protected $flashAllowScriptAccess;
183
184
    /**
185
     * Wmode for flash banners
186
     *
187
     * @var string
188
     */
189
    protected $flashWmode;
190
191
    /**
192
     * __construct
193
     */
194 33
    public function __construct()
195
    {
196
        //Do not remove the next line: It would break the functionality
197 33
        $this->initStorageObjects();
198 33
    }
199
200
    /**
201
     * Initializes all ObjectStorage properties
202
     * Do not modify this method!
203
     * It will be rewritten on each save in the extension builder
204
     * You may modify the constructor of this class instead
205
     *
206
     * @return void
207
     */
208 33
    protected function initStorageObjects()
209
    {
210 33
        $this->category = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
211 33
        $this->excludepages = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
212 33
    }
213
214
    /**
215
     * Sets allowScriptAccess
216
     *
217
     * @param string $flashAllowScriptAccess FlashAllowScriptAccess
218
     * @return void
219
     */
220 2
    public function setFlashAllowScriptAccess($flashAllowScriptAccess)
221
    {
222 2
        $this->flashAllowScriptAccess = $flashAllowScriptAccess;
223 2
    }
224
225
    /**
226
     * Getter for allowScriptAccess
227
     *
228
     * @return string
229
     */
230 3
    public function getFlashAllowScriptAccess()
231
    {
232 3
        return $this->flashAllowScriptAccess;
233
    }
234
235
    /**
236
     * Sets Wmode
237
     *
238
     * @param string $flashWmode FlashWMode
239
     * @return void
240
     */
241 2
    public function setFlashWmode($flashWmode)
242
    {
243 2
        $this->flashWmode = $flashWmode;
244 2
    }
245
246
    /**
247
     * Getter for Wmode
248
     *
249
     * @return string
250
     */
251 3
    public function getFlashWmode()
252
    {
253 3
        return $this->flashWmode;
254
    }
255
256
    /**
257
     * Returns the title
258
     *
259
     * @return string $title
260
     */
261 1
    public function getTitle()
262
    {
263 1
        return $this->title;
264
    }
265
266
    /**
267
     * Sets the title
268
     *
269
     * @param string $title The title
270
     * @return void
271
     */
272 1
    public function setTitle($title)
273
    {
274 1
        $this->title = $title;
275 1
    }
276
277
    /**
278
     * Returns the description
279
     *
280
     * @return string $description
281
     */
282 1
    public function getDescription()
283
    {
284 1
        return $this->description;
285
    }
286
287
    /**
288
     * Sets the description
289
     *
290
     * @param string $description The description
291
     * @return void
292
     */
293 1
    public function setDescription($description)
294
    {
295 1
        $this->description = $description;
296 1
    }
297
298
    /**
299
     * Returns the type
300
     *
301
     * @return integer $type
302
     */
303 1
    public function getType()
304
    {
305 1
        return $this->type;
306
    }
307
308
    /**
309
     * Sets the type
310
     *
311
     * @param integer $type The type
312
     * @return void
313
     */
314 1
    public function setType($type)
315
    {
316 1
        $this->type = $type;
317 1
    }
318
319
    /**
320
     * Adds a category
321
     *
322
     * @param \DERHANSEN\SfBanners\Domain\Model\Category $category
323
     * @return void
324
     */
325 1
    public function addCategory(\DERHANSEN\SfBanners\Domain\Model\Category $category)
326
    {
327 1
        $this->category->attach($category);
328 1
    }
329
330
    /**
331
     * Removes a category
332
     *
333
     * @param \DERHANSEN\SfBanners\Domain\Model\Category $categoryToRemove
334
     * @return void
335
     */
336 1
    public function removeCategory(\DERHANSEN\SfBanners\Domain\Model\Category $categoryToRemove)
337
    {
338 1
        $this->category->detach($categoryToRemove);
339 1
    }
340
341
    /**
342
     * Returns the category
343
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $category
344
     */
345 1
    public function getCategory()
346
    {
347 1
        return $this->category;
348
    }
349
350
    /**
351
     * Sets the category
352
     *
353
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $category One or multiple categories
354
     * @return void
355
     */
356 3
    public function setCategory($category)
357
    {
358 3
        $this->category = $category;
359 3
    }
360
361
    /**
362
     * Setter for alttext
363
     *
364
     * @param string $alttext Alttext
365
     * @return void
366
     */
367 1
    public function setAlttext($alttext)
368
    {
369 1
        $this->alttext = $alttext;
370 1
    }
371
372
    /**
373
     * Getter for alttext
374
     *
375
     * @return string
376
     */
377 1
    public function getAlttext()
378
    {
379 1
        return $this->alttext;
380
    }
381
382
    /**
383
     * Setter for clicks
384
     *
385
     * @param int $clicks Clicks
386
     * @return void
387
     */
388 1
    public function setClicks($clicks)
389
    {
390 1
        $this->clicks = $clicks;
391 1
    }
392
393
    /**
394
     * getter for clicks
395
     *
396
     * @return int
397
     */
398 1
    public function getClicks()
399
    {
400 1
        return $this->clicks;
401
    }
402
403
    /**
404
     * Setter for clicksmax
405
     *
406
     * @param int $clicksMax MaxClicks
407
     * @return void
408
     */
409 1
    public function setClicksMax($clicksMax)
410
    {
411 1
        $this->clicksMax = $clicksMax;
412 1
    }
413
414
    /**
415
     * Getter for clicksmax
416
     *
417
     * @return int
418
     */
419 1
    public function getClicksMax()
420
    {
421 1
        return $this->clicksMax;
422
    }
423
424
    /**
425
     * Adds a page
426
     *
427
     * @param \DERHANSEN\SfBanners\Domain\Model\Page $page
428
     * @return void
429
     */
430 1
    public function addExcludepages(\DERHANSEN\SfBanners\Domain\Model\Page $page)
431
    {
432 1
        $this->excludepages->attach($page);
433 1
    }
434
435
    /**
436
     * Removes a page
437
     *
438
     * @param \DERHANSEN\SfBanners\Domain\Model\page $pageToRemove
439
     * @return void
440
     */
441 1
    public function removeExcludepages(\DERHANSEN\SfBanners\Domain\Model\page $pageToRemove)
442
    {
443 1
        $this->excludepages->detach($pageToRemove);
444 1
    }
445
446
    /**
447
     * Setter for excludepages
448
     *
449
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $excludepages Excludepages
450
     * @return void
451
     */
452 3
    public function setExcludepages($excludepages)
453
    {
454 3
        $this->excludepages = $excludepages;
455 3
    }
456
457
    /**
458
     * Getter for excludepages
459
     *
460
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
461
     */
462 1
    public function getExcludepages()
463
    {
464 1
        return $this->excludepages;
465
    }
466
467
    /**
468
     * Setter for flash
469
     *
470
     * @param string $flash Flashfile
471
     * @return void
472
     */
473 1
    public function setFlash($flash)
474
    {
475 1
        $this->flash = $flash;
476 1
    }
477
478
    /**
479
     * Getter for flash
480
     *
481
     * @return string
482
     */
483 1
    public function getFlash()
484
    {
485 1
        return $this->flash;
486
    }
487
488
    /**
489
     * Setter for flashheight
490
     *
491
     * @param int $flashHeight Flashheight
492
     * @return void
493
     */
494 1
    public function setFlashHeight($flashHeight)
495
    {
496 1
        $this->flashHeight = $flashHeight;
497 1
    }
498
499
    /**
500
     * Getter for flash
501
     *
502
     * @return int
503
     */
504 1
    public function getFlashHeight()
505
    {
506 1
        return $this->flashHeight;
507
    }
508
509
    /**
510
     * Setter for flashwidth
511
     *
512
     * @param int $flashWidth Flashwidth
513
     * @return void
514
     */
515 1
    public function setFlashWidth($flashWidth)
516
    {
517 1
        $this->flashWidth = $flashWidth;
518 1
    }
519
520
    /**
521
     * Getter for flashwidth
522
     *
523
     * @return int
524
     */
525 1
    public function getFlashWidth()
526
    {
527 1
        return $this->flashWidth;
528
    }
529
530
    /**
531
     * Setter for HTML
532
     *
533
     * @param string $html HTML
534
     * @return void
535
     */
536 1
    public function setHtml($html)
537
    {
538 1
        $this->html = $html;
539 1
    }
540
541
    /**
542
     * Getter for HTML
543
     *
544
     * @return string
545
     */
546 1
    public function getHtml()
547
    {
548 1
        return $this->html;
549
    }
550
551
    /**
552
     * Setter for Image
553
     *
554
     * @param string $image Image
555
     * @return void
556
     */
557 1
    public function setImage($image)
558
    {
559 1
        $this->image = $image;
560 1
    }
561
562
    /**
563
     * Getter for image
564
     *
565
     * @return string
566
     */
567 1
    public function getImage()
568
    {
569 1
        return $this->image;
570
    }
571
572
    /**
573
     * Setter for impressions
574
     *
575
     * @param int $impressions Impressions
576
     * @return void
577
     */
578 1
    public function setImpressions($impressions)
579
    {
580 1
        $this->impressions = $impressions;
581 1
    }
582
583
    /**
584
     * Getter for impressions
585
     *
586
     * @return int
587
     */
588 1
    public function getImpressions()
589
    {
590 1
        return $this->impressions;
591
    }
592
593
    /**
594
     * Setter for max impressions
595
     *
596
     * @param int $impressionsMax Max impressions
597
     * @return void
598
     */
599 1
    public function setImpressionsMax($impressionsMax)
600
    {
601 1
        $this->impressionsMax = $impressionsMax;
602 1
    }
603
604
    /**
605
     * Getter for max impressions
606
     *
607
     * @return int
608
     */
609 1
    public function getImpressionsMax()
610
    {
611 1
        return $this->impressionsMax;
612
    }
613
614
    /**
615
     * Setter for link
616
     *
617
     * @param string $link Link
618
     * @return void
619
     */
620 1
    public function setLink($link)
621
    {
622 1
        $this->link = $link;
623 1
    }
624
625
    /**
626
     * Getter for link
627
     *
628
     * @return string
629
     */
630 1
    public function getLink()
631
    {
632 1
        return $this->link;
633
    }
634
635
    /**
636
     * Setter for margin bottom
637
     *
638
     * @param int $marginBottom Margin bottom
639
     * @return void
640
     */
641 1
    public function setMarginBottom($marginBottom)
642
    {
643 1
        $this->marginBottom = $marginBottom;
644 1
    }
645
646
    /**
647
     * Getter for margin bottom
648
     *
649
     * @return int
650
     */
651 1
    public function getMarginBottom()
652
    {
653 1
        return $this->marginBottom;
654
    }
655
656
    /**
657
     * Setter for margin left
658
     *
659
     * @param int $marginLeft Margin left
660
     * @return void
661
     */
662 1
    public function setMarginLeft($marginLeft)
663
    {
664 1
        $this->marginLeft = $marginLeft;
665 1
    }
666
667
    /**
668
     * Getter for margin left
669
     *
670
     * @return int
671
     */
672 1
    public function getMarginLeft()
673
    {
674 1
        return $this->marginLeft;
675
    }
676
677
    /**
678
     * Setter for margin right
679
     *
680
     * @param int $marginRight Margin right
681
     * @return void
682
     */
683 1
    public function setMarginRight($marginRight)
684
    {
685 1
        $this->marginRight = $marginRight;
686 1
    }
687
688
    /**
689
     * Getter for margin right
690
     *
691
     * @return int
692
     */
693 1
    public function getMarginRight()
694
    {
695 1
        return $this->marginRight;
696
    }
697
698
    /**
699
     * Setter for margin top
700
     *
701
     * @param int $marginTop Margin top
702
     * @return void
703
     */
704 1
    public function setMarginTop($marginTop)
705
    {
706 1
        $this->marginTop = $marginTop;
707 1
    }
708
709
    /**
710
     * Getter for margin top
711
     *
712
     * @return int
713
     */
714 1
    public function getMarginTop()
715
    {
716 1
        return $this->marginTop;
717
    }
718
719
    /**
720
     * Sets the recursive flag
721
     *
722
     * @param boolean $recursive
723
     * @return void
724
     */
725 1
    public function setRecursive($recursive)
726
    {
727 1
        $this->recursive = $recursive;
728 1
    }
729
730
    /**
731
     * Returns the recursive flag
732
     *
733
     * @return boolean
734
     */
735 1
    public function getRecursive()
736
    {
737 1
        return $this->recursive;
738
    }
739
740
    /**
741
     * Updates the Impressions by 1
742
     *
743
     * @return void
744
     */
745
    public function increaseImpressions()
746
    {
747
        $this->impressions += 1;
748
    }
749
750
    /**
751
     * Updates the Impressions by 1
752
     *
753
     * @return void
754
     */
755
    public function increaseClicks()
756
    {
757
        $this->clicks += 1;
758
    }
759
760
    /**
761
     * Returns the uri of the link
762
     *
763
     * @return mixed
764
     */
765
    public function getLinkUrl()
766
    {
767
        $cObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
768
        return $cObj->getTypoLink_URL($this->link);
769
    }
770
771
    /**
772
     * Returns the target of the link
773
     *
774
     * @return string
775
     */
776
    public function getLinkTarget()
777
    {
778
        $linkArray = GeneralUtility::trimExplode(' ', $this->link);
779
        $ret = '';
780
        if (count($linkArray) > 1) {
781
            $ret = $linkArray[1];
782
        }
783
        return $ret;
784
    }
785
}
786