diff options
-rw-r--r-- | engine/lib/widgets.php | 17 | ||||
-rw-r--r-- | views/default/canvas/layouts/widgets.php | 9 |
2 files changed, 25 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;
}
diff --git a/views/default/canvas/layouts/widgets.php b/views/default/canvas/layouts/widgets.php index 47a45c450..cbd267377 100644 --- a/views/default/canvas/layouts/widgets.php +++ b/views/default/canvas/layouts/widgets.php @@ -39,6 +39,9 @@ <table class="draggable_widget" cellspacing="0"><tr><td width="149px"> <h3> <?php echo $widget->name; ?> + <input type="hidden" name="multiple" value="<?php echo $widgettypes[$widget->handler]->multiple; ?>" /> + <input type="hidden" name="side" value="<?php echo in_array('side',$widgettypes[$widget->handler]->positions); ?>" /> + <input type="hidden" name="main" value="<?php echo in_array('main',$widgettypes[$widget->handler]->positions); ?>" /> <input type="hidden" name="handler" value="<?php echo htmlentities($handler); ?>" /> <input type="hidden" name="description" value="<?php echo htmlentities($widget->description); ?>" /> <input type="hidden" name="guid" value="0" /> @@ -93,6 +96,9 @@ Choose the features you want to add to your page by dragging them from the <b>Wi <input type="hidden" name="handler" value="<?php echo $widget->handler; ?>" /> + <input type="hidden" name="multiple" value="<?php echo $widgettypes[$widget->handler]->multiple; ?>" /> + <input type="hidden" name="side" value="<?php echo in_array('side',$widgettypes[$widget->handler]->positions); ?>" /> + <input type="hidden" name="main" value="<?php echo in_array('main',$widgettypes[$widget->handler]->positions); ?>" /> <input type="hidden" name="description" value="<?php echo htmlentities($widgettypes[$widget->handler]->description); ?>" /> <input type="hidden" name="guid" value="<?php echo $widget->getGUID(); ?>" /> </h3> @@ -131,6 +137,9 @@ Choose the features you want to add to your page by dragging them from the <b>Wi <input type="hidden" name="handler" value="<?php echo $widget->handler; ?>" /> + <input type="hidden" name="multiple" value="<?php echo $widgettypes[$widget->handler]->multiple; ?>" /> + <input type="hidden" name="side" value="<?php echo in_array('side',$widgettypes[$widget->handler]->positions); ?>" /> + <input type="hidden" name="main" value="<?php echo in_array('main',$widgettypes[$widget->handler]->positions); ?>" /> <input type="hidden" name="description" value="<?php echo htmlentities($widgettypes[$widget->handler]->description); ?>" /> <input type="hidden" name="guid" value="<?php echo $widget->getGUID(); ?>" /> </h3> |