__('Page Trash', __FILE__), // getModuleInfo title 'summary' => __('Handles emptying of Page trash', __FILE__), // getModuleInfo summary 'version' => 101, 'permanent' => true, ); } protected $trashPages; protected $maxItems = 1000; /** * Check if an empty request has been received and delete if so, otherwise render a confirmation form * */ public function ___execute() { if(isset($_POST['submit_empty']) && !empty($_POST['confirm_empty'])) { ini_set('max_execution_time', 60*10); $this->trashPages = $this->pages->get($this->config->trashPageID)->children("limit=$this->maxItems, status<" . Page::statusMax); $this->session->CSRF->validate(); $this->session->message($this->_("The trash has been emptied")); foreach($this->trashPages as $t) $this->pages->delete($t, true); // redirect to admin root after emptying trash $this->session->redirect($this->config->urls->admin); } else { // render a form showing what pages are in the trash and confirming they want to empty it $this->trashPages = $this->pages->get($this->config->trashPageID)->children("limit=2, status<" . Page::statusMax); return $this->render(); } } /** * Render a form showing what pages are in the trash and confirming they want to empty it * */ protected function render() { $form = $this->modules->get("InputfieldForm"); $form->attr('action', './'); $form->attr('method', 'post'); if(!count($this->trashPages)) return "

" . $this->_("The trash is empty") . "

"; $field = $this->modules->get("InputfieldMarkup"); $field->label = $this->_("The following pages are in the trash"); $pageList = $this->modules->get('ProcessPageList'); $pageList->set('id', $this->config->trashPageID); $pageList->set('showRootPage', false); $field->value = $pageList->execute(); $form->add($field); $field = $this->modules->get("InputfieldCheckbox"); $field->attr('name', 'confirm_empty'); $field->attr('value', 1); $field->label = $this->_('Empty trash'); $field->description = $this->_("Please confirm that you want to empty the page trash."); $field->notes = $this->_("If there are too many items in the trash, you may have to empty it multiple times."); $form->add($field); $field = $this->modules->get("InputfieldSubmit"); $field->attr('name', 'submit_empty'); $form->add($field); return $form->render(); } }