Skip to content
This repository has been archived by the owner on Aug 10, 2018. It is now read-only.

Commit

Permalink
fix a bug in Thumbnail() where width would be passed in as a string, …
Browse files Browse the repository at this point in the history
…not an int. Document. Update CMS fields for the file to better split out the options
  • Loading branch information
James Ellis committed May 5, 2012
1 parent 1fd9e4e commit 668acd5
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions code/dataobjects/UploadAnythingFile.php
Expand Up @@ -158,15 +158,14 @@ public function Link() {
/**
* Thumbnail()
* @note helper method to thumb an image to a certain width or height
* @param $width_height string WIDTHxHEIGHT
* @param $width_height string WIDTHxHEIGHT e.g 400x300 or a WIDTH e.g 400 -- In templates only two arguments are allowed by SS if you call $Thumbnail
* @param $method one of the image thumbing methods supported
*/
public function Thumbnail($method, $width_height, $height = "") {

if($height != "" && is_int($width_height)) {
public function Thumbnail($method, $width_height, $height = 0) {
if(is_numeric($width_height)) {
//called from script
$width = $width_height;
} else if(!is_int($width_height) && strpos( $width_height, "x") !== FALSE) {
} else if(strpos( $width_height, "x") !== FALSE) {
//called from template
$parts = explode("x", $width_height);
$width = $height = 0;
Expand Down Expand Up @@ -354,17 +353,10 @@ public function getCMSFields() {
$fields->addFieldsToTab(
'Root.FileInformation',
array(
new LiteralField('FilePathField', "<p class=\"message\">Editing {$this->Name} - {$this->Filename}</p>"),
new TextField('Title', 'Title of File', $this->Title),
new TextField('CallToActionText', 'Call To Action Text (placed on button or link selected)', $this->CallToActionText),
new TreeDropdownField(
"InternalLinkID",
"Internal page link",
"SiteTree"
),
new TextField('ExternalURL', 'External link (e.g http://example.com/landing/page) - will override Internal Page Link', $this->ExternalURL),
new TextField('Caption', 'File Caption', $this->Caption),
new TextareaField('Description', 'File Description', 5, NULL, $this->Description),
new ImageField('AlternateImage', 'Alternate Image (optional)'),
)
);

Expand Down Expand Up @@ -408,10 +400,30 @@ public function getCMSFields() {
)
);

$fields->addFieldsToTab(
'Root.Linking',
array(
new TreeDropdownField(
"InternalLinkID",
"Internal page link",
"SiteTree"
),
new TextField('ExternalURL', 'External link (e.g http://example.com/landing/page) - will override Internal Page Link', $this->ExternalURL),
new TextField('CallToActionText', 'Call To Action Text (placed on button or link selected)', $this->CallToActionText),
)
);

$fields->addFieldsToTab(
'Root.TemplateOptions',
array(
new ImageField('AlternateImage', 'Alternate Image (optional)'),
)
);

$fields->addFieldsToTab(
'Root.Ownership',
array(
new DropDownField('OwnerID','File Owner', DataObject::get('Member')->map('ID','Name'), $this->OwnerID)
new DropDownField('OwnerID','Who owns this file?', DataObject::get('Member')->map('ID','Name'), $this->OwnerID)
)
);

Expand Down

0 comments on commit 668acd5

Please sign in to comment.