Rev 1207 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1207 | daniel-mar | 1 | |
2 | Path functions in OIDplus |
||
3 | ========================= |
||
4 | |||
5 | How to get relative/absolute paths, e.g. when you are in a plugin? |
||
6 | |||
7 | Here is an overview of the methods `OIDplus::localpath()` and `OIDplus::webpath()`: |
||
8 | |||
9 | +--------------------------------------------------------------------------------- |
||
10 | | Local path URL |
||
11 | --------------------------+--------------------------------------------------------------------------------- |
||
12 | | |
||
1288 | daniel-mar | 13 | Canonical form of the | n/a OIDplus::canonicalURL(null) |
14 | URL in the browser | Example: https://www.example.com/oidplus/?goto=abc&lang=de |
||
15 | (Params preserved and | OIDplus::canonicalURL('def') |
||
16 | ordered) | Example: https://www.example.com/oidplus/?goto=def&lang=de |
||
17 | | |
||
18 | | |
||
19 | URL of the system | n/a OIDplus::getSystemUrl(OIDplus::PATH_RELATIVE) |
||
20 | | Example: ../ |
||
21 | | OIDplus::getSystemUrl(OIDplus::PATH_RELATIVE_TO_ROOT) |
||
22 | | Example: /oidplus/ |
||
23 | | OIDplus::getSystemUrl(OIDplus::PATH_RELATIVE_TO_ROOT_CANONICAL) |
||
24 | | Example: /oidplus/ (if baseconfig CANONICAL_SYSTEM_URL is set) |
||
25 | | OIDplus::getSystemUrl(OIDplus::PATH_ABSOLUTE) |
||
26 | | Example: http://www.example.com/oidplus/ |
||
27 | | OIDplus::getSystemUrl(OIDplus::PATH_ABSOLUTE_CANONICAL) |
||
28 | | Example: http://www.example.org/oidplus/ (if baseconfig CANONICAL_SYSTEM_URL is set) |
||
29 | | |
||
30 | | |
||
1207 | daniel-mar | 31 | Get relative path | OIDplus::localpath(null, true) OIDplus::webpath(null, OIDplus::PATH_RELATIVE) |
32 | to base directory | Example: ../ Example: ../ |
||
33 | | or |
||
34 | | OIDplus::webpath(null, OIDplus::PATH_RELATIVE_TO_ROOT) |
||
35 | | Example: /oidplus/ |
||
36 | | |
||
37 | | |
||
38 | Get relative path | OIDplus::localpath('file.jpg', true) OIDplus::webpath('file.jpg', OIDplus::PATH_RELATIVE) |
||
39 | to any file/dir | Example: xyz/file.jpg Example: xyz/file.jpg |
||
40 | | or |
||
41 | | OIDplus::webpath('file.jpg', OIDplus::PATH_RELATIVE_TO_ROOT) |
||
42 | | Example: /oidplus/xyz/file.jpg |
||
43 | | |
||
44 | | |
||
45 | Get absolute path | OIDplus::localpath(null, false) OIDplus::webpath(null, OIDplus::PATH_ABSOLUTE) |
||
46 | to base directory | Example: /var/www/oidplus/ Example: https://www.example.com/oidplus/ |
||
47 | | |
||
48 | | |
||
49 | Get absolute path | OIDplus::localpath('file.jpg', true) OIDplus::webpath('file.jpg', OIDplus::PATH_ABSOLUTE) |
||
50 | to any file/dir | Example: /var/www/oidplus/xyz/file.jpg Example: https://www.example.com/oidplus/xyz/file.jpg |
||
51 | | |
||
52 | --------------------------+--------------------------------------------------------------------------------- |
||
53 | |||
54 | |||
55 | These function ensure that directories end with a trailing path delimiter. |
||
56 | |||
57 | If you want to prefer the canonical system url (that can be set with the base config setting `CANONICAL_SYSTEM_URL`), |
||
58 | then you can replace `OIDplus::PATH_ABSOLUTE` with `OIDplus::PATH_ABSOLUTE_CANONICAL`. |
||
59 | |||
60 | Usage examples |
||
61 | -------------- |
||
62 | |||
63 | Here are some ways to test it: |
||
64 | |||
65 | echo "Rel Webpath null: ";print_r(OIDplus::webpath(null,OIDplus::PATH_RELATIVE));echo "\n"; |
||
66 | echo "Rel Webpath non-existing: ";print_r(OIDplus::webpath('xxx',OIDplus::PATH_RELATIVE));echo "\n"; |
||
67 | echo "Rel Webpath existing: ";print_r(OIDplus::webpath('test',OIDplus::PATH_RELATIVE));echo "\n"; |
||
68 | echo "Rel Webpath self: ";print_r(OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE));echo "\n"; |
||
69 | |||
70 | echo "Abs Webpath null: ";print_r(OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE));echo "\n"; |
||
71 | echo "Abs Webpath non-existing: ";print_r(OIDplus::webpath('xxx',OIDplus::PATH_ABSOLUTE));echo "\n"; |
||
72 | echo "Abs Webpath existing: ";print_r(OIDplus::webpath('test',OIDplus::PATH_ABSOLUTE));echo "\n"; |
||
73 | echo "Abs Webpath self: ";print_r(OIDplus::webpath(__DIR__,OIDplus::PATH_ABSOLUTE));echo "\n"; |
||
74 | |||
75 | echo "Rel localpath null: ";print_r(OIDplus::localpath(null,true));echo "\n"; |
||
76 | echo "Rel localpath non-existing: ";print_r(OIDplus::localpath('xxx',true));echo "\n"; |
||
77 | echo "Rel localpath existing: ";print_r(OIDplus::localpath('test',true));echo "\n"; |
||
78 | echo "Rel localpath self: ";print_r(OIDplus::localpath(__DIR__,true));echo "\n"; |
||
79 | |||
80 | echo "Abs localpath null: ";print_r(OIDplus::localpath(null,false));echo "\n"; |
||
81 | echo "Abs localpath non-existing: ";print_r(OIDplus::localpath('xxx',false));echo "\n"; |
||
82 | echo "Abs localpath existing: ";print_r(OIDplus::localpath('test',false));echo "\n"; |
||
83 | echo "Abs localpath self: ";print_r(OIDplus::localpath(__DIR__,false));echo "\n"; |