Subversion Repositories cheapmusic

Rev

Rev 81 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
9 - 1
<?php
65 - 2
class Vendors {
9 - 3
    private static $instance = null;
4
    private static $ebay = [];
5
    private static $discogs = [];
20 - 6
    private static $linkshare = [];
7
    private static $cjaffiliate = [];
8
    private static $walmart = [];
54 - 9
    private static $itunes = [];
81 - 10
    private static $amazon = [];
83 - 11
    private static $impact = [];
9 - 12
 
13
    const EBAY = 0;
14
    const DISCOGS = 1;
20 - 15
    const LINKSHARE = 2;
16
    const CJAFFILIATE = 3;
17
    const WALMART = 4;
54 - 18
    const ITUNES = 5;
81 - 19
    const AMAZON = 6;
83 - 20
    const IMPACT = 7;
9 - 21
 
65 - 22
    public static function getInstance() {
23
        if (is_null(self::$instance)) {
9 - 24
            self::$instance = new self();
25
        }
26
 
27
        return self::$instance;
28
    }
29
 
65 - 30
    public function setVendor($vendorArray, $type) {
10 - 31
        if ($type == self::EBAY) {
9 - 32
            self::$ebay = $vendorArray;
83 - 33
        } else if ($type == self::DISCOGS) {
9 - 34
            self::$discogs = $vendorArray;
83 - 35
        } else if ($type == self::LINKSHARE) {
20 - 36
            self::$linkshare = $vendorArray;
83 - 37
        } else if ($type == self::CJAFFILIATE) {
20 - 38
            self::$cjaffiliate = $vendorArray;
83 - 39
        } else if ($type == self::WALMART) {
20 - 40
            self::$walmart = $vendorArray;
83 - 41
        } else if ($type == self::ITUNES) {
54 - 42
            self::$itunes = $vendorArray;
83 - 43
        } else if ($type == self::AMAZON) {
81 - 44
            self::$amazon = $vendorArray;
83 - 45
        } else if ($type == self::IMPACT) {
46
            self::$impact = $vendorArray;
81 - 47
        }
9 - 48
    }
49
 
65 - 50
    public function getVendor($type) {
10 - 51
        if ($type == self::EBAY) {
9 - 52
            return self::$ebay;
83 - 53
        } else if ($type == self::DISCOGS) {
9 - 54
            return self::$discogs;
83 - 55
        } else if ($type == self::LINKSHARE) {
20 - 56
            return self::$linkshare;
83 - 57
        } else if ($type == self::CJAFFILIATE) {
20 - 58
            return self::$cjaffiliate;
83 - 59
        } else if ($type == self::WALMART) {
20 - 60
            return self::$walmart;
83 - 61
        } else if ($type == self::ITUNES) {
54 - 62
            return self::$itunes;
83 - 63
        } else if ($type == self::AMAZON) {
81 - 64
            return self::$amazon;
83 - 65
        } else if ($type == self::IMPACT) {
66
            return self::$impact;
81 - 67
        }
9 - 68
 
69
        return null;
70
    }
83 - 71
 
72
    public static function setAllVendors($configFile, $vendors) {
73
        $vendors->setVendor($configFile['ebay'], Vendors::EBAY);
74
        $vendors->setVendor($configFile['discogs'], Vendors::DISCOGS);
75
        $vendors->setVendor($configFile['linkshare'], Vendors::LINKSHARE);
76
        $vendors->setVendor($configFile['cjaffiliate'], Vendors::CJAFFILIATE);
77
        $vendors->setVendor($configFile['walmart'], Vendors::WALMART);
78
        $vendors->setVendor($configFile['itunes'], Vendors::ITUNES);
79
        $vendors->setVendor($configFile['amazon'], Vendors::AMAZON);
80
        $vendors->setVendor($configFile['impact'], Vendors::IMPACT);
81
    }
10 - 82
}