public function clear($data, CMSForm $form) { if (isset($data['ToClear'])) { $cleared = array(); foreach ($data['ToClear'] as $name) { $cache = $this->getCache($name); if ($cache) { if (isset($data['Key']) && strlen($data['Key'])) { $cache->delete($data['Key']); } else { $cache->clear(); } $cleared[] = $name; } } $cleared = implode(',', $cleared); $form->sessionMessage("Cleared {$cleared}", 'good'); } else { $form->sessionMessage("No caches cleared", 'good'); } return $form->getResponseNegotiator()->respond($this->getRequest()); }
/** * Handles the creation of mock children with {@link MockDataBuilder} * * @param array $data The data passed in from the form * @param CMSForm $form The Form object that was used * @return SSViewer */ public function doAddMockChildren($data, $form) { $parentPage = SiteTree::get()->byID((int) $data['ID']); if (!$parentPage) { return false; } $className = isset($data['PageType']) ? $data['PageType'] : "Page"; $builder = new MockDataBuilder($className); $builder->setCount((int) $data['Count'])->setIncludeRelations((bool) $data['IncludeRelations'])->setDownloadImages((bool) $data['DownloadImages'])->setParentField("ParentID")->setParentObj($parentPage); try { $ids = $builder->generate(); } catch (Exception $e) { $form->sessionMessage($e->getMessage(), "bad"); return $this->redirectBack(); } $this->response->addHeader('X-Status', _t('MockData.CREATESUCCESS', 'Created {count} mock children under {title}', array('count' => $data['Count'], 'title' => $parentPage->Title))); $this->redirect(Controller::join_links(singleton('CMSPagesController')->Link())); return $this->getResponseNegotiator()->respond($this->request); }