|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
*@author: nicolaas [at] sunny side up . co . nz |
|
5
|
|
|
* |
|
6
|
|
|
**/ |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
class SmartChimpNewsletter extends DataObject |
|
|
|
|
|
|
10
|
|
|
{ |
|
11
|
|
|
public static $has_one = array( |
|
12
|
|
|
"Parent" => "SmartChimpSignupPage" |
|
13
|
|
|
); |
|
14
|
|
|
|
|
15
|
|
|
public static $db = array( |
|
16
|
|
|
"Hide" => "Boolean", |
|
17
|
|
|
"CampaignID" => "Varchar(30)",//id |
|
18
|
|
|
"Date" => "Datetime",//send_time |
|
19
|
|
|
"Title" => "Varchar(255)",//title |
|
20
|
|
|
"Subject" => "Varchar(255)",//title |
|
21
|
|
|
"PermaLink" => "Varchar(255)",//archive_url |
|
22
|
|
|
"WebID" => "Int", //web_id |
|
23
|
|
|
"Status" => "Varchar(20)", //should be sent! |
|
24
|
|
|
"TextContent" => "Text", //html |
|
25
|
|
|
"HTMLContent" => "HTMLText", //text |
|
26
|
|
|
"Done" => "Boolean" |
|
27
|
|
|
); |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
|
|
31
|
|
|
public static $indexes = array( |
|
32
|
|
|
"CampaignID" => true |
|
33
|
|
|
); |
|
34
|
|
|
|
|
35
|
|
|
public static $casting = array( |
|
36
|
|
|
"DateNice" => "Text", |
|
37
|
|
|
"ShowOrHide" => "Text", |
|
38
|
|
|
"YearMonth" => "Int", |
|
39
|
|
|
"Month" => "Int", |
|
40
|
|
|
"Link" => "Text" |
|
41
|
|
|
); |
|
42
|
|
|
|
|
43
|
|
|
public function getYearMonth() |
|
44
|
|
|
{ |
|
45
|
|
|
return $this->obj('Date')->format("F")." ".$this->obj('Date')->format("Y"); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function getDateNice() |
|
|
|
|
|
|
49
|
|
|
{ |
|
50
|
|
|
return $this->obj('Date')->Long(); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function ShowOrHide() |
|
54
|
|
|
{ |
|
55
|
|
|
return $this->Hide ? "hide" : "show"; |
|
|
|
|
|
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function Link() |
|
|
|
|
|
|
59
|
|
|
{ |
|
60
|
|
|
return str_replace('&', '&', $this->PermaLink); |
|
|
|
|
|
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function requiredDefaultRecords() |
|
64
|
|
|
{ |
|
65
|
|
|
parent::requiredDefaultRecords(); |
|
|
|
|
|
|
66
|
|
|
} |
|
67
|
|
|
public static $default_sort = "\"Date\" DESC"; |
|
68
|
|
|
public static $defaults = array();//use fieldName => Default Value |
|
69
|
|
|
public static $searchable_fields = array("Title" => "PartialMatchFilter"); |
|
70
|
|
|
public static $field_labels = array("Title" => "Title"); |
|
71
|
|
|
public static $summary_fields = array("Title" => "Title", "DateNice" => "Date", "ShowOrHide" => "ShowOrHide"); |
|
72
|
|
|
public static $singular_name = "MailChimp Newsletter"; |
|
73
|
|
|
public static $plural_name = "MailChimp Newsletters"; |
|
74
|
|
|
|
|
75
|
|
|
public static function clean_up_characters() |
|
76
|
|
|
{ |
|
77
|
|
|
DB::query("UPDATE `SmartChimpNewsletter` SET `TextContent` = REPLACE(`TextContent`,'’','\'');"); |
|
78
|
|
|
DB::query("UPDATE `SmartChimpNewsletter` SET `TextContent` = REPLACE(`TextContent`,'…','');"); |
|
79
|
|
|
DB::query("UPDATE `SmartChimpNewsletter` SET `TextContent` = REPLACE(`TextContent`,'“','\"');"); |
|
80
|
|
|
DB::query("UPDATE `SmartChimpNewsletter` SET `TextContent` = REPLACE(`TextContent`,'“','\"');"); |
|
81
|
|
|
DB::query("UPDATE `SmartChimpNewsletter` SET `TextContent` = REPLACE(`TextContent`,'–','-');"); |
|
82
|
|
|
DB::query("UPDATE `SmartChimpNewsletter` SET `TextContent` = REPLACE(`TextContent`,'�','\"');"); |
|
83
|
|
|
DB::query("UPDATE `SmartChimpNewsletter` SET `TextContent` = REPLACE(`TextContent`,'� ','\"');"); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
public static $field_types = array( |
|
87
|
|
|
"CampaignID" => "TextField",//id |
|
88
|
|
|
"Date" => "TextField",//send_time |
|
89
|
|
|
"Title" => "TextField",//title |
|
90
|
|
|
"Subject" => "TextField",//title |
|
91
|
|
|
"PermaLink" => "TextField",//archive_url |
|
92
|
|
|
"WebID" => "NumericField", //web_id |
|
93
|
|
|
"Status" => "TextField", //should be sent! |
|
94
|
|
|
"TextContent" => "TextareaField", //html |
|
95
|
|
|
"HTMLContent" => "TextareaField", //text |
|
96
|
|
|
"Done" => "CheckboxField" |
|
97
|
|
|
); |
|
98
|
|
|
} |
|
99
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.