GinoPane /
oc-blogtaxonomy-plugin
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 declare(strict_types=1); |
||
| 2 | |||
| 3 | namespace GinoPane\BlogTaxonomy\Components; |
||
| 4 | |||
| 5 | use Cms\Classes\Page; |
||
| 6 | use GinoPane\BlogTaxonomy\Plugin; |
||
| 7 | use GinoPane\BlogTaxonomy\Models\Series; |
||
| 8 | use GinoPane\BlogTaxonomy\Classes\ComponentAbstract; |
||
| 9 | use GinoPane\BlogTaxonomy\Classes\TranslateArrayTrait; |
||
| 10 | use GinoPane\BlogTaxonomy\Classes\PostListFiltersTrait; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Class SeriesList |
||
| 14 | * |
||
| 15 | * @package GinoPane\BlogTaxonomy\Components |
||
| 16 | */ |
||
| 17 | class SeriesList extends ComponentAbstract |
||
| 18 | { |
||
| 19 | const NAME = 'seriesList'; |
||
| 20 | |||
| 21 | use TranslateArrayTrait; |
||
| 22 | use PostListFiltersTrait; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @var Series |
||
| 26 | */ |
||
| 27 | public $series; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Reference to the page name for linking to series |
||
| 31 | * |
||
| 32 | * @var string |
||
| 33 | */ |
||
| 34 | protected $seriesPage; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * If the series list should be ordered by another attribute |
||
| 38 | * |
||
| 39 | * @var string |
||
| 40 | */ |
||
| 41 | public $orderBy; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Whether display or not empty series |
||
| 45 | * |
||
| 46 | * @var bool |
||
| 47 | */ |
||
| 48 | public $displayEmpty; |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Limits the number of records to display |
||
| 52 | * |
||
| 53 | * @var int |
||
| 54 | */ |
||
| 55 | public $limit; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Whether to query related posts or not |
||
| 59 | * |
||
| 60 | * @var bool |
||
| 61 | */ |
||
| 62 | private $fetchPosts; |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @return array |
||
|
0 ignored issues
–
show
|
|||
| 66 | */ |
||
| 67 | public function componentDetails() |
||
| 68 | { |
||
| 69 | return [ |
||
| 70 | 'name' => Plugin::LOCALIZATION_KEY . 'components.series_list.name', |
||
| 71 | 'description' => Plugin::LOCALIZATION_KEY . 'components.series_list.description' |
||
| 72 | ]; |
||
| 73 | } |
||
| 74 | |||
| 75 | /** |
||
| 76 | * @return array |
||
| 77 | */ |
||
| 78 | public function defineProperties(): array |
||
| 79 | { |
||
| 80 | return array_merge([ |
||
| 81 | 'displayEmpty' => [ |
||
| 82 | 'title' => Plugin::LOCALIZATION_KEY . 'components.series_list.display_empty_title', |
||
| 83 | 'description' => Plugin::LOCALIZATION_KEY . 'components.series_list.display_empty_description', |
||
| 84 | 'type' => 'checkbox', |
||
| 85 | 'default' => false, |
||
| 86 | 'showExternalParam' => false |
||
| 87 | ], |
||
| 88 | 'fetchPosts' => [ |
||
| 89 | 'title' => Plugin::LOCALIZATION_KEY . 'components.series_list.fetch_posts_title', |
||
| 90 | 'description' => Plugin::LOCALIZATION_KEY . 'components.series_list.fetch_posts_description', |
||
| 91 | 'type' => 'checkbox', |
||
| 92 | 'default' => false, |
||
| 93 | 'showExternalParam' => false |
||
| 94 | ], |
||
| 95 | 'limit' => [ |
||
| 96 | 'title' => Plugin::LOCALIZATION_KEY . 'components.series_list.limit_title', |
||
| 97 | 'description' => Plugin::LOCALIZATION_KEY . 'components.series_list.limit_description', |
||
| 98 | 'type' => 'string', |
||
| 99 | 'default' => '0', |
||
| 100 | 'validationPattern' => '^[0-9]+$', |
||
| 101 | 'validationMessage' => Plugin::LOCALIZATION_KEY . 'components.series_list.limit_validation_message', |
||
| 102 | 'showExternalParam' => false |
||
| 103 | ], |
||
| 104 | 'orderBy' => [ |
||
| 105 | 'title' => Plugin::LOCALIZATION_KEY . 'components.series_list.order_title', |
||
| 106 | 'description' => Plugin::LOCALIZATION_KEY . 'components.series_list.order_description', |
||
| 107 | 'type' => 'dropdown', |
||
| 108 | 'default' => 'title asc', |
||
| 109 | 'showExternalParam' => false |
||
| 110 | ], |
||
| 111 | 'seriesPage' => [ |
||
| 112 | 'group' => Plugin::LOCALIZATION_KEY . 'components.post_list_abstract.links_group', |
||
| 113 | 'title' => Plugin::LOCALIZATION_KEY . 'components.series_list.series_page_title', |
||
| 114 | 'description' => Plugin::LOCALIZATION_KEY . 'components.series_list.series_page_description', |
||
| 115 | 'type' => 'dropdown', |
||
| 116 | 'default' => 'blog/series', |
||
| 117 | 'showExternalParam' => false |
||
| 118 | ], |
||
| 119 | ], $this->getPostFilterProperties()); |
||
| 120 | } |
||
| 121 | |||
| 122 | /** |
||
| 123 | * @return mixed |
||
| 124 | */ |
||
| 125 | public function getSeriesPageOptions() |
||
| 126 | { |
||
| 127 | return Page::sortBy('baseFileName')->lists('baseFileName', 'baseFileName'); |
||
| 128 | } |
||
| 129 | |||
| 130 | /** |
||
| 131 | * @return string[] |
||
| 132 | */ |
||
| 133 | public function getOrderByOptions(): array |
||
| 134 | { |
||
| 135 | $order = $this->translate(Series::$sortingOptions); |
||
| 136 | |||
| 137 | asort($order); |
||
| 138 | |||
| 139 | return $order; |
||
| 140 | } |
||
| 141 | |||
| 142 | /** |
||
| 143 | * Prepare and return a series list |
||
| 144 | * |
||
| 145 | * @return mixed |
||
| 146 | */ |
||
| 147 | public function onRun() |
||
| 148 | { |
||
| 149 | $this->prepareVars(); |
||
| 150 | |||
| 151 | // Exceptions |
||
| 152 | $this->populateFilters(); |
||
| 153 | |||
| 154 | $this->series = $this->listSeries(); |
||
| 155 | } |
||
| 156 | |||
| 157 | /** |
||
| 158 | * Get Series |
||
| 159 | * |
||
| 160 | * @return mixed |
||
| 161 | */ |
||
| 162 | protected function listSeries() |
||
| 163 | { |
||
| 164 | $series = Series::listFrontend([ |
||
| 165 | 'sort' => $this->orderBy, |
||
| 166 | 'displayEmpty' => $this->displayEmpty, |
||
| 167 | 'limit' => $this->limit, |
||
| 168 | 'fetchPosts' => $this->fetchPosts, |
||
| 169 | 'exceptPosts' => $this->exceptPosts, |
||
| 170 | 'includeCategories' => $this->includeCategories, |
||
| 171 | 'exceptCategories' => $this->exceptCategories |
||
| 172 | ]); |
||
| 173 | |||
| 174 | $this->handleUrls($series); |
||
| 175 | |||
| 176 | return $series; |
||
| 177 | } |
||
| 178 | |||
| 179 | /** |
||
| 180 | * @param $series |
||
| 181 | */ |
||
| 182 | protected function handleUrls($series) |
||
| 183 | { |
||
| 184 | $seriesComponent = $this->getComponent(SeriesPosts::NAME, $this->seriesPage); |
||
| 185 | |||
| 186 | $this->setUrls( |
||
| 187 | $series, |
||
| 188 | $this->seriesPage, |
||
| 189 | $this->controller, |
||
| 190 | [ |
||
| 191 | 'series' => $this->urlProperty($seriesComponent, 'series') |
||
| 192 | ] |
||
| 193 | ); |
||
| 194 | } |
||
| 195 | |||
| 196 | private function prepareVars(): void |
||
| 197 | { |
||
| 198 | $this->seriesPage = $this->getProperty('seriesPage'); |
||
| 199 | $this->orderBy = $this->getProperty('orderBy'); |
||
| 200 | $this->displayEmpty = (bool)$this->getProperty('displayEmpty'); |
||
| 201 | $this->fetchPosts = (bool)$this->getProperty('fetchPosts'); |
||
| 202 | $this->limit = $this->getProperty('limit'); |
||
| 203 | } |
||
| 204 | } |
||
| 205 |
This check looks for the generic type
arrayas a return type and suggests a more specific type. This type is inferred from the actual code.