forked from vdm-io/Joomla-Component-Builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.php
5467 lines (5071 loc) · 387 KB
/
script.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
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
* @copyright Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
JHTML::_('behavior.modal');
/**
* Script File of Componentbuilder Component
*/
class com_componentbuilderInstallerScript
{
/**
* method to install the component
*
* @return void
*/
function install($parent)
{
}
/**
* method to uninstall the component
*
* @return void
*/
function uninstall($parent)
{
// Get Application object
$app = JFactory::getApplication();
// Get The Database object
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Joomla_component alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_component') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$joomla_component_found = $db->getNumRows();
// Now check if there were any rows
if ($joomla_component_found)
{
// Since there are load the needed joomla_component type ids
$joomla_component_ids = $db->loadColumn();
// Remove Joomla_component from the content type table
$joomla_component_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_component') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($joomla_component_condition);
$db->setQuery($query);
// Execute the query to remove Joomla_component items
$joomla_component_done = $db->execute();
if ($joomla_component_done)
{
// If succesfully remove Joomla_component add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_component) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Joomla_component items from the contentitem tag map table
$joomla_component_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_component') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($joomla_component_condition);
$db->setQuery($query);
// Execute the query to remove Joomla_component items
$joomla_component_done = $db->execute();
if ($joomla_component_done)
{
// If succesfully remove Joomla_component add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_component) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Joomla_component items from the ucm content table
$joomla_component_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.joomla_component') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($joomla_component_condition);
$db->setQuery($query);
// Execute the query to remove Joomla_component items
$joomla_component_done = $db->execute();
if ($joomla_component_done)
{
// If succesfully remove Joomla_component add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_component) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Joomla_component items are cleared from DB
foreach ($joomla_component_ids as $joomla_component_id)
{
// Remove Joomla_component items from the ucm base table
$joomla_component_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $joomla_component_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($joomla_component_condition);
$db->setQuery($query);
// Execute the query to remove Joomla_component items
$db->execute();
// Remove Joomla_component items from the ucm history table
$joomla_component_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $joomla_component_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($joomla_component_condition);
$db->setQuery($query);
// Execute the query to remove Joomla_component items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Admin_view alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.admin_view') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$admin_view_found = $db->getNumRows();
// Now check if there were any rows
if ($admin_view_found)
{
// Since there are load the needed admin_view type ids
$admin_view_ids = $db->loadColumn();
// Remove Admin_view from the content type table
$admin_view_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.admin_view') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($admin_view_condition);
$db->setQuery($query);
// Execute the query to remove Admin_view items
$admin_view_done = $db->execute();
if ($admin_view_done)
{
// If succesfully remove Admin_view add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.admin_view) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Admin_view items from the contentitem tag map table
$admin_view_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.admin_view') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($admin_view_condition);
$db->setQuery($query);
// Execute the query to remove Admin_view items
$admin_view_done = $db->execute();
if ($admin_view_done)
{
// If succesfully remove Admin_view add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.admin_view) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Admin_view items from the ucm content table
$admin_view_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.admin_view') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($admin_view_condition);
$db->setQuery($query);
// Execute the query to remove Admin_view items
$admin_view_done = $db->execute();
if ($admin_view_done)
{
// If succesfully remove Admin_view add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.admin_view) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Admin_view items are cleared from DB
foreach ($admin_view_ids as $admin_view_id)
{
// Remove Admin_view items from the ucm base table
$admin_view_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $admin_view_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($admin_view_condition);
$db->setQuery($query);
// Execute the query to remove Admin_view items
$db->execute();
// Remove Admin_view items from the ucm history table
$admin_view_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $admin_view_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($admin_view_condition);
$db->setQuery($query);
// Execute the query to remove Admin_view items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Custom_admin_view alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.custom_admin_view') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$custom_admin_view_found = $db->getNumRows();
// Now check if there were any rows
if ($custom_admin_view_found)
{
// Since there are load the needed custom_admin_view type ids
$custom_admin_view_ids = $db->loadColumn();
// Remove Custom_admin_view from the content type table
$custom_admin_view_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.custom_admin_view') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($custom_admin_view_condition);
$db->setQuery($query);
// Execute the query to remove Custom_admin_view items
$custom_admin_view_done = $db->execute();
if ($custom_admin_view_done)
{
// If succesfully remove Custom_admin_view add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.custom_admin_view) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Custom_admin_view items from the contentitem tag map table
$custom_admin_view_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.custom_admin_view') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($custom_admin_view_condition);
$db->setQuery($query);
// Execute the query to remove Custom_admin_view items
$custom_admin_view_done = $db->execute();
if ($custom_admin_view_done)
{
// If succesfully remove Custom_admin_view add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.custom_admin_view) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Custom_admin_view items from the ucm content table
$custom_admin_view_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.custom_admin_view') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($custom_admin_view_condition);
$db->setQuery($query);
// Execute the query to remove Custom_admin_view items
$custom_admin_view_done = $db->execute();
if ($custom_admin_view_done)
{
// If succesfully remove Custom_admin_view add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.custom_admin_view) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Custom_admin_view items are cleared from DB
foreach ($custom_admin_view_ids as $custom_admin_view_id)
{
// Remove Custom_admin_view items from the ucm base table
$custom_admin_view_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $custom_admin_view_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($custom_admin_view_condition);
$db->setQuery($query);
// Execute the query to remove Custom_admin_view items
$db->execute();
// Remove Custom_admin_view items from the ucm history table
$custom_admin_view_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $custom_admin_view_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($custom_admin_view_condition);
$db->setQuery($query);
// Execute the query to remove Custom_admin_view items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Site_view alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.site_view') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$site_view_found = $db->getNumRows();
// Now check if there were any rows
if ($site_view_found)
{
// Since there are load the needed site_view type ids
$site_view_ids = $db->loadColumn();
// Remove Site_view from the content type table
$site_view_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.site_view') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($site_view_condition);
$db->setQuery($query);
// Execute the query to remove Site_view items
$site_view_done = $db->execute();
if ($site_view_done)
{
// If succesfully remove Site_view add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.site_view) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Site_view items from the contentitem tag map table
$site_view_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.site_view') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($site_view_condition);
$db->setQuery($query);
// Execute the query to remove Site_view items
$site_view_done = $db->execute();
if ($site_view_done)
{
// If succesfully remove Site_view add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.site_view) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Site_view items from the ucm content table
$site_view_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.site_view') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($site_view_condition);
$db->setQuery($query);
// Execute the query to remove Site_view items
$site_view_done = $db->execute();
if ($site_view_done)
{
// If succesfully remove Site_view add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.site_view) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Site_view items are cleared from DB
foreach ($site_view_ids as $site_view_id)
{
// Remove Site_view items from the ucm base table
$site_view_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $site_view_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($site_view_condition);
$db->setQuery($query);
// Execute the query to remove Site_view items
$db->execute();
// Remove Site_view items from the ucm history table
$site_view_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $site_view_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($site_view_condition);
$db->setQuery($query);
// Execute the query to remove Site_view items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Template alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.template') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$template_found = $db->getNumRows();
// Now check if there were any rows
if ($template_found)
{
// Since there are load the needed template type ids
$template_ids = $db->loadColumn();
// Remove Template from the content type table
$template_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.template') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($template_condition);
$db->setQuery($query);
// Execute the query to remove Template items
$template_done = $db->execute();
if ($template_done)
{
// If succesfully remove Template add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.template) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Template items from the contentitem tag map table
$template_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.template') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($template_condition);
$db->setQuery($query);
// Execute the query to remove Template items
$template_done = $db->execute();
if ($template_done)
{
// If succesfully remove Template add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.template) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Template items from the ucm content table
$template_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.template') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($template_condition);
$db->setQuery($query);
// Execute the query to remove Template items
$template_done = $db->execute();
if ($template_done)
{
// If succesfully remove Template add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.template) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Template items are cleared from DB
foreach ($template_ids as $template_id)
{
// Remove Template items from the ucm base table
$template_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $template_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($template_condition);
$db->setQuery($query);
// Execute the query to remove Template items
$db->execute();
// Remove Template items from the ucm history table
$template_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $template_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($template_condition);
$db->setQuery($query);
// Execute the query to remove Template items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Layout alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.layout') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$layout_found = $db->getNumRows();
// Now check if there were any rows
if ($layout_found)
{
// Since there are load the needed layout type ids
$layout_ids = $db->loadColumn();
// Remove Layout from the content type table
$layout_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.layout') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($layout_condition);
$db->setQuery($query);
// Execute the query to remove Layout items
$layout_done = $db->execute();
if ($layout_done)
{
// If succesfully remove Layout add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.layout) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Layout items from the contentitem tag map table
$layout_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.layout') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($layout_condition);
$db->setQuery($query);
// Execute the query to remove Layout items
$layout_done = $db->execute();
if ($layout_done)
{
// If succesfully remove Layout add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.layout) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Layout items from the ucm content table
$layout_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.layout') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($layout_condition);
$db->setQuery($query);
// Execute the query to remove Layout items
$layout_done = $db->execute();
if ($layout_done)
{
// If succesfully remove Layout add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.layout) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Layout items are cleared from DB
foreach ($layout_ids as $layout_id)
{
// Remove Layout items from the ucm base table
$layout_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $layout_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($layout_condition);
$db->setQuery($query);
// Execute the query to remove Layout items
$db->execute();
// Remove Layout items from the ucm history table
$layout_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $layout_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($layout_condition);
$db->setQuery($query);
// Execute the query to remove Layout items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Dynamic_get alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.dynamic_get') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$dynamic_get_found = $db->getNumRows();
// Now check if there were any rows
if ($dynamic_get_found)
{
// Since there are load the needed dynamic_get type ids
$dynamic_get_ids = $db->loadColumn();
// Remove Dynamic_get from the content type table
$dynamic_get_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.dynamic_get') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($dynamic_get_condition);
$db->setQuery($query);
// Execute the query to remove Dynamic_get items
$dynamic_get_done = $db->execute();
if ($dynamic_get_done)
{
// If succesfully remove Dynamic_get add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.dynamic_get) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Dynamic_get items from the contentitem tag map table
$dynamic_get_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.dynamic_get') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($dynamic_get_condition);
$db->setQuery($query);
// Execute the query to remove Dynamic_get items
$dynamic_get_done = $db->execute();
if ($dynamic_get_done)
{
// If succesfully remove Dynamic_get add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.dynamic_get) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Dynamic_get items from the ucm content table
$dynamic_get_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.dynamic_get') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($dynamic_get_condition);
$db->setQuery($query);
// Execute the query to remove Dynamic_get items
$dynamic_get_done = $db->execute();
if ($dynamic_get_done)
{
// If succesfully remove Dynamic_get add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.dynamic_get) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Dynamic_get items are cleared from DB
foreach ($dynamic_get_ids as $dynamic_get_id)
{
// Remove Dynamic_get items from the ucm base table
$dynamic_get_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $dynamic_get_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($dynamic_get_condition);
$db->setQuery($query);
// Execute the query to remove Dynamic_get items
$db->execute();
// Remove Dynamic_get items from the ucm history table
$dynamic_get_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $dynamic_get_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($dynamic_get_condition);
$db->setQuery($query);
// Execute the query to remove Dynamic_get items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Custom_code alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.custom_code') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$custom_code_found = $db->getNumRows();
// Now check if there were any rows
if ($custom_code_found)
{
// Since there are load the needed custom_code type ids
$custom_code_ids = $db->loadColumn();
// Remove Custom_code from the content type table
$custom_code_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.custom_code') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($custom_code_condition);
$db->setQuery($query);
// Execute the query to remove Custom_code items
$custom_code_done = $db->execute();
if ($custom_code_done)
{
// If succesfully remove Custom_code add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.custom_code) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Custom_code items from the contentitem tag map table
$custom_code_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.custom_code') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($custom_code_condition);
$db->setQuery($query);
// Execute the query to remove Custom_code items
$custom_code_done = $db->execute();
if ($custom_code_done)
{
// If succesfully remove Custom_code add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.custom_code) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Custom_code items from the ucm content table
$custom_code_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.custom_code') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($custom_code_condition);
$db->setQuery($query);
// Execute the query to remove Custom_code items
$custom_code_done = $db->execute();
if ($custom_code_done)
{
// If succesfully remove Custom_code add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.custom_code) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Custom_code items are cleared from DB
foreach ($custom_code_ids as $custom_code_id)
{
// Remove Custom_code items from the ucm base table
$custom_code_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $custom_code_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($custom_code_condition);
$db->setQuery($query);
// Execute the query to remove Custom_code items
$db->execute();
// Remove Custom_code items from the ucm history table
$custom_code_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $custom_code_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($custom_code_condition);
$db->setQuery($query);
// Execute the query to remove Custom_code items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Placeholder alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.placeholder') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$placeholder_found = $db->getNumRows();
// Now check if there were any rows
if ($placeholder_found)
{
// Since there are load the needed placeholder type ids
$placeholder_ids = $db->loadColumn();
// Remove Placeholder from the content type table
$placeholder_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.placeholder') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($placeholder_condition);
$db->setQuery($query);
// Execute the query to remove Placeholder items
$placeholder_done = $db->execute();
if ($placeholder_done)
{
// If succesfully remove Placeholder add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.placeholder) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Placeholder items from the contentitem tag map table
$placeholder_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.placeholder') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($placeholder_condition);
$db->setQuery($query);
// Execute the query to remove Placeholder items
$placeholder_done = $db->execute();
if ($placeholder_done)
{
// If succesfully remove Placeholder add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.placeholder) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Placeholder items from the ucm content table
$placeholder_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.placeholder') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($placeholder_condition);
$db->setQuery($query);
// Execute the query to remove Placeholder items
$placeholder_done = $db->execute();
if ($placeholder_done)
{
// If succesfully remove Placeholder add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.placeholder) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Placeholder items are cleared from DB
foreach ($placeholder_ids as $placeholder_id)
{
// Remove Placeholder items from the ucm base table
$placeholder_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $placeholder_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($placeholder_condition);
$db->setQuery($query);
// Execute the query to remove Placeholder items
$db->execute();
// Remove Placeholder items from the ucm history table
$placeholder_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $placeholder_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($placeholder_condition);
$db->setQuery($query);
// Execute the query to remove Placeholder items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Library alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.library') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$library_found = $db->getNumRows();
// Now check if there were any rows
if ($library_found)
{
// Since there are load the needed library type ids
$library_ids = $db->loadColumn();
// Remove Library from the content type table
$library_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.library') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($library_condition);
$db->setQuery($query);
// Execute the query to remove Library items
$library_done = $db->execute();
if ($library_done)
{
// If succesfully remove Library add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.library) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Library items from the contentitem tag map table
$library_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.library') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($library_condition);
$db->setQuery($query);
// Execute the query to remove Library items
$library_done = $db->execute();
if ($library_done)
{
// If succesfully remove Library add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.library) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Library items from the ucm content table
$library_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.library') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($library_condition);
$db->setQuery($query);
// Execute the query to remove Library items
$library_done = $db->execute();
if ($library_done)
{
// If succesfully remove Library add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.library) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Library items are cleared from DB
foreach ($library_ids as $library_id)
{
// Remove Library items from the ucm base table
$library_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $library_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($library_condition);
$db->setQuery($query);
// Execute the query to remove Library items
$db->execute();
// Remove Library items from the ucm history table
$library_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $library_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($library_condition);
$db->setQuery($query);
// Execute the query to remove Library items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Snippet alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.snippet') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$snippet_found = $db->getNumRows();
// Now check if there were any rows
if ($snippet_found)
{
// Since there are load the needed snippet type ids
$snippet_ids = $db->loadColumn();
// Remove Snippet from the content type table
$snippet_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.snippet') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($snippet_condition);
$db->setQuery($query);
// Execute the query to remove Snippet items
$snippet_done = $db->execute();
if ($snippet_done)
{
// If succesfully remove Snippet add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.snippet) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Snippet items from the contentitem tag map table
$snippet_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.snippet') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($snippet_condition);
$db->setQuery($query);
// Execute the query to remove Snippet items
$snippet_done = $db->execute();
if ($snippet_done)
{
// If succesfully remove Snippet add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.snippet) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Snippet items from the ucm content table
$snippet_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.snippet') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($snippet_condition);
$db->setQuery($query);
// Execute the query to remove Snippet items
$snippet_done = $db->execute();
if ($snippet_done)
{
// If succesfully remove Snippet add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.snippet) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Snippet items are cleared from DB
foreach ($snippet_ids as $snippet_id)
{
// Remove Snippet items from the ucm base table
$snippet_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $snippet_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($snippet_condition);
$db->setQuery($query);
// Execute the query to remove Snippet items
$db->execute();
// Remove Snippet items from the ucm history table
$snippet_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $snippet_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($snippet_condition);
$db->setQuery($query);
// Execute the query to remove Snippet items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Validation_rule alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.validation_rule') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();