ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

change_history_view.php
Go to the documentation of this file.
1 <?php
2
3 /*
4 * This source code is a part of the Ultimix Project.
5 * It is distributed under BSD license. All other third side source code (like tinyMCE) is distributed under
6 * it's own license wich could be found from the corresponding files or sources.
7 * This source code is provided "as is" without any warranties or garanties.
8 *
9 * Have a nice day!
10 *
11 * @url http://ultimix.sorceforge.net
12 *
13 * @author Alexey "gdever" Dodonov
14 */
15
26 class change_history_view_1_0_0{
27
38 var $ChangeHistoryAcces = false;
39
54 function __construct()
55 {
56 try
57 {
58 $this->ChangeHistoryAcces = get_package(
59 'database::change_history::change_history_access' , 'last' , __FILE__
60 );
61 }
62 catch( Exception $e )
63 {
64 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
65 }
66 }
67
90 function get_grid_header( $id )
91 {
92 try
93 {
94 $Code = $this->CachedMultyFS->get_template( __FILE__ , 'change_history_header.tpl' );
95
96 return( str_replace( '{id}' , $id , $Code ) );
97 }
98 catch( Exception $e )
99 {
100 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
101 }
102 }
103
122 private function get_replace_parameters()
123 {
124 try
125 {
126 $PlaceHolders = array(
127 '{class}' , '{date_string}' , '{time_string}' , '{author_name}' , '{field_name}' ,
128 '{previous}' , '{field_value}'
129 );
130
131 $Data = array(
132 'table_row_'.( $i % 2 ? 'even' : 'odd' ) , date( 'd.m.y' , $Time ) , date( 'H:i:s' , $Time ) ,
133 get_field( $Change , 'author_name' ) , $FieldName = get_field( $Change , 'field_name' ) ,
134 get_field( $Previous , $FieldName , '-' ) , $FieldValue = get_field( $Change , 'field_value' )
135 );
136
137 return( array( $PlaceHolders , $Data ) );
138 }
139 catch( Exception $e )
140 {
141 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
142 }
143 }
144
167 function get_grid_lines( &$Changes )
168 {
169 try
170 {
171 $Lines = $Previous = array();
172
173 foreach( $Changes as $i => $Change )
174 {
175 list( $PlaceHolders , $Data ) = $this->get_replace_parameters();
176
177 $Code = $this->CachedMultyFS->get_template( __FILE__ , 'change_history_item.tpl' );
178
179 $Code = str_replace( $PlaceHolders , $Data , $Code );
180
181 $Previous[ $FieldName ] = $FieldValue;
182
183 $Lines [] = $Code;
184 }
185
186 return( implode( '' , array_reverse( $Lines ) ) );
187 }
188 catch( Exception $e )
189 {
190 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
191 }
192 }
193
220 function get_changes_grid( $id , $ObjectType )
221 {
222 try
223 {
224 $Changes = $this->ChangeHistoryAcces->get_history( $id , $ObjectType );
225
226 if( isset( $Changes[ 0 ] ) )
227 {
228 $Code = $this->get_grid_header( $id );
229 $Code .= $this->get_grid_lines( $Changes );
230
231 $Footer = $this->CachedMultyFS->get_template( __FILE__ , 'change_history_footer.tpl' );
232 $Code .= str_replace( '{code}' , $Code , $Footer );
233 }
234 else
235 {
236 $NoDataFound = $this->CachedMultyFS->get_template( __FILE__ , 'change_history_no_data_found.tpl' );
237 $Code = str_replace( '{id}' , $id , $NoDataFound );
238 }
239
240 return( $Code );
241 }
242 catch( Exception $e )
243 {
244 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
245 }
246 }
247 }
248
249 ?>