* @package taoQtiItem */ class XInclude extends Element implements FlowContainer { /** * the QTI tag name as defined in QTI standard * * @access protected * @var string */ protected static $qtiTagName = 'include'; protected $body = null; public function __construct($attributes = [], Item $relatedItem = null, $serial = '') { parent::__construct($attributes, $relatedItem, $serial); $this->body = new ContainerStatic('', $relatedItem); } /** * Get the body of XInclude element * * @return oat\taoQtiItem\model\qti\container\ContainerStatic */ public function getBody() { return $this->body; } /** * Get the list of used attributes * * @return array */ public function getUsedAttributes() { return []; } /** * Get the variables for the qti template rendering * * @return array */ protected function getTemplateQtiVariables() { $variables = parent::getTemplateQtiVariables(); $tag = static::$qtiTagName; //search existing mathML ns declaration: $ns = $this->getXIncludeNamespace(); if (empty($ns)) { //add one! $relatedItem = $this->getRelatedItem(); if (!is_null($relatedItem)) { $ns = 'xi'; $relatedItem->addNamespace($ns, 'http://www.w3.org/2001/XInclude'); } } if (!empty($ns)) { //proceed to ns addition: $tag = $ns . ':' . $tag; } $variables['tag'] = $tag; return $variables; } /** * Get the xml namespace of the xinclude * * @return string */ public function getXIncludeNamespace() { $ns = ''; $relatedItem = $this->getRelatedItem(); if (!is_null($relatedItem)) { foreach ($relatedItem->getNamespaces() as $name => $uri) { if (strpos($uri, 'XInclude') > 0) { $ns = $name; break; } } } return $ns; } /** * Get the absolute path of the template of the qti.xml * * @return string */ public static function getTemplateQti() { return static::getTemplatePath() . '/qti.include.tpl.php'; } }