-
Notifications
You must be signed in to change notification settings - Fork 0
/
RDA.php
executable file
·1678 lines (1491 loc) · 64 KB
/
RDA.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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Adapter for Carousel RDA
*
* @author seth.phillips
*
*/
class RDA {
function __construct($UserName, $Password, $ServerURI = 'localhost') {
$this->UserName = $UserName;
$this->Password = $Password;
$this->HostIP = $ServerURI;
}
private $Port = 56906;
public $HostIP = '';
public $UserName = '';
public $Password = '';
private $ZoneID = array();
private $ZoneTag = array();
private $ZoneName = array();
private $TemplateName = '';
private $BulletinGuid = array();
private $BulletinTag = array();
private $CrawlGuid = array();
private $Alert = false;
private $ExclusiveAlert = false;
private $Block = array();
private $AlwaysOn = null;
public $DateTimeOn = '';
private $DateTimeOff = '';
private $CycletimeSet = false;
private $CycleTimeOn = '00:00:00';
private $CycleTimeOff = '23:59:59';
private $WeekdaysSet = false;
private $Weekdays = 127;
public $WebEnabled = true;
private $DisplayDurationSet = false;
public $DisplayDuration = 30;
private $LastError ='';
private $CreatedBulletins = array();
public $Description = 'RDA Created Bulletin';
// Zone information Getters and Setters
/**
* Set Zone IDs
*
* Allows the setting of 1 or more Zone IDs for use in the RDA.
* This function will overwrite the existing Zone IDs if any have been set.
* Related functions are getZoneIDs() and clearZoneIDs()
*
* @param int|string|array $ID a single Zone ID or an array of Zone IDs
* @return boolean returns false on failure.
*/
public function setZoneIDs($ID = null){
if($ID === null){return false;}
$this->ZoneID = array();
if(is_array($ID)){
foreach($ID as $i){ array_push($this->ZoneID, $i); }
}
else{ array_push($this->ZoneID, $ID);}
}
/**
* Get Zone IDs
*
* Returns the list of Zone IDs
* Related functions are setZoneIDs() and clearZoneIDs()
*
* @return array array of Zone IDs
*/
public function getZoneIDs(){
return $this->ZoneID;
}
/**
* Clear Zone IDs
*
* Clears out one or all of the zone IDs that have been set by setZoneIDs().
*
* @param string|int|null $ID A single zone ID or Null. Passing null will clear out all Zone IDs.
* @return boolean returns true on success
*/
public function clearZoneIDs($ID = null){
if($ID === null){$this->ZoneID = array();return true;}
else {foreach($this->ZoneID as $k=>$v){if($v===$ID){ array_splice($this->ZoneID, $k, 1);return TRUE;} } }
}
/**
* Function to set Zone Tags
*
* Allows the setting of 1 or more Zone Tags for use in the RDA.
* This function will overwrite the existing Zone Tags if any have been set.
* Related functions are getZoneTags() and clearZoneTags()
*
* @param int|string|array $Tag a single Zone tag or an array of Zone tags
* @return boolean returns false on failure.
*/
public function setZoneTags($Tag = null){
if($Tag === null){return false;}
$this->ZoneTag = array();
if(is_array($Tag)){
foreach($Tag as $i){ array_push($this->ZoneTag, $i); }
}
else{ array_push($this->ZoneTag, $Tag);}
}
/**
* Get Zone Tags
*
* Returns the list of Zone Tags
* Related functions are setZoneTags() and clearZoneTags()
*
* @return array array of Zone Tags
*/
public function getZoneTags(){
return $this->ZoneTag;
}
/**
* Clear Zone Tags
*
* Clears out one or all of the zone Tags that have been set by setZoneTags().
*
* @param string|int|null $Tag A single zone Tag or Null. Passing null will clear out all Zone Tags.
* @return boolean returns true on success
*/
public function clearZoneTags($Tag = null){
if($Tag === null){$this->ZoneTag = array();return true;}
else {foreach($this->ZoneTag as $k=>$v){if($v===$Tag){ array_splice($this->ZoneTag, $k, 1);return TRUE;} } }
}
/**
* Set Zone Names
*
* Allows the setting of 1 or more Zone Names for use in the RDA.
* This function will overwrite the existing Zone Names if any have been set.
* Related functions are getZoneNames() and clearZoneNames()
*
* @param int|string|array $Name a single Zone Name or an array of Zone Names
* @return boolean returns false on failure.
*/
public function setZoneNames($Name = null){
if($Name === null){return false;}
$this->ZoneName = array();
if(is_array($Name)){
foreach($Name as $i){ array_push($this->ZoneName, $i); }
}
else{ array_push($this->ZoneName, $Name);}
}
/**
* Get Zone Names
*
* Returns the list of Zone Names
* Related functions are setZoneNames() and clearZoneNames()
*
* @return array array of Zone Names
*/
public function getZoneNames(){
return $this->ZoneName;
}
/**
* Clear Zone Names
*
* Clears out one or all of the zone Names that have been set by setZoneNames().
*
* @param string|int|null $Name A single zone Name or Null. Passing null will clear out all Zone Names.
* @return boolean returns true on success
*/
public function clearZoneNames($Name = null){
if($Name === null){$this->ZoneName = array();return true;}
else {foreach($this->ZoneName as $k=>$v){if($v===$Name){ array_splice($this->ZoneName, $k, 1);return TRUE;} } }
}
/**
* Reset Zone Information
*
* Resets the list of Zone IDs Tags and Names to be used by the RDA. The same as calling clearZoneIDs(), clearZoneTags() and clearZoneNames().
*
*/
public function resetZones(){
$this->ZoneID = array();
$this->ZoneTag = array();
$this->ZoneName = array();
}
// Template Getters and Setters
/**
*
* Set Template Name
*
* Sets the template name to be used by CreatePage()
*
* @param string $Name The name of the template to be used.
*
*/
public function setTemplateName($Name){
$this->TemplateName = $Name;
}
/**
*
* Get Template Name
*
* Gets the currently set template name to be used by CreatePage()
*
* @return string Template Name
*
*/
public function getTemplateName(){
return $this->TemplateName;
}
/**
* Set Bulletin Guids
*
* Allows the setting of 1 or more Bulletin Guids for use in the RDA.
* This function will overwrite the existing Bulletin Guids if any have been set.
* Related functions are getBulletinGuids() and clearBulletinGuids()
*
* @param string|array $Guid a single Bulletin Guids or an array of Bulletin Guidss
* @return boolean returns false on failure.
*/
public function setBulletinGuids($Guid = null){
if($Guid === null){return false;}
$this->BulletinGuid = array();
if(is_array($Guid)){
foreach($Guid as $i){ array_push($this->BulletinGuid, $i); }
}
else{ array_push($this->BulletinGuid, $Guid);}
}
/**
* Get Bulletin Guids
*
* Returns the list of Bulletin Guids
* Related functions are setBulletinGuids() and clearBulletinGuids()
*
* @return array array of Bulletin Guids
*/
public function getBulletinGuids(){
return $this->BulletinGuid;
}
/**
* Clear Bulletin Guids
*
* Clears out one or all of the Bulletin Guids that have been set by setBulletinGuids().
*
* @param string|null $Name A single Bulletin Guid or Null. Passing null will clear out all Bulletin Guids.
* @return boolean returns true on success
*/
public function clearBulletinGuids($Guid = null){
if($Guid === null){$this->BulletinGuid = array();return true;}
else {foreach($this->BulletinGuid as $k=>$v){if($v===$Guid){ array_splice($this->BulletinGuid, $k, 1);return TRUE;} } }
}
/**
* Set Crawl Guids
*
* Allows the setting of 1 or more Crawl Guids for use in the RDA.
* This function will overwrite the existing Crawl Guids if any have been set.
* Related functions are getCrawlGuids() and clearCrawlGuids()
*
* @param string|array $Guid a single Crawl Guid or an array of Crawl Guids
* @return boolean returns false on failure.
*/
public function setCrawlGuids($Guid = null){
if($Guid === null){return false;}
$this->CrawlGuid = array();
if(is_array($Guid)){
foreach($Guid as $i){ array_push($this->CrawlGuid, $i); }
}
else{ array_push($this->CrawlGuid, $Guid);}
}
/**
* Get Crawl Guids
*
* Returns the list of Crawl Guids
* Related functions are setCrawlGuids() and clearCrawlGuids()
*
* @return array array of Crawl Guids
*/
public function getCrawlGuids(){
return $this->CrawlGuid;
}
/**
* Clear Crawl Guids
*
* Clears out one or all of the Crawl Guids that have been set by setCrawlGuids().
*
* @param string|null $Name A single Crawl Guid or Null. Passing null will clear out all Crawl Guids.
* @return boolean returns true on success
*/
public function clearCrawlGuids($Guid = null){
if($Guid === null){$this->CrawlGuid = array();return true;}
else {foreach($this->CrawlGuid as $k=>$v){if($v===$Guid){ array_splice($this->CrawlGuid, $k, 1);return TRUE;} } }
}
/**
* Set Bulletin Tags
*
* Allows the setting of 1 or more Bulletin Tags for use in the RDA.
* This function will overwrite the existing Bulletin Tags if any have been set.
* Related functions are getBulletinTags() and clearBulletinTags()
*
* @param string|array $Guid a single Bulletin Tag or an array of Bulletin Tags
* @return boolean returns false on failure.
*/
public function setBulletinTags($Tag = null){
if($Tag === null){return false;}
$this->BulletinTag = array();
if(is_array($Tag)){
foreach($Tag as $i){ array_push($this->BulletinTag, $i); }
}
else{ array_push($this->BulletinTag, $Tag);}
}
/**
* Get Bulletin Tags
*
* Returns the list of Bulletin Tags
* Related functions are setBulletinTags() and clearBulletinTags()
*
* @return array array of Bulletin Tags
*/
public function getBulletinTags(){
return $this->BulletinTag;
}
/**
* Clear Bulletin Tags
*
* Clears out one or all of the Bulletin Tags that have been set by setBulletinTags().
*
* @param string|null $Name A single Bulletin Tag or Null. Passing null will clear out all Bulletin Tags.
* @return boolean returns true on success
*/
public function clearBulletinTags($Tag = null){
if($Tag === null){$this->BulletinTag = array();return true;}
else {foreach($this->BulletinTag as $k=>$v){if($v===$Tag){ array_splice($this->BulletinTag, $k, 1);return TRUE;} } }
}
/**
* Set a Schedule
*
* Sets a Schedule to be used when creating or updating a bulletin or crawl.
*
* @param DateTime $DateOn DateTime Object representing when the schdule begins
* @param DateTime $DateOff DateTime Object representing when the schdule ends
*
*/
public function setSchedule(DateTime $DateOn, DateTime $DateOff){
$this->AlwaysOn = false;
$this->DateTimeOn = $DateOn->format(DateTime::W3C);
$this->DateTimeOff = $DateOff->format(DateTime::W3C);
}
/**
* Get the Schdule
*
* Gets the current schedule start and end dates and times that will be used to create or update bulletins and crawls
*
* @return string Representation of both the DateTimeOn and DateTimeOff separated by a en-dash, or 'Always On'. (ex.) '2014-04-05 00:00:00 - 2014-08-10 23:59:59'
*
*/
public function getSchedule(){
if($this->AlwaysOn){return 'Always On';}
return $this->DateTimeOn.' - '.$this->DateTimeOff;
}
/**
* Clear Schedule
*
* This defaults the RDA command to an Always On state.
*
*/
public function clearSchedule(){
$this->AlwaysOn = true;
}
/**
* Set Cycle Time
*
* Defines a start and end time to be used during each day of a bulletins schedule. Use a 24 hour time reference formatted 'HH:MM:SS' or 'HH:MM'.
*
* @param string $TimeOn String formatted as 'HH:MM:SS'
* @param string $TimeOff String formatted as 'HH:MM:SS'
*
* @return boolean returns true on success or false on failure. Failure will not reset the Cycle Times.
*/
public function setCycleTime($TimeOn = '00:00:00',$TimeOff = '23:59:59'){
$this->CycleTimeSet = true;
if(preg_match('/^[0-9]{1,2}:[0-9]{2}$/',$TimeOn) === 1){$TimeOn.=':00';}
if(preg_match('/^[0-9]{1,2}:[0-9]{2}$/',$TimeOff) === 1){$TimeOff.=':00';}
if(preg_match('/^[0-9]:[0-9]{2}:[0-9]{2}$/',$TimeOn) === 1){$TimeOn ='0'.$TimeOn;}
if(preg_match('/^[0-9]:[0-9]{2}:[0-9]{2}$/',$TimeOff) === 1){$TimeOff ='0'.$TimeOff;}
if(preg_match('/^[0-9]{1,2}:[0-9]{2}:[0-9]{2}$/',$TimeOff) === 1 && preg_match('/^[0-9]{1,2}:[0-9]{2}:[0-9]{2}$/',$TimeOn) === 1){
$this->CycleTimeOn = $TimeOn;
$this->CycleTimeOff = $TimeOff;
return 1;
}
else return 0;
}
/**
*
* Get Cycle Time
*
* Gets the currently set cycle time that will be used to create or update bulletins and crawls.
*
* @return string Cycle Time On and Off separated by an en-dash. (ex.) "08:30:00 - 23:15:00"
*
*/
public function getCycleTime(){
return $this->CycleTimeOn.' - '.$this->CycleTimeOff;
}
/**
* Clear Schedule
*
* This defaults the Cycle Time to an Always On state by setting CycleTimeOn and CycleTimeOff to '00:00:00' and '23:59:59' respectively.
*
*/
public function clearCycleTime(){
$this->CycleTimeOn = '00:00:00';
$this->CycleTimeOff = '23:59:59';
}
/**
* Set Week Days
*
* Sets the valid playback days for use within a bulletins schedule. Most abbreviations or full day names are valid. Days should be separated by a ' ', '-', ',' or ':'. Do not mix separators.
*
* @param string $Days A properly formed string representation of the Days of the week. (ex.) 'M-T-W-Th-F' or 'Mon,Tuesday,Wed,Thur,Friday' or a blank string for none
*
* @return boolean Returns true if weekdays have been set.
* Returns false if no days could be parsed and weekdays have been cleared.
*/
public function setWeekDays($Days = 'Sun-Mon-Tue-Wed-Thur-Fri-Sat'){
$this->WeekdaysSet = true;
if(preg_match('/:/', $Days) !== 0){$X = explode(':', $Days);}
elseif(preg_match('/-/', $Days) !== 0){$X = explode('-', $Days);}
elseif(preg_match("/,/", $Days) !== 0){$X = explode(',', $Days);}
elseif(preg_match('/ /', $Days) !== 0){$X = explode(' ', $Days);}
else{$X = array($Days);}
$Y = array(false,false,false,false,false,false,false);
$result = '';
foreach($X as $x){
switch(trim($x)){
case 'Sat':
$Y[0] = true;
break;
case 'Saturday':
$Y[0] = true;
break;
case 'Fri':
$Y[1] = true;
break;
case 'Friday':
$Y[1] = true;
break;
case 'F':
$Y[1] = true;
break;
case 'Thur':
$Y[2] = true;
break;
case 'Th':
$Y[2] = true;
break;
case 'Thurs':
$Y[2] = true;
break;
case 'Thursday':
$Y[2] = true;
break;
case 'Wed':
$Y[3] = true;
break;
case 'Wednesday':
$Y[3] = true;
break;
case 'W':
$Y[3] = true;
break;
case 'Tue':
$Y[4] = true;
break;
case 'Tuesday':
$Y[4] = true;
break;
case 'Tues':
$Y[4] = true;
break;
case 'T':
$Y[4] = true;
break;
case 'Mon':
$Y[5] = true;
break;
case 'Monday':
$Y[5] = true;
break;
case 'M':
$Y[5] = true;
break;
case 'Sun':
$Y[6] = true;
break;
case 'Sunday':
$Y[6] = true;
break;
default:
break;
}
}
foreach($Y as $y){
$result .= ($y)? '1':'0';
}
$DayBits = base_convert($result,2,10);
$this->Weekdays = $DayBits;
if($DayBits === 0){
return 0;
}
else {
return 1;
}
}
/**
* Set Block
*
* Prepares a Template block for use in Creating or Updating Bulletins. Blocks have a name and a value. Name is the block name as set in the Carousel Template Editor
* and value is the text in a text block, the uri in an RSS or web picture block and the GUID of a video or picture block.
*
* @param string $name the name of the template or bulletin block
* @param string $value the value of the text block, a uri for web image and rss blocks or a GUID for picture and video blocks
*/
public function setBlock($name, $value){
$block['Name'] = $name;
$block['Value'] = $value;
array_push($this->Block,$block);
}
/**
*
* Get Blocks
*
* Gets and array of the currently set blocks.
*
* @return array Array of the currently set blocks
*
*/
public function getBlocks(){
return $this->Block;
}
/**
*
* @param int|null $key integer representing the key of the block as referenced in getBlocks(), or null will clear out all blocks.
* @return boolean returns true for no good reason.
*/
public function clearBlocks($key = null){
if($key === null){$this->Block = array();return true;}
array_splice($this->Block, $key, 1);
return true;
}
/**
* Is Alert
*
* Gets or Sets the Alerting Feature. If a Boolean is supplied as an argument, it will set the current alert status
* if no argument is supplied it will tell you if the current RDA is set to prepare an alert bulletin.
*
* @param boolean|null $boolean Sets the current alert status if supplied.
* @return boolean Returns the current value of the alert setting if no arguement is passed in
*/
public function IsAlert($boolean = ''){
if(isset($boolean) && is_bool($boolean)){
$this->Alert = $boolean;
}
else{
return $this->Alert;
}
}
/**
* Is Exclusive Alert
*
* Gets or Sets the Exclusive Alerting Feature. If a Boolean is supplied as an argument, it will set the current exclusive alert status
* if no argument is supplied it will tell you if the current RDA is set to prepare an exclusive alert bulletin. Exclusive Alerts will disable all other alerts in the Zone.
*
* @param boolean|null $boolean Sets the current alert status if supplied.
* @return boolean Returns the current value of the alert setting if no arguement is passed in
*/
public function isExclusiveAlert($boolean = ''){
if(isset($boolean) && is_bool($boolean)){
$this->ExclusiveAlert = $boolean;
}
else{
return $this->ExclusiveAlert;
}
}
/**
* Is Exclusive Alert
*
* Gets or Sets the Exclusive Alerting Feature. If a Boolean is supplied as an argument, it will set the current exclusive alert status
* if no argument is supplied it will tell you if the current RDA is set to prepare an exclusive alert bulletin. Exclusive Alerts will disable all other alerts in the Zone.
*
* @param boolean|null $boolean Sets the current alert status if supplied.
* @return boolean Returns the current value of the alert setting if no arguement is passed in
*/
public function setDisplayDuration($duration = 30){
$this->DisplayDuration = $duration;
$this->DisplayDurationSet = true;
}
/**
* Create Page
*
* Creates Bulletins in Carousel from a template. This requires zone information, a template name, and
* and matching blocks to be set. Optional scheduling information can also be set. The command takes no arguments and requires
* that all needed information be set in advance using other methods. One bulletin will be created for each zone and each zone supplied
* must have the template available in it.
*
* @return array|boolean reutrns an array of created bulletin GUIDs on success, or false on failure.
* Upon failure an error message will be available in getLastError();
*/
public function CreatePage(){
$command = 'CreatePage';
$xml = new DOMDocument('1.0','utf-8');
$root = $xml->createElementNS('http://www.trms.com/CarouselRemoteCommand','CarouselCommand');
$xml->appendChild($root);
$ActionRoot = $xml->createElement($command);
$root->appendChild($ActionRoot);
$UserName = $xml->createElement('UserName',$this->UserName);
$ActionRoot->appendChild($UserName);
$Password = $xml->createElement('Password',$this->Password);
$ActionRoot->appendChild($Password);
$ZoneSet = $xml->createElement('ZoneSet');
foreach($this->ZoneID as $x){
$ZoneID = $xml->createElement('ZoneID',$x);
$ZoneSet->appendChild($ZoneID);
}
foreach($this->ZoneName as $x){
$ZoneName = $xml->createElement('ZoneName');
$ZoneNameText = $xml->createTextNode($x);
$ZoneName->appendChild($ZoneNameText);
$ZoneSet->appendChild($ZoneName);
}
foreach($this->ZoneTag as $x){
$ZoneTag = $xml->createElement('ZoneTag',$x);
$ZoneSet->appendChild($ZoneTag);
}
$ActionRoot->appendChild($ZoneSet);
$_AlwaysOn = ($this->AlwaysOn || $this->AlwaysOn === null)?'true':'false';
$AlwaysOn = $xml->createElement('AlwaysOn', $_AlwaysOn);
$ActionRoot->appendChild($AlwaysOn);
if($this->AlwaysOn === false)
{
$DateTimeOn = $xml->createElement('DateTimeOn', $this->DateTimeOn);
$DateTimeOff = $xml->createElement('DateTimeOff', $this->DateTimeOff);
$ActionRoot->appendChild($DateTimeOn);
$ActionRoot->appendChild($DateTimeOff);
}
$CycleTimeOn = $xml->createElement('CycleTimeOn',$this->CycleTimeOn);
$ActionRoot->appendChild($CycleTimeOn);
$CycleTimeOff = $xml->createElement('CycleTimeOff',$this->CycleTimeOff);
$ActionRoot->appendChild($CycleTimeOff);
$Weekdays = $xml->createElement('Weekdays',$this->Weekdays);
$ActionRoot->appendChild($Weekdays);
//$DisplayDuration = $xml->createElement('DisplayDuration',$this->DisplayDuration);
//$ActionRoot->appendChild($DisplayDuration);
$_WebEnabled = ($this->WebEnabled)?'true':'false';
$WebEnabled = $xml->createElement('WebEnabled',$_WebEnabled);
$ActionRoot->appendChild($WebEnabled);
$Description = $xml->createElement('Description');
$DescriptionText = $xml->createTextNode($this->Description);
$Description->appendChild($DescriptionText);
$ActionRoot->appendChild($Description);
if($this->Alert)
$PT = 'Alert';
else
$PT = 'Standard';
$PageType = $xml->createElement('PageType',$PT);
$ActionRoot->appendChild($PageType);
// if($this->ExclusiveAlert){ //invalid element??
// $ExclusiveAlert = $xml->createElement('ExclusiveAlertOn',true);
// $ActionRoot->appendChild($ExclusiveAlert);
// }
$PageTemplate = $xml->createElement('PageTemplate');
$TemplateName = $xml->createElement('TemplateName',$this->TemplateName);
$PageTemplate->appendChild($TemplateName);
foreach($this->Block as $block){
$BlockNode = $xml->createElement('Block');
$Name = $xml->createAttribute('Name');
$Value = $xml->createAttribute('Value');
$Name->value = $block['Name'];
$Value->value = $block['Value'];
$BlockNode->appendChild($Name);
$BlockNode->appendChild($Value);
$PageTemplate->appendChild($BlockNode);
}
$ActionRoot->appendChild($PageTemplate);
return $this->fireRDA($xml,$command);
}
/**
* Update Page
*
* Update a Page or 'Bulletin' in Carousel from a template. This requires a bulletin GUID, or
* bulletin tags as well as matching blocks to be set. Optional scheduling information can also be set. The command takes no arguments and requires
* that all needed information be set in advance using other methods.
*
* @return array|boolean reutrns an array of effected bulletin GUIDs on success, or false on failure.
* Upon failure an error message will be available in getLastError(); NOTE: if supplied an invalid GUID, the system
* will behave as if a bulletin was updated.
*
*/
public function UpdatePage(){
$command = 'UpdatePage';
$BulletinList = array();
foreach($this->BulletinGuid as $GUID){
$xml = new DOMDocument('1.0','utf-8');
$root = $xml->createElementNS('http://www.trms.com/CarouselRemoteCommand','CarouselCommand');
$xml->appendChild($root);
$ActionRoot = $xml->createElement($command);
$root->appendChild($ActionRoot);
$UserName = $xml->createElement('UserName',$this->UserName);
$ActionRoot->appendChild($UserName);
$Password = $xml->createElement('Password',$this->Password);
$ActionRoot->appendChild($Password);
$UpdateGUID = $xml->createElement('UpdateGUID',$GUID);
$ActionRoot->appendChild($UpdateGUID);
if($this->AlwaysOn !== null)
{
$_AlwaysOn = ($this->AlwaysOn)?'true':'false';
$AlwaysOn = $xml->createElement('AlwaysOn', $_AlwaysOn);
$ActionRoot->appendChild($AlwaysOn);
if(!$this->AlwaysOn)
{
$DateTimeOn = $xml->createElement('DateTimeOn', $this->DateTimeOn);
$DateTimeOff = $xml->createElement('DateTimeOff', $this->DateTimeOff);
$ActionRoot->appendChild($DateTimeOn);
$ActionRoot->appendChild($DateTimeOff);
}
}
if($this->CycleTimeSet === true)
{
$CycleTimeOn = $xml->createElement('CycleTimeOn',$this->CycleTimeOn);
$ActionRoot->appendChild($CycleTimeOn);
$CycleTimeOff = $xml->createElement('CycleTimeOff',$this->CycleTimeOff);
$ActionRoot->appendChild($CycleTimeOff);
}
if($this->WeekdaysSet === true)
{
$Weekdays = $xml->createElement('Weekdays',$this->Weekdays);
$ActionRoot->appendChild($Weekdays);
}
$_WebEnabled = ($this->WebEnabled)?'true':'false';
$WebEnabled = $xml->createElement('WebEnabled',$_WebEnabled);
$ActionRoot->appendChild($WebEnabled);
if($this->Description !== 'RDA Created Bulletin')
{
$Description = $xml->createElement('Description');
$DescriptionText = $xml->createTextNode($this->Description);
$Description->appendChild($DescriptionText);
$ActionRoot->appendChild($Description);
}
if($this->Alert)
$PT = 'Alert';
else
$PT = 'Standard';
$PageType = $xml->createElement('PageType',$PT);
$ActionRoot->appendChild($PageType);
if($this->ExclusiveAlert){
$ExclusiveAlert = $xml->createElement('ExclusiveAlertOn',true);
$ActionRoot->appendChild($ExclusiveAlert);
}
foreach($this->Block as $block){
$BlockNode = $xml->createElement('Block');
$Name = $xml->createAttribute('Name');
$Value = $xml->createAttribute('Value');
$Name->value = $block['Name'];
$Value->value = $block['Value'];
$BlockNode->appendChild($Name);
$BlockNode->appendChild($Value);
$ActionRoot->appendChild($BlockNode);
}
$result = $this->fireRDA($xml,$command);
if($result){
foreach($result as $x){array_push($BulletinList,$x);}
}
}
if( count($this->BulletinTag) > 0 ){
$xml = new DOMDocument('1.0','utf-8');
$root = $xml->createElementNS('http://www.trms.com/CarouselRemoteCommand','CarouselCommand');
$xml->appendChild($root);
$ActionRoot = $xml->createElement($command);
$root->appendChild($ActionRoot);
$UserName = $xml->createElement('UserName',$this->UserName);
$ActionRoot->appendChild($UserName);
$Password = $xml->createElement('Password',$this->Password);
$ActionRoot->appendChild($Password);
$SelectBulletinTags = $xml->createElement('SelectBulletinTags');
foreach($this->BulletinTag as $tag){
$Tag = $xml->createElement('Tag');
$TagText = $xml->createTextNode($tag);
$Tag->appendChild($TagText);
$SelectBulletinTags->appendChild($Tag);
}
$ActionRoot->appendChild($SelectBulletinTags);
if($this->AlwaysOn !== null)
{
$_AlwaysOn = ($this->AlwaysOn)?'true':'false';
$AlwaysOn = $xml->createElement('AlwaysOn', $_AlwaysOn);
$ActionRoot->appendChild($AlwaysOn);
if(!$this->AlwaysOn)
{
$DateTimeOn = $xml->createElement('DateTimeOn', $this->DateTimeOn);
$DateTimeOff = $xml->createElement('DateTimeOff', $this->DateTimeOff);
$ActionRoot->appendChild($DateTimeOn);
$ActionRoot->appendChild($DateTimeOff);
}
}
if($this->CycleTimeSet === true)
{
$CycleTimeOn = $xml->createElement('CycleTimeOn',$this->CycleTimeOn);
$ActionRoot->appendChild($CycleTimeOn);
$CycleTimeOff = $xml->createElement('CycleTimeOff',$this->CycleTimeOff);
$ActionRoot->appendChild($CycleTimeOff);
}
if($this->WeekdaysSet === true)
{
$Weekdays = $xml->createElement('Weekdays',$this->Weekdays);
$ActionRoot->appendChild($Weekdays);
}
$_WebEnabled = ($this->WebEnabled)?'true':'false';
$WebEnabled = $xml->createElement('WebEnabled',$_WebEnabled);
$ActionRoot->appendChild($WebEnabled);
if($this->Description !== 'RDA Created Bulletin')
{
$Description = $xml->createElement('Description');
$DescriptionText = $xml->createTextNode($this->Description);
$Description->appendChild($DescriptionText);
$ActionRoot->appendChild($Description);
}
if($this->Alert)
$PT = 'Alert';
else
$PT = 'Standard';
$PageType = $xml->createElement('PageType',$PT);
$ActionRoot->appendChild($PageType);
if($this->ExclusiveAlert){
$ExclusiveAlert = $xml->createElement('ExclusiveAlertOn','true');
$ActionRoot->appendChild($ExclusiveAlert);
}
foreach($this->Block as $block){
$BlockNode = $xml->createElement('Block');
$Name = $xml->createAttribute('Name');
$Value = $xml->createAttribute('Value');
$Name->value = $block['Name'];
$Value->value = $block['Value'];
$BlockNode->appendChild($Name);
$BlockNode->appendChild($Value);
$ActionRoot->appendChild($BlockNode);
}
$result = $this->fireRDA($xml,$command);
if($result){
foreach($result as $x){array_push($BulletinList,$x);}
}
}
if( count($BulletinList) === 0 ){return 0;}
else {return $BulletinList;}
}
/**
* Change Page Status
*
* Changes the "status" of a bulletin. This requires bulletin GUIDs or Bulletin Tags to be set and a status of "on" or "off" supplied as an argument.
*
*
* @return array reutrns an associative array of GUID->true on success and GUID->false on failure. Tags will come back under TagList->boolean
* Upon failure an error message will be available in getLastError();
*/
public function ChangePageStatus($Status){ // 'on' or 'off'
$command = 'ChangePageStatus';
$responseList = array();
foreach($this->BulletinGuid as $GUID){
$xml = new DOMDocument('1.0','utf-8');
$root = $xml->createElementNS('http://www.trms.com/CarouselRemoteCommand','CarouselCommand');
$xml->appendChild($root);
$ActionRoot = $xml->createElement($command);
$root->appendChild($ActionRoot);
$UserName = $xml->createElement('UserName',$this->UserName);
$ActionRoot->appendChild($UserName);
$Password = $xml->createElement('Password',$this->Password);
$ActionRoot->appendChild($Password);
$PageGUID = $xml->createElement('GUID',$GUID);
$ActionRoot->appendChild($PageGUID);
$pageStatus = $xml->createElement('Status',$Status);
$ActionRoot->appendChild($pageStatus);
$response = $this->fireRDA($xml,$command);
$responseList[$GUID] = $response;
}
if( count($this->BulletinTag) > 0 ){
$xml = new DOMDocument('1.0','utf-8');
$root = $xml->createElementNS('http://www.trms.com/CarouselRemoteCommand','CarouselCommand');
$xml->appendChild($root);
$ActionRoot = $xml->createElement($command);
$root->appendChild($ActionRoot);
$UserName = $xml->createElement('UserName',$this->UserName);
$ActionRoot->appendChild($UserName);
$Password = $xml->createElement('Password',$this->Password);
$ActionRoot->appendChild($Password);
$SelectBulletinTags = $xml->createElement('SelectBulletinTags');
foreach($this->BulletinTag as $tag){
$Tag = $xml->createElement('Tag');
$TagText = $xml->createTextNode($tag);
$Tag->appendChild($TagText);
$SelectBulletinTags->appendChild($Tag);
}
$ActionRoot->appendChild($SelectBulletinTags);
$pageStatus = $xml->createElement('Status',$Status);
$ActionRoot->appendChild($pageStatus);