if (init('action') == 'create') { $widget_ajax = json_decode(init('widget'), true); $widget = new widget(); $widget->setName($widget_ajax['name']); $widget->setType($widget_ajax['type']); $widget->setSubtype($widget_ajax['subtype']); $widget->setContent($widget_ajax['content']); $widget->setVersion($widget_ajax['version']); $widget->save(); ajax::success(utils::o2a($widget)); } if (init('action') == 'add') { $widget = new widget(); $_data = init('data'); $widget->setName($_data['name']); $widget->setVersion($_data['version']); $widget->setType($_data['type']); $widget->setSubtype($_data['subtype']); $widget->save(); $result = utils::o2a($widget); $result['path'] = $widget->generatePath(); ajax::success($result); } if (init('action') == 'remove') { $widget = widget::byPath(init('path')); if (!is_object($widget)) { throw new Exception(__('Widget non trouvé : ', __FILE__) . init('path')); } $widget->remove(); ajax::success(); }