@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | * @param int $kilobytes |
81 | 81 | */ |
82 | 82 | static function set_chunk_size($kilobytes) { |
83 | - $kilobytes = max(0, (int)$kilobytes); |
|
84 | - if(!$kilobytes) user_error("Invalid download chunk size", E_USER_ERROR); |
|
83 | + $kilobytes = max(0, (int) $kilobytes); |
|
84 | + if (!$kilobytes) user_error("Invalid download chunk size", E_USER_ERROR); |
|
85 | 85 | self::$chunck_size_kb = $kilobytes; |
86 | 86 | } |
87 | 87 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $file_path = Director::makeRelative($url); |
131 | 131 | $file = File::find($file_path); |
132 | 132 | |
133 | - if($file instanceof File) { |
|
133 | + if ($file instanceof File) { |
|
134 | 134 | if ($file->canView()) { |
135 | 135 | $file->extend('onAccessGranted'); |
136 | 136 | return $this->fileFound($file, $file_path); |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @return HTTPResponse |
151 | 151 | */ |
152 | 152 | function fileNotFound($body = "") { |
153 | - if(ClassInfo::exists('SS_HTTPResponse')) { |
|
153 | + if (ClassInfo::exists('SS_HTTPResponse')) { |
|
154 | 154 | return new SS_HTTPResponse($body, 404); |
155 | 155 | } else { |
156 | 156 | return new HTTPResponse($body, 404); |
@@ -182,8 +182,8 @@ discard block |
||
182 | 182 | $file_size = filesize($file_path); |
183 | 183 | |
184 | 184 | // Testing mode - return an HTTPResponse |
185 | - if(self::$use_ss_sendfile) { |
|
186 | - if(ClassInfo::exists('SS_HTTPRequest')) { |
|
185 | + if (self::$use_ss_sendfile) { |
|
186 | + if (ClassInfo::exists('SS_HTTPRequest')) { |
|
187 | 187 | return SS_HTTPRequest::send_file(file_get_contents($file_path), $file_name); |
188 | 188 | } else { |
189 | 189 | return HTTPRequest::send_file(file_get_contents($file_path), $file_name); |
@@ -198,15 +198,15 @@ discard block |
||
198 | 198 | header("Content-Length: {$file_size}"); |
199 | 199 | header("Pragma: "); |
200 | 200 | |
201 | - if(self::$use_x_sendfile) { |
|
201 | + if (self::$use_x_sendfile) { |
|
202 | 202 | session_write_close(); |
203 | - header('X-Sendfile: '.$file_path); |
|
203 | + header('X-Sendfile: ' . $file_path); |
|
204 | 204 | exit(); |
205 | - } elseif($filePointer = @fopen($file_path, 'rb')) { |
|
205 | + } elseif ($filePointer = @fopen($file_path, 'rb')) { |
|
206 | 206 | session_write_close(); |
207 | 207 | $this->flush(); |
208 | 208 | // Push the file while not EOF and connection exists |
209 | - while(!feof($filePointer) && !connection_aborted()) { |
|
209 | + while (!feof($filePointer) && !connection_aborted()) { |
|
210 | 210 | print(fread($filePointer, 1024 * self::$chunck_size_kb)); |
211 | 211 | $this->flush(); |
212 | 212 | } |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | * @see http://nz.php.net/manual/en/function.flush.php#93531 |
224 | 224 | */ |
225 | 225 | function flush() { |
226 | - if(ob_get_length()) { |
|
226 | + if (ob_get_length()) { |
|
227 | 227 | @ob_flush(); |
228 | 228 | @flush(); |
229 | 229 | @ob_end_flush(); |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $advert = Advert::get()->filter('DigitalSignature', $digsig)->first(); // should only be the one but make sure |
34 | 34 | |
35 | 35 | if (!$advert) { |
36 | - $this->httpError(404, 'Advert "'.$digsig.'"" not found'); |
|
36 | + $this->httpError(404, 'Advert "' . $digsig . '"" not found'); |
|
37 | 37 | } else { |
38 | 38 | // record the click |
39 | 39 | $advert->Clickthroughs = $advert->Clickthroughs + 1; |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | $advert = Advert::get()->filter('DigitalSignature', $digsig)->first(); // should only be the one but make sure |
55 | 55 | if (!$advert) { |
56 | - $this->httpError(404, 'Advert "'.$digsig.'"" not found'); |
|
56 | + $this->httpError(404, 'Advert "' . $digsig . '"" not found'); |
|
57 | 57 | } else { |
58 | 58 | // record the click |
59 | 59 | $advert->Impressions = $advert->Impressions + 1; |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | * @param int $kilobytes |
109 | 109 | */ |
110 | 110 | static function set_chunk_size($kilobytes) { |
111 | - $kilobytes = max(0, (int)$kilobytes); |
|
112 | - if(!$kilobytes) user_error("Invalid download chunk size", E_USER_ERROR); |
|
111 | + $kilobytes = max(0, (int) $kilobytes); |
|
112 | + if (!$kilobytes) user_error("Invalid download chunk size", E_USER_ERROR); |
|
113 | 113 | self::$chunck_size_kb = $kilobytes; |
114 | 114 | } |
115 | 115 | |
@@ -147,8 +147,8 @@ discard block |
||
147 | 147 | $file_size = filesize($file_path); |
148 | 148 | |
149 | 149 | // Testing mode - return an HTTPResponse |
150 | - if(self::$use_ss_sendfile) { |
|
151 | - if(ClassInfo::exists('SS_HTTPRequest')) { |
|
150 | + if (self::$use_ss_sendfile) { |
|
151 | + if (ClassInfo::exists('SS_HTTPRequest')) { |
|
152 | 152 | return SS_HTTPRequest::send_file(file_get_contents($file_path), $file_name); |
153 | 153 | } else { |
154 | 154 | return HTTPRequest::send_file(file_get_contents($file_path), $file_name); |
@@ -163,15 +163,15 @@ discard block |
||
163 | 163 | header("Content-Length: {$file_size}"); |
164 | 164 | header("Pragma: "); |
165 | 165 | |
166 | - if(self::$use_x_sendfile) { |
|
166 | + if (self::$use_x_sendfile) { |
|
167 | 167 | session_write_close(); |
168 | - header('X-Sendfile: '.$file_path); |
|
168 | + header('X-Sendfile: ' . $file_path); |
|
169 | 169 | exit(); |
170 | - } elseif($filePointer = @fopen($file_path, 'rb')) { |
|
170 | + } elseif ($filePointer = @fopen($file_path, 'rb')) { |
|
171 | 171 | session_write_close(); |
172 | 172 | $this->flush(); |
173 | 173 | // Push the file while not EOF and connection exists |
174 | - while(!feof($filePointer) && !connection_aborted()) { |
|
174 | + while (!feof($filePointer) && !connection_aborted()) { |
|
175 | 175 | //error_log("Sending $chunck_size_kb kb"); |
176 | 176 | print(fread($filePointer, 1024 * self::$chunck_size_kb)); |
177 | 177 | $this->flush(); |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | * @see http://nz.php.net/manual/en/function.flush.php#93531 |
190 | 190 | */ |
191 | 191 | function flush() { |
192 | - if(ob_get_length()) { |
|
192 | + if (ob_get_length()) { |
|
193 | 193 | @ob_flush(); |
194 | 194 | @flush(); |
195 | 195 | @ob_end_flush(); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | |
87 | 87 | // human readable title |
88 | - $fields->addFieldToTab('Root.Main', new TextField('Title', |
|
88 | + $fields->addFieldToTab('Root.Main', new TextField('Title', |
|
89 | 89 | 'Human readable title for the advert')); |
90 | 90 | |
91 | 91 | // a Javascript toggle on this field displays either the adbroker text field, or an image with URL |
@@ -107,10 +107,10 @@ discard block |
||
107 | 107 | |
108 | 108 | |
109 | 109 | // quick tags, faster than the grid editor - these are processed prior to save to create/assign tags |
110 | - $fields->addFieldToTab('Root.Main', new TextField('WebsiteLink', |
|
110 | + $fields->addFieldToTab('Root.Main', new TextField('WebsiteLink', |
|
111 | 111 | 'The URL that will be shown when the advert image is clicked')); |
112 | 112 | |
113 | - $fields->addFieldToTab('Root.Main', new TextareaField('AdbrokerJavascript', |
|
113 | + $fields->addFieldToTab('Root.Main', new TextareaField('AdbrokerJavascript', |
|
114 | 114 | 'JavaScript provided by the adbroker')); |
115 | 115 | |
116 | 116 | $fields->addFieldToTab('Root.Main', $sdf = new DateField('StartDate', 'The date the advert becomes active')); |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | - last edited |
151 | 151 | Otherwise the clickthrough will fail |
152 | 152 | */ |
153 | - $data = $this->ID.'_'.$this->AdvertCategory()->Title.'_'.$this->AdvertLayoutType()->Title.'_'.$this->AdbrokerJavascript; |
|
154 | - $data .= '_'.$this->StartDate.'_'.$this->FinishDate.'_'.$this->ClickThroughs.'_advert'; |
|
153 | + $data = $this->ID . '_' . $this->AdvertCategory()->Title . '_' . $this->AdvertLayoutType()->Title . '_' . $this->AdbrokerJavascript; |
|
154 | + $data .= '_' . $this->StartDate . '_' . $this->FinishDate . '_' . $this->ClickThroughs . '_advert'; |
|
155 | 155 | $hashed = hash('sha512', $data); |
156 | 156 | //error_log("HASH CREATED:".$hashed); |
157 | 157 | return $hashed; |
@@ -29,7 +29,7 @@ |
||
29 | 29 | } |
30 | 30 | |
31 | 31 | public function sourceRecords($params = null) { |
32 | - return DataList::create('Advert');//->limit(10); |
|
32 | + return DataList::create('Advert'); //->limit(10); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 |
@@ -43,13 +43,13 @@ |
||
43 | 43 | $fields = new FieldList(); |
44 | 44 | |
45 | 45 | // add a tab |
46 | - $fields->push( new TabSet( "Root", $mainTab = new Tab( "Main" ) ) ); |
|
47 | - $mainTab->setTitle( _t( 'SiteTree.TABMAIN', "Main" ) ); |
|
46 | + $fields->push(new TabSet("Root", $mainTab = new Tab("Main"))); |
|
47 | + $mainTab->setTitle(_t('SiteTree.TABMAIN', "Main")); |
|
48 | 48 | |
49 | 49 | |
50 | - $fields->addFieldToTab( 'Root.Main', new TextField( 'Title', 'The name of the category') ); |
|
51 | - $fields->addFieldToTab( 'Root.Main', new NumericField( 'Width', 'The width of the advert in pixels' ) ); |
|
52 | - $fields->addFieldToTab( 'Root.Main', new NumericField( 'Height', 'The height of the advert in pixels' ) ); |
|
50 | + $fields->addFieldToTab('Root.Main', new TextField('Title', 'The name of the category')); |
|
51 | + $fields->addFieldToTab('Root.Main', new NumericField('Width', 'The width of the advert in pixels')); |
|
52 | + $fields->addFieldToTab('Root.Main', new NumericField('Height', 'The height of the advert in pixels')); |
|
53 | 53 | |
54 | 54 | return $fields; |
55 | 55 | } |
@@ -3,7 +3,7 @@ |
||
3 | 3 | class AdvertAdmin extends ModelAdmin { |
4 | 4 | |
5 | 5 | public static $managed_models = array( //since 2.3.2 |
6 | - 'Advert','AdvertCategory','AdvertLayoutType' |
|
6 | + 'Advert', 'AdvertCategory', 'AdvertLayoutType' |
|
7 | 7 | ); |
8 | 8 | |
9 | 9 | static $url_segment = 'adverts'; // will be linked as /admin/adverts |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | @param $numberofads - the number of adverts to search for. Normally 1 but skyscraper needs 2 |
23 | 23 | @param $showonajax - set this to false to hide adverts on ajax |
24 | 24 | */ |
25 | - function RenderAdvert($cachekey,$adverttype,$template='InlineAdvert', $numberofads = 1, $showonajax = true) { |
|
25 | + function RenderAdvert($cachekey, $adverttype, $template = 'InlineAdvert', $numberofads = 1, $showonajax = true) { |
|
26 | 26 | // If we are using ajax and showonajax is set to false, return no ad |
27 | 27 | if (Director::is_ajax()) { |
28 | 28 | if ($showonajax !== true) { |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | if (isset($cachedcategories[$advertcategoryid])) { |
37 | 37 | $advertcategory = $cachedcategories[$advertcategoryid]; |
38 | 38 | } |
39 | - if (!isset($advertcategory) ){ |
|
39 | + if (!isset($advertcategory)) { |
|
40 | 40 | $advertcategory = AdvertCategory::get()->byID($advertcategoryid); |
41 | 41 | $cachedcategories[$advertcategoryid] = $advertcategory; |
42 | 42 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | $where = "AdvertLayoutType.Title = '$adverttype'"; |
47 | 47 | |
48 | 48 | if (isset($advertcategory)) { |
49 | - $where .= ' AND Advert.AdvertCategoryID = '.$advertcategoryid; |
|
49 | + $where .= ' AND Advert.AdvertCategoryID = ' . $advertcategoryid; |
|
50 | 50 | $where .= ' AND (StartDate IS NULL OR !StartDate OR StartDate < NOW()) AND (FinishDate IS NULL OR !FinishDate OR NOW() < FinishDate)'; |
51 | 51 | |
52 | 52 | if (count(self::$advertsalreadyserved) > 0) { |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | /* |
20 | 20 | Add a Location tab containing the map |
21 | 21 | */ |
22 | - public function updateCMSFields( FieldList $fields ) { |
|
22 | + public function updateCMSFields(FieldList $fields) { |
|
23 | 23 | $categoryfield = new DropdownField('AdvertCategoryID', 'Category', AdvertCategory::get()->sort('Title')->map('ID', 'Title')); |
24 | 24 | $categoryfield->setEmptyString('(Select one)'); |
25 | - $fields->addFieldToTab( "Root.AdvertCategory", $categoryfield); |
|
25 | + $fields->addFieldToTab("Root.AdvertCategory", $categoryfield); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /* |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | // if the record is not marked as cached, see if it has a category |
58 | 58 | if (!$this->owner->IsCached) { |
59 | - if($this->owner->AdvertCategoryID > 0) { |
|
59 | + if ($this->owner->AdvertCategoryID > 0) { |
|
60 | 60 | $this->owner->CachedAdvertCategoryID = $this->owner->AdvertCategoryID; |
61 | 61 | $this->owner->IsCached = true; |
62 | 62 | $this->owner->write; |
@@ -43,12 +43,12 @@ |
||
43 | 43 | $fields = new FieldList(); |
44 | 44 | |
45 | 45 | // add a tab |
46 | - $fields->push( new TabSet( "Root", $mainTab = new Tab( "Main" ) ) ); |
|
47 | - $mainTab->setTitle( _t( 'SiteTree.TABMAIN', "Main" ) ); |
|
46 | + $fields->push(new TabSet("Root", $mainTab = new Tab("Main"))); |
|
47 | + $mainTab->setTitle(_t('SiteTree.TABMAIN', "Main")); |
|
48 | 48 | |
49 | 49 | |
50 | - $fields->addFieldToTab( 'Root.Main', new TextField( 'Title', 'The name of the category') ); |
|
51 | - $fields->addFieldToTab( 'Root.Main', new CheckboxField( 'Enabled', 'Are adverts for this category enabled?' ) ); |
|
50 | + $fields->addFieldToTab('Root.Main', new TextField('Title', 'The name of the category')); |
|
51 | + $fields->addFieldToTab('Root.Main', new CheckboxField('Enabled', 'Are adverts for this category enabled?')); |
|
52 | 52 | |
53 | 53 | return $fields; |
54 | 54 | } |