2007-08-03 00:07:11 +02:00
|
|
|
<?php
|
2008-02-25 03:10:37 +01:00
|
|
|
/**
|
|
|
|
* Represents a set of widgets shown on a page.
|
|
|
|
* @package sapphire
|
|
|
|
* @subpackage widgets
|
|
|
|
*/
|
2007-08-03 00:07:11 +02:00
|
|
|
class WidgetArea extends DataObject {
|
2009-02-02 00:49:53 +01:00
|
|
|
|
2007-08-03 00:07:11 +02:00
|
|
|
static $db = array();
|
|
|
|
|
2009-02-02 00:49:53 +01:00
|
|
|
static $has_one = array();
|
|
|
|
|
2007-08-03 00:07:11 +02:00
|
|
|
static $has_many = array(
|
|
|
|
"Widgets" => "Widget"
|
|
|
|
);
|
|
|
|
|
2009-02-02 00:49:53 +01:00
|
|
|
static $many_many = array();
|
|
|
|
|
|
|
|
static $belongs_many_many = array();
|
|
|
|
|
2009-09-07 05:28:23 +02:00
|
|
|
/**
|
|
|
|
* Used in template instead of {@link Widgets()}
|
|
|
|
* to wrap each widget in its controller, making
|
|
|
|
* it easier to access and process form logic
|
|
|
|
* and actions stored in {@link Widget_Controller}.
|
|
|
|
*
|
|
|
|
* @return DataObjectSet Collection of {@link Widget_Controller}
|
|
|
|
*/
|
|
|
|
function WidgetControllers() {
|
|
|
|
$controllers = new DataObjectSet();
|
|
|
|
foreach($this->Widgets() as $widget) {
|
|
|
|
// find controller
|
|
|
|
$controllerClass = '';
|
|
|
|
foreach(array_reverse(ClassInfo::ancestry($widget->class)) as $widgetClass) {
|
|
|
|
$controllerClass = "{$widgetClass}_Controller";
|
|
|
|
if(class_exists($controllerClass)) break;
|
|
|
|
}
|
|
|
|
$controllers->push(new $controllerClass($widget));
|
|
|
|
}
|
|
|
|
|
|
|
|
return $controllers;
|
|
|
|
}
|
|
|
|
|
2007-08-03 00:07:11 +02:00
|
|
|
function forTemplate() {
|
2008-11-04 03:21:09 +01:00
|
|
|
return $this->renderWith($this->class);
|
2007-08-03 00:07:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|