aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-30 16:36:52 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-30 16:36:52 +0000
commitdf94762e70f5c143b728a62d90c298fb887231c6 (patch)
tree408a573c876801728806d27a2d5062a2bb7d3dbe /engine/lib
parent2733869001f3cab50d78a79277e6438e258863af (diff)
downloadelgg-df94762e70f5c143b728a62d90c298fb887231c6.tar.gz
elgg-df94762e70f5c143b728a62d90c298fb887231c6.tar.bz2
Added the ability to control widget contexts
git-svn-id: https://code.elgg.org/elgg/trunk@1211 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/widgets.php17
1 files changed, 16 insertions, 1 deletions
diff --git a/engine/lib/widgets.php b/engine/lib/widgets.php
index 6ffc976a2..5156a6332 100644
--- a/engine/lib/widgets.php
+++ b/engine/lib/widgets.php
@@ -196,10 +196,13 @@
* @param string $handler The identifier for the widget handler
* @param string $name The name of the widget type
* @param string $description A description for the widget type
+ * @param string $context A comma-separated list of contexts where this widget is allowed (default: 'all')
+ * @param true|false $multiple Whether or not multiple instances of this widget are allowed on a single dashboard (default: false)
+ * @param string $position A comma-separated list of positions on the page (side or main) where this widget is allowed (default: "side,main")
* @return true|false Depending on success
*/
- function add_widget_type($handler, $name, $description) {
+ function add_widget_type($handler, $name, $description, $context = "all", $multiple = false, $positions = "side,main") {
if (!empty($handler) && !empty($name)) {
@@ -214,6 +217,9 @@
$handlerobj = new stdClass;
$handlerobj->name = $name;
$handlerobj->description = $description;
+ $handlerobj->context = explode(",",$context);
+ $handlerobj->multiple = $multiple;
+ $handlerobj->positions = explode(",",$positions);
$CONFIG->widgets->handlers[$handler] = $handlerobj;
@@ -256,6 +262,15 @@
&& !empty($CONFIG->widgets->handlers)
&& is_array($CONFIG->widgets->handlers)) {
+ $context = get_context();
+
+ foreach($CONFIG->widgets->handlers as $key => $handler) {
+ if (!in_array('all',$handler->context) &&
+ !in_array($context,$handler->context)) {
+ unset($CONFIG->widgets->handlers[$key]);
+ }
+ }
+
return $CONFIG->widgets->handlers;
}