1<?php 2 3/* 4 Phoronix Test Suite 5 URLs: http://www.phoronix.com, http://www.phoronix-test-suite.com/ 6 Copyright (C) 2015 - 2016, Phoronix Media 7 Copyright (C) 2015 - 2016, Michael Larabel 8 9 This program is free software; you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation; either version 3 of the License, or 12 (at your option) any later version. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program. If not, see <http://www.gnu.org/licenses/>. 21*/ 22 23 24class phoromatic_local_suites implements pts_webui_interface 25{ 26 public static function page_title() 27 { 28 return 'Local Test Suite'; 29 } 30 public static function page_header() 31 { 32 return null; 33 } 34 public static function preload($PAGE) 35 { 36 return true; 37 } 38 public static function render_page_process($PATH) 39 { 40 $suite_dir = phoromatic_server::phoromatic_account_suite_path($_SESSION['AccountID']); 41 $main = '<h1>Local Suites</h1><p>These are test suites created by you or another account within your group. Suites are an easy collection of test profiles. New suits can be trivially made via the <a href="/?build_suite">build suite</a> page.</p>'; 42 43 if(!PHOROMATIC_USER_IS_VIEWER && isset($PATH[0]) && $PATH[0] == 'delete') 44 { 45 foreach(explode(',', $PATH[1]) as $id) 46 { 47 if(is_file($suite_dir . $id . '/suite-definition.xml')) 48 { 49 $main .= '<p><strong>Deleting:</strong> ' . $id . '</p>'; 50 unlink($suite_dir . $id . '/suite-definition.xml'); 51 pts_file_io::delete($suite_dir . $id, null, true); 52 } 53 } 54 } 55 56 $suite_count = 0; 57 foreach(pts_file_io::glob($suite_dir . '*/suite-definition.xml') as $xml_path) 58 { 59 $suite_count++; 60 $id = basename(dirname($xml_path)); 61 $test_suite = new pts_test_suite($xml_path); 62 63 $main .= '<a name="' . $id . '"></a><h1>' . $test_suite->get_title() . ' [' . $id . ']</h1>'; 64 $main .= '<p><strong>' . $test_suite->get_maintainer() . '</strong></p>'; 65 $main .= '<p><em>' . $test_suite->get_description() . '</em></p>'; 66 if(!PHOROMATIC_USER_IS_VIEWER) 67 { 68 $main .= '<p><a href="?build_suite/' . $id . '">Edit Suite</a> - <a href="?local_suites/delete/' . $id . '">Delete Suite</a></p>'; 69 } 70 $main .= '<div style="max-height: 400px; width: 80%; overflow-y: scroll;">'; 71 $test_suite->sort_contained_tests(); 72 foreach($test_suite->get_contained_test_result_objects() as $tro) 73 { 74 $main .= '<h3>' . $tro->test_profile->get_title() . ' [' . $tro->test_profile->get_identifier() . ']</h3>'; 75 $main .= '<p>' . $tro->get_arguments_description() . '</p>'; 76 } 77 $main .= '</div>'; 78 $main .= '<hr />'; 79 } 80 81 if($suite_count == 0) 82 $main .= '<h1>No Test Suites Found</h1>'; 83 84 echo phoromatic_webui_header_logged_in(); 85 echo '<div id="pts_phoromatic_main_area">' . $main . '</div>'; 86 echo phoromatic_webui_footer(); 87 } 88} 89 90?> 91