/[drupal]/contributions/modules/ad_flash/ad_flash_views.inc
ViewVC logotype

Contents of /contributions/modules/ad_flash/ad_flash_views.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Thu Dec 4 11:03:23 2008 UTC (11 months, 3 weeks ago) by chriscohen
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-5, DRUPAL-6--1
File MIME type: text/x-php
Initial commit of ad_flash module from ad_flash code originally written by mixman and developed by the Drupal community.
1 <?php
2 // $Id: $
3
4 /**
5 * @file
6 * Adds views support for the ad_flash.module
7 *
8 *
9 * Based on the ad_image.module by Jeremy Andrews
10 *
11 * Copyright (c) 2007
12 * Fabio Varesano <fvaresano at yahoo dot it> All rights reserved.
13 *
14 * Copyright (c) 2005-2007.
15 * Jeremy Andrews <jeremy@kerneltrap.org>. All rights reserved.
16 */
17
18 function ad_flash_views_tables() {
19 return array(
20 'ad_flash' => array(
21 'name' => 'ad_flash',
22 'join' => array(
23 'left' => array(
24 'table' => 'ads',
25 'field' => 'aid',
26 ),
27 'right' => array(
28 'field' => 'aid',
29 ),
30 ),
31 'fields' => array(
32 'url' => array(
33 'name' => 'Flash Ad: Click-through URL',
34 'handler' => 'ad_handler_field_url',
35 'option' => array(
36 '#type' => 'select',
37 '#options' => array(
38 'link' => t('As link'),
39 'nolink' => t('Not as link'),
40 ),
41 ),
42 ),
43 'aid' => array(
44 'name' => 'Flash Ad: Flash File',
45 'handler' => 'ad_flash_handler_field_flash',
46 'option' => array(
47 '#type' => 'select',
48 '#options' => array(
49 'linkflash' => t('Linked Flash File'),
50 'image' => t('Unlinked Flash File'),
51 'path' => t('Flash file path'),
52 ),
53 ),
54 ),
55 ),
56 ),
57 );
58 }
59
60 function ad_flash_handler_field_flash($fieldinfo, $fielddata, $value, $data) {
61 if ($fielddata['options'] == 'linkflash') {
62 $ad = db_fetch_object(db_query("SELECT a.redirect, f.filepath FROM {ads} a JOIN {ad_flash} i JOIN {files} f ON a.aid = i.aid AND i.aid = f.nid AND i.fid = f.fid WHERE i.aid = %d AND a.adtype = 'flash'", $value));
63 if ($ad) {
64 ad_statistics_increment($value, 'view');
65 return "<a href=\"$ad->redirect\"><img src=\"$ad->filepath\" /></a>";
66 }
67 }
68 else if ($fielddata['options'] == 'flash') {
69 $ad = db_fetch_object(db_query("SELECT f.filepath FROM {ad_flash} i JOIN {files} f ON i.aid = f.nid AND i.fid = f.fid WHERE i.aid = %d AND a.adtype = 'flash'", $value));
70 if ($ad) {
71 ad_statistics_increment($value, 'view');
72 return "<img src=\"$ad->filepath\" />";
73 }
74 }
75 else {
76 $ad = db_fetch_object(db_query("SELECT f.filepath FROM {ad_flash} i JOIN {files} f ON i.aid = f.nid AND i.fid = f.fid AND i.aid = %d", $value));
77 return $ad->filepath;
78 }
79 }
80
81 ?>

  ViewVC Help
Powered by ViewVC 1.1.2