File: phpweb.dsl.in

package info (click to toggle)
php-doc 20061001-1
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 45,764 kB
  • ctags: 1,611
  • sloc: xml: 502,485; php: 7,645; cpp: 500; makefile: 297; perl: 161; sh: 141; awk: 28
file content (225 lines) | stat: -rw-r--r-- 5,822 bytes parent folder | download | duplicates (2)
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [
<!ENTITY docbook.dsl SYSTEM "@DOCBOOK_HTML@" CDATA DSSSL>
<!ENTITY html-common.dsl SYSTEM "@srcdir@/html-common.dsl">
<!ENTITY common.dsl SYSTEM "common.dsl">
<!ENTITY version.dsl SYSTEM "@srcdir@/version.dsl">
]>

<!--

  $Id: phpweb.dsl.in,v 1.7 2004/08/04 16:30:59 goba Exp $

  HTML-specific stylesheet customization for use by the online manual.

-->

<style-sheet>
<style-specification id="docbook-php-website" use="docbook">
<style-specification-body>

(declare-flow-object-class processing-instruction
  "UNREGISTERED::James Clark//Flow Object Class::processing-instruction")

(define %html-ext% ".php")
(define %html-manifest% "PHPWEB.manifest")
(define %output-dir% "php")

;; Generate anchor for elements without an ID
;; Hackish workaround. I'm not sure what side effects setting
;; the element number to 0 would have?
(define (generate-anchor #!optional (nd (current-node)))
	(string-append
		"AEN"
		(number->string (or (all-element-number nd) 0))
	)
)

;; Quotes a string to be inserted to a single quoted string
(define (phpweb-quote str)
	(string-replace str "'" "\\'")
)

;; Prints out a PHP file header. Parameter is the current node (unused)
(define (phpweb-header #!optional (nd (current-node)))
	(php-code
		(string-append
			newline
			"include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';"
			newline
			(phpweb-page-setup nd) newline
			"manual_header();" newline
		)
	)
)

;; Prints out manual footer PHP code. Parameter is the current node (unused)
(define (phpweb-footer #!optional (nd (current-node)))
	(php-code
		(string-append
			"manual_footer();" newline
		)
	)
)

;; Retrieves a node's title from the XML source. Parameters are
;; the current node and title element's name (unused)
(define (phpweb-node-title #!optional (nd (current-node)) (title-elem "title"))
	(let*
		(
			(preferred-title-node
				(cond
					;; For "refentry"s search for the first (and only one)
					;; "refname" from the children list of "refnamediv" childrens.
					(
						(equal? (gi nd) "refentry")
							(node-list-first
								(select-elements
									(children
										(select-elements (children nd) "refnamediv")
									)
									"refname"
								)
							)
						)
					;; For other nodes, just select the first children node
					(else
						(node-list-first
							(select-elements (children nd) title-elem)
						)
					)
				)
			)
			;; The title node is the preferred title node, or if
			;; it cannot be find, then then "title" children
			(title-node
				(if (node-list-empty? preferred-title-node)
					(select-elements (children nd) "title")
					preferred-title-node
				)
			)
		)
		(data title-node)
	)
)
	       
;; Prints out the navigational array. Considers that the array was
;; needed (home, prev, next, up, toc) or not needed (local TOC).
;; In the later case, nothing should be printed, in the first
;; case, an emty array need to be injected. For local TOC
;; entries, text should be indented with 4 spaces.
;; Parameters are the node and a #t/#f value indicating that the
;; array is a main navigation array [#t]or local TOC array [#f].
(define (phpweb-header-nav-array nd main_nav_array)
	(let 
		(
			(href (href-to nd))
			(title (phpweb-quote (phpweb-node-title nd "titleabbrev")))
		)
		(if (string=? title "")
			(if main_nav_array
				(string-append "array('', '')," newline)
				""
			)
			(if main_nav_array
				(string-append "array('" href "', '" title "')," newline)
				(string-append "    array('" href "', '" title "')," newline)
			)
		)
	)
)
   
;; Returns a list of strings as provided by the "func" function
;; parameterized with the "node" node. Parameters are the function
;; to use for mapping and the node list on which to apply the mapping
(define (phpweb-node-list-map func ndl)
	(let*
		(
			(node (node-list-first ndl))
			(rest (node-list-rest ndl))
			(item (func node))
		)
		(if (node-list-empty? rest)
			(list item)
			(append (list item) (phpweb-node-list-map func rest))
		)
	)
)

;; Defines the header navigation with PHP calls to set up the
;; navigation array used by TOC printer functions. Parameter is
;; the current node.
(define (phpweb-page-setup nd)
	(let
		(
			(prev (prev-chunk-element nd))
			(next (next-chunk-element nd))
			(up (parent nd))
			(home (sgml-root-element))
			(toc-nodes (siblings (chunk-parent nd)))
		)
		(string-append
			"manual_setup(array(" newline
			"  'head' => array('@ENCODING@', '@LANGWEB@')," newline
			"  'home' => " (phpweb-header-nav-array home #t)
			"  'this' => array('" (phpweb-quote (html-base-filename nd))
			"', '" (phpweb-quote (phpweb-node-title nd)) "')," newline
			"  'prev' => " (phpweb-header-nav-array prev #t)
			"  'next' => " (phpweb-header-nav-array next #t)
			"  'up'   => " (phpweb-header-nav-array up #t)
			"  'toc'  => array(" newline
			(join
				(phpweb-node-list-map 
					(lambda
						(nnl)
						(phpweb-header-nav-array nnl #f)
					)
					toc-nodes
				)
			)
			")));"
		)
	)
)
    
;; Defines the format of all the output files
;; generated for phpweb display. Parameters are the
;; title sequence and the body sequence.
(define (html-document title-sosofo body-sosofo)
	(let
		(
			(doc-sosofo 
				(if (or (chunk?) (node-list=? (current-node) (sgml-root-element)))
					(make sequence
						(phpweb-header (current-node))
						body-sosofo
						(phpweb-footer (current-node))
					)
					body-sosofo
				)
			)
		)
		(if (chunk?)
			(make
				entity
				system-id: (html-entity-file (html-file))
				doc-sosofo
			)
			doc-sosofo
		)
	)
)

&html-common.dsl;
&common.dsl;
&version.dsl;

</style-specification-body>
</style-specification>
<external-specification id="docbook" document="docbook.dsl">
</style-sheet>

<!--
Local Variables:
mode: scheme
End:
-->