-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWePortal.ContentProvider.php
161 lines (146 loc) · 4.26 KB
/
WePortal.ContentProvider.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
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
<?php
/**
* Content Provider base class, extended by all the future content providers
*
* @package Dragooon:WePortal
* @author Shitiz "Dragooon" Garg <Email [email protected]> <Url http://smf-media.com>
* @copyright Shitiz "Dragooon" Garg <[email protected]>
* @license
* Without express written permission from the author, you cannot redistribute, in any form,
* modified or unmodified versions of the file or the package.
* The header in all the source files must remain intact
*
* Failure to comply with the above will result in lapse of the agreement, upon which you must
* destory all copies of this package, or parts of it, within 48 hours.
*
* THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY WARRANTY. ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE TO ANY PARTY FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* ARISING IN ANY WAY OUT OF THE USE OR MISUSE OF THIS PACKAGE.
*
* @version 0.1 "We're in the right direction!"
*/
/**
* Base class for content providers, meant to be extended and not used as is
*/
abstract class WePContentProvider
{
/**
* Stores the standard information about this block
*/
protected static $name;
protected static $input_parameters = null; // Parameters as set
protected $id_instance;
protected $title;
protected $parameters; // The parameters as passed
protected $holder_parameters;
protected $holder;
protected $portal;
protected $enabled;
protected $info = array();
/**
* Render function can never be pre-defined for a block
* The purpose of this function is to output the HTML for the block
* to display, and not set any templates. Dare you must set any templates
*/
abstract public function render();
/**
* This function is called from the sources, the purpose is to prepare
* any data etc before render is called from the templates
*/
abstract public function prepare();
/**
* This function returns the parameter as needed in the ACP
*/
abstract protected static function getParameters();
/**
* Constructor, takes the basic information and sets them up
*
* @access public
* @param array $parameters The parameters as set in ACP
* @param WePHolder $bar The instance of the holder this content proivder belongs to
* @param WePortal $portal The instance of the portal
* @param string $title The title of this block's instance
* @param int $id The ID of this block's instance
* @param bool $enabled Whether this block is enabled or not
* @param array $info All the information, also includes some of the above (title, id etc)
* @return void
*/
public function __construct(array $parameters, WePHolder $holder, WePortal $portal, $title, $id, $enabled, array $info)
{
// Set the parameters as required by this block
$this->parameters = $parameters['provider'];
$this->holder_parameters = $parameters['holder'];
// Set the bar and portal for future use(If any)
$this->holder = $holder;
$this->portal = $portal;
$this->enabled = $enabled;
// Title for this block
$this->title = $title;
$this->id_instance = $id;
$this->info = $info;
}
/**
* Return the holder parameters
*
* @access public
* @return array
*/
public function getHolderParameters()
{
return $this->holder_parameters;
}
/**
* Static function, returns the name of this block's controller for acp purposes
*
* @static
* @access public
* @return string
*/
public static function getName()
{
return static::$name;
}
/**
* Returns the title of this block
*
* @access public
* @return string
*/
public function title()
{
return $this->title;
}
/**
* Returns the ID of this block
*
* @access public
* @return int
*/
public function id()
{
return $this->id_instance;
}
/**
* Returns whether this block is enabled or not
* Extend this if you want to add a special clause or processing
*
* @access public
* @return bool
*/
public function enabled()
{
return $this->enabled;
}
/**
* Returns the info of this block
*
* @access public
* @return array
*/
public function info()
{
return $this->info;
}
}