-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathConferencePage.php
More file actions
209 lines (180 loc) · 7.79 KB
/
Copy pathConferencePage.php
File metadata and controls
209 lines (180 loc) · 7.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<?php
/**
* Copyright 2014 Openstack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
/**
* Defines the ConferencePage page type
*/
class ConferencePage extends Page
{
static $db = array(
'HeaderArea' => 'HTMLText',
'Sidebar' => 'HTMLText',
'HeadlineSponsors' => 'HTMLText',
'GAConversionId'=>'Text',
'GAConversionLanguage'=>'Text',
'GAConversionFormat'=>'Text',
'GAConversionColor'=>'Text',
'GAConversionLabel'=>'Text',
'GAConversionValue'=>'Int',
'GARemarketingOnly'=>'Boolean',
//Facebook Conversion Params
'FBPixelId' => 'Text',
'FBValue' => 'Text',
'FBCurrency' => 'Text',
);
static $defaults = array(
//Google
"GAConversionId" => "994798451",
"GAConversionLanguage" => "en",
"GAConversionFormat" => "3",
"GAConversionColor" => "ffffff",
"GAConversionLabel" => "IuM5CK3OzQYQ89at2gM",
"GAConversionValue" => 0,
"GARemarketingOnly" => false,
//FB
'FBPixelId' => '6013247449963',
'FBValue' => '0.00',
'FBCurrency' => 'USD',
);
static $has_one = array(
'Summit' => 'Summit',
'SummitImage' => 'CloudImage'
);
function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Main', new HTMLEditorField('HeaderArea', 'Page Header Area'), 'Content');
$fields->addFieldToTab('Root.Main', new HTMLEditorField('Sidebar', 'Right Sidebar Content'));
$fields->addFieldToTab('Root.Main', new HTMLEditorField('HeadlineSponsors', 'Headline Sponsors'));
$summits = Summit::get();
$SummitDropDownField = new DropdownField("SummitID", "Summit", $summits->map("ID", "Name"));
$fields->addFieldToTab('Root.Main', $SummitDropDownField);
$SummitImageField = UploadField::create('SummitImage','Summit Image');
$fields->addFieldToTab('Root.Main', $SummitImageField);
//Google Conversion Tracking params
$fields->addFieldToTab("Root.GoogleConversionTracking",new TextField("GAConversionId","Conversion Id","994798451"));
$fields->addFieldToTab("Root.GoogleConversionTracking",new TextField("GAConversionLanguage","Conversion Language","en"));
$fields->addFieldToTab("Root.GoogleConversionTracking",new TextField("GAConversionFormat","Conversion Format","3"));
$fields->addFieldToTab("Root.GoogleConversionTracking",new ColorField("GAConversionColor","Conversion Color","ffffff"));
$fields->addFieldToTab("Root.GoogleConversionTracking",new TextField("GAConversionLabel","Conversion Label","IuM5CK3OzQYQ89at2gM"));
$fields->addFieldToTab("Root.GoogleConversionTracking",new TextField("GAConversionValue","Conversion Value","0"));
$fields->addFieldToTab("Root.GoogleConversionTracking",new CheckboxField("GARemarketingOnly","Remarketing Only"));
//Facebook Conversion Params
$fields->addFieldToTab("Root.FacebookConversionTracking",new TextField("FBPixelId","Pixel Id","6013247449963"));
$fields->addFieldToTab("Root.FacebookConversionTracking",new TextField("FBValue","Value","0.00"));
$fields->addFieldToTab("Root.FacebookConversionTracking",new TextField("FBCurrency","Currency","USD"));
return $fields;
}
}
class ConferencePage_Controller extends Page_Controller
{
/*
* Return google tracking script if ?order=complete query string param is present
* using settings of current conference page
*/
function GATrackingCode(){
$request = $this->request;
$order = $request->requestVar("order");
$tracking_code = '';
if(isset($order) && $order == "complete"){
//add GA tracking script
$page = ConferencePage::get()->byID($this->ID);
if($page && !empty($page->GAConversionId)
&& !empty($page->GAConversionLanguage)
&& !empty($page->GAConversionFormat)
&& !empty($page->GAConversionColor)
&& !empty($page->GAConversionLabel)){
$tracking_code = $this->renderWith("ConferencePage_GA",array(
"GA_Data"=> new ArrayData(array(
"GAConversionId" => $page->GAConversionId,
"GAConversionLanguage" => $page->GAConversionLanguage,
"GAConversionFormat" => $page->GAConversionFormat,
"GAConversionColor" => $page->GAConversionColor,
"GAConversionLabel" => $page->GAConversionLabel,
"GAConversionValue" => $page->GAConversionValue,
"GARemarketingOnly" => $page->GARemarketingOnly?"true":"false",
))
));
}
}
return $tracking_code;
}
function FBTrackingCode(){
$request = $this->request;
$order = $request->requestVar("order");
$tracking_code = '';
if(isset($order) && $order=="complete"){
//add FB tracking script
$page = ConferencePage::get()->byID($this->ID);
if($page && !empty($page->FBPixelId)
&& !empty($page->FBValue)
&& !empty($page->FBCurrency)
){
$tracking_code = $this->renderWith("ConferencePage_FB",array(
"FB_Data"=> new ArrayData(array(
"FBPixelId" => $page->FBPixelId,
"FBValue" => $page->FBValue,
"FBCurrency" => $page->FBCurrency,
))
));
}
}
return $tracking_code;
}
function init()
{
RSSFeed::linkToFeed($this->Link() . "rss", "RSS feed of the OpenStack Conference");
parent::init();
}
function rss()
{
$rss = new RSSFeed($this->Children(), $this->Link(), "OpenStack Event Updates RSS Feed", "This feed provides updates related to the OpenStack Spring 2012 Conference and Design Summit.", "Title", "Content");
$rss->outputToBrowser();
}
function TrackingLink()
{
// Get the tracking code from the session if one is set.
$source = Session::get('TrackingLinkSource');
// Now look to see if a tracking code was passed in via a URL param.
// This will override what's in the session if need be
$getVars = $this->request->getVars();
if (isset($getVars['source'])) {
$source = Convert::raw2sql($getVars['source']);
// Save the source id from the URL param into the session
Session::set('TrackingLinkSource', $source);
}
return $source;
}
function TrackingLinkScript()
{
$trackingLink = $this->TrackingLink();
if ($trackingLink) {
$script = <<< JS
jQuery(document).ready(function($){
$("a.tracking-link").attr("href", function(i, h) {
return h.replace('summithomepage','$trackingLink');
});
});
JS;
Requirements::customScript($script,'TrackingLinkScript');
}
}
public function NewsItems($num = 5)
{
return ConferenceNewsPage::get()->filter('ParentID',$this->ID)->sort('Created','DESC')->limit($num);
}
public function SubPages($num = 10)
{
return ConferenceSubPage::get()->filter('ParentID',$this->ID)->sort('Sort','ASC')->limit($num);
}
}