ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\Style\StyleManager Class Reference
+ Collaboration diagram for ILIAS\Style\StyleManager:

Public Member Functions

 __construct ()
 
 saveStyleUsage (\ilPageObject $page, \DOMDocument $a_domdoc, int $a_old_nr=0)
 Save all style class/template usages. More...
 
 deleteStyleUsages (\ilPageObject $page, int $a_old_nr=0)
 Delete style usages. More...
 

Protected Attributes

ilDBInterface $db
 
ILIAS COPage Dom DomUtil $dom_util
 

Detailed Description

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 26 of file StyleManager.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Style\StyleManager::__construct ( )

Definition at line 31 of file StyleManager.php.

References $DIC.

32  {
33  global $DIC;
34 
35  $this->dom_util = $DIC->copage()->internal()->domain()->domUtil();
36  $this->db = $DIC->database();
37  }
global $DIC
Definition: shib_login.php:22

Member Function Documentation

◆ deleteStyleUsages()

ILIAS\Style\StyleManager::deleteStyleUsages ( \ilPageObject  $page,
int  $a_old_nr = 0 
)

Delete style usages.

Definition at line 151 of file StyleManager.php.

References ilPageObject\getId(), ilPageObject\getLanguage(), and ilPageObject\getParentType().

Referenced by ILIAS\Style\StyleManager\saveStyleUsage().

154  : void {
155  $and_old_nr = "";
156  if ($a_old_nr !== 0) {
157  $and_old_nr = " AND page_nr = " . $this->db->quote($a_old_nr, "integer");
158  }
159 
160  $this->db->manipulate(
161  "DELETE FROM page_style_usage WHERE " .
162  " page_id = " . $this->db->quote($page->getId(), "integer") .
163  " AND page_type = " . $this->db->quote($page->getParentType(), "text") .
164  " AND page_lang = " . $this->db->quote($page->getLanguage(), "text") .
165  $and_old_nr
166  );
167  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveStyleUsage()

ILIAS\Style\StyleManager::saveStyleUsage ( \ilPageObject  $page,
\DOMDocument  $a_domdoc,
int  $a_old_nr = 0 
)

Save all style class/template usages.

Definition at line 42 of file StyleManager.php.

References $id, $path, ILIAS\Style\StyleManager\deleteStyleUsages(), ilPageObject\getId(), ilPageObject\getLanguage(), ilPageObject\getParentType(), and ilStr\subStr().

46  : void {
47  $sname = "";
48  $stype = "";
49  $template = "";
50  // media aliases
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 
130  $this->deleteStyleUsages($page, $a_old_nr);
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  }
deleteStyleUsages(\ilPageObject $page, int $a_old_nr=0)
Delete style usages.
static subStr(string $a_str, int $a_start, ?int $a_length=null)
Definition: class.ilStr.php:24
$path
Definition: ltiservices.php:29
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ILIAS\Style\StyleManager::$db
protected

Definition at line 28 of file StyleManager.php.

◆ $dom_util

ILIAS COPage Dom DomUtil ILIAS\Style\StyleManager::$dom_util
protected

Definition at line 29 of file StyleManager.php.


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