Révision ce86144f
Ajouté par Florent Torregrosa il y a plus de 7 ans
drupal7/sites/all/modules/node_export/LICENSE.txt | ||
---|---|---|
1 |
GNU GENERAL PUBLIC LICENSE |
|
2 |
Version 2, June 1991 |
|
3 |
|
|
4 |
Copyright (C) 1989, 1991 Free Software Foundation, Inc., |
|
5 |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
6 |
Everyone is permitted to copy and distribute verbatim copies |
|
7 |
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 |
|
12 |
freedom to share and change it. By contrast, the GNU General Public |
|
13 |
License is intended to guarantee your freedom to share and change free |
|
14 |
software--to make sure the software is free for all its users. This |
|
15 |
General Public License applies to most of the Free Software |
|
16 |
Foundation's software and to any other program whose authors commit to |
|
17 |
using it. (Some other Free Software Foundation software is covered by |
|
18 |
the GNU Lesser General Public License instead.) You can apply it to |
|
19 |
your programs, too. |
|
20 |
|
|
21 |
When we speak of free software, we are referring to freedom, not |
|
22 |
price. Our General Public Licenses are designed to make sure that you |
|
23 |
have the freedom to distribute copies of free software (and charge for |
|
24 |
this service if you wish), that you receive source code or can get it |
|
25 |
if you want it, that you can change the software or use pieces of it |
|
26 |
in new free programs; and that you know you can do these things. |
|
27 |
|
|
28 |
To protect your rights, we need to make restrictions that forbid |
|
29 |
anyone to deny you these rights or to ask you to surrender the rights. |
|
30 |
These restrictions translate to certain responsibilities for you if you |
|
31 |
distribute copies of the software, or if you modify it. |
|
32 |
|
|
33 |
For example, if you distribute copies of such a program, whether |
|
34 |
gratis or for a fee, you must give the recipients all the rights that |
|
35 |
you have. You must make sure that they, too, receive or can get the |
|
36 |
source code. And you must show them these terms so they know their |
|
37 |
rights. |
|
38 |
|
|
39 |
We protect your rights with two steps: (1) copyright the software, and |
|
40 |
(2) offer you this license which gives you legal permission to copy, |
|
41 |
distribute and/or modify the software. |
|
42 |
|
|
43 |
Also, for each author's protection and ours, we want to make certain |
|
44 |
that everyone understands that there is no warranty for this free |
|
45 |
software. If the software is modified by someone else and passed on, we |
|
46 |
want its recipients to know that what they have is not the original, so |
|
47 |
that any problems introduced by others will not reflect on the original |
|
48 |
authors' reputations. |
|
49 |
|
|
50 |
Finally, any free program is threatened constantly by software |
|
51 |
patents. We wish to avoid the danger that redistributors of a free |
|
52 |
program will individually obtain patent licenses, in effect making the |
|
53 |
program proprietary. To prevent this, we have made it clear that any |
|
54 |
patent must be licensed for everyone's free use or not licensed at all. |
|
55 |
|
|
56 |
The precise terms and conditions for copying, distribution and |
|
57 |
modification follow. |
|
58 |
|
|
59 |
GNU GENERAL PUBLIC LICENSE |
|
60 |
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION |
|
61 |
|
|
62 |
0. This License applies to any program or other work which contains |
|
63 |
a notice placed by the copyright holder saying it may be distributed |
|
64 |
under the terms of this General Public License. The "Program", below, |
|
65 |
refers to any such program or work, and a "work based on the Program" |
|
66 |
means either the Program or any derivative work under copyright law: |
|
67 |
that is to say, a work containing the Program or a portion of it, |
|
68 |
either verbatim or with modifications and/or translated into another |
|
69 |
language. (Hereinafter, translation is included without limitation in |
|
70 |
the term "modification".) Each licensee is addressed as "you". |
|
71 |
|
|
72 |
Activities other than copying, distribution and modification are not |
|
73 |
covered by this License; they are outside its scope. The act of |
|
74 |
running the Program is not restricted, and the output from the Program |
|
75 |
is covered only if its contents constitute a work based on the |
|
76 |
Program (independent of having been made by running the Program). |
|
77 |
Whether that is true depends on what the Program does. |
|
78 |
|
|
79 |
1. You may copy and distribute verbatim copies of the Program's |
|
80 |
source code as you receive it, in any medium, provided that you |
|
81 |
conspicuously and appropriately publish on each copy an appropriate |
|
82 |
copyright notice and disclaimer of warranty; keep intact all the |
|
83 |
notices that refer to this License and to the absence of any warranty; |
|
84 |
and give any other recipients of the Program a copy of this License |
|
85 |
along with the Program. |
|
86 |
|
|
87 |
You may charge a fee for the physical act of transferring a copy, and |
|
88 |
you may at your option offer warranty protection in exchange for a fee. |
|
89 |
|
|
90 |
2. You may modify your copy or copies of the Program or any portion |
|
91 |
of it, thus forming a work based on the Program, and copy and |
|
92 |
distribute such modifications or work under the terms of Section 1 |
|
93 |
above, provided that you also meet all of these conditions: |
|
94 |
|
|
95 |
a) You must cause the modified files to carry prominent notices |
|
96 |
stating that you changed the files and the date of any change. |
|
97 |
|
|
98 |
b) You must cause any work that you distribute or publish, that in |
|
99 |
whole or in part contains or is derived from the Program or any |
|
100 |
part thereof, to be licensed as a whole at no charge to all third |
|
101 |
parties under the terms of this License. |
|
102 |
|
|
103 |
c) If the modified program normally reads commands interactively |
|
104 |
when run, you must cause it, when started running for such |
|
105 |
interactive use in the most ordinary way, to print or display an |
|
106 |
announcement including an appropriate copyright notice and a |
|
107 |
notice that there is no warranty (or else, saying that you provide |
|
108 |
a warranty) and that users may redistribute the program under |
|
109 |
these conditions, and telling the user how to view a copy of this |
|
110 |
License. (Exception: if the Program itself is interactive but |
|
111 |
does not normally print such an announcement, your work based on |
|
112 |
the Program is not required to print an announcement.) |
|
113 |
|
|
114 |
These requirements apply to the modified work as a whole. If |
|
115 |
identifiable sections of that work are not derived from the Program, |
|
116 |
and can be reasonably considered independent and separate works in |
|
117 |
themselves, then this License, and its terms, do not apply to those |
|
118 |
sections when you distribute them as separate works. But when you |
|
119 |
distribute the same sections as part of a whole which is a work based |
|
120 |
on the Program, the distribution of the whole must be on the terms of |
|
121 |
this License, whose permissions for other licensees extend to the |
|
122 |
entire whole, and thus to each and every part regardless of who wrote it. |
|
123 |
|
|
124 |
Thus, it is not the intent of this section to claim rights or contest |
|
125 |
your rights to work written entirely by you; rather, the intent is to |
|
126 |
exercise the right to control the distribution of derivative or |
|
127 |
collective works based on the Program. |
|
128 |
|
|
129 |
In addition, mere aggregation of another work not based on the Program |
|
130 |
with the Program (or with a work based on the Program) on a volume of |
|
131 |
a storage or distribution medium does not bring the other work under |
|
132 |
the scope of this License. |
|
133 |
|
|
134 |
3. You may copy and distribute the Program (or a work based on it, |
|
135 |
under Section 2) in object code or executable form under the terms of |
|
136 |
Sections 1 and 2 above provided that you also do one of the following: |
|
137 |
|
|
138 |
a) Accompany it with the complete corresponding machine-readable |
|
139 |
source code, which must be distributed under the terms of Sections |
|
140 |
1 and 2 above on a medium customarily used for software interchange; or, |
|
141 |
|
|
142 |
b) Accompany it with a written offer, valid for at least three |
|
143 |
years, to give any third party, for a charge no more than your |
|
144 |
cost of physically performing source distribution, a complete |
|
145 |
machine-readable copy of the corresponding source code, to be |
|
146 |
distributed under the terms of Sections 1 and 2 above on a medium |
|
147 |
customarily used for software interchange; or, |
|
148 |
|
|
149 |
c) Accompany it with the information you received as to the offer |
|
150 |
to distribute corresponding source code. (This alternative is |
|
151 |
allowed only for noncommercial distribution and only if you |
|
152 |
received the program in object code or executable form with such |
|
153 |
an offer, in accord with Subsection b above.) |
|
154 |
|
|
155 |
The source code for a work means the preferred form of the work for |
|
156 |
making modifications to it. For an executable work, complete source |
|
157 |
code means all the source code for all modules it contains, plus any |
|
158 |
associated interface definition files, plus the scripts used to |
|
159 |
control compilation and installation of the executable. However, as a |
|
160 |
special exception, the source code distributed need not include |
|
161 |
anything that is normally distributed (in either source or binary |
|
162 |
form) with the major components (compiler, kernel, and so on) of the |
|
163 |
operating system on which the executable runs, unless that component |
|
164 |
itself accompanies the executable. |
|
165 |
|
|
166 |
If distribution of executable or object code is made by offering |
|
167 |
access to copy from a designated place, then offering equivalent |
|
168 |
access to copy the source code from the same place counts as |
|
169 |
distribution of the source code, even though third parties are not |
|
170 |
compelled to copy the source along with the object code. |
|
171 |
|
|
172 |
4. You may not copy, modify, sublicense, or distribute the Program |
|
173 |
except as expressly provided under this License. Any attempt |
|
174 |
otherwise to copy, modify, sublicense or distribute the Program is |
|
175 |
void, and will automatically terminate your rights under this License. |
|
176 |
However, parties who have received copies, or rights, from you under |
|
177 |
this License will not have their licenses terminated so long as such |
|
178 |
parties remain in full compliance. |
|
179 |
|
|
180 |
5. You are not required to accept this License, since you have not |
|
181 |
signed it. However, nothing else grants you permission to modify or |
|
182 |
distribute the Program or its derivative works. These actions are |
|
183 |
prohibited by law if you do not accept this License. Therefore, by |
|
184 |
modifying or distributing the Program (or any work based on the |
|
185 |
Program), you indicate your acceptance of this License to do so, and |
|
186 |
all its terms and conditions for copying, distributing or modifying |
|
187 |
the Program or works based on it. |
|
188 |
|
|
189 |
6. Each time you redistribute the Program (or any work based on the |
|
190 |
Program), the recipient automatically receives a license from the |
|
191 |
original licensor to copy, distribute or modify the Program subject to |
|
192 |
these terms and conditions. You may not impose any further |
|
193 |
restrictions on the recipients' exercise of the rights granted herein. |
|
194 |
You are not responsible for enforcing compliance by third parties to |
|
195 |
this License. |
|
196 |
|
|
197 |
7. If, as a consequence of a court judgment or allegation of patent |
|
198 |
infringement or for any other reason (not limited to patent issues), |
|
199 |
conditions are imposed on you (whether by court order, agreement or |
|
200 |
otherwise) that contradict the conditions of this License, they do not |
|
201 |
excuse you from the conditions of this License. If you cannot |
|
202 |
distribute so as to satisfy simultaneously your obligations under this |
|
203 |
License and any other pertinent obligations, then as a consequence you |
|
204 |
may not distribute the Program at all. For example, if a patent |
|
205 |
license would not permit royalty-free redistribution of the Program by |
|
206 |
all those who receive copies directly or indirectly through you, then |
|
207 |
the only way you could satisfy both it and this License would be to |
|
208 |
refrain entirely from distribution of the Program. |
|
209 |
|
|
210 |
If any portion of this section is held invalid or unenforceable under |
|
211 |
any particular circumstance, the balance of the section is intended to |
|
212 |
apply and the section as a whole is intended to apply in other |
|
213 |
circumstances. |
|
214 |
|
|
215 |
It is not the purpose of this section to induce you to infringe any |
|
216 |
patents or other property right claims or to contest validity of any |
|
217 |
such claims; this section has the sole purpose of protecting the |
|
218 |
integrity of the free software distribution system, which is |
|
219 |
implemented by public license practices. Many people have made |
|
220 |
generous contributions to the wide range of software distributed |
|
221 |
through that system in reliance on consistent application of that |
|
222 |
system; it is up to the author/donor to decide if he or she is willing |
|
223 |
to distribute software through any other system and a licensee cannot |
|
224 |
impose that choice. |
|
225 |
|
|
226 |
This section is intended to make thoroughly clear what is believed to |
|
227 |
be a consequence of the rest of this License. |
|
228 |
|
|
229 |
8. If the distribution and/or use of the Program is restricted in |
|
230 |
certain countries either by patents or by copyrighted interfaces, the |
|
231 |
original copyright holder who places the Program under this License |
|
232 |
may add an explicit geographical distribution limitation excluding |
|
233 |
those countries, so that distribution is permitted only in or among |
|
234 |
countries not thus excluded. In such case, this License incorporates |
|
235 |
the limitation as if written in the body of this License. |
|
236 |
|
|
237 |
9. The Free Software Foundation may publish revised and/or new versions |
|
238 |
of the General Public License from time to time. Such new versions will |
|
239 |
be similar in spirit to the present version, but may differ in detail to |
|
240 |
address new problems or concerns. |
|
241 |
|
|
242 |
Each version is given a distinguishing version number. If the Program |
|
243 |
specifies a version number of this License which applies to it and "any |
|
244 |
later version", you have the option of following the terms and conditions |
|
245 |
either of that version or of any later version published by the Free |
|
246 |
Software Foundation. If the Program does not specify a version number of |
|
247 |
this License, you may choose any version ever published by the Free Software |
|
248 |
Foundation. |
|
249 |
|
|
250 |
10. If you wish to incorporate parts of the Program into other free |
|
251 |
programs whose distribution conditions are different, write to the author |
|
252 |
to ask for permission. For software which is copyrighted by the Free |
|
253 |
Software Foundation, write to the Free Software Foundation; we sometimes |
|
254 |
make exceptions for this. Our decision will be guided by the two goals |
|
255 |
of preserving the free status of all derivatives of our free software and |
|
256 |
of promoting the sharing and reuse of software generally. |
|
257 |
|
|
258 |
NO WARRANTY |
|
259 |
|
|
260 |
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY |
|
261 |
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN |
|
262 |
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES |
|
263 |
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED |
|
264 |
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
|
265 |
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS |
|
266 |
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE |
|
267 |
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, |
|
268 |
REPAIR OR CORRECTION. |
|
269 |
|
|
270 |
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
|
271 |
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR |
|
272 |
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, |
|
273 |
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING |
|
274 |
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED |
|
275 |
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY |
|
276 |
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER |
|
277 |
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE |
|
278 |
POSSIBILITY OF SUCH DAMAGES. |
|
279 |
|
|
280 |
END OF TERMS AND CONDITIONS |
|
281 |
|
|
282 |
How to Apply These Terms to Your New Programs |
|
283 |
|
|
284 |
If you develop a new program, and you want it to be of the greatest |
|
285 |
possible use to the public, the best way to achieve this is to make it |
|
286 |
free software which everyone can redistribute and change under these terms. |
|
287 |
|
|
288 |
To do so, attach the following notices to the program. It is safest |
|
289 |
to attach them to the start of each source file to most effectively |
|
290 |
convey the exclusion of warranty; and each file should have at least |
|
291 |
the "copyright" line and a pointer to where the full notice is found. |
|
292 |
|
|
293 |
<one line to give the program's name and a brief idea of what it does.> |
|
294 |
Copyright (C) <year> <name of author> |
|
295 |
|
|
296 |
This program is free software; you can redistribute it and/or modify |
|
297 |
it under the terms of the GNU General Public License as published by |
|
298 |
the Free Software Foundation; either version 2 of the License, or |
|
299 |
(at your option) any later version. |
|
300 |
|
|
301 |
This program is distributed in the hope that it will be useful, |
|
302 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
303 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
304 |
GNU General Public License for more details. |
|
305 |
|
|
306 |
You should have received a copy of the GNU General Public License along |
|
307 |
with this program; if not, write to the Free Software Foundation, Inc., |
|
308 |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|
309 |
|
|
310 |
Also add information on how to contact you by electronic and paper mail. |
|
311 |
|
|
312 |
If the program is interactive, make it output a short notice like this |
|
313 |
when it starts in an interactive mode: |
|
314 |
|
|
315 |
Gnomovision version 69, Copyright (C) year name of author |
|
316 |
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. |
|
317 |
This is free software, and you are welcome to redistribute it |
|
318 |
under certain conditions; type `show c' for details. |
|
319 |
|
|
320 |
The hypothetical commands `show w' and `show c' should show the appropriate |
|
321 |
parts of the General Public License. Of course, the commands you use may |
|
322 |
be called something other than `show w' and `show c'; they could even be |
|
323 |
mouse-clicks or menu items--whatever suits your program. |
|
324 |
|
|
325 |
You should also get your employer (if you work as a programmer) or your |
|
326 |
school, if any, to sign a "copyright disclaimer" for the program, if |
|
327 |
necessary. Here is a sample; alter the names: |
|
328 |
|
|
329 |
Yoyodyne, Inc., hereby disclaims all copyright interest in the program |
|
330 |
`Gnomovision' (which makes passes at compilers) written by James Hacker. |
|
331 |
|
|
332 |
<signature of Ty Coon>, 1 April 1989 |
|
333 |
Ty Coon, President of Vice |
|
334 |
|
|
335 |
This General Public License does not permit incorporating your program into |
|
336 |
proprietary programs. If your program is a subroutine library, you may |
|
337 |
consider it more useful to permit linking proprietary applications with the |
|
338 |
library. If this is what you want to do, use the GNU Lesser General |
|
339 |
Public License instead of this License. |
drupal7/sites/all/modules/node_export/README.txt | ||
---|---|---|
1 |
|
|
2 |
Node export README |
|
3 |
|
|
4 |
CONTENTS OF THIS FILE |
|
5 |
---------------------- |
|
6 |
|
|
7 |
* Introduction |
|
8 |
* Installation |
|
9 |
* Configuration |
|
10 |
* Usage |
|
11 |
* Node export features tips |
|
12 |
|
|
13 |
|
|
14 |
INTRODUCTION |
|
15 |
------------ |
|
16 |
This module allows users to export nodes and then import it into another |
|
17 |
Drupal installation, or on the same site. |
|
18 |
|
|
19 |
This module allows user to export/import nodes if they have the 'export nodes' |
|
20 |
or 'export own nodes' permission, have node access to view the node and create |
|
21 |
the node type, and the node type is not omitted in node export's settings. The |
|
22 |
module does not check access to the filter formats used by the node's fields, |
|
23 |
please keep this in mind when assigning permissions to user roles. |
|
24 |
|
|
25 |
Maintainer: Daniel Braksator (http://drupal.org/user/134005) |
|
26 |
Project page: http://drupal.org/project/node_export. |
|
27 |
|
|
28 |
Note: this module was originally built upon code from the node_clone module |
|
29 |
maintained by Peter Wolanin (http://drupal.org/user/49851) at |
|
30 |
http://drupal.org/project/node_clone which was derived from code posted by |
|
31 |
Steve Ringwood (http://drupal.org/user/12856) at |
|
32 |
http://drupal.org/node/73381#comment-137714 |
|
33 |
Features integration, relations, and UUID initially developed by Tushar Mahajan |
|
34 |
(http://drupal.org/user/398572). |
|
35 |
Significant improvements, file handling, and extra functionality pioneered by |
|
36 |
James Andres (http://drupal.org/user/33827). |
|
37 |
|
|
38 |
|
|
39 |
INSTALLATION |
|
40 |
------------ |
|
41 |
1. Copy node_export folder to modules directory (usually sites/all/modules). |
|
42 |
2. At admin/build/modules enable the Node export module in the Node export |
|
43 |
package. |
|
44 |
3. Enable any other modules in the Node export package that tickle your fancy. |
|
45 |
|
|
46 |
For detailed instructions on installing contributed modules see: |
|
47 |
http://drupal.org/documentation/install/modules-themes/modules-7 |
|
48 |
|
|
49 |
|
|
50 |
CONFIGURATION |
|
51 |
------------- |
|
52 |
1. Enable permissions at admin/user/permissions. |
|
53 |
Security Warning: Users with the permission "use PHP to import nodes" |
|
54 |
will be able to change nodes as they see fit before an import, as well as |
|
55 |
being able to execute PHP scripts on the server. It is advisable not to |
|
56 |
give this permission to a typical node author, only the administrator or |
|
57 |
developer should use this feature. You may even like to turn this module |
|
58 |
off when it is no longer required. |
|
59 |
This module does not check access to the filter formats used by the node's |
|
60 |
fields, please keep this in mind when assigning permissions to user roles. |
|
61 |
2. Configure module at admin/settings/node_export. |
|
62 |
|
|
63 |
|
|
64 |
USAGE |
|
65 |
----- |
|
66 |
1. To export nodes, either: |
|
67 |
a) Use the 'Node export' tab on a node page. |
|
68 |
b) Use the Find content page (admin/content) to filter the nodes you |
|
69 |
wish to export and then choose 'Node export' under the 'Update options'. |
|
70 |
c) Use Drush: http://drupal.org/project/drush |
|
71 |
d) Create a Feature (see tips below) http://drupal.org/project/features |
|
72 |
e) Create a View of nodes and use the Views Bulk Operations (VBO) module |
|
73 |
http://drupal.org/project/views_bulk_operations |
|
74 |
|
|
75 |
2. To import nodes that were exported with Node export, either: |
|
76 |
a) Use the form at 'Node export: import' under 'Add content' |
|
77 |
(node/add/node_export). |
|
78 |
b) Use Drush: http://drupal.org/project/drush |
|
79 |
c) Using your created Feature. |
|
80 |
d) For advanced imports if you are familiar with the Feeds module, enable |
|
81 |
Node export feeds module to use with the Feeds import interface |
|
82 |
http://drupal.org/project/feeds |
|
83 |
|
|
84 |
|
|
85 |
NODE EXPORT FEATURES TIPS |
|
86 |
------------------------- |
|
87 |
Regarding the Node export features module which integrates with the Features |
|
88 |
module, any nodes to be used with this must have a UUID (universally unique |
|
89 |
ID). To export older nodes that don't have UUID make sure you have selected |
|
90 |
the content type and click on 'create missings uuids' from |
|
91 |
'admin/settings/uuid' under the fieldset 'Synchronize'. Then you should be |
|
92 |
able to see more nodes under the feature component, If you don't see the node |
|
93 |
export component, that means no nodes has been configured with UUID. |
drupal7/sites/all/modules/node_export/formats/drupal.inc | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
/** |
|
4 |
* @file |
|
5 |
* The Node export Drupal format handler. |
|
6 |
* |
|
7 |
* Adds Drupal var export format to Node export. |
|
8 |
*/ |
|
9 |
|
|
10 |
/** |
|
11 |
* Export callback. |
|
12 |
*/ |
|
13 |
function node_export_drupal_export($nodes, $format) { |
|
14 |
require_once DRUPAL_ROOT . '/includes/utility.inc'; |
|
15 |
return drupal_var_export($nodes); |
|
16 |
} |
|
17 |
|
|
18 |
/** |
|
19 |
* Import callback. |
|
20 |
*/ |
|
21 |
function node_export_drupal_import($code_string) { |
|
22 |
if (substr(ltrim($code_string), 0, 6) == "array(") { |
|
23 |
$nodes = eval('return ' . $code_string . ';'); |
|
24 |
if (is_array($nodes)) { |
|
25 |
return node_export_drupal_decode_objects($nodes); |
|
26 |
} |
|
27 |
} |
|
28 |
} |
|
29 |
|
|
30 |
/** |
|
31 |
* Recursively convert arrays back to objects. |
|
32 |
* |
|
33 |
* This is only for backwards compatibility with the deprecated node_code format. |
|
34 |
*/ |
|
35 |
function node_export_drupal_decode_objects($array) { |
|
36 |
foreach ($array as $k => $v) { |
|
37 |
if (is_array($v)) { |
|
38 |
$array[$k] = node_export_drupal_decode_objects($v); |
|
39 |
} |
|
40 |
} |
|
41 |
if (isset($array['#_export_node_encode_object'])) { |
|
42 |
unset($array['#_export_node_encode_object']); |
|
43 |
$array = (object)$array; |
|
44 |
} |
|
45 |
return $array; |
|
46 |
} |
|
47 |
|
|
48 |
/** |
|
49 |
* Callback for actions. |
|
50 |
*/ |
|
51 |
function node_export_drupal_action_form($context, &$form_state) { |
|
52 |
return node_export_action_form($context, $form_state, 'drupal'); |
|
53 |
} |
drupal7/sites/all/modules/node_export/formats/dsv.inc | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
/** |
|
4 |
* @file |
|
5 |
* The Node export DSV format handler. |
|
6 |
* |
|
7 |
* Adds configurable DSV format to Node export. |
|
8 |
*/ |
|
9 |
|
|
10 |
/** |
|
11 |
* Settings callback. |
|
12 |
*/ |
|
13 |
function node_export_dsv_settings($form, $form_state) { |
|
14 |
$settings['dsv'] = array( |
|
15 |
'#type' => 'fieldset', |
|
16 |
'#title' => t('DSV format settings'), |
|
17 |
'#description' => t( |
|
18 |
'Select how your DSV output will be formatted - this must be configured the |
|
19 |
same on both sites. By default this is configured to RFC4180 CSV format |
|
20 |
where the delimiter is a comma (,), the enclosure is a double-quote ("), |
|
21 |
and the seperator is CRLF (\r\n). Not all configurations may be possible, |
|
22 |
use wisely. Enclosure will only be used to escape values that contain any |
|
23 |
of the configured strings. Additionally single-quotes will be used to |
|
24 |
escape values that are equivalent to reserved words (NULL, TRUE, FALSE).' |
|
25 |
), |
|
26 |
'#collapsible' => TRUE, |
|
27 |
'#collapsed' => TRUE, |
|
28 |
); |
|
29 |
|
|
30 |
$settings['dsv']['node_export_dsv_delimiter'] = array( |
|
31 |
'#type' => 'textfield', |
|
32 |
'#title' => t('Value delimiter'), |
|
33 |
'#size' => 5, |
|
34 |
'#maxlength' => 255, |
|
35 |
'#default_value' => variable_get('node_export_dsv_delimiter', ','), |
|
36 |
'#required' => TRUE, |
|
37 |
); |
|
38 |
|
|
39 |
$settings['dsv']['node_export_dsv_enclosure'] = array( |
|
40 |
'#type' => 'textfield', |
|
41 |
'#title' => t('Escape enclosure'), |
|
42 |
'#size' => 5, |
|
43 |
'#maxlength' => 255, |
|
44 |
'#default_value' => variable_get('node_export_dsv_enclosure', '"'), |
|
45 |
'#required' => TRUE, |
|
46 |
); |
|
47 |
|
|
48 |
$settings['dsv']['node_export_dsv_seperator'] = array( |
|
49 |
'#type' => 'textfield', |
|
50 |
'#title' => t('Record seperator'), |
|
51 |
'#size' => 5, |
|
52 |
'#maxlength' => 255, |
|
53 |
'#default_value' => variable_get('node_export_dsv_seperator', '\r\n'), |
|
54 |
'#required' => TRUE, |
|
55 |
); |
|
56 |
|
|
57 |
$settings['dsv']['node_export_dsv_escape_eol'] = array( |
|
58 |
'#type' => 'checkbox', |
|
59 |
'#title' => t('Always escape values containing line breaks'), |
|
60 |
'#default_value' => variable_get('node_export_dsv_escape_eol', 1), |
|
61 |
'#description' => t('This is to overcome problems where Windows injects CRLF line breaks.'), |
|
62 |
); |
|
63 |
|
|
64 |
return $settings; |
|
65 |
} |
|
66 |
|
|
67 |
function node_export_dsv_string($string) { |
|
68 |
$replace = array( |
|
69 |
'\n' => "\n", |
|
70 |
'\r' => "\r", |
|
71 |
'\t' => "\t", |
|
72 |
'\v' => "\v", |
|
73 |
'\e' => "\e", |
|
74 |
'\f' => "\f", |
|
75 |
); |
|
76 |
return str_replace(array_keys($replace), array_values($replace), $string); |
|
77 |
} |
|
78 |
|
|
79 |
/** |
|
80 |
* Export callback. |
|
81 |
*/ |
|
82 |
function node_export_dsv_export($nodes, $format) { |
|
83 |
$delimiter = node_export_dsv_string(variable_get('node_export_dsv_delimiter', ',')); |
|
84 |
$enclosure = node_export_dsv_string(variable_get('node_export_dsv_enclosure', '"')); |
|
85 |
$seperator = node_export_dsv_string(variable_get('node_export_dsv_seperator', '\r\n')); |
|
86 |
$escape_eol = variable_get('node_export_dsv_escape_eol', 1); |
|
87 |
return node_export_dsv_encode($nodes, $delimiter, $enclosure, $seperator, $escape_eol); |
|
88 |
} |
|
89 |
|
|
90 |
/** |
|
91 |
* Build DSV string. |
|
92 |
*/ |
|
93 |
function node_export_dsv_encode($nodes, $delimiter, $enclosure, $seperator, $escape_eol) { |
|
94 |
$encoded_nodes = array(); |
|
95 |
$dsv_lines = array(); |
|
96 |
|
|
97 |
$node_keys = array(); |
|
98 |
foreach (array_keys($nodes) as $node_key) { |
|
99 |
$new_node_key = 'node_' . $node_key; |
|
100 |
$node_keys[] = $new_node_key; |
|
101 |
node_export_dsv_encode_node($encoded_nodes, $new_node_key, $nodes[$node_key]); |
|
102 |
} |
|
103 |
|
|
104 |
$dsv_lines['node_export_dsv_header'] = array_keys($encoded_nodes); |
|
105 |
|
|
106 |
foreach (array_keys($encoded_nodes) as $header_value) { |
|
107 |
$encoded_nodes[$header_value] = array_merge(array_fill_keys($node_keys, NULL), $encoded_nodes[$header_value]); |
|
108 |
foreach (array_keys($encoded_nodes[$header_value]) as $encoded_node_key) { |
|
109 |
$dsv_lines[$encoded_node_key][$header_value] = $encoded_nodes[$header_value][$encoded_node_key]; |
|
110 |
} |
|
111 |
} |
|
112 |
|
|
113 |
return node_export_dsv_array_to_dsv($dsv_lines, $delimiter, $enclosure, $seperator, $escape_eol); |
|
114 |
} |
|
115 |
|
|
116 |
/** |
|
117 |
* Process a node and update $header and $encoded_nodes accordingly. |
|
118 |
*/ |
|
119 |
function node_export_dsv_encode_node(&$encoded_nodes, $node_key, $var, $parent = NULL) { |
|
120 |
|
|
121 |
foreach ($var as $k => &$v) { |
|
122 |
|
|
123 |
// Get the new header value. |
|
124 |
$header_value = node_export_dsv_encode_header_value($parent, $var, $k); |
|
125 |
|
|
126 |
if (is_object($v) || is_array($v)) { |
|
127 |
// Recurse through the structure. |
|
128 |
node_export_dsv_encode_node($encoded_nodes, $node_key, $v, $header_value); |
|
129 |
} |
|
130 |
else { |
|
131 |
// Create a safe text version of this value and store it against the header using a safe key. |
|
132 |
$encoded_nodes[$header_value][$node_key] = node_export_dsv_encode_sanitize_value($v); |
|
133 |
} |
|
134 |
} |
|
135 |
} |
|
136 |
|
|
137 |
/** |
|
138 |
* Encode a value. |
|
139 |
*/ |
|
140 |
function node_export_dsv_encode_sanitize_value($var) { |
|
141 |
if (is_numeric($var)) { |
|
142 |
return $var; |
|
143 |
} |
|
144 |
elseif (is_bool($var)) { |
|
145 |
return ($var ? 'TRUE' : 'FALSE'); |
|
146 |
} |
|
147 |
elseif (is_null($var)) { |
|
148 |
return 'NULL'; |
|
149 |
} |
|
150 |
elseif (is_string($var) && !empty($var)) { |
|
151 |
// Single-quote strings that could be confused for null or boolean. |
|
152 |
if (in_array(strtoupper($var), array('TRUE', 'FALSE', 'NULL'))) { |
|
153 |
$var = "'" . $var . "'"; |
|
154 |
} |
|
155 |
|
|
156 |
return $var; |
|
157 |
} |
|
158 |
else { |
|
159 |
return ''; |
|
160 |
} |
|
161 |
} |
|
162 |
|
|
163 |
/** |
|
164 |
* Decode a value. |
|
165 |
*/ |
|
166 |
function node_export_dsv_decode_sanitize_value($var) { |
|
167 |
// Allow numeric, bool, and null values to pass right back as is. |
|
168 |
if (is_numeric($var) || is_bool($var) || is_null($var)) { |
|
169 |
return $var; |
|
170 |
} |
|
171 |
// Allow the special case strings back as is. |
|
172 |
elseif (in_array(strtoupper($var), array("'TRUE'", "'FALSE'", "'NULL'"))) { |
|
173 |
return $var; |
|
174 |
} |
|
175 |
// Assume this is a string. |
|
176 |
return "'" . str_replace("'", "\'", $var) . "'"; |
|
177 |
} |
|
178 |
|
|
179 |
/** |
|
180 |
* Create header value from $parents, $var, and $k. |
|
181 |
*/ |
|
182 |
function node_export_dsv_encode_header_value($parents, $var, $k) { |
|
183 |
if (is_null($parents)) { |
|
184 |
// Special case; on the first level do not prefix the key. |
|
185 |
$header_value = $k; |
|
186 |
} |
|
187 |
elseif (is_object($var)) { |
|
188 |
$header_value = $parents . "->" . $k; |
|
189 |
} |
|
190 |
elseif (is_array($var)) { |
|
191 |
$header_value = $parents . "['" . $k . "']"; |
|
192 |
} |
|
193 |
return $header_value; |
|
194 |
} |
|
195 |
|
|
196 |
/** |
|
197 |
* Import callback. |
|
198 |
*/ |
|
199 |
function node_export_dsv_import($code_string) { |
|
200 |
$delimiter = node_export_dsv_string(variable_get('node_export_dsv_delimiter', ',')); |
|
201 |
$enclosure = node_export_dsv_string(variable_get('node_export_dsv_enclosure', '"')); |
|
202 |
$seperator = node_export_dsv_string(variable_get('node_export_dsv_seperator', '\r\n')); |
|
203 |
return node_export_dsv_decode($code_string, $delimiter, $enclosure, $seperator); |
|
204 |
} |
|
205 |
|
|
206 |
/** |
|
207 |
* Interpret a DSV string. |
|
208 |
*/ |
|
209 |
function node_export_dsv_decode($code_string, $delimiter, $enclosure, $seperator) { |
|
210 |
// Get array data from DSV. |
|
211 |
$array = @node_export_dsv_dsv_to_array($code_string, $delimiter, $enclosure, $seperator); |
|
212 |
|
|
213 |
// If the first two rows are of equal length, we can assume this is a DSV. |
|
214 |
// Also checks there are a decent number of fields. |
|
215 |
if (!empty($array[0]) && !empty($array[1]) && count($array[0]) > 10 && count($array[0]) == count($array[1])) { |
|
216 |
$nodes = array(); |
|
217 |
|
|
218 |
// Assume row 0 is the header, and the rest of the rows are the nodes. |
|
219 |
$header = array_shift($array); |
|
220 |
|
|
221 |
// Build the nodes. |
|
222 |
foreach ($array as &$row) { |
|
223 |
$node = (object)array(); |
|
224 |
foreach ($row as $key => $item) { |
|
225 |
$item = node_export_dsv_decode_sanitize_value($item); |
|
226 |
eval('$node->' . $header[$key] . ' = ' . $item . ';'); |
|
227 |
} |
|
228 |
$nodes[] = $node; |
|
229 |
} |
|
230 |
|
|
231 |
return $nodes; |
|
232 |
} |
|
233 |
} |
|
234 |
|
|
235 |
/** |
|
236 |
* Encode DSV. |
|
237 |
*/ |
|
238 |
function node_export_dsv_array_to_dsv($array, $delimiter, $enclosure, $seperator, $escape_eol) { |
|
239 |
$lines = array(); |
|
240 |
foreach ($array as $line) { |
|
241 |
$out_item = array(); |
|
242 |
foreach ($line as $item) { |
|
243 |
if (stripos($item, $enclosure) !== FALSE) { |
|
244 |
$item = str_replace($enclosure, $enclosure . $enclosure, $item); |
|
245 |
} |
|
246 |
if ( |
|
247 |
(stripos($item, $delimiter) !== FALSE) |
|
248 |
|| (stripos($item, $enclosure) !== FALSE) |
|
249 |
|| (stripos($item, $seperator) !== FALSE) |
|
250 |
|| ($escape_eol && stripos($item, "\n") !== FALSE) |
|
251 |
) { |
|
252 |
$item = $enclosure . $item . $enclosure; |
|
253 |
} |
|
254 |
$out_item[] = $item; |
|
255 |
} |
|
256 |
$lines[] = implode($delimiter, $out_item); |
|
257 |
} |
|
258 |
return implode($seperator, $lines); |
|
259 |
} |
|
260 |
|
|
261 |
/** |
|
262 |
* Decode DSV. |
|
263 |
*/ |
|
264 |
function node_export_dsv_dsv_to_array($string, $delimiter, $enclosure, $seperator) { |
|
265 |
$lines = array(); |
|
266 |
$out_item = array(); |
|
267 |
$count = strlen($string); |
|
268 |
$escape = FALSE; |
|
269 |
$double_escape = FALSE; |
|
270 |
$position = 0; |
|
271 |
$i = 0; |
|
272 |
$seperators = str_split($seperator); |
|
273 |
|
|
274 |
while ($i < $count) { |
|
275 |
$c = $string[$i]; |
|
276 |
|
|
277 |
// Determine whether this is an EOL. |
|
278 |
$is_eol = TRUE; |
|
279 |
for ($j = 0; $j < count($seperators); $j++) { |
|
280 |
if (!isset($string[$i + $j]) || $string[$i + $j] != $seperators[$j]) { |
|
281 |
$is_eol = FALSE; |
|
282 |
break; |
|
283 |
} |
|
284 |
} |
|
285 |
|
|
286 |
if ($is_eol) { |
|
287 |
if ($escape) { |
|
288 |
$out_item[$position] .= $c; |
|
289 |
} |
|
290 |
else { |
|
291 |
$i += count($seperators); |
|
292 |
$lines[] = $out_item; |
|
293 |
$out_item = array(); |
|
294 |
$position = 0; |
|
295 |
continue; |
|
296 |
} |
|
297 |
} |
|
298 |
elseif ($c == $delimiter) { |
|
299 |
if ($escape) { |
|
300 |
$out_item[$position] .= $c; |
|
301 |
} |
|
302 |
else { |
|
303 |
if ($string[$i - 1] == $delimiter) { |
|
304 |
$out_item[$position] .= ''; |
|
305 |
} |
|
306 |
$position++; |
|
307 |
$escape = FALSE; |
|
308 |
$double_escape = FALSE; |
|
309 |
} |
|
310 |
} |
|
311 |
elseif ($c == $enclosure) { |
|
312 |
if ($double_escape) { |
|
313 |
$out_item[$position] .= $enclosure; |
|
314 |
$double_escape = FALSE; |
|
315 |
} |
|
316 |
if ($escape) { |
|
317 |
$escape = FALSE; |
|
318 |
$double_escape = TRUE; |
|
319 |
} |
|
320 |
else { |
|
321 |
$escape = TRUE; |
|
322 |
$double_escape = FALSE; |
|
323 |
} |
|
324 |
} |
|
325 |
else { |
|
326 |
if ($double_escape) { |
|
327 |
$out_item[$position] .= $enclosure; |
|
328 |
$double_escape = FALSE; |
|
329 |
} |
|
330 |
$out_item[$position] .= $c; |
|
331 |
} |
|
332 |
$i++; |
|
333 |
} |
|
334 |
if (!empty($out_item)) { |
|
335 |
$lines[] = $out_item; |
|
336 |
} |
|
337 |
return $lines; |
|
338 |
} |
|
339 |
|
|
340 |
/** |
|
341 |
* Callback for actions. |
|
342 |
*/ |
|
343 |
function node_export_dsv_action_form($context, &$form_state) { |
|
344 |
return node_export_action_form($context, $form_state, 'dsv'); |
|
345 |
} |
drupal7/sites/all/modules/node_export/formats/json.inc | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
/** |
|
4 |
* @file |
|
5 |
* The Node export JSON format handler. |
|
6 |
* |
|
7 |
* Adds JSON format to Node export. |
|
8 |
*/ |
|
9 |
|
|
10 |
/** |
|
11 |
* Export callback. |
|
12 |
*/ |
|
13 |
function node_export_json_export($nodes, $format) { |
|
14 |
return drupal_json_encode(node_export_json_encode_objects($nodes)); |
|
15 |
} |
|
16 |
|
|
17 |
/** |
|
18 |
* Import callback. |
|
19 |
*/ |
|
20 |
function node_export_json_import($code_string) { |
|
21 |
return node_export_json_decode_objects(drupal_json_decode($code_string)); |
|
22 |
} |
|
23 |
|
|
24 |
/** |
|
25 |
* Mark objects as being objects. |
|
26 |
*/ |
|
27 |
function node_export_json_encode_objects($var) { |
|
28 |
if (is_object($var)) { |
|
29 |
$var = (array)$var; |
|
30 |
$var['#node_export_object'] = '1'; |
|
31 |
} |
|
32 |
if (is_array($var)) { |
|
33 |
foreach ($var as $key => $value) { |
|
34 |
$var[$key] = node_export_json_encode_objects($value); |
|
35 |
} |
|
36 |
} |
|
37 |
return $var; |
|
38 |
} |
|
39 |
|
|
40 |
/** |
|
41 |
* Recursively convert arrays back to objects. |
|
42 |
*/ |
|
43 |
function node_export_json_decode_objects($array) { |
|
44 |
if (is_array($array)) { |
|
45 |
foreach ($array as $k => $v) { |
|
46 |
if (is_array($v)) { |
|
47 |
$array[$k] = node_export_json_decode_objects($v); |
|
48 |
} |
|
49 |
} |
|
50 |
if (isset($array['#node_export_object'])) { |
|
51 |
unset($array['#node_export_object']); |
|
52 |
$array = (object)$array; |
|
53 |
} |
|
54 |
return $array; |
|
55 |
} |
|
56 |
} |
|
57 |
|
|
58 |
/** |
|
59 |
* Callback for actions. |
|
60 |
*/ |
|
61 |
function node_export_json_action_form($context, &$form_state) { |
|
62 |
return node_export_action_form($context, $form_state, 'json'); |
|
63 |
} |
drupal7/sites/all/modules/node_export/formats/serialize.inc | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
/** |
|
4 |
* @file |
|
5 |
* The Node export serialize format handler. |
|
6 |
* |
|
7 |
* Adds serialize format to Node export. |
|
8 |
*/ |
|
9 |
|
|
10 |
/** |
|
11 |
* Export callback. |
|
12 |
*/ |
|
13 |
function node_export_serialize_export($nodes, $format) { |
|
14 |
return 'node_export_serialize::' . htmlspecialchars(serialize($nodes)); |
|
15 |
} |
|
16 |
|
|
17 |
/** |
|
18 |
* Import callback. |
|
19 |
*/ |
|
20 |
function node_export_serialize_import($code_string) { |
|
21 |
// Check for 'node_export_serialize::' at the start. |
|
22 |
if (substr(ltrim($code_string), 0, 23) == 'node_export_serialize::') { |
|
23 |
return unserialize(htmlspecialchars_decode(str_replace('node_export_serialize::', '', $code_string))); |
|
24 |
} |
|
25 |
} |
|
26 |
|
|
27 |
/** |
|
28 |
* Callback for actions. |
|
29 |
*/ |
|
30 |
function node_export_serialize_action_form($context, &$form_state) { |
|
31 |
return node_export_action_form($context, $form_state, 'serialize'); |
|
32 |
} |
drupal7/sites/all/modules/node_export/formats/xml.inc | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
/** |
|
4 |
* @file |
|
5 |
* The Node export XML format handler. |
|
6 |
* |
|
7 |
* Adds XML format to Node export. |
|
8 |
*/ |
|
9 |
|
|
10 |
/** |
|
11 |
* Export callback. |
|
12 |
*/ |
|
13 |
function node_export_xml_export($nodes, $format) { |
|
14 |
$xml_code = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"; |
|
15 |
$xml_code .= "<node_export created=\"" . date('r') . "\">\n"; |
|
16 |
$xml_code .= node_export_xml_encode($nodes); |
|
17 |
$xml_code .= "</node_export>"; |
|
18 |
return $xml_code; |
|
19 |
} |
|
20 |
|
|
21 |
/** |
|
22 |
* Import callback. |
|
23 |
*/ |
|
24 |
function node_export_xml_import($code_string) { |
|
25 |
// Check for "<?xml" at the start. |
|
26 |
if (substr(ltrim($code_string), 0, 5) == "<?xml") { |
|
27 |
|
|
28 |
// Decode the XML. |
|
29 |
$xml_class = new NodeExportXmlDecoder(); |
|
30 |
$result = $xml_class->decode($code_string); |
|
31 |
|
|
32 |
// Convert the nodes into objects. |
|
33 |
if (!isset($result['success'])) { |
|
34 |
foreach($result as $k => $v) { |
|
35 |
$result[$k] = (object)$v; |
|
36 |
} |
|
37 |
} |
|
38 |
|
|
39 |
return $result; |
|
40 |
} |
|
41 |
} |
|
42 |
|
|
43 |
/** |
|
44 |
* Build XML string recursively. |
|
45 |
*/ |
|
46 |
function node_export_xml_encode($var, $iteration = 0) { |
|
47 |
$xml_code = ""; |
|
48 |
$tab = ''; |
|
49 |
for ($i = 0; $i <= $iteration; $i++) { |
|
50 |
$tab = $tab . " "; |
|
51 |
} |
|
52 |
$iteration++; |
|
53 |
foreach ($var as $key => $value) { |
|
54 |
$attributes = array(); |
|
55 |
if (is_bool($value)) { |
|
56 |
$attributes['type'] = 'boolean'; |
|
57 |
} |
|
58 |
elseif (is_null($value)) { |
|
59 |
$attributes['type'] = 'NULL'; |
|
60 |
} |
|
61 |
elseif (is_object($value)) { |
|
62 |
if ($iteration == 1 && isset($value->nid) && isset($value->type)) { |
|
63 |
// Assume first-level object with a nid and type is a stdClass node. |
|
64 |
$key = "node"; |
|
65 |
} |
|
66 |
else { |
|
67 |
$attributes['class'] = get_class($value); |
|
68 |
} |
|
69 |
$value = (array)$value; |
|
70 |
} |
|
71 |
if (is_array($value) && array_values($value) === $value) { |
|
72 |
$attributes['_numeric_keys'] = "1"; |
|
73 |
} |
|
74 |
$attr_string = ""; |
|
75 |
foreach ($attributes as $attr_name => $attr_value) { |
|
76 |
$attr_string .= ' ' . $attr_name . '="' . $attr_value . '"'; |
|
77 |
} |
|
78 |
|
|
79 |
if (is_numeric($key)) { |
|
80 |
$key = "n" . $key; |
|
81 |
} |
|
82 |
$xml_code .= $tab . "<" . $key . $attr_string . ">"; |
|
83 |
|
|
84 |
if (is_array($value)) { |
|
85 |
if (!empty($value)) { |
|
86 |
$xml_code .= "\n"; |
|
87 |
$xml_code .= node_export_xml_encode($value, $iteration); |
|
88 |
if (!is_numeric($key)) { |
|
89 |
$xml_code .= $tab; |
|
90 |
} |
|
91 |
} |
|
92 |
} |
|
93 |
elseif (is_numeric($value)) { |
|
94 |
$xml_code .= $value; |
|
95 |
} |
|
96 |
elseif (is_bool($value)) { |
|
97 |
$xml_code .= ($value ? 'TRUE' : 'FALSE'); |
|
98 |
} |
|
99 |
elseif (is_string($value)) { |
|
100 |
$xml_code .= htmlspecialchars($value); |
|
101 |
} |
|
102 |
$xml_code .= "</" . $key . ">\n"; |
|
103 |
} |
|
104 |
return $xml_code; |
|
105 |
} |
|
106 |
|
|
107 |
/** |
|
108 |
* Class for parsing Node export XML. |
|
109 |
*/ |
|
110 |
class NodeExportXmlDecoder { |
|
111 |
var $stack; |
|
112 |
var $output; |
|
113 |
|
|
114 |
function decode($code_string) { |
|
115 |
$parser = xml_parser_create(); |
|
116 |
xml_set_element_handler($parser, array(&$this, 'start_handler'), array(&$this, 'end_handler')); |
|
117 |
xml_set_character_data_handler($parser, array(&$this, 'data_handler')); |
|
118 |
$this->stack = array( |
|
119 |
array( |
|
120 |
'name' => 'node_export', |
|
121 |
'attributes' => array(), |
|
122 |
'children' => array(), |
|
123 |
'data' => '', |
|
124 |
) |
|
125 |
); |
|
126 |
if (!xml_parse($parser, $code_string)) { |
|
127 |
$errors[] = "Node export XML import was unsuccessful, error details follow. No nodes imported."; |
|
128 |
$line = xml_get_current_line_number($parser); |
|
129 |
$column = xml_get_current_column_number($parser); |
|
130 |
$error = xml_error_string(xml_get_error_code($parser)); |
|
131 |
$errors[] = "Line " . $line . ", Column " . $column .": ". $error; |
|
132 |
$lines = explode("\n", $code_string, $line + 1); |
|
133 |
$errors[] = "<pre>". htmlspecialchars($lines[$line - 1]) ."</pre>"; |
|
134 |
xml_parser_free($parser); |
|
135 |
return array( |
|
136 |
'success' => FALSE, |
|
137 |
'output' => $errors, |
|
138 |
); |
|
139 |
} |
|
140 |
xml_parser_free($parser); |
|
141 |
|
|
142 |
$tmp = $this->build($this->stack[0]); |
|
143 |
if (count($tmp) == 1) { |
|
144 |
$this->output = array_pop($tmp); |
|
145 |
} |
|
146 |
else { |
|
147 |
$this->output = array(); |
|
148 |
} |
|
149 |
unset($this->stack); |
|
150 |
return $this->output; |
|
151 |
} |
|
152 |
|
|
153 |
function build($stack) { |
|
154 |
$result = array(); |
|
155 |
|
|
156 |
if (count($stack['children']) > 0) { |
|
157 |
$keycount = array(); |
|
158 |
foreach ($stack['children'] as $child) { |
|
159 |
$keycount[] = $child['name']; |
|
160 |
} |
|
161 |
if (count(array_unique($keycount)) != count($keycount)) { |
|
162 |
// Enumerated array. |
|
163 |
$children = array(); |
|
164 |
foreach ($stack['children'] as $child) { |
|
165 |
$children[] = $this->build($child); |
|
166 |
} |
|
167 |
} |
|
168 |
else { |
|
169 |
// Associative array. |
|
170 |
$children = array(); |
|
171 |
foreach ($stack['children'] as $child) { |
|
172 |
if (!empty($stack['attributes']['_NUMERIC_KEYS'])) { |
|
173 |
$child['name'] = intval(substr($child['name'], 1)); |
|
174 |
} |
|
175 |
$children[$child['name']] = $this->build($child); |
|
176 |
} |
|
177 |
} |
|
178 |
$result = array_merge($result, $children); |
|
179 |
} |
|
180 |
|
|
181 |
if (count($result) == 0) { |
|
182 |
// An atomic value. |
|
183 |
$return = trim($stack['data']); |
|
184 |
if (isset($stack['attributes']['TYPE'])) { |
|
185 |
if ($stack['attributes']['TYPE'] == 'boolean') { |
|
186 |
return (trim($stack['data']) == 'TRUE' ? TRUE : FALSE); |
|
187 |
} |
|
188 |
elseif ($stack['attributes']['TYPE'] == 'NULL') { |
|
189 |
return NULL; |
|
190 |
} |
|
191 |
} |
|
192 |
return htmlspecialchars_decode(trim($stack['data'])); |
|
193 |
} |
|
194 |
else { |
|
195 |
// An array or object. |
|
196 |
if (isset($stack['attributes']['CLASS'])) { |
|
197 |
$object = new $stack['attributes']['CLASS'](); |
|
198 |
foreach ($result as $k => $v) { |
|
199 |
$object->$k = $v; |
|
200 |
} |
|
201 |
$result = $object; |
|
202 |
} |
|
203 |
return $result; |
|
204 |
} |
|
205 |
} |
|
206 |
|
|
207 |
function start_handler($parser, $name, $attributes = array()) { |
|
208 |
$token = array(); |
|
209 |
$token['name'] = strtolower($name); |
|
210 |
$token['attributes'] = $attributes; |
|
211 |
$token['data'] = ''; |
|
212 |
$token['children'] = array(); |
|
213 |
$this->stack[] = $token; |
|
214 |
} |
|
215 |
|
|
216 |
function end_handler($parser, $name, $attributes = array()) { |
|
217 |
$token = array_pop($this->stack); |
|
218 |
$this->stack[count($this->stack) - 1]['children'][] = $token; |
|
219 |
} |
|
220 |
|
|
221 |
function data_handler($parser, $data) { |
|
222 |
$this->stack[count($this->stack) - 1]['data'] .= $data; |
|
223 |
} |
|
224 |
|
|
225 |
} |
|
226 |
|
|
227 |
/** |
|
228 |
* Callback for actions. |
|
229 |
*/ |
|
230 |
function node_export_xml_action_form($context, &$form_state) { |
|
231 |
return node_export_action_form($context, $form_state, 'xml'); |
|
232 |
} |
drupal7/sites/all/modules/node_export/modules/node_export_dependency/node_export_dependency.api.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
/** |
|
4 |
* @file |
|
5 |
* Documents Node export dependency's hooks for api reference. |
|
6 |
*/ |
|
7 |
|
|
8 |
/** |
|
9 |
* Handle dependencies not already handled. |
|
10 |
* |
|
11 |
* Let other modules alter this - for example to only allow some users to |
|
12 |
* export specific nodes or types. |
|
13 |
* |
|
14 |
* @param &$handled |
|
15 |
* Boolean indicating whether the dependency was handled, only set to TRUE, |
|
16 |
* never explicitly set it to FALSE. Only run code when it is already FALSE. |
|
17 |
* @param $node |
|
18 |
* The node to handle the dependency for. |
|
19 |
* @param $dependency |
|
20 |
* The dependency data. |
|
21 |
*/ |
|
22 |
function hook_node_export_dependency_alter(&$handled, &$node, $dependency) { |
|
23 |
if (!$handled) { |
|
24 |
// Attempt to handle the dependency here. |
|
25 |
// If it's handled successfully set $handled to TRUE. |
|
26 |
} |
|
27 |
} |
drupal7/sites/all/modules/node_export/modules/node_export_dependency/node_export_dependency.core.inc | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
/** |
|
4 |
* @file |
|
5 |
* Contains hook implementations for all relevant core module. |
|
6 |
*/ |
|
7 |
|
|
8 |
/** |
|
9 |
* Implements hook_node_export_dependency(). |
|
10 |
*/ |
|
11 |
function node_node_export_dependency($entity, $entity_type) { |
|
12 |
if ($entity_type == 'node') { |
|
13 |
$dependencies = array(); |
|
14 |
// The node has a 'user' dependency through the 'uid' and |
|
15 |
// 'revision_uid' properties. |
|
16 |
node_export_dependency_add($dependencies, $entity, 'user', array('uid', 'revision_uid')); |
|
17 |
// The node has a 'node' dependency through the 'tnid' property. |
|
18 |
node_export_dependency_add($dependencies, $entity, 'node', 'tnid'); |
|
19 |
return $dependencies; |
|
20 |
} |
|
21 |
} |
|
22 |
|
|
23 |
/** |
|
24 |
* Implements hook_node_export_dependency() |
|
25 |
*/ |
|
26 |
function taxonomy_node_export_dependency($entity, $entity_type) { |
|
27 |
if ($entity_type == 'taxonomy_term') { |
|
28 |
$dependencies = array(); |
|
29 |
$terms = taxonomy_get_parents($entity->tid); |
|
30 |
$delta = 0; |
|
31 |
foreach ($terms as $tid => $term) { |
|
32 |
$dependencies[] = array( |
|
33 |
'type' => 'taxonomy_term', |
|
34 |
'id' => $tid, |
|
35 |
'property' => 'parent', |
|
36 |
'delta' => $delta++, |
|
37 |
); |
|
38 |
} |
|
39 |
return $dependencies; |
|
40 |
} |
|
41 |
} |
|
42 |
|
|
43 |
/** |
|
44 |
* Implements hook_node_export_dependency(). |
|
45 |
*/ |
|
46 |
function book_node_export_dependency($entity, $entity_type) { |
|
47 |
if ($entity_type == 'node' && !empty($entity->book)) { |
|
48 |
$dependencies = array(); |
|
49 |
|
|
50 |
// Book page's root book node. |
|
51 |
if (!empty($entity->book['bid'])) { |
|
52 |
$dependencies[] = array( |
|
53 |
'type' => 'node', |
|
54 |
'id' => $entity->book['bid'], |
|
55 |
'property' => array(array('book', 'bid')), |
|
56 |
); |
|
57 |
} |
|
58 |
|
|
59 |
// Book page's immediate parent. |
|
60 |
if (!empty($entity->book['plid'])) { |
|
61 |
$parent_nid = db_query( |
|
62 |
'SELECT nid FROM {book} WHERE mlid = :mlid', |
|
63 |
array(':mlid' => $entity->book['plid']) |
|
64 |
)->fetchField(); |
|
65 |
$dependencies[] = array( |
|
66 |
'type' => 'node', |
|
67 |
'id' => $parent_nid, |
|
68 |
'property' => array(array('book', 'plid')), |
|
69 |
// Recognise the relationship is not done through the entity id key. |
|
70 |
'relationship' => array( |
|
71 |
'key' => array('menu', 'mlid'), |
|
72 |
'value' => $entity->book['plid'], |
|
73 |
), |
|
74 |
); |
|
75 |
} |
|
76 |
|
|
77 |
// Book page's immediate children. |
|
78 |
$flat = book_get_flat_menu($entity->book); |
|
79 |
$children = array(); |
|
80 |
if ($entity->book['has_children']) { |
|
81 |
// Walk through the array until we find the current page. |
|
82 |
do { |
|
83 |
$link = array_shift($flat); |
|
84 |
} while ($link && ($link['mlid'] != $entity->book['mlid'])); |
|
85 |
// Continue through the array and collect the links whose parent is this page. |
|
86 |
while (($link = array_shift($flat)) && $link['plid'] == $entity->book['mlid']) { |
|
87 |
$matches = array(); |
|
88 |
if (preg_match('/^node\/([\d]+)$/', $link['href'], $matches)) { |
|
89 |
$dependencies[] = array( |
|
90 |
'type' => 'node', |
|
91 |
'id' => $matches[1], |
|
92 |
); |
|
93 |
} |
|
94 |
} |
|
95 |
} |
|
96 |
|
|
97 |
return $dependencies; |
|
98 |
} |
|
99 |
} |
|
100 |
|
|
101 |
/** |
|
102 |
* Implements hook_node_export_dependency(). |
|
103 |
*/ |
|
104 |
function og_node_export_dependency($entity, $entity_type) { |
|
105 |
if ($entity_type == 'node') { |
|
106 |
$dependencies = array(); |
|
107 |
|
|
108 |
if (!empty($entity->og_groups)) { |
|
109 |
foreach (array_keys($entity->og_groups) as $delta) { |
|
110 |
entity_dependency_add($dependencies, $entity, 'node', array(array('og_groups', $delta))); |
|
111 |
} |
|
112 |
} |
|
113 |
|
|
114 |
if (!empty($entity->og_parent->nid)) { |
|
115 |
entity_dependency_add($dependencies, $entity, 'node', array(array('og_parent', 'nid'))); |
|
116 |
} |
|
117 |
|
|
118 |
if (!empty($dependencies)) { |
|
119 |
return $dependencies; |
|
120 |
} |
|
121 |
} |
|
122 |
} |
|
123 |
|
|
124 |
/** |
|
125 |
* Implements hook_node_export_dependency(). |
|
126 |
*/ |
|
127 |
function field_node_export_dependency($entity, $entity_type) { |
|
128 |
$dependencies = array(); |
|
129 |
list(,, $bundle_name) = entity_extract_ids($entity_type, $entity); |
|
130 |
$instances = field_info_instances($entity_type, $bundle_name); |
|
131 |
|
|
132 |
foreach ($instances as $field_name => $instance) { |
|
133 |
$field = field_info_field($field_name); |
|
134 |
foreach ($entity->{$field_name} as $langcode => $items) { |
|
135 |
$field_dependencies = module_invoke($field['module'], 'node_export_dependency_field', $entity_type, $entity, $field, $instance, $langcode, $items); |
|
136 |
|
|
137 |
// Let other modules alter dependencies for this field. |
|
138 |
drupal_alter('node_export_dependency_field', $field_dependencies, $entity_type, $entity, $field, $instance, $langcode, $items); |
|
139 |
|
|
140 |
if (!empty($field_dependencies)) { |
|
141 |
foreach ($field_dependencies as &$field_dependency) { |
|
142 |
if (empty($field_dependency['module'])) { |
|
143 |
$field_dependency['module'] = $field['module']; |
|
144 |
} |
|
145 |
if (empty($field_dependency['field_name'])) { |
|
146 |
$field_dependency['field_name'] = $field_name; |
|
147 |
} |
|
148 |
if (empty($field_dependency['langcode'])) { |
|
149 |
$field_dependency['langcode'] = $langcode; |
|
150 |
} |
|
151 |
} |
|
152 |
$dependencies = array_merge_recursive($dependencies, $field_dependencies); |
|
153 |
} |
|
154 |
} |
|
155 |
} |
|
156 |
return $dependencies; |
|
157 |
} |
|
158 |
|
|
159 |
/** |
|
160 |
* Implements hook_node_export_dependency_field(). |
|
161 |
*/ |
|
162 |
function taxonomy_node_export_dependency_field($entity_type, $entity, $field, $instance, $langcode, $items) { |
|
163 |
// No need to check for the field type here, since this hook is only called |
|
164 |
// for the owner of this field. Taxonomy module only owns one field. |
|
165 |
$dependencies = array(); |
|
166 |
node_export_dependency_add($dependencies, $items, 'taxonomy_term', 'tid'); |
|
167 |
return $dependencies; |
|
168 |
} |
|
169 |
|
|
170 |
/** |
|
171 |
* Implements hook_node_export_dependency_field(). |
|
172 |
*/ |
|
173 |
function file_node_export_dependency_field($entity_type, $entity, $field, $instance, $langcode, $items) { |
|
174 |
$dependencies = array(); |
|
175 |
node_export_dependency_add($dependencies, $items, 'file', 'fid'); |
|
176 |
node_export_dependency_add($dependencies, $items, 'user', 'uid'); |
|
177 |
return $dependencies; |
|
178 |
} |
|
179 |
|
|
180 |
/** |
|
181 |
* Implements hook_node_export_dependency_field(). |
|
182 |
*/ |
|
183 |
function image_node_export_dependency_field($entity_type, $entity, $field, $instance, $langcode, $items) { |
|
184 |
return file_node_export_dependency_field($entity_type, $entity, $field, $instance, $langcode, $items); |
|
185 |
} |
|
186 |
|
|
187 |
/** |
|
188 |
* Implements hook_node_export_dependency_field(). |
|
189 |
*/ |
|
190 |
function node_reference_node_export_dependency_field($entity_type, $entity, $field, $instance, $langcode, $items) { |
|
191 |
$dependencies = array(); |
|
192 |
node_export_dependency_add($dependencies, $items, 'node', 'nid'); |
|
193 |
return $dependencies; |
|
194 |
} |
|
195 |
|
|
196 |
/** |
|
197 |
* Implements hook_node_export_dependency_field(). |
|
198 |
*/ |
|
199 |
function user_reference_node_export_dependency_field($entity_type, $entity, $field, $instance, $langcode, $items) { |
|
200 |
$dependencies = array(); |
|
201 |
node_export_dependency_add($dependencies, $items, 'user', 'uid'); |
|
202 |
return $dependencies; |
|
203 |
} |
|
204 |
|
|
205 |
/** |
|
206 |
* Implements hook_node_export_dependency_field(). |
|
207 |
*/ |
|
208 |
function entityreference_node_export_dependency_field($entity_type, $entity, $field, $instance, $langcode, $items) { |
|
209 |
$dependencies = array(); |
|
210 |
node_export_dependency_add($dependencies, $items, $field['settings']['target_type'], 'target_id'); |
|
211 |
return $dependencies; |
|
212 |
} |
|
213 |
|
|
214 |
/** |
|
215 |
* Implements hook_node_export_dependency_field(). |
|
216 |
*/ |
|
217 |
function field_collection_node_export_dependency_field($entity_type, $entity, $field, $instance, $langcode, $items) { |
|
218 |
$dependencies = array(); |
|
219 |
node_export_dependency_add($dependencies, $items, 'field_collection_item', 'value'); |
|
220 |
return $dependencies; |
|
221 |
} |
|
222 |
|
drupal7/sites/all/modules/node_export/modules/node_export_dependency/node_export_dependency.info | ||
---|---|---|
1 |
name = Node export dependency (experimental) |
|
2 |
description = Helps maintain relationships to dependent entities. Intended to make Node export relation obsolete. |
|
3 |
dependencies[] = node_export |
|
4 |
dependencies[] = uuid |
|
5 |
core = 7.x |
|
6 |
package = "Node export" |
|
7 |
; Information added by drupal.org packaging script on 2012-08-20 |
|
8 |
version = "7.x-3.0" |
|
9 |
core = "7.x" |
|
10 |
project = "node_export" |
|
11 |
datestamp = "1345435979" |
|
12 |
|
drupal7/sites/all/modules/node_export/modules/node_export_dependency/node_export_dependency.install | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
/** |
|
4 |
* @file |
|
5 |
* The Node export dependency install file. |
Formats disponibles : Unified diff
Remove node_export as it is not used.