/** * Gets a tag representation instance * * @param CMS_XMLTag $tag The xml tag from which to build the representation * @param array(mixed) $args The arguments needed to build * @return object The module tag representation instance * @access public */ function getTagRepresentation($tag, $args) { switch ($tag->getName()) { case "block": //try to guess the class to instanciate $class_name = "CMS_block_cms_forms"; if (class_exists($class_name)) { $instance = new $class_name(); } else { $this->raiseError("Unknown block type : CMS_block_cms_forms"); return false; } $instance->initializeFromTag($tag->getAttributes(), $tag->getInnerContent()); return $instance; break; case "atm-clientspace": if ($tag->getAttribute("type")) { $instance = new CMS_moduleClientspace($tag->getAttributes()); return $instance; } else { return false; } break; } }
/** * Gets a tag representation instance * * @param CMS_XMLTag $tag The xml tag from which to build the representation * @param array(mixed) $args The arguments needed to build * @return object The module tag representation instance * @access public */ function getTagRepresentation($tag, $args) { switch ($tag->getName()) { case "block": //try to guess the class to instanciate $class_name = "CMS_block_polymod"; if (class_exists($class_name)) { $instance = new $class_name(); } else { $this->raiseError("Unknown block type : CMS_block_polymod"); return false; } //pr(io::htmlspecialchars($tag->getInnerContent())); $instance->initializeFromTag($tag->getAttributes(), $tag->getInnerContent()); return $instance; break; } }
/** * Constructor. * initializes the linx. * * @param string $type The linx type * @param string $tagContent The tag content. * @param CMS_page $page The page we're parsing * @param boolean $publicTree Does the linx must be calculated in the public or edited tree ? * @return void * @access public */ function __construct($type, $tagContent, $page, $publicTree = false, $args = array()) { if (!SensitiveIO::isInSet($type, CMS_linxesCatalog::getAllTypes())) { $this->raiseError("Constructor has an unknown type : " . $type); return; } elseif (!is_a($page, "CMS_page")) { $this->raiseError("Constructor was not given a valid CMS_page"); return; } else { $this->_args = $args; $this->_type = $type; //Hack for shorthand writing of atm-linx //<atm-linx type="direct" node="pageID"> ... </atm-linx> //<atm-linx type="direct" codename="pageCodename"> ... </atm-linx> if ((isset($this->_args['node']) || isset($this->_args['codename'])) && $this->_type == 'direct') { $tag = new CMS_XMLTag('atm-linx', $this->_args); $tag->setTextContent($tagContent); $tagContent = '<atm-linx type="direct">' . '<selection ' . (isset($this->_args['crosswebsite']) ? ' crosswebsite="' . $this->_args['crosswebsite'] . '"' : '') . '>'; if (isset($this->_args['node'])) { $tagContent .= '<start><nodespec type="node" value="' . $this->_args['node'] . '" /></start>'; //remove useless node argument unset($this->_args['node']); } else { $tagContent .= '<start><nodespec type="codename" value="' . $this->_args['codename'] . '" /></start>'; //remove useless node argument unset($this->_args['codename']); } $tagContent .= '</selection>' . '<display>' . '<htmltemplate>' . $tag->getInnerContent() . '</htmltemplate>' . '</display>' . '</atm-linx>'; } $this->_page = $page; $this->_publicTree = $publicTree; $domdocument = new CMS_DOMDocument(); try { $domdocument->loadXML($tagContent); } catch (DOMException $e) { $this->raiseError('Malformed atm-linx content in page ' . $page->getID() . ' : ' . $e->getMessage() . "\n" . $tagContent, true); return false; } $selections = $domdocument->getElementsByTagName('selection'); if ($selections->length > 0) { $selection = $selections->item(0); //parse the selection for nodespecs and condition if (!$this->_parseSelection($selection)) { $this->raiseError(); return; } } $noselections = $domdocument->getElementsByTagName('noselection'); if ($noselections->length > 0) { $this->_noselection = $noselections->item(0); } $displays = $domdocument->getElementsByTagName('display'); //get the displays objects $unsortedDisplays = array(); foreach ($displays as $display) { $unsortedDisplays[] = new CMS_linxDisplay($display); } //put the default display (the one with no condition) at the end of the array $default = false; foreach ($unsortedDisplays as $dsp) { if ($dsp->hasCondition() && !$default) { $this->_displays[] = $dsp; } else { $default = $dsp; } } if ($default) { $this->_displays[] = $default; } } }
/** * Gets a tag representation instance * * @param CMS_XMLTag $tag The xml tag from which to build the representation * @param array(mixed) $args The arguments needed to build * @return object The module tag representation instance * @access public */ function getTagRepresentation($tag, $args) { switch ($tag->getName()) { case "atm-clientspace": if ($args["template"] && $tag->getAttribute("id")) { $args["editedMode"] = isset($args["editedMode"]) ? $args["editedMode"] : null; $instance = new CMS_moduleClientspace_standard($args["template"], $tag->getAttribute("id"), $args["editedMode"]); return $instance; } else { return false; } break; case "block": if ($tag->getAttribute("type")) { //try to guess the class to instanciate $class_name = "CMS_block_" . $tag->getAttribute("type"); if (class_exists($class_name)) { $instance = new $class_name(); } else { //not found. Place here block types requiring special attention switch ($tag->getAttribute("type")) { default: $this->raiseError("Unknown block type : " . $tag->getAttribute("type")); return false; break; } } $instance->initializeFromTag($tag->getAttributes(), $tag->getInnerContent()); return $instance; } else { return false; } break; } }