|
| 1 | +<?xml version="1.0" encoding="utf-8"?> |
| 2 | +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:cpd="https://github.com/systemsdk/phpcpd/schema" exclude-result-prefixes="cpd"> |
| 3 | +<xsl:output method="html" doctype-system="about:legacy-compat"/> |
| 4 | +<xsl:template match="/"> |
| 5 | +<html> |
| 6 | +<head> |
| 7 | + <meta charset="utf-8"/> |
| 8 | + |
| 9 | + <!-- Dependencies: |
| 10 | + https://getbootstrap.com/docs/5.3/getting-started/download/ |
| 11 | + https://datatables.net/download/ (Styling Bootstrap5 + DataTables + Buttons + Column Visibility + HTML5 Export + JSZip + pdfmake + Print view |
| 12 | + https://releases.jquery.com/ |
| 13 | + --> |
| 14 | + |
| 15 | + < link href= "https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel= "stylesheet" integrity= "sha384-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ" crossorigin= "anonymous"/> |
| 16 | + <script src="https://code.jquery.com/jquery-3.7.0.min.js" integrity="sha256-2Pmvv0kuTBOenSvLm6bvfBSSHrUJ+3A7x6P5Ebd07/g=" crossorigin="anonymous"/> |
| 17 | + <link href="https://cdn.datatables.net/v/bs5/jszip-2.5.0/dt-1.13.4/b-2.3.6/b-html5-2.3.6/b-print-2.3.6/datatables.min.css" rel="stylesheet"/> |
| 18 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"/> |
| 19 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"/> |
| 20 | + <script src="https://cdn.datatables.net/v/bs5/jszip-2.5.0/dt-1.13.4/b-2.3.6/b-html5-2.3.6/b-print-2.3.6/datatables.min.js"/> |
| 21 | + |
| 22 | +</head> |
| 23 | +<body style="padding-top: 3.5rem;"> |
| 24 | + <nav class="navbar navbar-expand-lg fixed-top navbar-dark bg-dark"> |
| 25 | + <a class="navbar-brand" href="#">PHP Copy/Paste Detector</a> |
| 26 | + <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" |
| 27 | + aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"> |
| 28 | + <span class="navbar-toggler-icon"></span> |
| 29 | + </button> |
| 30 | + <div class="collapse navbar-collapse" id="navbarNav"> |
| 31 | + <ul class="navbar-nav"> |
| 32 | + <li class="nav-item"> |
| 33 | + <a class="nav-link active" href="#">Report</a> |
| 34 | + </li> |
| 35 | + <li class="nav-item" id="nav_enable_datatable"> |
| 36 | + <a class="nav-link" href="?d=">Enable datatable</a> |
| 37 | + </li> |
| 38 | + <li class="nav-item" id="nav_disable_datatable"> |
| 39 | + <a class="nav-link" href="?">Disable datatable</a> |
| 40 | + </li> |
| 41 | + <li class="nav-item"> |
| 42 | + <a class="nav-link" target="_blank" rel="noopener noreferrer" href="https://packagist.org/packages/systemsdk/phpcpd">Package page</a> |
| 43 | + </li> |
| 44 | + </ul> |
| 45 | + </div> |
| 46 | + </nav> |
| 47 | + |
| 48 | + <div class="container"> |
| 49 | + <div class="row"> |
| 50 | + <div class="col"> |
| 51 | + <h4>Summary of duplicated code</h4> |
| 52 | + <p>This page summarizes the code fragments that have been found to be replicated in the code.</p> |
| 53 | + |
| 54 | + <table class="table table-light table-bordered table-striped table-hover"> |
| 55 | + <tr> |
| 56 | + <th># Duplications</th> |
| 57 | + <th>Total lines</th> |
| 58 | + <th>Total tokens</th> |
| 59 | + <th>Approximate number of bytes</th> |
| 60 | + </tr> |
| 61 | + <tr> |
| 62 | + <td class="SummaryNumber"><xsl:value-of select="count(//cpd:duplication)"/></td> |
| 63 | + <td class="SummaryNumber"><xsl:value-of select="sum(//cpd:duplication/@lines)"/></td> |
| 64 | + <td class="SummaryNumber"><xsl:value-of select="sum(//cpd:duplication/@tokens)"/></td> |
| 65 | + <td class="SummaryNumber"><xsl:value-of select="sum(//cpd:duplication/@tokens) * 4"/></td> |
| 66 | + </tr> |
| 67 | + </table> |
| 68 | + </div> |
| 69 | + </div> |
| 70 | + |
| 71 | + <div class="row"> |
| 72 | + <div class="col"> |
| 73 | + <h4>Details of duplicated code</h4> |
| 74 | + </div> |
| 75 | + <table style="width:100%" id="data_table" class="table table-light table-bordered table-striped table-hover"> |
| 76 | + <thead> |
| 77 | + <tr> |
| 78 | + <th>lines</th> |
| 79 | + <th>tokens</th> |
| 80 | + <th>files</th> |
| 81 | + <th>codefragment</th> |
| 82 | + </tr> |
| 83 | + </thead> |
| 84 | + <tbody> |
| 85 | + <xsl:apply-templates select="cpd:pmd-cpd/cpd:duplication" /> |
| 86 | + </tbody> |
| 87 | + </table> |
| 88 | + </div> |
| 89 | + </div> |
| 90 | + |
| 91 | +<script> |
| 92 | + let params = (new URL(document.location)).searchParams; |
| 93 | + let showDatatable = false; |
| 94 | + |
| 95 | + //------------ can be called with this parameter d |
| 96 | + if (params.get('d') !== null) { // got it via query param d |
| 97 | + showDatatable = true; |
| 98 | + } |
| 99 | + |
| 100 | + if (showDatatable) { |
| 101 | + $("#nav_disable_datatable").show(); |
| 102 | + $("#nav_enable_datatable").hide(); |
| 103 | + $(document).ready( function () { |
| 104 | + $('#data_table').DataTable({ |
| 105 | + dom: "<'row'<'col-sm-12 col-md-4'B><'col-sm-12 col-md-4'l><'col-sm-12 col-md-4'f>>" + |
| 106 | + "<'row'<'col-sm-12'tr>>" + |
| 107 | + "<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>", |
| 108 | + buttons: [ |
| 109 | + 'copy', 'csv', 'excel', 'pdf', 'print' |
| 110 | + ] |
| 111 | + } |
| 112 | + ); |
| 113 | + } ); |
| 114 | + } else { |
| 115 | + $("#nav_disable_datatable").hide(); |
| 116 | + $("#nav_enable_datatable").show(); |
| 117 | + } |
| 118 | + |
| 119 | +</script> |
| 120 | + |
| 121 | +</body> |
| 122 | +</html> |
| 123 | +</xsl:template> |
| 124 | + |
| 125 | +<!-- templates --> |
| 126 | +<xsl:template match="cpd:pmd-cpd/cpd:duplication"> |
| 127 | + <xsl:for-each select="."> |
| 128 | + <tr> |
| 129 | + <td><xsl:value-of select="@lines"/></td> |
| 130 | + <td><xsl:value-of select="@tokens"/></td> |
| 131 | + <td> |
| 132 | + <table class="table table-light table-bordered table-striped table-hover"> |
| 133 | + <tr><th>line</th><th>endline</th><th>path</th></tr> |
| 134 | + <xsl:for-each select="cpd:file"> |
| 135 | + <tr> |
| 136 | + <td><xsl:value-of select="@line"/></td> |
| 137 | + <td><xsl:value-of select="@endline"/></td> |
| 138 | + <td><xsl:value-of select="@path"/></td> |
| 139 | + </tr> |
| 140 | + </xsl:for-each> |
| 141 | + </table> |
| 142 | + </td> |
| 143 | + <td><pre><xsl:value-of select="cpd:codefragment"/></pre></td> |
| 144 | + </tr> |
| 145 | + </xsl:for-each> |
| 146 | +</xsl:template> |
| 147 | + |
| 148 | +</xsl:stylesheet> |
0 commit comments