PluginProbe
Yatra – Travel Booking & Tour Operator Software / 2.1.16
Yatra – Travel Booking & Tour Operator Software v2.1.16
3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 2.0.10 All 83 releases
yatra / core / Abstracts / TourParent.php

TourParent.php in Yatra – Travel Booking & Tour Operator Software 2.1.16, at core/Abstracts/TourParent.php

292 lines 6.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Yatra\Core\Abstracts;
4
5 use Yatra\Core\Data\TourData;
6
7 if (!defined('ABSPATH')) {
8 exit;
9 }
10
11 abstract class TourParent extends YatraData
12 {
13
14 /**
15 * This is the name of this object type.
16 *
17 * @var string
18 */
19 protected $object_type = 'tour';
20
21 /**
22 * Cache group.
23 *
24 * @var string
25 */
26 protected $cache_group = 'tours';
27
28 /**
29 * Stores tour main data.
30 *
31 * @var array
32 */
33 protected $data = array(
34 'name' => '',
35 'status' => '',
36 'type' => '',
37 'can_book' => true,
38 'is_featured' => false,
39 'is_fixed_departure' => false,
40 'external_url' => '',
41 'book_now_text' => '',
42 );
43
44
45 public function __construct($tour = 0)
46 {
47 parent::__construct($tour);
48 if (is_numeric($tour) && $tour > 0) {
49 $this->set_id($tour);
50 } elseif ($tour instanceof self) {
51 $this->set_id(absint($tour->get_id()));
52 } elseif (!empty($tour->ID)) {
53 $this->set_id(absint($tour->ID));
54 }
55
56
57 $data_store = new TourData();
58 if ($this->get_id() > 0) {
59 $data_store->read($this);
60 }
61 }
62
63 /**
64 * Get tour type.
65 *
66 * @param string $context What the value is for. Valid values are view and edit.
67 * @return string
68 * @since 2.1.12
69 */
70 public function get_type()
71 {
72 return $this->get_prop('type');
73 }
74
75 /**
76 * Get tour name.
77 *
78 * @param string $context What the value is for. Valid values are view and edit.
79 * @return string
80 * @since 2.1.12
81 */
82 public function get_name($context = 'view')
83 {
84 return $this->get_prop('name', $context);
85 }
86
87 /**
88 * Get tour status.
89 *
90 * @param string $context What the value is for. Valid values are view and edit.
91 * @return string
92 * @since 2.1.12
93 */
94 public function get_status($context = 'view')
95 {
96 return $this->get_prop('status', $context);
97 }
98
99 /**
100 * Get tour can book.
101 *
102 * @param string $context What the value is for. Valid values are view and edit.
103 * @return string
104 * @since 2.1.12
105 */
106 public function get_can_book($context = 'view')
107 {
108 return $this->get_prop('can_book', $context) && !self::is_type('external');
109 }
110
111 public function get_can_show_calendar($context = 'view')
112 {
113 return $this->get_prop('can_book', $context) || self::is_type('external');
114 }
115
116 /*
117 |--------------------------------------------------------------------------
118 | Setters
119 |--------------------------------------------------------------------------
120 |
121 | Functions for setting tour data. These should not update anything in the
122 | database itself and should only change what is stored in the class
123 | object.
124 */
125
126 /**
127 * Set tour name.
128 *
129 * @param string $name tour name.
130 * @since 2.1.12
131 */
132 public function set_name($name)
133 {
134 $this->set_prop('name', $name);
135 }
136
137 /**
138 * Set tour name.
139 *
140 * @param string $status Tour Status
141 * @since 2.1.12
142 */
143 public function set_status($status)
144 {
145 $this->set_prop('status', $status);
146 }
147
148 /**
149 * Set tour type.
150 *
151 * @param string $type Tour Type
152 * @since 2.1.12
153 */
154 public function set_type($type)
155 {
156 $this->set_prop('type', $type);
157 }
158
159 /**
160 * Set tour type.
161 *
162 * @param string $type Tour Can Book
163 * @since 2.1.12
164 */
165 public function set_can_book($type)
166 {
167 $this->set_prop('can_book', $type);
168 }
169
170 /**
171 * Set tour type.
172 *
173 * @param string $type Tour Is Featured
174 * @since 2.1.12
175 */
176 public function set_is_featured($is_featured)
177 {
178 $this->set_prop('is_featured', $is_featured);
179 }
180
181 /**
182 * Set tour type.
183 *
184 * @param string $type Tour is_fixed_departure
185 * @since 2.1.12
186 */
187 public function set_is_fixed_departure($is_fixed_departure)
188 {
189 $this->set_prop('is_fixed_departure', $is_fixed_departure);
190 }
191
192 /**
193 * Set external url
194 *
195 * @param string $external_url external url
196 * @since 2.1.12
197 */
198 public function set_external_url($external_url)
199 {
200 $this->set_prop('external_url', $external_url);
201 }
202
203 /**
204 * Set book now button text
205 *
206 * @param string $book_now_text book now text
207 * @since 2.1.12
208 */
209 public function set_book_now_text($book_now_text)
210 {
211 $this->set_prop('book_now_text', $book_now_text);
212 }
213
214 /*
215 |--------------------------------------------------------------------------
216 | Other Methods
217 |--------------------------------------------------------------------------
218 */
219
220
221 /**
222 * Returns whether or not the product post exists.
223 *
224 * @return bool
225 */
226 public function exists()
227 {
228 return false !== $this->get_status();
229 }
230
231 /**
232 * Checks the tour type.
233 *
234 *
235 * @param string|array $type Array or string of types.
236 * @return bool
237 */
238 public function is_type($type)
239 {
240 return ($this->get_type() === $type || (is_array($type) && in_array($this->get_type(), $type, true)));
241 }
242
243
244 /**
245 * Returns whether or not the product is featured.
246 *
247 * @return bool
248 */
249 public function is_featured()
250 {
251 return true === $this->get_prop('is_featured');
252 }
253
254 /**
255 * Returns whether or not the product is featured.
256 *
257 * @return bool
258 */
259 public function is_fixed_departure()
260 {
261 return true === $this->get_prop('is_fixed_departure');
262 }
263
264
265
266 /*
267 |--------------------------------------------------------------------------
268 | Non-CRUD Getters
269 |--------------------------------------------------------------------------
270 */
271
272 /**
273 * Get the tour's title. For tours this is the tour name.
274 *
275 * @return string
276 */
277 public function get_title()
278 {
279 return apply_filters('yatra_tour_title', $this->get_name(), $this);
280 }
281
282 /**
283 * tour permalink.
284 *
285 * @return string
286 */
287 public function get_permalink()
288 {
289 return get_permalink($this->get_id());
290 }
291 }
292