ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilStyleMigration Class Reference

Style Migration Class (->3.11) More...

+ Collaboration diagram for ilStyleMigration:

Public Member Functions

 addMissingStyleCharacteristics ($a_id="")
 Add missing style characteristics to styles. More...
 

Static Public Member Functions

static _getCoreStyles ()
 Get core styles. More...
 
static _determineTag ($a_type)
 
static _getBasicStyleDom ()
 Get basic style dom. More...
 
static _createImagesDirectory ($a_style_id)
 Create images directory <data_dir>/sty/sty_<id>/images. More...
 
static _getImagesDirectory ($a_style_id)
 Get images directory. More...
 
static _addMissingStyleClassesToAllStyles ()
 Add missing style classes to all styles. More...
 

Static Public Attributes

static $assigned_tags
 
static $core_styles
 

Static Protected Attributes

static $basic_style_file = "./Services/Migration/DBUpdate_1385/basic_style/style.xml"
 
static $basic_style_image_dir = "./Services/Migration/DBUpdate_1385/basic_style/images"
 
static $basic_style_dom
 

Detailed Description

Style Migration Class (->3.11)

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 12 of file class.ilStyleMigration.php.

Member Function Documentation

◆ _addMissingStyleClassesToAllStyles()

static ilStyleMigration::_addMissingStyleClassesToAllStyles ( )
static

Add missing style classes to all styles.

Definition at line 344 of file class.ilStyleMigration.php.

345 {
346 global $ilDB;
347
350
351 // get all core image files
352 $core_images = array();
354 if (is_dir($core_dir)) {
355 $dir = opendir($core_dir);
356 while ($file = readdir($dir)) {
357 if (substr($file, 0, 1) != "." && is_file($core_dir . "/" . $file)) {
358 $core_images[] = $file;
359 }
360 }
361 }
362
363 // check, whether core style class exists
364 $sets = $ilDB->query("SELECT * FROM object_data WHERE type = 'sty'");
365
366 while ($recs = $ilDB->fetchAssoc($sets)) {
367 $id = $recs["obj_id"];
368
369 foreach ($core_styles as $cs) {
370 // check, whether core style class exists
371 $set = $ilDB->queryF(
372 "SELECT * FROM style_char WHERE style_id = %s " .
373 "AND type = %s AND characteristic = %s",
374 array("integer", "text", "text"),
375 array($id, $cs["type"], $cs["class"])
376 );
377
378 // if not, add core style class
379 if (!($rec = $ilDB->fetchAssoc($set))) {
380 $ilDB->manipulateF(
381 "INSERT INTO style_char (style_id, type, characteristic) " .
382 " VALUES (%s,%s,%s) ",
383 array("integer", "text", "text"),
384 array($id, $cs["type"], $cs["class"])
385 );
386
387 $xpath = new DOMXPath($bdom);
388 $par_nodes = $xpath->query("/StyleSheet/Style[@Tag = '" . $cs["tag"] . "' and @Type='" .
389 $cs["type"] . "' and @Class='" . $cs["class"] . "']/StyleParameter");
390 foreach ($par_nodes as $par_node) {
391 // check whether style parameter exists
392 $set = $ilDB->queryF(
393 "SELECT * FROM style_parameter WHERE style_id = %s " .
394 "AND type = %s AND class = %s AND tag = %s AND parameter = %s",
395 array("integer", "text", "text", "text", "text"),
396 array($id, $cs["type"], $cs["class"],
397 $cs["tag"], $par_node->getAttribute("Name"))
398 );
399
400 // if not, create style parameter
401 if (!($rec = $ilDB->fetchAssoc($set))) {
402 $ilDB->manipulateF(
403 "INSERT INTO style_parameter (style_id, type, class, tag, parameter, value) " .
404 " VALUES (%s,%s,%s,%s,%s,%s)",
405 array("integer", "text", "text", "text", "text", "text"),
406 array($id, $cs["type"], $cs["class"], $cs["tag"],
407 $par_node->getAttribute("Name"), $par_node->getAttribute("Value"))
408 );
409 }
410 }
411 }
412 }
413
414 // now check, whether some core image files are missing
417 reset($core_images);
418 foreach ($core_images as $cim) {
419 if (!is_file($imdir . "/" . $cim)) {
420 copy($core_dir . "/" . $cim, $imdir . "/" . $cim);
421 }
422 }
423 }
424 }
static _getBasicStyleDom()
Get basic style dom.
static _createImagesDirectory($a_style_id)
Create images directory <data_dir>/sty/sty_<id>/images.
static _getCoreStyles()
Get core styles.
static _getImagesDirectory($a_style_id)
Get images directory.
if(!array_key_exists('StateId', $_REQUEST)) $id
$sets
Definition: fetch.php:11
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
global $ilDB

References $basic_style_image_dir, $core_styles, $file, $id, $ilDB, $sets, _createImagesDirectory(), _getBasicStyleDom(), _getCoreStyles(), and _getImagesDirectory().

+ Here is the call graph for this function:

◆ _createImagesDirectory()

static ilStyleMigration::_createImagesDirectory (   $a_style_id)
static

Create images directory <data_dir>/sty/sty_<id>/images.

Definition at line 297 of file class.ilStyleMigration.php.

298 {
299 global $ilErr;
300
301 $sty_data_dir = CLIENT_WEB_DIR . "/sty";
302 ilUtil::makeDir($sty_data_dir);
303 if (!is_writable($sty_data_dir)) {
304 $ilErr->raiseError("Style data directory (" . $sty_data_dir
305 . ") not writeable.", $ilErr->FATAL);
306 }
307
308 $style_dir = $sty_data_dir . "/sty_" . $a_style_id;
309 ilUtil::makeDir($style_dir);
310 if (!@is_dir($style_dir)) {
311 $ilErr->raiseError("Creation of style directory failed (" .
312 $style_dir . ").", $ilErr->FATAL);
313 }
314
315 // create images subdirectory
316 $im_dir = $style_dir . "/images";
317 ilUtil::makeDir($im_dir);
318 if (!@is_dir($im_dir)) {
319 $ilErr->raiseError("Creation of Import Directory failed (" .
320 $im_dir . ").", $ilErr->FATAL);
321 }
322
323 // create thumbnails directory
324 $thumb_dir = $style_dir . "/images/thumbnails";
325 ilUtil::makeDir($thumb_dir);
326 if (!@is_dir($thumb_dir)) {
327 $ilErr->raiseError("Creation of Import Directory failed (" .
328 $thumb_dir . ").", $ilErr->FATAL);
329 }
330 }
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
global $ilErr
Definition: raiseError.php:16

References $ilErr, and ilUtil\makeDir().

Referenced by _addMissingStyleClassesToAllStyles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _determineTag()

static ilStyleMigration::_determineTag (   $a_type)
static

Definition at line 273 of file class.ilStyleMigration.php.

274 {
275 return self::$assigned_tags[$a_type];
276 }
$a_type
Definition: workflow.php:92

References $a_type.

Referenced by _getCoreStyles().

+ Here is the caller graph for this function:

◆ _getBasicStyleDom()

static ilStyleMigration::_getBasicStyleDom ( )
static

Get basic style dom.

Definition at line 281 of file class.ilStyleMigration.php.

282 {
283 global $ilBench;
284
285 if (!is_object(self::$basic_style_dom)) {
286 self::$basic_style_dom = new DOMDocument();
287 self::$basic_style_dom->load(self::$basic_style_file);
288 }
289
291 }
global $ilBench
Definition: ilias.php:18

References $basic_style_dom, and $ilBench.

Referenced by _addMissingStyleClassesToAllStyles().

+ Here is the caller graph for this function:

◆ _getCoreStyles()

static ilStyleMigration::_getCoreStyles ( )
static

Get core styles.

Definition at line 261 of file class.ilStyleMigration.php.

262 {
263 $c_styles = array();
264 foreach (self::$core_styles as $cstyle) {
265 $c_styles[$cstyle["type"] . "." . ilStyleMigration::_determineTag($cstyle["type"]) . "." . $cstyle["class"]]
266 = array("type" => $cstyle["type"],
267 "tag" => ilStyleMigration::_determineTag($cstyle["type"]),
268 "class" => $cstyle["class"]);
269 }
270 return $c_styles;
271 }
static _determineTag($a_type)

References _determineTag().

Referenced by _addMissingStyleClassesToAllStyles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getImagesDirectory()

static ilStyleMigration::_getImagesDirectory (   $a_style_id)
static

Get images directory.

Definition at line 335 of file class.ilStyleMigration.php.

336 {
337 return CLIENT_WEB_DIR . "/sty/sty_" . $a_style_id .
338 "/images";
339 }

Referenced by _addMissingStyleClassesToAllStyles().

+ Here is the caller graph for this function:

◆ addMissingStyleCharacteristics()

ilStyleMigration::addMissingStyleCharacteristics (   $a_id = "")

Add missing style characteristics to styles.

Definition at line 121 of file class.ilStyleMigration.php.

122 {
123 global $ilDB;
124
125 $add_str = "";
126 if ($a_id != "") {
127 $add_str = " AND style_id = " . $ilDB->quote($a_id, "integer");
128 }
129
130 $set = $ilDB->query($q = "SELECT DISTINCT style_id, tag, class FROM style_parameter WHERE " .
131 $ilDB->equals("type", "", "text", true) . " " . $add_str);
132
133 while ($rec = $ilDB->fetchAssoc($set)) {
134 // derive types from tag
135 $types = array();
136 switch ($rec["tag"]) {
137 case "div":
138 case "p":
139 if (in_array($rec["class"], array("Headline3", "Headline1",
140 "Headline2", "TableContent", "List", "Standard", "Remark",
141 "Additional", "Mnemonic", "Citation", "Example"))) {
142 $types[] = "text_block";
143 }
144 if (in_array($rec["class"], array("Block", "Remark",
145 "Additional", "Mnemonic", "Example", "Excursus", "Special"))) {
146 $types[] = "section";
147 }
148 if (in_array($rec["class"], array("Page", "Footnote", "PageTitle", "LMNavigation"))) {
149 $types[] = "page";
150 }
151 break;
152
153 case "td":
154 $types[] = "table_cell";
155 break;
156
157 case "a":
158 if (in_array($rec["class"], array("ExtLink", "IntLink", "FootnoteLink"))) {
159 $types[] = "link";
160 }
161 break;
162
163 case "span":
164 $types[] = "text_inline";
165 break;
166
167 case "table":
168 $types[] = "table";
169 break;
170
171 default:
172 $types[] = array();
173 break;
174 }
175
176 // check if style_char set exists
177 foreach ($types as $t) {
178 // check if second type already exists
179 $set4 = $ilDB->queryF(
180 "SELECT * FROM style_char " .
181 " WHERE style_id = %s AND type = %s AND characteristic = %s",
182 array("integer", "text", "text"),
183 array($rec["style_id"], $t, $rec["class"])
184 );
185 if ($rec4 = $ilDB->fetchAssoc($set4)) {
186 // ok
187 } else {
188 //echo "<br>1-".$rec["style_id"]."-".$t."-".$rec["class"]."-";
189 $ilDB->manipulateF(
190 "INSERT INTO style_char " .
191 " (style_id, type, characteristic) VALUES " .
192 " (%s,%s,%s) ",
193 array("integer", "text", "text"),
194 array($rec["style_id"], $t, $rec["class"])
195 );
196 }
197 }
198
199 // update types
200 if ($rec["type"] == "") {
201 if (count($types) > 0) {
202 $ilDB->manipulateF(
203 "UPDATE style_parameter SET type = %s " .
204 " WHERE style_id = %s AND class = %s AND " . $ilDB->equals("type", "", "text", true),
205 array("text", "integer", "text"),
206 array($types[0], $rec["style_id"], $rec["class"])
207 );
208
209 // links extra handling
210 if ($types[0] == "link") {
211 $ilDB->manipulateF(
212 "UPDATE style_parameter SET type = %s " .
213 " WHERE style_id = %s AND (class = %s OR class = %s) AND " . $ilDB->equals("type", "", "text", true),
214 array("text", "integer", "text", "text"),
215 array($types[0], $rec["style_id"], $rec["class"] . ":visited",
216 $rec["class"] . ":hover")
217 );
218 //echo "<br>4-".$types[0]."-".$rec["style_id"]."-".$rec["class"].":visited"."-".
219// $rec["class"].":hover";
220 }
221 }
222
223 if (count($types) == 2) {
224 // select all records of first type and add second type
225 // records if necessary.
226 $set2 = $ilDB->queryF(
227 "SELECT * FROM style_parameter " .
228 " WHERE style_id = %s AND class = %s AND type = %s",
229 array("integer", "text", "text"),
230 array($rec["style_id"], $rec["class"], $types[0])
231 );
232 while ($rec2 = $ilDB->fetchAssoc($set2)) {
233 // check if second type already exists
234 $set3 = $ilDB->queryF(
235 "SELECT * FROM style_parameter " .
236 " WHERE style_id = %s AND tag = %s AND class = %s AND type = %s AND parameter = %s",
237 array("integer", "text", "text", "text", "text"),
238 array($rec["style_id"], $rec["tag"], $rec["class"], $types[1], $rec["parameter"])
239 );
240 if ($rec3 = $ilDB->fetchAssoc($set3)) {
241 // ok
242 } else {
243 $ilDB->manipulateF(
244 "INSERT INTO style_parameter " .
245 " (style_id, tag, class, parameter, value, type) VALUES " .
246 " (%s,%s,%s,%s,%s,%s) ",
247 array("integer", "text", "text", "text", "text", "text"),
248 array($rec2["style_id"], $rec2["tag"], $rec2["class"],
249 $rec2["parameter"], $rec2["value"], $types[1])
250 );
251 }
252 }
253 }
254 }
255 }
256 }

References $ilDB, and $t.

Field Documentation

◆ $assigned_tags

ilStyleMigration::$assigned_tags
static

Definition at line 15 of file class.ilStyleMigration.php.

◆ $basic_style_dom

ilStyleMigration::$basic_style_dom
staticprotected

Definition at line 116 of file class.ilStyleMigration.php.

Referenced by _getBasicStyleDom().

◆ $basic_style_file

ilStyleMigration::$basic_style_file = "./Services/Migration/DBUpdate_1385/basic_style/style.xml"
staticprotected

Definition at line 114 of file class.ilStyleMigration.php.

◆ $basic_style_image_dir

ilStyleMigration::$basic_style_image_dir = "./Services/Migration/DBUpdate_1385/basic_style/images"
staticprotected

Definition at line 115 of file class.ilStyleMigration.php.

Referenced by _addMissingStyleClassesToAllStyles().

◆ $core_styles

ilStyleMigration::$core_styles
static

Definition at line 57 of file class.ilStyleMigration.php.

Referenced by _addMissingStyleClassesToAllStyles().


The documentation for this class was generated from the following file: