/** * Handle GET requests. * * @param Alpha\Util\Http\Response $request * * @throws Alpha\Exception\IllegalArguementException * * @return Alpha\Util\Http\Response * * @since 1.0 */ public function doGET($request) { self::$logger->debug('>>doGET($request=[' . var_export($request, true) . '])'); $params = $request->getParams(); $config = ConfigProvider::getInstance(); if (!is_array($params)) { throw new IllegalArguementException('Bad $params [' . var_export($params, true) . '] passed to doGET method!'); } $body = View::displayPageHead($this); $message = $this->getStatusMessage(); if (!empty($message)) { $body .= $message; } $body .= '<h3>Listing contents of cache directory: ' . $this->dataDir . '</h3>'; $fileList = ''; $fileCount = FileUtils::listDirectoryContents($this->dataDir, $fileList, 0, array('.htaccess')); $body .= $fileList; $body .= '<h3>Total of ' . $fileCount . ' files in the cache.</h3>'; $body .= '<form action="' . $request->getURI() . '" method="post" name="clearForm" id="clearForm">'; $fieldname = $config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('clearCache')) : 'clearCache'; $body .= '<input type="hidden" name="' . $fieldname . '" id="' . $fieldname . '" value="false"/>'; $js = "if(window.jQuery) {\n BootstrapDialog.show({\n title: 'Confirmation',\n message: 'Are you sure you want to delete all files in the cache?',\n buttons: [\n {\n icon: 'glyphicon glyphicon-remove',\n label: 'Cancel',\n cssClass: 'btn btn-default btn-xs',\n action: function(dialogItself){\n dialogItself.close();\n }\n },\n {\n icon: 'glyphicon glyphicon-ok',\n label: 'Okay',\n cssClass: 'btn btn-default btn-xs',\n action: function(dialogItself) {\n \$('[id=\"" . $fieldname . "\"]').attr('value', 'true');\n \$('#clearForm').submit();\n dialogItself.close();\n }\n }\n ]\n });\n }"; $button = new Button($js, 'Clear cache', 'clearBut'); $body .= $button->render(); $body .= View::renderSecurityFields(); $body .= '</form>'; $body .= View::displayPageFoot($this); self::$logger->debug('<<doGET'); return new Response(200, $body, array('Content-Type' => 'text/html')); }
/** * Testing the listDirectoryContents() method. * * @since 2.0 */ public function testListDirectoryContents() { $fileList = ''; $this->assertTrue(FileUtils::listDirectoryContents('.', $fileList, 0, array()) > 0, 'Testing the listDirectoryContents() method'); $this->assertTrue(strpos($fileList, '</em><br>') !== false, 'Testing the listDirectoryContents() method'); }