ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

ad_banner_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 ad_banner_view_1_0_0{
27
38 var $Output;
39
50 var $CachedMultyFS = false;
51 var $String = false;
52
63 function __construct()
64 {
65 try
66 {
67 $this->CachedMultyFS = get_package( 'cached_multy_fs' , 'last' , __FILE__ );
68 $this->String = get_package( 'string' , 'last' , __FILE__ );
69 }
70 catch( Exception $e )
71 {
72 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
73 }
74 }
75
94 function pre_generation( $Options )
95 {
96 try
97 {
98 $this->PageCSS->add_stylesheet(
99 '{http_host}/'._get_package_relative_path_ex(
100 'ad::ad_banner::ad_banner_view' , '1.0.0'
101 ).'/res/css/ad_banner_view.css' ,
102 true
103 );
104
105 $Lang = get_package( 'lang' , 'last' , __FILE__ );
106 $Lang->include_strings_js( 'ad::ad_banner::ad_banner_view' );
107 }
108 catch( Exception $e )
109 {
110 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
111 }
112 }
113
132 function get_campaigns_and_banners()
133 {
134 try
135 {
136 $Campaigns = $this->AdCampaignAccess->unsafe_select(
137 'archived = 0 AND creator = '.$this->UserAlgorithms->get_id()
138 );
139
140 if( count( $Campaigns ) == 0 )
141 {
142 $Campaigns = array( array( 'id' => -1 ) );
143 }
144 $Banners = $this->AdBannerAccess->unsafe_select(
145 'archived = 0 AND campaign_id IN ( '.implode_ex( ',' , $Campaigns , 'id' ).' )'
146 );
147
148 return( array( $Campaigns , $Banners ) );
149 }
150 catch( Exception $e )
151 {
152 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
153 }
154 }
155
186 function compile_banners_for_campaign( $CampaignId , $Code , $Banners )
187 {
188 try
189 {
190 foreach( $Banners as $j => $b )
191 {
192 if( $CampaignId == $b->campaign_id )
193 {
194 $BannerTemplate = $this->CachedMultyFS->get_template( __FILE__ , 'banner.tpl' );
195 $BannerTemplate = $this->String->print_record( $BannerTemplate , $b );
196 $Code = str_replace(
197 '{banners}' , $BannerTemplate.'{banners}' , $Code
198 );
199 }
200 }
201
202 return( $Code );
203 }
204 catch( Exception $e )
205 {
206 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
207 }
208 }
209
232 function common_view( $Options )
233 {
234 try
235 {
236 list( $Campaigns , $Banners ) = $this->get_campaigns_and_banners();
237
238 foreach( $Campaigns as $i => $c )
239 {
240 $Code = $this->CachedMultyFS->get_template( __FILE__ , 'campaign.tpl' );
241 $Code = $this->String->print_record( $Code , $c );
242 $Code = str_replace( '{i}' , $i , $Code );
243
244 $this->Output .= $this->compile_banners_for_campaign( $c->id , $Code , $Banners );
245 }
246
247 $CampaignListTemplate = $this->CachedMultyFS->get_template( __FILE__ , 'campaign_list.tpl' );
248
249 $this->Output = str_replace( '{output}' , $this->Output , $CampaignListTemplate );
250 }
251 catch( Exception $e )
252 {
253 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
254 }
255 }
256
279 function view( $Options )
280 {
281 try
282 {
283 $ContextSet = get_package_object( 'gui::context_set' , 'last' , __FILE__ );
284
285 $ContextSet->add_context( dirname( __FILE__ ).'/conf/cfcx_ad_banner_view_common_view' );
286
287 $ContextSet->execute( $Options , $this , __FILE__ );
288
289 return( $this->Output );
290 }
291 catch( Exception $e )
292 {
293 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
294 }
295 }
296 }
297
298 ?>