-
Notifications
You must be signed in to change notification settings - Fork 0
/
sprishop.php
executable file
·1803 lines (1531 loc) · 68.5 KB
/
sprishop.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
# Bugs:
#!# Specials in the front page list don't show if their target table has a title__JOIN...
#!# Items marked as visible='N' should not necessarily generate a 404
#!# Images need to be denied, as the generator can be bypassed; consider a mod_rewrite rule which will deal with that automatically
# Future developments:
#!# Nightly flagging by e-mail of items out of stock
#!# Pagination and search needed
# Online shop application
class sprishop extends frontControllerApplication
{
# Function to assign defaults additional to the general application defaults
public function defaults ()
{
# Specify available arguments as defaults or as NULL (to represent a required argument)
$defaults = array (
'applicationName' => 'Museum Shop',
'hostname' => 'localhost',
'database' => 'sprishop',
'table' => 'shop',
'div' => 'sprishop',
'administrators' => true,
'useEditing' => true,
'apiUsername' => true, // No username
'sectionsImages' => '/_sections/',
'imageGenerationStub' => '/images/generator',
'showPublisherLinks' => true,
'imageResizeTo' => 200,
'tabUlClass' => 'tabsflat',
'enableShoppingCart' => 'No',
'enablePaymentWorkflow' => true, // When cart enabled
'useTemplating' => true, // Currently only used by shopping cart; has to be enabled earlier to enable editing UI
);
# Return the defaults
return $defaults;
}
# Function to assign supported actions
public function actions ()
{
# Define available tasks
$actions = array (
'home' => array (
'description' => false,
'url' => '',
'icon' => 'house',
'tab' => 'Home',
'droplist' => true,
),
'ordering' => array (
'description' => false,
'url' => 'ordering/',
'tab' => 'How to order',
'droplist' => true,
),
'listing' => array (
'description' => false,
'url' => '%1/',
'usetab' => 'home',
'droplist' => true,
),
'basket' => array (
'description' => 'Basket',
'tab' => 'Basket',
'icon' => 'basket',
'url' => 'basket/',
'enableIf' => $this->enableShoppingCart,
),
'checkout' => array (
'description' => 'Checkout',
'usetab' => 'basket',
'url' => 'checkout/',
'enableIf' => $this->enableShoppingCart,
),
'callback' => array (
'description' => false,
'usetab' => 'basket',
'url' => 'callback/',
'enableIf' => $this->enableShoppingCart,
'export' => true,
),
'orders' => array (
'description' => false,
'tab' => 'Orders',
'icon' => 'wand',
'url' => 'orders/',
'administrator' => true,
'enableIf' => $this->enableShoppingCart,
),
'stocklist' => array (
'description' => 'Stock list',
'parent' => 'admin',
'subtab' => 'Stock list',
'icon' => 'application_view_list',
'url' => 'stocklist.html',
'administrator' => true,
),
);
# Return the actions
return $actions;
}
# Database structure definition
public function databaseStructure ()
{
# Define the SQL
$sql = "
CREATE TABLE `administrators` (
`username` varchar(255) PRIMARY KEY NOT NULL COMMENT 'Username',
`active` enum('','Yes','No') NOT NULL DEFAULT 'Yes' COMMENT 'Currently active?',
`privilege` enum('Administrator','Restricted administrator') NOT NULL DEFAULT 'Administrator' COMMENT 'Administrator level',
`state` varchar(255) NULL COMMENT 'Headings expanded'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='System administrators';
CREATE TABLE `settings` (
`id` int(11) PRIMARY KEY NOT NULL COMMENT 'Automatic key (ignored)',
`feedbackRecipient` varchar(255) NOT NULL COMMENT 'Feedback recipient e-mail',
`introductionHtml` text NOT NULL COMMENT 'Introductory text',
`orderingHtml` text NOT NULL COMMENT 'Ordering page',
`enableShoppingCart` ENUM('No','Admins only','Yes') NOT NULL DEFAULT 'No' COMMENT 'Enable shopping cart?',
`shoppingCartPaymentUrl` VARCHAR(255) NULL COMMENT 'Shopping cart payment URL',
`shoppingCartSharedSecret` VARCHAR(255) NULL COMMENT 'Shopping cart shared secret',
`shoppingCartClientId` VARCHAR(255) NULL COMMENT 'Shopping cart client ID',
`shoppingCartPathwayId` VARCHAR(255) NULL COMMENT 'Shopping cart pathway ID',
`shoppingCartDepartmentId` VARCHAR(255) NULL COMMENT 'Shopping cart department ID',
`shoppingCartPayoptionCode` VARCHAR(255) NULL COMMENT 'Shopping cart pay option code',
`shoppingCartOrderPrefix` VARCHAR(255) NULL COMMENT 'Shopping cart order prefix',
`shoppingCartVatCode` VARCHAR(255) NULL COMMENT 'Shopping cart VAT code',
`shoppingCartOrderDescription` VARCHAR(255) NULL COMMENT 'Shopping cart order description (use %s for ID)'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Settings';
CREATE TABLE `books` (
`id` int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
`grouping__JOIN__sprishop___booksSubtypes__reserved` int(11) DEFAULT NULL COMMENT 'Grouping',
`authors` VARCHAR(255) NOT NULL COMMENT 'Author(s)',
`title` varchar(255) NOT NULL,
`pricePerUnit` float(5,2) NOT NULL DEFAULT '0.00',
`priceIncludesVat` enum('N','Y') NOT NULL DEFAULT 'N',
`photographFilename` varchar(255) DEFAULT NULL,
`stockAvailable` int(10) UNSIGNED NOT NULL DEFAULT '0',
`stockIdealLevel` int(10) UNSIGNED DEFAULT NULL,
`stockMinimumLevel` int(10) UNSIGNED DEFAULT NULL,
`description` text NOT NULL,
`descriptionLong` text,
`visible` enum('N','Y') NOT NULL DEFAULT 'Y',
`publisher__JOIN__sprishop___publishers__reserved` int(11) DEFAULT NULL,
`publicationDate` int(4) NOT NULL DEFAULT '0',
`isbn` varchar(255) DEFAULT NULL,
`pages` int(11) DEFAULT NULL,
`binding` enum('Hardback','Paperback') NOT NULL DEFAULT 'Hardback',
`edition` varchar(255) DEFAULT NULL,
`childrens` enum('N','Y') NOT NULL DEFAULT 'N',
`externalPurchaseUrl` VARCHAR(255) NULL COMMENT 'External purchasing link'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `cards` (
`id` int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
`pricePerUnit` float(5,2) NOT NULL DEFAULT '0.00',
`priceIncludesVat` enum('N','Y') NOT NULL DEFAULT 'Y',
`photographFilename` varchar(255) DEFAULT NULL,
`stockAvailable` int(10) UNSIGNED NOT NULL DEFAULT '0',
`stockIdealLevel` int(10) UNSIGNED DEFAULT NULL,
`stockMinimumLevel` int(10) UNSIGNED DEFAULT NULL,
`description` text NOT NULL,
`descriptionLong` text,
`visible` enum('N','Y') NOT NULL DEFAULT 'Y',
`type__JOIN__sprishop___cardTypes__reserved` int(11) DEFAULT NULL,
`sizeWidthInCm` int(10) UNSIGNED NOT NULL DEFAULT '0',
`sizeHeightInCm` int(10) UNSIGNED NOT NULL DEFAULT '0',
`message` varchar(255) NOT NULL DEFAULT 'Blank',
`colour` enum('Colour','Black & white','Unknown') NOT NULL DEFAULT 'Colour',
`numberPerPack` int(10) UNSIGNED NOT NULL DEFAULT '0',
`externalPurchaseUrl` VARCHAR(255) NULL COMMENT 'External purchasing link'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `clothing` (
`id` int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT COMMENT '#',
`title__JOIN__sprishop___clothingTypes__reserved` int(11) NOT NULL COMMENT 'Title',
`pricePerUnit` float(5,2) NOT NULL DEFAULT '0.00' COMMENT 'Price per unit',
`priceIncludesVat` enum('N','Y') NOT NULL DEFAULT 'Y' COMMENT 'Price includes VAT?',
`stockAvailable` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Stock available',
`stockIdealLevel` int(10) UNSIGNED DEFAULT NULL COMMENT 'Stock ideal level',
`stockMinimumLevel` int(10) UNSIGNED DEFAULT NULL COMMENT 'Stock minimum level',
`visible` enum('N','Y') NOT NULL DEFAULT 'Y' COMMENT 'Visible?',
`size__JOIN__sprishop___sizes__reserved` int(11) DEFAULT NULL COMMENT 'Size',
`colour__JOIN__sprishop___colours__reserved` varchar(255) DEFAULT NULL COMMENT 'Colour',
`material__JOIN__sprishop___materials__reserved` int(11) DEFAULT NULL COMMENT 'Material',
`externalPurchaseUrl` VARCHAR(255) NULL COMMENT 'External purchasing link'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `collectibles` (
`id` int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
`pricePerUnit` float(5,2) NOT NULL,
`priceIncludesVat` enum('N','Y') NOT NULL DEFAULT 'Y',
`photographFilename` varchar(255) DEFAULT NULL,
`stockAvailable` int(10) UNSIGNED NOT NULL DEFAULT '0',
`stockIdealLevel` int(10) UNSIGNED DEFAULT NULL,
`stockMinimumLevel` int(10) UNSIGNED DEFAULT NULL,
`description` text NOT NULL,
`descriptionLong` text,
`visible` enum('N','Y') NOT NULL DEFAULT 'Y',
`type__JOIN__sprishop___jewelleryTypes__reserved` int(11) DEFAULT NULL,
`sizeInCm` varchar(255) DEFAULT NULL,
`externalPurchaseUrl` VARCHAR(255) NULL COMMENT 'External purchasing link'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `jewellery` (
`id` int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
`pricePerUnit` float(5,2) NOT NULL,
`priceIncludesVat` enum('N','Y') NOT NULL DEFAULT 'Y',
`photographFilename` varchar(255) DEFAULT NULL,
`stockAvailable` int(10) UNSIGNED NOT NULL DEFAULT '0',
`stockIdealLevel` int(10) UNSIGNED DEFAULT NULL,
`stockMinimumLevel` int(10) UNSIGNED DEFAULT NULL,
`description` text NOT NULL,
`descriptionLong` text,
`visible` enum('N','Y') NOT NULL DEFAULT 'Y',
`type__JOIN__sprishop___jewelleryTypes__reserved` int(11) DEFAULT NULL,
`sizeInCm` varchar(255) DEFAULT NULL,
`externalPurchaseUrl` VARCHAR(255) NULL COMMENT 'External purchasing link'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `maps` (
`id` int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
`pricePerUnit` float(5,2) NOT NULL DEFAULT '0.00',
`priceIncludesVat` enum('N','Y') NOT NULL DEFAULT 'N',
`photographFilename` varchar(255) DEFAULT NULL,
`stockAvailable` int(10) UNSIGNED NOT NULL DEFAULT '0',
`stockIdealLevel` int(10) UNSIGNED DEFAULT NULL,
`stockMinimumLevel` int(10) UNSIGNED DEFAULT NULL,
`description` text NOT NULL,
`descriptionLong` text,
`visible` enum('N','Y') NOT NULL DEFAULT 'Y',
`publisher__JOIN__sprishop___publishers__reserved` int(11) DEFAULT NULL,
`scaleAs1To` int(10) UNSIGNED NOT NULL DEFAULT '0',
`mapDate` date DEFAULT NULL,
`publicationDate` date NOT NULL,
`isbn` varchar(255) DEFAULT NULL,
`sizeFoldedHeightInCm` DECIMAL(5,1) UNSIGNED NULL DEFAULT NULL,
`sizeFoldedWidthInCm` DECIMAL(5,1) UNSIGNED NULL DEFAULT NULL,
`sizeUnfoldedHeightInCm` DECIMAL(5,1) UNSIGNED NULL DEFAULT NULL,
`sizeUnfoldedWidthInCm` DECIMAL(5,1) UNSIGNED NULL DEFAULT NULL,
`externalPurchaseUrl` VARCHAR(255) NULL COMMENT 'External purchasing link'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `mugs` (
`id` int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
`pricePerUnit` float(5,2) NOT NULL DEFAULT '0.00',
`priceIncludesVat` enum('N','Y') NOT NULL DEFAULT 'Y',
`photographFilename` varchar(255) DEFAULT NULL,
`stockAvailable` int(10) UNSIGNED NOT NULL DEFAULT '0',
`stockIdealLevel` int(10) UNSIGNED DEFAULT NULL,
`stockMinimumLevel` int(10) UNSIGNED DEFAULT NULL,
`description` text NOT NULL,
`descriptionLong` text,
`visible` enum('N','Y') NOT NULL DEFAULT 'Y',
`externalPurchaseUrl` VARCHAR(255) NULL COMMENT 'External purchasing link'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `multimedia` (
`id` int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
`pricePerUnit` float(5,2) NOT NULL DEFAULT '0.00',
`priceIncludesVat` enum('N','Y') NOT NULL DEFAULT 'Y',
`photographFilename` varchar(255) DEFAULT NULL,
`stockAvailable` int(10) UNSIGNED NOT NULL DEFAULT '0',
`stockIdealLevel` int(10) UNSIGNED DEFAULT NULL,
`stockMinimumLevel` int(10) UNSIGNED DEFAULT NULL,
`description` text NOT NULL,
`descriptionLong` text,
`visible` enum('N','Y') NOT NULL DEFAULT 'Y',
`format__JOIN__sprishop___multimediaTypes__reserved` int(11) DEFAULT NULL,
`colour` enum('Colour','Black & white','Not applicable','Unknown') NOT NULL DEFAULT 'Colour',
`publisher__JOIN__sprishop___publishers__reserved` int(11) NOT NULL,
`performer` varchar(255) DEFAULT NULL,
`producer` varchar(255) DEFAULT NULL,
`productionDate` date DEFAULT NULL,
`publicationDate` date DEFAULT NULL,
`lengthMinutes` int(10) UNSIGNED NOT NULL DEFAULT '0',
`technicalDetails` text,
`isbn` varchar(255) DEFAULT NULL,
`externalPurchaseUrl` VARCHAR(255) NULL COMMENT 'External purchasing link'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `posters` (
`id` int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
`pricePerUnit` float(5,2) NOT NULL DEFAULT '0.00',
`priceIncludesVat` enum('N','Y') NOT NULL DEFAULT 'Y',
`photographFilename` varchar(255) DEFAULT NULL,
`stockAvailable` int(10) UNSIGNED NOT NULL DEFAULT '0',
`stockIdealLevel` int(10) UNSIGNED DEFAULT NULL,
`stockMinimumLevel` int(10) UNSIGNED DEFAULT NULL,
`description` text NOT NULL,
`descriptionLong` text,
`visible` enum('N','Y') NOT NULL DEFAULT 'Y',
`artist` varchar(255) DEFAULT NULL,
`type` enum('Poster','Picture','Photograph','Facsimile reproduction','Calendar','Black frame','Black ash frame') NOT NULL DEFAULT 'Poster',
`colour` enum('Colour','Black & white','Unknown') NOT NULL DEFAULT 'Colour',
`sizeWidthInCm` int(10) UNSIGNED NOT NULL DEFAULT '0',
`sizeHeightInCm` int(10) UNSIGNED NOT NULL DEFAULT '0',
`publisher` varchar(255) DEFAULT NULL,
`dateCreated` varchar(255) DEFAULT NULL,
`externalPurchaseUrl` VARCHAR(255) NULL COMMENT 'External purchasing link'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `stamps` (
`id` int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
`pricePerUnit` float(5,2) NOT NULL DEFAULT '0.00',
`priceIncludesVat` enum('N','Y') NOT NULL DEFAULT 'Y',
`photographFilename` varchar(255) DEFAULT NULL,
`stockAvailable` int(10) UNSIGNED NOT NULL DEFAULT '0',
`stockIdealLevel` int(10) UNSIGNED DEFAULT NULL,
`stockMinimumLevel` int(10) UNSIGNED DEFAULT NULL,
`description` text NOT NULL,
`descriptionLong` text,
`visible` enum('N','Y') NOT NULL DEFAULT 'Y',
`externalPurchaseUrl` VARCHAR(255) NULL COMMENT 'External purchasing link'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `stationery` (
`id` int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
`pricePerUnit` float(5,2) NOT NULL DEFAULT '0.00',
`priceIncludesVat` enum('N','Y') NOT NULL DEFAULT 'Y',
`photographFilename` varchar(255) DEFAULT NULL,
`stockAvailable` int(10) UNSIGNED NOT NULL DEFAULT '0',
`stockIdealLevel` int(10) UNSIGNED DEFAULT NULL,
`stockMinimumLevel` int(10) UNSIGNED DEFAULT NULL,
`description` text NOT NULL,
`descriptionLong` text,
`visible` enum('N','Y') NOT NULL DEFAULT 'Y',
`externalPurchaseUrl` VARCHAR(255) NULL COMMENT 'External purchasing link'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `toys` (
`id` int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
`pricePerUnit` float(5,2) NOT NULL DEFAULT '0.00',
`priceIncludesVat` enum('N','Y') NOT NULL DEFAULT 'Y',
`photographFilename` varchar(255) DEFAULT NULL,
`stockAvailable` int(10) UNSIGNED NOT NULL DEFAULT '0',
`stockIdealLevel` int(10) UNSIGNED DEFAULT NULL,
`stockMinimumLevel` int(10) UNSIGNED DEFAULT NULL,
`description` text NOT NULL,
`descriptionLong` text,
`visible` enum('N','Y') NOT NULL DEFAULT 'Y',
`heightInCm` int(10) UNSIGNED NOT NULL DEFAULT '0',
`relatedInstitution` varchar(255) DEFAULT NULL,
`safety` text,
`material` text,
`externalPurchaseUrl` VARCHAR(255) NULL COMMENT 'External purchasing link'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `_booksSubtypes` (
`id` int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT COMMENT 'Automatic key',
`subtypeName` varchar(255) NOT NULL COMMENT 'Name of book subtype',
`subtypeUrlSlug` varchar(191) NOT NULL COMMENT 'URL key for this subtype',
`featured__JOIN__sprishop__books__reserved` int(11) NOT NULL COMMENT 'Featured item',
UNIQUE KEY `subtypeUrlSlug` (`subtypeUrlSlug`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Book subtypes';
CREATE TABLE `_cardTypes` (
`id` int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `_clothingTypes` (
`id` int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT COMMENT '#',
`photographFilename` varchar(85) DEFAULT NULL COMMENT 'Photo',
`title` varchar(85) NOT NULL DEFAULT '' COMMENT 'Title',
`description` text NOT NULL COMMENT 'Description',
`descriptionLong` text COMMENT 'Long description'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `_colours` (
`hexCode` varchar(6) PRIMARY KEY NOT NULL,
`commonName` varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `_jewelleryTypes` (
`id` int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `_materials` (
`id` int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `_multimediaTypes` (
`id` int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `_publishers` (
`id` int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`url` varchar(255) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `_sizes` (
`id` int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `__announcement` (
`id` int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT COMMENT 'Unique key',
`announcementText` varchar(255) NOT NULL COMMENT 'Announcement text',
`startDate` date NOT NULL,
`endDate` date NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Announcement';
CREATE TABLE `__featured` (
`id` int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
`section__JOIN__sprishop____sectionData__reserved` varchar(255) NOT NULL,
`itemnumber` int(10) UNSIGNED NOT NULL DEFAULT '0',
`priority` tinyint(3) UNSIGNED NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Featured items';
CREATE TABLE `__sectionData` (
`id` varchar(85) PRIMARY KEY NOT NULL DEFAULT '',
`title` varchar(255) NOT NULL COMMENT 'Title (on front page)',
`singular` varchar(85) NOT NULL DEFAULT '',
`plural` varchar(85) NOT NULL DEFAULT '',
`hide` tinyint DEFAULT NULL COMMENT 'Hide?'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='* Product categories';
CREATE TABLE `__themes` (
`id` int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT COMMENT 'Automatic key',
`theme__JOIN__sprishop____themeTypes__reserved` varchar(85) NOT NULL COMMENT 'Theme',
`type__JOIN__sprishop____sectionData__reserved` varchar(64) NOT NULL COMMENT 'Section',
`number` int(11) NOT NULL COMMENT 'Item number in section table'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Items to be added to thematic groupings';
CREATE TABLE `__themeTypes` (
`id` varchar(85) PRIMARY KEY NOT NULL,
`title` varchar(255) NOT NULL COMMENT 'Name',
`singular` varchar(85) NOT NULL,
`plural` varchar(85) NOT NULL,
`description` text,
`enabled` ENUM('Yes','No') NOT NULL DEFAULT 'Yes' COMMENT 'Enabled?'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Available themes';
CREATE TABLE `__variationHeadings` (
`columnName` varchar(191) PRIMARY KEY NOT NULL,
`englishNameOrNull` varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Variation headings';
;";
if ($this->enableShoppingCart) {
$sql .= "
CREATE TABLE `shoppingcart` (
`id` int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT COMMENT 'Unique key',
`session` varchar(255) NOT NULL COMMENT 'User session number',
`provider` varchar(255) NOT NULL COMMENT 'Shop product provider',
`item` varchar(255) NOT NULL COMMENT 'Item number',
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Automatic timestamp',
`url` varchar(255) NOT NULL COMMENT 'URL of item',
`name` varchar(255) NOT NULL COMMENT 'Name of item',
`image` varchar(255) DEFAULT NULL COMMENT 'Image of item',
`price` float(8,2) NOT NULL COMMENT 'Price each',
`total` int(11) NOT NULL COMMENT 'Number of items required',
`maximumAvailable` int(11) NOT NULL COMMENT 'Maxmimum number of items of this type available',
`orderId` int(11) DEFAULT NULL COMMENT 'Order number'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Shopping cart session information (do not edit)';
CREATE TABLE `shoppingcartOrders` (
`id` int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT COMMENT 'Order no.',
`collectionDetails` varchar(255) DEFAULT NULL COMMENT 'Collection details',
`comments` text COMMENT 'Any other comments',
`sundries` text COMMENT 'Sundries (if any)',
`name` varchar(255) NOT NULL COMMENT 'Name',
`address` text NOT NULL COMMENT 'Address',
`email` varchar(255) NOT NULL COMMENT 'E-mail address',
`telephone` varchar(255) DEFAULT NULL COMMENT 'Telephone',
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`status` enum('unfinalised','finalised','shipped','returned','lost','ignore') NOT NULL COMMENT 'Status of order'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Shopping cart inquiry form';
;";
}
# Return the SQL
return $sql;
}
# Additional processing
public function mainPreActions ()
{
# Enable tabs if an administrator
if ($this->userIsAdministrator) {
$this->settings['disableTabs'] = false;
}
# Determine whether to enable the shopping cart
$this->enableShoppingCart = false;
if ($this->settings['enableShoppingCart'] == 'Yes') {$this->enableShoppingCart = true;}
if ($this->settings['enableShoppingCart'] == 'Admins only' && $this->userIsAdministrator) {$this->enableShoppingCart = true;}
if ($this->settings['enableShoppingCart'] != 'No' && $this->action == 'callback') {$this->enableShoppingCart = true;}
}
# Additional processing
public function main ()
{
# Get the product types and section data
$this->sections = $this->getSections ();
$this->productTypes = $this->getProductTypes ();
# Get the type and product id from the query string
$this->arguments['type'] = ((isSet ($_GET['type']) && isSet ($this->productTypes[$_GET['type']])) ? $_GET['type'] : NULL);
$this->arguments['page'] = (isSet ($_GET['page']) ? $_GET['page'] : NULL);
$this->arguments['id'] = (isSet ($_GET['id']) ? $_GET['id'] : NULL);
$this->arguments['orderby'] = (isSet ($_GET['orderby']) ? $_GET['orderby'] : NULL);
# Get the grouping (if any), e.g. 'youngreaders', etc. under 'books'
$this->subtypes = $this->getSubtypes ($this->arguments['type']);
# Show the droplist
if (isSet ($this->actions[$this->action]['droplist']) && $this->actions[$this->action]['droplist']) {
# Add a search box
echo "\n<div id=\"productnavigation\">";
echo $this->searchBox ();
echo $this->productTypeDroplist ();
echo "\n</div>";
}
# Set the How to order text
$this->howToOrderText = "\n<p>See <a href=\"{$this->baseUrl}/order/\"><strong>how to order</strong></a> when you have decided what you wish to purchase.</p>";
# Include administrator as feedback recipient
if ($this->action != 'settings') { // Except on the settings page itself
$this->settings['feedbackRecipient'] = array ($this->settings['feedbackRecipient'], $this->settings['administratorEmail']);
}
# Load the shopping cart library with the specified settings
if ($this->enableShoppingCart) {
$shoppingCartSettings = array (
'name' => $this->settings['applicationName'],
'administratorEmail' => $this->settings['administratorEmail'],
'provider' => __CLASS__,
'database' => $this->settings['database'], // Shop database
'administrators' => $this->administrators,
'dateLimitations' => true,
'requireUser' => false,
'confirmationEmail' => true,
'enablePaymentWorkflow' => $this->settings['enablePaymentWorkflow'],
'paymentUrl' => $this->settings['shoppingCartPaymentUrl'],
'sharedSecret' => $this->settings['shoppingCartSharedSecret'],
'clientId' => $this->settings['shoppingCartClientId'],
'pathwayId' => $this->settings['shoppingCartPathwayId'],
'departmentId' => $this->settings['shoppingCartDepartmentId'],
'payoptionCode' => $this->settings['shoppingCartPayoptionCode'],
'orderPrefix' => $this->settings['shoppingCartOrderPrefix'],
'vatCode' => $this->settings['shoppingCartVatCode'],
'orderDescription' => $this->settings['shoppingCartOrderDescription'],
'emailTemplate' => $this->applicationRoot . '/app/views/email.tpl', // Smarty template format
);
require_once ('shoppingCart.php');
$this->shoppingCart = new shoppingCart ($this->databaseConnection, $this->baseUrl, $shoppingCartSettings, $userData = array (), $this->userIsAdministrator, $this->user, $this->templateHandle);
}
}
# Function to show a list of product types
public function home ()
{
# Compile the HTML
$html = $this->settings['introductionHtml'];
$html .= $this->howToOrderText;
$html .= $this->announcementText ();
$html .= $this->featuredProducts ();
$html .= $this->productTypeBoxes ();
# Show the HTML
echo $html;
}
# Function to get the section metadata
#!# This needs to have filtering to remove anything in the droplist which has no items, e.g. /shop/shackleton/ has no items as of 27/Oct/2020
private function getSections ()
{
# Get the data
$sectionData = $this->databaseConnection->select ($this->settings['database'], '__sectionData', array ('hide' => NULL), array (), true, 'title');
foreach ($sectionData as $section => $attributes) {
$sectionData[$section]['type'] = 'section';
}
# Get the themes data
$themes = $this->getThemes ();
# Merge in the themes data, with the sections taking priority
$sectionData += $themes;
# Re-alphabetise, maintaining keys
uasort ($sectionData, function ($a, $b) {
return strnatcmp ($a['title'], $b['title']);
});
# Return the list
return $sectionData;
}
# Function to get the thematic groupings (with only those that actually have items assigned being picked up)
private function getThemes ()
{
# Get the data
$query = "SELECT
theme__JOIN__sprishop____themeTypes__reserved as theme,
__themeTypes.*,
'theme' AS type
FROM sprishop.__themes
LEFT JOIN __themeTypes ON theme__JOIN__sprishop____themeTypes__reserved = __themeTypes.id
WHERE enabled = 'Yes'
GROUP BY theme
;";
if (!$data = $this->databaseConnection->getData ($query, 'sprishop.__themes')) {
return array ();
}
# Return the data
return $data;
}
# Function to get the product types
private function getProductTypes ()
{
# Arrange the titles as an array
$types = array ();
foreach ($this->sections as $type => $attributes) {
$types[$type] = $attributes['title'];
}
# Return the list
return $types;
}
# Function to get the grouping (if any), e.g. 'youngreaders', etc. under 'books'
private function getSubtypes ($type)
{
# End if no type
if (!$type) {return array ();}
# Look for a table of subtypes for this type
$table = "_{$type}Subtypes";
if (!$this->databaseConnection->tableExists ($this->settings['database'], $table)) {
return array ();
}
# Get the subtypes for this table
$query = "SELECT
{$table}.*,
photographFilename
FROM `{$this->settings['database']}`.`{$table}`
LEFT JOIN {$type} ON featured__JOIN__{$this->settings['database']}__{$type}__reserved = {$type}.id
ORDER BY subtypeName
;";
$data = $this->databaseConnection->getData ($query, "{$this->settings['database']}.{$table}");
# Rekey by groupingUrlSlug; unfortunately the ID is also required so we couldn't use getPairs
$subtypes = array ();
foreach ($data as $id => $subtype) {
$subtypeUrlSlug = $subtype['subtypeUrlSlug'];
$subtypes[$subtypeUrlSlug] = $subtype;
}
# Return the groupings
return $subtypes;
}
# Function to show the ordering page
public function ordering ()
{
# Define the HTML
$html = '<h2>How to order</h2>';
if ($this->userIsAdministrator) {
$html .= "\n<p class=\"actions alignright\"><a href=\"{$this->baseUrl}/settings.html\"><img src=\"/images/icons/pencil.png\" alt=\"\"> Edit text</a></p>";
}
$html .= $this->settings['orderingHtml'];
# Show the HTML
echo $html;
}
# Function to create a product type list
private function productTypeDroplist ()
{
# Create the list
$values = array ();
$values["{$this->baseUrl}/"] = 'Introduction';
$values["{$this->baseUrl}/order/"] = 'Ordering information';
foreach ($this->productTypes as $type => $description) {
$location = "{$this->baseUrl}/{$type}/";
$values[$location] = $description;
}
# If no type selected, select the first in the list
$selected = $this->arguments['type'];
if (!$this->arguments['type']) {
foreach ($this->productTypes as $type => $description) {
$selected = $type;
break;
}
}
# Assign the selected item
$selected = "{$this->baseUrl}/{$selected}/";
# Create the list
$html = application::htmlJumplist ($values, $selected, $this->baseUrl . '/', $name = 'jumplist', $parentTabLevel = 0, $class = 'ultimateform jumplist alignright', 'Go to:');
# Return the HTML
return $html;
}
# Function to create a product type list
private function productTypeBoxes ()
{
# Create the list
$items = array ();
foreach ($this->productTypes as $type => $description) {
$imageFile = "{$this->imageStoreRoot}{$this->settings['sectionsImages']}{$type}.jpg";
$imageFileLocation = str_replace ($_SERVER['DOCUMENT_ROOT'], '', $imageFile);
$imageHtml = (is_readable ($imageFile) ? "<img src=\"{$imageFileLocation}\" alt=\"{$description}\">" : '<span class="blank"></span>');
$items[] = "<a href=\"{$this->baseUrl}/{$type}/\">{$imageHtml} {$description}</a>";
}
$html = "\n" . application::htmlUl ($items, 0, 'categories');
# Return the HTML
return $html;
}
# Function to create a list of featured products
private function featuredProducts ()
{
# Get the featured products list, so that we then know what tables to join to (dynamic table joins are not possible)
$items = $this->databaseConnection->select ($this->settings['database'], '__featured', array (), array (), false, 'priority');
# Loop through each item and get its data
$featuredItems = array ();
foreach ($items as $index => $item) {
# Get the data for this item, adding in the column name
$query = "SELECT
id,title,pricePerUnit,photographFilename,
'{$item['section__JOIN__sprishop____sectionData__reserved']}' AS ___section
FROM {$this->settings['database']}.{$item['section__JOIN__sprishop____sectionData__reserved']}
WHERE id = {$item['itemnumber']}
LIMIT 1;
;";
$data = $this->databaseConnection->getOne ($query);
if (!$data) {continue;}
# Add in the section name
$featuredItems[$index] = $data;
}
# End if there are no featured items
if (!$featuredItems) {return NULL;}
# Create each item as a list item
foreach ($featuredItems as $item) {
$list[] = "<a href=\"{$this->baseUrl}/{$item['___section']}/{$item['id']}/\">{$this->productTypes[$item['___section']]}: {$item['title']} - £{$item['pricePerUnit']}</a>";
}
# Compile the HTML
$html = application::htmlUl ($list, 0, 'featureditems');
# Return the HTML
return $html;
}
# Function to get announcement text
private function announcementText ()
{
# Determine if there is an announcement available
$query = "SELECT
announcementText
FROM {$this->settings['database']}.__announcement
WHERE
startDate <= CAST(NOW() AS DATE) AND
endDate >= CAST(NOW() AS DATE)
LIMIT 1;";
if (!$data = $this->databaseConnection->getOne ($query)) {return false;}
# Compile the HTML
$html = "\n" . '<p class="warning"><img src="/images/general/alert.gif" width="15" height="15" alt="!" border="0" /> ' . htmlspecialchars ($data['announcementText']) . '</p>';
# Return the HTML
return $html;
}
# Function to show a product listing
public function listing ()
{
# Start the HTML
$html = '';
# Validate whether this type exists, and handle the result up the chain
if (!isSet ($this->sections[$this->arguments['type']])) {
$html .= "\n<p>There is no such section. Please use the selection box to select an available section.</p>";
application::sendHeader (404);
echo $html;
return false;
}
# Check for a product grouping
$grouping = false;
if ($this->subtypes) {
# If no grouping is requested, show the list available
if (!isSet ($_GET['grouping'])) {
$html .= "\n<p>Please choose a category:</p>";
$html .= $this->subtypesTabs (false, 'sublist', $this->arguments['type']);
echo $html;
return;
}
# If the group is not valid, throw a 404
if (!isSet ($this->subtypes[$_GET['grouping']])) {
$this->page404 ();
return;
}
$grouping = $_GET['grouping'];
}
# Add tabs for this grouping if required
if ($grouping) {
$html .= '<br />' . $this->subtypesTabs ($grouping);
}
# Get the product data
$dataGrouped = $this->getProductData ($this->arguments['type'], $grouping, $this->arguments['id'], $this->arguments['orderby']);
# If there is no data, say there are no items of this type available at present
if (!$dataGrouped) {
$html .= "\n<p><strong>We regret that there are no {$this->sections[$this->arguments['type']]['plural']} available " . ($grouping ? ' in this grouping' : ' in our catalogue') . " at present.</strong></p>";
$html .= "\n<p>Please use the list above to select other items.</p>";
echo $html;
return;
}
# Show the How to order text
$html .= $this->howToOrderText;
# Loop through each type within the data (which will only be one group unless using a thematic grouping)
$isThematicType = ($this->sections[$this->arguments['type']]['type'] == 'theme');
foreach ($dataGrouped as $type => $data) {
# Clean up the data
foreach ($data as $item => $attributes) {
# Add the admin link for this item
if ($this->userIsAdministrator) {
$data[$item]['admin'] = "\n" . '<p class="actions right"><a href="' . $this->baseUrl . '/data/' . $type . '/' . $attributes['id'] . '/edit.html"><img src="/images/icons/pencil.png" alt="*" /> Edit</a></p>';
}
# Ensure a dot at the end of the description
#!# Allow ! or ?
$attributes['description'] = trim ($attributes['description']);
if (substr ($attributes['description'], -1) != '.') {$attributes['description'] .= '.';} // Ensure the description ends with a dot
$data[$item]['description'] = $attributes['description'];
}
# Reorganise some of the item components (irrespective of whether they become multiselect)
#!# These should be moved back towards a fuller model
foreach ($data as &$item) {
$item = $this->compileItemComponents ($item, $type, $grouping);
}
# Add the shopping cart controls
if ($this->enableShoppingCart) {
foreach ($data as &$item) {
#!# When groupByTitle is applied, each $item['fragment'] after the first in the group needs to be rewritten to be the first, so that the after-posting redirect position is correct
$item['shoppingCartControlsHtml'] = $this->shoppingCart->controls ($item['id'], $this->baseUrl . $item['fragment'], $item['title'], $item['pricePerUnit'], $item['priceIncludesVat'], $item['photographPath'], $item['stockAvailableNumeric'], false);
}
}
# Perform grouping by title
$data = $this->groupByTitle ($data);
# Count the items
$items = count ($data);
# Create the HTML
if (!$isThematicType) {
if (!$this->arguments['id']) {
#!# Need a consistency check that $this->sections[$type] always exists - it could have been forgotten
$html .= "\n<p>There " . ($items == 1 ? 'is' : 'are') . " {$items} " . $this->sections[$type][($items == 1 ? 'singular' : 'plural')] . ' available' . ($grouping ? ' in this grouping' : '') . ':</p>';
$html .= "\n<div id=\"parameters\">";
$html .= "\n</div>";
} else {
$html .= application::htmlUl (array ("<a href=\"{$this->baseUrl}/{$type}/\">Back to <strong>{$this->sections[$type]['plural']}</strong></a> or use the list above to go to a different section"));
}
}
# Admin link
if (!$isThematicType) {
if ($this->userIsAdministrator) {
$html .= "\n<p class=\"actions alignright\"><a href=\"" . $this->baseUrl . '/data/' . $type . "/add.html\"><img src=\"/images/icons/add.png\" alt=\"\"> Add new item</a></p>";
}
}
# End if no data
if (!$data) {
$this->page404 ();
return;
}
# Create the HTML for each item
foreach ($data as $item) {
$html .= $this->itemHtml ($item, $type, ($this->arguments['id']));
}
# If the type is not found, throw a 404
if ($item['visible'] == 'N') {
$this->page404 ();
return;
}
}
# Show the HTML
echo $html;
}
# Function to add grouping tabs
private function subtypesTabs ($selected = false, $cssClass = 'tabsflat small', $includeImagesType = false)
{
# Create the tabs
$tabs = array ();
foreach ($this->subtypes as $key => $grouping) {
$imageHtml = ($includeImagesType ? '<span>' . $this->imageHtml ($grouping['photographFilename'], 'Title', $includeImagesType) . '</span> ' : false);
$tabs[$key] = "<a href=\"{$this->baseUrl}/{$this->arguments['type']}/{$key}.html\">{$imageHtml}" . htmlspecialchars ($grouping['subtypeName']) . '</a>';
}
# Compile the HTML
$html = application::htmlUl ($tabs, false, $cssClass, true, false, false, false, $selected);
# Return the HTML
return $html;
}
# Function to group the data by the 'title'
private function groupByTitle ($data)
{
# Loop each item
$groups = array ();
foreach ($data as $itemKey => $item) {
# Get the title
$title = $item['title'];
# Loop through each item attribute
foreach ($item as $key => $value) {
# Add each attribute to the reordered master array
$groups[$title][$key][$itemKey] = $value;
}
}
# Loop through each group to enable collapsing of items which are the same
foreach ($groups as $itemName => $attributes) {
# Loop through each attribute
foreach ($attributes as $attributeKey => $attributeValues) {
# Merge where the same value is used for all items
if (count ($temporaryAttributeValues = array_unique ($attributeValues)) == 1) {
sort ($temporaryAttributeValues); // Reset key name to '0'
$groups[$itemName][$attributeKey] = $temporaryAttributeValues[0];