コード例 #1
0
ファイル: DocxMerge.php プロジェクト: jupitern/DocxMerge
 public function setValues($templateFilePath, $outputFilePath, $data)
 {
     if (!file_exists($templateFilePath)) {
         return -1;
     }
     if (!copy($templateFilePath, $outputFilePath)) {
         // Cannot create output file
         return -2;
     }
     $docx = new Docx($outputFilePath);
     $docx->loadHeadersAndFooters();
     foreach ($data as $key => $value) {
         $docx->findAndReplace("\${" . $key . "}", $value);
     }
     $docx->flush();
 }
コード例 #2
0
	public function __construct( $filename ) {
		$files = array(
			"_rels/.rels",
			"docProps/app.xml",
			"docProps/core.xml",
			"word/_rels/document.xml.rels",
			"word/_rels/header1.xml.rels",
			"word/media/image1.png",
			"word/media/image2.png",
			"word/media/image3.png",
			"word/media/image4.png",
			"word/media/image5.png",
			"word/media/image6.png",
			"word/media/image7.png",
			"word/media/image8.png",
			"word/media/image9.png",
			"word/media/image10.png",
			"word/media/image11.png",
			"word/media/image12.png",
			"word/document.xml",
			"word/fontTable.xml",
			"word/footer1.xml",
			"word/header1.xml",
			"word/numbering.xml",
			"word/settings.xml",
			"word/styles.xml",		
			"[Content_Types].xml" );
		
		parent::__construct( $filename, '/template/guarantee/', $files );
	}
コード例 #3
0
ファイル: StandartDocx.php プロジェクト: raffiz/my_home_tests
	public function __construct( $filename ) {
		$files = array(
			"_rels/.rels",
			
			"docProps/app.xml",
			"docProps/core.xml",
			
			"customXml/itemProps1.xml",
			"customXml/item1.xml",
			"customXml/_rels/item1.xml.rels",
			
			"word/_rels/document.xml.rels",
			"word/_rels/header1.xml.rels",
			
			"word/media/image1.png",
			"word/media/image2.png",
			
			"word/theme/theme1.xml",
						
			"word/webSettings.xml",
			"word/styles.xml",
			"word/settings.xml",
			"word/numbering.xml",
			"word/header1.xml",
			"word/footnotes.xml",
			"word/footer1.xml",
			"word/fontTable.xml",
			"word/endnotes.xml",
			"word/document.xml",			
			"[Content_Types].xml" );
		
		parent::__construct( $filename, '/template/standart/template/', $files );
	}
コード例 #4
0
	public function __construct( $filename ) {
		
		$files = array(
				"_rels/.rels",
				"customXml/_rels/item1.xml.rels",
				"customXml/item1.xml",
				"customXml/itemProps1.xml",
				"docProps/app.xml",
				"docProps/core.xml",
				"word/_rels/document.xml.rels",
				"word/media/image1.png",
				"word/theme/theme1.xml",
				"word/comments.xml",
				"word/document.xml",
				"word/fontTable.xml",
				"word/numbering.xml",
				"word/settings.xml",
				"word/styles.xml",
				"word/webSettings.xml",
				"word/stylesWithEffects.xml",				
				"[Content_Types].xml");

		parent::__construct( $filename, __DIR__ . '/commercial/', $files );
	}
コード例 #5
0
ファイル: Node.class.php プロジェクト: sophia2152/docx
 /**
  * @name parseNode
  * @desc Processes the node into php data or html
  * @param boolean $isDirect (Defaults to FALSE)
  */
 public function parseNode($isDirect = false)
 {
     $wordStyle = $this->findStyle($this->dom);
     $styleInfo = Style::getStyleObject($wordStyle, $this->docx);
     $this->wordStyle = $wordStyle;
     # Only proceed for nodes that are children of the w:body tag OR this method was called within a container
     if ($this->dom->parentNode->nodeName != 'w:body' && !$isDirect) {
         return;
     }
     if (!$isDirect) {
         $this->_tableId = null;
     }
     switch ($this->dom->nodeName) {
         case 'w:p':
             $isListItem = false;
             $listLevel = 0;
             $indent = null;
             # Get the list level using the openXml format
             $listQuery = $this->xPath->query("w:pPr/w:numPr/w:ilvl", $this->dom);
             if ($listQuery->length > 0) {
                 $listLevel = (int) $listQuery->item(0)->getAttribute('w:val') + 1;
             }
             # If the style list info is NOT 0, then override the openXml iteration
             if (is_object($styleInfo)) {
                 if ($styleInfo->listLevel > 0) {
                     $listLevel = $styleInfo->listLevel;
                 }
             }
             # Load hyperlink data (if any)
             $hyperQuery = $this->xPath->query("w:hyperlink", $this->dom);
             if ($hyperQuery->length > 0) {
                 $hyperlink = '';
                 $hyperNode = $hyperQuery->item(0);
                 foreach ($hyperNode->childNodes as $cn) {
                     if ($cn->nodeName == 'w:r') {
                         $hyperlink = $cn->nodeValue;
                     }
                 }
                 # If we have the raw hyperlink, parse it
                 if ($hyperlink != '') {
                     if (substr($hyperlink, 0, 4) != 'http') {
                         if (strpos($hyperlink, '@') !== false) {
                             $modHyperlink = 'mailto:' . $hyperlink;
                         } else {
                             $modHyperlink = 'http://' . $hyperlink;
                         }
                     } else {
                         $modHyperlink = $hyperlink;
                     }
                     $this->run[] = array('text' => '<a href="' . $modHyperlink . '">' . $hyperlink . '</a>', 'underline' => false, 'tab' => false, 'italic' => false, 'bold' => false);
                 }
             }
             # Join the different runs together
             $textRun = $this->xPath->query("w:r", $this->dom);
             $text = '';
             foreach ($textRun as $run) {
                 $wrArray = $this->_parseWrNode($run);
                 $this->run[] = $wrArray;
             }
             # Get the indentation
             $indentQuery = $this->xPath->query("w:pPr/w:ind", $this->dom);
             if ($indentQuery->length > 0) {
                 $firstLineInd = $indentQuery->item(0)->getAttribute('w:firstLine');
                 $indent = (int) Docx::twipToPt($firstLineInd);
             }
             $this->indent = $indent;
             $this->listLevel = $listLevel;
             break;
         case 'w:drawing':
             $this->img = $this->loadDrawing($this->dom);
             break;
         case 'w:txbxContent':
             break;
         case 'w:tbl':
             $this->_tableId = $this->id;
             $this->createTableGrid($this->dom);
             break;
     }
 }
コード例 #6
0
ファイル: Node.php プロジェクト: lmerotta/docx
 /**
  * @name parseNode
  * @desc Processes the node into php data or html
  * @param boolean $isDirect (Defaults to FALSE)
  */
 public function parseNode($isDirect = false)
 {
     $wordStyle = str_replace(' ', '', $this->findStyle($this->dom));
     $styleInfo = Style::getStyleObject($wordStyle, $this->docx);
     $this->wordStyle = $wordStyle;
     # Only proceed for nodes that are children of the w:body tag OR this method was called within a container
     if (!($this->dom->parentNode->nodeName == 'w:r' && $this->dom->nodeName == 'w:drawing')) {
         if ($this->dom->parentNode->nodeName != 'w:body' && !$isDirect) {
             return;
         }
     }
     if (!$isDirect) {
         $this->_tableId = null;
     }
     switch ($this->dom->nodeName) {
         case 'w:p':
             $isListItem = false;
             $listLevel = 0;
             $indent = null;
             # Get the list level using the openXml format
             $listQuery = $this->xPath->query("w:pPr/w:numPr/w:ilvl", $this->dom);
             if ($listQuery->length > 0) {
                 $listLevel = (int) $listQuery->item(0)->getAttribute('w:val') + 1;
             }
             # If the style list info is NOT 0, then override the openXml iteration
             if (is_object($styleInfo)) {
                 if ($styleInfo->listLevel > 0) {
                     $listLevel = $styleInfo->listLevel;
                 }
             }
             # Join the different runs together
             $textRun = $this->xPath->query("w:r|w:hyperlink|w:br", $this->dom);
             $text = '';
             foreach ($textRun as $run) {
                 $wrArray = $this->_parseWrNode($run);
                 $this->run[] = $wrArray;
             }
             # Get the indentation
             $indentQuery = $this->xPath->query("w:pPr/w:ind", $this->dom);
             if ($indentQuery->length > 0) {
                 $firstLineInd = $indentQuery->item(0)->getAttribute('w:firstLine');
                 $indent = (int) Docx::twipToPt($firstLineInd);
             }
             $this->indent = $indent;
             $this->listLevel = $listLevel;
             break;
         case 'w:drawing':
             $this->img = $this->loadDrawing($this->dom);
             break;
         case 'w:txbxContent':
             break;
         case 'w:tbl':
             $this->_tableId = $this->id;
             $this->createTableGrid($this->dom);
             break;
         case 'w:footnote':
             $id = intval($this->dom->getAttribute("w:id"));
             if ($id < 1) {
                 return;
             }
             $idDone = false;
             $textQuery = $this->xPath->query("w:p", $this->dom);
             $realnode = null;
             foreach ($textQuery as $textRes) {
                 $this->run[] = array('bold' => false, 'italic' => false, 'tab' => false, 'underline' => false, 'text' => !$idDone ? '[' . $id . ']' . $textRes->nodeValue . '<br/>' : $textRes->nodeValue);
                 $idDone = true;
             }
             break;
     }
 }
コード例 #7
0
ファイル: Docx.php プロジェクト: akiyatkin/files
function docx_get($src, $type = 'norm', $re = false)
{
    return Docx::get($src, $type, $re);
}