4 include_once(
"Services/MetaData/classes/class.ilMDSaxParser.php");
5 include_once(
"Services/MetaData/classes/class.ilMD.php");
6 include_once(
'Services/Utilities/interfaces/interface.ilSaxSubsetParser.php');
8 include_once
'./Modules/WebResource/classes/class.ilLinkResourceItems.php';
9 include_once
'./Modules/WebResource/classes/class.ilWebLinkXmlParserException.php';
10 include_once
'./Modules/WebResource/classes/class.ilParameterAppender.php';
27 private $mode = self::MODE_UNDEFINED;
73 $this->mode = $a_mode;
105 xml_set_object($a_xml_parser, $this);
106 xml_set_element_handler($a_xml_parser,
'handlerBeginTag',
'handlerEndTag');
107 xml_set_character_data_handler($a_xml_parser,
'handlerCharacterData');
123 if ($this->in_metadata) {
124 parent::handlerBeginTag($a_xml_parser, $a_name, $a_attribs);
130 $this->in_metadata =
true;
136 parent::handlerBeginTag($a_xml_parser, $a_name, $a_attribs);
141 $this->current_sorting_position = ($a_attribs[
'position'] ? $a_attribs[
'position'] : 0);
142 $this->current_link_update =
false;
143 $this->current_link_delete =
false;
144 $this->current_parameters = array();
146 if ($this->
getMode() == self::MODE_CREATE or (isset($a_attribs[
'action']) and $a_attribs[
'action'] ==
'Create')) {
149 } elseif ($this->
getMode() == self::MODE_UPDATE and $a_attribs[
'action'] ==
'Delete') {
150 $this->current_link_delete =
true;
152 $this->current_link->delete($a_attribs[
'id']);
154 } elseif ($this->
getMode() == self::MODE_UPDATE and ($a_attribs[
'action'] ==
'Update' or !isset($a_attribs[
'action']))) {
156 $this->current_link->readItem($a_attribs[
'id']);
157 $this->current_link_update =
true;
160 include_once
'./Modules/WebResource/classes/class.ilParameterAppender.php';
163 $param->delete($param_id);
170 $this->current_link->setActiveStatus($a_attribs[
'active'] ? 1 : 0);
173 if (!isset($a_attribs[
'valid'])) {
176 $valid = $a_attribs[
'valid'] ? 1 : 0;
178 $this->current_link->setValidStatus(
$valid);
181 $this->current_link->setDisableCheckStatus($a_attribs[
'disableValidation'] ? 1 : 0);
184 if (isset($a_attribs[
'internal'])) {
185 $this->current_link->setInternal($a_attribs[
'internal']);
192 include_once
'./Services/Container/classes/class.ilContainerSortingSettings.php';
196 switch ($a_attribs[
'type']) {
209 $this->sorting_positions = array();
217 case 'DynamicParameter':
220 $param->setName($a_attribs[
'name']);
222 switch ($a_attribs[
'type']) {
231 case 'matriculation':
240 $this->current_parameters[] =
$param;
255 $this->cdata = $this->
trimAndStrip((
string) $this->cdata);
257 if ($this->in_metadata) {
258 parent::handlerEndTag($a_xml_parser, $a_name);
264 $this->in_metadata =
false;
265 parent::handlerEndTag($a_xml_parser, $a_name);
269 $this->
getWebLink()->MDUpdateListener(
'General');
273 include_once
'./Services/Container/classes/class.ilContainerSorting.php';
275 $sorting->savePost($this->sorting_positions);
281 if ($this->current_link_delete) {
284 if (!$this->current_link) {
287 if (!$this->current_link->validate()) {
291 if ($this->current_link_update) {
292 $this->current_link->update();
294 $this->current_link->add();
298 foreach ($this->current_parameters as
$param) {
299 $param->add($this->current_link->getLinkId());
304 $this->sorting_positions[$this->current_link->getLinkId()] = (int) $this->current_sorting_position;
306 unset($this->current_link);
310 if ($this->current_link) {
311 $this->current_link->setTitle(trim($this->cdata));
316 if ($this->current_link) {
317 $this->current_link->setDescription(trim($this->cdata));
322 if ($this->current_link) {
323 $this->current_link->setTarget(trim($this->cdata));
342 if ($this->in_metadata) {
343 parent::handlerCharacterData($a_xml_parser, $a_data);
346 if ($a_data !=
"\n") {
348 $a_data = preg_replace(
"/\t+/",
" ", $a_data);
349 $this->cdata .= $a_data;
XML parser for weblink xml.
trimAndStrip(string $input)
static getParameterIds($a_webr_id, $a_link_id)
Get Parameter ids of link.
startParsing()
stores xml data in array
setMode($a_mode)
Set parsing mode.
const LINKS_MATRICULATION
trimAndStripAttribs(array $attribs)
setThrowException($throwException)
set error handling
$current_sorting_position
SaxParserException thrown by ilSaxParser if property throwException is set.
getMode()
Return parsing mode.
setHandlers($a_xml_parser)
set event handlers
getWebLink()
Get weblink object.
__construct($webr, $xml)
Constructor.
handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
handler for begin of element
handlerCharacterData($a_xml_parser, $a_data)
handler for character data
__construct(Container $dic, ilPlugin $plugin)
Class ilLinkResourceItems.
Class ilParameterAppender.
setWebLink(ilObject $webl)
set weblink
static getLogger($a_component_id)
Get component logger.
static _getInstance($a_obj_id)
get instance by obj_id
setXMLContent($a_xml_content)
handlerEndTag($a_xml_parser, $a_name)
handler for end of element