Project

General

Profile

« Previous | Next » 

Revision 28bd7c97

Added by Andreas Kohlbecker over 8 years ago

moving content of folder 7.x up to the repository root

View differences:

7.x/.buildpath
1
<?xml version="1.0" encoding="UTF-8"?>
2
<buildpath>
3
	<buildpathentry kind="src" path="modules/cdm_dataportal"/>
4
	<buildpathentry kind="src" path="modules/dwca_export"/>
5
	<buildpathentry kind="src" path="modules/dwca_export_views"/>
6
	<buildpathentry kind="src" path="themes/garland_cichorieae"/>
7
	<buildpathentry kind="src" path="themes/garland_diptera"/>
8
	<buildpathentry kind="src" path="themes/garland_EDIT"/>
9
	<buildpathentry kind="src" path="themes/palmweb_2"/>
10
	<buildpathentry kind="src" path="themes/zen"/>
11
	<buildpathentry kind="src" path="themes/zen_dataportal"/>
12
	<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>
13
</buildpath>
7.x/.project
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>drupalSvn</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.wst.common.project.facet.core.builder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
		<buildCommand>
14
			<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
15
			<arguments>
16
			</arguments>
17
		</buildCommand>
18
		<buildCommand>
19
			<name>org.eclipse.wst.validation.validationbuilder</name>
20
			<arguments>
21
			</arguments>
22
		</buildCommand>
23
		<buildCommand>
24
			<name>org.eclipse.dltk.core.scriptbuilder</name>
25
			<arguments>
26
			</arguments>
27
		</buildCommand>
28
	</buildSpec>
29
	<natures>
30
		<nature>org.eclipse.php.core.PHPNature</nature>
31
		<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
32
		<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
33
	</natures>
34
</projectDescription>
7.x/modules/cdm_dataportal/INSTALL.txt
1
For installation instructions please refer to http://wp5.e-taxonomy.eu/node/7
7.x/modules/cdm_dataportal/LICENSE.txt
1
GNU GENERAL PUBLIC LICENSE
2

  
3
              Version 2, June 1991
4

  
5
Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave,
6
Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute
7
verbatim copies of this license document, but changing it is not allowed.
8

  
9
                  Preamble
10

  
11
The licenses for most software are designed to take away your freedom to
12
share and change it. By contrast, the GNU General Public License is
13
intended to guarantee your freedom to share and change free software--to
14
make sure the software is free for all its users. This General Public License
15
applies to most of the Free Software Foundation's software and to any other
16
program whose authors commit to using it. (Some other Free Software
17
Foundation software is covered by the GNU Library General Public License
18
instead.) You can apply it to your programs, too.
19

  
20
When we speak of free software, we are referring to freedom, not price. Our
21
General Public Licenses are designed to make sure that you have the
22
freedom to distribute copies of free software (and charge for this service if
23
you wish), that you receive source code or can get it if you want it, that you
24
can change the software or use pieces of it in new free programs; and that
25
you know you can do these things.
26

  
27
To protect your rights, we need to make restrictions that forbid anyone to
28
deny you these rights or to ask you to surrender the rights. These restrictions
29
translate to certain responsibilities for you if you distribute copies of the
30
software, or if you modify it.
31

  
32
For example, if you distribute copies of such a program, whether gratis or for
33
a fee, you must give the recipients all the rights that you have. You must make
34
sure that they, too, receive or can get the source code. And you must show
35
them these terms so they know their rights.
36

  
37
We protect your rights with two steps: (1) copyright the software, and (2)
38
offer you this license which gives you legal permission to copy, distribute
39
and/or modify the software.
40

  
41
Also, for each author's protection and ours, we want to make certain that
42
everyone understands that there is no warranty for this free software. If the
43
software is modified by someone else and passed on, we want its recipients
44
to know that what they have is not the original, so that any problems
45
introduced by others will not reflect on the original authors' reputations.
46

  
47
Finally, any free program is threatened constantly by software patents. We
48
wish to avoid the danger that redistributors of a free program will individually
49
obtain patent licenses, in effect making the program proprietary. To prevent
50
this, we have made it clear that any patent must be licensed for everyone's
51
free use or not licensed at all.
52

  
53
The precise terms and conditions for copying, distribution and modification
54
follow.
55

  
56
           GNU GENERAL PUBLIC LICENSE
57
 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND
58
               MODIFICATION
59

  
60
0. This License applies to any program or other work which contains a notice
61
placed by the copyright holder saying it may be distributed under the terms
62
of this General Public License. The "Program", below, refers to any such
63
program or work, and a "work based on the Program" means either the
64
Program or any derivative work under copyright law: that is to say, a work
65
containing the Program or a portion of it, either verbatim or with
66
modifications and/or translated into another language. (Hereinafter, translation
67
is included without limitation in the term "modification".) Each licensee is
68
addressed as "you".
69

  
70
Activities other than copying, distribution and modification are not covered
71
by this License; they are outside its scope. The act of running the Program is
72
not restricted, and the output from the Program is covered only if its contents
73
constitute a work based on the Program (independent of having been made
74
by running the Program). Whether that is true depends on what the Program
75
does.
76

  
77
1. You may copy and distribute verbatim copies of the Program's source
78
code as you receive it, in any medium, provided that you conspicuously and
79
appropriately publish on each copy an appropriate copyright notice and
80
disclaimer of warranty; keep intact all the notices that refer to this License
81
and to the absence of any warranty; and give any other recipients of the
82
Program a copy of this License along with the Program.
83

  
84
You may charge a fee for the physical act of transferring a copy, and you
85
may at your option offer warranty protection in exchange for a fee.
86

  
87
2. You may modify your copy or copies of the Program or any portion of it,
88
thus forming a work based on the Program, and copy and distribute such
89
modifications or work under the terms of Section 1 above, provided that you
90
also meet all of these conditions:
91

  
92
a) You must cause the modified files to carry prominent notices stating that
93
you changed the files and the date of any change.
94

  
95
b) You must cause any work that you distribute or publish, that in whole or in
96
part contains or is derived from the Program or any part thereof, to be
97
licensed as a whole at no charge to all third parties under the terms of this
98
License.
99

  
100
c) If the modified program normally reads commands interactively when run,
101
you must cause it, when started running for such interactive use in the most
102
ordinary way, to print or display an announcement including an appropriate
103
copyright notice and a notice that there is no warranty (or else, saying that
104
you provide a warranty) and that users may redistribute the program under
105
these conditions, and telling the user how to view a copy of this License.
106
(Exception: if the Program itself is interactive but does not normally print such
107
an announcement, your work based on the Program is not required to print
108
an announcement.)
109

  
110
These requirements apply to the modified work as a whole. If identifiable
111
sections of that work are not derived from the Program, and can be
112
reasonably considered independent and separate works in themselves, then
113
this License, and its terms, do not apply to those sections when you distribute
114
them as separate works. But when you distribute the same sections as part
115
of a whole which is a work based on the Program, the distribution of the
116
whole must be on the terms of this License, whose permissions for other
117
licensees extend to the entire whole, and thus to each and every part
118
regardless of who wrote it.
119

  
120
Thus, it is not the intent of this section to claim rights or contest your rights to
121
work written entirely by you; rather, the intent is to exercise the right to
122
control the distribution of derivative or collective works based on the
123
Program.
124

  
125
In addition, mere aggregation of another work not based on the Program
126
with the Program (or with a work based on the Program) on a volume of a
127
storage or distribution medium does not bring the other work under the scope
128
of this License.
129

  
130
3. You may copy and distribute the Program (or a work based on it, under
131
Section 2) in object code or executable form under the terms of Sections 1
132
and 2 above provided that you also do one of the following:
133

  
134
a) Accompany it with the complete corresponding machine-readable source
135
code, which must be distributed under the terms of Sections 1 and 2 above
136
on a medium customarily used for software interchange; or,
137

  
138
b) Accompany it with a written offer, valid for at least three years, to give
139
any third party, for a charge no more than your cost of physically performing
140
source distribution, a complete machine-readable copy of the corresponding
141
source code, to be distributed under the terms of Sections 1 and 2 above on
142
a medium customarily used for software interchange; or,
143

  
144
c) Accompany it with the information you received as to the offer to distribute
145
corresponding source code. (This alternative is allowed only for
146
noncommercial distribution and only if you received the program in object
147
code or executable form with such an offer, in accord with Subsection b
148
above.)
149

  
150
The source code for a work means the preferred form of the work for
151
making modifications to it. For an executable work, complete source code
152
means all the source code for all modules it contains, plus any associated
153
interface definition files, plus the scripts used to control compilation and
154
installation of the executable. However, as a special exception, the source
155
code distributed need not include anything that is normally distributed (in
156
either source or binary form) with the major components (compiler, kernel,
157
and so on) of the operating system on which the executable runs, unless that
158
component itself accompanies the executable.
159

  
160
If distribution of executable or object code is made by offering access to
161
copy from a designated place, then offering equivalent access to copy the
162
source code from the same place counts as distribution of the source code,
163
even though third parties are not compelled to copy the source along with the
164
object code.
165

  
166
4. You may not copy, modify, sublicense, or distribute the Program except as
167
expressly provided under this License. Any attempt otherwise to copy,
168
modify, sublicense or distribute the Program is void, and will automatically
169
terminate your rights under this License. However, parties who have received
170
copies, or rights, from you under this License will not have their licenses
171
terminated so long as such parties remain in full compliance.
172

  
173
5. You are not required to accept this License, since you have not signed it.
174
However, nothing else grants you permission to modify or distribute the
175
Program or its derivative works. These actions are prohibited by law if you
176
do not accept this License. Therefore, by modifying or distributing the
177
Program (or any work based on the Program), you indicate your acceptance
178
of this License to do so, and all its terms and conditions for copying,
179
distributing or modifying the Program or works based on it.
180

  
181
6. Each time you redistribute the Program (or any work based on the
182
Program), the recipient automatically receives a license from the original
183
licensor to copy, distribute or modify the Program subject to these terms and
184
conditions. You may not impose any further restrictions on the recipients'
185
exercise of the rights granted herein. You are not responsible for enforcing
186
compliance by third parties to this License.
187

  
188
7. If, as a consequence of a court judgment or allegation of patent
189
infringement or for any other reason (not limited to patent issues), conditions
190
are imposed on you (whether by court order, agreement or otherwise) that
191
contradict the conditions of this License, they do not excuse you from the
192
conditions of this License. If you cannot distribute so as to satisfy
193
simultaneously your obligations under this License and any other pertinent
194
obligations, then as a consequence you may not distribute the Program at all.
195
For example, if a patent license would not permit royalty-free redistribution
196
of the Program by all those who receive copies directly or indirectly through
197
you, then the only way you could satisfy both it and this License would be to
198
refrain entirely from distribution of the Program.
199

  
200
If any portion of this section is held invalid or unenforceable under any
201
particular circumstance, the balance of the section is intended to apply and
202
the section as a whole is intended to apply in other circumstances.
203

  
204
It is not the purpose of this section to induce you to infringe any patents or
205
other property right claims or to contest validity of any such claims; this
206
section has the sole purpose of protecting the integrity of the free software
207
distribution system, which is implemented by public license practices. Many
208
people have made generous contributions to the wide range of software
209
distributed through that system in reliance on consistent application of that
210
system; it is up to the author/donor to decide if he or she is willing to
211
distribute software through any other system and a licensee cannot impose
212
that choice.
213

  
214
This section is intended to make thoroughly clear what is believed to be a
215
consequence of the rest of this License.
216

  
217
8. If the distribution and/or use of the Program is restricted in certain
218
countries either by patents or by copyrighted interfaces, the original copyright
219
holder who places the Program under this License may add an explicit
220
geographical distribution limitation excluding those countries, so that
221
distribution is permitted only in or among countries not thus excluded. In such
222
case, this License incorporates the limitation as if written in the body of this
223
License.
224

  
225
9. The Free Software Foundation may publish revised and/or new versions
226
of the General Public License from time to time. Such new versions will be
227
similar in spirit to the present version, but may differ in detail to address new
228
problems or concerns.
229

  
230
Each version is given a distinguishing version number. If the Program specifies
231
a version number of this License which applies to it and "any later version",
232
you have the option of following the terms and conditions either of that
233
version or of any later version published by the Free Software Foundation. If
234
the Program does not specify a version number of this License, you may
235
choose any version ever published by the Free Software Foundation.
236

  
237
10. If you wish to incorporate parts of the Program into other free programs
238
whose distribution conditions are different, write to the author to ask for
239
permission. For software which is copyrighted by the Free Software
240
Foundation, write to the Free Software Foundation; we sometimes make
241
exceptions for this. Our decision will be guided by the two goals of
242
preserving the free status of all derivatives of our free software and of
243
promoting the sharing and reuse of software generally.
244

  
245
               NO WARRANTY
246

  
247
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE,
248
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT
249
PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
250
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
251
OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
252
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
253
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
254
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
255
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
256
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
257
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
258
NECESSARY SERVICING, REPAIR OR CORRECTION.
259

  
260
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR
261
AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR
262
ANY OTHER PARTY WHO MAY MODIFY AND/OR
263
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE
264
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL,
265
SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
266
ARISING OUT OF THE USE OR INABILITY TO USE THE
267
PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
268
OR DATA BEING RENDERED INACCURATE OR LOSSES
269
SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE
270
PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN
271
IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF
272
THE POSSIBILITY OF SUCH DAMAGES.
273

  
274
          END OF TERMS AND CONDITIONS
7.x/modules/cdm_dataportal/cdm_api/LICENSE.txt
1
GNU GENERAL PUBLIC LICENSE
2

  
3
              Version 2, June 1991
4

  
5
Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave,
6
Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute
7
verbatim copies of this license document, but changing it is not allowed.
8

  
9
                  Preamble
10

  
11
The licenses for most software are designed to take away your freedom to
12
share and change it. By contrast, the GNU General Public License is
13
intended to guarantee your freedom to share and change free software--to
14
make sure the software is free for all its users. This General Public License
15
applies to most of the Free Software Foundation's software and to any other
16
program whose authors commit to using it. (Some other Free Software
17
Foundation software is covered by the GNU Library General Public License
18
instead.) You can apply it to your programs, too.
19

  
20
When we speak of free software, we are referring to freedom, not price. Our
21
General Public Licenses are designed to make sure that you have the
22
freedom to distribute copies of free software (and charge for this service if
23
you wish), that you receive source code or can get it if you want it, that you
24
can change the software or use pieces of it in new free programs; and that
25
you know you can do these things.
26

  
27
To protect your rights, we need to make restrictions that forbid anyone to
28
deny you these rights or to ask you to surrender the rights. These restrictions
29
translate to certain responsibilities for you if you distribute copies of the
30
software, or if you modify it.
31

  
32
For example, if you distribute copies of such a program, whether gratis or for
33
a fee, you must give the recipients all the rights that you have. You must make
34
sure that they, too, receive or can get the source code. And you must show
35
them these terms so they know their rights.
36

  
37
We protect your rights with two steps: (1) copyright the software, and (2)
38
offer you this license which gives you legal permission to copy, distribute
39
and/or modify the software.
40

  
41
Also, for each author's protection and ours, we want to make certain that
42
everyone understands that there is no warranty for this free software. If the
43
software is modified by someone else and passed on, we want its recipients
44
to know that what they have is not the original, so that any problems
45
introduced by others will not reflect on the original authors' reputations.
46

  
47
Finally, any free program is threatened constantly by software patents. We
48
wish to avoid the danger that redistributors of a free program will individually
49
obtain patent licenses, in effect making the program proprietary. To prevent
50
this, we have made it clear that any patent must be licensed for everyone's
51
free use or not licensed at all.
52

  
53
The precise terms and conditions for copying, distribution and modification
54
follow.
55

  
56
           GNU GENERAL PUBLIC LICENSE
57
 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND
58
               MODIFICATION
59

  
60
0. This License applies to any program or other work which contains a notice
61
placed by the copyright holder saying it may be distributed under the terms
62
of this General Public License. The "Program", below, refers to any such
63
program or work, and a "work based on the Program" means either the
64
Program or any derivative work under copyright law: that is to say, a work
65
containing the Program or a portion of it, either verbatim or with
66
modifications and/or translated into another language. (Hereinafter, translation
67
is included without limitation in the term "modification".) Each licensee is
68
addressed as "you".
69

  
70
Activities other than copying, distribution and modification are not covered
71
by this License; they are outside its scope. The act of running the Program is
72
not restricted, and the output from the Program is covered only if its contents
73
constitute a work based on the Program (independent of having been made
74
by running the Program). Whether that is true depends on what the Program
75
does.
76

  
77
1. You may copy and distribute verbatim copies of the Program's source
78
code as you receive it, in any medium, provided that you conspicuously and
79
appropriately publish on each copy an appropriate copyright notice and
80
disclaimer of warranty; keep intact all the notices that refer to this License
81
and to the absence of any warranty; and give any other recipients of the
82
Program a copy of this License along with the Program.
83

  
84
You may charge a fee for the physical act of transferring a copy, and you
85
may at your option offer warranty protection in exchange for a fee.
86

  
87
2. You may modify your copy or copies of the Program or any portion of it,
88
thus forming a work based on the Program, and copy and distribute such
89
modifications or work under the terms of Section 1 above, provided that you
90
also meet all of these conditions:
91

  
92
a) You must cause the modified files to carry prominent notices stating that
93
you changed the files and the date of any change.
94

  
95
b) You must cause any work that you distribute or publish, that in whole or in
96
part contains or is derived from the Program or any part thereof, to be
97
licensed as a whole at no charge to all third parties under the terms of this
98
License.
99

  
100
c) If the modified program normally reads commands interactively when run,
101
you must cause it, when started running for such interactive use in the most
102
ordinary way, to print or display an announcement including an appropriate
103
copyright notice and a notice that there is no warranty (or else, saying that
104
you provide a warranty) and that users may redistribute the program under
105
these conditions, and telling the user how to view a copy of this License.
106
(Exception: if the Program itself is interactive but does not normally print such
107
an announcement, your work based on the Program is not required to print
108
an announcement.)
109

  
110
These requirements apply to the modified work as a whole. If identifiable
111
sections of that work are not derived from the Program, and can be
112
reasonably considered independent and separate works in themselves, then
113
this License, and its terms, do not apply to those sections when you distribute
114
them as separate works. But when you distribute the same sections as part
115
of a whole which is a work based on the Program, the distribution of the
116
whole must be on the terms of this License, whose permissions for other
117
licensees extend to the entire whole, and thus to each and every part
118
regardless of who wrote it.
119

  
120
Thus, it is not the intent of this section to claim rights or contest your rights to
121
work written entirely by you; rather, the intent is to exercise the right to
122
control the distribution of derivative or collective works based on the
123
Program.
124

  
125
In addition, mere aggregation of another work not based on the Program
126
with the Program (or with a work based on the Program) on a volume of a
127
storage or distribution medium does not bring the other work under the scope
128
of this License.
129

  
130
3. You may copy and distribute the Program (or a work based on it, under
131
Section 2) in object code or executable form under the terms of Sections 1
132
and 2 above provided that you also do one of the following:
133

  
134
a) Accompany it with the complete corresponding machine-readable source
135
code, which must be distributed under the terms of Sections 1 and 2 above
136
on a medium customarily used for software interchange; or,
137

  
138
b) Accompany it with a written offer, valid for at least three years, to give
139
any third party, for a charge no more than your cost of physically performing
140
source distribution, a complete machine-readable copy of the corresponding
141
source code, to be distributed under the terms of Sections 1 and 2 above on
142
a medium customarily used for software interchange; or,
143

  
144
c) Accompany it with the information you received as to the offer to distribute
145
corresponding source code. (This alternative is allowed only for
146
noncommercial distribution and only if you received the program in object
147
code or executable form with such an offer, in accord with Subsection b
148
above.)
149

  
150
The source code for a work means the preferred form of the work for
151
making modifications to it. For an executable work, complete source code
152
means all the source code for all modules it contains, plus any associated
153
interface definition files, plus the scripts used to control compilation and
154
installation of the executable. However, as a special exception, the source
155
code distributed need not include anything that is normally distributed (in
156
either source or binary form) with the major components (compiler, kernel,
157
and so on) of the operating system on which the executable runs, unless that
158
component itself accompanies the executable.
159

  
160
If distribution of executable or object code is made by offering access to
161
copy from a designated place, then offering equivalent access to copy the
162
source code from the same place counts as distribution of the source code,
163
even though third parties are not compelled to copy the source along with the
164
object code.
165

  
166
4. You may not copy, modify, sublicense, or distribute the Program except as
167
expressly provided under this License. Any attempt otherwise to copy,
168
modify, sublicense or distribute the Program is void, and will automatically
169
terminate your rights under this License. However, parties who have received
170
copies, or rights, from you under this License will not have their licenses
171
terminated so long as such parties remain in full compliance.
172

  
173
5. You are not required to accept this License, since you have not signed it.
174
However, nothing else grants you permission to modify or distribute the
175
Program or its derivative works. These actions are prohibited by law if you
176
do not accept this License. Therefore, by modifying or distributing the
177
Program (or any work based on the Program), you indicate your acceptance
178
of this License to do so, and all its terms and conditions for copying,
179
distributing or modifying the Program or works based on it.
180

  
181
6. Each time you redistribute the Program (or any work based on the
182
Program), the recipient automatically receives a license from the original
183
licensor to copy, distribute or modify the Program subject to these terms and
184
conditions. You may not impose any further restrictions on the recipients'
185
exercise of the rights granted herein. You are not responsible for enforcing
186
compliance by third parties to this License.
187

  
188
7. If, as a consequence of a court judgment or allegation of patent
189
infringement or for any other reason (not limited to patent issues), conditions
190
are imposed on you (whether by court order, agreement or otherwise) that
191
contradict the conditions of this License, they do not excuse you from the
192
conditions of this License. If you cannot distribute so as to satisfy
193
simultaneously your obligations under this License and any other pertinent
194
obligations, then as a consequence you may not distribute the Program at all.
195
For example, if a patent license would not permit royalty-free redistribution
196
of the Program by all those who receive copies directly or indirectly through
197
you, then the only way you could satisfy both it and this License would be to
198
refrain entirely from distribution of the Program.
199

  
200
If any portion of this section is held invalid or unenforceable under any
201
particular circumstance, the balance of the section is intended to apply and
202
the section as a whole is intended to apply in other circumstances.
203

  
204
It is not the purpose of this section to induce you to infringe any patents or
205
other property right claims or to contest validity of any such claims; this
206
section has the sole purpose of protecting the integrity of the free software
207
distribution system, which is implemented by public license practices. Many
208
people have made generous contributions to the wide range of software
209
distributed through that system in reliance on consistent application of that
210
system; it is up to the author/donor to decide if he or she is willing to
211
distribute software through any other system and a licensee cannot impose
212
that choice.
213

  
214
This section is intended to make thoroughly clear what is believed to be a
215
consequence of the rest of this License.
216

  
217
8. If the distribution and/or use of the Program is restricted in certain
218
countries either by patents or by copyrighted interfaces, the original copyright
219
holder who places the Program under this License may add an explicit
220
geographical distribution limitation excluding those countries, so that
221
distribution is permitted only in or among countries not thus excluded. In such
222
case, this License incorporates the limitation as if written in the body of this
223
License.
224

  
225
9. The Free Software Foundation may publish revised and/or new versions
226
of the General Public License from time to time. Such new versions will be
227
similar in spirit to the present version, but may differ in detail to address new
228
problems or concerns.
229

  
230
Each version is given a distinguishing version number. If the Program specifies
231
a version number of this License which applies to it and "any later version",
232
you have the option of following the terms and conditions either of that
233
version or of any later version published by the Free Software Foundation. If
234
the Program does not specify a version number of this License, you may
235
choose any version ever published by the Free Software Foundation.
236

  
237
10. If you wish to incorporate parts of the Program into other free programs
238
whose distribution conditions are different, write to the author to ask for
239
permission. For software which is copyrighted by the Free Software
240
Foundation, write to the Free Software Foundation; we sometimes make
241
exceptions for this. Our decision will be guided by the two goals of
242
preserving the free status of all derivatives of our free software and of
243
promoting the sharing and reuse of software generally.
244

  
245
               NO WARRANTY
246

  
247
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE,
248
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT
249
PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
250
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
251
OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
252
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
253
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
254
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
255
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
256
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
257
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
258
NECESSARY SERVICING, REPAIR OR CORRECTION.
259

  
260
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR
261
AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR
262
ANY OTHER PARTY WHO MAY MODIFY AND/OR
263
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE
264
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL,
265
SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
266
ARISING OUT OF THE USE OR INABILITY TO USE THE
267
PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
268
OR DATA BEING RENDERED INACCURATE OR LOSSES
269
SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE
270
PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN
271
IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF
272
THE POSSIBILITY OF SUCH DAMAGES.
273

  
274
          END OF TERMS AND CONDITIONS
7.x/modules/cdm_dataportal/cdm_api/cdm_api.api.php
1
<?php
2

  
3
/**
4
 * @file
5
 * Hooks provided by the CDM API module.
6
 */
7

  
8
/**
9
 * @addtogroup hooks
10
 * @{
11
 */
12

  
13
/**
14
 * Define cdm specific node types.
15
 *
16
 * Modules implementing this hook can add cdm specific node types
17
 *
18
 */
19
function hook_cdm_nodetypes() {
20
  static $nodetypes;
21
  if (!$nodetypes) {
22
    $nodetypes = array(
23
        'cdm_treference' => 'reference',
24
        'cdm_taxon' => 'taxon',
25
    );
26
  }
27
  return $nodetypes;
28
}
29

  
30
/**
31
 * @} End of "addtogroup hooks".
32
 */
7.x/modules/cdm_dataportal/cdm_api/cdm_api.info
1
name = "CDM API"
2
description = "CDM Web Service API"
3
version = 7.x-3.0
4
package = "CDM"
5
core = 7.x
7.x/modules/cdm_dataportal/cdm_api/cdm_api.install
1
<?php
2
/**
3
 * @file
4
 * Install, update and uninstall functions for the cdm_api module.
5
 */
6

  
7
/**
8
 * Implements hook_schema().
9
 * The drupal_(un)install_schema functions are called automatically in D7.
10
 */
11
function cdm_api_schema() {
12
  $schema['cache_cdm_ws'] = array(
13
    'fields' => array(
14
      'cid' => array(
15
        'description' => 'Primary Key: Unique cache ID.',
16
        'type' => 'varchar',
17
        'length' => '333',
18
        'not null' => TRUE,
19
        'default' => '',
20
      ),
21
      'data' => array(
22
        'description' => 'The data to cache.',
23
        'type' => 'blob',
24
        'size' => 'big',
25
        'not null' => FALSE,
26
      ),
27
      'expire' => array(
28
        'description' => 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.',
29
        'type' => 'int',
30
        'not null' => TRUE,
31
        'default' => 0,
32
        'disp-width' => '11',
33
      ),
34
      'created' => array(
35
        'description' => 'Unix timestamp indicating when the cache entry was created.',
36
        'type' => 'int',
37
        'not null' => TRUE,
38
        'default' => 0,
39
        'disp-width' => '11',
40
      ),
41
      'serialized' => array(
42
        'description' => 'A flag to indicate whether content is serialized by Drupal (1) or not (0).',
43
        'type' => 'int',
44
        'size' => 'small',
45
        'not null' => FALSE,
46
      ),
47
    ),
48
    'primary key' => array('cid'),
49
    'indexes' => array(
50
      'expire' => array('expire'),
51
    ),
52
    // Important, since the 'cid' field is too big to create a key on in INNODB.
53
    // InnoDB allows a max. key length of 767 bytes, MyISAM 1000 bytes, which is
54
    // for utf8 (333*3)+1, so 333 characters max. instead of 255 chars.
55
    'mysql_engine' => 'MyISAM',
56
  );
57

  
58
  // @Comment WA: please describe the fields.
59
  $schema['node_cdm'] = array(
60
    'fields' => array(
61
      'nid' => array(
62
        'type' => 'int',
63
        'not null' => TRUE,
64
        'disp-width' => '11',
65
      ),
66
      'wsuri' => array(
67
        'type' => 'varchar',
68
        'length' => '255',
69
        'not null' => FALSE,
70
      ),
71
      'hash' => array(
72
        'type' => 'char',
73
        'length' => '32',
74
        'not null' => TRUE,
75
      ),
76
      'cdmtype' => array(
77
        'type' => 'varchar',
78
        'length' => '255',
79
        'not null' => FALSE,
80
      ),
81
      'uuid' => array(
82
        'type' => 'varchar',
83
        'length' => '255',
84
        'not null' => TRUE,
85
        'default' => '',
86
      ),
87
    ),
88
    'primary key' => array('hash'),
89
  );
90

  
91
  return $schema;
92
}
93

  
94
/**
95
 * Update D5 cache table to match Drupal 7 cache table columns.
96
 */
97
function cdm_api_update_7000() {
98
  $schema = cdm_api_schema();
99

  
100
  // No need to use db_change_field() here.
101
  // We simply drop and recreate the cache tables to start clean.
102
  db_drop_table('cache_cdm_ws');
103
  db_create_table('cache_cdm_ws', $schema['cache_cdm_ws']);
104
}
105

  
106

  
107
/**
108
 * Implements hook_requirements().
109
 *
110
 * This hook, like all others dealing with installation and updates, must
111
 * reside in the .install file, or it will not properly abort the installation
112
 * of the module if a critical requirement is missing.
113
 */
114
function cdm_api_requirements() {
115
  $requirements['cdm_api'] = array(
116
    'title' => 'CDM API'
117
  );
118

  
119
  return $requirements;
120
}
7.x/modules/cdm_dataportal/cdm_api/cdm_api.module
1
<?php
2
  /**
3
   * @file
4
   * Required or useful functions for using CDM Data Store Webservices.
5
   *
6
   * Naming conventions:
7
   * ----------------------
8
   * - All webservice access methods are prefixed with cdm_ws.
9
   *
10
   * @copyright
11
   *   (C) 2007-2012 EDIT
12
   *   European Distributed Institute of Taxonomy
13
   *   http://www.e-taxonomy.eu
14
   *
15
   *   The contents of this module are subject to the Mozilla
16
   *   Public License Version 1.1.
17
   * @see http://www.mozilla.org/MPL/MPL-1.1.html
18
   *
19
   * @author
20
   *   - Andreas Kohlbecker <a.kohlbecker@BGBM.org>
21
   *   - Wouter Addink <w.addink@eti.uva.nl> (migration from Drupal 5 to Drupal7)
22
   */
23

  
24
  module_load_include('php', 'cdm_api', 'xml2json');
25
  module_load_include('php', 'cdm_api', 'commons');
26
  module_load_include('php', 'cdm_api', 'uuids');
27
  module_load_include('php', 'cdm_api', 'enums');
28
  module_load_include('php', 'cdm_api', 'webservice_uris');
29
  module_load_include('php', 'cdm_api', 'cdm_node');
30

  
31
  /**
32
   * Timeout used to override the default of 30 seconds
33
   * in @see drupal_http_request()
34
   *
35
   * @var CDM_HTTP_REQUEST_TIMEOUT: A float representing the maximum number of seconds the function
36
   *     call may take
37
   */
38
  define('CDM_HTTP_REQUEST_TIMEOUT', 90.0);
39

  
40
  define('SORT_ORDER_ID', 'sort_by_order_id');
41

  
42
/**
43
 * Implements hook_menu().
44
 */
45
function cdm_api_menu() {
46
  $items = array();
47

  
48
  // usage: url('cdm_api/proxy/'.urlencode($content_url)."/$theme");
49
  $items['cdm_api/proxy'] = array(
50
    'page callback' => 'proxy_content',
51
    'access arguments' => array(
52
      'access content',
53
    ),
54
    'type' => MENU_CALLBACK,
55
  );
56

  
57
  $items['cdm_api/setvalue/session'] = array(
58
    'page callback' => 'setvalue_session',
59
    'access arguments' => array(
60
      'access content',
61
    ),
62
    'type' => MENU_CALLBACK,
63
  );
64

  
65
  return $items;
66
}
67

  
68
/**
69
 * Implements hook_block_info().
70
 */
71
function cdm_api_block_info() {
72

  
73
  $block['cdm_ws_debug'] = array(
74
      "info" => t("CDM web service debug"),
75
      "cache" => DRUPAL_NO_CACHE
76
  );
77
  return $block;
78
}
79

  
80
/**
81
 * Implements hook_block_view().
82
 */
83
function cdm_api_block_view($delta) {
84
  switch ($delta) {
85
    case 'cdm_ws_debug':
86

  
87
    $cdm_ws_url = variable_get('cdm_webservice_url', '');
88

  
89
    $field_map = array(
90
        'ws_uri' => t('URI') . ' <code>(' . $cdm_ws_url .'...)</code>',
91
        'time' => t('Time'),
92
        'fetch_seconds' => t('Fetching [s]'),
93
        'parse_seconds' => t('Parsing [s]'),
94
        'size_kb' => t('Size [kb]'),
95
        'status' => t('Status'),
96
        'data_links' =>  t('Links'),
97
    );
98

  
99

  
100
    if (!isset($_SESSION['cdm']['ws_debug'])) {
101
      $_SESSION['cdm']['ws_debug'] = array();
102
    }
103

  
104
    $header = '<thead><tr><th>' . join('</th><th>' , array_values($field_map)) . '</th></thead>';
105
    $footer = '<tfoot><tr><th>' . join('</th><th>' , array_values($field_map)) . '</th></tfoot>';
106
    $rows = array();
107

  
108
    foreach ($_SESSION['cdm']['ws_debug'] as $data){
109

  
110
      $data = unserialize($data);
111

  
112
      // stip of webservice base url
113
      $data['ws_uri'] = str_replace($cdm_ws_url, '', $data['ws_uri']);
114
      if($data['method'] == 'POST'){
115
        $data['ws_uri'] = 'POST: ' . $data['ws_uri'] . '?' . $data['post_data'];
116
      }
117

  
118
      $cells = array();
119
      foreach ($field_map as $field => $label){
120
        $cells[] = '<td class="' . $field . '">' .  $data[$field] . '</td>';
121
      }
122
      $rows[] = '<tr class="' . $data['status']  . '">' . join('' , $cells). '</tr>';
123
    }
124
    // clear session again
125
    $_SESSION['cdm']['ws_debug'] = array();
126

  
127
    _add_js_ws_debug();
128

  
129
    $block['subject'] = ''; // no subject, title in content for having a defined element id
130
    // otherwise it would depend on the theme
131
    $block['content'] =
132
        '<h4 id="cdm-ws-debug-button">' . t('CDM Debug') . '</h4>'
133
          // cannot use theme_table() since table footer is not jet supported in D7
134
        . '<div id="cdm-ws-debug-table-container"><table id="cdm-ws-debug-table">'
135
        . $header
136
        . '<tbody>' . join('', $rows) . '</tbody>'
137
        . $footer
138
        . '</table></div>';
139

  
140
    return $block;
141
  }
142
}
143

  
144
/**
145
 * Implements hook_cron().
146
 *
147
 * Expire outdated cache entries.
148
 */
149
function cdm_api_cron() {
150
  cache_clear_all(NULL, 'cache_cdm_ws');
151
}
152

  
153
/**
154
 * @todo Please document this function.
155
 * @see http://drupal.org/node/1354
156
 */
157
function cdm_api_permission() {
158
  return array(
159
    'administer cdm_api' => array(
160
      'title' => t('administer cdm_api'),
161
      'description' => t("TODO Add a description for 'administer cdm_api'"),
162
    ),
163
  );
164
}
165

  
166
/**
167
 * Converts an array of TaggedText items into corresponding html tags.
168
 *
169
 * Each item is provided with a class attribute which is set to the key of the
170
 * TaggedText item.
171
 *
172
 * @param array $taggedtxt
173
 *   Array with text items to convert.
174
 * @param string $tag
175
 *   Html tag name to convert the items into, default is 'span'.
176
 * @param string $glue
177
 *   The string by which the chained text tokens are concatenated together.
178
 *   Default is a blank character.
179
 *
180
 * @return string
181
 *   A string with HTML.
182
 */
183
function cdm_taggedtext2html(array $taggedtxt, $tag = 'span', $glue = ' ', $skiptags = array()) {
184
  $out = '';
185
  $i = 0;
186
  foreach ($taggedtxt as $tt) {
187
    if (!in_array($tt->type, $skiptags) && strlen($tt->text) > 0) {
188
      $out .= (strlen($out) > 0 && ++$i < count($taggedtxt) ? $glue : '') . '<' . $tag . ' class="' . $tt->type . '">' . t($tt->text) . '</' . $tag . '>';
189
    }
190
  }
191
  return $out;
192
}
193

  
194
/**
195
 * Finds the text tagged with $tag_type in an array of taggedText instances.
196
 *
197
 * Comment @WA: this function seems unused.
198
 *
199
 * @param array $taggedtxt
200
 *   Array with text items.
201
 * @param string $tag_type
202
 *   The type of tag for which to find text items in the $taggedtxt array.
203
 *
204
 * @return array
205
 *   An array with the texts mapped by $tag_type.
206
 */
207
function cdm_taggedtext_values(array $taggedtxt, $tag_type) {
208
  $tokens = array();
209
  if (!empty($taggedtxt)) {
210
    foreach ($taggedtxt as $tagtxt) {
211
      if ($tagtxt->type == $tag_type) {
212
        $tokens[] = $tagtxt->text;
213
      }
214
    }
215
  }
216
  return $tokens;
217
}
218

  
219
/**
220
 * Returns the currently classification tree in use.
221
 */
222
function get_taxonomictree_uuid_selected() {
223
  if (isset($_SESSION['cdm']['taxonomictree_uuid']) && is_uuid($_SESSION['cdm']['taxonomictree_uuid'])) {
224
    return $_SESSION['cdm']['taxonomictree_uuid'];
225
  }
226
  else {
227
    return variable_get(CDM_TAXONOMICTREE_UUID, FALSE);
228
  }
229
}
230

  
231
/**
232
 * Lists the classifications a taxon belongs to
233
 *
234
 * @param CDM type Taxon $taxon
235
 *   the taxon
236
 *
237
 * @return array
238
 *   aray of CDM instances of Type Classification
239
 */
240
function get_classifications_for_taxon($taxon) {
241

  
242
  return cdm_ws_get(CDM_WS_TAXON_CLASSIFICATIONS, $taxon->uuid);;
243
}
244

  
245
/**
246
 * Returns the chosen FeatureTree for the taxon profile.
247
 *
248
 * The FeatureTree profile returned is the one that has been set in the
249
 * dataportal settings (layout->taxon:profile).
250
 * When the chosen FeatureTree is not found in the database,
251
 * the standard feature tree (UUID_DEFAULT_FEATURETREE) will be returned.
252
 *
253
 * @return mixed
254
 *   A cdm FeatureTree object.
255
 */
256
function get_profile_feature_tree() {
257
  static $profile_featureTree;
258

  
259
  if($profile_featureTree == NULL) {
260
    $profile_featureTree = cdm_ws_get(
261
      CDM_WS_FEATURETREE,
262
      variable_get(CDM_PROFILE_FEATURETREE_UUID, UUID_DEFAULT_FEATURETREE)
263
    );
264
    if (!$profile_featureTree) {
265
      $profile_featureTree = cdm_ws_get(CDM_WS_FEATURETREE, UUID_DEFAULT_FEATURETREE);
266
    }
267
  }
268

  
269
  return $profile_featureTree;
270
}
271

  
272
/**
273
 * Returns the chosen FeatureTree for SpecimenDescriptions.
274
 *
275
 * The FeatureTree returned is the one that has been set in the
276
 * dataportal settings (layout->taxon:specimen).
277
 * When the chosen FeatureTree is not found in the database,
278
 * the standard feature tree (UUID_DEFAULT_FEATURETREE) will be returned.
279
 *
280
 * @return mixed
281
 *   A cdm FeatureTree object.
282
 */
283
function cdm_get_occurrence_featureTree() {
284
  static $occurrence_featureTree;
285

  
286
  if($occurrence_featureTree == NULL) {
287
    $occurrence_featureTree = cdm_ws_get(
288
      CDM_WS_FEATURETREE,
289
      variable_get(CDM_OCCURRENCE_FEATURETREE_UUID, UUID_DEFAULT_FEATURETREE)
290
    );
291
    if (!$occurrence_featureTree) {
292
      $occurrence_featureTree = cdm_ws_get(CDM_WS_FEATURETREE, UUID_DEFAULT_FEATURETREE);
293
    }
294
  }
295
  return $occurrence_featureTree;
296
}
297

  
298
/**
299
 * Returns the FeatureTree for structured descriptions
300
 *
301
 * The FeatureTree returned is the one that has been set in the
302
 * dataportal settings (layout->taxon:profile).
303
 * When the chosen FeatureTree is not found in the database,
304
 * the standard feature tree (UUID_DEFAULT_FEATURETREE) will be returned.
305
 *
306
 * @return mixed
307
 *   A cdm FeatureTree object.
308
 */
309
function get_structured_description_featureTree() {
310
  static $structured_description_featureTree;
311

  
312
  if($structured_description_featureTree == NULL) {
313
    $structured_description_featureTree = cdm_ws_get(
314
        CDM_WS_FEATURETREE,
315
        variable_get(CDM_DATAPORTAL_STRUCTURED_DESCRIPTION_FEATURETREE_UUID, UUID_DEFAULT_FEATURETREE)
316
    );
317
    if (!$structured_description_featureTree) {
318
      $structured_description_featureTree = cdm_ws_get(
319
          CDM_WS_FEATURETREE,
320
          UUID_DEFAULT_FEATURETREE
321
      );
322
    }
323
  }
324
  return $structured_description_featureTree;
325
}
326

  
327
/**
328
 * @todo Please document this function.
329
 * @see http://drupal.org/node/1354
330
 */
331
function switch_to_taxonomictree_uuid($taxonomictree_uuid) {
332
  $_SESSION['cdm']['taxonomictree_uuid'] = $taxonomictree_uuid;
333
}
334

  
335
/**
336
 * @todo Please document this function.
337
 * @see http://drupal.org/node/1354
338
 */
339
function reset_taxonomictree_uuid($taxonomictree_uuid) {
340
  unset($_SESSION['cdm']['taxonomictree_uuid']);
341
}
342

  
343
/**
344
 * @todo Please document this function.
345
 * @see http://drupal.org/node/1354
346
 */
347
function set_last_taxon_page_tab($taxonPageTab) {
348
  $_SESSION['cdm']['taxon_page_tab'] = $taxonPageTab;
349
}
350

  
351
/**
352
 * @todo Please document this function.
353
 * @see http://drupal.org/node/1354
354
 */
355
function get_last_taxon_page_tab() {
356
  if (isset($_SESSION['cdm']['taxon_page_tab'])) {
357
    return $_SESSION['cdm']['taxon_page_tab'];
358
  }
359
  else {
360
    return FALSE;
361
  }
362
}
363

  
364
/**
365
 * @todo Improve the documentation of this function.
366
 *
367
 * media Array [4]
368
 * representations Array [3]
369
 * mimeType image/jpeg
370
 * representationParts Array [1]
371
 * duration 0
372
 * heigth 0
373
 * size 0
374
 * uri
375
 * http://wp5.e-taxonomy.eu/dataportal/cichorieae/media/protolog/jpeg/Acanthocephalus_p1.jpg
376
 * uuid 15c687f1-f79d-4b79-992f-7ba0f55e610b
377
 * width 0
378
 * suffix jpg
379
 * uuid 930b7d51-e7b6-4350-b21e-8124b14fe29b
380
 * title
381
 * uuid 17e514f1-7a8e-4daa-87ea-8f13f8742cf9
382
 *
383
 * @param object $media
384
 * @param array $mimeTypes
385
 * @param int $width
386
 * @param int $height
387
 *
388
 * @return array
389
 *   An array with preferred media representations or else an empty array.
390
 */
391
function cdm_preferred_media_representations($media, array $mimeTypes, $width = 400, $height = 300) {
392
  $prefRepr = array();
393
  if (!isset($media->representations[0])) {
394
    return $prefRepr;
395
  }
396

  
397
  while (count($mimeTypes) > 0) {
398
    // getRepresentationByMimeType
399
    $mimeType = array_shift($mimeTypes);
400

  
401
    foreach ($media->representations as &$representation) {
402
      // If the mimetype is not known, try inferring it.
403
      if (!$representation->mimeType) {
404
        if (isset($representation->parts[0])) {
405
          $representation->mimeType = infer_mime_type($representation->parts[0]->uri);
406
        }
407
      }
408

  
409
      if ($representation->mimeType == $mimeType) {
410
        // Preferred mimetype found -> erase all remaining mimetypes
411
        // to end loop.
412
        $mimeTypes = array();
413
        $dwa = 0;
414
        $dw = 0;
415
        // Look for part with the best matching size.
416
        foreach ($representation->parts as $part) {
417
          if (isset($part->width) && isset($part->height)) {
418
            $dw = $part->width * $part->height - $height * $width;
419
          }
420
          if ($dw < 0) {
421
            $dw *= -1;
422
          }
423
          $dwa += $dw;
424
        }
425
        $dwa = (count($representation->parts) > 0) ? $dwa / count($representation->parts) : 0;
426
        $prefRepr[$dwa . '_'] = $representation;
427
      }
428
    }
429
  }
430
  // Sort the array.
431
  krsort($prefRepr);
432
  return $prefRepr;
433
}
434

  
435
/**
436
 * Infers the mime type of a file using the filename extension.
437
 *
438
 * The filename extension is used to infer the mime type.
439
 *
440
 * @param string $filepath
441
 *   The path to the respective file.
442
 *
443
 * @return string
444
 *   The mimetype for the file or FALSE if the according mime type could
445
 *   not be found.
446
 */
447
function infer_mime_type($filepath) {
448
  static $mimemap = NULL;
449
  if (!$mimemap) {
450
    $mimemap = array(
451
      'jpg' => 'image/jpeg',
452
      'jpeg' => 'image/jpeg',
453
      'png' => 'image/png',
454
      'gif' => 'image/gif',
455
      'giff' => 'image/gif',
456
      'tif' => 'image/tif',
457
      'tiff' => 'image/tif',
458
      'pdf' => 'application/pdf',
459
      'html' => 'text/html',
460
      'htm' => 'text/html',
461
    );
462
  }
463
  $extension = substr($filepath, strrpos($filepath, '.') + 1);
464
  if (isset($mimemap[$extension])) {
465
    return $mimemap[$extension];
466
  }
467
  else {
468
    // FIXME remove this hack just return FALSE;
469
    return 'text/html';
470
  }
471
}
472

  
473
/**
474
 * Converts an ISO 8601 org.joda.time.Partial to a year.
475
 *
476
 * The function expects an ISO 8601 time representation of a
477
 * org.joda.time.Partial of the form yyyy-MM-dd.
478
 *
479
 * @param string $partial
480
 *   ISO 8601 time representation of a org.joda.time.Partial.
481
 *
482
 * @return string
483
 *   Returns the year. In case the year is unknown (= ????), it returns NULL.
484
 */
485
function partialToYear($partial) {
486
  if (is_string($partial)) {
487
    $year = substr($partial, 0, 4);
488
    if (preg_match("/[0-9][0-9][0-9][0-9]/", $year)) {
489
      return $year;
490
    }
491
  }
492
  return;
493
}
494

  
495
/**
496
 * Converts an ISO 8601 org.joda.time.Partial to a month.
497
 *
498
 * This function expects an ISO 8601 time representation of a
499
 * org.joda.time.Partial of the form yyyy-MM-dd.
500
 * In case the month is unknown (= ???) NULL is returned.
501
 *
502
 * @param string $partial
503
 *   ISO 8601 time representation of a org.joda.time.Partial.
504
 *
505
 * @return string
506
 *   A month.
507
 */
508
function partialToMonth($partial) {
509
  if (is_string($partial)) {
510
    $month = substr($partial, 5, 2);
511
    if (preg_match("/[0-9][0-9]/", $month)) {
512
      return $month;
513
    }
514
  }
515
  return;
516
}
517

  
518
/**
519
 * Converts an ISO 8601 org.joda.time.Partial to a day.
520
 *
521
 * This function expects an ISO 8601 time representation of a
522
 * org.joda.time.Partial of the form yyyy-MM-dd and returns the day as string.
523
 * In case the day is unknown (= ???) NULL is returned.
524
 *
525
 * @param string $partial
526
 *   ISO 8601 time representation of a org.joda.time.Partial.
527
 *
528
 * @return string
529
 *   A day.
530
 */
531
function partialToDay($partial) {
532
  if (is_string($partial)) {
533
    $day = substr($partial, 8, 2);
534
    if (preg_match("/[0-9][0-9]/", $day)) {
535
      return $day;
536
    }
537
  }
538
  return;
539
}
540

  
541
/**
542
 * Converts an ISO 8601 org.joda.time.Partial to YYYY-MM-DD.
543
 *
544
 * This function expects an ISO 8601 time representations of a
545
 * org.joda.time.Partial of the form yyyy-MM-dd and returns
546
 * four digit year, month and day with dashes:
547
 * YYYY-MM-DD eg: "2012-06-30", "1956-00-00"
548
 *
549
 * The partial may contain question marks eg: "1973-??-??",
550
 * these are turned in to '00' or are stripped depending of the $stripZeros
551
 * parameter.
552
 *
553
 * @param string $partial
554
 *   org.joda.time.Partial.
555
 * @param bool $stripZeros
556
 *   If set to TRUE the zero (00) month and days will be hidden:
557
 *   eg 1956-00-00 becomes 1956. The default is TRUE.
558
 * @param string @format
559
 * 	 Can ve used to specify the format of the date string, currently the following format strings are supported
560
 *    - "YYYY": Year only
561
 *    - "YYYY-MM-DD": this is the default
562
 *
563
 * @return string
564
 *   YYYY-MM-DD formatted year, month, day.
565
 */
566
function partialToDate($partial, $stripZeros = TRUE, $format= "YYYY-MM-DD") {
567

  
568
  $y = NULL; $m = NULL; $d = NULL;
569

  
570
  if(strpos($format, 'YY') !== FALSE){
571
    $y = partialToYear($partial);
572
  }
573
  if(strpos($format, 'MM') !== FALSE){
574
    $m = partialToMonth($partial);
575
  }
576
  if(strpos($format, 'DD') !== FALSE){
577
    $d = partialToDay($partial);
578
  }
579

  
580
  $y = $y ? $y : '00';
581
  $m = $m ? $m : '00';
582
  $d = $d ? $d : '00';
583

  
584
  $date = '';
585

  
586
  if ($y == '00' && $stripZeros) {
587
    return;
588
  }
589
  else {
590
    $date = $y;
591
  }
592

  
593
  if ($m == '00' && $stripZeros) {
594
    return $date;
595
  }
596
  else {
597
    $date .= "-" . $m;
598
  }
599

  
600
  if ($d == '00' && $stripZeros) {
601
    return $date;
602
  }
603
  else {
604
    $date .= "-" . $d;
605
  }
606
  return $date;
607
}
608

  
609
/**
610
 * Converts a time period to a string.
611
 *
612
 * See also partialToDate($partial, $stripZeros).
613
 *
614
 * @param object $period
615
 *   An JodaTime org.joda.time.Period object.
616
 * @param bool $stripZeros
617
 *   If set to True, the zero (00) month and days will be hidden:
618
 *   eg 1956-00-00 becomes 1956. The default is TRUE.
619
 * @param string @format
620
 * 	 Can ve used to specify the format of the date string, currently the following format strings are supported
621
 *    - "YYYY": Year only
622
 *    - "YYYY-MM-DD": this is the default
623
 *
624
 * @return string
625
 *   Returns a date in the form of a string.
626
 */
627
function timePeriodToString($period, $stripZeros = TRUE, $format = "YYYY-MM-DD") {
628
  $dateString = '';
629
  if ($period->start) {
630
    $dateString = partialToDate($period->start, $stripZeros, $format);
631
  }
632
  if ($period->end) {
633
    $dateString .= (strlen($dateString) > 0 ? ' ' . t('to') . ' ' : '') . partialToDate($period->end, $stripZeros, $format);
634
  }
635
  return $dateString;
636
}
637

  
638
/**
639
 * returns the earliest date available in the $period in a normalized
640
 * form suitable for sorting, e.g.:
641
 *
642
 *  - 1956-00-00
643
 *  - 0000-00-00
644
 *  - 1957-03-00
645
 *
646
 * that is either the start date is returned if set otherwise the
647
 * end date
648
 *
649
 * @param  $period
650
 *    An JodaTime org.joda.time.Period object.
651
 * @return string normalized form of the date
652
 *   suitable for sorting
653
 */
654
function timePeriodAsOrderKey($period) {
655
  $dateString = '';
656
  if ($period->start) {
657
    $dateString = partialToDate($period->start, false);
658
  }
659
  if ($period->end) {
660
    $dateString .= partialToDate($period->end, false);
661
  }
662
  return $dateString;
663
}
664

  
665
/**
666
 * Composes a absolute CDM web service URI with parameters and querystring.
667
 *
668
 * @param string $uri_pattern
669
 *   String with place holders ($0, $1, ..) that should be replaced by the
670
 *   according element of the $pathParameters array.
671
 * @param array $pathParameters
672
 *   An array of path elements, or a single element.
673
 * @param string $query
674
 *   A query string to append to the URL.
675
 *
676
 * @return string
677
 *   A complete URL with parameters to a CDM webservice.
678
 */
679
function cdm_compose_url($uri_pattern, $pathParameters = array(), $query = NULL) {
680
  if (empty($pathParameters)) {
681
    $pathParameters = array();
682
  }
683

  
684
  $request_params = '';
685
  $path_params = '';
686

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff