1 | <?php |
||
3 | class OnePageSlide extends DataExtension |
||
|
|||
4 | { |
||
5 | |||
6 | private static $db = array( |
||
7 | 'BackgroundColor' => 'Varchar', |
||
8 | 'HeadingColor' => 'Varchar', |
||
9 | 'TextColor' => 'Varchar', |
||
10 | 'AdditionalCSSClass' => 'Varchar' |
||
11 | ); |
||
12 | |||
13 | private static $has_one = array( |
||
14 | 'BackgroundImage' => 'Image' |
||
15 | ); |
||
16 | |||
17 | private static $background_color_palette = array( |
||
18 | '#fff', |
||
19 | '#444', |
||
20 | '#000' |
||
21 | ); |
||
22 | private static $heading_color_palette = array( |
||
23 | '#000', |
||
24 | '#fff' |
||
25 | ); |
||
26 | private static $text_color_palette = array( |
||
27 | '#000', |
||
28 | '#fff' |
||
29 | ); |
||
30 | |||
31 | /** |
||
32 | * Should we modify the link to represent anchors? |
||
33 | * |
||
34 | * @var bool |
||
35 | */ |
||
36 | private static $do_modify_link = true; |
||
37 | |||
38 | /** |
||
39 | * limit the generated form fields to slides (direct children of a OnePageHolder) |
||
40 | * @var bool |
||
41 | */ |
||
42 | private static $use_only_on_onepage_slides = false; |
||
43 | |||
44 | /** |
||
45 | * do not require colors to be set |
||
46 | * @var bool |
||
47 | */ |
||
48 | private static $colors_can_be_empty = false; |
||
49 | |||
50 | /** |
||
51 | * @inheritdoc |
||
52 | */ |
||
53 | public function updateFieldLabels(&$labels) |
||
65 | |||
66 | |||
67 | /** |
||
68 | * @inheritdoc |
||
69 | */ |
||
70 | public function updateCMSFields(FieldList $fields) |
||
98 | |||
99 | protected function generateColorPalette($fieldName, $paletteSetting) |
||
117 | |||
118 | //@todo: if Parent is a OnePageHolder modify $Link to show to $Parent->Link() / #$URLSegment |
||
119 | //@todo: if Parent is a OnePageHolder disable ShowInMenus |
||
120 | //@todo: don't show slide in google sitempap |
||
121 | |||
122 | /** |
||
123 | * @todo: use customCSS? |
||
124 | * @return string |
||
125 | */ |
||
126 | public function getOnePageSlideStyle() |
||
142 | |||
143 | /** |
||
144 | * get's fired on ContentController::init() |
||
145 | * |
||
146 | * check if this is a OnePageSlide and redirect to parent if |
||
147 | * - controller has no action |
||
148 | * - request isn't an ajax request |
||
149 | */ |
||
150 | public function contentcontrollerInit(&$controller) |
||
171 | |||
172 | |||
173 | /** |
||
174 | * Updates RelativeLink() |
||
175 | * |
||
176 | * If no $action is given it changes /path/to/URLSegment into /path/to#URLSegment |
||
177 | * |
||
178 | * @param $base |
||
179 | * @param $action |
||
180 | */ |
||
181 | public function updateRelativeLink(&$base, &$action) |
||
202 | |||
203 | /** |
||
204 | * Helper to get a unmofified link if a slide should represent a classical page, not a "block" inside a OnePageHolder |
||
205 | * |
||
206 | * @param null $action |
||
207 | * @return mixed |
||
208 | */ |
||
209 | public function UnmodifiedRelativeLink($action = null) |
||
217 | |||
218 | /** |
||
219 | * Checks, if the current page is a slide of a one-page by checking if the parent page is a OnePageHolder |
||
220 | * |
||
221 | * @return bool |
||
222 | */ |
||
223 | public function isOnePageSlide() |
||
227 | |||
228 | /** |
||
229 | * Checks if the current page is a nested one-page slide |
||
230 | * |
||
231 | * @return bool |
||
232 | */ |
||
233 | public function isNestedOnePageSlide() { |
||
238 | |||
239 | /** |
||
240 | * Helper to check if we're previewing the current page in CMS |
||
241 | * |
||
242 | * @return bool |
||
243 | */ |
||
244 | public function isCMSPreview() |
||
250 | |||
251 | /** |
||
252 | * renders the current page using the ClassName_onepage template, |
||
253 | * e.g. Page_onepage |
||
254 | * |
||
255 | * The suffix is generated by @link getOnePageTemplateSuffix |
||
256 | * |
||
257 | * @return HTMLText |
||
258 | */ |
||
259 | public function getOnePageContent() |
||
268 | |||
269 | |||
270 | /** |
||
271 | * Helper function to generate the template suffix for the current page. |
||
272 | * Calls page's "generateOnePageTemplateSuffix" method if it exists. |
||
273 | * This way your page can define the template suffix to be e.g. '_layout1_onepage' instead of just '_onepage' |
||
274 | * |
||
275 | * @return string |
||
276 | */ |
||
277 | public function getOnePageTemplateSuffix() |
||
283 | |||
284 | } |
||
285 |
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.