Marshall a TemplateDefault object into a DOMElement object.

@param \qtism\data\QtiComponent $component A TemplateDefault object.
@return \DOMElement The according DOMElement object.
554148
protected function marshall(QtiComponent $component)
    {
        $element = static::getDOMCradle()->createElement($component->getQtiClassName());

        $this->setDOMElementAttribute($element, 'templateIdentifier', $component->getTemplateIdentifier());

        $expr = $component->getExpression();
        $exprMarshaller = $this->getMarshallerFactory()->createMarshaller($expr);
        $exprElt = $exprMarshaller->marshall($expr);

        $element->appendChild($exprElt);

        return $element;
    }
503289
public function getChildrenRenderings(QtiComponent $component)
    {
        $returnValue = array();

        foreach (array_reverse($component->getComponents()->getArrayCopy()) as $c) {

            if (count($this->getRenderingStack()) > 0) {
                list($renderedComponent, $rendering) = $this->getRenderingStack()->pop();

                if ($c === $renderedComponent) {
                    array_unshift($returnValue, $rendering);
                } else {
                    // repush...
                    $this->storeRendering($renderedComponent, $rendering);
                }
            }
        }

        return $returnValue;
    }
1186804
protected function marshall(QtiComponent $component)
    {
        $element = $this->createElement($component);
        $version = $this->getVersion();
        
        $this->setDOMElementAttribute($element, 'identifier', $component->getIdentifier());
        $this->setDOMElementAttribute($element, 'base', $component->getBase());
        
        if (Version::compare($version, '2.1.0', '>=') === true) {
            $this->setDOMElementAttribute($element, 'powerForm', $component->mustPowerForm());
            $this->setDOMElementAttribute($element, 'delimiter', $component->getDelimiter());
            $this->setDOMElementAttribute($element, 'mappingIndicator', $component->getMappingIndicator());
        }

        if ($component->hasFormat() === true) {
            $this->setDOMElementAttribute($element, 'format', $component->getFormat());
        }

        if ($component->hasIndex() === true) {
            $this->setDOMElementAttribute($element, 'index', $component->getIndex());
        }

        if ($component->hasField() === true) {
            $this->setDOMElementAttribute($element, 'field', $component->getField());
        }

        if ($component->hasXmlBase() === true) {
            self::setXmlBase($element, $component->getXmlBase());
        }

        $this->fillElement($element, $component);

        return $element;
    }
400266
public function addComponent(ComponentInterface $component)
    {
        $component->preMergeParams($this);
        return $this->overwriteWith($component->toArray());
    }
539073
public function unmarshall(DOMElement $element)
    {
        if (($responseIdentifier = $this->getDOMElementAttributeAs($element, 'responseIdentifier')) !== null) {
            
            if (($minConstraint = $this->getDOMElementAttributeAs($element, 'minConstraint', 'integer')) !== null) {
                
                if (($maxConstraint = $this->getDOMElementAttributeAs($element, 'maxConstraint', 'integer')) !== null) {
                    
                    if (($patternMask = $this->getDOMElementAttributeAs($element, 'patternMask')) === null) {
                        $patternMask = '';
                    }
                    try {
                        $component = new ResponseValidityConstraint($responseIdentifier, $minConstraint, $maxConstraint, $patternMask);
                    
                        // Find child associationValidityConstraint elements if any.
                        $associationValidityConstraintElts = $this->getChildElementsByTagName($element, 'associationValidityConstraint');
                            
                        foreach ($associationValidityConstraintElts as $associationValidityConstraintElt) {
                            $marshaller = $this->getMarshallerFactory()->createMarshaller($associationValidityConstraintElt);
                            $component->addAssociationValidityConstraint($marshaller->unmarshall($associationValidityConstraintElt));
                        }
                        
                        return $component;
                    } catch (InvalidArgumentException $e) {
                        throw new UnmarshallingException(
                            "An error occured while unmarshalling a 'responseValidityConstraint'. See chained exceptions for more information.",
                            $element,
                            $e
                        );
                    }
                    
                } else {
                    throw new UnmarshallingException(
                        "The mandatory 'maxConstraint' attribute is missing from element 'responseValididtyConstraint'.",
                        $element
                    );
                }
            } else {
                throw new UnmarshallingException(
                    "The mandatory 'minConstraint' attribute is missing from element 'responseValididtyConstraint'.",
                    $element
                );
            }
        } else {
            throw new UnmarshallingException(
                "The mandatory 'responseIdentifier' attribute is missing from element 'responseValididtyConstraint'.",
                $element
            );
        }
    }
1067539
protected function createFinalRendering(QtiComponent $component)
    {
        $dom = $this->getDocument();
        if (($last = $this->getLastRendering()) !== null) {
            $dom->appendChild($last);
        }

        // If we are rendering an item, let's try to find some Math to
        // for template variable mapping. 
        if ($component instanceof AssessmentItem && count($templateDeclarations = $component->getTemplateDeclarations()) > 0) {
            $xpath = new DOMXPath($dom);
            $xpath->registerNamespace('m', 'http://www.w3.org/1998/Math/MathML');
            $maths = $xpath->query('//m:math|//math');
            
            if ($maths->length > 0) {
                $printedVariableRenderer = new PrintedVariableRenderer($this);
                
                foreach ($templateDeclarations as $templateDeclaration) {
                    if ($templateDeclaration->isMathVariable() === true) {
                        $templateIdentifier = $templateDeclaration->getIdentifier();
                        
                        foreach ($maths as $math) {
                            // Find <mi> and <ci> elements.
                            foreach ($xpath->query(".//m:mi[text() = '${templateIdentifier}']|.//m:ci[text() = '${templateIdentifier}']|.//mi[text() = '${templateIdentifier}']|.//ci[text() = '${templateIdentifier}']", $math) as $mathElement) {
                                $localElementName = ($mathElement->localName === 'mi') ? 'mn' : 'cn';
                                $newMathElement = $mathElement->ownerDocument->createElement($localElementName);
                                $printedVariable = new PrintedVariable($templateIdentifier);
                                $printedVariableFragment = $printedVariableRenderer->render($printedVariable);
                                
                                if ($this->getPrintedVariablePolicy() === self::CONTEXT_STATIC) {
                                    foreach ($printedVariableFragment->childNodes as $node) {
                                        $newMathElement->appendChild($node);
                                        $mathElement->parentNode->replaceChild($newMathElement, $mathElement);
                                    }
                                } else if ($this->getPrintedVariablePolicy() === self::CONTEXT_AWARE) {
                                    $newMathElement->appendChild($newMathElement->ownerDocument->createTextNode($printedVariableFragment->firstChild->nodeValue));
                                    $mathElement->parentNode->replaceChild($newMathElement, $mathElement);
                                } else {
                                    foreach ($printedVariableFragment->firstChild->childNodes as $node) {
                                        $newMathElement->appendChild($node);
                                        $mathElement->parentNode->replaceChild($newMathElement, $mathElement);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        return $dom;
    }
681026
protected function marshall(QtiComponent $component)
    {
        $element = static::getDOMCradle()->createElement($component->getQtiClassName());

        $this->setDOMElementAttribute($element, 'sourceValue', $component->getSourceValue());
        $this->setDOMElementAttribute($element, 'targetValue', $component->getTargetValue());

        return $element;
    }
869886
public function getTemplateManager() {
		// if the component has not been created yet
		if (!isset($this->templateManager)) {
			// create the component
			$this->templateManager = new TemplateManager($this->templatesPath, $this->frameworkStoragePath . self::TEMPLATES_CACHE_SUBFOLDER);

			// add the current instance as a global to the template manager
			$this->templateManager->addGlobal('app', $this);
		}

		// return the component
		return $this->templateManager;
	}
566126
public function getComponent($component)
    {
        if (isset($this->_components[$component])) {
            return self::createComponents($this->_components[$component]);
        } else {
            throw new \Exception($component . '组件不存在');
        }
    }
585113
static public function getRootElementClass($component)
    {
        if (!is_string($component)) $component = $component->getData()->componentClass;
        $ret = '';
        if (self::hasSetting($component, 'rootElementClass')) {
            $ret .= self::getSetting($component, 'rootElementClass').' ';
        }
        $ret .= Kwf_Component_Abstract::formatRootElementClass($component, '');
        return $ret;
    }
420747
protected function marshall(QtiComponent $component)
    {
        $element = static::getDOMCradle()->createElement($component->getQtiClassName());
        foreach ($component->getInterpolationTableEntries() as $interpolationTableEntry) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($interpolationTableEntry, array($this->getBaseType()));
            $element->appendChild($marshaller->marshall($interpolationTableEntry));
        }

        if ($component->getDefaultValue() !== null) {
            $this->setDOMElementAttribute($element, 'defaultValue', $component->getDefaultValue());
        }

        return $element;
    }
911978
public function removeComponent(IComponent $component)
	{
		$name = $component->getName();
		if (!isset($this->components[$name]) || $this->components[$name] !== $component) {
			throw new Nette\InvalidArgumentException("Component named '$name' is not located in this container.");
		}

		unset($this->components[$name]);
		$component->setParent(NULL);
	}
162156
public function marshall(QtiComponent $component)
    {
        $element = self::getDOMCradle()->createElement('responseValidityConstraint');
        $this->setDOMElementAttribute($element, 'responseIdentifier', $component->getResponseIdentifier());
        $this->setDOMElementAttribute($element, 'minConstraint', $component->getMinConstraint());
        $this->setDOMElementAttribute($element, 'maxConstraint', $component->getMaxConstraint());
        
        if (($patternMask = $component->getPatternMask()) !== '') {
            $this->setDOMElementAttribute($element, 'patternMask', $patternMask);
        }
        
        foreach ($component->getAssociationValidityConstraints() as $associationValidityConstraint) {
            $marshaller = $this->getMarshallerFactory()->createMarshaller($associationValidityConstraint);
            $element->appendChild($marshaller->marshall($associationValidityConstraint));
        }

        return $element;
    }
259597
public function setTable(ContainerComponentInterface $component)
    {
        return $this->setComponent($component, Grid::TABLE_ID, Grid::FORM_ID);
    }
511327
protected function identifierMatches(QtiComponent $component)
    {
        $variableIdentifier = ($component instanceof FeedbackElement || $component instanceof ModalFeedback) ? $component->getOutcomeIdentifier() : $component->getTemplateIdentifier();
        $identifier = new QtiIdentifier($component->getIdentifier());
        $showHide = $component->getShowHide();
        $state = $this->getState();
        
        $matches = false;
        
        if (($val = $state[$variableIdentifier]) !== null) {
            if ($val instanceof QtiScalar) {
                $matches = $val->equals($identifier);
            } elseif ($val instanceof Container) {
                $matches = $val->contains($identifier);
            }
        }
        
        return $matches;
    }
749210
private function filter( $component )
    {
        if( $component instanceof FilterableComponentInterface )
        {
            $filter = $component->filter;

            if( is_callable( $filter ) ) 
            {
                $component->value = \call_user_func_array($filter, array($this->final_instance[$component->name]));
                $this->final_instance[$component->name] = $component->value;
            }
        }
    }
96016
function apply (Component $component)
  {
    if ($component->supportsProperties()) {
      if ($this->props)
        $component->props->applyDefaults ($this->props);
      if ($this->unset)
        foreach ($this->unset as $prop)
          unset ($component->props->$prop);
    }

    if ($this->content) {
      $component->removeChildren();
      Metadata::compile ($this->content, $component);
    }
    if ($this->prepend)
      Metadata::compile ($this->prepend, $component, true);
    if ($this->append)
      Metadata::compile ($this->append, $component);
  }