-
Notifications
You must be signed in to change notification settings - Fork 1
/
Page_builder.php
125 lines (104 loc) · 2.46 KB
/
Page_builder.php
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
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Page_builder
{
protected $ci;
protected $title;
protected $buttons;
protected $breadcrumb;
public function __construct()
{
$this->ci =& get_instance();
}
/**
* ADD BREADCRUMB
* @author Logic Design & Consultancy Ltd
*
* @param string $anchor
* @param string $target
*/
function addCrumb($anchor = 'Page', $target = null)
{
$this->breadcrumb[] = array('target' => $target, 'anchor' => $anchor);
return $this;
}
/**
* OUTPUT BREADCRUMBS
* @author Logic Design & Consultancy Ltd
*
* @return string
*/
function outputCrumb()
{
if ( empty($this->breadcrumb) ) {
return false;
}
$html = '<nav aria-label="breadcrumb">';
$html .= '<ol class="breadcrumb">';
$i = 1;
foreach ( $this->breadcrumb as $crumb ) {
if ( $i < count($this->breadcrumb) ) {
$html .= '<li class="breadcrumb-item">' . anchor($crumb['target'], $crumb['anchor']) . '</li>';
} else {
$html .= '<li class="breadcrumb-item active" aria-current="page">' . $crumb['anchor'] . '</li>';
}
$i++;
}
$html .= '</ol>';
$html .= '</nav>';
return $html;
}
/**
* SET PAGE TITLE
* @author Logic Design & Consultancy Ltd
*
* @param string $text
*/
function setTitle($text = 'Page Title', $pre_title = null)
{
$this->title = ( $pre_title ? '<small>' . $pre_title . '</small>' : '' ) . str_replace('/', '<span class="px-2">/</span>', $text);
return $this;
}
/**
* OUTPUT PAGE TITLE
* @author Logic Design & Consultancy Ltd
*
* @return string
*/
function outputTitle()
{
return ! empty($this->title) ? $this->title : false;
}
/**
* ADD PAGE BUTTON
* @author Logic Design & Consultancy Ltd
*
* @param string $target
* @param string $anchor
* @param integer $style
* @param integer $size
*/
function addButton($target, $anchor = 'Click Here', $style = 1, $size = 2)
{
$this->buttons[] = array( 'target' => $target, 'anchor' => $anchor, 'style' => $style, 'size' => $size );
return $this;
}
/**
* OUTPUT PAGE BUTTONS
* @author Logic Design & Consultancy Ltd
*
* @return string
*/
function outputButtons()
{
if ( empty($this->buttons) ) {
return false;
}
$html = '<div class="btn-group" role="group">';
foreach ( $this->buttons as $btn ) {
$html .= __button($btn['target'], $btn['anchor'], $btn['style'], $btn['size']);
}
$html .= '</div>';
return $html;
}
}