/**
  * Revert to a specific version
  *
  * @param void
  * @return null
  */
 function revert()
 {
     if ($this->active_page->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if ($this->request->isSubmitted()) {
         $to_version = null;
         $to_version_num = (int) $this->request->get('to');
         if ($to_version_num) {
             $to_version = PageVersions::findById(array('page_id' => $this->active_page->getId(), 'version' => $to_version_num));
         }
         // if
         if (!instance_of($to_version, 'PageVersion')) {
             $this->httpError(HTTP_ERR_NOT_FOUND);
         }
         // if
         $old_name = $this->active_page->getName();
         $revert = $this->active_page->revertToVersion($to_version);
         if ($revert && !is_error($revert)) {
             flash_success('Page ":name" has been reverted to version #:version', array('name' => $old_name, 'version' => $to_version->getVersion()));
         } else {
             flash_success('Failed to revert ":name" page to version #:version', array('name' => $old_name, 'version' => $to_version->getVersion()));
         }
         // if
         $this->redirectToUrl($this->active_page->getViewUrl());
     } else {
         $this->httpError(HTTP_ERR_BAD_REQUEST);
     }
     // if
 }