_file = WWW_PATH . '/rev'; if (false === $this->doc->getAuth()->getSuMode()) { $this->redirect(BASE_URL . '/admin'); } } protected function _bindFormFields($form) { $form->addElement('text', 'revision', array('label' => 'Site Revision')); $form->revision->addValidator('int'); $form->revision->getValidator('int')->setMessage('Revision is in wrong format', Zend_Validate_Int::NOT_INT); } protected function _getEditForm() { $form = $this->_getBaseForm(); $this->_bindFormFields($form); $this->_bindFormButtons($form); $form->addElement('hidden', 'action', array('value' => 'update')); return $form; } protected function _doEdit() { $form = $this->_getEditForm(); $data = array(); if (file_exists($this->_file)) { $data['revision'] = (int) file_get_contents($this->_file); } $form->setDefaults($data); $this->_renderMainForm($form); } protected function _doUpdate() { $form = $this->_getEditForm(); if ($form->validate()) { $revision = $form->getValue('revision'); if ($revision) { file_put_contents($this->_file, $revision); } else { if (file_exists($this->_file)) { unlink($this->_file); } } $this->_postUpdate(); $this->_setBackMessage('Revision has been updated'); $this->_doBack(); } else { $this->_renderMainForm($form); } return $this; } }