-
Notifications
You must be signed in to change notification settings - Fork 122
/
Copy pathfunctions.xsl
130 lines (113 loc) · 4.89 KB
/
functions.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:pdx="http://xml.phpdox.net/src"
xmlns:pdxf="http://xml.phpdox.net/functions"
xmlns:pu="https://schema.phpunit.de/coverage/1.0"
xmlns:func="http://exslt.org/functions"
xmlns:idx="http://xml.phpdox.net/src"
xmlns:git="http://xml.phpdox.net/gitlog"
xmlns:ctx="ctx://engine/html"
xmlns:php="http://php.net/xsl"
extension-element-prefixes="func"
exclude-result-prefixes="idx pdx pdxf pu git ctx php">
<func:function name="pdxf:link">
<xsl:param name="ctx"/>
<xsl:param name="method"/>
<xsl:param name="copy"/>
<xsl:variable name="dir">
<xsl:choose>
<xsl:when test="local-name($ctx) = 'implements'">interfaces</xsl:when>
<xsl:when test="local-name($ctx) = 'uses'">traits</xsl:when>
<xsl:when test="local-name($ctx) = 'interface'">interfaces</xsl:when>
<xsl:when test="local-name($ctx) = 'interface'">interfaces</xsl:when>
<xsl:when test="local-name($ctx) = 'trait'">traits</xsl:when>
<xsl:when test="local-name($ctx) = 'class'">classes</xsl:when>
<xsl:when test="local-name($unit) = 'interface'">interfaces</xsl:when>
<xsl:when test="local-name($unit) = 'class'">classes</xsl:when>
<xsl:when test="local-name($unit) = 'trait'">traits</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="withMethod">
<xsl:if test="$method != ''">
<xsl:value-of select="concat('/', $method)"/>
</xsl:if>
</xsl:variable>
<xsl:variable name="link">
<xsl:value-of
select="concat($base, $dir, '/', php:function('sha1', concat('', $ctx/@full)), $withMethod, '.', $extension)"/>
</xsl:variable>
<xsl:variable name="text">
<xsl:choose>
<xsl:when test="$copy">
<xsl:value-of select="$copy"/>
</xsl:when>
<xsl:when test="$ctx/@name">
<xsl:value-of select="$ctx/@name"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>object</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<func:result>
<xsl:choose>
<xsl:when test="$ctx/@unresolved = 'true' or not($ctx/@full)">
<xsl:value-of select="$text"/>
</xsl:when>
<xsl:otherwise>
<a title="{$ctx/@full}" href="{$link}">
<xsl:value-of select="$text"/>
</a>
</xsl:otherwise>
</xsl:choose>
</func:result>
</func:function>
<func:function name="pdxf:nl2br">
<xsl:param name="string"/>
<xsl:variable name="format">
<xsl:value-of select="normalize-space(substring-before($string,' '))"/>
<xsl:choose>
<xsl:when test="contains($string,' ')">
<br/>
<xsl:copy-of select="pdxf:nl2br(substring-after($string,' '))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$string"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<func:result>
<xsl:copy-of select="$format"/>
</func:result>
</func:function>
<func:function name="pdxf:format-number">
<xsl:param name="value"/>
<xsl:param name="format">0.##</xsl:param>
<func:result>
<xsl:choose>
<xsl:when test="string(number($value))='NaN'">
<xsl:value-of select="format-number(0, $format)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="format-number($value, $format)"/>
</xsl:otherwise>
</xsl:choose>
</func:result>
</func:function>
<func:function name="pdxf:filesize">
<xsl:param name="bytes"/>
<func:result>
<xsl:choose>
<xsl:when test="floor($bytes div 1024) = 0">
<xsl:value-of select="$bytes"/> Bytes
</xsl:when>
<xsl:when test="floor($bytes div 1048576) = 0">
<xsl:value-of select="format-number(($bytes div 1024), '0.0')"/> KB
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="format-number(($bytes div 1048576), '0.00')"/> MB
</xsl:otherwise>
</xsl:choose>
</func:result>
</func:function>
</xsl:stylesheet>