Browse code

Finalize module and also provide content element

Benjamin Roth authored on10/01/2023 21:52:20
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,94 @@
1
+<?php
2
+
3
+/*
4
+ * This file is part of Contao.
5
+ *
6
+ * (c) Leo Feyer
7
+ *
8
+ * @license LGPL-3.0-or-later
9
+ */
10
+
11
+namespace vonRotenberg\ModalBundle\Model;
12
+
13
+use Contao\Date;
14
+use Contao\Model;
15
+use Contao\Model\Collection;
16
+
17
+/**
18
+ * Reads and writes image sizes
19
+ *
20
+ * @property string|integer      $id
21
+ * @property string|integer      $tstamp
22
+ * @property string              $title
23
+ * @property string              $modal_title
24
+ * @property string|integer      $delay
25
+ * @property string|boolean      $show_once
26
+ * @property string|integer      $start
27
+ * @property string|integer      $stop
28
+ *
29
+ * @method static ModalModel|null findById($id, array $opt=array())
30
+ * @method static ModalModel|null findByPk($id, array $opt=array())
31
+ * @method static ModalModel|null findOneBy($col, $val, array $opt=array())
32
+ * @method static ModalModel|null findOneByTstamp($val, array $opt=array())
33
+ * @method static ModalModel|null findOneByTitle($val, array $opt=array())
34
+ * @method static ModalModel|null findOneByModalTitle($val, array $opt=array())
35
+ * @method static ModalModel|null findOneByDelay($val, array $opt=array())
36
+ * @method static ModalModel|null findOneByShowOnce($val, array $opt=array())
37
+ * @method static ModalModel|null findOneByPublished($val, array $opt=array())
38
+ * @method static ModalModel|null findOneByStart($val, array $opt=array())
39
+ * @method static ModalModel|null findOneByStop($val, array $opt=array())
40
+ *
41
+ * @method static Collection|ModalModel[]|ModalModel|null findByTstamp($val, array $opt=array())
42
+ * @method static Collection|ModalModel[]|ModalModel|null findByTitle($val, array $opt=array())
43
+ * @method static Collection|ModalModel[]|ModalModel|null findByModalTitle($val, array $opt=array())
44
+ * @method static Collection|ModalModel[]|ModalModel|null findByDelay($val, array $opt=array())
45
+ * @method static Collection|ModalModel[]|ModalModel|null findByShowOnce($val, array $opt=array())
46
+ * @method static Collection|ModalModel[]|ModalModel|null findByPublished($val, array $opt=array())
47
+ * @method static Collection|ModalModel[]|ModalModel|null findByStart($val, array $opt=array())
48
+ * @method static Collection|ModalModel[]|ModalModel|null findByStop($val, array $opt=array())
49
+ * @method static Collection|ModalModel[]|ModalModel|null findMultipleByIds($val, array $opt=array())
50
+ * @method static Collection|ModalModel[]|ModalModel|null findBy($col, $val, array $opt=array())
51
+ * @method static Collection|ModalModel[]|ModalModel|null findAll(array $opt=array())
52
+ *
53
+ * @method static integer countById($id, array $opt=array())
54
+ * @method static integer countByTstamp($val, array $opt=array())
55
+ * @method static integer countByTitle($val, array $opt=array())
56
+ * @method static integer countByModalTitle($val, array $opt=array())
57
+ * @method static integer countByDelay($val, array $opt=array())
58
+ * @method static integer countByShowOnce($val, array $opt=array())
59
+ * @method static integer countByPublished($val, array $opt=array())
60
+ * @method static integer countByStart($val, array $opt=array())
61
+ * @method static integer countByStop($val, array $opt=array())
62
+ */
63
+class ModalModel extends Model
64
+{
65
+	/**
66
+	 * Table name
67
+	 * @var string
68
+	 */
69
+	protected static $strTable = 'tl_vr_modal';
70
+
71
+    /**
72
+     * Find a published modal by its ID
73
+     *
74
+     * @param integer $intId      The modal ID
75
+     * @param array   $arrOptions An optional options array
76
+     *
77
+     * @return ModalModel|null The model or null if there is no modal
78
+     */
79
+    public static function findPublishedById($intId, array $arrOptions=array())
80
+    {
81
+        $t = static::$strTable;
82
+        $arrColumns = array("$t.id=?");
83
+
84
+        if (!static::isPreviewMode($arrOptions))
85
+        {
86
+            $time = Date::floorToMinute();
87
+            $arrColumns[] = "$t.published='1' AND ($t.start='' OR $t.start<='$time') AND ($t.stop='' OR $t.stop>'$time')";
88
+        }
89
+
90
+        return static::findOneBy($arrColumns, $intId, $arrOptions);
91
+    }
92
+}
93
+
94
+class_alias(ModalModel::class, 'ModalModel');