ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

review_markup.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 review_markup_1_0_0{
27
38 var $CachedMultyFS = false;
39 var $ReviewAccess = false;
40 var $ReviewAlgorithms = false;
41 var $String = false;
42
57 function __construct()
58 {
59 try
60 {
61 $this->CachedMultyFS = get_package_object( 'cached_multy_fs' , 'last' , __FILE__ );
62 $this->ReviewAccess = get_package( 'review::review_access' , 'last' , __FILE__ );
63 $this->ReviewAlgorithms = get_package( 'review::review_algorithms' , 'last' , __FILE__ );
64 $this->String = get_package( 'string' , 'last' , __FILE__ );
65 }
66 catch( Exception $e )
67 {
68 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
69 }
70 }
71
94 function get_reviews_for_object( &$Settings )
95 {
96 try
97 {
98 $MasterId = $Settings->get_setting( 'master_id' );
99 $MasterType = $Settings->get_setting( 'master_type' );
100
101 return( $this->ReviewAlgorithms->get_records_for_object( $MasterId , $MasterType ) );
102 }
103 catch( Exception $e )
104 {
105 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
106 }
107 }
108
131 function compile_review_line( &$Settings )
132 {
133 try
134 {
135 $Reviews = $this->get_reviews_for_object( $Settings );
136
137 if( isset( $Reviews[ 0 ] ) )
138 {
139 $ReviewLine = '';
140
141 $TemplatePath = dirname( __FILE__ ).'/res/templates/default_review_template.tpl';
142
143 foreach( $Reviews as $i => $Review )
144 {
145 $ReviewLine .= $this->CachedMultyFS->file_get_contents( $TemplatePath );
146 $ReviewLine = $this->String->print_record( $ReviewLine , $Review );
147 }
148
149 return( $ReviewLine );
150 }
151 else
152 {
153 return( '{lang:reviews_were_not_found}' );
154 }
155 }
156 catch( Exception $e )
157 {
158 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
159 }
160 }
161
184 function compile_review_form( &$Settings )
185 {
186 try
187 {
188 $MasterId = $Settings->get_setting( 'master_id' );
189 $MasterType = $Settings->get_setting( 'master_type' );
190
191 $Code = '{direct_controller:package_name=review::review_controller;meta=meta_create_review;'.
192 "master_type=$MasterType;master_id=$MasterId;direct_create=1}".
193 '{direct_view:package_name=review::review_view;meta=meta_create_review_form;'.
194 "master_type=$MasterType;master_id=$MasterId;direct_create=1}";
195
196 return( $Code );
197 }
198 catch( Exception $e )
199 {
200 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
201 }
202 }
203
226 function compile_review_rank( &$Settings )
227 {
228 try
229 {
230 $MasterType = $Settings->get_setting( 'master_type' );
231 $MasterId = $Settings->get_setting( 'master_id' );
232
233 return( $this->RankAccess->get_total_rank( $MasterType , $MasterId ) );
234 }
235 catch( Exception $e )
236 {
237 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
238 }
239 }
240 }
241 ?>