/** * Add a resource to the manifest * * @param cc_i_resource $res * @param string $identifier * @param string $type * @return array */ public function add_resource(cc_i_resource $res, $identifier = null, $type = 'webcontent') { if (!$this->ccobj->valid($type)) { throw new Exception("Type invalid..."); } if (is_null($res)) { throw new Exception('Invalid Resource or dont give it'); } $rst = null; if (is_string($res)) { $rst = new cc_resource($this->filePath(), $res); if (is_string($identifier)) { $rst->identifier = $identifier; } } else { $rst = $res; } //TODO: This has to be reviewed since it does not handle properly mutiple file // dependencies if (is_object($identifier)) { $this->activemanifest->create_resource_node($rst, $this->doc, $identifier); } else { $nresnode = null; $rst->type = $type; if (!cc_helpers::is_html($rst->filename)) { $rst->href = null; } $this->activemanifest->create_resource_node($rst, $this->doc, $nresnode); for ($i = 1; $i < count($rst->files); $i++) { $ident = $this->get_identifier_by_filename($rst->files[$i]); if (empty($ident)) { $newres = new cc_resource($rst->manifestroot, $rst->files[$i], false); if (!empty($newres)) { if (!cc_helpers::is_html($rst->files[$i])) { $newres->href = null; } $newres->type = 'webcontent'; $this->activemanifest->create_resource_node($newres, $this->doc, $nresnode); } } } foreach ($this->activemanifest->resources as $k => $v) { $k; $depen = $this->check_if_exist_in_other($v->files[0]); if (!empty($depen)) { $this->replace_file_x_dependency($depen, $v->files[0]); // coloca aca como type = webcontent porque son archivos dependientes // quizas aqui habria q ver de que type es el que vino y segun eso, ponerlo // en associatedcontent o en webcontent $v->type = 'webcontent'; } } } $tmparray = array($rst->identifier, $rst->files[0]); return $tmparray; }
/** * Add a resource to the manifest * * @param cc_i_resource $res * @param string $identifier * @param string $type * @return array */ public function add_resource(cc_i_resource $res, $identifier = null, $type = 'webcontent') { if (!$this->ccobj->valid($type)) { throw new Exception("Type invalid..."); } if ($res == null) { throw new Exception('Invalid Resource or dont give it'); } $rst = $res; // TODO: This has to be reviewed since it does not handle multiple files properly. // Dependencies. if (is_object($identifier)) { $this->activemanifest->create_resource_node($rst, $this->doc, $identifier); } else { $nresnode = null; $rst->type = $type; if (!cc_helpers::is_html($rst->filename)) { $rst->href = null; } $this->activemanifest->create_resource_node($rst, $this->doc, $nresnode); foreach ($rst->files as $file) { $ident = $this->get_identifier_by_filename($file); if ($ident == null) { $newres = new cc_resource($rst->manifestroot, $file); if (!cc_helpers::is_html($file)) { $newres->href = null; } $newres->type = 'webcontent'; $this->activemanifest->create_resource_node($newres, $this->doc, $nresnode); } } } $tmparray = array($rst->identifier, $rst->files[0]); return $tmparray; }