Ejemplo n.º 1
0
 /**
  * Import a resource
  *
  * @param DOMElement $node
  * @param cc_i_manifest $doc
  */
 public function import_resource(DOMElement &$node, cc_i_manifest &$doc)
 {
     $searchstr = "//imscc:manifest[@identifier='" . $doc->manifestID() . "']/imscc:resources/imscc:resource";
     $this->identifier = $this->get_attr_value($node, "identifier");
     $this->type = $this->get_attr_value($node, "type");
     $this->href = $this->get_attr_value($node, "href");
     $this->base = $this->get_attr_value($node, "base");
     $this->persiststate = null;
     $nodo = $doc->nodeList($searchstr . "[@identifier='" . $this->identifier . "']/metadata/@href");
     $this->metadata = $nodo->nodeValue;
     $this->filename = $this->href;
     $nlist = $doc->nodeList($searchstr . "[@identifier='" . $this->identifier . "']/imscc:file/@href");
     $this->files = array();
     foreach ($nlist as $file) {
         $this->files[] = $file->nodeValue;
     }
     $nlist = $doc->nodeList($searchstr . "[@identifier='" . $this->identifier . "']/imscc:dependency/@identifierref");
     $this->dependency = array();
     foreach ($nlist as $dependency) {
         $this->dependency[] = $dependency->nodeValue;
     }
     $this->isempty = false;
 }
Ejemplo n.º 2
0
 public static function add_files(cc_i_manifest &$manifest, $packageroot, $outdir, $allinone = true)
 {
     if (pkg_static_resources::instance()->finished) {
         return;
     }
     $files = cc_helpers::embedded_mapping($packageroot);
     $rdir = $allinone ? new cc_resource_location($outdir) : null;
     foreach ($files as $virtual => $values) {
         $clean_filename = $values[2];
         if (!$allinone) {
             $rdir = new cc_resource_location($outdir);
         }
         $rtp = $rdir->fullpath() . $values[7] . $clean_filename;
         //Are there any relative virtual directories?
         //let us try to recreate them
         $justdir = $rdir->fullpath(false) . $values[7];
         if (!file_exists($justdir)) {
             if (!mkdir($justdir, 0777, true)) {
                 throw new RuntimeException('Unable to create directories!');
             }
         }
         $source = $packageroot . DIRECTORY_SEPARATOR . $values[0];
         if (!copy($source, $rtp)) {
             throw new RuntimeException('Unable to copy files!');
         }
         $resource = new cc_resource($rdir->rootdir(), $values[7] . $clean_filename, $rdir->dirname(false));
         $res = $manifest->add_resource($resource, null, cc_version11::webcontent);
         pkg_static_resources::instance()->add($virtual, $res[0], $rdir->dirname(false) . $values[7] . $clean_filename, $values[1], $resource);
     }
     pkg_static_resources::instance()->finished = true;
 }