CreateDocx.inc
147 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
<?php
/**
* Generate a DOCX file
*
* @category Phpdocx
* @package create
* @copyright Copyright (c) Narcea Producciones Multimedia S.L.
* (http://www.2mdc.com)
* @license LGPL
* @version 3.0
* @link http://www.phpdocx.com
* @since File available since Release 3.0
*/
error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE);
require_once dirname(__FILE__) . '/AutoLoader.inc';
AutoLoader::load();
require_once dirname(__FILE__) . '/Phpdocx_config.inc';
class CreateDocx extends CreateDocument
{
const NAMESPACEWORD = 'w';
const SCHEMA_IMAGEDOCUMENT =
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image';
const SCHEMA_OFFICEDOCUMENT =
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument';
/**
*
* @var string
* @access public
* @static
*/
public static $PHPDOCXStyles;
/**
*
* @access public
* @static
* @var integer
*/
public static $numUL;
/**
*
* @access public
* @var integer
*/
public static $numOL;
/**
*
* @var string
* @access public
* @static
*/
public static $orderedListStyle;
/**
*
* @var string
* @access public
* @static
*/
public static $unorderedListStyle;
/**
*
* @access public
* @var array
*/
public $fileGraphicTemplate;
/**
*
* @access private
* @var boolean
*/
private $footerAdded;
/**
*
* @access private
* @var boolean
*/
private $headerAdded;
/**
*
* @access public
* @var string
*/
public $graphicTemplate;
/**
*
* @access public
* @static
* @var int
*/
public static $intIdWord;
/**
*
* @access public
* @static
* @var Logger
*/
public static $log;
/**
*
* @access public
* @static
* @var array
*/
public static $settings = array('w:writeProtection',
'w:view',
'w:zoom',
'w:removePersonalInformation',
'w:removeDateAndTime',
'w:doNotDisplayPageBoundaries',
'w:displayBackgroundShape',
'w:printPostScriptOverText',
'w:printFractionalCharacterWidth',
'w:printFormsData',
'w:embedTrueTypeFonts',
'w:embedSystemFonts',
'w:saveSubsetFonts',
'w:saveFormsData',
'w:mirrorMargins',
'w:alignBordersAndEdges',
'w:bordersDoNotSurroundHeader',
'w:bordersDoNotSurroundFooter',
'w:gutterAtTop',
'w:hideSpellingErrors',
'w:hideGrammaticalErrors',
'w:activeWritingStyle',
'w:proofState',
'w:formsDesign',
'w:attachedTemplate',
'w:linkStyles',
'w:stylePaneFormatFilter',
'w:stylePaneSortMethod',
'w:documentType',
'w:mailMerge',
'w:revisionView',
'w:trackRevisions',
'w:doNotTrackMoves',
'w:doNotTrackFormatting',
'w:documentProtection',
'w:autoFormatOverride',
'w:styleLockTheme',
'w:styleLockQFSet',
'w:defaultTabStop',
'w:autoHyphenation',
'w:consecutiveHyphenLimit',
'w:hyphenationZone',
'w:doNotHyphenateCaps',
'w:showEnvelope',
'w:summaryLength',
'w:clickAndTypeStyle',
'w:defaultTableStyle',
'w:evenAndOddHeaders',
'w:bookFoldRevPrinting',
'w:bookFoldPrinting',
'w:bookFoldPrintingSheets',
'w:drawingGridHorizontalSpacing',
'w:drawingGridVerticalSpacing',
'w:displayHorizontalDrawingGridEvery',
'w:displayVerticalDrawingGridEvery',
'w:doNotUseMarginsForDrawingGridOrigin',
'w:drawingGridHorizontalOrigin',
'w:drawingGridVerticalOrigin',
'w:doNotShadeFormData',
'w:noPunctuationKerning',
'w:characterSpacingControl',
'w:printTwoOnOne',
'w:strictFirstAndLastChars',
'w:noLineBreaksAfter',
'w:noLineBreaksBefore',
'w:savePreviewPicture',
'w:doNotValidateAgainstSchema',
'w:saveInvalidXml',
'w:ignoreMixedContent',
'w:alwaysShowPlaceholderText',
'w:doNotDemarcateInvalidXml',
'w:saveXmlDataOnly',
'w:useXSLTWhenSaving',
'w:saveThroughXslt',
'w:showXMLTags',
'w:alwaysMergeEmptyNamespace',
'w:updateFields',
'w:hdrShapeDefaults',
'w:footnotePr',
'w:endnotePr',
'w:compat',
'w:docVars',
'w:rsids',
'm:mathPr',
'w:uiCompat97To2003',
'w:attachedSchema',
'w:themeFontLang',
'w:clrSchemeMapping',
'w:doNotIncludeSubdocsInStats',
'w:doNotAutoCompressPictures',
'w:forceUpgrade',
'w:captions',
'w:readModeInkLockDown',
'w:smartTagType',
'sl:schemaLibrary',
'w:shapeDefaults',
'w:doNotEmbedSmartTags',
'w:decimalSymbol',
'w:listSeparator'
);
/**
*
* @access private
* @var string
*/
private $_background;
/**
*
* @access private
* @var string
*/
private $_backgroundColor;
/**
*
* @access private
* @var string
*/
private $_baseTemplateFilesPath;
/**
*
* @access private
* @var string
*/
private $_baseTemplatePath;
/**
*
* @access private
* @var string
*/
private $_baseTemplateZip;
/**
*
* @access private
* @var array
*/
private $_bookmarksIds;
/**
*
* @access private
* @var boolean
*/
private $_compatibilityMode;
/**
*
* @access private
* @var string
*/
private $_contentTypeC;
/**
*
* @access private
* @var string
*/
private $_defaultFont;
/**
*
* @access private
* @var Debug
*/
private $_debug;
/**
*
* @access private
* @var array
*/
private $_defaultPHPDOCXStyles;
/**
*
* @access private
* @var boolean
*/
private $_defaultTemplate;
/**
*
* @access private
* @var boolean
*/
private $_docm;
/**
*
* @access private
* @var string
*/
private $_docPropsAppC;
/**
*
* @access private
* @var string
*/
private $_docPropsAppT;
/**
*
* @access private
* @var string
*/
private $_docPropsCoreC;
/**
*
* @access private
* @var string
*/
private $_docPropsCoreT;
/**
*
* @access private
* @var string
*/
private $_docPropsCustomC;
/**
*
* @access private
* @var string
*/
private $_docPropsCustomT;
/**
*
* @access private
* @var string
*/
private static $_encodeUTF;
/**
*
* @access private
* @var string
*/
private $_extension;
/**
*
* @access private
* @var int
*/
private $_idImgHeader;
/**
*
* @access private
* @var int
*/
private $_idRels;
/**
*
* @access private
* @var array
*/
private $_idWords;
/**
*
* @access private
* @var string
*/
private $_language;
/**
*
* @access private
* @var boolean
*/
private $_macro;
/**
*
* @access private
* @var int
*/
private $_markAsFinal;
/**
*
* @access private
* @var array
*/
private $_parsedStyles;
/**
*
* @access private
* @var array
*/
private $_phpdocxconfig;
/**
*
* @access private
* @var string
*/
private $_relsRelsC;
/**
*
* @access private
* @var string
*/
private $_relsRelsT;
/**
*
* @access private
* @var array
*/
private $_relsHeader;
/**
*
* @access private
* @var array
*/
private $_relsHeaderFooterImage;
/**
*
* @access private
* @var array
*/
private $_relsHeaderFooterImageExternal;
/**
*
* @access private
* @var array
*/
private $_relsHeaderFooterLink;
/**
*
* @access private
* @var array
*/
private $_relsFooter;
/**
*
* @access private
* @var string
*/
private $_sectPr;
/**
* Directory path used for temporary files
*
* @access private
* @var string
*/
private $_tempDir;
/**
* Path of temp file to use as DOCX file
*
* @access private
* @var string
*/
private $_tempFile;
/**
* Paths of temps files to use as DOCX file
*
* @access private
* @var array
*/
private $_tempFileXLSX;
/**
* Numberings used by the replaceTemplateVariabeByHTML
*
* @access private
* @var array
*/
private $_templateNumberings;
/**
* Unique id for the insertion of new elements
*
* @access private
* @var string
*/
private $_uniqid;
/**
*
* @access private
* @var string
*/
private $_wordDocumentC;
/**
*
* @access private
* @var string
*/
private $_wordDocumentT;
/**
*
* @access private
* @var string
*/
private $_wordDocumentStyles;
/**
*
* @access private
* @var string
*/
private $_wordEndnotesC;
/**
*
* @access private
* @var string
*/
private $_wordEndnotesT;
/**
*
* @access private
* @var string
*/
private $_wordFontTableC;
/**
*
* @access private
* @var string
*/
private $_wordFontTableT;
/**
*
* @access private
* @var array
*/
private $_wordFooterC;
/**
*
* @access private
* @var array
*/
private $_wordFooterT;
/**
*
* @access private
* @var string
*/
private $_wordFootnotesC;
/**
*
* @access private
* @var string
*/
private $_wordFootnotesT;
/**
*
* @access private
* @var array
*/
private $_wordHeaderC;
/**
*
* @access private
* @var array
*/
private $_wordHeaderT;
/**
*
* @access private
* @var string
*/
private $_wordNumberingC;
/**
*
* @access private
* @var string
*/
private $_wordNumberingT;
/**
*
* @access private
* @var string
*/
private $_wordRelsDocumentRelsC;
/**
*
* @access private
* @var DOMDocument
*/
private $_wordRelsDocumentRelsT;
/**
*
* @access private
* @var array
*/
private $_wordRelsFooterRelsC;
/**
*
* @access private
* @var array
*/
private $_wordRelsFooterRelsT;
/**
*
* @access private
* @var array
*/
private $_wordRelsHeaderRelsC;
/**
*
* @access private
* @var array
*/
private $_wordRelsHeaderRelsT;
/**
*
* @access private
* @var string
*/
private $_wordSettingsC;
/**
*
* @access private
* @var string
*/
private $_wordSettingsT;
/**
*
* @access private
* @var string
*/
private $_wordStylesC;
/**
*
* @access private
* @var string
*/
private $_wordStylesT;
/**
*
* @access private
* @var string
*/
private $_wordThemeThemeT;
/**
*
* @access private
* @var string
*/
private $_wordThemeThemeC;
/**
*
* @access private
* @var string
*/
private $_wordWebSettingsC;
/**
*
* @access private
* @var string
*/
private $_wordWebSettingsT;
/**
*
* @access private
* @var ZipArchive
*/
private $_zipDocx;
/**
* Construct
*
* @access public
* @param string $baseTemplatePath. Optional, basicTemplate.docx as default
*/
public function __construct($baseTemplatePath = PHPDOCX_BASE_TEMPLATE)
{
$this->_debug = Debug::getInstance();
$this->_phpdocxconfig = PhpdocxUtilities::parseConfig();
$this->_background = '';
$this->_backgroundColor = 'FFFFFF';
$this->_baseTemplateFilesPath;
if ($baseTemplatePath == 'docm') {
$this->_baseTemplatePath = PHPDOCX_BASE_FOLDER.'phpdocxBaseTemplate.docm';
$this->_docm = true;
$this->_defaultTemplate = true;
$this->_extension = 'docm';
} else if($baseTemplatePath == 'docx') {
$this->_baseTemplatePath = PHPDOCX_BASE_FOLDER.'phpdocxBaseTemplate.docx';
$this->_docm = false;
$this->_defaultTemplate = true;
$this->_extension = 'docx';
} else {
if ($baseTemplatePath == PHPDOCX_BASE_TEMPLATE) {
$this->_defaultTemplate = true;
} else {
$this->_defaultTemplate = false;
}
$this->_baseTemplatePath = $baseTemplatePath;
$extensionArray = explode('.', $this->_baseTemplatePath);
$extension = array_pop($extensionArray);
$this->_extension = $extension;
if ($extension == 'docm') {
$this->_docm = true;
} else if ($extension == 'docx') {
$this->_docm = false;
} else {
PhpdocxLogger::logger('Invalid base template extension', 'fatal');
}
}
$this->_baseTemplateZip = new ZipArchive();
$this->_bookmarksIds = array();
$this->_idRels = array();
$this->_idWords = array();
$this->_idImgHeader = 1;
$this->_idRels = 1;
self::$intIdWord = rand(9999999,99999999);
self::$_encodeUTF = 0;
$this->_language = 'en-US';
$this->_markAsFinal = 0;
$this->graphicTemplate = array();
$this->fileGraphicTemplate = array();
$this->_zipDocx = new ZipArchive();
if ($this->_phpdocxconfig['settings']['temp_path']) {
$this->_tempDir = $this->_phpdocxconfig['settings']['temp_path'];
} else {
$this->_tempDir = self::getTempDir();
}
$this->_tempFile = tempnam($this->_tempDir, 'document');
$this->_templateNumberings;
$this->_zipDocx->open($this->_tempFile, ZipArchive::OVERWRITE);
$this->_compatibilityMode = false;
PhpdocxLogger::logger('Create a temp file to use as initial ZIP file. ' .
'DOCX is a ZIP file.', 'info');
// sign is set false as default
$this->_sign = false;
$this->_relsRelsC = '';
$this->_relsRelsT = '';
$this->_contentTypeC = '';
$this->_contentTypeT = NULL;
$this->_defaultFont = '';
$this->_docPropsAppC = '';
$this->_docPropsAppT = '';
$this->_docPropsCoreC = '';
$this->_docPropsCoreT = '';
$this->_docPropsCustomC = '';
$this->_docPropsCustomT = '';
$this->_macro = 0;
$this->_relsHeader = array();
$this->_relsFooter = array();
$this->_parsedStyles = array();
$this->_relsHeaderFooterImage = array();
$this->_relsHeaderFooterImageExternal = array();
$this->_relsHeaderFooterLink = array();
$this->_sectPr = NULL;
$this->_tempFileXLSX = array();
$this->_uniqid = 'phpdocx_'.uniqid();
$this->_wordDocumentT = '';
$this->_wordDocumentC = '';
$this->_wordDocumentStyles = '';
$this->_wordEndnotesC = '';
$this->_wordEndnotesT = '';
$this->_wordFontTableT = '';
$this->_wordFontTableC = '';
$this->_wordFooterC = array();
$this->_wordFooterT = array();
$this->_wordFootnotesC = '';
$this->_wordFootnotesT = '';
$this->_wordHeaderC = array();
$this->_wordHeaderT = array();
$this->_wordNumberingC;
$this->_wordNumberingT;
$this->_wordRelsDocumentRelsC = '';
$this->_wordRelsDocumentRelsT = NULL;
$this->_wordRelsHeaderRelsC = array();
$this->_wordRelsHeaderRelsT = array();
$this->_wordRelsFooterRelsC = array();
$this->_wordRelsFooterRelsT = array();
$this->_wordSettingsT = '';
$this->_wordSettingsC = '';
$this->_wordStylesT = '';
$this->_wordStylesC = '';
$this->_wordThemeThemeT = '';
$this->_wordThemeThemeC = '';
$this->_wordWebSettingsT = '';
$this->_wordWebSettingsC = '';
$this->_defaultPHPDOCXStyles = array('Default Paragraph Font PHPDOCX', //This is the default paragraph font style used in multiple places
'List Paragraph PHPDOCX', //This is the style used for the defolt ordered and unorderd lists
'Title PHPDOCX', //This style is used by the addTitle method
'Subtitle PHPDOCX', //This style is used by the addTitle method
'Normal Table PHPDOCX', //This style is used for the basic table
'Table Grid PHPDOCX', //This style is for basic tables and is also used to embed HTML tables with border="1"
'footnote text PHPDOCX', //This style is used for default footnotes
'footnote text Car PHPDOCX', //The character style for footnotes
'footnote reference PHPDOCX', // The style for the footnote
'endnote text PHPDOCX', //This style is used for default endnotes
'endnote text Car PHPDOCX', //The character style for endnotes
'endnote reference PHPDOCX'); // The style for the endnote
//Some variables to control that some v2.4 keep working
$this->footerAdded = false;
$this->headerAdded = false;
self::$PHPDOCXStyles = '<w:styles xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" >
<w:style w:type="character" w:styleId="DefaultParagraphFontPHPDOCX">
<w:name w:val="Default Paragraph Font PHPDOCX"/>
<w:uiPriority w:val="1"/>
<w:semiHidden/>
<w:unhideWhenUsed/>
</w:style>
<w:style w:type="paragraph" w:styleId="ListParagraphPHPDOCX">
<w:name w:val="List Paragraph PHPDOCX"/>
<w:basedOn w:val="Normal"/>
<w:uiPriority w:val="34"/>
<w:qFormat/>
<w:rsid w:val="00DF064E"/>
<w:pPr>
<w:ind w:left="720"/>
<w:contextualSpacing/>
</w:pPr>
</w:style>
<w:style w:type="paragraph" w:styleId="TitlePHPDOCX">
<w:name w:val="Title PHPDOCX"/>
<w:basedOn w:val="Normal"/>
<w:next w:val="Normal"/>
<w:link w:val="TitleCarPHPDOCX"/>
<w:uiPriority w:val="10"/>
<w:qFormat/>
<w:rsid w:val="00DF064E"/>
<w:pPr>
<w:pBdr>
<w:bottom w:val="single" w:sz="8" w:space="4" w:color="4F81BD" w:themeColor="accent1"/>
</w:pBdr>
<w:spacing w:after="300" w:line="240" w:lineRule="auto"/>
<w:contextualSpacing/>
</w:pPr>
<w:rPr>
<w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi"/>
<w:color w:val="17365D" w:themeColor="text2" w:themeShade="BF"/>
<w:spacing w:val="5"/>
<w:kern w:val="28"/>
<w:sz w:val="52"/>
<w:szCs w:val="52"/>
</w:rPr>
</w:style>
<w:style w:type="character" w:customStyle="1" w:styleId="TitleCarPHPDOCX">
<w:name w:val="Title Car PHPDOCX"/>
<w:basedOn w:val="DefaultParagraphFontPHPDOCX"/>
<w:link w:val="TitlePHPDOCX"/>
<w:uiPriority w:val="10"/>
<w:rsid w:val="00DF064E"/>
<w:rPr>
<w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi"/>
<w:color w:val="17365D" w:themeColor="text2" w:themeShade="BF"/>
<w:spacing w:val="5"/>
<w:kern w:val="28"/>
<w:sz w:val="52"/>
<w:szCs w:val="52"/>
</w:rPr>
</w:style>
<w:style w:type="paragraph" w:styleId="SubtitlePHPDOCX">
<w:name w:val="Subtitle PHPDOCX"/>
<w:basedOn w:val="Normal"/>
<w:next w:val="Normal"/>
<w:link w:val="SubtitleCarPHPDOCX"/>
<w:uiPriority w:val="11"/>
<w:qFormat/>
<w:rsid w:val="00DF064E"/>
<w:pPr>
<w:numPr>
<w:ilvl w:val="1"/>
</w:numPr>
</w:pPr>
<w:rPr>
<w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi"/>
<w:i/>
<w:iCs/>
<w:color w:val="4F81BD" w:themeColor="accent1"/>
<w:spacing w:val="15"/>
<w:sz w:val="24"/>
<w:szCs w:val="24"/>
</w:rPr>
</w:style>
<w:style w:type="character" w:customStyle="1" w:styleId="SubtitleCarPHPDOCX">
<w:name w:val="Subtitle Car PHPDOCX"/>
<w:basedOn w:val="DefaultParagraphFontPHPDOCX"/>
<w:link w:val="SubtitlePHPDOCX"/>
<w:uiPriority w:val="11"/>
<w:rsid w:val="00DF064E"/>
<w:rPr>
<w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi"/>
<w:i/>
<w:iCs/>
<w:color w:val="4F81BD" w:themeColor="accent1"/>
<w:spacing w:val="15"/>
<w:sz w:val="24"/>
<w:szCs w:val="24"/>
</w:rPr>
</w:style>
<w:style w:type="table" w:styleId="NormalTablePHPDOCX">
<w:name w:val="Normal Table PHPDOCX"/>
<w:uiPriority w:val="99"/>
<w:semiHidden/>
<w:unhideWhenUsed/>
<w:qFormat/>
<w:pPr>
<w:spacing w:after="0" w:line="240" w:lineRule="auto"/>
</w:pPr>
<w:tblPr>
<w:tblInd w:w="0" w:type="dxa"/>
<w:tblCellMar>
<w:top w:w="0" w:type="dxa"/>
<w:left w:w="108" w:type="dxa"/>
<w:bottom w:w="0" w:type="dxa"/>
<w:right w:w="108" w:type="dxa"/>
</w:tblCellMar>
</w:tblPr>
</w:style>
<w:style w:type="table" w:styleId="TableGridPHPDOCX">
<w:name w:val="Table Grid PHPDOCX"/>
<w:uiPriority w:val="59"/>
<w:rsid w:val="00493A0C"/>
<w:pPr>
<w:spacing w:after="0" w:line="240" w:lineRule="auto"/>
</w:pPr>
<w:tblPr>
<w:tblInd w:w="0" w:type="dxa"/>
<w:tblBorders>
<w:top w:val="single" w:sz="4" w:space="0" w:color="auto"/>
<w:left w:val="single" w:sz="4" w:space="0" w:color="auto"/>
<w:bottom w:val="single" w:sz="4" w:space="0" w:color="auto"/>
<w:right w:val="single" w:sz="4" w:space="0" w:color="auto"/>
<w:insideH w:val="single" w:sz="4" w:space="0" w:color="auto"/>
<w:insideV w:val="single" w:sz="4" w:space="0" w:color="auto"/>
</w:tblBorders>
<w:tblCellMar>
<w:top w:w="0" w:type="dxa"/>
<w:left w:w="108" w:type="dxa"/>
<w:bottom w:w="0" w:type="dxa"/>
<w:right w:w="108" w:type="dxa"/>
</w:tblCellMar>
</w:tblPr>
</w:style>
<w:style w:type="paragraph" w:styleId="footnoteTextPHPDOCX">
<w:name w:val="footnote Text PHPDOCX"/>
<w:basedOn w:val="Normal"/>
<w:link w:val="footnoteTextCarPHPDOCX"/>
<w:uiPriority w:val="99"/>
<w:semiHidden/>
<w:unhideWhenUsed/>
<w:rsid w:val="006E0FDA"/>
<w:pPr>
<w:spacing w:after="0" w:line="240" w:lineRule="auto"/>
</w:pPr>
<w:rPr>
<w:sz w:val="20"/>
<w:szCs w:val="20"/>
</w:rPr>
</w:style>
<w:style w:type="character" w:customStyle="1" w:styleId="footnoteTextCarPHPDOCX">
<w:name w:val="footnote Text Car PHPDOCX"/>
<w:basedOn w:val="DefaultParagraphFontPHPDOCX"/>
<w:link w:val="footnoteTextPHPDOCX"/>
<w:uiPriority w:val="99"/>
<w:semiHidden/>
<w:rsid w:val="006E0FDA"/>
<w:rPr>
<w:sz w:val="20"/>
<w:szCs w:val="20"/>
</w:rPr>
</w:style>
<w:style w:type="character" w:styleId="footnoteReferencePHPDOCX">
<w:name w:val="footnote Reference PHPDOCX"/>
<w:basedOn w:val="DefaultParagraphFontPHPDOCX"/>
<w:uiPriority w:val="99"/>
<w:semiHidden/>
<w:unhideWhenUsed/>
<w:rsid w:val="006E0FDA"/>
<w:rPr>
<w:vertAlign w:val="superscript"/>
</w:rPr>
</w:style>
<w:style w:type="paragraph" w:styleId="endnoteTextPHPDOCX">
<w:name w:val="endnote Text PHPDOCX"/>
<w:basedOn w:val="Normal"/>
<w:link w:val="endnoteTextCarPHPDOCX"/>
<w:uiPriority w:val="99"/>
<w:semiHidden/>
<w:unhideWhenUsed/>
<w:rsid w:val="006E0FDA"/>
<w:pPr>
<w:spacing w:after="0" w:line="240" w:lineRule="auto"/>
</w:pPr>
<w:rPr>
<w:sz w:val="20"/>
<w:szCs w:val="20"/>
</w:rPr>
</w:style>
<w:style w:type="character" w:customStyle="1" w:styleId="endnoteTextCarPHPDOCX">
<w:name w:val="endnote Text Car PHPDOCX"/>
<w:basedOn w:val="DefaultParagraphFontPHPDOCX"/>
<w:link w:val="endnoteTextPHPDOCX"/>
<w:uiPriority w:val="99"/>
<w:semiHidden/>
<w:rsid w:val="006E0FDA"/>
<w:rPr>
<w:sz w:val="20"/>
<w:szCs w:val="20"/>
</w:rPr>
</w:style>
<w:style w:type="character" w:styleId="endnoteReferencePHPDOCX">
<w:name w:val="endnote Reference PHPDOCX"/>
<w:basedOn w:val="DefaultParagraphFontPHPDOCX"/>
<w:uiPriority w:val="99"/>
<w:semiHidden/>
<w:unhideWhenUsed/>
<w:rsid w:val="006E0FDA"/>
<w:rPr>
<w:vertAlign w:val="superscript"/>
</w:rPr>
</w:style>
</w:styles>';
self::$unorderedListStyle = '<w:abstractNum w:abstractNumId="" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" >
<w:multiLevelType w:val="hybridMultilevel"/>
<w:lvl w:ilvl="0" w:tplc="">
<w:start w:val="1"/>
<w:numFmt w:val="bullet"/>
<w:lvlText w:val=""/>
<w:lvlJc w:val="left"/>
<w:pPr>
<w:ind w:left="720" w:hanging="360"/>
</w:pPr>
<w:rPr>
<w:rFonts w:ascii="Symbol" w:hAnsi="Symbol" w:hint="default"/>
</w:rPr>
</w:lvl>
<w:lvl w:ilvl="1" w:tplc="0C0A0003" w:tentative="1">
<w:start w:val="1"/>
<w:numFmt w:val="bullet"/>
<w:lvlText w:val="o"/>
<w:lvlJc w:val="left"/>
<w:pPr>
<w:ind w:left="1440" w:hanging="360"/>
</w:pPr>
<w:rPr>
<w:rFonts w:ascii="Courier New" w:hAnsi="Courier New" w:cs="Courier New" w:hint="default"/>
</w:rPr>
</w:lvl>
<w:lvl w:ilvl="2" w:tplc="0C0A0005" w:tentative="1">
<w:start w:val="1"/>
<w:numFmt w:val="bullet"/>
<w:lvlText w:val=""/>
<w:lvlJc w:val="left"/>
<w:pPr>
<w:ind w:left="2160" w:hanging="360"/>
</w:pPr>
<w:rPr>
<w:rFonts w:ascii="Wingdings" w:hAnsi="Wingdings" w:hint="default"/>
</w:rPr>
</w:lvl>
<w:lvl w:ilvl="3" w:tplc="0C0A0001" w:tentative="1">
<w:start w:val="1"/>
<w:numFmt w:val="bullet"/>
<w:lvlText w:val=""/>
<w:lvlJc w:val="left"/>
<w:pPr>
<w:ind w:left="2880" w:hanging="360"/>
</w:pPr>
<w:rPr>
<w:rFonts w:ascii="Symbol" w:hAnsi="Symbol" w:hint="default"/>
</w:rPr>
</w:lvl>
<w:lvl w:ilvl="4" w:tplc="0C0A0003" w:tentative="1">
<w:start w:val="1"/>
<w:numFmt w:val="bullet"/>
<w:lvlText w:val="o"/>
<w:lvlJc w:val="left"/>
<w:pPr>
<w:ind w:left="3600" w:hanging="360"/>
</w:pPr>
<w:rPr>
<w:rFonts w:ascii="Courier New" w:hAnsi="Courier New" w:cs="Courier New" w:hint="default"/>
</w:rPr>
</w:lvl>
<w:lvl w:ilvl="5" w:tplc="0C0A0005" w:tentative="1">
<w:start w:val="1"/>
<w:numFmt w:val="bullet"/>
<w:lvlText w:val=""/>
<w:lvlJc w:val="left"/>
<w:pPr>
<w:ind w:left="4320" w:hanging="360"/>
</w:pPr>
<w:rPr>
<w:rFonts w:ascii="Wingdings" w:hAnsi="Wingdings" w:hint="default"/>
</w:rPr>
</w:lvl>
<w:lvl w:ilvl="6" w:tplc="0C0A0001" w:tentative="1">
<w:start w:val="1"/>
<w:numFmt w:val="bullet"/>
<w:lvlText w:val=""/>
<w:lvlJc w:val="left"/>
<w:pPr>
<w:ind w:left="5040" w:hanging="360"/>
</w:pPr>
<w:rPr>
<w:rFonts w:ascii="Symbol" w:hAnsi="Symbol" w:hint="default"/>
</w:rPr>
</w:lvl>
<w:lvl w:ilvl="7" w:tplc="0C0A0003" w:tentative="1">
<w:start w:val="1"/>
<w:numFmt w:val="bullet"/>
<w:lvlText w:val="o"/>
<w:lvlJc w:val="left"/>
<w:pPr>
<w:ind w:left="5760" w:hanging="360"/>
</w:pPr>
<w:rPr>
<w:rFonts w:ascii="Courier New" w:hAnsi="Courier New" w:cs="Courier New" w:hint="default"/>
</w:rPr>
</w:lvl>
<w:lvl w:ilvl="8" w:tplc="0C0A0005" w:tentative="1">
<w:start w:val="1"/>
<w:numFmt w:val="bullet"/>
<w:lvlText w:val=""/>
<w:lvlJc w:val="left"/>
<w:pPr>
<w:ind w:left="6480" w:hanging="360"/>
</w:pPr>
<w:rPr>
<w:rFonts w:ascii="Wingdings" w:hAnsi="Wingdings" w:hint="default"/>
</w:rPr>
</w:lvl>
</w:abstractNum>';
self::$orderedListStyle ='<w:abstractNum w:abstractNumId="" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" >
<w:multiLevelType w:val="hybridMultilevel"/>
<w:lvl w:ilvl="0" w:tplc="">
<w:start w:val="1"/>
<w:numFmt w:val="decimal"/>
<w:lvlText w:val="%1."/>
<w:lvlJc w:val="left"/>
<w:pPr>
<w:ind w:left="720" w:hanging="360"/>
</w:pPr>
</w:lvl>
<w:lvl w:ilvl="1" w:tplc="" w:tentative="1">
<w:start w:val="1"/>
<w:numFmt w:val="lowerLetter"/>
<w:lvlText w:val="%2."/>
<w:lvlJc w:val="left"/>
<w:pPr>
<w:ind w:left="1440" w:hanging="360"/>
</w:pPr>
</w:lvl>
<w:lvl w:ilvl="2" w:tplc="" w:tentative="1">
<w:start w:val="1"/>
<w:numFmt w:val="lowerRoman"/>
<w:lvlText w:val="%3."/>
<w:lvlJc w:val="right"/>
<w:pPr>
<w:ind w:left="2160" w:hanging="180"/>
</w:pPr>
</w:lvl>
<w:lvl w:ilvl="3" w:tplc="" w:tentative="1">
<w:start w:val="1"/>
<w:numFmt w:val="decimal"/>
<w:lvlText w:val="%4."/>
<w:lvlJc w:val="left"/>
<w:pPr>
<w:ind w:left="2880" w:hanging="360"/>
</w:pPr>
</w:lvl>
<w:lvl w:ilvl="4" w:tplc="" w:tentative="1">
<w:start w:val="1"/>
<w:numFmt w:val="lowerLetter"/>
<w:lvlText w:val="%5."/>
<w:lvlJc w:val="left"/>
<w:pPr>
<w:ind w:left="3600" w:hanging="360"/>
</w:pPr>
</w:lvl>
<w:lvl w:ilvl="5" w:tplc="" w:tentative="1">
<w:start w:val="1"/>
<w:numFmt w:val="lowerRoman"/>
<w:lvlText w:val="%6."/>
<w:lvlJc w:val="right"/>
<w:pPr>
<w:ind w:left="4320" w:hanging="180"/>
</w:pPr>
</w:lvl>
<w:lvl w:ilvl="6" w:tplc="" w:tentative="1">
<w:start w:val="1"/>
<w:numFmt w:val="decimal"/>
<w:lvlText w:val="%7."/>
<w:lvlJc w:val="left"/>
<w:pPr>
<w:ind w:left="5040" w:hanging="360"/>
</w:pPr>
</w:lvl>
<w:lvl w:ilvl="7" w:tplc="" w:tentative="1">
<w:start w:val="1"/>
<w:numFmt w:val="lowerLetter"/>
<w:lvlText w:val="%8."/>
<w:lvlJc w:val="left"/>
<w:pPr>
<w:ind w:left="5760" w:hanging="360"/>
</w:pPr>
</w:lvl>
<w:lvl w:ilvl="8" w:tplc="" w:tentative="1">
<w:start w:val="1"/>
<w:numFmt w:val="lowerRoman"/>
<w:lvlText w:val="%9."/>
<w:lvlJc w:val="right"/>
<w:pPr>
<w:ind w:left="6480" w:hanging="180"/>
</w:pPr>
</w:lvl>
</w:abstractNum>';
//We now try to open the zip file defined as base template
try {
$openBaseTemplate = $this->_baseTemplateZip->open($this->_baseTemplatePath);
if ($openBaseTemplate !== true) {
throw new Exception('Error while opening the Base Template: please, check the path');
}
}
catch (Exception $e) {
PhpdocxLogger::logger($e->getMessage(), 'fatal');
}
//We now extract the contents of the base template into a temp dir for further manipulation
try {
$this->_baseTemplateFilesPath = $this->_tempDir.'/'.uniqid(true);
$extractBaseTemplate =$this->_baseTemplateZip->extractTo($this->_baseTemplateFilesPath);
if ($extractBaseTemplate !== true) {
throw new Exception('Error while extracting the Base Template: there may be problems writing in the default tmp folder');
}
}
catch (Exception $e) {
PhpdocxLogger::logger($e->getMessage(), 'fatal');
}
//We should now check if there is any structured content as front page to include it in the resulting document
try{
$baseTemplateDocumentT = $this->_baseTemplateZip->getFromName('word/document.xml');
if ($baseTemplateDocumentT == '') {
throw new Exception('Error while extracting the document.xml file from the base template');
}
}
catch (Exception $e) {
PhpdocxLogger::logger($e->getMessage(), 'fatal');
}
$baseDocument = new DOMDocument();
$baseDocument->loadXML($baseTemplateDocumentT);
$docXpath = new DOMXPath($baseDocument);
$docXpath->registerNamespace('w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
$queryDoc = '//w:body/w:sdt';
$docNodes = $docXpath->query($queryDoc);
if ($docNodes->length > 0){
if($docNodes->item(0)->nodeName == 'w:sdt'){
$tempDoc = new DomDocument();
$sdt =$tempDoc->importNode($docNodes->item(0), true);
$newNode = $tempDoc->appendChild($sdt);
$frontPage = $tempDoc->saveXML($newNode);
$this->_wordDocumentC .= $frontPage;
}
}
//Let us extract now the section information to include it at the end of the document.xml file
$sectPr = $baseDocument->getElementsByTagName('sectPr')->item(0);
$this->_sectPr = new DOMDocument();
$sectNode = $this->_sectPr->importNode($sectPr, true);
$this->_sectPr->appendChild($sectNode);
//Let us extract the contents of the [Content_Types].xml file for further manipulation
try {
$baseTemplateContentTypeT = $this->_baseTemplateZip->getFromName('[Content_Types].xml');
if ($baseTemplateContentTypeT == '') {
throw new Exception('Error while extracting the [Content_Types].xml file from the base template');
}
}
catch (Exception $e) {
PhpdocxLogger::logger($e->getMessage(), 'fatal');
}
$this->_contentTypeT = new DOMDocument();
$this->_contentTypeT->loadXML($baseTemplateContentTypeT);
//We are going to include the standard image defaults
$this->generateDEFAULT('gif', 'image/gif');
$this->generateDEFAULT('jpg', 'image/jpg');
$this->generateDEFAULT('png', 'image/png');
$this->generateDEFAULT('jpeg', 'image/jpeg');
$this->generateDEFAULT('bmp', 'image/bmp');
//Let us extract the document.xml.rels for further manipulation
try {
$baseTemplateDocumentRelsT = $this->_baseTemplateZip->getFromName('word/_rels/document.xml.rels');
if ($baseTemplateDocumentRelsT == '') {
throw new Exception('Error while extracting the document.xml.rels file from the base template');
}
}
catch (Exception $e) {
PhpdocxLogger::logger($e->getMessage(), 'fatal');
}
$this->_wordRelsDocumentRelsT = new DOMDocument();
$this->_wordRelsDocumentRelsT->loadXML($baseTemplateDocumentRelsT);
$relationships = $this->_wordRelsDocumentRelsT->getElementsByTagName('Relationship');
//Now we have to take care of the case that the template used is not one of the default preprocessed templates
if ($this->_defaultTemplate) {
self::$numUL = 1;
self::$numOL = rand(9999, 999999999);
//Let's get the original template numbering.xml file as a DOMdocument
try {
$this->_wordNumberingT = $this->_baseTemplateZip->getFromName('word/numbering.xml');
if ($this->_wordNumberingT == '') {
throw new Exception('Error while extracting the numbering file from the base template');
}
}
catch (Exception $e) {
PhpdocxLogger::logger($e->getMessage(), 'fatal');
}
} else {
//We should do now some cleaning of the files from the base template zip
//Let us first look at the document.xml.rels file to analyze the contents
//Let us analyze its structure
//In order to do that we should parse word/_rels/document.xml.rels
$counter = $relationships->length -1;
for ($j=$counter; $j > -1; $j--) {
$completeType = $relationships->item($j)->getAttribute('Type');
$target = $relationships->item($j)->getAttribute('Target');
$tempArray = explode('/', $completeType);
$type = array_pop($tempArray);
//This array holds the data that has to be changed in settings.xml
$arrayCleaner = array();
switch($type){
case 'header':
//TODO: this should be changed if we use default templates with headers
array_push($this->_relsHeader,$target);
break;
case 'footer':
//TODO: this should be changed if we use default templates with footers
array_push($this->_relsFooter,$target);
break;
case 'chart':
$this->recursiveDelete($this->_baseTemplateFilesPath.'/word/charts');
$this->_wordRelsDocumentRelsT->documentElement->removeChild($relationships->item($j));
break;
case 'embeddings':
$this->recursiveDelete($this->_baseTemplateFilesPath.'/word/embeddings');
$this->_wordRelsDocumentRelsT->documentElement->removeChild($relationships->item($j));
break;
}
}
//Let us now manage the numbering.xml and style.xml files
// We are going to use some default styles, for example, in the creation of lists, footnotes, titles, ...
// So we should make sure that it is included in the styles.xml document
$this->importStyles(PHPDOCX_BASE_TEMPLATE, 'merge', $this->_defaultPHPDOCXStyles);
//Let us first check if the base template file has a numbering.xml file
$numRef = rand(9999999, 99999999);
self::$numUL = $numRef;
self::$numOL = $numRef +1;
if(file_exists($this->_baseTemplateFilesPath.'/word/numbering.xml')) {
//Let's get the original template numbering.xml file as a DOMdocument
try {
$this->_wordNumberingT = $this->_baseTemplateZip->getFromName('word/numbering.xml');
if ($this->_wordNumberingT == '') {
throw new Exception('Error while extracting the numbering file from the base template');
}
} catch (Exception $e) {
PhpdocxLogger::logger($e->getMessage(), 'fatal');
}
$this->_wordNumberingT = $this->importSingleNumbering($this->_wordNumberingT, self::$unorderedListStyle, self::$numUL);
$this->_wordNumberingT = $this->importSingleNumbering($this->_wordNumberingT, self::$orderedListStyle, self::$numOL);
}else{
$this->_wordNumberingT = $this->generateBaseWordNumbering();
$this->_wordNumberingT = $this->importSingleNumbering($this->_wordNumberingT, self::$unorderedListStyle, self::$numUL);
$this->_wordNumberingT = $this->importSingleNumbering($this->_wordNumberingT, self::$orderedListStyle, self::$numOL);
//Now we should include the corresponding relationshipand Override
$this->_wordRelsDocumentRelsC .= $this->generateRELATIONSHIP(
'rId' . rand(99999999, 999999999), 'numbering', 'numbering.xml'
);
$this->generateOVERRIDE('/word/numbering.xml','application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml');
}
//Let us now make sure that there are the corresponding xmls, with all their relationships for endnotes and footnotes
if(!file_exists($this->_baseTemplateFilesPath.'/word/endnotes.xml') || !file_exists($this->_baseTemplateFilesPath.'/word/footnotes.xml')){
$notesZip = new ZipArchive();
try {
$openNotesZip = $notesZip->open(PHPDOCX_BASE_TEMPLATE);
if ($openNotesZip !== true){
throw new Exception('Error while opening the standard base template to extract the word/footnotes.xml and word/endnotes.xml file');
}
}
catch (Exception $e) {
PhpdocxLogger::logger($e->getMessage(), 'fatal');
}
$arraySettings = array();
if(!file_exists($this->_baseTemplateFilesPath.'/word/footnotes.xml')){
$notesZip->extractTo($this->_baseTemplateFilesPath, 'word/footnotes.xml');
//Now we should include the corresponding relationshipand Override
$this->_wordRelsDocumentRelsC .= $this->generateRELATIONSHIP(
'rId' . rand(99999999, 999999999), 'footnotes', 'footnotes.xml'
);
$this->generateOVERRIDE('/word/footnotes.xml','application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml');
array_push($arraySettings, '<w:footnotePr><w:footnote w:id="-1" /><w:footnote w:id="0" /></w:footnotePr>');
}
if(!file_exists($this->_baseTemplateFilesPath.'/word/endnotes.xml')){
$notesZip->extractTo($this->_baseTemplateFilesPath, 'word/endnotes.xml');
//Now we should include the corresponding relationshipand Override
$this->_wordRelsDocumentRelsC .= $this->generateRELATIONSHIP(
'rId' . rand(99999999, 999999999), 'endnotes', 'endnotes.xml'
);
$this->generateOVERRIDE('/word/endnotes.xml','application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml');
array_push($arraySettings,'<w:endnotePr><w:endnote w:id="-1" /><w:endnote w:id="0" /></w:endnotePr>');
}
//$this->includeSettings($arraySettings)
}
}
$this->setLanguage($this->_phpdocxconfig['settings']['language']);
}
/**
* Destruct
*
* @access public
*/
public function __destruct()
{
}
/**
* Magic method, returns current word XML
*
* @access public
* @return string Return current word
*/
public function __toString()
{
$this->generateTemplateWordDocument();
PhpdocxLogger::logger('Get document template content.', 'debug');
return $this->_wordDocumentT;
}
/**
* Setter
*
* @access public
*/
public function setExtension($extension)
{
$this->_extension = $extension;
}
/**
* Getter
*
* @access public
*/
public function getExtension()
{
return $this->_extension;
}
/**
* Setter
*
* @access public
*/
public function setTemporaryDirectory($tempDir)
{
$this->_tempDir = $tempDir;
}
/**
* Getter
*
* @access public
*/
public function getTemporaryDirectory()
{
return $this->_tempDir;
}
/**
* Setter
*
* @access public
*/
public function setXmlContentTypes($xmlContentTypes)
{
$this->_contentTypeC = $xmlContentTypes;
}
/**
* Getter
*
* @access public
*/
public function getXmlContentTypes()
{
return $this->_contentTypeC;
}
/**
* Setter
*
* @access public
*/
public function setXmlRelsRels($xmlRelsRels)
{
$this->_relsRelsC = $xmlRelsRels;
}
/**
* Getter
*
* @access public
*/
public function getXmlRelsRels()
{
return $this->_relsRelsC;
}
/**
* Setter
*
* @access public
*/
public function setXmlDocPropsApp($xmlDocPropsApp)
{
$this->_docPropsAppC = $xmlDocPropsApp;
}
/**
* Getter
*
* @access public
*/
public function getXmlDocPropsApp()
{
return $this->_docPropsAppC;
}
/**
* Setter
*
* @access public
*/
public function setXmlDocPropsCore($xmlDocPropsCore)
{
$this->_docPropsCoreC = $xmlDocPropsCore;
}
/**
* Getter
*
* @access public
*/
public function getXmlDocPropsCore()
{
return $this->_docPropsCoreC;
}
/**
* Setter
*
* @access public
*/
public function setXmlDocPropsCustom($xmlDocPropsCustom)
{
$this->_docPropsCustomC = $xmlDocPropsCustom;
}
/**
* Getter
*
* @access public
*/
public function getXmlDocPropsCustom()
{
return $this->_docPropsCustomC;
}
/**
* Setter
*
* @access public
*/
public function setXmlWordDocument($xmlWordDocument)
{
$this->_wordDocumentC = $xmlWordDocument;
}
/**
* Getter
*
* @access public
*/
public function getXmlWordDocumentContent()
{
return $this->_wordDocumentC;
}
/**
* Setter
*
* @access public
*/
public function setXmlWordDocumentStyles($xmlWordDocumentStyles)
{
$this->_wordDocumentStyles = $xmlWordDocumentStyles;
}
/**
* Getter
*
* @access public
*/
public function getXmlWordDocumentStyles()
{
return $this->_wordDocumentStyles;
}
/**
* Setter
*
* @access public
*/
public function setXmlWordEndnotes($xmlWordEndnotes)
{
$this->_wordEndnotesC = $xmlWordEndnotes;
}
/**
* Getter
*
* @access public
*/
public function getXmlWordEndnotes()
{
return $this->_wordEndnotesC;
}
/**
* Setter
*
* @access public
*/
public function setXmlWordFontTable($xmlWordFontTable)
{
$this->_wordFontTableC = $xmlWordFontTable;
}
/**
* Getter
*
* @access public
*/
public function getXmlWordFontTable()
{
return $this->_wordFontTableC;
}
/**
* Setter
*
* @access public
*/
public function setXmlWordFooter1($xmlWordFooter)
{
$this->_wordFooterC = $xmlWordFooter;
}
/**
* Getter
*
* @access public
*/
public function getXmlWordFooter1()
{
return $this->_wordFooterC;
}
/**
* Setter
*
* @access public
*/
public function setXmlWordHeader1($xmlWordHeader)
{
$this->_wordHeaderC = $xmlWordHeader;
}
/**
* Getter
*
* @access public
*/
public function getXmlWordHeader1()
{
return $this->_wordHeaderC;
}
/**
* Setter
*
* @access public
*/
public function setXmlWordRelsDocumentRels($xmlWordRelsDocumentRels)
{
$this->_wordRelsDocumentRelsC = $xmlWordRelsDocumentRels;
}
/**
* Getter
*
* @access public
*/
public function getXmlWordRelsDocumentRels()
{
return $this->_wordRelsDocumentRelsC;
}
/**
* Setter
*
* @access public
*/
public function setXmlWordSettings($xmlWordSettings)
{
$this->_wordSettingsC = $xmlWordSettings;
}
/**
* Getter
*
* @access public
*/
public function getXmlWordSettings()
{
return $this->_wordSettingsC;
}
/**
* Setter
*
* @access public
*/
public function setXmlWordStyles($xmlWordStyles)
{
$this->_wordStylesC = $xmlWordStyles;
}
/**
* Getter
*
* @access public
*/
public function getXmlWordStyles()
{
return $this->_wordStylesC;
}
/**
* Setter
*
* @access public
*/
public function setXmlWordThemeTheme1($xmlWordThemeTheme)
{
$this->_wordThemeThemeC = $xmlWordThemeTheme;
}
/**
* Getter
*
* @access public
*/
public function getXmlWordThemeTheme1()
{
return $this->_wordThemeThemeC;
}
/**
* Setter
*
* @access public
*/
public function setXmlWordWebSettings($xmlWordWebSettings)
{
$this->_wordWebSettingsC = $xmlWordWebSettings;
}
/**
* Setter
*
* @access public
*/
public function getXml_Word_WebSettings()
{
return $this->_wordWebSettingsC;
}
/**
* Add a break
*
* @access public
* @example ../examples/easy/PageBreak.php
* @param string $options
* Values:
* 'type' (line, page, column)
*/
public function addBreak($options = array('type' => 'line'))
{
$break = CreatePage::getInstance();
$break->generatePageBreak($options['type']);
PhpdocxLogger::logger('Add break to word document.', 'info');
$this->_wordDocumentC .= (string) $break;
}
/**
* Add a chart
*
* @access public
* @example ../examples/easy/Chart.php
* @example ../examples/easy/Chart_bar.php
* @param array $options
* Values: 'color' (1, 2, 3...) color scheme,
* 'perspective' (20, 30...),
* 'rotX' (20, 30...),
* 'rotY' (20, 30...),
* 'data' (array of values),
* 'float' (left, right, center) floating image. It only applies if textWrap is not inline (default value).
* 'font' (Arial, Times New Roman...),
* 'groupBar' (clustered, stacked, percentStacked),
* 'horizontalOffset' (int) given in emus (1cm = 360000 emus)
* 'jc' (center, left, right),
* 'showPercent' (0, 1),
* 'sizeX' (10, 11, 12...),
* 'sizeY' (10, 11, 12...),
* 'textWrap' (0 (inline), 1 (square), 2 (front), 3 (back), 4 (up and bottom)),
* 'verticalOffset' (int) given in emus (1cm = 360000 emus)
* 'title',
* 'type' (barChart, pieChart)
* 'legendPos' (r, l, t, b, none),
* 'legendOverlay' (0, 1),
* 'border' (0, 1),
* 'haxLabel' horizontal axis label,
* 'vaxLabel' vertical axis label,
* 'showtable' (0, 1) shows the table of values,
* 'vaxLabelDisplay' (rotated, vertical, horizontal),
* 'haxLabelDisplay' (rotated, vertical, horizontal),
* 'hgrid' (0, 1, 2, 3),
* 'vgrid' (0, 1, 2, 3),
* 'style' this work only in radar charts.
* 'gapWidth' distance between the pie and the second chart(ofpiechart)
* 'secondPieSize' : size of the second chart(ofpiechart)
* 'splitType' how decide to split the values :auto(Default Split), cust(Custom Split), percent(Split by Percentage), pos(Split by Position), val(Split by Value)
* 'splitPos' split position , integer or float
* 'custSplit' array of index to split
* 'subtype' type of the second chart pie or bar
* 'explosion' distance between the diferents values
* 'holeSize' size of the hole in doughnut type
* 'symbol' array of symbols(scatter chart)
* 'symbolSize' the size of the simbols
* 'smooth' smooth the line (scatter chart)
* 'wireframe' boolean(surface chart)to remove content color and only leave the border colors
* 'showValue' (0,1) shows the values inside the chart
* 'showCategory' (0,1) shows the category inside the chart
*/
public function addChart($options = array())
{
PhpdocxLogger::logger('Create chart.', 'debug');
try {
if (isset($options['data']) && isset($options['type'])) {
self::$intIdWord++;
PhpdocxLogger::logger('New ID ' . self::$intIdWord . ' . Chart.', 'debug');
$type = $options['type'];
if(strpos($type, 'Chart') === false)
$type .= 'Chart';
$graphic = CreateChartFactory::createObject($type);
if ($graphic->createGraphic(self::$intIdWord, $options) != false) {
PhpdocxLogger::logger('Add chart word/charts/chart' . self::$intIdWord .
'.xml to DOCX.', 'info');
$this->_zipDocx->addFromString(
'word/charts/chart' . self::$intIdWord . '.xml',
$graphic->getXmlChart()
);
$this->_wordRelsDocumentRelsC .=
$this->generateRELATIONSHIP(
'rId' . self::$intIdWord, 'chart',
'charts/chart' . self::$intIdWord . '.xml'
);
$this->generateDEFAULT('xlsx', 'application/octet-stream');
$this->generateOVERRIDE(
'/word/charts/chart' . self::$intIdWord . '.xml',
'application/vnd.openxmlformats-officedocument.' .
'drawingml.chart+xml'
);
} else {
throw new Exception(
'There was an error related to the chart.'
);
}
$excel = $graphic->getXlsxType();
$this->_tempFileXLSX[self::$intIdWord] =
tempnam($this->_tempDir, 'documentxlsx');
if (
$excel->createXlsx(
$this->_tempFileXLSX[self::$intIdWord],
$options['data']
) != false
) {
$this->_zipDocx->addFile(
$this->_tempFileXLSX[self::$intIdWord],
'word/embeddings/datos' . self::$intIdWord . '.xlsx'
);
$chartRels = CreateChartRels::getInstance();
$chartRels->createRelationship(self::$intIdWord);
$this->_zipDocx->addFromString(
'word/charts/_rels/chart' . self::$intIdWord .
'.xml.rels',
(string) $chartRels
);
}
$this->_wordDocumentC .= (string) $graphic;
} else {
throw new Exception(
'Images must have "data" and "type" values.'
);
}
}
catch (Exception $e) {
PhpdocxLogger::logger($e->getMessage(), 'fatal');
}
}
/**
* Add an image
*
* @access public
* @example ../examples/easy/Image.php
* @param array $data
* Values:
* 'border'(int) 1, 2, 3...
* 'borderDiscontinuous' (0, 1)
* 'float' (left, right, center) floating image. It only applies if textWrap is not inline (default value).
* 'font' (string) Arial, Times New Roman...
* 'horizontalOffset' (int) given in emus (1cm = 360000 emus). Only applies if there is the image is not floating
* 'jc' (center, left, right, inside, outside)
* 'name' (string) path to a local image
* 'scaling' (int) 50, 100, ..
* 'sizeX' (int) 10, 11, 12...
* 'sizeY' (int) 10, 11, 12...
* 'dpi' (int) dots per inch
* 'spacingTop' (int) 10, 11...
* 'spacingBottom' (int) 10, 11...
* 'spacingLeft' (int) 10, 11...
* 'spacingRight' (int) 10, 11...
* 'textWrap' 0 (inline), 1 (square), 2 (front), 3 (back), 4 (up and bottom))
* 'target' (string): document (default value), defaultHeader, firstHeader, evenHeader, defaultFooter, firstFooter, evenFooter
* 'verticalOffset' (int) given in emus (1cm = 360000 emus)
*/
public function addImage($data = '')
{
if(!isset($data['target'])){
$data['target'] = 'document';
}
PhpdocxLogger::logger('Create image.', 'debug');
try {
if (isset($data['name']) && file_exists($data['name']) == 'true') {
$attrImage = getimagesize($data['name']);
try {
if ($attrImage['mime'] == 'image/jpg' ||
$attrImage['mime'] == 'image/jpeg' ||
$attrImage['mime'] == 'image/png' ||
$attrImage['mime'] == 'image/gif'
) {
self::$intIdWord++;
PhpdocxLogger::logger('New ID rId' . self::$intIdWord . ' . Image.', 'debug');
$image = CreateImage::getInstance();
$data['rId'] = self::$intIdWord;
$image->createImage($data);
$dir = $this->parsePath($data['name']);
PhpdocxLogger::logger('Add image word/media/imgrId' .
self::$intIdWord . '.' . $dir['extension'] .
'.xml to DOCX.', 'info');
$this->_zipDocx->addFile(
$data['name'], 'word/media/imgrId' .
self::$intIdWord . '.' .
$dir['extension']
);
$this->generateDEFAULT(
$dir['extension'], $attrImage['mime']
);
if ((string) $image != ''){
//Here we consider the case where the image will be included in a header or footer
if($data['target'] == 'defaultHeader' ||
$data['target'] == 'firstHeader' ||
$data['target'] == 'evenHeader' ||
$data['target'] == 'defaultFooter' ||
$data['target'] == 'firstFooter' ||
$data['target'] == 'evenFooter'){
$this->_relsHeaderFooterImage[$data['target']][] =
array('rId' => 'rId' . self::$intIdWord, 'extension' => $dir['extension']);
}else{
$this->_wordRelsDocumentRelsC .=
$this->generateRELATIONSHIP(
'rId' . self::$intIdWord, 'image',
'media/imgrId' . self::$intIdWord . '.'
. $dir['extension']
);
}
}
$this->_wordDocumentC .= (string) $image;
} else {
throw new Exception('Image format is not supported.');
}
}
catch (Exception $e) {
PhpdocxLogger::logger($e->getMessage(), 'fatal');
}
} else {
throw new Exception('Image does not exist.');
}
}
catch (Exception $e) {
PhpdocxLogger::logger($e->getMessage(), 'fatal');
}
}
/**
* Add a link
*
* @access public
* @example ../examples/easy/Link.php
* @param array $options
* @see addText
* additional parameter:
* 'url' (string) URL or #bookmarkName
*
*/
public function addLink($text, $options = array('url' => '',
'font' => '',
'sz' => '',
'color' => '0000ff',
'u' => 'single',
))
{
if(substr($options['url'], 0, 1) == '#'){
$url = 'HYPERLINK \l "' . substr($options['url'], 1) . '"';
}else{
$url = 'HYPERLINK "' . $options['url'] . '"';
}
if ($text == '') {
PhpdocxLogger::logger('The linked text is missing', 'fatal');
} else if($options['url'] == '') {
PhpdocxLogger::logger('The URL is missing', 'fatal');
}
if (isset($options['color'])) {
$color = $options['color'];
} else {
$color = '0000ff';
}
if (isset($options['u'])) {
$u = $options['u'];
} else {
$u = 'single';
}
$textOptions = $options;
$textLink = CreateText::getInstance();
$textLink->createText($text, $textOptions);
$link = (string) $textLink;
$link = preg_replace('/__[A-Z]+__/', '', $link);
$startNodes ='<w:r><w:fldChar w:fldCharType="begin" /></w:r><w:r>
<w:instrText xml:space="preserve">'.$url.'</w:instrText>
</w:r><w:r><w:fldChar w:fldCharType="separate" /></w:r>';
if(strstr($link, '</w:pPr>')){
$link = preg_replace('/<\/w:pPr>/', '</w:pPr>'.$startNodes, $link);
}else{
$link = preg_replace('/<w:p>/', '<w:p>'.$startNodes, $link);
}
$endNode = '<w:r><w:fldChar w:fldCharType="end" /></w:r>';
$link = preg_replace('/<\/w:p>/', $endNode . '</w:p>', $link);
PhpdocxLogger::logger('Add link to word document.', 'info');
$this->_wordDocumentC .= (string) $link;
}
/**
* Add a list
*
* @access public
* @example ../examples/easy/List.php
* @param array $data Values of the list
* @param array $options
* Values:
* 'font' (string), Arial, Times New Roman, ...
* 'val' (int), 0 (clear), 1 (inordinate), 2(numerical)
* 'bullets' (array) 1 (), 2 (o), 3 ()
*/
public function addList($data, $options = array())
{
$list = CreateList::getInstance();
if ($options['val'] == 2){
self::$numOL++;
$this->_wordNumberingT = $this->importSingleNumbering($this->_wordNumberingT, self::$orderedListStyle, self::$numOL);
}
$list->createList($data, $options);
PhpdocxLogger::logger('Add list to word document.', 'info');
$this->_wordDocumentC .= (string) $list;
if (!empty($options['bullets'])
&& is_array($options['bullets'])
&& $options['val'] == 1
) {
for ($i = 0; $i <= CreateList::MAXDEPTH; $i++) {
$bullets = $options['bullets'];
if (isset($bullets[$i])) {
$styleId = $bullets[$i];
} else {
$styleId = $i;
}
$list->createListStyles($i, $styleId);
PhpdocxLogger::logger('Add list styles to word document.', 'info');
$this->_wordDocumentStyles .= (string) $list;
}
}
}
/**
* Add a raw WordML
*
* @access public
* @param string $wml WordML to add
* @deprecated See addWordML
*/
public function addRawWordML($wml)
{
PhpdocxLogger::logger('Add raw WordML.', 'info');
$this->_wordDocumentC .= $wml;
}
/**
* Add a table.
*
* @access public
* @example ../examples/easy/Table.php
* @param array $tableData an array of arrays with the table data organized by rows
* Each cell content may be a string or array.
* If the cell contents are in the form of an array its keys and posible values are:
* 'value' (string)
* 'rowspan' (int)
* 'colspan' (int)
* 'width' (int) in twentieths of a point
* 'border' (none, single, double, dashed, threeDEngrave, threeDEmboss, outset, inset)
* 'border_color' (ffffff, ff0000)
* 'border_spacing' (0, 1, 2...)
* 'border_sz' (10, 11...) in eights of a point
* 'border_<side>' (none, single, double, dashed, threeDEngrave, threeDEmboss, outset, inset) where the side may be: top, left, right or bottom
* 'border_<side>_color' (ffffff, ff0000)
* 'border_<side>_spacing' (0, 1, 2...)
* 'border_<side>_sz' (10, 11...)
* 'background_color' (ffffff, ff0000)
* 'noWrap' (boolean)
* 'cellMargin' (mixed) an integer value or an array:
* 'top' (int) in twentieths of a point
* 'right' (int) in twentieths of a point
* 'bottom' (int) in twentieths of a point
* 'left' (int) in twentieths of a point
* 'textDirection' (string) available values are: tbRl and btLr
* 'fitText' (boolean) if true fits the text to the size of the cell
* 'vAlign' (string) vertical align of text: top, center, both or bottom
*
* @param array $tableProperties Parameters to use
* Values:
* 'border' (none, single, double, dashed, threeDEngrave, threeDEmboss, outset, inset)
* 'border_color' (ffffff, ff0000)
* 'border_spacing' (0, 1, 2...)
* 'border_sz' (10, 11...) in eights of a point
* 'border_settings' (all, outside, inside) if all (default value) the border styles apply to all table borders.
* If the value is set to outside or inside the border styles will only apply to the outside or inside boreders respectively.
* 'cantSplitRows' (boolean) set global row split properties (can be overriden by rowProperties)
* 'cellMargin' (array) the keys are top, right, bottom and left and the values is given in twips (twentieths of a point)
* 'cellSpacing' (int) given in twips (twentieths of a point)
* 'float' (array) with the following keys and values:
* 'textMargin_top' (int) in twentieths of a point
* 'textMargin_right' (int) in twentieths of a point
* 'textMargin_bottom' (int) in twentieths of a point
* 'textMargin_left' (int) in twentieths of a point
* 'align' (string) posible values are: left, center, right, outside, inside
* 'font' (Arial, Times New Roman...)
* 'indent' (int) given in twips (twentieths of a point)
* 'jc' (center, left, right)
* 'decimalTab'
* 'size_col': column width fix (int)
* column width variable (array)
* 'tableWidth' (array) its posible keys and values are:
* 'type' (pct, dxa) pct if the value refers to percentage and dxa if the value is given in twentieths of a point (twips)
* 'value' (int)
* 'TBLSTYLEval' (string) Word table style
*
* @param array $rowProperties (array) a cero based array. Each entry is an array with keys and values:
* 'cantSplit' (boolean)
* 'minHeight' (int) in twentieths of a point
* 'height' (int) in twentieths of a point
* 'tblHeader' (boolean) if true this row repeats at the beguinning of each new page
*/
public function addTable($tableData, $tableProperties= array(), $rowProperties = array())
{
$table = CreateTable::getInstance();
$table->createTable($tableData, $tableProperties, $rowProperties);
PhpdocxLogger::logger('Add table to Word document.', 'info');
$this->_wordDocumentC .= (string) $table;
}
/**
* Add a text
*
* @access public
* @example ../examples/easy/Text.php
* @example ../examples/easy/Text_cursive.php
* @param mixed $textParams if a string just the text to be included, if an
* array is or an array of arrays with each element containing
* the text to be inserted and their formatting properties
* Array values:
* 'text' (string) the run of text to be inserted
* 'b' (on, off)
* 'caps' (on, off) display text in capital letters
* 'color' (ffffff, ff0000...)
* 'columnBreak' (before, after, both) inserts a column break before, after or both, a run of text
* 'font' (Arial, Times New Roman...)
* 'i' (on, off)
* 'lineBreak' (before, after, both) inserts a line break before, after or both, a run of text
* 'sz' (1, 2, 3...)
* 'tab' (boolean) inserts a tab. Default value is false
* 'spaces': number of spaces at the beguinning of the run of text
* 'u' (none, dash, dotted, double, single, wave, words)
* @param array $paragraphParams Style options to apply to the whole paragraph
* Values:
* 'pStyle' (string) Word style to be used. Run parseStyles() to check all available paragraph styles
* 'b' (on, off)
* 'caps' (on, off) display text in capital letters
* 'color' (ffffff, ff0000...)
* 'contextualSpacing' (on, off) ignore spacing above and below when using identical styles
* 'font' (Arial, Times New Roman...)
* 'i' (on, off)
* 'indent_left' 100...,
* 'indent_right' 100...
* 'jc' (both, center, distribute, left, right)
* 'keepLines' (on, off) keep all paragraph lines on the same page
* 'keepNext' (on, off) keep in the same page the current paragraph with next paragraph
* 'lineSpacing' 120, 240 (standard), 360, 480, ...
* 'pageBreakBefore' (on, off)
* 'spacingBottom' (int) bottom margin in twentieths of a point
* 'spacingTop' (int) top margin in twentieths of a point
* 'sz' (8, 9, 10, ...) size in points
* 'tabPositions' (array) each entry is an associative array with the following keys and values
* 'type' (string) can be clear, left (default), center, right, decimal, bar and num
* 'leader' (string) can be none (default), dot, hyphen, underscore, heavy and middleDot
* 'position' (int) given in twentieths of a point
* if there is a tab and the tabPositions array is not defined the standard tab position (default of 708) will be used
* 'textDirection' (lrTb, tbRl, btLr, lrTbV, tbRlV, tbLrV) text flow direction
* 'u' (none, dash, dotted, double, single, wave, words)
* 'widowControl' (on, off)
*/
public function addText($textParams, $paragraphParams = array())
{
$text = CreateText::getInstance();
$text->createText($textParams, $paragraphParams);
PhpdocxLogger::logger('Add text to word document.', 'info');
$this->_wordDocumentC .= (string) $text;
}
/**
* Generate a new DOCX file
*
* @access public
* @example ../examples/easy/Text.php
* @param string $args[0] File name
* @param string $args[1] Page style
* Values: 'bottom' (4000, 4001...), 'columns' (1, 2, 3), 'left' (4000, 4001...),
* 'orient' (landscape), 'right' (4000, 4001), 'titlePage' (1),
* 'top' (4000, 4001)
*/
public function createDocx()
{
$args = func_get_args();
if (!empty($args[0])) {
$fileName = $args[0];
} else {
$fileName = 'document';
}
PhpdocxLogger::logger('Set DOCX name to: ' . $fileName . '.', 'info');
PhpdocxLogger::logger('DOCX is a new file, not a template.', 'debug');
//We copy the rels content into the respective file
$relsHandler = fopen($this->_baseTemplateFilesPath.'/word/_rels/document.xml.rels', "w+");
fwrite($relsHandler, $this->_wordRelsDocumentRelsT->saveXML());
fclose($relsHandler);
//We also copy the contents of the [Content_types].xml file
$contentTypesHandler = fopen($this->_baseTemplateFilesPath.'/[Content_Types].xml', "w+");
fwrite($contentTypesHandler, $this->_contentTypeT->saveXML());
fclose($contentTypesHandler);
$arrArgsPage = array();
$this->generateTemplateWordDocument($arrArgsPage);
if ($this->_debug->getActive() == 1) {
PhpdocxLogger::logger('Debug is active, add messages to objDebug.', 'debug');
libxml_use_internal_errors(true);
simplexml_load_string(
$this->_wordDocumentT, 'SimpleXMLElement', LIBXML_NOWARNING
);
$xmlErrors = libxml_get_errors();
if (is_array($xmlErrors)) {
$this->_debug->addMessage($xmlErrors);
libxml_clear_errors();
}
}
PhpdocxLogger::logger('Add word/document.xml content to DOCX file.', 'info');
$documentHandler = fopen($this->_baseTemplateFilesPath.'/word/document.xml', "w+");
if (self::$_encodeUTF) {
$contentDocumentXML = utf8_encode($this->_wordDocumentT);
//TODO: sot out encoding problems
fwrite($documentHandler, utf8_encode($this->_wordDocumentT));
} else {
if ($this->_phpdocxconfig['settings']['encode_to_UTF8'] == 'true' && !PhpdocxUtilities::isUtf8($this->_wordDocumentT)) {
$contentDocumentXML = utf8_encode($this->_wordDocumentT);
} else {
$contentDocumentXML = $this->_wordDocumentT;
}
fwrite($documentHandler, $this->_wordDocumentT);
}
fclose($documentHandler);
if($this->_wordFootnotesC != ''){
PhpdocxLogger::logger('Add word/footnote.xml content to DOCX file.', 'info');
$footnoteHandler = fopen($this->_baseTemplateFilesPath.'/word/footnote.xml', "w+");
if (self::$_encodeUTF) {
//TODO: sot out encoding problems
fwrite($footnoteHandler, utf8_encode($this->_wordFootnotesT));
} else {
if ($this->_phpdocxconfig['settings']['encode_to_UTF8'] == 'true') {
if (!PhpdocxUtilities::isUtf8($this->_wordFootnotesT)) {
$this->_wordFootnotesT = utf8_encode($this->_wordFootnotesT);
}
}
fwrite($footnoteHandler, $this->_wordFootnotesT);
}
fclose($documentHandler);
}
$numberingHandler = fopen($this->_baseTemplateFilesPath.'/word/numbering.xml', "w+");
fwrite($numberingHandler, $this->_wordNumberingT);
fclose($numberingHandler);
PhpdocxLogger::logger('Close ZIP file', 'info');
$this->recursiveInsert($this->_zipDocx, $this->_baseTemplateFilesPath, $this->_baseTemplateFilesPath);
//Lets now insert the photos inserted by the embedHTML method
if (is_dir($this->_baseTemplateFilesPath.'/word/mediaTemplate')){
$contentsDir = scandir($this->_baseTemplateFilesPath.'/word/mediaTemplate');
$predefinedExtensions = explode(',', PHPDOCX_ALLOWED_IMAGE_EXT);
foreach($contentsDir as $element){
$arrayExtension = explode('.', $element);
$extension = strtolower(array_pop($arrayExtension));
if (in_array($extension, $predefinedExtensions)){
$this->_zipDocx->addFile($this->_baseTemplateFilesPath.'/word/mediaTemplate/'.$element, 'word/media/'.$element);
}
//Now we remove the image from the mediaTemplate folder
$this->_zipDocx->deleteName('word/mediaTemplate/'.$element);
}
//And now we delete the mediaTemplate folder
$deleteMediaTemplate = $this->_zipDocx->deleteName('word/mediaTemplate/');
}
//Check if there are openbookmars and if so throw an error
if (count($this->_bookmarksIds) > 0) {
PhpdocxLogger::logger('There are unclosed bookmarks. Please, check that all open bookmarks tags are properly closed.', 'fatal');
}
$this->_zipDocx->close();
$arrpathFile = pathinfo($fileName);
PhpdocxLogger::logger('Copy DOCX file using a new name.', 'info');
copy(
$this->_tempFile,
$fileName . '.' . $this->_extension
);
if ($this->_debug->getActive() == 1) {
PhpdocxLogger::logger('Debug is active, show messages.', 'debug');
echo $this->_debug;
}
// delete temp file
if (is_file($this->_tempFile) && is_writable($this->_tempFile)) {
unlink($this->_tempFile);
}
}
/**
*
* Transform a word document to a text file
*
* @example ../examples/easy/Docx2Text.php
* @param string $path. Path to the docx from which we wish to import the content
* @param string $path. Path to the text file output
* @param array styles.
* keys: table => true/false,list => true/false, paragraph => true/false, footnote => true/false, endnote => true/false, chart => (0=false,1=array,2=table)
*/
public static function docx2txt($from, $to, $options = array()) {
$text = new Docx2Text($options);
$text->setDocx($from);
$text->extract($to);
}
/**
* Imports an existing style sheet from an existing docx document.
*
* @access private
* @param string $path. Must be a valid path to an existing .docx, .dotx o .docm document
* @param string $type. You may choose 'replace' (overwrites the current styles) or 'merge' (adds the selected styles)
* @param array $myStyles. A list of specific styles to be merged. If it is empty or the choosen type is 'replace' it will be ignored.
*/
private function importStyles($path, $type= 'replace', $myStyles= array(), $styleIdentifier = 'styleName')
{
$zipStyles = new ZipArchive();
try {
$openStyle = $zipStyles->open($path);
if ($openStyle !== true) {
throw new Exception('Error while opening the Style Template: please, check the path');
}
}
catch (Exception $e) {
PhpdocxLogger::logger($e->getMessage(), 'fatal');
}
if ($type == 'replace') {
//Now we overwrite the original styles file
try {
$extractingStyleFile = $zipStyles->extractTo($this->_baseTemplateFilesPath.'/','word/styles.xml');
if (!$extractingStyleFile) {
throw new Exception('Error while trying to overwrite the styles.xml of the base template');
}
}
catch (Exception $e) {
PhpdocxLogger::logger($e->getMessage(), 'fatal');
}
//In order not to loose certain styles needed for certain PHPDOCX methods we should merge them
$this->importStyles(PHPDOCX_BASE_TEMPLATE, 'merge', $this->_defaultPHPDOCXStyles);
} else {
//We will first extract the new styles from the external docx
try {
$newStyles = $zipStyles->getFromName('word/styles.xml');
if ($newStyles == '') {
throw new Exception('Error while extracting the styles from the external docx');
}
}
catch (Exception $e) {
PhpdocxLogger::logger($e->getMessage(), 'fatal');
}
//let's parse the different styles via XPath
$newStylesDoc = new DOMDocument();
$newStylesDoc->loadXML($newStyles);
$stylesXpath = new DOMXPath($newStylesDoc);
$stylesXpath->registerNamespace('w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
$queryStyle = '//w:style';
$styleNodes = $stylesXpath->query($queryStyle);
//Let's get the original styles as a DOMdocument
try{
$styleHandler = fopen($this->_baseTemplateFilesPath.'/word/styles.xml', 'r');
$styleXML = fread($styleHandler, filesize($this->_baseTemplateFilesPath.'/word/styles.xml'));
fclose($styleHandler);
$this->_wordStylesT = $styleXML;
if ($styleXML == '') {
throw new Exception('Error while extracting the style file from the base template');
}
}
catch (Exception $e) {
PhpdocxLogger::logger($e->getMessage(), 'fatal');
}
$stylesDocument = new DomDocument();
$stylesDocument->loadXML($this->_wordStylesT);
$baseNode = $stylesDocument->documentElement;
$stylesDocumentXPath = new DOMXPath($stylesDocument);
$stylesDocumentXPath->registerNamespace('w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
$query = '//w:style';
$originalNodes = $stylesDocumentXPath->query($query);
//Now we start to insert the new styles at the end of the styles.xml
foreach($styleNodes as $node){
// in order to avoid duplicated Ids we first remove from the
// original styles.xml any duplicity with the new ones
// TODO: check performance
foreach($originalNodes as $oldNode){
if($styleIdentifier == 'styleID'){
if($oldNode->getAttribute('w:styleId') == $node->getAttribute('w:styleId')
&& in_array($oldNode->getAttribute('w:styleId'), $myStyles)){
$oldNode->parentNode->removeChild($oldNode);
}
}else{
$oldName = $oldNode->getElementsByTagName('w:name');
if($oldNode->getAttribute('w:styleId') == $node->getAttribute('w:styleId')
&& in_array($oldName, $myStyles)){
$oldNode->parentNode->removeChild($oldNode);
}
}
}
if(count($myStyles)>0){
//Lets insert the selected styles
if($styleIdentifier == 'styleID'){
if(in_array($node->getAttribute('w:styleId'), $myStyles)){
$insertNode = $stylesDocument->importNode($node, true);
$baseNode->appendChild($insertNode);
}
}else{
$nodeChilds = $node->childNodes;
foreach($nodeChilds as $child){
if ($child->nodeName == 'w:name'){
$styleName = $child->getAttribute('w:val');
if(in_array($styleName, $myStyles)){
$insertNode = $stylesDocument->importNode($node, true);
$baseNode->appendChild($insertNode);
}
}
}
}
}else{
$insertNode = $stylesDocument->importNode($node, true);
$baseNode->appendChild($insertNode);
}
}
$this->_wordStylesT = $stylesDocument->saveXML();
try {
$stylesFile=fopen($this->_baseTemplateFilesPath.'/word/styles.xml', 'w');
if ($stylesFile == false) {
throw new Exception('Error while opening the base template styles.xml file');
}
} catch (Exception $e) {
PhpdocxLogger::logger($e->getMessage(), 'fatal');
}
try {
$writeStyles = fwrite($stylesFile,$this->_wordStylesT);
if ($writeStyles == 0) {
throw new Exception('There were no new styles written');
}
} catch (Exception $e) {
PhpdocxLogger::logger($e->getMessage(), 'fatal');
}
}
PhpdocxLogger::logger('Importing styles from an external docx.', 'info');
}
/**
* Imports an existing theme from an existing docx document.
*
* @access private
* @param string $path. Must be a valid path to an existing .docx, .dotx o .docm document
*/
private function importThemeXML($path){
try {
$zipTheme = new ZipArchive();
$extractingThemeFile = $zipTheme->extractTo($this->_baseTemplateFilesPath.'/','word/theme/theme1.xml');
if (!$extractingThemeFile) {
throw new Exception('Error while trying to overwrite the theme1.xml of the base template');
}
}
catch (Exception $e) {
PhpdocxLogger::logger($e->getMessage(), 'fatal');
}
}
/**
* Imports an existing webSettings.xml file from an existing docx document.
*
* @access private
* @param string $path. Must be a valid path to an existing .docx, .dotx o .docm document
*/
private function importWebSettingsXML($path){
try {
$zipWebSettings = new ZipArchive();
$extractingWebSettingsFile = $zipTheme->extractTo($this->_baseTemplateFilesPath.'/','word/webSettings.xml');
if (!$extractingWebSettingsFile) {
throw new Exception('Error while trying to overwrite the webSettings.xml of the base template');
}
}
catch (Exception $e) {
PhpdocxLogger::logger($e->getMessage(), 'fatal');
}
}
/**
* Imports an existing settings.xml file from an existing docx document.
*
* @access private
* @param string $path. Must be a valid path to an existing .docx, .dotx o .docm document
*/
private function importSettingsXML($path){
try {
$zipSettings = new ZipArchive();
$extractingSettingsFile = $zipTheme->extractTo($this->_baseTemplateFilesPath.'/','word/settings.xml');
if (!$extractingSettingsFile) {
throw new Exception('Error while trying to overwrite the settings.xml of the base template');
}
}
catch (Exception $e) {
PhpdocxLogger::logger($e->getMessage(), 'fatal');
}
}
/**
* Imports an existing fontTable.xml file from an existing docx document.
*
* @access private
* @param string $path. Must be a valid path to an existing .docx, .dotx o .docm document
*/
private function importFontTableXML($path){
try {
$zipFontTable = new ZipArchive();
$extractingFontTableFile = $zipTheme->extractTo($this->_baseTemplateFilesPath.'/','word/fontTable.xml');
if (!$extractingFontTableFile) {
throw new Exception('Error while trying to overwrite the fontTable.xml of the base template');
}
}
catch (Exception $e) {
PhpdocxLogger::logger($e->getMessage(), 'fatal');
}
}
/**
* Transform to UTF-8 charset
*
* @access public
*/
public function setEncodeUTF8()
{
self::$_encodeUTF = 1;
}
/**
* Change default language.
* @example ../examples/easy/Language.php
* @param $lang Locale: en-US, es-ES...
* @access public
*/
public function setLanguage($lang = null)
{
if (!$lang) {
$lang = 'en-US';
}
//Let's get the original styles as a DOMdocument
try{
$styleHandler = fopen($this->_baseTemplateFilesPath.'/word/styles.xml', 'r');
$styleXML = fread($styleHandler, 10000000);
fclose($styleHandler);
$this->_wordStylesT = $styleXML;
if ($styleXML == '') {
throw new Exception('Error while extracting the style file from the base template to stablish default language');
}
}
catch (Exception $e) {
PhpdocxLogger::logger($e->getMessage(), 'fatal');
}
$stylesDocument = new DomDocument();
$stylesDocument->loadXML($this->_wordStylesT);
$langNode = $stylesDocument->getElementsByTagName('lang');
$langNode->item(0)->setAttribute('w:val', $lang);
$langNode->item(0)->setAttribute('w:eastAsia', $lang);
$this->_wordStylesT = $stylesDocument->saveXML();
try {
$stylesFile=fopen($this->_baseTemplateFilesPath.'/word/styles.xml', 'w');
if ($stylesFile == false) {
throw new Exception('Error while opening the base template styles.xml file');
}
}
catch (Exception $e) {
PhpdocxLogger::logger($e->getMessage(), 'fatal');
}
try {
$writeStyles = fwrite($stylesFile,$this->_wordStylesT );
if ($writeStyles == 0) {
throw new Exception('There was an error while trying to set the default language');
}
}
catch (Exception $e) {
PhpdocxLogger::logger($e->getMessage(), 'fatal');
}
PhpdocxLogger::logger('Set language.', 'info');
}
/**
* Add style
*
* @param string lang Language
* @access private
*/
private function addStyle($lang = 'en-US')
{
$style = CreateStyle::getInstance();
$style->createStyle($lang);
PhpdocxLogger::logger('Add styles to styles document.', 'info');
$this->_wordStylesC .= (string) $style;
}
/**
* Imports styles into the template stylesheet.
*
* @access private
* @param string $templateStyles
* @param DOMDocument $importedStylesheet
*/
private function addStylesTemplate($templateStyles, $importedStylesheet)
{
$templateStylesheet = new DomDocument();
$templateStylesheet->loadXML($templateStyles);
//let's parse the different styles via XPath
$stylesXpath = new DOMXPath($importedStylesheet);
$stylesXpath->registerNamespace('w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
$queryStyle = '//w:style';
$styleNodes = $stylesXpath->query($queryStyle);
//Let's get the original styles as a DOMNode
$stylesDocument = new DomDocument();
$stylesDocument->loadXML($templateStyles);
$baseNode = $stylesDocument->documentElement;
//Now we start to insert the new styles at the end of the styles.xml
foreach ($styleNodes as $node) {
// in order to avoid duplicated Ids we first remove from the
// original styles any duplicity with the new ones
$originalNodes = $stylesDocument->childNodes;
foreach($originalNodes as $oldNode) {
if ($oldNode->getAttribute('w:styleId') == $node->getAttribute('w:styleId')) {
$oldNode->parent->removeChild($oldNode);
}
}
$insertNode = $stylesDocument->importNode($node, true);
$baseNode->appendChild($insertNode);
}
PhpdocxLogger::logger('Importing styles into the template stylesheet.', 'info');
return $stylesDocument->saveXML();
}
/**
* Generate content type
*
* @access private
*/
private function generateContentType()
{
$this->generateDEFAULT(
'rels', 'application/vnd.openxmlformats-package.relationships+xml'
);
$this->generateDEFAULT('xml', 'application/xml');
$this->generateDEFAULT('htm', 'application/xhtml+xml');
$this->generateDEFAULT('rtf', 'application/rtf');
$this->generateDEFAULT('zip', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml');
$this->generateDEFAULT('mht', 'message/rfc822');
$this->generateDEFAULT('wml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml');
$this->generateOVERRIDE(
'/word/numbering.xml',
'application/vnd.openxmlformats-officedocument.wordprocessingml.' .
'numbering+xml'
);
$this->generateOVERRIDE(
'/word/styles.xml',
'application/vnd.openxmlformats-officedocument.wordprocessingml' .
'.styles+xml'
);
$this->generateOVERRIDE(
'/docProps/app.xml',
'application/vnd.openxmlformats-officedocument.extended-' .
'properties+xml'
);
$this->generateOVERRIDE(
'/docProps/custom.xml',
'application/vnd.openxmlformats-officedocument.' .
'custom-properties+xml'
);
$this->generateOVERRIDE(
'/word/settings.xml', 'application/' .
'vnd.openxmlformats-officedocument.wordprocessingml.settings+xml'
);
$this->generateOVERRIDE(
'/word/theme/theme1.xml',
'application/vnd.openxmlformats-officedocument.theme+xml'
);
$this->generateOVERRIDE(
'/word/fontTable.xml',
'application/vnd.openxmlformats-officedocument.wordprocessingml.' .
'fontTable+xml'
);
$this->generateOVERRIDE(
'/word/webSettings.xml',
'application/vnd.openxmlformats-officedocument.wordprocessingml' .
'.webSettings+xml'
);
if ($this->_wordFooterC != '' || $this->_wordHeaderC != '') {
$this->generateOVERRIDE(
'/word/header.xml',
'application/vnd.openxmlformats-officedocument.' .
'wordprocessingml.header+xml'
);
$this->generateOVERRIDE(
'/word/footer.xml',
'application/vnd.openxmlformats-officedocument.' .
'wordprocessingml.footer+xml'
);
$this->generateOVERRIDE(
'/word/footnotes.xml',
'application/vnd.openxmlformats-officedocument.' .
'wordprocessingml.footnotes+xml'
);
$this->generateOVERRIDE(
'/word/endnotes.xml',
'application/vnd.openxmlformats-officedocument.' .
'wordprocessingml.endnotes+xml'
);
}
$this->generateOVERRIDE(
'/docProps/core.xml',
'application/vnd.openxmlformats-package.core-properties+xml'
);
}
/**
* Generate DEFAULT
*
* @access private
*/
private function generateDEFAULT($extension, $contentType)
{
$strContent = $this->_contentTypeT->saveXML();
if (
strpos($strContent, 'Extension="' . $extension)
=== false
) {
$strContentTypes = '<Default Extension="'.$extension .'" ContentType="'. $contentType .'"> </Default>';
$tempNode = $this->_contentTypeT->createDocumentFragment();
$tempNode->appendXML($strContentTypes);
$this->_contentTypeT->documentElement->appendChild($tempNode);
}
}
/**
*
*
* @access private
*/
private function generateDefaultFonts()
{
$font = array(
'name' => 'Calibri', 'pitch' => 'variable', 'usb0' => 'A00002EF',
'usb1' => '4000207B', 'usb2' => '00000000', 'usb3' => '00000000',
'csb0' => '0000009F', 'csb1' => '00000000', 'family' => 'swiss',
'charset' => '00', 'panose1' => '020F0502020204030204'
);
$this->addFont($font);
$font = array(
'name' => 'Times New Roman', 'pitch' => 'variable',
'usb0' => 'E0002AEF', 'usb1' => 'C0007841', 'usb2' => '00000009',
'usb3' => '00000000', 'csb0' => '000001FF', 'csb1' => '00000000',
'family' => 'roman', 'charset' => '00',
'panose1' => '02020603050405020304'
);
$this->addFont($font);
$font = array(
'name' => 'Cambria', 'pitch' => 'variable', 'usb0' => 'A00002EF',
'usb1' => '4000004B', 'usb2' => '00000000', 'usb3' => '00000000',
'csb0' => '0000009F', 'csb1' => '00000000', 'family' => 'roman',
'charset' => '00', 'panose1' => '02040503050406030204'
);
$this->addFont($font);
}
/**
* Generate DefaultWordRels
*
* @access private
*/
private function generateDefaultWordRels()
{
self::$intIdWord++;
PhpdocxLogger::logger('New ID ' . self::$intIdWord . ' . numbering.xml.', 'debug');
$this->_wordRelsDocumentRelsC .= $this->generateRELATIONSHIP(
'rId' . self::$intIdWord, 'numbering', 'numbering.xml'
);
self::$intIdWord++;
PhpdocxLogger::logger('New ID ' . self::$intIdWord . ' . theme/theme1.xml.', 'debug');
$this->_wordRelsDocumentRelsC .= $this->generateRELATIONSHIP(
'rId' . self::$intIdWord, 'theme', 'theme/theme1.xml'
);
self::$intIdWord++;
PhpdocxLogger::logger('New ID ' . self::$intIdWord . ' . numbering.xml.', 'debug');
$this->_wordRelsDocumentRelsC .= $this->generateRELATIONSHIP(
'rId' . self::$intIdWord, 'webSettings', 'webSettings.xml'
);
self::$intIdWord++;
PhpdocxLogger::logger('New ID ' . self::$intIdWord . ' . webSettings.xml.', 'debug');
$this->_wordRelsDocumentRelsC .= $this->generateRELATIONSHIP(
'rId' . self::$intIdWord, 'fontTable', 'fontTable.xml'
);
self::$intIdWord++;
PhpdocxLogger::logger('New ID ' . self::$intIdWord . ' . fontTable.xml.', 'debug');
$this->_wordRelsDocumentRelsC .= $this->generateRELATIONSHIP(
'rId' . self::$intIdWord, 'settings', 'settings.xml'
);
self::$intIdWord++;
PhpdocxLogger::logger('New ID ' . self::$intIdWord . ' . settings.xml.', 'debug');
$this->_wordRelsDocumentRelsC .= $this->generateRELATIONSHIP(
'rId' . self::$intIdWord, 'styles', 'styles.xml'
);
}
/**
* Generate OVERRIDE
*
* @access private
* @param string $partName
* @param string $contentType
*/
private function generateOVERRIDE($partName, $contentType)
{
$strContent = $this->_contentTypeT->saveXML();
if (
strpos($strContent, 'PartName="' . $partName . '"')
=== false
) {
$strContentTypes = '<Override PartName="'.$partName.'" ContentType="'.$contentType.'" />';
$tempNode = $this->_contentTypeT->createDocumentFragment();
$tempNode->appendXML($strContentTypes);
$this->_contentTypeT->documentElement->appendChild($tempNode);
}
}
/**
* Generate RELATIONSHIP
*
* @access private
*/
private function generateRELATIONSHIP()
{
$arrArgs = func_get_args();
if ($arrArgs[1] == 'vbaProject') {
$type =
'http://schemas.microsoft.com/office/2006/relationships/vbaProject';
} else {
$type =
'http://schemas.openxmlformats.org/officeDocument/2006/' .
'relationships/' . $arrArgs[1];
}
if (!isset($arrArgs[3])) {
$nodeWML = '<Relationship Id="' . $arrArgs[0] . '" Type="' . $type .
'" Target="' . $arrArgs[2] . '"></Relationship>';
} else {
$nodeWML = '<Relationship Id="' . $arrArgs[0] . '" Type="' . $type .
'" Target="' . $arrArgs[2] . '" ' . $arrArgs[3] .
'></Relationship>';
}
$relsNode = $this->_wordRelsDocumentRelsT->createDocumentFragment();
$relsNode->appendXML($nodeWML);
$this->_wordRelsDocumentRelsT->documentElement->appendChild($relsNode);
}
/**
* Gnerate RELATIONSHIP
*
* @access private
*/
private function generateRELATIONSHIPTemplate()
{
$arrArgs = func_get_args();
if ($arrArgs[1] == 'vbaProject') {
$type =
'http://schemas.microsoft.com/office/2006/relationships/vbaProject';
} else {
$type =
'http://schemas.openxmlformats.org/officeDocument/2006/' .
'relationships/' . $arrArgs[1];
}
if (!isset($arrArgs[3])) {
$nodeWML = '<Relationship Id="' . $arrArgs[0] . '" Type="' . $type .
'" Target="' . $arrArgs[2] . '"></Relationship>';
} else {
$nodeWML = '<Relationship Id="' . $arrArgs[0] . '" Type="' . $type .
'" Target="' . $arrArgs[2] . '" ' . $arrArgs[3] .
'></Relationship>';
}
return $nodeWML;
}
/**
* Generate SECTPR
*
* @access private
* @param array $args Section style
*/
private function generateSECTPR($args = '')
{
$page = CreatePage::getInstance();
$page->createSECTPR($args);
$this->_wordDocumentC .= (string) $page;
}
/**
* Generates an element in settings.xml
*
* @access private
*/
private function generateSetting($tag)
{
if((!in_array($tag, self::$settings))){
self::$log->fatal('Incorrect setting tag');
}
$settingIndex = array_search($tag, self::$settings);
try{
$settings = fopen($this->_baseTemplateFilesPath.'/word/settings.xml', "r");
$baseTemplateSettingsT = fread($settings, 1000000);
fclose($settings);
if ($baseTemplateSettingsT == '') {
throw new Exception('Error while extracting settings.xml file from the base template to insert the selected element');
}
}
catch (Exception $e) {
PhpdocxLogger::logger($e->getMessage(), 'fatal');
}
$this->_wordSettingsT = new DOMDocument();
$this->_wordSettingsT->loadXML($baseTemplateSettingsT);
$selectedElements = $this->_wordSettingsT->documentElement->getElementsByTagName($tag);
if($selectedElements->length == 0){
$settingsElement = $this->_wordSettingsT->createDocumentFragment();
$settingsElement->appendXML('<' . $tag . ' xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" />');
$childNodes = $this->_wordSettingsT->documentElement->childNodes;
$index = false;
foreach($childNodes as $node){
$name = $node->nodeName;
$index = array_search($node->nodeName, self::$settings);
if($index > $settingIndex){
$node->parentNode->insertBefore($settingsElement, $node);
break;
}
}
//in case no node was found (pretty unlikely)we should append the node
if (!$index) {
$this->_wordSettingsT->documentElement->appendChild($settingsElement);
}
$newSettings = $this->_wordSettingsT->saveXML();
$settingsHandle = fopen($this->_baseTemplateFilesPath.'/word/settings.xml', "w+");
$contents = fwrite($settingsHandle, $newSettings);
fclose($settingsHandle);
}
}
/**
* Generate ContentType XML template
*
* @access private
*/
private function generateTemplateContentType()
{
$this->_wordContentTypeT =
'<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>' .
'<Types xmlns="http://schemas.openxmlformats.org/package/2006/' .
'content-types">' . $this->_contentTypeC . '</Types>';
}
/**
* Generate DocPropsApp XML template
*
* @access private
*/
private function generateTemplateDocPropsApp()
{
$this->_docPropsAppT =
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' .
'<Properties xmlns="http://schemas.openxmlformats.org/' .
'officeDocument/2006/extended-properties" xmlns:vt="' .
'http://schemas.openxmlformats.org/officeDocument/2006/' .
'docPropsVTypes"><Template>Normal.dotm</Template><TotalTime>' .
'0</TotalTime><Pages>1</Pages><Words>1</Words><Characters>1'
. '</Characters><Application>Microsoft Office Word</Application>' .
'<DocSecurity>4</DocSecurity><Lines>1</Lines><Paragraphs>1' .
'</Paragraphs><ScaleCrop>false</ScaleCrop>';
if ($this->_docPropsAppC) {
$this->_docPropsAppT .= $this->_docPropsAppC;
} else {
$this->_docPropsAppT .= '<Company>Company</Company>';
}
$this->_docPropsAppT .= '<LinksUpToDate>false</LinksUpToDate>' .
'<CharactersWithSpaces>1</CharactersWithSpaces><SharedDoc>' .
'false</SharedDoc><HyperlinksChanged>false</HyperlinksChanged>' .
'<AppVersion>12.0000</AppVersion></Properties>';
}
/**
* Generate DocPropsCore XML template
*
* @access private
*/
private function generateTemplateDocPropsCore()
{
date_default_timezone_set('UTC');
if ($this->_markAsFinal) {
$this->_docPropsCoreT =
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' .
'<cp:coreProperties xmlns:cp="http://schemas.openxmlformats' .
'.org/package/2006/metadata/core-properties" ' .
'xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms' .
'="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl' .
'.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XML' .
'Schema-instance"><dc:title>Title</dc:title><dc:subject>' .
'Subject</dc:subject><dc:creator>2mdc</dc:creator>' .
'<dc:description>Description</dc:description>' .
'<cp:lastModifiedBy>user</cp:lastModifiedBy><cp:revision>1' .
'</cp:revision><dcterms:created xsi:type="dcterms:W3CDTF">' .
date('c') . '</dcterms:created><dcterms:modified ' .
'xsi:type="dcterms:W3CDTF">' . date('c') .
'</dcterms:modified><cp:contentStatus>Final' .
'</cp:contentStatus></cp:coreProperties>';
} else {
$this->_docPropsCoreT =
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?> ' .
'<cp:coreProperties xmlns:cp="http://schemas.openxmlformats' .
'.org/package/2006/metadata/core-properties" ' .
'xmlns:dc="http://purl.org/dc/elements/1.1/" ' .
'xmlns:dcterms="http://purl.org/dc/terms/" ' .
'xmlns:dcmitype="http://purl.org/dc/dcmitype/" ' .
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' .
'<dc:title>Title</dc:title><dc:subject>Subject</dc:subject>' .
'<dc:creator>2mdc</dc:creator><dc:description>Description' .
'</dc:description><cp:lastModifiedBy>user' .
'</cp:lastModifiedBy><cp:revision>1</cp:revision>' .
'<dcterms:created xsi:type="dcterms:W3CDTF">' . date('c') .
'</dcterms:created><dcterms:modified xsi:type="dcterms:W3CDTF' .
'">' . date('c') . '</dcterms:modified></cp:coreProperties>';
}
}
/**
* Generate DocPropsCustom XML template
*
* @access private
*/
private function generateTemplateDocPropsCustom()
{
$this->_docPropsCustomT =
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' .
'<Properties xmlns="http://schemas.openxmlformats.org/' .
'officeDocument/2006/custom-properties" xmlns:vt="http://' .
'schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">' .
'<property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" ' .
'pid="2" name="_MarkAsFinal"><vt:bool>true</vt:bool></property>' .
'</Properties>';
}
/**
* Generate RelsRels XML template
*
* @access private
*/
private function generateTemplateRelsRels()
{
$this->_relsRelsT =
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' .
'<Relationships xmlns="http://schemas.openxmlformats.org/package/' .
'2006/relationships">' .
$this->generateRELATIONSHIP(
'rId3', 'extended-properties', 'docProps/app.xml'
) .
'<Relationship Id="rId2" Type="http://schemas.openxmlformats' .
'.org/package/2006/relationships/metadata/core-properties"' .
' Target="docProps/core.xml"/>' .
$this->generateRELATIONSHIP(
'rId1', 'officeDocument', 'word/document.xml'
);
if ($this->_markAsFinal) {
$this->_relsRelsT .=
'<Relationship Id="rId4" Type="http://schemas' .
'.openxmlformats.org/officeDocument/2006/relationships/' .
'custom-properties" Target="docProps/custom.xml"/>';
}
$this->_relsRelsT .= '</Relationships>';
}
/**
* Generate WordDocument XML template
*
* @access private
*/
private function generateTemplateWordDocument()
{
$arrArgs = func_get_args();
//$this->generateSECTPR($arrArgs[0]);
$this->_wordDocumentC .= $this->_sectPr->saveXML($this->_sectPr->documentElement);//FIXME: I am insertying by hand the sections of the base template
if (!empty($this->_wordHeaderC)) {
$this->_wordDocumentC = str_replace(
'__GENERATEHEADERREFERENCE__',
'<' . CreateDocx::NAMESPACEWORD . ':headerReference ' .
CreateDocx::NAMESPACEWORD . ':type="default" r:id="rId' .
$this->_idWords['header'] . '"></' .
CreateDocx::NAMESPACEWORD . ':headerReference>',
$this->_wordDocumentC
);
}
if (!empty($this->_wordFooterC)) {
$this->_wordDocumentC = str_replace(
'__GENERATEFOOTERREFERENCE__',
'<' . CreateDocx::NAMESPACEWORD . ':footerReference ' .
CreateDocx::NAMESPACEWORD . ':type="default" r:id="rId' .
$this->_idWords['footer'] . '"></' .
CreateDocx::NAMESPACEWORD . ':footerReference>',
$this->_wordDocumentC
);
}
$this->_wordDocumentT =
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' .
'<' . CreateDocx::NAMESPACEWORD . ':document xmlns:ve=' .
'"http://schemas.openxmlformats.org/markup-compatibility/2006" ' .
'xmlns:o="urn:schemas-microsoft-com:office:office"' .
' xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006' .
'/relationships" xmlns:m="http://schemas.openxmlformats.org/' .
'officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml"'.
' xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/' .
'wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:' .
'office:word" xmlns:w="http://schemas.openxmlformats.org/' .
'wordprocessingml/2006/main" xmlns:wne="http://schemas' .
'.microsoft.com/office/word/2006/wordml">' .
$this->_background.
'<' . CreateDocx::NAMESPACEWORD . ':body>' .
$this->_wordDocumentC .
'</' . CreateDocx::NAMESPACEWORD . ':body>' .
'</' . CreateDocx::NAMESPACEWORD . ':document>';
}
/**
* Generate WordEndnotes XML template
*
* @access private
*/
private function generateTemplateWordEndnotes()
{
$this->_wordEndnotesT =
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' .
'<' . CreateDocx::NAMESPACEWORD . ':endnotes xmlns:ve' .
'="http://schemas.openxmlformats.org/markup-compatibility/2006" ' .
'xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="' .
'http://schemas.openxmlformats.org/officeDocument/2006/' .
'relationships" xmlns:m="http://schemas.openxmlformats.org/' .
'officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:' .
'vml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006' .
'/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:' .
'office:word" xmlns:w="http://schemas.openxmlformats.org/' .
'wordprocessingml/2006/main" xmlns:wne="http://schemas' .
'.microsoft.com/office/word/2006/wordml">' .
$this->_wordEndnotesC .
'</' . CreateDocx::NAMESPACEWORD . ':endnotes>';
self::$intIdWord++;
PhpdocxLogger::logger('New ID ' . self::$intIdWord . ' . Endnotes.', 'debug');
$this->_wordRelsDocumentRelsC .= $this->generateRELATIONSHIP(
'rId' . self::$intIdWord, 'endnotes', 'endnotes.xml'
);
$this->generateOVERRIDE(
'/word/endnotes.xml',
'application/vnd.openxmlformats-officedocument.wordprocessingml' .
'.endnotes+xml'
);
}
/**
* Generate WordFontTable XML template
*
* @access private
*/
private function generateTemplateWordFontTable()
{
$this->_wordFontTableT =
'<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>' .
'<' . CreateDocx::NAMESPACEWORD . ':fonts xmlns:r="http://' .
'schemas.openxmlformats.org/officeDocument/2006/' .
'relationships" xmlns:w="http://schemas.openxmlformats.org/' .
'wordprocessingml/2006/main">' . $this->_wordFontTableC .
'</' . CreateDocx::NAMESPACEWORD . ':fonts>';
}
/**
* Generate WordFooter XML template
*
* @access private
*/
private function generateTemplateWordFooter()
{
self::$intIdWord++;
PhpdocxLogger::logger('New ID ' . self::$intIdWord . ' . Footer.', 'debug');
$this->_idWords['footer'] = self::$intIdWord;
$this->_wordFooterT =
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<' . CreateDocx::NAMESPACEWORD . ':ftr xmlns:ve' .
'="http://schemas.openxmlformats.org/markup-compatibility/' .
'2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns' .
':r="http://schemas.openxmlformats.org/officeDocument/2006/' .
'relationships" xmlns:m="http://schemas.openxmlformats.org/' .
'officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml' .
'" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/' .
'wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:' .
'office:word" xmlns:w="http://schemas.openxmlformats.org/' .
'wordprocessingml/2006/main" xmlns:wne="http://schemas' .
'.microsoft.com/office/word/2006/wordml">' . $this->_wordFooterC .
'</' . CreateDocx::NAMESPACEWORD . ':ftr>';
$this->_wordRelsDocumentRelsC .= $this->generateRELATIONSHIP(
'rId' . self::$intIdWord, 'footer', 'footer.xml'
);
return 'rId' . self::$intIdWord;
}
/**
* Generate WordFootnotes XML template
*
* @access private
*/
private function generateTemplateWordFootnotes()
{
$this->_wordFootnotesT =
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' .
'<' . CreateDocx::NAMESPACEWORD . ':footnotes xmlns:ve="' .
'http://schemas.openxmlformats.org/markup-compatibility/2006" ' .
'xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="' .
'http://schemas.openxmlformats.org/officeDocument/2006/' .
'relationships" xmlns:m="http://schemas.openxmlformats.org/' .
'officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:' .
'vml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006' .
'/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:' .
'office:word" xmlns:w="http://schemas.openxmlformats.org/' .
'wordprocessingml/2006/main" xmlns:wne="http://schemas.microsoft' .
'.com/office/word/2006/wordml">' . $this->_wordFootnotesC .
'</' . CreateDocx::NAMESPACEWORD . ':footnotes>';
self::$intIdWord++;
PhpdocxLogger::logger('New ID ' . self::$intIdWord . ' . Footnotes.', 'debug');
$this->_wordRelsDocumentRelsC .= $this->generateRELATIONSHIP(
'rId' . self::$intIdWord, 'footnotes', 'footnotes.xml'
);
$this->generateOVERRIDE(
'/word/footnotes.xml',
'application/vnd.openxmlformats-officedocument.wordprocessingml' .
'.footnotes+xml'
);
}
/**
* Generate WordHeader XML template
*
* @access private
*/
private function generateTemplateWordHeader()
{
self::$intIdWord++;
PhpdocxLogger::logger('New ID ' . self::$intIdWord . ' . Header.', 'debug');
$this->_idWords['header'] = self::$intIdWord;
$this->_wordHeaderT = '<?xml version="1.0" encoding="UTF-8" ' .
'standalone="yes"?>' .
'<' . CreateDocx::NAMESPACEWORD .
':hdr xmlns:ve="http://schemas.openxmlformats.org/markup' .
'-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:' .
'office:office" xmlns:r="http://schemas.openxmlformats.org/' .
'officeDocument/2006/relationships" xmlns:m="http://schemas' .
'.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:' .
'schemas-microsoft-com:vml" xmlns:wp="http://schemas' .
'.openxmlformats.org/drawingml/2006/wordprocessingDrawing" ' .
'xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="' .
'http://schemas.openxmlformats.org/wordprocessingml/2006/' .
'main" xmlns:wne="http://schemas.microsoft.com/office/word/' .
'2006/wordml"> ' . $this->_wordHeaderC .
'</' . CreateDocx::NAMESPACEWORD . ':hdr>';
$this->_wordRelsDocumentRelsC .= $this->generateRELATIONSHIP(
'rId' . self::$intIdWord, 'header', 'header.xml'
);
return 'rId' . self::$intIdWord;
}
/**
* Generate WordNumbering XML template
*
* @access private
*/
private function generateTemplateWordNumbering()
{
$this->_wordNumberingT =
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' .
'<w:numbering xmlns:ve="http://schemas.openxmlformats' .
'.org/markup-compatibility/2006" xmlns:o="urn:schemas-' .
'microsoft-com:office:office" xmlns:r="http://schemas' .
'.openxmlformats.org/officeDocument/2006/relationships" ' .
'xmlns:m="http://schemas.openxmlformats.org/officeDocument/' .
'2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:' .
'wp="http://schemas.openxmlformats.org/drawingml/2006/' .
'wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com' .
':office:word" xmlns:w="http://schemas.openxmlformats.org/' .
'wordprocessingml/2006/main" xmlns:wne="http://schemas.' .
'microsoft.com/office/word/2006/wordml"><w:abstractNum w:'
. 'abstractNumId="0"><w:nsid w:val="713727AE"/><w:multiLevelType' .
' w:val="hybridMultilevel"/><w:tmpl w:val="F0B4B6B8"/>' .
'<w:lvl w:ilvl="0" w:tplc="0C0A0001"><w:start w:val="1"/>' .
'<w:numFmt w:val="bullet"/><w:lvlText w:val=""/><w:lvlJc ' .
'w:val="left"/><w:pPr><w:ind w:left="720" w:hanging="360"/>' .
'</w:pPr><w:rPr><w:rFonts w:ascii="Symbol" w:hAnsi="Symbol" ' .
'w:hint="default"/></w:rPr></w:lvl><w:lvl w:ilvl="1" ' .
'w:tplc="0C0A0003" w:tentative="1"><w:start w:val="1"/>' .
'<w:numFmt w:val="bullet"/><w:lvlText w:val="o"/><w:lvlJc ' .
'w:val="left"/><w:pPr><w:ind w:left="1440" w:hanging="360"/>' . '
</w:pPr><w:rPr><w:rFonts w:ascii="Courier New" w:hAnsi=' .
'"Courier New" w:cs="Courier New" w:hint="default"/></w:rPr>' .
'</w:lvl><w:lvl w:ilvl="2" w:tplc="0C0A0005" w:tentative="1">' .
'<w:start w:val="1"/><w:numFmt w:val="bullet"/><w:lvlText ' .
'w:val=""/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="2160" ' .
'w:hanging="360"/></w:pPr><w:rPr><w:rFonts w:ascii="Wingdings" ' .
'w:hAnsi="Wingdings" w:hint="default"/></w:rPr></w:lvl><w:lvl ' .
'w:ilvl="3" w:tplc="0C0A0001" w:tentative="1"><w:start ' .
'w:val="1"/><w:numFmt w:val="bullet"/><w:lvlText w:val=""/>' .
'<w:lvlJc w:val="left"/><w:pPr><w:ind w:left="2880" w:hanging=' .
'"360"/></w:pPr><w:rPr><w:rFonts w:ascii="Symbol" w:hAnsi=' .
'"Symbol" w:hint="default"/></w:rPr></w:lvl><w:lvl w:ilvl="4" ' .
'w:tplc="0C0A0003" w:tentative="1"><w:start w:val="1"/>' .
'<w:numFmt w:val="bullet"/><w:lvlText w:val="o"/><w:lvlJc ' .
'w:val="left"/><w:pPr><w:ind w:left="3600" w:hanging="360"/>' .
'</w:pPr><w:rPr><w:rFonts w:ascii="Courier New" w:hAnsi=' .
'"Courier New" w:cs="Courier New" w:hint="default"/></w:rPr>' .
'</w:lvl><w:lvl w:ilvl="5" w:tplc="0C0A0005" w:tentative="1">' .
'<w:start w:val="1"/><w:numFmt w:val="bullet"/><w:lvlText ' .
'w:val=""/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="4320" ' .
'w:hanging="360"/></w:pPr><w:rPr><w:rFonts w:ascii="Wingdings" ' .
'w:hAnsi="Wingdings" w:hint="default"/></w:rPr></w:lvl><w:lvl ' .
'w:ilvl="6" w:tplc="0C0A0001" w:tentative="1"><w:start ' .
'w:val="1"/><w:numFmt w:val="bullet"/><w:lvlText w:val=""/>' .
'<w:lvlJc w:val="left"/><w:pPr><w:ind w:left="5040" ' .
'w:hanging="360"/></w:pPr><w:rPr><w:rFonts w:ascii="Symbol" ' .
'w:hAnsi="Symbol" w:hint="default"/></w:rPr></w:lvl><w:lvl ' .
'w:ilvl="7" w:tplc="0C0A0003" w:tentative="1"><w:start ' .
'w:val="1"/><w:numFmt w:val="bullet"/><w:lvlText w:val="o"/>' .
'<w:lvlJc w:val="left"/><w:pPr><w:ind w:left="5760" ' .
'w:hanging="360"/></w:pPr><w:rPr><w:rFonts w:ascii="Courier New" ' .
'w:hAnsi="Courier New" w:cs="Courier New" w:hint="default"/>' .
'</w:rPr></w:lvl><w:lvl w:ilvl="8" w:tplc="0C0A0005" ' .
'w:tentative="1"><w:start w:val="1"/><w:numFmt w:val="bullet"' .
'/><w:lvlText w:val=""/><w:lvlJc w:val="left"/><w:pPr><w:ind ' .
'w:left="6480" w:hanging="360"/></w:pPr><w:rPr><w:rFonts ' .
'w:ascii="Wingdings" w:hAnsi="Wingdings" w:hint="default"/>' .
'</w:rPr></w:lvl></w:abstractNum><w:num w:numId="1">' .
'<w:abstractNumId w:val="0"/></w:num></w:numbering>';
}
/**
* Generate WordNumbering XML template
*
* @access private
*/
private function generateTemplateWordNumberingStyles()
{
$this->_wordNumberingT =
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' .
'<w:numbering xmlns:ve="http://schemas.openxmlformats' .
'.org/markup-compatibility/2006" xmlns:o="urn:schemas-' .
'microsoft-com:office:office" xmlns:r="http://schemas' .
'.openxmlformats.org/officeDocument/2006/relationships" ' .
'xmlns:m="http://schemas.openxmlformats.org/officeDocument/' .
'2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:' .
'wp="http://schemas.openxmlformats.org/drawingml/2006/' .
'wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com' .
':office:word" xmlns:w="http://schemas.openxmlformats.org/' .
'wordprocessingml/2006/main" xmlns:wne="http://schemas.' .
'microsoft.com/office/word/2006/wordml"><w:abstractNum w:'
. 'abstractNumId="0"><w:nsid w:val="713727AE"/><w:multiLevelType' .
' w:val="hybridMultilevel"/><w:tmpl w:val="F0B4B6B8"/>' .
$this->_wordDocumentStyles . '</w:abstractNum><w:num w:numId="1">' .
'<w:abstractNumId w:val="0"/></w:num></w:numbering>';
}
/**
* Generate WordRelsDocumentRels XML template
*
* @access private
*/
private function generateTemplateWordRelsDocumentRels()
{
$this->_wordRelsDocumentRelsT =
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' .
'<Relationships xmlns="http://schemas.openxmlformats.org/' .
'package/2006/relationships">' . $this->_wordRelsDocumentRelsC .
'</Relationships>';
}
/**
* Generate WordRelsFooterRels XML template
*
* @access private
*/
private function generateTemplateWordRelsFooterRels()
{
$this->_wordRelsFooterRelsT =
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' .
'<Relationships xmlns="http://schemas.openxmlformats.org/' .
'package/2006/relationships">' . $this->_wordRelsFooterRelsC .
'</Relationships>';
}
/**
* Generate WordRelsHeaderRels XML template
*
* @access private
*/
private function generateTemplateWordRelsHeaderRels()
{
$this->_wordRelsHeaderRelsT =
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' .
'<Relationships xmlns="http://schemas.openxmlformats.org/' .
'package/2006/relationships">' . $this->_wordRelsHeaderRelsC .
'</Relationships>';
}
/**
* Generate WordSettings XML template
*
* @access private
*/
private function generateTemplateWordSettings()
{
$this->_wordSettingsT = $this->_wordSettingsC;
}
/**
* Generate WordStyles XML template
*
* @access private
*/
private function generateTemplateWordStyles()
{
$this->_wordStylesT =
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?><' .
CreateDocx::NAMESPACEWORD . ':styles xmlns:r="http://' .
'schemas.openxmlformats.org/officeDocument/2006/relationships' .
'" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/' .
'2006/main">' . $this->_wordStylesC .
'</' . CreateDocx::NAMESPACEWORD . ':styles>';
}
/**
* Generate WordThemeTheme1 XML template
*
* @access private
*/
private function generateTemplateWordThemeTheme1()
{
$this->addTheme($this->_defaultFont);
$this->_wordThemeThemeT =
'<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><' .
CreateTheme1::NAMESPACEWORD . ':theme xmlns:a="http://' .
'schemas.openxmlformats.org/drawingml/2006/main" name="' .
'Tema de Office">' . $this->_wordThemeThemeC .
'</' . CreateTheme1::NAMESPACEWORD . ':theme>';
}
/**
* Generate WordWebSettings XML template
*
* @access private
*/
private function generateTemplateWordWebSettings()
{
$this->_wordWebSettingsT = $this->_wordWebSettingsC;
}
/**
* Generates a TitlePg element in SectPr
*
* @access private
*/
private function generateTitlePg()
{
$foundNodes = $this->_sectPr->documentElement->getElementsByTagName('w:TitlePg');
if($foundNodes->length == 0){
$newSectNode = '<w:titlePg xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" />';
$sectNode = $this->_sectPr->createDocumentFragment();
$sectNode->appendXML($newSectNode);
$refNode =$this->_sectPr->documentElement->appendChild($sectNode);
}
}
/**
* To add support of sys_get_temp_dir for PHP versions under 5.2.1
*
* @access private
* @return string
*/
public static function getTempDir() {
if ( !function_exists('sys_get_temp_dir')) {
function sys_get_temp_dir() {
if ($temp = getenv('TMP')) {
return $temp;
}
if ($temp = getenv('TEMP')) {
return $temp;
}
if ($temp = getenv('TMPDIR')) {
return $temp;
}
$temp = tempnam(__FILE__,'');
if (file_exists($temp)) {
unlink($temp);
return dirname($temp);
}
return null;
}
} else {
return sys_get_temp_dir();
}
}
/**
* Parse path dir
*
* @access private
* @param string $dir Directory path
*/
private function parsePath($dir)
{
$slash = 0;
$path = '';
if (($slash = strrpos($dir, '/')) !== false) {
$slash += 1;
$path = substr($dir, 0, $slash);
}
$punto = strpos(substr($dir, $slash), '.');
$nombre = substr($dir, $slash, $punto);
$extension = substr($dir, $punto + $slash + 1);
return array(
'path' => $path, 'nombre' => $nombre, 'extension' => $extension
);
}
/**
* Delete a file or recursively delete a directory
*
* @param string $str path to file or directory
*/
private function recursiveDelete($str){
if(is_file($str)){
return @unlink($str);
}
elseif(is_dir($str)){
$scan = glob(rtrim($str,'/').'/*');
foreach($scan as $index=>$path){
$this->recursiveDelete($path);
}
return @rmdir($str);
}
}
/**
*
* Adds directory contents recursively into a zip.
*
* @param string $fileName. The path to the dir to add.
*
* @param string $myZip. The zip where the contents of the dir should be added.
*
*/
private function recursiveInsert($myZip, $fileName, $basePath){
$length = strlen($basePath);
if(is_dir($fileName)){
$contentsDir = scandir($fileName);
foreach($contentsDir as $element){
if($element != "." && $element !=".."){
$this->recursiveInsert($myZip, $fileName."/".$element, $basePath);
}
}
}else{
$newName = substr($fileName, $length + 1);
$myZip->addFile($fileName, $newName);
}
}
/**
*
* Includes data in the setting.xml file.
*
* @param array $settings. The string with the nodes that should be included in the settings.xml file.
*
*/
private function includeSettings($data){
try{
$baseSettings = $this->_baseTemplateZip->getFromName('word/settings.xml');
if ($baseSettings == '') {
throw new Exception('Error while extracting the settings.xml file from the base template');
}
}
catch (Exception $e) {
PhpdocxLogger::logger($e->getMessage(), 'fatal');
}
$settingsDoc = new DOMDocument();
$settingsDoc->loadXML($baseSettings);
$settings = $settingsDoc->documentElement;
foreach($data as $key => $value){
$newNode = $settingsDoc->createDocumentFragment();
$newNode->appendXML($value);
$settings->appendChild($newNode);
}
$settingsHandler = fopen($this->_baseTemplateFilesPath.'/word/settings.xml', "w+");
fwrite($settingsHandler, $settingsDoc->saveXML());
fclose($documentHandler);
}
}