From 59eec587fce55519edb3295fe4379aaad823e4f9 Mon Sep 17 00:00:00 2001
From: Ivan Lanin
Date: Sat, 15 Mar 2014 22:39:57 +0700
Subject: [PATCH] Convert samples
---
samples/Sample_01_SimpleText.php | 9 +--
samples/Sample_02_TabStops.php | 9 +--
samples/Sample_03_Sections.php | 9 +--
samples/Sample_04_Textrun.php | 9 +--
samples/Sample_05_Multicolumn.php | 9 +--
samples/Sample_06_Footnote.php | 9 +--
samples/Sample_07_TemplateCloneRow.php | 11 +---
samples/Sample_08_ParagraphPagination.php | 9 +--
samples/Sample_09_Tables.php | 9 +--
samples/Sample_10_EastAsianFontStyle.php | 9 +--
samples/Sample_11_ReadWord2007.php | 9 +--
samples/Sample_12_HeaderFooter.php | 9 +--
samples/Sample_13_Images.php | 10 +---
samples/Sample_14_ListItem.php | 10 +---
samples/Sample_15_Link.php | 10 +---
samples/Sample_16_Object.php | 10 +---
samples/Sample_17_TitleTOC.php | 12 +---
samples/Sample_18_Watermark.php | 12 +---
samples/Sample_19_TextBreak.php | 12 +---
samples/Sample_Footer.php | 33 +++++++++++
samples/Sample_Header.php | 68 +++++++++++++++++++++++
samples/bootstrap/css/bootstrap.min.css | 9 +++
samples/bootstrap/css/phpword.css | 8 +++
samples/bootstrap/js/bootstrap.min.js | 9 +++
samples/bootstrap/js/jquery.min.js | 6 ++
samples/index.php | 15 +++++
26 files changed, 190 insertions(+), 144 deletions(-)
create mode 100644 samples/Sample_Footer.php
create mode 100644 samples/Sample_Header.php
create mode 100644 samples/bootstrap/css/bootstrap.min.css
create mode 100644 samples/bootstrap/css/phpword.css
create mode 100644 samples/bootstrap/js/bootstrap.min.js
create mode 100644 samples/bootstrap/js/jquery.min.js
create mode 100644 samples/index.php
diff --git a/samples/Sample_01_SimpleText.php b/samples/Sample_01_SimpleText.php
index 10f129dbfa..a6d593ec2f 100755
--- a/samples/Sample_01_SimpleText.php
+++ b/samples/Sample_01_SimpleText.php
@@ -1,8 +1,5 @@
');
-require_once '../Classes/PHPWord.php';
+include_once 'Sample_Header.php';
// New Word Document
echo date('H:i:s') , " Create new PHPWord object" , EOL;
@@ -57,6 +54,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
-// Done
-echo date('H:i:s'), " Done writing file(s)", EOL;
-echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
+include_once 'Sample_Footer.php';
diff --git a/samples/Sample_02_TabStops.php b/samples/Sample_02_TabStops.php
index e9e2d84bcb..dc0fea42ff 100755
--- a/samples/Sample_02_TabStops.php
+++ b/samples/Sample_02_TabStops.php
@@ -1,8 +1,5 @@
');
-require_once '../Classes/PHPWord.php';
+include_once 'Sample_Header.php';
// New Word Document
echo date('H:i:s') , ' Create new PHPWord object' , EOL;
@@ -45,6 +42,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
-// Done
-echo date('H:i:s'), " Done writing file(s)", EOL;
-echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
+include_once 'Sample_Footer.php';
diff --git a/samples/Sample_03_Sections.php b/samples/Sample_03_Sections.php
index 1e49629e9c..383bf4e782 100755
--- a/samples/Sample_03_Sections.php
+++ b/samples/Sample_03_Sections.php
@@ -1,8 +1,5 @@
');
-require_once '../Classes/PHPWord.php';
+include_once 'Sample_Header.php';
// New Word Document
echo date('H:i:s') , ' Create new PHPWord object' , EOL;
@@ -38,6 +35,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
-// Done
-echo date('H:i:s'), " Done writing file(s)", EOL;
-echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
+include_once 'Sample_Footer.php';
diff --git a/samples/Sample_04_Textrun.php b/samples/Sample_04_Textrun.php
index b30db7a56f..d3e577bd6c 100644
--- a/samples/Sample_04_Textrun.php
+++ b/samples/Sample_04_Textrun.php
@@ -1,8 +1,5 @@
');
-require_once '../Classes/PHPWord.php';
+include_once 'Sample_Header.php';
// New Word Document
echo date('H:i:s') , ' Create new PHPWord object' , EOL;
@@ -45,6 +42,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
-// Done
-echo date('H:i:s'), " Done writing file(s)", EOL;
-echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
+include_once 'Sample_Footer.php';
diff --git a/samples/Sample_05_Multicolumn.php b/samples/Sample_05_Multicolumn.php
index 3877defeff..e636f8ad76 100644
--- a/samples/Sample_05_Multicolumn.php
+++ b/samples/Sample_05_Multicolumn.php
@@ -1,8 +1,5 @@
');
-require_once '../Classes/PHPWord.php';
+include_once 'Sample_Header.php';
// New Word Document
echo date('H:i:s') , " Create new PHPWord object" , EOL;
@@ -48,6 +45,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
-// Done
-echo date('H:i:s'), " Done writing file(s)", EOL;
-echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
+include_once 'Sample_Footer.php';
diff --git a/samples/Sample_06_Footnote.php b/samples/Sample_06_Footnote.php
index daaa6b4636..3c52cfcfeb 100755
--- a/samples/Sample_06_Footnote.php
+++ b/samples/Sample_06_Footnote.php
@@ -1,8 +1,5 @@
');
-require_once '../Classes/PHPWord.php';
+include_once 'Sample_Header.php';
// New Word Document
echo date('H:i:s') , " Create new PHPWord object" , EOL;
@@ -46,6 +43,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
-// Done
-echo date('H:i:s'), " Done writing file(s)", EOL;
-echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
+include_once 'Sample_Footer.php';
diff --git a/samples/Sample_07_TemplateCloneRow.php b/samples/Sample_07_TemplateCloneRow.php
index f797b986e5..e322001e74 100755
--- a/samples/Sample_07_TemplateCloneRow.php
+++ b/samples/Sample_07_TemplateCloneRow.php
@@ -1,8 +1,5 @@
');
-require_once '../Classes/PHPWord.php';
+include_once 'Sample_Header.php';
// New Word document
echo date('H:i:s') , " Create new PHPWord object" , EOL;
@@ -56,11 +53,9 @@
$document->setValue('userName#3', 'Ray');
$document->setValue('userPhone#3', '+1 428 889 775');
-$name = 'Sample_07_TemplateCloneRow_result.docx';
+$name = 'Sample_07_TemplateCloneRow.docx';
echo date('H:i:s'), " Write to Word2007 format", EOL;
$document->saveAs($name);
rename($name, "results/{$name}");
-// Done
-echo date('H:i:s'), " Done writing file(s)", EOL;
-echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
+include_once 'Sample_Footer.php';
diff --git a/samples/Sample_08_ParagraphPagination.php b/samples/Sample_08_ParagraphPagination.php
index edd1992c43..79879ad12e 100644
--- a/samples/Sample_08_ParagraphPagination.php
+++ b/samples/Sample_08_ParagraphPagination.php
@@ -1,8 +1,5 @@
');
-require_once '../Classes/PHPWord.php';
+include_once 'Sample_Header.php';
// New Word document
echo date('H:i:s') , " Create new PHPWord object" , EOL;
@@ -58,6 +55,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
-// Done
-echo date('H:i:s'), " Done writing file(s)", EOL;
-echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
+include_once 'Sample_Footer.php';
diff --git a/samples/Sample_09_Tables.php b/samples/Sample_09_Tables.php
index 96e411a020..62e5045759 100644
--- a/samples/Sample_09_Tables.php
+++ b/samples/Sample_09_Tables.php
@@ -1,8 +1,5 @@
');
-require_once '../Classes/PHPWord.php';
+include_once 'Sample_Header.php';
// New Word Document
echo date('H:i:s') , ' Create new PHPWord object' , EOL;
@@ -86,6 +83,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
-// Done
-echo date('H:i:s'), " Done writing file(s)", EOL;
-echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
+include_once 'Sample_Footer.php';
diff --git a/samples/Sample_10_EastAsianFontStyle.php b/samples/Sample_10_EastAsianFontStyle.php
index 8be721091c..164cf4950c 100644
--- a/samples/Sample_10_EastAsianFontStyle.php
+++ b/samples/Sample_10_EastAsianFontStyle.php
@@ -1,8 +1,5 @@
');
-require_once '../Classes/PHPWord.php';
+include_once 'Sample_Header.php';
// New Word Document
echo date('H:i:s') , ' Create new PHPWord object' , EOL;
@@ -22,6 +19,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
-// Done
-echo date('H:i:s'), " Done writing file(s)", EOL;
-echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
+include_once 'Sample_Footer.php';
diff --git a/samples/Sample_11_ReadWord2007.php b/samples/Sample_11_ReadWord2007.php
index d96e92644c..fff1057263 100644
--- a/samples/Sample_11_ReadWord2007.php
+++ b/samples/Sample_11_ReadWord2007.php
@@ -1,8 +1,5 @@
');
-require_once '../Classes/PHPWord.php';
+include_once 'Sample_Header.php';
// Read contents
$name = basename(__FILE__, '.php');
@@ -19,6 +16,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
-// Done
-echo date('H:i:s'), " Done writing file(s)", EOL;
-echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
+include_once 'Sample_Footer.php';
diff --git a/samples/Sample_12_HeaderFooter.php b/samples/Sample_12_HeaderFooter.php
index b0d0e13792..367076c681 100644
--- a/samples/Sample_12_HeaderFooter.php
+++ b/samples/Sample_12_HeaderFooter.php
@@ -1,8 +1,5 @@
');
-require_once '../Classes/PHPWord.php';
+include_once 'Sample_Header.php';
// New Word document
echo date('H:i:s') , " Create new PHPWord object" , EOL;
@@ -69,6 +66,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
-// Done
-echo date('H:i:s'), " Done writing file(s)", EOL;
-echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
+include_once 'Sample_Footer.php';
diff --git a/samples/Sample_13_Images.php b/samples/Sample_13_Images.php
index 0f64cb7bb8..e0f943239f 100644
--- a/samples/Sample_13_Images.php
+++ b/samples/Sample_13_Images.php
@@ -2,11 +2,7 @@
/**
* Image creation
*/
-
-// Init
-error_reporting(E_ALL);
-define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
');
-require_once '../Classes/PHPWord.php';
+include_once 'Sample_Header.php';
// New Word document
echo date('H:i:s'), " Create new PHPWord object", EOL;
@@ -37,6 +33,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
-// Done
-echo date('H:i:s'), " Done writing file(s)", EOL;
-echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
+include_once 'Sample_Footer.php';
diff --git a/samples/Sample_14_ListItem.php b/samples/Sample_14_ListItem.php
index fa64878407..40fcea9e0a 100644
--- a/samples/Sample_14_ListItem.php
+++ b/samples/Sample_14_ListItem.php
@@ -2,11 +2,7 @@
/**
* List item sample
*/
-
-// Init
-error_reporting(E_ALL);
-define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
');
-require_once '../Classes/PHPWord.php';
+include_once 'Sample_Header.php';
// New Word document
echo date('H:i:s'), " Create new PHPWord object", EOL;
@@ -61,6 +57,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
-// Done
-echo date('H:i:s'), " Done writing file(s)", EOL;
-echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
+include_once 'Sample_Footer.php';
diff --git a/samples/Sample_15_Link.php b/samples/Sample_15_Link.php
index ef631906d9..8fcd181651 100644
--- a/samples/Sample_15_Link.php
+++ b/samples/Sample_15_Link.php
@@ -2,11 +2,7 @@
/**
* Link sample
*/
-
-// Init
-error_reporting(E_ALL);
-define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
');
-require_once '../Classes/PHPWord.php';
+include_once 'Sample_Header.php';
// New Word document
echo date('H:i:s'), " Create new PHPWord object", EOL;
@@ -35,6 +31,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
-// Done
-echo date('H:i:s'), " Done writing file(s)", EOL;
-echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
+include_once 'Sample_Footer.php';
diff --git a/samples/Sample_16_Object.php b/samples/Sample_16_Object.php
index e04c49e54d..dda23be2ff 100644
--- a/samples/Sample_16_Object.php
+++ b/samples/Sample_16_Object.php
@@ -2,11 +2,7 @@
/**
* Object sample
*/
-
-// Init
-error_reporting(E_ALL);
-define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '
');
-require_once '../Classes/PHPWord.php';
+include_once 'Sample_Header.php';
// New Word document
echo date('H:i:s'), " Create new PHPWord object", EOL;
@@ -30,6 +26,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
-// Done
-echo date('H:i:s'), " Done writing file(s)", EOL;
-echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
+include_once 'Sample_Footer.php';
diff --git a/samples/Sample_17_TitleTOC.php b/samples/Sample_17_TitleTOC.php
index efa756e4df..3edf03e00b 100644
--- a/samples/Sample_17_TitleTOC.php
+++ b/samples/Sample_17_TitleTOC.php
@@ -1,12 +1,8 @@
');
-require_once '../Classes/PHPWord.php';
+include_once 'Sample_Header.php';
// New Word document
echo date('H:i:s'), " Create new PHPWord object", EOL;
@@ -62,6 +58,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
-// Done
-echo date('H:i:s'), " Done writing file(s)", EOL;
-echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
+include_once 'Sample_Footer.php';
diff --git a/samples/Sample_18_Watermark.php b/samples/Sample_18_Watermark.php
index 8332bd0330..df1d581a2e 100644
--- a/samples/Sample_18_Watermark.php
+++ b/samples/Sample_18_Watermark.php
@@ -1,12 +1,8 @@
');
-require_once '../Classes/PHPWord.php';
+include_once 'Sample_Header.php';
// New Word document
echo date('H:i:s'), " Create new PHPWord object", EOL;
@@ -31,6 +27,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
-// Done
-echo date('H:i:s'), " Done writing file(s)", EOL;
-echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
+include_once 'Sample_Footer.php';
diff --git a/samples/Sample_19_TextBreak.php b/samples/Sample_19_TextBreak.php
index 17299601c6..6aad699f77 100644
--- a/samples/Sample_19_TextBreak.php
+++ b/samples/Sample_19_TextBreak.php
@@ -1,12 +1,8 @@
');
-require_once '../Classes/PHPWord.php';
+include_once 'Sample_Header.php';
// New Word document
echo date('H:i:s'), " Create new PHPWord object", EOL;
@@ -44,6 +40,4 @@
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
}
-// Done
-echo date('H:i:s'), " Done writing file(s)", EOL;
-echo date('H:i:s'), " Peak memory usage: ", (memory_get_peak_usage(true) / 1024 / 1024), " MB", EOL;
+include_once 'Sample_Footer.php';
diff --git a/samples/Sample_Footer.php b/samples/Sample_Footer.php
new file mode 100644
index 0000000000..2bff9273ab
--- /dev/null
+++ b/samples/Sample_Footer.php
@@ -0,0 +1,33 @@
+
';
+ echo 'Results: ';
+ foreach ($types as $type) {
+ $result = "results/{$sampleFile}.{$type}";
+ if (file_exists($result)) {
+ echo "{$type} ";
+ }
+ }
+ echo '
';
+?>
+
+
+
+