File tree Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /**
4
+ * Contao Open Source CMS
5
+ * Copyright (c) 2005-2015 Leo Feyer
6
+ *
7
+ * @package semantic_html5
8
+ * @copyright MEN AT WORK 2016
9
+ * @author David Maack <david.maack@arcor.de>
10
+ * @license LGPL-3.0+
11
+ */
12
+
13
+ /**
14
+ * Callbacks
15
+ */
16
+ $ GLOBALS ['TL_DCA ' ]['tl_page ' ]['config ' ]['oncopy_callback ' ][] = array ('SemanticHTML5\Backend\Callbacks ' , 'oncopyPageCallback ' );
Original file line number Diff line number Diff line change @@ -91,6 +91,47 @@ public static function ondeleteCallback(\DataContainer $dc, $id)
91
91
}
92
92
}
93
93
94
+ /**
95
+ * This methods corrects the hml5-elements after using the copy function of
96
+ * the tl_page table
97
+ *
98
+ * @param type $id
99
+ * @param \DataContainer $dc
100
+ */
101
+ public static function oncopyPageCallback ($ id , \DataContainer $ dc )
102
+ {
103
+
104
+ $ pages = array ($ id );
105
+
106
+ //fetch the child pages, if needed
107
+ if (\Input::get ('childs ' )) {
108
+ $ pages = array_merge ($ pages , \Database::getInstance ()->getChildRecords ($ id , 'tl_page ' ));
109
+
110
+ }
111
+
112
+ //fetch all html5 start elemnts and update them the end elements will be corrected automatically
113
+ $ elements = \Database::getInstance ()
114
+ ->prepare (
115
+ sprintf (
116
+ 'SELECT * FROM tl_content '
117
+ . 'WHERE type = "sHtml5Start" '
118
+ . 'AND pid IN '
119
+ . '(SELECT id FROM tl_article WHERE pid in (%s)) ' ,
120
+ implode (', ' , $ pages ))
121
+ )->execute ($ pages );
122
+
123
+ //return if no elements were found
124
+ if ($ elements ->numRows == 0 ) {
125
+ return ;
126
+ }
127
+
128
+ $ util = new TagUtils ('tl_content ' );
129
+
130
+ while ($ elements ->next ()) {
131
+ $ util ->createOrUpdateCorresppondingTag ($ elements , true );
132
+ }
133
+ }
134
+
94
135
/**
95
136
* This methods corrects the hml5-elements after using the copy function of
96
137
* the tl_article table
You can’t perform that action at this time.
0 commit comments