i-lateral /
silverstripe-gallery
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * A single page that can display many images as thumbnails. |
||
| 5 | * |
||
| 6 | * @package gallery |
||
| 7 | */ |
||
| 8 | class GalleryPage extends GalleryHub |
||
|
0 ignored issues
–
show
|
|||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var string |
||
| 12 | */ |
||
| 13 | private static $description = 'Display a "gallery" of images'; |
||
|
0 ignored issues
–
show
|
|||
| 14 | |||
| 15 | private static $icon = "gallery/images/gallery.png"; |
||
|
0 ignored issues
–
show
|
|||
| 16 | |||
| 17 | private static $db = array( |
||
|
0 ignored issues
–
show
|
|||
| 18 | "ImageWidth" => "Int", |
||
| 19 | "ImageHeight" => "Int", |
||
| 20 | "ImageResizeType" => "Enum(array('crop','pad','ratio','width','height'), 'ratio')" |
||
| 21 | ); |
||
| 22 | |||
| 23 | private static $defaults = array( |
||
|
0 ignored issues
–
show
|
|||
| 24 | "ImageWidth" => 950, |
||
| 25 | "ImageHeight" => 500, |
||
| 26 | "ShowSideBar" => 1 |
||
| 27 | ); |
||
| 28 | |||
| 29 | private static $many_many = array( |
||
|
0 ignored issues
–
show
|
|||
| 30 | 'Images' => 'Image' |
||
| 31 | ); |
||
| 32 | |||
| 33 | private static $many_many_extraFields = array( |
||
|
0 ignored issues
–
show
|
|||
| 34 | 'Images' => array('SortOrder' => 'Int') |
||
| 35 | ); |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Return sorted images |
||
| 39 | * |
||
| 40 | * @return ArrayList |
||
| 41 | */ |
||
| 42 | public function SortedImages() |
||
| 43 | { |
||
| 44 | return $this->Images()->Sort('SortOrder'); |
||
| 45 | } |
||
| 46 | |||
| 47 | public function getCMSFields() |
||
|
0 ignored issues
–
show
The return type could not be reliably inferred; please add a
@return annotation.
Our type inference engine in quite powerful, but sometimes the code does not
provide enough clues to go by. In these cases we request you to add a Loading history...
|
|||
| 48 | { |
||
| 49 | $self =& $this; |
||
| 50 | |||
| 51 | $this->beforeUpdateCMSFields(function ($fields) use ($self) { |
||
| 52 | if (!$self->canEdit()) { |
||
| 53 | return; |
||
| 54 | } |
||
| 55 | |||
| 56 | $fields->removeByName('HideDescription'); |
||
| 57 | |||
| 58 | $upload_folder = Controller::join_links( |
||
| 59 | "gallery", |
||
| 60 | $self->ID |
||
| 61 | ); |
||
| 62 | |||
| 63 | $fields->addFieldToTab( |
||
| 64 | "Root.Gallery", |
||
| 65 | SortableUploadField::create( |
||
| 66 | 'Images', |
||
| 67 | $this->fieldLabel('Images') |
||
| 68 | )->setFolderName($upload_folder) |
||
| 69 | ); |
||
| 70 | }); |
||
| 71 | |||
| 72 | return parent::getCMSFields(); |
||
| 73 | } |
||
| 74 | |||
| 75 | public function getSettingsFields() { |
||
|
0 ignored issues
–
show
The return type could not be reliably inferred; please add a
@return annotation.
Our type inference engine in quite powerful, but sometimes the code does not
provide enough clues to go by. In these cases we request you to add a Loading history...
|
|||
| 76 | $fields = parent::getSettingsFields(); |
||
| 77 | |||
| 78 | $fields->addFieldsToTab( |
||
| 79 | 'Root.Settings', |
||
| 80 | array( |
||
| 81 | NumericField::create("ImageWidth"), |
||
| 82 | NumericField::create("ImageHeight"), |
||
| 83 | DropdownField::create("ImageResizeType") |
||
| 84 | ->setSource($this->dbObject("ImageResizeType")->enumValues()) |
||
| 85 | ) |
||
| 86 | ); |
||
| 87 | |||
| 88 | return $fields; |
||
| 89 | } |
||
| 90 | |||
| 91 | public function onBeforeWrite() |
||
| 92 | { |
||
| 93 | parent::onBeforeWrite(); |
||
| 94 | |||
| 95 | // default settings (if not set) |
||
| 96 | $defaults = $this->config()->defaults; |
||
| 97 | $this->ImageWidth = ($this->ImageWidth) ? $this->ImageWidth : $defaults["ImageWidth"]; |
||
| 98 | $this->ImageHeight = ($this->ImageHeight) ? $this->ImageHeight : $defaults["ImageHeight"]; |
||
| 99 | } |
||
| 100 | |||
| 101 | } |
||
| 102 |
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.