本文整理汇总了PHP中PhpOffice\PhpWord\Settings::setTempDir方法的典型用法代码示例。如果您正苦于以下问题:PHP Settings::setTempDir方法的具体用法?PHP Settings::setTempDir怎么用?PHP Settings::setTempDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhpOffice\PhpWord\Settings
的用法示例。
在下文中一共展示了Settings::setTempDir方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mergeDOCX
function mergeDOCX($source_file, $merged_file)
{
// Important: we get the merge data first, because the phpWord
// autoloader included below stuffs up the Jethro autoloader
// and causes errors.
$data = array_values($this->getMergeData());
// NB THIS FILE HAS BEEN CHANGED!
require_once 'include/phpword/src/PhpWord/Autoloader.php';
\PhpOffice\PhpWord\Autoloader::register();
\PhpOffice\PhpWord\Settings::setTempDir(dirname($source_file));
$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor($source_file);
if (!$templateProcessor->cloneBlock('MERGEBLOCK', count($data))) {
$vars = $templateProcessor->getVariables();
if (empty($vars)) {
trigger_error("You don't seem to have included any \${keywords} in your file; cannot merge");
return;
}
$templateProcessor->cloneRow(reset($vars), count($data));
}
foreach ($data as $num => $row) {
foreach ($row as $k => $v) {
$templateProcessor->setValue(strtoupper($k) . '#' . ($num + 1), $this->xmlEntities($v));
}
}
$templateProcessor->saveAs($merged_file);
}
示例2: testTempDirCanBeSet
/**
* @covers ::setTempDir
* @covers ::getTempDir
* @depends testPhpTempDirIsUsedByDefault
* @test
*/
public function testTempDirCanBeSet()
{
$userDefinedTempDir = 'C:\\PhpWordTemp';
Settings::setTempDir($userDefinedTempDir);
$currentTempDir = Settings::getTempDir();
$this->assertEquals($userDefinedTempDir, $currentTempDir);
$this->assertNotEquals(sys_get_temp_dir(), $currentTempDir);
}
示例3: _testReadWriteCycleSucks
public function _testReadWriteCycleSucks()
{
PhpWord\Settings::setTempDir(Tinebase_Core::getTempDir());
$source = str_replace('tests/tine20', 'tine20', __DIR__) . '/templates/addressbook_contact_letter.docx';
$phpWord = PhpWord\IOFactory::load($source);
$tempfile = tempnam(Tinebase_Core::getTempDir(), __METHOD__ . '_') . '.docx';
$writer = $phpWord->save($tempfile);
`open {$tempfile}`;
}
示例4: array
function __construct()
{
parent::__construct();
Autoloader::register();
Settings::loadConfig();
Settings::setTempDir(getcwd() . TMPDIR_WORD);
// Set writers
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf', 'HTML' => 'html', 'PDF' => 'pdf');
// Set PDF renderer
if (Settings::getPdfRendererPath() === null) {
$writers['PDF'] = null;
}
// Return to the caller script when runs by CLI
if (PHP_SAPI == 'cli') {
return;
}
}
示例5: _createDocument
/**
* create new PhpWord document
*
* @return void
*/
protected function _createDocument()
{
\PhpOffice\PhpWord\Settings::setTempDir(Tinebase_Core::getTempDir());
$templateFile = $this->_getTemplateFilename();
$this->_docObject = new \PhpOffice\PhpWord\PhpWord();
if ($templateFile !== NULL) {
$this->_docTemplate = new \PhpOffice\PhpWord\TemplateProcessor($templateFile);
}
}
示例6: generaDocumentTancament
/**
* Funció que em retorna el document de tancament
**/
public static function generaDocumentTancament($idSessio)
{
\PhpOffice\PhpWord\Settings::setTempDir(BASEURL . 'tmp/');
$phpword = new \PhpOffice\PhpWord\PhpWord();
$T = $phpword->loadTemplate(BASEURL . '/Data/Documents/InformeTancamentLaGorga.docx');
$EM = new EspectaclesModel();
$LlistatLocalitats = $EM->getLocalitatsForDocument($idSessio);
if (sizeof($LlistatLocalitats) == 0) {
throw new MyException('No he trobat cap seient ocupat.');
}
$RECAPTAT = array('TOTALS' => array('M' => array('PERSONES' => 0, 'PREU' => 0), 'T' => array('PERSONES' => 0, 'PREU' => 0), 'D' => array('PERSONES' => 0, 'PREU' => 0), 'TOTAL' => 0, 'PERSONES' => 0), 'TIPUS_ENTRADA' => array());
$LC = $LlistatLocalitats['COMANDES'];
$LS = $LlistatLocalitats['SESSIO'];
$LE = $LlistatLocalitats['ESPECTACLE'];
foreach ($LlistatLocalitats['LOCALITATS'] as $K => $LTO) {
$OP = $LTO->getPreu();
$idComanda = $LTO->localitat['l_idComanda'];
$TipusPagament = $LC[$idComanda]->comanda['co_TipusPagament'];
$NomPreu = $OP->preu['nom'];
$Import = $OP->preu['import'];
if ($LTO->localitat['l_estat'] == 'O') {
if (!isset($RECAPTAT['TOTALS'][$TipusPagament])) {
$RECAPTAT['TOTALS'][$TipusPagament] = array('PERSONES' => 0, 'PREU' => 0);
}
//Sumem import al recaptat per tipus pagament
$RECAPTAT['TOTALS'][$TipusPagament]['PREU'] += $Import;
$RECAPTAT['TOTALS'][$TipusPagament]['PERSONES'] += 1;
//Sumem import al total recaptat
$RECAPTAT['TOTALS']['TOTAL'] += $Import;
//Sumem l'import a la persona
$RECAPTAT['TOTALS']['PERSONES'] += 1;
//Sumem import al tipus de preu
if (!isset($RECAPTAT['TIPUS_ENTRADA'][$NomPreu])) {
$RECAPTAT['TIPUS_ENTRADA'][$NomPreu] = array('TOTAL' => 0, 'PERSONES' => 0, 'PREU' => $Import);
}
//Sumem import al total per tipus de preu
$RECAPTAT['TIPUS_ENTRADA'][$NomPreu]['TOTAL'] += $Import;
//Sumem persona al tipus de preu
$RECAPTAT['TIPUS_ENTRADA'][$NomPreu]['PERSONES'] += 1;
} else {
//Sumem import al tipus de preu
if (!isset($RECAPTAT['TIPUS_ENTRADA']['Reserves'])) {
$RECAPTAT['TIPUS_ENTRADA']['Reserves'] = array('TOTAL' => 0, 'PERSONES' => 0, 'PREU' => 0);
}
//Sumem import al total per tipus de preu
$RECAPTAT['TIPUS_ENTRADA']['Reserves']['TOTAL'] = 0;
//Sumem persona al tipus de preu
$RECAPTAT['TIPUS_ENTRADA']['Reserves']['PERSONES'] += 1;
}
}
$T->setValue('Espectacle', htmlspecialchars($LE->espectacle['e_Titol']));
$T->setValue('Dia', htmlspecialchars($LS->sessio['tmp_Dia']));
$T->setValue('Hora', htmlspecialchars($LS->sessio['tmp_Hora']));
$T->setValue('Organitzador', htmlspecialchars($LE->espectacle['e_OrganitzadorNom']));
$T->setValue('Cif', htmlspecialchars($LE->espectacle['e_OrganitzadorCif']));
$T->setValue('Recaptat', $RECAPTAT['TOTALS']['TOTAL']);
$T->setValue('Online', $RECAPTAT['TOTALS']['T']['PREU']);
$T->setValue('Datafon', $RECAPTAT['TOTALS']['D']['PREU']);
$T->setValue('Metalic', $RECAPTAT['TOTALS']['M']['PREU']);
$T->setValue('NOnline', $RECAPTAT['TOTALS']['T']['PERSONES']);
$T->setValue('NDatafon', $RECAPTAT['TOTALS']['D']['PERSONES']);
$T->setValue('NMetalic', $RECAPTAT['TOTALS']['M']['PERSONES']);
$T->setValue('Persones', $RECAPTAT['TOTALS']['PERSONES']);
$T->cloneRow('rowValue', sizeof($RECAPTAT['TIPUS_ENTRADA']));
$i = 1;
foreach ($RECAPTAT['TIPUS_ENTRADA'] as $K => $V) {
$T->setValue('rowValue#' . strval($i), htmlspecialchars($K));
$T->setValue('rowQuantitat#' . strval($i), $V['PERSONES']);
$T->setValue('rowPreu#' . strval($i), $V['PREU']);
$T->setValue('rowImport#' . strval($i), $V['TOTAL']);
$i++;
}
$T->setValue('Total', $RECAPTAT['TOTALS']['TOTAL']);
$config = J::loadJsonConfigFile("config.json");
$importTaxa1Dia = floatval($config['TAXA_OCUPACIO']);
$importTaxa = $RECAPTAT['TOTALS']['TOTAL'] * 25 / 100;
if ($importTaxa > $importTaxa1Dia) {
$importTaxa = $importTaxa1Dia * 0.3;
}
$T->setValue('ImportTaxa', $importTaxa);
$T->saveAs(BASEURL . 'Data/Documents/S' . $idSessio . '.docx');
return true;
}