FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cakephp_docs/scripts/toc_extractor.php at master · jklgithub/cakephp_docs · GitHub
jklgithub
/
cakephp_docs
Public
forked from
cakephp/docs
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cakephp_docs
/
scripts
/
toc_extractor.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
40 lines (36 loc) · 1.25 KB
Breadcrumbs
cakephp_docs
/
scripts
/
toc_extractor.php
Copy path
File metadata and controls
40 lines (36 loc) · 1.25 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
<?php
$
dir
=
getcwd
();
$
menu
=
array
();
transformMenu
(
$
menu
);
transformIndex
(
$
menu
);
file_put_contents
(
"
$
dir
/_static/menu.json
"
,
json_encode
(
$
menu
));
function
transformIndex
(&
$
menu
) {
$
dir
=
getcwd
();
$
html
=
explode
(
'
<table style="width: 100%" class="indextable genindextable">
'
,
file_get_contents
(
"
$
dir
/genindex.html
"
));
array_shift
(
$
html
);
foreach
(
$
html
as
$
piece
) {
$
piece
=
explode
(
'
</table>
'
,
$
piece
);
$
xml
=
new
SimpleXMLElement
(
$
piece
[
0
]);
foreach
(
$
xml
->
xpath
(
'
//a
'
)
as
$
node
) {
$
tmp
=
$
node
->
attributes
();
$
text
=
$
text
= (
string
)
$
node
;
if
(
$
text
&&
$
text
[
0
] ===
'
(
'
) {
$
url
= (
string
)
$
tmp
[
"
href
"
][
0
];
$
text
=
str_replace
(
'
$
'
,
'
'
,
end
(
explode
(
'
::
'
,
$
url
))) .
'
'
.
$
text
;
}
$
menu
[] =
array
(
'
text
'
=>
$
text
,
'
link
'
=> (
string
)
$
tmp
[
"
href
"
][
0
]);
}
}
}
function
transformMenu
(&
$
menu
) {
$
dir
=
getcwd
();
$
html
=
file_get_contents
(
"
$
dir
/contents.html
"
);
$
html
=
preg_replace
(
'
/&(.+);/
'
,
''
,
$
html
);
$
html
=
str_replace
(
'
xmlns="http://www.w3.org/1999/xhtml"
'
,
''
,
$
html
);
$
xml
=
new
SimpleXMLElement
(
$
html
);
$
path
=
$
xml
->
xpath
(
'
//div[@class="toctree-wrapper compound"]//li/a
'
);
foreach
(
$
path
as
$
node
) {
$
tmp
=
$
node
->
attributes
();
$
menu
[] =
array
(
'
text
'
=> (
string
)
$
node
[
0
],
'
link
'
=> (
string
)
$
tmp
[
"
href
"
][
0
]);
}
}
Back
|
FazBrowse Home
|
New Git URL