示例#1
0
     $widget_ajax = json_decode(init('widget'), true);
     if (file_exists($widget['path'])) {
         $widget_db = widget::byPath($widget['path']);
         if (!is_object($widget_db)) {
             $widget_db = new widget();
         }
     } else {
         $widget_db = new widget();
     }
     utils::a2o($widget_db, $widget_ajax);
     $widget_db->save();
     ajax::success(utils::o2a($widget_db));
 }
 if (init('action') == 'add') {
     $widget = new widget();
     $widget->setName(init('name'));
     $widget->save();
     ajax::success(utils::o2a($widget));
 }
 if (init('action') == 'remove') {
     $widget = widget::byPath(init('path'));
     if (!is_object($widget)) {
         throw new Exception('Widget non trouvé : ' . init('path'));
     }
     $widget->remove();
     ajax::success();
 }
 if (init('action') == 'applyWidget') {
     if (init('path') != 'default') {
         $widget = widget::byPath(init('path'));
         if (!is_object($widget)) {
示例#2
0
 }
 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();