@@ -16,23 +16,23 @@ discard block |
||
| 16 | 16 | 'IsCached' => 'Boolean', |
| 17 | 17 | ); |
| 18 | 18 | |
| 19 | - /* |
|
| 19 | + /* |
|
| 20 | 20 | Add a Location tab containing the map |
| 21 | 21 | */ |
| 22 | - public function updateCMSFields(FieldList $fields) |
|
| 23 | - { |
|
| 24 | - $categoryfield = new DropdownField('AdvertCategoryID', 'Category', AdvertCategory::get()->sort('Title')->map('ID', 'Title')); |
|
| 25 | - $categoryfield->setEmptyString('(Select one)'); |
|
| 26 | - $fields->addFieldToTab('Root.AdvertCategory', $categoryfield); |
|
| 27 | - } |
|
| 22 | + public function updateCMSFields(FieldList $fields) |
|
| 23 | + { |
|
| 24 | + $categoryfield = new DropdownField('AdvertCategoryID', 'Category', AdvertCategory::get()->sort('Title')->map('ID', 'Title')); |
|
| 25 | + $categoryfield->setEmptyString('(Select one)'); |
|
| 26 | + $fields->addFieldToTab('Root.AdvertCategory', $categoryfield); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - /* |
|
| 29 | + /* |
|
| 30 | 30 | Prior to an item being saved, check for the category having being changed. If so we need to clear the category cache |
| 31 | 31 | for all items in the database, and cache this one. |
| 32 | 32 | */ |
| 33 | - public function onBeforeWrite() |
|
| 34 | - { |
|
| 35 | - $savedpage = SiteTree::get()->byID($this->owner->ID); |
|
| 33 | + public function onBeforeWrite() |
|
| 34 | + { |
|
| 35 | + $savedpage = SiteTree::get()->byID($this->owner->ID); |
|
| 36 | 36 | //error_log("Formerly saved category id = ".$savedpage->AdvertCategory()->Title); |
| 37 | 37 | //error_log("Category before save for page ".$this->owner->ID." is :".$this->owner->AdvertCategory()->Title); |
| 38 | 38 | if ($savedpage->AdvertCategoryID != $this->owner->AdvertCategoryID) { |
@@ -44,10 +44,10 @@ discard block |
||
| 44 | 44 | } else { |
| 45 | 45 | //error_log("CACHE CAN KEEP GOING"); |
| 46 | 46 | } |
| 47 | - parent::onBeforeWrite(); |
|
| 48 | - } |
|
| 47 | + parent::onBeforeWrite(); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /* |
|
| 50 | + /* |
|
| 51 | 51 | Get the advert category. Either use the cached advert category, or traverse the tree towards the root looking for it |
| 52 | 52 | */ |
| 53 | 53 | public function CalculateAdvertCategoryID() |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | { |
| 9 | 9 | public static $searchable_fields = array( |
| 10 | 10 | 'Title', |
| 11 | - ); |
|
| 11 | + ); |
|
| 12 | 12 | |
| 13 | 13 | public static $db = array( |
| 14 | 14 | // name of the layout type, e.g. 'main banner' or 'skyscraper' |
@@ -17,17 +17,17 @@ discard block |
||
| 17 | 17 | // whether or not ads are enabled |
| 18 | 18 | 'Width' => 'Int', |
| 19 | 19 | 'Height' => 'Int', |
| 20 | - ); |
|
| 20 | + ); |
|
| 21 | 21 | |
| 22 | 22 | public static $summary_fields = array( |
| 23 | 23 | 'Title' => 'Title', |
| 24 | 24 | 'Width' => 'Width', |
| 25 | 25 | 'Height' => 'Height', |
| 26 | - ); |
|
| 26 | + ); |
|
| 27 | 27 | |
| 28 | 28 | public static $has_many = array( |
| 29 | 29 | 'Adverts' => 'Advert', |
| 30 | - ); |
|
| 30 | + ); |
|
| 31 | 31 | |
| 32 | 32 | public function getCMSFields() |
| 33 | 33 | { |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | $fields->push(new TabSet('Root', $mainTab = new Tab('Main'))); |
| 38 | 38 | $mainTab->setTitle(_t('SiteTree.TABMAIN', 'Main')); |
| 39 | 39 | |
| 40 | - $fields->addFieldToTab('Root.Main', new TextField('Title', 'The name of the category')); |
|
| 40 | + $fields->addFieldToTab('Root.Main', new TextField('Title', 'The name of the category')); |
|
| 41 | 41 | $fields->addFieldToTab('Root.Main', new NumericField('Width', 'The width of the advert in pixels')); |
| 42 | 42 | $fields->addFieldToTab('Root.Main', new NumericField('Height', 'The height of the advert in pixels')); |
| 43 | 43 | |
@@ -8,11 +8,11 @@ discard block |
||
| 8 | 8 | { |
| 9 | 9 | public static $searchable_fields = array( |
| 10 | 10 | 'Title', |
| 11 | - ); |
|
| 11 | + ); |
|
| 12 | 12 | |
| 13 | 13 | public static $has_many = array( |
| 14 | 14 | 'Adverts' => 'Advert', |
| 15 | - ); |
|
| 15 | + ); |
|
| 16 | 16 | |
| 17 | 17 | public static $db = array( |
| 18 | 18 | // name of the category |
@@ -21,12 +21,12 @@ discard block |
||
| 21 | 21 | // whether or not ads are enabled |
| 22 | 22 | 'Enabled' => 'Boolean', |
| 23 | 23 | |
| 24 | - ); |
|
| 24 | + ); |
|
| 25 | 25 | |
| 26 | 26 | public static $summary_fields = array( |
| 27 | 27 | 'Title' => 'Title', |
| 28 | 28 | 'Enabled' => 'Enabled', |
| 29 | - ); |
|
| 29 | + ); |
|
| 30 | 30 | |
| 31 | 31 | public function getCMSFields() |
| 32 | 32 | { |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | $fields->push(new TabSet('Root', $mainTab = new Tab('Main'))); |
| 37 | 37 | $mainTab->setTitle(_t('SiteTree.TABMAIN', 'Main')); |
| 38 | 38 | |
| 39 | - $fields->addFieldToTab('Root.Main', new TextField('Title', 'The name of the category')); |
|
| 39 | + $fields->addFieldToTab('Root.Main', new TextField('Title', 'The name of the category')); |
|
| 40 | 40 | $fields->addFieldToTab('Root.Main', new CheckboxField('Enabled', 'Are adverts for this category enabled?')); |
| 41 | 41 | |
| 42 | 42 | return $fields; |
@@ -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; |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | $advert = Advert::get()->filter('DigitalSignature', $digsig)->first(); // should only be the one but make sure |
| 53 | 53 | if (!$advert) { |
| 54 | - $this->httpError(404, 'Advert "'.$digsig.'"" not found'); |
|
| 54 | + $this->httpError(404, 'Advert "' . $digsig . '"" not found'); |
|
| 55 | 55 | } else { |
| 56 | 56 | // record the click |
| 57 | 57 | $advert->Impressions = $advert->Impressions + 1; |
@@ -159,15 +159,15 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | // Normal operation: |
| 161 | 161 | $mimeType = HTTP::get_mime_type($file_name); |
| 162 | - header("Content-Type: {$mimeType}; name=\"".addslashes($file_name).'"'); |
|
| 163 | - header('Content-Disposition: attachment; filename='.addslashes($file_name)); |
|
| 162 | + header("Content-Type: {$mimeType}; name=\"" . addslashes($file_name) . '"'); |
|
| 163 | + header('Content-Disposition: attachment; filename=' . addslashes($file_name)); |
|
| 164 | 164 | header('Cache-Control: max-age=1, private'); |
| 165 | 165 | header("Content-Length: {$file_size}"); |
| 166 | 166 | header('Pragma: '); |
| 167 | 167 | |
| 168 | 168 | if (self::$use_x_sendfile) { |
| 169 | 169 | session_write_close(); |
| 170 | - header('X-Sendfile: '.$file_path); |
|
| 170 | + header('X-Sendfile: ' . $file_path); |
|
| 171 | 171 | exit(); |
| 172 | 172 | } elseif ($filePointer = @fopen($file_path, 'rb')) { |
| 173 | 173 | session_write_close(); |
@@ -5,7 +5,7 @@ |
||
| 5 | 5 | public static $db = array( |
| 6 | 6 | 'MpuAboveFoldPosition' => 'Int', |
| 7 | 7 | 'MpuBelowFoldPosition' => 'Int', |
| 8 | - ); |
|
| 8 | + ); |
|
| 9 | 9 | |
| 10 | 10 | public static $defaults = array( |
| 11 | 11 | 'MpuAboveFoldPosition' => '4', |
@@ -3,9 +3,9 @@ |
||
| 3 | 3 | class AdvertAdmin extends ModelAdmin |
| 4 | 4 | { |
| 5 | 5 | public static $managed_models = array( //since 2.3.2 |
| 6 | - 'Advert', 'AdvertCategory', 'AdvertLayoutType', |
|
| 7 | - ); |
|
| 6 | + 'Advert', 'AdvertCategory', 'AdvertLayoutType', |
|
| 7 | + ); |
|
| 8 | 8 | |
| 9 | 9 | public static $url_segment = 'adverts'; // will be linked as /admin/adverts |
| 10 | - public static $menu_title = 'Adverts'; |
|
| 10 | + public static $menu_title = 'Adverts'; |
|
| 11 | 11 | } |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | { |
| 8 | 8 | public static $searchable_fields = array( |
| 9 | 9 | 'WebsiteLink', |
| 10 | - ); |
|
| 10 | + ); |
|
| 11 | 11 | |
| 12 | 12 | public static $db = array( |
| 13 | 13 | // title to show in model admin |
@@ -33,13 +33,13 @@ discard block |
||
| 33 | 33 | // stats |
| 34 | 34 | 'Impressions' => 'Int', |
| 35 | 35 | 'Clickthroughs' => 'Int', |
| 36 | - ); |
|
| 36 | + ); |
|
| 37 | 37 | |
| 38 | 38 | public static $has_one = array( |
| 39 | 39 | 'AdvertImage' => 'Image', |
| 40 | 40 | 'AdvertCategory' => 'AdvertCategory', |
| 41 | 41 | 'AdvertLayoutType' => 'AdvertLayoutType', |
| 42 | - ); |
|
| 42 | + ); |
|
| 43 | 43 | |
| 44 | 44 | public static $summary_fields = array( |
| 45 | 45 | 'Title' => 'Title', |
@@ -47,9 +47,9 @@ discard block |
||
| 47 | 47 | 'AdvertLayoutType.Title', |
| 48 | 48 | 'StartDate' => 'StartDate', |
| 49 | 49 | 'FinishDate' => 'FinishDate', |
| 50 | - ); |
|
| 50 | + ); |
|
| 51 | 51 | |
| 52 | - // add an index in the db for the digital signature and date ranges |
|
| 52 | + // add an index in the db for the digital signature and date ranges |
|
| 53 | 53 | public static $indexes = array( |
| 54 | 54 | 'DigitalSignature' => true, |
| 55 | 55 | 'StartDate' => '(StartDate)', |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | { |
| 62 | 62 | Requirements::javascript('weboftalent-adverts/javascript/advertedit.js'); |
| 63 | 63 | |
| 64 | - // throw away the scaffolding and start afresh |
|
| 64 | + // throw away the scaffolding and start afresh |
|
| 65 | 65 | $fields = new FieldList(); |
| 66 | 66 | |
| 67 | 67 | // add a main tab |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | // a Javascript toggle on this field displays either the adbroker text field, or an image with URL |
| 76 | 76 | $fields->addFieldToTab('Root.Main', new DropdownField('AdvertSource', 'The type of advert', |
| 77 | 77 | singleton('Advert')->dbObject('AdvertSource')->enumValues() |
| 78 | - )); |
|
| 78 | + )); |
|
| 79 | 79 | |
| 80 | 80 | if ($this->ID == 0) { |
| 81 | 81 | $html = '<div class="field text">An image can be uploaded after the advert is saved for the first time</div>'; |
@@ -119,21 +119,21 @@ discard block |
||
| 119 | 119 | parent::onBeforeWrite(); |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - /* |
|
| 122 | + /* |
|
| 123 | 123 | Calculate a digital signature from several of the fields |
| 124 | 124 | */ |
| 125 | - public function CalculateDigitalSignature() |
|
| 126 | - { |
|
| 127 | - //error_log("Calculating dig sig"); |
|
| 125 | + public function CalculateDigitalSignature() |
|
| 126 | + { |
|
| 127 | + //error_log("Calculating dig sig"); |
|
| 128 | 128 | /* because we save the impression counter on every rendition this cannot include |
| 129 | 129 | - number of impressions |
| 130 | 130 | - last edited |
| 131 | 131 | Otherwise the clickthrough will fail |
| 132 | 132 | */ |
| 133 | 133 | $data = $this->ID.'_'.$this->AdvertCategory()->Title.'_'.$this->AdvertLayoutType()->Title.'_'.$this->AdbrokerJavascript; |
| 134 | - $data .= '_'.$this->StartDate.'_'.$this->FinishDate.'_'.$this->ClickThroughs.'_advert'; |
|
| 135 | - $hashed = hash('sha512', $data); |
|
| 134 | + $data .= '_'.$this->StartDate.'_'.$this->FinishDate.'_'.$this->ClickThroughs.'_advert'; |
|
| 135 | + $hashed = hash('sha512', $data); |
|
| 136 | 136 | //error_log("HASH CREATED:".$hashed); |
| 137 | 137 | return $hashed; |
| 138 | - } |
|
| 138 | + } |
|
| 139 | 139 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | $mainTab->setTitle(_t('SiteTree.TABMAIN', 'Main')); |
| 70 | 70 | |
| 71 | 71 | // human readable title |
| 72 | - $fields->addFieldToTab('Root.Main', new TextField('Title', |
|
| 72 | + $fields->addFieldToTab('Root.Main', new TextField('Title', |
|
| 73 | 73 | 'Human readable title for the advert')); |
| 74 | 74 | |
| 75 | 75 | // a Javascript toggle on this field displays either the adbroker text field, or an image with URL |
@@ -89,10 +89,10 @@ discard block |
||
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | // quick tags, faster than the grid editor - these are processed prior to save to create/assign tags |
| 92 | - $fields->addFieldToTab('Root.Main', new TextField('WebsiteLink', |
|
| 92 | + $fields->addFieldToTab('Root.Main', new TextField('WebsiteLink', |
|
| 93 | 93 | 'The URL that will be shown when the advert image is clicked')); |
| 94 | 94 | |
| 95 | - $fields->addFieldToTab('Root.Main', new TextareaField('AdbrokerJavascript', |
|
| 95 | + $fields->addFieldToTab('Root.Main', new TextareaField('AdbrokerJavascript', |
|
| 96 | 96 | 'JavaScript provided by the adbroker')); |
| 97 | 97 | |
| 98 | 98 | $fields->addFieldToTab('Root.Main', $sdf = new DateField('StartDate', 'The date the advert becomes active')); |
@@ -130,8 +130,8 @@ discard block |
||
| 130 | 130 | - last edited |
| 131 | 131 | Otherwise the clickthrough will fail |
| 132 | 132 | */ |
| 133 | - $data = $this->ID.'_'.$this->AdvertCategory()->Title.'_'.$this->AdvertLayoutType()->Title.'_'.$this->AdbrokerJavascript; |
|
| 134 | - $data .= '_'.$this->StartDate.'_'.$this->FinishDate.'_'.$this->ClickThroughs.'_advert'; |
|
| 133 | + $data = $this->ID . '_' . $this->AdvertCategory()->Title . '_' . $this->AdvertLayoutType()->Title . '_' . $this->AdbrokerJavascript; |
|
| 134 | + $data .= '_' . $this->StartDate . '_' . $this->FinishDate . '_' . $this->ClickThroughs . '_advert'; |
|
| 135 | 135 | $hashed = hash('sha512', $data); |
| 136 | 136 | //error_log("HASH CREATED:".$hashed); |
| 137 | 137 | return $hashed; |
@@ -78,7 +78,7 @@ |
||
| 78 | 78 | 'Adverts' => $adverts, |
| 79 | 79 | 'Advert' => $firstad, |
| 80 | 80 | 'CacheKey' => $cachekey, |
| 81 | - )); |
|
| 81 | + )); |
|
| 82 | 82 | |
| 83 | 83 | return $forTemplate->renderWith($template); |
| 84 | 84 | } else { |
@@ -47,7 +47,7 @@ |
||
| 47 | 47 | $where = "AdvertLayoutType.Title = '$adverttype'"; |
| 48 | 48 | |
| 49 | 49 | if (isset($advertcategory)) { |
| 50 | - $where .= ' AND Advert.AdvertCategoryID = '.$advertcategoryid; |
|
| 50 | + $where .= ' AND Advert.AdvertCategoryID = ' . $advertcategoryid; |
|
| 51 | 51 | $where .= ' AND (StartDate IS NULL OR !StartDate OR StartDate < NOW()) AND (FinishDate IS NULL OR !FinishDate OR NOW() < FinishDate)'; |
| 52 | 52 | |
| 53 | 53 | if (count(self::$advertsalreadyserved) > 0) { |
@@ -1,10 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Handles requests for secure files by url. |
|
| 4 | - * |
|
| 5 | - * @author Hamish Campbell <[email protected]> |
|
| 6 | - * @copyright copyright (c) 2010, Hamish Campbell |
|
| 7 | - */ |
|
| 3 | + * Handles requests for secure files by url. |
|
| 4 | + * |
|
| 5 | + * @author Hamish Campbell <[email protected]> |
|
| 6 | + * @copyright copyright (c) 2010, Hamish Campbell |
|
| 7 | + */ |
|
| 8 | 8 | class SecureFileController extends Controller implements PermissionProvider |
| 9 | 9 | { |
| 10 | 10 | /** |
@@ -214,15 +214,15 @@ |
||
| 214 | 214 | |
| 215 | 215 | // Normal operation: |
| 216 | 216 | $mimeType = HTTP::getMimeType($file_name); |
| 217 | - header("Content-Type: {$mimeType}; name=\"".addslashes($file_name).'"'); |
|
| 218 | - header('Content-Disposition: attachment; filename='.addslashes($file_name)); |
|
| 217 | + header("Content-Type: {$mimeType}; name=\"" . addslashes($file_name) . '"'); |
|
| 218 | + header('Content-Disposition: attachment; filename=' . addslashes($file_name)); |
|
| 219 | 219 | header('Cache-Control: max-age=1, private'); |
| 220 | 220 | header("Content-Length: {$file_size}"); |
| 221 | 221 | header('Pragma: '); |
| 222 | 222 | |
| 223 | 223 | if (self::$use_x_sendfile) { |
| 224 | 224 | session_write_close(); |
| 225 | - header('X-Sendfile: '.$file_path); |
|
| 225 | + header('X-Sendfile: ' . $file_path); |
|
| 226 | 226 | exit(); |
| 227 | 227 | } elseif ($filePointer = @fopen($file_path, 'rb')) { |
| 228 | 228 | session_write_close(); |