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 | * Webcms admin module package. |
||
5 | */ |
||
6 | namespace WebCMS2\Common; |
||
7 | |||
8 | /** |
||
9 | * |
||
10 | */ |
||
11 | abstract class BasePresenter extends \Nette\Application\UI\Presenter |
||
12 | { |
||
13 | /** |
||
14 | * |
||
15 | * @var [type] |
||
16 | */ |
||
17 | protected $em; |
||
18 | |||
19 | /** |
||
20 | * |
||
21 | * |
||
22 | * @return [type] [description] |
||
0 ignored issues
–
show
|
|||
23 | */ |
||
24 | abstract protected function getLanguageId(); |
||
25 | |||
26 | /** |
||
27 | * |
||
28 | * |
||
29 | * @return [type] [description] |
||
0 ignored issues
–
show
The doc-type
[type] could not be parsed: Unknown type name "" at position 0. [(view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. ![]() |
|||
30 | */ |
||
31 | protected function startUp() |
||
32 | { |
||
33 | parent::startUp(); |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * |
||
38 | * |
||
39 | * @return [type] [description] |
||
0 ignored issues
–
show
The doc-type
[type] could not be parsed: Unknown type name "" at position 0. [(view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. ![]() |
|||
40 | */ |
||
41 | protected function getSettings() |
||
42 | { |
||
43 | $query = $this->em->createQuery('SELECT s FROM WebCMS\Entity\Setting s WHERE s.language = '.$this->getLanguageId().' OR s.language IS NULL'); |
||
44 | $tmp = $query->getResult(); |
||
45 | |||
46 | $settings = array(); |
||
47 | foreach ($tmp as $s) { |
||
48 | $settings[$s->getSection()][$s->getKey()] = $s; |
||
49 | } |
||
50 | |||
51 | return $settings; |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * Injects entity manager. |
||
56 | * |
||
57 | * @param \Doctrine\ORM\EntityManager $em |
||
58 | * |
||
59 | * @return BasePresenter |
||
60 | * @throws \Nette\InvalidStateException |
||
61 | */ |
||
62 | public function injectEntityManager(\Doctrine\ORM\EntityManager $em) |
||
63 | { |
||
64 | if ($this->em) { |
||
65 | throw new \Nette\InvalidStateException('Entity manager has been already set.'); |
||
66 | } |
||
67 | |||
68 | $this->em = $em; |
||
69 | |||
70 | return $this; |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * Generate sitemap.xml file in www (public) directory. |
||
75 | * |
||
76 | * @return XML sitemap |
||
77 | */ |
||
78 | View Code Duplication | public function generateSitemap() |
|
79 | { |
||
80 | $sitemapXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n"; |
||
81 | |||
82 | $repository = $this->em->getRepository('WebCMS\Entity\Page'); |
||
83 | $pages = $repository->findAll(); |
||
84 | |||
85 | foreach ($pages as $page) { |
||
86 | if ($page->getParent() !== null && $page->getVisible()) { |
||
87 | $sitemapXml .= "<url>\n\t<loc>".$this->getSitemapLink($page)."</loc>\n</url>\n"; |
||
88 | } |
||
89 | } |
||
90 | |||
91 | $sitemapXml .= '</urlset>'; |
||
92 | |||
93 | file_put_contents('./sitemap.xml', $sitemapXml); |
||
94 | } |
||
95 | |||
96 | /** |
||
97 | * Get single sitemap link url address. |
||
98 | * |
||
99 | * @param \WebCMS2\Entity\Page $page Page entity object. |
||
100 | * @return string Url address of the link. |
||
101 | */ |
||
102 | View Code Duplication | private function getSitemapLink($page) |
|
103 | { |
||
104 | $url = $this->context->httpRequest->url->baseUrl; |
||
0 ignored issues
–
show
The property
$context is declared private in Nette\Application\UI\Presenter . Since you implemented __get() , maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.
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. ![]() |
|||
105 | $url .= !$page->getLanguage()->getDefaultFrontend() ? $page->getLanguage()->getAbbr().'/' : ''; |
||
106 | $url .= $page->getPath(); |
||
107 | |||
108 | return $url; |
||
109 | } |
||
110 | |||
111 | /** |
||
112 | * |
||
113 | * |
||
114 | * @return [type] [description] |
||
0 ignored issues
–
show
The doc-type
[type] could not be parsed: Unknown type name "" at position 0. [(view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. ![]() |
|||
115 | */ |
||
116 | protected function getAllLanguages() |
||
117 | { |
||
118 | $languages = $this->em->getRepository('WebCMS\Entity\Language')->findAll(); |
||
119 | |||
120 | $langs = array('' => $this->translation['Pick a language']); |
||
0 ignored issues
–
show
The property
translation does not exist on object<WebCMS2\Common\BasePresenter> . 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. ![]() |
|||
121 | foreach ($languages as $l) { |
||
122 | $langs[$l->getId()] = $l->getName(); |
||
123 | } |
||
124 | |||
125 | return $langs; |
||
126 | } |
||
127 | |||
128 | /** |
||
129 | * |
||
130 | * |
||
131 | * @param [type] $name [description] |
||
0 ignored issues
–
show
The doc-type
[type] could not be parsed: Unknown type name "" at position 0. [(view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. ![]() |
|||
132 | * @return [type] [description] |
||
0 ignored issues
–
show
The doc-type
[type] could not be parsed: Unknown type name "" at position 0. [(view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. ![]() |
|||
133 | */ |
||
134 | protected function createObject($name) |
||
135 | { |
||
136 | $expl = explode('-', $name); |
||
137 | |||
138 | $objectName = ucfirst($expl[0]); |
||
139 | $objectName = "\\WebCMS\\$objectName"."Module\\".$objectName; |
||
140 | |||
141 | return new $objectName(); |
||
142 | } |
||
143 | } |
||
144 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.