/** * @see \qtism\runtime\rendering\markup\xhtml\AbstractXhtmlRenderer::appendAttributes() */ protected function appendAttributes(DOMDocumentFragment $fragment, QtiComponent $component, $base = '') { parent::appendAttributes($fragment, $component, $base); $this->additionalClass('qti-' . $component->getQtiClassName()); if ($component->hasId() === true) { $fragment->firstChild->setAttribute('id', $component->getId()); } if ($component->hasClass() === true) { $classes = explode(" ", $component->getClass()); foreach ($classes as $class) { $this->additionalUserClass($class); } } if ($component->hasLang() === true) { $fragment->firstChild->setAttribute('lang', $component->getLang()); } if ($component->getDir() !== Direction::AUTO) { $fragment->firstChild->setAttribute('dir', Direction::getNameByConstant($component->getDir())); } }
/** * Set the direction in which body elements must be displayed. * * @param integer $dir A value from the Direction enumeration. * @throws InvalidArgumentException If $dir is not a value from the Direction enumeration. */ public function setDir($dir) { if (in_array($dir, Direction::asArray()) === true) { $this->dir = $dir; } else { $msg = "The 'dir' argument must be a value from the Direction enumeration."; throw new InvalidArgumentException($msg); } }
/** * Fill $element with the attributes of $bodyElement. * * @param DOMElement $element The element from where the atribute values will be * @param BodyElement $bodyElement The bodyElement to be fill. */ protected function fillElement(DOMElement $element, BodyElement $bodyElement) { if (($id = $bodyElement->getId()) !== '') { $element->setAttribute('id', $id); } if (($class = $bodyElement->getClass()) !== '') { $element->setAttribute('class', $class); } if (($lang = $bodyElement->getLang()) !== '') { $element->setAttributeNS('http://www.w3.org/XML/1998/namespace', 'xml:lang', $lang); } if (($label = $bodyElement->getLabel()) != '') { $element->setAttribute('label', $label); } $version = $this->getVersion(); if (Version::compare($version, '2.2.0', '>=') === true && ($dir = $bodyElement->getDir()) !== Direction::AUTO && in_array($bodyElement->getQtiClassName(), self::$dirClasses) === true) { $element->setAttribute('dir', Direction::getNameByConstant($dir)); } }