1 | <?php |
---|
2 | /* vim: set expandtab tabstop=4 shiftwidth=4: */ |
---|
3 | // +----------------------------------------------------------------------+ |
---|
4 | // | TemplatePower Module => TPLSerializer: | |
---|
5 | // | offers you the ability save parsed templates to disk | |
---|
6 | // +----------------------------------------------------------------------+ |
---|
7 | // | | |
---|
8 | // | Copyright (C) 2001 R.P.J. Velzeboer, The Netherlands | |
---|
9 | // | | |
---|
10 | // | This program is free software; you can redistribute it and/or | |
---|
11 | // | modify it under the terms of the GNU General Public License | |
---|
12 | // | as published by the Free Software Foundation; either version 2 | |
---|
13 | // | of the License, or (at your option) any later version. | |
---|
14 | // | | |
---|
15 | // | This program is distributed in the hope that it will be useful, | |
---|
16 | // | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
17 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
---|
18 | // | GNU General Public License for more details. | |
---|
19 | // | | |
---|
20 | // | You should have received a copy of the GNU General Public License | |
---|
21 | // | along with this program; if not, write to the Free Software | |
---|
22 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
---|
23 | // | 02111-1307, USA. | |
---|
24 | // | | |
---|
25 | // | Author: R.P.J. Velzeboer, rovel@codocad.nl The Netherlands | |
---|
26 | // | | |
---|
27 | // +----------------------------------------------------------------------+ |
---|
28 | // | http://templatepower.codocad.com | |
---|
29 | // +----------------------------------------------------------------------+ |
---|
30 | // |
---|
31 | // $Id: Version 1.0 alpha$ |
---|
32 | |
---|
33 | include("./class.TemplatePower.inc.php"); |
---|
34 | |
---|
35 | class TPLSerializer extends TemplatePowerParser |
---|
36 | { |
---|
37 | var $stpl_file; |
---|
38 | |
---|
39 | /********** |
---|
40 | constructor |
---|
41 | ***********/ |
---|
42 | |
---|
43 | function TPLSerializer( $tpl_file, $stpl_file ) |
---|
44 | { |
---|
45 | $this->stpl_file = $stpl_file; |
---|
46 | |
---|
47 | TemplatePowerParser::TemplatePowerParser( $tpl_file, T_BYFILE ); |
---|
48 | } |
---|
49 | |
---|
50 | /********** |
---|
51 | private members |
---|
52 | ***********/ |
---|
53 | |
---|
54 | function __serializeTPL() |
---|
55 | { |
---|
56 | $fp = @fopen( $this->stpl_file, "w") or die( $this->__errorAlert('TemplatePower Error: Couldn\'t write [ '. $this->stpl_file .'] for serializing!') ); |
---|
57 | |
---|
58 | $stuffToSerialize = Array( defBlock => $this->defBlock, index => $this->index, parent => $this->parent ); |
---|
59 | |
---|
60 | fputs( $fp, serialize($stuffToSerialize) ); |
---|
61 | fclose( $fp ); |
---|
62 | chmod( $this->stpl_file, 0777 ); |
---|
63 | } |
---|
64 | |
---|
65 | /********** |
---|
66 | public members |
---|
67 | ***********/ |
---|
68 | |
---|
69 | function doSerialize() |
---|
70 | { |
---|
71 | TemplatePowerParser::__prepare(); |
---|
72 | $this->__serializeTPL(); |
---|
73 | } |
---|
74 | } |
---|
75 | ?> |
---|