Save all style class/template usages.
46 : void {
47 $sname = "";
48 $stype = "";
49 $template = "";
50
51 $path =
"//Paragraph | //Section | //MediaAlias | //FileItem" .
52 " | //Table | //TableData | //Tabs | //List";
53 $usages = array();
54 $nodes = $this->dom_util->path($a_domdoc,
$path);
55 foreach ($nodes as $node) {
56 switch ($node->localName) {
57 case "Paragraph":
58 $sname = $node->getAttribute("Characteristic");
59 $stype = "text_block";
60 $template = 0;
61 break;
62
63 case "Section":
64 $sname = $node->getAttribute("Characteristic");
65 $stype = "section";
66 $template = 0;
67 break;
68
69 case "MediaAlias":
70 $sname = $node->getAttribute("Class");
71 $stype = "media_cont";
72 $template = 0;
73 break;
74
75 case "FileItem":
76 $sname = $node->getAttribute("Class");
77 $stype = "flist_li";
78 $template = 0;
79 break;
80
81 case "Table":
82 $sname = $node->getAttribute("Template");
83 if ($sname == "") {
84 $sname = $node->getAttribute("Class");
85 $stype = "table";
86 $template = 0;
87 } else {
88 $stype = "table";
89 $template = 1;
90 }
91 break;
92
93 case "TableData":
94 $sname = $node->getAttribute("Class");
95 $stype = "table_cell";
96 $template = 0;
97 break;
98
99 case "Tabs":
100 $sname = $node->getAttribute("Template");
101 if ($sname != "") {
102 if ($node->getAttribute("Type") == "HorizontalAccordion") {
103 $stype = "haccordion";
104 }
105 if ($node->getAttribute("Type") == "VerticalAccordion") {
106 $stype = "vaccordion";
107 }
108 }
109 $template = 1;
110 break;
111
112 case "List":
113 $sname = $node->getAttribute("Class");
114 if ($node->getAttribute("Type") == "Ordered") {
115 $stype = "list_o";
116 } else {
117 $stype = "list_u";
118 }
119 $template = 0;
120 break;
121 }
122 if ($sname != "" && $stype != "") {
123 $usages[$sname . ":" . $stype . ":" . $template] = array("sname" => $sname,
124 "stype" => $stype,
125 "template" => $template
126 );
127 }
128 }
129
131
132 foreach ($usages as $u) {
133 $id = $this->db->nextId(
'page_style_usage');
134 $this->db->manipulate("INSERT INTO page_style_usage " .
135 "(id, page_id, page_type, page_lang, page_nr, template, stype, sname) VALUES (" .
136 $this->db->quote(
$id,
"integer") .
"," .
137 $this->db->quote($page->getId(), "integer") . "," .
138 $this->db->quote($page->getParentType(), "text") . "," .
139 $this->db->quote($page->getLanguage(), "text") . "," .
140 $this->db->quote($a_old_nr, "integer") . "," .
141 $this->db->quote($u["template"], "integer") . "," .
142 $this->db->quote($u["stype"], "text") . "," .
143 $this->db->quote(\
ilStr::subStr($u[
"sname"], 0, 30),
"text") .
144 ")");
145 }
146 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
deleteStyleUsages(\ilPageObject $page, int $a_old_nr=0)
Delete style usages.
static subStr(string $a_str, int $a_start, ?int $a_length=null)