-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.php
More file actions
99 lines (82 loc) · 2.57 KB
/
plugin.php
File metadata and controls
99 lines (82 loc) · 2.57 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
<?php
/**
* Content boxes plugin for Bludit 3.15.0
* Author: Crysanthus
* License: MIT
* Version: 1.0
* Release Date: 2024-06-18
* Website: https://crysanthus.blogspot.com
* GitHub: https://github.com/crysanthus
*/
class pluginContentBoxes extends Plugin
{
/**
* Initializes the plugin with default database fields for 'nosboxes' and 'noschars'.
*
*/
public function init()
{
$this->dbFields = array(
'nosboxes' => 6,
'noschars' => 50
);
}
/**
* Renders the form for the plugin settings page.
*
* @return string The HTML content for the form.
*/
public function form()
{
global $L;
$html = '<div class="alert alert-primary" role="alert">';
$html .= $this->description();
$html .= '</div>';
$html .= '<div>';
$html .= '<label>' . $L->get('Number of content boxes') . '</label>';
$html .= '<input name="nosboxes" type="number" value="' . $this->getValue('nosboxes') . '">';
$html .= '<span class="tip">' . $L->get('A number of content boxes to display') . '</span>';
$html .= '</div>';
$html .= '<div>';
$html .= '<label>' . $L->get('Number of characters in a content box') . '</label>';
$html .= '<input name="noschars" type="number" value="' . $this->getValue('noschars') . '">';
$html .= '<span class="tip">' . $L->get('A number of characters from the article/post to display') . '</span>';
$html .= '</div>';
return $html;
}
/**
* Renders the content boxes at the end of the site.
*
* @return string The HTML content for the content boxes.
*/
public function siteBodyEnd()
{
global $pages;
$startPageNumber = 1;
$numberOfPages = $this->getValue('nosboxes');
$onlyPublishedPages = true;
$items = $pages->getList($startPageNumber, $numberOfPages, $onlyPublishedPages);
$html = '<div class="container">';
$html .= '<div class="row">';
foreach ($items as $key) {
$page = buildPage($key);
$contentToDisplay = substr(strip_tags($page->content()), 0, $this->getValue('noschars'));
$html .= '<div class="col-md-3 m-1 mb-2 py-1 border rounded shadow">';
$html .= '<div class="panel panel-default">';
$html .= '<div class="panel-heading">';
$html .= '<div class="h4 panel-title">';
$html .= '<a class="text-dark h4" href="' . $page->permalink() . '">' . $page->title() . '</a>';
$html .= '</div>';
$html .= '</div>';
$html .= '<div class="panel-body">';
$html .= $contentToDisplay . ' ...';
$html .= '<a href="' . $page->permalink() . '"> more</a>';
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
}
$html .= '</div>';
$html .= '</div>';
return $html;
}
}