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 | *@author nicolaas[at]sunnysideup.co.nz |
||
5 | *@description: holds FAQs and displays them nicely. |
||
6 | * |
||
7 | */ |
||
8 | class FaqHolderPage extends Page |
||
9 | { |
||
10 | private static $icon = "mysite/images/treeicons/FaqHolderPage"; |
||
11 | |||
12 | private static $description = "A list of Frequently Asked Questions" ; |
||
13 | |||
14 | //private static $default_parent = ''; |
||
15 | |||
16 | private static $default_child = 'FaqOnePage'; |
||
17 | |||
18 | private static $allowed_children = array('FaqHolderPage', 'FaqOnePage'); |
||
19 | |||
20 | /** |
||
21 | * Standard SS variable. |
||
22 | */ |
||
23 | private static $singular_name = "FAQ Holder Page"; |
||
24 | public function i18n_singular_name() |
||
25 | { |
||
26 | return _t("FAQHolderPage.SINGULARNAME", "FAQ Holder Page"); |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * Standard SS variable. |
||
31 | */ |
||
32 | private static $plural_name = "FAQ Holder Pages"; |
||
33 | public function i18n_plural_name() |
||
34 | { |
||
35 | return _t("FAQHolderPage.PLURALNAME", "FAQ Holder Pages"); |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * The holder page class in use. |
||
40 | * You can extends this Class and change this value. |
||
41 | * @var String |
||
42 | */ |
||
43 | protected $holderPage = "FAQHolderPage"; |
||
44 | |||
45 | /** |
||
46 | * The item page class in use. |
||
47 | * You can extends this Class and change this value. |
||
48 | * @var String |
||
49 | */ |
||
50 | protected $entryPage = "FAQOnePage"; |
||
51 | |||
52 | /** |
||
53 | * Returns children FAQHolderPage pages of this FAQHolderPage. |
||
54 | * |
||
55 | * @param Int $maxRecursiveLevel - maximum depth , e.g. 1 = one level down - so no Child Groups are returned... |
||
56 | * @param Int $numberOfRecursions - current level of depth. DONT provide this variable... |
||
57 | * @return ArrayList (FAQHolderPages) |
||
58 | */ |
||
59 | public function ChildGroups($maxRecursiveLevel = 99, $numberOfRecursions = 0) |
||
60 | { |
||
61 | $arrayList = ArrayList::create(); |
||
62 | if ($numberOfRecursions < $maxRecursiveLevel) { |
||
63 | $className = $this->getHolderPage(); |
||
64 | $children = $className::get()->filter(array("ParentID" => $this->ID)); |
||
65 | if ($children->count()) { |
||
66 | foreach ($children as $child) { |
||
67 | $arrayList->push($child); |
||
68 | $arrayList->merge($child->ChildGroups($maxRecursiveLevel, $numberOfRecursions++)); |
||
69 | } |
||
70 | } |
||
71 | } |
||
72 | |||
73 | return $arrayList; |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * sets the classname for pages that are holder pages |
||
78 | * @param String $name |
||
79 | */ |
||
80 | public function setHolderPage($name) |
||
81 | { |
||
82 | $this->holderPage = $name; |
||
83 | } |
||
84 | |||
85 | /** |
||
86 | * gets the classname for pages that are holder pages |
||
87 | * @return String |
||
88 | */ |
||
89 | public function getHolderPage() |
||
90 | { |
||
91 | return $this->holderPage; |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * sets the classname for pages that are individual items |
||
96 | * @param String $name |
||
97 | */ |
||
98 | public function setEntryName($name) |
||
99 | { |
||
100 | $this->entryPage; |
||
101 | } |
||
102 | |||
103 | /** |
||
104 | * gets the classname for pages that are individual items |
||
105 | * @return String |
||
106 | */ |
||
107 | public function getEntryName() |
||
108 | { |
||
109 | return $this->entryPage; |
||
110 | } |
||
111 | } |
||
112 | |||
113 | class FaqHolderPage_Controller extends Page_Controller |
||
114 | { |
||
115 | public function init() |
||
116 | { |
||
117 | parent::init(); |
||
118 | Requirements::javascript(THIRDPARTY_DIR."/jquery/jquery.js"); |
||
119 | Requirements::javascript("faqs/javascript/FaqHolderPage.js"); |
||
120 | Requirements::themedCSS("FaqHolderPage", "faqs"); |
||
121 | } |
||
122 | |||
123 | /** |
||
124 | * returns all underlying FaqOnePage pages... |
||
125 | * for use in templates |
||
126 | * @return DataList | Null |
||
127 | */ |
||
128 | public function Entries() |
||
129 | { |
||
130 | $array = array($this->ID => $this->ID); |
||
131 | if ($childGroups = $this->ChildGroups(4)) { |
||
132 | if ($childGroups->count()) { |
||
133 | foreach ($childGroups->map("ID", "ID") as $id) { |
||
134 | $array[$id] = $id; |
||
135 | } |
||
136 | } |
||
137 | } |
||
138 | $stage = ''; |
||
139 | if (Versioned::current_stage() == "Live") { |
||
140 | $stage = "_Live"; |
||
141 | } |
||
142 | $className = $this->dataRecord->getEntryName(); |
||
143 | return $className::get() |
||
144 | ->filter(array("ParentID" => $array, "ShowInSearch" => 1)) |
||
145 | ->leftJoin("SiteTree".$stage, "SiteTree".$stage.".ParentID = MyParent.ID", "MyParent") |
||
146 | ->leftJoin("SiteTree".$stage, "MyParent.ParentID = MyGrandParent.ID", "MyGrandParent") |
||
147 | ->leftJoin("SiteTree".$stage, "MyGrandParent.ParentID = MyGreatGrandParent.ID", "MyGreatGrandParent") |
||
148 | ->leftJoin("SiteTree".$stage, "MyGreatGrandParent.ParentID = MyGreatGreatGrandParent.ID", "MyGreatGreatGrandParent") |
||
149 | ->sort( |
||
150 | " |
||
151 | MyGreatGreatGrandParent.Sort, |
||
152 | MyGreatGrandParent.Sort, |
||
153 | MyGrandParent.Sort, |
||
154 | MyParent.Sort, |
||
155 | SiteTree".$stage.".Sort" |
||
156 | ); |
||
157 | } |
||
158 | |||
159 | public function MyParentHolder() |
||
0 ignored issues
–
show
|
|||
160 | { |
||
161 | $className = $this->dataRecord->getHolderPage(); |
||
162 | return $className::get()->byID($this->ParentID); |
||
163 | } |
||
164 | } |
||
165 |
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.