ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

ad_campaign_manager.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_campaign_manager_1_0_0{
27
38 var $Output;
39
50 var $AdCampaignAccess = false;
51 var $AdBannerAccess = false;
52 var $CachedMultyFS = false;
53 var $String = false;
54 var $UserAlgorithms = false;
55
66 function __construct()
67 {
68 try
69 {
70 $this->AdCampaignAccess = get_package( 'ad::ad_campaign::ad_campaign_access' , 'last' , __FILE__ );
71 $this->AdBannerAccess = get_package( 'ad::ad_banner::ad_banner_access' , 'last' , __FILE__ );
72 $this->CachedMultyFS = get_package( 'cached_multy_fs' , 'last' , __FILE__ );
73 $this->String = get_package( 'string' , 'last' , __FILE__ );
74 $this->UserAlgorithms = get_package( 'user::user_algorithms' , 'last' , __FILE__ );
75 }
76 catch( Exception $e )
77 {
78 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
79 }
80 }
81
100 private function get_campaigns_and_banners()
101 {
102 try
103 {
104 $id = $this->UserAlgorithms->get_id();
105 $Campaigns = $this->AdCampaignAccess->unsafe_select( "archived = 0 AND creator = $id" );
106
107 if( isset( $Campaigns[ 0 ] ) )
108 {
109 $ids = implode_ex( ',' , $Campaigns , 'id' );
110 $Banners = $this->AdBannerAccess->unsafe_select( "archived = 0 AND campaign_id IN ( $ids )" );
111 }
112 else
113 {
114 $Campaigns = $Banners = array();
115 }
116
117 return( array( $Campaigns , $Banners ) );
118 }
119 catch( Exception $e )
120 {
121 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
122 }
123 }
124
147 private function compile_campaign( $Campaign , &$Banners )
148 {
149 try
150 {
151 $CompanyTemplate = $this->CachedMultyFS->get_template( __FILE__ , 'campaign.tpl' );
152 $CompanyTemplate = $this->String->print_record( $CompanyTemplate , $Campaign );
153
154 foreach( $Banners as $j => $Banner )
155 {
156 if( $Campaign->id == $Banner->campaign_id )
157 {
158 $Template2 = $this->CachedMultyFS->get_template( __FILE__ , 'banner.tpl' );
159 $Template2 = $this->String->print_record( $Template2 , $Banner );
160 $CompanyTemplate = str_replace( '{banners}' , $Template2.'{banners}' , $CompanyTemplate );
161 }
162 }
163
164 $this->Output .= $CompanyTemplate;
165 }
166 catch( Exception $e )
167 {
168 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
169 }
170 }
171
194 function common_view( &$Options )
195 {
196 try
197 {
198 list( $Campaigns , $Banners ) = $this->get_campaigns_and_banners();
199
200 if( isset( $Campaigns[ 0 ] ) )
201 {
202 foreach( $Campaigns as $i => $Campaign )
203 {
204 $this->compile_campaign( $Campaign , $Banners );
205 }
206
207 $Template = $this->CachedMultyFS->get_template( __FILE__ , 'campaigns_list.tpl' );
208
209 $this->Output = str_replace( '{output}' , $this->Output , $Template );
210 }
211 else
212 {
213 $this->Output = $this->CachedMultyFS->get_template( __FILE__ , 'ad_campaign_no_data_found.tpl' );
214 }
215 }
216 catch( Exception $e )
217 {
218 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
219 }
220 }
221
240 function controller( &$Options )
241 {
242 try
243 {
244 $ContextSet = get_package_object( 'gui::context_set' , 'last' , __FILE__ );
245
246 $ContextSet->execute( $Options , $this , __FILE__ );
247 }
248 catch( Exception $e )
249 {
250 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
251 }
252 }
253
276 function view( &$Options )
277 {
278 try
279 {
280 $ContextSet = get_package_object( 'gui::context_set' , 'last' , __FILE__ );
281
282 $ContextSet->add_context( dirname( __FILE__ ).'/conf/cfcxs_list_ad_campaign_form' );
283
284 $ContextSet->execute( $Options , $this , __FILE__ );
285
286 return( $this->Output );
287 }
288 catch( Exception $e )
289 {
290 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
291 }
292 }
293 }
294
295 ?>