ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

comment_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 comment_markup_1_0_0{
27
38 var $Settings = false;
39 var $CachedMultyFS = false;
40 var $CommentAlgorithms = false;
41 var $Link = false;
42 var $String = false;
43
58 function __construct()
59 {
60 try
61 {
62 $this->Settings = get_package_object( 'settings::settings' , 'last' , __FILE__ );
63 $this->CachedMultyFS = get_package( 'cached_multy_fs' , 'last' , __FILE__ );
64 $this->CommentAlgorithms = get_package( 'comment::comment_algorithms' , 'last' , __FILE__ );
65 $this->Link = get_package( 'link' , 'last' , __FILE__ );
66 $this->String = get_package( 'string' , 'last' , __FILE__ );
67 }
68 catch( Exception $e )
69 {
70 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
71 }
72 }
73
96 function compile_comments( &$Settings )
97 {
98 try
99 {
100 $Comments = $this->get_comments_for_object( $Settings );
101
102 if( isset( $Comments[ 0 ] ) )
103 {
104 $CommentLine = '';
105
106 $TemplatePath = dirname( __FILE__ ).'/res/templates/default_comment_template.tpl';
107
108 foreach( $Comments as $i => $Comment )
109 {
110 $CommentLine .= $this->CachedMultyFS->file_get_contents( $TemplatePath );
111 $CommentLine = $this->String->print_record( $CommentLine , $Comment );
112 }
113
114 return( $CommentLine );
115 }
116 else
117 {
118 return( '{lang:comments_were_not_found}' );
119 }
120 }
121 catch( Exception $e )
122 {
123 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
124 }
125 }
126
149 function get_comments_for_object( &$Settings )
150 {
151 try
152 {
153 $MasterId = $Settings->get_setting( 'master_id' );
154 $MasterType = $Settings->get_setting( 'master_type' );
155
156 return( $this->CommentAlgorithms->get_records_for_object( $MasterId , $MasterType ) );
157 }
158 catch( Exception $e )
159 {
160 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
161 }
162 }
163
186 function compile_comment_link( &$Settings )
187 {
188 try
189 {
190 $MasterId = $Settings->get_setting( 'master_id' );
191 $MasterType = $Settings->get_setting( 'master_type' );
192
193 $CommentsCount = $this->Link->get_links_count( $MasterId , false , $MasterType , 'comment' );
194
195 $Page = $Settings->get_setting( 'page' );
196
197 $Template = $this->CachedMultyFS->get_template( __FILE__ , 'comment_link.tpl' );
198 $PlaceHolders = array( '{page}' , '{comment_count}' );
199
200 return( str_replace( $PlaceHolders , array( $Page , $CommentsCount ) , $Template ) );
201 }
202 catch( Exception $e )
203 {
204 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
205 }
206 }
207
230 function compile_comment_form( $Parameters )
231 {
232 try
233 {
234 $this->Settings->load_settings( $Parameters );
235
236 list( $MasterType , $MasterId )= $this->Settings->get_settings( 'master_type,master_id' );
237 $NeedRun = $this->Settings->get_setting( 'need_run' , 1 );
238
239 $Code = '{direct_controller:package_name=comment::comment_controller;meta=meta_create_comment;'.
240 "master_type=$MasterType;master_id=$MasterId;direct_create=1;need_run=$NeedRun}".
241 '{direct_view:package_name=comment::comment_view;meta=meta_create_comment_form;'.
242 "master_type=$MasterType;master_id=$MasterId;direct_create=1;need_run=$NeedRun}";
243
244 return( $Code );
245 }
246 catch( Exception $e )
247 {
248 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
249 }
250 }
251 }
252
253 ?>