@@ -104,8 +104,59 @@ public function __construct($pageListNode, RequestContext $O_O) {
104104 parent ::__construct ($ pageListNode , $ O_O );
105105 $ this ->xml = new Xml ('festival ' , Xml::multiLingualOn, Xml::versionsOff);
106106 $ this ->xml ->loadFromFile ('data/pages/ ' .$ pageListNode ->getAttribute ('id ' ));
107+
108+ $ this ->migrate ();
109+ }
110+
111+ public function migrate () {
112+ if ($ this ->xml ->documentElement ->getAttribute ('migrated ' ))
113+ return ;
114+ $ this ->xml ->lockAndReload ();
115+
116+ // Make sure day ids are valid ids (starting
117+ // with a letter).
118+ foreach ($ this ->getConfigElement (self ::CONFIG_ID_DAYS , self ::CONFIG_TAG_DAYS )->children () as $ day )
119+ $ day ->setId ('day ' . $ day ->getId ());
120+
121+ foreach ($ this ->xml ->find (self ::TAG_CONTRIBUTION_EVENT ) as $ event )
122+ $ event ->setAttribute (self ::ATTR_EVENT_DAY , 'day ' . $ event ->getAttribute (self ::ATTR_EVENT_DAY ));
123+
124+ // Duplicate the header
125+ $ header = $ this ->getConfigElement ('header ' );
126+ if ($ header ) {
127+ $ this ->getConfigElement (self ::CONFIG_ID_LINEUP_HEADER , self ::CONFIG_TAG )->append ($ header ->html ());
128+ $ this ->getConfigElement (self ::CONFIG_ID_TIMETABLE_HEADER , self ::CONFIG_TAG )->append ($ header ->html ());
129+ $ header ->remove ();
130+ }
131+
132+ // Make stuff translated
133+ foreach ($ this ->xml ->find (self ::TAG_CONTRIBUTION ) as $ c ) {
134+ $ lang = $ this ->xml ->createElement (self ::TAG_CONTRIBUTION_LANGUAGE );
135+ $ lang ->setAttribute (self ::ATTR_LANGUAGE_ID , 'nl ' );
136+ $ c ->append ($ lang );
137+ foreach ([self ::ATTR_CONTRIBUTION_IMAGE , self ::ATTR_CONTRIBUTION_NAME , self ::ATTR_CONTRIBUTION_TITLE , self ::ATTR_CONTRIBUTION_WEBSITE , self ::ATTR_CONTRIBUTION_CATEGORY ] as $ attr ) {
138+ $ lang ->setAttribute ($ attr , $ c ->getAttribute ($ attr ));
139+ $ c ->removeAttribute ($ attr );
140+ }
141+ $ lang ->append ($ c ->get (self ::TAG_CONTRIBUTION_DESCRIPTION ));
142+ }
143+
144+ foreach ([self ::CONFIG_ID_CONTRIBUTION_FORM , self ::CONFIG_ID_SIGNUP_FORM , self ::CONFIG_ID_LINEUP_HEADER , self ::CONFIG_ID_TIMETABLE_HEADER , self ::CONFIG_ID_ABOUT ] as $ id ) {
145+ $ c = $ this ->getConfigElement ($ id );
146+ if ($ c ) {
147+ $ lang = $ this ->xml ->createElement (self ::CONFIG_TAG_LANGUAGE );
148+ $ lang ->setAttribute (self ::ATTR_LANGUAGE_ID , 'nl ' );
149+ $ lang ->append ($ c ->children ());
150+ $ c ->append ($ lang );
151+ }
152+ }
153+
154+
155+ $ this ->xml ->documentElement ->setAttribute ('migrated ' , 1 );
156+ $ this ->xml ->saveAndUnlock ();
107157 }
108158
159+
109160 public static function getDatatypeName () {
110161 return __ ('datatype.name.festivalpage ' );
111162 }
0 commit comments