public function addWidget(DmZone $zone, $moduleAction) { list($module, $action) = explode('/', $moduleAction); $this->info('Add a ' . $moduleAction . ' widget')->get(sprintf('/index.php/+/dmWidget/add?to_dm_zone=%d&mod=' . $module . '&act=' . $action . '&dm_cpi=%d', $zone->id, $this->getPage()->id))->checks(array('module_action' => 'dmWidget/add', 'method' => 'get'))->has('.dm_widget.' . str_replace('dm_widget_', '', dmString::underscore($module)) . '.' . dmString::underscore($action)); $zone->refreshRelated('Widgets'); return $this; }
public function createInZone(DmZone $zone, $moduleAction, $values = array()) { list($module, $action) = explode('/', $moduleAction); $widget = $this->create(array('dm_zone_id' => $zone->get('id'), 'module' => $module, 'action' => $action)); $widget->setValues($values); return $widget; }
public function paste(DmZone $zone) { if (!($widget = $this->getWidget())) { return; } if ('cut' == $this->getMethod()) { $widget->set('dm_zone_id', $zone->get('id')); // cutted then pasted widget becomes copied widget $this->save('widget', array('method' => 'copy', 'id' => $widget->id)); } else { $widget->get('Translation'); $widget = $widget->copy(true); $widget->set('dm_zone_id', $zone->get('id')); } $widget->save(); return $widget; }