1 | <?php |
||
10 | class CountryPrice extends DataObject |
||
11 | { |
||
12 | |||
13 | // CURRENCY LIST AND STATIC FUNCTIONS |
||
14 | |||
15 | private static $db = array( |
||
|
|||
16 | 'Price' => 'Currency', |
||
17 | 'Country' => 'Varchar(2)', |
||
18 | 'Currency' => 'Varchar(3)', |
||
19 | 'ObjectClass' => 'Varchar', |
||
20 | 'ObjectID' => 'Int' |
||
21 | ); |
||
22 | |||
23 | private static $field_labels = array( |
||
24 | 'Currency' => 'Currency Code', |
||
25 | 'Country' => 'Country Code', |
||
26 | 'ObjectClass' => 'Buyable Name', |
||
27 | 'ObjectID' => 'Buyable ID' |
||
28 | ); |
||
29 | private static $summary_fields = array( |
||
30 | 'BuyableName' => 'Buyable', |
||
31 | 'CountryName' => 'Country', |
||
32 | 'FullPrice' => 'Price' |
||
33 | ); |
||
34 | |||
35 | private static $casting = array( |
||
36 | 'BuyableName' => 'Varchar', |
||
37 | 'Title' => 'Varchar', |
||
38 | 'CountryName' => 'Varchar', |
||
39 | 'FullPrice' => 'Varchar' |
||
40 | ); |
||
41 | |||
42 | private static $indexes = array( |
||
43 | 'Unique' => array( |
||
44 | 'type' => 'unique', |
||
45 | 'value' => 'Country,ObjectClass,ObjectID' |
||
46 | ), |
||
47 | 'Currency' => true |
||
48 | ); |
||
49 | |||
50 | private static $searchable_fields = array( |
||
51 | 'Price' => 'PartialMatchFilter', |
||
52 | 'Country' => 'PartialMatchFilter', |
||
53 | 'Currency' => 'PartialMatchFilter' |
||
54 | ); |
||
55 | |||
56 | /** |
||
57 | * caching only variable |
||
58 | * @var EcommerceCountry | null |
||
59 | */ |
||
60 | private $_myBuyable = null; |
||
61 | |||
62 | /** |
||
63 | * the buyable we relate to |
||
64 | * return DataObject | null |
||
65 | */ |
||
66 | public function Buyable() |
||
77 | |||
78 | /** |
||
79 | * caching only variable |
||
80 | * @var EcommerceCountry | null |
||
81 | */ |
||
82 | private $_myCountryObject = null; |
||
83 | |||
84 | /** |
||
85 | * |
||
86 | * return EcommerceCountry | null |
||
87 | */ |
||
88 | public function CountryObject() |
||
100 | |||
101 | /** |
||
102 | * |
||
103 | * return EcommerceCountry | null |
||
104 | */ |
||
105 | public function CurrencyObject() |
||
111 | |||
112 | /** |
||
113 | * casted variable |
||
114 | * @return String |
||
115 | */ |
||
116 | public function getBuyableName() |
||
123 | |||
124 | /** |
||
125 | * casted variable |
||
126 | * @return String |
||
127 | */ |
||
128 | public function getTitle() |
||
132 | |||
133 | /** |
||
134 | * casted variable |
||
135 | * @return String |
||
136 | */ |
||
137 | public function getCountryName() |
||
141 | |||
142 | /** |
||
143 | * casted variable |
||
144 | * returns nicely formatted price.. |
||
145 | * @return String |
||
146 | */ |
||
147 | public function getFullPrice() |
||
151 | |||
152 | public function getCMSFields() |
||
209 | |||
210 | private static $cms_object = null; |
||
211 | |||
212 | //MUST KEEP |
||
213 | public static function set_cms_object($o) |
||
217 | |||
218 | public function canEdit($member = null) |
||
230 | |||
231 | /** |
||
232 | * We use validate as an onBeforeWrite as well because in this case it makes sense |
||
233 | * as in the validation process we add stuff... |
||
234 | * @return ValidationResult |
||
235 | */ |
||
236 | protected function validate() |
||
265 | |||
266 | /** |
||
267 | * Returns if the currency is an old currency not used anymore. |
||
268 | * @return Boolean |
||
269 | */ |
||
270 | public function isObsolete() |
||
277 | |||
278 | /** |
||
279 | * name of session variable used to set Country |
||
280 | * @var String |
||
281 | */ |
||
282 | private static $location_param = 'Location'; |
||
283 | |||
284 | |||
285 | /** |
||
286 | * country for user |
||
287 | * @var String |
||
288 | */ |
||
289 | private static $location_country; |
||
290 | |||
291 | /** |
||
292 | * returns Country code |
||
293 | * @return string |
||
294 | */ |
||
295 | public static function get_location_country() |
||
299 | } |
||
300 |