Issues (24)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

code/model/SilverstripeColumnsPageExtension.php (15 issues)

Upgrade to new PHP Analysis Engine

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
 *@author nicolaas [at] sunnysideup.co.nz
5
 *
6
 *
7
 **/
8
9
class SilverstripeColumnsPageExtension extends DataExtension
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
10
{
11
    private static $db = [
0 ignored issues
show
The property $db is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
12
        'Summary' => 'HTMLVarchar(255)',
13
        'DefaultSidebarContent' => 'HTMLText'
14
    ];
15
16
    private static $has_one = [
0 ignored issues
show
The property $has_one is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
17
        'SummaryImage' => 'Image',
18
        'SidebarImage' => 'Image'
19
    ];
20
21
    private static $casting = [
0 ignored issues
show
The property $casting is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
22
        'MyDefaultSidebarContent' => 'HTMLText',
23
        'FullWidthContent' => 'HTMLText',
24
        'SummaryContent' => 'HTMLText'
25
    ];
26
27
    private static $field_labels = [
0 ignored issues
show
The property $field_labels is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
28
        'Summary' => 'Page Summary',
29
        'DefaultSidebarContent' => 'Sidebar content',
30
        'SummaryImage' => 'Image for Summaries',
31
        'SidebarImage' => 'Sidebar Image'
32
    ];
33
34
    private static $field_labels_right = [
0 ignored issues
show
The property $field_labels_right is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
35
        'Summary' => 'A summary of the page for use on other pages.',
36
        'DefaultSidebarContent' => 'The sidebar show up to the right of the main content. It is usually for something like DID YOU KNOW? or CONTACT DETAILS.',
37
        'SummaryImage' => 'Image used to show a link to this page together with the summary of the page provided.',
38
        'SidebarImage' => 'Image to show up in the sidebar instead of content.'
39
    ];
40
41
    public function updateCMSFields(FieldList $fields)
42
    {
43
        $fieldLabels = $this->owner->FieldLabels();
44
        $fieldLabelsRight = Config::inst()->get('SilverstripeColumnsPageExtension', 'field_labels_right');
45
        $tabTitleSummary = _t('SilverstripeColumnsPageExtension.SUMMARY_TAB', 'Summary');
46
        $tabTitleContent = _t('SilverstripeColumnsPageExtension.ADDITIONAL_CONTENT_TAB', 'MoreContent');
47 View Code Duplication
        if ($this->owner->UseSummaries()) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
            $fields->addFieldsToTab(
49
            'Root.' . $tabTitleSummary,
50
            [
51
                HTMLEditorField::create(
52
                    'Summary',
53
                    $fieldLabels['Summary']
54
                )->setRows(3)
55
                ->setRightTitle($fieldLabelsRight['Summary']),
56
                UploadField::create(
57
                    'SummaryImage',
58
                    $fieldLabels['SummaryImage']
59
                )->setRightTitle($fieldLabelsRight['SummaryImage'])
60
            ]
61
        );
62
        }
63 View Code Duplication
        if ($this->owner->UseDefaultSidebarContent()) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
64
            $fields->addFieldsToTab(
65
                'Root.' . $tabTitleContent,
66
                [
67
                    UploadField::create(
68
                        'SidebarImage',
69
                        $fieldLabels['SidebarImage']
70
                    )->setRightTitle($fieldLabelsRight['SidebarImage']),
71
                    HTMLEditorField::create(
72
                        'DefaultSidebarContent',
73
                        $fieldLabels['DefaultSidebarContent']
74
                    )->setRightTitle($fieldLabelsRight['DefaultSidebarContent'])
75
                ]
76
            );
77
        }
78
79
        return $fields;
80
    }
81
82
83
84
    /**
85
     * @return boolean
86
     */
87
    public function UseDefaultSideBarContent()
88
    {
89
        if ($this->owner->hasMethod('UseDefaultSideBarContentOverloaded')) {
90
            $v = $this->owner->UseDefaultSideBarContentOverloaded();
91
            if ($v !== null) {
92
                return $v;
93
            }
94
        }
95
96
        return false;
97
    }
98
99
100
    /**
101
     * @return boolean
102
     */
103
    public function UseSummaries()
104
    {
105
        if ($this->owner->hasMethod('UseSummariesOverloaded')) {
106
            $v = $this->owner->UseSummariesOverloaded();
107
            if ($v !== null) {
108
                return $v;
109
            }
110
        }
111
112
        return false;
113
    }
114
115
    /**
116
     * @return Image | null
117
     */
118
    public function MySidebarImage()
119
    {
120
        if ($this->owner->hasMethod('MySidebarImageOverloaded')) {
121
            $v = $this->owner->MySidebarImageOverloaded();
122
            if ($v !== null) {
123
                return $v;
124
            }
125
        }
126
127
        if ($this->owner->SidebarImageID) {
128
            $image = $this->owner->SidebarImage();
129
            if ($image && $image->exists()) {
130
                return $image;
131
            }
132
        }
133
        $parent = $this->owner->Parent();
134
        if ($parent && $parent->exists() && $parent instanceof SiteTree) {
135
            return $parent->MySidebarImage();
136
        }
137
138
        return null;
139
    }
140
141
    /**
142
     *
143
     * @return string (HTML)
144
     */
145 View Code Duplication
    public function getMyDefaultSidebarContent()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
146
    {
147
        if ($this->owner->hasMethod('MyDefaultSidebarContentOverloaded')) {
148
            $v = $this->owner->MyDefaultSidebarContentOverloaded();
149
            if ($v !== null) {
150
                return $v;
151
            }
152
        }
153
        return $this->owner->DefaultSidebarContent;
154
    }
155
156
    /**
157
     *
158
     * @return string (HTML)
159
     */
160 View Code Duplication
    public function getFullWidthContent()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
161
    {
162
        if ($this->owner->hasMethod('FullWidthContentOverloaded')) {
163
            $v = $this->owner->FullWidthContentOverloaded();
164
            if ($v !== null) {
165
                return $v;
166
            }
167
        }
168
        return $this->owner->renderWith('FullWidthContent');
169
    }
170
171
    /**
172
     *
173
     * @return string (HTML)
174
     */
175 View Code Duplication
    public function getSummaryContent()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
176
    {
177
        if ($this->owner->hasMethod('SummaryContentOverloaded')) {
178
            $v = $this->owner->SummaryContentOverloaded();
179
            if ($v !== null) {
180
                return $v;
181
            }
182
        }
183
        return $this->owner->renderWith('SummaryContent');
184
    }
185
186
    private static $_children_show_in_menu = [];
187
188
    private $showMenuItemsFor = null;
189
190
    public function setShowMenuItemsFor($showMenuItemsFor)
191
    {
192
        $showMenuItemsFor = intval($showMenuItemsFor);
193
        $this->showMenuItemsFor = $showMenuItemsFor;
194
    }
195
196
    public function ChildrenShowInMenu($root = false)
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 @return annotation as described here.

Loading history...
197
    {
198
        $key = $this->owner->ID. '_'.($root ? 'true' : 'false');
199
        if (!isset(self::$_children_show_in_menu[$key])) {
200
            if ($this->owner->hasMethod('ChildrenShowInMenuOverloaded')) {
201
                $v = $this->owner->ChildrenShowInMenuOverloaded();
202
                if ($v instanceof ArrayList) {
203
                    self::$_children_show_in_menu[$key] = $v;
204
                }
205
            } else {
206
                if ($root) {
207
                    $list = Page::get()->filter(['ShowInMenus' => 1, 'ParentID' => 0]);
208
                    foreach ($list as $page) {
209
                        if (! $page->canView()) {
210
                            $list = $list->exclude(['ID' => $page->ID]);
211
                        }
212
                    }
213
                } else {
214
                    $list = $this->owner->Children();
215
                    foreach ($list as $page) {
216
                        if (! $page->ShowInMenus ) {
217
                            $list = $list->exclude(['ID' => $page->ID]);
218
                        }
219
                    }
220
                }
221
                self::$_children_show_in_menu[$key] = $list;
222
            }
223
        }
224
        return self::$_children_show_in_menu[$key];
225
    }
226
227
    public function MyMenuItems()
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 @return annotation as described here.

Loading history...
228
    {
229
        if ($this->owner->hasMethod('MyMenuItemsOverloaded')) {
230
            $v = $this->owner->MyMenuItemsOverloaded();
231
            if ($v !== null) {
232
                return $v;
233
            }
234
        }
235
        //first stop: children ...
236
        $parent = $this->owner;
237
        $dataSet = false;
238
        if ($this->showMenuItemsFor !== null) {
239
            if ($this->showMenuItemsFor) {
240
                $page = Page::get()->byID($this->showMenuItemsFor);
241
                $dataSet = $page->ChildrenShowInMenu();
242
            } else {
243
                $dataSet = $this->ChildrenShowInMenu(true);
244
            }
245
        } else {
246
            $isHomePage = $this->owner->URLSegment === Config::inst()->get('RootURLController', 'default_homepage_link');
247
            while ($parent && $dataSet === false) {
248
                $dataSet = $parent->ChildrenShowInMenu($isHomePage);
249
                if ($dataSet->count() === 0) {
250
                    $dataSet = false;
251
                }
252
                if ($dataSet === false) {
253
                    $parent = Page::get()->byID($parent->ParentID);
254
                }
255
            }
256
            if ($dataSet === false) {
257
                $dataSet = $this->ChildrenShowInMenu(true);
258
            }
259
        }
260
261
        return $dataSet;
262
    }
263
264
    public function MyMenuItemsParentPage()
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 @return annotation as described here.

Loading history...
265
    {
266
        $children = $this->MyMenuItems();
267
        if ($children) {
268
            if ($child = $children->first()) {
269
                $page = Page::get()->byID($child->ParentID);
270
                if ($page && $page->ShowInMenus && $page->canView()) {
271
                    return $page;
272
                }
273
            }
274
        }
275
    }
276
277
    public function MyMenuItemsParentLink()
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 @return annotation as described here.

Loading history...
278
    {
279
        $parent = $this->MyMenuItemsParentPage();
280
        if ($parent) {
281
            return $parent->MyMenuItemsMenuLink($parent->ParentID);
282
        }
283
        return $this->MyMenuItemsMenuLink(0);
284
    }
285
286
    public function MyMenuItemsMenuLink($id = null)
287
    {
288
        if ($id === null) {
289
            $id = $this->owner->ID;
290
        }
291
        return Controller::curr()->Link().'myspecificpagemenuitems/'.$id.'/';
292
    }
293
}
294