1 <?php
2 /* --------------------------------------------------------------
3 CategorySettings.inc.php 2016-02-01
4 Gambio GmbH
5 http://www.gambio.de
6 Copyright (c) 2016 Gambio GmbH
7 Released under the GNU General Public License (Version 2)
8 [http://www.gnu.org/licenses/gpl-2.0.html]
9 --------------------------------------------------------------
10 */
11
12 MainFactory::load_class('CategorySettingsInterface');
13
14
15 /**
16 * Class CategorySettings
17 *
18 * This Class stores some settings regarding display and visibility mode of category related data and is used within a
19 * CategoryInterface.
20 *
21 * @category System
22 * @package Category
23 * @subpackage Entities
24 */
25 class CategorySettings implements CategorySettingsInterface
26 {
27 /**
28 * Current template which is used for category listing.
29 *
30 * @var string The current category listing template.
31 */
32 protected $categoryListingTemplate = '';
33
34
35 /**
36 * Current template which is used for product listing.
37 *
38 * @var string
39 */
40 protected $productListingTemplate = '';
41
42
43 /**
44 * Current column by which the products are sorted.
45 *
46 * @var string
47 */
48 protected $productSortColumn = '';
49
50
51 /**
52 * Current direction which the products are sorted in.
53 *
54 * @var string
55 */
56 protected $productSortDirection = '';
57
58
59 /**
60 * Is category/product in the sitemap?
61 *
62 * @var bool
63 */
64 protected $sitemapEntry = false;
65
66
67 /**
68 * Priority of the element in the sitemap.
69 *
70 * @var string
71 */
72 protected $sitemapPriority = '';
73
74
75 /**
76 * Change frequency of the element in the sitemap.
77 *
78 * @var string
79 */
80 protected $sitemapChangeFreq = '';
81
82
83 /**
84 * Should attributes be displayed?
85 *
86 * @var bool
87 */
88 protected $attributes = false;
89
90
91 /**
92 * Should graduated prices be displayed?
93 *
94 * @var bool
95 */
96 protected $graduatedPrices = false;
97
98
99 /**
100 * Should quantities be displayed?
101 *
102 * @var bool
103 */
104 protected $quantityInput = false;
105
106
107 /**
108 * Should quantity info be displayed?
109 *
110 * @var bool
111 */
112 protected $stock = false;
113
114
115 /**
116 * Should subcategories be displayed?
117 *
118 * @var bool
119 */
120 protected $subcategories = false;
121
122
123 /**
124 * Should subcategory images be displayed?
125 *
126 * @var bool
127 */
128 protected $subcategoryImages = false;
129
130
131 /**
132 * Should subcategory names be displayed?
133 *
134 * @var bool
135 */
136 protected $subcategoryNames = false;
137
138
139 /**
140 * Should subcategory products be displayed?
141 *
142 * @var bool
143 */
144 protected $subcategoryProducts = false;
145
146
147 /**
148 * Should default view mode be "tiled"?
149 *
150 * @var bool
151 */
152 protected $viewModeTiled = false;
153
154
155 /**
156 * Array of permitted customer status.
157 *
158 * @var array
159 */
160 protected $permittedCustomerStatus = array();
161
162
163 /**
164 * Returns the current category listing template.
165 *
166 * @return string
167 */
168 public function getCategoryListingTemplate()
169 {
170 return $this->categoryListingTemplate;
171 }
172
173
174 /**
175 * Sets the current category listing template.
176 *
177 * @param StringType $filename Category listing template.
178 *
179 * @return CategorySettings Same instance for chained method calls.
180 */
181 public function setCategoryListingTemplate(StringType $filename)
182 {
183 $this->categoryListingTemplate = $filename->asString();
184
185 return $this;
186 }
187
188
189 /**
190 * Returns the current product listing template.
191 *
192 * @return string
193 */
194 public function getProductListingTemplate()
195 {
196 return $this->productListingTemplate;
197 }
198
199
200 /**
201 * Sets the current product listing template.
202 *
203 * @param StringType $filename Product listing template.
204 *
205 * @return CategorySettings Same instance for chained method calls.
206 */
207 public function setProductListingTemplate(StringType $filename)
208 {
209 $this->productListingTemplate = $filename->asString();
210
211 return $this;
212 }
213
214
215 /**
216 * Returns the column by which the products are currently sorted.
217 *
218 * @return string
219 */
220 public function getProductSortColumn()
221 {
222 return $this->productSortColumn;
223 }
224
225
226 /**
227 * Sets the column by which the products are currently sorted.
228 *
229 * @param StringType $column Column by which the products should be sorted.
230 *
231 * @return CategorySettings Same instance for chained method calls.
232 */
233 public function setProductSortColumn(StringType $column)
234 {
235 $this->productSortColumn = $column->asString();
236
237 return $this;
238 }
239
240
241 /**
242 * Returns the direction which the products are currently sorted in.
243 *
244 * @return string
245 */
246 public function getProductSortDirection()
247 {
248 return $this->productSortDirection;
249 }
250
251
252 /**
253 * Sets the direction which the products are currently sorted in.
254 *
255 * @param StringType $direction Direction which the products should be sorted in.
256 *
257 * @return CategorySettings Same instance for chained method calls.
258 */
259 public function setProductSortDirection(StringType $direction)
260 {
261 $this->productSortDirection = $direction->asString();
262
263 return $this;
264 }
265
266
267 /**
268 * Checks if category/product is part of the sitemap.
269 *
270 * @return bool
271 */
272 public function isSitemapEntry()
273 {
274 return $this->sitemapEntry;
275 }
276
277
278 /**
279 * Sets whether the category/product is part of the sitemap.
280 *
281 * @param BoolType $status Value whether the category/product is part of the sitemap.
282 *
283 * @return CategorySettings Same instance for chained method calls.
284 */
285 public function setSitemapEntry(BoolType $status)
286 {
287 $this->sitemapEntry = $status->asBool();
288
289 return $this;
290 }
291
292
293 /**
294 * Returns the sitemap priority of the element.
295 *
296 * @return string
297 */
298 public function getSitemapPriority()
299 {
300 return $this->sitemapPriority;
301 }
302
303
304 /**
305 * Sets the sitemap priority of the element.
306 *
307 * @param StringType $priority Element's sitemap priority.
308 *
309 * @return CategorySettings Same instance for chained method calls.
310 */
311 public function setSitemapPriority(StringType $priority)
312 {
313 $this->sitemapPriority = $priority->asString();
314
315 return $this;
316 }
317
318
319 /**
320 * Returns the change frequency of the element.
321 *
322 * @return string
323 */
324 public function getSitemapChangeFreq()
325 {
326 return $this->sitemapChangeFreq;
327 }
328
329
330 /**
331 * Sets the change frequency of the element.
332 *
333 * @param StringType $freq Change frequency value.
334 *
335 * @return CategorySettings Same instance for chained method calls.
336 */
337 public function setSitemapChangeFreq(StringType $freq)
338 {
339 $this->sitemapChangeFreq = $freq->asString();
340
341 return $this;
342 }
343
344
345 /**
346 * Checks if attributes should be displayed or not.
347 *
348 * @return bool
349 */
350 public function showAttributes()
351 {
352 return $this->attributes;
353 }
354
355
356 /**
357 * Sets whether the attributes should be displayed or not.
358 *
359 * @param BoolType $status Should attributes be displayed?
360 *
361 * @return CategorySettings Same instance for chained method calls.
362 */
363 public function setShowAttributes(BoolType $status)
364 {
365 $this->attributes = $status->asBool();
366
367 return $this;
368 }
369
370
371 /**
372 * Checks if graduated prices should be displayed or not.
373 *
374 * @return bool
375 */
376 public function showGraduatedPrices()
377 {
378 return $this->graduatedPrices;
379 }
380
381
382 /**
383 * Sets whether graduated prices should be displayed or not.
384 *
385 * @param BoolType $status Show graduated prices?
386 *
387 * @return CategorySettings Same instance for chained method calls.
388 */
389 public function setShowGraduatedPrices(BoolType $status)
390 {
391 $this->graduatedPrices = $status->asBool();
392
393 return $this;
394 }
395
396
397 /**
398 * Checks if a quantity input should be displayed in product forms or not.
399 *
400 * @return bool
401 */
402 public function showQuantityInput()
403 {
404 return $this->quantityInput;
405 }
406
407
408 /**
409 * Sets whether a quantity input should be displayed in product forms or not.
410 *
411 * @param BoolType $status Show quantity input?
412 *
413 * @return CategorySettings Same instance for chained method calls.
414 */
415 public function setShowQuantityInput(BoolType $status)
416 {
417 $this->quantityInput = $status->asBool();
418
419 return $this;
420 }
421
422
423 /**
424 * Checks if the stock should be displayed or not.
425 *
426 * @return bool
427 */
428 public function showStock()
429 {
430 return $this->stock;
431 }
432
433
434 /**
435 * Sets whether the stock should be displayed or not.
436 *
437 * @param BoolType $status Show quantity info?
438 *
439 * @return CategorySettings Same instance for chained method calls.
440 */
441 public function setShowStock(BoolType $status)
442 {
443 $this->stock = $status->asBool();
444
445 return $this;
446 }
447
448
449 /**
450 * Checks if subcategories should be displayed or not.
451 *
452 * @return bool
453 */
454 public function showSubcategories()
455 {
456 return $this->subcategories;
457 }
458
459
460 /**
461 * Sets whether subcategories should be displayed or not.
462 *
463 * @param BoolType $status Show subcategories?
464 *
465 * @return CategorySettings Same instance for chained method calls.
466 */
467 public function setShowSubcategories(BoolType $status)
468 {
469 $this->subcategories = $status->asBool();
470
471 return $this;
472 }
473
474
475 /**
476 * Checks if subcategory images should be displayed or not.
477 *
478 * @return bool
479 */
480 public function showSubcategoryImages()
481 {
482 return $this->subcategoryImages;
483 }
484
485
486 /**
487 * Sets whether subcategory images should be displayed or not.
488 *
489 * @param BoolType $status Show subcategory images?
490 *
491 * @return CategorySettings Same instance for chained method calls.
492 */
493 public function setShowSubcategoryImages(BoolType $status)
494 {
495 $this->subcategoryImages = $status->asBool();
496
497 return $this;
498 }
499
500
501 /**
502 * Checks if subcategory names should be displayed or not.
503 *
504 * @return bool
505 */
506 public function showSubcategoryNames()
507 {
508 return $this->subcategoryNames;
509 }
510
511
512 /**
513 * Sets whether subcategory names should be displayed or not.
514 *
515 * @param BoolType $status Show subcategory names?
516 *
517 * @return CategorySettings Same instance for chained method calls.
518 */
519 public function setShowSubcategoryNames(BoolType $status)
520 {
521 $this->subcategoryNames = $status->asBool();
522
523 return $this;
524 }
525
526
527 /**
528 * Checks if subcategory products should be displayed or not.
529 *
530 * @return bool
531 */
532 public function showSubcategoryProducts()
533 {
534 return $this->subcategoryProducts;
535 }
536
537
538 /**
539 * Sets whether subcategory products should be displayed or not.
540 *
541 * @param BoolType $status Show subcategory products?
542 *
543 * @return CategorySettings Same instance for chained method calls.
544 */
545 public function setShowSubcategoryProducts(BoolType $status)
546 {
547 $this->subcategoryProducts = $status->asBool();
548
549 return $this;
550 }
551
552
553 /**
554 * Checks if default view mode should be tiled or not.
555 *
556 * @return bool
557 */
558 public function isDefaultViewModeTiled()
559 {
560 return $this->viewModeTiled;
561 }
562
563
564 /**
565 * Sets whether default view mode should be tiled or not.
566 *
567 * @param BoolType $status Is tiled the default view mode?
568 *
569 * @return CategorySettings Same instance for chained method calls.
570 */
571 public function setDefaultViewModeTiled(BoolType $status)
572 {
573 $this->viewModeTiled = $status->asBool();
574
575 return $this;
576 }
577
578
579 /**
580 * Checks if it is a permitted customer status or not.
581 *
582 * @param IdType $customerStatusId Customer status ID.
583 *
584 * @return bool
585 */
586 public function isPermittedCustomerStatus(IdType $customerStatusId)
587 {
588 return (array_key_exists($customerStatusId->asInt(),
589 $this->permittedCustomerStatus)) ? $this->permittedCustomerStatus[$customerStatusId->asInt()] : false;
590 }
591
592
593 /**
594 * Sets whether a customer status is permitted or not.
595 *
596 * @param IdType $customerStatusId Customer status ID.
597 * @param BoolType $permitted Is permitted?
598 *
599 * @return CategorySettings Same instance for chained method calls.
600 */
601 public function setPermittedCustomerStatus(IdType $customerStatusId, BoolType $permitted)
602 {
603 $this->permittedCustomerStatus[$customerStatusId->asInt()] = $permitted->asBool();
604
605 return $this;
606 }
607 }