/**
  * Load assets from the custom elements (CustomInteraction, PCI, PIC)
  * @param Element $element the custom element
  */
 private function loadCustomElementAssets(Element $element)
 {
     if ($element instanceof PortableCustomInteraction || $element instanceof PortableInfoControl) {
         $this->addAsset('js', $element->getEntryPoint());
         foreach ($element->getLibraries() as $lib) {
             $this->addAsset('js', $lib);
         }
     }
     //parse and extract assets from markup using XPATH
     if ($element instanceof CustomInteraction || $element instanceof InfoControl) {
         $xml = new SimpleXMLElement($element->getMarkup());
         foreach ($xml->xpath('//img') as $img) {
             $this->addAsset('img', (string) $img['src']);
         }
         foreach ($xml->xpath('//video') as $video) {
             $this->addAsset('video', (string) $video['src']);
         }
         foreach ($xml->xpath('//audio') as $audio) {
             $this->addAsset('audio', (string) $audio['src']);
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Load assets from the custom elements (CustomInteraction, PCI, PIC)
  * @param Element $element the custom element
  */
 private function loadCustomElementAssets(Element $element)
 {
     if ($this->getGetCustomElementDefinition()) {
         if ($element instanceof PortableCustomInteraction) {
             $this->assets['PCI'][$element->getTypeIdentifier()] = $element;
         }
         if ($element instanceof PortableInfoControl) {
             $this->assets['PIC'][$element->getTypeIdentifier()] = $element;
         }
     }
     $xmls = array();
     if ($element instanceof PortableCustomInteraction || $element instanceof PortableInfoControl) {
         //some portable elements contains htmlentitied markup in their properties...
         $xmls = $this->getXmlProperties($element->getProperties());
     }
     //parse and extract assets from markup using XPATH
     if ($element instanceof CustomInteraction || $element instanceof InfoControl) {
         // http://php.net/manual/fr/simplexmlelement.xpath.php#116622
         $sanitizedMarkup = str_replace('xmlns=', 'ns=', $element->getMarkup());
         $xmls[] = new SimpleXMLElement($sanitizedMarkup);
         $this->loadCustomElementPropertiesAssets($element->getProperties());
         /** @var SimpleXMLElement $xml */
         foreach ($xmls as $xml) {
             foreach ($xml->xpath('//img') as $img) {
                 $this->addAsset('img', (string) $img['src']);
             }
             foreach ($xml->xpath('//video') as $video) {
                 $this->addAsset('video', (string) $video['src']);
             }
             foreach ($xml->xpath('//audio') as $audio) {
                 $this->addAsset('audio', (string) $audio['src']);
             }
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Load assets from the custom elements (CustomInteraction, PCI, PIC)
  * @param Element $element the custom element
  */
 private function loadCustomElementAssets(Element $element)
 {
     $libBasePath = ROOT_PATH . 'taoQtiItem/views/js/portableSharedLibraries';
     $libRootUrl = ROOT_URL . 'taoQtiItem/views/js/portableSharedLibraries';
     if ($element instanceof PortableCustomInteraction || $element instanceof PortableInfoControl) {
         $entryPoint = $element->getEntryPoint();
         $fileName = substr($entryPoint, -3) != '.js' ? $entryPoint . '.js' : $entryPoint;
         $this->addAsset('js', $fileName);
         foreach ($element->getLibraries() as $lib) {
             if ($this->getGetSharedLibraries() || !ClientLibRegistry::getRegistry()->isRegistered($lib)) {
                 $fileName = substr($lib, -3) != '.js' ? $lib . '.js' : $lib;
                 $this->addAsset('js', $fileName);
             }
         }
     }
     //parse and extract assets from markup using XPATH
     if ($element instanceof CustomInteraction || $element instanceof InfoControl) {
         $xml = new SimpleXMLElement($element->getMarkup());
         foreach ($xml->xpath('//img') as $img) {
             $this->addAsset('img', (string) $img['src']);
         }
         foreach ($xml->xpath('//video') as $video) {
             $this->addAsset('video', (string) $video['src']);
         }
         foreach ($xml->xpath('//audio') as $audio) {
             $this->addAsset('audio', (string) $audio['src']);
         }
     }
 }