-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlocksCode.module
More file actions
57 lines (47 loc) · 1.65 KB
/
BlocksCode.module
File metadata and controls
57 lines (47 loc) · 1.65 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
<?php
namespace ProcessWire;
class BlocksCode extends WireData implements Module {
public static function getModuleInfo() {
return [
'title' => 'Custom Code Block',
'summary' => 'Installs Template and Fields for a PageGrid Block',
'href' => 'https://page-grid.com/docs/blocks/',
'author' => 'Jan Ploch',
'icon' => 'code',
'autoload' => 'template=admin',
'requires' => array('PageGridBlocks'),
'version' => '0.0.0.12',
'pg_name' => 'pg_code',
'pg_label' => 'Code',
'pg_description' => 'Allows embedding of custom HTML, CSS, and JavaScript code. Provides a code block that executes frontend code while showing disabled preview in the backend editor.'
];
}
//function to create block
public function createBlock() {
$b = $this->modules->get('PageGridBlocks');
$blockName = $this->getModuleInfo()['pg_name'];
$blockLabel = $this->getModuleInfo()['pg_label'];
$blockIcon = $this->getModuleInfo()['icon'];
$t = $b->createTemplate($blockName, $blockLabel, $blockIcon);
$t->noChildren = 1;
$t->save();
$f = $b->createField($blockName, 'FieldtypeTextarea', $blockName);
$f->label = $blockLabel;
$f->inputfieldClass = 'InputfieldTextarea';
$f->contentType = 1;
$f->stripTags = 0;
$f->rows = 30;
$f->textformatters = array();
$f->save();
}
public function ___upgrade($fromVersion, $toVersion) {
$this->createBlock();
}
public function ___install() {
$this->createBlock();
}
public function ___uninstall() {
$blockName = $this->getModuleInfo()['pg_name'];
$this->modules->get('PageGridBlocks')->removeBlock($blockName);
}
}