/**
  *
  * Stores any files that need to be stored
  */
 protected function store(general_cc_file $doc, $outdir, $title, $deps = null)
 {
     $rdir = new cc_resource_location($outdir);
     $rtp = $rdir->fullpath(true) . $this->defaultname;
     if ($doc->saveTo($rtp)) {
         $resource = new cc_resource($rdir->rootdir(), $this->defaultname, $rdir->dirname(true));
         $resource->dependency = empty($deps) ? array() : $deps;
         $res = $this->manifest->add_resource($resource, null, $this->cc_type);
         $resitem = new cc_item();
         $resitem->attach_resource($res[0]);
         $resitem->title = $title;
         $this->item->add_child_item($resitem);
     } else {
         throw new RuntimeException("Unable to save file {$rtp}!");
     }
 }
示例#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;
 }