Mercurial > defr > drupal > ad
annotate weight/percent/ad_weight_percent.inc @ 0:d8a3998dac8e ad
ajout module ad
| author | pierre | 
|---|---|
| date | Fri, 20 Feb 2009 14:04:09 +0000 | 
| parents | |
| children | 
| rev | line source | 
|---|---|
| pierre@0 | 1 <?php | 
| pierre@0 | 2 // $Id: ad_weight_percent.inc,v 1.1.2.2.2.2 2009/02/16 17:06:50 jeremy Exp $ | 
| pierre@0 | 3 | 
| pierre@0 | 4 /** | 
| pierre@0 | 5 * @file | 
| pierre@0 | 6 * A plug in for the ad.module, providing a percentage based weighting mechanism | 
| pierre@0 | 7 * for the random selection of ads. | 
| pierre@0 | 8 * | 
| pierre@0 | 9 * Copyright (c) 2007-2009. | 
| pierre@0 | 10 * Jeremy Andrews <jeremy@tag1consulting.com>. | 
| pierre@0 | 11 */ | 
| pierre@0 | 12 | 
| pierre@0 | 13 function ad_weight_percent_select_ad($ads, $quantity, $invalid) { | 
| pierre@0 | 14 $tid = NULL; | 
| pierre@0 | 15 if (adserve_variable('tids')) { | 
| pierre@0 | 16 $id = adserve_variable('tids'); | 
| pierre@0 | 17 $tids = explode(',', $id); | 
| pierre@0 | 18 // A group can only be comprised of one tid. If multiple tids are defined, | 
| pierre@0 | 19 // then we're not working with a group. | 
| pierre@0 | 20 if (sizeof($tids) == 1) { | 
| pierre@0 | 21 $tid = $tids[0]; | 
| pierre@0 | 22 } | 
| pierre@0 | 23 } | 
| pierre@0 | 24 else if (!adserve_variable('nids')) { | 
| pierre@0 | 25 // The default group. | 
| pierre@0 | 26 $tid = 0; | 
| pierre@0 | 27 } | 
| pierre@0 | 28 | 
| pierre@0 | 29 // Only do something if we're currently processing a specific ad group. | 
| pierre@0 | 30 if ($tid !== NULL) { | 
| pierre@0 | 31 // TODO: The percentage information needs to be stored in the file cache, | 
| pierre@0 | 32 // as obviously we don't want to bootstrap the database layer and perform | 
| pierre@0 | 33 // a query at this point. | 
| pierre@0 | 34 } | 
| pierre@0 | 35 } | 
