PHP Classes

simplification

Recommend this page to a friend!

      PHP DOCX Metadata  >  All threads  >  simplification  >  (Un) Subscribe thread alerts  
Subject:simplification
Summary:simplification
Messages:2
Author:Yves Marie HAMAYON
Date:2013-10-09 21:09:21
Update:2013-10-12 00:54:13
 

  1. simplification   Reply   Report abuse  
Picture of Yves Marie HAMAYON Yves Marie HAMAYON - 2013-10-09 21:09:22
class docxmetadata{
var $metadocument = "";
var $mxsi = "xsi:type=\"dcterms:W3CDTF\"";

function setDocument($path){
$zip = new ZipArchive;
$res = $zip->open($path);
if ($res === TRUE) {
$folder = md5(time());
mkdir($folder, 0700);
$zip->extractTo($folder, array("docProps/core.xml"));
$zip->close();
$this->metadocument = file_get_contents($folder."/docProps/core.xml");
unlink($folder."/docProps/core.xml");
rmdir($folder."/docProps");
rmdir($folder);
}
}
function getMeta($x, $dc="dc", $xsi=''){
$r = "";
$s = explode("</$dc:$x>", $this->metadocument);
// pr($s);
print_r("<$dc:$x $xsi>");
$e = explode("<$dc:$x $xsi>", $s[0]);

$r = isset($e[1]) ? $e[1] : "";
return $r;
}
function getDateCreated(){
return $this->getMeta("created", 'dcterms', $this->mxsi);
}

function getDateModified(){
return $this->getMeta("modified", 'dcterms', $this->mxsi);
}
function getTitle(){
return $this->getMeta("title");
}

function getSubject(){
return $this->getMeta("subject");
}

function getCreator(){
return $this->getMeta("creator");
}

function getKeywords(){
return $this->getMeta("keywords", 'cp');
}

function getDescription(){
return $this->getMeta("description");
}

function getLastModifiedBy(){
return $this->getMeta("lastModifiedBy", 'cp');
}

function getRevision(){
return $this->getMeta("revision", 'cp');
}

}

  2. Re: simplification   Reply   Report abuse  
Picture of Miftakhul Ulum Miftakhul Ulum - 2013-10-12 00:54:13 - In reply to message 1 from Yves Marie HAMAYON
Thank you, you are the best! :D