sunnysideup /
silverstripe-searchplus
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 | *@author: nicolaas[at]sunnysideup.co.nz |
||
| 4 | *@description: |
||
| 5 | * a log history and counted history of searches done (e.g. 100 people searched for "sunshine") |
||
| 6 | * it allows gives the opportunity to link zero or more pages to a particular search phrase |
||
| 7 | * |
||
| 8 | * |
||
| 9 | * |
||
| 10 | **/ |
||
| 11 | |||
| 12 | class RecommendedSearchPlusSection extends DataObject |
||
|
0 ignored issues
–
show
|
|||
| 13 | { |
||
| 14 | private static $db = array( |
||
|
0 ignored issues
–
show
|
|||
| 15 | "Title" => "Varchar(255)", |
||
| 16 | "Intro" => "Text", |
||
| 17 | "Sort" => "Int" |
||
| 18 | ); |
||
| 19 | |||
| 20 | private static $has_one = array( |
||
|
0 ignored issues
–
show
|
|||
| 21 | "ParentPage" => "Page", |
||
| 22 | "Parent" => "SearchPlusPage" |
||
| 23 | ); |
||
| 24 | |||
| 25 | private static $defaults = array( |
||
|
0 ignored issues
–
show
|
|||
| 26 | "Sort" => 100 |
||
| 27 | ); |
||
| 28 | |||
| 29 | private static $singular_name = 'Recommended SearchPlus Section'; |
||
|
0 ignored issues
–
show
|
|||
| 30 | |||
| 31 | private static $plural_name = 'Recommended SearchPlus Sections'; |
||
|
0 ignored issues
–
show
|
|||
| 32 | |||
| 33 | private static $default_sort = 'Sort, Title'; |
||
|
0 ignored issues
–
show
|
|||
| 34 | |||
| 35 | private static $searchable_fields = array( |
||
|
0 ignored issues
–
show
|
|||
| 36 | "Title" |
||
| 37 | ); |
||
| 38 | |||
| 39 | private static $summary_fields = array( |
||
|
0 ignored issues
–
show
|
|||
| 40 | "Title", "Sort" |
||
| 41 | ); |
||
| 42 | |||
| 43 | private static $field_labels = array( |
||
|
0 ignored issues
–
show
|
|||
| 44 | "Sort" => "Sort Index" |
||
| 45 | ); |
||
| 46 | |||
| 47 | public function getCMSFields() |
||
| 48 | { |
||
| 49 | $fields = parent::getCMSFields(); |
||
| 50 | $fields->removeByName("ParentPageID"); |
||
| 51 | $fields->removeByName("ParentID"); |
||
| 52 | $fields->addFieldToTab("Root.Main", new TreeDropdownField($name = "ParentPageID", $title = "Parent Page (show all child pages as links for this recommended section)", $sourceObject = "SiteTree")); |
||
| 53 | return $fields; |
||
| 54 | } |
||
| 55 | |||
| 56 | public function onBeforeWrite() |
||
| 57 | { |
||
| 58 | parent::onBeforeWrite(); |
||
| 59 | if (!$this->ParentID) { |
||
|
0 ignored issues
–
show
The property
ParentID does not exist on object<RecommendedSearchPlusSection>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 60 | if ($page = SearchPlusPage::get()->first()) { |
||
| 61 | $this->ParentID = $page->ID; |
||
|
0 ignored issues
–
show
The property
ParentID does not exist on object<RecommendedSearchPlusSection>. Since you implemented __set, maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 62 | } else { |
||
| 63 | user_error("Make sure to create a SearchPlusPage", E_USER_NOTICE); |
||
| 64 | } |
||
| 65 | } |
||
| 66 | } |
||
| 67 | } |
||
| 68 |
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.