예제 #1
0
 /**
  * Moves the current position to the next QtiComponent object to be
  * traversed.
  */
 public function next()
 {
     if ($this->trailCount > 0) {
         while ($this->trailCount > 0) {
             $trailEntry = $this->popFromTrail();
             $component = $trailEntry[1];
             $source = $trailEntry[0];
             if ($this->isTraversed($component) === false) {
                 $this->currentComponent = $component;
                 $this->currentContainer = $source;
                 $this->pushOnTrail($component, $this->currentComponent->getComponents());
                 $this->markTraversed($this->currentComponent);
                 if (empty($this->classes) === true || in_array($this->currentComponent->getQTIClassName(), $this->classes) === true) {
                     // If all classes are seeked or the current component has a class name
                     // that must be seeked, stop the iteration.
                     return;
                 }
             }
         }
         $this->isValid = false;
         $this->currentContainer = null;
     } else {
         $this->isValid = false;
         $this->currentContainer = null;
     }
 }
 /**
  * Get the renderings related to the children of $component.
  *
  * @param QtiComponent $component A QtiComponent object to be rendered.
  * @return array
  */
 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;
 }