ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
ilStyleImportParser Class Reference

Style Import Parser. More...

+ Inheritance diagram for ilStyleImportParser:
+ Collaboration diagram for ilStyleImportParser:

Public Member Functions

 __construct (string $a_xml_file, ilObjStyleSheet $a_style_obj)
 
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class private More...
 
 startParsing ()
 start the parser More...
 
 handlerBeginTag ( $a_xml_parser, string $a_name, array $a_attribs)
 
 handlerEndTag ( $a_xml_parser, string $a_name)
 
 handlerCharacterData ( $a_xml_parser, string $a_data)
 
- Public Member Functions inherited from ilSaxParser
 __construct (?string $path_to_file='', ?bool $throw_exception=false)
 
 setXMLContent (string $a_xml_content)
 
 getXMLContent ()
 
 getInputType ()
 
 startParsing ()
 stores xml data in array More...
 
 createParser ()
 
 setHandlers ($a_xml_parser)
 
 parse ($a_xml_parser, $a_fp=null)
 

Protected Member Functions

 trimAndStripAttribs (array $attribs)
 
 trimAndStrip (string $input)
 
- Protected Member Functions inherited from ilSaxParser
 openXMLFile ()
 
 handleError (string $message)
 
 setThrowException (bool $throw_exception)
 

Protected Attributes

string $cdata = ""
 
array $cur_template_classes
 
array $cur_template
 
array $current_tags = []
 
string $current_type = ""
 
string $current_class = ""
 
string $current_tag = ""
 
array $styles
 
ilObjStyleSheet $style_obj
 
ilTree $tree
 
Content ColorManager $color_manager
 
array $chars = []
 
- Protected Attributes inherited from ilSaxParser
ilLanguage $lng = null
 

Additional Inherited Members

- Data Fields inherited from ilSaxParser
string $xml_file
 
bool $throw_exception = false
 

Detailed Description

Style Import Parser.

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

Definition at line 28 of file class.ilStyleImportParser.php.

Constructor & Destructor Documentation

◆ __construct()

ilStyleImportParser::__construct ( string  $a_xml_file,
ilObjStyleSheet  $a_style_obj 
)

Definition at line 43 of file class.ilStyleImportParser.php.

References $DIC, $service, ILIAS\GlobalScreen\Provider\__construct(), ilObject\getId(), and ILIAS\Repository\lng().

46  {
47  global $DIC;
48 
49  $this->lng = $DIC->language();
50  $this->tree = $DIC->repositoryTree();
51 
52  $service = $DIC->contentStyle()->internal();
53  $access_manager = $service->domain()->access(0, $DIC->user()->getId());
54  $access_manager->enableWrite(true);
55 
56  $this->color_manager = $service->domain()->color(
57  $a_style_obj->getId(),
58  $access_manager
59  );
60 
61  $this->style_obj = $a_style_obj;
62 
63  parent::__construct($a_xml_file);
64  }
global $DIC
Definition: shib_login.php:26
__construct(Container $dic, ilPlugin $plugin)
$service
Definition: ltiservices.php:40
+ Here is the call graph for this function:

Member Function Documentation

◆ handlerBeginTag()

ilStyleImportParser::handlerBeginTag (   $a_xml_parser,
string  $a_name,
array  $a_attribs 
)

Definition at line 89 of file class.ilStyleImportParser.php.

References null, and trimAndStripAttribs().

Referenced by setHandlers().

93  : void {
94  $a_attribs = $this->trimAndStripAttribs($a_attribs);
95  switch ($a_name) {
96  case "Style":
97  $this->current_tag = $a_attribs["Tag"];
98  $this->current_class = $a_attribs["Class"];
99  $this->current_type = $a_attribs["Type"];
100  if ($this->current_class == "PageTitle" && $this->current_type == "page_title" && $this->current_tag == "div") {
101  $this->current_tag = "h1";
102  }
103  if ($this->current_class == "Headline1" && $this->current_tag == "div") {
104  $this->current_tag = "h1";
105  $this->current_type = "heading1";
106  }
107  if ($this->current_class == "Headline2" && $this->current_tag == "div") {
108  $this->current_tag = "h2";
109  $this->current_type = "heading2";
110  }
111  if ($this->current_class == "Headline3" && $this->current_tag == "div") {
112  $this->current_tag = "h3";
113  $this->current_type = "heading3";
114  }
115  $this->current_tags = array();
116  $this->chars[] = array("type" => $this->current_type,
117  "class" => $this->current_class);
118  break;
119 
120  case "StyleParameter":
121  $this->current_tags[] = array(
122  "tag" => $this->current_tag,
123  "class" => $this->current_class,
124  "parameter" => $a_attribs["Name"],
125  "type" => $this->current_type,
126  "value" => $a_attribs["Value"],
127  "custom" => $a_attribs["Custom"] ?? null);
128  break;
129 
130  case "StyleColor":
131  $this->color_manager->addColor($a_attribs["Name"], $a_attribs["Code"]);
132  break;
133 
134  case "StyleTemplate":
135  $this->cur_template = array("type" => $a_attribs["Type"],
136  "name" => $a_attribs["Name"]);
137  $this->cur_template_classes = array();
138  break;
139 
140  case "StyleTemplateClass":
141  $this->cur_template_classes[$a_attribs["ClassType"]] =
142  $a_attribs["Class"];
143  break;
144  }
145  $this->cdata = "";
146  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handlerCharacterData()

ilStyleImportParser::handlerCharacterData (   $a_xml_parser,
string  $a_data 
)

Definition at line 176 of file class.ilStyleImportParser.php.

Referenced by setHandlers().

179  : void {
180  // i don't know why this is necessary, but
181  // the parser seems to convert "&gt;" to ">" and "&lt;" to "<"
182  // in character data, but we don't want that, because it's the
183  // way we mask user html in our content, so we convert back...
184  $a_data = str_replace("<", "&lt;", $a_data);
185  $a_data = str_replace(">", "&gt;", $a_data);
186 
187  // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
188  $a_data = preg_replace("/\n/", "", $a_data);
189  $a_data = preg_replace("/\t+/", "", $a_data);
190  if (!empty($a_data)) {
191  $this->cdata .= $a_data;
192  }
193  }
+ Here is the caller graph for this function:

◆ handlerEndTag()

ilStyleImportParser::handlerEndTag (   $a_xml_parser,
string  $a_name 
)

Definition at line 148 of file class.ilStyleImportParser.php.

References $current_tags, and trimAndStrip().

Referenced by setHandlers().

151  : void {
152  $this->cdata = $this->trimAndStrip($this->cdata);
153  switch ($a_name) {
154  case "Title":
155  $this->style_obj->setTitle($this->cdata);
156  break;
157 
158  case "Description":
159  $this->style_obj->setDescription($this->cdata);
160  break;
161 
162  case "Style":
163  $this->styles[] = $this->current_tags;
164  break;
165 
166  case "StyleTemplate":
167  $this->style_obj->addTemplate(
168  $this->cur_template["type"],
169  $this->cur_template["name"],
170  $this->cur_template_classes
171  );
172  break;
173  }
174  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHandlers()

ilStyleImportParser::setHandlers (   $a_xml_parser)

set event handler should be overwritten by inherited class private

Definition at line 72 of file class.ilStyleImportParser.php.

References handlerBeginTag(), handlerCharacterData(), and handlerEndTag().

72  : void
73  {
74  xml_set_element_handler($a_xml_parser, $this->handlerBeginTag(...), $this->handlerEndTag(...));
75  xml_set_character_data_handler($a_xml_parser, $this->handlerCharacterData(...));
76  }
handlerEndTag( $a_xml_parser, string $a_name)
handlerBeginTag( $a_xml_parser, string $a_name, array $a_attribs)
handlerCharacterData( $a_xml_parser, string $a_data)
+ Here is the call graph for this function:

◆ startParsing()

ilStyleImportParser::startParsing ( )

start the parser

Definition at line 81 of file class.ilStyleImportParser.php.

81  : void
82  {
83  $this->styles = array();
84  parent::startParsing();
85  $this->style_obj->setStyle($this->styles);
86  $this->style_obj->setCharacteristics($this->chars);
87  }

◆ trimAndStrip()

ilStyleImportParser::trimAndStrip ( string  $input)
protected

Definition at line 204 of file class.ilStyleImportParser.php.

References ilUtil\stripSlashes().

Referenced by handlerEndTag(), and trimAndStripAttribs().

204  : string
205  {
206  return ilUtil::stripSlashes(trim($input));
207  }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ trimAndStripAttribs()

ilStyleImportParser::trimAndStripAttribs ( array  $attribs)
protected

Definition at line 195 of file class.ilStyleImportParser.php.

References trimAndStrip().

Referenced by handlerBeginTag().

195  : array
196  {
197  $ret = [];
198  foreach ($attribs as $k => $v) {
199  $ret[$k] = $this->trimAndStrip((string) $v);
200  }
201  return $ret;
202  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $cdata

string ilStyleImportParser::$cdata = ""
protected

Definition at line 30 of file class.ilStyleImportParser.php.

◆ $chars

array ilStyleImportParser::$chars = []
protected

Definition at line 41 of file class.ilStyleImportParser.php.

◆ $color_manager

Content ColorManager ilStyleImportParser::$color_manager
protected

Definition at line 40 of file class.ilStyleImportParser.php.

◆ $cur_template

array ilStyleImportParser::$cur_template
protected

Definition at line 32 of file class.ilStyleImportParser.php.

◆ $cur_template_classes

array ilStyleImportParser::$cur_template_classes
protected

Definition at line 31 of file class.ilStyleImportParser.php.

◆ $current_class

string ilStyleImportParser::$current_class = ""
protected

Definition at line 35 of file class.ilStyleImportParser.php.

◆ $current_tag

string ilStyleImportParser::$current_tag = ""
protected

Definition at line 36 of file class.ilStyleImportParser.php.

◆ $current_tags

array ilStyleImportParser::$current_tags = []
protected

Definition at line 33 of file class.ilStyleImportParser.php.

Referenced by handlerEndTag().

◆ $current_type

string ilStyleImportParser::$current_type = ""
protected

Definition at line 34 of file class.ilStyleImportParser.php.

◆ $style_obj

ilObjStyleSheet ilStyleImportParser::$style_obj
protected

Definition at line 38 of file class.ilStyleImportParser.php.

◆ $styles

array ilStyleImportParser::$styles
protected

Definition at line 37 of file class.ilStyleImportParser.php.

◆ $tree

ilTree ilStyleImportParser::$tree
protected

Definition at line 39 of file class.ilStyleImportParser.php.


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