86 lines
2.4 KiB
PHP
86 lines
2.4 KiB
PHP
|
|
<?
|
||
|
|
|
||
|
|
namespace controller\ms\widget;
|
||
|
|
|
||
|
|
use ms\ms\structure\msControllerTable;
|
||
|
|
use ms\ms\structure\msModuleTable;
|
||
|
|
use ms\Widget;
|
||
|
|
use ms\widget\Settings;
|
||
|
|
use ms\widget\structure\eWidget;
|
||
|
|
use ms\Table;
|
||
|
|
use ms\widget\structure\eWidgetAction;
|
||
|
|
|
||
|
|
class Api extends msControllerTable {
|
||
|
|
|
||
|
|
static $class = 'ms\Widget';
|
||
|
|
|
||
|
|
static function start(){
|
||
|
|
include_once(dirname(__FILE__).'/views/start.php');
|
||
|
|
}
|
||
|
|
|
||
|
|
static function saveWidthHeight(){
|
||
|
|
$type = intval($_POST['type']);
|
||
|
|
$id = intval($_POST['id']);
|
||
|
|
$oid = intval($_POST['oid']);
|
||
|
|
|
||
|
|
Settings::setValue($type,$id,$oid,
|
||
|
|
$c = [
|
||
|
|
'width' =>max(320,floatval($_POST['width'])),
|
||
|
|
'height'=>max(240,floatval($_POST['height']))
|
||
|
|
]
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
static function window(){
|
||
|
|
$type = intval($_POST['type']);
|
||
|
|
$id = intval($_POST['id']);
|
||
|
|
$oid = intval($_POST['oid']);
|
||
|
|
|
||
|
|
$C = null;
|
||
|
|
$widget = eWidget::$array[$type];
|
||
|
|
if($id) {
|
||
|
|
$C = Widget::getByID($id);
|
||
|
|
}
|
||
|
|
|
||
|
|
$settings = Settings::get($type,$id,$oid);
|
||
|
|
$params = [
|
||
|
|
'data'=>[
|
||
|
|
'type' => $type,
|
||
|
|
'id' => $id ,
|
||
|
|
'oid' => $oid,
|
||
|
|
],
|
||
|
|
'title'=>$widget[eWidget::TITLE],
|
||
|
|
];
|
||
|
|
if($c = $settings[$k = 'width']) $params[$k] = $c;
|
||
|
|
if($c = $settings[$k = 'height']) $params[$k] = $c;
|
||
|
|
|
||
|
|
/** @var msModuleTable $class */
|
||
|
|
$class = $widget[eWidget::CONTROLLER];
|
||
|
|
|
||
|
|
switch ($widget[eWidget::ACTION]) {
|
||
|
|
case eWidgetAction::ADD:
|
||
|
|
$res = $class::renderWindowForm(['module'=>$class]);
|
||
|
|
break;
|
||
|
|
default:
|
||
|
|
$params['no_scroll'] = true;
|
||
|
|
$params['table'] = true;
|
||
|
|
if($C) {
|
||
|
|
$table_id = Widget::getWidgetTableID($C);
|
||
|
|
} else {
|
||
|
|
$table_id = 'table_'.$type.'_'.$id.'_'.$oid;
|
||
|
|
Table::add([
|
||
|
|
Table::$NAME => $table_id,
|
||
|
|
Table::$CLASS => $class,
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
$table_settings = Table::getSettings($table_id);
|
||
|
|
$table_settings += $class::getWindowTableRules();
|
||
|
|
$res = $class::drawTable($table_settings);
|
||
|
|
}
|
||
|
|
echo '<div class="window_content" data-data="'.h(je($params)).'">'.$res.'</div>';
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|