public function handleBatchAction($request)
    {
        // This method can't be called without ajax.
        if (!$request->isAjax()) {
            return $this->parentController->redirectBack();
        }

        // Protect against CSRF on destructive action
        if (!SecurityToken::inst()->checkRequest($request)) {
            return $this->httpError(400);
        }

        // Find the action handler
        $action = $request->param('BatchAction');
        $actionHandler = $this->actionByName($action);

        // Sanitise ID list and query the database for apges
        $csvIDs = $request->requestVar('csvIDs');
        $ids = $this->cleanIDs($csvIDs);

        // Filter ids by those which are applicable to this action
        // Enforces front end filter in LeftAndMain.BatchActions.js:refreshSelected
        $ids = $actionHandler->applicablePages($ids);

        // Query ids and pass to action to process
        $pages = $this->getPages($ids);
        return $actionHandler->run($pages);
    }