-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomNotes.module
More file actions
672 lines (586 loc) · 28.7 KB
/
CustomNotes.module
File metadata and controls
672 lines (586 loc) · 28.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
<?php namespace ProcessWire;
class CustomNotes extends Process implements Module, ConfigurableModule {
public static function getModuleinfo() {
return [
'title' => 'CustomNotes',
'summary' => 'Put your custom notes into an admin page, with some settings to show it.',
'author' => 'Mauro Romano of NewMediaConsulting (newmc.it) and Teppo Koivula',
'version' => 101,
'permission' => 'view-notes',
'autoload' => 'template=admin',
'singular' => true
];
}
public function init() {
if ($this->wire('input')->get->name == 'CustomNotes') {
$this->wire('config')->scripts->add(wire('urls')->$this.'CustomNotes.js');
}
}
public function ready() {
$this->addHookAfter("ProcessPageEdit::buildForm", function($event) {
$form = $event->return;
$page = $event->process->getPage();
if (!$this->enable_module){
if ($this->button){
if(!in_array($page->template->id, $this->tpls_sticky)) return;
if(!in_array($page->id, $this->pages_sticky)) return;
$divPos = $this->v_position.':'.$this->ver.'%';
$aPos = $this->h_position.':'.$this->hor.'%';
$button = '<div class="container" style="position:sticky;'.$divPos.';z-index:10;">';
$button .= '<a title="'.$this->linkLabel().'" href="'.wire('urls')->admin.'page/custom-notes/" class="sticky-button ui-button ui-state-default '.$this->view_mode_sticky.'" style="position:absolute;'.$aPos.';">';
$button .= '<i class="fa fa-list"></i> '. $this->linkLabel();
$button .= '</a>';
$button .= '</div>';
$form->prependMarkup($button);
$event->return = $form;
}
}
});
$this->addHookAfter("ProcessPageEdit::buildForm", function($event) {
$form = $event->return;
$page = $event->process->getPage();
if (!$this->enable_module){
if ($this->note){
if(!in_array($page->template->id, $this->tpls_note)) return;
if(!in_array($page->id, $this->pages_note)) return;
// @BernhardBaumrock Tip: Adding link into field note. Where it all began! ;)
foreach ($this->fields_note as $field_note){
if($f = $form->get($field_note)) {
$f->notes = '';
if (!trim($this->custom_link)){
$f->notes .= " <a href='".wire('urls')->admin."page/custom-notes/' class='".$this->view_mode_note."'>".$this->linkLabel()."</a>";
} else {
$f->notes .= " <a href='".wire('urls')->admin."page/custom-notes/' class='".$this->view_mode_note."'>".$this->linkLabel()."</a>";
}
$f->entityEncodeText = false;
}
}
}
}
});
}
public function linkLabel() {
// get user language to determine which language to output
if($this->wire('languages')) {
$userLanguage = $this->wire('user')->language;
$langIdSuffix = $userLanguage->isDefault() ? '' : "__$userLanguage->id";
} else {
$langIdSuffix = '';
}
$linkLabel = $this->get('custom_link'.$langIdSuffix);
return $linkLabel;
}
// Sets Default data
public static function getDefaultData() {
$content = '<h1>Welcome to CustomNotes.</h1><p>Here you can put everything you want. If installed, you can also choose a textformatters.</p><ul><li>First of all, set the main content for your notes.</li><li>Then go to Setting Tab e start to play! ;)</li></ul><p>Here some example stuff</p><table border="0" cellpadding="5" cellspacing="0" class="single-row table table-striped" style="width:100%"><tbody><tr><td>PW Forums</td><td><a class="g-text-underline--none--hover" href="https://processwire.com/talk/" rel="nofollow noreferrer noopener" target="_blank">https://processwire.com/talk/</a></td></tr><tr><td>PW Cheatsheet</td><td><a class="g-text-underline--none--hover" href="https://cheatsheet.processwire.com/" rel="nofollow noreferrer noopener" target="_blank">https://cheatsheet.processwire.com/</a></td></tr></tbody></table><p>https://www.youtube.com/watch?v=IHqnLQy9R1A&t=1s</p>';
return array(
'custom_text' => $content,
'custom_link' => 'Link',
'v_position' => 'top',
'ver' => 90,
'h_position' => 'right',
'hor' => 5,
);
}
/*
Called only when the module is installed
Creates a new page and a new permission.
*/
public function ___install() {
$tp = new Page();
$tp->template = 'admin';
$tp->parent = 'page';
// $tp->parent = $this->page_parent;
$tp->name = 'custom-notes';
$tp->process = $this;
// we will make the page title the same as our module title
$info = self::getModuleInfo();
$tp->title = $info['title'];
$tp->save();
$this->message("Created Page: {$tp->path}");
// Set module permission
if (count(wire('pages')->find('name=view-notes, parent.name=permissions')) < 1) {
$permission = wire('permissions')->add('view-notes');
$permission->title = 'View Custom Notes Page';
$permission->save();
$this->message("Created Permission: {$permission->name}");
}
//save default module configurations on install
wire('modules')->saveModuleConfigData($this, self::getDefaultData());
}
/*
Called only when the module is uninstalled
Delete the created page and permission.
*/
public function ___uninstall() {
// find the page we installed, locating it by the process field (which has the module ID)
// it would probably be sufficient just to locate by name, but this is just to be extra sure.
$moduleID = $this->modules->getModuleID($this);
$pages = $this->pages->find("template=admin, process=".$moduleID);
if(count($pages)) {
foreach ($pages as $page){
// if we found the page, let the user know and delete it
$this->message("Deleting Page: {$page->path}");
$page->delete();
}
}
// Let user know that we are deleting Permission
$permission = wire('permissions')->get('view-notes');
$this->message("Deleting Permission: {$permission->name}");
$permission->delete();
}
public function ___execute() {
// get user language to determine which language to output
if($this->wire('languages')) {
$userLanguage = $this->wire('user')->language;
$langIdSuffix = $userLanguage->isDefault() ? '' : "__$userLanguage->id";
} else {
$langIdSuffix = '';
}
// Custom Text
$fieldML = 'custom_text'.$langIdSuffix;
$out = $this->$fieldML;
// Textformatter Usage
if (!is_array(wire('modules')->get('CustomNotes')->textformatters)) wire('modules')->get('CustomNotes')->textformatters = array(wire('modules')->get('CustomNotes')->textformatters);
foreach (wire('modules')->get('CustomNotes')->textformatters as $tf){
$tFM = wire('modules')->getModuleInfo($tf);
$mName = $tFM['name'];
wire('modules')->$mName->format($out);
}
// Edit Button to module (only for Superusers)
if (wire('user')->isSuperuser()){
if ($this->editing == 1){
$out .= '<div class="g-py-25"><a title="Open new page to edit this notes" target="_blank" class="ui-button ui-state-default" href="'.wire('urls')->admin.'module/edit?name='.$this.'&collapse_info=1">Edit</a></div>';
}
}
// Custom Stylesheet load
if (trim($this->css_file)){
$out .= '<link rel="stylesheet" type="text/css" href="'.$this->css_file.'" />';
}
// Custom Inline JS
if (($this->custom_js)&&($this->notstupid)){
$out .= '<script>'.$this->custom_js.'</script>';
}
return $out;
}
public static function getModuleConfigInputfields(array $data) {
// JQuery Tab loading
wire('modules')->get('JqueryWireTabs');
$thisModule = wire('modules')->get('CustomNotes');
$thisPage = wire('pages')->get('name=custom-notes');
if (wire('modules')->get('CustomNotes')->enable_module == 0) {
$thisPage->status(1);
$thisPage->save();
} else {
$thisPage->status(2049);
$thisPage->save();
}
$inputfields = new InputfieldWrapper();
// // WIP - ONLY FOR WIP POURPOSES
// // Page Creation details
// $wrap = new InputfieldWrapper();
// $form = wire('modules')->get('InputfieldFieldset');
// $form->label = __('Page Details');
// $form->notes = __("```FEATURES CURRENTLY DISABLED - ONLY FOR WIP POURPOSES```");
// $form->icon = "file";
// $form->set("themeColor", "secondary");
// // $form->set("themeBorder", "card");
// // $form->set("themeOffset", "m");
// // $form->collapsed = Inputfield::collapsedNever;
// $form->collapsed = Inputfield::collapsedHidden;
// // Name (the end of the url)
// $f = wire('modules')->get('InputfieldText');
// $f->name = 'page_name';
// $f->useLanguages = true;
// // $f->required = 'true'; // ONLY IN PRODUCTION ?
// $f->columnWidth = 34;
// $f->label = __("Name");
// $f->notes = __("Eg. 'yourdomain.com/admin/page/```this_name_of_the_page```'
// Automatically lowercased and special chars replaced by hypen");
// if(isset($data['page_name'])) $f->value = $data['page_name'];
// $form->add($f);
// // Title
// $f = wire('modules')->get('InputfieldText');
// $f->name = 'page_title';
// $f->useLanguages = true;
// $f->columnWidth = 33;
// $f->label = __("Title");
// $f->notes = __("Not mandatory: if blank, name will be used");
// if(isset($data['page_title'])) $f->value = $data['page_title'];
// $form->add($f);
// // Parent
// $f = wire('modules')->get('InputfieldSelect');
// $f->name = 'page_parent';
// $f->icon = 'tree';
// $f->columnWidth = 33;
// $f->label = __("Parent where to place your page");
// $f->description = __("For not superuser & all the roles with permission related access, select 'page'");
// $f->notes = __("Always below admin parent.");
// $pp = wire('pages')->find('sort=id, parent=2');
// foreach($pp as $p){
// $f->addOption($p->id,$p->name);
// }
// if(isset($data['page_parent'])) $f->value = $data['page_parent'];
// $form->add($f);
// $wrap->add($form);
// $inputfields->append($wrap);
// TAB CONTENT
$tab = new InputfieldWrapper();
$tab->attr('title', 'Content');
$tab->attr('class', 'CN-WireTab');
$markup = $thisModule->modules->get('InputfieldMarkup');
// $markup->label = 'Content';
// $markup->value = '<p>Here you can define the content of your Custon Notes page.</p>';
$tab->add($markup);
// Custom Text
$field = wire('modules')->get('InputfieldCKEditor');
$field->name = 'custom_text';
$field->label = __("Custom Text");
// $field->type = 'CKEditor';
$field->useLanguages = true;
$field->rows = 12;
if(isset($data['custom_text'])) $field->value = $data['custom_text'];
$tab->add($field);
// TextFormatters
$field = wire('modules')->get('InputfieldAsmSelect');
$field->name = 'textformatters';
$field->icon = 'font';
$field->label = __("Text Formatters");
$field->description = __(" If you select more than one, drag them into the order they should be applied.");
$field->notes = __("Due to the CKEditor field, only appropriate Textformatters are enabled");
$field->columnWidth = 33;
$textFmts = wire('modules')->find('name*=textformatter');
foreach ($textFmts as $textF){
$tFInfo = wire('modules')->getModuleInfo($textF);
// Due to the CKEditor field, only appropriate Textformatters are enabled
if(($tFInfo['name']=='TextformatterVideoEmbed')||($tFInfo['name']=='TextformatterEntities')){
$field->addOption($tFInfo['id'],$tFInfo['title']);
}
}
if(isset($data['textformatters'])) $field->value = $data['textformatters'];
$tab->add($field);
// Custom link
$field = wire('modules')->get('InputfieldText');
$field->name = 'custom_link';
$field->label = __("Custom text for link into Field Note");
$field->description = __("The link will be shown as a red link into the field notes.");
$field->placeholder = 'Link';
$thisModule->custom_link ? $thisLink = '```['.$thisModule->custom_link.']('.wire('urls')->admin.'page/custom-notes/)```' : $thisLink = 'Default value is: ```[Link]('.wire('urls')->admin.'page/custom-notes/)```';
$field->notes = __("$thisLink");
$field->columnWidth = 33;
$field->useLanguages = true;
if(isset($data['custom_link'])) $field->value = $data['custom_link'];
$tab->add($field);
// Inline Style
$field = wire('modules')->get('InputfieldText');
$field->name = 'css_file';
$field->label = __("Custom CSS file to load");
$field->columnWidth = 34;
$field->placeholder = '/site/templates/styles/yourfile.css';
$field->description = 'Put the url to your stylesheet in the format of **/site/templates/styles/yourfile.css**';
// $field->collapsed = 2;
if(isset($data['css_file'])) $field->value = $data['css_file'];
$tab->add($field);
$inputfields->add($tab);
// TAB SETTINGS
$tab = new InputfieldWrapper();
// $tab->attr('id', 'ext_settings');
$tab->attr('title', 'Settings');
$tab->attr('class', 'CN-WireTab');
$markup = $thisModule->modules->get('InputfieldMarkup');
$markup->label = 'Settings';
// $markup->value = '<p>For very experienced developers only.</p>';
$tab->add($markup);
// ENABLE/DISABLE MODULE
$field = wire('modules')->get('InputfieldCheckbox');
$field->name = 'enable_module';
$field->columnWidth = 33;
$field->label = __("Hide Custom Notes page");
$field->notes = __("Leave unchecked to show the page (default status).");
// $field->collapsed = Inputfield::collapsedBlank;
$field->icon = "on";
// $field->set("themeColor", "warning");
// $field->set("themeOffset", "s");
// $field->attr('checked') = 0;
$field->attr('checked', empty($data['enable_module']) ? '' : 'checked');
$tab->add($field);
//Append Edit button
$field = wire('modules')->get('InputfieldCheckbox');
$field->name = 'editing';
$field->columnWidth = 33;
$field->label = __("Editable notes (only for Superusers)");
// $field->description = __("Like the 'Settings' button into admin->modules");
$field->notes = __("An edit button will be appended at the end of the page to quickly jump into module editing.");
$field->icon = "edit";
$field->value = 0;
$field->attr('checked', empty($data['editing']) ? '' : 'checked');
$tab->add($field);
// Permisssions
$f = wire('modules')->get('InputfieldAsmSelect');
$f->name = 'role_permissions';
$f->icon = 'users';
$f->columnWidth = 34;
$f->label = __("Add Permission to Roles");
$f->description = __("Select the roles to assign view permission for the page of this module");
$f->notes = __("Superuser and Guest are automatically excluded from this select.");
$allRoles = wire('roles')->find('sort=id, name!=guest|superuser');
foreach($allRoles as $oneRole){
$f->addOption($oneRole->id,$oneRole->name);
}
if(isset($data['role_permissions'])) $f->value = $data['role_permissions'];
$tab->add($f);
// Set permission to selected roles on save and reload
$allRoles = wire('modules')->get('CustomNotes')->role_permissions;
if(!is_array($allRoles)) $allRoles = array();
foreach ($allRoles as $oneRole){
if (!in_array('view-notes', wire('roles')->get($oneRole)->permissions->getArray())){
wire('roles')->get($oneRole)->addPermission("view-notes");
wire('roles')->get($oneRole)->save();
wire('modules')->get('CustomNotes')->message(wire('roles')->get($oneRole)->name.' ha permesso di tipo: view-notes');
} else {
wire('modules')->get('CustomNotes')->message(wire('roles')->get($oneRole)->name.' non ha ancora permesso di tipo: view-notes');
}
}
// Getting Global Permissions and Setted Permission by module
$rolesWithPermission = wire('roles')->find('permissions=view-notes');
$allRoles = wire('modules')->get('CustomNotes')->role_permissions;
// Leave permission only to selected Roles
foreach($rolesWithPermission as $rwp){
if (!in_array($rwp->id, $allRoles) || (empty($allRoles)) ){
wire('roles')->get($rwp->id)->removePermission('view-notes');
wire('roles')->get($rwp->id)->save();
}
}
// Custom inline JS
$field = wire('modules')->get('InputfieldTextarea');
$field->name = 'custom_js';
$field->label = __("Custom inline JS");
$field->placeholder = 'Your JS code, without html tags';
$field->notes = 'JS to append to your HTML code, setted into module.
**N.B.** Write your js code **without** ```<script></script>``` tags.
After saving your code, a checkbox will appear to enable/disable JS.';
$field->collapsed = 2;
$field->rows = 12;
if(isset($data['custom_js'])) $field->value = $data['custom_js'];
$tab->add($field);
// CHECKBOX "I'm not a stupid!"
if(array_key_exists('custom_js', $data)){
if (trim($data['custom_js'])){
$field3 = wire('modules')->get('InputfieldCheckbox');
$field3->name = 'notstupid';
$field3->columnWidth = 100;
$field3->label = __("**I'm not a stupid**, my JS is safe for my site!");
$field3->icon = "exclamation";
$field3->set("themeColor", "warning");
$field3->set("themeOffset", "s");
$field3->value = 0;
$field3->attr('checked', empty($data['notstupid']) ? '' : 'checked');
$tab->add($field3);
}
}
// CHECKBOX for ENABLING/DISABILING FIELD NOTE
$field2 = wire('modules')->get('InputfieldCheckbox');
$field2->name = 'note';
$field2->columnWidth = 100;
$field2->label = __("Enable Field Note with Link");
$field2->description = __("Create simple link into bottom field notes in the templates+fields that you'll select.");
$field2->notes = __("This will add an **a.pw-panel** link");
$field2->icon = "link";
$field2->value = 0;
$field2->attr('checked', empty($data['note']) ? '' : 'checked');
$tab->add($field2);
if (wire('modules')->get('CustomNotes')->note == 1){
// View Mode Select
$field = wire('modules')->get('InputfieldSelect');
$field->name = 'view_mode_note';
$field->icon = 'eye';
$field->columnWidth = 25;
$field->label = __("View Mode (Field Note)");
$field->notes = __("Select how to open the link.
Leave blank to open as a default page.");
$field->addOption('pw-modal', 'Modal Popup');
$field->addOption('pw-panel', 'PW Panel');
if(isset($data['view_mode_note'])) $field->value = $data['view_mode_note'];
$tab->add($field);
// template to apply FIELD NOTE LINK
$field = wire('modules')->get('InputfieldAsmSelect');
$field->name = 'tpls_note';
$field->icon = 'cubes';
$field->columnWidth = 25;
$field->label = __("Templates to apply field note");
$field->notes = __("Save before page select (to filter pages by selected templates).");
$tpls = wire('templates')->find('sort=template.name');
foreach($tpls as $tpl){
$field->addOption($tpl->id,$tpl->name);
}
if(isset($data['tpls_note'])) $field->value = $data['tpls_note'];
$tab->add($field);
// pages to apply FIELD NOTE LINK
if (array_key_exists('tpls_note', $data)){
$field = wire('modules')->get('InputfieldAsmSelect');
$field->name = 'pages_note';
$field->icon = 'file';
$field->columnWidth = 25;
$field->label = __("Pages to apply field note");
$field->notes = __("Save before field select.
Published pages (```hasParent!=2```): to modify, change selectors into module.");
$pgs = wire('pages')->find('sort=title, hasParent!=2');
foreach($pgs as $pg){
if (in_array($pg->template->id, wire('modules')->get('CustomNotes')->tpls_note)){
$field->addOption($pg->id,$pg->title);
}
}
if(isset($data['pages_note'])) $field->value = $data['pages_note'];
$tab->add($field);
}
// fields to apply FIELD NOTE LINK
if (array_key_exists('pages_note', $data)){
$field = wire('modules')->get('InputfieldAsmSelect');
$field->name = 'fields_note';
$field->icon = 'cube';
$field->columnWidth = 25;
$field->label = __("Field to apply Field Note");
$flds = wire('fields')->find('sort=title');
foreach($flds as $fld){
foreach(wire('modules')->get('CustomNotes')->pages_note as $pg_note){
if (wire('pages')->get($pg_note)->hasField($fld->name)){
$field->addOption($fld->name);
}
}
}
if(isset($data['fields_note'])) $field->value = $data['fields_note'];
$tab->add($field);
}
} // end check for field note link
// CHECKBOX for ENABLING/DISABILING STICKY BUTTON
$field1 = wire('modules')->get('InputfieldCheckbox');
$field1->name = 'button';
$field1->columnWidth = 100;
$field1->label = __("Enable Sticky Button");
$field1->description = __("Create a ui-button with sticky position in templates+pages that you'll select forward.");
$field1->notes = __("This will add a **div.container > a.sticky-button** with a ```\$form->prependMarkup(\$button)``` method");
$field1->icon = "sticky-note";
$field1->value = 0;
$field1->attr('checked', empty($data['button']) ? '' : 'checked');
$tab->add($field1);
if (wire('modules')->get('CustomNotes')->button == 1){
// View Mode Select
$field = wire('modules')->get('InputfieldSelect');
$field->name = 'view_mode_sticky';
$field->icon = 'eye';
$field->columnWidth = 33;
$field->label = __("View Mode (Sticky Button)");
$field->notes = __("Select how to open the link.
Leave blank to open as a default page.");
$field->addOption('pw-modal', 'Modal Popup');
$field->addOption('pw-panel', 'PW Panel');
if(isset($data['view_mode_sticky'])) $field->value = $data['view_mode_sticky'];
$tab->add($field);
// template to apply sticky button
$field = wire('modules')->get('InputfieldAsmSelect');
$field->name = 'tpls_sticky';
$field->icon = 'cubes';
$field->columnWidth = 33;
$field->label = __("Templates to apply sticky button");
$field->notes = __("Save before page select (to filter pages by selected templates).");
$tpls = wire('templates')->find('sort=template.name');
foreach($tpls as $tpl){
$field->addOption($tpl->id,$tpl->name);
}
if(isset($data['tpls_sticky'])) $field->value = $data['tpls_sticky'];
$tab->add($field);
// pages to apply sticky button
if (array_key_exists('tpls_sticky', $data)){
$field = wire('modules')->get('InputfieldAsmSelect');
$field->name = 'pages_sticky';
$field->icon = 'file';
$field->columnWidth = 34;
$field->label = __("Pages to apply sticky button");
$field->notes = __("Published pages (```hasParent!=2```).
To modify that, change selectors into module config.");
$pgs = wire('pages')->find('sort=title, hasParent!=2');
foreach($pgs as $pg){
if (in_array($pg->template->id, wire('modules')->get('CustomNotes')->tpls_sticky)){
$field->addOption($pg->id,$pg->title);
}
}
if(isset($data['pages_sticky'])) $field->value = $data['pages_sticky'];
$tab->add($field);
}
} // End check for button link
// Position settings group
$wrapPos = new InputfieldWrapper();
$setPos = wire('modules')->get('InputfieldFieldset');
$setPos->label = __('Button Position');
$setPos->description = 'CSS rule for positions with percentage values.
Verticlas refer to ```div.container```, horizontals refer to ```a.sticky-button```';
$setPos->collapsed = 1;
$setPos->icon = "arrows";
// $setPos->set("themeColor", "primary");
// $setPos->set("themeOffset", "m");
// Radio buttons
$field = wire('modules')->get("InputfieldRadios");
$field->name = "v_position";
$field->label = __("Vertical Position");
$field->notes = __("Suggested **top**");
$field->columnWidth = 25;
$field->addOption('top');
$field->addOption('bottom');
if (!isset($data['v_position'])) $field->value = 'Bottom';
if (isset($data['v_position'])) $field->value = $data['v_position'];
$setPos->append($field);
$wrapPos->add($setPos);
$perY = wire('modules')->get('InputfieldInteger');
$perY->name = 'ver';
$perY->label = 'Vertical deviation';
$perY->notes = __("Suggested **90**. Don't digit ```%```.");
$perY->icon = __('arrows-v');
$perY->columnWidth = 25;
if (isset($data['ver'])) $perY->value = $data['ver'];
$setPos->append($perY);
$wrapPos->add($setPos);
$field = wire('modules')->get("InputfieldRadios");
$field->name = "h_position";
$field->label = __("Horizontal Position");
$field->notes = __("Suggested **right**");
$field->columnWidth = 25;
$field->addOption('left');
$field->addOption('right');
if (!isset($data['h_position'])) $field->value = 'Right';
if (isset($data['h_position'])) $field->value = $data['h_position'];
$setPos->append($field);
$wrapPos->add($setPos);
$perX = wire('modules')->get('InputfieldInteger');
$perX->name = 'hor';
$perX->label = 'Horizontal deviation';
$perX->notes = __("Suggested **5** Don't digit ```%```.");
$perX->icon = __('arrows-h');
$perX->columnWidth = 25;
if (isset($data['hor'])) $perX->value = $data['hor'];
$setPos->append($perX);
$wrapPos->add($setPos);
$tab->append($wrapPos);
$inputfields->add($tab);
return $inputfields;
}
/*
Flags Reminder
Page Status Flags
1 = published
5 = locked + published
33 = published + unique
37 = published + locked + unique
1025 = hidden
1029 = hidden + locked
1057 = hidden + unique
1061 = hidden + unique + locked
2049 = unpublished
2053 = unpublished + locked
2081 = unpublished + unique
2085 = unpublished + unique + locked
3073 = hidden + unpublished
3077 = hidden + unpublished + locked
3105 = hidden + unpublished + unique
3109 = hidden + unpublished + unique + locked
*/
}