本文整理汇总了PHP中PhpOffice\PhpPresentation\PhpPresentation::getProperties方法的典型用法代码示例。如果您正苦于以下问题:PHP PhpPresentation::getProperties方法的具体用法?PHP PhpPresentation::getProperties怎么用?PHP PhpPresentation::getProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhpOffice\PhpPresentation\PhpPresentation
的用法示例。
在下文中一共展示了PhpPresentation::getProperties方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testProperties
public function testProperties()
{
$object = new PhpPresentation();
$this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->getProperties());
$this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->getDocumentProperties());
$this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $object->setProperties(new DocumentProperties()));
$this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->getProperties());
$this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->getDocumentProperties());
$this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $object->setDocumentProperties(new DocumentProperties()));
$this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->getProperties());
$this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->getDocumentProperties());
}
示例2: testConstruct
/**
* Test create new instance
*/
public function testConstruct()
{
$object = new PhpPresentation();
$slide = $object->getSlide();
$this->assertEquals(new DocumentProperties(), $object->getProperties());
$this->assertEquals(new DocumentLayout(), $object->getLayout());
$this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->getSlide());
$this->assertEquals(1, count($object->getAllSlides()));
$this->assertEquals(0, $object->getIndex($slide));
$this->assertEquals(1, $object->getSlideCount());
$this->assertEquals(0, $object->getActiveSlideIndex());
$this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Iterator', $object->getSlideIterator());
}
示例3: writePart
/**
* Write Meta file to XML format
*
* @param PhpPresentation $pPhpPresentation
* @return string XML Output
* @throws \Exception
*/
public function writePart(PhpPresentation $pPhpPresentation)
{
// Create XML writer
$objWriter = $this->getXMLWriter();
// XML header
$objWriter->startDocument('1.0', 'UTF-8');
// office:document-meta
$objWriter->startElement('office:document-meta');
$objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
$objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
$objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
$objWriter->writeAttribute('xmlns:presentation', 'urn:oasis:names:tc:opendocument:xmlns:presentation:1.0');
$objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
$objWriter->writeAttribute('xmlns:smil', 'urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0');
$objWriter->writeAttribute('xmlns:anim', 'urn:oasis:names:tc:opendocument:xmlns:animation:1.0');
$objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#');
$objWriter->writeAttribute('xmlns:officeooo', 'http://openoffice.org/2009/office');
$objWriter->writeAttribute('xmlns:drawooo', 'http://openoffice.org/2010/draw');
$objWriter->writeAttribute('office:version', '1.2');
// office:meta
$objWriter->startElement('office:meta');
// dc:creator
$objWriter->writeElement('dc:creator', $pPhpPresentation->getProperties()->getLastModifiedBy());
// dc:date
$objWriter->writeElement('dc:date', gmdate('Y-m-d\\TH:i:s.000', $pPhpPresentation->getProperties()->getModified()));
// dc:description
$objWriter->writeElement('dc:description', $pPhpPresentation->getProperties()->getDescription());
// dc:subject
$objWriter->writeElement('dc:subject', $pPhpPresentation->getProperties()->getSubject());
// dc:title
$objWriter->writeElement('dc:title', $pPhpPresentation->getProperties()->getTitle());
// meta:creation-date
$objWriter->writeElement('meta:creation-date', gmdate('Y-m-d\\TH:i:s.000', $pPhpPresentation->getProperties()->getCreated()));
// meta:initial-creator
$objWriter->writeElement('meta:initial-creator', $pPhpPresentation->getProperties()->getCreator());
// meta:keyword
$objWriter->writeElement('meta:keyword', $pPhpPresentation->getProperties()->getKeywords());
// @todo : Where these properties are written ?
// $pPhpPresentation->getProperties()->getCategory()
// $pPhpPresentation->getProperties()->getCompany()
$objWriter->endElement();
$objWriter->endElement();
// Return
return $objWriter->getData();
}
示例4: loadDocumentProperties
/**
* Read Document Properties
*/
protected function loadDocumentProperties()
{
$arrayProperties = array('/office:document-meta/office:meta/meta:initial-creator' => 'setCreator', '/office:document-meta/office:meta/dc:creator' => 'setLastModifiedBy', '/office:document-meta/office:meta/dc:title' => 'setTitle', '/office:document-meta/office:meta/dc:description' => 'setDescription', '/office:document-meta/office:meta/dc:subject' => 'setSubject', '/office:document-meta/office:meta/meta:keyword' => 'setKeywords', '/office:document-meta/office:meta/meta:creation-date' => 'setCreated', '/office:document-meta/office:meta/dc:date' => 'setModified');
$oProperties = $this->oPhpPresentation->getProperties();
foreach ($arrayProperties as $path => $property) {
if (is_object($oElement = $this->oXMLReader->getElement($path))) {
if (in_array($property, array('setCreated', 'setModified'))) {
$oDateTime = new \DateTime();
$oDateTime->createFromFormat(\DateTime::W3C, $oElement->nodeValue);
$oProperties->{$property}($oDateTime->getTimestamp());
} else {
$oProperties->{$property}($oElement->nodeValue);
}
}
}
}
示例5: loadDocumentProperties
/**
* Read Document Properties
* @param string $sPart
*/
protected function loadDocumentProperties($sPart)
{
$xmlReader = new XMLReader();
if ($xmlReader->getDomFromString($sPart)) {
$arrayProperties = array('/cp:coreProperties/dc:creator' => 'setCreator', '/cp:coreProperties/cp:lastModifiedBy' => 'setLastModifiedBy', '/cp:coreProperties/dc:title' => 'setTitle', '/cp:coreProperties/dc:description' => 'setDescription', '/cp:coreProperties/dc:subject' => 'setSubject', '/cp:coreProperties/cp:keywords' => 'setKeywords', '/cp:coreProperties/cp:category' => 'setCategory', '/cp:coreProperties/dcterms:created' => 'setCreated', '/cp:coreProperties/dcterms:modified' => 'setModified');
$oProperties = $this->oPhpPresentation->getProperties();
foreach ($arrayProperties as $path => $property) {
if (is_object($oElement = $xmlReader->getElement($path))) {
if ($oElement->hasAttribute('xsi:type') && $oElement->getAttribute('xsi:type') == 'dcterms:W3CDTF') {
$oDateTime = new \DateTime();
$oDateTime->createFromFormat(\DateTime::W3C, $oElement->nodeValue);
$oProperties->{$property}($oDateTime->getTimestamp());
} else {
$oProperties->{$property}($oElement->nodeValue);
}
}
}
}
}
示例6: date
<?php
include_once 'Sample_Header.php';
use PhpOffice\PhpPresentation\PhpPresentation;
use PhpOffice\PhpPresentation\Style\Alignment;
use PhpOffice\PhpPresentation\Style\Color;
use PhpOffice\PhpPresentation\IOFactory;
// Create new PHPPresentation object
echo date('H:i:s') . ' Create new PHPPresentation object' . EOL;
$objPHPPresentation = new PhpPresentation();
// Set properties
echo date('H:i:s') . ' Set properties' . EOL;
$objPHPPresentation->getProperties()->setCreator('PHPOffice')->setLastModifiedBy('PHPPresentation Team')->setTitle('Sample 03 Title')->setSubject('Sample 03 Subject')->setDescription('Sample 03 Description')->setKeywords('office 2007 openxml libreoffice odt php')->setCategory('Sample Category');
// Create slide
echo date('H:i:s') . ' Create slide' . EOL;
$currentSlide = $objPHPPresentation->getActiveSlide();
// Create a shape (drawing)
echo date('H:i:s') . ' Create a shape (drawing)' . EOL;
$shape = $currentSlide->createDrawingShape();
$shape->setName('PHPPresentation logo')->setDescription('PHPPresentation logo')->setPath('./resources/phppowerpoint_logo.gif')->setHeight(36)->setOffsetX(10)->setOffsetY(10);
$shape->getShadow()->setVisible(true)->setDirection(45)->setDistance(10);
// Create a shape (text)
echo date('H:i:s') . ' Create a shape (rich text)' . EOL;
$shape = $currentSlide->createRichTextShape()->setHeight(300)->setWidth(600)->setOffsetX(170)->setOffsetY(180);
$shape->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
$textRun = $shape->createTextRun('Thank you for using PHPPresentation!');
$textRun->getFont()->setBold(true)->setSize(60)->setColor(new Color('FFE06B20'));
// Save serialized file
$basename = basename(__FILE__, '.php');
echo date('H:i:s') . ' Write to serialized format' . EOL;
$objWriter = IOFactory::createWriter($objPHPPresentation, 'Serialized');
示例7: displayPhpPresentationInfo
protected function displayPhpPresentationInfo(PhpPresentation $oPHPPpt)
{
$this->append('<div class="infoBlk" id="divPhpPresentationInfo">');
$this->append('<dl>');
$this->append('<dt>Number of slides</dt><dd>' . $oPHPPpt->getSlideCount() . '</dd>');
$this->append('<dt>Document Layout Height</dt><dd>' . $oPHPPpt->getLayout()->getCY(DocumentLayout::UNIT_MILLIMETER) . ' mm</dd>');
$this->append('<dt>Document Layout Width</dt><dd>' . $oPHPPpt->getLayout()->getCX(DocumentLayout::UNIT_MILLIMETER) . ' mm</dd>');
$this->append('<dt>Properties : Category</dt><dd>' . $oPHPPpt->getProperties()->getCategory() . '</dd>');
$this->append('<dt>Properties : Company</dt><dd>' . $oPHPPpt->getProperties()->getCompany() . '</dd>');
$this->append('<dt>Properties : Created</dt><dd>' . $oPHPPpt->getProperties()->getCreated() . '</dd>');
$this->append('<dt>Properties : Creator</dt><dd>' . $oPHPPpt->getProperties()->getCreator() . '</dd>');
$this->append('<dt>Properties : Description</dt><dd>' . $oPHPPpt->getProperties()->getDescription() . '</dd>');
$this->append('<dt>Properties : Keywords</dt><dd>' . $oPHPPpt->getProperties()->getKeywords() . '</dd>');
$this->append('<dt>Properties : Last Modified By</dt><dd>' . $oPHPPpt->getProperties()->getLastModifiedBy() . '</dd>');
$this->append('<dt>Properties : Modified</dt><dd>' . $oPHPPpt->getProperties()->getModified() . '</dd>');
$this->append('<dt>Properties : Subject</dt><dd>' . $oPHPPpt->getProperties()->getSubject() . '</dd>');
$this->append('<dt>Properties : Title</dt><dd>' . $oPHPPpt->getProperties()->getTitle() . '</dd>');
$this->append('</dl>');
$this->append('</div>');
foreach ($oPHPPpt->getAllSlides() as $oSlide) {
$this->append('<div class="infoBlk" id="div' . $oSlide->getHashCode() . 'Info">');
$this->append('<dl>');
$this->append('<dt>HashCode</dt><dd>' . $oSlide->getHashCode() . '</dd>');
$this->append('<dt>Slide Layout</dt><dd>Layout::' . $this->getConstantName('\\PhpOffice\\PhpPresentation\\Slide\\Layout', $oSlide->getSlideLayout()) . '</dd>');
$this->append('<dt>Offset X</dt><dd>' . $oSlide->getOffsetX() . '</dd>');
$this->append('<dt>Offset Y</dt><dd>' . $oSlide->getOffsetY() . '</dd>');
$this->append('<dt>Extent X</dt><dd>' . $oSlide->getExtentX() . '</dd>');
$this->append('<dt>Extent Y</dt><dd>' . $oSlide->getExtentY() . '</dd>');
$oBkg = $oSlide->getBackground();
if ($oBkg instanceof Slide\AbstractBackground) {
if ($oBkg instanceof Slide\Background\Color) {
$this->append('<dt>Background Color</dt><dd>#' . $oBkg->getColor()->getRGB() . '</dd>');
}
if ($oBkg instanceof Slide\Background\Image) {
$sBkgImgContents = file_get_contents($oBkg->getPath());
$this->append('<dt>Background Image</dt><dd><img src="data:image/png;base64,' . base64_encode($sBkgImgContents) . '"></dd>');
}
}
$this->append('</dl>');
$this->append('</div>');
foreach ($oSlide->getShapeCollection() as $oShape) {
if ($oShape instanceof Group) {
foreach ($oShape->getShapeCollection() as $oShapeChild) {
$this->displayShapeInfo($oShapeChild);
}
} else {
$this->displayShapeInfo($oShape);
}
}
}
}
示例8: writeDocPropsCore
/**
* Write docProps/core.xml to XML format
*
* @param PhpPresentation $pPhpPresentation
* @return string XML Output
* @throws \Exception
*/
public function writeDocPropsCore(PhpPresentation $pPhpPresentation)
{
// Create XML writer
$objWriter = $this->getXMLWriter();
// XML header
$objWriter->startDocument('1.0', 'UTF-8', 'yes');
// cp:coreProperties
$objWriter->startElement('cp:coreProperties');
$objWriter->writeAttribute('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties');
$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
$objWriter->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/');
$objWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/');
$objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
// dc:creator
$objWriter->writeElement('dc:creator', $pPhpPresentation->getProperties()->getCreator());
// cp:lastModifiedBy
$objWriter->writeElement('cp:lastModifiedBy', $pPhpPresentation->getProperties()->getLastModifiedBy());
// dcterms:created
$objWriter->startElement('dcterms:created');
$objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
$objWriter->writeRaw(gmdate("Y-m-d\\TH:i:s\\Z", $pPhpPresentation->getProperties()->getCreated()));
$objWriter->endElement();
// dcterms:modified
$objWriter->startElement('dcterms:modified');
$objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
$objWriter->writeRaw(gmdate("Y-m-d\\TH:i:s\\Z", $pPhpPresentation->getProperties()->getModified()));
$objWriter->endElement();
// dc:title
$objWriter->writeElement('dc:title', $pPhpPresentation->getProperties()->getTitle());
// dc:description
$objWriter->writeElement('dc:description', $pPhpPresentation->getProperties()->getDescription());
// dc:subject
$objWriter->writeElement('dc:subject', $pPhpPresentation->getProperties()->getSubject());
// cp:keywords
$objWriter->writeElement('cp:keywords', $pPhpPresentation->getProperties()->getKeywords());
// cp:category
$objWriter->writeElement('cp:category', $pPhpPresentation->getProperties()->getCategory());
$objWriter->endElement();
// Return
return $objWriter->getData();
}
示例9: writeSpreadsheet
/**
* Write chart to XML format
*
* @param PhpPresentation $presentation
* @param \PhpOffice\PhpPresentation\Shape\Chart $chart
* @param string $tempName
* @return string String output
* @throws \Exception
*/
public function writeSpreadsheet(PhpPresentation $presentation, $chart, $tempName)
{
// Need output?
if (!$chart->hasIncludedSpreadsheet()) {
throw new \Exception('No spreadsheet output is required for the given chart.');
}
// Verify PHPExcel
if (!class_exists('PHPExcel')) {
throw new \Exception('PHPExcel has not been loaded. Include PHPExcel.php in your script, e.g. require_once \'PHPExcel.php\'.');
}
// Create new spreadsheet
$workbook = new \PHPExcel();
// Set properties
$title = $chart->getTitle()->getText();
if (strlen($title) == 0) {
$title = 'Chart';
}
$workbook->getProperties()->setCreator($presentation->getProperties()->getCreator())->setLastModifiedBy($presentation->getProperties()->getLastModifiedBy())->setTitle($title);
// Add chart data
$sheet = $workbook->setActiveSheetIndex(0);
$sheet->setTitle('Sheet1');
// Write series
$seriesIndex = 0;
foreach ($chart->getPlotArea()->getType()->getData() as $series) {
// Title
$sheet->setCellValueByColumnAndRow(1 + $seriesIndex, 1, $series->getTitle());
// X-axis
$axisXData = array_keys($series->getValues());
$numAxisXData = count($axisXData);
for ($i = 0; $i < $numAxisXData; $i++) {
$sheet->setCellValueByColumnAndRow(0, $i + 2, $axisXData[$i]);
}
// Y-axis
$axisYData = array_values($series->getValues());
$numAxisYData = count($axisYData);
for ($i = 0; $i < $numAxisYData; $i++) {
$sheet->setCellValueByColumnAndRow(1 + $seriesIndex, $i + 2, $axisYData[$i]);
}
++$seriesIndex;
}
// Save to string
$writer = \PHPExcel_IOFactory::createWriter($workbook, 'Excel2007');
$writer->save($tempName);
// Load file in memory
$returnValue = file_get_contents($tempName);
if (@unlink($tempName) === false) {
throw new \Exception('The file ' . $tempName . ' could not removed.');
}
return $returnValue;
}
示例10: date
echo date('H:i:s') . ' Create templated slide' . EOL;
$currentSlide = createTemplatedSlide($objPHPPresentation);
// Create a shape (text)
echo date('H:i:s') . ' Create a shape (rich text) with shadow' . EOL;
$shape = $currentSlide->createRichTextShape();
$shape->setHeight(100);
$shape->setWidth(400);
$shape->setOffsetX(100);
$shape->setOffsetY(100);
$shape->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_LEFT);
$shape->getShadow()->setVisible(true)->setAlpha(75)->setBlurRadius(2)->setDirection(45);
$textRun = $shape->createTextRun('RichText with shadow');
$textRun->getFont()->setColor(new Color('FF000000'));
}
// Create new PHPPresentation object
echo date('H:i:s') . ' Create new PHPPresentation object' . EOL;
$objPHPPresentation = new PhpPresentation();
// Set properties
echo date('H:i:s') . ' Set properties' . EOL;
$oProperties = $objPHPPresentation->getProperties();
$oProperties->setCreator('PHPOffice')->setLastModifiedBy('PHPPresentation Team')->setTitle('Sample 11 Title')->setSubject('Sample 11 Subject')->setDescription('Sample 11 Description')->setKeywords('office 2007 openxml libreoffice odt php')->setCategory('Sample Category');
// Remove first slide
echo date('H:i:s') . ' Remove first slide' . EOL;
$objPHPPresentation->removeSlideByIndex(0);
fnSlideRichText($objPHPPresentation);
fnSlideRichTextShadow($objPHPPresentation);
// Save file
echo write($objPHPPresentation, basename(__FILE__, '.php'), $writers);
if (!CLI) {
include_once 'Sample_Footer.php';
}
示例11: displayPhpPresentationInfo
protected function displayPhpPresentationInfo(PhpPresentation $oPHPPpt)
{
$this->append('<div class="infoBlk" id="divPhpPresentationInfo">');
$this->append('<dl>');
$this->append('<dt>Number of slides</dt><dd>' . $oPHPPpt->getSlideCount() . '</dd>');
$this->append('<dt>Document Layout Height</dt><dd>' . $oPHPPpt->getLayout()->getCY(DocumentLayout::UNIT_MILLIMETER) . ' mm</dd>');
$this->append('<dt>Document Layout Width</dt><dd>' . $oPHPPpt->getLayout()->getCX(DocumentLayout::UNIT_MILLIMETER) . ' mm</dd>');
$this->append('<dt>Properties : Category</dt><dd>' . $oPHPPpt->getProperties()->getCategory() . '</dd>');
$this->append('<dt>Properties : Company</dt><dd>' . $oPHPPpt->getProperties()->getCompany() . '</dd>');
$this->append('<dt>Properties : Created</dt><dd>' . $oPHPPpt->getProperties()->getCreated() . '</dd>');
$this->append('<dt>Properties : Creator</dt><dd>' . $oPHPPpt->getProperties()->getCreator() . '</dd>');
$this->append('<dt>Properties : Description</dt><dd>' . $oPHPPpt->getProperties()->getDescription() . '</dd>');
$this->append('<dt>Properties : Keywords</dt><dd>' . $oPHPPpt->getProperties()->getKeywords() . '</dd>');
$this->append('<dt>Properties : Last Modified By</dt><dd>' . $oPHPPpt->getProperties()->getLastModifiedBy() . '</dd>');
$this->append('<dt>Properties : Modified</dt><dd>' . $oPHPPpt->getProperties()->getModified() . '</dd>');
$this->append('<dt>Properties : Subject</dt><dd>' . $oPHPPpt->getProperties()->getSubject() . '</dd>');
$this->append('<dt>Properties : Title</dt><dd>' . $oPHPPpt->getProperties()->getTitle() . '</dd>');
$this->append('</dl>');
$this->append('</div>');
foreach ($oPHPPpt->getAllSlides() as $oSlide) {
$this->append('<div class="infoBlk" id="div' . $oSlide->getHashCode() . 'Info">');
$this->append('<dl>');
$this->append('<dt>HashCode</dt><dd>' . $oSlide->getHashCode() . '</dd>');
$this->append('<dt>Slide Layout</dt><dd>Layout::' . $this->getConstantName('\\PhpOffice\\PhpPresentation\\Slide\\Layout', $oSlide->getSlideLayout()) . '</dd>');
$this->append('<dt>Offset X</dt><dd>' . $oSlide->getOffsetX() . '</dd>');
$this->append('<dt>Offset Y</dt><dd>' . $oSlide->getOffsetY() . '</dd>');
$this->append('<dt>Extent X</dt><dd>' . $oSlide->getExtentX() . '</dd>');
$this->append('<dt>Extent Y</dt><dd>' . $oSlide->getExtentY() . '</dd>');
$this->append('</dl>');
$this->append('</div>');
foreach ($oSlide->getShapeCollection() as $oShape) {
if ($oShape instanceof Group) {
foreach ($oShape->getShapeCollection() as $oShapeChild) {
$this->displayShapeInfo($oShapeChild);
}
} else {
$this->displayShapeInfo($oShape);
}
}
}
}