Completed
Pull Request — master (#157)
by
unknown
25:59
created

Banner::getIncludeRecursive()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
ccs 0
cts 0
cp 0
cc 1
eloc 2
nc 1
nop 0
crap 2
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
     * Do not display on pages
173
     * @lazy
174
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\DERHANSEN\SfBanners\Domain\Model\Page>
175
     */
176
    protected $includepages;
177
178
    /**
179
     * Recursively use excludepages
180
     * @var bool
181
     */
182
    protected $recursive;
183
184
    /**
185
     * Recursively use includepages
186
     * @var bool
187
     */
188
    protected $includeRecursive;
189
190
    /**
191
     * AllowScriptAccess for flash banners
192
     *
193
     * @var string
194
     */
195
    protected $flashAllowScriptAccess;
196
197
    /**
198
     * Wmode for flash banners
199
     *
200
     * @var string
201
     */
202
    protected $flashWmode;
203
204
    /**
205
     * __construct
206
     */
207
    public function __construct()
208
    {
209
        //Do not remove the next line: It would break the functionality
210
        $this->initStorageObjects();
211
    }
212
213
    /**
214
     * Initializes all ObjectStorage properties
215
     * Do not modify this method!
216
     * It will be rewritten on each save in the extension builder
217
     * You may modify the constructor of this class instead
218
     *
219
     * @return void
220
     */
221
    protected function initStorageObjects()
222
    {
223
        $this->category = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
224
        $this->excludepages = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
225
        $this->includepages = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
226
    }
227
228
    /**
229
     * Sets allowScriptAccess
230
     *
231
     * @param string $flashAllowScriptAccess FlashAllowScriptAccess
232
     * @return void
233
     */
234
    public function setFlashAllowScriptAccess($flashAllowScriptAccess)
235
    {
236
        $this->flashAllowScriptAccess = $flashAllowScriptAccess;
237
    }
238
239
    /**
240
     * Getter for allowScriptAccess
241
     *
242
     * @return string
243
     */
244
    public function getFlashAllowScriptAccess()
245
    {
246
        return $this->flashAllowScriptAccess;
247
    }
248
249
    /**
250
     * Sets Wmode
251
     *
252
     * @param string $flashWmode FlashWMode
253
     * @return void
254
     */
255
    public function setFlashWmode($flashWmode)
256
    {
257
        $this->flashWmode = $flashWmode;
258
    }
259
260
    /**
261
     * Getter for Wmode
262
     *
263
     * @return string
264
     */
265
    public function getFlashWmode()
266
    {
267
        return $this->flashWmode;
268
    }
269
270
    /**
271
     * Returns the title
272
     *
273
     * @return string $title
274
     */
275
    public function getTitle()
276
    {
277
        return $this->title;
278
    }
279
280
    /**
281
     * Sets the title
282
     *
283
     * @param string $title The title
284
     * @return void
285
     */
286
    public function setTitle($title)
287
    {
288
        $this->title = $title;
289
    }
290
291
    /**
292
     * Returns the description
293
     *
294
     * @return string $description
295
     */
296
    public function getDescription()
297
    {
298
        return $this->description;
299
    }
300
301
    /**
302
     * Sets the description
303
     *
304
     * @param string $description The description
305
     * @return void
306
     */
307
    public function setDescription($description)
308
    {
309
        $this->description = $description;
310
    }
311
312
    /**
313
     * Returns the type
314
     *
315
     * @return integer $type
316
     */
317
    public function getType()
318
    {
319
        return $this->type;
320
    }
321
322
    /**
323
     * Sets the type
324
     *
325
     * @param integer $type The type
326
     * @return void
327
     */
328
    public function setType($type)
329
    {
330
        $this->type = $type;
331
    }
332
333
    /**
334
     * Adds a category
335
     *
336
     * @param \DERHANSEN\SfBanners\Domain\Model\Category $category
337
     * @return void
338
     */
339
    public function addCategory(\DERHANSEN\SfBanners\Domain\Model\Category $category)
340
    {
341
        $this->category->attach($category);
342
    }
343
344
    /**
345
     * Removes a category
346
     *
347
     * @param \DERHANSEN\SfBanners\Domain\Model\Category $categoryToRemove
348
     * @return void
349
     */
350
    public function removeCategory(\DERHANSEN\SfBanners\Domain\Model\Category $categoryToRemove)
351
    {
352
        $this->category->detach($categoryToRemove);
353
    }
354
355
    /**
356
     * Returns the category
357
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $category
358
     */
359
    public function getCategory()
360
    {
361
        return $this->category;
362
    }
363
364
    /**
365
     * Sets the category
366
     *
367
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $category One or multiple categories
368
     * @return void
369
     */
370
    public function setCategory($category)
371
    {
372
        $this->category = $category;
373
    }
374
375
    /**
376
     * Setter for alttext
377
     *
378
     * @param string $alttext Alttext
379
     * @return void
380
     */
381
    public function setAlttext($alttext)
382
    {
383
        $this->alttext = $alttext;
384
    }
385
386
    /**
387
     * Getter for alttext
388
     *
389
     * @return string
390
     */
391
    public function getAlttext()
392
    {
393
        return $this->alttext;
394
    }
395
396
    /**
397
     * Setter for clicks
398 2
     *
399
     * @param int $clicks Clicks
400 2
     * @return void
401
     */
402
    public function setClicks($clicks)
403
    {
404
        $this->clicks = $clicks;
405
    }
406
407
    /**
408
     * getter for clicks
409
     *
410
     * @return int
411
     */
412
    public function getClicks()
413
    {
414
        return $this->clicks;
415
    }
416
417
    /**
418
     * Setter for clicksmax
419 8
     *
420
     * @param int $clicksMax MaxClicks
421 8
     * @return void
422
     */
423
    public function setClicksMax($clicksMax)
424
    {
425
        $this->clicksMax = $clicksMax;
426
    }
427
428
    /**
429
     * Getter for clicksmax
430
     *
431
     * @return int
432
     */
433
    public function getClicksMax()
434
    {
435
        return $this->clicksMax;
436
    }
437
438
    /**
439
     * Adds a page
440
     *
441
     * @param \DERHANSEN\SfBanners\Domain\Model\Page $page
442
     * @return void
443
     */
444
    public function addExcludepages(\DERHANSEN\SfBanners\Domain\Model\Page $page)
445
    {
446
        $this->excludepages->attach($page);
447
    }
448
449
    /**
450
     * Removes a page
451
     *
452
     * @param \DERHANSEN\SfBanners\Domain\Model\page $pageToRemove
453
     * @return void
454
     */
455
    public function removeExcludepages(\DERHANSEN\SfBanners\Domain\Model\page $pageToRemove)
456
    {
457
        $this->excludepages->detach($pageToRemove);
458
    }
459
460
    /**
461
     * Setter for excludepages
462 8
     *
463
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $excludepages Excludepages
464 8
     * @return void
465
     */
466
    public function setExcludepages($excludepages)
467
    {
468
        $this->excludepages = $excludepages;
469
    }
470
471
    /**
472
     * Getter for excludepages
473
     *
474
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
475
     */
476
    public function getExcludepages()
477
    {
478
        return $this->excludepages;
479
    }
480
481
482
    /**
483
     * Adds a page
484
     *
485
     * @param \DERHANSEN\SfBanners\Domain\Model\Page $page
486
     * @return void
487
     */
488
    public function addIncludepages(\DERHANSEN\SfBanners\Domain\Model\Page $page)
489
    {
490
        $this->includepages->attach($page);
491
    }
492
493
    /**
494
     * Removes a page
495
     *
496
     * @param \DERHANSEN\SfBanners\Domain\Model\page $pageToRemove
497
     * @return void
498
     */
499
    public function removeIncludepages(\DERHANSEN\SfBanners\Domain\Model\page $pageToRemove)
500
    {
501
        $this->includepages->detach($pageToRemove);
502
    }
503
504
    /**
505
     * Setter for includepages
506
     *
507
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $includepages Includepages
508
     * @return void
509
     */
510
    public function setIncludepages($includepages)
511
    {
512
        $this->includepages = $includepages;
513
    }
514
515
    /**
516
     * Getter for includepages
517
     *
518
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
519
     */
520
    public function getIncludepages()
521
    {
522
        return $this->includepages;
523
    }
524
525
    /**
526
     * Setter for flash
527
     *
528
     * @param string $flash Flashfile
529
     * @return void
530
     */
531
    public function setFlash($flash)
532
    {
533
        $this->flash = $flash;
534
    }
535
536
    /**
537
     * Getter for flash
538
     *
539
     * @return string
540
     */
541
    public function getFlash()
542
    {
543
        return $this->flash;
544
    }
545
546
    /**
547
     * Setter for flashheight
548
     *
549
     * @param int $flashHeight Flashheight
550
     * @return void
551
     */
552
    public function setFlashHeight($flashHeight)
553
    {
554
        $this->flashHeight = $flashHeight;
555
    }
556
557
    /**
558
     * Getter for flash
559
     *
560
     * @return int
561
     */
562
    public function getFlashHeight()
563
    {
564
        return $this->flashHeight;
565
    }
566
567
    /**
568
     * Setter for flashwidth
569
     *
570
     * @param int $flashWidth Flashwidth
571
     * @return void
572
     */
573
    public function setFlashWidth($flashWidth)
574
    {
575
        $this->flashWidth = $flashWidth;
576
    }
577
578
    /**
579
     * Getter for flashwidth
580
     *
581
     * @return int
582
     */
583
    public function getFlashWidth()
584
    {
585
        return $this->flashWidth;
586
    }
587
588 2
    /**
589
     * Setter for HTML
590 2
     *
591
     * @param string $html HTML
592
     * @return void
593
     */
594
    public function setHtml($html)
595
    {
596
        $this->html = $html;
597
    }
598
599
    /**
600
     * Getter for HTML
601
     *
602
     * @return string
603
     */
604
    public function getHtml()
605
    {
606
        return $this->html;
607
    }
608
609 8
    /**
610
     * Setter for Image
611 8
     *
612
     * @param string $image Image
613
     * @return void
614
     */
615
    public function setImage($image)
616
    {
617
        $this->image = $image;
618
    }
619
620
    /**
621
     * Getter for image
622
     *
623
     * @return string
624
     */
625
    public function getImage()
626
    {
627
        return $this->image;
628
    }
629
630
    /**
631
     * Setter for impressions
632
     *
633
     * @param int $impressions Impressions
634
     * @return void
635
     */
636
    public function setImpressions($impressions)
637
    {
638
        $this->impressions = $impressions;
639
    }
640
641
    /**
642
     * Getter for impressions
643
     *
644
     * @return int
645
     */
646
    public function getImpressions()
647
    {
648
        return $this->impressions;
649
    }
650
651
    /**
652
     * Setter for max impressions
653
     *
654
     * @param int $impressionsMax Max impressions
655
     * @return void
656
     */
657
    public function setImpressionsMax($impressionsMax)
658
    {
659
        $this->impressionsMax = $impressionsMax;
660
    }
661
662
    /**
663
     * Getter for max impressions
664
     *
665
     * @return int
666
     */
667
    public function getImpressionsMax()
668
    {
669
        return $this->impressionsMax;
670
    }
671
672
    /**
673
     * Setter for link
674
     *
675
     * @param string $link Link
676
     * @return void
677
     */
678
    public function setLink($link)
679
    {
680
        $this->link = $link;
681
    }
682
683
    /**
684
     * Getter for link
685
     *
686
     * @return string
687
     */
688
    public function getLink()
689
    {
690
        return $this->link;
691
    }
692
693
    /**
694
     * Setter for margin bottom
695
     *
696
     * @param int $marginBottom Margin bottom
697
     * @return void
698
     */
699
    public function setMarginBottom($marginBottom)
700
    {
701
        $this->marginBottom = $marginBottom;
702
    }
703
704
    /**
705
     * Getter for margin bottom
706
     *
707
     * @return int
708
     */
709
    public function getMarginBottom()
710
    {
711
        return $this->marginBottom;
712
    }
713
714
    /**
715
     * Setter for margin left
716
     *
717
     * @param int $marginLeft Margin left
718
     * @return void
719
     */
720
    public function setMarginLeft($marginLeft)
721
    {
722
        $this->marginLeft = $marginLeft;
723
    }
724
725
    /**
726
     * Getter for margin left
727
     *
728
     * @return int
729
     */
730
    public function getMarginLeft()
731
    {
732
        return $this->marginLeft;
733
    }
734
735 2
    /**
736
     * Setter for margin right
737 2
     *
738
     * @param int $marginRight Margin right
739
     * @return void
740
     */
741
    public function setMarginRight($marginRight)
742
    {
743
        $this->marginRight = $marginRight;
744
    }
745
746
    /**
747
     * Getter for margin right
748
     *
749
     * @return int
750
     */
751
    public function getMarginRight()
752
    {
753
        return $this->marginRight;
754
    }
755
756
    /**
757
     * Setter for margin top
758
     *
759
     * @param int $marginTop Margin top
760
     * @return void
761
     */
762
    public function setMarginTop($marginTop)
763
    {
764
        $this->marginTop = $marginTop;
765
    }
766
767
    /**
768
     * Getter for margin top
769
     *
770
     * @return int
771
     */
772
    public function getMarginTop()
773
    {
774
        return $this->marginTop;
775
    }
776
777
    /**
778
     * Sets the recursive flag
779
     *
780
     * @param boolean $recursive
781
     * @return void
782
     */
783
    public function setRecursive($recursive)
784
    {
785
        $this->recursive = $recursive;
786
    }
787
788
    /**
789
     * Returns the recursive flag
790
     *
791
     * @return boolean
792
     */
793
    public function getRecursive()
794
    {
795
        return $this->recursive;
796
    }
797
798
    /**
799
     * Sets the include recursive flag
800
     *
801
     * @param boolean $includeRecursive
802
     * @return void
803
     */
804
    public function setIncludeRecursive($includeRecursive)
805
    {
806
        $this->includeRecursive = $includeRecursive;
807
    }
808
809
    /**
810
     * Returns the include recursive flag
811
     *
812
     * @return boolean
813
     */
814
    public function getIncludeRecursive()
815
    {
816
        return $this->includeRecursive;
817
    }
818
819
    /**
820
     * Updates the Impressions by 1
821
     *
822
     * @return void
823
     */
824
    public function increaseImpressions()
825
    {
826
        $this->impressions += 1;
827
    }
828
829
    /**
830
     * Updates the Impressions by 1
831
     *
832
     * @return void
833
     */
834
    public function increaseClicks()
835
    {
836
        $this->clicks += 1;
837
    }
838
839
    /**
840
     * Returns the uri of the link
841
     *
842
     * @return mixed
843
     */
844
    public function getLinkUrl()
845
    {
846
        $cObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
847
        return $cObj->getTypoLink_URL($this->link);
848
    }
849
850
    /**
851
     * Returns the target of the link
852
     *
853
     * @return string
854
     */
855
    public function getLinkTarget()
856
    {
857
        $linkArray = GeneralUtility::trimExplode(' ', $this->link);
858
        $ret = '';
859
        if (count($linkArray) > 1) {
860
            $ret = $linkArray[1];
861
        }
862
        return $ret;
863
    }
864
}
865