@ -0,0 +1,94 @@ | |||||
This file lists current & previous members of the refbase development team | |||||
and other contributors. | |||||
Please avoid sending e-mail with refbase-related questions directly to them; | |||||
your questions are likely to be answered much faster if you post them to one | |||||
of the mailing lists or forums: | |||||
<http://support.refbase.net/> | |||||
msteffens:Matthias Steffens <refbase@extracts.de>: | |||||
Project manager, lead developer, application engineering & design | |||||
karnesky:Richard Karnesky <karnesky@gmail.com>: | |||||
Project manager, application engineering, MODS XML export, Endnote style, | |||||
COinS, update.php, some bugfixes & docs | |||||
pnault:Pierre Nault <pnault@users.sourceforge.net>: | |||||
Localization efforts, some bugfixes | |||||
Previous developers: | |||||
Michael Bartz <michaelbartz@users.sourceforge.net>: | |||||
Advisor | |||||
wendebaum:Jochen Wendebaum <wendebaum@users.sourceforge.net>: | |||||
Internationalization, german localization | |||||
Daniel Stepputtis <antedon@users.sourceforge.net>: | |||||
Documentation & general support | |||||
Thanks to: | |||||
- Joachim Almergren <jlacan@users.sourceforge.net>: | |||||
Various patches | |||||
- Oleksandr Moskalenko <oleksa@users.sourceforge.net>: | |||||
Troubleshooting and patch for directory renaming | |||||
- Dave Burt: | |||||
Fix for MODS encoding | |||||
- Nicholaus Lance Hepler <nhelper@gmail.com>: | |||||
Patch to retrieve information from PubMed before CrossRef | |||||
- Denis Potapov <potapov@exemail.com.au>: | |||||
PHP7 compatibility patching | |||||
- Yibiao Bai <mountangellib@gmail.com> and Yong Fan, Shanxi Agricultural | |||||
University Library, China: | |||||
Chinese localization. | |||||
- Alexander Belozerov <alexander.belozerov@gmail.com>: | |||||
Russian localization. | |||||
- Masahiro Mikami <ZBN15427@nifty.com>: | |||||
Japanese localization. | |||||
- Chris Putnam <cdputnam@scripps.edu>: | |||||
Developer of Bibutils, a set of command line programs that interconvert | |||||
between various bibliography formats using a common XML intermediate. | |||||
<http://www.scripps.edu/~cdputnam/software/bibutils/bibutils.html> | |||||
- Mark Grimshaw <sirfragalot@users.sourceforge.net>: | |||||
Developer of MINIMALRTF, a minimal set of RTF coding methods to produce | |||||
Rich Text Format documents on the fly. <http://bibliophile.sourceforge.net> | |||||
- Wayne Munro at R&OS New Zealand: | |||||
Developer of the module-free pdf-PHP class that allows to dynamically create | |||||
PDF documents with PHP. <http://www.ros.co.nz/pdf> | |||||
- Ryan Parman and Geoffrey Sneddon: | |||||
Developers of the SimplePie PHP class that allows to manage RSS and Atom feeds | |||||
with PHP. <http://simplepie.org> | |||||
- Thomas Fuchs and contributors: | |||||
Developers of the script.aculo.us JavaScript framework. <http://script.aculo.us> | |||||
- Sam Stephenson and contributors: | |||||
Developers of the Prototype JavaScript framework. <http://www.prototypejs.org/> | |||||
- nijel and garvinhicking of the phpMyAdmin project: | |||||
Developers of zip.inc.php, which is used to zip OpenDocument files. | |||||
<http://www.phpmyadmin.net> | |||||
- Ryan Thrash: | |||||
Developer of the "Simple Rounded Corner CSS Boxes". | |||||
<http://www.modxcms.com/simple-rounded-corner-css-boxes.html> | |||||
see also the ThrashBox online generator at <http://www.spiffybox.com/> | |||||
- Hugh E. Williams and David Lane, authors of the book "Web Database Applications | |||||
with PHP and MySQL", published by O'Reilly & Associates, whose example code | |||||
helped getting started. <http://www.oreilly.com/catalog/webdbapps2/> | |||||
Many other people have contributed to this project with feature requests, bug | |||||
reports, testing, and helpful suggestions. |
@ -0,0 +1,29 @@ | |||||
We are aware of the following problems, bugs and/or limitations: | |||||
- The clickable search links do not maintain the current sort order, | |||||
and they do not maintain the currently chosen fields in List view. | |||||
- For the main page, only partial HTML is returned when clicking one of the | |||||
clickable search links within the "more info" section underneath each | |||||
citation. | |||||
- The advanced search form employs lots of dynamic drop-down menus to ease | |||||
user entry of data. This works well for small databases (<10,000 records) | |||||
but may cause significant speed problems for larger databases! | |||||
- There's no support for transactions. This means that multiple users will be | |||||
able to edit the same record at the same time. This will usually cause the | |||||
record to be overwritten by the last submitter, but it could cause | |||||
surprising results. Please remember to reload record data if you kept a | |||||
record's "edit" form open for a long period of time. | |||||
- The 'allow_edit_call_number' permission setting isn't honoured yet. | |||||
- The process of internationalization and localization has not been completed | |||||
yet. | |||||
- Working simultaneously in different browser windows or tabs may cause some | |||||
unexpected results (due to referrer-related issues). You can avoid problems | |||||
if you reload the current browser window/tab before doing anything else in | |||||
that window/tab. | |||||
@ -0,0 +1,340 @@ | |||||
GNU GENERAL PUBLIC LICENSE | |||||
Version 2, June 1991 | |||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc. | |||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||||
Everyone is permitted to copy and distribute verbatim copies | |||||
of this license document, but changing it is not allowed. | |||||
Preamble | |||||
The licenses for most software are designed to take away your | |||||
freedom to share and change it. By contrast, the GNU General Public | |||||
License is intended to guarantee your freedom to share and change free | |||||
software--to make sure the software is free for all its users. This | |||||
General Public License applies to most of the Free Software | |||||
Foundation's software and to any other program whose authors commit to | |||||
using it. (Some other Free Software Foundation software is covered by | |||||
the GNU Library General Public License instead.) You can apply it to | |||||
your programs, too. | |||||
When we speak of free software, we are referring to freedom, not | |||||
price. Our General Public Licenses are designed to make sure that you | |||||
have the freedom to distribute copies of free software (and charge for | |||||
this service if you wish), that you receive source code or can get it | |||||
if you want it, that you can change the software or use pieces of it | |||||
in new free programs; and that you know you can do these things. | |||||
To protect your rights, we need to make restrictions that forbid | |||||
anyone to deny you these rights or to ask you to surrender the rights. | |||||
These restrictions translate to certain responsibilities for you if you | |||||
distribute copies of the software, or if you modify it. | |||||
For example, if you distribute copies of such a program, whether | |||||
gratis or for a fee, you must give the recipients all the rights that | |||||
you have. You must make sure that they, too, receive or can get the | |||||
source code. And you must show them these terms so they know their | |||||
rights. | |||||
We protect your rights with two steps: (1) copyright the software, and | |||||
(2) offer you this license which gives you legal permission to copy, | |||||
distribute and/or modify the software. | |||||
Also, for each author's protection and ours, we want to make certain | |||||
that everyone understands that there is no warranty for this free | |||||
software. If the software is modified by someone else and passed on, we | |||||
want its recipients to know that what they have is not the original, so | |||||
that any problems introduced by others will not reflect on the original | |||||
authors' reputations. | |||||
Finally, any free program is threatened constantly by software | |||||
patents. We wish to avoid the danger that redistributors of a free | |||||
program will individually obtain patent licenses, in effect making the | |||||
program proprietary. To prevent this, we have made it clear that any | |||||
patent must be licensed for everyone's free use or not licensed at all. | |||||
The precise terms and conditions for copying, distribution and | |||||
modification follow. | |||||
GNU GENERAL PUBLIC LICENSE | |||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | |||||
0. This License applies to any program or other work which contains | |||||
a notice placed by the copyright holder saying it may be distributed | |||||
under the terms of this General Public License. The "Program", below, | |||||
refers to any such program or work, and a "work based on the Program" | |||||
means either the Program or any derivative work under copyright law: | |||||
that is to say, a work containing the Program or a portion of it, | |||||
either verbatim or with modifications and/or translated into another | |||||
language. (Hereinafter, translation is included without limitation in | |||||
the term "modification".) Each licensee is addressed as "you". | |||||
Activities other than copying, distribution and modification are not | |||||
covered by this License; they are outside its scope. The act of | |||||
running the Program is not restricted, and the output from the Program | |||||
is covered only if its contents constitute a work based on the | |||||
Program (independent of having been made by running the Program). | |||||
Whether that is true depends on what the Program does. | |||||
1. You may copy and distribute verbatim copies of the Program's | |||||
source code as you receive it, in any medium, provided that you | |||||
conspicuously and appropriately publish on each copy an appropriate | |||||
copyright notice and disclaimer of warranty; keep intact all the | |||||
notices that refer to this License and to the absence of any warranty; | |||||
and give any other recipients of the Program a copy of this License | |||||
along with the Program. | |||||
You may charge a fee for the physical act of transferring a copy, and | |||||
you may at your option offer warranty protection in exchange for a fee. | |||||
2. You may modify your copy or copies of the Program or any portion | |||||
of it, thus forming a work based on the Program, and copy and | |||||
distribute such modifications or work under the terms of Section 1 | |||||
above, provided that you also meet all of these conditions: | |||||
a) You must cause the modified files to carry prominent notices | |||||
stating that you changed the files and the date of any change. | |||||
b) You must cause any work that you distribute or publish, that in | |||||
whole or in part contains or is derived from the Program or any | |||||
part thereof, to be licensed as a whole at no charge to all third | |||||
parties under the terms of this License. | |||||
c) If the modified program normally reads commands interactively | |||||
when run, you must cause it, when started running for such | |||||
interactive use in the most ordinary way, to print or display an | |||||
announcement including an appropriate copyright notice and a | |||||
notice that there is no warranty (or else, saying that you provide | |||||
a warranty) and that users may redistribute the program under | |||||
these conditions, and telling the user how to view a copy of this | |||||
License. (Exception: if the Program itself is interactive but | |||||
does not normally print such an announcement, your work based on | |||||
the Program is not required to print an announcement.) | |||||
These requirements apply to the modified work as a whole. If | |||||
identifiable sections of that work are not derived from the Program, | |||||
and can be reasonably considered independent and separate works in | |||||
themselves, then this License, and its terms, do not apply to those | |||||
sections when you distribute them as separate works. But when you | |||||
distribute the same sections as part of a whole which is a work based | |||||
on the Program, the distribution of the whole must be on the terms of | |||||
this License, whose permissions for other licensees extend to the | |||||
entire whole, and thus to each and every part regardless of who wrote it. | |||||
Thus, it is not the intent of this section to claim rights or contest | |||||
your rights to work written entirely by you; rather, the intent is to | |||||
exercise the right to control the distribution of derivative or | |||||
collective works based on the Program. | |||||
In addition, mere aggregation of another work not based on the Program | |||||
with the Program (or with a work based on the Program) on a volume of | |||||
a storage or distribution medium does not bring the other work under | |||||
the scope of this License. | |||||
3. You may copy and distribute the Program (or a work based on it, | |||||
under Section 2) in object code or executable form under the terms of | |||||
Sections 1 and 2 above provided that you also do one of the following: | |||||
a) Accompany it with the complete corresponding machine-readable | |||||
source code, which must be distributed under the terms of Sections | |||||
1 and 2 above on a medium customarily used for software interchange; or, | |||||
b) Accompany it with a written offer, valid for at least three | |||||
years, to give any third party, for a charge no more than your | |||||
cost of physically performing source distribution, a complete | |||||
machine-readable copy of the corresponding source code, to be | |||||
distributed under the terms of Sections 1 and 2 above on a medium | |||||
customarily used for software interchange; or, | |||||
c) Accompany it with the information you received as to the offer | |||||
to distribute corresponding source code. (This alternative is | |||||
allowed only for noncommercial distribution and only if you | |||||
received the program in object code or executable form with such | |||||
an offer, in accord with Subsection b above.) | |||||
The source code for a work means the preferred form of the work for | |||||
making modifications to it. For an executable work, complete source | |||||
code means all the source code for all modules it contains, plus any | |||||
associated interface definition files, plus the scripts used to | |||||
control compilation and installation of the executable. However, as a | |||||
special exception, the source code distributed need not include | |||||
anything that is normally distributed (in either source or binary | |||||
form) with the major components (compiler, kernel, and so on) of the | |||||
operating system on which the executable runs, unless that component | |||||
itself accompanies the executable. | |||||
If distribution of executable or object code is made by offering | |||||
access to copy from a designated place, then offering equivalent | |||||
access to copy the source code from the same place counts as | |||||
distribution of the source code, even though third parties are not | |||||
compelled to copy the source along with the object code. | |||||
4. You may not copy, modify, sublicense, or distribute the Program | |||||
except as expressly provided under this License. Any attempt | |||||
otherwise to copy, modify, sublicense or distribute the Program is | |||||
void, and will automatically terminate your rights under this License. | |||||
However, parties who have received copies, or rights, from you under | |||||
this License will not have their licenses terminated so long as such | |||||
parties remain in full compliance. | |||||
5. You are not required to accept this License, since you have not | |||||
signed it. However, nothing else grants you permission to modify or | |||||
distribute the Program or its derivative works. These actions are | |||||
prohibited by law if you do not accept this License. Therefore, by | |||||
modifying or distributing the Program (or any work based on the | |||||
Program), you indicate your acceptance of this License to do so, and | |||||
all its terms and conditions for copying, distributing or modifying | |||||
the Program or works based on it. | |||||
6. Each time you redistribute the Program (or any work based on the | |||||
Program), the recipient automatically receives a license from the | |||||
original licensor to copy, distribute or modify the Program subject to | |||||
these terms and conditions. You may not impose any further | |||||
restrictions on the recipients' exercise of the rights granted herein. | |||||
You are not responsible for enforcing compliance by third parties to | |||||
this License. | |||||
7. If, as a consequence of a court judgment or allegation of patent | |||||
infringement or for any other reason (not limited to patent issues), | |||||
conditions are imposed on you (whether by court order, agreement or | |||||
otherwise) that contradict the conditions of this License, they do not | |||||
excuse you from the conditions of this License. If you cannot | |||||
distribute so as to satisfy simultaneously your obligations under this | |||||
License and any other pertinent obligations, then as a consequence you | |||||
may not distribute the Program at all. For example, if a patent | |||||
license would not permit royalty-free redistribution of the Program by | |||||
all those who receive copies directly or indirectly through you, then | |||||
the only way you could satisfy both it and this License would be to | |||||
refrain entirely from distribution of the Program. | |||||
If any portion of this section is held invalid or unenforceable under | |||||
any particular circumstance, the balance of the section is intended to | |||||
apply and the section as a whole is intended to apply in other | |||||
circumstances. | |||||
It is not the purpose of this section to induce you to infringe any | |||||
patents or other property right claims or to contest validity of any | |||||
such claims; this section has the sole purpose of protecting the | |||||
integrity of the free software distribution system, which is | |||||
implemented by public license practices. Many people have made | |||||
generous contributions to the wide range of software distributed | |||||
through that system in reliance on consistent application of that | |||||
system; it is up to the author/donor to decide if he or she is willing | |||||
to distribute software through any other system and a licensee cannot | |||||
impose that choice. | |||||
This section is intended to make thoroughly clear what is believed to | |||||
be a consequence of the rest of this License. | |||||
8. If the distribution and/or use of the Program is restricted in | |||||
certain countries either by patents or by copyrighted interfaces, the | |||||
original copyright holder who places the Program under this License | |||||
may add an explicit geographical distribution limitation excluding | |||||
those countries, so that distribution is permitted only in or among | |||||
countries not thus excluded. In such case, this License incorporates | |||||
the limitation as if written in the body of this License. | |||||
9. The Free Software Foundation may publish revised and/or new versions | |||||
of the General Public License from time to time. Such new versions will | |||||
be similar in spirit to the present version, but may differ in detail to | |||||
address new problems or concerns. | |||||
Each version is given a distinguishing version number. If the Program | |||||
specifies a version number of this License which applies to it and "any | |||||
later version", you have the option of following the terms and conditions | |||||
either of that version or of any later version published by the Free | |||||
Software Foundation. If the Program does not specify a version number of | |||||
this License, you may choose any version ever published by the Free Software | |||||
Foundation. | |||||
10. If you wish to incorporate parts of the Program into other free | |||||
programs whose distribution conditions are different, write to the author | |||||
to ask for permission. For software which is copyrighted by the Free | |||||
Software Foundation, write to the Free Software Foundation; we sometimes | |||||
make exceptions for this. Our decision will be guided by the two goals | |||||
of preserving the free status of all derivatives of our free software and | |||||
of promoting the sharing and reuse of software generally. | |||||
NO WARRANTY | |||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY | |||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN | |||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES | |||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED | |||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS | |||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE | |||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, | |||||
REPAIR OR CORRECTION. | |||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING | |||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR | |||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, | |||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING | |||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED | |||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY | |||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER | |||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE | |||||
POSSIBILITY OF SUCH DAMAGES. | |||||
END OF TERMS AND CONDITIONS | |||||
How to Apply These Terms to Your New Programs | |||||
If you develop a new program, and you want it to be of the greatest | |||||
possible use to the public, the best way to achieve this is to make it | |||||
free software which everyone can redistribute and change under these terms. | |||||
To do so, attach the following notices to the program. It is safest | |||||
to attach them to the start of each source file to most effectively | |||||
convey the exclusion of warranty; and each file should have at least | |||||
the "copyright" line and a pointer to where the full notice is found. | |||||
<one line to give the program's name and a brief idea of what it does.> | |||||
Copyright (C) <year> <name of author> | |||||
This program is free software; you can redistribute it and/or modify | |||||
it under the terms of the GNU General Public License as published by | |||||
the Free Software Foundation; either version 2 of the License, or | |||||
(at your option) any later version. | |||||
This program is distributed in the hope that it will be useful, | |||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
GNU General Public License for more details. | |||||
You should have received a copy of the GNU General Public License | |||||
along with this program; if not, write to the Free Software | |||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||||
Also add information on how to contact you by electronic and paper mail. | |||||
If the program is interactive, make it output a short notice like this | |||||
when it starts in an interactive mode: | |||||
Gnomovision version 69, Copyright (C) year name of author | |||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. | |||||
This is free software, and you are welcome to redistribute it | |||||
under certain conditions; type `show c' for details. | |||||
The hypothetical commands `show w' and `show c' should show the appropriate | |||||
parts of the General Public License. Of course, the commands you use may | |||||
be called something other than `show w' and `show c'; they could even be | |||||
mouse-clicks or menu items--whatever suits your program. | |||||
You should also get your employer (if you work as a programmer) or your | |||||
school, if any, to sign a "copyright disclaimer" for the program, if | |||||
necessary. Here is a sample; alter the names: | |||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program | |||||
`Gnomovision' (which makes passes at compilers) written by James Hacker. | |||||
<signature of Ty Coon>, 1 April 1989 | |||||
Ty Coon, President of Vice | |||||
This General Public License does not permit incorporating your program into | |||||
proprietary programs. If your program is a subroutine library, you may | |||||
consider it more useful to permit linking proprietary applications with the | |||||
library. If this is what you want to do, use the GNU Library General | |||||
Public License instead of this License. |
@ -0,0 +1,170 @@ | |||||
How to install? | |||||
--------------- | |||||
- You'll need a web server and an existing PHP and MySQL installation. | |||||
If you require help on installation of these packages please visit | |||||
<http://httpd.apache.org>, <http://php.net> and <http://mysql.com>. | |||||
- Move all refbase-0.9.7 files to your web directory. | |||||
- Open the file 'initialize/db.inc.php' in a text editor and edit the values | |||||
of the variables '$databaseName', '$username' and '$password' to fit your | |||||
needs. | |||||
(Note that you might be able to use the refbase package without modifying | |||||
these variables, but we highly recommend not to use the default values!) | |||||
- Now, open a web browser and access the 'install.php' script by typing: | |||||
<http://SERVER_ADDRESS/PATH_ON_SERVER/install.php> | |||||
(where the string 'SERVER_ADDRESS' is replaced by your server name and | |||||
'PATH_ON_SERVER' is the actual path to your refbase-0.9.7 web directory) | |||||
This should bring up the install form. Edit the contents of all text entry | |||||
fields to match your server setup and supply the MySQL admin password, then | |||||
click the 'Install' button to complete the installation process. | |||||
WIN32: Be sure to set a password for the MySQL root user. The path to MySQL | |||||
is probably '/Program Files/MySQL/bin/mysql.exe' or | |||||
'/wamp/mysql/bin/mysql.exe', or wherever you've installed MySQL. | |||||
- Please delete 'install.php' and 'update.php' from your webserver. | |||||
Solutions for known problems and general troubleshooting tips are given at: | |||||
<http://troubleshooting.refbase.net> | |||||
See also: | |||||
<http://requirements.refbase.net> | |||||
<http://install.refbase.net> | |||||
How to setup your own admin user? | |||||
--------------------------------- | |||||
- After you've successfully installed the database (see above), open the main | |||||
page ('index.php') and login with: | |||||
Email = user@refbase.net | |||||
Password = start | |||||
You should now see a welcome message at the top right corner of the page | |||||
confirming your successful login. | |||||
- Click on 'Add User' which should bring up an empty form. At a minimum, you | |||||
have to specify the admin's first name & last name, his institutional | |||||
abbreviation as well as his email address and password. Then click the 'Add | |||||
User' button. You will be shown a receipt page with the account details you | |||||
just entered. | |||||
- Now open the file 'initialize/ini.inc.php' in a text editor and change the | |||||
value of the '$adminLoginEmail' variable to the email address you've | |||||
specified for your new admin user. | |||||
- Log out from the database, then login again using the email address and | |||||
password of your newly created admin account. | |||||
- You can now delete the initial user by choosing 'Manage Users' and clicking | |||||
the appropriate trash icon. (However, we recommend to keep this user until | |||||
you've explored the example records that come with the database) | |||||
See also: | |||||
<http://adduser.refbase.net> | |||||
How to configure the database? | |||||
------------------------------ | |||||
In order to properly configure your database you'll need to edit the global | |||||
configuration file: | |||||
- Open the file 'initialize/ini.inc.php' & edit all values of the contained | |||||
variables to fit your needs. Please see the comments within the file for | |||||
further guidance. | |||||
Especially note that if you've chosen 'utf8' (Unicode) as default character | |||||
set on installation, you must re-save the file 'ini.inc.php' with Unicode | |||||
encoding (UTF-8, no BOM) and set variable '$contentTypeCharset' to 'UTF-8'. | |||||
See also: | |||||
<http://configure.refbase.net> | |||||
Import Options | |||||
-------------- | |||||
refbase offers batch import of records via the web interface ('import.php') or | |||||
the command line ('contrib/command_line/refbase_import'). These scripts allow | |||||
to import records from various common bibliographic formats (BibTeX, Copac, | |||||
Endnote (tagged text & XML), MODS XML, RefWorks, RIS or SciFinder) as well as | |||||
from online databases (CSA Illumina, ISI Web of Science or PubMed (MEDLINE & XML)). | |||||
If you're coming from Endnote you may want to try out the Endnote style file | |||||
and PHP script that's included with refbase. This style file and PHP script | |||||
allows Endnote users to transfer data into refbase at the command line (see | |||||
the README file in the 'contrib/endnote' directory for further information). | |||||
In addition, refbase allows PHP developers to write their own import parsers | |||||
and use the provided templates to import their records into the refbase | |||||
database (see the 'contrib/import_templates' directory for available | |||||
templates). | |||||
If you can't use any of the above mentioned import options, you might be able | |||||
to convert your data into a tab-delimited text format that can be imported | |||||
directly into the MySQL database. Here are some notes how to prepare | |||||
tab-delimited data for direct upload into your newly created MySQL tables: | |||||
- Fields are separated by tabs, records are separated by returns | |||||
(if not specified otherwise within the LOAD DATA statement). | |||||
- The order of fields must resemble the field order specified in the MySQL | |||||
table 'refs'. Field information for table 'refs' is given at: | |||||
<http://wiki.refbase.net/index.php/Table_refs> | |||||
- DATE format must be YYYY-MM-DD and TIME format must be HH:MM:SS. | |||||
- Carriage returns *within* fields must be represented by a newline character | |||||
('\n', ASCII character 10). | |||||
- Empty fields must be indicated by \N. | |||||
- Character encoding: if you've chose 'latin1' as default character set upon | |||||
installation, higher ASCII chars must be encoded as ISO-8859-1 aka 'Western | |||||
(ISO Latin 1)', otherwise data should be encoded as Unicode (UTF-8, no BOM). | |||||
- File encoding must be UNIX. | |||||
- Assuming your data file is named 'refs.txt', you should be able to upload | |||||
your data via use of the 'mysql' command line interpreter: | |||||
LOAD DATA LOCAL INFILE "/PATH/TO/FILE/refs.txt" INTO TABLE refs; | |||||
or, alternatively, use something like the following from your shell: | |||||
mysqlimport --local -u root -p YOUR_DB_NAME "/PATH/TO/FILE/refs.txt" | |||||
Note that if you're going to use the mysqlimport data import program the | |||||
data file *must* be named 'refs.txt'. | |||||
See also: | |||||
<http://import.refbase.net> | |||||
Skins | |||||
----- | |||||
refbase ships with alternative skins to change the appearance of the program. | |||||
These are in the 'contrib/skins' directory. You can replace your | |||||
'includes/header.inc.php', 'includes/footer.inc.php' with these. You may also | |||||
need to copy files to the 'css' directory. | |||||
Please contribute other skins to <info@refbase.net>. | |||||
Extensions for other software | |||||
----------------------------- | |||||
In 'contribs/mediawiki', there is an extension for MediaWiki to more easily | |||||
include reference information from refbase in a wiki page. This will also | |||||
allow you to use Wikipedia's citation templates, which may have an appearance | |||||
that you like or might be easier for you (and the other users of your wiki) to | |||||
customize. | |||||
@ -0,0 +1,795 @@ | |||||
This file presents a summary of the main fixes and enhancements. | |||||
See the 'ChangeLog' or the commit messages on SourceForge for a detailed | |||||
history: | |||||
<http://refbase.svn.sourceforge.net/viewvc/refbase/> | |||||
Following sites list the refbase commit messages in chronological order | |||||
(allowing you to follow the refbase development progress): | |||||
<http://cia.vc/stats/project/refbase/> | |||||
<https://www.ohloh.net/projects/refbase/commits> | |||||
refbase-0.9.7 | |||||
------------- | |||||
[DATE] | |||||
Changes | |||||
--------- | |||||
Security: | |||||
- Prevent refbase use when 'install.php' or 'update.php' are still present (a good practice anyway, but it works around CVE-2015-6008, CVE-2015-7381, CVW-2015-7382, and CVE-2015-7383 until we replace install.php with something better) | |||||
- Verify that referer is on the same site (fixes CVE-2015-6012 and partially addresses CVE-2015-6007) | |||||
- Prevent HTML injection attacks in more user-editable fields (fixes CVE-2008-6400 and CVE-2015-6010) | |||||
- Whitelist for XSL files (fixes CVE-2015-6011) | |||||
General: | |||||
- PHP7 compatibility | |||||
- Revise SQL files to meet new requirements of MySQL | |||||
- Allow logged-in users to search locations | |||||
- Increase default # of responses from 5 to 10 | |||||
Miscellaneous: | |||||
- A lot of improvements to the MediaWiki plugin, including support for localization, HTTP AUTH, and MySQL/PDO | |||||
Bug fixes | |||||
----------- | |||||
- Fixed localization of type field in list view | |||||
refbase-0.9.6 | |||||
------------- | |||||
[28-FEB-2013] | |||||
Feature additions | |||||
------------------- | |||||
Interface: | |||||
- Support for clickable links in cite_html | |||||
Localization: | |||||
- Localized user login | |||||
- Localized duplicate manager | |||||
- Localized query manager | |||||
- Added Russian localization | |||||
- Added Japanese localization | |||||
Changes | |||||
--------- | |||||
Security: | |||||
- Restrictions for non-admin users of search.php to prevent SQL injection | |||||
- quote_smart in query_modify.php | |||||
General: | |||||
- Removed functions deprecated in PHP 5.3.0 | |||||
- Add parameter 'approved' to show.php | |||||
- Unify styling of show.php | |||||
- Re-arrange user detail fields by importance | |||||
Import: | |||||
- RIS import changes to follow the current spec | |||||
- File imports are improved by removing a BOM, if present | |||||
- Import of Endnote tagged files without requiring bibutils | |||||
- PubMed is now preferred over CrossRef for importing DOIs | |||||
- Improvements to CrossRef imports | |||||
- Improved import of references exported by refbase | |||||
- Minor improvements for RefWorks, Medline, and other formats | |||||
Export: | |||||
- COinS are now encoded as UTF-8, regardless of database encoding | |||||
- Change MODS export of theses to use the marcgt genre authority | |||||
Bug fixes | |||||
----------- | |||||
- Fixed encoding special characters in MODS exporter | |||||
- CSS positioning fo quickSearch | |||||
- Fixed import of RIS tag "CP" | |||||
- Fixed file uploads to subdirectories that don't exist | |||||
- Timezone fixes in PHP 5.1 and above | |||||
refbase-0.9.5 | |||||
------------- | |||||
[19-Nov-2008] | |||||
Feature additions | |||||
------------------- | |||||
Import/Add Records: | |||||
- New resource types: Abstract, Conference Article, Conference Volume, Magazine | |||||
Article, Manual, Miscellaneous, Newspaper Article, Patent, Report, Software | |||||
- Import from Endnote XML and SciFinder | |||||
- Direct import from arXiv IDs, DOIs and OpenURLs | |||||
- Direct upload of references from Bookends <http://www.sonnysoftware.com> | |||||
Search/Display: | |||||
- Improved interface: | |||||
- Redesigned main page, page footer/header & forms on results pages | |||||
- Quick Search form now always available in the page header | |||||
- Search suggestions for text entered by the user | |||||
- Forms on results pages can be hidden | |||||
- Search results can be browsed & searched in three different views: | |||||
List view, Citations, Details | |||||
- Additional record info (keywords, abstract, etc) and links to cite | |||||
or export the record can be displayed underneath each citation | |||||
- OpenSearch support (which e.g. enables Firefox & IE users to search refbase | |||||
directly from their browser's toolbar) | |||||
- Initial support for searching & managing of duplicate records | |||||
- New query history with links to any previous search results | |||||
- New customizable "main fields" search option that allows to search across | |||||
multiple fields at once | |||||
- New option to customize the default number of records per page | |||||
- Results can be dynamically included in foreign web pages | |||||
Export/Citation: | |||||
- New export formats: ADS, Atom XML, ISI Web of Science, OAI_DC XML, SRW_DC XML, | |||||
Word XML | |||||
- New citation styles: AMA, APA, Chicago, Harvard (3 variants), MLA, Vancouver | |||||
- Output of citations in LaTeX bibliography (.bbl) format | |||||
- Cite, group or export ALL found records (instead of just the selected ones) | |||||
- For PDF output, US letter is now supported as page format | |||||
- The 'headerMsg' URL parameter adds a header to any of the citation formats | |||||
- Upon export, links to corresponding files are now included if the export | |||||
format and user permissions allow so | |||||
Localization: | |||||
- Added chinese localization | |||||
Command Line Clients: | |||||
- Added support for all new export formats | |||||
- Added new options that allow to append found records to a local BibTeX or | |||||
MODS/SRW XML file (if they don't yet exist in that file), and update existing | |||||
records in that file if their modification date on the server is more recent | |||||
- Added new option to extract citation IDs from a file and retrieve matching | |||||
records from refbase (supported file types: .aux, .bbl, .bib, .enw, .ris, | |||||
.tex, (MODS|SRW|Endnote) .xml) | |||||
Miscellaneous: | |||||
- Added a refbase extension for MediaWiki which allows to place a serial number | |||||
within <refbase>...</refbase>' markup tags; metadata for the reference is | |||||
retrieved from refbase and marked-up according to a MediaWiki citation template | |||||
- Added support for the sitemaps.org protocol which allows for better indexing | |||||
by search engines | |||||
- Added unAPI support for the new export formats 'atom', 'oai_dc' and 'srw_dc' | |||||
Changes | |||||
--------- | |||||
Security: | |||||
- Introduced measures to better prevent cross-site scripting (XSS) attacks | |||||
- For security reasons, HTML tags are now stripped from the 'headerMsg' URL | |||||
parameter; string formatting can now be done using the refbase markup syntax | |||||
Installation/Update: | |||||
- Improved support for PHP installations running with 'safe_mode=On' | |||||
Import/Add Records: | |||||
- The 'edition' field now accepts string values | |||||
- After any add/edit/delete action, refbase now includes a link to the last | |||||
multi-record search results list in the feedback message if the previous query | |||||
resulted in a single record; Along with other changes, this obviates | |||||
'receipt.php' | |||||
- When importing multiple records, ALL records are now imported by default | |||||
- Improved UTF-8 handling on import so that e.g. a best-effort conversion is | |||||
done for UTF-8 data which are imported into a latin1-based database | |||||
- When importing (or exporting) RIS records, the type of thesis (such as | |||||
"Masters thesis" or "Ph.D. thesis") is now taken from (or exported to) the | |||||
'U1' field (as is supported by Bibutils v3.35 or greater) | |||||
- Upon import, if the given URL actually is a DOI prefixed with | |||||
<http://dx.doi.org/>, we'll extract the DOI and move it to the 'doi' field | |||||
- Improved recognition of PubMed resource types | |||||
Search/Display: | |||||
- refbase now remembers many more search & display options while navigating or | |||||
refining the results list | |||||
- Changed the HTTP transfer method in most forms from POST to GET; this helps to | |||||
avoid warnings about re-sending POST data in some browsers (such as Firefox) | |||||
- When linking to particular records via 'show.php', one can now use consecutive | |||||
serial number ranges as values of the 'records' URL parameter; examples: | |||||
<show.php?records=123-131> or <show.php?records=123-141,145,147,150-152> | |||||
- One can now specify 'creation-date' as value for the 'citeOrder' parameter in | |||||
'show.php' URLs (or the '--order' option of the 'refbase' CLI); this allows to | |||||
sort records such that newly added/edited records get listed top of the list | |||||
- One can now specify 'Mobile' as value for the 'viewType' URL parameter (or the | |||||
'--view' option of the 'refbase' CLI); this will return results in simple HTML | |||||
suitable for mobile devices or any postprocessing | |||||
- Refined layout of 'user_receipt.php' | |||||
- Added many CSS attributes (id/class names) to HTML output where appropriate; | |||||
this allows to easier refine the CSS styling of the refbase interface | |||||
Export/Citation: | |||||
- By default, export via the refbase GUI is now enabled for anonymous users | |||||
- By default, the SRU formats SRW_DC XML and SRW_MODS XML are now transformed to | |||||
HTML via XSL stylesheets | |||||
- MODS XML exports include file links that Zotero is able to download | |||||
- Renamed the Bibutils 'xml2word' command line tool to 'xml2wordbib' according | |||||
to the name changes in Bibutils v3.40; note that if you're using a Bibutils | |||||
version prior to Bibutils v3.40, you must revert this change in file | |||||
'export/bibutils/export_xml2word.php' | |||||
- The citation output options (previously located in the results footer) have | |||||
been moved to the Display Options form of the results header in Citation view | |||||
Admin settings: | |||||
- The admin can now define any of the supported views (List view, Citations, | |||||
Details) as the default view | |||||
- For each view, the admin can now define whether the results header & footer | |||||
should be displayed open or closed by default, or whether they should be | |||||
entirely hidden from the interface | |||||
- The admin can now customize the list of fields that are displayed by default | |||||
in List & Details view; similarly, the list of fields that are available in | |||||
dropdown menus of the results header can also be customized | |||||
- The admin can now define 'accesskey' values which allow for keyboard | |||||
navigation of the main parts of the refbase interface | |||||
- The '$databaseBaseURL' in 'ini.inc.php' is now auto-generated by default | |||||
- The refbase logo image files have been updated to the new refbase logo, and | |||||
the logo URL path & dimensions can now be customized easily via 'ini.inc.php' | |||||
- The session/temp dir path can now be specified explicitly in 'ini.inc.php'; | |||||
this allows you to define a custom directory path that's used on your server | |||||
to save session data and to write any temporary files | |||||
Localization: | |||||
- Improved internationalization and added many additional localization strings | |||||
- Changed or merged some localization strings to allow for better translations | |||||
to languages such as Spanish or Chinese | |||||
Miscellaneous: | |||||
- Underline fontshape markup is now supported in various import and citation | |||||
formats as well as in refbase markup (use: '__underlined text__') | |||||
- For the "Extract citations" functionality, refbase now checks whether the | |||||
extracted serial numbers and cite keys exist in the database and report any | |||||
missing record identifiers | |||||
Bug fixes | |||||
----------- | |||||
- Fixed bug that prevented correct directory creation/renaming and/or file | |||||
upload on some platforms | |||||
- Fixed 'preg_match()' compilation errors when importing BibTeX records into a | |||||
refbase UTF-8 database | |||||
- Worked around an error in Internet Explorer when importing single records via | |||||
the web interface | |||||
- When importing PubMed MEDLINE source data, refbase now extracts author | |||||
information from the 'AU' field if the 'FAU' field is not available | |||||
- refbase now converts Endnote XML text style markup into appropriate refbase | |||||
markup | |||||
- Upon RIS import, refbase now makes sure that HTML encoded source data (such as | |||||
'ä', 'ö' or 'é') get decoded before import | |||||
- Fixed an issue were it wasn't possible to correctly import (or cite) records | |||||
which contained non-ASCII characters in author's given names | |||||
- Records of unrecognized resource type were omitted upon citation output; fixed | |||||
- When outputting to LaTeX or RIS, curly brackets are now escaped to avoid | |||||
incorrect output | |||||
- Fixed an error when exporting data to ODF XML and when the user-specific | |||||
fields were missing from the SQL query | |||||
refbase-0.9.0 | |||||
------------- | |||||
[27-Oct-2006] | |||||
Feature additions | |||||
------------------- | |||||
Installation/Update: | |||||
- Searches path and common locations for supporting binaries | |||||
<http://install.refbase.net> | |||||
Import/Add Records: | |||||
- Import from Endnote, Reference Manager (RIS), RefWorks, BibTeX, MODS XML, | |||||
ISI Web of Science, PubMed (MEDLINE or XML), Cambridge Scientific Abstracts | |||||
and COPAC (with automatic detection of bibliographic format) | |||||
<http://import.refbase.net> | |||||
- Import of multiple records | |||||
- Import from a file or from PubMed ID | |||||
- Automatic file renaming and creation of subdirectories via placeholders | |||||
<http://placeholders.refbase.net> | |||||
- Command line client to batch import records <http://cli.refbase.net> | |||||
Search/Display: | |||||
- Improved query API with short, permanent links to records | |||||
<http://linking.refbase.net> | |||||
- SRU/W (Search & Retrieve via URL) web service <http://sru.refbase.net> | |||||
- OpenURL support <http://openurl.refbase.net> | |||||
- Embedding of COinS metadata within HTML pages <http://coins.refbase.net> | |||||
- UnAPI support <http://unapi.refbase.net> | |||||
- Command line client to search & retrieve records <http://cli.refbase.net> | |||||
- "Show All" link | |||||
- Links that display all records which were added/edited since a user's last | |||||
login | |||||
- "is within range" and "is within list" searching of numeric fields | |||||
- French localization | |||||
Export/Citation: | |||||
- ODF XML export for use with OpenOffice.org <http://openoffice.refbase.net> | |||||
- Formatted citation export (RTF, PDF, LaTeX, Markdown, ASCII) | |||||
- Automatic generation of user-specific cite keys and text citations | |||||
- Sort by resource type (i.e., peer-reviewed publications, monographs, book | |||||
contributions, theses, etc) when outputting citations | |||||
- Better transliteration between character sets | |||||
Changes | |||||
--------- | |||||
- Masking of fields which may contain e-mail addresses to prevent spam | |||||
- The number of records that are returned by default can now be customized | |||||
- Improved localization support | |||||
- Better quoting of MySQL queries (user-inputted data can contain slashes and | |||||
quotation marks) | |||||
- refbase will now work independent of the 'magic_quotes_gpc' setting in your | |||||
PHP configuration file 'php.ini'. | |||||
- Improvements in session management | |||||
- Search queries may be submitted via GET rather than POST | |||||
- The admin can now control which links shall be displayed in List view and | |||||
Citation view | |||||
Bug fixes | |||||
----------- | |||||
- Improvements in protection against disallowed searches | |||||
- Fixes to MODS XML export | |||||
- Short opening tags have been replaced with '<?php' for compatibility | |||||
- The user-specific language setting is now honoured correctly | |||||
- The contents of the 'file' field will now only be revealed if the user has | |||||
permission to view/download files | |||||
- refbase now issues a correct error message if the size of the uploaded file | |||||
exceeds 'post_max_size' | |||||
refbase-0.8.0 | |||||
------------- | |||||
[05-Apr-2005] | |||||
Feature additions | |||||
------------------- | |||||
Installation: | |||||
- New 'update.php' script and 'update.sql' to update refbase-0.7 to 0.8.0. | |||||
- 'install.php' and 'update.php' both work on Windows servers. | |||||
Export/citation: | |||||
- Export to MODS XML: refbase can output records in MODS format, a bibliographic | |||||
XML standard developed by the Library of Congress: | |||||
<http://www.loc.gov/standards/mods/> | |||||
- Export to Endnote/Bibtex/RIS: refbase supports export of records to common | |||||
bibliographic formats by use of bibutils: | |||||
<http://www.scripps.edu/~cdputnam/software/bibutils/> | |||||
- User-specific cite keys: The new user-specific field "Cite Key" allows users | |||||
to specify a custom identifier for each record. Cite keys will be supported | |||||
in export formats (MODS XML & Bibtex) and text citations as well as when | |||||
generating reference lists. | |||||
Adding/editing/deleting of records: | |||||
- Unicode support: You can now set the default character set to 'utf8' (Unicode) | |||||
when installing refbase on MySQL 4.1.x or greater. This provides support for | |||||
double-byte languages. | |||||
- RSS support: Users can now track queries using RSS, i.e. users are able to | |||||
convert any query into a dynamic RSS feed and subscribe to it using their | |||||
favorite news aggregator. The feed will display all newly added records | |||||
matching the users query. | |||||
- Print view: Added a print-friendly view which eases printing or copying of | |||||
records. | |||||
- Includes an Endnote style file and PHP script to ease the manual batch import | |||||
of bibliographic records. | |||||
- Started localization: Provided core structure to support web interfaces in | |||||
different languages. Note that the localization feature isn't finished nor | |||||
enabled yet and will be available in a future release. | |||||
Admin features: | |||||
- User-specific permissions: The admin can now assign access rights individually | |||||
for each user. Permission settings are provided for basic actions like | |||||
add/edit/delete records or file upload/download as well as other features like | |||||
import, export or cite. | |||||
- Reference types, citation styles and export formats can be enabled/disabled by | |||||
the admin for each user individually. The user, in turn, can choose which of | |||||
the enabled types/styles/formats shall be visible. | |||||
- User- and criteria-specific file downloads: Download links can be made | |||||
available to either everyone, logged-in users only or on a user-specific | |||||
basis. In addition, you can optionally specify a condition where files will | |||||
be always made visible. | |||||
- The admin interface now allows to group particular database users. | |||||
User customization: | |||||
- User-specific groups: Users can now add records to user-specific groups. A | |||||
drop-down menu on the main page (or any search results list) provides quick | |||||
access to all records belonging to a particular group. | |||||
- Saved queries: It is now possible to permanently save any search query | |||||
together with the current display settings. Saved queries can be easily | |||||
recalled or edited from the main page. | |||||
- Link records: A new user-specific field ("Related") enables users to link | |||||
records to other records in the database. Links can be either static (by | |||||
explicitly linking to particular record serials) or dynamic (by entering | |||||
queries like "author:lee; title:ecosystem"). | |||||
Changes | |||||
--------- | |||||
- The MySQL database used by refbase has undergone some significant changes. | |||||
Please use the 'update.php' script to update any old refbase MySQL database. | |||||
- refbase will now work independent of the 'register_globals' setting in your | |||||
PHP configuration file 'php.ini'. | |||||
- Links to particular pages/features will be only made visible if the user has | |||||
appropriate access rights. | |||||
- Re-designed the "Search within Results" form. | |||||
- Users can now choose on every search results page which fields and how many | |||||
records shall be displayed. | |||||
- Logged-in users can now use user-specific cite keys (instead of serial | |||||
numbers) as record identifiers when generating a reference list using | |||||
'extract.php'. | |||||
- Citation style and export format definitions now reside in individual files | |||||
(within the 'cite/' and 'export/' sub-directories, respectively) and are | |||||
managed via MySQL tables. This enables users to develop custom styles and/or | |||||
formats. | |||||
- Added support for fields 'keywords', 'notes', 'marked' and 'language' within | |||||
the admin interface. | |||||
- Custom CSS style sheets can be specified within 'ini.inc.php' to change the | |||||
visual appearance of the served web pages. | |||||
- You can now define (in 'initialize/ini.inc.php') what will be searched by | |||||
script 'library_search.php'. | |||||
- Added variables to the database configuration file ('initialize/db.inc.php') | |||||
which allow to use custom names for the refbase MySQL tables. | |||||
- Renamed the v0.7 'Export' feature to 'Cite' to better reflect its purpose and | |||||
to make room for the new export capabilities. | |||||
- Include files and configuration files were moved to separate sub-directories. | |||||
- refbase now tries harder to prevent a malicious user from hacking the database | |||||
by use of a custom SQL query. | |||||
- A lot of internal code re-structuring. | |||||
Bug fixes | |||||
----------- | |||||
- When adding records, entered values will be reloaded correctly if an error | |||||
occurs. | |||||
refbase-0.7 | |||||
----------- | |||||
[11-Jan-2004] | |||||
Feature additions | |||||
------------------- | |||||
Installation: | |||||
- Provided a web interface ('install.php') as well as a MySQL dump file for | |||||
installation. This should make it a lot easier to setup the database. Besides | |||||
the database structure, the MySQL dump file includes a temporary admin user | |||||
and twelve sample records. | |||||
User customization: | |||||
- The database now offers six user-specific fields. These fields are stored | |||||
individually for each user within a separate table. You can use these fields | |||||
to store personal information for a particular record (for example your | |||||
personal keywords or notes). These fields are only provided to logged-in users | |||||
and can't be viewed by other users. | |||||
- After login, a 'Show My Refs' form will allow you to easily display all of | |||||
your own literature. This form also offers a quick way of searching your own | |||||
literature by your personal fields (such as your personal keywords or notes). | |||||
Display features: | |||||
- Provided display support for rich text (like italics, super-/subscript or | |||||
greek symbols) within the title, keywords and abstract fields by use of a | |||||
configurable, extensible and human readable markup syntax. | |||||
- A direct download link to any file that's associated with a particular | |||||
record will be shown to logged in users. | |||||
- By default, exported records will now feature a 'show details' link to the | |||||
right. | |||||
- Export output can now optionally list records in blocks sorted by year. | |||||
- Provided support for custom header messages within database queries: by | |||||
including the 'headerMsg' parameter within query URLs it is now possible to | |||||
include any information string within a link. As an example, a query URL | |||||
pointing to articles written by a particular author can now include the | |||||
appropriate author information (e.g. "Articles by Matthias Steffens:") which | |||||
will show up as a header message on every results page. | |||||
User management: | |||||
- 'Search within Results' functionality now also works when managing users. | |||||
- It is now possible to delete any non-admin user via the user management | |||||
interface. | |||||
- Two new fields will store information about the date & time of the last login | |||||
as well as the total number of logins for a particular user. | |||||
Admin features: | |||||
- The admin user is allowed to execute custom SQL statements other than SELECT | |||||
queries (according to his GRANT privileges). This will enable him to make | |||||
batch changes to the database. | |||||
Adding/editing/deleting of records: | |||||
- Added record announcement capabilities: If a new record has been added to the | |||||
database a short email announcement can be sent to a mailing list email | |||||
address. | |||||
- Provided some magic that figures out what do to depending on the state of the | |||||
new 'is Editor' check box and the content of the 'author', 'editor' and 'type' | |||||
fields. | |||||
- Introduced a new field 'thesis' which enables you to specify the type of | |||||
degree ("Bachelor's thesis", "Master's thesis", "Ph.D. thesis", "Diploma | |||||
thesis", "Doctoral thesis" or "Habilitation thesis") that was achieved by a | |||||
publication. | |||||
- Provided support for online publications by the introduction of two new | |||||
database fields: 'online_publication' & 'online_citation'. If the field | |||||
'online_publication' is set to 'yes' by marking the appropriate checkbox, the | |||||
export view will display the doi number as well as any string that was entered | |||||
into the 'online_citation' field. | |||||
- Introduced a new field 'contribution_id'. By marking the appropriate checkbox | |||||
within the 'record' form your institutional abbreviation will be added to the | |||||
contents of the 'contribution_id' field. This serves as an easy method to tag | |||||
all those records that were published by your own institution. | |||||
- 'record.php' now enables you to upload a file that's associated with a | |||||
particular record entry. If the root directory where your files will be stored | |||||
(specified in 'ini.inc.php') contains a sub-directory whose name matches the | |||||
string provided within the 'abbrev_journal' field (after converting the string | |||||
to lowercase and stripping all characters but ascii letters) the uploaded file | |||||
will be placed inside that sub-directory. As an example, if you've created a | |||||
sub-directory named 'polarbiol' within your files root directory, any uploaded | |||||
file will be copied to that sub-directory if its accompanying record contains | |||||
the string 'Polar Biol.' within its 'abbrev_journal' field. | |||||
- Depending on the value of the 'locationSelector' drop-down, the user's name | |||||
and email address will be added/removed from the 'location' field | |||||
automatically. | |||||
Changes | |||||
--------- | |||||
- The format of the MySQL tables has changed (added & renamed some fields and | |||||
changed some field types). You'll need to update your table definitions in | |||||
order to use this version! See the online documentation for further help: | |||||
<http://sourceforge.net/docman/?group_id=64647> | |||||
- File 'db.inc': Removed 'root' as default value for '$username' (the use of a | |||||
separate mysql user with more restrictive permissions is highly recommended). | |||||
- Non-admin users will be only shown their own call number information. This is | |||||
done to ease data entry and to prevent non-admin users from messing with other | |||||
user's call number information. The data entered by the user will be | |||||
automatically completed with the user's correct call number prefix. | |||||
- Instead of deleting data, deleted records will now be moved to the 'deleted' | |||||
table. Data will be stored within the 'deleted' table until they are removed | |||||
manually. This is to provide the admin with a simple recovery method in case | |||||
a user did delete some data by accident. | |||||
Bug fixes | |||||
----------- | |||||
- Fixed a (potentially disastrous) security hole where non-admin users were | |||||
allowed to execute custom queries other than SELECT queries. | |||||
- When adding/updating a record the fields 'created_date', 'created_time', | |||||
'created_by', 'modified_date', 'modified_time', 'modified_by' will be set | |||||
correctly now. | |||||
- Similarly, when adding/updating a record, the calculation fields | |||||
'first_author', 'author_count' and 'first_page' will be setup correctly now. | |||||
- Modifying the SQL query of a particular search result now also works properly | |||||
for details and export view. | |||||
The following known issues have been fixed: | |||||
- If you clicked on login/logout within the first of any query results pages | |||||
before clicking somewhere else, you did get an 'Error 1065: Query was empty'. | |||||
- Export as 'Text Citation' didn't work properly on records that were added via | |||||
the web interface. | |||||
refbase-0.6.1b1 | |||||
--------------- | |||||
[30-Jun-2003] | |||||
- Fixes a bug which made it impossible to setup the first user of the database. | |||||
- A user management interface is provided to admins. | |||||
- Users can now change their password later on. | |||||
- Variable settings from 'ini.inc.php' are now honoured correctly. | |||||
- Provided a search form that shows up on the main page after successful login | |||||
which will allow a user to easily search his *own* literature only. |
@ -0,0 +1,98 @@ | |||||
refbase 0.9.7 README | |||||
==================== | |||||
About refbase | |||||
------------- | |||||
refbase is a web-based solution for managing scientific literature, | |||||
references and citations. | |||||
Currently, the following features have been implemented for: | |||||
EVERYONE | |||||
- search the database using different search forms | |||||
- search within results | |||||
- browse found records and sort results by any database field | |||||
- view results in different views (list view, citations, details, | |||||
print view) | |||||
- display results in different citation styles & output formats | |||||
- export selected records to XML (Atom, MODS, OAI_DC, ODF) and (via | |||||
the GPLed Bibutils programs) to ADS, BibTeX, EndNote, ISI, RIS and | |||||
Word XML | |||||
- display rich text (i.e., italics, super/sub-script, greek letters) | |||||
- extract citations from a text & build an appropriate reference list | |||||
- track additions via RSS and generate custom RSS feeds from searches | |||||
- web services (SRU & OpenSearch) that allow clients to access a | |||||
refbase database using a standard query syntax and retrieve results | |||||
in structured XML format | |||||
- dissemination of bibliographic data via standard methods (COinS & | |||||
unAPI) allowing clients to automatically discover and extract data | |||||
from refbase | |||||
- search a refbase online database from the command line and retrieve | |||||
results in various export & citation formats | |||||
LOGGED IN USERS | |||||
- user-specific fields which are stored individually for each user | |||||
- import of records from common bibliographic formats and online | |||||
databases via the web interface or the command line | |||||
- automatic email announcements for newly added records | |||||
- save and recall search queries | |||||
- adding records to user-specific groups | |||||
- add/edit/delete records as well as file upload & download links | |||||
ADMINISTRATOR | |||||
- user management interface provided to the database admin | |||||
- set access permissions on a per-user basis | |||||
More information is given at: | |||||
<http://features.refbase.net> | |||||
Credits | |||||
------- | |||||
See AUTHORS | |||||
Requirements | |||||
------------ | |||||
refbase requires: | |||||
- a web server (like the Apache HTTP Server <http://httpd.apache.org/>) | |||||
- PHP <http://www.php.net/> (version 5.2.0 or greater) with enabled | |||||
session support & installed PHP MySQL module | |||||
- MySQL <http://www.mysql.com/> (version 4.1.x or greater required for | |||||
Unicode support) | |||||
- for import and export of various formats (e.g., Endnote & BibTeX): | |||||
Bibutils <http://www.refbase.net/index.php/Bibutils> | |||||
(version 3.21 or greater) | |||||
More detailed information is available at: | |||||
<http://requirements.refbase.net> | |||||
Installation & Import | |||||
--------------------- | |||||
See INSTALL | |||||
Update | |||||
------ | |||||
See UPDATE | |||||
New Features | |||||
------------ | |||||
See NEWS | |||||
Changelog | |||||
--------- | |||||
See ChangeLog | |||||
Known issues | |||||
------------ | |||||
See BUGS | |||||
What is missing? | |||||
---------------- | |||||
See TODO | |||||
License | |||||
------- | |||||
See COPYING | |||||
Further information | |||||
------------------- | |||||
For more information about the refbase project and pointers to working | |||||
examples of refbase please visit: | |||||
<http://www.refbase.net/> or <http://refbase.sourceforge.net/> |
@ -0,0 +1,98 @@ | |||||
Suggestions for improving refbase: | |||||
- Open up the refbase group (aka tagging) mechanism so that groups can be made | |||||
public, group-specific or private. | |||||
- Improved search capabilities which, e.g., allow for 'OR' searches and/or a | |||||
Google-like search syntax. One possible solution might be to offer support for | |||||
the Contextual Query Language (CQL) across the entire interface. More flexible | |||||
handling of accented characters and umlauts would be also desirable. | |||||
- Offer means to auto-detect duplicates on import, link duplicate entries with | |||||
their original ones and allow users to migrate their user-specific data from a | |||||
duplicate record to the original. It would be also nice if duplicate records | |||||
could be hidden from the interface. | |||||
- Improve the installation process so that the web-based installer works with | |||||
more server setups (including installation on shared hosts), and allows | |||||
setting important config options via the web interface. | |||||
- More user-specific and record-specific rights management. | |||||
- Provide additional citation styles, preferably via the use of a plugin | |||||
mechanism which would make it easy to add or edit citation styles. Support for | |||||
the Citation Style Language (CSL) would be desirable. | |||||
- Increase number of supported resource types and allow users to add their own | |||||
types. A hierarchical system with basic fallback types would be desirable. | |||||
- Provide a machine-readable interface (API) that not only allows clients to | |||||
query a refbase database and retrieve results in a structured format, but that | |||||
also allows modification of any database information. | |||||
- Provide better integration with desktop reference managers so that users could | |||||
search an online refbase database from within their desktop application, or | |||||
upload (and eventually synch) records to a refbase server directly from within | |||||
their desktop application. | |||||
- Upon add/edit, offer to auto-fill empty fields based on information available | |||||
in other fields/records/tables or via web services. Eventually, such a system | |||||
could also be used to validate data that were entered/imported by the user. | |||||
- Simplify manual data input by providing record type specific forms. These | |||||
forms could guide a user by only showing (or at least indicating) those fields | |||||
that are required for a particular record type (like journal articles, book | |||||
chapters or whole books). | |||||
- Allow users to upload multiple files per record. | |||||
- Allow users to specify multiple URLs for the same record, and eventually | |||||
provide a customizable system for auto-generation of links (based on the | |||||
record's metadata). | |||||
- Store record identifiers from foreign repositories (e.g. arXiv.org or | |||||
PubMed.gov) in some dedicated field(s), which would allow to easily | |||||
auto-generate links back to these repositories. | |||||
- Implement the OAI Protocol for Metadata Harvesting which would provide (yet | |||||
another) standard way for software to retrieve information from refbase. | |||||
- More localizations, i.e. translations of the refbase interface into other | |||||
languages. | |||||
- Cross-site searches (both through other copies of refbase and through other | |||||
bibliographic databases). | |||||
- Refactor for more code reuse (share more between cite/list/details views, | |||||
etc.), and eventually modularize the code to allow for other RDBMS, custom | |||||
database schemes and/or a plugin mechanism. | |||||
- Provide better interface customization via a templating/skin mechanism and/or | |||||
improved CSS styling. | |||||
- Allow the admin to add any custom fields and/or alter the layout of available | |||||
fields. | |||||
- More embedding of citation metadata in HTML pages in a machine-readable form | |||||
(such as embedded RDF or microformats) which may be processed by clients. | |||||
- Improved export through both revisions to the current MODS XML/bibutils system | |||||
and through adding more native export options which wouldn't require bibutils. | |||||
- User customization: provide a user-specific preferences page where one could | |||||
specify the default view and the default columns that are visible in query | |||||
results or the default fields that are visible in particular search forms. | |||||
- Easier import of bibliographic data from web sources via bookmarklets and/or | |||||
scrapers. | |||||
- Offer a notes/comment system where multiple notes (of unlimited length) would | |||||
be allowed for a particular record and where notes would be searchable, and | |||||
could be made public, group-specific or private. | |||||
- Enable remembering of marked records across different requests. | |||||
- Provide an administrative interface to deleted records. | |||||
A more detailed list of planned feature additions is given at: | |||||
<http://additions.refbase.net> |
@ -0,0 +1,66 @@ | |||||
Please follow the steps below to update an existing refbase installation to | |||||
refbase-0.9.7. The update script should also be able to update any refbase | |||||
version that was installed from SVN prior to the release of refbase-0.9.7. To | |||||
update versions of refbase prior to refbase-0.8.0, please update to | |||||
refbase-0.8.0 first. | |||||
- First of all, please make sure that you have a recent backup of your refbase | |||||
MySQL database! This can be accomplished by issuing the following command | |||||
from your shell: | |||||
mysqldump DATABASE_NAME -uADMINUSER -p --complete-insert --opt > refbase.sql | |||||
In the above line, replace DATABASE_NAME with the database name that you've | |||||
specified for the variable '$databaseName' (in file | |||||
'initialize/db.inc.php'). Similarly, replace ADMINUSER with the name of the | |||||
administrative user that has full access to the refbase MySQL database. As | |||||
an example, if the variable '$databaseName' is set to "literature" and your | |||||
administrative user is "root", the above line would read: | |||||
mysqldump literature -uroot -p --complete-insert --opt > refbase.sql | |||||
WARNING: If using MySQL 4.1.x, mysqldump's charset conversion may damage | |||||
data. If necessary, use the '--default-character-set=latin1' option | |||||
to avoid the conversion. More info is available at | |||||
<http://backup.refbase.net>. | |||||
- Backup your original configuration files 'initialize/db.inc.php' and | |||||
'initialize/ini.inc.php'. Optionally, you may want to backup all of your | |||||
existing refbase scripts. | |||||
- Move all refbase-0.9.7 files to your server's web directory. | |||||
- Open the file 'initialize/db.inc.php' in a text editor and re-enter the | |||||
values from your old 'db.inc.php' file for the variables '$databaseName', | |||||
'$username' and '$password'. Similarly, migrate all custom values that | |||||
you've entered within the old 'ini.inc.php' file to the new one. | |||||
- Now, open a web browser and access the 'update.php' script by typing: | |||||
<http://SERVER_ADDRESS/PATH_ON_SERVER/update.php> | |||||
(where the string 'SERVER_ADDRESS' is replaced by your server name and | |||||
'PATH_ON_SERVER' is the actual path to your refbase-0.9.5 web directory) | |||||
This should bring up the update form. Edit the contents of all text entry | |||||
fields to match your server setup and supply the MySQL admin password, then | |||||
click the 'Update' button to update the database. | |||||
WIN32: Be sure to set a password for the MySQL root user. | |||||
This will add the MySQL tables that were added in 0.9.x and alter existing | |||||
tables to match the table design used by refbase-0.9.x. A detailed log is | |||||
generated for all performed update actions. Your data should remain | |||||
untouched by this operation. | |||||
- After you've successfully performed the update, please remove the files | |||||
'update.php' & 'update.sql' (as well as 'install.php' & 'install.sql') from | |||||
your web directory. | |||||
- Note: The update process modifies some existing formats in table 'formats' | |||||
and adds additional ones. Please login as admin and make sure that suitable | |||||
import, export and citation formats are enabled for all of your users within | |||||
the "Display Options" section of the admin interface. | |||||
See also: | |||||
<http://update.refbase.net> |
@ -0,0 +1,176 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./cite/formats/cite_ascii.php | |||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/cite/formats/cite_ascii.php $ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 10-Jun-06, 02:54 | |||||
// Modified: $Date: 2017-04-13 02:00:18 +0000 (Thu, 13 Apr 2017) $ | |||||
// $Author: karnesky $ | |||||
// $Revision: 1416 $ | |||||
// This is a citation format file (which must reside within the 'cite/formats/' sub-directory of your refbase root directory). It contains a | |||||
// version of the 'citeRecords()' function that outputs a reference list from selected records in plain text format. Plain text output is | |||||
// mainly meant for command line interfaces such as the refbase command line client (<http://cli.refbase.net/>). | |||||
// -------------------------------------------------------------------- | |||||
// --- BEGIN CITATION FORMAT --- | |||||
function citeRecords($result, $rowsFound, $query, $queryURL, $showQuery, $showLinks, $rowOffset, $showRows, $previousOffset, $nextOffset, $wrapResults, $citeStyle, $citeOrder, $citeType, $orderBy, $headerMsg, $userID, $viewType) | |||||
{ | |||||
global $officialDatabaseName; // these variables are defined in 'ini.inc.php' | |||||
global $databaseBaseURL; | |||||
global $contentTypeCharset; | |||||
global $client; | |||||
// The array '$transtab_refbase_ascii' contains search & replace patterns for conversion from refbase markup to plain text | |||||
global $transtab_refbase_ascii; // defined in 'transtab_refbase_ascii.inc.php' | |||||
$plainTextData = ""; // make sure that our buffer variable is empty | |||||
// Header: | |||||
if (!empty($headerMsg)) | |||||
{ | |||||
// Decode any HTML entities: | |||||
// (these may occur in the header message e.g. if the user's preferred display language is not English but German or French, etc) | |||||
$headerMsg = decodeHTML($contentTypeCharset, $headerMsg); // function 'decodeHTML()' is defined in 'include.inc.php', and '$contentTypeCharset' is defined in 'ini.inc.php' | |||||
// Convert refbase markup in the header message into plain text: | |||||
$headerMsg = searchReplaceText($transtab_refbase_ascii, $headerMsg, true); // function 'searchReplaceText()' is defined in 'include.inc.php' | |||||
$plainTextData .= "$headerMsg\n\n"; // prefix any passed header message | |||||
} | |||||
// Initialize array variables: | |||||
$yearsArray = array(); | |||||
$typeTitlesArray = array(); | |||||
// Define inline text markup to be used by the 'citeRecord()' function: | |||||
$markupPatternsArray = array("bold-prefix" => "", // for plain text output, we'll omit any font-shape markup | |||||
"bold-suffix" => "", | |||||
"italic-prefix" => "", | |||||
"italic-suffix" => "", | |||||
"underline-prefix" => "", | |||||
"underline-suffix" => "", | |||||
"endash" => "-", | |||||
"emdash" => "-", | |||||
"ampersand" => "&", | |||||
"double-quote" => '"', | |||||
"double-quote-left" => '"', | |||||
"double-quote-right" => '"', | |||||
"single-quote" => "'", | |||||
"single-quote-left" => "'", | |||||
"single-quote-right" => "'", | |||||
"less-than" => "<", | |||||
"greater-than" => ">", | |||||
"newline" => "\n" | |||||
); | |||||
// Defines search & replace 'actions' that will be applied upon TEXT output to all those refbase fields that are listed | |||||
// in the corresponding 'fields' element: | |||||
$plainTextSearchReplaceActionsArray = array( | |||||
array('fields' => array("title", "publication", "abbrev_journal", "address", "keywords", "abstract", "orig_title", "series_title", "abbrev_series_title", "notes"), | |||||
'actions' => $transtab_refbase_ascii | |||||
) | |||||
); | |||||
// For CLI queries, we'll allow paging thru the result set, i.e. we honour the values of the CLI options '-S|--start' ('$rowOffset') | |||||
// and '-R|--rows' ('$showRows') ('$rowOffset' and '$showRows' are re-assigned in function 'seekInMySQLResultsToOffset()' in 'include.inc.php') | |||||
if (preg_match("/^cli/i", $client)) // if the query originated from a command line client such as the "refbase" CLI client ("cli-refbase-1.0") | |||||
$showMaxRows = $showRows; // show only rows up to the value given in '$showRows' | |||||
else | |||||
$showMaxRows = $rowsFound; // otherwise show all rows | |||||
// LOOP OVER EACH RECORD: | |||||
// Fetch one page of results (or less if on the last page) | |||||
// (i.e., upto the limit specified in $showMaxRows) fetch a row into the $row array and ... | |||||
for ($rowCounter=0; (($rowCounter < $showMaxRows) && ($row = @ mysqli_fetch_array($result))); $rowCounter++) | |||||
{ | |||||
foreach ($row as $rowFieldName => $rowFieldValue) | |||||
// Apply search & replace 'actions' to all fields that are listed in the 'fields' element of the arrays contained in '$plainTextSearchReplaceActionsArray': | |||||
foreach ($plainTextSearchReplaceActionsArray as $fieldActionsArray) | |||||
if (in_array($rowFieldName, $fieldActionsArray['fields'])) | |||||
$row[$rowFieldName] = searchReplaceText($fieldActionsArray['actions'], $row[$rowFieldName], true); // function 'searchReplaceText()' is defined in 'include.inc.php' | |||||
// Order attributes according to the chosen output style & record type: | |||||
$record = citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, false); // function 'citeRecord()' is defined in the citation style file given in '$citeStyleFile' (which, in turn, must reside in the 'cite' directory of the refbase root directory), see function 'generateCitations()' | |||||
// Print out the current record: | |||||
if (!empty($record)) // unless the record buffer is empty... | |||||
{ | |||||
// Print any section heading(s): | |||||
if (preg_match("/year|type/i", $citeOrder)) | |||||
{ | |||||
list($yearsArray, $typeTitlesArray, $sectionHeading) = generateSectionHeading($yearsArray, $typeTitlesArray, $row, $citeOrder, "", "", "", "\n\n", "", "\n\n"); // function 'generateSectionHeading()' is defined in 'cite.inc.php' | |||||
$plainTextData .= $sectionHeading; | |||||
} | |||||
// Write plain TEXT paragraph: | |||||
if (preg_match("/^cli/i", $client)) // when outputting results to a command line client, we'll prefix the record with it's serial number (and it's user-specific cite key, if available) | |||||
{ | |||||
// This is a stupid hack that maps the names of the '$row' array keys to those used | |||||
// by the '$formVars' array (which is required by function 'generateCiteKey()') | |||||
// (eventually, the '$formVars' array should use the MySQL field names as names for its array keys) | |||||
$formVars = buildFormVarsArray($row); // function 'buildFormVarsArray()' is defined in 'include.inc.php' | |||||
// Generate or extract the cite key for this record: | |||||
// NOTE: currently, the following placeholders are not available for citation output: | |||||
// <:keywords:>, <:issn:>, <:area:>, <:notes:>, <:userKeys:> | |||||
// if the cite key specification uses one of these placeholders, it will get ignored | |||||
$citeKey = generateCiteKey($formVars); // function 'generateCiteKey()' is defined in 'include.inc.php' | |||||
$plainTextData .= "[" . $row['serial'] . "] "; | |||||
if (!empty($citeKey)) | |||||
// Use the custom cite key that's been build according to the user's individual export options: | |||||
$plainTextData .= "{" . $citeKey . "} "; | |||||
} | |||||
$plainTextData .= $record . "\n\n"; // create paragraph with encoded record text | |||||
} | |||||
} | |||||
if (preg_match("/^cli/i", $client)) // when outputting results to a command line client, we'll append some info about the number of rows displayed/found, the database name/URL and optionally display the SQL query | |||||
{ | |||||
// Calculate the maximum result number on each page: | |||||
if (($rowOffset + $showRows) < $rowsFound) | |||||
$showMaxRow = ($rowOffset + $showRows); // maximum result number on each page | |||||
else | |||||
$showMaxRow = $rowsFound; // for the last results page, correct the maximum result number if necessary | |||||
if ($rowsFound == 1) | |||||
$footerInfoPart = " record found"; | |||||
else | |||||
$footerInfoPart = " records found"; | |||||
$rowsFoundInfo = ($rowOffset + 1) . "-" . $showMaxRow . " of " . $rowsFound . $footerInfoPart; // prints e.g. "1-5 of 23 records found" | |||||
$rowsFoundDelimiter = preg_replace("/./i", "-", $rowsFoundInfo); // generate a line of hyphens which has the same length as the string in '$rowsFoundInfo' (e.g. "-----------------------") | |||||
$plainTextData .= $rowsFoundDelimiter . "\n" . $rowsFoundInfo . "\n\n"; // append info about rows displayed/found | |||||
$plainTextData .= $officialDatabaseName . "\n" . $databaseBaseURL . "\n\n"; // append database name and URL (comment this line if you don't like that) | |||||
if ($showQuery == "1") // display SQL query: | |||||
$plainTextData .= "Query: " . $query . "\n\n"; | |||||
} | |||||
return $plainTextData; | |||||
} | |||||
// --- END CITATION FORMAT --- | |||||
?> |
@ -0,0 +1,496 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./cite/formats/cite_html.php | |||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/cite/formats/cite_html.php $ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 10-Jun-06, 02:30 | |||||
// Modified: $Date: 2017-04-13 02:00:18 +0000 (Thu, 13 Apr 2017) $ | |||||
// $Author: karnesky $ | |||||
// $Revision: 1416 $ | |||||
// This is a citation format file (which must reside within the 'cite/formats/' sub-directory of your refbase root directory). It contains a | |||||
// version of the 'citeRecords()' function that outputs a reference list from selected records in HTML format. | |||||
// | |||||
// TODO: - use divs + CSS styling (instead of a table-based layout) for _all_ output (not only for 'viewType=Mobile') | |||||
// -------------------------------------------------------------------- | |||||
// --- BEGIN CITATION FORMAT --- | |||||
function citeRecords($result, $rowsFound, $query, $queryURL, $showQuery, $showLinks, $rowOffset, $showRows, $previousOffset, $nextOffset, $wrapResults, $citeStyle, $citeOrder, $citeType, $orderBy, $headerMsg, $userID, $viewType) | |||||
{ | |||||
global $databaseBaseURL; // these variables are defined in 'ini.inc.php' | |||||
global $useVisualEffects; | |||||
global $defaultDropDownFieldsEveryone; | |||||
global $defaultDropDownFieldsLogin; | |||||
global $defaultCiteStyle; | |||||
global $additionalFieldsCitationView; | |||||
global $displayResultsHeaderDefault; | |||||
global $displayResultsFooterDefault; | |||||
global $showLinkTypesInCitationView; | |||||
global $showFieldItemLinks; | |||||
global $maximumBrowseLinks; | |||||
global $loc; // '$loc' is made globally available in 'core.php' | |||||
global $client; | |||||
global $displayType; | |||||
$htmlData = ""; // make sure that our buffer variables are empty | |||||
$recordData = ""; | |||||
// First, initialize some variables that we'll need later on | |||||
// Calculate the number of all visible columns (which is needed as colspan value inside some TD tags) | |||||
if ($showLinks == "1" && preg_match("/^(type|type-year|year)$/i", $citeOrder)) // in citation layout, we simply set it to a fixed value (either '1' or '2', depending on the values of '$showLinks' and '$citeOrder') | |||||
$NoColumns = 2; // first column: literature citation, second column: 'display details' link | |||||
else | |||||
$NoColumns = 1; | |||||
if (empty($displayType)) | |||||
$displayType = $_SESSION['userDefaultView']; // get the default view for the current user | |||||
// If the results footer is displayed, we increase the colspan value by 1 to account for the checkbox column: | |||||
if ((!preg_match("/^(Print|Mobile)$/i", $viewType)) AND (!preg_match("/^cli/i", $client)) AND ($wrapResults != "0") AND (!isset($displayResultsFooterDefault[$displayType]) OR (isset($displayResultsFooterDefault[$displayType]) AND ($displayResultsFooterDefault[$displayType] != "hidden")))) | |||||
$NoColumns++; | |||||
// Initialize array variables: | |||||
$yearsArray = array(); | |||||
$typeTitlesArray = array(); | |||||
// Define inline text markup to be used by the 'citeRecord()' function: | |||||
$markupPatternsArray = array("bold-prefix" => "<b>", | |||||
"bold-suffix" => "</b>", | |||||
"italic-prefix" => "<i>", | |||||
"italic-suffix" => "</i>", | |||||
"underline-prefix" => "<u>", | |||||
"underline-suffix" => "</u>", | |||||
"endash" => "–", | |||||
"emdash" => "—", | |||||
"ampersand" => "&", | |||||
"double-quote" => '"', | |||||
"double-quote-left" => "“", | |||||
"double-quote-right" => "”", | |||||
"single-quote" => "'", | |||||
"single-quote-left" => "‘", | |||||
"single-quote-right" => "’", | |||||
"less-than" => "<", | |||||
"greater-than" => ">", | |||||
"newline" => "\n<br>\n" | |||||
); | |||||
// Defines field-specific search & replace 'actions' that will be applied to the actual citation | |||||
// for all those refbase fields that are listed in the corresponding 'fields' element: | |||||
// (These search and replace actions will be performed *in addition* to those specified globally | |||||
// in '$searchReplaceActionsArray' (defined in 'ini.inc.php'). Same rules apply as for | |||||
// '$searchReplaceActionsArray'.) | |||||
$fieldSpecificSearchReplaceActionsArray = array( | |||||
array( | |||||
'fields' => array("abstract"), | |||||
'actions' => array("/[\r\n]+/" => "\n<br>\n") // for the 'abstract' field, transform runs of newline ('\n') or return ('\r') characters into a single <br> tag | |||||
) | |||||
); | |||||
// In addition, for the "more info" section, we also substitute contents of the below 'fields' | |||||
// with localized field values from variable '$loc'. Since the locales in '$loc' are already | |||||
// HTML encoded, we have to exclude these fields from any further HTML encoding (done below). | |||||
$fieldSpecificSearchReplaceActionsArray2 = $fieldSpecificSearchReplaceActionsArray; | |||||
$fieldSpecificSearchReplaceActionsArray2[] = array( | |||||
'fields' => array("thesis", "approved", "marked", "copy", "selected"), | |||||
'actions' => array("/(.+)/e" => "\$loc['\\1']") // use localized field values (e.g., in case of german we display 'ja' instead of 'yes', etc) | |||||
); | |||||
static $encodingExceptionsArray = array("thesis", "approved", "marked", "copy", "selected"); | |||||
// LOOP OVER EACH RECORD: | |||||
// Fetch one page of results (or less if on the last page) | |||||
// (i.e., upto the limit specified in $showRows) fetch a row into the $row array and ... | |||||
for ($rowCounter=0; (($rowCounter < $showRows) && ($row = @ mysqli_fetch_array($result))); $rowCounter++) | |||||
{ | |||||
$encodedRowData = $row; // we keep '$row' in its original (unencoded) form since unencoded data will be required by function 'linkifyFieldItems()' below | |||||
// NOTES: - Currently, HTML encoding and search & replace actions are applied separately | |||||
// for the citation and the "more info" section underneath the citation. The | |||||
// actions in this 'foreach' block concern the actual citation | |||||
// - It might be better to pass the unencoded '$row' data to function 'citeRecord()' | |||||
// which would then make calls to function 'encodeField()' individually for each | |||||
// field (similar to as it is done it 'modsxml.inc.php') | |||||
foreach ($encodedRowData as $rowFieldName => $rowFieldValue) | |||||
{ | |||||
// NOTES: - We HTML encode non-ASCII chars for all but the author & editor fields. The author & editor | |||||
// fields are excluded here since these fields must be passed *without* HTML entities to the | |||||
// 'reArrangeAuthorContents()' function (which will then handle the HTML encoding by itself) | |||||
// - Function 'encodeField()' will also apply any field-specific search & replace actions | |||||
$encodedRowData[$rowFieldName] = encodeField($rowFieldName, $rowFieldValue, $fieldSpecificSearchReplaceActionsArray, array("author", "editor")); // function 'encodeField()' is defined in 'include.inc.php' | |||||
} | |||||
// Order attributes according to the chosen output style & record type: | |||||
$record = citeRecord($encodedRowData, $citeStyle, $citeType, $markupPatternsArray, true); // function 'citeRecord()' is defined in the citation style file given in '$citeStyleFile' (which, in turn, must reside in the 'cite' directory of the refbase root directory), see function 'generateCitations()' | |||||
// Print out the current record: | |||||
if (!empty($record)) // unless the record buffer is empty... | |||||
{ | |||||
// Print any section heading(s): | |||||
if (preg_match("/year|type/i", $citeOrder)) | |||||
{ | |||||
if (preg_match("/^Mobile$/i", $viewType)) | |||||
{ | |||||
$headingPrefix = "\n<div class=\"sect\">"; | |||||
$headingSuffix = "</div>"; | |||||
} | |||||
else | |||||
{ | |||||
$headingPrefix = "\n<tr>" | |||||
. "\n\t<td valign=\"top\" colspan=\"$NoColumns\">"; | |||||
$headingSuffix = "</td>" | |||||
. "\n</tr>"; | |||||
} | |||||
list($yearsArray, $typeTitlesArray, $sectionHeading) = generateSectionHeading($yearsArray, $typeTitlesArray, $row, $citeOrder, $headingPrefix, $headingSuffix, "<h4>", "</h4>", "<h5>", "</h5>"); // function 'generateSectionHeading()' is defined in 'cite.inc.php' | |||||
$recordData .= $sectionHeading; | |||||
} | |||||
// Print out the record: | |||||
if (is_integer($rowCounter / 2)) // if we currently are at an even number of rows | |||||
$rowClass = "even"; | |||||
else | |||||
$rowClass = "odd"; | |||||
if (preg_match("/^(cli|inc)/i", $client) OR ($wrapResults == "0")) // we use absolute links for CLI clients, for include mechanisms, or when returning only a partial document structure | |||||
$baseURL = $databaseBaseURL; | |||||
else | |||||
$baseURL = ""; | |||||
$recordPermaLink = $databaseBaseURL . "show.php?record=" . $row["serial"]; // generate a permanent link for the current record | |||||
if (preg_match("/^Mobile$/i", $viewType)) | |||||
{ | |||||
$recordData .= "\n<div class=\"" . $rowClass . "\">" | |||||
. "\n\t<div class=\"citation\">" . $record . "</div>"; | |||||
} | |||||
else | |||||
{ | |||||
$recordData .= "\n<tr class=\"" . $rowClass . "\">"; | |||||
// Print a column with a checkbox: | |||||
// Note: we omit the results footer in print/mobile view ('viewType=Print' or 'viewType=Mobile'), for CLI clients, and when outputting only a partial document structure ('wrapResults=0')! | |||||
if ((!preg_match("/^Print$/i", $viewType)) AND (!preg_match("/^cli/i", $client)) AND ($wrapResults != "0") AND (!isset($displayResultsFooterDefault[$displayType]) OR (isset($displayResultsFooterDefault[$displayType]) AND ($displayResultsFooterDefault[$displayType] != "hidden")))) | |||||
{ | |||||
$recordData .= "\n\t<td align=\"center\" valign=\"top\" width=\"10\">"; | |||||
// - Print a checkbox form element: | |||||
if (!isset($displayResultsFooterDefault[$displayType]) OR (isset($displayResultsFooterDefault[$displayType]) AND ($displayResultsFooterDefault[$displayType] != "hidden"))) | |||||
$recordData .= "\n\t\t<input type=\"checkbox\" onclick=\"updateAllRecs();\" name=\"marked[]\" value=\"" . $row["serial"] . "\" title=\"" . $loc["selectRecord"] . "\">"; | |||||
if (!empty($row["orig_record"])) | |||||
{ | |||||
if (!isset($displayResultsFooterDefault[$displayType]) OR (isset($displayResultsFooterDefault[$displayType]) AND ($displayResultsFooterDefault[$displayType] != "hidden"))) | |||||
$recordData .= "\n\t\t<br>"; | |||||
if ($row["orig_record"] < 0) | |||||
$recordData .= "\n\t\t<img src=\"" . $baseURL . "img/ok.gif\" alt=\"(" . $loc["original"] . ")\" title=\"" . $loc["originalRecord"] . "\" width=\"14\" height=\"16\" hspace=\"0\" border=\"0\">"; | |||||
else // $row["orig_record"] > 0 | |||||
$recordData .= "\n\t\t<img src=\"" . $baseURL . "img/caution.gif\" alt=\"(" . $loc["duplicate"] . ")\" title=\"" . $loc["duplicateRecord"] . "\" width=\"5\" height=\"16\" hspace=\"0\" border=\"0\">"; | |||||
} | |||||
// - Add <abbr> block which works as a microformat that allows applications to identify objects on web pages; see <http://unapi.info/specs/> for more info | |||||
$recordData .= "\n\t\t<div class=\"unapi\"><abbr class=\"unapi-id\" title=\"" . $recordPermaLink . "\"></abbr></div>"; | |||||
$recordData .= "\n\t</td>"; | |||||
} | |||||
// Print record data as a citation: | |||||
$recordData .= "\n\t<td id=\"ref" . $row["serial"] . "\" class=\"citation\" valign=\"top\">" | |||||
. "\n\t\t" . $record; | |||||
// Display a triangle widget to show more info (keywords, abstract, etc) under each citation: | |||||
if (!empty($additionalFieldsCitationView)) | |||||
{ | |||||
// Map MySQL field names to localized column names: | |||||
$fieldNamesArray = mapFieldNames(); // function 'mapFieldNames()' is defined in 'include.inc.php' | |||||
if ($useVisualEffects == "yes") | |||||
$toggleVisibilityFunction = "toggleVisibilitySlide"; | |||||
else | |||||
$toggleVisibilityFunction = "toggleVisibility"; | |||||
$recordData .= "\n\t\t<div class=\"showhide\">" | |||||
. "\n\t\t\t<a href=\"javascript:" . $toggleVisibilityFunction . "('moreinfo" . $row["serial"] . "','toggleimg" . $row["serial"] . "','toggletxt" . $row["serial"] . "','more%20info')\" title=\"" . $loc["LinkTitle_ToggleVisibility"] . "\">" | |||||
. "<img id=\"toggleimg" . $row["serial"] . "\" class=\"toggleimg\" src=\"" . $baseURL . "img/closed.gif\" alt=\"" . $loc["LinkTitle_ToggleVisibility"] . "\" width=\"9\" height=\"9\" hspace=\"0\" border=\"0\">" | |||||
. "</a>" | |||||
. "\n\t\t</div>" | |||||
. "\n\t\t<div id=\"moreinfo" . $row["serial"] . "\" class=\"moreinfo\" style=\"display: none;\">"; | |||||
// Print additional fields: | |||||
foreach ($additionalFieldsCitationView as $field) | |||||
{ | |||||
if (isset($row[$field]) AND !empty($row[$field])) | |||||
{ | |||||
$recordData .= "\n\t\t\t<div class=\"" . $field . "\"><strong>" . $fieldNamesArray[$field] . ":</strong> "; | |||||
// Make field items into clickable search links: | |||||
if (in_array($displayType, $showFieldItemLinks)) | |||||
// Note: Function 'linkifyFieldItems()' will also call function 'encodeField()' to HTML | |||||
// encode non-ASCII chars and to apply any field-specific search & replace actions | |||||
$recordData .= linkifyFieldItems($field, $row[$field], $userID, $fieldSpecificSearchReplaceActionsArray2, $encodingExceptionsArray, "/\s*[;]+\s*/", "; ", $showQuery, $showLinks, $showRows, $citeStyle, $citeOrder, $wrapResults, $displayType, $viewType); // function 'linkifyFieldItems()' is defined in 'include.inc.php' | |||||
else // don't hotlink field items | |||||
$recordData .= encodeField($field, $row[$field], $fieldSpecificSearchReplaceActionsArray2, $encodingExceptionsArray); // function 'encodeField()' is defined in 'include.inc.php' | |||||
$recordData .= "</div>"; | |||||
} | |||||
} | |||||
// Print a row with links for the current record: | |||||
$recordData .= "\n\t\t\t<div class=\"reflinks\">"; | |||||
// - Print the record's permanent URL: | |||||
if (preg_match("/^inc/i", $client)) // we open links in a new browser window if refbase data are included somewhere else: | |||||
$target = " target=\"_blank\""; | |||||
else | |||||
$target = ""; | |||||
$recordData .= "\n\t\t\t\t<div class=\"permalink\"><a href=\"" . $recordPermaLink . "\"" . $target . " title=\"" . $loc["LinkTitle_Permalink"] . "\">"; | |||||
if (preg_match("/^Print$/i", $viewType)) // for print view, we use the URL as link title | |||||
$recordData .= $recordPermaLink; | |||||
else | |||||
$recordData .= $loc["PermalinkShort"]; | |||||
$recordData .= "</a></div>"; | |||||
// - Print additional links to cite/export the current record: | |||||
// Note: we omit the additional links in print view ('viewType=Print') | |||||
if (!preg_match("/^Print$/i", $viewType)) | |||||
{ | |||||
// -- Print cite links: | |||||
if (isset($_SESSION['user_permissions']) AND preg_match("/allow_cite/", $_SESSION['user_permissions']) AND isset($_SESSION['user_cite_formats'])) | |||||
{ | |||||
$userCiteFormatsArray = preg_split("/ *; */", $_SESSION['user_cite_formats'], -1, PREG_SPLIT_NO_EMPTY); // get a list of the user's cite formats (the 'PREG_SPLIT_NO_EMPTY' flag causes only non-empty pieces to be returned) | |||||
$recordData .= "\n\t\t\t\t<div class=\"citelinks\">" | |||||
. " | " . $loc["SaveCitation"] . ":"; | |||||
foreach ($userCiteFormatsArray as $citeFormat) | |||||
if (!preg_match("/^html$/i", $citeFormat)) // for now, we exclude the "HTML" cite format (as it's not any different to the regular Citation view HTML output) | |||||
$recordData .= "\n\t\t\t\t\t <a href=\"" . $baseURL . generateURL("show.php", $citeFormat, array("record" => $row['serial']), true, "", "", $citeStyle, $citeOrder) . "\" title=\"" . $loc["LinkTitle_SaveCitationFormat_Prefix"] . $citeFormat . $loc["LinkTitle_SaveCitationFormat_Suffix"] . "\">" . $citeFormat . "</a>"; | |||||
$recordData .= "\n\t\t\t\t</div>"; | |||||
} | |||||
// -- Print export links: | |||||
if (isset($_SESSION['user_permissions']) AND preg_match("/allow_export|allow_batch_export/", $_SESSION['user_permissions']) AND isset($_SESSION['user_export_formats'])) | |||||
{ | |||||
$userExportFormatsArray = preg_split("/ *; */", $_SESSION['user_export_formats'], -1, PREG_SPLIT_NO_EMPTY); // get a list of the user's export formats | |||||
$recordData .= "\n\t\t\t\t<div class=\"exportlinks\">" | |||||
. " | " . $loc["ExportRecord"] . ":"; | |||||
foreach ($userExportFormatsArray as $exportFormat) | |||||
$recordData .= "\n\t\t\t\t\t <a href=\"" . $baseURL . generateURL("show.php", $exportFormat, array("record" => $row['serial'], "exportType" => "file"), true, "", "", $citeStyle) . "\" title=\"" . $loc["LinkTitle_ExportRecordFormat_Prefix"] . $exportFormat . $loc["LinkTitle_ExportRecordFormat_Suffix"] . "\">" . $exportFormat . "</a>"; | |||||
$recordData .= "\n\t\t\t\t</div>"; | |||||
} | |||||
} | |||||
$recordData .= "\n\t\t\t</div>" | |||||
. "\n\t\t</div>"; | |||||
} | |||||
$recordData .= "\n\t</td>"; | |||||
} | |||||
// Display the regular links column: | |||||
if ($showLinks == "1") | |||||
{ | |||||
if (preg_match("/^Mobile$/i", $viewType)) | |||||
$recordData .= "\n\t<div class=\"links\">"; | |||||
else | |||||
$recordData .= "\n\t<td class=\"links\" valign=\"top\" width=\"42\">"; | |||||
// Print out available links: | |||||
// for Citation view, we'll use the '$showLinkTypesInCitationView' array that's defined in 'ini.inc.php' | |||||
// to specify which links shall be displayed (if available and if 'showLinks == 1') | |||||
// (for links of type DOI/URL/ISBN/XREF, only one link will be printed; order of preference: DOI, URL, ISBN, XREF) | |||||
$recordData .= printLinks($showLinkTypesInCitationView, $row, $showQuery, $showLinks, $wrapResults, $userID, $viewType, $orderBy); // function 'printLinks()' is defined in 'search.php' | |||||
if (preg_match("/^Mobile$/i", $viewType)) | |||||
$recordData .= "\n\t</div>"; | |||||
else | |||||
$recordData .= "\n\t</td>"; | |||||
} | |||||
if (preg_match("/^Mobile$/i", $viewType)) | |||||
$recordData .= "\n</div>"; | |||||
else | |||||
$recordData .= "\n</tr>"; | |||||
} | |||||
} | |||||
// OUTPUT RESULTS: | |||||
// Note: we omit the results header, browse links & query form for CLI clients, and when outputting only a partial document structure ('wrapResults=0') | |||||
if (!preg_match("/^cli/i", $client) AND ($wrapResults != "0")) | |||||
{ | |||||
// Note: we also omit the results header in print/mobile view ('viewType=Print' or 'viewType=Mobile') | |||||
if ((!preg_match("/^(Print|Mobile)$/i", $viewType)) AND (!isset($displayResultsHeaderDefault[$displayType]) OR (isset($displayResultsHeaderDefault[$displayType]) AND ($displayResultsHeaderDefault[$displayType] != "hidden")))) | |||||
{ | |||||
// Extract the first field from the 'WHERE' clause: | |||||
if (preg_match("/ WHERE [ ()]*(\w+)/i", $query)) | |||||
$selectedField = preg_replace("/.+ WHERE [ ()]*(\w+).*/i", "\\1", $query); | |||||
else | |||||
$selectedField = "author"; // in the 'Search within Results" form, we'll select the 'author' field by default | |||||
// Map MySQL field names to localized column names: | |||||
$fieldNamesArray = mapFieldNames(true); | |||||
$localizedDropDownFieldsArray = array(); | |||||
if (isset($_SESSION['loginEmail']) AND !empty($defaultDropDownFieldsLogin)) // if a user is logged in -AND- there were any additional fields specified... | |||||
$dropDownFieldsArray = array_merge($defaultDropDownFieldsEveryone, $defaultDropDownFieldsLogin); // ...add these additional fields to the list of fields visible in the dropdown menus of the results header | |||||
else | |||||
$dropDownFieldsArray = $defaultDropDownFieldsEveryone; | |||||
foreach ($dropDownFieldsArray as $field) | |||||
{ | |||||
if (isset($fieldNamesArray[$field])) | |||||
$localizedDropDownFieldsArray[$field] = $fieldNamesArray[$field]; | |||||
else // no localized field name exists, so we use the original field name | |||||
$localizedDropDownFieldsArray[$field] = $field; | |||||
} | |||||
// Get all citation styles for the current user: | |||||
if (!isset($_SESSION['user_styles'])) | |||||
$citationStylesArray = array($defaultCiteStyle); | |||||
else | |||||
{ | |||||
$citationStylesArray = array(); | |||||
$citationStylesTempArray = preg_split("/ *; */", $_SESSION['user_styles']); // get the user's list of citation styles | |||||
foreach ($citationStylesTempArray as $citationStyle) | |||||
$citationStylesArray[$citationStyle] = $citationStyle; | |||||
} | |||||
// 2) Build forms containing options to show the user's groups, refine the search results or change the displayed columns: | |||||
// TODO for 2b+2c: should we allow users to choose via the web interface which columns are included in the popup menus? | |||||
// 2a) Build a FORM with a popup containing the user's groups: | |||||
$formElementsGroup = buildGroupSearchElements("search.php", $queryURL, $query, $showQuery, $showLinks, $showRows, $citeStyle, $citeOrder, $displayType); // function 'buildGroupSearchElements()' is defined in 'include.inc.php' | |||||
// 2b) Build a FORM containing options to refine the search results: | |||||
// Call the 'buildRefineSearchElements()' function (defined in 'include.inc.php') which does the actual work: | |||||
$formElementsRefine = buildRefineSearchElements("search.php", $queryURL, $showQuery, $showLinks, $showRows, $citeStyle, $citeOrder, $localizedDropDownFieldsArray, $selectedField, $displayType); | |||||
// 2c) Build a FORM containing display options (change citation style & sort order, or change the number of records displayed per page): | |||||
// Call the 'buildDisplayOptionsElements()' function (defined in 'include.inc.php') which does the actual work: | |||||
$formElementsDisplayOptions = buildDisplayOptionsElements("search.php", $queryURL, $showQuery, $showLinks, $rowOffset, $showRows, $citeStyle, $citeOrder, $citationStylesArray, $citeStyle, 2, $displayType, $headerMsg); | |||||
$htmlData .= displayResultsHeader("search.php", $formElementsGroup, $formElementsRefine, $formElementsDisplayOptions, $displayType); // function 'displayResultsHeader()' is defined in 'results_header.inc.php' | |||||
// and insert a divider line (which separates the results header from the browse links & results data below): | |||||
$htmlData .= "\n<hr class=\"resultsheader\" align=\"center\" width=\"93%\">"; | |||||
} | |||||
// Build a TABLE with links for "previous" & "next" browsing, as well as links to intermediate pages | |||||
// call the 'buildBrowseLinks()' function (defined in 'include.inc.php'): | |||||
$BrowseLinks = buildBrowseLinks("search.php", $query, $NoColumns, $rowsFound, $showQuery, $showLinks, $showRows, $rowOffset, $previousOffset, $nextOffset, $wrapResults, $maximumBrowseLinks, "sqlSearch", "Cite", $citeStyle, $citeOrder, $orderBy, $headerMsg, $viewType); | |||||
$htmlData .= $BrowseLinks; | |||||
if (preg_match("/^Mobile$/i", $viewType)) | |||||
{ | |||||
// Extract the original OpenSearch/CQL query that was saved by 'opensearch.php' as a session variable: | |||||
if (isset($_SESSION['cqlQuery'])) | |||||
$cqlQuery = $_SESSION['cqlQuery']; | |||||
else | |||||
$cqlQuery = ""; | |||||
// Include an OpenSearch-style (CQL) query form: | |||||
$htmlData .= "\n<div id=\"queryform\">" | |||||
. "\n\t<form action=\"opensearch.php\" method=\"GET\" name=\"openSearch\">" | |||||
. "\n\t\t<input type=\"hidden\" name=\"formType\" value=\"openSearch\">" | |||||
. "\n\t\t<input type=\"hidden\" name=\"submit\" value=\"" . $loc["ButtonTitle_Search"] . "\">" | |||||
. "\n\t\t<input type=\"hidden\" name=\"viewType\" value=\"" . $viewType . "\">" | |||||
. "\n\t\t<input type=\"hidden\" name=\"startRecord\" value=\"1\">" | |||||
. "\n\t\t<input type=\"hidden\" name=\"maximumRecords\" value=\"" . $showRows . "\">" | |||||
. "\n\t\t<input type=\"hidden\" name=\"recordSchema\" value=\"html\">" | |||||
. "\n\t\t<input type=\"text\" name=\"query\" value=\"" . $cqlQuery . "\" size=\"25\" title=\"" . $loc["DescriptionEnterSearchString"] . "\">" | |||||
. "\n\t\t<input type=\"submit\" name=\"submit\" value=\"" . $loc["ButtonTitle_Search"] . "\" title=\"" . $loc["DescriptionSearchDB"] . "\">" | |||||
. "\n\t</form>" | |||||
. "\n</div>"; | |||||
} | |||||
elseif ((!preg_match("/^Print$/i", $viewType)) AND (!isset($displayResultsFooterDefault[$displayType]) OR (isset($displayResultsFooterDefault[$displayType]) AND ($displayResultsFooterDefault[$displayType] != "hidden")))) | |||||
{ | |||||
// Include the 'queryResults' form: | |||||
$htmlData .= "\n<form action=\"search.php\" method=\"GET\" name=\"queryResults\">" | |||||
. "\n<input type=\"hidden\" name=\"formType\" value=\"queryResults\">" | |||||
. "\n<input type=\"hidden\" name=\"submit\" value=\"Cite\">" // provide a default value for the 'submit' form tag (then, if any form element is selected, hitting <enter> will act as if the user clicked the 'Cite' button) | |||||
. "\n<input type=\"hidden\" name=\"originalDisplayType\" value=\"" . $displayType . "\">" // embed the original value of the '$displayType' variable | |||||
. "\n<input type=\"hidden\" name=\"orderBy\" value=\"" . rawurlencode($orderBy) . "\">" // embed the current ORDER BY parameter so that it can be re-applied when displaying details | |||||
. "\n<input type=\"hidden\" name=\"showQuery\" value=\"" . $showQuery . "\">" // embed the current value of '$showQuery' so that it's available on 'display details' (batch display) & 'cite' | |||||
. "\n<input type=\"hidden\" name=\"showLinks\" value=\"" . $showLinks . "\">" // embed the current value of '$showLinks' so that it's available on 'display details' (batch display) & 'cite' | |||||
. "\n<input type=\"hidden\" name=\"showRows\" value=\"" . $showRows . "\">" // embed the current value of '$showRows' so that it's available on 'display details' (batch display) & 'cite' | |||||
. "\n<input type=\"hidden\" name=\"rowOffset\" value=\"" . $rowOffset . "\">" // embed the current value of '$rowOffset' so that it can be re-applied after the user pressed either of the 'Add' or 'Remove' buttons within the 'queryResults' form | |||||
// Note: the inclusion of '$rowOffset' here is only meant to support reloading of the same results page again after a user clicked the 'Add' or 'Remove' buttons | |||||
// However, '$rowOffset' MUST NOT be set if the user clicked the 'Display' or 'Cite' button! Therefore we'll trap for this case at the top of the script. | |||||
. "\n<input type=\"hidden\" name=\"sqlQuery\" value=\"" . $queryURL . "\">"; // embed the current sqlQuery so that it can be re-applied after the user pressed either of the 'Add' or 'Remove' buttons within the 'queryResults' form | |||||
} | |||||
} | |||||
// Output query results: | |||||
if (preg_match("/^Mobile$/i", $viewType)) | |||||
{ | |||||
$htmlData .= "\n<div id=\"citations\" class=\"results\">" | |||||
. $recordData | |||||
. "\n</div>"; | |||||
} | |||||
else | |||||
{ | |||||
$htmlData .= "\n<table id=\"citations\" class=\"results\" align=\"center\" border=\"0\" cellpadding=\"7\" cellspacing=\"0\" width=\"95%\" summary=\"This table holds the database results for your query\">" | |||||
. $recordData | |||||
. "\n</table>"; | |||||
} | |||||
// Append the footer: | |||||
// Note: we omit the results footer & browse links in print/mobile view ('viewType=Print' or 'viewType=Mobile'), for CLI clients, and when outputting only a partial document structure ('wrapResults=0')! | |||||
if ((!preg_match("/^(Print|Mobile)$/i", $viewType)) AND (!preg_match("/^cli/i", $client)) AND ($wrapResults != "0")) | |||||
{ | |||||
// Again, insert the (already constructed) BROWSE LINKS | |||||
// (i.e., a TABLE with links for "previous" & "next" browsing, as well as links to intermediate pages) | |||||
$htmlData .= $BrowseLinks; | |||||
// Build a results footer with form elements to cite, group or export all/selected records: | |||||
if (!isset($displayResultsFooterDefault[$displayType]) OR (isset($displayResultsFooterDefault[$displayType]) AND ($displayResultsFooterDefault[$displayType] != "hidden"))) | |||||
{ | |||||
if (isset($_SESSION['user_permissions']) AND ((isset($_SESSION['loginEmail']) AND preg_match("/allow_cite|allow_user_groups|allow_export|allow_batch_export/", $_SESSION['user_permissions'])) OR (!isset($_SESSION['loginEmail']) AND preg_match("/allow_cite/", $_SESSION['user_permissions'])))) // if the 'user_permissions' session variable does contain any of the following: 'allow_cite' -AND- if logged in, aditionally: 'allow_user_groups', 'allow_export', 'allow_batch_export'... | |||||
// ...Insert a divider line (which separates the results data from the forms in the footer): | |||||
$htmlData .= "\n<hr class=\"resultsfooter\" align=\"center\">"; | |||||
// Call the 'buildResultsFooter()' function (which does the actual work): | |||||
$htmlData .= buildResultsFooter($showRows, $citeStyle, $citeOrder, $displayType, $headerMsg); | |||||
} | |||||
} | |||||
if ((!preg_match("/^(Print|Mobile)$/i", $viewType)) AND (!preg_match("/^cli/i", $client)) AND ($wrapResults != "0") AND (!isset($displayResultsFooterDefault[$displayType]) OR (isset($displayResultsFooterDefault[$displayType]) AND ($displayResultsFooterDefault[$displayType] != "hidden")))) | |||||
{ | |||||
// Finish the form: | |||||
$htmlData .= "\n</form>"; | |||||
} | |||||
return $htmlData; | |||||
} | |||||
// --- END CITATION FORMAT --- | |||||
?> |
@ -0,0 +1,199 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./cite/formats/cite_latex.php | |||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/cite/formats/cite_latex.php $ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 10-Jun-06, 02:32 | |||||
// Modified: $Date: 2017-04-13 02:00:18 +0000 (Thu, 13 Apr 2017) $ | |||||
// $Author: karnesky $ | |||||
// $Revision: 1416 $ | |||||
// This is a citation format file (which must reside within the 'cite/formats/' sub-directory of your refbase root directory). It contains a | |||||
// version of the 'citeRecords()' function that outputs a reference list from selected records in LaTeX format. | |||||
// | |||||
// -------------------------------------------------------------------- | |||||
// --- BEGIN CITATION FORMAT --- | |||||
function citeRecords($result, $rowsFound, $query, $queryURL, $showQuery, $showLinks, $rowOffset, $showRows, $previousOffset, $nextOffset, $wrapResults, $citeStyle, $citeOrder, $citeType, $orderBy, $headerMsg, $userID, $viewType) | |||||
{ | |||||
global $contentTypeCharset; // defined in 'ini.inc.php' | |||||
global $client; | |||||
// The array '$transtab_refbase_latex' contains search & replace patterns for conversion from refbase markup to LaTeX markup & entities. | |||||
// Converts refbase fontshape markup (italic, bold) into LaTeX commands of the 'textcomp' package, super- and subscript as well as greek | |||||
// symbols get converted into the respective commands in math mode. You may need to adopt the LaTeX markup to suit your individual needs. | |||||
global $transtab_refbase_latex; // defined in 'transtab_refbase_latex.inc.php' | |||||
// The arrays '$transtab_latin1_latex' and '$transtab_unicode_latex' provide translation tables for best-effort conversion of higher ASCII | |||||
// characters from ISO-8859-1 (or Unicode, respectively) to LaTeX entities. | |||||
global $transtab_latin1_latex; // defined in 'transtab_latin1_latex.inc.php' | |||||
global $transtab_unicode_latex; // defined in 'transtab_unicode_latex.inc.php' | |||||
// Initialize array variables: | |||||
$yearsArray = array(); | |||||
$typeTitlesArray = array(); | |||||
// Define inline text markup to be used by the 'citeRecord()' function: | |||||
$markupPatternsArray = array("bold-prefix" => "\\textbf{", | |||||
"bold-suffix" => "}", | |||||
"italic-prefix" => "\\textit{", | |||||
"italic-suffix" => "}", | |||||
"underline-prefix" => "\\ul{", // the '\ul' command requires '\usepackage{soul}' | |||||
"underline-suffix" => "}", | |||||
"endash" => "--", // or use '{\\textendash}' | |||||
"emdash" => "---", // or use '{\\textemdash}' | |||||
"ampersand" => "&", // conversion of ampersands is done below, after the citation has been generated | |||||
"double-quote" => '"', | |||||
"double-quote-left" => "{\\textquotedblleft}", | |||||
"double-quote-right" => "{\\textquotedblright}", | |||||
"single-quote" => "'", // same as for ampersands | |||||
"single-quote-left" => "{\\textquoteleft}", | |||||
"single-quote-right" => "{\\textquoteright}", | |||||
"less-than" => "<", | |||||
"greater-than" => ">", | |||||
"newline" => "\n\n" | |||||
); | |||||
// Defines search & replace 'actions' that will be applied upon LaTeX output to all those refbase fields that are listed | |||||
// in the corresponding 'fields' element: | |||||
$latexSearchReplaceActionsArray = array( | |||||
array('fields' => array("title", "publication", "abbrev_journal", "address", "keywords", "abstract", "orig_title", "series_title", "abbrev_series_title", "notes"), | |||||
'actions' => $transtab_refbase_latex | |||||
) | |||||
); | |||||
// For CLI queries, we'll allow paging thru the result set, i.e. we honour the values of the CLI options '-S|--start' ('$rowOffset') | |||||
// and '-R|--rows' ('$showRows') ('$rowOffset' and '$showRows' are re-assigned in function 'seekInMySQLResultsToOffset()' in 'include.inc.php') | |||||
if (preg_match("/^cli/i", $client)) // if the query originated from a command line client such as the "refbase" CLI client ("cli-refbase-1.0") | |||||
$showMaxRows = $showRows; // show only rows up to the value given in '$showRows' | |||||
else | |||||
$showMaxRows = $rowsFound; // otherwise show all rows | |||||
// Setup the basic LaTeX document structure: | |||||
$latexData = "%&LaTeX\n" | |||||
. "\\documentclass{article}\n\n"; | |||||
// NOTE: the "Vancouver" & "Harvard 1" citation styles make use of the '\ul' command which requires '\usepackage{soul}' | |||||
// TODO: figure out a better logic when to include the '\usepackage{soul}' statement (or should we simply always include it?) | |||||
if (preg_match("/^(Vancouver|Harvard 1)$/i", $citeStyle)) | |||||
$latexData .= "\\usepackage{soul}\n"; | |||||
if ($contentTypeCharset == "UTF-8") | |||||
$latexData .= "\\usepackage[utf8]{inputenc}\n"; | |||||
else | |||||
$latexData .= "\\usepackage[latin1]{inputenc}\n"; | |||||
$latexData .= "\\usepackage[T1]{fontenc}\n" | |||||
. "\\usepackage{textcomp}\n\n"; | |||||
$latexData .= "\\begin{document}\n\n"; | |||||
// Header: | |||||
if (!empty($headerMsg)) | |||||
{ | |||||
// Remove any colon (":") from end of header message: | |||||
$headerMsg = trimTextPattern($headerMsg, ":", false, true); // function 'trimTextPattern()' is defined in 'include.inc.php' | |||||
// Decode any HTML entities: | |||||
// (these may occur in the header message e.g. if the user's preferred display language is not English but German or French, etc) | |||||
$headerMsg = decodeHTML($contentTypeCharset, $headerMsg); // function 'decodeHTML()' is defined in 'include.inc.php', and '$contentTypeCharset' is defined in 'ini.inc.php' | |||||
// Convert refbase markup in the header message into appropriate LaTeX markup & entities: | |||||
$headerMsg = searchReplaceText($transtab_refbase_latex, $headerMsg, true); // function 'searchReplaceText()' is defined in 'include.inc.php' | |||||
// Attempt to convert higher ASCII chars (i.e., characters with an ASCII value of >= 128) in the header message to their corresponding LaTeX entities: | |||||
if ($contentTypeCharset == "UTF-8") | |||||
$headerMsg = searchReplaceText($transtab_unicode_latex, $headerMsg, false); | |||||
else | |||||
$headerMsg = searchReplaceText($transtab_latin1_latex, $headerMsg, false); | |||||
$latexData .= "\\title{" . $headerMsg . "}\n\n" | |||||
. "\\maketitle\n\n"; | |||||
} | |||||
if (!preg_match("/type|year/i", $citeOrder)) | |||||
$latexData .= "\\begin{thebibliography}{" . $showMaxRows . "}\n\n"; | |||||
// LOOP OVER EACH RECORD: | |||||
// Fetch one page of results (or less if on the last page) | |||||
// (i.e., upto the limit specified in $showMaxRows) fetch a row into the $row array and ... | |||||
for ($rowCounter=0; (($rowCounter < $showMaxRows) && ($row = @ mysqli_fetch_array($result))); $rowCounter++) | |||||
{ | |||||
foreach ($row as $rowFieldName => $rowFieldValue) | |||||
// Apply search & replace 'actions' to all fields that are listed in the 'fields' element of the arrays contained in '$latexSearchReplaceActionsArray': | |||||
foreach ($latexSearchReplaceActionsArray as $fieldActionsArray) | |||||
if (in_array($rowFieldName, $fieldActionsArray['fields'])) | |||||
$row[$rowFieldName] = searchReplaceText($fieldActionsArray['actions'], $row[$rowFieldName], true); // function 'searchReplaceText()' is defined in 'include.inc.php' | |||||
// Order attributes according to the chosen output style & record type: | |||||
$record = citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, false); // function 'citeRecord()' is defined in the citation style file given in '$citeStyleFile' (which, in turn, must reside in the 'cite' directory of the refbase root directory), see function 'generateCitations()' | |||||
// Print out the current record: | |||||
if (!empty($record)) // unless the record buffer is empty... | |||||
{ | |||||
// Print any section heading(s): | |||||
if (preg_match("/year|type/i", $citeOrder)) | |||||
{ | |||||
list($yearsArray, $typeTitlesArray, $sectionHeading) = generateSectionHeading($yearsArray, $typeTitlesArray, $row, $citeOrder, "", "", "\\section*{", "}\n\n", "\\subsection*{", "}\n\n"); // function 'generateSectionHeading()' is defined in 'cite.inc.php' | |||||
$latexData .= $sectionHeading; | |||||
} | |||||
// Attempt to convert higher ASCII chars (i.e., characters with an ASCII value of >= 128) to their corresponding LaTeX entities: | |||||
if ($contentTypeCharset == "UTF-8") | |||||
$recordEncoded = searchReplaceText($transtab_unicode_latex, $record, false); // function 'searchReplaceText()' is defined in 'include.inc.php' | |||||
else | |||||
$recordEncoded = searchReplaceText($transtab_latin1_latex, $record, false); | |||||
// Write LaTeX paragraph: | |||||
if (!preg_match("/type|year/i", $citeOrder)) | |||||
{ | |||||
// This is a stupid hack that maps the names of the '$row' array keys to those used | |||||
// by the '$formVars' array (which is required by function 'generateCiteKey()') | |||||
// (eventually, the '$formVars' array should use the MySQL field names as names for its array keys) | |||||
$formVars = buildFormVarsArray($row); // function 'buildFormVarsArray()' is defined in 'include.inc.php' | |||||
// Generate or extract the cite key for this record: | |||||
// NOTE: currently, the following placeholders are not available for citation output: | |||||
// <:keywords:>, <:issn:>, <:area:>, <:notes:>, <:userKeys:> | |||||
// if the cite key specification uses one of these placeholders, it will get ignored | |||||
$citeKey = generateCiteKey($formVars); // function 'generateCiteKey()' is defined in 'include.inc.php' | |||||
if (!empty($citeKey)) | |||||
// Use the custom cite key that's been build according to the user's individual export options: | |||||
$latexData .= "\\bibitem{" . $citeKey . "} "; | |||||
else | |||||
// The '\bibitem' command requires a cite key, which is why we'll include the record's serial number | |||||
// even when the user's export options specify 'export_cite_keys=no' or 'autogenerate_cite_keys=no': | |||||
$latexData .= "\\bibitem{" . $row['serial'] . "} "; | |||||
} | |||||
$latexData .= $recordEncoded . "\n\n"; // create paragraph with encoded record text | |||||
} | |||||
} | |||||
if (!preg_match("/type|year/i", $citeOrder)) | |||||
$latexData .= "\\end{thebibliography}\n\n"; | |||||
$latexData .= "\\end{document}\n\n"; | |||||
return $latexData; | |||||
} | |||||
// --- END CITATION FORMAT --- | |||||
?> |
@ -0,0 +1,281 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./cite/formats/cite_latex_bbl.php | |||||
// Repository: $HeadURL$ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 20-Jul-07, 19:42 | |||||
// Modified: $Date: 2017-04-13 02:00:18 +0000 (Thu, 13 Apr 2017) $ | |||||
// $Author$ | |||||
// $Revision: 1416 $ | |||||
// This is a citation format file (which must reside within the 'cite/formats/' sub-directory of your refbase root directory). It contains a version of | |||||
// the 'citeRecords()' function that outputs a reference list from selected records in LateX .bbl format, to be used with LaTeX/BibTeX. The .bbl file | |||||
// generated by refbase can be used as a replacement of the BibTeX-generated .bbl file. Make sure to use "citeOrder=author" when generating the .bbl file. | |||||
// NOTE: In its current incarnation, this script outputs a .bbl variant that is intended to be used with the natbib package. | |||||
// You may want to adopt the style-specific settings below if necessary. The natbib package is available at: | |||||
// <http://www.ctan.org/tex-archive/macros/latex/contrib/natbib/> | |||||
// -------------------------------------------------------------------- | |||||
// --- BEGIN CITATION FORMAT --- | |||||
function citeRecords($result, $rowsFound, $query, $queryURL, $showQuery, $showLinks, $rowOffset, $showRows, $previousOffset, $nextOffset, $wrapResults, $citeStyle, $citeOrder, $citeType, $orderBy, $headerMsg, $userID, $viewType) | |||||
{ | |||||
global $contentTypeCharset; // defined in 'ini.inc.php' | |||||
global $client; | |||||
// The array '$transtab_refbase_latex' contains search & replace patterns for conversion from refbase markup to LaTeX markup & entities. | |||||
// Converts refbase fontshape markup (italic, bold) into LaTeX commands of the 'textcomp' package, super- and subscript as well as greek | |||||
// symbols get converted into the respective commands in math mode. You may need to adopt the LaTeX markup to suit your individual needs. | |||||
global $transtab_refbase_latex; // defined in 'transtab_refbase_latex.inc.php' | |||||
// The arrays '$transtab_latin1_latex' and '$transtab_unicode_latex' provide translation tables for best-effort conversion of higher ASCII | |||||
// characters from ISO-8859-1 (or Unicode, respectively) to LaTeX entities. | |||||
global $transtab_latin1_latex; // defined in 'transtab_latin1_latex.inc.php' | |||||
global $transtab_unicode_latex; // defined in 'transtab_unicode_latex.inc.php' | |||||
// --- Begin style-specific settings ---------------------------------- | |||||
// NOTE: the given settings are meant to be used with the natbib package; | |||||
// you'll have to adopt these settings if you'd like to generate a | |||||
// .bbl file for another style/package | |||||
// 1) Define header with .bst style-specific declarations: | |||||
// NOTE: since this header is normally inserted by BibTeX from the used .bst style, I'm not sure if there's a variant of this header that's | |||||
// universally accepted by natbib. So, if necessary adopt it to your needs. | |||||
// -- by default, we use this header (as inserted by a .bst style that was generated from 'merlin.mbs' via the docstrip utility): | |||||
$bblHeader = "\\providecommand{\\natexlab}[1]{#1}" . "\n" | |||||
. "\\providecommand{\\url}[1]{\\texttt{#1}}" . "\n" | |||||
. "\\providecommand{\\urlprefix}{URL }" . "\n" | |||||
. "\\providecommand{\\eprint}[2][]{\\url{#2}}" . "\n\n"; | |||||
// -- here's another header example (as inserted by 'elsart-harv.bst'): | |||||
// $bblHeader = "\\expandafter\\ifx\\csname natexlab\\endcsname\\relax\\def\\natexlab#1{#1}\\fi" . "\n" | |||||
// . "\\expandafter\\ifx\\csname url\\endcsname\\relax" . "\n" | |||||
// . " \\def\\url#1{\\texttt{#1}}\\fi" . "\n" | |||||
// . "\\expandafter\\ifx\\csname urlprefix\\endcsname\\relax\\def\\urlprefix{URL }\\fi" . "\n\n"; | |||||
// 2) Define name of \bibitem command: | |||||
$bibItemCommand = "\\bibitem"; // use "\\harvarditem" for the Harvard family of styles | |||||
// 3) Define variables and placeholder strings which together will form the \bibitem option string: | |||||
// -- variables: | |||||
$betweenShortAuthorsDelim = " & "; // used to connect individual author names in the short author list | |||||
$betweenFullAuthorsDelim = ", "; // used to connect multiple authors in the full author list | |||||
$betweenLastAuthorsDelim = " & "; // used to connect the second-to-last author with the last author in the full author list | |||||
$etalIdentifierString = " et~al."; // appended to the first author's last name if the record's number of authors exceeds the number given in '$maxAuthorCountInShortAuthorList' | |||||
$maxAuthorCountInShortAuthorList = 2; // maximum number of authors to be used in the short author list | |||||
// -- placeholder strings: | |||||
// (please see the refbase online documentation for more info about placeholders and their syntax: <http://placeholders.refbase.net/>) | |||||
$year = "<:year[4]:>"; // year format, e.g. "1990" | |||||
$shortAuthorList = "<:authors[" . $maxAuthorCountInShortAuthorList . "|" . $betweenShortAuthorsDelim . "|" . $etalIdentifierString . "]:>"; // format of the short author list which is used as text citation, e.g. "Jones", "Jones and Baker" or "Jones et al." | |||||
$fullAuthorList = "<:authors[0|_#_§_~_|]:>"; // format of the full author list, e.g. "Jones, Baker, and Williams" | |||||
// NOTE: in the above placeholder string, we use the string "_#_§_~_" as author delimiter which allows us to uniquely identify that delimiter again below, and replace it with the contents of either '$betweenFullAuthorsDelim' or '$betweenLastAuthorsDelim' (depending on its position) | |||||
// 4) Define \bibitem option format: | |||||
// -- extended natbib 5.3 style: | |||||
$bibItemOptionShort = "[{" . $shortAuthorList . "}(" . $year . ")" . "]"; // e.g.: \bibitem[{Jones et al.}(1990)]{key}... | |||||
$bibItemOptionFull = "[{" . $shortAuthorList . "}(" . $year . "){" . $fullAuthorList . "}]"; // e.g.: \bibitem[{Jones et al.}(1990){Jones, Baker, and Williams}]{key}... | |||||
// NOTE: since the author lists may contain parentheses, we need to enclose them in curly brackets to work around a natbib limitation | |||||
// -- native natbib style: | |||||
// $bibItemOptionShort = "[" . $shortAuthorList . "(" . $year . ")" . "]"; // e.g.: \bibitem[Jones et al.(1990)]{key}... | |||||
// $bibItemOptionFull = ""; | |||||
// -- apalike style: | |||||
// $bibItemOptionShort = "[" . $shortAuthorList . ", " . $year . "]"; // e.g.: \bibitem[Jones et al., 1990]{key}... | |||||
// $bibItemOptionFull = ""; | |||||
// -- newapa or chicago styles: | |||||
// $bibItemOptionShort = "[\\protect\\citeauthoryear{" . $fullAuthorList . "}{" . $shortAuthorList . "}{" . $year . "}" . "]"; // this assumes that it's not allowed to omit the full author list, though I dunno) | |||||
// $bibItemOptionFull = "[\\protect\\citeauthoryear{" . $fullAuthorList . "}{" . $shortAuthorList . "}{" . $year . "}" . "]"; // e.g.: \bibitem[\protect\citeauthoryear{Jones, Baker, and Williams}{Jones et al.}{1990}]{key}... | |||||
// -- named style: | |||||
// $bibItemOptionShort = "[\\protect\\citeauthoryear{" . $shortAuthorList . "}{" . $year . "}" . "]"; // e.g.: \bibitem[\protect\citeauthoryear{Jones et al.}{1990}]{key}... | |||||
// $bibItemOptionFull = ""; | |||||
// -- astron style: | |||||
// $bibItemOptionShort = "[\\protect\\astroncite{" . $shortAuthorList . "}{" . $year . "}" . "]"; // e.g.: \bibitem[\protect\astroncite{Jones et al.}{1990}]{key}... | |||||
// $bibItemOptionFull = ""; | |||||
// -- authordate style: | |||||
// $bibItemOptionShort = "[\\protect\\citename{" . $shortAuthorList . ", }" . $year . "]"; // e.g.: \bibitem[\protect\citename{Jones et al., }1990]{key}... | |||||
// $bibItemOptionFull = ""; | |||||
// -- harvard style: | |||||
// $bibItemOptionShort = "[" . $shortAuthorList . "]{" . $fullAuthorList . "}{" . $year . "}"; // this assumes that it's not allowed to omit the full author list, though I dunno) | |||||
// $bibItemOptionFull = "[" . $shortAuthorList . "]{" . $fullAuthorList . "}{" . $year . "}"; // e.g.: \harvarditem[Jones et al.]{Jones, Baker, and Williams}{1990}{key}... | |||||
// 5) Define deduplication prefix and suffix strings: | |||||
// Identical text citation strings get uniquified by appending letters to the year, e.g. duplicate occurrences | |||||
// of "Jones et al. 1990" should become "Jones et al. 1990a" and "Jones et al. 1990b" in the final output. | |||||
// These prefix/suffix strings will be inserted before/after the deduplication letter: | |||||
$dedupPrefix = "{\\natexlab{"; // these prefix/suffix strings are required by natbib; if any custom command (such as '\natexlab') is used, make sure that the command is also defined above in variable '$bblHeader' | |||||
$dedupSuffix = "}}"; | |||||
// --- End style-specific settings ------------------------------------ | |||||
// Initialize array variables: | |||||
$yearsArray = array(); | |||||
$typeTitlesArray = array(); | |||||
$bibItemsArray = array(); | |||||
// Define inline text markup to be used by the 'citeRecord()' function: | |||||
$markupPatternsArray = array("bold-prefix" => "\\textbf{", | |||||
"bold-suffix" => "}", | |||||
"italic-prefix" => "\\textit{", | |||||
"italic-suffix" => "}", | |||||
"underline-prefix" => "\\ul{", // the '\ul' command requires '\usepackage{soul}' | |||||
"underline-suffix" => "}", | |||||
"endash" => "--", // or use '{\\textendash}' | |||||
"emdash" => "---", // or use '{\\textemdash}' | |||||
"ampersand" => "&", // conversion of ampersands is done below, after the citation has been generated | |||||
"double-quote" => '"', | |||||
"double-quote-left" => "{\\textquotedblleft}", | |||||
"double-quote-right" => "{\\textquotedblright}", | |||||
"single-quote" => "'", // same as for ampersands | |||||
"single-quote-left" => "{\\textquoteleft}", | |||||
"single-quote-right" => "{\\textquoteright}", | |||||
"less-than" => "<", | |||||
"greater-than" => ">", | |||||
"newline" => "\n\n" | |||||
); | |||||
// Defines search & replace 'actions' that will be applied upon LaTeX output to all those refbase fields that are listed | |||||
// in the corresponding 'fields' element: | |||||
$latexSearchReplaceActionsArray = array( | |||||
array('fields' => array("title", "publication", "abbrev_journal", "address", "keywords", "abstract", "orig_title", "series_title", "abbrev_series_title", "notes"), | |||||
'actions' => $transtab_refbase_latex | |||||
) | |||||
); | |||||
// For CLI queries, we'll allow paging thru the result set, i.e. we honour the values of the CLI options '-S|--start' ('$rowOffset') | |||||
// and '-R|--rows' ('$showRows') ('$rowOffset' and '$showRows' are re-assigned in function 'seekInMySQLResultsToOffset()' in 'include.inc.php') | |||||
if (preg_match("/^cli/i", $client)) // if the query originated from a command line client such as the "refbase" CLI client ("cli-refbase-1.0") | |||||
$showMaxRows = $showRows; // show only rows up to the value given in '$showRows' | |||||
else | |||||
$showMaxRows = $rowsFound; // otherwise show all rows | |||||
// Setup the basic .bbl document structure: | |||||
$latexData = "\\begin{thebibliography}{" . $showMaxRows . "}\n\n"; | |||||
// Add header with .bst style-specific declarations: | |||||
$latexData .= $bblHeader; | |||||
// LOOP OVER EACH RECORD: | |||||
// Fetch one page of results (or less if on the last page) | |||||
// (i.e., upto the limit specified in $showMaxRows) fetch a row into the $row array and ... | |||||
for ($rowCounter=0; (($rowCounter < $showMaxRows) && ($row = @ mysqli_fetch_array($result))); $rowCounter++) | |||||
{ | |||||
foreach ($row as $rowFieldName => $rowFieldValue) | |||||
// Apply search & replace 'actions' to all fields that are listed in the 'fields' element of the arrays contained in '$latexSearchReplaceActionsArray': | |||||
foreach ($latexSearchReplaceActionsArray as $fieldActionsArray) | |||||
if (in_array($rowFieldName, $fieldActionsArray['fields'])) | |||||
$row[$rowFieldName] = searchReplaceText($fieldActionsArray['actions'], $row[$rowFieldName], true); // function 'searchReplaceText()' is defined in 'include.inc.php' | |||||
// Order attributes according to the chosen output style & record type: | |||||
$record = citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, false); // function 'citeRecord()' is defined in the citation style file given in '$citeStyleFile' (which, in turn, must reside in the 'cite' directory of the refbase root directory), see function 'generateCitations()' | |||||
// Print out the current record: | |||||
if (!empty($record)) // unless the record buffer is empty... | |||||
{ | |||||
// This is a stupid hack that maps the names of the '$row' array keys to those used | |||||
// by the '$formVars' array (which is required by function 'generateCiteKey()') | |||||
// (eventually, the '$formVars' array should use the MySQL field names as names for its array keys) | |||||
$formVars = buildFormVarsArray($row); // function 'buildFormVarsArray()' is defined in 'include.inc.php' | |||||
// Generate or extract the cite key for this record: | |||||
// NOTE: currently, the following placeholders are not available for citation output: | |||||
// <:keywords:>, <:issn:>, <:area:>, <:notes:>, <:userKeys:> | |||||
// if the cite key specification uses one of these placeholders, it will get ignored | |||||
$citeKey = generateCiteKey($formVars); // function 'generateCiteKey()' is defined in 'include.inc.php' | |||||
// The '\bibitem' command requires a cite key, which is why we'll include the record's serial number | |||||
// even when the user's export options specify 'export_cite_keys=no' or 'autogenerate_cite_keys=no': | |||||
// NOTE: maybe we should always generate a cite key here, even if 'export_cite_keys=no' or 'autogenerate_cite_keys=no'?? | |||||
if (empty($citeKey)) | |||||
$citeKey = $row['serial']; | |||||
// Generate the \bibitem option string that's used to build the proper text citation: | |||||
$bibItemOptionShortString = parsePlaceholderString($formVars, $bibItemOptionShort, "<:authors[2| and | et~al.]:><(:year:)>"); // function 'parsePlaceholderString()' is defined in 'include.inc.php' | |||||
if (!empty($bibItemOptionFull) AND preg_match("/^[^;]+(;[^;]+){" . $maxAuthorCountInShortAuthorList . "}/", $row['author'])) // if the 'author' field does contain more authors as specified in '$maxAuthorCountInShortAuthorList' | |||||
{ | |||||
// include full author list: | |||||
$bibItemOptionString = parsePlaceholderString($formVars, $bibItemOptionFull, "<:authors[2| and | et~al.]:><(:year:)><:authors[0|, |]:>"); | |||||
$bibItemOptionString = preg_replace("/_#_§_~_(?!.*?_#_§_~_)/", $betweenLastAuthorsDelim, $bibItemOptionString); // replace last occurrence of "_#_§_~_" | |||||
$bibItemOptionString = preg_replace("/_#_§_~_/", $betweenFullAuthorsDelim, $bibItemOptionString); // replace all other occurrences of "_#_§_~_" | |||||
} | |||||
else // only include short author list: | |||||
$bibItemOptionString = $bibItemOptionShortString; | |||||
// In case of duplicate text citation strings, append a letter to the year in the \bibitem option string as well as in the formatted reference: | |||||
// NOTE: - this is not fool proof and currently only works if there are no more than 26 duplicate text citations (letters a-z) | |||||
// - the below replace actions get triggered on the first four-digit number that happens to be identical to the record's year, but depending on the reference format, this may not be the actual year of the reference but some other number! | |||||
for ($i=0; isset($bibItemsArray[$bibItemOptionShortString]); $i++) | |||||
{ | |||||
// Update the existing \bibitem entry (that has an identical text citation string) and append an "a" to it's year items: | |||||
if ($i == 0) | |||||
{ | |||||
$dedupPrefixQuoted = preg_quote($dedupPrefix, "/"); // escape meta characters (including '/' that is used as delimiter for the PCRE replace functions below and which gets passed as second argument) | |||||
$dedupSuffixQuoted = preg_quote($dedupSuffix, "/"); | |||||
$oldBibItemOptionShortString = preg_replace("/^\[(.+)\]$/", "\\1", $bibItemOptionShortString); // remove square brackets from short \bibitem option string (which is required for the subsequent 'str_replace()' action to work with short and full option strings) | |||||
$newBibItemOptionShortString = preg_replace("/(" . $row['year'] . ")(" . $dedupPrefixQuoted . "[a-z]*" . $dedupSuffixQuoted . ")*/", "\\1" . $dedupPrefix . "a" . $dedupSuffix, $oldBibItemOptionShortString, 1); | |||||
$bibItemsArray[$bibItemOptionShortString] = str_replace($oldBibItemOptionShortString, $newBibItemOptionShortString, $bibItemsArray[$bibItemOptionShortString]); | |||||
$bibItemsArray[$bibItemOptionShortString] = preg_replace("/(" . $row['year'] . ")(" . $dedupPrefixQuoted . "[a-z]*" . $dedupSuffixQuoted . ")*(?!.*?" . $row['year'] . ")/", "\\1" . $dedupPrefix . "a" . $dedupSuffix, $bibItemsArray[$bibItemOptionShortString], 1); // note that this will fail if the formatted reference contains a number after the year that is identical to the year! | |||||
} | |||||
// Append a letter to the year items of the current \bibitem entry: | |||||
$bibItemOptionShortString = preg_replace("/(" . $row['year'] . ")(" . $dedupPrefixQuoted . "[a-z]*" . $dedupSuffixQuoted . ")*/e", "'\\1$dedupPrefix'.chr(98 + $i).'$dedupSuffix'", $bibItemOptionShortString, 1); // the 'e' modifier allows to execute PHP code within the replacement pattern | |||||
$bibItemOptionString = preg_replace("/(" . $row['year'] . ")(" . $dedupPrefixQuoted . "[a-z]*" . $dedupSuffixQuoted . ")*/e", "'\\1$dedupPrefix'.chr(98 + $i).'$dedupSuffix'", $bibItemOptionString, 1); | |||||
$record = preg_replace("/(" . $row['year'] . ")(" . $dedupPrefixQuoted . "[a-z]*" . $dedupSuffixQuoted . ")*/e", "'\\1$dedupPrefix'.chr(98 + $i).'$dedupSuffix'", $record, 1); | |||||
} | |||||
// Attempt to convert higher ASCII chars (i.e., characters with an ASCII value of >= 128) to their corresponding LaTeX entities: | |||||
if ($contentTypeCharset == "UTF-8") | |||||
$recordEncoded = searchReplaceText($transtab_unicode_latex, $record, false); // function 'searchReplaceText()' is defined in 'include.inc.php' | |||||
else | |||||
$recordEncoded = searchReplaceText($transtab_latin1_latex, $record, false); | |||||
// We have to make sure that the \bibitem option string also contains proper LaTeX entities: | |||||
if ($contentTypeCharset == "UTF-8") | |||||
$bibItemOptionStringEncoded = searchReplaceText($transtab_unicode_latex, $bibItemOptionString, false); | |||||
else | |||||
$bibItemOptionStringEncoded = searchReplaceText($transtab_latin1_latex, $bibItemOptionString, false); | |||||
// Copy the current \bibitem entry to the array of generated \bibitem entries: | |||||
$bibItemsArray[$bibItemOptionShortString] = $bibItemCommand . $bibItemOptionStringEncoded . "{" . $citeKey . "} " . $recordEncoded; | |||||
} | |||||
} | |||||
$latexData .= implode("\n\n", $bibItemsArray) . "\n\n"; | |||||
$latexData .= "\\end{thebibliography}\n\n"; | |||||
return $latexData; | |||||
} | |||||
// --- END CITATION FORMAT --- | |||||
?> |
@ -0,0 +1,147 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./cite/formats/cite_markdown.php | |||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/cite/formats/cite_markdown.php $ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 10-Jun-06, 02:58 | |||||
// Modified: $Date: 2017-04-13 02:00:18 +0000 (Thu, 13 Apr 2017) $ | |||||
// $Author: karnesky $ | |||||
// $Revision: 1416 $ | |||||
// This is a citation format file (which must reside within the 'cite/formats/' sub-directory of your refbase root directory). It contains a | |||||
// version of the 'citeRecords()' function that outputs a reference list from selected records in Markdown format. Markdown is a plain text | |||||
// formatting syntax as well as a software tool that converts the plain text formatting back to HTML (<http://daringfireball.net/projects/markdown/>) | |||||
// -------------------------------------------------------------------- | |||||
// --- BEGIN CITATION FORMAT --- | |||||
function citeRecords($result, $rowsFound, $query, $queryURL, $showQuery, $showLinks, $rowOffset, $showRows, $previousOffset, $nextOffset, $wrapResults, $citeStyle, $citeOrder, $citeType, $orderBy, $headerMsg, $userID, $viewType) | |||||
{ | |||||
global $contentTypeCharset; // defined in 'ini.inc.php' | |||||
global $client; | |||||
// The array '$transtab_refbase_markdown' contains search & replace patterns for conversion from refbase markup to Markdown markup & entities | |||||
global $transtab_refbase_markdown; // defined in 'transtab_refbase_markdown.inc.php' | |||||
$markdownData = ""; // make sure that our buffer variable is empty | |||||
// Header: | |||||
if (!empty($headerMsg)) | |||||
{ | |||||
// Decode any HTML entities: | |||||
// (these may occur in the header message e.g. if the user's preferred display language is not English but German or French, etc) | |||||
$headerMsg = decodeHTML($contentTypeCharset, $headerMsg); // function 'decodeHTML()' is defined in 'include.inc.php', and '$contentTypeCharset' is defined in 'ini.inc.php' | |||||
// Convert refbase markup in the header message into appropriate Markdown markup & entities: | |||||
$headerMsg = searchReplaceText($transtab_refbase_markdown, $headerMsg, true); // function 'searchReplaceText()' is defined in 'include.inc.php' | |||||
$markdownData .= "# $headerMsg #\n\n"; | |||||
} | |||||
// Initialize array variables: | |||||
$yearsArray = array(); | |||||
$typeTitlesArray = array(); | |||||
// Define inline text markup to be used by the 'citeRecord()' function: | |||||
$markupPatternsArray = array("bold-prefix" => "**", | |||||
"bold-suffix" => "**", | |||||
"italic-prefix" => "_", | |||||
"italic-suffix" => "_", | |||||
"underline-prefix" => "<u>", | |||||
"underline-suffix" => "</u>", | |||||
"endash" => "–", | |||||
"emdash" => "—", | |||||
"ampersand" => "&", | |||||
"double-quote" => '"', | |||||
"double-quote-left" => "“", | |||||
"double-quote-right" => "”", | |||||
"single-quote" => "'", | |||||
"single-quote-left" => "‘", | |||||
"single-quote-right" => "’", | |||||
"less-than" => "<", | |||||
"greater-than" => ">", | |||||
"newline" => " \n" | |||||
); | |||||
// Defines search & replace 'actions' that will be applied upon Markdown output to all those refbase fields that are listed | |||||
// in the corresponding 'fields' element: | |||||
$markdownSearchReplaceActionsArray = array( | |||||
array('fields' => array("title", "publication", "abbrev_journal", "address", "keywords", "abstract", "orig_title", "series_title", "abbrev_series_title", "notes"), | |||||
'actions' => $transtab_refbase_markdown | |||||
) | |||||
); | |||||
// For CLI queries, we'll allow paging thru the result set, i.e. we honour the values of the CLI options '-S|--start' ('$rowOffset') | |||||
// and '-R|--rows' ('$showRows') ('$rowOffset' and '$showRows' are re-assigned in function 'seekInMySQLResultsToOffset()' in 'include.inc.php') | |||||
if (preg_match("/^cli/i", $client)) // if the query originated from a command line client such as the "refbase" CLI client ("cli-refbase-1.0") | |||||
$showMaxRows = $showRows; // show only rows up to the value given in '$showRows' | |||||
else | |||||
$showMaxRows = $rowsFound; // otherwise show all rows | |||||
// LOOP OVER EACH RECORD: | |||||
// Fetch one page of results (or less if on the last page) | |||||
// (i.e., upto the limit specified in $showMaxRows) fetch a row into the $row array and ... | |||||
for ($rowCounter=0; (($rowCounter < $showMaxRows) && ($row = @ mysqli_fetch_array($result))); $rowCounter++) | |||||
{ | |||||
foreach ($row as $rowFieldName => $rowFieldValue) | |||||
// Apply search & replace 'actions' to all fields that are listed in the 'fields' element of the arrays contained in '$markdownSearchReplaceActionsArray': | |||||
foreach ($markdownSearchReplaceActionsArray as $fieldActionsArray) | |||||
if (in_array($rowFieldName, $fieldActionsArray['fields'])) | |||||
$row[$rowFieldName] = searchReplaceText($fieldActionsArray['actions'], $row[$rowFieldName], true); // function 'searchReplaceText()' is defined in 'include.inc.php' | |||||
// Order attributes according to the chosen output style & record type: | |||||
$record = citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, false); // function 'citeRecord()' is defined in the citation style file given in '$citeStyleFile' (which, in turn, must reside in the 'cite' directory of the refbase root directory), see function 'generateCitations()' | |||||
// Print out the current record: | |||||
if (!empty($record)) // unless the record buffer is empty... | |||||
{ | |||||
// Print any section heading(s): | |||||
if (preg_match("/year|type/i", $citeOrder)) | |||||
{ | |||||
$headingPrefix = ""; | |||||
$headingSuffix = ""; | |||||
if (!empty($headerMsg)) // if there's a custom header message available, we decrease the heading level of sections & subsections by one (since the header message has level 1) | |||||
{ | |||||
$sectionMarkupPrefix = "## "; | |||||
$sectionMarkupSuffix = " ##\n\n"; | |||||
$subSectionMarkupPrefix = "### "; | |||||
$subSectionMarkupSuffix = " ###\n\n"; | |||||
} | |||||
else // no custom header message given | |||||
{ | |||||
$sectionMarkupPrefix = "# "; | |||||
$sectionMarkupSuffix = " #\n\n"; | |||||
$subSectionMarkupPrefix = "## "; | |||||
$subSectionMarkupSuffix = " ##\n\n"; | |||||
} | |||||
list($yearsArray, $typeTitlesArray, $sectionHeading) = generateSectionHeading($yearsArray, $typeTitlesArray, $row, $citeOrder, $headingPrefix, $headingSuffix, $sectionMarkupPrefix, $sectionMarkupSuffix, $subSectionMarkupPrefix, $subSectionMarkupSuffix); // function 'generateSectionHeading()' is defined in 'cite.inc.php' | |||||
$markdownData .= $sectionHeading; | |||||
} | |||||
// Write plain TEXT paragraph: | |||||
$markdownData .= $record . "\n\n"; // create paragraph with encoded record text | |||||
} | |||||
} | |||||
return $markdownData; | |||||
} | |||||
// --- END CITATION FORMAT --- | |||||
?> |
@ -0,0 +1,260 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./cite/formats/cite_pdf.php | |||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/cite/formats/cite_pdf.php $ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 10-Jun-06, 02:04 | |||||
// Modified: $Date: 2017-04-13 02:00:18 +0000 (Thu, 13 Apr 2017) $ | |||||
// $Author: karnesky $ | |||||
// $Revision: 1416 $ | |||||
// This is a citation format file (which must reside within the 'cite/formats/' sub-directory of your refbase root directory). It contains a | |||||
// version of the 'citeRecords()' function that outputs a reference list from selected records in PDF format. | |||||
// PDF format specification is available at <http://partners.adobe.com/public/developer/pdf/index_reference.html>, more info at <http://en.wikipedia.org/wiki/PDF> | |||||
// LIMITATIONS: - export of cited references to PDF does currently only work with a latin1 database but not with UTF-8 (since I don't know how to write Unicode characters to PDF) | |||||
// - there's currently no conversion of en-/emdashes or markup for greek letters and super-/subscript (reasons are that I don't know how to print chars by code number) | |||||
// -------------------------------------------------------------------- | |||||
// Include the pdf-php package | |||||
require_once 'includes/classes/org/pdf-php/class.ezpdf.php'; | |||||
// --- BEGIN CITATION FORMAT --- | |||||
// Requires the "PHP Pdf creation (pdf-php)" Package (by Wayne Munro, R&OS Ltd), which is available | |||||
// under a public domain licence: <http://www.ros.co.nz/pdf> | |||||
function citeRecords($result, $rowsFound, $query, $queryURL, $showQuery, $showLinks, $rowOffset, $showRows, $previousOffset, $nextOffset, $wrapResults, $citeStyle, $citeOrder, $citeType, $orderBy, $headerMsg, $userID, $viewType) | |||||
{ | |||||
global $officialDatabaseName; // these variables are defined in 'ini.inc.php' | |||||
global $databaseBaseURL; | |||||
global $contentTypeCharset; | |||||
global $pdfPageSize; | |||||
global $client; | |||||
// The array '$transtab_refbase_pdf' contains search & replace patterns for conversion from refbase markup to PDf markup & entities | |||||
global $transtab_refbase_pdf; // defined in 'transtab_refbase_pdf.inc.php' | |||||
// Initialize array variables: | |||||
$yearsArray = array(); | |||||
$typeTitlesArray = array(); | |||||
// Define inline text markup to be used by the 'citeRecord()' function: | |||||
$markupPatternsArray = array("bold-prefix" => "<b>", // html-style fontshape markup is recognized and converted by the pdf-php package | |||||
"bold-suffix" => "</b>", | |||||
"italic-prefix" => "<i>", | |||||
"italic-suffix" => "</i>", | |||||
"underline-prefix" => "<u>", | |||||
"underline-suffix" => "</u>", | |||||
"endash" => "¦", // see notes for "*-quote-*" below; we could also use "–" here | |||||
"emdash" => "©", // an emdash might also be faked with two endashes ("––") | |||||
"ampersand" => "&", | |||||
"double-quote" => '"', | |||||
"double-quote-left" => "ª", // AFAIK, the ISO-8859-1 (latin1) character set does not have any curly quotes, | |||||
"double-quote-right" => "¬", // see e.g. <http://www.ramsch.org/martin/uni/fmi-hp/iso8859-1.html>; but ... | |||||
"single-quote" => "'", | |||||
"single-quote-left" => "®", // ... since the pdf-php package let's you replace an (unused) character for any other PostScript char (see below), we use | |||||
"single-quote-right" => "¶", // the '$diff' array below to replace e.g. "®" with a single left curly quote and "¶" with a single right curly quote, etc | |||||
"less-than" => "<", | |||||
"greater-than" => ">", | |||||
"newline" => "\n" | |||||
); | |||||
// Defines search & replace 'actions' that will be applied upon PDF output to all those refbase fields that are listed | |||||
// in the corresponding 'fields' element: | |||||
$pdfSearchReplaceActionsArray = array( | |||||
array('fields' => array("title", "publication", "abbrev_journal", "address", "keywords", "abstract", "orig_title", "series_title", "abbrev_series_title", "notes"), | |||||
'actions' => $transtab_refbase_pdf | |||||
) | |||||
); | |||||
// For CLI queries, we'll allow paging thru the result set, i.e. we honour the values of the CLI options '-S|--start' ('$rowOffset') | |||||
// and '-R|--rows' ('$showRows') ('$rowOffset' and '$showRows' are re-assigned in function 'seekInMySQLResultsToOffset()' in 'include.inc.php') | |||||
if (preg_match("/^cli/i", $client)) // if the query originated from a command line client such as the "refbase" CLI client ("cli-refbase-1.0") | |||||
$showMaxRows = $showRows; // show only rows up to the value given in '$showRows' | |||||
else | |||||
$showMaxRows = $rowsFound; // otherwise show all rows | |||||
// Setup the basic PDF document structure (PDF functions defined in 'class.ezpdf.php'): | |||||
$pdf = new Cezpdf($pdfPageSize, 'portrait'); // initialize PDF object | |||||
if (!empty($headerMsg)) // adjust upper page margin if a custom header message was given | |||||
$pageMarginTop = "70"; | |||||
else | |||||
$pageMarginTop = "50"; | |||||
$pdf -> ezSetMargins($pageMarginTop, 70, 50, 50); // set document margins (top, bottom, left, right) | |||||
// Set fonts: | |||||
$headingFont = 'includes/classes/org/pdf-php/fonts/Helvetica.afm'; | |||||
$textBodyFont = 'includes/classes/org/pdf-php/fonts/Times-Roman.afm'; | |||||
// Re-map character numbers from the 0->255 range to a named character, i.e. replace an (unused) character for any other PostScript char; | |||||
// see the PDF reference for a list of supported PostScript/PDF character names: <http://www.adobe.com/devnet/pdf/pdf_reference.html>; | |||||
// for the decimal code numbers of the ISO-8859-1 character set, see e.g.: <http://www.ramsch.org/martin/uni/fmi-hp/iso8859-1.html> | |||||
$diff = array( | |||||
166 => 'endash', // "¦" | |||||
169 => 'emdash', // "©" | |||||
170 => 'quotedblleft', // "ª" | |||||
172 => 'quotedblright', // "¬" | |||||
174 => 'quoteleft', // "®" | |||||
182 => 'quoteright' // "¶" | |||||
); | |||||
// Select a font: | |||||
$pdf->selectFont($textBodyFont, array('encoding' => 'WinAnsiEncoding', 'differences' => $diff)); | |||||
$pdf->openHere('Fit'); | |||||
// Put a footer (and optionally a header) on all the pages: | |||||
$all = $pdf->openObject(); // start an independent object; all further writes to a page will actually go into this object, until a 'closeObject()' call is made | |||||
$pdf->saveState(); | |||||
$pdf->setStrokeColor(0, 0, 0, 1); // set line color | |||||
$pdf->setLineStyle(0.5); // set line width | |||||
// - print header line and header message at the specified x/y position: | |||||
if (!empty($headerMsg)) // if a custom header message was given | |||||
{ | |||||
// Remove any colon (":") from end of header message: | |||||
$headerMsg = trimTextPattern($headerMsg, ":", false, true); // function 'trimTextPattern()' is defined in 'include.inc.php' | |||||
// Decode any HTML entities: | |||||
// (these may occur in the header message e.g. if the user's preferred display language is not English but German or French, etc) | |||||
$headerMsg = decodeHTML($contentTypeCharset, $headerMsg); // function 'decodeHTML()' is defined in 'include.inc.php', and '$contentTypeCharset' is defined in 'ini.inc.php' | |||||
// Convert refbase markup in the header message into appropriate PDF markup & entities: | |||||
$headerMsg = searchReplaceText($transtab_refbase_pdf, $headerMsg, true); // function 'searchReplaceText()' is defined in 'include.inc.php' | |||||
if ($pdfPageSize == 'a4') // page dimensions 'a4': 595.28 x 841.89 pt. | |||||
{ | |||||
$pdf->line(20, 800, 575, 800); | |||||
$pdf->addText(50, 805, 10, $headerMsg); | |||||
} | |||||
elseif ($pdfPageSize == 'letter') // page dimensions 'letter': 612 x 792 pt. | |||||
{ | |||||
$pdf->line(20, 750, 592, 750); | |||||
$pdf->addText(50, 755, 10, $headerMsg); | |||||
} | |||||
} | |||||
// - print footer line and footer text at the specified x/y position: | |||||
if ($pdfPageSize == 'a4') | |||||
{ | |||||
$pdf->line(20, 40, 575, 40); | |||||
$pdf->addText(50, 28, 10, $officialDatabaseName . ' ¦ ' . $databaseBaseURL); // w.r.t. the endash, see notes at '$markupPatternsArray' and '$diff' above | |||||
} | |||||
elseif ($pdfPageSize == 'letter') | |||||
{ | |||||
$pdf->line(20, 40, 592, 40); | |||||
$pdf->addText(50, 28, 10, $officialDatabaseName . ' ¦ ' . $databaseBaseURL); | |||||
} | |||||
$pdf->restoreState(); | |||||
$pdf->closeObject(); // close the currently open object; further writes will now go to the current page | |||||
$pdf->addObject($all, 'all'); // note that object can be told to appear on just odd or even pages by changing 'all' to 'odd' or 'even' | |||||
// Start printing page numbers: | |||||
if ($pdfPageSize == 'a4') | |||||
{ | |||||
$pdf->ezStartPageNumbers(550, 28, 10, '', '', 1); | |||||
} | |||||
elseif ($pdfPageSize == 'letter') | |||||
{ | |||||
$pdf->ezStartPageNumbers(567, 28, 10, '', '', 1); | |||||
} | |||||
// LOOP OVER EACH RECORD: | |||||
// Fetch one page of results (or less if on the last page) | |||||
// (i.e., upto the limit specified in $showMaxRows) fetch a row into the $row array and ... | |||||
for ($rowCounter=0; (($rowCounter < $showMaxRows) && ($row = @ mysqli_fetch_array($result))); $rowCounter++) | |||||
{ | |||||
foreach ($row as $rowFieldName => $rowFieldValue) | |||||
// Apply search & replace 'actions' to all fields that are listed in the 'fields' element of the arrays contained in '$pdfSearchReplaceActionsArray': | |||||
foreach ($pdfSearchReplaceActionsArray as $fieldActionsArray) | |||||
if (in_array($rowFieldName, $fieldActionsArray['fields'])) | |||||
$row[$rowFieldName] = searchReplaceText($fieldActionsArray['actions'], $row[$rowFieldName], true); // function 'searchReplaceText()' is defined in 'include.inc.php' | |||||
// Order attributes according to the chosen output style & record type: | |||||
$record = citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, false); // function 'citeRecord()' is defined in the citation style file given in '$citeStyleFile' (which, in turn, must reside in the 'cite' directory of the refbase root directory), see function 'generateCitations()' | |||||
// Print out the current record: | |||||
if (!empty($record)) // unless the record buffer is empty... | |||||
{ | |||||
// Print any section heading(s): | |||||
if (preg_match("/year|type/i", $citeOrder)) | |||||
{ | |||||
$headingPrefix = ""; | |||||
$headingSuffix = ""; | |||||
$sectionMarkupPrefix = "<b>"; | |||||
$sectionMarkupSuffix = "</b>\n"; | |||||
$subSectionMarkupPrefix = ""; | |||||
$subSectionMarkupSuffix = "\n"; | |||||
if ($citeOrder == "type-year") | |||||
$sectionMarkupSuffix .= "\n"; | |||||
list($yearsArray, $typeTitlesArray, $sectionHeading) = generateSectionHeading($yearsArray, $typeTitlesArray, $row, $citeOrder, $headingPrefix, $headingSuffix, $sectionMarkupPrefix, $sectionMarkupSuffix, $subSectionMarkupPrefix, $subSectionMarkupSuffix); // function 'generateSectionHeading()' is defined in 'cite.inc.php' | |||||
if (!empty($sectionHeading)) | |||||
{ | |||||
$pdf->selectFont($headingFont, array('encoding' => 'WinAnsiEncoding', 'differences' => $diff)); // use Helvetica | |||||
$pdf->ezText($sectionHeading, '14', array('justification' => 'left')); // create heading using a font size of 14pt | |||||
} | |||||
} | |||||
// If character encoding is not UTF-8 already, convert record text to UTF-8: | |||||
// if ($contentTypeCharset != "UTF-8") | |||||
// $record = convertToCharacterEncoding("UTF-8", "IGNORE", $record); // function 'convertToCharacterEncoding()' is defined in 'include.inc.php' | |||||
// NOTE: Export of cited references to PDF does currently only work with a latin1 database but not with UTF-8 (since I don't know how to write Unicode characters to PDF). | |||||
// As a workaround, we could convert UTF-8 characters to latin1 if possible (and omit any other higher ASCII chars) | |||||
// TODO: While this workaround indeed fixes display issues with higher ASCII chars that have equivalents in the latin1 charset, this will currently swallow higher ASCII | |||||
// hyphens/dashes such as endashes (which display correctly without this workaround). | |||||
// if ($contentTypeCharset == "UTF-8") | |||||
// $record = convertToCharacterEncoding("ISO-8859-1", "TRANSLIT", $record, "UTF-8"); // function 'convertToCharacterEncoding()' is defined in 'include.inc.php' | |||||
// Set paragraph text options: | |||||
$textOptions = array( | |||||
'justification' => 'full' | |||||
// 'aleft' => '50', | |||||
// 'aright' => '545' | |||||
); | |||||
// possible array options: | |||||
// 'left'=> number, gap to leave from the left margin | |||||
// 'right'=> number, gap to leave from the right margin | |||||
// 'aleft'=> number, absolute left position (overrides 'left') | |||||
// 'aright'=> number, absolute right position (overrides 'right') | |||||
// 'justification' => 'left','right','center','centre','full' | |||||
// | |||||
// only set one of the next two items (leading overrides spacing) | |||||
// 'leading' => number, defines the total height taken by the line, independent of the font height. | |||||
// 'spacing' => a real number, though usually set to one of 1, 1.5, 2 (line spacing as used in word processing) | |||||
// Write PDF paragraph: | |||||
$pdf->selectFont($textBodyFont, array('encoding' => 'WinAnsiEncoding')); // use Times-Roman | |||||
$pdf->ezText($record . "\n", '12', $textOptions); // create text block with record text using "Times Roman" and a font size of 12pt | |||||
} | |||||
} | |||||
return $pdf->ezStream(); | |||||
} | |||||
// --- END CITATION FORMAT --- | |||||
?> |
@ -0,0 +1,170 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./cite/formats/cite_rtf.php | |||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/cite/formats/cite_rtf.php $ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 10-Jun-06, 02:04 | |||||
// Modified: $Date: 2017-04-13 02:00:18 +0000 (Thu, 13 Apr 2017) $ | |||||
// $Author: karnesky $ | |||||
// $Revision: 1416 $ | |||||
// This is a citation format file (which must reside within the 'cite/formats/' sub-directory of your refbase root directory). It contains a | |||||
// version of the 'citeRecords()' function that outputs a reference list from selected records in RTF format. | |||||
// RTF 1.0 format specification is available at <http://latex2rtf.sourceforge.net/RTF-Spec-1.0.txt>, more info at <http://en.wikipedia.org/wiki/RTF> | |||||
// -------------------------------------------------------------------- | |||||
// Include the MINIMALRTF Package | |||||
require_once 'includes/classes/org/bibliophile/MINIMALRTF.php'; | |||||
// --- BEGIN CITATION FORMAT --- | |||||
// Requires the MINIMALRTF Package (by Mark Grimshaw), which is available | |||||
// under the GPL from: <http://bibliophile.sourceforge.net> | |||||
function citeRecords($result, $rowsFound, $query, $queryURL, $showQuery, $showLinks, $rowOffset, $showRows, $previousOffset, $nextOffset, $wrapResults, $citeStyle, $citeOrder, $citeType, $orderBy, $headerMsg, $userID, $viewType) | |||||
{ | |||||
global $contentTypeCharset; // defined in 'ini.inc.php' | |||||
global $client; | |||||
// The array '$transtab_refbase_rtf' contains search & replace patterns for conversion from refbase markup to RTF markup & entities | |||||
global $transtab_refbase_rtf; // defined in 'transtab_refbase_rtf.inc.php' | |||||
// Initialize array variables: | |||||
$yearsArray = array(); | |||||
$typeTitlesArray = array(); | |||||
// Define inline text markup to be used by the 'citeRecord()' function: | |||||
$markupPatternsArray = array("bold-prefix" => "{\\b ", | |||||
"bold-suffix" => "}", | |||||
"italic-prefix" => "{\\i ", | |||||
"italic-suffix" => "}", | |||||
"underline-prefix" => "{\\ul ", | |||||
"underline-suffix" => "}", | |||||
"endash" => "\\endash ", // or use "\\uc0\\u8211 " or "\\u8211\\'2D" (the first two seem to work more reliably than the third one) | |||||
"emdash" => "\\emdash ", // or use "\\uc0\\u8212 " or "\\u8212\\'2D" | |||||
"ampersand" => "&", | |||||
"double-quote" => '"', | |||||
"double-quote-left" => "\\ldblquote ", // or use "\\uc0\\u8220 " or "\\u8220\\'22" | |||||
"double-quote-right" => "\\rdblquote ", // or use "\\uc0\\u8221 " or "\\u8221\\'22" | |||||
"single-quote" => "'", | |||||
"single-quote-left" => "\\lquote ", // or use "\\uc0\\u8216 " or "\\u8216\\'27" | |||||
"single-quote-right" => "\\rquote ", // or use "\\uc0\\u8217 " or "\\u8217\\'27" | |||||
"less-than" => "<", | |||||
"greater-than" => ">", | |||||
"newline" => "\n{\\f1\\fs24 \par}\n" | |||||
); | |||||
// Defines search & replace 'actions' that will be applied upon RTF output to all those refbase fields that are listed | |||||
// in the corresponding 'fields' element: | |||||
$rtfSearchReplaceActionsArray = array( | |||||
array( | |||||
'fields' => array("title", "publication", "abbrev_journal", "address", "keywords", "abstract", "orig_title", "series_title", "abbrev_series_title", "notes"), | |||||
'actions' => $transtab_refbase_rtf | |||||
) | |||||
); | |||||
// For CLI queries, we'll allow paging thru the result set, i.e. we honour the values of the CLI options '-S|--start' ('$rowOffset') | |||||
// and '-R|--rows' ('$showRows') ('$rowOffset' and '$showRows' are re-assigned in function 'seekInMySQLResultsToOffset()' in 'include.inc.php') | |||||
if (preg_match("/^cli/i", $client)) // if the query originated from a command line client such as the "refbase" CLI client ("cli-refbase-1.0") | |||||
$showMaxRows = $showRows; // show only rows up to the value given in '$showRows' | |||||
else | |||||
$showMaxRows = $rowsFound; // otherwise show all rows | |||||
// Setup the basic RTF document structure (RTF functions defined in 'MINIMALRTF.php'): | |||||
$rtf = new MINIMALRTF(); // initialize RTF object | |||||
$rtfData = $rtf->openRtf(); // create RTF opening tag | |||||
$rtf->createFontBlock(0, "Arial"); // create & set RTF font blocks | |||||
$rtf->createFontBlock(1, "Times New Roman"); | |||||
$rtfData .= $rtf->setFontBlock(); | |||||
// Header: | |||||
if (!empty($headerMsg)) | |||||
{ | |||||
// Remove any colon (":") from end of header message: | |||||
$headerMsg = trimTextPattern($headerMsg, ":", false, true); // function 'trimTextPattern()' is defined in 'include.inc.php' | |||||
// Decode any HTML entities: | |||||
// (these may occur in the header message e.g. if the user's preferred display language is not English but German or French, etc) | |||||
$headerMsg = decodeHTML($contentTypeCharset, $headerMsg); // function 'decodeHTML()' is defined in 'include.inc.php', and '$contentTypeCharset' is defined in 'ini.inc.php' | |||||
// Convert refbase markup in the header message into appropriate RTF markup & entities: | |||||
$headerMsg = searchReplaceText($transtab_refbase_rtf, $headerMsg, true); // function 'searchReplaceText()' is defined in 'include.inc.php' | |||||
$rtfData .= "{\header\pard\qc $headerMsg\par}\n"; | |||||
} | |||||
$rtfData .= $rtf->justify("full", 0.5, 0, -0.5); // by default, we'll justify text and set a hanging indent (left indent: 0.5, right indent: 0, first-line indent: -0.5) | |||||
// LOOP OVER EACH RECORD: | |||||
// Fetch one page of results (or less if on the last page) | |||||
// (i.e., upto the limit specified in $showMaxRows) fetch a row into the $row array and ... | |||||
for ($rowCounter=0; (($rowCounter < $showMaxRows) && ($row = @ mysqli_fetch_array($result))); $rowCounter++) | |||||
{ | |||||
foreach ($row as $rowFieldName => $rowFieldValue) | |||||
// Apply search & replace 'actions' to all fields that are listed in the 'fields' element of the arrays contained in '$rtfSearchReplaceActionsArray': | |||||
foreach ($rtfSearchReplaceActionsArray as $fieldActionsArray) | |||||
if (in_array($rowFieldName, $fieldActionsArray['fields'])) | |||||
$row[$rowFieldName] = searchReplaceText($fieldActionsArray['actions'], $row[$rowFieldName], true); // function 'searchReplaceText()' is defined in 'include.inc.php' | |||||
// Order attributes according to the chosen output style & record type: | |||||
$record = citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, false); // function 'citeRecord()' is defined in the citation style file given in '$citeStyleFile' (which, in turn, must reside in the 'cite' directory of the refbase root directory), see function 'generateCitations()' | |||||
// Print out the current record: | |||||
if (!empty($record)) // unless the record buffer is empty... | |||||
{ | |||||
// Print any section heading(s): | |||||
if (preg_match("/year|type/i", $citeOrder)) | |||||
{ | |||||
$headingPrefix = $rtf->justify("left", 0, 0, 0) // left-align the current heading without any indents | |||||
. $rtf->paragraph(0, 12); // create empty paragraph in front of heading using "Arial" (font block 0) and a font size of 12pt | |||||
$headingSuffix = $rtf->justify("full", 0.5, 0, -0.5); // justify any following text and set a hanging indent (left indent: 0.5, right indent: 0, first-line indent: -0.5) | |||||
if ($citeOrder == "type") // for 'citeOrder=type' we'll always print an empty paragraph after the heading | |||||
$headingSuffix .= $rtf->paragraph(0, 12); // create empty paragraph using "Arial" (font block 0) and a font size of 12pt | |||||
list($yearsArray, $typeTitlesArray, $sectionHeading) = generateSectionHeading($yearsArray, $typeTitlesArray, $row, $citeOrder, $headingPrefix, $headingSuffix, "{\\f0\\fs28 {\b ", "}\par}\n", "{\\f0\\fs24 {\b ", "}\par}\n"); // function 'generateSectionHeading()' is defined in 'cite.inc.php' | |||||
// Note that we pass raw RTF commands to the above function instead of using the 'textBlock()' function from 'MINIMALRTF.php'. This is due to a current limitation of the 'generateSectionHeading()' function. | |||||
// For 'citeOrder=year', the appropriate call to the 'textBlock()' function would look like this: | |||||
// $rtfData .= $rtf->textBlock(0, 14, $rtf->bold($row['year'])); // create major heading with the current year using "Arial" (font block 0) and a font size of 14pt, printed in bold | |||||
$rtfData .= $sectionHeading; | |||||
} | |||||
// If character encoding is not UTF-8 already, convert record text to UTF-8: | |||||
if ($contentTypeCharset != "UTF-8") | |||||
$record = convertToCharacterEncoding("UTF-8", "IGNORE", $record); // function 'convertToCharacterEncoding()' is defined in 'include.inc.php' | |||||
// Encode characters with an ASCII value of >= 128 in RTF 1.16 unicode format: | |||||
$recordUnicodeCharEncoded = $rtf->utf8_2_unicode($record); // converts UTF-8 chars to unicode character codes | |||||
// Write RTF paragraph: | |||||
$rtfData .= $rtf->textBlock(1, 12, $recordUnicodeCharEncoded); // create text block with encoded record text using "Times New Roman" (font block 1) and a font size of 12pt | |||||
} | |||||
} | |||||
$rtfData .= $rtf->closeRtf(); // create RTF closing tag | |||||
return $rtfData; | |||||
} | |||||
// --- END CITATION FORMAT --- | |||||
?> |
@ -0,0 +1,678 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./cite/styles/cite_AMA.php | |||||
// Repository: $HeadURL$ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> and | |||||
// Richard Karnesky <mailto:karnesky@gmail.com> | |||||
// | |||||
// Created: 25-Feb-08, 20:05 | |||||
// Modified: $Date: 2012-02-27 20:25:30 +0000 (Mon, 27 Feb 2012) $ | |||||
// $Author$ | |||||
// $Revision: 1337 $ | |||||
// This is a citation style file (which must reside within the 'cite/styles/' sub-directory of your refbase root directory). It contains a | |||||
// version of the 'citeRecord()' function that outputs a reference list from selected records according to the citation style used by | |||||
// the American Medical Association (AMA) | |||||
// based on 'cite_Chicago.php' | |||||
// TODO: - abstracts, conference proceedings, patents, reports | |||||
// - book/volume/report/etc titles should be formatted in heading caps | |||||
// - don't add a dot if the abbreviated journal (or series title) ends with a dot! | |||||
// -------------------------------------------------------------------- | |||||
// --- BEGIN CITATION STYLE --- | |||||
function citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, $encodeHTML) | |||||
{ | |||||
$record = ""; // make sure that our buffer variable is empty | |||||
// --- BEGIN TYPE = JOURNAL ARTICLE / MAGAZINE ARTICLE / NEWSPAPER ARTICLE -------------------------------------------------------------- | |||||
if (preg_match("/^(Journal Article|Magazine Article|Newspaper Article)$/", $row['type'])) | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($row['author'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", ", // 5. | |||||
"/ *, */", // 6. | |||||
" ", // 7. | |||||
" ", // 8. | |||||
"", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"6", // 13. | |||||
"3", // 14. | |||||
", et al.", // 15. | |||||
$encodeHTML // 16. | |||||
); | |||||
if (!preg_match("/\. *$/", $author)) | |||||
$record .= $author . "."; | |||||
else | |||||
$record .= $author; | |||||
} | |||||
if (!empty($row['title'])) // title | |||||
{ | |||||
if (!empty($row['author'])) | |||||
$record .= " "; | |||||
$record .= $row['title']; | |||||
} | |||||
// From here on we'll assume that at least either the 'author' or the 'title' field did contain some contents | |||||
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below) | |||||
if (!preg_match("/[?!.] *$/", $record)) | |||||
$record .= "."; | |||||
if (!empty($row['abbrev_journal'])) // abbreviated journal name | |||||
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['abbrev_journal'] . $markupPatternsArray["italic-suffix"]; | |||||
// if there's no abbreviated journal name, we'll use the full journal name | |||||
elseif (!empty($row['publication'])) // publication (= journal) name | |||||
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['publication'] . $markupPatternsArray["italic-suffix"]; | |||||
if (preg_match("/^(Magazine Article|Newspaper Article)$/", $row['type']) AND !preg_match("/^\d+$/", $row['volume'])) // for newspaper articles (and magazine articles if w/o volume number), volume (=month) and issue (=day) information is printed before the year | |||||
{ | |||||
if (!empty($row['volume'])) // volume (=month) | |||||
$record .= ". " . $row['volume']; | |||||
if (!empty($row['issue'])) // issue (=day) | |||||
$record .= " " . $row['issue']; | |||||
if (!empty($row['year'])) // year | |||||
$record .= ", " . $row['year']; | |||||
} | |||||
else // journal article (or a magazine article with volume numbers) | |||||
{ | |||||
if (!empty($row['year'])) // year | |||||
$record .= ". " . $row['year']; | |||||
if (!empty($row['volume']) || !empty($row['issue'])) | |||||
$record .= ";"; | |||||
if (!empty($row['volume'])) // volume | |||||
$record .= $row['volume']; | |||||
if (!empty($row['issue'])) // issue | |||||
$record .= "(" . $row['issue'] . ")"; | |||||
} | |||||
if (!empty($row['pages'])) // pages | |||||
{ | |||||
if (!empty($row['year']) || !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add ": " if either year, volume, issue, abbrev_journal or publication isn't empty | |||||
$record .= ":"; | |||||
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"]); // function 'formatPageInfo()' is defined in 'cite.inc.php' | |||||
} | |||||
if ($row['online_publication'] == "yes") // this record refers to an online article | |||||
{ | |||||
// append an optional string (given in 'online_citation') plus the current date and the DOI (or URL): | |||||
$today = date("F j, Y"); | |||||
if (!empty($row['online_citation'])) // online_citation | |||||
{ | |||||
if (!empty($row['year']) || !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add ":" or "," if either year, volume, issue, abbrev_journal or publication isn't empty | |||||
{ | |||||
if (empty($row['pages'])) | |||||
$record .= ":"; // print instead of pages | |||||
else | |||||
$record .= ","; // append to pages | |||||
} | |||||
$record .= $row['online_citation']; | |||||
} | |||||
if (!empty($row['doi'])) // doi | |||||
{ | |||||
if (!empty($row['online_citation']) OR (empty($row['online_citation']) AND (!empty($row['year']) || !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])))) // only add "." if online_citation isn't empty, or else if either year, volume, issue, abbrev_journal or publication isn't empty | |||||
$record .= "."; | |||||
if ($encodeHTML) | |||||
$record .= " " . encodeHTML("http://dx.doi.org/" . $row['doi']) . ". Accessed " . $today; | |||||
else | |||||
$record .= " " . "http://dx.doi.org/" . $row['doi'] . ". Accessed " . $today; | |||||
} | |||||
elseif (!empty($row['url'])) // url | |||||
{ | |||||
if (!empty($row['online_citation']) OR (empty($row['online_citation']) AND (!empty($row['year']) || !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])))) // only add "." if online_citation isn't empty, or else if either year, volume, issue, abbrev_journal or publication isn't empty | |||||
$record .= "."; | |||||
if ($encodeHTML) | |||||
$record .= " " . encodeHTML($row['url']) . ". Accessed " . $today; | |||||
else | |||||
$record .= " " . $row['url'] . ". Accessed " . $today; | |||||
} | |||||
} | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
} | |||||
// --- BEGIN TYPE = ABSTRACT / BOOK CHAPTER / CONFERENCE ARTICLE ------------------------------------------------------------------------ | |||||
elseif (preg_match("/^(Abstract|Book Chapter|Conference Article)$/", $row['type'])) | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($row['author'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", ", // 5. | |||||
"/ *, */", // 6. | |||||
" ", // 7. | |||||
" ", // 8. | |||||
"", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"6", // 13. | |||||
"3", // 14. | |||||
", et al.", // 15. | |||||
$encodeHTML // 16. | |||||
); | |||||
if (!preg_match("/\. *$/", $author)) | |||||
$record .= $author . "."; | |||||
else | |||||
$record .= $author; | |||||
} | |||||
if (!empty($row['title'])) // title | |||||
{ | |||||
if (!empty($row['author'])) | |||||
$record .= " "; | |||||
$record .= $row['title']; | |||||
} | |||||
if ($row['type'] == "Abstract") // for abstracts, add "[abstract]" label | |||||
$record .= " [abstract]"; | |||||
// From here on we'll assume that at least either the 'author' or the 'title' field did contain some contents | |||||
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below) | |||||
if (!empty($row['editor'])) // editor | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$editor = reArrangeAuthorContents($row['editor'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", ", // 5. | |||||
"/ *, */", // 6. | |||||
" ", // 7. | |||||
" ", // 8. | |||||
"", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"6", // 13. | |||||
"3", // 14. | |||||
", et al.", // 15. | |||||
$encodeHTML // 16. | |||||
); | |||||
if (!preg_match("/[?!.] *$/", $record)) | |||||
$record .= "."; | |||||
$record .= " In: " . $editor . ", "; | |||||
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';') | |||||
$record .= "eds"; | |||||
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s]) | |||||
$record .= "ed"; | |||||
} | |||||
$publication = preg_replace("/[ \r\n]*\(Eds?:[^\)\r\n]*\)/i", "", $row['publication']); | |||||
if (!empty($publication)) // publication | |||||
{ | |||||
if (!preg_match("/[?!.] *$/", $record)) | |||||
$record .= "."; | |||||
if (empty($row['editor'])) | |||||
$record .= " In:"; | |||||
// TODO: container titles should be formatted in heading caps, however, this doesn't yet work correctly if the publication title contains HTML entities | |||||
$record .= " " . $markupPatternsArray["italic-prefix"] . $publication . $markupPatternsArray["italic-suffix"]; | |||||
// $record .= " " . $markupPatternsArray["italic-prefix"] . changeCase("heading", $publication) . $markupPatternsArray["italic-suffix"]; // function 'changeCase()' is defined in 'include.inc.php' | |||||
} | |||||
if (!empty($row['volume'])) // volume | |||||
{ | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
$record .= " Vol. " . $row['volume']; | |||||
} | |||||
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // edition | |||||
{ | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd ed.") | |||||
{ | |||||
if ($row['edition'] == "2") | |||||
$editionSuffix = "nd"; | |||||
elseif ($row['edition'] == "3") | |||||
$editionSuffix = "rd"; | |||||
else | |||||
$editionSuffix = "th"; | |||||
} | |||||
else | |||||
$editionSuffix = ""; | |||||
if (!preg_match("/( ed\.?| edition)$/i", $row['edition'])) | |||||
$editionSuffix .= " ed."; | |||||
$record .= " " . $row['edition'] . $editionSuffix; | |||||
} | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
if (!empty($row['place'])) // place | |||||
$record .= " " . $row['place']; | |||||
if (!empty($row['publisher'])) // publisher | |||||
{ | |||||
if (!empty($row['place'])) | |||||
$record .= ":"; | |||||
$record .= " " . $row['publisher']; | |||||
} | |||||
if (!empty($row['year'])) // year | |||||
$record .= "; " . $row['year']; | |||||
if (!empty($row['pages'])) // pages | |||||
$record .= ":" . formatPageInfo($row['pages'], $markupPatternsArray["endash"]); // function 'formatPageInfo()' is defined in 'cite.inc.php' | |||||
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title | |||||
{ | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
$record .= " "; | |||||
if (!empty($row['abbrev_series_title'])) | |||||
$record .= $row['abbrev_series_title']; // abbreviated series title | |||||
// if there's no abbreviated series title, we'll use the full series title instead: | |||||
elseif (!empty($row['series_title'])) | |||||
$record .= $row['series_title']; // full series title | |||||
if (!empty($row['series_volume'])||!empty($row['series_issue'])) | |||||
$record .= " "; | |||||
if (!empty($row['series_volume'])) // series volume | |||||
$record .= $row['series_volume']; | |||||
if (!empty($row['series_issue'])) // series issue (I'm not really sure if -- for this cite style -- the series issue should be rather omitted here) | |||||
$record .= "(" . $row['series_issue'] . ")"; // is it correct to format series issues similar to journal article issues? | |||||
} | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
} | |||||
// --- BEGIN TYPE = BOOK WHOLE / CONFERENCE VOLUME / JOURNAL / MANUAL / MANUSCRIPT / MAP / MISCELLANEOUS / PATENT / REPORT / SOFTWARE --- | |||||
else // if (preg_match("/Book Whole|Conference Volume|Journal|Manual|Manuscript|Map|Miscellaneous|Patent|Report|Software/", $row['type'])) | |||||
// note that this also serves as a fallback: unrecognized resource types will be formatted similar to whole books | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
$author = preg_replace("/[ \r\n]*\(eds?\)/i", "", $row['author']); | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($author, // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", ", // 5. | |||||
"/ *, */", // 6. | |||||
" ", // 7. | |||||
" ", // 8. | |||||
"", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"6", // 13. | |||||
"3", // 14. | |||||
", et al.", // 15. | |||||
$encodeHTML // 16. | |||||
); | |||||
// if the author is actually the editor of the resource we'll append ', ed' (or ', eds') to the author string: | |||||
// [to distinguish editors from authors in the 'author' field, the 'modify.php' script does append ' (ed)' or ' (eds)' if appropriate, | |||||
// so we're just checking for these identifier strings here. Alternatively, we could check whether the editor field matches the author field] | |||||
if (preg_match("/[ \r\n]*\(ed\)/", $row['author'])) // single editor | |||||
$author = $author . ", ed"; | |||||
elseif (preg_match("/[ \r\n]*\(eds\)/", $row['author'])) // multiple editors | |||||
$author = $author . ", eds"; | |||||
if (!preg_match("/\. *$/", $author)) | |||||
$record .= $author . "."; | |||||
else | |||||
$record .= $author; | |||||
} | |||||
if (!empty($row['title'])) // title | |||||
{ | |||||
if (!empty($row['author'])) | |||||
$record .= " "; | |||||
// TODO: book/volume/report/etc titles should be formatted in heading caps, however, this doesn't yet work correctly if the publication title contains HTML entities | |||||
$record .= $markupPatternsArray["italic-prefix"] . $row['title'] . $markupPatternsArray["italic-suffix"]; | |||||
// $record .= $markupPatternsArray["italic-prefix"] . changeCase("heading", $row['title']) . $markupPatternsArray["italic-suffix"]; // function 'changeCase()' is defined in 'include.inc.php' | |||||
} | |||||
if ($row['type'] == "Software") // for software, add software label | |||||
$record .= " [computer program]"; | |||||
if (!empty($row['volume']) AND ($row['type'] != "Software")) // volume | |||||
{ | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
$record .= " Vol. " . $row['volume']; | |||||
} | |||||
if (!empty($row['edition'])) // edition | |||||
{ | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
if ($row['type'] == "Software") // software edition (=version) | |||||
{ | |||||
$record .= " Version " . $row['edition']; | |||||
} | |||||
elseif (!preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // edition | |||||
{ | |||||
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd ed.") | |||||
{ | |||||
if ($row['edition'] == "2") | |||||
$editionSuffix = "nd"; | |||||
elseif ($row['edition'] == "3") | |||||
$editionSuffix = "rd"; | |||||
else | |||||
$editionSuffix = "th"; | |||||
} | |||||
else | |||||
$editionSuffix = ""; | |||||
if (!preg_match("/( ed\.?| edition)$/i", $row['edition'])) | |||||
$editionSuffix .= " ed."; | |||||
$record .= " " . $row['edition'] . $editionSuffix; | |||||
} | |||||
} | |||||
if (!empty($row['editor']) && !preg_match("/[ \r\n]*\(eds?\)/", $row['author'])) // editor (if different from author, see note above regarding the check for ' (ed)' or ' (eds)') | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$editor = reArrangeAuthorContents($row['editor'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", ", // 5. | |||||
"/ *, */", // 6. | |||||
" ", // 7. | |||||
" ", // 8. | |||||
"", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"6", // 13. | |||||
"3", // 14. | |||||
", et al.", // 15. | |||||
$encodeHTML // 16. | |||||
); | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
$record .= " " . $editor; | |||||
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';') | |||||
$record .= ", eds"; | |||||
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s]) | |||||
$record .= ", ed"; | |||||
} | |||||
if (!empty($row['thesis'])) // thesis | |||||
// TODO: do we need to use the term "[dissertation]" instead of "[Ph.D. thesis]", etc? What about other thesis types then? | |||||
$record .= " [" . $row['thesis'] . "]"; | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
if (!empty($row['place'])) // place | |||||
$record .= " " . $row['place']; | |||||
if (!empty($row['publisher'])) // publisher | |||||
{ | |||||
if (!empty($row['place'])) | |||||
$record .= ":"; | |||||
$record .= " " . $row['publisher']; | |||||
} | |||||
$record .= ";"; | |||||
if ($row['type'] == "Software") // for software, volume (=month) and issue (=day) information is printed before the year (similar to newspaper articles) | |||||
{ | |||||
if (!empty($row['volume'])) // volume (=month) | |||||
$record .= " " . $row['volume']; | |||||
if (!empty($row['issue'])) // issue (=day) | |||||
$record .= " " . $row['issue']; | |||||
$record .= ","; | |||||
} | |||||
if (!empty($row['year'])) // year | |||||
$record .= " " . $row['year']; | |||||
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title | |||||
{ | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
$record .= " "; | |||||
if (!empty($row['abbrev_series_title'])) | |||||
$record .= $row['abbrev_series_title']; // abbreviated series title | |||||
// if there's no abbreviated series title, we'll use the full series title instead: | |||||
elseif (!empty($row['series_title'])) | |||||
$record .= $row['series_title']; // full series title | |||||
if (!empty($row['series_volume'])||!empty($row['series_issue'])) | |||||
$record .= " "; | |||||
if (!empty($row['series_volume'])) // series volume | |||||
$record .= $row['series_volume']; | |||||
if (!empty($row['series_issue'])) // series issue (I'm not really sure if -- for this cite style -- the series issue should be rather omitted here) | |||||
$record .= "(" . $row['series_issue'] . ")"; // is it correct to format series issues similar to journal article issues? | |||||
} | |||||
if ($row['online_publication'] == "yes" || $row['type'] == "Software") // this record refers to an online article, or a computer program/software | |||||
{ | |||||
// append an optional string (given in 'online_citation') plus the current date and the DOI (or URL): | |||||
$today = date("F j, Y"); | |||||
if (!empty($row['online_citation'])) // online_citation | |||||
{ | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
$record .= $row['online_citation']; | |||||
} | |||||
if (!empty($row['doi'])) // doi | |||||
{ | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
if ($encodeHTML) | |||||
$record .= " " . encodeHTML("http://dx.doi.org/" . $row['doi']) . ". Accessed " . $today; | |||||
else | |||||
$record .= " " . "http://dx.doi.org/" . $row['doi'] . ". Accessed " . $today; | |||||
} | |||||
elseif (!empty($row['url'])) // url | |||||
{ | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
if ($encodeHTML) | |||||
$record .= " " . encodeHTML($row['url']) . ". Accessed " . $today; | |||||
else | |||||
$record .= " " . $row['url'] . ". Accessed " . $today; | |||||
} | |||||
} | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
} | |||||
// --- BEGIN POST-PROCESSING ----------------------------------------------------------------------------------------------------------- | |||||
// do some further cleanup: | |||||
$record = trim($record); // remove any preceding or trailing whitespace | |||||
return $record; | |||||
} | |||||
// --- END CITATION STYLE --- | |||||
?> |
@ -0,0 +1,699 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./cite/styles/cite_APA.php | |||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/cite/styles/cite_APA.php $ | |||||
// Author(s): Richard Karnesky <mailto:karnesky@gmail.com> and | |||||
// Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 06-Nov-06, 13:00 | |||||
// Modified: $Date: 2012-02-27 20:25:30 +0000 (Mon, 27 Feb 2012) $ | |||||
// $Author: msteffens $ | |||||
// $Revision: 1337 $ | |||||
// This is a citation style file (which must reside within the 'cite/styles/' sub-directory of your refbase root directory). It contains a | |||||
// version of the 'citeRecord()' function that outputs a reference list from selected records according to the citation style used by | |||||
// the APA | |||||
// based on 'cite_AnnGlaciol_JGlaciol.php' | |||||
// TODO: - magazine articles, conference proceedings, patents & reports? | |||||
// -------------------------------------------------------------------- | |||||
// --- BEGIN CITATION STYLE --- | |||||
function citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, $encodeHTML) | |||||
{ | |||||
$record = ""; // make sure that our buffer variable is empty | |||||
// --- BEGIN TYPE = JOURNAL ARTICLE / MAGAZINE ARTICLE / NEWSPAPER ARTICLE -------------------------------------------------------------- | |||||
if (preg_match("/^(Journal Article|Magazine Article|Newspaper Article)$/", $row['type'])) | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($row['author'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", " . $markupPatternsArray["ampersand"] . " ", // 5. | |||||
"/ *, */", // 6. | |||||
", ", // 7. | |||||
", ", // 8. | |||||
". ", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"6", // 13. | |||||
"6", // 14. | |||||
", et al.", // 15. | |||||
$encodeHTML); // 16. | |||||
if (!preg_match("/\. *$/", $author)) | |||||
$record .= $author . "."; | |||||
else | |||||
$record .= $author; | |||||
} | |||||
if (!empty($row['year']) || !empty($row['volume']) || !empty($row['issue'])) | |||||
{ | |||||
if (!empty($row['author'])) | |||||
$record .= " "; | |||||
$record .= "("; | |||||
if (!empty($row['year'])) // year | |||||
$record .= $row['year']; | |||||
if ($row['type'] == "Newspaper Article") // for newspaper articles, volume (=month) and issue (=day) information is printed after the year | |||||
{ | |||||
if (!empty($row['year']) && (!empty($row['volume']) || !empty($row['issue']))) | |||||
$record .= ","; | |||||
if (!empty($row['volume'])) // volume (=month) | |||||
$record .= " " . $row['volume']; | |||||
if (!empty($row['issue'])) // issue (=day) | |||||
$record .= " " . $row['issue']; | |||||
} | |||||
$record .= ")."; | |||||
} | |||||
if (!empty($row['title'])) // title | |||||
{ | |||||
if (!empty($row['author']) || !empty($row['year'])) | |||||
$record .= " "; | |||||
$record .= $row['title']; | |||||
if (!preg_match("/[?!.]$/", $row['title'])) | |||||
$record .= "."; | |||||
} | |||||
// From here on we'll assume that at least one of the fields 'author', 'year' or 'title' did contain some contents | |||||
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below) | |||||
if (!empty($row['abbrev_journal'])) // abbreviated journal name | |||||
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['abbrev_journal'] . $markupPatternsArray["italic-suffix"]; | |||||
// if there's no abbreviated journal name, we'll use the full journal name | |||||
elseif (!empty($row['publication'])) // publication (= journal) name | |||||
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['publication'] . $markupPatternsArray["italic-suffix"]; | |||||
if (preg_match("/^(Journal Article|Magazine Article)$/", $row['type'])) // for journal and magazine articles, volume and issue information is printed after the publication name | |||||
{ | |||||
if (!empty($row['abbrev_journal']) || !empty($row['publication'])) | |||||
$record .= ", "; | |||||
if (!empty($row['volume'])) // volume | |||||
$record .= $markupPatternsArray["italic-prefix"] . $row['volume'] . $markupPatternsArray["italic-suffix"]; | |||||
if (!empty($row['issue'])) // issue | |||||
$record .= "(" . $row['issue'] . ")"; | |||||
} | |||||
if ($row['online_publication'] == "yes") // this record refers to an online article | |||||
{ | |||||
// instead of any pages info (which normally doesn't exist for online publications) we append | |||||
// an optional string (given in 'online_citation') plus the current date and the DOI (or URL): | |||||
$today = date("F j, Y"); | |||||
if (!empty($row['online_citation'])) // online_citation | |||||
{ | |||||
if (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add "," if either volume, issue, abbrev_journal or publication isn't empty | |||||
$record .= ","; | |||||
$record .= " " . $row['online_citation']; | |||||
} | |||||
if (!empty($row['doi'])) // doi | |||||
{ | |||||
if (!empty($row['online_citation']) OR (empty($row['online_citation']) AND (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])))) // only add "." if online_citation isn't empty, or else if either volume, issue, abbrev_journal or publication isn't empty | |||||
$record .= "."; | |||||
if ($encodeHTML) | |||||
$record .= " Retrieved " . $today . ", from " . encodeHTML("http://dx.doi.org/" . $row['doi']); | |||||
else | |||||
$record .= " Retrieved " . $today . ", from http://dx.doi.org/" . $row['doi']; | |||||
} | |||||
elseif (!empty($row['url'])) // url | |||||
{ | |||||
if (!empty($row['online_citation']) OR (empty($row['online_citation']) AND (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])))) // only add "." if online_citation isn't empty, or else if either volume, issue, abbrev_journal or publication isn't empty | |||||
$record .= "."; | |||||
if ($encodeHTML) | |||||
$record .= " Retrieved " . $today . ", from " . encodeHTML($row['url']); | |||||
else | |||||
$record .= " Retrieved " . $today . ", from " . $row['url']; | |||||
} | |||||
} | |||||
else // $row['online_publication'] == "no" -> this record refers to a printed article, so we append any pages info instead: | |||||
{ | |||||
if (!empty($row['pages'])) // pages | |||||
{ | |||||
if (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add ", " if either volume, issue, abbrev_journal or publication isn't empty | |||||
$record .= ", "; | |||||
if ($row['type'] == "Newspaper Article") // for newspaper articles, we prefix page numbers with "p." or "pp." | |||||
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p. ", "pp. "); // function 'formatPageInfo()' is defined in 'cite.inc.php' | |||||
else | |||||
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"]); | |||||
} | |||||
} | |||||
if (!preg_match("/\. *$/", $record) && !($row['online_publication'] == "yes" && (!empty($row['doi']) || !empty($row['url'])))) // if the string doesn't end with a period or a DOI/URL | |||||
$record .= "."; | |||||
} | |||||
// --- BEGIN TYPE = ABSTRACT / BOOK CHAPTER / CONFERENCE ARTICLE ------------------------------------------------------------------------ | |||||
elseif (preg_match("/^(Abstract|Book Chapter|Conference Article)$/", $row['type'])) | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($row['author'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", " . $markupPatternsArray["ampersand"] . " ", // 5. | |||||
"/ *, */", // 6. | |||||
", ", // 7. | |||||
", ", // 8. | |||||
". ", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"6", // 13. | |||||
"6", // 14. | |||||
", et al.", // 15. | |||||
$encodeHTML); // 16. | |||||
if (!preg_match("/\. *$/", $author)) | |||||
$record .= $author . "."; | |||||
else | |||||
$record .= $author; | |||||
} | |||||
if (!empty($row['year'])) // year | |||||
{ | |||||
if (!empty($row['author'])) | |||||
$record .= " "; | |||||
$record .= "(" . $row['year'] . ")."; | |||||
} | |||||
if (!empty($row['title'])) // title | |||||
{ | |||||
if (!empty($row['author']) || !empty($row['year'])) | |||||
$record .= " "; | |||||
$record .= $row['title']; | |||||
if (!preg_match("/[?!.]$/", $row['title'])) | |||||
$record .= "."; | |||||
} | |||||
// From here on we'll assume that at least one of the fields 'author', 'year' or 'title' did contain some contents | |||||
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below) | |||||
if (!empty($row['editor'])) // editor | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$editor = reArrangeAuthorContents($row['editor'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", " . $markupPatternsArray["ampersand"] . " ", // 5. | |||||
"/ *, */", // 6. | |||||
" ", // 7. | |||||
" ", // 8. | |||||
". ", // 9. | |||||
true, // 10. | |||||
true, // 11. | |||||
true, // 12. | |||||
"6", // 13. | |||||
"6", // 14. | |||||
", et al.", // 15. | |||||
$encodeHTML); // 16. | |||||
$record .= " In " . $editor . " ("; | |||||
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';') | |||||
$record .= "Eds."; | |||||
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s]) | |||||
$record .= "Ed."; | |||||
$record .= "),"; | |||||
} | |||||
$publication = preg_replace("/[ \r\n]*\(Eds?:[^\)\r\n]*\)/i", "", $row['publication']); | |||||
if (!empty($publication)) // publication | |||||
{ | |||||
if (empty($row['editor'])) | |||||
$record .= " In"; | |||||
$record .= " " . $markupPatternsArray["italic-prefix"] . $publication . $markupPatternsArray["italic-suffix"]; | |||||
} | |||||
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition']) || !empty($row['volume']) || !empty($row['pages'])) | |||||
{ | |||||
$record .= " ("; | |||||
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // edition | |||||
{ | |||||
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd ed.") | |||||
{ | |||||
if ($row['edition'] == "2") | |||||
$editionSuffix = "nd"; | |||||
elseif ($row['edition'] == "3") | |||||
$editionSuffix = "rd"; | |||||
else | |||||
$editionSuffix = "th"; | |||||
} | |||||
else | |||||
$editionSuffix = ""; | |||||
if (!empty($row['edition']) && !preg_match("/( ed\.?| edition)$/i", $row['edition'])) | |||||
$editionSuffix .= " ed."; | |||||
$record .= $row['edition'] . $editionSuffix; | |||||
} | |||||
if (!empty($row['volume'])) // volume | |||||
{ | |||||
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) | |||||
$record .= ", "; | |||||
$record .= "Vol. " . $row['volume']; | |||||
} | |||||
if (!empty($row['pages'])) // pages | |||||
{ | |||||
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition']) || !empty($row['volume'])) | |||||
$record .= ", "; | |||||
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p. ", "pp. "); // function 'formatPageInfo()' is defined in 'cite.inc.php' | |||||
} | |||||
$record .= ")"; | |||||
} | |||||
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title | |||||
{ | |||||
if (!preg_match("@[?!.][ " . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
$record .= " "; | |||||
if (!empty($row['abbrev_series_title'])) | |||||
$record .= $row['abbrev_series_title']; // abbreviated series title | |||||
// if there's no abbreviated series title, we'll use the full series title instead: | |||||
elseif (!empty($row['series_title'])) | |||||
$record .= $row['series_title']; // full series title | |||||
if (!empty($row['series_volume'])||!empty($row['series_issue'])) | |||||
$record .= ", "; | |||||
if (!empty($row['series_volume'])) // series volume (I'm not really sure if -- for this cite style -- the series volume & issue should be rather omitted here) | |||||
$record .= $row['series_volume']; | |||||
if (!empty($row['series_issue'])) // series issue (see note for series volume) | |||||
$record .= "(" . $row['series_issue'] . ")"; | |||||
} | |||||
$record .= "."; | |||||
if (!empty($row['place'])) // place | |||||
$record .= " " . $row['place']; | |||||
if (!empty($row['publisher'])) // publisher | |||||
{ | |||||
if (!empty($row['place'])) | |||||
$record .= ":"; | |||||
$record .= " " . $row['publisher']; | |||||
} | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
} | |||||
// --- BEGIN TYPE = BOOK WHOLE / CONFERENCE VOLUME / JOURNAL / MANUAL / MANUSCRIPT / MAP / MISCELLANEOUS / PATENT / REPORT / SOFTWARE --- | |||||
else // if (preg_match("/Book Whole|Conference Volume|Journal|Manual|Manuscript|Map|Miscellaneous|Patent|Report|Software/", $row['type'])) | |||||
// note that this also serves as a fallback: unrecognized resource types will be formatted similar to whole books | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
$author = preg_replace("/[ \r\n]*\(eds?\)/i", "", $row['author']); | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($author, // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", " . $markupPatternsArray["ampersand"] . " ", // 5. | |||||
"/ *, */", // 6. | |||||
", ", // 7. | |||||
", ", // 8. | |||||
". ", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"6", // 13. | |||||
"6", // 14. | |||||
", et al.", // 15. | |||||
$encodeHTML); // 16. | |||||
// if the author is actually the editor of the resource we'll append ', ed' (or ', eds') to the author string: | |||||
// [to distinguish editors from authors in the 'author' field, the 'modify.php' script does append ' (ed)' or ' (eds)' if appropriate, | |||||
// so we're just checking for these identifier strings here. Alternatively, we could check whether the editor field matches the author field] | |||||
if (preg_match("/[ \r\n]*\(ed\)/", $row['author'])) // single editor | |||||
$author = $author . " (Ed.)."; | |||||
elseif (preg_match("/[ \r\n]*\(eds\)/", $row['author'])) // multiple editors | |||||
$author = $author . " (Eds.)."; | |||||
if (!preg_match("/\. *$/", $author)) | |||||
$record .= $author . "."; | |||||
else | |||||
$record .= $author; | |||||
} | |||||
if (!empty($row['year'])) // year | |||||
{ | |||||
if (!empty($row['author'])) | |||||
$record .= " "; | |||||
$record .= "(" . $row['year'] . ")."; | |||||
} | |||||
if (!empty($row['title'])) // title | |||||
{ | |||||
if (!empty($row['author']) || !empty($row['year'])) | |||||
$record .= " "; | |||||
if ($row['type'] == "Software") // except for software, the title is printed in italics | |||||
$record .= $row['title']; | |||||
else | |||||
$record .= $markupPatternsArray["italic-prefix"] . $row['title'] . $markupPatternsArray["italic-suffix"]; | |||||
} | |||||
if (!empty($row['editor']) && !preg_match("/[ \r\n]*\(eds?\)/", $row['author'])) // editor (if different from author, see note above regarding the check for ' (ed)' or ' (eds)') | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$editor = reArrangeAuthorContents($row['editor'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", " . $markupPatternsArray["ampersand"] . " ", // 5. | |||||
"/ *, */", // 6. | |||||
" ", // 7. | |||||
" ", // 8. | |||||
". ", // 9. | |||||
true, // 10. | |||||
true, // 11. | |||||
true, // 12. | |||||
"6", // 13. | |||||
"6", // 14. | |||||
", et al.", // 15. | |||||
$encodeHTML); // 16. | |||||
if (!empty($row['author']) || !empty($row['year']) || !empty($row['title'])) | |||||
$record .= " "; | |||||
$record .= " (" . $editor . ", "; | |||||
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';') | |||||
$record .= "Eds."; | |||||
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s]) | |||||
$record .= "Ed."; | |||||
$record .= ")"; | |||||
} | |||||
if (!empty($row['edition']) || !empty($row['volume'])) | |||||
{ | |||||
if (!empty($row['author']) || !empty($row['year']) || !empty($row['title']) || (!empty($row['editor']) && !preg_match("/[ \r\n]*\(eds?\)/", $row['author']))) | |||||
$record .= " "; | |||||
$record .= "("; | |||||
if ($row['type'] == "Software") // software edition (=version) | |||||
{ | |||||
$record .= "Version " . $row['edition']; | |||||
} | |||||
elseif (!preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // regular edition (other than the first) | |||||
{ | |||||
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd ed.") | |||||
{ | |||||
if ($row['edition'] == "2") | |||||
$editionSuffix = "nd"; | |||||
elseif ($row['edition'] == "3") | |||||
$editionSuffix = "rd"; | |||||
else | |||||
$editionSuffix = "th"; | |||||
} | |||||
else | |||||
$editionSuffix = ""; | |||||
if (!empty($row['edition']) && !preg_match("/( ed\.?| edition)$/i", $row['edition'])) | |||||
$editionSuffix .= " ed."; | |||||
$record .= $row['edition'] . $editionSuffix; | |||||
} | |||||
if (!empty($row['volume'])) // volume | |||||
{ | |||||
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) | |||||
$record .= ", "; | |||||
$record .= "Vol. " . $row['volume']; | |||||
} | |||||
$record .= ")"; | |||||
} | |||||
if ($row['type'] == "Software") // for software, add software label | |||||
{ | |||||
$record .= " [Computer software]"; | |||||
} | |||||
else // add series info, thesis info, and publisher & place | |||||
{ | |||||
if ((!empty($row['title']) && !preg_match("/[?!.]$/", $row['title'])) || (!empty($row['editor']) && !preg_match("/[ \r\n]*\(eds?\)/", $row['author'])) || !empty($row['edition']) || !empty($row['volume'])) | |||||
$record .= "."; | |||||
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title | |||||
{ | |||||
$record .= " "; | |||||
if (!empty($row['abbrev_series_title'])) | |||||
$record .= $row['abbrev_series_title']; // abbreviated series title | |||||
// if there's no abbreviated series title, we'll use the full series title instead: | |||||
elseif (!empty($row['series_title'])) | |||||
$record .= $row['series_title']; // full series title | |||||
if (!empty($row['series_volume'])||!empty($row['series_issue'])) | |||||
$record .= ", "; | |||||
if (!empty($row['series_volume'])) // series volume (I'm not really sure if -- for this cite style -- the series volume & issue should be rather omitted here) | |||||
$record .= $row['series_volume']; | |||||
if (!empty($row['series_issue'])) // series issue (see note for series volume) | |||||
$record .= "(" . $row['series_issue'] . ")"; | |||||
$record .= "."; | |||||
} | |||||
if (!empty($row['thesis'])) // thesis | |||||
{ | |||||
$record .= " " . $row['thesis']; | |||||
$record .= ", " . $row['publisher']; | |||||
$record .= ", " . $row['place']; | |||||
} | |||||
else // not a thesis | |||||
{ | |||||
if (!empty($row['place'])) // place | |||||
$record .= " " . $row['place']; | |||||
if (!empty($row['publisher'])) // publisher | |||||
{ | |||||
if (!empty($row['place'])) | |||||
$record .= ":"; | |||||
if ($row['author'] == $row['publisher']) // in APA style, the string "Author" is used instead of the publisher's name when the author and publisher are identical | |||||
$record .= " Author"; | |||||
else | |||||
$record .= " " . $row['publisher']; | |||||
} | |||||
} | |||||
} | |||||
if ($row['online_publication'] == "yes" || $row['type'] == "Software") // this record refers to an online article, or a computer program/software | |||||
{ | |||||
if (!empty($row['online_citation'])) // online_citation | |||||
{ | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
$record .= " " . $row['online_citation']; | |||||
} | |||||
if (!empty($row['doi']) || !empty($row['url'])) | |||||
{ | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
if ($row['type'] == "Software") | |||||
{ | |||||
$record .= " Available from "; | |||||
} | |||||
else | |||||
{ | |||||
$today = date("F j, Y"); | |||||
$record .= " Retrieved " . $today . ", from "; | |||||
} | |||||
if (!empty($row['doi'])) // doi | |||||
{ | |||||
if ($encodeHTML) | |||||
$record .= encodeHTML("http://dx.doi.org/" . $row['doi']); | |||||
else | |||||
$record .= "http://dx.doi.org/" . $row['doi']; | |||||
} | |||||
elseif (!empty($row['url'])) // url | |||||
{ | |||||
if ($encodeHTML) | |||||
$record .= encodeHTML($row['url']); | |||||
else | |||||
$record .= $row['url']; | |||||
} | |||||
} | |||||
} | |||||
if (!preg_match("/\. *$/", $record) && !(($row['online_publication'] == "yes" || $row['type'] == "Software") && !empty($row['url']))) // if the string doesn't end with a period or no URL/DOI was given | |||||
$record .= "."; | |||||
} | |||||
// --- BEGIN POST-PROCESSING ----------------------------------------------------------------------------------------------------------- | |||||
// do some further cleanup: | |||||
$record = trim($record); // remove any preceding or trailing whitespace | |||||
return $record; | |||||
} | |||||
// --- END CITATION STYLE --- | |||||
?> |
@ -0,0 +1,471 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./cite/styles/cite_AnnGlaciol_JGlaciol.php | |||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/cite/styles/cite_AnnGlaciol_JGlaciol.php $ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 07-Sep-05, 14:53 | |||||
// Modified: $Date: 2012-02-27 20:25:30 +0000 (Mon, 27 Feb 2012) $ | |||||
// $Author: msteffens $ | |||||
// $Revision: 1337 $ | |||||
// This is a citation style file (which must reside within the 'cite/styles/' sub-directory of your refbase root directory). It contains a | |||||
// version of the 'citeRecord()' function that outputs a reference list from selected records according to the citation style used by | |||||
// the journals "Annals of Glaciology" and "Journal of Glaciology" (International Glaciological Society, www.igsoc.org). | |||||
// -------------------------------------------------------------------- | |||||
// --- BEGIN CITATION STYLE --- | |||||
function citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, $encodeHTML) | |||||
{ | |||||
$record = ""; // make sure that our buffer variable is empty | |||||
// --- BEGIN TYPE = JOURNAL ARTICLE / MAGAZINE ARTICLE / NEWSPAPER ARTICLE -------------------------------------------------------------- | |||||
if (preg_match("/^(Journal Article|Magazine Article|Newspaper Article)$/", $row['type'])) | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($row['author'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
" and ", // 5. | |||||
"/ *, */", // 6. | |||||
", ", // 7. | |||||
" ", // 8. | |||||
".", // 9. | |||||
false, // 10. | |||||
true, // 11. | |||||
true, // 12. | |||||
"6", // 13. | |||||
"1", // 14. | |||||
" " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15. | |||||
$encodeHTML); // 16. | |||||
if (!preg_match("/\. *$/", $author)) | |||||
$record .= $author . "."; | |||||
else | |||||
$record .= $author; | |||||
} | |||||
if (!empty($row['year'])) // year | |||||
{ | |||||
if (!empty($row['author'])) | |||||
$record .= " "; | |||||
$record .= $row['year'] . "."; | |||||
} | |||||
if (!empty($row['title'])) // title | |||||
{ | |||||
if (!empty($row['author']) || !empty($row['year'])) | |||||
$record .= " "; | |||||
$record .= $row['title']; | |||||
if (!preg_match("/[?!.]$/", $row['title'])) | |||||
$record .= "."; | |||||
} | |||||
// From here on we'll assume that at least one of the fields 'author', 'year' or 'title' did contain some contents | |||||
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below) | |||||
if (!empty($row['abbrev_journal'])) // abbreviated journal name | |||||
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['abbrev_journal'] . $markupPatternsArray["italic-suffix"]; | |||||
// if there's no abbreviated journal name, we'll use the full journal name | |||||
elseif (!empty($row['publication'])) // publication (= journal) name | |||||
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['publication'] . $markupPatternsArray["italic-suffix"]; | |||||
if (!empty($row['volume'])) // volume | |||||
{ | |||||
if (!empty($row['abbrev_journal']) || !empty($row['publication'])) | |||||
$record .= ","; | |||||
$record .= " " . $markupPatternsArray["bold-prefix"] . $row['volume'] . $markupPatternsArray["bold-suffix"]; | |||||
} | |||||
if (!empty($row['issue'])) // issue | |||||
$record .= "(" . $row['issue'] . ")"; | |||||
if ($row['online_publication'] == "yes") // this record refers to an online article | |||||
{ | |||||
// instead of any pages info (which normally doesn't exist for online publications) we append | |||||
// an optional string (given in 'online_citation') plus the DOI: | |||||
if (!empty($row['online_citation'])) // online_citation | |||||
{ | |||||
if (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add "," if either volume, issue, abbrev_journal or publication isn't empty | |||||
$record .= ","; | |||||
$record .= " " . $row['online_citation']; | |||||
} | |||||
if (!empty($row['doi'])) // doi | |||||
{ | |||||
if (!empty($row['online_citation']) OR (empty($row['online_citation']) AND (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])))) // only add "," if online_citation isn't empty, or else if either volume, issue, abbrev_journal or publication isn't empty | |||||
$record .= "."; | |||||
$record .= " (" . $row['doi'] . ".)"; | |||||
} | |||||
} | |||||
else // $row['online_publication'] == "no" -> this record refers to a printed article, so we append any pages info instead: | |||||
{ | |||||
if (!empty($row['pages'])) // pages | |||||
{ | |||||
if (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add "," if either volume, issue, abbrev_journal or publication isn't empty | |||||
$record .= ", "; | |||||
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"]); // function 'formatPageInfo()' is defined in 'cite.inc.php' | |||||
} | |||||
} | |||||
if (!preg_match("/\.\)? *$/", $record)) | |||||
$record .= "."; | |||||
} | |||||
// --- BEGIN TYPE = ABSTRACT / BOOK CHAPTER / CONFERENCE ARTICLE ------------------------------------------------------------------------ | |||||
elseif (preg_match("/^(Abstract|Book Chapter|Conference Article)$/", $row['type'])) | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($row['author'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
" and ", // 5. | |||||
"/ *, */", // 6. | |||||
", ", // 7. | |||||
" ", // 8. | |||||
".", // 9. | |||||
false, // 10. | |||||
true, // 11. | |||||
true, // 12. | |||||
"6", // 13. | |||||
"1", // 14. | |||||
" " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15. | |||||
$encodeHTML); // 16. | |||||
if (!preg_match("/\. *$/", $author)) | |||||
$record .= $author . "."; | |||||
else | |||||
$record .= $author; | |||||
} | |||||
if (!empty($row['year'])) // year | |||||
{ | |||||
if (!empty($row['author'])) | |||||
$record .= " "; | |||||
$record .= $row['year'] . "."; | |||||
} | |||||
if (!empty($row['title'])) // title | |||||
{ | |||||
if (!empty($row['author']) || !empty($row['year'])) | |||||
$record .= " "; | |||||
$record .= $row['title']; | |||||
if (!preg_match("/[?!.]$/", $row['title'])) | |||||
$record .= "."; | |||||
} | |||||
// From here on we'll assume that at least one of the fields 'author', 'year' or 'title' did contain some contents | |||||
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below) | |||||
if (!empty($row['editor'])) // editor | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$editor = reArrangeAuthorContents($row['editor'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
" and ", // 5. | |||||
"/ *, */", // 6. | |||||
", ", // 7. | |||||
" ", // 8. | |||||
".", // 9. | |||||
false, // 10. | |||||
true, // 11. | |||||
true, // 12. | |||||
"6", // 13. | |||||
"1", // 14. | |||||
" " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15. | |||||
$encodeHTML); // 16. | |||||
$record .= " " . $markupPatternsArray["italic-prefix"] . "In" . $markupPatternsArray["italic-suffix"] . " " . $editor; | |||||
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';') | |||||
$record .= ", " . $markupPatternsArray["italic-prefix"] . "eds" . $markupPatternsArray["italic-suffix"] . "."; | |||||
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s]) | |||||
$record .= ", " . $markupPatternsArray["italic-prefix"] . "ed" . $markupPatternsArray["italic-suffix"] . "."; | |||||
} | |||||
$publication = preg_replace("/[ \r\n]*\(Eds?:[^\)\r\n]*\)/i", "", $row['publication']); | |||||
if (!empty($publication)) // publication | |||||
$record .= " " . $markupPatternsArray["italic-prefix"] . $publication . $markupPatternsArray["italic-suffix"] . "."; | |||||
if (!empty($row['place'])) // place | |||||
$record .= " " . $row['place']; | |||||
if (!empty($row['publisher'])) // publisher | |||||
{ | |||||
if (!empty($row['place'])) | |||||
$record .= ","; | |||||
$record .= " " . $row['publisher']; | |||||
} | |||||
if (!empty($row['pages'])) // pages | |||||
{ | |||||
if (!empty($row['place']) || !empty($row['publisher'])) | |||||
$record .= ", "; | |||||
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"]); // function 'formatPageInfo()' is defined in 'cite.inc.php' | |||||
} | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title | |||||
{ | |||||
$record .= " ("; | |||||
if (!empty($row['abbrev_series_title'])) | |||||
$record .= $row['abbrev_series_title']; // abbreviated series title | |||||
// if there's no abbreviated series title, we'll use the full series title instead: | |||||
elseif (!empty($row['series_title'])) | |||||
$record .= $row['series_title']; // full series title | |||||
if (!empty($row['series_volume'])||!empty($row['series_issue'])) | |||||
$record .= " "; | |||||
if (!empty($row['series_volume'])) // series volume | |||||
$record .= $row['series_volume']; | |||||
if (!empty($row['series_issue'])) // series issue (I'm not really sure if -- for this cite style -- the series issue should be rather omitted here) | |||||
$record .= "(" . $row['series_issue'] . ")"; | |||||
$record .= ".)"; | |||||
} | |||||
} | |||||
// --- BEGIN TYPE = BOOK WHOLE / CONFERENCE VOLUME / JOURNAL / MANUAL / MANUSCRIPT / MAP / MISCELLANEOUS / PATENT / REPORT / SOFTWARE --- | |||||
else // if (preg_match("/Book Whole|Conference Volume|Journal|Manual|Manuscript|Map|Miscellaneous|Patent|Report|Software/", $row['type'])) | |||||
// note that this also serves as a fallback: unrecognized resource types will be formatted similar to whole books | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
$author = preg_replace("/[ \r\n]*\(eds?\)/i", "", $row['author']); | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($author, // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
" and ", // 5. | |||||
"/ *, */", // 6. | |||||
", ", // 7. | |||||
" ", // 8. | |||||
".", // 9. | |||||
false, // 10. | |||||
true, // 11. | |||||
true, // 12. | |||||
"6", // 13. | |||||
"1", // 14. | |||||
" " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15. | |||||
$encodeHTML); // 16. | |||||
// if the author is actually the editor of the resource we'll append ', ed' (or ', eds') to the author string: | |||||
// [to distinguish editors from authors in the 'author' field, the 'modify.php' script does append ' (ed)' or ' (eds)' if appropriate, | |||||
// so we're just checking for these identifier strings here. Alternatively, we could check whether the editor field matches the author field] | |||||
if (preg_match("/[ \r\n]*\(ed\)/", $row['author'])) // single editor | |||||
$author = $author . ", " . $markupPatternsArray["italic-prefix"] . "ed" . $markupPatternsArray["italic-suffix"]; | |||||
elseif (preg_match("/[ \r\n]*\(eds\)/", $row['author'])) // multiple editors | |||||
$author = $author . ", " . $markupPatternsArray["italic-prefix"] . "eds" . $markupPatternsArray["italic-suffix"]; | |||||
if (!preg_match("/\. *$/", $author)) | |||||
$record .= $author . "."; | |||||
else | |||||
$record .= $author; | |||||
} | |||||
if (!empty($row['year'])) // year | |||||
{ | |||||
if (!empty($row['author'])) | |||||
$record .= " "; | |||||
$record .= $row['year'] . "."; | |||||
} | |||||
if (!empty($row['title'])) // title | |||||
{ | |||||
if (!empty($row['author']) || !empty($row['year'])) | |||||
$record .= " "; | |||||
$record .= $markupPatternsArray["italic-prefix"] . $row['title'] . $markupPatternsArray["italic-suffix"]; | |||||
if (!preg_match("/[?!.]$/", $row['title'])) | |||||
$record .= "."; | |||||
} | |||||
if (!empty($row['thesis'])) // thesis | |||||
{ | |||||
$record .= " (" . $row['thesis']; | |||||
$record .= ", " . $row['publisher'] . ".)"; | |||||
} | |||||
else // not a thesis | |||||
{ | |||||
if (!empty($row['place'])) // place | |||||
$record .= " " . $row['place']; | |||||
if (!empty($row['publisher'])) // publisher | |||||
{ | |||||
if (!empty($row['place'])) | |||||
$record .= ","; | |||||
$record .= " " . $row['publisher']; | |||||
} | |||||
// if (!empty($row['pages'])) // pages | |||||
// { | |||||
// if (!empty($row['place']) || !empty($row['publisher'])) | |||||
// $record .= ", "; | |||||
// | |||||
// $record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"]); // function 'formatPageInfo()' is defined in 'cite.inc.php' | |||||
// } | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
} | |||||
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title | |||||
{ | |||||
$record .= " ("; | |||||
if (!empty($row['abbrev_series_title'])) | |||||
$record .= $row['abbrev_series_title']; // abbreviated series title | |||||
// if there's no abbreviated series title, we'll use the full series title instead: | |||||
elseif (!empty($row['series_title'])) | |||||
$record .= $row['series_title']; // full series title | |||||
if (!empty($row['series_volume'])||!empty($row['series_issue'])) | |||||
$record .= " "; | |||||
if (!empty($row['series_volume'])) // series volume | |||||
$record .= $row['series_volume']; | |||||
if (!empty($row['series_issue'])) // series issue (I'm not really sure if -- for this cite style -- the series issue should be rather omitted here) | |||||
$record .= "(" . $row['series_issue'] . ")"; | |||||
$record .= ".)"; | |||||
} | |||||
} | |||||
// --- BEGIN POST-PROCESSING ----------------------------------------------------------------------------------------------------------- | |||||
// do some further cleanup: | |||||
$record = trim($record); // remove any preceding or trailing whitespace | |||||
return $record; | |||||
} | |||||
// --- END CITATION STYLE --- | |||||
?> |
@ -0,0 +1,629 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./cite/styles/cite_Chicago.php | |||||
// Repository: $HeadURL$ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> and | |||||
// Richard Karnesky <mailto:karnesky@gmail.com> | |||||
// | |||||
// Created: 25-Feb-08, 20:05 | |||||
// Modified: $Date: 2012-02-27 20:25:30 +0000 (Mon, 27 Feb 2012) $ | |||||
// $Author$ | |||||
// $Revision: 1337 $ | |||||
// This is a citation style file (which must reside within the 'cite/styles/' sub-directory of your refbase root directory). It contains a | |||||
// version of the 'citeRecord()' function that outputs a reference list from selected records according to the citation style documented | |||||
// in the "Chicago Manual of Style" (2003), and Kate Turabian's "Manual for Writer's of Term Papers, Theses, and Dissertations" (1996) | |||||
// based on 'cite_MLA.php' | |||||
// TODO: - newspaper & magazine articles, conference proceedings, manuals, patents, reports, software -> see e.g. examples at <http://www.library.hbs.edu/guides/citationguide.pdf> | |||||
// - " and " vs. ", and "? | |||||
// -------------------------------------------------------------------- | |||||
// --- BEGIN CITATION STYLE --- | |||||
function citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, $encodeHTML) | |||||
{ | |||||
$record = ""; // make sure that our buffer variable is empty | |||||
// --- BEGIN TYPE = JOURNAL ARTICLE / MAGAZINE ARTICLE / NEWSPAPER ARTICLE -------------------------------------------------------------- | |||||
if (preg_match("/^(Journal Article|Magazine Article|Newspaper Article)$/", $row['type'])) | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($row['author'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", and ", // 5. | |||||
"/ *, */", // 6. | |||||
", ", // 7. | |||||
" ", // 8. | |||||
". ", // 9. | |||||
false, // 10. | |||||
true, // 11. | |||||
false, // 12. | |||||
"10", // 13. | |||||
"10", // 14. | |||||
" et al.", // 15. | |||||
$encodeHTML // 16. | |||||
); | |||||
if (!preg_match("/\. *$/", $author)) | |||||
$record .= $author . "."; | |||||
else | |||||
$record .= $author; | |||||
} | |||||
if (!empty($row['title'])) // title | |||||
{ | |||||
if (!empty($row['author'])) | |||||
$record .= " "; | |||||
$record .= '"' . $row['title']; | |||||
if (!preg_match("/[?!.]$/", $row['title'])) | |||||
$record .= "."; | |||||
$record .= '"'; | |||||
} | |||||
// From here on we'll assume that at least either the 'author' or the 'title' field did contain some contents | |||||
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below) | |||||
if (!empty($row['publication'])) // publication (= journal) name | |||||
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['publication'] . $markupPatternsArray["italic-suffix"]; | |||||
// if there's no full journal name, we'll use the abbreviated journal name | |||||
elseif (!empty($row['abbrev_journal'])) // abbreviated journal name | |||||
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['abbrev_journal'] . $markupPatternsArray["italic-suffix"]; | |||||
if (!empty($row['volume'])) // volume | |||||
$record .= " " . $row['volume']; | |||||
if (!empty($row['issue'])) // issue | |||||
$record .= ", no. " . $row['issue']; | |||||
if (!empty($row['year'])) // year | |||||
$record .= " (" . $row['year'] . ")"; | |||||
if (!empty($row['pages'])) // pages | |||||
{ | |||||
if (!empty($row['year']) || !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add ": " if either year, volume, issue, abbrev_journal or publication isn't empty | |||||
$record .= ": "; | |||||
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"]); // function 'formatPageInfo()' is defined in 'cite.inc.php' | |||||
} | |||||
if ($row['online_publication'] == "yes") // this record refers to an online article | |||||
{ | |||||
// append an optional string (given in 'online_citation') plus the current date and the DOI (or URL): | |||||
$today = date("F j, Y"); | |||||
if (!empty($row['online_citation'])) // online_citation | |||||
{ | |||||
if (!empty($row['year']) || !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add "," if either year, volume, issue, abbrev_journal or publication isn't empty | |||||
{ | |||||
if (empty($row['pages'])) | |||||
$record .= ":"; // print instead of pages | |||||
else | |||||
$record .= ","; // append to pages | |||||
} | |||||
$record .= " " . $row['online_citation']; | |||||
} | |||||
if (!empty($row['doi'])) // doi | |||||
{ | |||||
if (!empty($row['online_citation']) OR (empty($row['online_citation']) AND (!empty($row['year']) || !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])))) // only add "." if online_citation isn't empty, or else if either year, volume, issue, abbrev_journal or publication isn't empty | |||||
$record .= "."; // NOTE: some Chicago examples (e.g. <http://www.lib.berkeley.edu/instruct/guides/chicago-turabianstyle.pdf>) use a comma here (not sure what's correct) | |||||
if ($encodeHTML) | |||||
$record .= " " . encodeHTML("http://dx.doi.org/" . $row['doi']) . " (accessed " . $today . ")"; | |||||
else | |||||
$record .= " " . "http://dx.doi.org/" . $row['doi'] . " (accessed " . $today . ")"; | |||||
} | |||||
elseif (!empty($row['url'])) // url | |||||
{ | |||||
if (!empty($row['online_citation']) OR (empty($row['online_citation']) AND (!empty($row['year']) || !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])))) // only add "." if online_citation isn't empty, or else if either year, volume, issue, abbrev_journal or publication isn't empty | |||||
$record .= "."; // see note for doi | |||||
if ($encodeHTML) | |||||
$record .= " " . encodeHTML($row['url']) . " (accessed " . $today . ")"; | |||||
else | |||||
$record .= " " . $row['url'] . " (accessed " . $today . ")"; | |||||
} | |||||
} | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
} | |||||
// --- BEGIN TYPE = ABSTRACT / BOOK CHAPTER / CONFERENCE ARTICLE ------------------------------------------------------------------------ | |||||
elseif (preg_match("/^(Abstract|Book Chapter|Conference Article)$/", $row['type'])) | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($row['author'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", and ", // 5. | |||||
"/ *, */", // 6. | |||||
", ", // 7. | |||||
" ", // 8. | |||||
". ", // 9. | |||||
false, // 10. | |||||
true, // 11. | |||||
false, // 12. | |||||
"10", // 13. | |||||
"10", // 14. | |||||
" et al.", // 15. | |||||
$encodeHTML // 16. | |||||
); | |||||
if (!preg_match("/\. *$/", $author)) | |||||
$record .= $author . "."; | |||||
else | |||||
$record .= $author; | |||||
} | |||||
if (!empty($row['title'])) // title | |||||
{ | |||||
if (!empty($row['author'])) | |||||
$record .= " "; | |||||
$record .= '"' . $row['title']; | |||||
if (!preg_match("/[?!.]$/", $row['title'])) | |||||
$record .= "."; | |||||
$record .= '"'; | |||||
} | |||||
$publication = preg_replace("/[ \r\n]*\(Eds?:[^\)\r\n]*\)/i", "", $row['publication']); | |||||
if (!empty($publication)) // publication | |||||
$record .= " In " . $markupPatternsArray["italic-prefix"] . $publication . $markupPatternsArray["italic-suffix"]; | |||||
// From here on we'll assume that at least either the 'author' or the 'title' field did contain some contents | |||||
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below) | |||||
if (!empty($row['editor'])) // editor | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$editor = reArrangeAuthorContents($row['editor'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
" and ", // 5. | |||||
"/ *, */", // 6. | |||||
" ", // 7. | |||||
" ", // 8. | |||||
". ", // 9. | |||||
true, // 10. | |||||
true, // 11. | |||||
false, // 12. | |||||
"10", // 13. | |||||
"10", // 14. | |||||
" et al.", // 15. | |||||
$encodeHTML // 16. | |||||
); | |||||
$record .= ", edited by " . $editor; | |||||
} | |||||
if (!empty($row['pages'])) // pages | |||||
$record .= ", " . formatPageInfo($row['pages'], $markupPatternsArray["endash"]); // function 'formatPageInfo()' is defined in 'cite.inc.php' | |||||
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // edition | |||||
{ | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd ed.") | |||||
{ | |||||
if ($row['edition'] == "2") | |||||
$editionSuffix = "nd"; | |||||
elseif ($row['edition'] == "3") | |||||
$editionSuffix = "rd"; | |||||
else | |||||
$editionSuffix = "th"; | |||||
} | |||||
else | |||||
$editionSuffix = ""; | |||||
if (!preg_match("/( ed\.?| edition)$/i", $row['edition'])) | |||||
$editionSuffix .= " ed."; | |||||
$record .= " " . $row['edition'] . $editionSuffix; | |||||
} | |||||
if (!empty($row['volume'])) // volume | |||||
{ | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
$record .= " Vol. " . $row['volume']; | |||||
} | |||||
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title | |||||
{ | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
$record .= " "; | |||||
if (!empty($row['abbrev_series_title'])) | |||||
$record .= $row['abbrev_series_title']; // abbreviated series title | |||||
// if there's no abbreviated series title, we'll use the full series title instead: | |||||
elseif (!empty($row['series_title'])) | |||||
$record .= $row['series_title']; // full series title | |||||
if (!empty($row['series_volume'])||!empty($row['series_issue'])) | |||||
$record .= " "; | |||||
if (!empty($row['series_volume'])) // series volume | |||||
$record .= $row['series_volume']; | |||||
if (!empty($row['series_issue'])) // series issue (I'm not really sure if -- for this cite style -- the series issue should be rather omitted here) | |||||
$record .= ", no. " . $row['series_issue']; // is it correct to format series issues similar to journal article issues? | |||||
} | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
if (!empty($row['place'])) // place | |||||
$record .= " " . $row['place']; | |||||
if (!empty($row['publisher'])) // publisher | |||||
{ | |||||
if (!empty($row['place'])) | |||||
$record .= ":"; | |||||
$record .= " " . $row['publisher']; | |||||
} | |||||
if (!empty($row['year'])) // year | |||||
$record .= ", " . $row['year']; | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
} | |||||
// --- BEGIN TYPE = BOOK WHOLE / CONFERENCE VOLUME / JOURNAL / MANUAL / MANUSCRIPT / MAP / MISCELLANEOUS / PATENT / REPORT / SOFTWARE --- | |||||
else // if (preg_match("/Book Whole|Conference Volume|Journal|Manual|Manuscript|Map|Miscellaneous|Patent|Report|Software/", $row['type'])) | |||||
// note that this also serves as a fallback: unrecognized resource types will be formatted similar to whole books | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
$author = preg_replace("/[ \r\n]*\(eds?\)/i", "", $row['author']); | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($author, // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", and ", // 5. | |||||
"/ *, */", // 6. | |||||
", ", // 7. | |||||
" ", // 8. | |||||
". ", // 9. | |||||
false, // 10. | |||||
true, // 11. | |||||
false, // 12. | |||||
"10", // 13. | |||||
"10", // 14. | |||||
" et al.", // 15. | |||||
$encodeHTML // 16. | |||||
); | |||||
// if the author is actually the editor of the resource we'll append ', ed' (or ', eds') to the author string: | |||||
// [to distinguish editors from authors in the 'author' field, the 'modify.php' script does append ' (ed)' or ' (eds)' if appropriate, | |||||
// so we're just checking for these identifier strings here. Alternatively, we could check whether the editor field matches the author field] | |||||
if (preg_match("/[ \r\n]*\(ed\)/", $row['author'])) // single editor | |||||
$author = $author . ", ed"; | |||||
elseif (preg_match("/[ \r\n]*\(eds\)/", $row['author'])) // multiple editors | |||||
$author = $author . ", eds"; | |||||
if (!preg_match("/\. *$/", $author)) | |||||
$record .= $author . "."; | |||||
else | |||||
$record .= $author; | |||||
} | |||||
if (!empty($row['title'])) // title | |||||
{ | |||||
if (!empty($row['author'])) | |||||
$record .= " "; | |||||
if (!empty($row['thesis'])) // thesis | |||||
{ | |||||
$record .= '"' . $row['title']; | |||||
if (!preg_match("/[?!.]$/", $row['title'])) | |||||
$record .= "."; | |||||
$record .= '"'; | |||||
} | |||||
else // not a thesis | |||||
$record .= $markupPatternsArray["italic-prefix"] . $row['title'] . $markupPatternsArray["italic-suffix"]; | |||||
} | |||||
if (!empty($row['editor']) && !preg_match("/[ \r\n]*\(eds?\)/", $row['author'])) // editor (if different from author, see note above regarding the check for ' (ed)' or ' (eds)') | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$editor = reArrangeAuthorContents($row['editor'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", and ", // 5. | |||||
"/ *, */", // 6. | |||||
" ", // 7. | |||||
" ", // 8. | |||||
". ", // 9. | |||||
true, // 10. | |||||
true, // 11. | |||||
false, // 12. | |||||
"10", // 13. | |||||
"10", // 14. | |||||
" et al.", // 15. | |||||
$encodeHTML // 16. | |||||
); | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
$record .= " Edited by " . $editor; | |||||
} | |||||
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // edition | |||||
{ | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd ed.") | |||||
{ | |||||
if ($row['edition'] == "2") | |||||
$editionSuffix = "nd"; | |||||
elseif ($row['edition'] == "3") | |||||
$editionSuffix = "rd"; | |||||
else | |||||
$editionSuffix = "th"; | |||||
} | |||||
else | |||||
$editionSuffix = ""; | |||||
if (!preg_match("/( ed\.?| edition)$/i", $row['edition'])) | |||||
$editionSuffix .= " ed."; | |||||
$record .= " " . $row['edition'] . $editionSuffix; | |||||
} | |||||
if (!empty($row['volume'])) // volume | |||||
{ | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
$record .= " Vol. " . $row['volume']; | |||||
} | |||||
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title | |||||
{ | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
$record .= " "; | |||||
if (!empty($row['abbrev_series_title'])) | |||||
$record .= $row['abbrev_series_title']; // abbreviated series title | |||||
// if there's no abbreviated series title, we'll use the full series title instead: | |||||
elseif (!empty($row['series_title'])) | |||||
$record .= $row['series_title']; // full series title | |||||
if (!empty($row['series_volume'])||!empty($row['series_issue'])) | |||||
$record .= " "; | |||||
if (!empty($row['series_volume'])) // series volume | |||||
$record .= $row['series_volume']; | |||||
if (!empty($row['series_issue'])) // series issue (I'm not really sure if -- for this cite style -- the series issue should be rather omitted here) | |||||
$record .= ", no. " . $row['series_issue']; // is it correct to format series issues similar to journal article issues? | |||||
} | |||||
if (!empty($row['thesis'])) // thesis | |||||
{ | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
$record .= " " . $row['thesis']; | |||||
$record .= ", " . $row['publisher']; | |||||
} | |||||
else // not a thesis | |||||
{ | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
if (!empty($row['place'])) // place | |||||
$record .= " " . $row['place']; | |||||
if (!empty($row['publisher'])) // publisher | |||||
{ | |||||
if (!empty($row['place'])) | |||||
$record .= ":"; | |||||
$record .= " " . $row['publisher']; | |||||
} | |||||
} | |||||
if (!empty($row['year'])) // year | |||||
$record .= ", ".$row['year']; | |||||
if ($row['online_publication'] == "yes") // this record refers to an online article | |||||
{ | |||||
// append an optional string (given in 'online_citation') plus the current date and the DOI (or URL): | |||||
$today = date("F j, Y"); | |||||
if (!empty($row['online_citation'])) // online_citation | |||||
{ | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
$record .= " " . $row['online_citation']; | |||||
} | |||||
if (!empty($row['doi'])) // doi | |||||
{ | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
if ($encodeHTML) | |||||
$record .= " " . encodeHTML("http://dx.doi.org/" . $row['doi']) . " (accessed " . $today . ")"; | |||||
else | |||||
$record .= " " . "http://dx.doi.org/" . $row['doi'] . " (accessed " . $today . ")"; | |||||
} | |||||
elseif (!empty($row['url'])) // url | |||||
{ | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
if ($encodeHTML) | |||||
$record .= " " . encodeHTML($row['url']) . " (accessed " . $today . ")"; | |||||
else | |||||
$record .= " " . $row['url'] . " (accessed " . $today . ")"; | |||||
} | |||||
} | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
} | |||||
// --- BEGIN POST-PROCESSING ----------------------------------------------------------------------------------------------------------- | |||||
// do some further cleanup: | |||||
$record = trim($record); // remove any preceding or trailing whitespace | |||||
return $record; | |||||
} | |||||
// --- END CITATION STYLE --- | |||||
?> |
@ -0,0 +1,438 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./cite/styles/cite_DeepSeaRes.php | |||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/cite/styles/cite_DeepSeaRes.php $ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 28-Sep-04, 23:36 | |||||
// Modified: $Date: 2012-02-27 20:25:30 +0000 (Mon, 27 Feb 2012) $ | |||||
// $Author: msteffens $ | |||||
// $Revision: 1337 $ | |||||
// This is a citation style file (which must reside within the 'cite/styles/' sub-directory of your refbase root directory). It contains a | |||||
// version of the 'citeRecord()' function that outputs a reference list from selected records according to the citation style used by | |||||
// the journal "Deep Sea Research". | |||||
// -------------------------------------------------------------------- | |||||
// --- BEGIN CITATION STYLE --- | |||||
function citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, $encodeHTML) | |||||
{ | |||||
global $alnum, $alpha, $cntrl, $dash, $digit, $graph, $lower, $print, $punct, $space, $upper, $word, $patternModifiers; // defined in 'transtab_unicode_charset.inc.php' and 'transtab_latin1_charset.inc.php' | |||||
$record = ""; // make sure that our buffer variable is empty | |||||
// --- BEGIN TYPE = JOURNAL ARTICLE / MAGAZINE ARTICLE / NEWSPAPER ARTICLE -------------------------------------------------------------- | |||||
if (preg_match("/^(Journal Article|Magazine Article|Newspaper Article)$/", $row['type'])) | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($row['author'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", ", // 5. | |||||
"/ *, */", // 6. | |||||
", ", // 7. | |||||
", ", // 8. | |||||
".", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"", // 13. | |||||
"", // 14. | |||||
" " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15. | |||||
$encodeHTML); // 16. | |||||
$record .= $author . ", "; | |||||
} | |||||
if (!empty($row['year'])) // year | |||||
$record .= $row['year'] . ". "; | |||||
if (!empty($row['title'])) // title | |||||
{ | |||||
$record .= $row['title']; | |||||
if (!preg_match("/[?!.]$/", $row['title'])) | |||||
$record .= "."; | |||||
$record .= " "; | |||||
} | |||||
if (!empty($row['publication'])) // publication | |||||
$record .= $row['publication'] . " "; | |||||
if (!empty($row['volume'])) // volume | |||||
$record .= $row['volume']; | |||||
if (!empty($row['issue'])) // issue | |||||
$record .= " (" . $row['issue'] . ")"; | |||||
if ($row['online_publication'] == "yes") // this record refers to an online article | |||||
{ | |||||
// instead of any pages info (which normally doesn't exist for online publications) we append | |||||
// an optional string (given in 'online_citation') plus the DOI: | |||||
if (!empty($row['online_citation'])) // online_citation | |||||
{ | |||||
if (!empty($row['publication'])||!empty($row['volume'])||!empty($row['issue'])) // only add "," if either publication, volume or issue isn't empty | |||||
$record .= ","; | |||||
$record .= " " . $row['online_citation']; | |||||
} | |||||
if (!empty($row['doi'])) // doi | |||||
{ | |||||
if (!empty($row['publication'])||!empty($row['volume'])||!empty($row['issue'])) // only add "," if either publication, volume or issue isn't empty | |||||
$record .= ","; | |||||
$record .= " doi:" . $row['doi']; | |||||
} | |||||
} | |||||
else // $row['online_publication'] == "no" -> this record refers to a printed article, so we append any pages info instead: | |||||
{ | |||||
if (!empty($row['pages'])) // pages | |||||
{ | |||||
if (!empty($row['volume'])||!empty($row['issue'])) // only add "," if either volume or issue isn't empty | |||||
$record .= ", "; | |||||
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "", "", "pp"); // function 'formatPageInfo()' is defined in 'cite.inc.php' | |||||
} | |||||
} | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
} | |||||
// --- BEGIN TYPE = ABSTRACT / BOOK CHAPTER / CONFERENCE ARTICLE ------------------------------------------------------------------------ | |||||
elseif (preg_match("/^(Abstract|Book Chapter|Conference Article)$/", $row['type'])) | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($row['author'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", ", // 5. | |||||
"/ *, */", // 6. | |||||
", ", // 7. | |||||
", ", // 8. | |||||
".", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"", // 13. | |||||
"", // 14. | |||||
" " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15. | |||||
$encodeHTML); // 16. | |||||
$record .= $author . ", "; | |||||
} | |||||
if (!empty($row['year'])) // year | |||||
$record .= $row['year'] . ". "; | |||||
if (!empty($row['title'])) // title | |||||
{ | |||||
$record .= $row['title']; | |||||
if (!preg_match("/[?!.]$/", $row['title'])) | |||||
$record .= "."; | |||||
$record .= " "; | |||||
} | |||||
if (!empty($row['editor'])) // editor | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$editor = reArrangeAuthorContents($row['editor'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", ", // 5. | |||||
"/ *, */", // 6. | |||||
", ", // 7. | |||||
", ", // 8. | |||||
".", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"", // 13. | |||||
"", // 14. | |||||
" " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15. | |||||
$encodeHTML); // 16. | |||||
$record .= "In: " . $editor; | |||||
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';') | |||||
$record .= " (Eds.)"; | |||||
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s]) | |||||
$record .= " (Ed.)"; | |||||
} | |||||
$publication = preg_replace("/[ \r\n]*\(Eds?:[^\)\r\n]*\)/i", "", $row['publication']); | |||||
if (!empty($publication)) // publication | |||||
$record .= ", " . $publication . ". "; | |||||
else | |||||
if (!empty($row['editor'])) | |||||
$record .= ". "; | |||||
if (!empty($row['series_title'])) // if there's a series title, series information will replace the publisher & place information | |||||
{ | |||||
$record .= $row['series_title']; // series title | |||||
if (!empty($row['series_volume'])||!empty($row['series_issue'])) | |||||
$record .= " "; | |||||
if (!empty($row['series_volume'])) // series volume | |||||
$record .= $row['series_volume']; | |||||
if (!empty($row['series_issue'])) // series issue | |||||
$record .= "(" . $row['series_issue'] . ")"; | |||||
if (!empty($row['pages'])) | |||||
$record .= ", "; | |||||
} | |||||
else // if there's NO series title available, we'll insert the publisher & place instead: | |||||
{ | |||||
if (!empty($row['publisher'])) // publisher | |||||
{ | |||||
$record .= $row['publisher']; | |||||
if (!empty($row['place'])) | |||||
$record .= ", "; | |||||
else | |||||
{ | |||||
if (!preg_match("/,$/", $row['publisher'])) | |||||
$record .= ","; | |||||
$record .= " "; | |||||
} | |||||
} | |||||
if (!empty($row['place'])) // place | |||||
{ | |||||
$record .= $row['place']; | |||||
if (!empty($row['pages'])) | |||||
{ | |||||
if (!preg_match("/,$/", $row['place'])) | |||||
$record .= ","; | |||||
$record .= " "; | |||||
} | |||||
} | |||||
} | |||||
if (!empty($row['pages'])) // pages | |||||
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p. ", "pp. ", "pp"); // function 'formatPageInfo()' is defined in 'cite.inc.php' | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
} | |||||
// --- BEGIN TYPE = BOOK WHOLE / CONFERENCE VOLUME / JOURNAL / MANUAL / MANUSCRIPT / MAP / MISCELLANEOUS / PATENT / REPORT / SOFTWARE --- | |||||
else // if (preg_match("/Book Whole|Conference Volume|Journal|Manual|Manuscript|Map|Miscellaneous|Patent|Report|Software/", $row['type'])) | |||||
// note that this also serves as a fallback: unrecognized resource types will be formatted similar to whole books | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
$author = preg_replace("/[ \r\n]*\(eds?\)/i", "", $row['author']); | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($author, // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", ", // 5. | |||||
"/ *, */", // 6. | |||||
", ", // 7. | |||||
", ", // 8. | |||||
".", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"", // 13. | |||||
"", // 14. | |||||
" " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15. | |||||
$encodeHTML); // 16. | |||||
$record .= $author . ", "; | |||||
} | |||||
if (!empty($row['year'])) // year | |||||
$record .= $row['year'] . ". "; | |||||
if (!empty($row['title'])) // title | |||||
{ | |||||
$record .= $row['title']; | |||||
if (!preg_match("/[?!.]$/", $row['title'])) | |||||
$record .= "."; | |||||
$record .= " "; | |||||
} | |||||
if (!empty($row['thesis'])) // thesis | |||||
$record .= $row['thesis'] . ". "; | |||||
if (!empty($row['publisher'])) // publisher | |||||
{ | |||||
$record .= $row['publisher']; | |||||
if (!empty($row['place'])) | |||||
$record .= ", "; | |||||
else | |||||
{ | |||||
if (!preg_match("/[?!.]$/", $row['publisher'])) | |||||
$record .= ". "; | |||||
else | |||||
$record .= " "; | |||||
} | |||||
} | |||||
if (!empty($row['place'])) // place | |||||
{ | |||||
$record .= $row['place']; | |||||
if (!empty($row['series_title']) || !empty($row['pages'])) | |||||
{ | |||||
if (!preg_match("/,$/", $row['place'])) | |||||
$record .= ","; | |||||
$record .= " "; | |||||
} | |||||
} | |||||
if (!empty($row['series_title'])) // series title | |||||
{ | |||||
$record .= $row['series_title']; | |||||
if (!empty($row['series_volume'])) // series volume (will get appended only if there's also a series title!) | |||||
{ | |||||
$record .= " "; | |||||
$record .= $row['series_volume']; | |||||
} | |||||
if (!empty($row['pages'])) | |||||
{ | |||||
if (!preg_match("/,$/", $row['series_volume'])) | |||||
$record .= ","; | |||||
$record .= " "; | |||||
} | |||||
} | |||||
if (!empty($row['pages'])) // pages | |||||
{ | |||||
// TODO: use function 'formatPageInfo()' when it can recognize & process total number of pages | |||||
// $record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p. ", "pp. ", "pp"); // function 'formatPageInfo()' is defined in 'cite.inc.php' | |||||
if (preg_match("/\d *[$dash] *\d/$patternModifiers", $row['pages'])) // if the 'pages' field contains a page range (like: "127-132") | |||||
// Note that we'll check for page ranges here although for whole books the 'pages' field should NOT contain a page range but the total number of pages! (like: "623 pp") | |||||
$pagesDisplay = (preg_replace("@(\d+) *[$dash] *(\d+)@$patternModifiers", "\\1" . $markupPatternsArray["endash"] . "\\2", $row['pages'])); | |||||
else | |||||
$pagesDisplay = $row['pages']; | |||||
$record .= $pagesDisplay; | |||||
} | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
} | |||||
// --- BEGIN POST-PROCESSING ----------------------------------------------------------------------------------------------------------- | |||||
// do some further cleanup: | |||||
$record = preg_replace("/[ \r\n]*$/i", "", $record); // remove whitespace at end of line | |||||
$record = preg_replace("/([0-9]+) *pp\.$/i", "\\1pp.", $record); // remove space between (book whole) page numbers & "pp" | |||||
return $record; | |||||
} | |||||
// --- END CITATION STYLE --- | |||||
?> |
@ -0,0 +1,691 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./cite/styles/cite_Harvard_1.php | |||||
// Repository: $HeadURL$ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 12-Aug-08, 16:00 | |||||
// Modified: $Date: 2012-02-27 20:25:30 +0000 (Mon, 27 Feb 2012) $ | |||||
// $Author$ | |||||
// $Revision: 1337 $ | |||||
// This is a citation style file (which must reside within the 'cite/styles/' sub-directory of your refbase root directory). It contains a | |||||
// version of the 'citeRecord()' function that outputs a reference list from selected records according to the citation style used by | |||||
// the Harvard referencing system | |||||
// This is a variant of the Harvard author/date style, modeled after this guide: | |||||
// <http://libweb.anglia.ac.uk/referencing/harvard.htm> | |||||
// based on 'cite_Harvard_3.php' | |||||
// TODO: - abstracts, conference proceedings, magazine articles, patents, reports & software? | |||||
// - should we shorten ending page numbers if necessary (e.g. "p. 10-8" or "p. 51-5", but "p. 19-26"), or only if numbers are >=3 digits? | |||||
// - where to put (and how to format) series info & editors of whole books that also have an author? | |||||
// - see also inline comments labeled with TODO (and NOTE) | |||||
// -------------------------------------------------------------------- | |||||
// --- BEGIN CITATION STYLE --- | |||||
function citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, $encodeHTML) | |||||
{ | |||||
$record = ""; // make sure that our buffer variable is empty | |||||
// --- BEGIN TYPE = JOURNAL ARTICLE / MAGAZINE ARTICLE / NEWSPAPER ARTICLE -------------------------------------------------------------- | |||||
if (preg_match("/^(Journal Article|Magazine Article|Newspaper Article)$/", $row['type'])) | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($row['author'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
" " . $markupPatternsArray["ampersand"] . " ", // 5. | |||||
"/ *, */", // 6. | |||||
", ", // 7. | |||||
", ", // 8. | |||||
".", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"4", // 13. | |||||
"1", // 14. | |||||
" et al", // 15. | |||||
$encodeHTML); // 16. | |||||
$record .= $author; | |||||
} | |||||
if (!empty($row['year'])) // year | |||||
{ | |||||
if (!empty($row['author'])) | |||||
$record .= ", "; | |||||
if (!empty($row['year'])) | |||||
$record .= $row['year']; | |||||
} | |||||
if (!empty($row['title'])) // title | |||||
{ | |||||
if (!empty($row['author']) || !empty($row['year'])) | |||||
$record .= ". "; | |||||
$record .= $row['title']; | |||||
$record .= ","; | |||||
} | |||||
// From here on we'll assume that at least one of the fields 'author', 'year' or 'title' did contain some contents | |||||
if (!empty($row['publication'])) // publication (= journal) name | |||||
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['publication'] . $markupPatternsArray["italic-suffix"]; | |||||
// if there's no full journal name, we'll use the abbreviated journal name instead: | |||||
elseif (!empty($row['abbrev_journal'])) // abbreviated journal name | |||||
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['abbrev_journal'] . $markupPatternsArray["italic-suffix"]; | |||||
if ((!empty($row['abbrev_journal']) || !empty($row['publication'])) && (!empty($row['volume']) || !empty($row['issue']))) | |||||
$record .= ","; // NOTE: for newspaper articles, the above mentioned guide uses a dot instead of a comma ("The Times, 3 Sep. p.4-5.") but this seems incorrect/inconsistent to me | |||||
if ($row['online_publication'] == "yes") // this record refers to an online publication | |||||
$record .= " [Online]"; | |||||
if ($row['type'] == "Journal Article") | |||||
{ | |||||
if (!empty($row['volume'])) // volume | |||||
$record .= " " . $row['volume']; | |||||
if (!empty($row['issue'])) // issue | |||||
{ | |||||
if (!empty($row['volume'])) | |||||
$record .= " "; | |||||
$record .= "(" . $row['issue'] . ")"; | |||||
} | |||||
} | |||||
elseif (preg_match("/^(Newspaper Article|Magazine Article)$/", $row['type'])) // for newspaper and magazine articles, volume (=month) and issue (=day) information is printed without prefix | |||||
{ | |||||
if (!empty($row['issue'])) // issue (=day) | |||||
$record .= " " . $row['issue']; | |||||
if (!empty($row['volume'])) // volume (=month) | |||||
$record .= " " . $row['volume']; | |||||
} | |||||
if (!empty($row['pages'])) // pages | |||||
{ | |||||
if (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add ", " if either volume, issue, abbrev_journal or publication isn't empty | |||||
$record .= ", "; | |||||
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p. ", "p. "); // function 'formatPageInfo()' is defined in 'cite.inc.php' (NOTE: from the examples in the above mentioned guide it's unclear whether "p." should be followed by a space or not) | |||||
} | |||||
if ($row['online_publication'] == "yes") // this record refers to an online article | |||||
{ | |||||
// append an optional string (given in 'online_citation') plus the current date and the DOI (or URL): | |||||
if (!empty($row['online_citation'])) // online_citation | |||||
{ | |||||
if (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add "," if either volume, issue, abbrev_journal or publication isn't empty | |||||
$record .= ","; | |||||
$record .= " " . $row['online_citation']; | |||||
} | |||||
if (!empty($row['doi']) || !empty($row['url'])) // doi OR url | |||||
{ | |||||
if (!empty($row['online_citation']) OR (empty($row['online_citation']) AND (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])))) // only add "." if online_citation isn't empty, or else if either volume, issue, abbrev_journal or publication isn't empty | |||||
$record .= "."; | |||||
$today = date("j F Y"); | |||||
$record .= " Available at: " . $markupPatternsArray["underline-prefix"]; | |||||
if (!empty($row['doi'])) // doi | |||||
$uri = "http://dx.doi.org/" . $row['doi']; | |||||
else // url | |||||
$uri = $row['url']; | |||||
if ($encodeHTML) | |||||
$record .= encodeHTML($uri); | |||||
else | |||||
$record .= $uri; | |||||
$record .= $markupPatternsArray["underline-suffix"]; | |||||
$record .= " [accessed " . $today . "]"; | |||||
} | |||||
} | |||||
if (!preg_match("/\. *$/", $record)) // if the string doesn't end with a period | |||||
$record .= "."; | |||||
} | |||||
// --- BEGIN TYPE = ABSTRACT / BOOK CHAPTER / CONFERENCE ARTICLE ------------------------------------------------------------------------ | |||||
elseif (preg_match("/^(Abstract|Book Chapter|Conference Article)$/", $row['type'])) | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($row['author'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
" " . $markupPatternsArray["ampersand"] . " ", // 5. | |||||
"/ *, */", // 6. | |||||
", ", // 7. | |||||
", ", // 8. | |||||
".", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"4", // 13. | |||||
"1", // 14. | |||||
" et al", // 15. | |||||
$encodeHTML); // 16. | |||||
$record .= $author; | |||||
} | |||||
if (!empty($row['year'])) // year | |||||
{ | |||||
if (!empty($row['author'])) | |||||
$record .= ", "; | |||||
$record .= $row['year']; | |||||
} | |||||
if (!empty($row['title'])) // title | |||||
{ | |||||
if (!empty($row['author']) || !empty($row['year'])) | |||||
$record .= ". "; | |||||
$record .= $row['title']; | |||||
$record .= "."; | |||||
} | |||||
// From here on we'll assume that at least one of the fields 'author', 'year' or 'title' did contain some contents | |||||
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below) | |||||
if (!empty($row['editor'])) // editor | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$editor = reArrangeAuthorContents($row['editor'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
" " . $markupPatternsArray["ampersand"] . " ", // 5. | |||||
"/ *, */", // 6. | |||||
" ", // 7. | |||||
" ", // 8. | |||||
".", // 9. | |||||
true, // 10. | |||||
true, // 11. | |||||
true, // 12. | |||||
"4", // 13. | |||||
"1", // 14. | |||||
" et al", // 15. | |||||
$encodeHTML); // 16. | |||||
$record .= " In " . $editor . ", "; | |||||
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';') | |||||
$record .= "eds."; | |||||
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s]) | |||||
$record .= "ed."; | |||||
} | |||||
$publication = preg_replace("/[ \r\n]*\(Eds?:[^\)\r\n]*\)/i", "", $row['publication']); | |||||
if (!empty($publication)) // publication | |||||
{ | |||||
if (empty($row['editor'])) | |||||
$record .= " In"; | |||||
$record .= " " . $markupPatternsArray["italic-prefix"] . $publication . $markupPatternsArray["italic-suffix"]; | |||||
} | |||||
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition']) || !empty($row['volume'])) | |||||
{ | |||||
$record .= ". "; | |||||
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // edition | |||||
{ | |||||
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd ed.") | |||||
{ | |||||
if ($row['edition'] == "2") | |||||
$editionSuffix = "nd"; | |||||
elseif ($row['edition'] == "3") | |||||
$editionSuffix = "rd"; | |||||
else | |||||
$editionSuffix = "th"; | |||||
} | |||||
else | |||||
$editionSuffix = ""; | |||||
if (!empty($row['edition']) && !preg_match("/( ed\.?| edition)$/i", $row['edition'])) | |||||
$editionSuffix .= " ed."; | |||||
$record .= $row['edition'] . $editionSuffix; | |||||
} | |||||
if (!empty($row['volume'])) // volume | |||||
{ | |||||
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) | |||||
$record .= ", "; | |||||
$record .= "vol. " . $row['volume']; // TODO: not sure whether this is correct | |||||
} | |||||
} | |||||
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title | |||||
{ | |||||
$record .= ". "; | |||||
if (!empty($row['series_title'])) | |||||
$record .= $row['series_title']; // full series title | |||||
// if there's no full series title, we'll use the abbreviated series title instead: | |||||
elseif (!empty($row['abbrev_series_title'])) | |||||
$record .= $row['abbrev_series_title']; // abbreviated series title | |||||
if (!empty($row['series_volume'])||!empty($row['series_issue'])) | |||||
$record .= ", "; | |||||
if (!empty($row['series_volume'])) // series volume (I'm not really sure if -- for this cite style -- the series volume & issue should be rather omitted here) | |||||
$record .= "vol. " . $row['series_volume']; // TODO: not sure whether this is correct | |||||
if (!empty($row['series_issue'])) // series issue (see note for series volume) | |||||
{ | |||||
if (!empty($row['series_volume'])) | |||||
$record .= ", "; | |||||
$record .= "no. " . $row['series_issue']; // TODO: not sure whether this is correct | |||||
} | |||||
} | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
if (!empty($row['place'])) // place | |||||
$record .= " " . $row['place']; | |||||
if (!empty($row['publisher'])) // publisher | |||||
{ | |||||
if (!empty($row['place'])) | |||||
$record .= ":"; | |||||
$record .= " " . $row['publisher']; | |||||
} | |||||
if (!empty($row['pages'])) // pages | |||||
{ | |||||
if (!empty($row['publisher']) || !empty($row['place'])) | |||||
$record .= ", "; | |||||
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p. ", "p. "); // function 'formatPageInfo()' is defined in 'cite.inc.php' (NOTE: from the examples in the above mentioned guide it's unclear whether "p." should be followed by a space or not) | |||||
} | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
} | |||||
// --- BEGIN TYPE = BOOK WHOLE / CONFERENCE VOLUME / JOURNAL / MANUAL / MANUSCRIPT / MAP / MISCELLANEOUS / PATENT / REPORT / SOFTWARE --- | |||||
else // if (preg_match("/Book Whole|Conference Volume|Journal|Manual|Manuscript|Map|Miscellaneous|Patent|Report|Software/", $row['type'])) | |||||
// note that this also serves as a fallback: unrecognized resource types will be formatted similar to whole books | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
$author = preg_replace("/[ \r\n]*\(eds?\)/i", "", $row['author']); | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($author, // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
" " . $markupPatternsArray["ampersand"] . " ", // 5. | |||||
"/ *, */", // 6. | |||||
", ", // 7. | |||||
", ", // 8. | |||||
".", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"4", // 13. | |||||
"1", // 14. | |||||
" et al", // 15. | |||||
$encodeHTML); // 16. | |||||
// if the author is actually the editor of the resource we'll append ', ed' (or ', eds') to the author string: | |||||
// [to distinguish editors from authors in the 'author' field, the 'modify.php' script does append ' (ed)' or ' (eds)' if appropriate, | |||||
// so we're just checking for these identifier strings here. Alternatively, we could check whether the editor field matches the author field] | |||||
if (preg_match("/[ \r\n]*\(ed\)/", $row['author'])) // single editor | |||||
$author = $author . " ed."; | |||||
elseif (preg_match("/[ \r\n]*\(eds\)/", $row['author'])) // multiple editors | |||||
$author = $author . " eds."; | |||||
$record .= $author; | |||||
} | |||||
if (!empty($row['year'])) // year | |||||
{ | |||||
if (!empty($row['author'])) | |||||
$record .= ", "; | |||||
$record .= $row['year']; | |||||
} | |||||
if (!empty($row['title'])) // title | |||||
{ | |||||
if (!empty($row['author']) || !empty($row['year'])) | |||||
$record .= ". "; | |||||
$record .= $markupPatternsArray["italic-prefix"] . $row['title'] . $markupPatternsArray["italic-suffix"]; | |||||
} | |||||
if ($row['online_publication'] == "yes") // this record refers to an online publication | |||||
$record .= ". [Online]"; // TODO: this may not be entirely correct, since, according to the above mentioned guide, the actual type should be used: e.g. "[e-book]" or "[CD-ROM]" | |||||
if (!empty($row['editor']) && !preg_match("/[ \r\n]*\(eds?\)/", $row['author'])) // editor (if different from author, see note above regarding the check for ' (ed)' or ' (eds)') | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$editor = reArrangeAuthorContents($row['editor'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
" " . $markupPatternsArray["ampersand"] . " ", // 5. | |||||
"/ *, */", // 6. | |||||
" ", // 7. | |||||
" ", // 8. | |||||
".", // 9. | |||||
true, // 10. | |||||
true, // 11. | |||||
true, // 12. | |||||
"4", // 13. | |||||
"1", // 14. | |||||
" et al", // 15. | |||||
$encodeHTML); // 16. | |||||
if (!empty($row['author']) || !empty($row['year']) || !empty($row['title'])) | |||||
$record .= " "; | |||||
$record .= " (" . $editor . ", "; | |||||
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';') | |||||
$record .= "eds."; | |||||
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s]) | |||||
$record .= "ed."; | |||||
$record .= ")"; | |||||
} | |||||
if (!empty($row['edition']) || !empty($row['volume'])) | |||||
{ | |||||
if (!empty($row['author']) || !empty($row['year']) || !empty($row['title']) || (!empty($row['editor']) && !preg_match("/[ \r\n]*\(eds?\)/", $row['author']))) | |||||
$record .= ". "; | |||||
if ($row['type'] == "Software") // software edition (=version) | |||||
{ | |||||
if (!empty($row['edition'])) | |||||
{ | |||||
$record .= "Version " . $row['edition']; | |||||
if (!empty($row['volume']) || !empty($row['issue'])) | |||||
$record .= ", "; | |||||
} | |||||
if (!empty($row['issue'])) // issue (=day) | |||||
$record .= " " . $row['issue']; | |||||
if (!empty($row['volume'])) // volume (=month) | |||||
$record .= " " . $row['volume']; | |||||
} | |||||
elseif (!preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // regular edition (other than the first) | |||||
{ | |||||
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd ed.") | |||||
{ | |||||
if ($row['edition'] == "2") | |||||
$editionSuffix = "nd"; | |||||
elseif ($row['edition'] == "3") | |||||
$editionSuffix = "rd"; | |||||
else | |||||
$editionSuffix = "th"; | |||||
} | |||||
else | |||||
$editionSuffix = ""; | |||||
if (!empty($row['edition']) && !preg_match("/( ed\.?| edition)$/i", $row['edition'])) | |||||
$editionSuffix .= " ed."; | |||||
$record .= $row['edition'] . $editionSuffix; | |||||
if (!empty($row['volume'])) // volume | |||||
{ | |||||
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) | |||||
$record .= ", "; | |||||
$record .= "vol. " . $row['volume']; // TODO: not sure whether this is correct | |||||
} | |||||
} | |||||
} | |||||
if ($row['type'] == "Software") // for software, add software label | |||||
{ | |||||
$record .= ", computer software."; | |||||
} | |||||
else // add series info | |||||
{ | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title | |||||
{ | |||||
$record .= " "; | |||||
if (!empty($row['series_title'])) | |||||
$record .= $row['series_title']; // full series title | |||||
// if there's no full series title, we'll use the abbreviated series title instead: | |||||
elseif (!empty($row['abbrev_series_title'])) | |||||
$record .= $row['abbrev_series_title']; // abbreviated series title | |||||
if (!empty($row['series_volume'])||!empty($row['series_issue'])) | |||||
$record .= ", "; | |||||
if (!empty($row['series_volume'])) // series volume (I'm not really sure if -- for this cite style -- the series volume & issue should be rather omitted here) | |||||
$record .= "vol. " . $row['series_volume']; // TODO: not sure whether this is correct | |||||
if (!empty($row['series_issue'])) // series issue (see note for series volume) | |||||
{ | |||||
if (!empty($row['series_volume'])) | |||||
$record .= ", "; | |||||
$record .= "no. " . $row['series_issue']; // TODO: not sure whether this is correct | |||||
} | |||||
$record .= "."; | |||||
} | |||||
} | |||||
if (!empty($row['thesis'])) // thesis | |||||
$record .= " " . $row['thesis']; | |||||
if (!empty($row['place']) || !empty($row['publisher'])) | |||||
{ | |||||
if (!empty($row['thesis'])) | |||||
$record .= "."; | |||||
if (!empty($row['place'])) // place (NOTE: should we omit the place of publication for theses?) | |||||
$record .= " " . $row['place']; | |||||
if (!empty($row['publisher'])) // publisher | |||||
{ | |||||
if (!empty($row['place'])) | |||||
$record .= ":"; | |||||
$record .= " " . $row['publisher']; | |||||
} | |||||
} | |||||
if ($row['online_publication'] == "yes" || $row['type'] == "Software") // this record refers to an online article, or a computer program/software | |||||
{ | |||||
if (!empty($row['online_citation'])) // online_citation | |||||
{ | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
$record .= " " . $row['online_citation']; | |||||
} | |||||
if (!empty($row['doi']) || !empty($row['url'])) // doi OR url | |||||
{ | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
$today = date("j F Y"); | |||||
$record .= " Available at: " . $markupPatternsArray["underline-prefix"]; | |||||
if (!empty($row['doi'])) // doi | |||||
$uri = "http://dx.doi.org/" . $row['doi']; | |||||
else // url | |||||
$uri = $row['url']; | |||||
if ($encodeHTML) | |||||
$record .= encodeHTML($uri); | |||||
else | |||||
$record .= $uri; | |||||
$record .= $markupPatternsArray["underline-suffix"]; | |||||
$record .= " [accessed " . $today . "]"; | |||||
} | |||||
} | |||||
if (!preg_match("/\. *$/", $record)) // if the string doesn't end with a period | |||||
$record .= "."; | |||||
} | |||||
// --- BEGIN POST-PROCESSING ----------------------------------------------------------------------------------------------------------- | |||||
// do some further cleanup: | |||||
$record = trim($record); // remove any preceding or trailing whitespace | |||||
return $record; | |||||
} | |||||
// --- END CITATION STYLE --- | |||||
?> |
@ -0,0 +1,657 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./cite/styles/cite_Harvard_2.php | |||||
// Repository: $HeadURL$ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 12-Aug-08, 20:00 | |||||
// Modified: $Date: 2012-02-27 20:25:30 +0000 (Mon, 27 Feb 2012) $ | |||||
// $Author$ | |||||
// $Revision: 1337 $ | |||||
// This is a citation style file (which must reside within the 'cite/styles/' sub-directory of your refbase root directory). It contains a | |||||
// version of the 'citeRecord()' function that outputs a reference list from selected records according to the citation style used by | |||||
// the Harvard referencing system | |||||
// This is a variant of the Harvard author/date style, modeled after this guide: | |||||
// <http://skillsforlearning.leedsmet.ac.uk/harvard_2004.pdf> | |||||
// based on 'cite_Harvard_1.php' | |||||
// NOTES: - For conference proceedings, you'll currently need to add the place & date of the conference in the proceedings title field | |||||
// (e.g. "Proceedings of the 67th IFLA Council and General Conference, August 16-25, 2001, Boston USA"). | |||||
// TODO: - abstracts, conference proceedings, magazine articles, patents, reports & software? | |||||
// - for references where there are more than four authors, we currently only use the first author followed by " et al"; is this correct? | |||||
// - where to put (and how to format) series info & editors of whole books that also have an author? | |||||
// - see also inline comments labeled with TODO (and NOTE) | |||||
// -------------------------------------------------------------------- | |||||
// --- BEGIN CITATION STYLE --- | |||||
function citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, $encodeHTML) | |||||
{ | |||||
$record = ""; // make sure that our buffer variable is empty | |||||
// --- BEGIN TYPE = JOURNAL ARTICLE / MAGAZINE ARTICLE / NEWSPAPER ARTICLE -------------------------------------------------------------- | |||||
if (preg_match("/^(Journal Article|Magazine Article|Newspaper Article)$/", $row['type'])) | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($row['author'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
" " . $markupPatternsArray["ampersand"] . " ", // 5. | |||||
"/ *, */", // 6. | |||||
", ", // 7. | |||||
", ", // 8. | |||||
".", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"4", // 13. | |||||
"1", // 14. | |||||
" et al", // 15. | |||||
$encodeHTML); // 16. | |||||
$record .= $author; | |||||
} | |||||
if (!empty($row['year'])) // year | |||||
$record .= " (" . $row['year'] . ")"; | |||||
if (!empty($row['title'])) // title | |||||
$record .= " " . $row['title'] . "."; | |||||
// From here on we'll assume that at least one of the fields 'author', 'year' or 'title' did contain some contents | |||||
if (!empty($row['publication'])) // publication (= journal) name | |||||
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['publication'] . $markupPatternsArray["italic-suffix"]; | |||||
// if there's no full journal name, we'll use the abbreviated journal name instead: | |||||
elseif (!empty($row['abbrev_journal'])) // abbreviated journal name | |||||
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['abbrev_journal'] . $markupPatternsArray["italic-suffix"]; | |||||
if ($row['online_publication'] == "yes") // this record refers to an online publication | |||||
$record .= " [Internet]"; | |||||
if ((!empty($row['abbrev_journal']) || !empty($row['publication'])) && (!empty($row['volume']) || !empty($row['issue']))) | |||||
$record .= ","; | |||||
if ($row['type'] == "Journal Article") | |||||
{ | |||||
if (!empty($row['volume'])) // volume | |||||
$record .= " " . $row['volume']; | |||||
if (!empty($row['issue'])) // issue | |||||
{ | |||||
if (!empty($row['volume'])) | |||||
$record .= " "; | |||||
$record .= "(" . $row['issue'] . ")"; | |||||
} | |||||
} | |||||
elseif (preg_match("/^(Newspaper Article|Magazine Article)$/", $row['type'])) // for newspaper and magazine articles, volume (=month) and issue (=day) information is printed without prefix | |||||
{ | |||||
if (!empty($row['issue'])) // issue (=day) | |||||
$record .= " " . $row['issue']; | |||||
if (!empty($row['volume'])) // volume (=month) | |||||
$record .= " " . $row['volume']; | |||||
} | |||||
if (!empty($row['pages'])) // pages | |||||
{ | |||||
if (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add ", " if either volume, issue, abbrev_journal or publication isn't empty | |||||
$record .= ", "; | |||||
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p.", "pp."); // function 'formatPageInfo()' is defined in 'cite.inc.php' | |||||
} | |||||
if ($row['online_publication'] == "yes") // this record refers to an online article | |||||
{ | |||||
// append an optional string (given in 'online_citation') plus the current date and the DOI (or URL): | |||||
if (!empty($row['online_citation'])) // online_citation | |||||
{ | |||||
if (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add "," if either volume, issue, abbrev_journal or publication isn't empty | |||||
$record .= ","; | |||||
$record .= " " . $row['online_citation']; | |||||
} | |||||
if (!empty($row['doi']) || !empty($row['url'])) // doi OR url | |||||
{ | |||||
if (!empty($row['online_citation']) OR (empty($row['online_citation']) AND (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])))) // only add "." if online_citation isn't empty, or else if either volume, issue, abbrev_journal or publication isn't empty | |||||
$record .= "."; | |||||
$today = date("j F Y"); | |||||
$record .= " Available from: "; | |||||
if (!empty($row['doi'])) // doi | |||||
$uri = "http://dx.doi.org/" . $row['doi']; | |||||
else // url | |||||
$uri = $row['url']; | |||||
if ($encodeHTML) | |||||
$record .= encodeHTML($markupPatternsArray["less-than"] . $uri . $markupPatternsArray["greater-than"]); | |||||
else | |||||
$record .= $markupPatternsArray["less-than"] . $uri . $markupPatternsArray["greater-than"]; | |||||
$record .= " [Accessed " . $today . "]"; | |||||
} | |||||
} | |||||
if (!preg_match("/\. *$/", $record)) // if the string doesn't end with a period | |||||
$record .= "."; | |||||
} | |||||
// --- BEGIN TYPE = ABSTRACT / BOOK CHAPTER / CONFERENCE ARTICLE ------------------------------------------------------------------------ | |||||
elseif (preg_match("/^(Abstract|Book Chapter|Conference Article)$/", $row['type'])) | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($row['author'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
" " . $markupPatternsArray["ampersand"] . " ", // 5. | |||||
"/ *, */", // 6. | |||||
", ", // 7. | |||||
", ", // 8. | |||||
".", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"4", // 13. | |||||
"1", // 14. | |||||
" et al", // 15. | |||||
$encodeHTML); // 16. | |||||
$record .= $author; | |||||
} | |||||
if (!empty($row['year'])) // year | |||||
$record .= " (" . $row['year'] . ")"; | |||||
if (!empty($row['title'])) // title | |||||
$record .= " " . $row['title'] . "."; | |||||
// From here on we'll assume that at least one of the fields 'author', 'year' or 'title' did contain some contents | |||||
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below) | |||||
if (!empty($row['editor'])) // editor | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$editor = reArrangeAuthorContents($row['editor'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
" " . $markupPatternsArray["ampersand"] . " ", // 5. | |||||
"/ *, */", // 6. | |||||
", ", // 7. | |||||
", ", // 8. | |||||
".", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"4", // 13. | |||||
"1", // 14. | |||||
" et al", // 15. | |||||
$encodeHTML); // 16. | |||||
$record .= " In: " . $editor . " "; | |||||
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';') | |||||
$record .= "eds."; | |||||
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s]) | |||||
$record .= "ed."; | |||||
} | |||||
$publication = preg_replace("/[ \r\n]*\(Eds?:[^\)\r\n]*\)/i", "", $row['publication']); | |||||
if (!empty($publication)) // publication | |||||
{ | |||||
if (empty($row['editor'])) | |||||
$record .= " In:"; | |||||
$record .= " " . $markupPatternsArray["italic-prefix"] . $publication . $markupPatternsArray["italic-suffix"]; | |||||
} | |||||
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition']) || !empty($row['volume'])) | |||||
{ | |||||
$record .= ". "; | |||||
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // edition | |||||
{ | |||||
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd ed.") | |||||
{ | |||||
if ($row['edition'] == "2") | |||||
$editionSuffix = "nd"; | |||||
elseif ($row['edition'] == "3") | |||||
$editionSuffix = "rd"; | |||||
else | |||||
$editionSuffix = "th"; | |||||
} | |||||
else | |||||
$editionSuffix = ""; | |||||
if (!empty($row['edition']) && !preg_match("/( ed\.?| edition)$/i", $row['edition'])) | |||||
$editionSuffix .= " ed."; | |||||
$record .= $row['edition'] . $editionSuffix; | |||||
} | |||||
if (!empty($row['volume'])) // volume | |||||
{ | |||||
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) | |||||
$record .= ", "; | |||||
$record .= "vol. " . $row['volume']; // TODO: not sure whether this is correct (should this be printed before the edition number?) | |||||
} | |||||
} | |||||
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title | |||||
{ | |||||
$record .= ". "; | |||||
if (!empty($row['series_title'])) | |||||
$record .= $row['series_title']; // full series title | |||||
// if there's no full series title, we'll use the abbreviated series title instead: | |||||
elseif (!empty($row['abbrev_series_title'])) | |||||
$record .= $row['abbrev_series_title']; // abbreviated series title | |||||
if (!empty($row['series_volume'])||!empty($row['series_issue'])) | |||||
$record .= ", "; | |||||
if (!empty($row['series_volume'])) // series volume (I'm not really sure if -- for this cite style -- the series volume & issue should be rather omitted here) | |||||
$record .= "vol. " . $row['series_volume']; // TODO: not sure whether this is correct | |||||
if (!empty($row['series_issue'])) // series issue (see note for series volume) | |||||
{ | |||||
if (!empty($row['series_volume'])) | |||||
$record .= ", "; | |||||
$record .= "no. " . $row['series_issue']; // TODO: not sure whether this is correct | |||||
} | |||||
} | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
if (!empty($row['place'])) // place | |||||
$record .= " " . $row['place']; | |||||
if (!empty($row['publisher'])) // publisher | |||||
{ | |||||
if (!empty($row['place'])) | |||||
$record .= ","; | |||||
$record .= " " . $row['publisher']; | |||||
} | |||||
if (!empty($row['pages'])) // pages | |||||
{ | |||||
if (!empty($row['publisher']) || !empty($row['place'])) | |||||
$record .= ", "; | |||||
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p.", "pp."); // function 'formatPageInfo()' is defined in 'cite.inc.php' | |||||
} | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
} | |||||
// --- BEGIN TYPE = BOOK WHOLE / CONFERENCE VOLUME / JOURNAL / MANUAL / MANUSCRIPT / MAP / MISCELLANEOUS / PATENT / REPORT / SOFTWARE --- | |||||
else // if (preg_match("/Book Whole|Conference Volume|Journal|Manual|Manuscript|Map|Miscellaneous|Patent|Report|Software/", $row['type'])) | |||||
// note that this also serves as a fallback: unrecognized resource types will be formatted similar to whole books | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
$author = preg_replace("/[ \r\n]*\(eds?\)/i", "", $row['author']); | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($author, // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
" " . $markupPatternsArray["ampersand"] . " ", // 5. | |||||
"/ *, */", // 6. | |||||
", ", // 7. | |||||
", ", // 8. | |||||
".", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"4", // 13. | |||||
"1", // 14. | |||||
" et al", // 15. | |||||
$encodeHTML); // 16. | |||||
// if the author is actually the editor of the resource we'll append ', ed' (or ', eds') to the author string: | |||||
// [to distinguish editors from authors in the 'author' field, the 'modify.php' script does append ' (ed)' or ' (eds)' if appropriate, | |||||
// so we're just checking for these identifier strings here. Alternatively, we could check whether the editor field matches the author field] | |||||
if (preg_match("/[ \r\n]*\(ed\)/", $row['author'])) // single editor | |||||
$author = $author . " ed."; | |||||
elseif (preg_match("/[ \r\n]*\(eds\)/", $row['author'])) // multiple editors | |||||
$author = $author . " eds."; | |||||
$record .= $author; | |||||
} | |||||
if (!empty($row['year'])) // year | |||||
$record .= " (" . $row['year'] . ")"; | |||||
if (!empty($row['title'])) // title | |||||
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['title'] . $markupPatternsArray["italic-suffix"]; | |||||
if ($row['online_publication'] == "yes") // this record refers to an online publication | |||||
$record .= " [Internet]"; | |||||
if (!empty($row['editor']) && !preg_match("/[ \r\n]*\(eds?\)/", $row['author'])) // editor (if different from author, see note above regarding the check for ' (ed)' or ' (eds)') | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$editor = reArrangeAuthorContents($row['editor'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
" " . $markupPatternsArray["ampersand"] . " ", // 5. | |||||
"/ *, */", // 6. | |||||
", ", // 7. | |||||
", ", // 8. | |||||
".", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"4", // 13. | |||||
"1", // 14. | |||||
" et al", // 15. | |||||
$encodeHTML); // 16. | |||||
if (!empty($row['author']) || !empty($row['year']) || !empty($row['title'])) | |||||
$record .= " "; | |||||
$record .= " (" . $editor . " "; | |||||
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';') | |||||
$record .= "eds."; | |||||
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s]) | |||||
$record .= "ed."; | |||||
$record .= ")"; | |||||
} | |||||
if (!empty($row['edition']) || !empty($row['volume'])) | |||||
{ | |||||
if (!empty($row['author']) || !empty($row['year']) || !empty($row['title']) || (!empty($row['editor']) && !preg_match("/[ \r\n]*\(eds?\)/", $row['author']))) | |||||
$record .= ". "; | |||||
if ($row['type'] == "Software") // software edition (=version) | |||||
{ | |||||
if (!empty($row['edition'])) | |||||
{ | |||||
$record .= "Version " . $row['edition']; | |||||
if (!empty($row['volume']) || !empty($row['issue'])) | |||||
$record .= ", "; | |||||
} | |||||
if (!empty($row['issue'])) // issue (=day) | |||||
$record .= " " . $row['issue']; | |||||
if (!empty($row['volume'])) // volume (=month) | |||||
$record .= " " . $row['volume']; | |||||
} | |||||
elseif (!preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // regular edition (other than the first) | |||||
{ | |||||
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd ed.") | |||||
{ | |||||
if ($row['edition'] == "2") | |||||
$editionSuffix = "nd"; | |||||
elseif ($row['edition'] == "3") | |||||
$editionSuffix = "rd"; | |||||
else | |||||
$editionSuffix = "th"; | |||||
} | |||||
else | |||||
$editionSuffix = ""; | |||||
if (!empty($row['edition']) && !preg_match("/( ed\.?| edition)$/i", $row['edition'])) | |||||
$editionSuffix .= " ed."; | |||||
$record .= $row['edition'] . $editionSuffix; | |||||
if (!empty($row['volume'])) // volume | |||||
{ | |||||
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) | |||||
$record .= ", "; | |||||
$record .= "vol. " . $row['volume']; // TODO: not sure whether this is correct (should this be printed before the edition number?) | |||||
} | |||||
} | |||||
} | |||||
if ($row['type'] == "Software") // for software, add software label | |||||
{ | |||||
$record .= ", computer software."; | |||||
} | |||||
else // add series info | |||||
{ | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title | |||||
{ | |||||
$record .= " "; | |||||
if (!empty($row['series_title'])) | |||||
$record .= $row['series_title']; // full series title | |||||
// if there's no full series title, we'll use the abbreviated series title instead: | |||||
elseif (!empty($row['abbrev_series_title'])) | |||||
$record .= $row['abbrev_series_title']; // abbreviated series title | |||||
if (!empty($row['series_volume'])||!empty($row['series_issue'])) | |||||
$record .= ", "; | |||||
if (!empty($row['series_volume'])) // series volume (I'm not really sure if -- for this cite style -- the series volume & issue should be rather omitted here) | |||||
$record .= "vol. " . $row['series_volume']; // TODO: not sure whether this is correct | |||||
if (!empty($row['series_issue'])) // series issue (see note for series volume) | |||||
{ | |||||
if (!empty($row['series_volume'])) | |||||
$record .= ", "; | |||||
$record .= "no. " . $row['series_issue']; // TODO: not sure whether this is correct | |||||
} | |||||
$record .= "."; | |||||
} | |||||
} | |||||
if (!empty($row['thesis'])) // thesis | |||||
$record .= " " . $row['thesis']; | |||||
if (!empty($row['place']) || !empty($row['publisher'])) | |||||
{ | |||||
if (!empty($row['thesis'])) | |||||
$record .= ","; | |||||
if (!empty($row['place'])) // place (NOTE: should we omit the place of publication for theses?) | |||||
$record .= " " . $row['place']; | |||||
if (!empty($row['publisher'])) // publisher | |||||
{ | |||||
if (!empty($row['place'])) | |||||
$record .= ","; | |||||
$record .= " " . $row['publisher']; | |||||
} | |||||
} | |||||
if ($row['online_publication'] == "yes" || $row['type'] == "Software") // this record refers to an online article, or a computer program/software | |||||
{ | |||||
if (!empty($row['online_citation'])) // online_citation | |||||
{ | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
$record .= " " . $row['online_citation']; | |||||
} | |||||
if (!empty($row['doi']) || !empty($row['url'])) // doi OR url | |||||
{ | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
$today = date("j F Y"); | |||||
$record .= " Available from: "; | |||||
if (!empty($row['doi'])) // doi | |||||
$uri = "http://dx.doi.org/" . $row['doi']; | |||||
else // url | |||||
$uri = $row['url']; | |||||
if ($encodeHTML) | |||||
$record .= encodeHTML($markupPatternsArray["less-than"] . $uri . $markupPatternsArray["greater-than"]); | |||||
else | |||||
$record .= $markupPatternsArray["less-than"] . $uri . $markupPatternsArray["greater-than"]; | |||||
$record .= " [Accessed " . $today . "]"; | |||||
} | |||||
} | |||||
if (!preg_match("/\. *$/", $record)) // if the string doesn't end with a period | |||||
$record .= "."; | |||||
} | |||||
// --- BEGIN POST-PROCESSING ----------------------------------------------------------------------------------------------------------- | |||||
// do some further cleanup: | |||||
$record = trim($record); // remove any preceding or trailing whitespace | |||||
return $record; | |||||
} | |||||
// --- END CITATION STYLE --- | |||||
?> |
@ -0,0 +1,684 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./cite/styles/cite_Harvard_3.php | |||||
// Repository: $HeadURL$ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 01-Aug-08, 02:00 | |||||
// Modified: $Date: 2012-02-27 20:25:30 +0000 (Mon, 27 Feb 2012) $ | |||||
// $Author$ | |||||
// $Revision: 1337 $ | |||||
// This is a citation style file (which must reside within the 'cite/styles/' sub-directory of your refbase root directory). It contains a | |||||
// version of the 'citeRecord()' function that outputs a reference list from selected records according to the citation style used by | |||||
// the Harvard referencing system | |||||
// This is a variant of the Harvard author/date style, modeled after these resources: | |||||
// <http://library.curtin.edu.au/referencing/harvard.html> (not available anymore?) | |||||
// <http://www.usq.edu.au/library/help/ehelp/ref_guides/harvard.htm> | |||||
// <http://www.library.uwa.edu.au/education_training_and_support/guides/harvard_citation_style> | |||||
// <http://www.lib.unimelb.edu.au/cite/harvard_dis/> | |||||
// based on 'cite_APA.php' | |||||
// TODO: - patents & reports? | |||||
// - should we shorten ending page numbers if necessary (e.g. "pp. 10-8" or "pp. 51-5", but "pp. 19-26"), or only if numbers are >=3 digits? | |||||
// - where to put (and how to format) series info & editors of whole books that also have an author? | |||||
// -------------------------------------------------------------------- | |||||
// --- BEGIN CITATION STYLE --- | |||||
function citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, $encodeHTML) | |||||
{ | |||||
$record = ""; // make sure that our buffer variable is empty | |||||
// --- BEGIN TYPE = JOURNAL ARTICLE / MAGAZINE ARTICLE / NEWSPAPER ARTICLE -------------------------------------------------------------- | |||||
if (preg_match("/^(Journal Article|Magazine Article|Newspaper Article)$/", $row['type'])) | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($row['author'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
" " . $markupPatternsArray["ampersand"] . " ", // 5. | |||||
"/ *, */", // 6. | |||||
", ", // 7. | |||||
", ", // 8. | |||||
"", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"", // 13. | |||||
"", // 14. | |||||
" et al", // 15. | |||||
$encodeHTML); // 16. | |||||
$record .= $author; | |||||
} | |||||
if (!empty($row['year'])) // year | |||||
{ | |||||
if (!empty($row['author'])) | |||||
$record .= " "; | |||||
if (!empty($row['year'])) | |||||
$record .= $row['year']; | |||||
} | |||||
if (!empty($row['title'])) // title | |||||
{ | |||||
if (!empty($row['author']) || !empty($row['year'])) | |||||
$record .= ", "; | |||||
$record .= $markupPatternsArray["single-quote-left"] . $row['title'] . $markupPatternsArray["single-quote-right"]; | |||||
$record .= ","; | |||||
} | |||||
// From here on we'll assume that at least one of the fields 'author', 'year' or 'title' did contain some contents | |||||
if (!empty($row['publication'])) // publication (= journal) name | |||||
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['publication'] . $markupPatternsArray["italic-suffix"]; | |||||
// if there's no full journal name, we'll use the abbreviated journal name instead: | |||||
elseif (!empty($row['abbrev_journal'])) // abbreviated journal name | |||||
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['abbrev_journal'] . $markupPatternsArray["italic-suffix"]; | |||||
if ((!empty($row['abbrev_journal']) || !empty($row['publication'])) && (!empty($row['volume']) || !empty($row['issue']))) | |||||
$record .= ","; | |||||
if ($row['type'] == "Journal Article") // for journal articles, volume (or issue) information is printed with a "vol." (or "no.") prefix | |||||
{ | |||||
if (!empty($row['volume'])) // volume | |||||
$record .= " vol. " . $row['volume']; | |||||
if (!empty($row['issue'])) // issue | |||||
{ | |||||
if (!empty($row['volume'])) | |||||
$record .= ","; | |||||
$record .= " no. " . $row['issue']; | |||||
} | |||||
} | |||||
elseif (preg_match("/^(Newspaper Article|Magazine Article)$/", $row['type'])) // for newspaper and magazine articles, volume (=month) and issue (=day) information is printed without prefix | |||||
{ | |||||
if (!empty($row['issue'])) // issue (=day) | |||||
$record .= " " . $row['issue']; | |||||
if (!empty($row['volume'])) // volume (=month) | |||||
$record .= " " . $row['volume']; | |||||
} | |||||
if (!empty($row['pages'])) // pages | |||||
{ | |||||
if (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add ", " if either volume, issue, abbrev_journal or publication isn't empty | |||||
$record .= ", "; | |||||
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p. ", "pp. "); // function 'formatPageInfo()' is defined in 'cite.inc.php' | |||||
} | |||||
if ($row['online_publication'] == "yes") // this record refers to an online article | |||||
{ | |||||
// append an optional string (given in 'online_citation') plus the current date and the DOI (or URL): | |||||
if (!empty($row['online_citation'])) // online_citation | |||||
{ | |||||
if (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add "," if either volume, issue, abbrev_journal or publication isn't empty | |||||
$record .= ","; | |||||
$record .= " " . $row['online_citation']; | |||||
} | |||||
if (!empty($row['doi']) || !empty($row['url'])) // doi OR url | |||||
{ | |||||
if (!empty($row['online_citation']) OR (empty($row['online_citation']) AND (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])))) // only add "." if online_citation isn't empty, or else if either volume, issue, abbrev_journal or publication isn't empty | |||||
$record .= "."; | |||||
$today = date("j F Y"); | |||||
$record .= " Available from: "; // NOTE: some of the above mentioned resources use ", accessed 26 February 2004, from <http://...>." (or ", viewed on ...") instead | |||||
if (!empty($row['doi'])) // doi | |||||
$uri = "http://dx.doi.org/" . $row['doi']; | |||||
else // url | |||||
$uri = $row['url']; | |||||
if ($encodeHTML) | |||||
$record .= encodeHTML($markupPatternsArray["less-than"] . $uri . $markupPatternsArray["greater-than"]); | |||||
else | |||||
$record .= $markupPatternsArray["less-than"] . $uri . $markupPatternsArray["greater-than"]; | |||||
$record .= " [" . $today . "]"; | |||||
} | |||||
} | |||||
if (!preg_match("/\. *$/", $record)) // if the string doesn't end with a period | |||||
$record .= "."; | |||||
} | |||||
// --- BEGIN TYPE = ABSTRACT / BOOK CHAPTER / CONFERENCE ARTICLE ------------------------------------------------------------------------ | |||||
elseif (preg_match("/^(Abstract|Book Chapter|Conference Article)$/", $row['type'])) | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($row['author'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
" " . $markupPatternsArray["ampersand"] . " ", // 5. | |||||
"/ *, */", // 6. | |||||
", ", // 7. | |||||
", ", // 8. | |||||
"", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"", // 13. | |||||
"", // 14. | |||||
" et al", // 15. | |||||
$encodeHTML); // 16. | |||||
$record .= $author; | |||||
} | |||||
if (!empty($row['year'])) // year | |||||
{ | |||||
if (!empty($row['author'])) | |||||
$record .= " "; | |||||
$record .= $row['year']; | |||||
} | |||||
if (!empty($row['title'])) // title | |||||
{ | |||||
if (!empty($row['author']) || !empty($row['year'])) | |||||
$record .= ", "; | |||||
$record .= $markupPatternsArray["single-quote-left"] . $row['title'] . $markupPatternsArray["single-quote-right"]; | |||||
$record .= ","; | |||||
} | |||||
// From here on we'll assume that at least one of the fields 'author', 'year' or 'title' did contain some contents | |||||
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below) | |||||
if (!empty($row['editor'])) // editor | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$editor = reArrangeAuthorContents($row['editor'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
" " . $markupPatternsArray["ampersand"] . " ", // 5. | |||||
"/ *, */", // 6. | |||||
" ", // 7. | |||||
" ", // 8. | |||||
"", // 9. | |||||
true, // 10. | |||||
true, // 11. | |||||
true, // 12. | |||||
"", // 13. | |||||
"", // 14. | |||||
" et al", // 15. | |||||
$encodeHTML); // 16. | |||||
$record .= " in " . $editor . " ("; | |||||
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';') | |||||
$record .= "eds."; | |||||
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s]) | |||||
$record .= "ed."; | |||||
$record .= "),"; | |||||
} | |||||
$publication = preg_replace("/[ \r\n]*\(Eds?:[^\)\r\n]*\)/i", "", $row['publication']); | |||||
if (!empty($publication)) // publication | |||||
{ | |||||
if (empty($row['editor'])) | |||||
$record .= " in"; | |||||
$record .= " " . $markupPatternsArray["italic-prefix"] . $publication . $markupPatternsArray["italic-suffix"]; | |||||
} | |||||
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition']) || !empty($row['volume'])) | |||||
{ | |||||
$record .= ", "; | |||||
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // edition | |||||
{ | |||||
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd edn") | |||||
{ | |||||
if ($row['edition'] == "2") | |||||
$editionSuffix = "nd"; | |||||
elseif ($row['edition'] == "3") | |||||
$editionSuffix = "rd"; | |||||
else | |||||
$editionSuffix = "th"; | |||||
} | |||||
else | |||||
$editionSuffix = ""; | |||||
if (!empty($row['edition']) && !preg_match("/( ed\.?| edition)$/i", $row['edition'])) | |||||
$editionSuffix .= " edn"; | |||||
$record .= $row['edition'] . $editionSuffix; | |||||
} | |||||
if (!empty($row['volume'])) // volume | |||||
{ | |||||
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) | |||||
$record .= ", "; | |||||
$record .= "vol. " . $row['volume']; | |||||
} | |||||
} | |||||
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title | |||||
{ | |||||
$record .= ", "; | |||||
if (!empty($row['series_title'])) | |||||
$record .= $row['series_title']; // full series title | |||||
// if there's no full series title, we'll use the abbreviated series title instead: | |||||
elseif (!empty($row['abbrev_series_title'])) | |||||
$record .= $row['abbrev_series_title']; // abbreviated series title | |||||
if (!empty($row['series_volume'])||!empty($row['series_issue'])) | |||||
$record .= ", "; | |||||
if (!empty($row['series_volume'])) // series volume (I'm not really sure if -- for this cite style -- the series volume & issue should be rather omitted here) | |||||
$record .= "vol. " . $row['series_volume']; | |||||
if (!empty($row['series_issue'])) // series issue (see note for series volume) | |||||
{ | |||||
if (!empty($row['series_volume'])) | |||||
$record .= ", "; | |||||
$record .= "no. " . $row['series_issue']; | |||||
} | |||||
} | |||||
$record .= ","; | |||||
if (!empty($row['publisher'])) // publisher | |||||
$record .= " " . $row['publisher']; | |||||
if (!empty($row['place'])) // place | |||||
{ | |||||
if (!empty($row['publisher'])) | |||||
$record .= ","; | |||||
$record .= " " . $row['place']; | |||||
} | |||||
if (!empty($row['pages'])) // pages | |||||
{ | |||||
if (!empty($row['publisher']) || !empty($row['place'])) | |||||
$record .= ", "; | |||||
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p. ", "pp. "); // function 'formatPageInfo()' is defined in 'cite.inc.php' | |||||
} | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
} | |||||
// --- BEGIN TYPE = BOOK WHOLE / CONFERENCE VOLUME / JOURNAL / MANUAL / MANUSCRIPT / MAP / MISCELLANEOUS / PATENT / REPORT / SOFTWARE --- | |||||
else // if (preg_match("/Book Whole|Conference Volume|Journal|Manual|Manuscript|Map|Miscellaneous|Patent|Report|Software/", $row['type'])) | |||||
// note that this also serves as a fallback: unrecognized resource types will be formatted similar to whole books | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
$author = preg_replace("/[ \r\n]*\(eds?\)/i", "", $row['author']); | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($author, // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
" " . $markupPatternsArray["ampersand"] . " ", // 5. | |||||
"/ *, */", // 6. | |||||
", ", // 7. | |||||
", ", // 8. | |||||
"", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"", // 13. | |||||
"", // 14. | |||||
" et al", // 15. | |||||
$encodeHTML); // 16. | |||||
// if the author is actually the editor of the resource we'll append ', ed' (or ', eds') to the author string: | |||||
// [to distinguish editors from authors in the 'author' field, the 'modify.php' script does append ' (ed)' or ' (eds)' if appropriate, | |||||
// so we're just checking for these identifier strings here. Alternatively, we could check whether the editor field matches the author field] | |||||
if (preg_match("/[ \r\n]*\(ed\)/", $row['author'])) // single editor | |||||
$author = $author . " (ed.)"; | |||||
elseif (preg_match("/[ \r\n]*\(eds\)/", $row['author'])) // multiple editors | |||||
$author = $author . " (eds.)"; | |||||
$record .= $author; | |||||
} | |||||
if (!empty($row['year'])) // year | |||||
{ | |||||
if (!empty($row['author'])) | |||||
$record .= " "; | |||||
$record .= $row['year']; | |||||
} | |||||
if (!empty($row['title'])) // title | |||||
{ | |||||
if (!empty($row['author']) || !empty($row['year'])) | |||||
$record .= ", "; | |||||
if (!empty($row['thesis'])) // for theses, the title is printed in roman type and in quotation marks | |||||
$record .= $markupPatternsArray["single-quote-left"] . $row['title'] . $markupPatternsArray["single-quote-right"]; | |||||
else // otherwise, the title is printed in italics | |||||
$record .= $markupPatternsArray["italic-prefix"] . $row['title'] . $markupPatternsArray["italic-suffix"]; | |||||
} | |||||
if (!empty($row['editor']) && !preg_match("/[ \r\n]*\(eds?\)/", $row['author'])) // editor (if different from author, see note above regarding the check for ' (ed)' or ' (eds)') | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$editor = reArrangeAuthorContents($row['editor'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
" " . $markupPatternsArray["ampersand"] . " ", // 5. | |||||
"/ *, */", // 6. | |||||
" ", // 7. | |||||
" ", // 8. | |||||
"", // 9. | |||||
true, // 10. | |||||
true, // 11. | |||||
true, // 12. | |||||
"", // 13. | |||||
"", // 14. | |||||
" et al", // 15. | |||||
$encodeHTML); // 16. | |||||
if (!empty($row['author']) || !empty($row['year']) || !empty($row['title'])) | |||||
$record .= " "; | |||||
$record .= " (" . $editor . ", "; | |||||
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';') | |||||
$record .= "eds."; | |||||
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s]) | |||||
$record .= "ed."; | |||||
$record .= ")"; | |||||
} | |||||
if (!empty($row['edition']) || !empty($row['volume'])) | |||||
{ | |||||
if (!empty($row['author']) || !empty($row['year']) || !empty($row['title']) || (!empty($row['editor']) && !preg_match("/[ \r\n]*\(eds?\)/", $row['author']))) | |||||
$record .= ", "; | |||||
if ($row['type'] == "Software") // software edition (=version) | |||||
{ | |||||
if (!empty($row['edition'])) | |||||
{ | |||||
$record .= "version " . $row['edition']; | |||||
if (!empty($row['volume']) || !empty($row['issue'])) | |||||
$record .= ", "; | |||||
} | |||||
if (!empty($row['issue'])) // issue (=day) | |||||
$record .= " " . $row['issue']; | |||||
if (!empty($row['volume'])) // volume (=month) | |||||
$record .= " " . $row['volume']; | |||||
} | |||||
elseif (!preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // regular edition (other than the first) | |||||
{ | |||||
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd edn") | |||||
{ | |||||
if ($row['edition'] == "2") | |||||
$editionSuffix = "nd"; | |||||
elseif ($row['edition'] == "3") | |||||
$editionSuffix = "rd"; | |||||
else | |||||
$editionSuffix = "th"; | |||||
} | |||||
else | |||||
$editionSuffix = ""; | |||||
if (!empty($row['edition']) && !preg_match("/( ed\.?| edition)$/i", $row['edition'])) | |||||
$editionSuffix .= " edn"; | |||||
$record .= $row['edition'] . $editionSuffix; | |||||
if (!empty($row['volume'])) // volume | |||||
{ | |||||
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) | |||||
$record .= ", "; | |||||
$record .= "vol. " . $row['volume']; | |||||
} | |||||
} | |||||
} | |||||
if ($row['type'] == "Software") // for software, add software label | |||||
{ | |||||
$record .= ", computer software"; | |||||
} | |||||
else // add series info | |||||
{ | |||||
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title | |||||
{ | |||||
if ((!empty($row['title']) && !preg_match("/[?!.]$/", $row['title'])) || (!empty($row['editor']) && !preg_match("/[ \r\n]*\(eds?\)/", $row['author'])) || !empty($row['edition']) || !empty($row['volume'])) | |||||
$record .= ","; | |||||
$record .= " "; | |||||
if (!empty($row['series_title'])) | |||||
$record .= $row['series_title']; // full series title | |||||
// if there's no full series title, we'll use the abbreviated series title instead: | |||||
elseif (!empty($row['abbrev_series_title'])) | |||||
$record .= $row['abbrev_series_title']; // abbreviated series title | |||||
if (!empty($row['series_volume'])||!empty($row['series_issue'])) | |||||
$record .= ", "; | |||||
if (!empty($row['series_volume'])) // series volume (I'm not really sure if -- for this cite style -- the series volume & issue should be rather omitted here) | |||||
$record .= "vol. " . $row['series_volume']; | |||||
if (!empty($row['series_issue'])) // series issue (see note for series volume) | |||||
{ | |||||
if (!empty($row['series_volume'])) | |||||
$record .= ", "; | |||||
$record .= "no. " . $row['series_issue']; | |||||
} | |||||
} | |||||
} | |||||
if (!empty($row['thesis'])) // thesis | |||||
{ | |||||
$record .= ", " . $row['thesis']; | |||||
$record .= ", " . $row['publisher']; | |||||
$record .= ", " . $row['place']; // NOTE: should we omit the place of publication for theses? | |||||
} | |||||
else // not a thesis | |||||
{ | |||||
if (!empty($row['publisher'])) // publisher | |||||
$record .= ", " . $row['publisher']; | |||||
if (!empty($row['place'])) // place | |||||
{ | |||||
if (!empty($row['publisher'])) | |||||
$record .= ","; | |||||
$record .= " " . $row['place']; | |||||
} | |||||
} | |||||
if ($row['online_publication'] == "yes" || $row['type'] == "Software") // this record refers to an online article, or a computer program/software | |||||
{ | |||||
if (!empty($row['online_citation'])) // online_citation | |||||
{ | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
$record .= " " . $row['online_citation']; | |||||
} | |||||
if (!empty($row['doi']) || !empty($row['url'])) // doi OR url | |||||
{ | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
$today = date("j F Y"); | |||||
$record .= " Available from: "; // NOTE: some of the above mentioned resources use ", accessed 26 February 2004, from <http://...>." (or ", viewed on ...") instead | |||||
if (!empty($row['doi'])) // doi | |||||
$uri = "http://dx.doi.org/" . $row['doi']; | |||||
else // url | |||||
$uri = $row['url']; | |||||
if ($encodeHTML) | |||||
$record .= encodeHTML($markupPatternsArray["less-than"] . $uri . $markupPatternsArray["greater-than"]); | |||||
else | |||||
$record .= $markupPatternsArray["less-than"] . $uri . $markupPatternsArray["greater-than"]; | |||||
$record .= " [" . $today . "]"; | |||||
} | |||||
} | |||||
if (!preg_match("/\. *$/", $record)) // if the string doesn't end with a period | |||||
$record .= "."; | |||||
} | |||||
// --- BEGIN POST-PROCESSING ----------------------------------------------------------------------------------------------------------- | |||||
// do some further cleanup: | |||||
$record = trim($record); // remove any preceding or trailing whitespace | |||||
return $record; | |||||
} | |||||
// --- END CITATION STYLE --- | |||||
?> |
@ -0,0 +1,660 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./cite/styles/cite_MLA.php | |||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/cite/styles/cite_MLA.php $ | |||||
// Author(s): Richard Karnesky <mailto:karnesky@gmail.com> and | |||||
// Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 13-Nov-06, 15:00 | |||||
// Modified: $Date: 2012-02-27 20:25:30 +0000 (Mon, 27 Feb 2012) $ | |||||
// $Author: msteffens $ | |||||
// $Revision: 1337 $ | |||||
// This is a citation style file (which must reside within the 'cite/styles/' sub-directory of your refbase root directory). It contains a | |||||
// version of the 'citeRecord()' function that outputs a reference list from selected records according to the citation style used by | |||||
// the Modern Language Association (MLA) | |||||
// based on 'cite_APA.php' | |||||
// TODO: - newspaper & magazine articles, conference proceedings, manuals, patents, reports, software, published dissertation | |||||
// - use dashes for subsequent entries when citing two or more books by the same author -> see e.g. example at: <http://web.csustan.edu/english/reuben/pal/append/AXI.HTML> | |||||
// - don't add a dot if the abbreviated journal (or series title) ends with a dot! | |||||
// -------------------------------------------------------------------- | |||||
// --- BEGIN CITATION STYLE --- | |||||
function citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, $encodeHTML) | |||||
{ | |||||
$record = ""; // make sure that our buffer variable is empty | |||||
// --- BEGIN TYPE = JOURNAL ARTICLE / MAGAZINE ARTICLE / NEWSPAPER ARTICLE -------------------------------------------------------------- | |||||
if (preg_match("/^(Journal Article|Magazine Article|Newspaper Article)$/", $row['type'])) | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($row['author'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", and ", // 5. | |||||
"/ *, */", // 6. | |||||
", ", // 7. | |||||
" ", // 8. | |||||
". ", // 9. | |||||
false, // 10. | |||||
true, // 11. | |||||
false, // 12. | |||||
"3", // 13. | |||||
"1", // 14. | |||||
", et al.", // 15. | |||||
$encodeHTML); // 16. | |||||
if (!preg_match("/\. *$/", $author)) | |||||
$record .= $author . "."; | |||||
else | |||||
$record .= $author; | |||||
} | |||||
if (!empty($row['title'])) // title | |||||
{ | |||||
if (!empty($row['author'])) | |||||
$record .= " "; | |||||
$record .= '"' . $row['title']; | |||||
if (!preg_match("/[?!.]$/", $row['title'])) | |||||
$record .= "."; | |||||
$record .= '"'; | |||||
} | |||||
// From here on we'll assume that at least either the 'author' or the 'title' field did contain some contents | |||||
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below) | |||||
if (!empty($row['abbrev_journal'])) // abbreviated journal name | |||||
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['abbrev_journal'] . $markupPatternsArray["italic-suffix"]; | |||||
// if there's no abbreviated journal name, we'll use the full journal name | |||||
elseif (!empty($row['publication'])) // publication (= journal) name | |||||
$record .= " " . $markupPatternsArray["italic-prefix"] . $row['publication'] . $markupPatternsArray["italic-suffix"]; | |||||
if (!empty($row['volume'])) // volume | |||||
{ | |||||
if (!empty($row['abbrev_journal']) || !empty($row['publication'])) | |||||
$record .= "."; | |||||
$record .= " " . $row['volume']; | |||||
} | |||||
if (!empty($row['issue'])) // issue | |||||
$record .= "." . $row['issue']; | |||||
if (!empty($row['year'])) // year | |||||
{ | |||||
$record .= " (".$row['year'] . ")"; | |||||
} | |||||
if ($row['online_publication'] == "yes") // this record refers to an online article | |||||
{ | |||||
// instead of any pages info (which normally doesn't exist for online publications) we append | |||||
// an optional string (given in 'online_citation') plus the current date and the DOI (or URL): | |||||
$today = date("j M. Y"); | |||||
if (!empty($row['online_citation'])) // online_citation | |||||
{ | |||||
if (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add ":" if either volume, issue, abbrev_journal or publication isn't empty | |||||
$record .= ":"; | |||||
$record .= " " . $row['online_citation']; | |||||
} | |||||
if (!empty($row['doi'])) // doi | |||||
{ | |||||
if (!empty($row['online_citation']) OR (empty($row['online_citation']) AND (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])))) // only add "." if online_citation isn't empty, or else if either volume, issue, abbrev_journal or publication isn't empty | |||||
$record .= "."; | |||||
if ($encodeHTML) | |||||
$record .= " " . $today . encodeHTML(" <http://dx.doi.org/" . $row['doi'] . ">"); | |||||
else | |||||
$record .= " " . $today . " <http://dx.doi.org/" . $row['doi'] . ">"; | |||||
} | |||||
elseif (!empty($row['url'])) // url | |||||
{ | |||||
if (!empty($row['online_citation']) OR (empty($row['online_citation']) AND (!empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])))) // only add "." if online_citation isn't empty, or else if either volume, issue, abbrev_journal or publication isn't empty | |||||
$record .= "."; | |||||
if ($encodeHTML) | |||||
$record .= " " . $today . encodeHTML(" <" . $row['url'] . ">"); | |||||
else | |||||
$record .= " " . $today . " <" . $row['url'] . ">"; | |||||
} | |||||
} | |||||
else // $row['online_publication'] == "no" -> this record refers to a printed article, so we append any pages info instead: | |||||
{ | |||||
if (!empty($row['pages'])) // pages | |||||
{ | |||||
if (!empty($row['year']) || !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add ": " if either volume, issue, abbrev_journal or publication isn't empty | |||||
$record .= ": "; | |||||
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"]); // function 'formatPageInfo()' is defined in 'cite.inc.php' | |||||
} | |||||
} | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
} | |||||
// --- BEGIN TYPE = ABSTRACT / BOOK CHAPTER / CONFERENCE ARTICLE ------------------------------------------------------------------------ | |||||
elseif (preg_match("/^(Abstract|Book Chapter|Conference Article)$/", $row['type'])) | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($row['author'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", and ", // 5. | |||||
"/ *, */", // 6. | |||||
", ", // 7. | |||||
" ", // 8. | |||||
". ", // 9. | |||||
false, // 10. | |||||
true, // 11. | |||||
false, // 12. | |||||
"3", // 13. | |||||
"1", // 14. | |||||
", et al.", // 15. | |||||
$encodeHTML); // 16. | |||||
if (!preg_match("/\. *$/", $author)) | |||||
$record .= $author . "."; | |||||
else | |||||
$record .= $author; | |||||
} | |||||
if (!empty($row['title'])) // title | |||||
{ | |||||
if (!empty($row['author'])) | |||||
$record .= " "; | |||||
$record .= '"' . $row['title']; | |||||
if (!preg_match("/[?!.]$/", $row['title'])) | |||||
$record .= "."; | |||||
$record .= '"'; | |||||
} | |||||
$publication = preg_replace("/[ \r\n]*\(Eds?:[^\)\r\n]*\)/i", "", $row['publication']); | |||||
if (!empty($publication)) // publication | |||||
$record .= " " . $markupPatternsArray["italic-prefix"] . $publication . $markupPatternsArray["italic-suffix"]; | |||||
// From here on we'll assume that at least either the 'author' or the 'title' field did contain some contents | |||||
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below) | |||||
if (!empty($row['editor'])) // editor | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$editor = reArrangeAuthorContents($row['editor'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", and ", // 5. | |||||
"/ *, */", // 6. | |||||
" ", // 7. | |||||
" ", // 8. | |||||
". ", // 9. | |||||
true, // 10. | |||||
true, // 11. | |||||
false, // 12. | |||||
"3", // 13. | |||||
"1", // 14. | |||||
", et al.", // 15. | |||||
$encodeHTML); // 16. | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';') | |||||
$record .= " Eds. " . $editor; | |||||
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s]) | |||||
$record .= " Ed. " . $editor; | |||||
} | |||||
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // edition | |||||
{ | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd ed.") | |||||
{ | |||||
if ($row['edition'] == "2") | |||||
$editionSuffix = "nd"; | |||||
elseif ($row['edition'] == "3") | |||||
$editionSuffix = "rd"; | |||||
else | |||||
$editionSuffix = "th"; | |||||
} | |||||
else | |||||
$editionSuffix = ""; | |||||
if (preg_match("/^(Rev\.?|Revised)( ed\.?| edition)?$/i", $row['edition'])) | |||||
$row['edition'] = "Rev."; | |||||
elseif (preg_match("/^(Abr\.?|Abridged)( ed\.?| edition)?$/i", $row['edition'])) | |||||
$row['edition'] = "Abr."; | |||||
if (!preg_match("/( ed\.?| edition)$/i", $row['edition'])) | |||||
$editionSuffix .= " ed."; | |||||
$record .= " " . $row['edition'] . $editionSuffix; | |||||
} | |||||
if (!empty($row['volume'])) // volume | |||||
{ | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
$record .= " Vol. " . $row['volume']; | |||||
} | |||||
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title | |||||
{ | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
$record .= " "; | |||||
if (!empty($row['abbrev_series_title'])) | |||||
$record .= $row['abbrev_series_title']; // abbreviated series title | |||||
// if there's no abbreviated series title, we'll use the full series title instead: | |||||
elseif (!empty($row['series_title'])) | |||||
$record .= $row['series_title']; // full series title | |||||
if (!empty($row['series_volume'])||!empty($row['series_issue'])) | |||||
$record .= ", "; | |||||
if (!empty($row['series_volume'])) // series volume | |||||
$record .= $row['series_volume']; | |||||
if (!empty($row['series_issue'])) // series issue (I'm not really sure if -- for this cite style -- the series issue should be rather omitted here) | |||||
$record .= "." . $row['series_issue']; // is it correct to format series issues similar to journal article issues? | |||||
} | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
if (!empty($row['place'])) // place | |||||
$record .= " " . $row['place']; | |||||
if (!empty($row['publisher'])) // publisher | |||||
{ | |||||
if (!empty($row['place'])) | |||||
$record .= ":"; | |||||
$record .= " " . $row['publisher']; | |||||
} | |||||
if (!empty($row['year'])) // year | |||||
{ | |||||
$record .= ", " . $row['year']; | |||||
} | |||||
if (!empty($row['pages'])) // pages | |||||
$record .= ". " . formatPageInfo($row['pages'], $markupPatternsArray["endash"]); // function 'formatPageInfo()' is defined in 'cite.inc.php' | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
} | |||||
// --- BEGIN TYPE = BOOK WHOLE / CONFERENCE VOLUME / JOURNAL / MANUAL / MANUSCRIPT / MAP / MISCELLANEOUS / PATENT / REPORT / SOFTWARE --- | |||||
else // if (preg_match("/Book Whole|Conference Volume|Journal|Manual|Manuscript|Map|Miscellaneous|Patent|Report|Software/", $row['type'])) | |||||
// note that this also serves as a fallback: unrecognized resource types will be formatted similar to whole books | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
$author = preg_replace("/[ \r\n]*\(eds?\)/i", "", $row['author']); | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($author, // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", and ", // 5. | |||||
"/ *, */", // 6. | |||||
", ", // 7. | |||||
" ", // 8. | |||||
". ", // 9. | |||||
false, // 10. | |||||
true, // 11. | |||||
false, // 12. | |||||
"3", // 13. | |||||
"1", // 14. | |||||
", et al.", // 15. | |||||
$encodeHTML); // 16. | |||||
// if the author is actually the editor of the resource we'll append ', ed' (or ', eds') to the author string: | |||||
// [to distinguish editors from authors in the 'author' field, the 'modify.php' script does append ' (ed)' or ' (eds)' if appropriate, | |||||
// so we're just checking for these identifier strings here. Alternatively, we could check whether the editor field matches the author field] | |||||
if (preg_match("/[ \r\n]*\(ed\)/", $row['author'])) // single editor | |||||
$author = $author . ", " . "ed"; | |||||
elseif (preg_match("/[ \r\n]*\(eds\)/", $row['author'])) // multiple editors | |||||
$author = $author . ", " . "eds"; | |||||
if (!preg_match("/\. *$/", $author)) | |||||
$record .= $author . "."; | |||||
else | |||||
$record .= $author; | |||||
} | |||||
if (!empty($row['title'])) // title | |||||
{ | |||||
if (!empty($row['author'])) | |||||
$record .= " "; | |||||
if (!empty($row['thesis'])) // thesis | |||||
{ | |||||
$record .= '"' . $row['title']; | |||||
if (!preg_match("/[?!.]$/", $row['title'])) | |||||
$record .= "."; | |||||
$record .= '"'; | |||||
} | |||||
else // not a thesis | |||||
$record .= $markupPatternsArray["italic-prefix"] . $row['title'] . $markupPatternsArray["italic-suffix"]; | |||||
} | |||||
if (!empty($row['editor']) && !preg_match("/[ \r\n]*\(eds?\)/", $row['author'])) // editor (if different from author, see note above regarding the check for ' (ed)' or ' (eds)') | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$editor = reArrangeAuthorContents($row['editor'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", and ", // 5. | |||||
"/ *, */", // 6. | |||||
" ", // 7. | |||||
" ", // 8. | |||||
". ", // 9. | |||||
true, // 10. | |||||
true, // 11. | |||||
false, // 12. | |||||
"3", // 13. | |||||
"1", // 14. | |||||
", et al.", // 15. | |||||
$encodeHTML); // 16. | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';') | |||||
$record .= " Eds. " . $editor; | |||||
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s]) | |||||
$record .= " Ed. " . $editor; | |||||
} | |||||
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // edition | |||||
{ | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd ed.") | |||||
{ | |||||
if ($row['edition'] == "2") | |||||
$editionSuffix = "nd"; | |||||
elseif ($row['edition'] == "3") | |||||
$editionSuffix = "rd"; | |||||
else | |||||
$editionSuffix = "th"; | |||||
} | |||||
else | |||||
$editionSuffix = ""; | |||||
if (preg_match("/^(Rev\.?|Revised)( ed\.?| edition)?$/i", $row['edition'])) | |||||
$row['edition'] = "Rev."; | |||||
elseif (preg_match("/^(Abr\.?|Abridged)( ed\.?| edition)?$/i", $row['edition'])) | |||||
$row['edition'] = "Abr."; | |||||
if (!preg_match("/( ed\.?| edition)$/i", $row['edition'])) | |||||
$editionSuffix .= " ed."; | |||||
$record .= " " . $row['edition'] . $editionSuffix; | |||||
} | |||||
if (!empty($row['volume'])) // volume | |||||
{ | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
$record .= " Vol. " . $row['volume']; | |||||
} | |||||
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title | |||||
{ | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
$record .= " "; | |||||
if (!empty($row['abbrev_series_title'])) | |||||
$record .= $row['abbrev_series_title']; // abbreviated series title | |||||
// if there's no abbreviated series title, we'll use the full series title instead: | |||||
elseif (!empty($row['series_title'])) | |||||
$record .= $row['series_title']; // full series title | |||||
if (!empty($row['series_volume'])||!empty($row['series_issue'])) | |||||
$record .= ", "; | |||||
if (!empty($row['series_volume'])) // series volume | |||||
$record .= $row['series_volume']; | |||||
if (!empty($row['series_issue'])) // series issue (I'm not really sure if -- for this cite style -- the series issue should be rather omitted here) | |||||
$record .= "." . $row['series_issue']; // is it correct to format series issues similar to journal article issues? | |||||
} | |||||
if (!empty($row['thesis'])) // thesis (unpublished dissertation) | |||||
{ | |||||
// TODO: a published dissertation needs to be formatted differently! | |||||
// see e.g. example at: <http://web.csustan.edu/english/reuben/pal/append/AXI.HTML> | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
// TODO: I've also seen MLA examples that separate thesis name, name of institution and year by dots. ?:-| | |||||
// Also, do we need to use the abbreviation "Diss." instead of "Ph.D. thesis"? What about other thesis types then? | |||||
// see e.g. <http://www.english.uiuc.edu/cws/wworkshop/writer_resources/citation_styles/mla/unpublished_diss.htm> | |||||
$record .= " " . $row['thesis']; | |||||
$record .= ", " . $row['publisher']; | |||||
} | |||||
else // not a thesis | |||||
{ | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
if (!empty($row['place'])) // place | |||||
$record .= " " . $row['place']; | |||||
if (!empty($row['publisher'])) // publisher | |||||
{ | |||||
if (!empty($row['place'])) | |||||
$record .= ":"; | |||||
$record .= " " . $row['publisher']; | |||||
} | |||||
} | |||||
if (!empty($row['year'])) // year | |||||
$record .= ", ".$row['year']; | |||||
if ($row['online_publication'] == "yes") // this record refers to an online article | |||||
{ | |||||
$today = date("j M. Y"); | |||||
if (!empty($row['online_citation'])) // online_citation | |||||
{ | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
$record .= " " . $row['online_citation']; | |||||
} | |||||
if (!empty($row['doi'])) // doi | |||||
{ | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
if ($encodeHTML) | |||||
$record .= " " . $today . encodeHTML(" <http://dx.doi.org/" . $row['doi'] . ">"); | |||||
else | |||||
$record .= " " . $today . " <http://dx.doi.org/" . $row['doi'] . ">"; | |||||
} | |||||
elseif (!empty($row['url'])) // url | |||||
{ | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
if ($encodeHTML) | |||||
$record .= " " . $today . encodeHTML(" <" . $row['url'] . ">"); | |||||
else | |||||
$record .= " " . $today . " <" . $row['url'] . ">"; | |||||
} | |||||
} | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
} | |||||
// --- BEGIN POST-PROCESSING ----------------------------------------------------------------------------------------------------------- | |||||
// do some further cleanup: | |||||
$record = trim($record); // remove any preceding or trailing whitespace | |||||
return $record; | |||||
} | |||||
// --- END CITATION STYLE --- | |||||
?> |
@ -0,0 +1,442 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./cite/styles/cite_PolarBiol_MarBiol_MEPS.php | |||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/cite/styles/cite_PolarBiol_MarBiol_MEPS.php $ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 28-Sep-04, 22:14 | |||||
// Modified: $Date: 2012-02-27 20:25:30 +0000 (Mon, 27 Feb 2012) $ | |||||
// $Author: msteffens $ | |||||
// $Revision: 1337 $ | |||||
// This is a citation style file (which must reside within the 'cite/styles/' sub-directory of your refbase root directory). It contains a | |||||
// version of the 'citeRecord()' function that outputs a reference list from selected records according to the citation style used by | |||||
// the journals "Polar Biology", "Marine Biology" (both Springer-Verlag, springeronline.com) and "MEPS" (Inter-Research, int-res.com). | |||||
// -------------------------------------------------------------------- | |||||
// --- BEGIN CITATION STYLE --- | |||||
function citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, $encodeHTML) | |||||
{ | |||||
global $alnum, $alpha, $cntrl, $dash, $digit, $graph, $lower, $print, $punct, $space, $upper, $word, $patternModifiers; // defined in 'transtab_unicode_charset.inc.php' and 'transtab_latin1_charset.inc.php' | |||||
$record = ""; // make sure that our buffer variable is empty | |||||
// --- BEGIN TYPE = JOURNAL ARTICLE / MAGAZINE ARTICLE / NEWSPAPER ARTICLE -------------------------------------------------------------- | |||||
if (preg_match("/^(Journal Article|Magazine Article|Newspaper Article)$/", $row['type'])) | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($row['author'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", ", // 5. | |||||
"/ *, */", // 6. | |||||
" ", // 7. | |||||
" ", // 8. | |||||
"", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"", // 13. | |||||
"", // 14. | |||||
" " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15. | |||||
$encodeHTML); // 16. | |||||
$record .= $author . " "; | |||||
} | |||||
if (!empty($row['year'])) // year | |||||
$record .= "(" . $row['year'] . ") "; | |||||
if (!empty($row['title'])) // title | |||||
{ | |||||
$record .= $row['title']; | |||||
if (!preg_match("/[?!.]$/", $row['title'])) | |||||
$record .= "."; | |||||
$record .= " "; | |||||
} | |||||
if (!empty($row['abbrev_journal'])) // abbreviated journal name | |||||
$record .= $row['abbrev_journal'] . " "; | |||||
// if there's no abbreviated journal name, we'll use the full journal name | |||||
elseif (!empty($row['publication'])) // publication (= journal) name | |||||
$record .= $row['publication'] . " "; | |||||
if (!empty($row['volume'])) // volume | |||||
$record .= $row['volume']; | |||||
if (!empty($row['issue'])) // issue | |||||
$record .= "(" . $row['issue'] . ")"; | |||||
if ($row['online_publication'] == "yes") // this record refers to an online article | |||||
{ | |||||
// instead of any pages info (which normally doesn't exist for online publications) we append | |||||
// an optional string (given in 'online_citation') plus the DOI: | |||||
if (!empty($row['online_citation'])) // online_citation | |||||
{ | |||||
if (!empty($row['volume'])||!empty($row['issue'])) // only add ":" if either volume or issue isn't empty | |||||
$record .= ":"; | |||||
$record .= " " . $row['online_citation']; | |||||
} | |||||
if (!empty($row['doi'])) // doi | |||||
$record .= " doi:" . $row['doi']; | |||||
} | |||||
else // $row['online_publication'] == "no" -> this record refers to a printed article, so we append any pages info instead: | |||||
{ | |||||
if (!empty($row['pages'])) // pages | |||||
{ | |||||
if (!empty($row['volume'])||!empty($row['issue'])) // only add ":" if either volume or issue isn't empty | |||||
$record .= ":"; | |||||
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "", "", " pp"); // function 'formatPageInfo()' is defined in 'cite.inc.php' | |||||
} | |||||
} | |||||
} | |||||
// --- BEGIN TYPE = ABSTRACT / BOOK CHAPTER / CONFERENCE ARTICLE ------------------------------------------------------------------------ | |||||
elseif (preg_match("/^(Abstract|Book Chapter|Conference Article)$/", $row['type'])) | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($row['author'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", ", // 5. | |||||
"/ *, */", // 6. | |||||
" ", // 7. | |||||
" ", // 8. | |||||
"", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"", // 13. | |||||
"", // 14. | |||||
" " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15. | |||||
$encodeHTML); // 16. | |||||
$record .= $author . " "; | |||||
} | |||||
if (!empty($row['year'])) // year | |||||
$record .= "(" . $row['year'] . ") "; | |||||
if (!empty($row['title'])) // title | |||||
{ | |||||
$record .= $row['title']; | |||||
if (!preg_match("/[?!.]$/", $row['title'])) | |||||
$record .= "."; | |||||
$record .= " "; | |||||
} | |||||
if (!empty($row['editor'])) // editor | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$editor = reArrangeAuthorContents($row['editor'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", ", // 5. | |||||
"/ *, */", // 6. | |||||
" ", // 7. | |||||
" ", // 8. | |||||
"", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"", // 13. | |||||
"", // 14. | |||||
" " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15. | |||||
$encodeHTML); // 16. | |||||
$record .= "In: " . $editor; | |||||
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';') | |||||
$record .= " (eds)"; | |||||
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s]) | |||||
$record .= " (ed)"; | |||||
} | |||||
$publication = preg_replace("/[ \r\n]*\(Eds?:[^\)\r\n]*\)/i", "", $row['publication']); | |||||
if (!empty($publication)) // publication | |||||
$record .= " " . $publication . ". "; | |||||
else | |||||
if (!empty($row['editor'])) | |||||
$record .= ". "; | |||||
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title, series information will replace the publisher & place information | |||||
{ | |||||
if (!empty($row['abbrev_series_title'])) | |||||
$record .= $row['abbrev_series_title']; // abbreviated series title | |||||
// if there's no abbreviated series title, we'll use the full series title instead: | |||||
elseif (!empty($row['series_title'])) | |||||
$record .= $row['series_title']; // full series title | |||||
if (!empty($row['series_volume'])||!empty($row['series_issue'])) | |||||
$record .= " "; | |||||
if (!empty($row['series_volume'])) // series volume | |||||
$record .= $row['series_volume']; | |||||
if (!empty($row['series_issue'])) // series issue | |||||
$record .= "(" . $row['series_issue'] . ")"; | |||||
if (!empty($row['pages'])) | |||||
$record .= ", "; | |||||
} | |||||
else // if there's NO series title at all (neither full nor abbreviated), we'll insert the publisher & place instead: | |||||
{ | |||||
if (!empty($row['publisher'])) // publisher | |||||
{ | |||||
$record .= $row['publisher']; | |||||
if (!empty($row['place'])) | |||||
$record .= ", "; | |||||
else | |||||
{ | |||||
if (!preg_match("/,$/", $row['publisher'])) | |||||
$record .= ","; | |||||
$record .= " "; | |||||
} | |||||
} | |||||
if (!empty($row['place'])) // place | |||||
{ | |||||
$record .= $row['place']; | |||||
if (!empty($row['pages'])) | |||||
{ | |||||
if (!preg_match("/,$/", $row['place'])) | |||||
$record .= ","; | |||||
$record .= " "; | |||||
} | |||||
} | |||||
} | |||||
if (!empty($row['pages'])) // pages | |||||
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p ", "pp ", " pp"); // function 'formatPageInfo()' is defined in 'cite.inc.php' | |||||
} | |||||
// --- BEGIN TYPE = BOOK WHOLE / CONFERENCE VOLUME / JOURNAL / MANUAL / MANUSCRIPT / MAP / MISCELLANEOUS / PATENT / REPORT / SOFTWARE --- | |||||
else // if (preg_match("/Book Whole|Conference Volume|Journal|Manual|Manuscript|Map|Miscellaneous|Patent|Report|Software/", $row['type'])) | |||||
// note that this also serves as a fallback: unrecognized resource types will be formatted similar to whole books | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
$author = preg_replace("/[ \r\n]*\(eds?\)/i", "", $row['author']); | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($author, // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", ", // 5. | |||||
"/ *, */", // 6. | |||||
" ", // 7. | |||||
" ", // 8. | |||||
"", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"", // 13. | |||||
"", // 14. | |||||
" " . $markupPatternsArray["italic-prefix"] . "and __NUMBER_OF_AUTHORS__ others" . $markupPatternsArray["italic-suffix"], // 15. | |||||
$encodeHTML); // 16. | |||||
$record .= $author . " "; | |||||
} | |||||
if (!empty($row['year'])) // year | |||||
$record .= "(" . $row['year'] . ") "; | |||||
if (!empty($row['title'])) // title | |||||
{ | |||||
$record .= $row['title']; | |||||
if (!preg_match("/[?!.]$/", $row['title'])) | |||||
$record .= "."; | |||||
$record .= " "; | |||||
} | |||||
if (!empty($row['thesis'])) // thesis | |||||
$record .= $row['thesis'] . ". "; | |||||
if (!empty($row['publisher'])) // publisher | |||||
{ | |||||
$record .= $row['publisher']; | |||||
if (!empty($row['place'])) | |||||
$record .= ", "; | |||||
else | |||||
{ | |||||
if (!preg_match("/,$/", $row['publisher'])) | |||||
$record .= ","; | |||||
$record .= " "; | |||||
} | |||||
} | |||||
if (!empty($row['place'])) // place | |||||
{ | |||||
$record .= $row['place']; | |||||
if (!empty($row['abbrev_series_title']) || !empty($row['series_title']) || !empty($row['pages'])) | |||||
{ | |||||
if (!preg_match("/,$/", $row['place'])) | |||||
$record .= ","; | |||||
$record .= " "; | |||||
} | |||||
} | |||||
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // add either abbreviated or full series title | |||||
{ | |||||
if (!empty($row['abbrev_series_title'])) | |||||
$record .= $row['abbrev_series_title']; // abbreviated series title | |||||
// if there's no abbreviated series title, we'll use the full series title instead: | |||||
elseif (!empty($row['series_title'])) | |||||
$record .= $row['series_title']; // full series title | |||||
// series volume & series issue will get appended only if there's also either the full or an abbreviated series title(!): | |||||
if (!empty($row['series_volume'])||!empty($row['series_issue'])) | |||||
$record .= " "; | |||||
if (!empty($row['series_volume'])) // series volume | |||||
$record .= $row['series_volume']; | |||||
if (!empty($row['series_issue'])) // series issue | |||||
$record .= "(" . $row['series_issue'] . ")"; | |||||
if (!empty($row['pages'])) | |||||
{ | |||||
if (!preg_match("/,$/", $row['series_volume'])) | |||||
$record .= ","; | |||||
$record .= " "; | |||||
} | |||||
} | |||||
if (!empty($row['pages'])) // pages | |||||
{ | |||||
// TODO: use function 'formatPageInfo()' when it can recognize & process total number of pages | |||||
// $record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p ", "pp ", " pp"); // function 'formatPageInfo()' is defined in 'cite.inc.php' | |||||
if (preg_match("/\d *[$dash] *\d/$patternModifiers", $row['pages'])) // if the 'pages' field contains a page range (like: "127-132") | |||||
// Note that we'll check for page ranges here although for whole books the 'pages' field should NOT contain a page range but the total number of pages! (like: "623 pp") | |||||
$pagesDisplay = (preg_replace("@(\d+) *[$dash] *(\d+)@$patternModifiers", "\\1" . $markupPatternsArray["endash"] . "\\2", $row['pages'])); | |||||
else | |||||
$pagesDisplay = $row['pages']; | |||||
$record .= $pagesDisplay; | |||||
} | |||||
} | |||||
// --- BEGIN POST-PROCESSING ----------------------------------------------------------------------------------------------------------- | |||||
// do some further cleanup: | |||||
$record = preg_replace("/[.,][ \r\n]*$/i", "", $record); // remove '.' or ',' at end of line | |||||
if ($citeStyle == "MEPS") // if '$citeStyle' = 'MEPS' ... | |||||
$record = preg_replace("/pp ([0-9]+)/i", "p \\1", $record); // ... replace 'pp' with 'p' in front of (book chapter) page numbers | |||||
return $record; | |||||
} | |||||
// --- END CITATION STYLE --- | |||||
?> |
@ -0,0 +1,69 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./cite/styles/cite_TextCitation.php | |||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/cite/styles/cite_TextCitation.php $ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 28-Sep-04, 23:46 | |||||
// Modified: $Date: 2012-02-27 20:25:30 +0000 (Mon, 27 Feb 2012) $ | |||||
// $Author: msteffens $ | |||||
// $Revision: 1337 $ | |||||
// This is a citation style file (which must reside within the 'cite/styles/' sub-directory of your refbase root directory). It contains a | |||||
// version of the 'citeRecord()' function that outputs a reference list from selected records according to the citation style defined | |||||
// by a user's custom text citation format (or by the default format given in '$defaultTextCitationFormat' in 'ini.inc.php'). | |||||
// -------------------------------------------------------------------- | |||||
// --- BEGIN CITATION STYLE --- | |||||
function citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, $encodeHTML) | |||||
{ | |||||
global $defaultTextCitationFormat; // defined in 'ini.inc.php' | |||||
global $userOptionsArray; // '$userOptionsArray' is made globally available by function 'generateCitations()' in 'search.php' | |||||
// output records suitable for citation within a text, e.g., like: "Ambrose 1991 {3735}", "Ambrose & Renaud 1995 {3243}" or "Ambrose et al. 2001 {4774}" | |||||
if (!empty($userOptionsArray) AND ($userOptionsArray['use_custom_text_citation_format'] == "yes")) // if the user wants to use a custom text citation format | |||||
$textCitationFormat = $userOptionsArray['text_citation_format']; | |||||
else // use the default text citation format that was specified by the admin in 'ini.inc.php' | |||||
$textCitationFormat = $defaultTextCitationFormat; | |||||
// this is a stupid hack that maps the names of the '$row' array keys to those used | |||||
// by the '$formVars' array (which is required by function 'parsePlaceholderString()') | |||||
// (eventually, the '$formVars' array should use the MySQL field names as names for its array keys) | |||||
$formVars = buildFormVarsArray($row); // function 'buildFormVarsArray()' is defined in 'include.inc.php' | |||||
if (preg_match("/RTF|LaTeX/i", $citeType)) | |||||
{ | |||||
$textCitationFormat = preg_replace("/([{}])/i", "\\\\1", $textCitationFormat); // in case of RTF or LaTeX output we need to escape braces in placeholder strings | |||||
$fallbackPlaceholderString = "<:authors[2| & | et al.]:>< :year:>< \{:recordIdentifier:\}>"; | |||||
} | |||||
else | |||||
$fallbackPlaceholderString = "<:authors[2| & | et al.]:>< :year:>< {:recordIdentifier:}>"; | |||||
// generate a text citation according to the given naming scheme: | |||||
$record = parsePlaceholderString($formVars, $textCitationFormat, $fallbackPlaceholderString); // function 'parsePlaceholderString()' is defined in 'include.inc.php' | |||||
// Perform search & replace actions on the text: | |||||
$searchReplaceActionsArray["(et +al\.)"] = $markupPatternsArray["italic-prefix"] . "\\1" . $markupPatternsArray["italic-suffix"]; // print 'et al.' in italic | |||||
$record = searchReplaceText($searchReplaceActionsArray, $record, false); // function 'searchReplaceText()' is defined in 'include.inc.php' | |||||
return $record; | |||||
} | |||||
// --- END CITATION STYLE --- | |||||
?> |
@ -0,0 +1,714 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./cite/styles/cite_Vancouver.php | |||||
// Repository: $HeadURL$ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 04-Aug-08, 12:00 | |||||
// Modified: $Date: 2012-02-27 20:25:30 +0000 (Mon, 27 Feb 2012) $ | |||||
// $Author$ | |||||
// $Revision: 1337 $ | |||||
// This is a citation style file (which must reside within the 'cite/styles/' sub-directory of your refbase root directory). It contains a | |||||
// version of the 'citeRecord()' function that outputs a reference list from selected records according to the citation style used by | |||||
// the Vancouver referencing system (also known as "Uniform Requirements for Manuscripts Submitted to Biomedical Journals") | |||||
// This Vancouver style was modeled after these resources: | |||||
// <http://www.library.uq.edu.au/training/citation/vancouv.pdf> | |||||
// <http://library.curtin.edu.au/research_and_information_skills/referencing/vancouver.pdf> | |||||
// <http://www.icmje.org/index.html> citing: <http://www.nlm.nih.gov/citingmedicine/> | |||||
// <http://www.nlm.nih.gov/bsd/uniform_requirements.html> | |||||
// <http://library.sun.ac.za//eng/help/infolit2002/bibvancouver.htm> | |||||
// based on 'cite_AMA.php' | |||||
// NOTES: - In the Vancouver style, the reference list is arranged numerically in the order in which references are cited in the text. | |||||
// This isn't currently handled by this style (it needs to be implemented in the 'cite/formats/cite_*.php' files). | |||||
// - For conference proceedings, you'll currently need to add the place & date of the conference in the proceedings title field | |||||
// (e.g. "Proceedings of the 5th Germ Cell Tumour Conference; 2001 Sep 13-15; Leeds, UK"). | |||||
// TODO: - abstracts, newspaper/magazine articles, patents & reports? | |||||
// - arrange references numerically | |||||
// - for newspaper articles, only the beginning page number of an article should be included (see: <http://www.ncbi.nlm.nih.gov/books/bv.fcgi?rid=citmed.section.41496#41607>) | |||||
// - where to put (and how to format) editors of whole books that also have an author? | |||||
// - see also inline comments labeled with TODO (and NOTE) | |||||
// -------------------------------------------------------------------- | |||||
// --- BEGIN CITATION STYLE --- | |||||
function citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, $encodeHTML) | |||||
{ | |||||
global $alnum, $alpha, $cntrl, $dash, $digit, $graph, $lower, $print, $punct, $space, $upper, $word, $patternModifiers; // defined in 'transtab_unicode_charset.inc.php' and 'transtab_latin1_charset.inc.php' | |||||
static $uspsStateAbbreviations; | |||||
// Official USPS state abbreviations: | |||||
// see <http://www.usps.com/ncsc/lookups/usps_abbreviations.htm> | |||||
$uspsStateAbbreviations = "AL|AK|AS|AZ|AR|CA|CO|CT|DE|DC|FM|FL|GA|GU|HI|ID|IL|IN|IA|KS|KY|LA|ME|MH|MD|MA|MI|MN|MS|MO|MT|" | |||||
. "NE|NV|NH|NJ|NM|NY|NC|ND|MP|OH|OK|OR|PW|PA|PR|RI|SC|SD|TN|TX|UT|VT|VI|VA|WA|WV|WI|WY"; | |||||
$record = ""; // make sure that our buffer variable is empty | |||||
// --- BEGIN TYPE = JOURNAL ARTICLE / MAGAZINE ARTICLE / NEWSPAPER ARTICLE -------------------------------------------------------------- | |||||
if (preg_match("/^(Journal Article|Magazine Article|Newspaper Article)$/", $row['type'])) | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($row['author'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", ", // 5. | |||||
"/ *, */", // 6. | |||||
" ", // 7. | |||||
" ", // 8. | |||||
"", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"6", // 13. | |||||
"6", // 14. | |||||
", et al.", // 15. | |||||
$encodeHTML // 16. | |||||
); | |||||
if (!preg_match("/\. *$/", $author)) | |||||
$record .= $author . "."; | |||||
else | |||||
$record .= $author; | |||||
} | |||||
if (!empty($row['title'])) // title | |||||
{ | |||||
if (!empty($row['author'])) | |||||
$record .= " "; | |||||
$record .= $row['title']; | |||||
} | |||||
// From here on we'll assume that at least either the 'author' or the 'title' field did contain some contents | |||||
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below) | |||||
if (!preg_match("/[?!.] *$/", $record)) | |||||
$record .= "."; | |||||
if (!empty($row['abbrev_journal'])) // abbreviated journal name | |||||
$record .= " " . preg_replace("/\./", "", $row['abbrev_journal']); // no punctuation marks are used in the abbreviated journal name, just spaces (TODO: smarten regex pattern) | |||||
// if there's no abbreviated journal name, we'll use the full journal name instead: | |||||
elseif (!empty($row['publication'])) // publication (= journal) name | |||||
$record .= " " . $row['publication']; | |||||
if ($row['online_publication'] == "yes") // this record refers to an online publication | |||||
$record .= " [Internet]"; // NOTE: some of the above mentioned resources use "[serial online]", "[serial on the Internet]" or just "[online]" instead | |||||
// NOTE: the formatting of year/volume/issue is meant for journal articles (TODO: newspaper/magazine articles) | |||||
if (!empty($row['year'])) // year | |||||
$record .= ". " . $row['year']; | |||||
if ($row['online_publication'] == "yes") // append the current date if this record refers to an online publication | |||||
$record .= " [cited " . date("Y M j") . "]"; | |||||
if (!empty($row['volume']) || !empty($row['issue'])) | |||||
$record .= ";"; | |||||
if (!empty($row['volume'])) // volume (=month) | |||||
$record .= $row['volume']; | |||||
if (!empty($row['issue'])) // issue (=day) | |||||
$record .= "(" . $row['issue'] . ")"; | |||||
if (!empty($row['pages'])) // pages | |||||
{ | |||||
if (!empty($row['year']) || !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add ": " if either year, volume, issue, abbrev_journal or publication isn't empty | |||||
$record .= ":"; | |||||
$record .= formatPageInfo($row['pages'], $markupPatternsArray["endash"], "", "", "", "", "", "", true); // function 'formatPageInfo()' is defined in 'cite.inc.php' | |||||
} | |||||
if ($row['online_publication'] == "yes") // this record refers to an online publication | |||||
{ | |||||
// append an optional string (given in 'online_citation') plus the DOI (or URL): | |||||
if (!empty($row['online_citation'])) // online_citation | |||||
{ | |||||
if (!empty($row['year']) || !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])) // only add ":" or "," if either year, volume, issue, abbrev_journal or publication isn't empty | |||||
{ | |||||
if (empty($row['pages'])) | |||||
$record .= ":"; // print instead of pages | |||||
else | |||||
$record .= ";"; // append to pages (TODO: not sure whether this is correct) | |||||
} | |||||
$record .= $row['online_citation']; | |||||
} | |||||
if (!empty($row['doi']) || !empty($row['url'])) // doi OR url | |||||
{ | |||||
if (!empty($row['online_citation']) OR (empty($row['online_citation']) AND (!empty($row['year']) || !empty($row['volume']) || !empty($row['issue']) || !empty($row['abbrev_journal']) || !empty($row['publication'])))) // only add "." if online_citation isn't empty, or else if either year, volume, issue, abbrev_journal or publication isn't empty | |||||
$record .= "."; | |||||
$record .= " Available from: " . $markupPatternsArray["underline-prefix"]; // NOTE: some of the above mentioned resources use "Available from: URL:http://..." instead | |||||
if (!empty($row['doi'])) // doi | |||||
$uri = "http://dx.doi.org/" . $row['doi']; | |||||
else // url | |||||
$uri = $row['url']; | |||||
if ($encodeHTML) | |||||
$record .= encodeHTML($uri); | |||||
else | |||||
$record .= $uri; | |||||
$record .= $markupPatternsArray["underline-suffix"]; | |||||
} | |||||
} | |||||
if (!preg_match("/\. *$/", $record) AND ($row['online_publication'] != "yes")) | |||||
$record .= "."; // NOTE: the examples in the above mentioned resources differ wildly w.r.t. whether the closing period should be omitted for online publications | |||||
} | |||||
// --- BEGIN TYPE = ABSTRACT / BOOK CHAPTER / CONFERENCE ARTICLE ------------------------------------------------------------------------ | |||||
elseif (preg_match("/^(Abstract|Book Chapter|Conference Article)$/", $row['type'])) | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($row['author'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", ", // 5. | |||||
"/ *, */", // 6. | |||||
" ", // 7. | |||||
" ", // 8. | |||||
"", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"6", // 13. | |||||
"6", // 14. | |||||
", et al.", // 15. | |||||
$encodeHTML // 16. | |||||
); | |||||
if (!preg_match("/\. *$/", $author)) | |||||
$record .= $author . "."; | |||||
else | |||||
$record .= $author; | |||||
} | |||||
if (!empty($row['title'])) // title | |||||
{ | |||||
if (!empty($row['author'])) | |||||
$record .= " "; | |||||
$record .= $row['title']; | |||||
} | |||||
if ($row['type'] == "Abstract") // for abstracts, add "[abstract]" label | |||||
$record .= " [abstract]"; | |||||
// From here on we'll assume that at least either the 'author' or the 'title' field did contain some contents | |||||
// if this is not the case, the output string will begin with a space. However, any preceding/trailing whitespace will be removed at the cleanup stage (see below) | |||||
if (!empty($row['editor'])) // editor | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$editor = reArrangeAuthorContents($row['editor'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", ", // 5. | |||||
"/ *, */", // 6. | |||||
" ", // 7. | |||||
" ", // 8. | |||||
"", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"6", // 13. | |||||
"6", // 14. | |||||
", et al.", // 15. | |||||
$encodeHTML // 16. | |||||
); | |||||
if (!preg_match("/[?!.] *$/", $record)) | |||||
$record .= "."; | |||||
$record .= " In: " . $editor . ", "; | |||||
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';') | |||||
$record .= "editors"; | |||||
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s]) | |||||
$record .= "editor"; | |||||
} | |||||
$publication = preg_replace("/[ \r\n]*\(Eds?:[^\)\r\n]*\)/i", "", $row['publication']); | |||||
if (!empty($publication)) // publication | |||||
{ | |||||
if (!preg_match("/[?!.] *$/", $record)) | |||||
$record .= "."; | |||||
if (empty($row['editor'])) | |||||
$record .= " In:"; | |||||
$record .= " " . $publication; | |||||
} | |||||
if (!empty($row['volume'])) // volume | |||||
{ | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
$record .= " Vol " . $row['volume']; // TODO: not sure whether this is correct | |||||
} | |||||
if (!empty($row['edition']) && !preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // edition | |||||
{ | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd ed.") | |||||
{ | |||||
if ($row['edition'] == "2") | |||||
$editionSuffix = "nd"; | |||||
elseif ($row['edition'] == "3") | |||||
$editionSuffix = "rd"; | |||||
else | |||||
$editionSuffix = "th"; | |||||
} | |||||
else | |||||
$editionSuffix = ""; | |||||
if (!preg_match("/( ed\.?| edition)$/i", $row['edition'])) | |||||
$editionSuffix .= " ed."; | |||||
$record .= " " . $row['edition'] . $editionSuffix; | |||||
} | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
if (!empty($row['place'])) // place | |||||
{ | |||||
// for places in the USA, format any two-letter postal code for the state (i.e. ensure upper case & wrap in parens, eg. "Boca Raton (FL)"): | |||||
if (preg_match("/(.+?)[$punct$space]+($uspsStateAbbreviations)[$punct$space]*$/i$patternModifiers", $row['place'])) | |||||
$record .= " " . preg_replace("/(.+?)[$punct$space]+($uspsStateAbbreviations)[$punct$space]*$/ie$patternModifiers", "'\\1 ('.strtoupper('\\2').')'", $row['place']); | |||||
else | |||||
$record .= " " . $row['place']; | |||||
} | |||||
if (!empty($row['publisher'])) // publisher | |||||
{ | |||||
if (!empty($row['place'])) | |||||
$record .= ":"; | |||||
$record .= " " . $row['publisher']; | |||||
} | |||||
if (!empty($row['year'])) // year | |||||
$record .= "; " . $row['year']; | |||||
if (!empty($row['pages'])) // pages | |||||
$record .= ". " . formatPageInfo($row['pages'], $markupPatternsArray["endash"], "p. ", "p. ", "", "", "", "", true); // function 'formatPageInfo()' is defined in 'cite.inc.php' | |||||
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title | |||||
{ | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
$record .= " ("; | |||||
if (!empty($row['abbrev_series_title'])) // abbreviated series title | |||||
$record .= preg_replace("/\./", "", $row['abbrev_series_title']); // no punctuation marks are used in the abbreviated series title, just spaces (TODO: smarten regex pattern) | |||||
// if there's no abbreviated series title, we'll use the full series title instead: | |||||
elseif (!empty($row['series_title'])) // full series title | |||||
$record .= $row['series_title']; | |||||
if (!empty($row['series_volume'])||!empty($row['series_issue'])) | |||||
$record .= "; "; | |||||
if (!empty($row['series_volume'])) // series volume | |||||
$record .= "vol " . $row['series_volume']; | |||||
if (!empty($row['series_volume']) && !empty($row['series_issue'])) | |||||
$record .= "; "; // TODO: not sure whether this is correct | |||||
if (!empty($row['series_issue'])) // series issue (I'm not really sure if -- for this cite style -- the series issue should be rather omitted here) | |||||
$record .= "no " . $row['series_issue']; // since a series volume should be prefixed with "vol", is it correct to prefix series issues with "no"? | |||||
$record .= ")"; | |||||
} | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
} | |||||
// --- BEGIN TYPE = BOOK WHOLE / CONFERENCE VOLUME / JOURNAL / MANUAL / MANUSCRIPT / MAP / MISCELLANEOUS / PATENT / REPORT / SOFTWARE --- | |||||
else // if (preg_match("/Book Whole|Conference Volume|Journal|Manual|Manuscript|Map|Miscellaneous|Patent|Report|Software/", $row['type'])) | |||||
// note that this also serves as a fallback: unrecognized resource types will be formatted similar to whole books | |||||
{ | |||||
if (!empty($row['author'])) // author | |||||
{ | |||||
$author = preg_replace("/[ \r\n]*\(eds?\)/i", "", $row['author']); | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$author = reArrangeAuthorContents($author, // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", ", // 5. | |||||
"/ *, */", // 6. | |||||
" ", // 7. | |||||
" ", // 8. | |||||
"", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"6", // 13. | |||||
"6", // 14. | |||||
", et al.", // 15. | |||||
$encodeHTML // 16. | |||||
); | |||||
// if the author is actually the editor of the resource we'll append ', ed' (or ', eds') to the author string: | |||||
// [to distinguish editors from authors in the 'author' field, the 'modify.php' script does append ' (ed)' or ' (eds)' if appropriate, | |||||
// so we're just checking for these identifier strings here. Alternatively, we could check whether the editor field matches the author field] | |||||
if (preg_match("/[ \r\n]*\(ed\)/", $row['author'])) // single editor | |||||
$author = $author . ", editor"; | |||||
elseif (preg_match("/[ \r\n]*\(eds\)/", $row['author'])) // multiple editors | |||||
$author = $author . ", editors"; | |||||
if (!preg_match("/\. *$/", $author)) | |||||
$record .= $author . "."; | |||||
else | |||||
$record .= $author; | |||||
} | |||||
if (!empty($row['title'])) // title | |||||
{ | |||||
if (!empty($row['author'])) | |||||
$record .= " "; | |||||
$record .= $row['title']; | |||||
} | |||||
if ($row['type'] == "Software") // for software, add software label | |||||
$record .= " [computer program]"; | |||||
if (($row['online_publication'] == "yes") AND empty($row['thesis'])) // this record refers to an online publication (online theses will be handled further down below) | |||||
$record .= " [Internet]"; // NOTE: some of the above mentioned resources use "[monograph online]", "[monograph on the Internet]" or just "[online]" instead | |||||
if (!empty($row['volume']) AND ($row['type'] != "Software")) // volume | |||||
{ | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
$record .= " Vol " . $row['volume']; // TODO: not sure whether this is correct | |||||
} | |||||
if (!empty($row['edition'])) // edition | |||||
{ | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
if ($row['type'] == "Software") // software edition (=version) | |||||
{ | |||||
$record .= " Version " . $row['edition']; | |||||
} | |||||
elseif (!preg_match("/^(1|1st|first|one)( ed\.?| edition)?$/i", $row['edition'])) // edition | |||||
{ | |||||
if (preg_match("/^\d{1,3}$/", $row['edition'])) // if the edition field contains a number of up to three digits, we assume it's an edition number (such as "2nd ed.") | |||||
{ | |||||
if ($row['edition'] == "2") | |||||
$editionSuffix = "nd"; | |||||
elseif ($row['edition'] == "3") | |||||
$editionSuffix = "rd"; | |||||
else | |||||
$editionSuffix = "th"; | |||||
} | |||||
else | |||||
$editionSuffix = ""; | |||||
if (!preg_match("/( ed\.?| edition)$/i", $row['edition'])) | |||||
$editionSuffix .= " ed."; | |||||
$record .= " " . $row['edition'] . $editionSuffix; | |||||
} | |||||
} | |||||
if (!empty($row['editor']) && !preg_match("/[ \r\n]*\(eds?\)/", $row['author'])) // editor (if different from author, see note above regarding the check for ' (ed)' or ' (eds)') | |||||
{ | |||||
// Call the 'reArrangeAuthorContents()' function (defined in 'include.inc.php') in order to re-order contents of the author field. Required Parameters: | |||||
// 1. input: contents of the author field | |||||
// 2. input: boolean value that specifies whether the author's family name comes first (within one author) in the source string | |||||
// ('true' means that the family name is followed by the given name (or initials), 'false' if it's the other way around) | |||||
// | |||||
// 3. input: pattern describing old delimiter that separates different authors | |||||
// 4. output: for all authors except the last author: new delimiter that separates different authors | |||||
// 5. output: for the last author: new delimiter that separates the last author from all other authors | |||||
// | |||||
// 6. input: pattern describing old delimiter that separates author name & initials (within one author) | |||||
// 7. output: for the first author: new delimiter that separates author name & initials (within one author) | |||||
// 8. output: for all authors except the first author: new delimiter that separates author name & initials (within one author) | |||||
// 9. output: new delimiter that separates multiple initials (within one author) | |||||
// 10. output: for the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 11. output: for all authors except the first author: boolean value that specifies if initials go *before* the author's name ['true'], or *after* the author's name ['false'] (which is the default in the db) | |||||
// 12. output: boolean value that specifies whether an author's full given name(s) shall be shortened to initial(s) | |||||
// | |||||
// 13. output: if the total number of authors is greater than the given number (integer >= 1), only the number of authors given in (14) will be included in the citation along with the string given in (15); keep empty if all authors shall be returned | |||||
// 14. output: number of authors (integer >= 1) that is included in the citation if the total number of authors is greater than the number given in (13); keep empty if not applicable | |||||
// 15. output: string that's appended to the number of authors given in (14) if the total number of authors is greater than the number given in (13); the actual number of authors can be printed by including '__NUMBER_OF_AUTHORS__' (without quotes) within the string | |||||
// | |||||
// 16. output: boolean value that specifies whether the re-ordered string shall be returned with higher ASCII chars HTML encoded | |||||
$editor = reArrangeAuthorContents($row['editor'], // 1. | |||||
true, // 2. | |||||
"/ *; */", // 3. | |||||
", ", // 4. | |||||
", ", // 5. | |||||
"/ *, */", // 6. | |||||
" ", // 7. | |||||
" ", // 8. | |||||
"", // 9. | |||||
false, // 10. | |||||
false, // 11. | |||||
true, // 12. | |||||
"6", // 13. | |||||
"6", // 14. | |||||
", et al.", // 15. | |||||
$encodeHTML // 16. | |||||
); | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
$record .= " " . $editor; | |||||
if (preg_match("/^[^;\r\n]+(;[^;\r\n]+)+$/", $row['editor'])) // there are at least two editors (separated by ';') | |||||
$record .= ", editors"; | |||||
else // there's only one editor (or the editor field is malformed with multiple editors but missing ';' separator[s]) | |||||
$record .= ", editor"; | |||||
} | |||||
if (!empty($row['thesis'])) // thesis | |||||
{ | |||||
// TODO: do we need to use the term "[dissertation]" instead of "[Ph.D. thesis]", etc? What about other thesis types then? | |||||
$record .= " [" . $row['thesis']; | |||||
if ($row['online_publication'] == "yes") // this record refers to an online thesis | |||||
$record .= " on the Internet]"; | |||||
else | |||||
$record .= "]"; | |||||
} | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
if (!empty($row['place'])) // place | |||||
{ | |||||
// for places in the USA, format any two-letter postal code for the state (i.e. ensure upper case & wrap in parentheses, eg. "Boca Raton (FL)"): | |||||
if (preg_match("/(.+?)[$punct$space]+($uspsStateAbbreviations)[$punct$space]*$/i$patternModifiers", $row['place'])) | |||||
$record .= " " . preg_replace("/(.+?)[$punct$space]+($uspsStateAbbreviations)[$punct$space]*$/ie$patternModifiers", "'\\1 ('.strtoupper('\\2').')'", $row['place']); | |||||
else | |||||
$record .= " " . $row['place']; | |||||
} | |||||
if (!empty($row['publisher'])) // publisher | |||||
{ | |||||
if (!empty($row['place'])) | |||||
$record .= ":"; | |||||
$record .= " " . $row['publisher']; | |||||
} | |||||
$record .= ";"; | |||||
if (!empty($row['year'])) // year | |||||
$record .= " " . $row['year']; | |||||
if ($row['type'] == "Software") // for software, volume (=month) and issue (=day) information is printed after the year (TODO: not sure whether this is correct) | |||||
{ | |||||
if (!empty($row['volume'])) // volume (=month) | |||||
$record .= " " . $row['volume']; | |||||
if (!empty($row['issue'])) // issue (=day) | |||||
$record .= " " . $row['issue']; | |||||
} | |||||
if ($row['online_publication'] == "yes") // append the current date if this record refers to an online publication | |||||
$record .= " [cited " . date("Y M j") . "]"; | |||||
if (!empty($row['abbrev_series_title']) OR !empty($row['series_title'])) // if there's either a full or an abbreviated series title | |||||
{ | |||||
if (!preg_match("@[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*$@", $record)) | |||||
$record .= "."; | |||||
$record .= " ("; | |||||
if (!empty($row['abbrev_series_title'])) // abbreviated series title | |||||
$record .= preg_replace("/\./", "", $row['abbrev_series_title']); // no punctuation marks are used in the abbreviated series title, just spaces (TODO: smarten regex pattern) | |||||
// if there's no abbreviated series title, we'll use the full series title instead: | |||||
elseif (!empty($row['series_title'])) // full series title | |||||
$record .= $row['series_title']; | |||||
if (!empty($row['series_volume'])||!empty($row['series_issue'])) | |||||
$record .= "; "; | |||||
if (!empty($row['series_volume'])) // series volume | |||||
$record .= "vol " . $row['series_volume']; | |||||
if (!empty($row['series_volume']) && !empty($row['series_issue'])) | |||||
$record .= "; "; // TODO: not sure whether this is correct | |||||
if (!empty($row['series_issue'])) // series issue (I'm not really sure if -- for this cite style -- the series issue should be rather omitted here) | |||||
$record .= "no " . $row['series_issue']; // since a series volume should be prefixed with "vol", is it correct to prefix series issues with "no"? | |||||
$record .= ")"; | |||||
} | |||||
if ($row['online_publication'] == "yes" || $row['type'] == "Software") // this record refers to an online publication, or a computer program/software | |||||
{ | |||||
// append an optional string (given in 'online_citation') plus the DOI (or URL): | |||||
if (!empty($row['online_citation'])) // online_citation | |||||
{ | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
$record .= $row['online_citation']; | |||||
} | |||||
if (!empty($row['doi']) || !empty($row['url'])) // doi OR url | |||||
{ | |||||
if (!preg_match("/\. *$/", $record)) | |||||
$record .= "."; | |||||
$record .= " Available from: " . $markupPatternsArray["underline-prefix"]; // NOTE: some of the above mentioned resources use "Available from: URL:http://..." instead | |||||
if (!empty($row['doi'])) // doi | |||||
$uri = "http://dx.doi.org/" . $row['doi']; | |||||
else // url | |||||
$uri = $row['url']; | |||||
if ($encodeHTML) | |||||
$record .= encodeHTML($uri); | |||||
else | |||||
$record .= $uri; | |||||
$record .= $markupPatternsArray["underline-suffix"]; | |||||
} | |||||
} | |||||
if (!preg_match("/\. *$/", $record) AND ($row['online_publication'] != "yes") AND ($row['type'] != "Software")) | |||||
$record .= "."; // NOTE: the examples in the above mentioned resources differ wildly w.r.t. whether the closing period should be omitted for online publications | |||||
} | |||||
// --- BEGIN POST-PROCESSING ----------------------------------------------------------------------------------------------------------- | |||||
// do some further cleanup: | |||||
$record = trim($record); // remove any preceding or trailing whitespace | |||||
return $record; | |||||
} | |||||
// --- END CITATION STYLE --- | |||||
?> |
@ -0,0 +1,23 @@ | |||||
refbase command line clients | |||||
============================ | |||||
Author | |||||
------ | |||||
Matthias Steffens <refbase@extracts.de> | |||||
About | |||||
----- | |||||
'refbase' is a command line client (written in perl) to search refbase. | |||||
'refbase_import' is a client to import references into refbase. | |||||
Use | |||||
--- | |||||
Part I: Configuration | |||||
- Both scripts may be edited in a text editor. It is suggested that you set: | |||||
- %hosts | |||||
- %loginParams | |||||
Part II: Use | |||||
- Both scripts will print help if run with an argument of '-h' or '--help' | |||||
- They will print usage examples if run with '-X' or '--examples' | |||||
See also: | |||||
<http://cli.refbase.net> |
@ -0,0 +1,459 @@ | |||||
#!/usr/bin/perl | |||||
# Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
# Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
# original author(s). | |||||
# | |||||
# This code is distributed in the hope that it will be useful, | |||||
# but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
# License for more details. | |||||
# | |||||
# File: ./contrib/command_line/refbase_import | |||||
# Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/contrib/command_line/refbase_import $ | |||||
# Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
# | |||||
# Created: 06-Jun-06, 18:00 | |||||
# Modified: $Date: 2008-10-30 18:16:54 +0000 (Thu, 30 Oct 2008) $ | |||||
# $Author: msteffens $ | |||||
# $Revision: 1289 $ | |||||
# REFBASE_IMPORT -- a refbase command line interface | |||||
# Purpose: Perl script that allows to upload data in various formats to a refbase online database from the command line | |||||
# Usage: refbase_import [OPTIONS] [FILE] | |||||
# Help: For help with the syntax type 'refbase_import -h' | |||||
# To view some usage examples type 'refbase_import -X' | |||||
# Further information is available at <http://cli.refbase.net/> | |||||
# A list of supported import formats is given at <http://import.refbase.net/> | |||||
# Version: 1.2 | |||||
# Requires: - a shell with Perl execution capabilities | |||||
# - the Perl CPAN modules LWP::UserAgent, HTTP::Request::Common, HTTP::Response, HTTP::Cookies and URI::URL | |||||
# - access with import permissions to a refbase database (refbase-0.9.0 or greater) | |||||
# Limits: - The character encoding of your import data must match the encoding of your refbase database (i.e., 'latin1' or 'utf8') | |||||
# - The authentication mechanism is currently limited in that a given password will be transferred as parameter in the POST request | |||||
# -------------------------------------------------------------------------------------------------------------- | |||||
$version = "1.2"; | |||||
# Configure variables: | |||||
# Specify the full URLs to any refbase servers that shall be queried: | |||||
# Notes: - the given hash keys will work as shortcuts, e.g. '--host=local' would upload | |||||
# data to your local refbase installation; one hash key must be named 'default', | |||||
# all other keys can be freely chosen | |||||
# - by default, data will be uploaded to the server labeled with key 'default' | |||||
%hosts = ( | |||||
'default' => 'http://beta.refbase.net/', | |||||
'local' => 'http://localhost/refs/', | |||||
'beta' => 'http://beta.refbase.net/', | |||||
'beta2' => 'http://refbase.textdriven.com/beta/', | |||||
'demo' => 'http://demo.refbase.net/', | |||||
'org' => 'http://www.refbase.org/' | |||||
); | |||||
# Specify the default values for all options that are not explicitly specified: | |||||
%params = ( | |||||
# import options: | |||||
'skipBadRecords' => '0', # -b|--skipbad -> must be '0' (don't skip records with unrecognized data format) or '1' (skip records with unrecognized data format) | |||||
'importRecordsRadio' => 'all', # -i|--import -> must be 'all' (import all records) or 'only' (import only those records specified in 'importRecords') | |||||
'sourceIDs' => '', # -p|--pmid -> this also applies for '--arxiv|--doi|--openurl' since they are essentially just aliases for '-p' | |||||
'importRecords' => '1', # -r|--records -> must be a list of numbers and/or ranges (e.g., '1-5' will import the first five records; '1 3-5 7' will import records 1, 3, 4, 5 and 7) | |||||
'formType' => 'data', # -t|--type -> must be 'data' (generic data import) or 'id' (import via ID) | |||||
# fixed parameters: | |||||
'client' => "cli-refbase_import-" . $version # the client ID of this command line utility | |||||
); | |||||
%outputParams = ( | |||||
# output options: | |||||
'citeStyle' => '', # -C|--style => desired citation style, given name must match an entry within the database's MySQL table 'styles' (keep empty to use the database default) | |||||
'format' => 'ascii', # -F|--format => output format must be 'html', 'rtf', 'pdf', 'latex', 'latex_bbl', 'markdown', 'ascii', 'ads', 'bibtex', 'endnote', 'isi', 'ris', 'atom', 'mods', 'oai_dc', 'odf', 'srw_dc', 'srw_mods', 'word' or '' (the empty string '' will produce the default 'ascii' output style) | |||||
'showLinks' => '1', # -L|--showlinks => hide/display links column in HTML output; must be '0', '1', or '' (the empty string '' will produce the default output style, i.e. print any links) | |||||
'citeOrder' => 'author', # -O|--order => cite order must be 'author', 'year', 'type', 'type-year', 'creation-date' or '' (the empty string '' will produce the default 'author' sort order) | |||||
'viewType' => 'web' # -V|--view => view type of HTML output; must be 'Web', 'Print', 'Mobile' or '' (the empty string '' will produce the default 'Web' output style) | |||||
); | |||||
# Specify the default login credentials for a refbase user account: | |||||
# Imported data will get associated with this user account | |||||
%loginParams = ( | |||||
'loginEmail' => '', # -U|--user -> the login email address of an existing refbase user with import permissions | |||||
'loginPassword' => '' # -P|--password -> the password for the given user account | |||||
); | |||||
# Specify the location of the cookie jar file: | |||||
# This file will be used to store & retrieve cookies | |||||
$cookieJarFile = "$ENV{HOME}/.lwpcookies.txt"; | |||||
# -------------------------------------------------------------------------------- | |||||
# NOTE: You shouldn't need to change anything below this line | |||||
# CPAN modules: | |||||
use LWP::UserAgent; # more info: <http://search.cpan.org/~gaas/libwww-perl-5.805/lib/LWP/UserAgent.pm> | |||||
use HTTP::Request::Common; # more info: <http://search.cpan.org/~gaas/libwww-perl-5.805/lib/HTTP/Request/Common.pm> | |||||
use HTTP::Response; # more info: <http://search.cpan.org/~gaas/libwww-perl-5.805/lib/HTTP/Response.pm> | |||||
use HTTP::Cookies; # more info: <http://search.cpan.org/~gaas/libwww-perl-5.805/lib/HTTP/Cookies.pm> | |||||
use URI::URL; # more info: <http://search.cpan.org/~gaas/URI-1.35/URI/URL.pm> | |||||
# initialize variables: | |||||
$host = $hosts{'default'}; | |||||
$format = ''; | |||||
# Extract options: | |||||
# TODO: use Getopt::Long | |||||
# general options: | |||||
if (($ARGV[0] eq '--help') or ($ARGV[0] eq '-h') or ($ARGV[0] eq '')) { &usage (0); } # if the user asked for --help/-h or didn't provide any input, call the 'usage' subroutine | |||||
elsif (($ARGV[0] eq '--version') or ($ARGV[0] eq '-v')) { &version (0); } # show version information | |||||
elsif (($ARGV[0] eq '--examples') or ($ARGV[0] eq '-X')) { &examples (0); } # print some usage examples | |||||
else { | |||||
foreach (@ARGV) { | |||||
# extract import options: | |||||
if ($_ =~ /^(?:-b|--skipbad)=(.+)$/) { $params{'skipBadRecords'} = $1; } | |||||
elsif ($_ =~ /^(?:-i|--import)=(.+)$/) { $params{'importRecordsRadio'} = $1; } | |||||
elsif ($_ =~ /^(?:-p|--pmid|--arxiv|--doi|--openurl)=(.+)$/) { $params{'sourceIDs'} = $1; } | |||||
elsif ($_ =~ /^(?:-r|--records)=(.+)$/) { $params{'importRecords'} = $1; } | |||||
elsif ($_ =~ /^(?:-t|--type)=(.+)$/) { $params{'formType'} = $1; } | |||||
# extract output options: | |||||
elsif ($_ =~ /^(?:-C|--style)=(.+)$/) { $outputParams{'citeStyle'} = $1; } | |||||
elsif ($_ =~ /^(?:-F|--format)=(.+)$/) { $outputParams{'format'} = $1; } | |||||
elsif ($_ =~ /^(?:-L|--showlinks)=(.+)$/) { $outputParams{'showLinks'} = $1; } | |||||
elsif ($_ =~ /^(?:-O|--order)=(.+)$/) { $outputParams{'citeOrder'} = $1; } | |||||
elsif ($_ =~ /^(?:-V|--view)=(.+)$/) { $outputParams{'viewType'} = $1; } | |||||
# extract server options: | |||||
elsif ($_ =~ /^(?:-H|--host)=(.+)$/) { $host = $1; } | |||||
elsif ($_ =~ /^(?:-P|--password)=(.+)$/) { $loginParams{'loginPassword'} = $1; } | |||||
elsif ($_ =~ /^(?:-U|--user)=(.+)$/) { $loginParams{'loginEmail'} = $1; } | |||||
# extract file: | |||||
# (note that if multiple files were given, only the last given file will be honoured) | |||||
elsif ($_ =~ /^(?!(-[biprtCFLOVHPU]|--(?:skipbad|import|pmid|arxiv|doi|openurl|records|type|style|format|showlinks|order|view|host|password|user))=)([^ ]+)/) { @sourceFile = $2; } | |||||
} | |||||
} | |||||
# for '--type=data', check if a source file was specified: | |||||
if (($params{'formType'} =~ /^data$/i) && (scalar @sourceFile == 0)) { | |||||
print "There were validation errors regarding the data you submitted:\n\n"; | |||||
print "FILE: The file operand is missing! The generic data import feature ('--type=data')\n" | |||||
. " requires a FILE to be specified. Type 'refbase_import -X' to see some usage\n" | |||||
. " examples. For general help with the syntax type 'refbase_import -h'.\n\n"; | |||||
exit; | |||||
} | |||||
# for '--type=id' (or, previously: --type=pmid), check if at least one PubMed ID, arXiv ID, DOI or OpenURL was given: | |||||
# TODO: improve identification/verification of the given IDs | |||||
elsif (($params{'formType'} =~ /^(pm)?id$/i) && ($params{'sourceIDs'} !~ /\d+/)) { | |||||
print "There were validation errors regarding the data you submitted:\n\n"; | |||||
print "sourceIDs: You must specify at least one PubMed ID, arXiv ID, DOI or OpenURL! The 'import via ID'\n" | |||||
. " feature ('--type=id') requires the '-p, --pmid' option or one of '--arxiv|--doi|--openurl'\n" | |||||
. " to be specified. Type 'refbase_import -X' to see some usage examples. For general help\n" | |||||
. " with the syntax type 'refbase_import -h'.\n\n"; | |||||
exit; | |||||
} | |||||
# adjust form type value: | |||||
if ($params{'formType'} =~ /^(pm)?id$/i) { # --type=id (or, previously: --type=pmid) | |||||
$params{'formType'} = "importID"; | |||||
} | |||||
else { # --type=data | |||||
$params{'formType'} = "import"; | |||||
} | |||||
# resolve any host shortcuts: | |||||
if (exists($hosts{$host})) { | |||||
$host = $hosts{$host}; | |||||
} | |||||
elsif ($host !~ /^https?:\/\//i) { | |||||
$host = $hosts{'default'}; # can't resolve given host, reset back to default | |||||
} | |||||
# assign correct URL params based on the '-F|--format' option: | |||||
if (exists($outputParams{'format'})) { | |||||
$format = $outputParams{'format'}; | |||||
if ($format =~ /^(html|rtf|pdf|latex|latex_bbl|markdown|ascii)$/i) { | |||||
$outputParams{'submit'} = "Cite"; | |||||
} | |||||
if ($format =~ /^(html|rtf|pdf|latex|latex_bbl|markdown|ascii)$/i) { | |||||
$format =~ s/^latex_bbl$/LaTeX .bbl/i; | |||||
$outputParams{'citeType'} = $format; | |||||
} | |||||
elsif ($format =~ /^(ads|bibtex|endnote|isi|ris|atom|mods|oai_dc|odf|srw(_dc|_mods)?|word)$/i) { | |||||
$outputParams{'submit'} = "Export"; | |||||
$outputParams{'exportType'} = "file"; | |||||
if ($format =~ /^(ads|bibtex|endnote|isi|ris)$/i) { | |||||
$outputParams{'exportFormat'} = $format; | |||||
} | |||||
elsif ($format =~ /^(atom|mods|oai_dc|odf|srw(_dc|_mods)?|word)$/i) { | |||||
$outputParams{'exportFormat'} = $format . " xml"; | |||||
} | |||||
} | |||||
else { | |||||
$outputParams{'citeType'} = "ascii"; | |||||
} | |||||
delete($outputParams{'format'}); | |||||
} | |||||
# construct URL: | |||||
# (uses URI::URL) | |||||
$importScript = "import_modify.php"; | |||||
$importURL = url($host . $importScript); | |||||
# initialize new user agent: | |||||
# (uses LWP::UserAgent) | |||||
$userAgent = LWP::UserAgent->new; | |||||
# set user agent string: | |||||
$userAgent->agent("refbase_import/" . $version . " (http://cli.refbase.net/) "); | |||||
# set cookie jar object: | |||||
# LWP will collect cookies and respond to cookie requests via its cookie jar, thus | |||||
# enabling the user agent to fetch a PHP session ID from the refbase login response | |||||
# and automatically resend it upon next import request | |||||
$userAgent->cookie_jar({ file => $cookieJarFile, autosave => 1 }); | |||||
# attempt to authenticate using the given login credentials: | |||||
if (($loginParams{'loginEmail'} ne '') && ($loginParams{'loginPassword'} ne '')) { | |||||
$loginSuccessful = &login(0); # call the 'login' subroutine | |||||
} | |||||
else { | |||||
$loginSuccessful = 0; | |||||
} | |||||
if (!$loginSuccessful) { | |||||
print "Login failed! You provided an incorrect email address or password.\n\n"; | |||||
exit; | |||||
} | |||||
# send POST request: | |||||
# (uses HTTP::Request::Common & HTTP::Response) | |||||
if ($params{'formType'} =~ /^importID$/i) { # --type=id (or, previously: --type=pmid) | |||||
$request = POST $importURL, \%params; | |||||
} | |||||
else { # --type=data | |||||
$params{'uploadFile'} = \@sourceFile; | |||||
$request = POST $importURL, Content_Type => 'form-data', Content => \%params; | |||||
} | |||||
$response = $userAgent->request($request); | |||||
if ($response->is_error()) { | |||||
print STDERR $response->status_line, "\n"; | |||||
} | |||||
else { | |||||
$location = $response->header('Location'); | |||||
if ($location ne '') { | |||||
if ($location =~ /show.php/) { | |||||
# display imported records: | |||||
foreach $key (keys %outputParams) { | |||||
$location .= "&" . $key . "=" . $outputParams{$key}; | |||||
} | |||||
if ($location =~ /&headerMsg=\D*(\d+)/i) { | |||||
$location .= "&showRows=" . $1; | |||||
} | |||||
} | |||||
# construct URL: | |||||
# (uses URI::URL) | |||||
$responseURL = url($host . $location); | |||||
# send GET request: | |||||
# (uses HTTP::Request::Common & HTTP::Response) | |||||
$request = GET $responseURL; | |||||
$response = $userAgent->request($request); # or use: $response = $userAgent->get($responseURL); | |||||
} | |||||
binmode STDOUT; | |||||
print $response->content(); | |||||
} | |||||
# -------------------------------------------------------------------------------- | |||||
# Login with login credentials given in '%loginParams': | |||||
sub login | |||||
{ | |||||
local ($status) = @_; | |||||
# construct URL: | |||||
# (uses URI::URL) | |||||
$loginScript = "user_login.php"; | |||||
$loginURL = url($host . $loginScript); | |||||
# send POST request: | |||||
# (uses HTTP::Request::Common & HTTP::Response) | |||||
$request = POST $loginURL, \%loginParams; | |||||
$response = $userAgent->request($request); | |||||
if ($response->is_error()) { | |||||
print STDERR $response->status_line, "\n"; | |||||
exit $status; | |||||
} | |||||
else { | |||||
$location = $response->header('Location'); | |||||
# upon successful login, refbase will redirect to 'index.php' | |||||
if ($location =~ /index.php/) { | |||||
return 1; # login successful | |||||
} | |||||
else { | |||||
return 0; # login NOT successful | |||||
} | |||||
} | |||||
} | |||||
# -------------------------------------------------------------------------------- | |||||
# Print usage and exit: | |||||
sub usage | |||||
{ | |||||
local ($status) = @_; | |||||
print "\nrefbase_import command line client, v" . $version . " by Matthias Steffens, http://cli.refbase.net/\n\n" | |||||
. "Usage: refbase_import [OPTIONS] [FILE]\n\n" | |||||
. "Notes: - Two import modes are supported:\n" | |||||
. " 1) '--type=data' requires an import FILE to be specified;\n" | |||||
. " for supported import formats, see: http://import.refbase.net/\n" | |||||
. " 2) '--type=id' requires the '-p, --pmid' option or one of '--arxiv|--doi|--openurl' with\n" | |||||
. " one or more whitespace-delimited PubMed IDs, arXiv IDs, DOIs or OpenURLs, respectively.\n" | |||||
. " - Options syntax: [OPTION]=[VALUE], e.g. '-p=16351846' or '--pmid=\"16351846 16783713\"'.\n" | |||||
. " - For each option, default values can be specified at the top of the script.\n" | |||||
. " Current defaults are given in parentheses.\n\n" | |||||
. "General Options: -h, --help - display this help text\n" | |||||
. " -v, --version - display version information\n" | |||||
. " -X, --examples - display usage examples\n\n" | |||||
. "Import Options: -b, --skipbad - skip records with unrecognized data format ('" . $params{'skipBadRecords'} . "')\n" | |||||
. " possible values: 0, 1\n" | |||||
. " -i, --import - import all or only some records ('" . $params{'importRecordsRadio'} . "')\n" | |||||
. " possible values: all, only\n" | |||||
. " -p, --pmid, - IDs of records to import ('" . $params{'sourceIDs'} . "')\n" | |||||
. " --arxiv, supported IDs: PubMed ID (PMID), arXiv ID, DOI, OpenURL\n" | |||||
. " --doi, \n" | |||||
. " --openurl \n" | |||||
. " -r, --records - positional numbers and/or ranges of records to import ('" . $params{'importRecords'} . "')\n" | |||||
. " requires the '--import=only' option\n" | |||||
. " -t, --type - import type ('" . $params{'formType'} . "')\n" | |||||
. " possible values: data, id\n\n" | |||||
. "Output Options: -C, --style - citation style ('" . $outputParams{'citeStyle'} . "')\n" | |||||
. " -F, --format - output format ('" . $outputParams{'format'} . "')\n" | |||||
. " possible values: html, rtf, pdf, latex, latex_bbl, markdown, ascii,\n" | |||||
. " ads, bibtex, endnote, isi, ris, atom, mods, oai_dc,\n" | |||||
. " odf, srw_dc, srw_mods, word\n" | |||||
. " -L, --showlinks - hide/display links column in html output ('" . $outputParams{'showLinks'} . "')\n" | |||||
. " possible values: 0, 1\n" | |||||
. " -O, --order - sort order of returned records ('" . $outputParams{'citeOrder'} . "')\n" | |||||
. " possible values: author, year, type, type-year, creation-date\n" | |||||
. " -V, --view - view type of html output ('" . $outputParams{'viewType'} . "')\n" | |||||
. " possible values: web, print, mobile\n\n" | |||||
. "Server Options: -H, --host - URL of the refbase database ('" . $host . "')\n" | |||||
. " defined shortcuts: " . join(', ', sort keys(%hosts)) . "\n" | |||||
. " -P, --password - password for given '-U, --user' account"; | |||||
if ($loginParams{'loginPassword'} ne '') { | |||||
print "\n (a default pwd has been defined)\n"; | |||||
} | |||||
else { | |||||
print " ('')\n"; | |||||
} | |||||
print " -U, --user - login email address of an existing refbase user with\n" | |||||
. " import permissions ('" . $loginParams{'loginEmail'} . "')\n\n"; | |||||
exit $status; | |||||
} | |||||
# -------------------------------------------------------------------------------- | |||||
# Print version number and exit: | |||||
sub version | |||||
{ | |||||
local ($status) = @_; | |||||
print "\nrefbase_import command line client, version " . $version | |||||
. "\ncheck for updates at http://cli.refbase.net/\n\n"; | |||||
exit $status; | |||||
} | |||||
# -------------------------------------------------------------------------------- | |||||
# Print examples and exit: | |||||
sub examples | |||||
{ | |||||
local ($status) = @_; | |||||
print <<'END_EXAMPLES'; | |||||
-------------------------------------------------------------------------------- | |||||
REFBASE_IMPORT USAGE EXAMPLES: | |||||
-------------------------------------------------------------------------------- | |||||
1) Import BibTeX records from file 'import.bib' using the defaults defined | |||||
within the refbase_import script: | |||||
refbase_import import.bib | |||||
-------------------------------------------------------------------------------- | |||||
2) Import all Endnote records given in file 'import.enw' into your default | |||||
refbase database: | |||||
refbase_import -t=data -i=all import.enw | |||||
-------------------------------------------------------------------------------- | |||||
3) Take RIS records from file 'import.ris' but import only the first three as | |||||
well as the fifth and the tenth record into your local refbase database: | |||||
refbase_import -H=local -t=data -i=only -r=1-3,5,10 import.ris | |||||
-------------------------------------------------------------------------------- | |||||
4) Import MODS XML records from file 'mods.xml' into the refbase demo database | |||||
using the defaults defined within the refbase_import script: | |||||
refbase_import -H=http://demo.refbase.net/ -U=user@refbase.net -P=user mods.xml | |||||
-------------------------------------------------------------------------------- | |||||
5) Fetch two records from PubMed.gov via their PMID (i.e. the unique PubMed | |||||
identifier, in this example, records with PMIDs 16351846 and 16783713) and | |||||
import them into your local refbase database: | |||||
refbase_import -H=local -t=id -p="16351846 16783713" | |||||
-------------------------------------------------------------------------------- | |||||
6) Fetch two records from CrossRef.org via their DOI (i.e. the unique Document | |||||
Object Identifier, in this example, records with DOIs 10.3354/meps251037 and | |||||
10.1103/PhysRev.47.777) and import them into your local refbase database: | |||||
refbase_import -H=local -t=id --doi="10.3354/meps251037 10.1103/PhysRev.47.777" | |||||
-------------------------------------------------------------------------------- | |||||
7) Fetch three records from arXiv.org via their arXiv ID (i.e. the unique arXiv | |||||
identifier, in this example, records with arXiv IDs astro-ph/0609768, 0806.1829 | |||||
and 0802.0204v1) and import them into your local refbase database: | |||||
refbase_import -H=local -t=id --arxiv="astro-ph/0609768 0806.1829 0802.0204v1" | |||||
-------------------------------------------------------------------------------- | |||||
END_EXAMPLES | |||||
exit $status; | |||||
} | |||||
__END__ |
@ -0,0 +1,42 @@ | |||||
endnote2refbase | |||||
=============== | |||||
Author | |||||
------ | |||||
Richard Karnesky <karnesky@gmail.com> | |||||
About | |||||
----- | |||||
This is an alternative to refbase's web-based import of Endnote data. It | |||||
allows Endnote users to export a text file which can be imported into the | |||||
refbase MySQL database. | |||||
Use | |||||
--- | |||||
Part I: Endnote | |||||
- Copy refbase.ens into your Endnote styles directory. | |||||
On win32 systems, this is typically: | |||||
C:\Program Files\Endnote\Styles | |||||
On Mac systems, this is typically: | |||||
Macintosh HD\Applications\EndNote #\Styles | |||||
(where # corresponds to a version #) | |||||
- Open the Endnote file you wish to import into refbase. | |||||
- Choose the refbase Output Style | |||||
- Export to 'endnote.txt' | |||||
Part II: PHP [*] | |||||
- Executing 'php endnote2mysql.php' will produce 'import.txt' | |||||
('php' must be in your path or you should prefix it with the path to php) | |||||
Part III: Check it! | |||||
- As this is a preliminary script that has undergone little testing, it is | |||||
suggested that you look at 'import.txt' in spreadsheet software. | |||||
- New versions of Endnote dump UTF-8 data. You should be able to use this as | |||||
is if you have a UTF-8 database. If you don't have a UTF-8 database, you | |||||
should convert the file to the character encoding you do use (using iconv, | |||||
recode, or <http://www.motobit.com/util/charset-codepage-conversion.asp>). | |||||
Part IV: MySQL [*] | |||||
- From within your MySQL command line interpreter (mysql -u root literature -p): | |||||
LOAD DATA LOCAL INFILE "import.txt" INTO TABLE refs; | |||||
[*]If you are comfortable that the script works and are on a system with a POSIX | |||||
shell (nearly all *nix, including OS X; Windows through Cygwin or similar), | |||||
you may use Andreas Czerniak's en-importer.sh to automate Parts II-IV. |
@ -0,0 +1,51 @@ | |||||
#!/bin/bash | |||||
# | |||||
# EndNote - Importer to RefBase MySQL table | |||||
# | |||||
# Andreas Czerniak <ac@oceanlibrary.org> | |||||
# | |||||
# initial: 05-11-2005 | |||||
# | |||||
# modified: | |||||
# 2005-12-11 ; ac ; clean up static codes | |||||
# 2005-12-15 ; rk ; remove "v.9", import into CVS | |||||
# 2006-01-03 ; ac ; replace LOAD DATA INTO statement with mysqlimport - Thx. Matthias Steffens <refbase@extracts.de> | |||||
# | |||||
if [ $# -lt 1 ]; then | |||||
echo "Which endnote file ?" | |||||
echo -e "\nusage: $0 endnote.file [database [mysql-options] ]\n" | |||||
exit 127 | |||||
fi | |||||
ENFILE=$1 | |||||
MYSQLDB=$2 || MYSQLDB="literature" # default: literature | |||||
MYSQLOPTION=$3 || MYSQLOPTION="-p" # default: with password | |||||
if [ ! -d imported ] ; then | |||||
mkdir imported | |||||
fi | |||||
./endnote2mysql.php $1 | |||||
if [ ! -f import.txt ] ; then | |||||
echo "endnote2mysql convert failed !" | |||||
exit 0 | |||||
fi | |||||
mv import.txt refs.txt | |||||
mysqlimport --local $MYSQLOPTION $MYSQLDB "refs.txt" > sqloutput.txt | |||||
cat sqloutput.txt | |||||
rm refs.txt | |||||
rm sqloutput.txt | |||||
cat $ENFILE | tail | |||||
echo "\n\nrows imported: " | |||||
cat $ENFILE | wc -l | |||||
mv $ENFILE imported/. | |||||
@ -0,0 +1,63 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author. | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./contrib/endnote/endnote2mysql.php | |||||
// Author: Richard Karnesky <mailto:karnesky@northwestern.edu> | |||||
// | |||||
// Created: 18-Mar-05, 17:10 | |||||
// Modified: 19-Mar-05, 13:50 | |||||
// WARNING | |||||
// This hasn't been tested extensively & can cause weirdness. Give the data | |||||
// a once over in a spreadsheet to confirm it looks OK before import!!! | |||||
// This processes the text file produced by using refbase.ens in Endnote: | |||||
// - Fixes linefeeds, which Endnote can't handle well: | |||||
// - trims carriage returns | |||||
// - replaces newlines with '\n' | |||||
// - trims '<REFBASE>' from the start of each citation | |||||
// - replaces '</REFBASE>' with a newline character | |||||
// - Replaces '<REFBASE J/>' with 'Journal' (a Field Name in Endnote) | |||||
// - Inserts '\N' between multiple tabs (to explicitly NULL empty fields) | |||||
// - Replaces '<Go to ISI>://*\t' with '\N' (bad URLs in Endnote) | |||||
// TODO: | |||||
// - Tabs within fields aren't replaced! This can screw things up! | |||||
// - Allow people to change import & export filenames | |||||
// - More fields (particularly all dates, first author, number of authors) | |||||
// - Better parsing of current fields (correct use of 'ed' vs 'eds) | |||||
// - Automatically import via mysql (intentionally unimplemented for safety) | |||||
// - Deprecate this whole darn mess by adding native import facilities ;-) | |||||
$fin = file_get_contents('endnote.txt'); | |||||
if (!$fin) { | |||||
echo "Error! Couldn't open endnote.txt."; | |||||
} | |||||
else { | |||||
$fin = str_replace("\r","",$fin); | |||||
$fin = str_replace("\n","\\n",$fin); | |||||
$fin = str_replace("<REFBASE>","",$fin); | |||||
$fin = str_replace("</REFBASE>\\n","\n",$fin); | |||||
$fin = str_replace("<REFBASE J/>","Journal",$fin); | |||||
$fin = preg_replace("/(?<=\t)(?=\t)/","\\N",$fin); | |||||
$fin = preg_replace("/<Go to ISI>:\/\/\S*/","\\N",$fin); | |||||
} | |||||
do { | |||||
if (!($fout = fopen('import.txt', "w"))) { | |||||
$rc = 1; break; | |||||
} | |||||
if (!fwrite($fout, $fin)) { | |||||
$rc = 2; break; | |||||
} | |||||
$rc = true; | |||||
} while (0); | |||||
if ($fout) { | |||||
fclose($fout); | |||||
} | |||||
?> |
@ -0,0 +1,209 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./import_template_base.php | |||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/contrib/import_templates/import_template_base.php $ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 11-Jan-06, 18:36 | |||||
// Modified: $Date: 2012-02-27 20:25:30 +0000 (Mon, 27 Feb 2012) $ | |||||
// $Author: msteffens $ | |||||
// $Revision: 1337 $ | |||||
// Template for a batch import script. | |||||
// Use this script to develop your own batch importer. | |||||
// See the scripts 'import.php' and 'import_modify.php' for a working example. | |||||
// Incorporate some include files: | |||||
include 'initialize/db.inc.php'; // 'db.inc.php' is included to hide username and password | |||||
include 'includes/include.inc.php'; // include common functions | |||||
include 'initialize/ini.inc.php'; // include common variables | |||||
// -------------------------------------------------------------------- | |||||
// START A SESSION: | |||||
// call the 'start_session()' function (from 'include.inc.php') which will also read out available session variables: | |||||
start_session(true); | |||||
// -------------------------------------------------------------------- | |||||
// Initialize preferred display language: | |||||
// (note that 'locales.inc.php' has to be included *after* the call to the 'start_session()' function) | |||||
include 'includes/locales.inc.php'; // include the locales | |||||
// -------------------------------------------------------------------- | |||||
// Get the referring page (or set a default one if no referrer is available): | |||||
if (!empty($_SERVER['HTTP_REFERER'])) // if the referrer variable isn't empty | |||||
$referer = $_SERVER['HTTP_REFERER']; // on error, redirect to calling page | |||||
else | |||||
$referer = "import.php"; // on error, redirect to the web import form (if you've got your own import form, insert it's script name here) | |||||
// First of all, check if the user is logged in: | |||||
if (!isset($_SESSION['loginEmail'])) // -> if the user isn't logged in | |||||
{ | |||||
header("Location: user_login.php?referer=" . rawurlencode($referer)); // ask the user to login first, then he'll get directed back to the calling page | |||||
exit; // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> !EXIT! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |||||
} | |||||
// now, check if the (logged in) user is allowed to import any record into the database: | |||||
if (isset($_SESSION['user_permissions']) AND !preg_match("/allow_import|allow_batch_import/", $_SESSION['user_permissions'])) // if the 'user_permissions' session variable does NOT contain either 'allow_import' or 'allow_batch_import'... | |||||
{ | |||||
// return an appropriate error message: | |||||
$HeaderString = returnMsg($loc["NoPermission"] . $loc["NoPermission_ForImport"] . "!", "warning", "strong", "HeaderString"); // function 'returnMsg()' is defined in 'include.inc.php' | |||||
header("Location: index.php"); // redirect back to main page ('index.php') | |||||
exit; // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> !EXIT! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |||||
} | |||||
// -------------------------------------------------------------------- | |||||
// PROCESS SOURCE DATA: | |||||
$parsedRecordsArray = array(); // initialize array variable which will hold parsed data of all records that shall be imported | |||||
// >>> insert your own code here that parses your source data into an array of arrays holding the extracted field data <<< | |||||
// ToDo: | |||||
// (1) Obtain your source data via a web form, file upload, direct read-in of a local source file, etc | |||||
// If your script allows input from the web, make sure to validate your data, see 'import.php' & 'import_modify.php' for an example | |||||
// (2) Split your source data into individual bits representing individual records | |||||
// (3) Loop over each record and extract the record's field data into an array; | |||||
// For each record you should end up with an array structure similar to the one below ('$recordFieldParametersArray'): | |||||
// NOTES: - you can safely omit unneeded fields from your data array; for any fields that aren't present in the data array, the database will insert its default values | |||||
// - the 'addRecords()' function will take care of the calculation fields ('first_author', 'author_count', 'first_page', 'volume_numeric' and 'series_volume_numeric') | |||||
// - similarly, the *date/*time/*by fields ('created_date', 'created_time', 'created_by', 'modified_date', 'modified_time', 'modified_by') will be filled automatically | |||||
// if no custom values (in correct date ['YYYY-MM-DD'] and time ['HH:MM:SS'] format) are given in your array | |||||
// - you can pass any custom info for the 'location' field in your array; however, if you omit the 'location' field from the array | |||||
// the 'addRecords()' function will insert name & email address of the currently logged-in user (e.g. 'Matthias Steffens (refbase@extracts.de)') | |||||
// - the serial number(s) will be assigned automatically (and returned by the 'addRecords()' function in form of an array) | |||||
// - this import example will only add to the main MySQL table ('refs'), but not to the 'user_data' table | |||||
// Example record data array. Commented fields will be filled automatically if not present (see notes above). | |||||
// Comments behind field spec give the resulting calculation field values for this example: | |||||
$recordFieldParametersArray = array( | |||||
'author' => "FirstAuthor, Initials; SecondAuthor, Initials", // 'first_author' = "FirstAuthor, Initials"; 'author_count' = "2" | |||||
'address' => "Address", | |||||
'corporate_author' => "Corporate Author", | |||||
'title' => "Title", | |||||
'orig_title' => "Orig Title", | |||||
'publication' => "Publication", | |||||
'abbrev_journal' => "Abbrev Journal", | |||||
'year' => "2005", | |||||
'volume' => "2nd Volume", // 'volume_numeric' = "2" | |||||
'issue' => "Issue", | |||||
'pages' => "5 Pages", // 'first_page' = "5" | |||||
'keywords' => "Keywords", | |||||
'abstract' => "Abstract", | |||||
'edition' => "2", | |||||
'editor' => "Editor", | |||||
'publisher' => "Publisher", | |||||
'place' => "Place", | |||||
'medium' => "Medium", | |||||
'series_editor' => "Series Editor", | |||||
'series_title' => "Series Title", | |||||
'abbrev_series_title' => "Abbrev Series Title", | |||||
'series_volume' => "3rd Series Volume", // 'series_volume_numeric' = "3" | |||||
'series_issue' => "Series Issue", | |||||
'issn' => "ISSN", | |||||
'isbn' => "ISBN", | |||||
'language' => "Language", | |||||
'summary_language' => "Summary Language", | |||||
'area' => "Area", | |||||
'type' => "Type", | |||||
'thesis' => "Diploma thesis", | |||||
'expedition' => "Expedition", | |||||
'doi' => "DOI", | |||||
'conference' => "Conference", | |||||
'url' => "URL", | |||||
'call_number' => "Call Number", | |||||
// 'location' => "Location", | |||||
'contribution_id' => "Contribution Id", | |||||
'online_publication' => "no", | |||||
'online_citation' => "Online Citation", | |||||
'file' => "File", | |||||
'notes' => "Notes", | |||||
'approved' => "no", | |||||
// 'created_date' => "1999-11-30", | |||||
// 'created_time' => "00:00:01", | |||||
// 'created_by' => "Created By", | |||||
// 'modified_date' => "1999-11-31", | |||||
// 'modified_time' => "00:00:02", | |||||
// 'modified_by' => "Modified By", | |||||
'orig_record' => "-123" | |||||
); | |||||
// (4) Append the array of extracted field data to the main data array which holds all records to import: | |||||
$parsedRecordsArray[] = $recordFieldParametersArray; // in this example, we simply import a single record, adopt to your needs | |||||
$recordsCount = count($parsedRecordsArray); // count how many records are available | |||||
// check if the current user has batch import permission: | |||||
if (($recordsCount > 1) AND isset($_SESSION['user_permissions']) AND !preg_match("/allow_batch_import/", $_SESSION['user_permissions'])) // if we're supposed to import several records BUT the 'user_permissions' session variable does NOT contain 'allow_batch_import'... | |||||
{ | |||||
// return an appropriate error message: | |||||
// (note that this error message will overwrite any '$headerMessage' that gets specified below) | |||||
$HeaderString = returnMsg($loc["NoPermission"] . $loc["NoPermission_ForBatchImport"] . "!", "warning", "strong", "HeaderString", "", " " . $loc["Warning_OnlyFirstRecordImported"]) . ":"; // function 'returnMsg()' is defined in 'include.inc.php' | |||||
array_splice($parsedRecordsArray, 1); // remove all but the first record from the array of records that shall be imported | |||||
} | |||||
// -------------------------------------------------------------------- | |||||
// IMPORT RECORDS: | |||||
// Build an array structure suitable for passing to the 'addRecords()' function: | |||||
$importDataArray = array(); // for an explanation of the structure of '$importDataArray', see the comments above the 'addRecords()' function (in 'include.inc.php') | |||||
$importDataArray['type'] = "refbase"; // we use the "refbase" array format | |||||
$importDataArray['version'] = "1.0"; // we use version "1.0" of the array structure | |||||
$importDataArray['creator'] = "http://refbase.net"; // calling script/importer is "refbase" (insert the unique name of your importer here or give the web address of it's home page) | |||||
$importDataArray['author'] = "Matthias Steffens"; // author/contact name of the person who's responsible for this script/importer (insert your own name here) | |||||
$importDataArray['contact'] = "refbase@extracts.de"; // author's email/contact address (insert your email address here) | |||||
$importDataArray['options'] = array('prefix_call_number' => "true"); // if "true", any 'call_number' string will be prefixed with the correct call number prefix of the currently logged-in user (e.g. 'IPÖ @ msteffens @ ') | |||||
$importDataArray['records'] = $parsedRecordsArray; // this array will hold the record(s) (with each record being a sub-array of fields) | |||||
// Add all records to the database (i.e., for each record, add a row entry to MySQL table 'refs'): | |||||
// ('$importedRecordsArray' will hold the serial numbers of all newly imported records) | |||||
$importedRecordsArray = addRecords($importDataArray); // function 'addRecords()' is defined in 'include.inc.php' | |||||
// -------------------------------------------------------------------- | |||||
// DISPLAY RESULTS: | |||||
if (!empty($importedRecordsArray)) // if some records were successfully imported | |||||
{ | |||||
$recordSerialsQueryString = "^(" . implode("|", $importedRecordsArray) . ")$"; | |||||
$importedRecordsCount = count($importedRecordsArray); | |||||
if ($importedRecordsCount == 1) | |||||
$headerMessage = $importedRecordsCount . " " . $loc["RecordSuccessfullyImported"] . ":"; | |||||
else // $importedRecordsCount > 1 | |||||
$headerMessage = $importedRecordsCount . " " . $loc["RecordsSuccessfullyImported"] . ":"; | |||||
// display all newly added records: | |||||
header("Location: show.php?serial=" . rawurlencode($recordSerialsQueryString) . "&headerMsg=" . rawurlencode($headerMessage)); | |||||
} | |||||
else // nothing imported | |||||
{ | |||||
// return an appropriate error message: | |||||
$HeaderString = returnMsg($loc["NoRecordsImported"] . "!", "warning", "strong", "HeaderString"); // function 'returnMsg()' is defined in 'include.inc.php' | |||||
if (!empty($_SERVER['HTTP_REFERER'])) // if the referer variable isn't empty | |||||
header("Location: " . $_SERVER['HTTP_REFERER']); // redirect to calling page | |||||
else | |||||
header("Location: index.php"); // redirect to main page ('index.php') | |||||
} | |||||
// -------------------------------------------------------------------- | |||||
?> |
@ -0,0 +1,156 @@ | |||||
refbase extension for MediaWiki | |||||
=============================== | |||||
Authors | |||||
------- | |||||
Richard Karnesky <karnesky@gmail.com> | |||||
Thibault Marin <thibault.marin at gmx dot com> | |||||
About | |||||
----- | |||||
This is an extension to MediaWiki: | |||||
<https://www.mediawiki.org/> | |||||
It allows you to cite references by enclosing the serial or the citation key | |||||
in tags such as: | |||||
<refbase>17</refbase> or <refbase>Author2000</refbase> | |||||
To install the extension, download and extract the files in a directory called | |||||
Refbase in your mediawiki extensions/ folder. Add the following code at the | |||||
bottom of your LocalSettings.php: | |||||
require_once( "$IP/extensions/Refbase/Refbase.php" ); | |||||
To verify that the extension is successfully installed, go to the | |||||
"Special:Version" page on your wiki, you should see the Refbase extension in | |||||
the list of parser hook extensions. | |||||
To configure the extension, add the following lines (modified to match your | |||||
setup) after the 'require_once' line in your LocalSettings.php (omitted fields | |||||
take the default value indicated here): | |||||
$wgRefbaseDbHost = "localhost"; // refbase database host | |||||
$wgRefbaseDbName = "literature"; // Database name | |||||
$wgRefbaseDbUser = "litwww"; // User name for database | |||||
$wgRefbaseDbPass = "%l1t3ratur3?"; // Database password | |||||
$wgRefbaseDbCharset = "utf8"; // Database charset | |||||
$wgRefbaseDbRefTable = "refs"; // Table with references | |||||
$wgRefbaseDbUserDataTable = "user_data"; // Table with cite_key field | |||||
$wgRefbaseDbAccessMethod = "mysql"; // Database access mode | |||||
// 'mysql' or 'PDO' | |||||
// Host for refbase instance (used for url links). This may differ from the | |||||
// database host (requires a trailing slash) | |||||
$wgRefbaseURL = "http://".$_SERVER['HTTP_HOST']."/refbase/"; | |||||
// HTTP (basic) authentication mode when accessing refbase instance (only | |||||
// used with 'cite' and 'link' output types, when using a 'rb-*' citation | |||||
// type), see below for details. | |||||
$wgRefbaseURLAuth = ''; // '', 'default' or 'user:pass' | |||||
A few options can also be set (see below for description): | |||||
// Tag type | |||||
$wgRefbaseDefaultTagType = 'serial'; // 'serial' or 'citekey' | |||||
// Output type | |||||
$wgRefbaseDefaultOutputType = 'cite_journal'; // 'cite_journal', 'cite' | |||||
// or 'link' | |||||
// Citation type | |||||
$wgRefbaseDefaultCitationType = 'minimal'; // 'minimal' or 'rb-*' | |||||
Options | |||||
------- | |||||
0. Scope | |||||
All options are set globally (by the $wgRefbaseDefault* variables) for the | |||||
whole wiki. Most can also be modified for individual instances of the | |||||
<refbase> tag by passing extra arguments to the tag, e.g. <refbase | |||||
tagtype='citekey' output='cite'>XXX</refbase>. | |||||
1. Tag type | |||||
Possible values: 'serial', 'citekey' | |||||
Global setting | |||||
$wgRefbaseDefaultTagType = 'serial'; | |||||
Individual setting | |||||
<refbase tagtype='serial'>XXX</refbase> | |||||
This option controls the interpretation of the tag input: when using the | |||||
refbase tag in wikipages, e.g. <refbase>XXX</refbase>, the input key (XXX) | |||||
can refer to the serial number ('serial' type) or the citation key | |||||
('citekey' type). Note that if no entry is found using the selected tag | |||||
type, a second search is performed with the other tag type. | |||||
2. Output type | |||||
Possible values: 'cite_journal', 'cite', 'link' | |||||
Global setting | |||||
$wgRefbaseDefaultOutputType = 'cite_journal'; | |||||
Individual setting | |||||
<refbase output='cite_journal'>XXX</refbase> | |||||
This option determines the way citations are rendered in the wikipage. There | |||||
are several modes: | |||||
.'cite_journal': This is the default mode, used in version 0.9 of the | |||||
extension. The output will use citation templates, as are used on | |||||
Wikipedia: | |||||
<https://en.wikipedia.org/wiki/Wikipedia:Citation_templates> | |||||
Currently, only journal articles may be cited with this output type. In | |||||
the future, this extension is likely to be modified. 'refbase' should | |||||
be able to generate WP citation templates as an export format & this | |||||
extension should make use of that functionality directly. | |||||
.'cite': This mode uses the Cite extension | |||||
<https://www.mediawiki.org/wiki/Extension:Cite> | |||||
A footnote is generated for each citation using the <ref> tag. Multiple | |||||
references to the same entry are automatically combined using the <ref | |||||
name=YYY> option. To see the list of references a <references/> tag | |||||
must be added to the wikipage where the bibliography should be | |||||
displayed. See the Cite extension documentation for details. The | |||||
footnote text is a citation following the 'citation type' option (see | |||||
below). | |||||
.'link': This is a simple renderer which does not require any installed | |||||
template/extension. It simply writes the tag input (serial or citation | |||||
key) to the wikipage, adding a tooltip and a hyperlink to the refbase | |||||
entry. The tooltip contains the citation text (controlled by the | |||||
citation type variable) and the hyperlink links to the refbase page (the | |||||
base refbase installation location is given by the $wgRefbaseURL | |||||
variable). | |||||
3. Citation type | |||||
Possible values: 'minimal, 'rb-default', 'rb-MLA', 'rb-APA', etc. | |||||
Global setting | |||||
$wgRefbaseDefaultCitationType = 'minimal'; | |||||
Individual setting | |||||
<refbase citationtype='minimal'>XXX</refbase> | |||||
This option determines how citations are rendered in the 'cite' and 'link' | |||||
output modes (it has no effect when using the 'cite_journal' output type). | |||||
The two possible modes are: | |||||
.'minimal': This generates a simple citation with the authors, title, | |||||
publication and year. | |||||
.'rb-*': This requests the citation text from the refbase web interface. | |||||
The * in 'rb-*' can be 'default' (i.e. 'rb-default') or any acceptable | |||||
citation style (defined in the 'styles' database). | |||||
4. Database connection mode | |||||
Possible values: 'mysql', 'PDO' | |||||
Global setting | |||||
$wgRefbaseDbAccessMethod = 'mysql'; | |||||
Individual setting | |||||
This option can only be set at the global level. | |||||
This option selects the way the extension connects to the mysql database. | |||||
The 'mysql' mode is getting deprecated in recent versions of php, but is | |||||
still available for older installations. | |||||
5. HTTP authentication for requests to refbase instance | |||||
Possible values: '', 'default' or 'user:pass' | |||||
Global setting | |||||
$wgRefbaseURLAuth = ''; | |||||
Individual setting | |||||
This option can only be set at the global level. | |||||
This option is used to pass an HTTP authentication token to the server | |||||
hosting the refbase installation (basic authentication e.g. from apache | |||||
server). If $wgRefbaseURLAuth is empty (''), no authentication is passed. | |||||
If set to 'default', the current user/password token will be passed when | |||||
requesting data from the refbase web interface (this is useful when both | |||||
mediawiki and refbase are under the same basic server authentication). To | |||||
specify an arbitrary user and password, set $wgRefbaseURLAuth to 'user:pass' | |||||
where 'user' is the username and 'pass' the password for that user (note | |||||
that the username cannot contain colon characters ':'). This option is | |||||
relevant only when using the 'cite' or 'link' output types along with one of | |||||
the 'rb-*' citation type. | |||||
Notes | |||||
----- | |||||
You may also be interested in the MonoBook skin, included in the | |||||
'contrib/skins/mediawiki-monobook' directory from refbase. | |||||
An installation of MediaWiki that uses this extension is the Northwestern | |||||
University Center for Atom-Probe Tomography: | |||||
<http://arc.nucapt.northwestern.edu/#Literature> | |||||
@ -0,0 +1,113 @@ | |||||
<?php | |||||
/** | |||||
* Refbase hooks and parser | |||||
*/ | |||||
class RefbaseHooks { | |||||
/** | |||||
* Register <refbase> hook | |||||
*/ | |||||
public static function efRefbaseParserInit( $parser ) { | |||||
$parser->setHook( 'refbase', | |||||
'RefbaseHooks::efRefbaseRender' ); | |||||
return true; | |||||
} | |||||
/** | |||||
* Define special formatting for this tag | |||||
*/ | |||||
private static function makeOutputString ( $str ) { | |||||
return $str; | |||||
} | |||||
/** | |||||
* Add <pre></pre> tags around error message and return | |||||
*/ | |||||
private static function makeErrorOutputString ( $errMsg ) { | |||||
$errMsg = "Refbase: <br/>" . $errMsg; | |||||
$preMsg = Html::openElement( 'pre' ) . $errMsg . | |||||
Html::closeElement( 'pre' ); | |||||
return self::makeOutputString( $preMsg ); | |||||
} | |||||
/** | |||||
* Main function: parse input and create HTML table with events | |||||
*/ | |||||
public static function efRefbaseRender( $input, array $args, | |||||
Parser $parser, | |||||
PPFrame $frame ) { | |||||
// Global parameters | |||||
global $wgRefbaseDefaultTagType; | |||||
global $wgRefbaseDefaultOutputType; | |||||
global $wgRefbaseDefaultCitationType; | |||||
// Read arguments | |||||
if ( isset( $args['tagtype'] ) ) { | |||||
$tagType = $args['tagtype']; | |||||
} else { | |||||
$tagType = $wgRefbaseDefaultTagType; | |||||
} | |||||
if ( ! ( strtolower( $tagType ) === 'serial' ) && | |||||
! ( strtolower( $tagType ) === 'citekey' ) ) { | |||||
$errStr = wfMessage( 'refbase-error-tagtype' )->text(); | |||||
return self::makeErrorOutputString( $errStr ); | |||||
} | |||||
if ( isset( $args['output'] ) ) { | |||||
$outputType = $args['output']; | |||||
} else { | |||||
$outputType = $wgRefbaseDefaultOutputType; | |||||
} | |||||
if ( ! ( strtolower( $outputType ) === 'cite_journal' ) && | |||||
! ( strtolower( $outputType ) === 'link' ) && | |||||
! ( strtolower( $outputType ) === 'cite' ) ) { | |||||
$errStr = wfMessage( 'refbase-error-outputtype' )->text(); | |||||
return self::makeErrorOutputString( $errStr ); | |||||
} | |||||
if ( isset( $args['citationtype'] ) ) { | |||||
$citationType = $args['citationtype']; | |||||
} else { | |||||
$citationType = $wgRefbaseDefaultCitationType; | |||||
} | |||||
if ( ! ( strtolower( $citationType ) === 'minimal' ) && | |||||
! ( strtolower( substr( $citationType, 0, 3 ) ) === 'rb-' ) ) { | |||||
$errStr = wfMessage( 'refbase-error-citation-type' )->text(); | |||||
return self::makeErrorOutputString( $errStr ); | |||||
} | |||||
// Order tag types | |||||
switch ( strtolower( $tagType ) ) { | |||||
case 'serial': | |||||
$tagTypeList = array( 'serial', 'citekey' ); | |||||
break; | |||||
case 'citekey': | |||||
$tagTypeList = array( 'citekey', 'serial' ); | |||||
break; | |||||
} | |||||
// Instantiate renderer based on options | |||||
$refbaseRenderer = RefbaseRenderer::create( $outputType, | |||||
$citationType ); | |||||
// Request list of fields to extract | |||||
$fieldList = $refbaseRenderer->getFieldList(); | |||||
// Perform database query to get entry | |||||
$refbaseDbConnector = new RefbaseConnector(); | |||||
$entry = ""; | |||||
if ( !$refbaseDbConnector->getEntry( $input, $tagTypeList, $entry, | |||||
$fieldList ) ) { | |||||
return self::makeErrorOutputString( $entry ); | |||||
} | |||||
// Generate output | |||||
$citekey = $input; | |||||
$renderOpts = array( 'citekey' => $citekey ); | |||||
$outputStr = ""; | |||||
if ( !$refbaseRenderer->render( $entry, $outputStr, $renderOpts ) ) { | |||||
return self::makeErrorOutputString( $outputStr ); | |||||
} | |||||
$outputStr = $parser->recursiveTagParse( $outputStr ); | |||||
return self::makeOutputString( $outputStr ); | |||||
} | |||||
} |
@ -0,0 +1,35 @@ | |||||
<?php | |||||
/** | |||||
* This is a backwards-compatibility shim, generated by: | |||||
* https://git.wikimedia.org/blob/mediawiki%2Fcore.git/HEAD/maintenance%2FgenerateJsonI18n.php | |||||
* | |||||
* Beginning with MediaWiki 1.23, translation strings are stored in json files, | |||||
* and the EXTENSION.i18n.php file only exists to provide compatibility with | |||||
* older releases of MediaWiki. For more information about this migration, see: | |||||
* https://www.mediawiki.org/wiki/Requests_for_comment/Localisation_format | |||||
* | |||||
* This shim maintains compatibility back to MediaWiki 1.17. | |||||
*/ | |||||
$messages = array(); | |||||
if ( !function_exists( 'wfJsonI18nShime97052c48294abb71' ) ) { | |||||
function wfJsonI18nShime97052c48294abb71( $cache, $code, &$cachedData ) { | |||||
$codeSequence = array_merge( array( $code ), $cachedData['fallbackSequence'] ); | |||||
foreach ( $codeSequence as $csCode ) { | |||||
$fileName = dirname( __FILE__ ) . "/i18n/$csCode.json"; | |||||
if ( is_readable( $fileName ) ) { | |||||
$data = FormatJson::decode( file_get_contents( $fileName ), true ); | |||||
foreach ( array_keys( $data ) as $key ) { | |||||
if ( $key === '' || $key[0] === '@' ) { | |||||
unset( $data[$key] ); | |||||
} | |||||
} | |||||
$cachedData['messages'] = array_merge( $data, $cachedData['messages'] ); | |||||
} | |||||
$cachedData['deps'][] = new FileDependency( $fileName ); | |||||
} | |||||
return true; | |||||
} | |||||
$GLOBALS['wgHooks']['LocalisationCacheRecache'][] = 'wfJsonI18nShime97052c48294abb71'; | |||||
} |
@ -0,0 +1,105 @@ | |||||
<?php | |||||
// Copyright: Richard Karnesky <mailto:karnesky@gmail.com> | |||||
// This code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. | |||||
// Please see the GNU General Public License for more details. | |||||
if( !defined( 'MEDIAWIKI' ) ) | |||||
{ | |||||
echo( "This is an extension to the MediaWiki package and cannot be run standalone.\n" ); | |||||
die( -1 ); | |||||
} | |||||
$wgExtensionCredits['parserhook'][] = array( | |||||
'path' => __FILE__, | |||||
'name' => 'Refbase', | |||||
'author' => array( 'Richard Karnesky', 'Thibault Marin' ), | |||||
'url' => 'https://www.mediawiki.org/wiki/Extension:Refbase', | |||||
'descriptionmsg' => 'refbase-desc', | |||||
'version' => '1.0', | |||||
'license-name' => '' // Short name of the license, links LICENSE or COPYING file if existing - string, added in 1.23.0 | |||||
); | |||||
/** | |||||
* Extension class | |||||
*/ | |||||
$wgAutoloadClasses['RefbaseHooks'] = | |||||
dirname( __FILE__ ) . '/Refbase.Hooks.php'; | |||||
$wgAutoloadClasses['RefbaseRenderer'] = | |||||
dirname( __FILE__ ) . '/include/Refbase.Renderer.php'; | |||||
$wgAutoloadClasses['RefbaseRendererCitationTemplate'] = | |||||
dirname( __FILE__ ) . '/include/Refbase.Renderer.CitationTemplate.php'; | |||||
$wgAutoloadClasses['RefbaseRendererLink'] = | |||||
dirname( __FILE__ ) . '/include/Refbase.Renderer.Link.php'; | |||||
$wgAutoloadClasses['RefbaseRendererCite'] = | |||||
dirname( __FILE__ ) . '/include/Refbase.Renderer.Cite.php'; | |||||
$wgAutoloadClasses['RefbaseConnector'] = | |||||
dirname( __FILE__ ) . '/include/Refbase.Connector.php'; | |||||
$wgAutoloadClasses['RefbaseCitationCreator'] = | |||||
dirname( __FILE__ ) . '/include/Refbase.CitationCreator.php'; | |||||
$wgAutoloadClasses['RefbaseCitationType'] = | |||||
dirname( __FILE__ ) . '/include/Refbase.CitationCreator.php'; | |||||
$wgAutoloadClasses['RefbaseTools'] = | |||||
dirname( __FILE__ ) . '/include/Refbase.Tools.php'; | |||||
/** | |||||
* Register hooks | |||||
*/ | |||||
$wgHooks['ParserFirstCallInit'][] = 'RefbaseHooks::efRefbaseParserInit'; | |||||
/** | |||||
* Internationalization | |||||
*/ | |||||
$wgMessagesDirs['Refbase'] = __DIR__ . '/i18n'; | |||||
$wgExtensionMessagesFiles['Refbase'] = | |||||
dirname( __FILE__ ) . '/Refbase.i18n.php'; | |||||
/** | |||||
* Parameters (modify in LocalSettings.php) | |||||
*/ | |||||
// refbase database host | |||||
$wgRefbaseDbHost = "localhost"; | |||||
// Database name | |||||
$wgRefbaseDbName = "literature"; | |||||
// User name for database | |||||
$wgRefbaseDbUser = "litwww"; | |||||
// Database password | |||||
$wgRefbaseDbPass = "%l1t3ratur3?"; | |||||
// Database charset | |||||
$wgRefbaseDbCharset = "utf8"; | |||||
// Table with references | |||||
$wgRefbaseDbRefTable = "refs"; | |||||
// Table with user data (cite key) | |||||
$wgRefbaseDbUserDataTable = "user_data"; | |||||
// Extension to interface with database ('mysql' or 'PDO') | |||||
$wgRefbaseDbAccessMethod = "mysql"; | |||||
// Host for refbase instance (used for url links). This may differ from the | |||||
// database host if using https for instance (requires a trailing slash) | |||||
$wgRefbaseURL = "http://".$_SERVER['HTTP_HOST']."/refbase/"; | |||||
// Default tag input: when using <refbase>XXX</refbase>, XXX can refer to the | |||||
// serial number ('serial' type) or the citation key ('citekey' type) | |||||
$wgRefbaseDefaultTagType = "serial"; | |||||
// Default output type: may use cite_journal, cite or link | |||||
$wgRefbaseDefaultOutputType = 'cite_journal'; | |||||
// Default citation type: 'minimal' or 'rb-default' (only for 'link' and 'cite' modes) | |||||
//$wgRefbaseDefaultCitationType = 'minimal'; | |||||
$wgRefbaseDefaultCitationType = 'rb-default'; | |||||
// Option to pass http authentication token when accessing the refbase web | |||||
// interface (used for rb-* citation types). If empty, authentication is | |||||
// disabled. If set to 'default', use the same token as the one used for the | |||||
// mediawiki web site (if any). If this option is set to 'user:pass', then | |||||
// 'user' and 'pass' will be used to form the token (the colon character ':' is | |||||
// not allowed in the username). | |||||
$wgRefbaseURLAuth = ''; |
@ -0,0 +1,16 @@ | |||||
{ | |||||
"@metadata": { | |||||
"authors": [ | |||||
"thibault marin" | |||||
] | |||||
}, | |||||
"refbase-desc": "This extension allows inclusion of bibliographic references from a refbase installation.", | |||||
"refbase-error-tagtype" : "Unsupported tag type (should be 'serial' or 'citekey').", | |||||
"refbase-error-outputtype" : "Unsupported output type (should be 'cite_journal', 'cite' or 'link').", | |||||
"refbase-error-dbquery" : "Error in database query: ", | |||||
"refbase-error-mysqlconn" : "Could not connect to mysql database.", | |||||
"refbase-error-mysqldb" : "Could not select mysql database: ", | |||||
"refbase-error-notfound" : "Entry not found.", | |||||
"refbase-error-cite_journal-type": "cite_journal mode can only display journal articles.", | |||||
"refbase-error-citation-type" : "Citation type unsupported (should be 'minimal' or 'rb-???')." | |||||
} |
@ -0,0 +1,16 @@ | |||||
{ | |||||
"@metadata": { | |||||
"authors": [ | |||||
"thibault marin" | |||||
] | |||||
}, | |||||
"refbase-desc": "{{desc}}", | |||||
"refbase-error-tagtype" : "Error message displayed when the tag type used is not supported.", | |||||
"refbase-error-outputttype" : "Error message displayed when the output type used is not supported.", | |||||
"refbase-error-dbquery" : "Error message displayed when refbase database query failed (followed by error message).", | |||||
"refbase-error-mysqlconn" : "Error message displayed when mysql connection failed (using the mysql extension).", | |||||
"refbase-error-mysqldb" : "Error message displayed when mysql database selection failed (using the mysql extension), error message follows", | |||||
"refbase-error-notfound" : "Error message displayed when key was not gound in database", | |||||
"refbase-error-cite_journal-type": "Error message displayed when cite_journal is used with non-journal entry.", | |||||
"refbase-error-citation-type" : "Error message displayed when trying to create a citation of an unsupported type." | |||||
} |
@ -0,0 +1,144 @@ | |||||
<?php | |||||
/** | |||||
* Enum for citation types | |||||
*/ | |||||
abstract class RefbaseCitationType { | |||||
// Minimal reference type (author, title, publication, year) | |||||
const CT_MINIMAL = 0; | |||||
// Request citation from refbase installation (using show.php interface) | |||||
const CT_RB = 1; | |||||
/** | |||||
* Convert string to RefbaseCitationType | |||||
*/ | |||||
static public function decodeCitationType ( $str, & $citeStyle ) { | |||||
if ( strtolower( $str ) == 'minimal' ) { | |||||
return self::CT_MINIMAL; | |||||
} elseif ( preg_match( '/rb-(.*)/', strtolower( $str ), | |||||
$citeStyle ) ) { | |||||
return self::CT_RB; | |||||
} else { | |||||
return null; | |||||
} | |||||
} | |||||
} | |||||
/** | |||||
* Helper class to generate citation text | |||||
*/ | |||||
class RefbaseCitationCreator { | |||||
/// Citation type | |||||
private $citationType; | |||||
/// Citation style (only with $citationType = CT_RB) | |||||
private $citationStyle = ""; | |||||
/// Location of refbase installation (may differ from $dbHost if using https | |||||
/// for instance) | |||||
protected $refbaseURL = ""; | |||||
/** | |||||
* Constructor | |||||
*/ | |||||
public function __construct( $citationTypeStr ) { | |||||
global $wgRefbaseURL; | |||||
$this->refbaseURL = $wgRefbaseURL; | |||||
$this->citationType = | |||||
RefbaseCitationType::decodeCitationType( $citationTypeStr, | |||||
$citeStyle ); | |||||
if ( !empty( $citeStyle ) ) { | |||||
$this->citationStyle = $citeStyle[1]; | |||||
} | |||||
wfDebug('refbase-decode-in:' . $citationTypeStr . "\n"); | |||||
wfDebug('refbase-decode:' . $this->citationType . ", " . var_export($this->citationStyle,true)."\n"); | |||||
} | |||||
/** | |||||
* Create citation text | |||||
*/ | |||||
public function createCitation( $entry, & $cite ) { | |||||
switch( $this->citationType ) { | |||||
case RefbaseCitationType::CT_MINIMAL: | |||||
$cite = $entry['author'] . ", " . $entry['title'] . ", " . | |||||
$entry['publication'] . ", " . $entry['year'] . "."; | |||||
break; | |||||
case RefbaseCitationType::CT_RB: | |||||
$url = $this->refbaseURL . "show.php?" . | |||||
"record=" . "27711"//$entry['serial'] . | |||||
"&submit=Cite&exportType=text&citeType=ASCII"; | |||||
if ( !empty( $this->citationStyle ) ) { | |||||
$url .= "&citeStyle=" . $this->citationStyle; | |||||
} | |||||
wfDebug('refbase-getcite:' . $url . "\n"); | |||||
// Get citation from url (add http authentication if desired) | |||||
global $wgRefbaseURLAuth; | |||||
if ( !empty( $wgRefbaseURLAuth ) ) { | |||||
if ( strcmp( strtolower( $wgRefbaseURLAuth ), | |||||
'default' ) == 0 ) { | |||||
if ( isset( $_SERVER['PHP_AUTH_USER'] ) && | |||||
isset( $_SERVER['PHP_AUTH_PW'] ) ) { | |||||
$username = $_SERVER['PHP_AUTH_USER']; | |||||
$password = $_SERVER['PHP_AUTH_PW']; | |||||
$authStr = "Authorization: Basic " . | |||||
base64_encode( "$username:$password" ); | |||||
} else { | |||||
$authStr = ''; | |||||
} | |||||
} else { | |||||
preg_match( "/([^:]*):(.*)$/", $wgRefbaseURLAuth, $out); | |||||
$username = $out[1]; | |||||
$password = $out[2]; | |||||
$authStr = "Authorization: Basic " . | |||||
base64_encode( "$username:$password" ); | |||||
} | |||||
$param = array( 'http' => array( 'header' => $authStr ) ); | |||||
$context = stream_context_create( $param ); | |||||
$cite = trim( file_get_contents( $url, false, $context ) ); | |||||
} else { | |||||
$cite = trim( file_get_contents( $url ) ); | |||||
} | |||||
break; | |||||
default: | |||||
$cite = wfMessage( 'refbase-error-citation-type' )->text(); | |||||
} | |||||
return true; | |||||
} | |||||
/* | |||||
* Get list of required fields to produce the citation in the desired format | |||||
*/ | |||||
public function getFieldList() { | |||||
switch( $this->citationType ) { | |||||
case RefbaseCitationType::CT_MINIMAL: | |||||
$fieldList = array( 'author', | |||||
'title', | |||||
'publication', | |||||
'year' ); | |||||
break; | |||||
case RefbaseCitationType::CT_RB: | |||||
$fieldList = array( 'serial' ); | |||||
break; | |||||
default: | |||||
$fieldList = array(); | |||||
} | |||||
return $fieldList; | |||||
} | |||||
} |
@ -0,0 +1,139 @@ | |||||
<?php | |||||
/** | |||||
* Refbase database connector | |||||
*/ | |||||
class RefbaseConnector { | |||||
/// Database location | |||||
private $dbHost = ""; | |||||
/// Database name | |||||
private $dbName = ""; | |||||
/// Database user | |||||
private $dbUser = ""; | |||||
/// Database password | |||||
private $dbPass = ""; | |||||
/// Character set | |||||
private $dbCharset = ""; | |||||
/// Reference table | |||||
private $dbRefTable = ""; | |||||
/// User data table (for cite key entry) | |||||
private $dbUserDataTable = ""; | |||||
/// Method to access database (mysql or PDO) | |||||
private $dbAccessMethod = ""; | |||||
/** | |||||
* Constructor | |||||
*/ | |||||
public function __construct() { | |||||
global $wgRefbaseDbHost; | |||||
global $wgRefbaseDbName; | |||||
global $wgRefbaseDbUser; | |||||
global $wgRefbaseDbPass; | |||||
global $wgRefbaseDbRefTable; | |||||
global $wgRefbaseDbUserDataTable; | |||||
global $wgRefbaseDbCharset; | |||||
global $wgRefbaseDbAccessMethod; | |||||
// Read from global configuration | |||||
$this->dbHost = $wgRefbaseDbHost; | |||||
$this->dbName = $wgRefbaseDbName; | |||||
$this->dbUser = $wgRefbaseDbUser; | |||||
$this->dbPass = $wgRefbaseDbPass; | |||||
$this->dbRefTable = $wgRefbaseDbRefTable; | |||||
$this->dbUserDataTable = $wgRefbaseDbUserDataTable; | |||||
$this->dbCharset = $wgRefbaseDbCharset; | |||||
$this->dbAccessMethod = $wgRefbaseDbAccessMethod; | |||||
} | |||||
/** | |||||
* Query by serial number or cite key entry | |||||
*/ | |||||
public function getEntry( $input, $tagTypeList, & $outputEntry, | |||||
$fieldList ) { | |||||
// List of fields to extract (prefix 'r.' to each element) | |||||
$fieldPref = $fieldList; | |||||
array_walk( $fieldPref, function ( &$value, $key) { | |||||
$value="r.$value"; | |||||
} ); | |||||
$fieldPref = join(",", $fieldPref); | |||||
$flagFound = false; | |||||
for ( $i = 0; $i < count($tagTypeList) && ! $flagFound; $i++ ) { | |||||
$tagType = $tagTypeList[$i]; | |||||
// Query string | |||||
$queryStr = ""; | |||||
if ( $tagType === 'citekey' ) { | |||||
$queryStr = "SELECT $fieldPref " . | |||||
"FROM " . $this->dbRefTable . " r " . | |||||
"INNER JOIN " . $this->dbUserDataTable . " u " . | |||||
"ON r.serial = u.record_id " . | |||||
"WHERE u.cite_key='$input'"; | |||||
} else { | |||||
$queryStr = "SELECT $fieldPref " . | |||||
"FROM " . $this->dbRefTable . " r " . | |||||
"WHERE r.serial='$input'"; | |||||
} | |||||
if ( strtolower( $this->dbAccessMethod ) === 'pdo' ) { | |||||
// Connect and query | |||||
$link = new PDO( 'mysql:host=' . $this->dbHost . ';dbname=' . | |||||
$this->dbName . ';charset=' . $this->dbCharset, | |||||
$this->dbUser, $this->dbPass ); | |||||
$dbexec = $link->prepare( $queryStr ); | |||||
try { | |||||
// Perform query | |||||
$outputEntry = $dbexec->execute(); | |||||
} catch( PDOException $ex ) { | |||||
$outputEntry = wfMessage( 'refbase-error-dbquery' )->text() . | |||||
$ex->getMessage(); | |||||
return false; | |||||
} | |||||
$outputEntry = $dbexec->fetch(PDO::FETCH_ASSOC); | |||||
} elseif ( strtolower( $this->dbAccessMethod ) === 'mysql' ) { | |||||
$link = mysqli_connect( $this->dbHost, $this->dbUser, $this->dbPass, $this->dbName ) or die("db error"); | |||||
if ( !$link ) { | |||||
$outputEntry = wfMessage( 'refbase-error-mysqlconn' )->text(); | |||||
return false; | |||||
} | |||||
$result = mysqli_query($link, $queryStr ); | |||||
if ( !$result ) { | |||||
$outputEntry = wfMessage( 'refbase-error-dbquery' )->text() . | |||||
mysqli_error($link); | |||||
return false; | |||||
} | |||||
$outputEntry = mysqli_fetch_array($result); | |||||
} | |||||
if ( !empty( $outputEntry ) ) { | |||||
$flagFound = true; | |||||
} | |||||
} | |||||
if ( empty( $outputEntry ) ) { | |||||
$outputEntry = wfMessage( 'refbase-error-notfound' )->text(); | |||||
return false; | |||||
} | |||||
return true; | |||||
} | |||||
} | |||||
@ -0,0 +1,113 @@ | |||||
<?php | |||||
/** | |||||
* Refbase entry renderer using citation templates (cite_journal only for now) | |||||
*/ | |||||
class RefbaseRendererCitationTemplate extends RefbaseRenderer { | |||||
/** | |||||
* Constructor (simply inherit from parent) | |||||
*/ | |||||
public function __construct() { | |||||
parent::__construct(); | |||||
} | |||||
/** | |||||
* List fields required to build template | |||||
*/ | |||||
public function getFieldList() { | |||||
return array( 'type', | |||||
'serial', | |||||
'author', | |||||
'year', | |||||
'title', | |||||
'language', | |||||
'publication', | |||||
'volume', | |||||
'issue', | |||||
'pages', | |||||
'place', | |||||
'publisher', | |||||
'issn', | |||||
'doi' ); | |||||
} | |||||
/** | |||||
* Prepare text for template (supports journal articles only) | |||||
*/ | |||||
public function render( $entry, & $cite, $options ) { | |||||
$cite = ""; | |||||
$ret = true; | |||||
if ( $entry["type"] == "Journal Article" ) { | |||||
$cite .= "{{cite_journal|url=" . $this->refbaseURL . "show.php?"; | |||||
$cite .= "record=" . $entry['serial']; | |||||
if( !empty( $entry["author"] ) ) { | |||||
$author = $entry["author"]; | |||||
$aulast = RefbaseTools::extractAuthorsLastName | |||||
( " *; *", " *, *", 1, $author ); | |||||
$aufirst = RefbaseTools::extractAuthorsGivenName | |||||
( " *; *", " *, *", 1, $author ); | |||||
if( !empty( $aulast ) ) { | |||||
$cite .= "|last=" . $aulast; | |||||
} | |||||
if( !empty( $aufirst ) ) { | |||||
$cite .= "|first=" . $aufirst; | |||||
if( !empty( $aulast ) ) { | |||||
$cite .= "|authorlink=$aufirst $aulast"; | |||||
} | |||||
} | |||||
$authorcount = count( preg_split( "/ *; */", $author ) ); | |||||
$au = ""; | |||||
for ( $i=0; $i < $authorcount - 1; $i++ ) { | |||||
$aul = RefbaseTools::extractAuthorsLastName | |||||
( " *; *", " *, *", $i + 2, $author ); | |||||
$auf = RefbaseTools::extractAuthorsGivenName | |||||
( " *; *", " *, *", $i + 2, $author ); | |||||
if ( !empty( $aul ) ) { | |||||
if ( !empty( $auf ) ) { | |||||
$au .= "[[$auf $aul|$aul, $auf]]; "; | |||||
} | |||||
} | |||||
} | |||||
if ( !empty( $au ) ) { | |||||
$cite .= "|coauthors=" . trim( $au, '; ' ); | |||||
} | |||||
} | |||||
if( !empty( $entry["year"] ) ) { | |||||
$cite .= "|year=" . $entry['year']; | |||||
} | |||||
if( !empty( $entry["title"] ) ) { | |||||
$title = RefbaseTools::searchReplaceText( $entry['title'], | |||||
true ); | |||||
$cite .= "|title=" . $title; | |||||
} | |||||
if( !empty( $entry["language"] ) ) | |||||
$cite .= "|language=" . $entry['language']; | |||||
if( !empty( $entry["publication"] ) ) | |||||
$cite .= "|journal=" . $entry['publication']; | |||||
if( !empty( $entry["volume"] ) ) | |||||
$cite .= "|volume=" . $entry['volume']; | |||||
if( !empty( $entry["issue"] ) ) | |||||
$cite .= "|issue=" . $entry['issue']; | |||||
if( !empty( $entry["pages"] ) ) | |||||
$cite .= "|pages=" . $entry['pages']; | |||||
if( !empty( $entry["place"] ) ) | |||||
$cite .= "|location=" . $entry['place']; | |||||
if( !empty( $entry["publiser"] ) ) | |||||
$cite .= "|publisher=" . $entry['publisher']; | |||||
if( !empty( $entry["issn"] ) ) | |||||
$cite .= "|issn=" . $entry['issn']; | |||||
if( !empty( $entry["doi"] ) ) | |||||
$cite .= "|doi=" . $entry['doi']; | |||||
$cite .= "}}"; | |||||
$ret &= true; | |||||
} else { | |||||
$cite .= wfMessage( 'refbase-error-cite_journal-type' )->text(); | |||||
$ret &= false; | |||||
} | |||||
return $ret; | |||||
} | |||||
} | |||||
@ -0,0 +1,48 @@ | |||||
<?php | |||||
/** | |||||
* Refbase entry renderer using the Cite extension tag (<ref>) | |||||
*/ | |||||
class RefbaseRendererCite extends RefbaseRenderer { | |||||
/// Object generating citations | |||||
private $citationCreator; | |||||
/** | |||||
* Constructor (simply inherit from parent) | |||||
*/ | |||||
public function __construct( $citationType ) { | |||||
parent::__construct(); | |||||
$this->citationCreator = new RefbaseCitationCreator( $citationType ); | |||||
} | |||||
/** | |||||
* List fields required to build template | |||||
*/ | |||||
public function getFieldList() { | |||||
$citeList = $this->citationCreator->getFieldList(); | |||||
return array_unique( array_merge( array(), $citeList ) ); | |||||
} | |||||
/** | |||||
* Render output: add wiki link to refbase page, include citation in tooltip | |||||
*/ | |||||
public function render( $entry, & $cite, $options ) { | |||||
$citekey = $options['citekey']; | |||||
$cite = ""; | |||||
// Simply link to refbase, and add tooltip | |||||
// (form string [URL <span title="CITATION"> KEY </span>] ) | |||||
$citation = ""; | |||||
$this->citationCreator->createCitation( $entry, $citation ); | |||||
// Use #tag method to properly pass inputs to <ref> | |||||
$cite .= "{{#tag:ref|$citation|name=$citekey}}"; | |||||
return true; | |||||
} | |||||
} |
@ -0,0 +1,56 @@ | |||||
<?php | |||||
/** | |||||
* Refbase entry renderer using simple hyperlink and tooltip | |||||
*/ | |||||
class RefbaseRendererLink extends RefbaseRenderer { | |||||
/// Object generating citations | |||||
private $citationCreator; | |||||
/** | |||||
* Constructor (simply inherit from parent) | |||||
*/ | |||||
public function __construct( $citationType ) { | |||||
parent::__construct(); | |||||
$this->citationCreator = new RefbaseCitationCreator( $citationType ); | |||||
} | |||||
/** | |||||
* List fields required to build template | |||||
*/ | |||||
public function getFieldList() { | |||||
$citeList = $this->citationCreator->getFieldList(); | |||||
return array_unique( array_merge( array( 'serial' ), $citeList ) ); | |||||
} | |||||
/** | |||||
* Render output: add wiki link to refbase page, include citation in tooltip | |||||
*/ | |||||
public function render( $entry, & $cite, $options ) { | |||||
$citekey = $options['citekey']; | |||||
$cite = ""; | |||||
// Simply link to refbase, and add tooltip | |||||
// (form string [URL <span title="CITATION"> KEY </span>] ) | |||||
// Display the key (cite_key or serial number as wiki text) | |||||
$wikiText = $citekey; | |||||
// Add full citation as a tooltip | |||||
$toolTip = ""; | |||||
$this->citationCreator->createCitation( $entry, $toolTip ); | |||||
// Link to refbase page for current entry | |||||
$link = $this->refbaseURL . "show.php?record=" . $entry['serial']; | |||||
// Build full string | |||||
$cite .= "[" . $link . " "; | |||||
$cite .= Html::openElement( 'span', array( 'title' => "\"" . $toolTip . "\"" ) ); | |||||
$cite .= $wikiText . Html::closeElement( 'span' ) . "]"; | |||||
return true; | |||||
} | |||||
} |
@ -0,0 +1,46 @@ | |||||
<?php | |||||
/** | |||||
* Refbase entry renderer | |||||
*/ | |||||
abstract class RefbaseRenderer { | |||||
/// Location of refbase installation (may differ from $dbHost if using https | |||||
/// for instance) | |||||
protected $refbaseURL = ""; | |||||
/** | |||||
* Constructor | |||||
*/ | |||||
public function __construct() { | |||||
global $wgRefbaseURL; | |||||
$this->refbaseURL = $wgRefbaseURL; | |||||
} | |||||
/** | |||||
* Instantiation subclass instances | |||||
*/ | |||||
public static function create( $outputType, $citationType = "" ) { | |||||
if ( strtolower( $outputType ) == 'cite_journal' ) { | |||||
return new RefbaseRendererCitationTemplate(); | |||||
} elseif ( strtolower( $outputType ) == 'link' ) { | |||||
return new RefbaseRendererLink( $citationType ); | |||||
} elseif ( strtolower( $outputType ) == 'cite' ) { | |||||
return new RefbaseRendererCite( $citationType ); | |||||
} else { | |||||
return false; | |||||
} | |||||
} | |||||
/** | |||||
* Returns the list of fields to extract from the database | |||||
*/ | |||||
abstract public function getFieldList(); | |||||
/** | |||||
* Render entries | |||||
*/ | |||||
abstract public function render( $entry, & $cite, $options ); | |||||
} | |||||
@ -0,0 +1,130 @@ | |||||
<?php | |||||
/** | |||||
* Refbase helper functions (cleanup strings, author extraction) | |||||
*/ | |||||
class RefbaseTools { | |||||
/// Character translation table | |||||
private static $transtab_refbase_html = array( | |||||
"/__(?!_)(.+?)__/" => "<u>\\1</u>", // the pattern for underline (__...__) must come before the one for italic (_..._) | |||||
"/_(.+?)_/" => "<i>\\1</i>", | |||||
"/\\*\\*(.+?)\\*\\*/" => "<b>\\1</b>", | |||||
"/\\[super:(.+?)\\]/i" => "<sup>\\1</sup>", | |||||
"/\\[sub:(.+?)\\]/i" => "<sub>\\1</sub>", | |||||
"/\\[permil\\]/" => "‰", | |||||
"/\\[infinity\\]/" => "∞", | |||||
"/\\[alpha\\]/" => "α", | |||||
"/\\[beta\\]/" => "β", | |||||
"/\\[gamma\\]/" => "γ", | |||||
"/\\[delta\\]/" => "δ", | |||||
"/\\[epsilon\\]/" => "ε", | |||||
"/\\[zeta\\]/" => "ζ", | |||||
"/\\[eta\\]/" => "η", | |||||
"/\\[theta\\]/" => "θ", | |||||
"/\\[iota\\]/" => "ι", | |||||
"/\\[kappa\\]/" => "κ", | |||||
"/\\[lambda\\]/" => "λ", | |||||
"/\\[mu\\]/" => "μ", | |||||
"/\\[nu\\]/" => "ν", | |||||
"/\\[xi\\]/" => "ξ", | |||||
"/\\[omicron\\]/" => "ο", | |||||
"/\\[pi\\]/" => "π", | |||||
"/\\[rho\\]/" => "ρ", | |||||
"/\\[sigmaf\\]/" => "ς", | |||||
"/\\[sigma\\]/" => "σ", | |||||
"/\\[tau\\]/" => "τ", | |||||
"/\\[upsilon\\]/" => "υ", | |||||
"/\\[phi\\]/" => "φ", | |||||
"/\\[chi\\]/" => "χ", | |||||
"/\\[psi\\]/" => "ψ", | |||||
"/\\[omega\\]/" => "ω", | |||||
"/\\[Alpha\\]/" => "Α", | |||||
"/\\[Beta\\]/" => "Β", | |||||
"/\\[Gamma\\]/" => "Γ", | |||||
"/\\[Delta\\]/" => "Δ", | |||||
"/\\[Epsilon\\]/" => "Ε", | |||||
"/\\[Zeta\\]/" => "Ζ", | |||||
"/\\[Eta\\]/" => "Η", | |||||
"/\\[Theta\\]/" => "Θ", | |||||
"/\\[Iota\\]/" => "Ι", | |||||
"/\\[Kappa\\]/" => "Κ", | |||||
"/\\[Lambda\\]/" => "Λ", | |||||
"/\\[Mu\\]/" => "Μ", | |||||
"/\\[Nu\\]/" => "Ν", | |||||
"/\\[Xi\\]/" => "Ξ", | |||||
"/\\[Omicron\\]/" => "Ο", | |||||
"/\\[Pi\\]/" => "Π", | |||||
"/\\[Rho\\]/" => "Ρ", | |||||
"/\\[Sigma\\]/" => "Σ", | |||||
"/\\[Tau\\]/" => "Τ", | |||||
"/\\[Upsilon\\]/" => "Υ", | |||||
"/\\[Phi\\]/" => "Φ", | |||||
"/\\[Chi\\]/" => "Χ", | |||||
"/\\[Psi\\]/" => "Ψ", | |||||
"/\\[Omega\\]/" => "Ω", | |||||
"/(?:\"|")(.+?)(?:\"|")/" => "“\\1”", | |||||
"/ +- +/" => " – " | |||||
); | |||||
// EXTRACT AUTHOR'S LAST NAME | |||||
// this function takes the contents of the author field and will extract the last name of a particular author (specified by position) | |||||
// (e.g., setting '$authorPosition' to "1" will return the 1st author's last name) | |||||
// Note: this function assumes that: | |||||
// 1. within one author object, there's only *one* delimiter separating author name & initials! | |||||
// 2. author objects are stored in the db as "<author_name><author_initials_delimiter><author_initials>", i.e., initials follow *after* the author's name! | |||||
// Required Parameters: | |||||
// 1. pattern describing delimiter that separates different authors | |||||
// 2. pattern describing delimiter that separates author name & initials (within one author) | |||||
// 3. position of the author whose last name shall be extracted (e.g., "1" will return the 1st author's last name) | |||||
// 4. contents of the author field | |||||
public static function extractAuthorsLastName( $oldBetweenAuthorsDelim, $oldAuthorsInitialsDelim, $authorPosition, $authorContents ) { | |||||
$authorsArray = preg_split( "/" . $oldBetweenAuthorsDelim . "/", $authorContents ); // get a list of all authors for this record | |||||
$authorPosition = $authorPosition - 1; // php array elements start with "0", so we decrease the authors position by 1 | |||||
$singleAuthor = $authorsArray[$authorPosition]; // for the author in question, extract the full author name (last name & initials) | |||||
$singleAuthorArray = preg_split( "/" . $oldAuthorsInitialsDelim . "/", $singleAuthor ); // then, extract author name & initials to separate list items | |||||
$singleAuthorsLastName = $singleAuthorArray[0]; // extract this author's last name into a new variable | |||||
return $singleAuthorsLastName; | |||||
} | |||||
// EXTRACT AUTHOR'S GIVEN NAME | |||||
// this function takes the contents of the author field and will extract the given name of a particular author (specified by position) | |||||
// (e.g., setting '$authorPosition' to "1" will return the 1st author's given name) | |||||
// Required Parameters: | |||||
// 1. pattern describing delimiter that separates different authors | |||||
// 2. pattern describing delimiter that separates author name & initials (within one author) | |||||
// 3. position of the author whose last name shall be extracted (e.g., "1" will return the 1st author's last name) | |||||
// 4. contents of the author field | |||||
public static function extractAuthorsGivenName( $oldBetweenAuthorsDelim, $oldAuthorsInitialsDelim, $authorPosition, $authorContents ) { | |||||
$authorsArray = preg_split( "/" . $oldBetweenAuthorsDelim . "/", $authorContents ); // get a list of all authors for this record | |||||
$authorPosition = $authorPosition - 1; // php array elements start with "0", so we decrease the authors position by 1 | |||||
$singleAuthor = $authorsArray[$authorPosition]; // for the author in question, extract the full author name (last name & initials) | |||||
$singleAuthorArray = preg_split( "/" . $oldAuthorsInitialsDelim . "/", $singleAuthor ); // then, extract author name & initials to separate list items | |||||
if ( !empty($singleAuthorArray[1]) ) { | |||||
$singleAuthorsGivenName = $singleAuthorArray[1]; // extract this author's last name into a new variable | |||||
} else { | |||||
$singleAuthorsGivenName = ''; | |||||
} | |||||
return $singleAuthorsGivenName; | |||||
} | |||||
// Perform search & replace actions on the given text input: | |||||
// ('$includesSearchPatternDelimiters' must be a boolean value that specifies whether the leading and trailing slashes | |||||
// are included within the search pattern ['true'] or not ['false']) | |||||
public static function searchReplaceText( $sourceString, $includesSearchPatternDelimiters ) { | |||||
// apply the search & replace actions defined in '$transtab_refbase_html' to the text passed in '$sourceString': | |||||
foreach ( self::$transtab_refbase_html as $searchString => $replaceString ) { | |||||
if ( !$includesSearchPatternDelimiters ) { | |||||
$searchString = "/" . $searchString . "/"; // add search pattern delimiters | |||||
} | |||||
if ( preg_match($searchString, $sourceString ) ) { | |||||
$sourceString = preg_replace( $searchString, $replaceString, $sourceString ); | |||||
} | |||||
} | |||||
return $sourceString; | |||||
} | |||||
} | |||||
@ -0,0 +1,4 @@ | |||||
The current method to change the appearance of refbase is to edit the style | |||||
files in the 'css' subdirectory and/or to replace the 'header.inc.php' and | |||||
'footer.inc.php' in the 'includes' subdirectory. This directory contains | |||||
examples of customized versions of these files. |
@ -0,0 +1,20 @@ | |||||
mediawiki-monobook skin for refbase | |||||
=================================== | |||||
Author | |||||
------ | |||||
Richard Karnesky <karnesky@gmail.com> | |||||
About | |||||
----- | |||||
These files mimic the Monobook skin from MediaWiki: | |||||
<http://www.mediawiki.org/> | |||||
This is the default skin for the Wikipedia: | |||||
<http://wikipedia.org/> | |||||
You may also be interested in the refbase extension for MediaWiki, included in the | |||||
'contrib/mediawiki' directory from refbase. | |||||
An installation of refbase that uses this skin is the Northwestern University | |||||
Center for Atom-Probe Tomography: | |||||
<http://arc.nucapt.northwestern.edu/refbase/> |
@ -0,0 +1,235 @@ | |||||
<?php | |||||
// Copyright: Richard Karnesky <karnesky@gmail.com> | |||||
// This code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. | |||||
// Please see the GNU General Public License for more details. | |||||
// File: ./includes/footer.inc.php | |||||
// -------------------------------------------------------------------- | |||||
// Inserts the closing HTML </body> and </html> tags: | |||||
function displayHTMLfoot() | |||||
{ | |||||
?> | |||||
</body> | |||||
</html> | |||||
<?php | |||||
} | |||||
// -------------------------------------------------------------------- | |||||
// Displays the visible footer: | |||||
function showPageFooter($HeaderString) | |||||
{ | |||||
global $officialDatabaseName; // usage example: <a href="index.php">[? echo encodeHTML($officialDatabaseName); ?]</a> | |||||
global $hostInstitutionAbbrevName; // usage example: <a href="[? echo $hostInstitutionURL; ?]">[? echo encodeHTML($hostInstitutionAbbrevName); ?] Home</a> | |||||
global $hostInstitutionName; // (note: in the examples above, square brackets must be replaced by their respective angle brackets) | |||||
global $hostInstitutionURL; | |||||
global $helpResourcesURL; | |||||
global $loginWelcomeMsg; // these variables are globally defined in function 'showLogin()' in 'include.inc.php' | |||||
global $loginStatus; | |||||
global $loginLinks; | |||||
global $loc; // '$loc' is made globally available in 'core.php' | |||||
?> | |||||
</div></div></div> | |||||
<div id="column-one"> | |||||
<div id="p-cactions" class="portlet"> | |||||
<h5>Views</h5> | |||||
<ul> | |||||
<li id="ca-talk" | |||||
class="selected" ><a href="index.php">References</a></li><li id="search"><a href="simple_search.php" title="search the main fields of the database">Simple Search</a></li> | |||||
<li><a href="advanced_search.php" title="search all fields of the database">Advanced Search</a></li> | |||||
<?php | |||||
// ------------------------------------------------------- | |||||
if (isset($_SESSION['user_permissions']) AND preg_match("/allow_add/", $_SESSION['user_permissions'])) // if the 'user_permissions' session variable contains 'allow_add'... | |||||
{ | |||||
// ... include a link to 'record.php?recordAction=add...': | |||||
?> | |||||
<LI id="ca-watch"><a href="record.php?recordAction=add" title="add a record to the database">Add Record</a> | |||||
<?php | |||||
} | |||||
else {?> | |||||
<LI id="ca-watch"><a href="/refbase-svn/record.php?recordAction=add" title="add a suggested record to the database">Add Record (suggest)</a> | |||||
<?php } | |||||
// ------------------------------------------------------- | |||||
if (isset($_SESSION['user_permissions']) AND preg_match("/allow_import|allow_batch_import/", $_SESSION['user_permissions'])) // if the 'user_permissions' session variable contains either 'allow_import' or 'allow_batch_import'... | |||||
{ | |||||
// ... include a link to 'import.php': | |||||
?> | |||||
<LI><a href="import.php" title="import records">Import</a> | |||||
<?php | |||||
} else { | |||||
?> | |||||
<LI><a href="/refbase-svn/import.php" title="import suggested records">Import (suggest)</a> | |||||
<?php | |||||
}?> | |||||
</ul> | |||||
</div> | |||||
<div class="portlet" id="p-personal"> | |||||
<h5>Personal tools</h5> | |||||
<div class="pBody"> | |||||
<ul> | |||||
<li id="pt-userpage"><? echo preg_replace('/You\'re logged in as<br>/','',$loginStatus); ?></li><li id="pt-mytalk"> | |||||
<? echo $loginLinks; ?></li> | |||||
</ul> | |||||
</div> | |||||
</div> | |||||
<div class="portlet" id="p-logo"> | |||||
<a style="background-image: | |||||
url(../skins/common/images/wiki.png);" | |||||
href="../index.php/Seidman_Group" | |||||
title="Seidman Group"></a> | |||||
</div> | |||||
<div class='portlet' id='p-Seidman_Group'> | |||||
<h5>Seidman Group</h5> | |||||
<div class='pBody'> | |||||
<ul> | |||||
<li id="n-Seidman-Group"><a href="/Seidman_Group">Seidman Group</a></li> | |||||
<li id="n-Research"><a href="/Category:Research">Research</a></li> | |||||
<li id="n-People"><a href="/Category:People">People</a></li> | |||||
</ul> | |||||
</div> | |||||
</div> | |||||
<div class='portlet' id='p-NUCAPT'> | |||||
<h5>NUCAPT</h5> | |||||
<div class='pBody'> | |||||
<ul> | |||||
<li id="n-Instruments"><a href="/Category:Tools">Instruments</a></li> | |||||
<li id="n-Calendar"><a href="http://arc.nucapt.northwestern.edu/phpicalendar">Calendar</a></li> | |||||
<li id="n-Visit"><a href="/Visit">Visit</a></li> | |||||
</ul> | |||||
</div> | |||||
</div> | |||||
<div class='portlet' id='p-Atom-Probe_Tomography'> | |||||
<h5>Atom-Probe Tomography</h5> | |||||
<div class='pBody'> | |||||
<ul> | |||||
<li id="n-References"><a href="http://arc.nucapt.northwestern.edu/refbase">References</a></li> | |||||
<li id="n-AtomProbe-mailing-list"><a href="http://arc.nucapt.northwestern.edu/mailman/listinfo/atomprobe">AtomProbe mailing list</a></li> | |||||
</ul> | |||||
</div> | |||||
</div> | |||||
<div class="portlet" id="p-tb"> | |||||
<h5>Search</h5> | |||||
<div class="pBody"> | |||||
<?php echo buildQuickSearchElements($query, $queryURL, $showQuery, $showLinks, $showRows, $citeStyle, $citeOrder, $displayType); ?> | |||||
<ul> | |||||
<li><a href="simple_search.php" title="search the main fields of the database">Simple Search</a> | |||||
<li><a href="advanced_search.php" title="search all fields of the database">Advanced Search</a> | |||||
<?php | |||||
// ------------------------------------------------------- | |||||
if (isset($_SESSION['user_permissions']) AND preg_match("/allow_sql_search/", $_SESSION['user_permissions'])) // if the 'user_permissions' session variable contains 'allow_sql_search'... | |||||
{ | |||||
// ... include a link to 'sql_search.php': | |||||
?> | |||||
<li><a href="sql_search.php" title="search the database by use of a SQL query">SQL Search</a> | |||||
<?php | |||||
} | |||||
// ------------------------------------------------------- | |||||
?> | |||||
<li><a href="library_search.php" title="search the library of the <? echo encodeHTML($hostInstitutionAbbrevName); ?>">Library Search</a> | |||||
</ul> | |||||
</div></div> | |||||
<div class="portlet" id="p-tc"> | |||||
<h5>Toolbox</h5> | |||||
<div class="pBody"> | |||||
<ul> | |||||
<?php | |||||
// ------------------------------------------------------- | |||||
if (isset($_SESSION['user_permissions']) AND preg_match("/allow_add/", $_SESSION['user_permissions'])) // if the 'user_permissions' session variable contains 'allow_add'... | |||||
{ | |||||
// ... include a link to 'record.php?recordAction=add...': | |||||
?> | |||||
<LI><a href="record.php?recordAction=add" title="add a record to the database">Add Record</a> | |||||
<?php | |||||
} | |||||
// ------------------------------------------------------- | |||||
if (isset($_SESSION['user_permissions']) AND preg_match("/allow_import|allow_batch_import/", $_SESSION['user_permissions'])) // if the 'user_permissions' session variable contains either 'allow_import' or 'allow_batch_import'... | |||||
{ | |||||
// ... include a link to 'import.php': | |||||
?> | |||||
<LI><a href="import.php" title="import records">Import</a> | |||||
<?php | |||||
} | |||||
// ------------------------------------------------------- | |||||
if (isset($_SESSION['user_permissions']) AND preg_match("/allow_details_view/", $_SESSION['user_permissions'])) // if the 'user_permissions' session variable contains 'allow_details_view'... | |||||
{ | |||||
// ... include a link to 'show.php': | |||||
?> | |||||
<LI><a href="show.php" title="display details for a particular record by entering its database serial number">Show Record</a> | |||||
<?php | |||||
} | |||||
if (isset($_SESSION['user_permissions']) AND preg_match("/allow_cite/", $_SESSION['user_permissions'])) // if the 'user_permissions' session variable contains 'allow_cite'... | |||||
{ | |||||
// ... include a link to 'extract.php': | |||||
?> | |||||
<LI><a href="extract.php" title="extract citations from a text and build an appropriate reference list">Extract Citations</a><?php | |||||
} | |||||
// ------------------------------------------------------- | |||||
?> | |||||
</ul> | |||||
</div></div></div> | |||||
<div class="visualClear"></div> | |||||
<div id="footer"> | |||||
<div id="f-poweredbyico"><a href="http://www.refbase.net/"><img src="img/refbase_credit.gif" alt="refbase"></a></div><ul id="f-list"> | |||||
<li><? echo date('j M Y'); ?></li> | |||||
<li id="f-about"><a | |||||
href="/index.php/Seidman_Group" title="Seidman Group">NUCAPT: Northwestern University Center for Atom-Probe Tomography</a></li> </ul> | |||||
</div> | |||||
</div> | |||||
<?php | |||||
} | |||||
?> |
@ -0,0 +1,164 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./contrib/skins/mediawiki-monobook/header.inc.php | |||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/contrib/skins/mediawiki-monobook/header.inc.php $ | |||||
// Author(s): Richard Karnesky <mailto:karnesky@gmail.com> | |||||
// | |||||
// Created: 31-Oct-06, 00:28 | |||||
// Modified: $Date: 2012-02-27 20:25:30 +0000 (Mon, 27 Feb 2012) $ | |||||
// $Author: msteffens $ | |||||
// $Revision: 1337 $ | |||||
// This is the header include file. | |||||
// It contains functions that provide the HTML header | |||||
// as well as the visible header that gets displayed on every page. | |||||
// -------------------------------------------------------------------- | |||||
// Inserts the HTML <head>...</head> block as well as the initial <body> tag: | |||||
// | |||||
// TODO: include OpenSearch elements in HTML header | |||||
// (see examples at <http://www.opensearch.org/Specifications/OpenSearch/1.1#Response_metadata_in_HTML.2FXHTML>) | |||||
function displayHTMLhead($pageTitle, $metaRobots, $metaDescription, $additionalMeta, $includeJavaScript, $includeJavaScriptFile, $viewType, $rssURLArray) | |||||
{ | |||||
global $officialDatabaseName; // these variables are defined in 'ini.inc.php' | |||||
global $contentTypeCharset; | |||||
global $defaultStyleSheet; | |||||
global $printStyleSheet; | |||||
global $mobileStyleSheet; | |||||
global $useVisualEffects; | |||||
global $databaseBaseURL; | |||||
global $databaseKeywords; | |||||
global $defaultFeedFormat; | |||||
?> | |||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | |||||
"http://www.w3.org/TR/html4/loose.dtd"> | |||||
<html> | |||||
<head profile="http://a9.com/-/spec/opensearch/1.1/"> | |||||
<title><?php echo $pageTitle; ?></title> | |||||
<meta name="date" content="<?php echo date('d-M-y'); ?>"> | |||||
<meta name="robots" content="<?php echo $metaRobots; ?>"> | |||||
<meta name="description" lang="en" content="<?php echo $metaDescription; ?>"> | |||||
<meta name="keywords" lang="en" content="<?php echo $databaseKeywords; ?>"><?php | |||||
if (!empty($additionalMeta)) | |||||
echo $additionalMeta; | |||||
?> | |||||
<meta http-equiv="content-language" content="<?php echo getUserLanguage(); ?>"> | |||||
<meta http-equiv="content-type" content="text/html; charset=<?php echo $contentTypeCharset; ?>"> | |||||
<meta http-equiv="Content-Style-Type" content="text/css"><?php | |||||
if (preg_match("/^Print$/i", $viewType)) | |||||
{ | |||||
?> | |||||
<link rel="stylesheet" href="<?php echo $printStyleSheet; ?>" type="text/css" title="CSS Definition"><?php | |||||
} | |||||
elseif (preg_match("/^Mobile$/i", $viewType)) | |||||
{ | |||||
?> | |||||
<link rel="stylesheet" href="<?php echo $mobileStyleSheet; ?>" type="text/css" title="CSS Definition"><?php | |||||
} | |||||
else | |||||
{ | |||||
?> | |||||
<link rel="stylesheet" href="<?php echo $defaultStyleSheet; ?>" type="text/css" title="CSS Definition"><?php | |||||
} | |||||
if (!empty($rssURLArray) AND isset($_SESSION['user_permissions']) AND preg_match("/allow_rss_feeds/", $_SESSION['user_permissions'])) // if some RSS URLs were specified AND the 'user_permissions' session variable contains 'allow_rss_feeds'... | |||||
{ | |||||
foreach ($rssURLArray as $rssURL) | |||||
{ | |||||
if ($defaultFeedFormat == "Atom XML") | |||||
$feedContentType = "application/atom+xml"; | |||||
else // RSS XML | |||||
$feedContentType = "application/rss+xml"; | |||||
// ...include a link tag pointing to a dynamic RSS feed for the current query: | |||||
?> | |||||
<link rel="alternate" type="<?php echo $feedContentType; ?>" href="<?php echo $databaseBaseURL . $rssURL['href']; ?>" title="<?php echo $rssURL['title']; ?>"><?php | |||||
} | |||||
} | |||||
?> | |||||
<link rel="unapi-server" type="application/xml" title="unAPI" href="<?php echo $databaseBaseURL; ?>unapi.php"> | |||||
<link rel="search" type="application/opensearchdescription+xml" title="<?php echo encodeHTML($officialDatabaseName); ?>" href="<?php echo $databaseBaseURL; ?>opensearch.php?operation=explain"><?php | |||||
if ($includeJavaScript OR (isset($_SESSION['userAutoCompletions']) AND ($_SESSION['userAutoCompletions'] == "yes")) OR ($useVisualEffects == "yes")) | |||||
{ | |||||
// ...include common refbase JavaScript functions: | |||||
?> | |||||
<script language="JavaScript" type="text/javascript" src="javascript/common.js"></script><?php | |||||
} | |||||
if ((isset($_SESSION['userAutoCompletions']) AND ($_SESSION['userAutoCompletions'] == "yes")) OR ($useVisualEffects == "yes")) | |||||
{ | |||||
// ...include the Prototype & script.aculo.us JavaScript frameworks: | |||||
?> | |||||
<script language="JavaScript" type="text/javascript" src="javascript/prototype.js"></script> | |||||
<script language="JavaScript" type="text/javascript" src="javascript/scriptaculous.js?load=effects,controls"></script><?php | |||||
} | |||||
if (!empty($includeJavaScriptFile)) | |||||
{ | |||||
// ...include additional JavaScript functions: | |||||
?> | |||||
<script language="JavaScript" type="text/javascript" src="<?php echo $includeJavaScriptFile; ?>"></script><?php | |||||
} | |||||
?> | |||||
</head> | |||||
<body><?php | |||||
} | |||||
// -------------------------------------------------------------------- | |||||
// Displays the visible header: | |||||
function showPageHeader($HeaderString) | |||||
{ | |||||
global $officialDatabaseName; // these variables are defined in 'ini.inc.php' | |||||
global $hostInstitutionAbbrevName; | |||||
global $hostInstitutionName; | |||||
global $hostInstitutionURL; | |||||
global $helpResourcesURL; | |||||
global $loginWelcomeMsg; // these variables are globally defined in function 'showLogin()' in 'include.inc.php' | |||||
global $loginStatus; | |||||
global $loginLinks; | |||||
global $loc; // '$loc' is made globally available in 'core.php' | |||||
?> | |||||
<div id="globalWrapper"> | |||||
<div id="column-content"> | |||||
<div id="content"> | |||||
<a name="top" id="contentTop"></a> | |||||
<h1 class="firstHeading"><? echo encodeHTML($officialDatabaseName); ?></h1> | |||||
<div id="bodyContent"> | |||||
<h3 id="siteSub">From NUCAPT</h3> | |||||
<div id="contentSub"></div> | |||||
<!-- start content --> | |||||
<h2><? echo $HeaderString; ?></h2> | |||||
<?php | |||||
} | |||||
// -------------------------------------------------------------------- | |||||
?> |
@ -0,0 +1,858 @@ | |||||
/* | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./css/style.css | |||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/css/style.css $ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 20-Oct-02, 15:08 | |||||
// Modified: $Date: 2013-04-16 20:34:32 +0000 (Tue, 16 Apr 2013) $ | |||||
// $Author: msteffens $ | |||||
// $Revision: 1373 $ | |||||
*/ | |||||
/* refbase CSS definitions - default style */ | |||||
body { | |||||
background: #FFFFFF; | |||||
color: #000000; | |||||
} | |||||
pre, code { | |||||
font-family: monaco,courier,monospace; | |||||
font-size: 7pt; | |||||
} | |||||
.smaller { | |||||
font-size: 0.7em; | |||||
} | |||||
.small { | |||||
font-size: 0.7em; | |||||
} | |||||
.smallup { | |||||
font-size: 0.85em; | |||||
position: relative; | |||||
top: -10px; | |||||
} | |||||
.moveup { | |||||
position: relative; | |||||
top: -8px; | |||||
} | |||||
.unapi { | |||||
font-size: smaller; | |||||
} | |||||
.Z3988 { | |||||
font-size: smaller; | |||||
} | |||||
.ok { | |||||
color: #009900; | |||||
} | |||||
.warning { | |||||
color: red; | |||||
} | |||||
.warning2 { | |||||
color: red; | |||||
font-family: "lucida grande",helvetica,arial,sans-serif; | |||||
font-size: 0.75em; | |||||
} | |||||
.mainfieldsbg { | |||||
background-color: #E6E6E6; | |||||
} | |||||
.otherfieldsbg { | |||||
background-color: #FFFFFF; | |||||
} | |||||
.userfieldsbg { | |||||
background-color: #FFFFCC; | |||||
} | |||||
th { | |||||
font-family: "lucida grande",helvetica,arial,sans-serif; | |||||
font-size: 0.9em; | |||||
} | |||||
td, div { | |||||
font-family: "lucida grande",helvetica,arial,sans-serif; | |||||
font-size: 0.8em; | |||||
} | |||||
p { | |||||
font-family: "lucida grande",helvetica,arial,sans-serif; | |||||
font-size: 0.8em; | |||||
} | |||||
a:link { | |||||
color: #0033CC; | |||||
text-decoration: none; | |||||
} | |||||
a:visited { | |||||
color: #666666; | |||||
text-decoration: none; | |||||
} | |||||
a:active { | |||||
color: #990000; | |||||
text-decoration: none; | |||||
} | |||||
a:hover { | |||||
color: #3366FF; | |||||
text-decoration: none; | |||||
} | |||||
h1, h2, h3, h4 { | |||||
font-family: "lucida grande",helvetica,arial,sans-serif; | |||||
color: #990000; | |||||
} | |||||
h5, h6 { | |||||
font-family: "lucida grande",helvetica,arial,sans-serif; | |||||
} | |||||
h2, h3 { | |||||
margin-top: 1em; | |||||
margin-bottom: 0.5em; | |||||
} | |||||
h2 { | |||||
font-size: 1.8em; | |||||
} | |||||
h3 { | |||||
font-size: 1.35em; | |||||
} | |||||
h4, h5 { | |||||
margin-top: 0em; | |||||
margin-bottom: 0em; | |||||
} | |||||
h4 { | |||||
font-size: 1.25em; | |||||
} | |||||
h5 { | |||||
font-size: 1.1em; | |||||
} | |||||
.pageheader { | |||||
} | |||||
.pagefooter { | |||||
} | |||||
.results { | |||||
} | |||||
hr.results { | |||||
width: 100%; | |||||
background-color: #DEDEDE; | |||||
height: 1px; | |||||
border: 0; | |||||
} | |||||
div.resultsheader { | |||||
margin: 1.2em 3.3em 0.9em 3.3em; | |||||
} | |||||
hr.resultsheader, hr.resultsfooter { | |||||
width: 93%; | |||||
background-color: #DEDEDE; | |||||
height: 1px; | |||||
border: 0; | |||||
} | |||||
div.resultsfooter { | |||||
margin: 1.2em 3.3em 0.9em 3.3em; | |||||
} | |||||
.showhide { | |||||
} | |||||
#loginInfo { | |||||
font-size: 1em; | |||||
} | |||||
#loginInfo > * { | |||||
margin-top: 0.4em; | |||||
font-size: 1em; | |||||
} | |||||
.suggestProgress { | |||||
position: absolute; | |||||
margin-top: 3px; | |||||
margin-left: -25px; | |||||
} | |||||
.searchSuggestions { | |||||
background-color: #FFFFFF; | |||||
border: 1px solid #999999; | |||||
margin-left: -1px; | |||||
z-index: 1; | |||||
text-align: left; | |||||
font-size: 1em; | |||||
} | |||||
.searchSuggestions ul { | |||||
margin: 0 0 0 -40px; | |||||
list-style-type: none; | |||||
font-size: 1em; | |||||
line-height: 1.3em; | |||||
} | |||||
.searchSuggestions li { | |||||
border-top: 1px solid #999999; | |||||
padding: 0.15em 0 0.15em 0.5em; | |||||
} | |||||
.searchSuggestions .selected { | |||||
background-color: #DDDDDD; | |||||
} | |||||
form[name="record"] .searchSuggestions, form[name="record"] .suggestProgress { | |||||
font-size: 0.85em; | |||||
} | |||||
form[name="show"] .searchSuggestions, form[name="show"] .suggestProgress { | |||||
font-size: 0.85em; | |||||
} | |||||
form[name="simpleSearch"] .searchSuggestions, form[name="simpleSearch"] .suggestProgress { | |||||
font-size: 0.85em; | |||||
} | |||||
#refineresults .searchSuggestions, #refineresults .suggestProgress { | |||||
font-size: 0.85em; | |||||
} | |||||
#queryrefs { | |||||
margin-top: 1.3em; | |||||
margin-bottom: -1em; | |||||
margin-right: -11px; | |||||
font-size: 1em; | |||||
} | |||||
#queryrefs fieldset { | |||||
border: none; | |||||
} | |||||
#queryrefs legend, #queryrefs #queryField label { | |||||
display: none; | |||||
} | |||||
#queryrefs #queryField, #queryrefs #querySubmit { | |||||
display: inline; | |||||
font-size: 1em; | |||||
} | |||||
#userlogin, #userlogin .boxBody { | |||||
margin-bottom: -1.1em; | |||||
font-size: 1em; | |||||
} | |||||
#userlogin fieldset { | |||||
border: none; | |||||
} | |||||
#userlogin legend { | |||||
display: none; | |||||
} | |||||
#userlogin #loginUser, #userlogin #loginPwd { | |||||
font-size: 1em; | |||||
} | |||||
/* NOTE: Support for the 'inline-block' display type was added in Firefox 3. | |||||
A JavaScript work-around that works for Firefox 2 users is given at: | |||||
<http://www.alistapart.com/articles/prettyaccessibleforms> | |||||
*/ | |||||
#userlogin #loginUserLabel, #userlogin #loginPwdLabel { | |||||
display: inline-block; | |||||
width: 38%; | |||||
font-size: 1em; | |||||
} | |||||
#userlogin #loginUserLabel:lang(fr), #userlogin #loginPwdLabel:lang(fr) { | |||||
width: 52%; | |||||
} | |||||
#userlogin #loginUserLabel:lang(cn), #userlogin #loginPwdLabel:lang(cn) { | |||||
width: 27%; | |||||
} | |||||
#userlogin #loginUserInput, #userlogin #loginPwdInput { | |||||
display: inline; | |||||
} | |||||
#userlogin #loginEmail, #userlogin #loginPassword { | |||||
width: 55%; | |||||
} | |||||
#userlogin #loginEmail:lang(fr), #userlogin #loginPassword:lang(fr) { | |||||
width: 41%; | |||||
} | |||||
#userlogin #loginEmail:lang(cn), #userlogin #loginPassword:lang(cn) { | |||||
width: 66%; | |||||
} | |||||
#userlogin #loginSubmit input[type=submit] { | |||||
margin-top: 0.6em; | |||||
} | |||||
#userlogin #register { | |||||
margin-top: 1em; | |||||
text-align: right; | |||||
font-size: 0.7em; | |||||
font-weight: bold; | |||||
line-height: 1.5em; | |||||
} | |||||
#recentlinks { | |||||
margin-left: -15px; | |||||
font-size: 1em; | |||||
} | |||||
#includerefs { | |||||
margin-left: -22px; | |||||
font-size: 1.25em; | |||||
} | |||||
#includeprogress, #includerefs > a { | |||||
margin-left: 30px; | |||||
font-size: 0.8em; | |||||
} | |||||
#includeprogress > img { | |||||
position: relative; | |||||
top: 3px; | |||||
left: 5px; | |||||
} | |||||
#showgroupmain { | |||||
margin-bottom: 1.25em; | |||||
font-size: 1em; | |||||
} | |||||
#showgroupmain fieldset { | |||||
border: none; | |||||
} | |||||
#showgroupmain legend, #showgroupmain #groupSelect label { | |||||
display: none; | |||||
} | |||||
#showgroupmain #groupSubmit input[type=submit] { | |||||
margin-top: 0.6em; | |||||
} | |||||
#recallquerymain { | |||||
margin-top: -0.9em; | |||||
font-size: 1em; | |||||
} | |||||
#recallquerymain fieldset { | |||||
border: none; | |||||
} | |||||
#recallquerymain legend, #recallquerymain #recallSelect label { | |||||
display: none; | |||||
} | |||||
#recallquerymain #recallSubmit input[type=submit] { | |||||
margin-top: 0.6em; | |||||
} | |||||
#resultoptions { | |||||
margin-left: 20px; | |||||
text-align: center; | |||||
font-size: 1em; | |||||
} | |||||
#resultoptions legend { | |||||
color: #000000; | |||||
font-style: italic; | |||||
text-align: left; | |||||
} | |||||
#resultoptions label { | |||||
margin-left: 0.15em; | |||||
} | |||||
#resultoptions form { | |||||
display: inline; | |||||
} | |||||
#resultoptions fieldset { | |||||
display: inline; | |||||
border: none; | |||||
text-align: left; | |||||
} | |||||
#showgroup { | |||||
display: inline; | |||||
margin-right: 1.1em; | |||||
font-size: 1em; | |||||
} | |||||
#showgroup #groupSelect { | |||||
font-size: 1em; | |||||
} | |||||
#showgroup #groupSubmit { | |||||
margin-top: 0.25em; | |||||
font-size: 1em; | |||||
} | |||||
#showgroup #groupSelect label, #refineresults #refineField label, #displayopt #optShowHideField label { | |||||
display: none; | |||||
} | |||||
#refineresults { | |||||
display: inline; | |||||
font-size: 1em; | |||||
} | |||||
#refineresults #refineField { | |||||
display: block; | |||||
margin-bottom: 0.25em; | |||||
font-size: 1em; | |||||
} | |||||
#refineresults form[action="search.php"] #refineField:lang(en) { | |||||
width: 16.7em; | |||||
} | |||||
#refineresults form[action="search.php"] #refineField:lang(de), #refineresults form[action="search.php"] #refineField:lang(fr) { | |||||
width: 20.2em; | |||||
} | |||||
#refineresults form[action="search.php"] #refineField:lang(cn) { | |||||
width: 14.1em; | |||||
} | |||||
#refineresults #refineOpt, #refineresults #refineSubmit { | |||||
display: inline; | |||||
font-size: 1em; | |||||
} | |||||
#displayopt { | |||||
display: inline; | |||||
margin-left: 1.1em; | |||||
font-size: 1em; | |||||
} | |||||
#displayopt #optMain { | |||||
font-size: 1em; | |||||
} | |||||
#displayopt #optShowHideField, #displayopt #optCiteStyle, #displayopt #optSubmit { | |||||
display: inline; | |||||
font-size: 1em; | |||||
} | |||||
#displayopt #optOther { | |||||
margin-top: 0.25em; | |||||
font-size: 1em; | |||||
} | |||||
#displayopt #optCiteOrder, #displayopt #optRecsPerPage { | |||||
display: inline; | |||||
font-size: 1em; | |||||
} | |||||
#displayopt #optCiteOrder { | |||||
margin-right: 0.4em; | |||||
} | |||||
.resultnav { | |||||
} | |||||
.mainnav { | |||||
} | |||||
.pagenav { | |||||
} | |||||
.viewnav { | |||||
font-size: 0.75em; | |||||
} | |||||
#columns { | |||||
position: relative; | |||||
left: 4px; | |||||
} | |||||
#columns .itemlinks a { | |||||
color: #000000; | |||||
border-bottom: 1px #CCCCCC solid; | |||||
} | |||||
#columns .itemlinks a:hover { | |||||
color: #3366FF; | |||||
border-bottom: 0px; | |||||
} | |||||
#details { | |||||
position: relative; | |||||
left: 4px; | |||||
} | |||||
#details .itemlinks a { | |||||
color: #000000; | |||||
border-bottom: 1px #CCCCCC solid; | |||||
} | |||||
#details .mainfieldsbg .itemlinks a { | |||||
border-bottom: 1px #CCCCCC solid; | |||||
} | |||||
#details .itemlinks a:hover { | |||||
color: #3366FF; | |||||
border-bottom: 0px; | |||||
} | |||||
#citations { | |||||
position: relative; | |||||
left: 4px; | |||||
} | |||||
.citation { | |||||
} | |||||
.citation .showhide { | |||||
margin-top: 0.4em; | |||||
} | |||||
.citation .moreinfo { | |||||
margin-left: 1.25em; | |||||
font-size: 1em; | |||||
} | |||||
.citation .moreinfo > * { | |||||
margin-bottom: 0.4em; | |||||
font-size: 0.85em; | |||||
color: #333333; | |||||
line-height: 1.3em; | |||||
/* | |||||
max-width: 700px; | |||||
*/ | |||||
} | |||||
.citation .moreinfo .reflinks { | |||||
margin-top: 0.8em; | |||||
/* | |||||
max-width: none; | |||||
*/ | |||||
} | |||||
.citation .moreinfo .reflinks > * { | |||||
display: inline; | |||||
font-size: 1em; | |||||
} | |||||
.citation .moreinfo .itemlinks a { | |||||
color: #333333; | |||||
border-bottom: 1px #CCCCCC solid; | |||||
} | |||||
.citation .moreinfo .itemlinks a:hover { | |||||
color: #3366FF; | |||||
border-bottom: 0px; | |||||
} | |||||
#error { | |||||
} | |||||
#queryhistory { | |||||
margin-left: 2.6em; | |||||
margin-right: 2.6em; | |||||
margin-bottom: 1.75em; | |||||
} | |||||
#currentquery, #previousqueries { | |||||
margin-top: 1.2em; | |||||
font-size: 1em; | |||||
} | |||||
#queryhistory .even, #queryhistory .odd { | |||||
margin-top: 0.25em; | |||||
margin-left: 1.2em; | |||||
margin-right: 1.2em; | |||||
font-size: 1em; | |||||
} | |||||
.helpbody { | |||||
font-size: 1em; | |||||
} | |||||
.examples { | |||||
font-size: 1em; | |||||
} | |||||
.links { | |||||
} | |||||
.sect { | |||||
font-size: 1em; | |||||
font-weight: bold; | |||||
} | |||||
.even { | |||||
background-color: #FFFFFF; | |||||
padding: 5px; | |||||
} | |||||
.odd { | |||||
background-color: #F4F4F4; | |||||
padding: 5px; | |||||
} | |||||
#queryform { | |||||
} | |||||
#resultactions { | |||||
margin-left: 20px; | |||||
text-align: center; | |||||
font-size: 1em; | |||||
} | |||||
#resultactions input, #resultactions select { | |||||
margin-left: 0.5em; | |||||
} | |||||
#resultactions legend { | |||||
color: #000000; | |||||
font-style: italic; | |||||
text-align: left; | |||||
} | |||||
#resultactions label { | |||||
margin-left: 0.15em; | |||||
} | |||||
#resultactions fieldset { | |||||
display: inline; | |||||
margin-left: 1.5em; | |||||
border: none; | |||||
vertical-align: top; | |||||
text-align: left; | |||||
} | |||||
#selectresults { | |||||
margin-bottom: 0.75em; | |||||
font-size: 1em; | |||||
text-align: left; | |||||
} | |||||
#selectresults input#selRecs { | |||||
margin-left: 1.5em; | |||||
} | |||||
#citerefs { | |||||
font-size: 1em; | |||||
} | |||||
#citerefs input[type=submit], #exportrefs input[type=submit] { | |||||
display: block; | |||||
margin-top: 0.6em; | |||||
margin-left: 0.25em; | |||||
} | |||||
#citerefs label, #exportrefs label { | |||||
display: none; | |||||
} | |||||
#citerefs select, #exportrefs select { | |||||
margin-left: 0.25em; | |||||
} | |||||
#grouprefs { | |||||
font-size: 1em; | |||||
} | |||||
#grouprefs #myGroup { | |||||
display: block; | |||||
margin-bottom: 0.25em; | |||||
font-size: 1em; | |||||
} | |||||
#grouprefs #newGroup, #grouprefs #addRemoveGroup { | |||||
display: inline; | |||||
font-size: 1em; | |||||
} | |||||
#exportrefs { | |||||
font-size: 1em; | |||||
} | |||||
#searchopt { | |||||
display: none; | |||||
} | |||||
#helptxt { | |||||
display: none; | |||||
} | |||||
#helptxt .sect { | |||||
padding-top: 2px; | |||||
} | |||||
#helptxt .even { | |||||
margin-left: -5px; | |||||
margin-top: -3px; | |||||
} | |||||
#helptxt .odd { | |||||
margin-left: -5px; | |||||
} | |||||
.toggleimg { | |||||
} | |||||
.toggletxt { | |||||
display: inline; | |||||
margin-left: 5px; | |||||
font-size: 1em; | |||||
} | |||||
a:link .toggletxt { | |||||
color: #0033CC; | |||||
} | |||||
a:visited .toggletxt { | |||||
color: #666666; | |||||
} | |||||
a:hover .toggletxt { | |||||
color: #3366FF; | |||||
} | |||||
.resultviews { | |||||
display: inline; | |||||
font-size: 0.85em; | |||||
} | |||||
.activeview { | |||||
display: inline; | |||||
font-size: 1em; | |||||
} | |||||
.leftview { | |||||
display: inline; | |||||
font-size: 1em; | |||||
} | |||||
.middleview { | |||||
display: inline; | |||||
font-size: 1em; | |||||
} | |||||
.rightview { | |||||
display: inline; | |||||
font-size: 1em; | |||||
} | |||||
.toggleprint { | |||||
position: relative; | |||||
top: 3px; | |||||
} | |||||
#accountinfo { | |||||
font-size: 1.25em; | |||||
} | |||||
#accountdetails { | |||||
font-size: 1em; | |||||
} | |||||
#accountopt { | |||||
font-size: 1em; | |||||
} | |||||
#accountperm { | |||||
font-size: 1em; | |||||
} | |||||
#accountdetails ul, #accountopt ul, #accountperm ul { | |||||
position: relative; | |||||
top: -0.8em; | |||||
list-style-type: none; | |||||
font-size: 0.85em; | |||||
line-height: 1.3em; | |||||
} | |||||
/* Begin ThrashBox code (modified slightly for use with refbase) | |||||
Credit: Simple Rounded Corner CSS Boxes by Ryan Thrash | |||||
see <http://www.modxcms.com/simple-rounded-corner-css-boxes.html> | |||||
and the ThrashBox online generator <http://www.spiffybox.com/> | |||||
*/ | |||||
/* set the image to use and establish the lower-right position */ | |||||
.box, .boxBody, .boxHead, .boxHead h3 { | |||||
background: transparent url(../img/rounded_box.png) no-repeat bottom right; | |||||
} | |||||
.box { | |||||
/* intended total box width - padding-right(next) */ | |||||
/* width: 200px !important; */ | |||||
/* IE Win = width - padding */ | |||||
/* width: 185px; */ | |||||
padding-right: 5px; /* the gap on the right edge of the image (not content padding) */ | |||||
margin: 0 auto; /* use to position the box */ | |||||
} | |||||
/* set the top-right image */ | |||||
.boxHead { | |||||
background-position: top right; margin-right: -5px; /* pull the right image over on top of border */ | |||||
padding-right: 15px; /* right-image-gap + right-inside padding */ | |||||
} | |||||
/* set the top-left image */ | |||||
.boxHead h3 { | |||||
background-position: top left; | |||||
margin: 0; /* reset main site styles*/ | |||||
border: 0; /* ditto */ | |||||
padding: 10px 0 10px 15px; /* padding-left = image gap + interior padding ... no padding-right */ | |||||
height: auto !important; height: 1%; /* IE Holly Hack */ | |||||
} | |||||
/* set the lower-left corner image */ | |||||
.boxBody { | |||||
background-position: bottom left; | |||||
margin-right: 0; /* interior-padding right */ | |||||
padding: 0 0 1px 5px; /* mirror .boxHead right/left */ | |||||
} | |||||
/* font styling */ | |||||
.boxHead h3 { | |||||
color: #222222; | |||||
} | |||||
/* End ThrashBox code */ |
@ -0,0 +1,428 @@ | |||||
/* | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./css/style_mobile.css | |||||
// Repository: $HeadURL$ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 14-Mar-08, 22:00 | |||||
// Modified: $Date: 2008-05-14 16:05:09 +0000 (Wed, 14 May 2008) $ | |||||
// $Author$ | |||||
// $Revision: 1120 $ | |||||
*/ | |||||
/* refbase CSS definitions - mobile view style */ | |||||
body { | |||||
background: #FFFFFF; | |||||
color: #000000; | |||||
margin: 0.5em; | |||||
} | |||||
pre, code { | |||||
font-family: monaco,courier,monospace; | |||||
font-size: 7pt; | |||||
} | |||||
.smaller { | |||||
font-size: 0.7em; | |||||
} | |||||
.small { | |||||
font-size: 0.7em; | |||||
} | |||||
.smallup { | |||||
font-size: 0.85em; | |||||
position: relative; | |||||
top: -10px; | |||||
} | |||||
.moveup { | |||||
position: relative; | |||||
top: -8px; | |||||
} | |||||
.unapi { | |||||
font-size: smaller; | |||||
} | |||||
.Z3988 { | |||||
font-size: smaller; | |||||
} | |||||
.ok { | |||||
color: #009900; | |||||
} | |||||
.warning { | |||||
color: red; | |||||
} | |||||
.warning2 { | |||||
color: red; | |||||
font-family: "lucida grande",helvetica,arial,sans-serif; | |||||
font-size: 0.75em; | |||||
} | |||||
.mainfieldsbg { | |||||
background-color: #FFFFFF; | |||||
} | |||||
.otherfieldsbg { | |||||
background-color: #FFFFFF; | |||||
} | |||||
.userfieldsbg { | |||||
background-color: #FFFFFF; | |||||
} | |||||
th { | |||||
font-family: "lucida grande",helvetica,arial,sans-serif; | |||||
font-size: 0.9em; | |||||
} | |||||
td, div { | |||||
font-family: "lucida grande",helvetica,arial,sans-serif; | |||||
font-size: 0.8em; | |||||
} | |||||
p { | |||||
font-family: "lucida grande",helvetica,arial,sans-serif; | |||||
font-size: 0.8em; | |||||
} | |||||
div.items { | |||||
} | |||||
div.item, div.even, div.odd { | |||||
} | |||||
div.even { | |||||
display: table-row; | |||||
} | |||||
div.odd { | |||||
display: table-row; | |||||
} | |||||
a:link { | |||||
color: #0033CC; | |||||
text-decoration: none; | |||||
} | |||||
a:visited { | |||||
color: #666666; | |||||
text-decoration: none; | |||||
} | |||||
a:active { | |||||
color: #990000; | |||||
text-decoration: none; | |||||
} | |||||
a:hover { | |||||
color: #3366FF; | |||||
text-decoration: underline; | |||||
} | |||||
h1, h2, h3, h4 { | |||||
font-family: "lucida grande",helvetica,arial,sans-serif; | |||||
} | |||||
h5, h6 { | |||||
font-family: "lucida grande",helvetica,arial,sans-serif; | |||||
} | |||||
h2, h3 { | |||||
margin-top: 1em; | |||||
margin-bottom: 0.5em; | |||||
} | |||||
h2 { | |||||
font-size: 1.8em; | |||||
} | |||||
h3 { | |||||
font-size: 1.35em; | |||||
} | |||||
h4, h5 { | |||||
margin-top: 0em; | |||||
margin-bottom: 0em; | |||||
} | |||||
h4 { | |||||
font-size: 1.25em; | |||||
} | |||||
h5 { | |||||
font-size: 1.1em; | |||||
} | |||||
div.pageheader img { | |||||
position: absolute; | |||||
top: 2em; | |||||
right: 2em; | |||||
} | |||||
div.pageheader p, form p { | |||||
margin: 0; | |||||
padding: 0; | |||||
} | |||||
form { | |||||
margin: 0; | |||||
margin-top: 1em; | |||||
font-size: 0.8em; | |||||
} | |||||
input { | |||||
} | |||||
.pageheader { | |||||
} | |||||
.pagefooter { | |||||
} | |||||
.results { | |||||
} | |||||
.resultsheader { | |||||
font-size: 1em; | |||||
} | |||||
.resultsfooter { | |||||
margin-left: 3.3em; | |||||
margin-right: 3.3em; | |||||
} | |||||
div.resultsfooter { | |||||
margin-top: 1.2em; | |||||
margin-bottom: 0.9em; | |||||
} | |||||
.showhide { | |||||
} | |||||
#resultoptions { | |||||
display: none; | |||||
} | |||||
.resultnav { | |||||
display: block; | |||||
margin-top: 1em; | |||||
margin-bottom: 0.5em; | |||||
text-align: center; | |||||
} | |||||
.mainnav { | |||||
display: inline-block; | |||||
margin-left: 0.5em; | |||||
margin-right: 1em; | |||||
position: absolute; | |||||
} | |||||
.pagenav { | |||||
display: inline-block; | |||||
} | |||||
.viewnav { | |||||
display: inline-block; | |||||
margin-top: -0.25em; | |||||
margin-right: 0.5em; | |||||
position: absolute; | |||||
right: 8px; | |||||
font-size: 0.75em; | |||||
} | |||||
#columns { | |||||
} | |||||
#details { | |||||
} | |||||
#citations { | |||||
font-size: 0.85em; | |||||
} | |||||
.citation { | |||||
display: inline-block; | |||||
min-height: 38px; | |||||
margin: 0.5em; | |||||
padding-right: 45px; | |||||
font-size: 1em; | |||||
} | |||||
#error { | |||||
} | |||||
#queryhistory { | |||||
margin-left: 2.6em; | |||||
margin-right: 2.6em; | |||||
margin-bottom: 1.75em; | |||||
} | |||||
#currentquery, #previousqueries { | |||||
margin-top: 1.2em; | |||||
font-size: 1em; | |||||
} | |||||
#queryhistory .even, #queryhistory .odd { | |||||
margin-top: 0.25em; | |||||
margin-left: 1.2em; | |||||
margin-right: 1.2em; | |||||
font-size: 1em; | |||||
} | |||||
.examples { | |||||
font-size: 1em; | |||||
} | |||||
.links { | |||||
display: inline-block; | |||||
min-height: 38px; | |||||
margin: 0.5em; | |||||
position: absolute; | |||||
right: 8px; | |||||
} | |||||
.sect { | |||||
padding-top: 2px; | |||||
font-size: 1em; | |||||
} | |||||
.even { | |||||
background-color: #FFFFFF; | |||||
} | |||||
.odd { | |||||
background-color: #F4F4F4; | |||||
} | |||||
#queryform { | |||||
margin-left: 0.5em; | |||||
text-align: center; | |||||
} | |||||
#queryform input[name=query] { | |||||
width: 15em; | |||||
margin-bottom: 0.9em; | |||||
} | |||||
#resultactions { | |||||
display: none; | |||||
} | |||||
#searchopt { | |||||
display: none; | |||||
} | |||||
#helptxt { | |||||
display: none; | |||||
} | |||||
#helptxt .even { | |||||
display: block; | |||||
margin-left: -5px; | |||||
margin-top: -3px; | |||||
padding: 5px; | |||||
} | |||||
#helptxt .odd { | |||||
display: block; | |||||
margin-left: -5px; | |||||
padding: 5px; | |||||
} | |||||
.toggleimg { | |||||
} | |||||
.toggletxt { | |||||
display: inline; | |||||
margin-left: 5px; | |||||
font-size: 1em; | |||||
} | |||||
a:link .toggletxt { | |||||
color: #000000; | |||||
} | |||||
a:visited .toggletxt { | |||||
color: #000000; | |||||
} | |||||
a:hover .toggletxt { | |||||
color: #3366FF; | |||||
} | |||||
.resultviews { | |||||
display: inline; | |||||
font-size: 0.85em; | |||||
} | |||||
.activeview { | |||||
display: inline; | |||||
font-size: 1em; | |||||
} | |||||
.leftview { | |||||
display: inline; | |||||
font-size: 1em; | |||||
} | |||||
.middleview { | |||||
display: inline; | |||||
font-size: 1em; | |||||
} | |||||
.rightview { | |||||
display: inline; | |||||
font-size: 1em; | |||||
} | |||||
.toggleprint { | |||||
position: relative; | |||||
top: 3px; | |||||
} | |||||
#accountinfo { | |||||
font-size: 1.25em; | |||||
} | |||||
#accountdetails { | |||||
font-size: 1em; | |||||
} | |||||
#accountopt { | |||||
font-size: 1em; | |||||
} | |||||
#accountperm { | |||||
font-size: 1em; | |||||
} | |||||
#accountdetails ul, #accountopt ul, #accountperm ul { | |||||
position: relative; | |||||
top: -0.8em; | |||||
list-style-type: none; | |||||
font-size: 0.85em; | |||||
line-height: 1.3em; | |||||
} |
@ -0,0 +1,414 @@ | |||||
/* | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./css/style_print.css | |||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/css/style_print.css $ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 20-Oct-02, 15:08 | |||||
// Modified: $Date: 2012-02-28 23:11:45 +0000 (Tue, 28 Feb 2012) $ | |||||
// $Author: msteffens $ | |||||
// $Revision: 1340 $ | |||||
*/ | |||||
/* refbase CSS definitions - print view style */ | |||||
body { | |||||
background: #FFFFFF; | |||||
color: #000000; | |||||
} | |||||
pre, code { | |||||
font-family: monaco,courier,monospace; | |||||
font-size: 7pt; | |||||
} | |||||
.smaller { | |||||
font-size: 0.7em; | |||||
} | |||||
.small { | |||||
font-size: 0.7em; | |||||
} | |||||
.smallup { | |||||
font-size: 0.85em; | |||||
position: relative; | |||||
top: -10px; | |||||
} | |||||
.moveup { | |||||
position: relative; | |||||
top: -8px; | |||||
} | |||||
.unapi { | |||||
font-size: smaller; | |||||
} | |||||
.Z3988 { | |||||
font-size: smaller; | |||||
} | |||||
.ok { | |||||
color: #009900; | |||||
} | |||||
.warning { | |||||
color: red; | |||||
} | |||||
.warning2 { | |||||
color: red; | |||||
font-family: "lucida grande",helvetica,arial,sans-serif; | |||||
font-size: 0.75em; | |||||
} | |||||
.mainfieldsbg { | |||||
background-color: #FFFFFF; | |||||
} | |||||
.otherfieldsbg { | |||||
background-color: #FFFFFF; | |||||
} | |||||
.userfieldsbg { | |||||
background-color: #FFFFFF; | |||||
} | |||||
th { | |||||
font-family: "lucida grande",helvetica,arial,sans-serif; | |||||
font-size: 0.8em; | |||||
} | |||||
td, div { | |||||
font-family: "lucida grande",helvetica,arial,sans-serif; | |||||
font-size: 0.7em; | |||||
} | |||||
p { | |||||
font-family: "lucida grande",helvetica,arial,sans-serif; | |||||
font-size: 0.7em; | |||||
} | |||||
a:link { | |||||
color: #000000; | |||||
text-decoration: underline; | |||||
} | |||||
a:visited { | |||||
color: #000000; | |||||
text-decoration: underline; | |||||
} | |||||
a:active { | |||||
color: #000000; | |||||
text-decoration: underline; | |||||
} | |||||
a:hover { | |||||
color: #3366FF; | |||||
text-decoration: underline; | |||||
} | |||||
h1, h2, h3, h4 { | |||||
font-family: "lucida grande",helvetica,arial,sans-serif; | |||||
} | |||||
h5, h6 { | |||||
font-family: "lucida grande",helvetica,arial,sans-serif; | |||||
} | |||||
h2, h3 { | |||||
margin-top: 1em; | |||||
margin-bottom: 0.5em; | |||||
} | |||||
h2 { | |||||
font-size: 1.8em; | |||||
} | |||||
h3 { | |||||
font-size: 1.35em; | |||||
} | |||||
h4, h5 { | |||||
margin-top: 0em; | |||||
margin-bottom: 0em; | |||||
} | |||||
h4 { | |||||
font-size: 1.25em; | |||||
} | |||||
h5 { | |||||
font-size: 1.1em; | |||||
} | |||||
.pageheader { | |||||
} | |||||
.pagefooter { | |||||
} | |||||
.results { | |||||
} | |||||
.resultsheader { | |||||
font-size: 1em; | |||||
} | |||||
.resultsfooter { | |||||
margin-left: 3.3em; | |||||
margin-right: 3.3em; | |||||
} | |||||
div.resultsfooter { | |||||
margin-top: 1.2em; | |||||
margin-bottom: 0.9em; | |||||
} | |||||
.showhide { | |||||
} | |||||
#resultoptions { | |||||
display: none; | |||||
} | |||||
.resultnav { | |||||
} | |||||
.mainnav { | |||||
} | |||||
.pagenav { | |||||
} | |||||
.viewnav { | |||||
font-size: 0.75em; | |||||
} | |||||
#columns { | |||||
} | |||||
#columns .itemlinks a { | |||||
color: #000000; | |||||
text-decoration: none; | |||||
} | |||||
#columns .itemlinks a:hover { | |||||
color: #3366FF; | |||||
} | |||||
#details { | |||||
} | |||||
#details .itemlinks a { | |||||
color: #000000; | |||||
text-decoration: none; | |||||
} | |||||
#details .itemlinks a:hover { | |||||
color: #3366FF; | |||||
} | |||||
#citations { | |||||
} | |||||
.citation { | |||||
} | |||||
.citation .showhide { | |||||
margin-top: 0.4em; | |||||
} | |||||
.citation .moreinfo { | |||||
margin-left: 1.25em; | |||||
font-size: 1em; | |||||
} | |||||
.citation .moreinfo > * { | |||||
margin-bottom: 0.4em; | |||||
font-size: 0.85em; | |||||
} | |||||
.citation .moreinfo .reflinks { | |||||
margin-top: 0.8em; | |||||
} | |||||
.citation .moreinfo .reflinks > * { | |||||
display: inline; | |||||
font-size: 1em; | |||||
} | |||||
.citation .moreinfo .itemlinks a { | |||||
color: #000000; | |||||
text-decoration: none; | |||||
} | |||||
.citation .moreinfo .itemlinks a:hover { | |||||
color: #3366FF; | |||||
} | |||||
#error { | |||||
} | |||||
#queryhistory { | |||||
margin-left: 2.6em; | |||||
margin-right: 2.6em; | |||||
margin-bottom: 1.75em; | |||||
} | |||||
#currentquery, #previousqueries { | |||||
margin-top: 1.2em; | |||||
font-size: 1em; | |||||
} | |||||
#queryhistory .even, #queryhistory .odd { | |||||
margin-top: 0.25em; | |||||
margin-left: 1.2em; | |||||
margin-right: 1.2em; | |||||
font-size: 1em; | |||||
} | |||||
.examples { | |||||
font-size: 1em; | |||||
} | |||||
.links { | |||||
} | |||||
.sect { | |||||
padding-top: 2px; | |||||
font-size: 1em; | |||||
} | |||||
.even { | |||||
background-color: #FFFFFF; | |||||
padding: 5px; | |||||
} | |||||
.odd { | |||||
background-color: #F4F4F4; | |||||
padding: 5px; | |||||
} | |||||
#queryform { | |||||
} | |||||
#resultactions { | |||||
display: none; | |||||
} | |||||
#searchopt { | |||||
display: none; | |||||
} | |||||
#helptxt { | |||||
display: none; | |||||
} | |||||
#helptxt .even { | |||||
margin-left: -5px; | |||||
margin-top: -3px; | |||||
} | |||||
#helptxt .odd { | |||||
margin-left: -5px; | |||||
} | |||||
.toggleimg { | |||||
} | |||||
.toggletxt { | |||||
display: inline; | |||||
margin-left: 5px; | |||||
font-size: 1em; | |||||
} | |||||
a:link .toggletxt { | |||||
color: #000000; | |||||
} | |||||
a:visited .toggletxt { | |||||
color: #000000; | |||||
} | |||||
a:hover .toggletxt { | |||||
color: #3366FF; | |||||
} | |||||
.resultviews { | |||||
display: inline; | |||||
font-size: 0.85em; | |||||
} | |||||
.activeview { | |||||
display: inline; | |||||
font-size: 1em; | |||||
} | |||||
.leftview { | |||||
display: inline; | |||||
font-size: 1em; | |||||
} | |||||
.middleview { | |||||
display: inline; | |||||
font-size: 1em; | |||||
} | |||||
.rightview { | |||||
display: inline; | |||||
font-size: 1em; | |||||
} | |||||
.toggleprint { | |||||
position: relative; | |||||
top: 3px; | |||||
} | |||||
#accountinfo { | |||||
font-size: 1.25em; | |||||
} | |||||
#accountdetails { | |||||
font-size: 1em; | |||||
} | |||||
#accountopt { | |||||
font-size: 1em; | |||||
} | |||||
#accountperm { | |||||
font-size: 1em; | |||||
} | |||||
#accountdetails ul, #accountopt ul, #accountperm ul { | |||||
position: relative; | |||||
top: -0.8em; | |||||
list-style-type: none; | |||||
font-size: 0.85em; | |||||
line-height: 1.3em; | |||||
} |
@ -0,0 +1,234 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./duplicate_manager.php | |||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/duplicate_manager.php $ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 27-Jan-07, 21:18 | |||||
// Modified: $Date: 2015-02-16 20:53:19 +0000 (Mon, 16 Feb 2015) $ | |||||
// $Author: karnesky $ | |||||
// $Revision: 1405 $ | |||||
// This script enables you to manually manage duplicate records by entering their database serial numbers | |||||
// into the provided form. The form lets you flag (i.e. identify) an "original" record and its related | |||||
// duplicate entries. The script will then update the 'orig_record' field in table 'refs' accordingly. | |||||
// TODO: I18n | |||||
// Incorporate some include files: | |||||
include 'initialize/db.inc.php'; // 'db.inc.php' is included to hide username and password | |||||
include 'includes/header.inc.php'; // include header | |||||
include 'includes/footer.inc.php'; // include footer | |||||
include 'includes/include.inc.php'; // include common functions | |||||
include 'initialize/ini.inc.php'; // include common variables | |||||
// -------------------------------------------------------------------- | |||||
// START A SESSION: | |||||
// call the 'start_session()' function (from 'include.inc.php') which will also read out available session variables: | |||||
start_session(true); | |||||
// -------------------------------------------------------------------- | |||||
// Initialize preferred display language: | |||||
// (note that 'locales.inc.php' has to be included *after* the call to the 'start_session()' function) | |||||
include 'includes/locales.inc.php'; // include the locales | |||||
// -------------------------------------------------------------------- | |||||
// Extract session variables (only necessary if register globals is OFF!): | |||||
if (isset($_SESSION['errors'])) | |||||
$errors = $_SESSION['errors']; | |||||
else | |||||
$errors = array(); // initialize variable (in order to prevent 'Undefined index/variable...' messages) | |||||
if (isset($_SESSION['formVars'])) | |||||
$formVars = $_SESSION['formVars']; | |||||
else | |||||
$formVars = array(); // initialize variable (in order to prevent 'Undefined index/variable...' messages) | |||||
// The current values of the session variables 'errors' and 'formVars' get stored in '$errors' or '$formVars', respectively. (either automatically if | |||||
// register globals is ON, or explicitly if register globals is OFF [by uncommenting the code above]). | |||||
// We need to clear these session variables here, since they would otherwise be still there on a subsequent call of 'duplicate_manager.php'! | |||||
// Note: though we clear the session variables, the current error message (or form variables) is still available to this script via '$errors' (or '$formVars', respectively). | |||||
deleteSessionVariable("errors"); // function 'deleteSessionVariable()' is defined in 'include.inc.php' | |||||
deleteSessionVariable("formVars"); | |||||
// -------------------------------------------------------------------- | |||||
// TODO: enable checking for 'allow_flag_duplicates' permission | |||||
// CAUTION: Since there's not a 'allow_flag_duplicates' permission setting (yet), we currently just check whether a user is logged in! | |||||
if (!isset($_SESSION['loginEmail'])) // if a user isn't logged in... | |||||
// In order to flag any records as duplicates, a user must be logged in AND must be allowed to flag duplicates in the database: | |||||
// if (!(isset($_SESSION['loginEmail']) AND (isset($_SESSION['user_permissions']) AND preg_match("/allow_flag_duplicates/", $_SESSION['user_permissions'])))) // if a user isn't logged in OR if the 'user_permissions' session variable does NOT contain 'allow_flag_duplicates'... | |||||
{ | |||||
// return an appropriate error message: | |||||
$HeaderString = returnMsg($loc["NoPermission"] . $loc["NoPermission_ForFlagDups"] . "!", "warning", "strong", "HeaderString"); // function 'returnMsg()' is defined in 'include.inc.php' | |||||
// save the URL of the currently displayed page: | |||||
$referer = $_SERVER['HTTP_REFERER']; | |||||
// Write back session variables: | |||||
saveSessionVariable("referer", $referer); // function 'saveSessionVariable()' is defined in 'include.inc.php' | |||||
header("Location: index.php"); | |||||
exit; // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> !EXIT! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |||||
} | |||||
// -------------------------------------------------------------------- | |||||
// Extract the view type requested by the user (either 'Mobile', 'Print', 'Web' or ''): | |||||
// ('' will produce the default 'Web' output style) | |||||
if (isset($_REQUEST['viewType'])) | |||||
$viewType = $_REQUEST['viewType']; | |||||
else | |||||
$viewType = ""; | |||||
// Setup some required variables: | |||||
// If there's no stored message available: | |||||
if (!isset($_SESSION['HeaderString'])) | |||||
{ | |||||
if (empty($errors)) // provide one of the default messages: | |||||
{ | |||||
$errors = array(); // re-assign an empty array (in order to prevent 'Undefined variable "errors"...' messages when calling the 'fieldError' function later on) | |||||
$HeaderString = "Flag records as original or duplicate entries:"; // Provide the default message | |||||
} | |||||
else // -> there were errors validating the data entered by the user | |||||
$HeaderString = "There were validation errors regarding the data you entered:"; | |||||
} | |||||
else | |||||
{ | |||||
$HeaderString = $_SESSION['HeaderString']; // extract 'HeaderString' session variable (only necessary if register globals is OFF!) | |||||
// Note: though we clear the session variable, the current message is still available to this script via '$HeaderString': | |||||
deleteSessionVariable("HeaderString"); // function 'deleteSessionVariable()' is defined in 'include.inc.php' | |||||
} | |||||
// -------------------------------------------------------------------- | |||||
// Assign correct values to the form variables: | |||||
if (!empty($errors)) // if there were some errors on submit | |||||
{ | |||||
// load the form data that were entered by the user: | |||||
$origRecord = $formVars['origRecord']; | |||||
$dupRecords = $formVars['dupRecords']; | |||||
} | |||||
else | |||||
{ | |||||
$origRecord = ""; | |||||
$dupRecords = ""; | |||||
} | |||||
// -------------------------------------------------------------------- | |||||
// Show the login status: | |||||
showLogin(); // (function 'showLogin()' is defined in 'include.inc.php') | |||||
// (2a) Display header: | |||||
// call the 'displayHTMLhead()' and 'showPageHeader()' functions (which are defined in 'header.inc.php'): | |||||
displayHTMLhead(encodeHTML($officialDatabaseName) . " -- " . "Manage Duplicates", "index,follow", "Manage duplicate records in the " . encodeHTML($officialDatabaseName), "", false, "", $viewType, array()); | |||||
showPageHeader($HeaderString); | |||||
// (2b) Start <form> and <table> holding the form elements: | |||||
// note: we provide a default value for the 'submit' form tag so that hitting <enter> within a text entry field will act as if the user clicked the 'Flag Duplicates' button | |||||
?> | |||||
<form action="duplicate_modify.php" method="POST"> | |||||
<input type="hidden" name="formType" value="flagDuplicates"> | |||||
<input type="hidden" name="viewType" value="<?php echo encodeHTML($viewType); ?>"> | |||||
<input type="hidden" name="submit" value="Flag Duplicates"> | |||||
<table align="center" border="0" cellpadding="0" cellspacing="10" width="95%" summary="This table holds a form that allows you to manage duplicate database entries"> | |||||
<tr> | |||||
<td width="120"> | |||||
<div class="sect"><?php echo $loc["Original"]; ?>:</div> | |||||
</td> | |||||
<td><?php echo fieldError("origRecord", $errors); ?> | |||||
<input type="text" name="origRecord" value="<?php echo encodeHTML($origRecord); ?>" size="10" title="enter the serial number of the original (master) record"> | |||||
</td> | |||||
</tr> | |||||
<tr> | |||||
<td width="120"> | |||||
<div class="sect"><?php echo $loc["Duplicates"]; ?>:</div> | |||||
</td> | |||||
<td><?php echo fieldError("dupRecords", $errors); ?> | |||||
<input type="text" name="dupRecords" value="<?php echo encodeHTML($dupRecords); ?>" size="50" title="enter the serial number(s) of all records that are duplicate entries of the above specified record; separate multiple serials with any non-digit characters"> | |||||
</td> | |||||
</tr> | |||||
<tr> | |||||
<td> </td> | |||||
<td> | |||||
<input type="submit" name="submit" value="Flag Duplicates" title="mark the given records as original/duplicate entries"> | |||||
</td> | |||||
</tr> | |||||
</table> | |||||
<table class="showhide" align="center" border="0" cellpadding="0" cellspacing="10" width="95%"> | |||||
<tr> | |||||
<td class="small" width="120" valign="top"> | |||||
<a href="javascript:toggleVisibility('helptxt','helpToggleimg','helpToggletxt','<?php echo rawurlencode($loc["HelpAndExamples"]); ?>')"<?php echo addAccessKey("attribute", "search_help"); ?> title="<?php echo $loc["LinkTitle_ToggleVisibility"] . addAccessKey("title", "search_help"); ?>"> | |||||
<img id="helpToggleimg" class="toggleimg" src="img/closed.gif" alt="<?php echo $loc["LinkTitle_ToggleVisibility"]; ?>" width="9" height="9" hspace="0" border="0"> | |||||
<span id="helpToggletxt" class="toggletxt"><?php echo $loc["HelpAndExamples"]; ?></span> | |||||
</a> | |||||
</td> | |||||
</tr> | |||||
</table> | |||||
<table id="helptxt" align="center" border="0" cellpadding="0" cellspacing="10" width="95%" summary="This table holds some help text for the form on this page" style="display: none;"> | |||||
<tr> | |||||
<td width="120" valign="top"> | |||||
<div class="sect"><?php echo $loc["Help"]; ?>:</div> | |||||
</td> | |||||
<td class="helpbody" valign="top"> | |||||
<div class="even"> | |||||
This form allows you to manually flag records as original or duplicate entries. If the database contains multiple entries of the same bibliographic resource, enter the serial number of the "original" record (i.e. the master record) in the upper text entry field. Then enter the serial number(s) of its duplicate record entries (delimited by any non-digit characters) in the lower text entry field and press the <em>Flag Duplicates</em> button. | |||||
</div> | |||||
<div class="odd"> | |||||
If records have been flagged as original or duplicate entries, a small icon is displayed next to these records in list view to inform the user about it: <img src="img/ok.gif" alt="(original)" title="original record" width="14" height="16" hspace="0" border="0"> indicates original entries, while <img src="img/caution.gif" alt="(duplicate)" title="duplicate record" width="5" height="16" hspace="0" border="0"> denotes duplicate entries. | |||||
</div> | |||||
</td> | |||||
</tr> | |||||
<tr> | |||||
<td width="120" valign="top"> | |||||
<div class="sect"><?php echo $loc["Examples"]; ?>:</div> | |||||
</td> | |||||
<td class="examples" valign="top"> | |||||
<div class="even"> | |||||
To flag record number 123 as an original record, and mark records 456, 7890 and 13579 as duplicate entries (which get linked to their original record), use: | |||||
<pre><b>Original:</b> 123</pre> | |||||
<pre><b>Duplicates:</b> 456 7890 13579</pre> | |||||
</div> | |||||
</td> | |||||
</tr> | |||||
</table> | |||||
</form><?php | |||||
// -------------------------------------------------------------------- | |||||
// SHOW ERROR IN RED: | |||||
function fieldError($fieldName, $errors) | |||||
{ | |||||
if (isset($errors[$fieldName])) | |||||
return "<b><span class=\"warning2\">" . $errors[$fieldName] . "</span></b><br>"; | |||||
} | |||||
// -------------------------------------------------------------------- | |||||
// DISPLAY THE HTML FOOTER: | |||||
// call the 'showPageFooter()' and 'displayHTMLfoot()' functions (which are defined in 'footer.inc.php') | |||||
showPageFooter($HeaderString); | |||||
displayHTMLfoot(); | |||||
// -------------------------------------------------------------------- | |||||
?> |
@ -0,0 +1,198 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./duplicate_modify.php | |||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/duplicate_modify.php $ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 27-Jan-07, 23:22 | |||||
// Modified: $Date: 2017-04-13 02:00:18 +0000 (Thu, 13 Apr 2017) $ | |||||
// $Author: karnesky $ | |||||
// $Revision: 1416 $ | |||||
// This php script will flag records as original and duplicate records. | |||||
// It then displays the affected records using 'search.php' so that the user | |||||
// can verify the changes. | |||||
// TODO: I18n | |||||
// Incorporate some include files: | |||||
include 'initialize/db.inc.php'; // 'db.inc.php' is included to hide username and password | |||||
include 'includes/include.inc.php'; // include common functions | |||||
include 'initialize/ini.inc.php'; // include common variables | |||||
// -------------------------------------------------------------------- | |||||
// START A SESSION: | |||||
// call the 'start_session()' function (from 'include.inc.php') which will also read out available session variables: | |||||
start_session(true); | |||||
// -------------------------------------------------------------------- | |||||
// Initialize preferred display language: | |||||
// (note that 'locales.inc.php' has to be included *after* the call to the 'start_session()' function) | |||||
include 'includes/locales.inc.php'; // include the locales | |||||
// -------------------------------------------------------------------- | |||||
// Clear any errors that might have been found previously: | |||||
$errors = array(); | |||||
// Write the form variables into an array: | |||||
foreach($_REQUEST as $varname => $value) | |||||
$formVars[$varname] = trim($value); // remove any leading or trailing whitespace from the field's contents & copy the trimmed string to the '$formVars' array | |||||
// $formVars[$varname] = trim(clean($value, 50)); // the use of the clean function would be more secure! | |||||
// -------------------------------------------------------------------- | |||||
// Extract form variables: | |||||
// Note: Although we could use the '$formVars' array directly below (e.g.: $formVars['origRecord'] etc., like in 'user_validation.php'), we'll read out | |||||
// all variables individually again. This is done to enhance readability. (A smarter way of doing so seems be the use of the 'extract()' function, but that | |||||
// may expose yet another security hole...) | |||||
// First of all, check if this script was called by something else than 'duplicate_manager.php': | |||||
if (!preg_match("#/duplicate_manager\.php#i", $referer)) // variable '$referer' is globally defined in function 'start_session()' in 'include.inc.php' | |||||
{ | |||||
// return an appropriate error message: | |||||
$HeaderString = returnMsg($loc["Warning_InvalidCallToScript"] . " '" . scriptURL() . "'!", "warning", "strong", "HeaderString"); // functions 'returnMsg()' and 'scriptURL()' are defined in 'include.inc.php' | |||||
header("Location: " . $referer); // redirect to calling page | |||||
exit; // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> !EXIT! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |||||
} | |||||
// Extract the form used by the user: | |||||
$formType = $formVars['formType']; | |||||
// Extract the view type requested by the user (either 'Mobile', 'Print', 'Web' or ''): | |||||
// ('' will produce the default 'Web' output style) | |||||
if (isset($formVars['viewType'])) | |||||
$viewType = $formVars['viewType']; | |||||
else | |||||
$viewType = ""; | |||||
// Extract other form values provided by 'duplicate_manager.php': | |||||
if (isset($formVars['origRecord'])) | |||||
$origRecord = $formVars['origRecord']; | |||||
else | |||||
$origRecord = ""; | |||||
if (isset($formVars['dupRecords'])) | |||||
$dupRecords = $formVars['dupRecords']; | |||||
else | |||||
$dupRecords = ""; | |||||
// Extract serial numbers (i.e. discard any non-digit characters from the original user input): | |||||
$origRecordSerial = preg_replace("/\D*(\d+).*/", "\\1", $origRecord); // extract the first number given | |||||
$dupRecordSerialsArray = preg_split("/\D+/", $dupRecords, -1, PREG_SPLIT_NO_EMPTY); // extract all given serial numbers (the 'PREG_SPLIT_NO_EMPTY' flag causes only non-empty pieces to be returned) | |||||
// -------------------------------------------------------------------- | |||||
// (1) OPEN CONNECTION, (2) SELECT DATABASE | |||||
connectToMySQLDatabase(); // function 'connectToMySQLDatabase()' is defined in 'include.inc.php' | |||||
// -------------------------------------------------------------------- | |||||
// VALIDATE data fields: | |||||
// NOTE: for all fields that are validated here must exist error parsing code (of the form: " . fieldError("origRecord", $errors) . ") | |||||
// in front of the respective <input> form field in 'duplicate_manager.php'! Otherwise the generated error won't be displayed! | |||||
// Validate the 'Original' field: | |||||
if (empty($origRecord) OR !preg_match("/\d/", $origRecord)) | |||||
$errors["origRecord"] = "You must specify a serial number for the original record:"; // 'origRecord' must not be empty and must contain a number | |||||
elseif (preg_match("/\d\D+\d/", $origRecord)) | |||||
$errors["origRecord"] = "You can only specify a single record as original entry:"; // only one serial number must be given | |||||
elseif (in_array($origRecordSerial, $dupRecordSerialsArray)) | |||||
$errors["origRecord"] = "The original record cannot be one of the duplicate records:"; // the serial number of the original record must not be given within the list of duplicate serial numbers | |||||
// Validate the 'Duplicates' field: | |||||
if (empty($dupRecords) OR !preg_match("/\d/", $dupRecords)) | |||||
$errors["dupRecords"] = "You must specify at least one serial number that identifies a duplicate record:"; // 'dupRecords' must not be empty and at least one serial number must be given | |||||
// -------------------------------------------------------------------- | |||||
// Now the script has finished the validation, check if there were any errors: | |||||
if (count($errors) > 0) | |||||
{ | |||||
// Write back session variables: | |||||
saveSessionVariable("errors", $errors); // function 'saveSessionVariable()' is defined in 'include.inc.php' | |||||
saveSessionVariable("formVars", $formVars); | |||||
// There are errors. Relocate back to the 'Flag Duplicates' form (script 'duplicate_manager.php'): | |||||
header("Location: " . $referer); | |||||
exit; // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> !EXIT! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |||||
} | |||||
// -------------------------------------------------------------------- | |||||
// If we made it here, then the data is considered valid! | |||||
// CONSTRUCT SQL QUERY: | |||||
// UPDATE field 'orig_record' in table 'refs': | |||||
// original record: | |||||
$queryArray[] = "UPDATE $tableRefs SET " | |||||
. "orig_record = -" . $origRecordSerial | |||||
. " WHERE serial = " . $origRecordSerial; | |||||
// duplicate record(s): | |||||
$queryArray[] = "UPDATE $tableRefs SET " | |||||
. "orig_record = " . $origRecordSerial | |||||
. " WHERE serial RLIKE \"^(" . implode("|", $dupRecordSerialsArray) . ")$\""; | |||||
// -------------------------------------------------------------------- | |||||
// (3) RUN QUERY, (4) DISPLAY HEADER & RESULTS | |||||
// (3) RUN the queries on the database through the connection: | |||||
foreach($queryArray as $query) | |||||
$result = queryMySQLDatabase($query); // function 'queryMySQLDatabase()' is defined in 'include.inc.php' | |||||
$affectedRows = ($result ? mysqli_affected_rows ($connection) : 0); // get the number of rows that were modified (or return 0 if an error occurred) | |||||
if ($affectedRows == 0) // no rows were affected by the update | |||||
{ | |||||
// we'll file this additional error element here so that the 'errors' session variable isn't empty causing 'duplicate_manager.php' to re-load the form data that were submitted by the user | |||||
$errors["ignoredRecords"] = "all"; | |||||
// return an appropriate error message: | |||||
$HeaderString = returnMsg("Nothing was changed by your query!", "warning", "strong", "HeaderString"); // function 'returnMsg()' is defined in 'include.inc.php' | |||||
// Write back session variables: | |||||
saveSessionVariable("errors", $errors); // function 'saveSessionVariable()' is defined in 'include.inc.php' | |||||
saveSessionVariable("formVars", $formVars); | |||||
// Relocate back to the 'Flag Duplicates' form (script 'duplicate_manager.php'): | |||||
header("Location: " . $referer); | |||||
exit; // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> !EXIT! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |||||
} | |||||
// Build correct header message: | |||||
$HeaderString = returnMsg("The records below have been successfully flagged as original/duplicate records:", "", "", "HeaderString"); // function 'returnMsg()' is defined in 'include.inc.php' | |||||
// Merge all given record serial numbers: | |||||
$allRecordSerialsString = $origRecordSerial . "," . implode(",", $dupRecordSerialsArray); | |||||
// (4) Call 'show.php' which will display all affected records along with the header message | |||||
// (routing feedback output to a different script page will avoid any reload problems effectively!) | |||||
header("Location: show.php?records=" . $allRecordSerialsString); | |||||
// -------------------------------------------------------------------- | |||||
// (5) CLOSE CONNECTION | |||||
disconnectFromMySQLDatabase(); // function 'disconnectFromMySQLDatabase()' is defined in 'include.inc.php' | |||||
// -------------------------------------------------------------------- | |||||
?> |
@ -0,0 +1,478 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./duplicate_search.php | |||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/duplicate_search.php $ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 28-Jan-07, 09:17 | |||||
// Modified: $Date: 2015-02-16 20:53:19 +0000 (Mon, 16 Feb 2015) $ | |||||
// $Author: karnesky $ | |||||
// $Revision: 1405 $ | |||||
// This script provides a form that lets you search for duplicate records. | |||||
// | |||||
// | |||||
// TODO: I18n | |||||
// Incorporate some include files: | |||||
include 'initialize/db.inc.php'; // 'db.inc.php' is included to hide username and password | |||||
include 'includes/header.inc.php'; // include header | |||||
include 'includes/footer.inc.php'; // include footer | |||||
include 'includes/include.inc.php'; // include common functions | |||||
include 'initialize/ini.inc.php'; // include common variables | |||||
// -------------------------------------------------------------------- | |||||
// START A SESSION: | |||||
// call the 'start_session()' function (from 'include.inc.php') which will also read out available session variables: | |||||
start_session(true); | |||||
// -------------------------------------------------------------------- | |||||
// Initialize preferred display language: | |||||
// (note that 'locales.inc.php' has to be included *after* the call to the 'start_session()' function) | |||||
include 'includes/locales.inc.php'; // include the locales | |||||
// -------------------------------------------------------------------- | |||||
// Extract session variables (only necessary if register globals is OFF!): | |||||
if (isset($_SESSION['errors'])) | |||||
$errors = $_SESSION['errors']; | |||||
else | |||||
$errors = array(); // initialize variable (in order to prevent 'Undefined index/variable...' messages) | |||||
if (isset($_SESSION['formVars'])) | |||||
$formVars = $_SESSION['formVars']; | |||||
else | |||||
$formVars = array(); // initialize variable (in order to prevent 'Undefined index/variable...' messages) | |||||
// The current values of the session variables 'errors' and 'formVars' get stored in '$errors' or '$formVars', respectively. (either automatically if | |||||
// register globals is ON, or explicitly if register globals is OFF [by uncommenting the code above]). | |||||
// We need to clear these session variables here, since they would otherwise be still there on a subsequent call of 'duplicate_search.php'! | |||||
// Note: though we clear the session variables, the current error message (or form variables) is still available to this script via '$errors' (or '$formVars', respectively). | |||||
deleteSessionVariable("errors"); // function 'deleteSessionVariable()' is defined in 'include.inc.php' | |||||
deleteSessionVariable("formVars"); | |||||
// -------------------------------------------------------------------- | |||||
// Extract the view type requested by the user (either 'Mobile', 'Print', 'Web' or ''): | |||||
// ('' will produce the default 'Web' output style) | |||||
if (isset($_REQUEST['viewType'])) | |||||
$viewType = $_REQUEST['viewType']; | |||||
else | |||||
$viewType = ""; | |||||
// Check if the script was called with parameters (like: 'duplicate_search.php?customQuery=1&sqlQuery=...') | |||||
// If so, the parameter 'customQuery=1' will be set: | |||||
if (isset($_REQUEST['customQuery']) AND ($_REQUEST['customQuery'] == "1")) | |||||
$customQuery = "1"; // accept any previous SQL queries | |||||
else | |||||
$customQuery = "0"; | |||||
// Setup some required variables: | |||||
// If there's no stored message available: | |||||
if (!isset($_SESSION['HeaderString'])) | |||||
{ | |||||
if (empty($errors)) // provide one of the default messages: | |||||
{ | |||||
$errors = array(); // re-assign an empty array (in order to prevent 'Undefined variable "errors"...' messages when calling the 'fieldError' function later on) | |||||
if ($customQuery == "1") // the script was called with parameters | |||||
$HeaderString = "Find duplicates that match your current query:"; // Provide the default message | |||||
else // the script was called without any custom SQL query | |||||
$HeaderString = "Find duplicates:"; // Provide the default message | |||||
} | |||||
else // -> there were errors validating the data entered by the user | |||||
$HeaderString = "There were validation errors regarding the data you entered:"; | |||||
} | |||||
else | |||||
{ | |||||
$HeaderString = $_SESSION['HeaderString']; // extract 'HeaderString' session variable (only necessary if register globals is OFF!) | |||||
// Note: though we clear the session variable, the current message is still available to this script via '$HeaderString': | |||||
deleteSessionVariable("HeaderString"); // function 'deleteSessionVariable()' is defined in 'include.inc.php' | |||||
} | |||||
// -------------------------------------------------------------------- | |||||
// Assign correct values to the form variables: | |||||
// a) Provide the default query and options: | |||||
// list of fields that are selected by default: | |||||
$selectedFieldsArray = array("author", "title", "year", "publication", "volume", "pages"); | |||||
// default SQL query: | |||||
// TODO: build the complete SQL query using functions 'buildFROMclause()' and 'buildORDERclause()' | |||||
$sqlQuery = buildSELECTclause("", "", "", false, false); // function 'buildSELECTclause()' is defined in 'include.inc.php' | |||||
if (isset($_SESSION['loginEmail'])) | |||||
$sqlQuery .= " FROM $tableRefs WHERE location RLIKE \"" . $loginEmail . "\" ORDER BY year DESC, author"; // '$loginEmail' is defined in function 'start_session()' (in 'include.inc.php') | |||||
else | |||||
$sqlQuery .= " FROM $tableRefs WHERE serial RLIKE \".+\" ORDER BY year DESC, author"; | |||||
// default search options: | |||||
$ignoreWhitespace = "1"; | |||||
$ignorePunctuation = "1"; | |||||
$ignoreCharacterCase = "1"; | |||||
$ignoreAuthorInitials = "1"; | |||||
$nonASCIICharsSelected = "strip"; | |||||
// default display options: | |||||
$displayType = $_SESSION['userDefaultView']; // get the default view for the current user | |||||
$showLinks = "1"; | |||||
$showRows = $_SESSION['userRecordsPerPage']; // get the default number of records per page preferred by the current user | |||||
$citeStyle = $defaultCiteStyle; // defined in 'ini.inc.php' | |||||
$citeOrder = ""; | |||||
// b) The default query and options are overwritten if the script was called with parameters or if there were some errors on submit: | |||||
if ($customQuery == "1") // the script was called with parameters | |||||
{ | |||||
// extract selected fields: | |||||
if (isset($_REQUEST['matchFieldsSelector'])) | |||||
{ | |||||
if (is_string($_REQUEST['matchFieldsSelector'])) // we accept a string containing a (e.g. comma delimited) list of field names | |||||
$selectedFieldsArray = preg_split("/[^a-z_]+/", $_REQUEST['matchFieldsSelector'], -1, PREG_SPLIT_NO_EMPTY); // (the 'PREG_SPLIT_NO_EMPTY' flag causes only non-empty pieces to be returned) | |||||
else // the field list is already provided as array: | |||||
$selectedFieldsArray = $_REQUEST['matchFieldsSelector']; | |||||
} | |||||
// extract SQL query: | |||||
if (isset($_REQUEST['sqlQuery'])) | |||||
{ | |||||
$sqlQuery = $_REQUEST['sqlQuery']; // accept any previous SQL queries | |||||
$sqlQuery = stripSlashesIfMagicQuotes($sqlQuery); // function 'stripSlashesIfMagicQuotes()' is defined in 'include.inc.php' | |||||
} | |||||
// extract search options: | |||||
if (isset($_REQUEST['ignoreWhitespace']) AND ($_REQUEST['ignoreWhitespace'] == "0")) | |||||
$ignoreWhitespace = "0"; | |||||
if (isset($_REQUEST['ignorePunctuation']) AND ($_REQUEST['ignorePunctuation'] == "0")) | |||||
$ignorePunctuation = "0"; | |||||
if (isset($_REQUEST['ignoreCharacterCase']) AND ($_REQUEST['ignoreCharacterCase'] == "0")) | |||||
$ignoreCharacterCase = "0"; | |||||
if (isset($_REQUEST['ignoreAuthorInitials']) AND ($_REQUEST['ignoreAuthorInitials'] == "0")) | |||||
$ignoreAuthorInitials = "0"; | |||||
if (isset($_REQUEST['nonASCIIChars'])) | |||||
$nonASCIICharsSelected = $_REQUEST['nonASCIIChars']; | |||||
// extract display options: | |||||
if (isset($_REQUEST['originalDisplayType'])) | |||||
$displayType = $_REQUEST['originalDisplayType']; // extract the type of display requested by the user (either 'Display', 'Cite', 'List' or '') | |||||
if (isset($_REQUEST['showLinks']) AND ($_REQUEST['showLinks'] == "0")) | |||||
$showLinks = "0"; | |||||
if (isset($_REQUEST['showRows']) AND preg_match("/^[1-9]+[0-9]*$/", $_REQUEST['showRows'])) | |||||
$showRows = $_REQUEST['showRows']; | |||||
if (isset($_REQUEST['citeStyle'])) | |||||
$citeStyle = $_REQUEST['citeStyle']; | |||||
if (isset($_REQUEST['citeOrder'])) | |||||
$citeOrder = $_REQUEST['citeOrder']; | |||||
} | |||||
elseif (!empty($errors)) // there were some errors on submit | |||||
{ | |||||
// load selected fields: | |||||
if (isset($formVars['matchFieldsSelector'])) | |||||
$selectedFieldsArray = $formVars['matchFieldsSelector']; | |||||
// load the form data that were entered by the user: | |||||
if (isset($formVars['sqlQuery'])) | |||||
{ | |||||
$sqlQuery = $formVars['sqlQuery']; | |||||
$sqlQuery = stripSlashesIfMagicQuotes($sqlQuery); | |||||
} | |||||
// load search options: | |||||
if (isset($formVars['ignoreWhitespace'])) | |||||
$ignoreWhitespace = $formVars['ignoreWhitespace']; | |||||
if (isset($formVars['ignorePunctuation'])) | |||||
$ignorePunctuation = $formVars['ignorePunctuation']; | |||||
if (isset($formVars['ignoreCharacterCase'])) | |||||
$ignoreCharacterCase = $formVars['ignoreCharacterCase']; | |||||
if (isset($formVars['ignoreAuthorInitials'])) | |||||
$ignoreAuthorInitials = $formVars['ignoreAuthorInitials']; | |||||
if (isset($formVars['nonASCIIChars'])) | |||||
$nonASCIICharsSelected = $formVars['nonASCIIChars']; | |||||
// load display options: | |||||
if (isset($formVars['originalDisplayType'])) | |||||
$displayType = $formVars['originalDisplayType']; | |||||
if (isset($formVars['showLinks'])) | |||||
$showLinks = $formVars['showLinks']; | |||||
if (isset($formVars['showRows'])) | |||||
$showRows = $formVars['showRows']; | |||||
if (isset($formVars['citeStyle'])) | |||||
$citeStyle = $formVars['citeStyle']; | |||||
if (isset($formVars['citeOrder'])) | |||||
$citeOrder = $formVars['citeOrder']; | |||||
} | |||||
// Set search and display options according to the fetched attribute values: | |||||
// 'ignoreWhitespace' option: | |||||
if ($ignoreWhitespace == "1") | |||||
$ignoreWhitespaceChecked = " checked"; | |||||
else | |||||
$ignoreWhitespaceChecked = ""; | |||||
// 'ignorePunctuation' option: | |||||
if ($ignorePunctuation == "1") | |||||
$ignorePunctuationChecked = " checked"; | |||||
else | |||||
$ignorePunctuationChecked = ""; | |||||
// 'ignoreCharacterCase' option: | |||||
if ($ignoreCharacterCase == "1") | |||||
$ignoreCharacterCaseChecked = " checked"; | |||||
else | |||||
$ignoreCharacterCaseChecked = ""; | |||||
// 'ignoreAuthorInitials' option: | |||||
if ($ignoreAuthorInitials == "1") | |||||
$ignoreAuthorInitialsChecked = " checked"; | |||||
else | |||||
$ignoreAuthorInitialsChecked = ""; | |||||
// 'showLinks' option: | |||||
if ($showLinks == "1") | |||||
$checkLinks = " checked"; | |||||
else | |||||
$checkLinks = ""; | |||||
// Initialize variables used for the multi-select & drop-down form elements: | |||||
// specify which fields should be available in the multi-select box: | |||||
// (the list of fields is similar to that of the "Search within Results" form; while only | |||||
// some fields make sense with regard to duplicate identification, the other fields may be | |||||
// useful in finding non-duplicate records with matching field contents) | |||||
$dropDownItemArray1 = array("author" => "author", | |||||
"title" => "title", | |||||
// "type" => "type", | |||||
"year" => "year", | |||||
"publication" => "publication", | |||||
"abbrev_journal" => "abbrev_journal", | |||||
"volume" => "volume", | |||||
"issue" => "issue", | |||||
"pages" => "pages", | |||||
// "thesis" => "thesis", | |||||
// "keywords" => "keywords", | |||||
// "abstract" => "abstract", | |||||
// "publisher" => "publisher", | |||||
// "place" => "place", | |||||
// "editor" => "editor", | |||||
// "language" => "language", | |||||
// "series_title" => "series_title", | |||||
// "area" => "area", | |||||
"notes" => "notes"); | |||||
// if (isset($_SESSION['loginEmail'])) | |||||
// $dropDownItemArray1["location"] = "location"; // we only add the 'location' field if the user is logged in | |||||
// if (isset($_SESSION['loginEmail'])) // add user-specific fields if a user is logged in | |||||
// { | |||||
// $dropDownItemArray1["marked"] = "marked"; | |||||
// $dropDownItemArray1["copy"] = "copy"; | |||||
// $dropDownItemArray1["selected"] = "selected"; | |||||
// $dropDownItemArray1["user_keys"] = "user_keys"; | |||||
// $dropDownItemArray1["user_notes"] = "user_notes"; | |||||
// $dropDownItemArray1["user_file"] = "user_file"; | |||||
// $dropDownItemArray1["user_groups"] = "user_groups"; | |||||
// $dropDownItemArray1["cite_key"] = "cite_key"; | |||||
// } | |||||
// build properly formatted <option> tag elements from array items given in '$dropDownItemArray1': | |||||
$matchFieldsOptionTags = buildSelectMenuOptions($dropDownItemArray1, "//", "\t\t\t\t", true); // function 'buildSelectMenuOptions()' is defined in 'include.inc.php' | |||||
// by default we select all fields that are listed within '$selectedFieldsArray': | |||||
$selectedFields = implode("|", $selectedFieldsArray); // merge array of fields that shall be selected | |||||
$matchFieldsOptionTags = preg_replace("/<option([^>]*)>($selectedFields)<\\/option>/", "<option\\1 selected>\\2</option>", $matchFieldsOptionTags); | |||||
// define variable holding the 'nonASCIIChars' drop-down elements: | |||||
$dropDownItemArray2 = array("strip" => "strip", | |||||
"transliterate" => "transliterate", | |||||
"keep" => "don't change"); | |||||
// build properly formatted <option> tag elements from array items given in '$dropDownItemArray2': | |||||
$nonASCIICharsOptionTags = buildSelectMenuOptions($dropDownItemArray2, "//", "\t\t\t\t", true); | |||||
// add 'selected' attribute: | |||||
$nonASCIICharsOptionTags = preg_replace("/<option([^>]*)>($dropDownItemArray2[$nonASCIICharsSelected])<\\/option>/", "<option\\1 selected>\\2</option>", $nonASCIICharsOptionTags); | |||||
// -------------------------------------------------------------------- | |||||
// Show the login status: | |||||
showLogin(); // (function 'showLogin()' is defined in 'include.inc.php') | |||||
// (2a) Display header: | |||||
// call the 'displayHTMLhead()' and 'showPageHeader()' functions (which are defined in 'header.inc.php'): | |||||
displayHTMLhead(encodeHTML($officialDatabaseName) . " -- " . "Find Duplicates", "index,follow", "Search for duplicates within the " . encodeHTML($officialDatabaseName), "", false, "", $viewType, array()); | |||||
showPageHeader($HeaderString); | |||||
// (2b) Start <form> and <table> holding the form elements: | |||||
// note: we provide a default value for the 'submit' form tag so that hitting <enter> within a text entry field will act as if the user clicked the 'Add/Edit Query' button | |||||
?> | |||||
<form action="search.php" method="GET"> | |||||
<input type="hidden" name="formType" value="duplicateSearch"> | |||||
<input type="hidden" name="originalDisplayType" value="<?php echo $displayType; ?>"> | |||||
<input type="hidden" name="submit" value="Find Duplicates"> | |||||
<input type="hidden" name="citeStyle" value="<?php echo rawurlencode($citeStyle); ?>"> | |||||
<input type="hidden" name="citeOrder" value="<?php echo $citeOrder; ?>"> | |||||
<table align="center" border="0" cellpadding="0" cellspacing="10" width="95%" summary="This table holds a form that lets you search for duplicate records"> | |||||
<tr> | |||||
<td width="120" valign="top"> | |||||
<div class="sect"><?php echo $loc["MatchFields"]; ?>:</div> | |||||
</td> | |||||
<td valign="top"><?php echo fieldError("matchFieldsSelector", $errors); ?> | |||||
<select name="matchFieldsSelector[]" multiple><?php echo $matchFieldsOptionTags; ?> | |||||
</select> | |||||
<input type="submit" name="submit" value="Find Duplicates"> | |||||
</td> | |||||
</tr> | |||||
</table> | |||||
<table class="showhide" align="center" border="0" cellpadding="0" cellspacing="10" width="95%"> | |||||
<tr> | |||||
<td class="small" width="120" valign="top"> | |||||
<a href="javascript:toggleVisibility('searchopt','optToggleimg','optToggletxt','<?php echo rawurlencode($loc["SearchAndDisplayOptions"]); ?>')"<?php echo addAccessKey("attribute", "search_opt"); ?> title="<?php echo $loc["LinkTitle_ToggleVisibility"] . addAccessKey("title", "search_opt"); ?>"> | |||||
<img id="optToggleimg" class="toggleimg" src="img/closed.gif" alt="<?php echo $loc["LinkTitle_ToggleVisibility"]; ?>" width="9" height="9" hspace="0" border="0"> | |||||
<span id="optToggletxt" class="toggletxt"><?php echo $loc["SearchAndDisplayOptions"]; ?></span> | |||||
</a> | |||||
</td> | |||||
</tr> | |||||
</table> | |||||
<table id="searchopt" align="center" border="0" cellpadding="0" cellspacing="10" width="95%" summary="This table holds search & display options" style="display: none;"> | |||||
<tr> | |||||
<td width="120" valign="top" rowspan="5"> | |||||
<div class="sect"><?php echo $loc["SearchOptions"]; ?>:</div> | |||||
</td> | |||||
<td valign="top" colspan="2"> | |||||
<input type="checkbox" name="ignoreWhitespace" value="1"<?php echo $ignoreWhitespaceChecked; ?>> Ignore whitespace | |||||
</td> | |||||
</tr> | |||||
<tr> | |||||
<td valign="top" colspan="2"> | |||||
<input type="checkbox" name="ignorePunctuation" value="1"<?php echo $ignorePunctuationChecked; ?>> Ignore punctuation | |||||
</td> | |||||
</tr> | |||||
<tr> | |||||
<td valign="top" colspan="2"> | |||||
<input type="checkbox" name="ignoreCharacterCase" value="1"<?php echo $ignoreCharacterCaseChecked; ?>> Ignore character case | |||||
</td> | |||||
</tr> | |||||
<tr> | |||||
<td valign="top" colspan="2"> | |||||
<input type="checkbox" name="ignoreAuthorInitials" value="1"<?php echo $ignoreAuthorInitialsChecked; ?>> Ignore initials in author names | |||||
</td> | |||||
</tr> | |||||
<tr> | |||||
<td valign="top" colspan="2"> | |||||
<select name="nonASCIIChars"><?php echo $nonASCIICharsOptionTags; ?> | |||||
</select> | |||||
non-ASCII characters before comparison | |||||
</td> | |||||
</tr> | |||||
<tr> | |||||
<td valign="top"> | |||||
<div class="sect"><?php echo $loc["SQLQuery"]; ?>:</div> | |||||
</td> | |||||
<td colspan="2"><?php echo fieldError("sqlQuery", $errors); ?> | |||||
<textarea name="sqlQuery" rows="6" cols="60"><?php echo $sqlQuery; ?> | |||||
</textarea> | |||||
</td> | |||||
</tr> | |||||
<tr> | |||||
<td valign="middle"> | |||||
<div class="sect"><?php echo $loc["DisplayOptions"]; ?>:</div> | |||||
</td> | |||||
<td width="205" valign="middle"> | |||||
<input type="checkbox" id="showLinks" name="showLinks" value="1"<?php echo $checkLinks; ?>> <?php echo $loc["ShowLinks"]; ?> | |||||
</td> | |||||
<td valign="middle"> | |||||
<?php echo $loc["ShowRecordsPerPage_Prefix"]; ?> <input type="text" name="showRows" value="<?php echo $showRows; ?>" size="4" title="<?php echo $loc["DescriptionShowRecordsPerPage"]; ?>"> <?php echo $loc["ShowRecordsPerPage_Suffix"]; ?> | |||||
</td> | |||||
</tr> | |||||
</table> | |||||
<table class="showhide" align="center" border="0" cellpadding="0" cellspacing="10" width="95%"> | |||||
<tr> | |||||
<td class="small" width="120" valign="top"> | |||||
<a href="javascript:toggleVisibility('helptxt','helpToggleimg','helpToggletxt','<?php echo rawurlencode($loc["Help"]); ?>')"<?php echo addAccessKey("attribute", "search_help"); ?> title="<?php echo $loc["LinkTitle_ToggleVisibility"] . addAccessKey("title", "search_help"); ?>"> | |||||
<img id="helpToggleimg" class="toggleimg" src="img/closed.gif" alt="<?php echo $loc["LinkTitle_ToggleVisibility"]; ?>" width="9" height="9" hspace="0" border="0"> | |||||
<span id="helpToggletxt" class="toggletxt"><?php echo $loc["Help"]; ?></span> | |||||
</a> | |||||
</td> | |||||
</tr> | |||||
</table> | |||||
<table id="helptxt" align="center" border="0" cellpadding="0" cellspacing="10" width="95%" summary="This table holds the help text" style="display: none;"> | |||||
<tr> | |||||
<td width="120" valign="top"> | |||||
<div class="sect"><?php echo $loc["Help"]; ?>:</div> | |||||
</td> | |||||
<td class="helpbody" valign="top"> | |||||
<div class="even"> | |||||
This form allows you to find duplicate records within your current query results. Modify the elements of this form as needed and click the <em>Find Duplicates</em> button. You can use the field selector to specify which fields shall be considered when matching records. The search options allow you to normalize field contents before comparison. The SQL query string defines the scope of the duplicate search and (in case of List view) specifies the columns that will be displayed in the results list. | |||||
</div> | |||||
<div class="odd"> | |||||
Some usage tips: Generally it should suffice to simply press the <em>Find Duplicates</em> button. W.r.t. the field selector, it's usually a good idea to leave a few more fields selected. The more fields you select, the more conservative will the dup detection be (and vice versa). The default selection (<code>author</code>, <code>title</code>, <code>year</code>, <code>publication</code>, <code>volume</code>, <code>pages</code>) is rather conservative and should thus avoid false positives. In general, deselecting one or more of the fields <code>author</code>, <code>title</code> and/or <code>publication</code> will often detect additional duplicate entries but may also display some false positives. | |||||
</div> | |||||
</td> | |||||
</tr> | |||||
</table> | |||||
</form><?php | |||||
// -------------------------------------------------------------------- | |||||
// SHOW ERROR IN RED: | |||||
function fieldError($fieldName, $errors) | |||||
{ | |||||
if (isset($errors[$fieldName])) | |||||
return "<b><span class=\"warning2\">" . $errors[$fieldName] . "</span></b><br>"; | |||||
} | |||||
// -------------------------------------------------------------------- | |||||
// DISPLAY THE HTML FOOTER: | |||||
// call the 'showPageFooter()' and 'displayHTMLfoot()' functions (which are defined in 'footer.inc.php') | |||||
showPageFooter($HeaderString); | |||||
displayHTMLfoot(); | |||||
// -------------------------------------------------------------------- | |||||
?> |
@ -0,0 +1,132 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./error.php | |||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/error.php $ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 05-Jan-03, 16:35 | |||||
// Modified: $Date: 2018-02-23 04:16:36 +0000 (Fri, 23 Feb 2018) $ | |||||
// $Author: karnesky $ | |||||
// $Revision: 1422 $ | |||||
// This php script will display an error page | |||||
// showing any error that did occur. It will display | |||||
// a link to the previous search results page (if any) | |||||
// Incorporate some include files: | |||||
include 'initialize/db.inc.php'; // 'db.inc.php' is included to hide username and password | |||||
include 'includes/header.inc.php'; // include header | |||||
include 'includes/footer.inc.php'; // include footer | |||||
include 'includes/include.inc.php'; // include common functions | |||||
include 'initialize/ini.inc.php'; // include common variables | |||||
// -------------------------------------------------------------------- | |||||
// START A SESSION: | |||||
// call the 'start_session()' function (from 'include.inc.php') which will also read out available session variables: | |||||
start_session(false); | |||||
// -------------------------------------------------------------------- | |||||
// Initialize preferred display language: | |||||
// (note that 'locales.inc.php' has to be included *after* the call to the 'start_session()' function) | |||||
include 'includes/locales.inc.php'; // include the locales | |||||
// -------------------------------------------------------------------- | |||||
// [ Extract form variables sent through POST/GET by use of the '$_REQUEST' variable ] | |||||
// [ !! NOTE !!: for details see <http://www.php.net/release_4_2_1.php> & <http://www.php.net/manual/en/language.variables.predefined.php> ] | |||||
// Check if any error occurred while processing the database UPDATE/INSERT/DELETE | |||||
// /referr | |||||
if(!preg_match("/error.php/", $referer) && (strtolower(parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST)) == strtolower($_SERVER['HTTP_HOST']))){ | |||||
$errorNo = $_REQUEST['errorNo']; | |||||
$errorMsg = $_REQUEST['errorMsg']; | |||||
$errorMsg = stripSlashesIfMagicQuotes($errorMsg); // function 'stripSlashesIfMagicQuotes()' is defined in 'include.inc.php' | |||||
// Extract the header message that was returned by originating script: | |||||
$HeaderString = $_REQUEST['headerMsg']; | |||||
$HeaderString = stripSlashesIfMagicQuotes($HeaderString); | |||||
} | |||||
else{ | |||||
$errorMsg = "Unexpected Error."; | |||||
$referer="/"; | |||||
} | |||||
// Extract the view type requested by the user (either 'Mobile', 'Print', 'Web' or ''): | |||||
// ('' will produce the default 'Web' output style) | |||||
if (isset($_REQUEST['viewType'])) | |||||
$viewType = $_REQUEST['viewType']; | |||||
else | |||||
$viewType = ""; | |||||
// Extract generic variables from the request: | |||||
if (isset($_SESSION['oldQuery'])) | |||||
$oldQuery = $_SESSION['oldQuery']; // get the query URL of the formerly displayed results page | |||||
else | |||||
$oldQuery = array(); | |||||
// -------------------------------------------------------------------- | |||||
// (4) DISPLAY HEADER & RESULTS | |||||
// (NOTE: Since there's no need to query the database here, we won't perform any of the following: (1) OPEN CONNECTION, (2) SELECT DATABASE, (3) RUN QUERY, (5) CLOSE CONNECTION) | |||||
// Show the login status: | |||||
showLogin(); // (function 'showLogin()' is defined in 'include.inc.php') | |||||
// (4a) DISPLAY header: | |||||
// call the 'displayHTMLhead()' and 'showPageHeader()' functions (which are defined in 'header.inc.php'): | |||||
displayHTMLhead(encodeHTML($officialDatabaseName) . " -- Error", "noindex,nofollow", "Feedback page that shows any error that occurred while using the " . encodeHTML($officialDatabaseName), "", false, "", $viewType, array()); | |||||
showPageHeader($HeaderString); | |||||
// Generate a 'search.php' URL that points to the formerly displayed results page: | |||||
if (!empty($oldQuery)) | |||||
$oldQueryURL = generateURL("search.php", "html", $oldQuery, true); // function 'generateURL()' is defined in 'include.inc.php' | |||||
// Build appropriate links: | |||||
$links = "\n<tr>" | |||||
. "\n\t<td>" | |||||
. "\n\t\tChoose how to proceed: "; | |||||
// - provide a 'go back' link (the following would only work with javascript: <a href=\"javascript:history.back()\">Go Back</a>") | |||||
$links .= "\n\t\t<a href=\"" . encodeHTML($referer) . "\">Go Back</a>"; // variable '$referer' is globally defined in function 'start_session()' in 'include.inc.php' | |||||
// - provide a link to any previous search results: | |||||
if (!empty($oldQuery)) | |||||
$links .= "\n\t\t -OR- " | |||||
. "\n\t\t<a href=\"" . $oldQueryURL . "\">Display previous search results</a>"; | |||||
// - we also include a link to the home page here: | |||||
$links .= "\n\t\t -OR- " | |||||
. "\n\t\t<a href=\"index.php\">Goto " . encodeHTML($officialDatabaseName) . " Home</a>" | |||||
. "\n\t</td>" | |||||
. "\n</tr>"; | |||||
// SHOW ERROR MESSAGE: | |||||
echo "\n<table class=\"error\" align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"10\" width=\"95%\">\n<tr>\n\t<td valign=\"top\"> Error " | |||||
. encodeHTML($errorNo) . " : <b>" . encodeHTML($errorMsg) . "</b>" // function 'encodeHTML()' is defined in 'include.inc.php' | |||||
. "</td>\n</tr>" | |||||
. $links | |||||
. "\n</table>"; | |||||
// -------------------------------------------------------------------- | |||||
// DISPLAY THE HTML FOOTER: | |||||
// call the 'showPageFooter()' and 'displayHTMLfoot()' functions (which are defined in 'footer.inc.php') | |||||
showPageFooter($HeaderString); | |||||
displayHTMLfoot(); | |||||
// -------------------------------------------------------------------- | |||||
exit; // die | |||||
?> |
@ -0,0 +1,42 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./export/bibutils/export_xml2ads.php | |||||
// Repository: $HeadURL$ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 04-Jun-08, 21:15 | |||||
// Modified: $Date: 2008-06-19 17:47:19 +0000 (Thu, 19 Jun 2008) $ | |||||
// $Author$ | |||||
// $Revision: 1143 $ | |||||
// This is an export format file (which must reside within the 'export/' sub-directory of your refbase root directory). It contains a version of the | |||||
// 'exportRecords()' function that outputs records according to the export format used by the SAO/NASA Astrophysics Data System (http://adsabs.harvard.edu/). | |||||
// This function is basically a wrapper for the bibutils 'xml2ads' command line tool (http://www.scripps.edu/~cdputnam/software/bibutils/bibutils.html). | |||||
// -------------------------------------------------------------------- | |||||
// --- BEGIN EXPORT FORMAT --- | |||||
// Export found records in 'ADS' format: | |||||
// Requires the following packages (available under the GPL): | |||||
// - bibutils v3.40 or greater <http://www.scripps.edu/~cdputnam/software/bibutils/bibutils.html> | |||||
// - ActiveLink PHP XML Package <http://www.active-link.com/software/> | |||||
function exportRecords($result, $rowOffset, $showRows, $exportStylesheet, $displayType) | |||||
{ | |||||
// function 'exportBibutils()' is defined in 'execute.inc.php' | |||||
return exportBibutils($result,"xml2ads"); | |||||
} | |||||
// --- END EXPORT FORMAT --- | |||||
// -------------------------------------------------------------------- | |||||
?> |
@ -0,0 +1,45 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./export/bibutils/export_xml2bib.php | |||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/export/bibutils/export_xml2bib.php $ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 28-Sep-04, 22:14 | |||||
// Modified: $Date: 2007-02-17 01:10:14 +0000 (Sat, 17 Feb 2007) $ | |||||
// $Author: msteffens $ | |||||
// $Revision: 894 $ | |||||
// This is an export format file (which must reside within the 'export/' sub-directory of your refbase root directory). It contains a version of the | |||||
// 'exportRecords()' function that outputs records according to the export format used by 'BibTeX', the bibliographic companion to the LaTeX macro package. | |||||
// This function is basically a wrapper for the bibutils 'xml2bib' command line tool (http://www.scripps.edu/~cdputnam/software/bibutils/bibutils.html). | |||||
// -------------------------------------------------------------------- | |||||
// --- BEGIN EXPORT FORMAT --- | |||||
// Export found records in 'BibTeX' format: | |||||
// Requires the following packages (available under the GPL): | |||||
// - bibutils <http://www.scripps.edu/~cdputnam/software/bibutils/bibutils.html> | |||||
// - ActiveLink PHP XML Package <http://www.active-link.com/software/> | |||||
function exportRecords($result, $rowOffset, $showRows, $exportStylesheet, $displayType) | |||||
{ | |||||
// function 'exportBibutils()' is defined in 'execute.inc.php' | |||||
$bibtexSourceText = exportBibutils($result,"xml2bib"); | |||||
// function 'standardizeBibtexOutput()' is defined in 'export.inc.php' | |||||
return standardizeBibtexOutput($bibtexSourceText); | |||||
} | |||||
// --- END EXPORT FORMAT --- | |||||
// -------------------------------------------------------------------- | |||||
?> |
@ -0,0 +1,42 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./export/bibutils/export_xml2end.php | |||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/export/bibutils/export_xml2end.php $ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 28-Sep-04, 22:14 | |||||
// Modified: $Date: 2007-02-17 01:10:14 +0000 (Sat, 17 Feb 2007) $ | |||||
// $Author: msteffens $ | |||||
// $Revision: 894 $ | |||||
// This is an export format file (which must reside within the 'export/' sub-directory of your refbase root directory). It contains a version of the | |||||
// 'exportRecords()' function that outputs records according to the export format used by the commercial bibliographic package 'Endnote' (http://www.endnote.com). | |||||
// This function is basically a wrapper for the bibutils 'xml2end' command line tool (http://www.scripps.edu/~cdputnam/software/bibutils/bibutils.html). | |||||
// -------------------------------------------------------------------- | |||||
// --- BEGIN EXPORT FORMAT --- | |||||
// Export found records in 'Endnote' format: | |||||
// Requires the following packages (available under the GPL): | |||||
// - bibutils <http://www.scripps.edu/~cdputnam/software/bibutils/bibutils.html> | |||||
// - ActiveLink PHP XML Package <http://www.active-link.com/software/> | |||||
function exportRecords($result, $rowOffset, $showRows, $exportStylesheet, $displayType) | |||||
{ | |||||
// function 'exportBibutils()' is defined in 'execute.inc.php' | |||||
return exportBibutils($result,"xml2end"); | |||||
} | |||||
// --- END EXPORT FORMAT --- | |||||
// -------------------------------------------------------------------- | |||||
?> |
@ -0,0 +1,42 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./export/bibutils/export_xml2isi.php | |||||
// Repository: $HeadURL$ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 21-Mar-07, 23:17 | |||||
// Modified: $Date: 2007-03-21 22:36:40 +0000 (Wed, 21 Mar 2007) $ | |||||
// $Author$ | |||||
// $Revision: 908 $ | |||||
// This is an export format file (which must reside within the 'export/' sub-directory of your refbase root directory). It contains a version of the | |||||
// 'exportRecords()' function that outputs records according to the export format used by the ISI Web of Science Internet Database Service (http://scientific.thomson.com/products/wos/). | |||||
// This function is basically a wrapper for the bibutils 'xml2isi' command line tool (http://www.scripps.edu/~cdputnam/software/bibutils/bibutils.html). | |||||
// -------------------------------------------------------------------- | |||||
// --- BEGIN EXPORT FORMAT --- | |||||
// Export found records in 'ISI' format: | |||||
// Requires the following packages (available under the GPL): | |||||
// - bibutils <http://www.scripps.edu/~cdputnam/software/bibutils/bibutils.html> | |||||
// - ActiveLink PHP XML Package <http://www.active-link.com/software/> | |||||
function exportRecords($result, $rowOffset, $showRows, $exportStylesheet, $displayType) | |||||
{ | |||||
// function 'exportBibutils()' is defined in 'execute.inc.php' | |||||
return exportBibutils($result,"xml2isi"); | |||||
} | |||||
// --- END EXPORT FORMAT --- | |||||
// -------------------------------------------------------------------- | |||||
?> |
@ -0,0 +1,48 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./export/bibutils/export_xml2ris.php | |||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/export/bibutils/export_xml2ris.php $ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 28-Sep-04, 22:14 | |||||
// Modified: $Date: 2008-08-19 17:13:01 +0000 (Tue, 19 Aug 2008) $ | |||||
// $Author: msteffens $ | |||||
// $Revision: 1198 $ | |||||
// This is an export format file (which must reside within the 'export/' sub-directory of your refbase root directory). It contains a version of the | |||||
// 'exportRecords()' function that outputs records according to the standard export format used e.g. by commercial bibliographic packages like 'Reference Manager' (http://www.refman.com). | |||||
// This function is basically a wrapper for the bibutils 'xml2ris' command line tool (http://www.scripps.edu/~cdputnam/software/bibutils/bibutils.html). | |||||
// -------------------------------------------------------------------- | |||||
// --- BEGIN EXPORT FORMAT --- | |||||
// Export found records in 'RIS' format: | |||||
// Requires the following packages (available under the GPL): | |||||
// - bibutils <http://www.scripps.edu/~cdputnam/software/bibutils/bibutils.html> | |||||
// - ActiveLink PHP XML Package <http://www.active-link.com/software/> | |||||
function exportRecords($result, $rowOffset, $showRows, $exportStylesheet, $displayType) | |||||
{ | |||||
// function 'exportBibutils()' is defined in 'execute.inc.php' | |||||
$risSourceText = exportBibutils($result,"xml2ris"); | |||||
// NOTE: the 'exec()' command that is used in function 'execute()' in file 'execute.inc.php' | |||||
// does not include trailing whitespace in its '$output' array [*]; since this would | |||||
// chop off trailing whitespace from closing RIS 'ER - ' tags, we add it back here | |||||
// [*] see <http://www.php.net/manual/en/function.exec.php> | |||||
return preg_replace("/^ER -$/m", "ER - ", $risSourceText); | |||||
} | |||||
// --- END EXPORT FORMAT --- | |||||
// -------------------------------------------------------------------- | |||||
?> |
@ -0,0 +1,44 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./export/bibutils/export_xml2word.php | |||||
// Repository: $HeadURL$ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 21-Mar-07, 23:17 | |||||
// Modified: $Date: 2008-04-14 17:00:27 +0000 (Mon, 14 Apr 2008) $ | |||||
// $Author$ | |||||
// $Revision: 1075 $ | |||||
// This is an export format file (which must reside within the 'export/' sub-directory of your refbase root directory). It contains a version of the | |||||
// 'exportRecords()' function that outputs records according to the Word 2007 bibliography XML format (http://office.microsoft.com/word/). | |||||
// This function is basically a wrapper for the bibutils 'xml2wordbib' command line tool (http://www.scripps.edu/~cdputnam/software/bibutils/bibutils.html). | |||||
// -------------------------------------------------------------------- | |||||
// --- BEGIN EXPORT FORMAT --- | |||||
// Export found records in Word 2007 bibliography format: | |||||
// Requires the following packages (available under the GPL): | |||||
// - bibutils <http://www.scripps.edu/~cdputnam/software/bibutils/bibutils.html> | |||||
// - ActiveLink PHP XML Package <http://www.active-link.com/software/> | |||||
function exportRecords($result, $rowOffset, $showRows, $exportStylesheet, $displayType) | |||||
{ | |||||
// function 'exportBibutils()' is defined in 'execute.inc.php' | |||||
// NOTE: if you're using a Bibutils version prior to Bibutils v3.40, | |||||
// you must rename "xml2wordbib" to "xml2word" in the line below | |||||
return exportBibutils($result,"xml2wordbib"); | |||||
} | |||||
// --- END EXPORT FORMAT --- | |||||
// -------------------------------------------------------------------- | |||||
?> |
@ -0,0 +1,52 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./export/export_atomxml.php | |||||
// Repository: $HeadURL$ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 08-Jan-08, 22:00 | |||||
// Modified: $Date: 2008-04-04 08:12:54 +0000 (Fri, 04 Apr 2008) $ | |||||
// $Author$ | |||||
// $Revision: 1026 $ | |||||
// This exports OpenSearch Atom XML. This file must reside in the 'export' directory of the refbase root directory. | |||||
// It uses functions from include files 'opensearch.inc.php' and 'atomxml.inc.php' that require the ActiveLink PHP XML Package, | |||||
// which is available under the GPL from: <http://www.active-link.com/software/> | |||||
// -------------------------------------------------------------------- | |||||
// --- BEGIN EXPORT FORMAT --- | |||||
// Export found records as OpenSearch Atom XML: | |||||
function exportRecords($result, $rowOffset, $showRows, $exportStylesheet, $displayType) | |||||
{ | |||||
global $rowsFound; | |||||
if ($rowsFound > 0 && ($rowOffset + 1) > $rowsFound) // Invalid offset for current MySQL result set, error with an appropriate diagnostics response: | |||||
{ | |||||
if ($rowsFound == 1) | |||||
$recordString = "record"; | |||||
else | |||||
$recordString = "records"; | |||||
$recordCollection = openSearchDiagnostics(61, "Record offset " . ($rowOffset + 1) . " is invalid for current result set (" . $rowsFound . " " . $recordString . " found)", $exportStylesheet); // function 'openSearchDiagnostics()' is defined in 'opensearch.inc.php' | |||||
} | |||||
else // Generate and serve an OpenSearch Atom XML file of ALL records: | |||||
{ | |||||
$recordCollection = atomCollection($result, $rowOffset, $showRows, $exportStylesheet, $displayType); // function 'atomCollection()' is defined in 'atomxml.inc.php' | |||||
} | |||||
return $recordCollection; | |||||
} | |||||
// --- END EXPORT FORMAT --- | |||||
// -------------------------------------------------------------------- | |||||
?> |
@ -0,0 +1,39 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./export/export_modsxml.php | |||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/export/export_modsxml.php $ | |||||
// Author(s): Richard Karnesky <mailto:karnesky@gmail.com> | |||||
// | |||||
// Created: 02-Oct-04, 12:00 | |||||
// Modified: $Date: 2007-02-17 01:10:14 +0000 (Sat, 17 Feb 2007) $ | |||||
// $Author: msteffens $ | |||||
// $Revision: 894 $ | |||||
// This exports MODS XML. This file must reside in the 'export' directory of the refbase root directory. | |||||
// It uses functions from include file 'modsxml.inc.php' that requires the ActiveLink PHP XML Package, | |||||
// which is available under the GPL from: <http://www.active-link.com/software/> | |||||
// -------------------------------------------------------------------- | |||||
// --- BEGIN EXPORT FORMAT --- | |||||
// Export found records as MODS XML: | |||||
function exportRecords($result, $rowOffset, $showRows, $exportStylesheet, $displayType) | |||||
{ | |||||
// Generate and serve a MODS XML file of ALL records: | |||||
$recordCollection = modsCollection($result); // function 'modsCollection()' is defined in 'modsxml.inc.php' | |||||
return $recordCollection; | |||||
} | |||||
// --- END EXPORT FORMAT --- | |||||
// -------------------------------------------------------------------- | |||||
?> |
@ -0,0 +1,39 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./export/export_oaidcxml.php | |||||
// Repository: $HeadURL$ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 08-Jan-08, 22:00 | |||||
// Modified: $Date: 2008-04-04 08:14:28 +0000 (Fri, 04 Apr 2008) $ | |||||
// $Author$ | |||||
// $Revision: 1027 $ | |||||
// This exports OAI_DC XML. This file must reside in the 'export' directory of the refbase root directory. | |||||
// It uses functions from include file 'oaidcxml.inc.php' that requires the ActiveLink PHP XML Package, | |||||
// which is available under the GPL from: <http://www.active-link.com/software/> | |||||
// -------------------------------------------------------------------- | |||||
// --- BEGIN EXPORT FORMAT --- | |||||
// Export found records as OAI_DC XML: | |||||
function exportRecords($result, $rowOffset, $showRows, $exportStylesheet, $displayType) | |||||
{ | |||||
// Generate and serve a OAI_DC XML file of ALL records: | |||||
$recordCollection = oaidcCollection($result); // function 'oaidcCollection()' is defined in 'oaidcxml.inc.php' | |||||
return $recordCollection; | |||||
} | |||||
// --- END EXPORT FORMAT --- | |||||
// -------------------------------------------------------------------- | |||||
?> |
@ -0,0 +1,39 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./export/export_odfxml.php | |||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/export/export_odfxml.php $ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 01-Jun-06, 13:57 | |||||
// Modified: $Date: 2007-02-17 01:10:14 +0000 (Sat, 17 Feb 2007) $ | |||||
// $Author: msteffens $ | |||||
// $Revision: 894 $ | |||||
// This exports ODF XML. This file must reside in the 'export' directory of the refbase root directory. | |||||
// It uses functions from include file 'odfxml.inc.php' that requires the ActiveLink PHP XML Package, | |||||
// which is available under the GPL from: <http://www.active-link.com/software/> | |||||
// -------------------------------------------------------------------- | |||||
// --- BEGIN EXPORT FORMAT --- | |||||
// Export found records as ODF XML: | |||||
function exportRecords($result, $rowOffset, $showRows, $exportStylesheet, $displayType) | |||||
{ | |||||
// Generate and serve an ODF XML file of ALL records: | |||||
$recordCollection = odfDocument($result, "spreadsheet"); // function 'odfDocument()' is defined in 'odfxml.inc.php' | |||||
return $recordCollection; | |||||
} | |||||
// --- END EXPORT FORMAT --- | |||||
// -------------------------------------------------------------------- | |||||
?> |
@ -0,0 +1,52 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./export/export_srwxml.php | |||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/export/export_srwxml.php $ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 17-May-05, 16:31 | |||||
// Modified: $Date: 2008-04-14 17:02:24 +0000 (Mon, 14 Apr 2008) $ | |||||
// $Author: msteffens $ | |||||
// $Revision: 1076 $ | |||||
// This exports SRW XML. This file must reside in the 'export' directory of the refbase root directory. | |||||
// It uses functions from include files 'srwxml.inc.php', 'modsxml.inc.php' and 'oaidcxml.inc.php' that require | |||||
// the ActiveLink PHP XML Package, which is available under the GPL from: <http://www.active-link.com/software/> | |||||
// -------------------------------------------------------------------- | |||||
// --- BEGIN EXPORT FORMAT --- | |||||
// Export found records as SRW XML: | |||||
function exportRecords($result, $rowOffset, $showRows, $exportStylesheet, $displayType) | |||||
{ | |||||
global $rowsFound; | |||||
if ($rowsFound > 0 && ($rowOffset + 1) > $rowsFound) // Invalid offset for current MySQL result set, error with an appropriate diagnostics response: | |||||
{ | |||||
if ($rowsFound == 1) | |||||
$recordString = "record"; | |||||
else | |||||
$recordString = "records"; | |||||
$recordCollection = srwDiagnostics(61, "Record offset " . ($rowOffset + 1) . " is invalid for current result set (" . $rowsFound . " " . $recordString . " found)", $exportStylesheet); // function 'srwDiagnostics()' is defined in 'srwxml.inc.php' | |||||
} | |||||
else // Generate and serve a SRW XML file of ALL records: | |||||
{ | |||||
$recordCollection = srwCollection($result, $rowOffset, $showRows, $exportStylesheet, $displayType); // function 'srwCollection()' is defined in 'srwxml.inc.php' | |||||
} | |||||
return $recordCollection; | |||||
} | |||||
// --- END EXPORT FORMAT --- | |||||
// -------------------------------------------------------------------- | |||||
?> |
@ -0,0 +1,179 @@ | |||||
<?php | |||||
// Project: Web Reference Database (refbase) <http://www.refbase.net> | |||||
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's | |||||
// original author(s). | |||||
// | |||||
// This code is distributed in the hope that it will be useful, | |||||
// but WITHOUT ANY WARRANTY. Please see the GNU General Public | |||||
// License for more details. | |||||
// | |||||
// File: ./extract.php | |||||
// Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/extract.php $ | |||||
// Author(s): Matthias Steffens <mailto:refbase@extracts.de> | |||||
// | |||||
// Created: 29-Jul-02, 16:39 | |||||
// Modified: $Date: 2012-02-27 20:25:30 +0000 (Mon, 27 Feb 2012) $ | |||||
// $Author: msteffens $ | |||||
// $Revision: 1337 $ | |||||
// Search form that offers to extract | |||||
// literature cited within a text and build | |||||
// an appropriate reference list from that. | |||||
// TODO: I18n | |||||
// Incorporate some include files: | |||||
include 'includes/header.inc.php'; // include header | |||||
include 'includes/footer.inc.php'; // include footer | |||||
include 'includes/include.inc.php'; // include common functions | |||||
include 'initialize/ini.inc.php'; // include common variables | |||||
// -------------------------------------------------------------------- | |||||
// START A SESSION: | |||||
// call the 'start_session()' function (from 'include.inc.php') which will also read out available session variables: | |||||
start_session(true); | |||||
// -------------------------------------------------------------------- | |||||
// Initialize preferred display language: | |||||
// (note that 'locales.inc.php' has to be included *after* the call to the 'start_session()' function) | |||||
include 'includes/locales.inc.php'; // include the locales | |||||
// -------------------------------------------------------------------- | |||||
// If there's no stored message available: | |||||
if (!isset($_SESSION['HeaderString'])) | |||||
$HeaderString = "Extract citations from a text and build an appropriate reference list:"; // Provide the default message | |||||
else | |||||
{ | |||||
$HeaderString = $_SESSION['HeaderString']; // extract 'HeaderString' session variable (only necessary if register globals is OFF!) | |||||
// Note: though we clear the session variable, the current message is still available to this script via '$HeaderString': | |||||
deleteSessionVariable("HeaderString"); // function 'deleteSessionVariable()' is defined in 'include.inc.php' | |||||
} | |||||
// Extract the view type requested by the user (either 'Mobile', 'Print', 'Web' or ''): | |||||
// ('' will produce the default 'Web' output style) | |||||
if (isset($_REQUEST['viewType'])) | |||||
$viewType = $_REQUEST['viewType']; | |||||
else | |||||
$viewType = ""; | |||||
// Show the login status: | |||||
showLogin(); // (function 'showLogin()' is defined in 'include.inc.php') | |||||
// (2a) Display header: | |||||
// call the 'displayHTMLhead()' and 'showPageHeader()' functions (which are defined in 'header.inc.php'): | |||||
displayHTMLhead(encodeHTML($officialDatabaseName) . " -- Extract Citations", "index,follow", "Search the " . encodeHTML($officialDatabaseName), "", false, "", $viewType, array()); | |||||
showPageHeader($HeaderString); | |||||
// (2b) Start <form> and <table> holding the form elements: | |||||
echo "\n<form action=\"search.php\" method=\"POST\">"; | |||||
echo "\n<input type=\"hidden\" name=\"formType\" value=\"extractSearch\">" | |||||
. "\n<input type=\"hidden\" name=\"submit\" value=\"Cite\">"; // provide a default value for the 'submit' form tag. Otherwise, some browsers may not recognize the correct output format when a user hits <enter> within a form field (instead of clicking the "Cite" button) | |||||
if (!isset($_SESSION['user_styles'])) | |||||
$citeStyleDisabled = " disabled"; // disable the style popup if the session variable holding the user's styles isn't available | |||||
else | |||||
$citeStyleDisabled = ""; | |||||
if (!isset($_SESSION['user_cite_formats'])) | |||||
$citeFormatDisabled = " disabled"; // disable the cite format popup if the session variable holding the user's cite formats isn't available | |||||
else | |||||
$citeFormatDisabled = ""; | |||||
echo "\n<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"10\" width=\"95%\" summary=\"This table holds the search form\">" | |||||
. "\n<tr>\n\t<td width=\"58\" valign=\"top\"><b>Extract Citations From:</b></td>\n\t<td width=\"10\"> </td>" | |||||
. "\n\t<td><textarea name=\"sourceText\" rows=\"6\" cols=\"60\">Paste your text here...</textarea></td>" | |||||
. "\n</tr>" | |||||
. "\n<tr>\n\t<td valign=\"top\" rowspan=\"2\"><b>Serial Delimiters:</b></td>\n\t<td> </td>" | |||||
. "\n\t<td valign=\"top\">Specify the character(s) that enclose record serial numbers or cite keys:</td>" | |||||
. "\n</tr>" | |||||
. "\n<tr>\n\t<td> </td>" | |||||
. "\n\t<td valign=\"top\">Start Delimiter: <input type=\"text\" name=\"startDelim\" value=\"{\" size=\"4\"> End Delimiter: <input type=\"text\" name=\"endDelim\" value=\"}\" size=\"4\"></td>" | |||||
. "\n</tr>" | |||||
. "\n<tr>\n\t<td valign=\"top\" rowspan=\"2\"><b>Display Options:</b></td>\n\t<td> </td>" | |||||
. "\n\t<td valign=\"top\"><input type=\"checkbox\" name=\"showLinks\" value=\"1\" checked> Display Links" | |||||
. " Show <input type=\"text\" name=\"showRows\" value=\"100\" size=\"4\" title=\"" . $loc["DescriptionShowRecordsPerPage"] . "\"> records per page</td>" | |||||
. "\n</tr>" | |||||
. "\n<tr>\n\t<td> </td>" | |||||
. "\n\t<td valign=\"top\">View type: " | |||||
. "\n\t\t<select name=\"viewType\">" | |||||
. "\n\t\t\t<option>Web</option>" | |||||
. "\n\t\t\t<option>Print</option>" | |||||
. "\n\t\t\t<option>Mobile</option>" | |||||
. "\n\t\t</select>" | |||||
. "\n\t</td>" | |||||
. "\n</tr>" | |||||
. "\n<tr>\n\t<td> </td>\n\t<td> </td>"; | |||||
if (isset($_SESSION['user_permissions']) AND preg_match("/allow_cite/", $_SESSION['user_permissions'])) // if the 'user_permissions' session variable contains 'allow_cite'... | |||||
// adjust the title string for the show cite button | |||||
{ | |||||
$citeButtonLock = ""; | |||||
$citeTitle = "build a reference list for all citations contained within the entered text"; | |||||
} | |||||
else // Note, that disabling the submit button is just a cosmetic thing -- the user can still submit the form by pressing enter or by building the correct URL from scratch! (however, there's some code in 'search.php' that will prevent query execution) | |||||
{ | |||||
$citeButtonLock = " disabled"; | |||||
$citeTitle = "not available since you have no permission to use the cite feature"; | |||||
} | |||||
echo "\n\t<td>\n\t\t<br><input type=\"submit\" name=\"submit\" value=\"Cite\"$citeButtonLock title=\"$citeTitle\"> " | |||||
. "\n\t\tusing style: " | |||||
. "\n\t\t<select name=\"citeStyle\" title=\"choose the output style for your reference list\"$citeStyleDisabled>"; | |||||
if (isset($_SESSION['user_styles'])) | |||||
{ | |||||
$optionTags = buildSelectMenuOptions($_SESSION['user_styles'], "/ *; */", "\t\t\t", false); // build properly formatted <option> tag elements from the items listed in the 'user_styles' session variable | |||||
echo $optionTags; | |||||
} | |||||
else | |||||
echo "\n\t\t\t<option>" . $defaultCiteStyle . "</option>"; // defined in 'ini.inc.php' | |||||
echo "\n\t\t</select> " | |||||
. "\n\t\tsort by: " | |||||
. "\n\t\t<select name=\"citeOrder\" title=\"choose the primary sort order for your reference list\">" | |||||
. "\n\t\t\t<option value=\"author\">author</option>" | |||||
. "\n\t\t\t<option value=\"year\">year</option>" | |||||
. "\n\t\t\t<option value=\"type\">type</option>" | |||||
. "\n\t\t\t<option value=\"type-year\">type, year</option>" | |||||
. "\n\t\t\t<option value=\"creation-date\">date created</option>" | |||||
. "\n\t\t</select> " | |||||
. "\n\t\treturn as: " | |||||
. "\n\t\t<select name=\"citeType\" title=\"choose how your reference list shall be returned\"$citeFormatDisabled>"; | |||||
if (isset($_SESSION['user_cite_formats'])) | |||||
{ | |||||
$optionTags = buildSelectMenuOptions($_SESSION['user_cite_formats'], "/ *; */", "\t\t\t", false); // build properly formatted <option> tag elements from the items listed in the 'user_cite_formats' session variable | |||||
echo $optionTags; | |||||
} | |||||
else | |||||
echo "\n\t\t\t<option>(no formats available)</option>"; | |||||
echo "\n\t\t</select>\n\t</td>" | |||||
. "\n</tr>" | |||||
. "\n<tr>\n\t<td align=\"center\" colspan=\"3\"> </td>" | |||||
. "\n</tr>" | |||||
. "\n<tr>\n\t<td valign=\"top\"><b>Help:</b></td>\n\t<td> </td>" | |||||
. "\n\t<td valign=\"top\">This form enables you to extract all citations from your text and build an appropriate reference list. To have this work simply include the serial numbers or cite keys of your cited records within your text (as shown below) and enclose the identifiers by some preferrably unique characters. These delimiters must be specified in the text fields above.</td>" | |||||
. "\n</tr>" | |||||
. "\n<tr>\n\t<td valign=\"top\"><b>Example:</b></td>\n\t<td> </td>" | |||||
. "\n\t<td valign=\"top\"><code>Results of the german south polar expedition were published by Hennings (1906) {1141} as well as several other authors (e.g.: Wille 1924 {1785}; Heiden & Kolbe 1928 {1127}).</code></td>" | |||||
. "\n</tr>" | |||||
. "\n</table>" | |||||
. "\n</form>"; | |||||
// -------------------------------------------------------------------- | |||||
// DISPLAY THE HTML FOOTER: | |||||
// call the 'showPageFooter()' and 'displayHTMLfoot()' functions (which are defined in 'footer.inc.php') | |||||
showPageFooter($HeaderString); | |||||
displayHTMLfoot(); | |||||
// -------------------------------------------------------------------- | |||||
?> |