當前位置: 首頁>>代碼示例>>PHP>>正文


PHP eZFileHandler::doIsWriteable方法代碼示例

本文整理匯總了PHP中eZFileHandler::doIsWriteable方法的典型用法代碼示例。如果您正苦於以下問題:PHP eZFileHandler::doIsWriteable方法的具體用法?PHP eZFileHandler::doIsWriteable怎麽用?PHP eZFileHandler::doIsWriteable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在eZFileHandler的用法示例。


在下文中一共展示了eZFileHandler::doIsWriteable方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: generatePDF

 /**
  * Converts xhtml to pdf
  *
  * @param $xhtml
  * @return Binary pdf content or false if error
  */
 public function generatePDF($xhtml)
 {
     //check if $tmpdir exists else try to create it
     if (!eZFileHandler::doExists($this->tmpDir)) {
         if (!eZDir::mkdir($this->tmpDir, eZDir::directoryPermission(), true)) {
             eZDebug::writeWarning("ParadoxPDF::generatePDF Error : could not create temporary directory {$this->tmpDir} ", 'ParadoxPDF::generatePDF');
             eZLog::write("ParadoxPDF::generatePDF Error : could not create temporary directory {$this->tmpDir} ", 'paradoxpdf.log');
             return false;
         }
     } elseif (!eZFileHandler::doIsWriteable($this->tmpDir)) {
         //check if $tmpdir is writable
         eZDebug::writeWarning("ParadoxPDF::generatePDF Error : please make {$this->tmpDir} writable ", 'ParadoxPDF::generatePDF');
         eZLog::write("ParadoxPDF::generatePDF Error : please make {$this->tmpDir} writable ", 'paradoxpdf.log');
         return false;
     }
     $rand = md5('paradoxpdf' . getmypid() . mt_rand());
     $tmpXHTMLFile = eZDir::path(array($this->tmpDir, "{$rand}.xhtml"));
     $tmpPDFFile = eZDir::path(array($this->tmpDir, "{$rand}.pdf"));
     //fix relative urls to match ez root directory
     $xhtml = $this->fixURL($xhtml);
     eZFile::create($tmpXHTMLFile, false, $xhtml);
     $pdfContent = '';
     //run jar in headless mode
     $command = $this->javaExec . " -Djava.awt.headless=true";
     if ($this->debugEnabled && $this->debugVerbose) {
         $command .= " -Dxr.util-logging.loggingEnabled=true";
     }
     $command .= " -jar " . $this->paradoxPDFExec . " {$tmpXHTMLFile} {$tmpPDFFile}";
     //fix to get all command output
     $command .= "  2>&1";
     //Enter the Matrix
     exec($command, $output, $returnCode);
     //Cant trust java return code so we test if a plain pdf file is genereated
     if (!(eZFileHandler::doExists($tmpPDFFile) && ($this->size = filesize($tmpPDFFile)))) {
         $this->writeCommandLog($command, $output, false);
         return false;
     }
     $this->writeCommandLog($command, $output, true);
     $pdfContent = file_get_contents($tmpPDFFile);
     //cleanup temporary files
     //if debug enabled preseves the temporary pdf file
     //else remove all temporary files
     if (!$this->debugEnabled) {
         eZFileHandler::unlink($tmpPDFFile);
         eZFileHandler::unlink($tmpXHTMLFile);
     }
     return $pdfContent;
 }
開發者ID:informaticatrentina,項目名稱:paradoxpdf,代碼行數:54,代碼來源:paradoxpdf.php


注:本文中的eZFileHandler::doIsWriteable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。