function run($request) { $days = intval($request->getVar("days") - 0); if (!$days) { $days = $this->defaultDays; } $countMin = intval($request->getVar("min") - 0); if (!$countMin) { $countMin = $this->defaultMinimum; } $endingDaysBack = intval($request->getVar("ago") - 0); if (!$endingDaysBack) { $endingDaysBack = $this->endingDaysBack; } $field = EcommerceSearchHistoryFormField::create("stats", $this->title)->setNumberOfDays($days)->setMinimumCount($countMin)->setEndingDaysBack($endingDaysBack); echo $field->forTemplate(); $arrayNumberOfDays = array(30, 365); $link = "/dev/tasks/EcommerceTaskReviewSearches/"; for ($months = 0; $months++; $months < 36) { foreach ($arrayNumberOfDays as $numberOfDays) { $myLink = $link . "?ago=" . floor($months * 30.5) . "&days=" . $numberOfDays; DB::alteration_message("<a href=\"" . $myLink . "\">{$months} months ago, last {$numberOfDays} days</a>"); } } }
function getEditForm($id = null, $fields = null) { $form = parent::getEditForm(); if (singleton($this->modelClass) instanceof SiteTree) { if ($gridField = $form->Fields()->dataFieldByName($this->sanitiseClassName($this->modelClass))) { if ($gridField instanceof GridField) { $gridField->setConfig(GridFieldEditOriginalPageConfig::create()); } } } elseif ($this->modelClass == "SearchHistory") { if ($gridField = $form->Fields()->dataFieldByName($this->sanitiseClassName($this->modelClass))) { $form->Fields()->replaceField($gridField->getName(), EcommerceSearchHistoryFormField::create("SearchHistoryTable")); } } return $form; }