merged views submodule
This commit is contained in:
commit
ad76968844
2
sites/all/modules/contrib/views/views/D7UPGRADE.txt
Normal file
2
sites/all/modules/contrib/views/views/D7UPGRADE.txt
Normal file
@ -0,0 +1,2 @@
|
||||
Information about upgrading existing views from Drupal 6 to Drupal 7 is located
|
||||
in the module's advanced help under api upgrading.
|
339
sites/all/modules/contrib/views/views/LICENSE.txt
Normal file
339
sites/all/modules/contrib/views/views/LICENSE.txt
Normal file
@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 Lesser 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.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 Lesser General
|
||||
Public License instead of this License.
|
19
sites/all/modules/contrib/views/views/README.txt
Normal file
19
sites/all/modules/contrib/views/views/README.txt
Normal file
@ -0,0 +1,19 @@
|
||||
|
||||
Welcome to Views 3. Please see the advanced help for more information.
|
||||
|
||||
If you're having trouble installing this module, please ensure that your
|
||||
tar program is not flattening the directory tree, truncating filenames
|
||||
or losing files.
|
||||
|
||||
Installing Views:
|
||||
|
||||
Place the entirety of this directory in sites/all/modules/views
|
||||
You must also install the CTools module (http://www.drupal.org/project/ctools) to use Views.
|
||||
|
||||
Navigate to administer >> build >> modules. Enable Views and Views UI.
|
||||
|
||||
If you're new to Views, try the Simple Views module which can create some
|
||||
often used Views for you, this might save you some time.
|
||||
|
||||
Here you can find many modules extending the functionality of Views:
|
||||
http://drupal.org/taxonomy/term/89
|
@ -0,0 +1,91 @@
|
||||
/**
|
||||
* The query details collapsible divs are not visible in IE7 because has-layout
|
||||
* is not being triggered. Trigger has-layout with height: 1%;
|
||||
*/
|
||||
.views-edit-view .collapsible > .fieldset-wrapper {
|
||||
height: 1%;
|
||||
}
|
||||
|
||||
/**
|
||||
* The column width for the bucket containers in the query details section
|
||||
* is not being calculated to 32% correctly. Give IE7 a slightly smaller
|
||||
* width so that the three columns line up next to each other
|
||||
*/
|
||||
.views-edit-view .views-display-column {
|
||||
width: 31.95%;
|
||||
}
|
||||
|
||||
/**
|
||||
* IE7 has no idea how large this container should be and it doesn't
|
||||
* apply has-layout. Expand it's width to 100% and trigger has-layout.
|
||||
*/
|
||||
.views-edit-view .views-displays {
|
||||
height: 1%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/**
|
||||
* IE7 isn't positioning the span correctly as a display-inline element
|
||||
*/
|
||||
.views-edit-view .views-displays .icon {
|
||||
display: block;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.views-edit-view .views-displays .icon-add {
|
||||
top: 2px;
|
||||
}
|
||||
|
||||
/**
|
||||
* The add display query dropdown needs a lot of help
|
||||
*/
|
||||
|
||||
.views-edit-view .views-displays .tabs.secondary {
|
||||
position: relative;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.views-edit-view .views-displays .secondary .open > a {
|
||||
border-bottom: 1px solid #f1f1f1;
|
||||
}
|
||||
|
||||
.views-edit-view .views-displays .secondary .action-list {
|
||||
border-bottom: 1px solid #cbcbcb;
|
||||
top: 30px;
|
||||
}
|
||||
|
||||
.views-edit-view .views-displays .secondary input {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
/**
|
||||
* IE7 does not interpret div > * correctly
|
||||
*/
|
||||
.page-admin-structure-views #content .views-ui-display-tab-bucket {
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
zoom: 1;
|
||||
}
|
||||
|
||||
.page-admin-structure-views #content .views-display-column + .views-display-column {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* IE7 is interpreting a top margin of 18px from somewhere. remove it
|
||||
*/
|
||||
|
||||
.page-admin-structure-views #content .views-display-setting {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* IE7 can't handle the + selector that indents form wrappers after a checkbox on the add page
|
||||
* zoom is necessary to trigger has layout. !imporant is necessary because IE7 is precedent
|
||||
* to the theme.css stylesheet, even though it is included before this file.
|
||||
*/
|
||||
|
||||
.page-admin-structure-views #content .form-type-checkbox + .form-wrapper {
|
||||
margin-left: 27px !important;
|
||||
zoom: 1;
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
/**
|
||||
* The .css file is intended to only contain positioning and size declarations
|
||||
* For example: display, position, float, clear, and overflow.
|
||||
*/
|
||||
|
||||
/* @group Inline lists */
|
||||
|
||||
.horizontal > * {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.horizontal.right {
|
||||
float: left;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Attachment details
|
||||
*
|
||||
* The attachment details section, its tabs for each section and the buttons
|
||||
* to add a new section
|
||||
*/
|
||||
|
||||
.form-actions {
|
||||
float: left;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Attachment details tabs
|
||||
*
|
||||
* The tabs that switch between sections
|
||||
*/
|
||||
|
||||
.views-displays .secondary > li {
|
||||
float: right;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Attachment details new section button */
|
||||
|
||||
.views-displays .secondary .action-list {
|
||||
left: auto;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Attachment details collapsible fieldset */
|
||||
|
||||
.views-display-tab .fieldset-legend {
|
||||
left: auto;
|
||||
right: -5px;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Attachment details actions
|
||||
*
|
||||
* Display the "Delete" and "Duplicate" buttons to the right.
|
||||
*/
|
||||
.views-display-tab .fieldset-wrapper > .views-ui-display-tab-bucket .actions {
|
||||
left: 0;
|
||||
right: auto;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Attachment configuration columns */
|
||||
|
||||
.views-display-columns > * {
|
||||
float: right;
|
||||
margin-left: 0;
|
||||
margin-right: 1%;
|
||||
padding-left: 0;
|
||||
padding-right: 1%;
|
||||
}
|
||||
|
||||
.views-display-columns > *:first-child {
|
||||
margin-right: 0;
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Settings forms */
|
||||
|
||||
.views-dependent {
|
||||
margin-right: 1.5em;
|
||||
}
|
||||
|
||||
.views-display-setting .label,
|
||||
.views-display-setting .views-ajax-link {
|
||||
float: right;
|
||||
}
|
||||
|
||||
/* @end */
|
@ -0,0 +1,24 @@
|
||||
/**
|
||||
* The .advanced_help.css file is intended to contain styles that override declarations
|
||||
* in the Advanced Help module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Adjust the advanced help icons
|
||||
*/
|
||||
.views-ui-display-tab-bucket .advanced-help-link {
|
||||
padding: 0;
|
||||
margin: 5px 3px 0px 6px; /* LTR */
|
||||
}
|
||||
|
||||
.views-ui-display-tab-bucket .icon-text {
|
||||
padding-left: 25px; /* LTR */
|
||||
}
|
||||
|
||||
.views-ui-display-tab-bucket .icon-linked {
|
||||
background-position: 6px -151px; /* LTR */
|
||||
}
|
||||
|
||||
.views-ui-display-tab-bucket .icon-unlinked {
|
||||
background-position: 6px -193px; /* LTR */
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
/**
|
||||
* The .bartik.css file is intended to contain styles that override declarations
|
||||
* in the Bartik theme.
|
||||
*/
|
||||
|
||||
/* @group Lists */
|
||||
|
||||
.views-display-top .secondary .action-list {
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
/* @end */
|
233
sites/all/modules/contrib/views/views/css/views-admin.bartik.css
Normal file
233
sites/all/modules/contrib/views/views/css/views-admin.bartik.css
Normal file
@ -0,0 +1,233 @@
|
||||
/**
|
||||
* The .bartik.css file is intended to contain styles that override declarations
|
||||
* in the Bartik theme.
|
||||
*/
|
||||
|
||||
/* @group Lists */
|
||||
|
||||
.views-display-top .secondary .action-list {
|
||||
padding-left: 0; /* LTR */
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Attachment details tabs
|
||||
*
|
||||
* The tabs that switch between sections
|
||||
*/
|
||||
|
||||
.views-displays .region-content .secondary,
|
||||
.views-displays .region-content .secondary {
|
||||
padding-bottom: 0;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.views-displays .secondary a {
|
||||
font-size: smaller;
|
||||
}
|
||||
|
||||
.views-displays .secondary > li a {
|
||||
-moz-border-radius: 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.views-displays .secondary > li.open a {
|
||||
-moz-border-radius: 5px 5px 0 0;
|
||||
-webkit-border-bottom-left-radius: 0;
|
||||
-webkit-border-bottom-right-radius: 0;
|
||||
-webkit-border-top-left-radius: 5px;
|
||||
-webkit-border-top-right-radius: 5px;
|
||||
border-radius: 5px 5px 0 0;
|
||||
}
|
||||
|
||||
.views-displays .secondary .open > a:hover {
|
||||
color: #0071B3;
|
||||
}
|
||||
|
||||
.views-displays .secondary input.form-submit {
|
||||
font-size: smaller;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Modal dialog box
|
||||
*
|
||||
* The contents of the popup dialog on the views edit form.
|
||||
*/
|
||||
|
||||
.views-filterable-options .even .form-type-checkbox {
|
||||
background-color: #F9F9F9;
|
||||
}
|
||||
|
||||
.views-ui-dialog .ui-dialog-titlebar-close,
|
||||
.views-ui-dialog #views-ajax-title,
|
||||
.views-ui-dialog .views-override,
|
||||
.views-ui-dialog .form-buttons {
|
||||
background-color: #f6f6f6;
|
||||
}
|
||||
|
||||
.views-ui-dialog a {
|
||||
color: #0071b3;
|
||||
}
|
||||
|
||||
.views-ui-dialog a:hover,
|
||||
.views-ui-dialog a:focus {
|
||||
color: #018fe2;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group CTools */
|
||||
|
||||
/* @group Buttons */
|
||||
|
||||
.ctools-button-processed {
|
||||
background-image:
|
||||
-moz-linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f9f9f9 100%);
|
||||
background-image:
|
||||
-webkit-gradient(
|
||||
linear,
|
||||
left top,
|
||||
left bottom,
|
||||
color-stop(0.0, rgba(255, 255, 255, 1.0)),
|
||||
color-stop(1.0, rgba(249, 249, 249, 1.0))
|
||||
);
|
||||
background-image:
|
||||
-webkit-linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f9f9f9 100%);
|
||||
background-image:
|
||||
linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f9f9f9 100%);
|
||||
-moz-border-radius: 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
padding-bottom: 1px;
|
||||
padding-top: 1px;
|
||||
}
|
||||
|
||||
.ctools-button-processed:hover {
|
||||
background-image:
|
||||
-moz-linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f1f1f1 100%);
|
||||
background-image:
|
||||
-webkit-gradient(
|
||||
linear,
|
||||
left top,
|
||||
left bottom,
|
||||
color-stop(0.0, rgba(255, 255, 255, 1.0)),
|
||||
color-stop(1.0, rgba(241, 241, 241, 1.0))
|
||||
);
|
||||
background-image:
|
||||
-webkit-linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f1f1f1 100%);
|
||||
background-image:
|
||||
linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f1f1f1 100%);
|
||||
}
|
||||
|
||||
.ctools-button-processed li a,
|
||||
.views-ui-display-tab-actions .ctools-button-processed input {
|
||||
padding-left: 9px;
|
||||
padding-right: 9px;
|
||||
}
|
||||
|
||||
.ctools-content ul.actions {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.ctools-dropbutton-processed.open:hover {
|
||||
background-image:
|
||||
-moz-linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f9f9f9 100%);
|
||||
background-image:
|
||||
-webkit-gradient(
|
||||
linear,
|
||||
left top,
|
||||
left bottom,
|
||||
color-stop(0.0, rgba(255, 255, 255, 1.0)),
|
||||
color-stop(1.0, rgba(249, 249, 249, 1.0))
|
||||
);
|
||||
background-image:
|
||||
-webkit-linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f9f9f9 100%);
|
||||
background-image:
|
||||
linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f9f9f9 100%);
|
||||
}
|
||||
|
||||
.ctools-dropbutton-processed.open {
|
||||
-moz-box-shadow: 1px 1px 2px rgba(0,0,0,0.25);
|
||||
-webkit-box-shadow: 1px 1px 2px rgba(0,0,0,0.25);
|
||||
box-shadow: 1px 1px 2px rgba(0,0,0,0.25);
|
||||
}
|
||||
|
||||
.ctools-twisty {
|
||||
top: 0.6667em;
|
||||
}
|
||||
|
||||
.ctools-dropbutton-processed.open .ctools-twisty {
|
||||
top: 0.3333em;
|
||||
}
|
||||
|
||||
.ctools-dropbutton-processed li a,
|
||||
.views-ui-display-tab-actions .ctools-dropbutton-processed input {
|
||||
padding-right: 7px;
|
||||
}
|
||||
|
||||
.views-ui-display-tab-actions .ctools-button-processed input.form-submit {
|
||||
margin-right: 0;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Collapsible */
|
||||
|
||||
.ctools-toggle {
|
||||
margin-top: 0.9em;
|
||||
}
|
||||
|
||||
.ctools-toggle.ctools-toggle-collapsed {
|
||||
margin-top: 0.72em;
|
||||
}
|
||||
|
||||
.views-display-column > .ctools-toggle {
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
.views-display-column > .ctools-toggle.ctools-toggle-collapsed {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.views-ui-display-tab-actions .ctools-button input {
|
||||
color: #0071B3;
|
||||
}
|
||||
|
||||
.views-ui-display-tab-actions .ctools-button input:hover,
|
||||
.views-ui-display-tab-actions .ctools-button input:focus {
|
||||
color: #018FE2;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @end */
|
@ -0,0 +1,63 @@
|
||||
/**
|
||||
* The .contextual.css file is intended to contain styles that override declarations
|
||||
* in the Contextual module.
|
||||
*/
|
||||
|
||||
/* @group Wrapper */
|
||||
|
||||
#views-live-preview .contextual-links-region-active {
|
||||
outline: medium none;
|
||||
}
|
||||
|
||||
#views-live-preview div.contextual-links-wrapper {
|
||||
right: auto;
|
||||
top: auto;
|
||||
}
|
||||
|
||||
html.js #views-live-preview div.contextual-links-wrapper {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Trigger */
|
||||
|
||||
#views-live-preview a.contextual-links-trigger {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group List */
|
||||
|
||||
div.contextual-links-wrapper ul.contextual-links {
|
||||
-moz-border-radius: 0 4px 4px 4px;
|
||||
-webkit-border-radius: 0 4px 4px 4px;
|
||||
border-radius: 0 4px 4px 4px;
|
||||
min-width: 10em;
|
||||
padding: 6px 6px 9px 6px;
|
||||
right: auto;
|
||||
}
|
||||
|
||||
ul.contextual-links li a,
|
||||
ul.contextual-links li span {
|
||||
padding-bottom: 0.25em;
|
||||
padding-right: 0.1667em;
|
||||
padding-top: 0.25em;
|
||||
}
|
||||
|
||||
ul.contextual-links li span {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
ul.contextual-links li a {
|
||||
color: #666666 !important;
|
||||
margin: 0.25em 0;
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
ul.contextual-links li a:hover {
|
||||
background-color: #badbec;
|
||||
}
|
||||
|
||||
/* @end */
|
361
sites/all/modules/contrib/views/views/css/views-admin.css
Normal file
361
sites/all/modules/contrib/views/views/css/views-admin.css
Normal file
@ -0,0 +1,361 @@
|
||||
/**
|
||||
* The .css file is intended to only contain positioning and size declarations
|
||||
* For example: display, position, float, clear, and overflow.
|
||||
*/
|
||||
|
||||
/* @group Resets */
|
||||
|
||||
.views-admin ul,
|
||||
.views-admin menu,
|
||||
.views-admin dir {
|
||||
padding-left: 0; /* LTR for IE */
|
||||
/* padding-start is used so that RTL works out of the box */
|
||||
-moz-padding-start: 0;
|
||||
-webkit-padding-start: 0;
|
||||
padding-start: 0;
|
||||
}
|
||||
|
||||
.views-admin pre {
|
||||
margin-bottom: 0;
|
||||
margin-top: 0;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Inline lists */
|
||||
|
||||
.horizontal > * {
|
||||
clear: none;
|
||||
float: left; /* LTR */
|
||||
}
|
||||
|
||||
.horizontal.right {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.horizontal label {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.horizontal .form-item > [class] {
|
||||
margin-top: 25px;
|
||||
}
|
||||
|
||||
.horizontal .form-item > [class] + [class] {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Columns */
|
||||
|
||||
.views-left-25 {
|
||||
float: left;
|
||||
width: 25%;
|
||||
}
|
||||
|
||||
.views-left-30 {
|
||||
float: left;
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
.views-left-40 {
|
||||
float: left;
|
||||
width: 40%;
|
||||
}
|
||||
|
||||
.views-left-50 {
|
||||
float: left;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.views-left-75 {
|
||||
float: left;
|
||||
width: 75%;
|
||||
}
|
||||
|
||||
.views-right-50 {
|
||||
float: right;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.views-right-60 {
|
||||
float: right;
|
||||
width: 60%;
|
||||
}
|
||||
|
||||
.views-right-70 {
|
||||
float: right;
|
||||
width: 70%;
|
||||
}
|
||||
|
||||
.views-group-box .form-item {
|
||||
margin-left: 3px;
|
||||
margin-right: 3px;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Attachment details
|
||||
*
|
||||
* The attachment details section, its tabs for each section and the buttons
|
||||
* to add a new section
|
||||
*/
|
||||
|
||||
.form-edit .form-actions {
|
||||
float: right; /* LTR */
|
||||
}
|
||||
|
||||
.views-displays {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Attachment details tabs
|
||||
*
|
||||
* The tabs that switch between sections
|
||||
*/
|
||||
.views-displays .secondary {
|
||||
border-bottom: 0 none;
|
||||
margin: 0;
|
||||
overflow: visible;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.views-displays .secondary > li {
|
||||
border-right: 0 none;
|
||||
display: inline-block;
|
||||
float: left; /* LTR */
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.views-displays .secondary .open > a {
|
||||
position: relative;
|
||||
z-index: 51;
|
||||
}
|
||||
|
||||
.views-displays .views-display-deleted-link {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.views-display-deleted > fieldset > legend,
|
||||
.views-display-deleted .fieldset-wrapper > .views-ui-display-tab-bucket > *,
|
||||
.views-display-deleted .views-display-columns {
|
||||
opacity: 0.25;
|
||||
}
|
||||
|
||||
.views-display-disabled > fieldset > legend,
|
||||
.views-display-disabled .fieldset-wrapper > .views-ui-display-tab-bucket > *,
|
||||
.views-display-disabled .views-display-columns {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.views-display-tab .fieldset-wrapper > .views-ui-display-tab-bucket .actions {
|
||||
opacity: 1.0;
|
||||
}
|
||||
/* @end */
|
||||
|
||||
/* @group Attachment details new section button */
|
||||
|
||||
.views-displays .secondary li.add {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.views-displays .secondary .action-list {
|
||||
left: 0; /* LTR */
|
||||
margin: 0;
|
||||
position: absolute;
|
||||
top: 23px;
|
||||
z-index: 50;
|
||||
}
|
||||
|
||||
.views-displays .secondary .action-list li {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Attachment details collapsible fieldset */
|
||||
|
||||
.views-display-tab .fieldset-legend {
|
||||
left: -5px; /* LTR */
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.views-display-tab .fieldset-wrapper {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Attachment details actions
|
||||
*
|
||||
* Display the "Delete" and "Duplicate" buttons to the right.
|
||||
*/
|
||||
.views-display-tab .fieldset-wrapper > .views-ui-display-tab-bucket .actions {
|
||||
position: absolute;
|
||||
right: 0; /* LTR */
|
||||
top: -5px;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Attachment configuration columns */
|
||||
|
||||
.views-display-columns > * {
|
||||
float: left; /* LTR */
|
||||
margin-left: 1%; /* LTR */
|
||||
padding-left: 1%; /* LTR */
|
||||
width: 32%;
|
||||
}
|
||||
|
||||
.views-display-columns > *:first-child {
|
||||
margin-left: 0; /* LTR */
|
||||
padding-left: 0; /* LTR */
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Modal dialog box */
|
||||
|
||||
.views-ui-dialog {
|
||||
/* We need this so the button is visible. */
|
||||
overflow: visible;
|
||||
position: fixed;
|
||||
}
|
||||
|
||||
.views-ui-dialog .ui-dialog-titlebar-close {
|
||||
border: 1px solid transparent;
|
||||
display: block;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 2px;
|
||||
/* Make sure this is in front of the modal backdrop. */
|
||||
z-index: 1002;
|
||||
}
|
||||
|
||||
.views-ui-dialog .ui-dialog-titlebar {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.views-ui-dialog .ui-dialog-title {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.views-ui-dialog #views-ajax-popup {
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.views-ui-dialog #views-ajax-title,
|
||||
.views-ui-dialog #views-ajax-body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.views-ui-dialog #views-ajax-popup {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.views-ui-dialog .scroll {
|
||||
max-height: 400px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
#views-filterable-options-controls {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.views-ui-dialog #views-filterable-options-controls {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* Don't let the messages overwhelm the modal */
|
||||
.views-ui-dialog .views-messages {
|
||||
max-height: 200px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Settings forms */
|
||||
|
||||
.views-display-setting .label,
|
||||
.views-display-setting .views-ajax-link {
|
||||
display: inline-block;
|
||||
float: left; /* LTR */
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Filter Settings form */
|
||||
|
||||
div.form-item-options-value-all {
|
||||
display: none;
|
||||
}
|
||||
/* @end */
|
||||
|
||||
/* @group Drupal overrides */
|
||||
|
||||
/* The .progress-disabled class added to the form on submit floats the element
|
||||
* left and causes the form width to shrink-wrap to the content. Setting the
|
||||
* width to 100% prevents this.
|
||||
*/
|
||||
#views-ajax-body form {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
|
||||
|
||||
/* @group Javascript dependent styling */
|
||||
|
||||
.js-only {
|
||||
display: none;
|
||||
}
|
||||
|
||||
html.js .js-only {
|
||||
display: inherit;
|
||||
}
|
||||
|
||||
html.js span.js-only {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group AJAX throbber */
|
||||
|
||||
/* Base Page */
|
||||
#views-ui-list-page .ajax-progress-throbber,
|
||||
.views-admin .ajax-progress-throbber {
|
||||
/* Can't do center:50% middle: 50%, so approximate it for a typical window size. */
|
||||
left: 49%;
|
||||
position: fixed;
|
||||
top: 48.5%;
|
||||
z-index: 1000;
|
||||
}
|
||||
#views-ui-list-page .ajax-progress-throbber .message,
|
||||
.views-admin .ajax-progress-throbber .message {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Modal */
|
||||
#views-ajax-popup .ajax-progress-throbber {
|
||||
/* Can't do center:50% middle: 50%, so approximate it for a typical window size. */
|
||||
left: 49%;
|
||||
position: fixed;
|
||||
top: 48.5%;
|
||||
z-index: 1000;
|
||||
}
|
||||
#views-ajax-popup .ajax-progress-throbber .message {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* @end */
|
@ -0,0 +1,82 @@
|
||||
/* @group Buttons */
|
||||
|
||||
.ctools-dropbutton .ctools-content {
|
||||
border-left: 1px solid #e8e8e8;
|
||||
}
|
||||
|
||||
.ctools-content ul.actions {
|
||||
padding-left: auto;
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
.ctools-dropbutton .ctools-link {
|
||||
border-right: 1px solid #ffffff;
|
||||
}
|
||||
|
||||
.ctools-dropbutton li {
|
||||
padding-left: 9px;
|
||||
padding-left: auto;
|
||||
}
|
||||
|
||||
.views-display-top .ctools-button {
|
||||
left: 12px;
|
||||
right: auto;
|
||||
}
|
||||
|
||||
.views-ui-display-tab-bucket .ctools-button {
|
||||
left: 5px;
|
||||
right: auto;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Collapsible */
|
||||
|
||||
.ctools-toggle {
|
||||
float: right;
|
||||
margin-left: 2px;
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.ctools-toggle.ctools-toggle-collapsed {
|
||||
border-left: 0;
|
||||
border-right: 4px solid;
|
||||
border-left-color: transparent;
|
||||
border-width: 5px 5px 5px 0;
|
||||
margin-left: 5px;
|
||||
margin-right: 2px;
|
||||
}
|
||||
|
||||
.ctools-export-ui-row label {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.views-display-column > .ctools-toggle {
|
||||
margin-left: 3px;
|
||||
margin-right: 6px;
|
||||
}
|
||||
.views-display-column > .ctools-toggle.ctools-toggle-collapsed {
|
||||
margin-left: 5px;
|
||||
margin-right: 9px;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Dependent */
|
||||
|
||||
.dependent-options {
|
||||
margin-left: 0;
|
||||
margin-right: 18px;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Export */
|
||||
|
||||
/* Override for filter button on the views list screen */
|
||||
#ctools-export-ui-list-form .form-submit {
|
||||
margin-left: 0em;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
/* @end */
|
232
sites/all/modules/contrib/views/views/css/views-admin.ctools.css
Normal file
232
sites/all/modules/contrib/views/views/css/views-admin.ctools.css
Normal file
@ -0,0 +1,232 @@
|
||||
/* @group Buttons */
|
||||
|
||||
.ctools-button-processed {
|
||||
background-color: #ffffff;
|
||||
border-color: #cccccc;
|
||||
font-size: 11px;
|
||||
padding-bottom: 2px;
|
||||
padding-top: 2px;
|
||||
}
|
||||
|
||||
.ctools-button-processed:hover {
|
||||
border-color: #b8b8b8;
|
||||
}
|
||||
|
||||
.ctools-button-processed:active {
|
||||
border-color: #a0a0a0;
|
||||
}
|
||||
|
||||
.ctools-button-processed .ctools-content {
|
||||
padding-bottom: 0;
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.ctools-dropbutton-processed {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.ctools-dropbutton-processed .ctools-content {
|
||||
border-right: 1px solid #e8e8e8;
|
||||
}
|
||||
|
||||
.ctools-dropbutton-processed .ctools-content ul {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.ctools-content ul.actions {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.ctools-button-processed .ctools-content a {
|
||||
background-image: none;
|
||||
border: medium none;
|
||||
}
|
||||
|
||||
.ctools-dropbutton-processed.open:hover {
|
||||
border-color: #D0D0D0;
|
||||
}
|
||||
|
||||
.ctools-dropbutton-processed.open {
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.ctools-dropbutton-processed .ctools-link {
|
||||
border-left: 1px solid #ffffff;
|
||||
}
|
||||
|
||||
.ctools-dropbutton-processed.open .ctools-content {
|
||||
padding-bottom: 4px;
|
||||
}
|
||||
|
||||
.ctools-dropbutton-processed li a,
|
||||
.ctools-dropbutton-processed li input {
|
||||
padding-right: 9px;
|
||||
}
|
||||
|
||||
.ctools-dropbutton-processed.open li + li {
|
||||
border-top: 1px solid #efefef;
|
||||
margin-top: 4px;
|
||||
padding-bottom: 0;
|
||||
padding-top: 4px;
|
||||
}
|
||||
|
||||
.ctools-twisty:focus {
|
||||
outline: medium none;
|
||||
}
|
||||
|
||||
.ctools-no-js .ctools-content ul {
|
||||
margin-bottom: 0;
|
||||
margin-top: 0;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.views-display-top .ctools-button-processed {
|
||||
font-size: 12px;
|
||||
position: absolute;
|
||||
right: 12px;
|
||||
top: 7px;
|
||||
}
|
||||
|
||||
.views-ui-display-tab-bucket .ctools-button-processed {
|
||||
position: absolute;
|
||||
right: 5px;
|
||||
top: 4px;
|
||||
}
|
||||
|
||||
.views-ui-display-tab-actions .ctools-button-processed li a,
|
||||
.views-ui-display-tab-actions .ctools-button-processed input {
|
||||
background: none;
|
||||
border: medium;
|
||||
font-family: inherit;
|
||||
font-size: 12px;
|
||||
padding-bottom: 0;
|
||||
padding-left: 12px;
|
||||
padding-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.views-ui-display-tab-actions .ctools-button-processed input:hover {
|
||||
background: none;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Collapsible */
|
||||
|
||||
.ctools-toggle {
|
||||
border-bottom-color: transparent;
|
||||
border-left-color: transparent;
|
||||
border-right-color: transparent;
|
||||
border-style: solid;
|
||||
border-width: 5px 5px 0;
|
||||
display: inline-block;
|
||||
float: left;
|
||||
height: 0;
|
||||
margin-right: 2px;
|
||||
margin-top: 0.4545em;
|
||||
width: 0;
|
||||
}
|
||||
|
||||
.ctools-toggle.ctools-toggle-collapsed {
|
||||
border-bottom-color: transparent;
|
||||
border-left: 4px solid;
|
||||
border-right-color: transparent;
|
||||
border-top-color: transparent;
|
||||
border-width: 5px 0 5px 5px;
|
||||
margin-left: 2px;
|
||||
margin-right: 5px;
|
||||
margin-top: 0.3333em;
|
||||
}
|
||||
|
||||
.ctools-toggle:hover,
|
||||
.ctools-collapsible-handle:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.ctools-export-ui-row {
|
||||
margin-bottom: 0;
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.ctools-export-ui-row label {
|
||||
display: block;
|
||||
float: left;
|
||||
width: 55px;
|
||||
}
|
||||
|
||||
.views-display-settings .ctools-toggle {
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.views-display-column > .ctools-toggle {
|
||||
margin-left: 6px;
|
||||
margin-right: 3px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.views-display-column > .ctools-toggle.ctools-toggle-collapsed {
|
||||
margin-left: 9px;
|
||||
margin-right: 5px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.views-display-column > .ctools-collapsible-handle {
|
||||
border-color: #F3F3F3;
|
||||
border-style: solid;
|
||||
border-width: 1px 1px 0;
|
||||
font-size: 13px;
|
||||
font-weight: normal;
|
||||
margin: 0;
|
||||
padding: 6px 3px;
|
||||
}
|
||||
|
||||
.views-display-column > .ctools-toggle.ctools-toggle-collapsed + .ctools-collapsible-handle {
|
||||
border-width: 1px;
|
||||
}
|
||||
|
||||
.views-display-column > .ctools-collapsible-content > .views-ui-display-tab-bucket:first-child {
|
||||
border-top: medium none;
|
||||
}
|
||||
|
||||
h2.ctools-collapsible-handle {
|
||||
display: inline;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Dependent */
|
||||
|
||||
.dependent-options {
|
||||
margin-left: 18px; /* LTR */
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Export */
|
||||
|
||||
/* Override for filter button on the views list screen */
|
||||
#ctools-export-ui-list-form .form-submit {
|
||||
margin-top: 0em !important;
|
||||
margin-right: 0em;
|
||||
}
|
||||
|
||||
.ctools-export-ui-row + .ctools-export-ui-row {
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
.ctools-export-ui-fourth-row input {
|
||||
margin-top: 5px !important;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Jump list */
|
||||
|
||||
#views-live-preview .ctools-jump-menu-select{
|
||||
max-width: 450px;
|
||||
}
|
||||
|
||||
/* @end */
|
@ -0,0 +1,13 @@
|
||||
/**
|
||||
* The .garland.css file is intended to contain styles that override declarations
|
||||
* in the Garland theme.
|
||||
*/
|
||||
|
||||
/* @group Lists */
|
||||
|
||||
.views-displays .secondary .action-list {
|
||||
left: auto;
|
||||
right: 1px;
|
||||
}
|
||||
|
||||
/* @end */
|
@ -0,0 +1,263 @@
|
||||
/**
|
||||
* The .garland.css file is intended to contain styles that override declarations
|
||||
* in the Garland theme.
|
||||
*/
|
||||
|
||||
/* @group Attachment details tabs
|
||||
*
|
||||
* The tabs that switch between sections
|
||||
*/
|
||||
|
||||
.views-displays .region-content .secondary,
|
||||
.views-displays .region-content .secondary {
|
||||
padding-bottom: 0;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.views-displays .secondary .action-list {
|
||||
left: 1px;
|
||||
top: 20px;
|
||||
}
|
||||
|
||||
.views-displays .secondary .action-list li,
|
||||
.views-displays .secondary a {
|
||||
border-color: #e9e9e9;
|
||||
}
|
||||
|
||||
.views-displays .secondary a {
|
||||
font-size: 12px;
|
||||
padding: 2px 7px;
|
||||
}
|
||||
|
||||
.views-displays ul.secondary li a:hover,
|
||||
.views-displays ul.secondary li.active a {
|
||||
border: 1px solid transparent;
|
||||
padding: 2px 7px;
|
||||
}
|
||||
|
||||
.views-displays .secondary > li a {
|
||||
-moz-border-radius: 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.views-displays .secondary > li.open a {
|
||||
background-image: none;
|
||||
-moz-border-radius: 5px 5px 0 0;
|
||||
-webkit-border-bottom-left-radius: 0;
|
||||
-webkit-border-bottom-right-radius: 0;
|
||||
-webkit-border-top-left-radius: 5px;
|
||||
-webkit-border-top-right-radius: 5px;
|
||||
border-radius: 5px 5px 0 0;
|
||||
}
|
||||
|
||||
.views-displays .secondary .open > a:hover {
|
||||
border-color: #e9e9e9 #e9e9e9 #f1f1f1 #e9e9e9;
|
||||
border-width: 1px 1px 1px 1px;
|
||||
color: #0071B3;
|
||||
}
|
||||
|
||||
.views-displays .secondary input.form-submit {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Attachment buckets
|
||||
*
|
||||
* These are the individual "buckets," or boxes, inside the display settings area
|
||||
*/
|
||||
|
||||
.views-ui-display-tab-bucket h3 {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Modal dialog box
|
||||
*
|
||||
* The contents of the popup dialog on the views edit form.
|
||||
*/
|
||||
|
||||
.views-filterable-options .form-type-checkbox {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.views-filterable-options .even .form-type-checkbox {
|
||||
background-color: #F9F9F9;
|
||||
}
|
||||
|
||||
.views-ui-dialog .ui-dialog-titlebar-close,
|
||||
.views-ui-dialog #views-ajax-title,
|
||||
.views-ui-dialog .views-override,
|
||||
.views-ui-dialog .form-buttons {
|
||||
background-color: #f6f6f6;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group CTools */
|
||||
|
||||
/* @group Buttons */
|
||||
|
||||
.ctools-button-processed {
|
||||
background-image:
|
||||
-moz-linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f9f9f9 100%);
|
||||
background-image:
|
||||
-webkit-gradient(
|
||||
linear,
|
||||
left top,
|
||||
left bottom,
|
||||
color-stop(0.0, rgba(255, 255, 255, 1.0)),
|
||||
color-stop(1.0, rgba(249, 249, 249, 1.0))
|
||||
);
|
||||
background-image:
|
||||
-webkit-linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f9f9f9 100%);
|
||||
background-image:
|
||||
linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f9f9f9 100%);
|
||||
-moz-border-radius: 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
padding-bottom: 1px;
|
||||
padding-top: 1px;
|
||||
}
|
||||
|
||||
.ctools-button-processed:hover {
|
||||
background-image:
|
||||
-moz-linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f1f1f1 100%);
|
||||
background-image:
|
||||
-webkit-gradient(
|
||||
linear,
|
||||
left top,
|
||||
left bottom,
|
||||
color-stop(0.0, rgba(255, 255, 255, 1.0)),
|
||||
color-stop(1.0, rgba(241, 241, 241, 1.0))
|
||||
);
|
||||
background-image:
|
||||
-webkit-linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f1f1f1 100%);
|
||||
background-image:
|
||||
linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f1f1f1 100%);
|
||||
}
|
||||
|
||||
.ctools-button-processed ol li,
|
||||
.ctools-button-processed ul li {
|
||||
margin: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.views-ui-display-tab-actions .ctools-button-processed input {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.ctools-content ul.actions {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.ctools-dropbutton-processed.open:hover {
|
||||
background-image:
|
||||
-moz-linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f9f9f9 100%);
|
||||
background-image:
|
||||
-webkit-gradient(
|
||||
linear,
|
||||
left top,
|
||||
left bottom,
|
||||
color-stop(0.0, rgba(255, 255, 255, 1.0)),
|
||||
color-stop(1.0, rgba(249, 249, 249, 1.0))
|
||||
);
|
||||
background-image:
|
||||
-webkit-linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f9f9f9 100%);
|
||||
background-image:
|
||||
linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f9f9f9 100%);
|
||||
}
|
||||
|
||||
.ctools-dropbutton-processed.open {
|
||||
-moz-box-shadow: 1px 1px 2px rgba(0,0,0,0.25);
|
||||
-webkit-box-shadow: 1px 1px 2px rgba(0,0,0,0.25);
|
||||
box-shadow: 1px 1px 2px rgba(0,0,0,0.25);
|
||||
}
|
||||
|
||||
.ctools-twisty {
|
||||
top: 0.6667em;
|
||||
}
|
||||
|
||||
.ctools-dropbutton-processed.open .ctools-twisty {
|
||||
top: 0.3333em;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Dependent */
|
||||
|
||||
.dependent-options,
|
||||
.form-checkboxes.dependent-options,
|
||||
.form-radios.dependent-options,
|
||||
.form-checkboxes .form-item.dependent-options,
|
||||
.form-radios .form-item.dependent-options {
|
||||
margin-left: 25px;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Collapsible */
|
||||
|
||||
.ctools-toggle {
|
||||
margin-top: 0.5em;
|
||||
}
|
||||
|
||||
.ctools-toggle,
|
||||
.views-display-settings .ctools-toggle {
|
||||
color: #494949;
|
||||
}
|
||||
|
||||
.ctools-toggle.ctools-toggle-collapsed {
|
||||
margin-top: 0.25em;
|
||||
}
|
||||
|
||||
.views-display-column > .ctools-toggle {
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
.views-display-column > .ctools-toggle.ctools-toggle-collapsed {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.views-ui-display-tab-actions .ctools-button input {
|
||||
color: #027AC6;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.views-ui-display-tab-actions .ctools-button input:hover,
|
||||
.views-ui-display-tab-actions .ctools-button input:focus {
|
||||
color: #0062A0;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @end */
|
@ -0,0 +1,43 @@
|
||||
/**
|
||||
* The .seven.css file is intended to contain styles that override declarations
|
||||
* in the Seven admin theme.
|
||||
*/
|
||||
|
||||
/* @group Forms */
|
||||
|
||||
.views-admin .form-submit,
|
||||
.views-admin a.button {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Lists */
|
||||
|
||||
.views-admin .links li {
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Attachments */
|
||||
|
||||
.views-displays .secondary {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Attachment details tabs */
|
||||
|
||||
.views-display-top ul.secondary {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.views-displays .secondary .action-list li:first-child {
|
||||
-moz-border-radius: 7px 0 0 0;
|
||||
-webkit-border-radius: 7px 0 0 0;
|
||||
border-radius: 7px 0 0 0;
|
||||
}
|
||||
|
||||
/* @end */
|
552
sites/all/modules/contrib/views/views/css/views-admin.seven.css
Normal file
552
sites/all/modules/contrib/views/views/css/views-admin.seven.css
Normal file
@ -0,0 +1,552 @@
|
||||
/**
|
||||
* The .seven.css file is intended to contain styles that override declarations
|
||||
* in the Seven admin theme.
|
||||
*/
|
||||
|
||||
/* @group Content */
|
||||
|
||||
.views-ui-display-tab-bucket h1,
|
||||
.views-ui-display-tab-bucket h2,
|
||||
.views-ui-display-tab-bucket h3,
|
||||
.views-ui-display-tab-bucket h4,
|
||||
.views-ui-display-tab-bucket h5 {
|
||||
margin-bottom: 0;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Forms */
|
||||
|
||||
.views-ui-dialog fieldset {
|
||||
padding-top: 2.5em;
|
||||
}
|
||||
|
||||
fieldset fieldset {
|
||||
border: medium none;
|
||||
}
|
||||
|
||||
/**
|
||||
* Seven positions the legend absolutely, but does not have a way to ignore
|
||||
* fieldsets without a legend so we make one up.
|
||||
*/
|
||||
fieldset.fieldset-no-legend {
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Being extra safe here and scoping this to the add view wizard form (where
|
||||
* a layout problem occurs for the Display format fieldset if we don't fix its
|
||||
* padding), but it's probably safe to just let it apply everywhere.
|
||||
*/
|
||||
#views-ui-add-form fieldset fieldset .fieldset-wrapper {
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
.views-display-tab fieldset {
|
||||
padding: 0 12px;
|
||||
}
|
||||
|
||||
.views-display-tab .fieldset-wrapper {
|
||||
padding: 10px 12px 12px;
|
||||
}
|
||||
|
||||
.views-display-tab fieldset.box-padding .fieldset-wrapper {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.views-display-tab legend + .fieldset-wrapper {
|
||||
padding-top: 2.5em;
|
||||
}
|
||||
|
||||
.views-admin .form-item label.option,
|
||||
#views-ui-preview-form .form-item label.option {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
#views-ui-preview-form .form-submit {
|
||||
margin-top: 3px;
|
||||
}
|
||||
|
||||
.views-admin input.form-submit,
|
||||
.views-ui-dialog input.form-submit,
|
||||
.views-admin a.button,
|
||||
.views-ui-dialog a.button {
|
||||
margin-bottom: 0;
|
||||
margin-right: 0; /* LTR */
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
/* Override for a button on the edit display screen */
|
||||
#edit-displays-preview-controls .form-submit {
|
||||
display: inline-block;
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
/* Override for filter button on the views list screen */
|
||||
#ctools-export-ui-list-form .form-submit {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
#ctools-export-ui-list-form .ctools-export-ui-first-row .form-item {
|
||||
margin-top: 3px;
|
||||
margin-right: 5px; /* LTR */
|
||||
}
|
||||
|
||||
.form-item,
|
||||
.form-item .form-item {
|
||||
margin-bottom: 0;
|
||||
margin-top: 9px;
|
||||
padding-bottom: 0;
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.form-actions {
|
||||
margin-bottom: 0;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.form-item .form-item {
|
||||
padding-bottom: 0;
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.form-radios > .form-item {
|
||||
margin-top: 3px;
|
||||
}
|
||||
|
||||
/* @group Dependent options
|
||||
*
|
||||
* Dependent options are identified in CTools dependent.js
|
||||
*/
|
||||
|
||||
/* The .dependent-options.form-item is necessary to supercede the Seven .form-item
|
||||
* reset declaration that sets the margin to zero.
|
||||
*/
|
||||
.dependent-options,
|
||||
.dependent-options.form-item,
|
||||
.form-item-options-expose-required,
|
||||
.form-item-options-expose-label,
|
||||
.form-item-options-expose-description {
|
||||
margin-left: 1.5em;
|
||||
}
|
||||
|
||||
.views-admin-dependent .form-item .form-item,
|
||||
.views-admin-dependent .form-type-checkboxes,
|
||||
.views-admin-dependent .form-type-radios,
|
||||
.views-admin-dependent .dependent-options,
|
||||
.views-admin-dependent .form-item .form-item,
|
||||
.views-admin-dependent .dependent-options .form-type-select,
|
||||
.views-admin-dependent .dependent-options .form-type-textfield,
|
||||
.form-item-options-expose-required,
|
||||
.form-item-options-expose-label,
|
||||
.form-item-options-expose-description {
|
||||
margin-bottom: 6px;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
.views-admin-dependent .form-type-radio,
|
||||
.views-admin-dependent .form-radios .form-item {
|
||||
margin-bottom: 2px;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Lists */
|
||||
|
||||
.views-admin ul.secondary,
|
||||
.views-admin .item-list ul {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.views-admin ul.secondary {
|
||||
clear: none;
|
||||
}
|
||||
|
||||
.views-displays ul.secondary li a,
|
||||
.views-displays ul.secondary li.active a,
|
||||
.views-displays ul.secondary li.active a.active {
|
||||
padding: 2px 7px 3px;
|
||||
}
|
||||
|
||||
.views-displays ul.secondary li.active a,
|
||||
.views-displays ul.secondary li.active a.active {
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
|
||||
.views-admin .links li {
|
||||
padding-right: 0; /* LTR */
|
||||
}
|
||||
|
||||
.views-admin .button .links li {
|
||||
padding-right: 12px; /* LTR */
|
||||
}
|
||||
|
||||
.page-admin-structure-views #content ul.action-links {
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
.views-display-top ul.secondary {
|
||||
background-color: transparent;
|
||||
float: left
|
||||
}
|
||||
|
||||
.views-display-top .secondary .action-list li {
|
||||
float: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Buttons */
|
||||
|
||||
.ctools-button-processed ul {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* Override for input elements that are themed like ctools-buttons */
|
||||
.ctools-button-processed input.form-submit:hover {
|
||||
background-image: none;
|
||||
color: #0074BD;
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
.ctools-button-processed input.form-submit:active {
|
||||
background: none;
|
||||
border: medium none;
|
||||
color: #0074BD;
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Tables */
|
||||
|
||||
table td,
|
||||
table th {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Attachment details */
|
||||
|
||||
#edit-display-settings-title {
|
||||
color: #008BCB;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Attachment details tabs
|
||||
*
|
||||
* The tabs that switch between sections
|
||||
*/
|
||||
|
||||
.views-displays .secondary {
|
||||
text-align: left; /* LTR */
|
||||
}
|
||||
|
||||
.views-displays .secondary > li:first-child {
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.views-admin .icon.add {
|
||||
background-position: center 3px;
|
||||
}
|
||||
|
||||
.views-displays .secondary a {
|
||||
background-color: #f1f1f1;
|
||||
-moz-border-radius: 7px;
|
||||
-webkit-border-radius: 7px;
|
||||
border-radius: 7px;
|
||||
color: #008BCB;
|
||||
}
|
||||
|
||||
.views-displays .secondary a:hover > .icon.add {
|
||||
background-position: center -25px;
|
||||
}
|
||||
|
||||
.views-displays .secondary .open > a {
|
||||
-moz-border-radius: 7px 7px 0 0;
|
||||
-webkit-border-radius: 7px 7px 0 0;
|
||||
border-radius: 7px 7px 0 0;
|
||||
}
|
||||
|
||||
.views-displays .secondary .open > a:hover {
|
||||
background-color: #f1f1f1;
|
||||
color: #008BCB;
|
||||
}
|
||||
|
||||
.views-displays .secondary .action-list li:first-child {
|
||||
-moz-border-radius: 0 7px 0 0;
|
||||
-webkit-border-radius: 0 7px 0 0;
|
||||
border-radius: 0 7px 0 0;
|
||||
}
|
||||
|
||||
.views-displays .secondary .action-list li:last-child {
|
||||
-moz-border-radius: 0 0 7px 7px;
|
||||
-webkit-border-radius: 0 0 7px 7px;
|
||||
border-radius: 0 0 7px 7px;
|
||||
}
|
||||
|
||||
.views-displays .secondary .action-list input.form-submit {
|
||||
-moz-border-radius: 0;
|
||||
-webkit-border-radius: 0;
|
||||
border-radius: 0;
|
||||
color: #008BCB;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Attachment buckets
|
||||
*
|
||||
* These are the individual "buckets," or boxes, inside the display settings area
|
||||
*/
|
||||
|
||||
.views-ui-display-tab-bucket h3 {
|
||||
font-size: 12px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.views-ui-display-tab-bucket .links {
|
||||
padding: 2px 6px 4px;
|
||||
}
|
||||
|
||||
.views-ui-display-tab-bucket .links li + li {
|
||||
margin-left: 3px;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Rearrange filter criteria */
|
||||
|
||||
#views-ui-rearrange-filter-form .action-links {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#views-ui-rearrange-filter-form table {
|
||||
border: medium none;
|
||||
}
|
||||
|
||||
#views-ui-rearrange-filter-form [id^="views-row"] {
|
||||
border: medium none;
|
||||
}
|
||||
|
||||
#views-ui-rearrange-filter-form tr td:last-child {
|
||||
border-right: medium none;
|
||||
}
|
||||
|
||||
#views-ui-rearrange-filter-form .filter-group-operator-row {
|
||||
border-left: 1px solid transparent !important;
|
||||
border-right: 1px solid transparent !important;
|
||||
}
|
||||
|
||||
#views-ui-rearrange-filter-form tr.drag td {
|
||||
background-color: #FFEE77 !important;
|
||||
}
|
||||
|
||||
#views-ui-rearrange-filter-form tr.drag-previous td {
|
||||
background-color: #FFFFBB !important;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Live preview elements */
|
||||
|
||||
.views-query-info pre {
|
||||
margin-bottom: 0;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
/* @group Query info table */
|
||||
|
||||
.views-query-info table {
|
||||
-moz-border-radius: 7px;
|
||||
-webkit-border-radius: 7px;
|
||||
border-radius: 7px;
|
||||
-webkit-border-horizontal-spacing: 1px;
|
||||
-webkit-border-vertical-spacing: 1px;
|
||||
}
|
||||
|
||||
.views-query-info table tr td:last-child {
|
||||
/* Fixes a Seven style that bleeds down into this table unnecessarily */
|
||||
border-right: 0 none;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Add view */
|
||||
|
||||
.form-item-page-create,
|
||||
.form-item-block-create {
|
||||
margin-top: 13px;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Modal dialog box
|
||||
*
|
||||
* The contents of the popup dialog on the views edit form.
|
||||
*/
|
||||
|
||||
.views-ui-dialog .ui-dialog-titlebar-close {
|
||||
-moz-box-shadow: none;
|
||||
-webkit-box-shadow: none;
|
||||
box-shadow: none;
|
||||
border-color: #cccccc;
|
||||
right: -27px;
|
||||
top: -1px;
|
||||
}
|
||||
|
||||
.views-ui-dialog fieldset.collapsible {
|
||||
padding-top: 1.5em;
|
||||
}
|
||||
|
||||
.views-ui-dialog fieldset.collapsed {
|
||||
padding-top: 2.5em;
|
||||
}
|
||||
|
||||
.filterable-option .form-item.form-type-checkbox {
|
||||
/* This selector is aggressive because Seven's reset for .form-items is aggressive. */
|
||||
padding-bottom: 4px;
|
||||
padding-left: 4px;
|
||||
padding-top: 4px;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group CTools */
|
||||
|
||||
/* @group Buttons */
|
||||
|
||||
.ctools-button-processed {
|
||||
background-image:
|
||||
-moz-linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f9f9f9 100%);
|
||||
background-image:
|
||||
-webkit-gradient(
|
||||
linear,
|
||||
left top,
|
||||
left bottom,
|
||||
color-stop(0.0, rgba(255, 255, 255, 1.0)),
|
||||
color-stop(1.0, rgba(249, 249, 249, 1.0))
|
||||
);
|
||||
background-image:
|
||||
-webkit-linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f9f9f9 100%);
|
||||
background-image:
|
||||
linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f9f9f9 100%);
|
||||
-moz-border-radius: 11px 11px 11px 11px;
|
||||
-webkit-border-radius: 11px 11px 11px 11px;
|
||||
border-radius: 11px 11px 11px 11px;
|
||||
}
|
||||
|
||||
.ctools-button-processed:hover {
|
||||
background-image:
|
||||
-moz-linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f1f1f1 100%);
|
||||
background-image:
|
||||
-webkit-gradient(
|
||||
linear,
|
||||
left top,
|
||||
left bottom,
|
||||
color-stop(0.0, rgba(255, 255, 255, 1.0)),
|
||||
color-stop(1.0, rgba(241, 241, 241, 1.0))
|
||||
);
|
||||
background-image:
|
||||
-webkit-linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f1f1f1 100%);
|
||||
background-image:
|
||||
linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f1f1f1 100%);
|
||||
}
|
||||
|
||||
.ctools-dropbutton-processed.open:hover {
|
||||
background-image:
|
||||
-moz-linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f9f9f9 100%);
|
||||
background-image:
|
||||
-webkit-gradient(
|
||||
linear,
|
||||
left top,
|
||||
left bottom,
|
||||
color-stop(0.0, rgba(255, 255, 255, 1.0)),
|
||||
color-stop(1.0, rgba(249, 249, 249, 1.0))
|
||||
);
|
||||
background-image:
|
||||
-webkit-linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f9f9f9 100%);
|
||||
background-image:
|
||||
linear-gradient(
|
||||
-90deg,
|
||||
#ffffff 0px,
|
||||
#f9f9f9 100%);
|
||||
}
|
||||
|
||||
.ctools-dropbutton-processed.open {
|
||||
-moz-box-shadow: 1px 1px 2px rgba(0,0,0,0.25);
|
||||
-webkit-box-shadow: 1px 1px 2px rgba(0,0,0,0.25);
|
||||
box-shadow: 1px 1px 2px rgba(0,0,0,0.25);
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Collapsible */
|
||||
|
||||
.ctools-toggle {
|
||||
margin-top: 0.6667em;
|
||||
}
|
||||
|
||||
.ctools-toggle.ctools-toggle-collapsed {
|
||||
margin-top: 0.5em;
|
||||
}
|
||||
|
||||
.views-display-settings .ctools-toggle {
|
||||
color: #008BCB;
|
||||
}
|
||||
|
||||
.views-display-column > .ctools-toggle {
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
.views-display-column > .ctools-toggle.ctools-toggle-collapsed {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.views-display-column > .ctools-collapsible-handle {
|
||||
color: #008BCB;
|
||||
}
|
||||
|
||||
.views-ui-display-tab-actions .ctools-button-processed input {
|
||||
color: #0074BD;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @end */
|
@ -0,0 +1,208 @@
|
||||
/**
|
||||
* The .theme.css file is intended to contain presentation declarations including
|
||||
* images, borders, colors, and fonts.
|
||||
*/
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Icons */
|
||||
|
||||
.actions a,
|
||||
.views-admin .icon,
|
||||
.views-admin .icon-text {
|
||||
background-position: right top;
|
||||
}
|
||||
|
||||
/* Targets any element with an icon -> text combo */
|
||||
.views-admin .icon-text {
|
||||
padding-right: 19px;
|
||||
}
|
||||
|
||||
.views-admin .icon-linked {
|
||||
background-position: right -153px;
|
||||
}
|
||||
|
||||
.views-admin .icon-unlinked {
|
||||
background-position: right -195px;
|
||||
}
|
||||
|
||||
.actions .views-button-add {
|
||||
background-position: right -39px;
|
||||
}
|
||||
|
||||
.actions .views-button-rearrange {
|
||||
background-position: right -96px;
|
||||
}
|
||||
|
||||
.actions .views-button-add:hover {
|
||||
background-position: right -58px;
|
||||
}
|
||||
|
||||
.actions .views-button-rearrange:hover {
|
||||
background-position: right -115px;
|
||||
}
|
||||
|
||||
.actions .views-button-add:active {
|
||||
background-position: right -77px;
|
||||
}
|
||||
|
||||
.actions .views-button-rearrange:active {
|
||||
background-position: right -134px;
|
||||
}
|
||||
|
||||
.views-displays .icon-add {
|
||||
background-position: right -3px;
|
||||
}
|
||||
|
||||
.views-displays .secondary a:hover > .icon-add {
|
||||
background-position: right -21px;
|
||||
}
|
||||
|
||||
.views-displays .secondary .open a:hover > .icon-add {
|
||||
background-position: right -3px;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Forms */
|
||||
|
||||
.form-submit + .form-submit,
|
||||
.views-admin a.button + a.button {
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
.container-inline > * + *,
|
||||
.container-inline .fieldset-wrapper > * + * {
|
||||
padding-left: 0;
|
||||
padding-right: 4pt;
|
||||
}
|
||||
|
||||
.views-admin .form-type-checkbox + .form-wrapper {
|
||||
margin-right: 16px;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Lists */
|
||||
|
||||
.horizontal > * + * {
|
||||
margin-right: 9px;
|
||||
padding-right: 9px;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Attachments */
|
||||
|
||||
.views-displays .secondary {
|
||||
padding: 6px 8px 8px;
|
||||
}
|
||||
|
||||
.views-displays .views-display-top > ul > li + li {
|
||||
margin-right: 3px;
|
||||
}
|
||||
|
||||
.views-displays .views-extra-actions {
|
||||
left: 10px;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Attachment details tabs
|
||||
*
|
||||
* The tabs that switch between sections
|
||||
*/
|
||||
|
||||
.views-displays .secondary .action-list li:first-child {
|
||||
-moz-border-radius: 7px 0 0 0;
|
||||
-webkit-border-top-left-radius: 7px;
|
||||
-webkit-border-top-right-radius: 0;
|
||||
border-radius: 7px 0 0 0;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Attachment details collapsible fieldset
|
||||
*
|
||||
* The attachment details section is a collapsible fieldset, but should not
|
||||
* have a border around it.
|
||||
*/
|
||||
|
||||
.views-display-tab .fieldset-legend {
|
||||
left: auto;
|
||||
right: -5px;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Auto preview
|
||||
*
|
||||
* The auto-preview checkbox line. This may have more stuff added to it.
|
||||
*/
|
||||
|
||||
div.form-item-displays-live-preview {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Attachment buckets
|
||||
*
|
||||
* These are the individual "buckets," or boxes, inside the three columns in the
|
||||
* attachment details section.
|
||||
*/
|
||||
|
||||
.views-ui-display-tab-bucket .icon-text {
|
||||
padding-right: 25px;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Attachment bucket rows
|
||||
*
|
||||
* This is each row within one of the "boxes."
|
||||
*/
|
||||
|
||||
.views-display-setting .label {
|
||||
margin-left: 3pt;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Modal dialog box
|
||||
*
|
||||
* The contents of the popup dialog on the views edit form.
|
||||
*/
|
||||
|
||||
#views-filterable-options-controls .form-item {
|
||||
margin-left: 2%;
|
||||
}
|
||||
|
||||
.views-ui-dialog #views-progress-indicator {
|
||||
left: 10px;
|
||||
right: auto;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Rearrange filters
|
||||
*
|
||||
* Styling for the form that allows views filters to be rearranged.
|
||||
*/
|
||||
.views-operator-label {
|
||||
padding-right: 0.5em;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Live preview elements */
|
||||
|
||||
/* @group HTML list */
|
||||
|
||||
#views-live-preview .view-content > .item-list > ul {
|
||||
padding-right: 21px;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @end */
|
1083
sites/all/modules/contrib/views/views/css/views-admin.theme.css
Normal file
1083
sites/all/modules/contrib/views/views/css/views-admin.theme.css
Normal file
File diff suppressed because it is too large
Load Diff
5
sites/all/modules/contrib/views/views/css/views-rtl.css
Normal file
5
sites/all/modules/contrib/views/views/css/views-rtl.css
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
.views-exposed-form .views-exposed-widget {
|
||||
float: right; /* RTL */
|
||||
padding: .5em 1em 0 0; /* RTL */
|
||||
}
|
42
sites/all/modules/contrib/views/views/css/views.css
Normal file
42
sites/all/modules/contrib/views/views/css/views.css
Normal file
@ -0,0 +1,42 @@
|
||||
.views-exposed-form .views-exposed-widget {
|
||||
float: left; /* LTR */
|
||||
padding: .5em 1em 0 0; /* LTR */
|
||||
}
|
||||
|
||||
.views-exposed-form .views-exposed-widget .form-submit {
|
||||
margin-top: 1.6em;
|
||||
}
|
||||
|
||||
.views-exposed-form .form-item,
|
||||
.views-exposed-form .form-submit {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.views-exposed-form label {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.views-exposed-widgets {
|
||||
margin-bottom: .5em;
|
||||
}
|
||||
|
||||
/* table style column align */
|
||||
.views-align-left {
|
||||
text-align: left;
|
||||
}
|
||||
.views-align-right {
|
||||
text-align: right;
|
||||
}
|
||||
.views-align-center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* Remove the border on tbody that system puts in */
|
||||
.views-view-grid tbody {
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
.view .progress-disabled {
|
||||
float: none;
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
- If the interface text is *bolded*, it got strong tags.
|
||||
- If it's a button they need to click, that's *bold* too.
|
||||
- If the text is not bolded (ex: links to click, options to check), it
|
||||
got /italicized/.
|
||||
- If it's user-entered text it got 'single quotes'.
|
496
sites/all/modules/contrib/views/views/drush/views.drush.inc
Normal file
496
sites/all/modules/contrib/views/views/drush/views.drush.inc
Normal file
@ -0,0 +1,496 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Drush integration of views.
|
||||
*
|
||||
* drush cache-clear views - Clears the views specific caches.
|
||||
* views-revert - Drush command to revert views overridden in the system.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implement hook_drush_help().
|
||||
*/
|
||||
function views_drush_help($section) {
|
||||
switch ($section) {
|
||||
case 'drush:views-revert':
|
||||
$help = dt('Reverts views in the drupal installation that have been overriden. ');
|
||||
$help .= dt('If no view names are specified, you will be presented with a list of overridden views to choose from. ');
|
||||
$help .= dt('To revert all views, do not specify any view names, and choose the option "All" from the options presented.');
|
||||
return $help;
|
||||
case 'drush:views-list':
|
||||
return dt('Show a list of available views with information about them.');
|
||||
case 'drush:views-enable':
|
||||
return dt('Enable the specified views. Follow the command with a space delimited list of view names');
|
||||
case 'drush:views-disable':
|
||||
return dt('Disable the specified views. Follow the command with a space delimited list of view names');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement hook_drush_command().
|
||||
*/
|
||||
function views_drush_command() {
|
||||
$items = array();
|
||||
|
||||
$items['views-revert'] = array(
|
||||
'callback' => 'views_revert_views',
|
||||
'drupal dependencies' => array('views'),
|
||||
'description' => 'Revert overridden views to their default state. Make sure to backup first.',
|
||||
'arguments' => array(
|
||||
'views' => 'A space delimited list of view names.',
|
||||
),
|
||||
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
|
||||
'aliases' => array('vr'),
|
||||
'examples' => array(
|
||||
'drush vr archive' => 'Reverts the "archive" view.',
|
||||
'drush rln archive frontpage' => 'Reverts the "archive" and "frontpage" view.',
|
||||
'drush vr' => 'Will present you with a list of overridden views to choose from, and an option to revert all overridden views.',
|
||||
),
|
||||
);
|
||||
$items['views-dev'] = array(
|
||||
'callback' => 'views_development_settings',
|
||||
'drupal dependencies' => array('views'),
|
||||
'description' => 'Set the Views settings to more developer-oriented values.',
|
||||
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
|
||||
'aliases' => array('vd'),
|
||||
);
|
||||
|
||||
$items['views-list'] = array(
|
||||
'drupal dependencies' => array('views'),
|
||||
'description' => 'Get a list of all views in the system.',
|
||||
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
|
||||
'aliases' => array('vl'),
|
||||
'options' => array(
|
||||
'name' => 'String contained in view\'s name by which filter the results.',
|
||||
'tags' => 'A comma-separated list of views tags by which to filter the results.',
|
||||
'status' => 'Status of the views by which to filter the results. Choices: enabled, disabled.',
|
||||
'type' => 'Type of the views by which to filter the results. Choices: normal, default or overridden.',
|
||||
),
|
||||
'examples' => array(
|
||||
'drush vl' => 'Show a list of all available views.',
|
||||
'drush vl --name=blog' => 'Show a list of views which names contain "blog".',
|
||||
'drush vl --tags=tag1,tag2' => 'Show a list of views tagged with "tag1" or "tag2".',
|
||||
'drush vl --status=enabled' => 'Show a list of enabled views.',
|
||||
'drush vl --type=overridden' => 'Show a list of overridden views.',
|
||||
),
|
||||
);
|
||||
$items['views-analyze'] = array(
|
||||
'drupal dependencies' => array('views', 'views_ui'),
|
||||
'description' => 'Get a list of all Views analyze warnings',
|
||||
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
|
||||
'aliases' => array('va'),
|
||||
);
|
||||
$items['views-enable'] = array(
|
||||
'drupal dependencies' => array('views'),
|
||||
'description' => 'Enable the specified views.',
|
||||
'arguments' => array(
|
||||
'views' => 'A space delimited list of view names.',
|
||||
),
|
||||
'aliases' => array('ven'),
|
||||
'examples' => array(
|
||||
'drush ven frontpage taxonomy_term' => 'Enable the frontpage and taxonomy_term views.',
|
||||
),
|
||||
);
|
||||
$items['views-disable'] = array(
|
||||
'drupal dependencies' => array('views'),
|
||||
'description' => 'Disable the specified views.',
|
||||
'arguments' => array(
|
||||
'views' => 'A space delimited list of view names.',
|
||||
),
|
||||
'aliases' => array('vdis'),
|
||||
'examples' => array(
|
||||
'drush vdis frontpage taxonomy_term' => 'Disable the frontpage and taxonomy_term views.',
|
||||
),
|
||||
);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback function for views-revert command.
|
||||
*/
|
||||
function views_revert_views() {
|
||||
$views = views_get_all_views();
|
||||
$i = 0;
|
||||
// The provided views names specified in the command.
|
||||
$viewnames = _convert_csv_to_array(func_get_args());
|
||||
|
||||
// Find all overridden views.
|
||||
foreach ($views as $view) {
|
||||
if ($view->disabled) {
|
||||
continue;
|
||||
}
|
||||
if ($view->type == dt('Overridden')) {
|
||||
$overridden[$view->name] = $view->name;
|
||||
}
|
||||
}
|
||||
|
||||
// Return early if there are no overridden views in the system.
|
||||
if (empty($overridden)) {
|
||||
return drush_set_error(dt('There are no overridden views in the system.'));
|
||||
}
|
||||
|
||||
// If the user specified in the command the views to be overridden.
|
||||
if (!empty($viewnames)) {
|
||||
foreach ($viewnames as $key => $viewname) {
|
||||
$is_overridden = key_exists($viewname, $overridden);
|
||||
// Check if the provided view name is in the system
|
||||
if ($viewname && !key_exists($viewname, $views)) {
|
||||
drush_set_error(dt("'@viewname' view is not present in the system.", array('@viewname' => $viewname)));
|
||||
}
|
||||
// Check if the provided view is overridden.
|
||||
elseif (!$is_overridden) {
|
||||
drush_set_error(dt("The view specified '@viewname' is not overridden.", array('@viewname' => $viewname)));
|
||||
}
|
||||
// If the view is overriden, revert it.
|
||||
elseif ($is_overridden){
|
||||
views_revert_view($views[$viewname]);
|
||||
$i++;
|
||||
}
|
||||
// We should never get here but well...
|
||||
else {
|
||||
drush_set_error(dt("The view specified '@viewname' is not provided in code, and thus cannot be reverted.", array('@viewname' => $viewname)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The user did not specify any views in the command, prompt the user
|
||||
else {
|
||||
// list of choices for the user
|
||||
$overridden['all'] = dt('Revert all overridden views'); // add a choice at the end
|
||||
$choice = drush_choice($overridden, 'Enter a number to choose which view to revert.', '!key'); // prompt the user
|
||||
|
||||
if ($choice !== FALSE) {
|
||||
// revert all views option
|
||||
if ($choice == 'all') {
|
||||
$i = views_revert_allviews($views);
|
||||
}
|
||||
// else the user specified a single view
|
||||
else {
|
||||
views_revert_view($views[$choice]);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// final results output
|
||||
if ($i == 0) {
|
||||
drush_log(dt('No views were reverted.'), 'ok');
|
||||
}
|
||||
else {
|
||||
drush_log(dt('Reverted a total of @count views.', array('@count' => $i)), 'ok');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverts all views
|
||||
* @param $views
|
||||
* All views in the system as provided by views_get_all_views().
|
||||
*/
|
||||
function views_revert_allviews($views) {
|
||||
$i = 0;
|
||||
foreach ($views as $view) {
|
||||
if ($view->disabled) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($view->type == t('Overridden')) {
|
||||
views_revert_view($view);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
return $i;
|
||||
}
|
||||
|
||||
/**
|
||||
* Revert a specified view
|
||||
* @param $view
|
||||
* The view object to be reverted
|
||||
*
|
||||
* Checks on wether or not the view is overridden is handled in views_revert_views_revert()
|
||||
* We perform a check here anyway in case someone somehow calls this function on their own...
|
||||
*/
|
||||
function views_revert_view($view) {
|
||||
// check anyway just in case
|
||||
if ($view->type == t('Overridden')) {
|
||||
// Revert the view.
|
||||
$view->delete();
|
||||
// Clear its cache.
|
||||
ctools_include('object-cache');
|
||||
ctools_object_cache_clear('view', $view->name);
|
||||
// Give feedback.
|
||||
$message = dt("Reverted the view '@viewname'", array('@viewname' => $view->name));
|
||||
drush_log($message, 'success');
|
||||
// Reverted one more view.
|
||||
}
|
||||
else {
|
||||
drush_set_error(dt("The view '@viewname' is not overridden.", array('@viewname' => $view->name)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the settings to a more developer oriented value.
|
||||
*/
|
||||
function views_development_settings() {
|
||||
variable_set('views_ui_show_listing_filters', TRUE);
|
||||
variable_set('views_ui_show_master_display', TRUE);
|
||||
variable_set('views_ui_show_advanced_column', TRUE);
|
||||
variable_set('views_ui_always_live_preview', FALSE);
|
||||
variable_set('views_ui_always_live_preview_button', TRUE);
|
||||
variable_set('views_ui_show_preview_information', TRUE);
|
||||
variable_set('views_ui_show_sql_query', TRUE);
|
||||
variable_set('views_ui_show_performance_statistics', TRUE);
|
||||
variable_set('views_show_additional_queries', TRUE);
|
||||
variable_set('views_devel_output', TRUE);
|
||||
variable_set('views_devel_region', 'message');
|
||||
variable_set('views_ui_display_embed', TRUE);
|
||||
$message = dt("Setup the new views settings.");
|
||||
drush_log($message, 'success');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Callback function for views-list command.
|
||||
*/
|
||||
function drush_views_list() {
|
||||
// Initialize stuf
|
||||
$rows = array();
|
||||
$disabled_views = array();
|
||||
$enabled_views = array();
|
||||
$overridden = 0;
|
||||
$indb = 0;
|
||||
$incode = 0;
|
||||
$disabled = 0;
|
||||
$total = 0;
|
||||
|
||||
$views = views_get_all_views();
|
||||
|
||||
// get the --name option
|
||||
// TODO : take into account the case off a comma-separated list of names
|
||||
$name = drush_get_option_list('name');
|
||||
$with_name = !empty($name) ? TRUE : FALSE;
|
||||
|
||||
// get the --tags option
|
||||
$tags = drush_get_option_list('tags');
|
||||
$with_tags = !empty($tags) ? TRUE : FALSE;
|
||||
|
||||
// get the --status option
|
||||
// store user input appart to reuse it after
|
||||
$status_opt = drush_get_option_list('status');
|
||||
// use the same logic than $view->disabled
|
||||
if (in_array('disabled', $status_opt)) {
|
||||
$status = TRUE;
|
||||
$with_status = TRUE;
|
||||
}
|
||||
elseif (in_array('enabled', $status_opt)) {
|
||||
$status = FALSE;
|
||||
$with_status = TRUE;
|
||||
}
|
||||
else {
|
||||
$status = NULL;
|
||||
// wrong or empty --status option
|
||||
$with_status = FALSE;
|
||||
}
|
||||
|
||||
// get the --type option
|
||||
$type = drush_get_option_list('type');
|
||||
// use the same logic than $view->type
|
||||
$with_type = FALSE;
|
||||
if (in_array('normal', $type) || in_array('default', $type)|| in_array('overridden', $type)) {
|
||||
$with_type = TRUE;
|
||||
}
|
||||
|
||||
// set the table headers
|
||||
$header = array(
|
||||
dt('Machine name'),
|
||||
dt('Description'),
|
||||
dt('Type'),
|
||||
dt('Status'),
|
||||
dt('Tag'),
|
||||
);
|
||||
|
||||
// setup a row for each view
|
||||
foreach($views as $id => $view){
|
||||
// if options were specified, check that first
|
||||
// mismatch push the loop to the next view
|
||||
if ($with_tags && !in_array($view->tag, $tags)) {
|
||||
continue;
|
||||
}
|
||||
if ($with_status && !$view->disabled == $status) {
|
||||
continue;
|
||||
}
|
||||
if ($with_type && strtolower($view->type) !== $type[0]) {
|
||||
continue;
|
||||
}
|
||||
if ($with_name && !stristr($view->name, $name[0])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$row = array();
|
||||
// each row entry should be in the same order as the header
|
||||
$row[] = $view->name;
|
||||
$row[] = $view->description;
|
||||
$row[] = $view->type;
|
||||
$row[] = $view->disabled ? dt('Disabled') : dt('Enabled');
|
||||
$row[] = $view->tag;
|
||||
|
||||
// place the row in the appropiate array,
|
||||
// so we can have disabled views at the bottom
|
||||
if($view->disabled) {
|
||||
$disabled_views[] = $row;
|
||||
}
|
||||
else{
|
||||
$enabled_views[] = $row;
|
||||
}
|
||||
unset($row);
|
||||
|
||||
// gather some statistics
|
||||
switch($view->type) {
|
||||
case dt('Normal'):
|
||||
$indb++;
|
||||
break;
|
||||
|
||||
case dt('Overridden'):
|
||||
$overridden++;
|
||||
break;
|
||||
|
||||
case dt('Default'):
|
||||
$incode++;
|
||||
break;
|
||||
}
|
||||
$total++;
|
||||
}
|
||||
|
||||
$disabled = count($disabled_views);
|
||||
|
||||
// sort alphabeticaly
|
||||
asort($disabled_views);
|
||||
asort($enabled_views);
|
||||
|
||||
// if options were used
|
||||
$summary = "";
|
||||
if ($with_name || $with_tags || $with_status || $with_type) {
|
||||
$summary = "Views";
|
||||
|
||||
if ($with_name) {
|
||||
$summary .= " named $name[0]";
|
||||
}
|
||||
|
||||
if ($with_tags) {
|
||||
$tags = implode(" or ", $tags);
|
||||
$summary .= " tagged $tags";
|
||||
}
|
||||
|
||||
if ($with_status) {
|
||||
$status_opt = implode("", $status_opt);
|
||||
$summary .= " which status is '$status_opt'";
|
||||
}
|
||||
|
||||
if ($with_type) {
|
||||
$type = ucfirst($type[0]);
|
||||
$summary .= " of type '$type'";
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($summary)) {
|
||||
drush_print($summary . "\n");
|
||||
}
|
||||
|
||||
// print all rows as a table
|
||||
if ($total > 0) {
|
||||
$rows = array_merge($enabled_views, $disabled_views);
|
||||
// put the headers as first row
|
||||
array_unshift($rows, $header);
|
||||
|
||||
drush_print_table($rows, TRUE);
|
||||
}
|
||||
|
||||
// print the statistics messages
|
||||
drush_print(dt("A total of @total views were found in this Drupal installation:", array('@total' => $total)));
|
||||
drush_print(dt(" @indb views reside only in the database", array('@indb' => $indb )));
|
||||
drush_print(dt(" @over views are overridden", array('@over' => $overridden)));
|
||||
drush_print(dt(" @incode views are in their default state", array('@incode' => $incode)));
|
||||
drush_print(dt(" @dis views are disabled\n", array('@dis' => $disabled)));
|
||||
}
|
||||
|
||||
function drush_views_analyze() {
|
||||
views_include('analyze');
|
||||
$messages_count = 0;
|
||||
$total = 0;
|
||||
|
||||
foreach (views_get_all_views() as $view_name => $view) {
|
||||
$total++;
|
||||
if ($messages = views_analyze_view($view)) {
|
||||
drush_print($view_name);
|
||||
foreach ($messages as $message) {
|
||||
$messages_count++;
|
||||
drush_print($message['type'] .': '. $message['message'], 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
drush_log(dt('A total of @total views were analyzed and @messages problems were found.', array('@total' => $total, '@messages' => $messages_count)), 'ok');
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables views
|
||||
*/
|
||||
function drush_views_enable() {
|
||||
$viewnames = _convert_csv_to_array(func_get_args());
|
||||
// Return early if no view names were specified.
|
||||
if (empty($viewnames)) {
|
||||
return drush_set_error(dt('Please specify a space delimited list of view names to enable'));
|
||||
}
|
||||
_views_drush_changestatus($viewnames, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables views
|
||||
*/
|
||||
function drush_views_disable() {
|
||||
$viewnames = _convert_csv_to_array(func_get_args());
|
||||
// Return early if no view names were specified.
|
||||
if (empty($viewnames)) {
|
||||
return drush_set_error(dt('Please specify a space delimited list of view names to disable'));
|
||||
}
|
||||
_views_drush_changestatus($viewnames, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to enable / disable views
|
||||
* @param $viewnames: array of viewnames to process
|
||||
* @param $status: TRUE to disable or FALSE to enable the view
|
||||
*/
|
||||
function _views_drush_changestatus($viewnames = array(), $status = NULL) {
|
||||
if ($status !== NULL && !empty($viewnames)) {
|
||||
$changed = FALSE;
|
||||
$processed = $status ? dt('disabled') : dt('enabled');
|
||||
$views_status = variable_get('views_defaults', array());
|
||||
|
||||
foreach ($viewnames as $key => $viewname) {
|
||||
if ($views_status[$viewname] !== $status) {
|
||||
$views_status[$viewname] = $status;
|
||||
$changed = TRUE;
|
||||
drush_log(dt("The view '!name' has been !processed", array('!name' => $viewname, '!processed' => $processed)), 'success');
|
||||
}
|
||||
else {
|
||||
drush_set_error(dt("The view '!name' is already !processed", array('!name' => $viewname, '!processed' => $processed)));
|
||||
}
|
||||
}
|
||||
// If we made changes to views status, save them and clear caches
|
||||
if ($changed) {
|
||||
variable_set('views_defaults', $views_status);
|
||||
views_invalidate_cache();
|
||||
drush_log(dt("Views cache was cleared"), 'ok');
|
||||
drush_log(dt("Menu cache is set to be rebuilt on the next request."), 'ok');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a cache clear option for views.
|
||||
*/
|
||||
function views_drush_cache_clear(&$types) {
|
||||
$types['views'] = 'views_invalidate_cache';
|
||||
}
|
@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Views area handlers.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup views_area_handlers Views area handlers
|
||||
* @{
|
||||
* Handlers to tell Views what can display in header, footer
|
||||
* and empty text in a view.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base class for area handlers.
|
||||
*
|
||||
* @ingroup views_area_handlers
|
||||
*/
|
||||
class views_handler_area extends views_handler {
|
||||
|
||||
/**
|
||||
* Overrides views_handler::init().
|
||||
*
|
||||
* Make sure that no result area handlers are set to be shown when the result
|
||||
* is empty.
|
||||
*/
|
||||
function init(&$view, &$options) {
|
||||
parent::init($view, $options);
|
||||
if ($this->handler_type == 'empty') {
|
||||
$this->options['empty'] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this field's label.
|
||||
*/
|
||||
function label() {
|
||||
if (!isset($this->options['label'])) {
|
||||
return $this->ui_name();
|
||||
}
|
||||
return $this->options['label'];
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$this->definition['field'] = !empty($this->definition['field']) ? $this->definition['field'] : '';
|
||||
$label = !empty($this->definition['label']) ? $this->definition['label'] : $this->definition['field'];
|
||||
$options['label'] = array('default' => $label, 'translatable' => TRUE);
|
||||
$options['empty'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide extra data to the administration form
|
||||
*/
|
||||
function admin_summary() {
|
||||
return $this->label();
|
||||
}
|
||||
|
||||
/**
|
||||
* Default options form that provides the label widget that all fields
|
||||
* should have.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$form['label'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Label'),
|
||||
'#default_value' => isset($this->options['label']) ? $this->options['label'] : '',
|
||||
'#description' => t('The label for this area that will be displayed only administratively.'),
|
||||
);
|
||||
|
||||
if ($form_state['type'] != 'empty') {
|
||||
$form['empty'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display even if view has no result'),
|
||||
'#default_value' => isset($this->options['empty']) ? $this->options['empty'] : 0,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't run a query
|
||||
*/
|
||||
function query() { }
|
||||
|
||||
/**
|
||||
* Render the area
|
||||
*/
|
||||
function render($empty = FALSE) {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Area handlers shouldn't have groupby.
|
||||
*/
|
||||
function use_group_by() {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A special handler to take the place of missing or broken handlers.
|
||||
*
|
||||
* @ingroup views_area_handlers
|
||||
*/
|
||||
class views_handler_area_broken extends views_handler_area {
|
||||
function ui_name($short = FALSE) {
|
||||
return t('Broken/missing handler');
|
||||
}
|
||||
|
||||
function ensure_my_table() { /* No table to ensure! */ }
|
||||
function query($group_by = FALSE) { /* No query to run */ }
|
||||
function render($empty = FALSE) { return ''; }
|
||||
function options_form(&$form, &$form_state) {
|
||||
$form['markup'] = array(
|
||||
'#prefix' => '<div class="form-item description">',
|
||||
'#value' => t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the handler is considered 'broken'
|
||||
*/
|
||||
function broken() { return TRUE; }
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_area_result.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Views area handler to display some configurable result summary.
|
||||
*
|
||||
* @ingroup views_area_handlers
|
||||
*/
|
||||
class views_handler_area_result extends views_handler_area {
|
||||
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['content'] = array(
|
||||
'default' => 'Displaying @start - @end of @total',
|
||||
'translatable' => TRUE,
|
||||
);
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$variables = array(
|
||||
'items' => array(
|
||||
'@start -- the initial record number in the set',
|
||||
'@end -- the last record number in the set',
|
||||
'@total -- the total records in the set',
|
||||
'@name -- the human-readable name of the view',
|
||||
'@per_page -- the number of items per page',
|
||||
'@current_page -- the current page number',
|
||||
'@current_record_count -- the current page record count',
|
||||
'@page_count -- the total page count',
|
||||
),
|
||||
);
|
||||
$list = theme('item_list', $variables);
|
||||
$form['content'] = array(
|
||||
'#title' => t('Display'),
|
||||
'#type' => 'textarea',
|
||||
'#rows' => 3,
|
||||
'#default_value' => $this->options['content'],
|
||||
'#description' => t('You may use HTML code in this field. The following tokens are supported:') . $list,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Find out the information to render.
|
||||
*/
|
||||
function render($empty = FALSE) {
|
||||
// Must have options and does not work on summaries.
|
||||
if (!isset($this->options['content']) || $this->view->plugin_name == 'default_summary') {
|
||||
return;
|
||||
}
|
||||
$output = '';
|
||||
$format = $this->options['content'];
|
||||
// Calculate the page totals.
|
||||
$current_page = (int) $this->view->get_current_page() + 1;
|
||||
$per_page = (int) $this->view->get_items_per_page();
|
||||
$count = count($this->view->result);
|
||||
// @TODO: Maybe use a possible is views empty functionality.
|
||||
// Not every view has total_rows set, use view->result instead.
|
||||
$total = isset($this->view->total_rows) ? $this->view->total_rows : count($this->view->result);
|
||||
$name = check_plain($this->view->human_name);
|
||||
if ($per_page === 0) {
|
||||
$page_count = 1;
|
||||
$start = 1;
|
||||
$end = $total;
|
||||
}
|
||||
else {
|
||||
$page_count = (int) ceil($total / $per_page);
|
||||
$total_count = $current_page * $per_page;
|
||||
if ($total_count > $total) {
|
||||
$total_count = $total;
|
||||
}
|
||||
$start = ($current_page - 1) * $per_page + 1;
|
||||
$end = $total_count;
|
||||
}
|
||||
$current_record_count = ($end - $start) + 1;
|
||||
// Get the search information.
|
||||
$items = array('start', 'end', 'total', 'name', 'per_page', 'current_page', 'current_record_count', 'page_count');
|
||||
$replacements = array();
|
||||
foreach ($items as $item) {
|
||||
$replacements["@$item"] = ${$item};
|
||||
}
|
||||
// Send the output.
|
||||
if (!empty($total)) {
|
||||
$output .= filter_xss_admin(str_replace(array_keys($replacements), array_values($replacements), $format));
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_area_text.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Views area text handler.
|
||||
*
|
||||
* @ingroup views_area_handlers
|
||||
*/
|
||||
class views_handler_area_text extends views_handler_area {
|
||||
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['content'] = array('default' => '', 'translatable' => TRUE, 'format_key' => 'format');
|
||||
$options['format'] = array('default' => NULL);
|
||||
$options['tokenize'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
$form['content'] = array(
|
||||
'#type' => 'text_format',
|
||||
'#default_value' => $this->options['content'],
|
||||
'#rows' => 6,
|
||||
'#format' => isset($this->options['format']) ? $this->options['format'] : filter_default_format(),
|
||||
'#wysiwyg' => FALSE,
|
||||
);
|
||||
|
||||
// @TODO: Refactor token handling into a base class.
|
||||
$form['tokenize'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Use replacement tokens from the first row'),
|
||||
'#default_value' => $this->options['tokenize'],
|
||||
);
|
||||
|
||||
// Get a list of the available fields and arguments for token replacement.
|
||||
$options = array();
|
||||
foreach ($this->view->display_handler->get_handlers('field') as $field => $handler) {
|
||||
$options[t('Fields')]["[$field]"] = $handler->ui_name();
|
||||
}
|
||||
|
||||
$count = 0; // This lets us prepare the key as we want it printed.
|
||||
foreach ($this->view->display_handler->get_handlers('argument') as $arg => $handler) {
|
||||
$options[t('Arguments')]['%' . ++$count] = t('@argument title', array('@argument' => $handler->ui_name()));
|
||||
$options[t('Arguments')]['!' . $count] = t('@argument input', array('@argument' => $handler->ui_name()));
|
||||
}
|
||||
|
||||
if (!empty($options)) {
|
||||
$output = '<p>' . t('The following tokens are available. If you would like to have the characters \'[\' and \']\' please use the html entity codes \'%5B\' or \'%5D\' or they will get replaced with empty space.' . '</p>');
|
||||
foreach (array_keys($options) as $type) {
|
||||
if (!empty($options[$type])) {
|
||||
$items = array();
|
||||
foreach ($options[$type] as $key => $value) {
|
||||
$items[] = $key . ' == ' . check_plain($value);
|
||||
}
|
||||
$output .= theme('item_list',
|
||||
array(
|
||||
'items' => $items,
|
||||
'type' => $type
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
$form['token_help'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Replacement patterns'),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
'#value' => $output,
|
||||
'#id' => 'edit-options-token-help',
|
||||
'#dependency' => array(
|
||||
'edit-options-tokenize' => array(1),
|
||||
),
|
||||
'#prefix' => '<div>',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function options_submit(&$form, &$form_state) {
|
||||
$form_state['values']['options']['format'] = $form_state['values']['options']['content']['format'];
|
||||
$form_state['values']['options']['content'] = $form_state['values']['options']['content']['value'];
|
||||
parent::options_submit($form, $form_state);
|
||||
}
|
||||
|
||||
function render($empty = FALSE) {
|
||||
$format = isset($this->options['format']) ? $this->options['format'] : filter_default_format();
|
||||
if (!$empty || !empty($this->options['empty'])) {
|
||||
return $this->render_textarea($this->options['content'], $format);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a text area, using the proper format.
|
||||
*/
|
||||
function render_textarea($value, $format) {
|
||||
if ($value) {
|
||||
if ($this->options['tokenize']) {
|
||||
$value = $this->view->style_plugin->tokenize_value($value, 0);
|
||||
}
|
||||
return check_markup($value, $format, '', FALSE);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_area_text_custom.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Views area text custom handler.
|
||||
*
|
||||
* @ingroup views_area_handlers
|
||||
*/
|
||||
class views_handler_area_text_custom extends views_handler_area_text {
|
||||
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
unset($options['format']);
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
// Alter the form element, to be a regular text area.
|
||||
$form['content']['#type'] = 'textarea';
|
||||
unset($form['content']['#format']);
|
||||
unset($form['content']['#wysiwyg']);
|
||||
|
||||
// @TODO: Use the token refactored base class.
|
||||
}
|
||||
|
||||
// Empty, so we don't inherit options_submit from the parent.
|
||||
function options_submit(&$form, &$form_state) {
|
||||
}
|
||||
|
||||
function render($empty = FALSE) {
|
||||
if (!$empty || !empty($this->options['empty'])) {
|
||||
return $this->render_textarea_custom($this->options['content']);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a text area with filter_xss_admin.
|
||||
*/
|
||||
function render_textarea_custom($value) {
|
||||
if ($value) {
|
||||
if ($this->options['tokenize']) {
|
||||
$value = $this->view->style_plugin->tokenize_value($value, 0);
|
||||
}
|
||||
return $this->sanitize_value($value, 'xss_admin');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_area_view.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Views area handlers. Insert a view inside of an area.
|
||||
*
|
||||
* @ingroup views_area_handlers
|
||||
*/
|
||||
class views_handler_area_view extends views_handler_area {
|
||||
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['view_to_insert'] = array('default' => '');
|
||||
$options['inherit_arguments'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default options form that provides the label widget that all fields
|
||||
* should have.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
$view_display = $this->view->name . ':' . $this->view->current_display;
|
||||
|
||||
$options = array('' => t('-Select-'));
|
||||
$options += views_get_views_as_options(FALSE, 'all', $view_display, FALSE, TRUE);
|
||||
$form['view_to_insert'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('View to insert'),
|
||||
'#default_value' => $this->options['view_to_insert'],
|
||||
'#description' => t('The view to insert into this area.'),
|
||||
'#options' => $options,
|
||||
);
|
||||
|
||||
$form['inherit_arguments'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Inherit contextual filters'),
|
||||
'#default_value' => $this->options['inherit_arguments'],
|
||||
'#description' => t('If checked, this view will receive the same contextual filters as its parent.'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the area
|
||||
*/
|
||||
function render($empty = FALSE) {
|
||||
if (!empty($this->options['view_to_insert'])) {
|
||||
list($view_name, $display_id) = explode(':', $this->options['view_to_insert']);
|
||||
|
||||
$view = views_get_view($view_name);
|
||||
if (empty($view) || !$view->access($display_id)) {
|
||||
return;
|
||||
}
|
||||
$view->set_display($display_id);
|
||||
|
||||
// Avoid recursion
|
||||
$view->parent_views += $this->view->parent_views;
|
||||
$view->parent_views[] = "$view_name:$display_id";
|
||||
|
||||
// Check if the view is part of the parent views of this view
|
||||
$search = "$view_name:$display_id";
|
||||
if (in_array($search, $this->view->parent_views)) {
|
||||
drupal_set_message(t("Recursion detected in view @view display @display.", array('@view' => $view_name, '@display' => $display_id)), 'error');
|
||||
}
|
||||
else {
|
||||
if (!empty($this->options['inherit_arguments']) && !empty($this->view->args)) {
|
||||
return $view->preview($display_id, $this->view->args);
|
||||
}
|
||||
else {
|
||||
return $view->preview($display_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_argument_date.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Abstract argument handler for dates.
|
||||
*
|
||||
* Adds an option to set a default argument based on the current date.
|
||||
*
|
||||
* @param $arg_format
|
||||
* The format string to use on the current time when
|
||||
* creating a default date argument.
|
||||
*
|
||||
* Definitions terms:
|
||||
* - many to one: If true, the "many to one" helper will be used.
|
||||
* - invalid input: A string to give to the user for obviously invalid input.
|
||||
* This is deprecated in favor of argument validators.
|
||||
*
|
||||
* @see views_many_to_one_helper()
|
||||
*
|
||||
* @ingroup views_argument_handlers
|
||||
*/
|
||||
class views_handler_argument_date extends views_handler_argument_formula {
|
||||
var $option_name = 'default_argument_date';
|
||||
var $arg_format = 'Y-m-d';
|
||||
|
||||
/**
|
||||
* Add an option to set the default value to the current date.
|
||||
*/
|
||||
function default_argument_form(&$form, &$form_state) {
|
||||
parent::default_argument_form($form, $form_state);
|
||||
$form['default_argument_type']['#options'] += array('date' => t('Current date'));
|
||||
$form['default_argument_type']['#options'] += array('node_created' => t("Current node's creation time"));
|
||||
$form['default_argument_type']['#options'] += array('node_changed' => t("Current node's update time")); }
|
||||
|
||||
/**
|
||||
* Set the empty argument value to the current date,
|
||||
* formatted appropriately for this argument.
|
||||
*/
|
||||
function get_default_argument($raw = FALSE) {
|
||||
if (!$raw && $this->options['default_argument_type'] == 'date') {
|
||||
return date($this->arg_format, REQUEST_TIME);
|
||||
}
|
||||
else if (!$raw && in_array($this->options['default_argument_type'], array('node_created', 'node_changed'))) {
|
||||
foreach (range(1, 3) as $i) {
|
||||
$node = menu_get_object('node', $i);
|
||||
if (!empty($node)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (arg(0) == 'node' && is_numeric(arg(1))) {
|
||||
$node = node_load(arg(1));
|
||||
}
|
||||
|
||||
if (empty($node)) {
|
||||
return parent::get_default_argument();
|
||||
}
|
||||
elseif ($this->options['default_argument_type'] == 'node_created') {
|
||||
return date($this->arg_format, $node->created);
|
||||
}
|
||||
elseif ($this->options['default_argument_type'] == 'node_changed') {
|
||||
return date($this->arg_format, $node->changed);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::get_default_argument($raw);
|
||||
}
|
||||
|
||||
/**
|
||||
* The date handler provides some default argument types, which aren't argument default plugins,
|
||||
* so addapt the export mechanism.
|
||||
*/
|
||||
function export_plugin($indent, $prefix, $storage, $option, $definition, $parents) {
|
||||
|
||||
// Only use a special behaviour for the special argument types, else just
|
||||
// use the default behaviour.
|
||||
if ($option == 'default_argument_type') {
|
||||
$type = 'argument default';
|
||||
$option_name = 'default_argument_options';
|
||||
|
||||
$plugin = $this->get_plugin($type);
|
||||
$name = $this->options[$option];
|
||||
if (in_array($name, array('date', 'node_created', 'node_changed'))) {
|
||||
|
||||
// Write which plugin to use.
|
||||
$output = $indent . $prefix . "['$option'] = '$name';\n";
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
return parent::export_plugin($indent, $prefix, $storage, $option, $definition, $parents);
|
||||
}
|
||||
|
||||
|
||||
function get_sort_name() {
|
||||
return t('Date', array(), array('context' => 'Sort order'));
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_argument_formula.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Abstract argument handler for simple formulae.
|
||||
*
|
||||
* Child classes of this object should implement summary_argument, at least.
|
||||
*
|
||||
* Definition terms:
|
||||
* - formula: The formula to use for this handler.
|
||||
*
|
||||
* @ingroup views_argument_handlers
|
||||
*/
|
||||
class views_handler_argument_formula extends views_handler_argument {
|
||||
var $formula = NULL;
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function construct() {
|
||||
parent::construct();
|
||||
|
||||
if (!empty($this->definition['formula'])) {
|
||||
$this->formula = $this->definition['formula'];
|
||||
}
|
||||
}
|
||||
|
||||
function get_formula() {
|
||||
return str_replace('***table***', $this->table_alias, $this->formula);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summary query based on a formula
|
||||
*/
|
||||
function summary_query() {
|
||||
$this->ensure_my_table();
|
||||
// Now that our table is secure, get our formula.
|
||||
$formula = $this->get_formula();
|
||||
|
||||
// Add the field.
|
||||
$this->base_alias = $this->name_alias = $this->query->add_field(NULL, $formula, $this->field);
|
||||
$this->query->set_count_field(NULL, $formula, $this->field);
|
||||
|
||||
return $this->summary_basics(FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the query based upon the formula
|
||||
*/
|
||||
function query($group_by = FALSE) {
|
||||
$this->ensure_my_table();
|
||||
// Now that our table is secure, get our formula.
|
||||
$placeholder = $this->placeholder();
|
||||
$formula = $this->get_formula() .' = ' . $placeholder;
|
||||
$placeholders = array(
|
||||
$placeholder => $this->argument,
|
||||
);
|
||||
$this->query->add_where(0, $formula, $placeholders, 'formula');
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_argument_group_by_numeric.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Simple handler for arguments using group by.
|
||||
*
|
||||
* @ingroup views_argument_handlers
|
||||
*/
|
||||
class views_handler_argument_group_by_numeric extends views_handler_argument {
|
||||
function query($group_by = FALSE) {
|
||||
$this->ensure_my_table();
|
||||
$field = $this->get_field();
|
||||
$placeholder = $this->placeholder();
|
||||
|
||||
$this->query->add_having_expression(0, "$field = $placeholder", array($placeholder => $this->argument));
|
||||
}
|
||||
|
||||
function ui_name($short = FALSE) {
|
||||
return $this->get_field(parent::ui_name($short));
|
||||
}
|
||||
|
||||
function get_sort_name() {
|
||||
return t('Numerical', array(), array('context' => 'Sort order'));
|
||||
}
|
||||
}
|
@ -0,0 +1,185 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_argument_many_to_one.
|
||||
*/
|
||||
|
||||
/**
|
||||
* An argument handler for use in fields that have a many to one relationship
|
||||
* with the table(s) to the left. This adds a bunch of options that are
|
||||
* reasonably common with this type of relationship.
|
||||
* Definition terms:
|
||||
* - numeric: If true, the field will be considered numeric. Probably should
|
||||
* always be set TRUE as views_handler_argument_string has many to one
|
||||
* capabilities.
|
||||
* - zero is null: If true, a 0 will be handled as empty, so for example
|
||||
* a default argument can be provided or a summary can be shown.
|
||||
*
|
||||
* @ingroup views_argument_handlers
|
||||
*/
|
||||
class views_handler_argument_many_to_one extends views_handler_argument {
|
||||
function init(&$view, &$options) {
|
||||
parent::init($view, $options);
|
||||
$this->helper = new views_many_to_one_helper($this);
|
||||
|
||||
// Ensure defaults for these, during summaries and stuff:
|
||||
$this->operator = 'or';
|
||||
$this->value = array();
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
if (!empty($this->definition['numeric'])) {
|
||||
$options['break_phrase'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
}
|
||||
|
||||
$options['add_table'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
$options['require_value'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
|
||||
if (isset($this->helper)) {
|
||||
$this->helper->option_definition($options);
|
||||
}
|
||||
else {
|
||||
$helper = new views_many_to_one_helper($this);
|
||||
$helper->option_definition($options);
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
// allow + for or, , for and
|
||||
if (!empty($this->definition['numeric'])) {
|
||||
$form['break_phrase'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Allow multiple values'),
|
||||
'#description' => t('If selected, users can enter multiple values in the form of 1+2+3 (for OR) or 1,2,3 (for AND).'),
|
||||
'#default_value' => !empty($this->options['break_phrase']),
|
||||
'#fieldset' => 'more',
|
||||
);
|
||||
}
|
||||
|
||||
$form['add_table'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Allow multiple filter values to work together'),
|
||||
'#description' => t('If selected, multiple instances of this filter can work together, as though multiple values were supplied to the same filter. This setting is not compatible with the "Reduce duplicates" setting.'),
|
||||
'#default_value' => !empty($this->options['add_table']),
|
||||
'#fieldset' => 'more',
|
||||
);
|
||||
|
||||
$form['require_value'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Do not display items with no value in summary'),
|
||||
'#default_value' => !empty($this->options['require_value']),
|
||||
'#fieldset' => 'more',
|
||||
);
|
||||
|
||||
$this->helper->options_form($form, $form_state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override ensure_my_table so we can control how this joins in.
|
||||
* The operator actually has influence over joining.
|
||||
*/
|
||||
function ensure_my_table() {
|
||||
$this->helper->ensure_my_table();
|
||||
}
|
||||
|
||||
function query($group_by = FALSE) {
|
||||
$empty = FALSE;
|
||||
if (isset($this->definition['zero is null']) && $this->definition['zero is null']) {
|
||||
if (empty($this->argument)) {
|
||||
$empty = TRUE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!isset($this->argument)) {
|
||||
$empty = TRUE;
|
||||
}
|
||||
}
|
||||
if ($empty) {
|
||||
parent::ensure_my_table();
|
||||
$this->query->add_where(0, "$this->table_alias.$this->real_field", NULL, 'IS NULL');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!empty($this->options['break_phrase'])) {
|
||||
views_break_phrase($this->argument, $this);
|
||||
}
|
||||
else {
|
||||
$this->value = array($this->argument);
|
||||
$this->operator = 'or';
|
||||
}
|
||||
|
||||
$this->helper->add_filter();
|
||||
}
|
||||
|
||||
function title() {
|
||||
if (!$this->argument) {
|
||||
return !empty($this->definition['empty field name']) ? $this->definition['empty field name'] : t('Uncategorized');
|
||||
}
|
||||
|
||||
if (!empty($this->options['break_phrase'])) {
|
||||
views_break_phrase($this->argument, $this);
|
||||
}
|
||||
else {
|
||||
$this->value = array($this->argument);
|
||||
$this->operator = 'or';
|
||||
}
|
||||
|
||||
// @todo -- both of these should check definition for alternate keywords.
|
||||
|
||||
if (empty($this->value)) {
|
||||
return !empty($this->definition['empty field name']) ? $this->definition['empty field name'] : t('Uncategorized');
|
||||
}
|
||||
|
||||
if ($this->value === array(-1)) {
|
||||
return !empty($this->definition['invalid input']) ? $this->definition['invalid input'] : t('Invalid input');
|
||||
}
|
||||
|
||||
return implode($this->operator == 'or' ? ' + ' : ', ', $this->title_query());
|
||||
}
|
||||
|
||||
function summary_query() {
|
||||
$field = $this->table . '.' . $this->field;
|
||||
$join = $this->get_join();
|
||||
|
||||
if (!empty($this->options['require_value'])) {
|
||||
$join->type = 'INNER';
|
||||
}
|
||||
|
||||
if (empty($this->options['add_table']) || empty($this->view->many_to_one_tables[$field])) {
|
||||
$this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join);
|
||||
}
|
||||
else {
|
||||
$this->table_alias = $this->helper->summary_join();
|
||||
}
|
||||
|
||||
// Add the field.
|
||||
$this->base_alias = $this->query->add_field($this->table_alias, $this->real_field);
|
||||
|
||||
$this->summary_name_field();
|
||||
|
||||
return $this->summary_basics();
|
||||
}
|
||||
|
||||
function summary_argument($data) {
|
||||
$value = $data->{$this->base_alias};
|
||||
if (empty($value)) {
|
||||
$value = 0;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override for specific title lookups.
|
||||
*/
|
||||
function title_query() {
|
||||
return $this->value;
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_argument_null.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Argument handler that ignores the argument.
|
||||
*
|
||||
* @ingroup views_argument_handlers
|
||||
*/
|
||||
class views_handler_argument_null extends views_handler_argument {
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['must_not_be'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override options_form() so that only the relevant options
|
||||
* are displayed to the user.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$form['must_not_be'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Fail basic validation if any argument is given'),
|
||||
'#default_value' => !empty($this->options['must_not_be']),
|
||||
'#description' => t('By checking this field, you can use this to make sure views with more arguments than necessary fail validation.'),
|
||||
'#fieldset' => 'more',
|
||||
);
|
||||
|
||||
unset($form['exception']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override default_actions() to remove actions that don't
|
||||
* make sense for a null argument.
|
||||
*/
|
||||
function default_actions($which = NULL) {
|
||||
if ($which) {
|
||||
if (in_array($which, array('ignore', 'not found', 'empty', 'default'))) {
|
||||
return parent::default_actions($which);
|
||||
}
|
||||
return;
|
||||
}
|
||||
$actions = parent::default_actions();
|
||||
unset($actions['summary asc']);
|
||||
unset($actions['summary desc']);
|
||||
return $actions;
|
||||
}
|
||||
|
||||
function validate_argument_basic($arg) {
|
||||
if (!empty($this->options['must_not_be'])) {
|
||||
return !isset($arg);
|
||||
}
|
||||
|
||||
return parent::validate_argument_basic($arg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the behavior of query() to prevent the query
|
||||
* from being changed in any way.
|
||||
*/
|
||||
function query($group_by = FALSE) {}
|
||||
}
|
@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_argument_numeric.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Basic argument handler for arguments that are numeric. Incorporates
|
||||
* break_phrase.
|
||||
*
|
||||
* @ingroup views_argument_handlers
|
||||
*/
|
||||
class views_handler_argument_numeric extends views_handler_argument {
|
||||
/**
|
||||
* The operator used for the query: or|and.
|
||||
* @var string
|
||||
*/
|
||||
var $operator;
|
||||
|
||||
/**
|
||||
* The actual value which is used for querying.
|
||||
* @var array
|
||||
*/
|
||||
var $value;
|
||||
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['break_phrase'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
$options['not'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
// allow + for or, , for and
|
||||
$form['break_phrase'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Allow multiple values'),
|
||||
'#description' => t('If selected, users can enter multiple values in the form of 1+2+3 (for OR) or 1,2,3 (for AND).'),
|
||||
'#default_value' => !empty($this->options['break_phrase']),
|
||||
'#fieldset' => 'more',
|
||||
);
|
||||
|
||||
$form['not'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Exclude'),
|
||||
'#description' => t('If selected, the numbers entered for the filter will be excluded rather than limiting the view.'),
|
||||
'#default_value' => !empty($this->options['not']),
|
||||
'#fieldset' => 'more',
|
||||
);
|
||||
}
|
||||
|
||||
function title() {
|
||||
if (!$this->argument) {
|
||||
return !empty($this->definition['empty field name']) ? $this->definition['empty field name'] : t('Uncategorized');
|
||||
}
|
||||
|
||||
if (!empty($this->options['break_phrase'])) {
|
||||
views_break_phrase($this->argument, $this);
|
||||
}
|
||||
else {
|
||||
$this->value = array($this->argument);
|
||||
$this->operator = 'or';
|
||||
}
|
||||
|
||||
if (empty($this->value)) {
|
||||
return !empty($this->definition['empty field name']) ? $this->definition['empty field name'] : t('Uncategorized');
|
||||
}
|
||||
|
||||
if ($this->value === array(-1)) {
|
||||
return !empty($this->definition['invalid input']) ? $this->definition['invalid input'] : t('Invalid input');
|
||||
}
|
||||
|
||||
return implode($this->operator == 'or' ? ' + ' : ', ', $this->title_query());
|
||||
}
|
||||
|
||||
/**
|
||||
* Override for specific title lookups.
|
||||
* @return array
|
||||
* Returns all titles, if it's just one title it's an array with one entry.
|
||||
*/
|
||||
function title_query() {
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
function query($group_by = FALSE) {
|
||||
$this->ensure_my_table();
|
||||
|
||||
if (!empty($this->options['break_phrase'])) {
|
||||
views_break_phrase($this->argument, $this);
|
||||
}
|
||||
else {
|
||||
$this->value = array($this->argument);
|
||||
}
|
||||
|
||||
$placeholder = $this->placeholder();
|
||||
$null_check = empty($this->options['not']) ? '' : "OR $this->table_alias.$this->real_field IS NULL";
|
||||
|
||||
if (count($this->value) > 1) {
|
||||
$operator = empty($this->options['not']) ? 'IN' : 'NOT IN';
|
||||
$this->query->add_where_expression(0, "$this->table_alias.$this->real_field $operator($placeholder) $null_check", array($placeholder => $this->value));
|
||||
}
|
||||
else {
|
||||
$operator = empty($this->options['not']) ? '=' : '!=';
|
||||
$this->query->add_where_expression(0, "$this->table_alias.$this->real_field $operator $placeholder $null_check", array($placeholder => $this->argument));
|
||||
}
|
||||
}
|
||||
|
||||
function get_sort_name() {
|
||||
return t('Numerical', array(), array('context' => 'Sort order'));
|
||||
}
|
||||
}
|
@ -0,0 +1,274 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_argument_string.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Basic argument handler to implement string arguments that may have length
|
||||
* limits.
|
||||
*
|
||||
* @ingroup views_argument_handlers
|
||||
*/
|
||||
class views_handler_argument_string extends views_handler_argument {
|
||||
function init(&$view, &$options) {
|
||||
parent::init($view, $options);
|
||||
if (!empty($this->definition['many to one'])) {
|
||||
$this->helper = new views_many_to_one_helper($this);
|
||||
|
||||
// Ensure defaults for these, during summaries and stuff:
|
||||
$this->operator = 'or';
|
||||
$this->value = array();
|
||||
}
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['glossary'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
$options['limit'] = array('default' => 0);
|
||||
$options['case'] = array('default' => 'none');
|
||||
$options['path_case'] = array('default' => 'none');
|
||||
$options['transform_dash'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
$options['break_phrase'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
|
||||
if (!empty($this->definition['many to one'])) {
|
||||
$options['add_table'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
$options['require_value'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
$form['glossary'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Glossary mode'),
|
||||
'#description' => t('Glossary mode applies a limit to the number of characters used in the filter value, which allows the summary view to act as a glossary.'),
|
||||
'#default_value' => $this->options['glossary'],
|
||||
'#fieldset' => 'more',
|
||||
);
|
||||
|
||||
$form['limit'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Character limit'),
|
||||
'#description' => t('How many characters of the filter value to filter against. If set to 1, all fields starting with the first letter in the filter value would be matched.'),
|
||||
'#default_value' => $this->options['limit'],
|
||||
'#dependency' => array('edit-options-glossary' => array(TRUE)),
|
||||
'#fieldset' => 'more',
|
||||
);
|
||||
|
||||
$form['case'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Case'),
|
||||
'#description' => t('When printing the title and summary, how to transform the case of the filter value.'),
|
||||
'#options' => array(
|
||||
'none' => t('No transform'),
|
||||
'upper' => t('Upper case'),
|
||||
'lower' => t('Lower case'),
|
||||
'ucfirst' => t('Capitalize first letter'),
|
||||
'ucwords' => t('Capitalize each word'),
|
||||
),
|
||||
'#default_value' => $this->options['case'],
|
||||
'#fieldset' => 'more',
|
||||
);
|
||||
|
||||
$form['path_case'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Case in path'),
|
||||
'#description' => t('When printing url paths, how to transform the case of the filter value. Do not use this unless with Postgres as it uses case sensitive comparisons.'),
|
||||
'#options' => array(
|
||||
'none' => t('No transform'),
|
||||
'upper' => t('Upper case'),
|
||||
'lower' => t('Lower case'),
|
||||
'ucfirst' => t('Capitalize first letter'),
|
||||
'ucwords' => t('Capitalize each word'),
|
||||
),
|
||||
'#default_value' => $this->options['path_case'],
|
||||
'#fieldset' => 'more',
|
||||
);
|
||||
|
||||
$form['transform_dash'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Transform spaces to dashes in URL'),
|
||||
'#default_value' => $this->options['transform_dash'],
|
||||
'#fieldset' => 'more',
|
||||
);
|
||||
|
||||
if (!empty($this->definition['many to one'])) {
|
||||
$form['add_table'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Allow multiple filter values to work together'),
|
||||
'#description' => t('If selected, multiple instances of this filter can work together, as though multiple values were supplied to the same filter. This setting is not compatible with the "Reduce duplicates" setting.'),
|
||||
'#default_value' => !empty($this->options['add_table']),
|
||||
'#fieldset' => 'more',
|
||||
);
|
||||
|
||||
$form['require_value'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Do not display items with no value in summary'),
|
||||
'#default_value' => !empty($this->options['require_value']),
|
||||
'#fieldset' => 'more',
|
||||
);
|
||||
}
|
||||
|
||||
// allow + for or, , for and
|
||||
$form['break_phrase'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Allow multiple values'),
|
||||
'#description' => t('If selected, users can enter multiple values in the form of 1+2+3 (for OR) or 1,2,3 (for AND).'),
|
||||
'#default_value' => !empty($this->options['break_phrase']),
|
||||
'#fieldset' => 'more',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the summary query based on a string
|
||||
*/
|
||||
function summary_query() {
|
||||
if (empty($this->definition['many to one'])) {
|
||||
$this->ensure_my_table();
|
||||
}
|
||||
else {
|
||||
$this->table_alias = $this->helper->summary_join();
|
||||
}
|
||||
|
||||
if (empty($this->options['glossary'])) {
|
||||
// Add the field.
|
||||
$this->base_alias = $this->query->add_field($this->table_alias, $this->real_field);
|
||||
$this->query->set_count_field($this->table_alias, $this->real_field);
|
||||
}
|
||||
else {
|
||||
// Add the field.
|
||||
$formula = $this->get_formula();
|
||||
$this->base_alias = $this->query->add_field(NULL, $formula, $this->field . '_truncated');
|
||||
$this->query->set_count_field(NULL, $formula, $this->field, $this->field . '_truncated');
|
||||
}
|
||||
|
||||
$this->summary_name_field();
|
||||
return $this->summary_basics(FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the formula for this argument.
|
||||
*
|
||||
* $this->ensure_my_table() MUST have been called prior to this.
|
||||
*/
|
||||
function get_formula() {
|
||||
return "SUBSTRING($this->table_alias.$this->real_field, 1, " . intval($this->options['limit']) . ")";
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the query based upon the formula
|
||||
*/
|
||||
function query($group_by = FALSE) {
|
||||
$argument = $this->argument;
|
||||
if (!empty($this->options['transform_dash'])) {
|
||||
$argument = strtr($argument, '-', ' ');
|
||||
}
|
||||
|
||||
if (!empty($this->options['break_phrase'])) {
|
||||
views_break_phrase_string($argument, $this);
|
||||
}
|
||||
else {
|
||||
$this->value = array($argument);
|
||||
$this->operator = 'or';
|
||||
}
|
||||
|
||||
if (!empty($this->definition['many to one'])) {
|
||||
if (!empty($this->options['glossary'])) {
|
||||
$this->helper->formula = TRUE;
|
||||
}
|
||||
$this->helper->ensure_my_table();
|
||||
$this->helper->add_filter();
|
||||
return;
|
||||
}
|
||||
|
||||
$this->ensure_my_table();
|
||||
$formula = FALSE;
|
||||
if (empty($this->options['glossary'])) {
|
||||
$field = "$this->table_alias.$this->real_field";
|
||||
}
|
||||
else {
|
||||
$formula = TRUE;
|
||||
$field = $this->get_formula();
|
||||
}
|
||||
|
||||
if (count($this->value) > 1) {
|
||||
$operator = 'IN';
|
||||
$argument = $this->value;
|
||||
}
|
||||
else {
|
||||
$operator = '=';
|
||||
}
|
||||
|
||||
if ($formula) {
|
||||
$placeholder = $this->placeholder();
|
||||
if ($operator == 'IN') {
|
||||
$field .= " IN($placeholder)";
|
||||
}
|
||||
else {
|
||||
$field .= ' = ' . $placeholder;
|
||||
}
|
||||
$placeholders = array(
|
||||
$placeholder => $argument,
|
||||
);
|
||||
$this->query->add_where_expression(0, $field, $placeholders);
|
||||
}
|
||||
else {
|
||||
$this->query->add_where(0, $field, $argument, $operator);
|
||||
}
|
||||
}
|
||||
|
||||
function summary_argument($data) {
|
||||
$value = $this->case_transform($data->{$this->base_alias}, $this->options['path_case']);
|
||||
if (!empty($this->options['transform_dash'])) {
|
||||
$value = strtr($value, ' ', '-');
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
function get_sort_name() {
|
||||
return t('Alphabetical', array(), array('context' => 'Sort order'));
|
||||
}
|
||||
|
||||
function title() {
|
||||
$this->argument = $this->case_transform($this->argument, $this->options['case']);
|
||||
if (!empty($this->options['transform_dash'])) {
|
||||
$this->argument = strtr($this->argument, '-', ' ');
|
||||
}
|
||||
|
||||
if (!empty($this->options['break_phrase'])) {
|
||||
views_break_phrase_string($this->argument, $this);
|
||||
}
|
||||
else {
|
||||
$this->value = array($this->argument);
|
||||
$this->operator = 'or';
|
||||
}
|
||||
|
||||
if (empty($this->value)) {
|
||||
return !empty($this->definition['empty field name']) ? $this->definition['empty field name'] : t('Uncategorized');
|
||||
}
|
||||
|
||||
if ($this->value === array(-1)) {
|
||||
return !empty($this->definition['invalid input']) ? $this->definition['invalid input'] : t('Invalid input');
|
||||
}
|
||||
|
||||
return implode($this->operator == 'or' ? ' + ' : ', ', $this->title_query());
|
||||
}
|
||||
|
||||
/**
|
||||
* Override for specific title lookups.
|
||||
*/
|
||||
function title_query() {
|
||||
return drupal_map_assoc($this->value, 'check_plain');
|
||||
}
|
||||
|
||||
function summary_name($data) {
|
||||
return $this->case_transform(parent::summary_name($data), $this->options['case']);
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_field_boolean.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A handler to provide proper displays for booleans.
|
||||
*
|
||||
* Allows for display of true/false, yes/no, on/off, enabled/disabled.
|
||||
*
|
||||
* Definition terms:
|
||||
* - output formats: An array where the first entry is displayed on boolean true
|
||||
* and the second is displayed on boolean false. An example for sticky is:
|
||||
* @code
|
||||
* 'output formats' => array(
|
||||
* 'sticky' => array(t('Sticky'), ''),
|
||||
* ),
|
||||
* @endcode
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_field_boolean extends views_handler_field {
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['type'] = array('default' => 'yes-no');
|
||||
$options['type_custom_true'] = array('default' => '', 'translatable' => TRUE);
|
||||
$options['type_custom_false'] = array('default' => '', 'translatable' => TRUE);
|
||||
$options['not'] = array('definition bool' => 'reverse');
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function init(&$view, &$options) {
|
||||
parent::init($view, $options);
|
||||
|
||||
$default_formats = array(
|
||||
'yes-no' => array(t('Yes'), t('No')),
|
||||
'true-false' => array(t('True'), t('False')),
|
||||
'on-off' => array(t('On'), t('Off')),
|
||||
'enabled-disabled' => array(t('Enabled'), t('Disabled')),
|
||||
'boolean' => array(1, 0),
|
||||
'unicode-yes-no' => array('✔', '✖'),
|
||||
);
|
||||
$output_formats = isset($this->definition['output formats']) ? $this->definition['output formats'] : array();
|
||||
$custom_format = array('custom' => array(t('Custom')));
|
||||
$this->formats = array_merge($default_formats, $output_formats, $custom_format);
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
foreach ($this->formats as $key => $item) {
|
||||
$options[$key] = implode('/', $item);
|
||||
}
|
||||
|
||||
$form['type'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Output format'),
|
||||
'#options' => $options,
|
||||
'#default_value' => $this->options['type'],
|
||||
);
|
||||
|
||||
$form['type_custom_true'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Custom output for TRUE'),
|
||||
'#default_value' => $this->options['type_custom_true'],
|
||||
'#states' => array(
|
||||
'visible' => array(
|
||||
'select[name="options[type]"]' => array('value' => 'custom'),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$form['type_custom_false'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Custom output for FALSE'),
|
||||
'#default_value' => $this->options['type_custom_false'],
|
||||
'#states' => array(
|
||||
'visible' => array(
|
||||
'select[name="options[type]"]' => array('value' => 'custom'),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$form['not'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Reverse'),
|
||||
'#description' => t('If checked, true will be displayed as false.'),
|
||||
'#default_value' => $this->options['not'],
|
||||
);
|
||||
parent::options_form($form, $form_state);
|
||||
}
|
||||
|
||||
function render($values) {
|
||||
$value = $this->get_value($values);
|
||||
if (!empty($this->options['not'])) {
|
||||
$value = !$value;
|
||||
}
|
||||
|
||||
if ($this->options['type'] == 'custom') {
|
||||
return $value ? filter_xss_admin($this->options['type_custom_true']) : filter_xss_admin($this->options['type_custom_false']);
|
||||
}
|
||||
else if (isset($this->formats[$this->options['type']])) {
|
||||
return $value ? $this->formats[$this->options['type']][0] : $this->formats[$this->options['type']][1];
|
||||
}
|
||||
else {
|
||||
return $value ? $this->formats['yes-no'][0] : $this->formats['yes-no'][1];
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_field_contextual_links.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provides a handler that adds contextual links.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_field_contextual_links extends views_handler_field {
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['fields'] = array('default' => array());
|
||||
$options['destination'] = array('default' => TRUE, 'bool' => TRUE);
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
$all_fields = $this->view->display_handler->get_field_labels();
|
||||
// Offer to include only those fields that follow this one.
|
||||
$field_options = array_slice($all_fields, 0, array_search($this->options['id'], array_keys($all_fields)));
|
||||
$form['fields'] = array(
|
||||
'#type' => 'checkboxes',
|
||||
'#title' => t('Fields'),
|
||||
'#description' => t('Fields to be included as contextual links.'),
|
||||
'#options' => $field_options,
|
||||
'#default_value' => $this->options['fields'],
|
||||
);
|
||||
$form['destination'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Include destination'),
|
||||
'#description' => t('Include a "destination" parameter in the link to return the user to the original view upon completing the contextual action.'),
|
||||
'#default_value' => $this->options['destination'],
|
||||
);
|
||||
}
|
||||
|
||||
function pre_render(&$values) {
|
||||
// Add a row plugin css class for the contextual link.
|
||||
$class = 'contextual-links-region';
|
||||
if (!empty($this->view->style_plugin->options['row_class'])) {
|
||||
$this->view->style_plugin->options['row_class'] .= " $class";
|
||||
}
|
||||
else {
|
||||
$this->view->style_plugin->options['row_class'] = $class;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the contextual fields.
|
||||
*/
|
||||
function render($values) {
|
||||
$links = array();
|
||||
foreach ($this->options['fields'] as $field) {
|
||||
if (empty($this->view->style_plugin->rendered_fields[$this->view->row_index][$field])) {
|
||||
continue;
|
||||
}
|
||||
$title = $this->view->field[$field]->last_render_text;
|
||||
$path = '';
|
||||
if (!empty($this->view->field[$field]->options['alter']['path'])) {
|
||||
$path = $this->view->field[$field]->options['alter']['path'];
|
||||
}
|
||||
if (!empty($title) && !empty($path)) {
|
||||
// Make sure that tokens are replaced for this paths as well.
|
||||
$tokens = $this->get_render_tokens(array());
|
||||
$path = strip_tags(decode_entities(strtr($path, $tokens)));
|
||||
|
||||
$links[$field] = array(
|
||||
'href' => $path,
|
||||
'title' => $title,
|
||||
);
|
||||
if (!empty($this->options['destination'])) {
|
||||
$links[$field]['query'] = drupal_get_destination();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($links)) {
|
||||
$build = array(
|
||||
'#prefix' => '<div class="contextual-links-wrapper">',
|
||||
'#suffix' => '</div>',
|
||||
'#theme' => 'links__contextual',
|
||||
'#links' => $links,
|
||||
'#attributes' => array('class' => array('contextual-links')),
|
||||
'#attached' => array(
|
||||
'library' => array(array('contextual', 'contextual-links')),
|
||||
),
|
||||
'#access' => user_access('access contextual links'),
|
||||
);
|
||||
return drupal_render($build);
|
||||
}
|
||||
else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function query() { }
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_field_counter.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Field handler to show a counter of the current row.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_field_counter extends views_handler_field {
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['counter_start'] = array('default' => 1);
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
$form['counter_start'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Starting value'),
|
||||
'#default_value' => $this->options['counter_start'],
|
||||
'#description' => t('Specify the number the counter should start at.'),
|
||||
'#size' => 2,
|
||||
);
|
||||
|
||||
parent::options_form($form, $form_state);
|
||||
}
|
||||
|
||||
function query() {
|
||||
// do nothing -- to override the parent query.
|
||||
}
|
||||
|
||||
function render($values) {
|
||||
// Note: 1 is subtracted from the counter start value below because the
|
||||
// counter value is incremented by 1 at the end of this function.
|
||||
$count = is_numeric($this->options['counter_start']) ? $this->options['counter_start'] - 1 : 0;
|
||||
$pager = $this->view->query->pager;
|
||||
// Get the base count of the pager.
|
||||
if ($pager->use_pager()) {
|
||||
$count += ($pager->get_items_per_page() * $pager->get_current_page() + $pager->get_offset());
|
||||
}
|
||||
// Add the counter for the current site.
|
||||
$count += $this->view->row_index + 1;
|
||||
|
||||
return $count;
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_field_custom.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A handler to provide a field that is completely custom by the administrator.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_field_custom extends views_handler_field {
|
||||
function query() {
|
||||
// do nothing -- to override the parent query.
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
// Override the alter text option to always alter the text.
|
||||
$options['alter']['contains']['alter_text'] = array('default' => TRUE, 'bool' => TRUE);
|
||||
$options['hide_alter_empty'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
// Remove the checkbox
|
||||
unset($form['alter']['alter_text']);
|
||||
unset($form['alter']['text']['#dependency']);
|
||||
unset($form['alter']['text']['#process']);
|
||||
unset($form['alter']['help']['#dependency']);
|
||||
unset($form['alter']['help']['#process']);
|
||||
$form['#pre_render'][] = 'views_handler_field_custom_pre_render_move_text';
|
||||
}
|
||||
|
||||
function render($values) {
|
||||
// Return the text, so the code never thinks the value is empty.
|
||||
return $this->options['alter']['text'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prerender function to move the textarea to the top.
|
||||
*/
|
||||
function views_handler_field_custom_pre_render_move_text($form) {
|
||||
$form['text'] = $form['alter']['text'];
|
||||
$form['help'] = $form['alter']['help'];
|
||||
unset($form['alter']['text']);
|
||||
unset($form['alter']['help']);
|
||||
|
||||
return $form;
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_field_date.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A handler to provide proper displays for dates.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_field_date extends views_handler_field {
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['date_format'] = array('default' => 'small');
|
||||
$options['custom_date_format'] = array('default' => '');
|
||||
$options['timezone'] = array('default' => '');
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
|
||||
$date_formats = array();
|
||||
$date_types = system_get_date_types();
|
||||
foreach ($date_types as $key => $value) {
|
||||
$date_formats[$value['type']] = t('@date_format format', array('@date_format' => $value['title'])) . ': ' . format_date(REQUEST_TIME, $value['type']);
|
||||
}
|
||||
|
||||
$form['date_format'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Date format'),
|
||||
'#options' => $date_formats + array(
|
||||
'custom' => t('Custom'),
|
||||
'raw time ago' => t('Time ago'),
|
||||
'time ago' => t('Time ago (with "ago" appended)'),
|
||||
'raw time hence' => t('Time hence'),
|
||||
'time hence' => t('Time hence (with "hence" appended)'),
|
||||
'raw time span' => t('Time span (future dates have "-" prepended)'),
|
||||
'inverse time span' => t('Time span (past dates have "-" prepended)'),
|
||||
'time span' => t('Time span (with "ago/hence" appended)'),
|
||||
),
|
||||
'#default_value' => isset($this->options['date_format']) ? $this->options['date_format'] : 'small',
|
||||
);
|
||||
$form['custom_date_format'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Custom date format'),
|
||||
'#description' => t('If "Custom", see the <a href="@url" target="_blank">PHP manual</a> for date formats. Otherwise, enter the number of different time units to display, which defaults to 2.', array('@url' => 'http://php.net/manual/function.date.php')),
|
||||
'#default_value' => isset($this->options['custom_date_format']) ? $this->options['custom_date_format'] : '',
|
||||
'#dependency' => array('edit-options-date-format' => array('custom', 'raw time ago', 'time ago', 'raw time hence', 'time hence', 'raw time span', 'time span', 'raw time span', 'inverse time span', 'time span')),
|
||||
);
|
||||
$form['timezone'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Timezone'),
|
||||
'#description' => t('Timezone to be used for date output.'),
|
||||
'#options' => array('' => t('- Default site/user timezone -')) + system_time_zones(FALSE),
|
||||
'#default_value' => $this->options['timezone'],
|
||||
'#dependency' => array('edit-options-date-format' => array_merge(array('custom'), array_keys($date_formats))),
|
||||
);
|
||||
|
||||
parent::options_form($form, $form_state);
|
||||
}
|
||||
|
||||
function render($values) {
|
||||
$value = $this->get_value($values);
|
||||
$format = $this->options['date_format'];
|
||||
if (in_array($format, array('custom', 'raw time ago', 'time ago', 'raw time hence', 'time hence', 'raw time span', 'time span', 'raw time span', 'inverse time span', 'time span'))) {
|
||||
$custom_format = $this->options['custom_date_format'];
|
||||
}
|
||||
|
||||
if ($value) {
|
||||
$timezone = !empty($this->options['timezone']) ? $this->options['timezone'] : NULL;
|
||||
$time_diff = REQUEST_TIME - $value; // will be positive for a datetime in the past (ago), and negative for a datetime in the future (hence)
|
||||
switch ($format) {
|
||||
case 'raw time ago':
|
||||
return format_interval($time_diff, is_numeric($custom_format) ? $custom_format : 2);
|
||||
case 'time ago':
|
||||
return t('%time ago', array('%time' => format_interval($time_diff, is_numeric($custom_format) ? $custom_format : 2)));
|
||||
case 'raw time hence':
|
||||
return format_interval(-$time_diff, is_numeric($custom_format) ? $custom_format : 2);
|
||||
case 'time hence':
|
||||
return t('%time hence', array('%time' => format_interval(-$time_diff, is_numeric($custom_format) ? $custom_format : 2)));
|
||||
case 'raw time span':
|
||||
return ($time_diff < 0 ? '-' : '') . format_interval(abs($time_diff), is_numeric($custom_format) ? $custom_format : 2);
|
||||
case 'inverse time span':
|
||||
return ($time_diff > 0 ? '-' : '') . format_interval(abs($time_diff), is_numeric($custom_format) ? $custom_format : 2);
|
||||
case 'time span':
|
||||
return t(($time_diff < 0 ? '%time hence' : '%time ago'), array('%time' => format_interval(abs($time_diff), is_numeric($custom_format) ? $custom_format : 2)));
|
||||
case 'custom':
|
||||
if ($custom_format == 'r') {
|
||||
return format_date($value, $format, $custom_format, $timezone, 'en');
|
||||
}
|
||||
return format_date($value, $format, $custom_format, $timezone);
|
||||
default:
|
||||
return format_date($value, $format, '', $timezone);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_field_entity.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A handler to display data from entity objects.
|
||||
*
|
||||
* Fields based upon this handler work with all query-backends if the tables
|
||||
* used by the query backend have an 'entity type' specified. In order to
|
||||
* make fields based upon this handler automatically available to all compatible
|
||||
* query backends, the views field can be defined in the table
|
||||
* @code views_entity_{ENTITY_TYPE} @endcode.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_field_entity extends views_handler_field {
|
||||
|
||||
/**
|
||||
* Stores the entity type which is loaded by this field.
|
||||
*/
|
||||
public $entity_type;
|
||||
|
||||
/**
|
||||
* Stores all entites which are in the result.
|
||||
*/
|
||||
public $entities;
|
||||
|
||||
/**
|
||||
* The base field of the entity type assosiated with this field.
|
||||
*/
|
||||
public $base_field;
|
||||
|
||||
/**
|
||||
* Initialize the entity type.
|
||||
*/
|
||||
public function init(&$view, &$options) {
|
||||
parent::init($view, $options);
|
||||
|
||||
// Initialize the entity-type used.
|
||||
$table_data = views_fetch_data($this->table);
|
||||
$this->entity_type = $table_data['table']['entity type'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Overriden to add the field for the entity id.
|
||||
*/
|
||||
function query() {
|
||||
$this->table_alias = $base_table = $this->view->base_table;
|
||||
$this->base_field = $this->view->base_field;
|
||||
|
||||
if (!empty($this->relationship)) {
|
||||
foreach ($this->view->relationship as $relationship) {
|
||||
if ($relationship->alias == $this->relationship) {
|
||||
$base_table = $relationship->definition['base'];
|
||||
$this->table_alias = $relationship->alias;
|
||||
|
||||
$table_data = views_fetch_data($base_table);
|
||||
$this->base_field = empty($relationship->definition['base field']) ? $table_data['table']['base']['field'] : $relationship->definition['base field'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add the field if the query back-end implements an add_field() method,
|
||||
// just like the default back-end.
|
||||
if (method_exists($this->query, 'add_field')) {
|
||||
$this->field_alias = $this->query->add_field($this->table_alias, $this->base_field, '');
|
||||
}
|
||||
|
||||
$this->add_additional_fields();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the entities for all rows that are about to be displayed.
|
||||
*/
|
||||
function pre_render(&$values) {
|
||||
if (!empty($values)) {
|
||||
list($this->entity_type, $this->entities) = $this->query->get_result_entities($values, !empty($this->relationship) ? $this->relationship : NULL, $this->field_alias);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden to return the entity object, or a certain property of the entity.
|
||||
*/
|
||||
function get_value($values, $field = NULL) {
|
||||
if (isset($this->entities[$this->view->row_index])) {
|
||||
$entity = $this->entities[$this->view->row_index];
|
||||
// Support to get a certain part of the entity.
|
||||
if (isset($field) && isset($entity->{$field})) {
|
||||
return $entity->{$field};
|
||||
}
|
||||
// Support to get a part of the values as the normal get_value.
|
||||
elseif (isset($field) && isset($values->{$this->aliases[$field]})) {
|
||||
return $values->{$this->aliases[$field]};
|
||||
}
|
||||
else {
|
||||
return $entity;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_field_machine_name.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Field handler whichs allows to show machine name content as human name.
|
||||
* @ingroup views_field_handlers
|
||||
*
|
||||
* Definition items:
|
||||
* - options callback: The function to call in order to generate the value options. If omitted, the options 'Yes' and 'No' will be used.
|
||||
* - options arguments: An array of arguments to pass to the options callback.
|
||||
*/
|
||||
class views_handler_field_machine_name extends views_handler_field {
|
||||
/**
|
||||
* @var array Stores the available options.
|
||||
*/
|
||||
var $value_options;
|
||||
|
||||
function get_value_options() {
|
||||
if (isset($this->value_options)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($this->definition['options callback']) && is_callable($this->definition['options callback'])) {
|
||||
if (isset($this->definition['options arguments']) && is_array($this->definition['options arguments'])) {
|
||||
$this->value_options = call_user_func_array($this->definition['options callback'], $this->definition['options arguments']);
|
||||
}
|
||||
else {
|
||||
$this->value_options = call_user_func($this->definition['options callback']);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->value_options = array();
|
||||
}
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['machine_name'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
$form['machine_name'] = array(
|
||||
'#title' => t('Output machine name'),
|
||||
'#description' => t('Display field as machine name.'),
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => !empty($this->options['machine_name']),
|
||||
);
|
||||
}
|
||||
|
||||
function pre_render(&$values) {
|
||||
$this->get_value_options();
|
||||
}
|
||||
|
||||
function render($values) {
|
||||
$value = $values->{$this->field_alias};
|
||||
if (!empty($this->options['machine_name']) || !isset($this->value_options[$value])) {
|
||||
$result = check_plain($value);
|
||||
}
|
||||
else {
|
||||
$result = $this->value_options[$value];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_field_markup.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A handler to run a field through check_markup, using a companion
|
||||
* format field.
|
||||
*
|
||||
* - format: (REQUIRED) Either a string format id to use for this field or an
|
||||
* array('field' => {$field}) where $field is the field in this table
|
||||
* used to control the format such as the 'format' field in the node,
|
||||
* which goes with the 'body' field.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_field_markup extends views_handler_field {
|
||||
/**
|
||||
* Constructor; calls to base object constructor.
|
||||
*/
|
||||
function construct() {
|
||||
parent::construct();
|
||||
|
||||
$this->format = $this->definition['format'];
|
||||
|
||||
$this->additional_fields = array();
|
||||
if (is_array($this->format)) {
|
||||
$this->additional_fields['format'] = $this->format;
|
||||
}
|
||||
}
|
||||
|
||||
function render($values) {
|
||||
$value = $this->get_value($values);
|
||||
if (is_array($this->format)) {
|
||||
$format = $this->get_value($values, 'format');
|
||||
}
|
||||
else {
|
||||
$format = $this->format;
|
||||
}
|
||||
if ($value) {
|
||||
$value = str_replace('<!--break-->', '', $value);
|
||||
return check_markup($value, $format, '');
|
||||
}
|
||||
}
|
||||
|
||||
function element_type($none_supported = FALSE, $default_empty = FALSE, $inline = FALSE) {
|
||||
if ($inline) {
|
||||
return 'span';
|
||||
}
|
||||
|
||||
if (isset($this->definition['element type'])) {
|
||||
return $this->definition['element type'];
|
||||
}
|
||||
|
||||
return 'div';
|
||||
}
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_field_math.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Render a mathematical expression as a numeric value
|
||||
*
|
||||
* Definition terms:
|
||||
* - float: If true this field contains a decimal value. If unset this field
|
||||
* will be assumed to be integer.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_field_math extends views_handler_field_numeric {
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['expression'] = array('default' => '');
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
$form['expression'] = array(
|
||||
'#type' => 'textarea',
|
||||
'#title' => t('Expression'),
|
||||
'#description' => t('Enter mathematical expressions such as 2 + 2 or sqrt(5). You may assign variables and create mathematical functions and evaluate them. Use the ; to separate these. For example: f(x) = x + 2; f(2).'),
|
||||
'#default_value' => $this->options['expression'],
|
||||
);
|
||||
|
||||
// Create a place for the help
|
||||
$form['expression_help'] = array();
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
// Then move the existing help:
|
||||
$form['expression_help'] = $form['alter']['help'];
|
||||
unset($form['expression_help']['#dependency']);
|
||||
unset($form['alter']['help']);
|
||||
}
|
||||
|
||||
function render($values) {
|
||||
ctools_include('math-expr');
|
||||
$tokens = array_map('floatval', $this->get_render_tokens(array()));
|
||||
$value = strtr($this->options['expression'], $tokens);
|
||||
$expressions = explode(';', $value);
|
||||
$math = new ctools_math_expr;
|
||||
foreach ($expressions as $expression) {
|
||||
if ($expression !== '') {
|
||||
$value = $math->evaluate($expression);
|
||||
}
|
||||
}
|
||||
|
||||
// The rest is directly from views_handler_field_numeric but because it
|
||||
// does not allow the value to be passed in, it is copied.
|
||||
if (!empty($this->options['set_precision'])) {
|
||||
$value = number_format($value, $this->options['precision'], $this->options['decimal'], $this->options['separator']);
|
||||
}
|
||||
else {
|
||||
$remainder = abs($value) - intval(abs($value));
|
||||
$value = $value > 0 ? floor($value) : ceil($value);
|
||||
$value = number_format($value, 0, '', $this->options['separator']);
|
||||
if ($remainder) {
|
||||
// The substr may not be locale safe.
|
||||
$value .= $this->options['decimal'] . substr($remainder, 2);
|
||||
}
|
||||
}
|
||||
|
||||
// Check to see if hiding should happen before adding prefix and suffix.
|
||||
if ($this->options['hide_empty'] && empty($value) && ($value !== 0 || $this->options['empty_zero'])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Should we format as a plural.
|
||||
if (!empty($this->options['format_plural']) && ($value != 0 || !$this->options['empty_zero'])) {
|
||||
$value = format_plural($value, $this->options['format_plural_singular'], $this->options['format_plural_plural']);
|
||||
}
|
||||
|
||||
return $this->sanitize_value($this->options['prefix'] . $value . $this->options['suffix']);
|
||||
}
|
||||
|
||||
function query() { }
|
||||
}
|
@ -0,0 +1,137 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_field_numeric.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Render a field as a numeric value
|
||||
*
|
||||
* Definition terms:
|
||||
* - float: If true this field contains a decimal value. If unset this field
|
||||
* will be assumed to be integer.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_field_numeric extends views_handler_field {
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['set_precision'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
$options['precision'] = array('default' => 0);
|
||||
$options['decimal'] = array('default' => '.', 'translatable' => TRUE);
|
||||
$options['separator'] = array('default' => ',', 'translatable' => TRUE);
|
||||
$options['format_plural'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
$options['format_plural_singular'] = array('default' => '1');
|
||||
$options['format_plural_plural'] = array('default' => '@count');
|
||||
$options['prefix'] = array('default' => '', 'translatable' => TRUE);
|
||||
$options['suffix'] = array('default' => '', 'translatable' => TRUE);
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
if (!empty($this->definition['float'])) {
|
||||
$form['set_precision'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Round'),
|
||||
'#description' => t('If checked, the number will be rounded.'),
|
||||
'#default_value' => $this->options['set_precision'],
|
||||
);
|
||||
$form['precision'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Precision'),
|
||||
'#default_value' => $this->options['precision'],
|
||||
'#description' => t('Specify how many digits to print after the decimal point.'),
|
||||
'#dependency' => array('edit-options-set-precision' => array(TRUE)),
|
||||
'#size' => 2,
|
||||
);
|
||||
$form['decimal'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Decimal point'),
|
||||
'#default_value' => $this->options['decimal'],
|
||||
'#description' => t('What single character to use as a decimal point.'),
|
||||
'#size' => 2,
|
||||
);
|
||||
}
|
||||
$form['separator'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Thousands marker'),
|
||||
'#options' => array(
|
||||
'' => t('- None -'),
|
||||
',' => t('Comma'),
|
||||
' ' => t('Space'),
|
||||
'.' => t('Decimal'),
|
||||
'\'' => t('Apostrophe'),
|
||||
),
|
||||
'#default_value' => $this->options['separator'],
|
||||
'#description' => t('What single character to use as the thousands separator.'),
|
||||
'#size' => 2,
|
||||
);
|
||||
$form['format_plural'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Format plural'),
|
||||
'#description' => t('If checked, special handling will be used for plurality.'),
|
||||
'#default_value' => $this->options['format_plural'],
|
||||
);
|
||||
$form['format_plural_singular'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Singular form'),
|
||||
'#default_value' => $this->options['format_plural_singular'],
|
||||
'#description' => t('Text to use for the singular form.'),
|
||||
'#dependency' => array('edit-options-format-plural' => array(TRUE)),
|
||||
);
|
||||
$form['format_plural_plural'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Plural form'),
|
||||
'#default_value' => $this->options['format_plural_plural'],
|
||||
'#description' => t('Text to use for the plural form, @count will be replaced with the value.'),
|
||||
'#dependency' => array('edit-options-format-plural' => array(TRUE)),
|
||||
);
|
||||
$form['prefix'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Prefix'),
|
||||
'#default_value' => $this->options['prefix'],
|
||||
'#description' => t('Text to put before the number, such as currency symbol.'),
|
||||
);
|
||||
$form['suffix'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Suffix'),
|
||||
'#default_value' => $this->options['suffix'],
|
||||
'#description' => t('Text to put after the number, such as currency symbol.'),
|
||||
);
|
||||
|
||||
parent::options_form($form, $form_state);
|
||||
}
|
||||
|
||||
function render($values) {
|
||||
$value = $this->get_value($values);
|
||||
if (!empty($this->options['set_precision'])) {
|
||||
$value = number_format($value, $this->options['precision'], $this->options['decimal'], $this->options['separator']);
|
||||
}
|
||||
else {
|
||||
$remainder = abs($value) - intval(abs($value));
|
||||
$value = $value > 0 ? floor($value) : ceil($value);
|
||||
$value = number_format($value, 0, '', $this->options['separator']);
|
||||
if ($remainder) {
|
||||
// The substr may not be locale safe.
|
||||
$value .= $this->options['decimal'] . substr($remainder, 2);
|
||||
}
|
||||
}
|
||||
|
||||
// Check to see if hiding should happen before adding prefix and suffix.
|
||||
if ($this->options['hide_empty'] && empty($value) && ($value !== 0 || $this->options['empty_zero'])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Should we format as a plural.
|
||||
if (!empty($this->options['format_plural'])) {
|
||||
$value = format_plural($value, $this->options['format_plural_singular'], $this->options['format_plural_plural']);
|
||||
}
|
||||
|
||||
return $this->sanitize_value($this->options['prefix'], 'xss')
|
||||
. $this->sanitize_value($value)
|
||||
. $this->sanitize_value($this->options['suffix'], 'xss');
|
||||
}
|
||||
}
|
@ -0,0 +1,158 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_field_prerender_list.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Field handler to provide a list of items.
|
||||
*
|
||||
* The items are expected to be loaded by a child object during pre_render,
|
||||
* and 'my field' is expected to be the pointer to the items in the list.
|
||||
*
|
||||
* Items to render should be in a list in $this->items
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_field_prerender_list extends views_handler_field {
|
||||
/**
|
||||
* Stores all items which are used to render the items.
|
||||
* It should be keyed first by the id of the base table, for example nid.
|
||||
* The second key is the id of the thing which is displayed multiple times
|
||||
* per row, for example the tid.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $items = array();
|
||||
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['type'] = array('default' => 'separator');
|
||||
$options['separator'] = array('default' => ', ');
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
$form['type'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Display type'),
|
||||
'#options' => array(
|
||||
'ul' => t('Unordered list'),
|
||||
'ol' => t('Ordered list'),
|
||||
'separator' => t('Simple separator'),
|
||||
),
|
||||
'#default_value' => $this->options['type'],
|
||||
);
|
||||
|
||||
$form['separator'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Separator'),
|
||||
'#default_value' => $this->options['separator'],
|
||||
'#dependency' => array('radio:options[type]' => array('separator')),
|
||||
);
|
||||
parent::options_form($form, $form_state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the field.
|
||||
*
|
||||
* This function is deprecated, but left in for older systems that have not
|
||||
* yet or won't update their prerender list fields. If a render_item method
|
||||
* exists, this will not get used by advanced_render.
|
||||
*/
|
||||
function render($values) {
|
||||
$field = $this->get_value($values);
|
||||
if (!empty($this->items[$field])) {
|
||||
if ($this->options['type'] == 'separator') {
|
||||
return implode($this->sanitize_value($this->options['separator']), $this->items[$field]);
|
||||
}
|
||||
else {
|
||||
return theme('item_list',
|
||||
array(
|
||||
'items' => $this->items[$field],
|
||||
'title' => NULL,
|
||||
'type' => $this->options['type']
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render all items in this field together.
|
||||
*
|
||||
* When using advanced render, each possible item in the list is rendered
|
||||
* individually. Then the items are all pasted together.
|
||||
*/
|
||||
function render_items($items) {
|
||||
if (!empty($items)) {
|
||||
if ($this->options['type'] == 'separator') {
|
||||
return implode($this->sanitize_value($this->options['separator'], 'xss_admin'), $items);
|
||||
}
|
||||
else {
|
||||
return theme('item_list',
|
||||
array(
|
||||
'items' => $items,
|
||||
'title' => NULL,
|
||||
'type' => $this->options['type']
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of items for the field.
|
||||
*
|
||||
* Items should be stored in the result array, if possible, as an array
|
||||
* with 'value' as the actual displayable value of the item, plus
|
||||
* any items that might be found in the 'alter' options array for
|
||||
* creating links, such as 'path', 'fragment', 'query' etc, such a thing
|
||||
* is to be made. Additionally, items that might be turned into tokens
|
||||
* should also be in this array.
|
||||
*/
|
||||
function get_items($values) {
|
||||
// Only the parent get_value returns a single field.
|
||||
$field = parent::get_value($values);
|
||||
if (!empty($this->items[$field])) {
|
||||
return $this->items[$field];
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value that's supposed to be rendered.
|
||||
*
|
||||
* @param $values
|
||||
* An object containing all retrieved values.
|
||||
* @param $field
|
||||
* Optional name of the field where the value is stored.
|
||||
* @param $raw
|
||||
* Use the raw data and not the data defined in pre_render
|
||||
*/
|
||||
function get_value($values, $field = NULL, $raw = FALSE) {
|
||||
if ($raw) {
|
||||
return parent::get_value($values, $field);
|
||||
}
|
||||
$item = $this->get_items($values);
|
||||
$item = (array) $item;
|
||||
if (isset($field) && isset($item[$field])) {
|
||||
return $item[$field];
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if advanced rendering is allowed.
|
||||
*
|
||||
* By default, advanced rendering will NOT be allowed if the class
|
||||
* inheriting from this does not implement a 'render_items' method.
|
||||
*/
|
||||
function allow_advanced_render() {
|
||||
// Note that the advanced render bits also use the presence of
|
||||
// this method to determine if it needs to render items as a list.
|
||||
return method_exists($this, 'render_item');
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_field_serialized.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Field handler to show data of serialized fields.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_field_serialized extends views_handler_field {
|
||||
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['format'] = array('default' => 'unserialized');
|
||||
$options['key'] = array('default' => '');
|
||||
return $options;
|
||||
}
|
||||
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
$form['format'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Display format'),
|
||||
'#description' => t('How should the serialized data be displayed. You can choose a custom array/object key or a print_r on the full output.'),
|
||||
'#options' => array(
|
||||
'unserialized' => t('Full data (unserialized)'),
|
||||
'serialized' => t('Full data (serialized)'),
|
||||
'key' => t('A certain key'),
|
||||
),
|
||||
'#default_value' => $this->options['format'],
|
||||
);
|
||||
$form['key'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Which key should be displayed'),
|
||||
'#default_value' => $this->options['key'],
|
||||
'#dependency' => array('edit-options-format' => array('key')),
|
||||
);
|
||||
}
|
||||
|
||||
function options_validate(&$form, &$form_state) {
|
||||
// Require a key if the format is key.
|
||||
if ($form_state['values']['options']['format'] == 'key' && $form_state['values']['options']['key'] == '') {
|
||||
form_error($form['key'], t('You have to enter a key if you want to display a key of the data.'));
|
||||
}
|
||||
}
|
||||
|
||||
function render($values) {
|
||||
$value = $values->{$this->field_alias};
|
||||
|
||||
if ($this->options['format'] == 'unserialized') {
|
||||
return check_plain(print_r(unserialize($value), TRUE));
|
||||
}
|
||||
elseif ($this->options['format'] == 'key' && !empty($this->options['key'])) {
|
||||
$value = (array) unserialize($value);
|
||||
return check_plain($value[$this->options['key']]);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_field_time_interval.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A handler to provide proper displays for time intervals.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_field_time_interval extends views_handler_field {
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['granularity'] = array('default' => 2);
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
$form['granularity'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Granularity'),
|
||||
'#description' => t('How many different units to display in the string.'),
|
||||
'#default_value' => $this->options['granularity'],
|
||||
);
|
||||
}
|
||||
|
||||
function render($values) {
|
||||
$value = $values->{$this->field_alias};
|
||||
return format_interval($value, isset($this->options['granularity']) ? $this->options['granularity'] : 2);
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_field_url.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Field handler to provide simple renderer that turns a URL into a clickable link.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_field_url extends views_handler_field {
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['display_as_link'] = array('default' => TRUE, 'bool' => TRUE);
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide link to the page being visited.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
$form['display_as_link'] = array(
|
||||
'#title' => t('Display as link'),
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => !empty($this->options['display_as_link']),
|
||||
);
|
||||
parent::options_form($form, $form_state);
|
||||
}
|
||||
|
||||
function render($values) {
|
||||
$value = $this->get_value($values);
|
||||
if (!empty($this->options['display_as_link'])) {
|
||||
$this->options['alter']['make_link'] = TRUE;
|
||||
$this->options['alter']['path'] = $value;
|
||||
$text = !empty($this->options['text']) ? $this->sanitize_value($this->options['text']) : $this->sanitize_value($value, 'url');
|
||||
return $text;
|
||||
}
|
||||
else {
|
||||
return $this->sanitize_value($value, 'url');
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,179 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_filter_boolean_operator.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Simple filter to handle matching of boolean values
|
||||
*
|
||||
* Definition items:
|
||||
* - label: (REQUIRED) The label for the checkbox.
|
||||
* - type: For basic 'true false' types, an item can specify the following:
|
||||
* - true-false: True/false (this is the default)
|
||||
* - yes-no: Yes/No
|
||||
* - on-off: On/Off
|
||||
* - enabled-disabled: Enabled/Disabled
|
||||
* - accept null: Treat a NULL value as false.
|
||||
* - use equal: If you use this flag the query will use = 1 instead of <> 0.
|
||||
* This might be helpful for performance reasons.
|
||||
*
|
||||
* @ingroup views_filter_handlers
|
||||
*/
|
||||
class views_handler_filter_boolean_operator extends views_handler_filter {
|
||||
// exposed filter options
|
||||
var $always_multiple = TRUE;
|
||||
// Don't display empty space where the operator would be.
|
||||
var $no_operator = TRUE;
|
||||
// Whether to accept NULL as a false value or not
|
||||
var $accept_null = FALSE;
|
||||
|
||||
function construct() {
|
||||
$this->value_value = t('True');
|
||||
if (isset($this->definition['label'])) {
|
||||
$this->value_value = $this->definition['label'];
|
||||
}
|
||||
if (isset($this->definition['accept null'])) {
|
||||
$this->accept_null = (bool) $this->definition['accept null'];
|
||||
}
|
||||
else if (isset($this->definition['accept_null'])) {
|
||||
$this->accept_null = (bool) $this->definition['accept_null'];
|
||||
}
|
||||
$this->value_options = NULL;
|
||||
parent::construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the possible options for this filter.
|
||||
*
|
||||
* Child classes should override this function to set the possible values
|
||||
* for the filter. Since this is a boolean filter, the array should have
|
||||
* two possible keys: 1 for "True" and 0 for "False", although the labels
|
||||
* can be whatever makes sense for the filter. These values are used for
|
||||
* configuring the filter, when the filter is exposed, and in the admin
|
||||
* summary of the filter. Normally, this should be static data, but if it's
|
||||
* dynamic for some reason, child classes should use a guard to reduce
|
||||
* database hits as much as possible.
|
||||
*/
|
||||
function get_value_options() {
|
||||
if (isset($this->definition['type'])) {
|
||||
if ($this->definition['type'] == 'yes-no') {
|
||||
$this->value_options = array(1 => t('Yes'), 0 => t('No'));
|
||||
}
|
||||
if ($this->definition['type'] == 'on-off') {
|
||||
$this->value_options = array(1 => t('On'), 0 => t('Off'));
|
||||
}
|
||||
if ($this->definition['type'] == 'enabled-disabled') {
|
||||
$this->value_options = array(1 => t('Enabled'), 0 => t('Disabled'));
|
||||
}
|
||||
}
|
||||
|
||||
// Provide a fallback if the above didn't set anything.
|
||||
if (!isset($this->value_options)) {
|
||||
$this->value_options = array(1 => t('True'), 0 => t('False'));
|
||||
}
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['value']['default'] = FALSE;
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function operator_form(&$form, &$form_state) {
|
||||
$form['operator'] = array();
|
||||
}
|
||||
|
||||
function value_form(&$form, &$form_state) {
|
||||
if (empty($this->value_options)) {
|
||||
// Initialize the array of possible values for this filter.
|
||||
$this->get_value_options();
|
||||
}
|
||||
if (!empty($form_state['exposed'])) {
|
||||
// Exposed filter: use a select box to save space.
|
||||
$filter_form_type = 'select';
|
||||
}
|
||||
else {
|
||||
// Configuring a filter: use radios for clarity.
|
||||
$filter_form_type = 'radios';
|
||||
}
|
||||
$form['value'] = array(
|
||||
'#type' => $filter_form_type,
|
||||
'#title' => $this->value_value,
|
||||
'#options' => $this->value_options,
|
||||
'#default_value' => $this->value,
|
||||
);
|
||||
if (!empty($this->options['exposed'])) {
|
||||
$identifier = $this->options['expose']['identifier'];
|
||||
if (!empty($form_state['exposed']) && !isset($form_state['input'][$identifier])) {
|
||||
$form_state['input'][$identifier] = $this->value;
|
||||
}
|
||||
// If we're configuring an exposed filter, add an <Any> option.
|
||||
if (empty($form_state['exposed']) || empty($this->options['expose']['required'])) {
|
||||
$any_label = variable_get('views_exposed_filter_any_label', 'new_any') == 'old_any' ? '<Any>' : t('- Any -');
|
||||
if ($form['value']['#type'] != 'select') {
|
||||
$any_label = check_plain($any_label);
|
||||
}
|
||||
$form['value']['#options'] = array('All' => $any_label) + $form['value']['#options'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function value_validate($form, &$form_state) {
|
||||
if ($form_state['values']['options']['value'] == 'All' && !empty($form_state['values']['options']['expose']['required'])) {
|
||||
form_set_error('value', t('You must select a value unless this is an non-required exposed filter.'));
|
||||
}
|
||||
}
|
||||
|
||||
function admin_summary() {
|
||||
if ($this->is_a_group()) {
|
||||
return t('grouped');
|
||||
}
|
||||
if (!empty($this->options['exposed'])) {
|
||||
return t('exposed');
|
||||
}
|
||||
if (empty($this->value_options)) {
|
||||
$this->get_value_options();
|
||||
}
|
||||
// Now that we have the valid options for this filter, just return the
|
||||
// human-readable label based on the current value. The value_options
|
||||
// array is keyed with either 0 or 1, so if the current value is not
|
||||
// empty, use the label for 1, and if it's empty, use the label for 0.
|
||||
return $this->value_options[!empty($this->value)];
|
||||
}
|
||||
|
||||
function expose_options() {
|
||||
parent::expose_options();
|
||||
$this->options['expose']['operator_id'] = '';
|
||||
$this->options['expose']['label'] = $this->value_value;
|
||||
$this->options['expose']['required'] = TRUE;
|
||||
}
|
||||
|
||||
function query() {
|
||||
$this->ensure_my_table();
|
||||
$field = "$this->table_alias.$this->real_field";
|
||||
|
||||
if (empty($this->value)) {
|
||||
if ($this->accept_null) {
|
||||
$or = db_or()
|
||||
->condition($field, 0, '=')
|
||||
->condition($field, NULL, 'IS NULL');
|
||||
$this->query->add_where($this->options['group'], $or);
|
||||
}
|
||||
else {
|
||||
$this->query->add_where($this->options['group'], $field, 0, '=');
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!empty($this->definition['use equal'])) {
|
||||
$this->query->add_where($this->options['group'], $field, 1, '=');
|
||||
}
|
||||
else {
|
||||
$this->query->add_where($this->options['group'], $field, 0, '<>');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_filter_boolean_operator_string.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Simple filter to handle matching of boolean values.
|
||||
*
|
||||
* This handler checks to see if a string field is empty (equal to '') or not.
|
||||
* It is otherwise identical to the parent operator.
|
||||
*
|
||||
* Definition items:
|
||||
* - label: (REQUIRED) The label for the checkbox.
|
||||
*
|
||||
* @ingroup views_filter_handlers
|
||||
*/
|
||||
class views_handler_filter_boolean_operator_string extends views_handler_filter_boolean_operator {
|
||||
function query() {
|
||||
$this->ensure_my_table();
|
||||
$where = "$this->table_alias.$this->real_field ";
|
||||
|
||||
if (empty($this->value)) {
|
||||
$where .= "= ''";
|
||||
if ($this->accept_null) {
|
||||
$where = '(' . $where . " OR $this->table_alias.$this->real_field IS NULL)";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$where .= "<> ''";
|
||||
}
|
||||
$this->query->add_where($this->options['group'], $where);
|
||||
}
|
||||
}
|
@ -0,0 +1,170 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_filter_combine.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Filter handler which allows to search on multiple fields.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_filter_combine extends views_handler_filter_string {
|
||||
/**
|
||||
* @var views_plugin_query_default
|
||||
*/
|
||||
public $query;
|
||||
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['fields'] = array('default' => array());
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$this->view->init_style();
|
||||
|
||||
// Allow to choose all fields as possible.
|
||||
if ($this->view->style_plugin->uses_fields()) {
|
||||
$options = array();
|
||||
foreach ($this->view->display_handler->get_handlers('field') as $name => $field) {
|
||||
$options[$name] = $field->ui_name(TRUE);
|
||||
}
|
||||
if ($options) {
|
||||
$form['fields'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Choose fields to combine for filtering'),
|
||||
'#description' => t("This filter doesn't work for very special field handlers."),
|
||||
'#multiple' => TRUE,
|
||||
'#options' => $options,
|
||||
'#default_value' => $this->options['fields'],
|
||||
);
|
||||
}
|
||||
else {
|
||||
form_set_error('', t('You have to add some fields to be able to use this filter.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function query() {
|
||||
$this->view->_build('field');
|
||||
$fields = array();
|
||||
// Only add the fields if they have a proper field and table alias.
|
||||
foreach ($this->options['fields'] as $id) {
|
||||
$field = $this->view->field[$id];
|
||||
// Always add the table of the selected fields to be sure a table alias
|
||||
// exists.
|
||||
$field->ensure_my_table();
|
||||
if (!empty($field->field_alias) && !empty($field->field_alias)) {
|
||||
$fields[] = "$field->table_alias.$field->real_field";
|
||||
}
|
||||
}
|
||||
if ($fields) {
|
||||
$count = count($fields);
|
||||
$separated_fields = array();
|
||||
foreach ($fields as $key => $field) {
|
||||
$separated_fields[] = $field;
|
||||
if ($key < $count - 1) {
|
||||
$separated_fields[] = "' '";
|
||||
}
|
||||
}
|
||||
$expression = implode(', ', $separated_fields);
|
||||
$expression = "CONCAT_WS(' ', $expression)";
|
||||
|
||||
$info = $this->operators();
|
||||
if (!empty($info[$this->operator]['method'])) {
|
||||
$this->{$info[$this->operator]['method']}($expression);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// By default things like op_equal uses add_where, that doesn't support
|
||||
// complex expressions, so override all operators.
|
||||
function op_equal($field) {
|
||||
$placeholder = $this->placeholder();
|
||||
$operator = $this->operator();
|
||||
$this->query->add_where_expression($this->options['group'], "$field $operator $placeholder", array($placeholder => $this->value));
|
||||
}
|
||||
|
||||
function op_contains($field) {
|
||||
$placeholder = $this->placeholder();
|
||||
$this->query->add_where_expression($this->options['group'], "$field LIKE $placeholder", array($placeholder => '%' . db_like($this->value) . '%'));
|
||||
}
|
||||
|
||||
function op_word($field) {
|
||||
$where = $this->operator == 'word' ? db_or() : db_and();
|
||||
|
||||
// Don't filter on empty strings.
|
||||
if (empty($this->value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
preg_match_all('/ (-?)("[^"]+"|[^" ]+)/i', ' ' . $this->value, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $match) {
|
||||
$phrase = FALSE;
|
||||
// Strip off phrase quotes.
|
||||
if ($match[2]{0} == '"') {
|
||||
$match[2] = substr($match[2], 1, -1);
|
||||
$phrase = TRUE;
|
||||
}
|
||||
$words = trim($match[2], ',?!();:-');
|
||||
$words = $phrase ? array($words) : preg_split('/ /', $words, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$placeholder = $this->placeholder();
|
||||
foreach ($words as $word) {
|
||||
$where->where($field . " LIKE $placeholder", array($placeholder => '%' . db_like(trim($word, " ,!?")) . '%'));
|
||||
}
|
||||
}
|
||||
|
||||
if (!$where) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Previously this was a call_user_func_array() but that's unnecessary
|
||||
// as views will unpack an array that is a single arg.
|
||||
$this->query->add_where($this->options['group'], $where);
|
||||
}
|
||||
|
||||
function op_starts($field) {
|
||||
$placeholder = $this->placeholder();
|
||||
$this->query->add_where_expression($this->options['group'], "$field LIKE $placeholder", array($placeholder => db_like($this->value) . '%'));
|
||||
}
|
||||
|
||||
function op_not_starts($field) {
|
||||
$placeholder = $this->placeholder();
|
||||
$this->query->add_where_expression($this->options['group'], "$field NOT LIKE $placeholder", array($placeholder => db_like($this->value) . '%'));
|
||||
}
|
||||
|
||||
function op_ends($field) {
|
||||
$placeholder = $this->placeholder();
|
||||
$this->query->add_where_expression($this->options['group'], "$field LIKE $placeholder", array($placeholder => '%' . db_like($this->value)));
|
||||
}
|
||||
|
||||
function op_not_ends($field) {
|
||||
$placeholder = $this->placeholder();
|
||||
$this->query->add_where_expression($this->options['group'], "$field NOT LIKE $placeholder", array($placeholder => '%' . db_like($this->value)));
|
||||
}
|
||||
|
||||
function op_not($field) {
|
||||
$placeholder = $this->placeholder();
|
||||
$this->query->add_where_expression($this->options['group'], "$field NOT LIKE $placeholder", array($placeholder => '%' . db_like($this->value) . '%'));
|
||||
}
|
||||
|
||||
function op_regex($field) {
|
||||
$placeholder = $this->placeholder();
|
||||
$this->query->add_where_expression($this->options['group'], "$field RLIKE $placeholder", array($placeholder => $this->value));
|
||||
}
|
||||
|
||||
function op_empty($field) {
|
||||
if ($this->operator == 'empty') {
|
||||
$operator = "IS NULL";
|
||||
}
|
||||
else {
|
||||
$operator = "IS NOT NULL";
|
||||
}
|
||||
|
||||
$this->query->add_where_expression($this->options['group'], "$field $operator");
|
||||
}
|
||||
}
|
@ -0,0 +1,183 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_filter_date.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Filter to handle dates stored as a timestamp.
|
||||
*
|
||||
* @ingroup views_filter_handlers
|
||||
*/
|
||||
class views_handler_filter_date extends views_handler_filter_numeric {
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
// value is already set up properly, we're just adding our new field to it.
|
||||
$options['value']['contains']['type']['default'] = 'date';
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a type selector to the value form
|
||||
*/
|
||||
function value_form(&$form, &$form_state) {
|
||||
if (empty($form_state['exposed'])) {
|
||||
$form['value']['type'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Value type'),
|
||||
'#options' => array(
|
||||
'date' => t('A date in any machine readable format. CCYY-MM-DD HH:MM:SS is preferred.'),
|
||||
'offset' => t('An offset from the current time such as "!example1" or "!example2"', array('!example1' => '+1 day', '!example2' => '-2 hours -30 minutes')),
|
||||
),
|
||||
'#default_value' => !empty($this->value['type']) ? $this->value['type'] : 'date',
|
||||
);
|
||||
}
|
||||
parent::value_form($form, $form_state);
|
||||
}
|
||||
|
||||
function options_validate(&$form, &$form_state) {
|
||||
parent::options_validate($form, $form_state);
|
||||
|
||||
if (!empty($this->options['exposed']) && empty($form_state['values']['options']['expose']['required'])) {
|
||||
// Who cares what the value is if it's exposed and non-required.
|
||||
return;
|
||||
}
|
||||
|
||||
$this->validate_valid_time($form['value'], $form_state['values']['options']['operator'], $form_state['values']['options']['value']);
|
||||
}
|
||||
|
||||
function exposed_validate(&$form, &$form_state) {
|
||||
if (empty($this->options['exposed'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($this->options['expose']['required'])) {
|
||||
// Who cares what the value is if it's exposed and non-required.
|
||||
return;
|
||||
}
|
||||
|
||||
$value = &$form_state['values'][$this->options['expose']['identifier']];
|
||||
if (!empty($this->options['expose']['use_operator']) && !empty($this->options['expose']['operator_id'])) {
|
||||
$operator = $form_state['values'][$this->options['expose']['operator_id']];
|
||||
}
|
||||
else {
|
||||
$operator = $this->operator;
|
||||
}
|
||||
|
||||
$this->validate_valid_time($this->options['expose']['identifier'], $operator, $value);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that the time values convert to something usable.
|
||||
*/
|
||||
function validate_valid_time(&$form, $operator, $value) {
|
||||
$operators = $this->operators();
|
||||
|
||||
if ($operators[$operator]['values'] == 1) {
|
||||
$convert = strtotime($value['value']);
|
||||
if (!empty($form['value']) && ($convert == -1 || $convert === FALSE)) {
|
||||
form_error($form['value'], t('Invalid date format.'));
|
||||
}
|
||||
}
|
||||
elseif ($operators[$operator]['values'] == 2) {
|
||||
$min = strtotime($value['min']);
|
||||
if ($min == -1 || $min === FALSE) {
|
||||
form_error($form['min'], t('Invalid date format.'));
|
||||
}
|
||||
$max = strtotime($value['max']);
|
||||
if ($max == -1 || $max === FALSE) {
|
||||
form_error($form['max'], t('Invalid date format.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the build group options form.
|
||||
*/
|
||||
function build_group_validate($form, &$form_state) {
|
||||
// Special case to validate grouped date filters, this is because the
|
||||
// $group['value'] array contains the type of filter (date or offset)
|
||||
// and therefore the number of items the comparission has to be done
|
||||
// against 'one' instead of 'zero'.
|
||||
foreach ($form_state['values']['options']['group_info']['group_items'] as $id => $group) {
|
||||
if (empty($group['remove'])) {
|
||||
// Check if the title is defined but value wasn't defined.
|
||||
if (!empty($group['title'])) {
|
||||
if ((!is_array($group['value']) && empty($group['value'])) || (is_array($group['value']) && count(array_filter($group['value'])) == 1)) {
|
||||
form_error($form['group_info']['group_items'][$id]['value'], t('The value is required if title for this item is defined.'));
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the value is defined but title wasn't defined.
|
||||
if ((!is_array($group['value']) && !empty($group['value'])) || (is_array($group['value']) && count(array_filter($group['value'])) > 1)) {
|
||||
if (empty($group['title'])) {
|
||||
form_error($form['group_info']['group_items'][$id]['title'], t('The title is required if value for this item is defined.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function accept_exposed_input($input) {
|
||||
if (empty($this->options['exposed'])) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Store this because it will get overwritten.
|
||||
$type = $this->value['type'];
|
||||
$rc = parent::accept_exposed_input($input);
|
||||
|
||||
// Don't filter if value(s) are empty.
|
||||
$operators = $this->operators();
|
||||
if (!empty($this->options['expose']['use_operator']) && !empty($this->options['expose']['operator_id'])) {
|
||||
$operator = $input[$this->options['expose']['operator_id']];
|
||||
}
|
||||
else {
|
||||
$operator = $this->operator;
|
||||
}
|
||||
|
||||
if ($operators[$operator]['values'] == 1) {
|
||||
if ($this->value['value'] == '') {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($this->value['min'] == '' || $this->value['max'] == '') {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// restore what got overwritten by the parent.
|
||||
$this->value['type'] = $type;
|
||||
return $rc;
|
||||
}
|
||||
|
||||
function op_between($field) {
|
||||
$a = intval(strtotime($this->value['min'], 0));
|
||||
$b = intval(strtotime($this->value['max'], 0));
|
||||
|
||||
if ($this->value['type'] == 'offset') {
|
||||
$a = '***CURRENT_TIME***' . sprintf('%+d', $a); // keep sign
|
||||
$b = '***CURRENT_TIME***' . sprintf('%+d', $b); // keep sign
|
||||
}
|
||||
// This is safe because we are manually scrubbing the values.
|
||||
// It is necessary to do it this way because $a and $b are formulas when using an offset.
|
||||
$operator = strtoupper($this->operator);
|
||||
$this->query->add_where_expression($this->options['group'], "$field $operator $a AND $b");
|
||||
}
|
||||
|
||||
function op_simple($field) {
|
||||
$value = intval(strtotime($this->value['value'], 0));
|
||||
if (!empty($this->value['type']) && $this->value['type'] == 'offset') {
|
||||
$value = '***CURRENT_TIME***' . sprintf('%+d', $value); // keep sign
|
||||
}
|
||||
// This is safe because we are manually scrubbing the value.
|
||||
// It is necessary to do it this way because $value is a formula when using an offset.
|
||||
$this->query->add_where_expression($this->options['group'], "$field $this->operator $value");
|
||||
}
|
||||
}
|
@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_filter_entity_bundle
|
||||
*/
|
||||
|
||||
/**
|
||||
* Filter class which allows to filter by certain bundles of an entity.
|
||||
*
|
||||
* This class provides workarounds for taxonomy and comment.
|
||||
*
|
||||
* @ingroup views_filter_handlers
|
||||
*/
|
||||
class views_handler_filter_entity_bundle extends views_handler_filter_in_operator {
|
||||
/**
|
||||
* Stores the entity type on which the filter filters.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $entity_type;
|
||||
|
||||
function init(&$view, &$options) {
|
||||
parent::init($view, $options);
|
||||
|
||||
$this->get_entity_type();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set and returns the entity_type.
|
||||
*
|
||||
* @return string
|
||||
* The entity type on the filter.
|
||||
*/
|
||||
function get_entity_type() {
|
||||
if (!isset($this->entity_type)) {
|
||||
$data = views_fetch_data($this->table);
|
||||
if (isset($data['table']['entity type'])) {
|
||||
$this->entity_type = $data['table']['entity type'];
|
||||
}
|
||||
|
||||
// If the current filter is under a relationship you can't be sure that the
|
||||
// entity type of the view is the entity type of the current filter
|
||||
// For example a filter from a node author on a node view does have users as entity type.
|
||||
if (!empty($this->options['relationship']) && $this->options['relationship'] != 'none') {
|
||||
$relationships = $this->view->display_handler->get_option('relationships');
|
||||
if (!empty($relationships[$this->options['relationship']])) {
|
||||
$options = $relationships[$this->options['relationship']];
|
||||
$data = views_fetch_data($options['table']);
|
||||
$this->entity_type = $data['table']['entity type'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->entity_type;
|
||||
}
|
||||
|
||||
|
||||
function get_value_options() {
|
||||
if (!isset($this->value_options)) {
|
||||
$info = entity_get_info($this->entity_type);
|
||||
$types = $info['bundles'];
|
||||
$this->value_title = t('@entity types', array('@entity' => $info['label']));
|
||||
|
||||
$options = array();
|
||||
foreach ($types as $type => $info) {
|
||||
$options[$type] = t($info['label']);
|
||||
}
|
||||
asort($options);
|
||||
$this->value_options = $options;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* All entity types beside comment and taxonomy terms have a proper implement
|
||||
* bundle, though these two need an additional join to node/vocab table
|
||||
* to work as required.
|
||||
*/
|
||||
function query() {
|
||||
$this->ensure_my_table();
|
||||
|
||||
// Adjust the join for the comment case.
|
||||
if ($this->entity_type == 'comment') {
|
||||
$join = new views_join();
|
||||
$def = array(
|
||||
'table' => 'node',
|
||||
'field' => 'nid',
|
||||
'left_table' => $this->table_alias,
|
||||
'left_field' => 'nid',
|
||||
);
|
||||
$join->definition = $def;
|
||||
$join->construct();
|
||||
$join->adjusted = TRUE;
|
||||
$this->table_alias = $this->query->add_table('node', $this->relationship, $join);
|
||||
$this->real_field = 'type';
|
||||
|
||||
// Replace the value to match the node type column.
|
||||
foreach ($this->value as &$value) {
|
||||
$value = str_replace('comment_node_', '', $value);
|
||||
}
|
||||
}
|
||||
elseif ($this->entity_type == 'taxonomy_term') {
|
||||
$join = new views_join();
|
||||
$def = array(
|
||||
'table' => 'taxonomy_vocabulary',
|
||||
'field' => 'vid',
|
||||
'left_table' => $this->table_alias,
|
||||
'left_field' => 'vid',
|
||||
);
|
||||
$join->definition = $def;
|
||||
$join->construct();
|
||||
$join->adjusted = TRUE;
|
||||
$this->table_alias = $this->query->add_table('taxonomy_vocabulary', $this->relationship, $join);
|
||||
$this->real_field = 'machine_name';
|
||||
}
|
||||
else {
|
||||
$entity_info = entity_get_info($this->entity_type);
|
||||
$this->real_field = $entity_info['bundle keys']['bundle'];
|
||||
}
|
||||
parent::query();
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_filter_equality.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Simple filter to handle equal to / not equal to filters
|
||||
*
|
||||
* @ingroup views_filter_handlers
|
||||
*/
|
||||
class views_handler_filter_equality extends views_handler_filter {
|
||||
// exposed filter options
|
||||
var $always_multiple = TRUE;
|
||||
|
||||
/**
|
||||
* Provide simple equality operator
|
||||
*/
|
||||
function operator_options() {
|
||||
return array(
|
||||
'=' => t('Is equal to'),
|
||||
'!=' => t('Is not equal to'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a simple textfield for equality
|
||||
*/
|
||||
function value_form(&$form, &$form_state) {
|
||||
$form['value'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Value'),
|
||||
'#size' => 30,
|
||||
'#default_value' => $this->value,
|
||||
);
|
||||
|
||||
if (!empty($form_state['exposed'])) {
|
||||
$identifier = $this->options['expose']['identifier'];
|
||||
if (!isset($form_state['input'][$identifier])) {
|
||||
$form_state['input'][$identifier] = $this->value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_filter_group_by_numeric.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Simple filter to handle greater than/less than filters
|
||||
*
|
||||
* @ingroup views_filter_handlers
|
||||
*/
|
||||
class views_handler_filter_group_by_numeric extends views_handler_filter_numeric {
|
||||
function query() {
|
||||
$this->ensure_my_table();
|
||||
$field = $this->get_field();
|
||||
|
||||
$info = $this->operators();
|
||||
if (!empty($info[$this->operator]['method'])) {
|
||||
$this->{$info[$this->operator]['method']}($field);
|
||||
}
|
||||
}
|
||||
function op_between($field) {
|
||||
$placeholder_min = $this->placeholder();
|
||||
$placeholder_max = $this->placeholder();
|
||||
if ($this->operator == 'between') {
|
||||
$this->query->add_having_expression($this->options['group'], "$field >= $placeholder_min", array($placeholder_min => $this->value['min']));
|
||||
$this->query->add_having_expression($this->options['group'], "$field <= $placeholder_max", array($placeholder_max => $this->value['max']));
|
||||
}
|
||||
else {
|
||||
$this->query->add_having_expression($this->options['group'], "$field <= $placeholder_min OR $field >= $placeholder_max", array($placeholder_min => $this->value['min'], $placeholder_max => $this->value['max']));
|
||||
}
|
||||
}
|
||||
|
||||
function op_simple($field) {
|
||||
$placeholder = $this->placeholder();
|
||||
$this->query->add_having_expression($this->options['group'], "$field $this->operator $placeholder", array($placeholder => $this->value['value']));
|
||||
}
|
||||
|
||||
function op_empty($field) {
|
||||
if ($this->operator == 'empty') {
|
||||
$operator = "IS NULL";
|
||||
}
|
||||
else {
|
||||
$operator = "IS NOT NULL";
|
||||
}
|
||||
|
||||
$this->query->add_having_expression($this->options['group'], "$field $operator");
|
||||
}
|
||||
|
||||
function ui_name($short = FALSE) {
|
||||
return $this->get_field(parent::ui_name($short));
|
||||
}
|
||||
|
||||
function can_group() { return FALSE; }
|
||||
}
|
@ -0,0 +1,426 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_filter_in_operator.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Simple filter to handle matching of multiple options selectable via checkboxes
|
||||
*
|
||||
* Definition items:
|
||||
* - options callback: The function to call in order to generate the value options. If omitted, the options 'Yes' and 'No' will be used.
|
||||
* - options arguments: An array of arguments to pass to the options callback.
|
||||
*
|
||||
* @ingroup views_filter_handlers
|
||||
*/
|
||||
class views_handler_filter_in_operator extends views_handler_filter {
|
||||
var $value_form_type = 'checkboxes';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* Stores all operations which are available on the form.
|
||||
*/
|
||||
var $value_options = NULL;
|
||||
|
||||
function construct() {
|
||||
parent::construct();
|
||||
$this->value_title = t('Options');
|
||||
$this->value_options = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Child classes should be used to override this function and set the
|
||||
* 'value options', unless 'options callback' is defined as a valid function
|
||||
* or static public method to generate these values.
|
||||
*
|
||||
* This can use a guard to be used to reduce database hits as much as
|
||||
* possible.
|
||||
*
|
||||
* @return
|
||||
* Return the stored values in $this->value_options if someone expects it.
|
||||
*/
|
||||
function get_value_options() {
|
||||
if (isset($this->value_options)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($this->definition['options callback']) && is_callable($this->definition['options callback'])) {
|
||||
if (isset($this->definition['options arguments']) && is_array($this->definition['options arguments'])) {
|
||||
$this->value_options = call_user_func_array($this->definition['options callback'], $this->definition['options arguments']);
|
||||
}
|
||||
else {
|
||||
$this->value_options = call_user_func($this->definition['options callback']);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->value_options = array(t('Yes'), t('No'));
|
||||
}
|
||||
|
||||
return $this->value_options;
|
||||
}
|
||||
|
||||
function expose_options() {
|
||||
parent::expose_options();
|
||||
$this->options['expose']['reduce'] = FALSE;
|
||||
}
|
||||
|
||||
function expose_form(&$form, &$form_state) {
|
||||
parent::expose_form($form, $form_state);
|
||||
$form['expose']['reduce'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Limit list to selected items'),
|
||||
'#description' => t('If checked, the only items presented to the user will be the ones selected here.'),
|
||||
'#default_value' => !empty($this->options['expose']['reduce']), // safety
|
||||
);
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['operator']['default'] = 'in';
|
||||
$options['value']['default'] = array();
|
||||
$options['expose']['contains']['reduce'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* This kind of construct makes it relatively easy for a child class
|
||||
* to add or remove functionality by overriding this function and
|
||||
* adding/removing items from this array.
|
||||
*/
|
||||
function operators() {
|
||||
$operators = array(
|
||||
'in' => array(
|
||||
'title' => t('Is one of'),
|
||||
'short' => t('in'),
|
||||
'short_single' => t('='),
|
||||
'method' => 'op_simple',
|
||||
'values' => 1,
|
||||
),
|
||||
'not in' => array(
|
||||
'title' => t('Is not one of'),
|
||||
'short' => t('not in'),
|
||||
'short_single' => t('<>'),
|
||||
'method' => 'op_simple',
|
||||
'values' => 1,
|
||||
),
|
||||
);
|
||||
// if the definition allows for the empty operator, add it.
|
||||
if (!empty($this->definition['allow empty'])) {
|
||||
$operators += array(
|
||||
'empty' => array(
|
||||
'title' => t('Is empty (NULL)'),
|
||||
'method' => 'op_empty',
|
||||
'short' => t('empty'),
|
||||
'values' => 0,
|
||||
),
|
||||
'not empty' => array(
|
||||
'title' => t('Is not empty (NOT NULL)'),
|
||||
'method' => 'op_empty',
|
||||
'short' => t('not empty'),
|
||||
'values' => 0,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return $operators;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build strings from the operators() for 'select' options
|
||||
*/
|
||||
function operator_options($which = 'title') {
|
||||
$options = array();
|
||||
foreach ($this->operators() as $id => $info) {
|
||||
$options[$id] = $info[$which];
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function operator_values($values = 1) {
|
||||
$options = array();
|
||||
foreach ($this->operators() as $id => $info) {
|
||||
if (isset($info['values']) && $info['values'] == $values) {
|
||||
$options[] = $id;
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function value_form(&$form, &$form_state) {
|
||||
$form['value'] = array();
|
||||
$options = array();
|
||||
|
||||
if (empty($form_state['exposed'])) {
|
||||
// Add a select all option to the value form.
|
||||
$options = array('all' => t('Select all'));
|
||||
}
|
||||
|
||||
$this->get_value_options();
|
||||
$options += $this->value_options;
|
||||
$default_value = (array) $this->value;
|
||||
|
||||
$which = 'all';
|
||||
if (!empty($form['operator'])) {
|
||||
$source = ($form['operator']['#type'] == 'radios') ? 'radio:options[operator]' : 'edit-options-operator';
|
||||
}
|
||||
if (!empty($form_state['exposed'])) {
|
||||
$identifier = $this->options['expose']['identifier'];
|
||||
|
||||
if (empty($this->options['expose']['use_operator']) || empty($this->options['expose']['operator_id'])) {
|
||||
// exposed and locked.
|
||||
$which = in_array($this->operator, $this->operator_values(1)) ? 'value' : 'none';
|
||||
}
|
||||
else {
|
||||
$source = 'edit-' . drupal_html_id($this->options['expose']['operator_id']);
|
||||
}
|
||||
|
||||
if (!empty($this->options['expose']['reduce'])) {
|
||||
$options = $this->reduce_value_options();
|
||||
|
||||
if (!empty($this->options['expose']['multiple']) && empty($this->options['expose']['required'])) {
|
||||
$default_value = array();
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($this->options['expose']['multiple'])) {
|
||||
if (empty($this->options['expose']['required']) && (empty($default_value) || !empty($this->options['expose']['reduce']))) {
|
||||
$default_value = 'All';
|
||||
}
|
||||
elseif (empty($default_value)) {
|
||||
$keys = array_keys($options);
|
||||
$default_value = array_shift($keys);
|
||||
}
|
||||
else {
|
||||
$copy = $default_value;
|
||||
$default_value = array_shift($copy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($which == 'all' || $which == 'value') {
|
||||
$form['value'] = array(
|
||||
'#type' => $this->value_form_type,
|
||||
'#title' => $this->value_title,
|
||||
'#options' => $options,
|
||||
'#default_value' => $default_value,
|
||||
// These are only valid for 'select' type, but do no harm to checkboxes.
|
||||
'#multiple' => TRUE,
|
||||
'#size' => count($options) > 8 ? 8 : count($options),
|
||||
);
|
||||
if (!empty($form_state['exposed']) && !isset($form_state['input'][$identifier])) {
|
||||
$form_state['input'][$identifier] = $default_value;
|
||||
}
|
||||
|
||||
if ($which == 'all') {
|
||||
if (empty($form_state['exposed']) && (in_array($this->value_form_type, array('checkbox', 'checkboxes', 'radios', 'select')))) {
|
||||
$form['value']['#prefix'] = '<div id="edit-options-value-wrapper">';
|
||||
$form['value']['#suffix'] = '</div>';
|
||||
}
|
||||
$form['value']['#dependency'] = array($source => $this->operator_values(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When using exposed filters, we may be required to reduce the set.
|
||||
*/
|
||||
function reduce_value_options($input = NULL) {
|
||||
if (!isset($input)) {
|
||||
$input = $this->value_options;
|
||||
}
|
||||
|
||||
// Because options may be an array of strings, or an array of mixed arrays
|
||||
// and strings (optgroups) or an array of objects, we have to
|
||||
// step through and handle each one individually.
|
||||
$options = array();
|
||||
foreach ($input as $id => $option) {
|
||||
if (is_array($option)) {
|
||||
$options[$id] = $this->reduce_value_options($option);
|
||||
continue;
|
||||
}
|
||||
elseif (is_object($option)) {
|
||||
$keys = array_keys($option->option);
|
||||
$key = array_shift($keys);
|
||||
if (isset($this->options['value'][$key])) {
|
||||
$options[$id] = $option;
|
||||
}
|
||||
}
|
||||
elseif (isset($this->options['value'][$id])) {
|
||||
$options[$id] = $option;
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
function accept_exposed_input($input) {
|
||||
// A very special override because the All state for this type of
|
||||
// filter could have a default:
|
||||
if (empty($this->options['exposed'])) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// If this is non-multiple and non-required, then this filter will
|
||||
// participate, but using the default settings, *if* 'limit is true.
|
||||
if (empty($this->options['expose']['multiple']) && empty($this->options['expose']['required']) && !empty($this->options['expose']['limit'])) {
|
||||
$identifier = $this->options['expose']['identifier'];
|
||||
if ($input[$identifier] == 'All') {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return parent::accept_exposed_input($input);
|
||||
}
|
||||
|
||||
function value_submit($form, &$form_state) {
|
||||
// Drupal's FAPI system automatically puts '0' in for any checkbox that
|
||||
// was not set, and the key to the checkbox if it is set.
|
||||
// Unfortunately, this means that if the key to that checkbox is 0,
|
||||
// we are unable to tell if that checkbox was set or not.
|
||||
|
||||
// Luckily, the '#value' on the checkboxes form actually contains
|
||||
// *only* a list of checkboxes that were set, and we can use that
|
||||
// instead.
|
||||
|
||||
$form_state['values']['options']['value'] = $form['value']['#value'];
|
||||
}
|
||||
|
||||
function admin_summary() {
|
||||
if ($this->is_a_group()) {
|
||||
return t('grouped');
|
||||
}
|
||||
if (!empty($this->options['exposed'])) {
|
||||
return t('exposed');
|
||||
}
|
||||
$info = $this->operators();
|
||||
|
||||
$this->get_value_options();
|
||||
|
||||
if (!is_array($this->value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$operator = check_plain($info[$this->operator]['short']);
|
||||
$values = '';
|
||||
if (in_array($this->operator, $this->operator_values(1))) {
|
||||
// Remove every element which is not known.
|
||||
foreach ($this->value as $value) {
|
||||
if (!isset($this->value_options[$value])) {
|
||||
unset($this->value[$value]);
|
||||
}
|
||||
}
|
||||
// Choose different kind of ouput for 0, a single and multiple values.
|
||||
if (count($this->value) == 0) {
|
||||
$values = t('Unknown');
|
||||
}
|
||||
else if (count($this->value) == 1) {
|
||||
// If any, use the 'single' short name of the operator instead.
|
||||
if (isset($info[$this->operator]['short_single'])) {
|
||||
$operator = check_plain($info[$this->operator]['short_single']);
|
||||
}
|
||||
|
||||
$keys = $this->value;
|
||||
$value = array_shift($keys);
|
||||
if (isset($this->value_options[$value])) {
|
||||
$values = check_plain($this->value_options[$value]);
|
||||
}
|
||||
else {
|
||||
$values = '';
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach ($this->value as $value) {
|
||||
if ($values !== '') {
|
||||
$values .= ', ';
|
||||
}
|
||||
if (drupal_strlen($values) > 8) {
|
||||
$values .= '...';
|
||||
break;
|
||||
}
|
||||
if (isset($this->value_options[$value])) {
|
||||
$values .= check_plain($this->value_options[$value]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $operator . (($values !== '') ? ' ' . $values : '');
|
||||
}
|
||||
|
||||
function query() {
|
||||
$info = $this->operators();
|
||||
if (!empty($info[$this->operator]['method'])) {
|
||||
$this->{$info[$this->operator]['method']}();
|
||||
}
|
||||
}
|
||||
|
||||
function op_simple() {
|
||||
if (empty($this->value)) {
|
||||
return;
|
||||
}
|
||||
$this->ensure_my_table();
|
||||
|
||||
// We use array_values() because the checkboxes keep keys and that can cause
|
||||
// array addition problems.
|
||||
$this->query->add_where($this->options['group'], "$this->table_alias.$this->real_field", array_values($this->value), $this->operator);
|
||||
}
|
||||
|
||||
function op_empty() {
|
||||
$this->ensure_my_table();
|
||||
if ($this->operator == 'empty') {
|
||||
$operator = "IS NULL";
|
||||
}
|
||||
else {
|
||||
$operator = "IS NOT NULL";
|
||||
}
|
||||
|
||||
$this->query->add_where($this->options['group'], "$this->table_alias.$this->real_field", NULL, $operator);
|
||||
}
|
||||
|
||||
function validate() {
|
||||
$this->get_value_options();
|
||||
$errors = array();
|
||||
|
||||
// If the operator is an operator which doesn't require a value, there is
|
||||
// no need for additional validation.
|
||||
if (in_array($this->operator, $this->operator_values(0))) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if (!in_array($this->operator, $this->operator_values(1))) {
|
||||
$errors[] = t('The operator is invalid on filter: @filter.', array('@filter' => $this->ui_name(TRUE)));
|
||||
}
|
||||
if (is_array($this->value)) {
|
||||
if (!isset($this->value_options)) {
|
||||
// Don't validate if there are none value options provided, for example for special handlers.
|
||||
return $errors;
|
||||
}
|
||||
if ($this->options['exposed'] && !$this->options['expose']['required'] && empty($this->value)) {
|
||||
// Don't validate if the field is exposed and no default value is provided.
|
||||
return $errors;
|
||||
}
|
||||
|
||||
// Some filter_in_operator usage uses optgroups forms, so flatten it.
|
||||
$flat_options = form_options_flatten($this->value_options, TRUE);
|
||||
|
||||
// Remove every element which is not known.
|
||||
foreach ($this->value as $value) {
|
||||
if (!isset($flat_options[$value])) {
|
||||
unset($this->value[$value]);
|
||||
}
|
||||
}
|
||||
// Choose different kind of ouput for 0, a single and multiple values.
|
||||
if (count($this->value) == 0) {
|
||||
$errors[] = t('No valid values found on filter: @filter.', array('@filter' => $this->ui_name(TRUE)));
|
||||
}
|
||||
}
|
||||
elseif (!empty($this->value) && ($this->operator == 'in' || $this->operator == 'not in')) {
|
||||
$errors[] = t('The value @value is not an array for @operator on filter: @filter', array('@value' => views_var_export($this->value), '@operator' => $this->operator, '@filter' => $this->ui_name(TRUE)));
|
||||
}
|
||||
return $errors;
|
||||
}
|
||||
}
|
@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_filter_many_to_one.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Complex filter to handle filtering for many to one relationships,
|
||||
* such as terms (many terms per node) or roles (many roles per user).
|
||||
*
|
||||
* The construct method needs to be overridden to provide a list of options;
|
||||
* alternately, the value_form and admin_summary methods need to be overriden
|
||||
* to provide something that isn't just a select list.
|
||||
*
|
||||
* @ingroup views_filter_handlers
|
||||
*/
|
||||
class views_handler_filter_many_to_one extends views_handler_filter_in_operator {
|
||||
/**
|
||||
* @var views_many_to_one_helper
|
||||
*
|
||||
* Stores the Helper object which handles the many_to_one complexity.
|
||||
*/
|
||||
var $helper = NULL;
|
||||
|
||||
function init(&$view, &$options) {
|
||||
parent::init($view, $options);
|
||||
$this->helper = new views_many_to_one_helper($this);
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['operator']['default'] = 'or';
|
||||
$options['value']['default'] = array();
|
||||
|
||||
if (isset($this->helper)) {
|
||||
$this->helper->option_definition($options);
|
||||
}
|
||||
else {
|
||||
$helper = new views_many_to_one_helper($this);
|
||||
$helper->option_definition($options);
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function operators() {
|
||||
$operators = array(
|
||||
'or' => array(
|
||||
'title' => t('Is one of'),
|
||||
'short' => t('or'),
|
||||
'short_single' => t('='),
|
||||
'method' => 'op_helper',
|
||||
'values' => 1,
|
||||
'ensure_my_table' => 'helper',
|
||||
),
|
||||
'and' => array(
|
||||
'title' => t('Is all of'),
|
||||
'short' => t('and'),
|
||||
'short_single' => t('='),
|
||||
'method' => 'op_helper',
|
||||
'values' => 1,
|
||||
'ensure_my_table' => 'helper',
|
||||
),
|
||||
'not' => array(
|
||||
'title' => t('Is none of'),
|
||||
'short' => t('not'),
|
||||
'short_single' => t('<>'),
|
||||
'method' => 'op_helper',
|
||||
'values' => 1,
|
||||
'ensure_my_table' => 'helper',
|
||||
),
|
||||
);
|
||||
// if the definition allows for the empty operator, add it.
|
||||
if (!empty($this->definition['allow empty'])) {
|
||||
$operators += array(
|
||||
'empty' => array(
|
||||
'title' => t('Is empty (NULL)'),
|
||||
'method' => 'op_empty',
|
||||
'short' => t('empty'),
|
||||
'values' => 0,
|
||||
),
|
||||
'not empty' => array(
|
||||
'title' => t('Is not empty (NOT NULL)'),
|
||||
'method' => 'op_empty',
|
||||
'short' => t('not empty'),
|
||||
'values' => 0,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return $operators;
|
||||
}
|
||||
|
||||
var $value_form_type = 'select';
|
||||
function value_form(&$form, &$form_state) {
|
||||
parent::value_form($form, $form_state);
|
||||
|
||||
if (empty($form_state['exposed'])) {
|
||||
$this->helper->options_form($form, $form_state);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Override ensure_my_table so we can control how this joins in.
|
||||
* The operator actually has influence over joining.
|
||||
*/
|
||||
function ensure_my_table() {
|
||||
// Defer to helper if the operator specifies it.
|
||||
$info = $this->operators();
|
||||
if (isset($info[$this->operator]['ensure_my_table']) && $info[$this->operator]['ensure_my_table'] == 'helper') {
|
||||
return $this->helper->ensure_my_table();
|
||||
}
|
||||
|
||||
return parent::ensure_my_table();
|
||||
}
|
||||
|
||||
function op_helper() {
|
||||
if (empty($this->value)) {
|
||||
return;
|
||||
}
|
||||
$this->helper->add_filter();
|
||||
}
|
||||
}
|
@ -0,0 +1,325 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_filter_numeric.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Simple filter to handle greater than/less than filters
|
||||
*
|
||||
* @ingroup views_filter_handlers
|
||||
*/
|
||||
class views_handler_filter_numeric extends views_handler_filter {
|
||||
var $always_multiple = TRUE;
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['value'] = array(
|
||||
'contains' => array(
|
||||
'min' => array('default' => ''),
|
||||
'max' => array('default' => ''),
|
||||
'value' => array('default' => ''),
|
||||
),
|
||||
);
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function operators() {
|
||||
$operators = array(
|
||||
'<' => array(
|
||||
'title' => t('Is less than'),
|
||||
'method' => 'op_simple',
|
||||
'short' => t('<'),
|
||||
'values' => 1,
|
||||
),
|
||||
'<=' => array(
|
||||
'title' => t('Is less than or equal to'),
|
||||
'method' => 'op_simple',
|
||||
'short' => t('<='),
|
||||
'values' => 1,
|
||||
),
|
||||
'=' => array(
|
||||
'title' => t('Is equal to'),
|
||||
'method' => 'op_simple',
|
||||
'short' => t('='),
|
||||
'values' => 1,
|
||||
),
|
||||
'!=' => array(
|
||||
'title' => t('Is not equal to'),
|
||||
'method' => 'op_simple',
|
||||
'short' => t('!='),
|
||||
'values' => 1,
|
||||
),
|
||||
'>=' => array(
|
||||
'title' => t('Is greater than or equal to'),
|
||||
'method' => 'op_simple',
|
||||
'short' => t('>='),
|
||||
'values' => 1,
|
||||
),
|
||||
'>' => array(
|
||||
'title' => t('Is greater than'),
|
||||
'method' => 'op_simple',
|
||||
'short' => t('>'),
|
||||
'values' => 1,
|
||||
),
|
||||
'between' => array(
|
||||
'title' => t('Is between'),
|
||||
'method' => 'op_between',
|
||||
'short' => t('between'),
|
||||
'values' => 2,
|
||||
),
|
||||
'not between' => array(
|
||||
'title' => t('Is not between'),
|
||||
'method' => 'op_between',
|
||||
'short' => t('not between'),
|
||||
'values' => 2,
|
||||
),
|
||||
);
|
||||
|
||||
// if the definition allows for the empty operator, add it.
|
||||
if (!empty($this->definition['allow empty'])) {
|
||||
$operators += array(
|
||||
'empty' => array(
|
||||
'title' => t('Is empty (NULL)'),
|
||||
'method' => 'op_empty',
|
||||
'short' => t('empty'),
|
||||
'values' => 0,
|
||||
),
|
||||
'not empty' => array(
|
||||
'title' => t('Is not empty (NOT NULL)'),
|
||||
'method' => 'op_empty',
|
||||
'short' => t('not empty'),
|
||||
'values' => 0,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Add regexp support for MySQL.
|
||||
if (Database::getConnection()->databaseType() == 'mysql') {
|
||||
$operators += array(
|
||||
'regular_expression' => array(
|
||||
'title' => t('Regular expression'),
|
||||
'short' => t('regex'),
|
||||
'method' => 'op_regex',
|
||||
'values' => 1,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return $operators;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a list of all the numeric operators
|
||||
*/
|
||||
function operator_options($which = 'title') {
|
||||
$options = array();
|
||||
foreach ($this->operators() as $id => $info) {
|
||||
$options[$id] = $info[$which];
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function operator_values($values = 1) {
|
||||
$options = array();
|
||||
foreach ($this->operators() as $id => $info) {
|
||||
if ($info['values'] == $values) {
|
||||
$options[] = $id;
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
/**
|
||||
* Provide a simple textfield for equality
|
||||
*/
|
||||
function value_form(&$form, &$form_state) {
|
||||
$form['value']['#tree'] = TRUE;
|
||||
|
||||
// We have to make some choices when creating this as an exposed
|
||||
// filter form. For example, if the operator is locked and thus
|
||||
// not rendered, we can't render dependencies; instead we only
|
||||
// render the form items we need.
|
||||
$which = 'all';
|
||||
if (!empty($form['operator'])) {
|
||||
$source = ($form['operator']['#type'] == 'radios') ? 'radio:options[operator]' : 'edit-options-operator';
|
||||
}
|
||||
|
||||
if (!empty($form_state['exposed'])) {
|
||||
$identifier = $this->options['expose']['identifier'];
|
||||
|
||||
if (empty($this->options['expose']['use_operator']) || empty($this->options['expose']['operator_id'])) {
|
||||
// exposed and locked.
|
||||
$which = in_array($this->operator, $this->operator_values(2)) ? 'minmax' : 'value';
|
||||
}
|
||||
else {
|
||||
$source = 'edit-' . drupal_html_id($this->options['expose']['operator_id']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($which == 'all') {
|
||||
$form['value']['value'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => empty($form_state['exposed']) ? t('Value') : '',
|
||||
'#size' => 30,
|
||||
'#default_value' => $this->value['value'],
|
||||
'#dependency' => array($source => $this->operator_values(1)),
|
||||
);
|
||||
if (!empty($form_state['exposed']) && !isset($form_state['input'][$identifier]['value'])) {
|
||||
$form_state['input'][$identifier]['value'] = $this->value['value'];
|
||||
}
|
||||
}
|
||||
elseif ($which == 'value') {
|
||||
// When exposed we drop the value-value and just do value if
|
||||
// the operator is locked.
|
||||
$form['value'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => empty($form_state['exposed']) ? t('Value') : '',
|
||||
'#size' => 30,
|
||||
'#default_value' => $this->value['value'],
|
||||
);
|
||||
if (!empty($form_state['exposed']) && !isset($form_state['input'][$identifier])) {
|
||||
$form_state['input'][$identifier] = $this->value['value'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($which == 'all' || $which == 'minmax') {
|
||||
$form['value']['min'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => empty($form_state['exposed']) ? t('Min') : '',
|
||||
'#size' => 30,
|
||||
'#default_value' => $this->value['min'],
|
||||
);
|
||||
$form['value']['max'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => empty($form_state['exposed']) ? t('And max') : t('And'),
|
||||
'#size' => 30,
|
||||
'#default_value' => $this->value['max'],
|
||||
);
|
||||
if ($which == 'all') {
|
||||
$dependency = array(
|
||||
'#dependency' => array($source => $this->operator_values(2)),
|
||||
);
|
||||
$form['value']['min'] += $dependency;
|
||||
$form['value']['max'] += $dependency;
|
||||
}
|
||||
if (!empty($form_state['exposed']) && !isset($form_state['input'][$identifier]['min'])) {
|
||||
$form_state['input'][$identifier]['min'] = $this->value['min'];
|
||||
}
|
||||
if (!empty($form_state['exposed']) && !isset($form_state['input'][$identifier]['max'])) {
|
||||
$form_state['input'][$identifier]['max'] = $this->value['max'];
|
||||
}
|
||||
|
||||
if (!isset($form['value'])) {
|
||||
// Ensure there is something in the 'value'.
|
||||
$form['value'] = array(
|
||||
'#type' => 'value',
|
||||
'#value' => NULL
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function query() {
|
||||
$this->ensure_my_table();
|
||||
$field = "$this->table_alias.$this->real_field";
|
||||
|
||||
$info = $this->operators();
|
||||
if (!empty($info[$this->operator]['method'])) {
|
||||
$this->{$info[$this->operator]['method']}($field);
|
||||
}
|
||||
}
|
||||
|
||||
function op_between($field) {
|
||||
if ($this->operator == 'between') {
|
||||
$this->query->add_where($this->options['group'], $field, array($this->value['min'], $this->value['max']), 'BETWEEN');
|
||||
}
|
||||
else {
|
||||
$this->query->add_where($this->options['group'], db_or()->condition($field, $this->value['min'], '<=')->condition($field, $this->value['max'], '>='));
|
||||
}
|
||||
}
|
||||
|
||||
function op_simple($field) {
|
||||
$this->query->add_where($this->options['group'], $field, $this->value['value'], $this->operator);
|
||||
}
|
||||
|
||||
function op_empty($field) {
|
||||
if ($this->operator == 'empty') {
|
||||
$operator = "IS NULL";
|
||||
}
|
||||
else {
|
||||
$operator = "IS NOT NULL";
|
||||
}
|
||||
|
||||
$this->query->add_where($this->options['group'], $field, NULL, $operator);
|
||||
}
|
||||
|
||||
function op_regex($field) {
|
||||
$this->query->add_where($this->options['group'], $field, $this->value['value'], 'RLIKE');
|
||||
}
|
||||
|
||||
function admin_summary() {
|
||||
if ($this->is_a_group()) {
|
||||
return t('grouped');
|
||||
}
|
||||
if (!empty($this->options['exposed'])) {
|
||||
return t('exposed');
|
||||
}
|
||||
|
||||
$options = $this->operator_options('short');
|
||||
$output = check_plain($options[$this->operator]);
|
||||
if (in_array($this->operator, $this->operator_values(2))) {
|
||||
$output .= ' ' . t('@min and @max', array('@min' => $this->value['min'], '@max' => $this->value['max']));
|
||||
}
|
||||
elseif (in_array($this->operator, $this->operator_values(1))) {
|
||||
$output .= ' ' . check_plain($this->value['value']);
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do some minor translation of the exposed input
|
||||
*/
|
||||
function accept_exposed_input($input) {
|
||||
if (empty($this->options['exposed'])) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// rewrite the input value so that it's in the correct format so that
|
||||
// the parent gets the right data.
|
||||
if (!empty($this->options['expose']['identifier'])) {
|
||||
$value = &$input[$this->options['expose']['identifier']];
|
||||
if (!is_array($value)) {
|
||||
$value = array(
|
||||
'value' => $value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$rc = parent::accept_exposed_input($input);
|
||||
|
||||
if (empty($this->options['expose']['required'])) {
|
||||
// We have to do some of our own checking for non-required filters.
|
||||
$info = $this->operators();
|
||||
if (!empty($info[$this->operator]['values'])) {
|
||||
switch ($info[$this->operator]['values']) {
|
||||
case 1:
|
||||
if ($value['value'] === '') {
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if ($value['min'] === '' && $value['max'] === '') {
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $rc;
|
||||
}
|
||||
}
|
@ -0,0 +1,338 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_filter_string.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Basic textfield filter to handle string filtering commands
|
||||
* including equality, like, not like, etc.
|
||||
*
|
||||
* @ingroup views_filter_handlers
|
||||
*/
|
||||
class views_handler_filter_string extends views_handler_filter {
|
||||
// exposed filter options
|
||||
var $always_multiple = TRUE;
|
||||
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['expose']['contains']['required'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* This kind of construct makes it relatively easy for a child class
|
||||
* to add or remove functionality by overriding this function and
|
||||
* adding/removing items from this array.
|
||||
*/
|
||||
function operators() {
|
||||
$operators = array(
|
||||
'=' => array(
|
||||
'title' => t('Is equal to'),
|
||||
'short' => t('='),
|
||||
'method' => 'op_equal',
|
||||
'values' => 1,
|
||||
),
|
||||
'!=' => array(
|
||||
'title' => t('Is not equal to'),
|
||||
'short' => t('!='),
|
||||
'method' => 'op_equal',
|
||||
'values' => 1,
|
||||
),
|
||||
'contains' => array(
|
||||
'title' => t('Contains'),
|
||||
'short' => t('contains'),
|
||||
'method' => 'op_contains',
|
||||
'values' => 1,
|
||||
),
|
||||
'word' => array(
|
||||
'title' => t('Contains any word'),
|
||||
'short' => t('has word'),
|
||||
'method' => 'op_word',
|
||||
'values' => 1,
|
||||
),
|
||||
'allwords' => array(
|
||||
'title' => t('Contains all words'),
|
||||
'short' => t('has all'),
|
||||
'method' => 'op_word',
|
||||
'values' => 1,
|
||||
),
|
||||
'starts' => array(
|
||||
'title' => t('Starts with'),
|
||||
'short' => t('begins'),
|
||||
'method' => 'op_starts',
|
||||
'values' => 1,
|
||||
),
|
||||
'not_starts' => array(
|
||||
'title' => t('Does not start with'),
|
||||
'short' => t('not_begins'),
|
||||
'method' => 'op_not_starts',
|
||||
'values' => 1,
|
||||
),
|
||||
'ends' => array(
|
||||
'title' => t('Ends with'),
|
||||
'short' => t('ends'),
|
||||
'method' => 'op_ends',
|
||||
'values' => 1,
|
||||
),
|
||||
'not_ends' => array(
|
||||
'title' => t('Does not end with'),
|
||||
'short' => t('not_ends'),
|
||||
'method' => 'op_not_ends',
|
||||
'values' => 1,
|
||||
),
|
||||
'not' => array(
|
||||
'title' => t('Does not contain'),
|
||||
'short' => t('!has'),
|
||||
'method' => 'op_not',
|
||||
'values' => 1,
|
||||
),
|
||||
'shorterthan' => array(
|
||||
'title' => t('Length is shorter than'),
|
||||
'short' => t('shorter than'),
|
||||
'method' => 'op_shorter',
|
||||
'values' => 1,
|
||||
),
|
||||
'longerthan' => array(
|
||||
'title' => t('Length is longer than'),
|
||||
'short' => t('longer than'),
|
||||
'method' => 'op_longer',
|
||||
'values' => 1,
|
||||
),
|
||||
);
|
||||
// if the definition allows for the empty operator, add it.
|
||||
if (!empty($this->definition['allow empty'])) {
|
||||
$operators += array(
|
||||
'empty' => array(
|
||||
'title' => t('Is empty (NULL)'),
|
||||
'method' => 'op_empty',
|
||||
'short' => t('empty'),
|
||||
'values' => 0,
|
||||
),
|
||||
'not empty' => array(
|
||||
'title' => t('Is not empty (NOT NULL)'),
|
||||
'method' => 'op_empty',
|
||||
'short' => t('not empty'),
|
||||
'values' => 0,
|
||||
),
|
||||
);
|
||||
}
|
||||
// Add regexp support for MySQL.
|
||||
if (Database::getConnection()->databaseType() == 'mysql') {
|
||||
$operators += array(
|
||||
'regular_expression' => array(
|
||||
'title' => t('Regular expression'),
|
||||
'short' => t('regex'),
|
||||
'method' => 'op_regex',
|
||||
'values' => 1,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return $operators;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build strings from the operators() for 'select' options
|
||||
*/
|
||||
function operator_options($which = 'title') {
|
||||
$options = array();
|
||||
foreach ($this->operators() as $id => $info) {
|
||||
$options[$id] = $info[$which];
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function admin_summary() {
|
||||
if ($this->is_a_group()) {
|
||||
return t('grouped');
|
||||
}
|
||||
if (!empty($this->options['exposed'])) {
|
||||
return t('exposed');
|
||||
}
|
||||
|
||||
$options = $this->operator_options('short');
|
||||
$output = '';
|
||||
if(!empty($options[$this->operator])) {
|
||||
$output = check_plain($options[$this->operator]);
|
||||
}
|
||||
if (in_array($this->operator, $this->operator_values(1))) {
|
||||
$output .= ' ' . check_plain($this->value);
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
function operator_values($values = 1) {
|
||||
$options = array();
|
||||
foreach ($this->operators() as $id => $info) {
|
||||
if (isset($info['values']) && $info['values'] == $values) {
|
||||
$options[] = $id;
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a simple textfield for equality
|
||||
*/
|
||||
function value_form(&$form, &$form_state) {
|
||||
// We have to make some choices when creating this as an exposed
|
||||
// filter form. For example, if the operator is locked and thus
|
||||
// not rendered, we can't render dependencies; instead we only
|
||||
// render the form items we need.
|
||||
$which = 'all';
|
||||
if (!empty($form['operator'])) {
|
||||
$source = ($form['operator']['#type'] == 'radios') ? 'radio:options[operator]' : 'edit-options-operator';
|
||||
}
|
||||
if (!empty($form_state['exposed'])) {
|
||||
$identifier = $this->options['expose']['identifier'];
|
||||
|
||||
if (empty($this->options['expose']['use_operator']) || empty($this->options['expose']['operator_id'])) {
|
||||
// exposed and locked.
|
||||
$which = in_array($this->operator, $this->operator_values(1)) ? 'value' : 'none';
|
||||
}
|
||||
else {
|
||||
$source = 'edit-' . drupal_html_id($this->options['expose']['operator_id']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($which == 'all' || $which == 'value') {
|
||||
$form['value'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Value'),
|
||||
'#size' => 30,
|
||||
'#default_value' => $this->value,
|
||||
);
|
||||
if (!empty($form_state['exposed']) && !isset($form_state['input'][$identifier])) {
|
||||
$form_state['input'][$identifier] = $this->value;
|
||||
}
|
||||
|
||||
if ($which == 'all') {
|
||||
$form['value'] += array(
|
||||
'#dependency' => array($source => $this->operator_values(1)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($form['value'])) {
|
||||
// Ensure there is something in the 'value'.
|
||||
$form['value'] = array(
|
||||
'#type' => 'value',
|
||||
'#value' => NULL
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function operator() {
|
||||
return $this->operator == '=' ? 'LIKE' : 'NOT LIKE';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add this filter to the query.
|
||||
*
|
||||
* Due to the nature of fapi, the value and the operator have an unintended
|
||||
* level of indirection. You will find them in $this->operator
|
||||
* and $this->value respectively.
|
||||
*/
|
||||
function query() {
|
||||
$this->ensure_my_table();
|
||||
$field = "$this->table_alias.$this->real_field";
|
||||
|
||||
$info = $this->operators();
|
||||
if (!empty($info[$this->operator]['method'])) {
|
||||
$this->{$info[$this->operator]['method']}($field);
|
||||
}
|
||||
}
|
||||
|
||||
function op_equal($field) {
|
||||
$this->query->add_where($this->options['group'], $field, $this->value, $this->operator());
|
||||
}
|
||||
|
||||
function op_contains($field) {
|
||||
$this->query->add_where($this->options['group'], $field, '%' . db_like($this->value) . '%', 'LIKE');
|
||||
}
|
||||
|
||||
function op_word($field) {
|
||||
$where = $this->operator == 'word' ? db_or() : db_and();
|
||||
|
||||
// Don't filter on empty strings.
|
||||
if (empty($this->value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
preg_match_all('/ (-?)("[^"]+"|[^" ]+)/i', ' ' . $this->value, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $match) {
|
||||
$phrase = false;
|
||||
// Strip off phrase quotes
|
||||
if ($match[2]{0} == '"') {
|
||||
$match[2] = substr($match[2], 1, -1);
|
||||
$phrase = true;
|
||||
}
|
||||
$words = trim($match[2], ',?!();:-');
|
||||
$words = $phrase ? array($words) : preg_split('/ /', $words, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($words as $word) {
|
||||
$placeholder = $this->placeholder();
|
||||
$where->condition($field, '%' . db_like(trim($word, " ,!?")) . '%', 'LIKE');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$where) {
|
||||
return;
|
||||
}
|
||||
|
||||
// previously this was a call_user_func_array but that's unnecessary
|
||||
// as views will unpack an array that is a single arg.
|
||||
$this->query->add_where($this->options['group'], $where);
|
||||
}
|
||||
|
||||
function op_starts($field) {
|
||||
$this->query->add_where($this->options['group'], $field, db_like($this->value) . '%', 'LIKE');
|
||||
}
|
||||
|
||||
function op_not_starts($field) {
|
||||
$this->query->add_where($this->options['group'], $field, db_like($this->value) . '%', 'NOT LIKE');
|
||||
}
|
||||
|
||||
function op_ends($field) {
|
||||
$this->query->add_where($this->options['group'], $field, '%' . db_like($this->value), 'LIKE');
|
||||
}
|
||||
|
||||
function op_not_ends($field) {
|
||||
$this->query->add_where($this->options['group'], $field, '%' . db_like($this->value), 'NOT LIKE');
|
||||
}
|
||||
|
||||
function op_not($field) {
|
||||
$this->query->add_where($this->options['group'], $field, '%' . db_like($this->value) . '%', 'NOT LIKE');
|
||||
}
|
||||
|
||||
function op_shorter($field) {
|
||||
$placeholder = $this->placeholder();
|
||||
$this->query->add_where_expression($this->options['group'], "LENGTH($field) < $placeholder", array($placeholder => $this->value));
|
||||
}
|
||||
|
||||
function op_longer($field) {
|
||||
$placeholder = $this->placeholder();
|
||||
$this->query->add_where_expression($this->options['group'], "LENGTH($field) > $placeholder", array($placeholder => $this->value));
|
||||
}
|
||||
|
||||
function op_regex($field) {
|
||||
$this->query->add_where($this->options['group'], $field, $this->value, 'RLIKE');
|
||||
}
|
||||
|
||||
function op_empty($field) {
|
||||
if ($this->operator == 'empty') {
|
||||
$operator = "IS NULL";
|
||||
}
|
||||
else {
|
||||
$operator = "IS NOT NULL";
|
||||
}
|
||||
|
||||
$this->query->add_where($this->options['group'], $field, NULL, $operator);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,186 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Views' relationship handlers.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup views_relationship_handlers Views relationship handlers
|
||||
* @{
|
||||
* Handlers to tell Views how to create alternate relationships.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Simple relationship handler that allows a new version of the primary table
|
||||
* to be linked in.
|
||||
*
|
||||
* The base relationship handler can only handle a single join. Some relationships
|
||||
* are more complex and might require chains of joins; for those, you must
|
||||
* utilize a custom relationship handler.
|
||||
*
|
||||
* Definition items:
|
||||
* - base: The new base table this relationship will be adding. This does not
|
||||
* have to be a declared base table, but if there are no tables that
|
||||
* utilize this base table, it won't be very effective.
|
||||
* - base field: The field to use in the relationship; if left out this will be
|
||||
* assumed to be the primary field.
|
||||
* - relationship table: The actual table this relationship operates against.
|
||||
* This is analogous to using a 'table' override.
|
||||
* - relationship field: The actual field this relationship operates against.
|
||||
* This is analogous to using a 'real field' override.
|
||||
* - label: The default label to provide for this relationship, which is
|
||||
* shown in parentheses next to any field/sort/filter/argument that uses
|
||||
* the relationship.
|
||||
*
|
||||
* @ingroup views_relationship_handlers
|
||||
*/
|
||||
class views_handler_relationship extends views_handler {
|
||||
/**
|
||||
* Init handler to let relationships live on tables other than
|
||||
* the table they operate on.
|
||||
*/
|
||||
function init(&$view, &$options) {
|
||||
parent::init($view, $options);
|
||||
if (isset($this->definition['relationship table'])) {
|
||||
$this->table = $this->definition['relationship table'];
|
||||
}
|
||||
if (isset($this->definition['relationship field'])) {
|
||||
// Set both real_field and field so custom handler
|
||||
// can rely on the old field value.
|
||||
$this->real_field = $this->field = $this->definition['relationship field'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this field's label.
|
||||
*/
|
||||
function label() {
|
||||
if (!isset($this->options['label'])) {
|
||||
return $this->ui_name();
|
||||
}
|
||||
return $this->options['label'];
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
|
||||
// Relationships definitions should define a default label, but if they aren't get another default value.
|
||||
if (!empty($this->definition['label'])) {
|
||||
$label = $this->definition['label'];
|
||||
}
|
||||
else {
|
||||
$label = !empty($this->definition['field']) ? $this->definition['field'] : $this->definition['base field'];
|
||||
}
|
||||
|
||||
$options['label'] = array('default' => $label, 'translatable' => TRUE);
|
||||
$options['required'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default options form that provides the label widget that all fields
|
||||
* should have.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$form['label'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Identifier'),
|
||||
'#default_value' => isset($this->options['label']) ? $this->options['label'] : '',
|
||||
'#description' => t('Edit the administrative label displayed when referencing this relationship from filters, etc.'),
|
||||
'#required' => TRUE,
|
||||
);
|
||||
|
||||
$form['required'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Require this relationship'),
|
||||
'#description' => t('Enable to hide items that do not contain this relationship'),
|
||||
'#default_value' => !empty($this->options['required']),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to implement a relationship in a query.
|
||||
*/
|
||||
function query() {
|
||||
// Figure out what base table this relationship brings to the party.
|
||||
$table_data = views_fetch_data($this->definition['base']);
|
||||
$base_field = empty($this->definition['base field']) ? $table_data['table']['base']['field'] : $this->definition['base field'];
|
||||
|
||||
$this->ensure_my_table();
|
||||
|
||||
$def = $this->definition;
|
||||
$def['table'] = $this->definition['base'];
|
||||
$def['field'] = $base_field;
|
||||
$def['left_table'] = $this->table_alias;
|
||||
$def['left_field'] = $this->real_field;
|
||||
if (!empty($this->options['required'])) {
|
||||
$def['type'] = 'INNER';
|
||||
}
|
||||
|
||||
if (!empty($this->definition['extra'])) {
|
||||
$def['extra'] = $this->definition['extra'];
|
||||
}
|
||||
|
||||
if (!empty($def['join_handler']) && class_exists($def['join_handler'])) {
|
||||
$join = new $def['join_handler'];
|
||||
}
|
||||
else {
|
||||
$join = new views_join();
|
||||
}
|
||||
|
||||
$join->definition = $def;
|
||||
$join->options = $this->options;
|
||||
$join->construct();
|
||||
$join->adjusted = TRUE;
|
||||
|
||||
// use a short alias for this:
|
||||
$alias = $def['table'] . '_' . $this->table;
|
||||
|
||||
$this->alias = $this->query->add_relationship($alias, $join, $this->definition['base'], $this->relationship);
|
||||
|
||||
// Add access tags if the base table provide it.
|
||||
if (empty($this->query->options['disable_sql_rewrite']) && isset($table_data['table']['base']['access query tag'])) {
|
||||
$access_tag = $table_data['table']['base']['access query tag'];
|
||||
$this->query->add_tag($access_tag);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* You can't groupby a relationship.
|
||||
*/
|
||||
function use_group_by() {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A special handler to take the place of missing or broken handlers.
|
||||
*
|
||||
* @ingroup views_relationship_handlers
|
||||
*/
|
||||
class views_handler_relationship_broken extends views_handler_relationship {
|
||||
function ui_name($short = FALSE) {
|
||||
return t('Broken/missing handler');
|
||||
}
|
||||
|
||||
function ensure_my_table() { /* No table to ensure! */ }
|
||||
function query() { /* No query to run */ }
|
||||
function options_form(&$form, &$form_state) {
|
||||
$form['markup'] = array(
|
||||
'#markup' => '<div class="form-item description">' . t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.') . '</div>',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the handler is considered 'broken'
|
||||
*/
|
||||
function broken() { return TRUE; }
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
@ -0,0 +1,382 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Relationship for groupwise maximum handler.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Relationship handler that allows a groupwise maximum of the linked in table.
|
||||
* For a definition, see:
|
||||
* http://dev.mysql.com/doc/refman/5.0/en/example-maximum-column-group-row.html
|
||||
* In lay terms, instead of joining to get all matching records in the linked
|
||||
* table, we get only one record, a 'representative record' picked according
|
||||
* to a given criteria.
|
||||
*
|
||||
* Example:
|
||||
* Suppose we have a term view that gives us the terms: Horse, Cat, Aardvark.
|
||||
* We wish to show for each term the most recent node of that term.
|
||||
* What we want is some kind of relationship from term to node.
|
||||
* But a regular relationship will give us all the nodes for each term,
|
||||
* giving the view multiple rows per term. What we want is just one
|
||||
* representative node per term, the node that is the 'best' in some way:
|
||||
* eg, the most recent, the most commented on, the first in alphabetical order.
|
||||
*
|
||||
* This handler gives us that kind of relationship from term to node.
|
||||
* The method of choosing the 'best' implemented with a sort
|
||||
* that the user selects in the relationship settings.
|
||||
*
|
||||
* So if we want our term view to show the most commented node for each term,
|
||||
* add the relationship and in its options, pick the 'Comment count' sort.
|
||||
*
|
||||
* Relationship definition
|
||||
* - 'outer field': The outer field to substitute into the correlated subquery.
|
||||
* This must be the full field name, not the alias.
|
||||
* Eg: 'term_data.tid'.
|
||||
* - 'argument table',
|
||||
* 'argument field': These options define a views argument that the subquery
|
||||
* must add to itself to filter by the main view.
|
||||
* Example: the main view shows terms, this handler is being used to get to
|
||||
* the nodes base table. Your argument must be 'term_node', 'tid', as this
|
||||
* is the argument that should be added to a node view to filter on terms.
|
||||
*
|
||||
* A note on performance:
|
||||
* This relationship uses a correlated subquery, which is expensive.
|
||||
* Subsequent versions of this handler could also implement the alternative way
|
||||
* of doing this, with a join -- though this looks like it could be pretty messy
|
||||
* to implement. This is also an expensive method, so providing both methods and
|
||||
* allowing the user to choose which one works fastest for their data might be
|
||||
* the best way.
|
||||
* If your use of this relationship handler is likely to result in large
|
||||
* data sets, you might want to consider storing statistics in a separate table,
|
||||
* in the same way as node_comment_statistics.
|
||||
*
|
||||
* @ingroup views_relationship_handlers
|
||||
*/
|
||||
class views_handler_relationship_groupwise_max extends views_handler_relationship {
|
||||
|
||||
/**
|
||||
* Defines default values for options.
|
||||
*/
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['subquery_sort'] = array('default' => NULL);
|
||||
// Descending more useful.
|
||||
$options['subquery_order'] = array('default' => 'DESC');
|
||||
$options['subquery_regenerate'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
$options['subquery_view'] = array('default' => FALSE);
|
||||
$options['subquery_namespace'] = array('default' => FALSE);
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extends the relationship's basic options, allowing the user to pick
|
||||
* a sort and an order for it.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
// Get the sorts that apply to our base.
|
||||
$sorts = views_fetch_fields($this->definition['base'], 'sort');
|
||||
foreach ($sorts as $sort_id => $sort) {
|
||||
$sort_options[$sort_id] = "$sort[group]: $sort[title]";
|
||||
}
|
||||
$base_table_data = views_fetch_data($this->definition['base']);
|
||||
|
||||
$form['subquery_sort'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Representative sort criteria'),
|
||||
// Provide the base field as sane default sort option.
|
||||
'#default_value' => !empty($this->options['subquery_sort']) ? $this->options['subquery_sort'] : $this->definition['base'] . '.' . $base_table_data['table']['base']['field'],
|
||||
'#options' => $sort_options,
|
||||
'#description' => theme('advanced_help_topic', array('module' => 'views', 'topic' => 'relationship-representative')) .
|
||||
t("The sort criteria is applied to the data brought in by the relationship to determine how a representative item is obtained for each row. For example, to show the most recent node for each user, pick 'Content: Updated date'."),
|
||||
);
|
||||
|
||||
$form['subquery_order'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Representative sort order'),
|
||||
'#description' => t("The ordering to use for the sort criteria selected above."),
|
||||
'#options' => array('ASC' => t('Ascending'), 'DESC' => t('Descending')),
|
||||
'#default_value' => $this->options['subquery_order'],
|
||||
);
|
||||
|
||||
$form['subquery_namespace'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Subquery namespace'),
|
||||
'#description' => t('Advanced. Enter a namespace for the subquery used by this relationship.'),
|
||||
'#default_value' => $this->options['subquery_namespace'],
|
||||
);
|
||||
|
||||
|
||||
// WIP: This stuff doens't work yet: namespacing issues.
|
||||
// A list of suitable views to pick one as the subview.
|
||||
$views = array('' => '<none>');
|
||||
$all_views = views_get_all_views();
|
||||
foreach ($all_views as $view) {
|
||||
// Only get views that are suitable:
|
||||
// - base must the base that our relationship joins towards
|
||||
// - must have fields.
|
||||
if ($view->base_table == $this->definition['base'] && !empty($view->display['default']->display_options['fields'])) {
|
||||
// TODO: check the field is the correct sort?
|
||||
// or let users hang themselves at this stage and check later?
|
||||
if ($view->type == 'Default') {
|
||||
$views[t('Default Views')][$view->name] = $view->name;
|
||||
}
|
||||
else {
|
||||
$views[t('Existing Views')][$view->name] = $view->name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$form['subquery_view'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Representative view'),
|
||||
'#default_value' => $this->options['subquery_view'],
|
||||
'#options' => $views,
|
||||
'#description' => t('Advanced. Use another view to generate the relationship subquery. This allows you to use filtering and more than one sort. If you pick a view here, the sort options above are ignored. Your view must have the ID of its base as its only field, and should have some kind of sorting.'),
|
||||
);
|
||||
|
||||
$form['subquery_regenerate'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Generate subquery each time view is run.'),
|
||||
'#default_value' => $this->options['subquery_regenerate'],
|
||||
'#description' => t('Will re-generate the subquery for this relationship every time the view is run, instead of only when these options are saved. Use for testing if you are making changes elsewhere. WARNING: seriously impairs performance.'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to create a pseudo view.
|
||||
*
|
||||
* We use this to obtain our subquery SQL.
|
||||
*/
|
||||
function get_temporary_view() {
|
||||
views_include('view');
|
||||
$view = new view();
|
||||
$view->vid = 'new'; // @todo: what's this?
|
||||
$view->base_table = $this->definition['base'];
|
||||
$view->add_display('default');
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* When the form is submitted, take sure to clear the subquery string cache.
|
||||
*/
|
||||
function options_form_submit(&$form, &$form_state) {
|
||||
$cid = 'views_relationship_groupwise_max:' . $this->view->name . ':' . $this->view->current_display . ':' . $this->options['id'];
|
||||
cache_clear_all($cid, 'cache_views_data');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a subquery given the user options, as set in the options.
|
||||
* These are passed in rather than picked up from the object because we
|
||||
* generate the subquery when the options are saved, rather than when the view
|
||||
* is run. This saves considerable time.
|
||||
*
|
||||
* @param $options
|
||||
* An array of options:
|
||||
* - subquery_sort: the id of a views sort.
|
||||
* - subquery_order: either ASC or DESC.
|
||||
* @return
|
||||
* The subquery SQL string, ready for use in the main query.
|
||||
*/
|
||||
function left_query($options) {
|
||||
// Either load another view, or create one on the fly.
|
||||
if ($options['subquery_view']) {
|
||||
$temp_view = views_get_view($options['subquery_view']);
|
||||
// Remove all fields from default display
|
||||
unset($temp_view->display['default']->display_options['fields']);
|
||||
}
|
||||
else {
|
||||
// Create a new view object on the fly, which we use to generate a query
|
||||
// object and then get the SQL we need for the subquery.
|
||||
$temp_view = $this->get_temporary_view();
|
||||
|
||||
// Add the sort from the options to the default display.
|
||||
// This is broken, in that the sort order field also gets added as a
|
||||
// select field. See http://drupal.org/node/844910.
|
||||
// We work around this further down.
|
||||
$sort = $options['subquery_sort'];
|
||||
list($sort_table, $sort_field) = explode('.', $sort);
|
||||
$sort_options = array('order' => $options['subquery_order']);
|
||||
$temp_view->add_item('default', 'sort', $sort_table, $sort_field, $sort_options);
|
||||
}
|
||||
|
||||
// Get the namespace string.
|
||||
$temp_view->namespace = (!empty($options['subquery_namespace'])) ? '_'. $options['subquery_namespace'] : '_INNER';
|
||||
$this->subquery_namespace = (!empty($options['subquery_namespace'])) ? '_'. $options['subquery_namespace'] : 'INNER';
|
||||
|
||||
// The value we add here does nothing, but doing this adds the right tables
|
||||
// and puts in a WHERE clause with a placeholder we can grab later.
|
||||
$temp_view->args[] = '**CORRELATED**';
|
||||
|
||||
// Add the base table ID field.
|
||||
$views_data = views_fetch_data($this->definition['base']);
|
||||
$base_field = $views_data['table']['base']['field'];
|
||||
$temp_view->add_item('default', 'field', $this->definition['base'], $this->definition['field']);
|
||||
|
||||
// Add the correct argument for our relationship's base
|
||||
// ie the 'how to get back to base' argument.
|
||||
// The relationship definition tells us which one to use.
|
||||
$temp_view->add_item(
|
||||
'default',
|
||||
'argument',
|
||||
$this->definition['argument table'], // eg 'term_node',
|
||||
$this->definition['argument field'] // eg 'tid'
|
||||
);
|
||||
|
||||
// Build the view. The creates the query object and produces the query
|
||||
// string but does not run any queries.
|
||||
$temp_view->build();
|
||||
|
||||
// Now take the SelectQuery object the View has built and massage it
|
||||
// somewhat so we can get the SQL query from it.
|
||||
$subquery = $temp_view->build_info['query'];
|
||||
|
||||
// Workaround until http://drupal.org/node/844910 is fixed:
|
||||
// Remove all fields from the SELECT except the base id.
|
||||
$fields =& $subquery->getFields();
|
||||
foreach (array_keys($fields) as $field_name) {
|
||||
// The base id for this subquery is stored in our definition.
|
||||
if ($field_name != $this->definition['field']) {
|
||||
unset($fields[$field_name]);
|
||||
}
|
||||
}
|
||||
|
||||
// Make every alias in the subquery safe within the outer query by
|
||||
// appending a namespace to it, '_inner' by default.
|
||||
$tables =& $subquery->getTables();
|
||||
foreach (array_keys($tables) as $table_name) {
|
||||
$tables[$table_name]['alias'] .= $this->subquery_namespace;
|
||||
// Namespace the join on every table.
|
||||
if (isset($tables[$table_name]['condition'])) {
|
||||
$tables[$table_name]['condition'] = $this->condition_namespace($tables[$table_name]['condition']);
|
||||
}
|
||||
}
|
||||
// Namespace fields.
|
||||
foreach (array_keys($fields) as $field_name) {
|
||||
$fields[$field_name]['table'] .= $this->subquery_namespace;
|
||||
$fields[$field_name]['alias'] .= $this->subquery_namespace;
|
||||
}
|
||||
// Namespace conditions.
|
||||
$where =& $subquery->conditions();
|
||||
$this->alter_subquery_condition($subquery, $where);
|
||||
// Not sure why, but our sort order clause doesn't have a table.
|
||||
// TODO: the call to add_item() above to add the sort handler is probably
|
||||
// wrong -- needs attention from someone who understands it.
|
||||
// In the meantime, this works, but with a leap of faith...
|
||||
$orders =& $subquery->getOrderBy();
|
||||
foreach ($orders as $order_key => $order) {
|
||||
// But if we're using a whole view, we don't know what we have!
|
||||
if ($options['subquery_view']) {
|
||||
list($sort_table, $sort_field) = explode('.', $order_key);
|
||||
}
|
||||
$orders[$sort_table . $this->subquery_namespace . '.' . $sort_field] = $order;
|
||||
unset($orders[$order_key]);
|
||||
}
|
||||
|
||||
// The query we get doesn't include the LIMIT, so add it here.
|
||||
$subquery->range(0, 1);
|
||||
|
||||
// Extract the SQL the temporary view built.
|
||||
$subquery_sql = $subquery->__toString();
|
||||
|
||||
// Replace the placeholder with the outer, correlated field.
|
||||
// Eg, change the placeholder ':users_uid' into the outer field 'users.uid'.
|
||||
// We have to work directly with the SQL, because putting a name of a field
|
||||
// into a SelectQuery that it does not recognize (because it's outer) just
|
||||
// makes it treat it as a string.
|
||||
$outer_placeholder = ':' . str_replace('.', '_', $this->definition['outer field']);
|
||||
$subquery_sql = str_replace($outer_placeholder, $this->definition['outer field'], $subquery_sql);
|
||||
|
||||
return $subquery_sql;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursive helper to add a namespace to conditions.
|
||||
*
|
||||
* Similar to _views_query_tag_alter_condition().
|
||||
*
|
||||
* (Though why is the condition we get in a simple query 3 levels deep???)
|
||||
*/
|
||||
function alter_subquery_condition(QueryAlterableInterface $query, &$conditions) {
|
||||
foreach ($conditions as $condition_id => &$condition) {
|
||||
// Skip the #conjunction element.
|
||||
if (is_numeric($condition_id)) {
|
||||
if (is_string($condition['field'])) {
|
||||
$condition['field'] = $this->condition_namespace($condition['field']);
|
||||
}
|
||||
elseif (is_object($condition['field'])) {
|
||||
$sub_conditions =& $condition['field']->conditions();
|
||||
$this->alter_subquery_condition($query, $sub_conditions);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to namespace query pieces.
|
||||
*
|
||||
* Turns 'foo.bar' into 'foo_NAMESPACE.bar'.
|
||||
*/
|
||||
function condition_namespace($string) {
|
||||
return str_replace('.', $this->subquery_namespace . '.', $string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to implement a relationship in a query.
|
||||
* This is mostly a copy of our parent's query() except for this bit with
|
||||
* the join class.
|
||||
*/
|
||||
function query() {
|
||||
// Figure out what base table this relationship brings to the party.
|
||||
$table_data = views_fetch_data($this->definition['base']);
|
||||
$base_field = empty($this->definition['base field']) ? $table_data['table']['base']['field'] : $this->definition['base field'];
|
||||
|
||||
$this->ensure_my_table();
|
||||
|
||||
$def = $this->definition;
|
||||
$def['table'] = $this->definition['base'];
|
||||
$def['field'] = $base_field;
|
||||
$def['left_table'] = $this->table_alias;
|
||||
$def['left_field'] = $this->field;
|
||||
if (!empty($this->options['required'])) {
|
||||
$def['type'] = 'INNER';
|
||||
}
|
||||
|
||||
if ($this->options['subquery_regenerate']) {
|
||||
// For testing only, regenerate the subquery each time.
|
||||
$def['left_query'] = $this->left_query($this->options);
|
||||
}
|
||||
else {
|
||||
// Get the stored subquery SQL string.
|
||||
$cid = 'views_relationship_groupwise_max:' . $this->view->name . ':' . $this->view->current_display . ':' . $this->options['id'];
|
||||
$cache = cache_get($cid, 'cache_views_data');
|
||||
if (isset($cache->data)) {
|
||||
$def['left_query'] = $cache->data;
|
||||
}
|
||||
else {
|
||||
$def['left_query'] = $this->left_query($this->options);
|
||||
cache_set($cid, $def['left_query'], 'cache_views_data');
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($def['join_handler']) && class_exists($def['join_handler'])) {
|
||||
$join = new $def['join_handler'];
|
||||
}
|
||||
else {
|
||||
$join = new views_join_subquery();
|
||||
}
|
||||
|
||||
$join->definition = $def;
|
||||
$join->construct();
|
||||
$join->adjusted = TRUE;
|
||||
|
||||
// use a short alias for this:
|
||||
$alias = $def['table'] . '_' . $this->table;
|
||||
|
||||
$this->alias = $this->query->add_relationship($alias, $join, $this->definition['base'], $this->relationship);
|
||||
}
|
||||
}
|
@ -0,0 +1,240 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @todo.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup views_sort_handlers Views sort handlers
|
||||
* @{
|
||||
* Handlers to tell Views how to sort queries.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base sort handler that has no options and performs a simple sort.
|
||||
*
|
||||
* @ingroup views_sort_handlers
|
||||
*/
|
||||
class views_handler_sort extends views_handler {
|
||||
|
||||
/**
|
||||
* Determine if a sort can be exposed.
|
||||
*/
|
||||
function can_expose() { return TRUE; }
|
||||
|
||||
/**
|
||||
* Called to add the sort to a query.
|
||||
*/
|
||||
function query() {
|
||||
$this->ensure_my_table();
|
||||
// Add the field.
|
||||
$this->query->add_orderby($this->table_alias, $this->real_field, $this->options['order']);
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['order'] = array('default' => 'ASC');
|
||||
$options['exposed'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
$options['expose'] = array(
|
||||
'contains' => array(
|
||||
'label' => array('default' => '', 'translatable' => TRUE),
|
||||
),
|
||||
);
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display whether or not the sort order is ascending or descending
|
||||
*/
|
||||
function admin_summary() {
|
||||
if (!empty($this->options['exposed'])) {
|
||||
return t('Exposed');
|
||||
}
|
||||
switch ($this->options['order']) {
|
||||
case 'ASC':
|
||||
case 'asc':
|
||||
default:
|
||||
return t('asc');
|
||||
break;
|
||||
case 'DESC';
|
||||
case 'desc';
|
||||
return t('desc');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic options for all sort criteria
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
if ($this->can_expose()) {
|
||||
$this->show_expose_button($form, $form_state);
|
||||
}
|
||||
$form['op_val_start'] = array('#value' => '<div class="clearfix">');
|
||||
$this->show_sort_form($form, $form_state);
|
||||
$form['op_val_end'] = array('#value' => '</div>');
|
||||
if ($this->can_expose()) {
|
||||
$this->show_expose_form($form, $form_state);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut to display the expose/hide button.
|
||||
*/
|
||||
function show_expose_button(&$form, &$form_state) {
|
||||
$form['expose_button'] = array(
|
||||
'#prefix' => '<div class="views-expose clearfix">',
|
||||
'#suffix' => '</div>',
|
||||
// Should always come first
|
||||
'#weight' => -1000,
|
||||
);
|
||||
|
||||
// Add a checkbox for JS users, which will have behavior attached to it
|
||||
// so it can replace the button.
|
||||
$form['expose_button']['checkbox'] = array(
|
||||
'#theme_wrappers' => array('container'),
|
||||
'#attributes' => array('class' => array('js-only')),
|
||||
);
|
||||
$form['expose_button']['checkbox']['checkbox'] = array(
|
||||
'#title' => t('Expose this sort to visitors, to allow them to change it'),
|
||||
'#type' => 'checkbox',
|
||||
);
|
||||
|
||||
// Then add the button itself.
|
||||
if (empty($this->options['exposed'])) {
|
||||
$form['expose_button']['markup'] = array(
|
||||
'#markup' => '<div class="description exposed-description" style="float: left; margin-right:10px">' . t('This sort is not exposed. Expose it to allow the users to change it.') . '</div>',
|
||||
);
|
||||
$form['expose_button']['button'] = array(
|
||||
'#limit_validation_errors' => array(),
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Expose sort'),
|
||||
'#submit' => array('views_ui_config_item_form_expose'),
|
||||
);
|
||||
$form['expose_button']['checkbox']['checkbox']['#default_value'] = 0;
|
||||
}
|
||||
else {
|
||||
$form['expose_button']['markup'] = array(
|
||||
'#markup' => '<div class="description exposed-description">' . t('This sort is exposed. If you hide it, users will not be able to change it.') . '</div>',
|
||||
);
|
||||
$form['expose_button']['button'] = array(
|
||||
'#limit_validation_errors' => array(),
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Hide sort'),
|
||||
'#submit' => array('views_ui_config_item_form_expose'),
|
||||
);
|
||||
$form['expose_button']['checkbox']['checkbox']['#default_value'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple validate handler
|
||||
*/
|
||||
function options_validate(&$form, &$form_state) {
|
||||
$this->sort_validate($form, $form_state);
|
||||
if (!empty($this->options['exposed'])) {
|
||||
$this->expose_validate($form, $form_state);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple submit handler
|
||||
*/
|
||||
function options_submit(&$form, &$form_state) {
|
||||
unset($form_state['values']['expose_button']); // don't store this.
|
||||
$this->sort_submit($form, $form_state);
|
||||
if (!empty($this->options['exposed'])) {
|
||||
$this->expose_submit($form, $form_state);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut to display the value form.
|
||||
*/
|
||||
function show_sort_form(&$form, &$form_state) {
|
||||
$options = $this->sort_options();
|
||||
if (!empty($options)) {
|
||||
$form['order'] = array(
|
||||
'#type' => 'radios',
|
||||
'#options' => $options,
|
||||
'#default_value' => $this->options['order'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function sort_validate(&$form, &$form_state) { }
|
||||
|
||||
function sort_submit(&$form, &$form_state) { }
|
||||
|
||||
/**
|
||||
* Provide a list of options for the default sort form.
|
||||
* Should be overridden by classes that don't override sort_form
|
||||
*/
|
||||
function sort_options() {
|
||||
return array(
|
||||
'ASC' => t('Sort ascending'),
|
||||
'DESC' => t('Sort descending'),
|
||||
);
|
||||
}
|
||||
|
||||
function expose_form(&$form, &$form_state) {
|
||||
// #flatten will move everything from $form['expose'][$key] to $form[$key]
|
||||
// prior to rendering. That's why the pre_render for it needs to run first,
|
||||
// so that when the next pre_render (the one for fieldsets) runs, it gets
|
||||
// the flattened data.
|
||||
array_unshift($form['#pre_render'], 'views_ui_pre_render_flatten_data');
|
||||
$form['expose']['#flatten'] = TRUE;
|
||||
|
||||
$form['expose']['label'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => $this->options['expose']['label'],
|
||||
'#title' => t('Label'),
|
||||
'#required' => TRUE,
|
||||
'#size' => 40,
|
||||
'#weight' => -1,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide default options for exposed sorts.
|
||||
*/
|
||||
function expose_options() {
|
||||
$this->options['expose'] = array(
|
||||
'order' => $this->options['order'],
|
||||
'label' => $this->definition['title'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A special handler to take the place of missing or broken handlers.
|
||||
*
|
||||
* @ingroup views_sort_handlers
|
||||
*/
|
||||
class views_handler_sort_broken extends views_handler_sort {
|
||||
function ui_name($short = FALSE) {
|
||||
return t('Broken/missing handler');
|
||||
}
|
||||
|
||||
function ensure_my_table() { /* No table to ensure! */ }
|
||||
function query($group_by = FALSE) { /* No query to run */ }
|
||||
function options_form(&$form, &$form_state) {
|
||||
$form['markup'] = array(
|
||||
'#markup' => '<div class="form-item description">' . t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.') . '</div>',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the handler is considered 'broken'
|
||||
*/
|
||||
function broken() { return TRUE; }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_sort_date.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Basic sort handler for dates.
|
||||
*
|
||||
* This handler enables granularity, which is the ability to make dates
|
||||
* equivalent based upon nearness.
|
||||
*
|
||||
* @ingroup views_sort_handlers
|
||||
*/
|
||||
class views_handler_sort_date extends views_handler_sort {
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['granularity'] = array('default' => 'second');
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
$form['granularity'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Granularity'),
|
||||
'#options' => array(
|
||||
'second' => t('Second'),
|
||||
'minute' => t('Minute'),
|
||||
'hour' => t('Hour'),
|
||||
'day' => t('Day'),
|
||||
'month' => t('Month'),
|
||||
'year' => t('Year'),
|
||||
),
|
||||
'#description' => t('The granularity is the smallest unit to use when determining whether two dates are the same; for example, if the granularity is "Year" then all dates in 1999, regardless of when they fall in 1999, will be considered the same date.'),
|
||||
'#default_value' => $this->options['granularity'],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to add the sort to a query.
|
||||
*/
|
||||
function query() {
|
||||
$this->ensure_my_table();
|
||||
switch ($this->options['granularity']) {
|
||||
case 'second':
|
||||
default:
|
||||
$this->query->add_orderby($this->table_alias, $this->real_field, $this->options['order']);
|
||||
return;
|
||||
case 'minute':
|
||||
$formula = views_date_sql_format('YmdHi', "$this->table_alias.$this->real_field");
|
||||
break;
|
||||
case 'hour':
|
||||
$formula = views_date_sql_format('YmdH', "$this->table_alias.$this->real_field");
|
||||
break;
|
||||
case 'day':
|
||||
$formula = views_date_sql_format('Ymd', "$this->table_alias.$this->real_field");
|
||||
break;
|
||||
case 'month':
|
||||
$formula = views_date_sql_format('Ym', "$this->table_alias.$this->real_field");
|
||||
break;
|
||||
case 'year':
|
||||
$formula = views_date_sql_format('Y', "$this->table_alias.$this->real_field");
|
||||
break;
|
||||
}
|
||||
|
||||
// Add the field.
|
||||
$this->query->add_orderby(NULL, $formula, $this->options['order'], $this->table_alias . '_' . $this->field . '_' . $this->options['granularity']);
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_sort_group_by_numeric.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handler for GROUP BY on simple numeric fields.
|
||||
*
|
||||
* @ingroup views_sort_handlers
|
||||
*/
|
||||
class views_handler_sort_group_by_numeric extends views_handler_sort {
|
||||
function init(&$view, &$options) {
|
||||
parent::init($view, $options);
|
||||
|
||||
// Initialize the original handler.
|
||||
$this->handler = views_get_handler($options['table'], $options['field'], 'sort');
|
||||
$this->handler->init($view, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to add the field to a query.
|
||||
*/
|
||||
function query() {
|
||||
$this->ensure_my_table();
|
||||
|
||||
$params = array(
|
||||
'function' => $this->options['group_type'],
|
||||
);
|
||||
|
||||
$this->query->add_orderby($this->table_alias, $this->real_field, $this->options['order'], NULL, $params);
|
||||
}
|
||||
|
||||
function ui_name($short = FALSE) {
|
||||
return $this->get_field(parent::ui_name($short));
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_sort_menu_hierarchy.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Sort in menu hierarchy order.
|
||||
*
|
||||
* Given a field name of 'p' this produces an ORDER BY on p1, p2, ..., p9;
|
||||
* and optionally injects multiple joins to {menu_links} to sort by weight
|
||||
* and title as well.
|
||||
*
|
||||
* This is only really useful for the {menu_links} table.
|
||||
*
|
||||
* @ingroup views_sort_handlers
|
||||
*/
|
||||
class views_handler_sort_menu_hierarchy extends views_handler_sort {
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['sort_within_level'] = array('default' => FALSE);
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$form['sort_within_level'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Sort within each hierarchy level'),
|
||||
'#description' => t('Enable this to sort the items within each level of the hierarchy by weight and title. Warning: this may produce a slow query.'),
|
||||
'#default_value' => $this->options['sort_within_level'],
|
||||
);
|
||||
}
|
||||
|
||||
function query() {
|
||||
$this->ensure_my_table();
|
||||
$max_depth = isset($this->definition['max depth']) ? $this->definition['max depth'] : MENU_MAX_DEPTH;
|
||||
for ($i = 1; $i <= $max_depth; ++$i) {
|
||||
if ($this->options['sort_within_level']) {
|
||||
$join = new views_join();
|
||||
$join->construct('menu_links', $this->table_alias, $this->field . $i, 'mlid');
|
||||
$menu_links = $this->query->add_table('menu_links', NULL, $join);
|
||||
$this->query->add_orderby($menu_links, 'weight', $this->options['order']);
|
||||
$this->query->add_orderby($menu_links, 'link_title', $this->options['order']);
|
||||
}
|
||||
|
||||
// We need this even when also sorting by weight and title, to make sure
|
||||
// that children of two parents with the same weight and title are
|
||||
// correctly separated.
|
||||
$this->query->add_orderby($this->table_alias, $this->field . $i, $this->options['order']);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_sort_random.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handle a random sort.
|
||||
*
|
||||
* @ingroup views_sort_handlers
|
||||
*/
|
||||
class views_handler_sort_random extends views_handler_sort {
|
||||
function query() {
|
||||
$this->query->add_orderby('rand');
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$form['order']['#access'] = FALSE;
|
||||
}
|
||||
}
|
62
sites/all/modules/contrib/views/views/help/about.html
Normal file
62
sites/all/modules/contrib/views/views/help/about.html
Normal file
@ -0,0 +1,62 @@
|
||||
The views module allows administrators and site designers to create, manage, and display lists of content. Each list managed by the views module is known as a "view", and the output of a view is known as a "display". Displays are provided in either block or page form, and a single view may have multiple displays. Optional navigation aids, including a system path and menu item, can be set for each page-based display of a view. By default, views may be created that list content (a <em>Node</em> view type), content revisions (a <em>Node revisions</em> view type) or users (a <em>User</em> view type). A view may be restricted to members of specific user roles, and may be added, edited or deleted at the <a href="base_url:admin/structure/views">views administration page</a>.
|
||||
|
||||
For more technical users, views can be understood as a user interface to compose SQL-queries and to pull information (Content, Users, etc.) from the database and show it on a screen as desired.
|
||||
|
||||
The "building block" design of the views system provides power and flexibility, allowing parameters to be specified only when needed. While an advanced view may use all of available parameters to create complex and highly interactive applications, a simple content listing may specify only a few options. All views rely on a conceptual framework that includes:
|
||||
|
||||
<ul>
|
||||
<li><a href="topic:views/field">Fields</a>, or the individual pieces of data being displayed. Adding the fields <em>Node: Title</em>, <em>Node: Type</em>, and <em>Node: Post date</em> to a node view, for example, includes the title, content type and creation date in the displayed results </li>
|
||||
|
||||
<li><a href="topic:views/relationship">Relationships</a>, or information about how data elements relate to one another. If relationship data is available, like that provided by a CCK <em>nodereference</em> field, items from a related node may be included in the view </li>
|
||||
|
||||
<li><a href="topic:views/argument">Arguments</a>, or additional parameters that dynamically refine the view results, passed as part of the path. Adding an argument of <em>Node: Type</em> to a node view with a path of "content", for example, dynamically filters the displayed items by content type. In this example (shown with Clean URLs enabled), accessing the view through the path "<em>http://www.example.com/content/page</em>" displays all posts of the type "page", the path "<em>http://www.example.com/content/story</em>" displays all posts of the type "story", and "<em>http://www.example.com/content</em>" displays all posts regardless of type) </li>
|
||||
|
||||
<li><a href="topic:views/sort">Sort criteria</a>, which determine the order of items displayed in the view results. Adding the sort criteria <em>Node: Post date</em> (in descending order) to a node <em>view</em>, for example, sorts the displayed posts in descending order by creation date </li>
|
||||
|
||||
<li><a href="topic:views/filter">Filters</a>, which limit items displayed in the results. Adding the filter <em>Node: Published</em> (and setting it equal to "Published") to a node view, for example, prevents unpublished items from being displayed</li>
|
||||
|
||||
<li><a href="topic:views/display">Displays</a>, which control where the output will be seen. Every view has a default display, which doesn't actually display the view anywhere, but is used to hold the default settings for the view, and is used when the view is called programmatically if another display is not specified. Much more useful to users are the <a href="topic:views/display-page">page</a> display, which gives a view a path and allows it to be the primary content of a page, or the <a href="topic:views/display-block">block</a> display which allows it to appear as secondary content on other pages.</li>
|
||||
|
||||
<li><a href="topic:views/header">Header</a>, which allow you to add by default one or more text area above the views output. </li>
|
||||
|
||||
<li><a href="topic:views/footer">Footer</a>, which allow you to add by default one or more text area beneath the views output. </li>
|
||||
|
||||
<li>The <a href="topic:views/footer">Emtpy Text</a> content will be displayed, when you choose in the Arguments Section "Action to take if argument is not present" the option "Display empty text".</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
Parallels between the components in the Views interface and an sql query:
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Sql Query</th>
|
||||
<th>Views Component</th>
|
||||
<tr>
|
||||
</thead>
|
||||
<tr>
|
||||
<td>SELECT n.title, u.name</td>
|
||||
<td>fields</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>FROM {node} n base table</td>
|
||||
<td>view type</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>INNER JOIN {users} u ON n.uid = u.uid</td>
|
||||
<td>relationship</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>WHERE n.status = 1</td>
|
||||
<td>filter</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>AND u.uid = arg(1)</td>
|
||||
<td>argument</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>ORDER BY n.changed DESC</td>
|
||||
<td>sort</td>
|
||||
</tr>
|
||||
</table>
|
@ -0,0 +1,43 @@
|
||||
In the category <strong>Other</strong> you have different options to set Advanced configurations in your View.
|
||||
|
||||
<strong>Machine Name:</strong>
|
||||
You can change the default machine name of the view.
|
||||
|
||||
<strong>Comment: No comment</strong>
|
||||
You can Use the comment option to write comments for your Views, the comments are only shown in the Views UI. Comment your Display for other Maintainer
|
||||
|
||||
<strong>Use AJAX: No</strong>
|
||||
If set, this view will use an AJAX mechanism for paging, table sorting and exposed filters. This prevents the entire page from refreshing. It is not recommended that you use this if this view is the main content of the page as it will prevent deep linking to specific pages, but it is very useful for side content. Block displays require this setting to be ON if exposed filters are being used.
|
||||
|
||||
<strong>Hide attachments in summary: No</strong>
|
||||
|
||||
<strong>Use aggregation: No</strong>
|
||||
All fields that are selected for grouping will be collapsed to one record per distinct value. Other fields which are selected for aggregation will have the function run on them. For example, you can group nodes on title and count the number of nids in order to get a list of duplicate titles.
|
||||
For more Information how aggregation work see the "Use Aggregation" Help Page
|
||||
|
||||
<strong>Query settings: Settings</strong>
|
||||
|
||||
Here can you set advanced Settings for the SQL Settings
|
||||
<ul>
|
||||
<li><strong>Disable SQL rewriting</strong></li>
|
||||
|
||||
<li><strong>Distinct: No</strong></li>
|
||||
This will make the view display only distinct items. If there are multiple identical items, each will be displayed only once. You can use this to try and remove duplicates from a view, though it does not always work. Note that this can slow queries down, so use it with caution.
|
||||
|
||||
<li><strong>Use Slave Server</strong></li>
|
||||
|
||||
<li><strong>Query Comment</strong></li>
|
||||
</ul>
|
||||
<strong>Field Language: Current user's language</strong>
|
||||
|
||||
<strong>Caching: None</strong>
|
||||
You can choose a "Time-based" Caching if you want. With it you get the option to choose the length of time raw query results should be cached and "The length of time rendered HTML output should be cached."
|
||||
|
||||
<strong>Link display: Page</strong>
|
||||
|
||||
<strong>CSS class: None</strong>
|
||||
You can define some own CSS Classes for your View
|
||||
|
||||
<strong>Theme: Information</strong>
|
||||
Clicking on the "Theme: Information" link provides you with a listing of all posiible theming files. The highlighted files are the ones Views is currently using. All other filenames are suggested templates.
|
||||
For more Information see the <a href="/help/views/analyze-theme" title="Theme Information" >"Theme information"</a> Page
|
@ -0,0 +1,30 @@
|
||||
In Views 3 you can set Advanced Style Settings, they help you to insert markup of your own from the Views UI, so that you can fairly easily override the default markup without having to restyle via templates.
|
||||
|
||||
|
||||
<ul>
|
||||
<li> Customize field HTML</li>
|
||||
With Customize field HTML you can generate html tags around the field.
|
||||
|
||||
<li>Customize label HTML</li>
|
||||
Here you can generate html tags around the label of a field.
|
||||
|
||||
<li>Customize field and label wrapper HTML</li>
|
||||
Here you can generate html tags around the wrapper of the label and field
|
||||
</ul>
|
||||
|
||||
<a href="path:images/views3-semanticviews.png"><img src="path:images/views3-semanticviews.png" /></a>
|
||||
|
||||
Usage example
|
||||
|
||||
In a view with a field:
|
||||
<ol>
|
||||
<li>Configure the field. (Click on the field.)</li>
|
||||
|
||||
<li>In the modal that opens, scroll down to <strong>Style Settings</strong>.</li>
|
||||
|
||||
<li>Choose one or more of the three <i>Customize</i> options. This will reveal a dropdown menu where you can choose from one or more HTML tags to use on that field and allow you to add a CSS class specific to that field should you desire.</li>
|
||||
|
||||
<li>Decide if you want to keep the Views default classes. Unchecking this box means your markup is *it*.</li>
|
||||
</ol>
|
||||
|
||||
In Views 2 you needed for Style Settings the <a href="http://drupal.org/project/semanticviews">Semantic Views</a> Modul, now the Semantic Views module has been mostly incorporated into Views 3.x. Semantic Views is still around for people who need it, though. For some details on how the original module is different from the Views implementation, please see <a href="http://drupal.org/node/1013876">this issue</a>.
|
@ -0,0 +1 @@
|
||||
See: <a href="topic:views/group-by">Group by</a>
|
@ -0,0 +1,31 @@
|
||||
Modifying default values of a views exposed form is tricky, because FAPI was not designed to work with GET forms. One consequence is that it often can't tell if textfields (there are others) were submitted or not.
|
||||
|
||||
As a consequence, it *always* thinks the value was submitted, even if it was not. To fix that, Views modifies $form_state['input'][$identifier] with the default value if $form_state['input'][$identifier] was not set. In order to modify the default value in an alter, you need to do this:
|
||||
|
||||
<pre>
|
||||
<?php
|
||||
if (empty($form_state['view']->exposed_input[$identifier])) .
|
||||
{ $form_state['input'][$identifier] = $default_value; }
|
||||
?>
|
||||
</pre>
|
||||
|
||||
where $identifier is the particular filter for which you want to change the default value, and $default_value is the new default value you want to set.
|
||||
|
||||
If you use a hook_form_FORM_ID_alter or hook_form_alter, you can modify exposed filters on the fly based on information that is external to Views. For example, I modified the exposed filter of a form to set a taxonomy term ID based on the user's GeoIP.
|
||||
|
||||
To do this, I used the following function, where geoip_redirect_get_tid() loads the relevant term id based on the user's current ip_address():
|
||||
|
||||
<pre>
|
||||
<?php
|
||||
function MODULENAME_form_views_exposed_form_alter(&$form, $form_state) {
|
||||
if(strpos($form['#id'], 'volunteer-directory') !== FALSE) {
|
||||
$city_tid = geoip_redirect_get_tid();
|
||||
if(is_numeric($city_tid) && $city_tid != 7660) {
|
||||
if (empty($form_state['view']->exposed_input['tid'])) {
|
||||
$form_state['input']['tid'] = $city_tid;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</pre>
|
@ -0,0 +1,24 @@
|
||||
<p>Clicking on the "Theme: Information" link provides you with a listing of all posiible theming files. The highlighted files are the ones Views is currently using. All other filenames are suggested templates.</p>
|
||||
<p>You may use any of the following possible theme files to modify individual parts of your view. In total, there are four parts to theming a view.</p>
|
||||
<ul>
|
||||
<li> The <strong>display</strong> theme is usually views-view.tpl.php and it largely controls the decorations around a view; where the header, footer, pager, more link, feed icon, etc, will be placed. </li>
|
||||
|
||||
<li> The <strong>style</strong> will control how all of the results of the display are put together. It may be as simple as just displaying all of the rows, or it may be a complex table generator or something in between. </li>
|
||||
|
||||
<li> The <strong>row</strong> style controls each individual row; not all styles utilize the row style (notably the table), but most others do.
|
||||
|
||||
<li> Finally, <strong>field</strong> themes allow you to override the look and even the data of each individual field, if the style uses fields. The actual template the system will use should be hilighted in <strong>bold</strong>.</li>
|
||||
</ul>
|
||||
|
||||
<div class="help-box" style="text-align:center">
|
||||
<a href="path:images/style-breakdown-large.png"><img src="path:images/style-breakdown.png" /></a>
|
||||
<em>A breakdown of View output</em>
|
||||
</div>
|
||||
|
||||
<p>The link to the left of each type will give you information about the default template used for that type. You may cut and paste this and place it in your theme with the appropriate template, or you may copy the base file from the views/theme directory (or, if provided by a module, from the module's directory). <strong>It is important that you clear the theme registry cache every time you add a new template, or the new template will not be picked up.</strong></p>
|
||||
|
||||
<p><strong>Important note:</strong> You place your custom template files in your theme directory, <strong>not views/theme</strong>. This is always true of theming with Drupal.
|
||||
|
||||
<p>In addition to this tool, the very useful <a href="http://drupal.org/project/devel">devel</a> module contains a tool called the "Theme developer" which does a good job of visually showing you which areas of your site use which themes. Be careful with it, though, as the theme developer causes the Views edit page to break.</p>
|
||||
|
||||
<p>Also, this feature will only work properly with Drupal 6.3 and later; prior to Drupal 6.3 <a href="http://drupal.org/node/241570">this patch</a> will be required.</p>
|
@ -0,0 +1,103 @@
|
||||
Views can be stored in the database, which is typical of smaller sites and hobby sites. However, Views may also be stored directly in the code as "default" views, (which simply means they're available by default). Modules often come with views that are specific to the module data, but it's also possible -- and <b>highly</b> recommended -- that sites which have separate "development" and "production" sites export their views into default views in a site-specific module. This makes it very easy to transfer views from dev to production without making database changes.
|
||||
|
||||
<h3>Creating a module</h3>
|
||||
First, create a directory in <em>sites/all/modules</em> for your new module. Call it whatever you like, but for this example we will call it <em>mymodule</em>.
|
||||
|
||||
In this directory, create a <em>mymodule.module</em> file. It can be empty for now, but it should at least contain an opening PHP tag:
|
||||
<pre><?php
|
||||
</pre>
|
||||
|
||||
It should not contain a closing ?> tag, as the closing ?> tag is not required and anything AFTER the closing tag, such as a space or a linefeed, will be displayed directly to the browser and can potentially cause problems.
|
||||
|
||||
The .module file will contain functions and drupal hooks. Hooks are specially named functions that Drupal will call in order to get your module's response at certain times while generating pages. The only function you will need for this exercise is the 'views_api' hook that tells Views that this module supports the Views API and what version:
|
||||
|
||||
<pre>function mymodule_views_api() {
|
||||
return array('api' => 2.0);
|
||||
}
|
||||
</pre>
|
||||
|
||||
For other uses you may well add additional functions.
|
||||
|
||||
Second, you need to create a <em>mymodule.info</em> file:
|
||||
|
||||
<pre>name = My module
|
||||
description = My site specific module.
|
||||
core = 6.x
|
||||
</pre>
|
||||
|
||||
Once you have these two files set up, you should be able to activate your new module at the <em>Administer >> Modules</em> page.
|
||||
<h3>Exporting your views</h3>
|
||||
|
||||
The easiest way to do this is to activate the 'views_export' module, and navigate to <em>Administer >> Structure >> Views >> Tools >> Bulk export</em> Place a check next to each view that you want in your module, type the module name into the text field, and click export. This will create the entire <em>hook_views_default_views()</em> function for you.
|
||||
|
||||
You can also export individual views. If you do this, keep in mind that this export does not include the line that adds the exported $view into the larger $views array:
|
||||
|
||||
<pre>$views[$view->name] = $view</pre>
|
||||
|
||||
To place this into your <em>hook_views_default_views()</em> you will need to place that after the view, and make sure the function returns $views at the end.
|
||||
|
||||
<h3>Placing your exported views into your module</h3>
|
||||
Cut and paste the entire output of the bulk export tool into mymodule.views_default.inc -- and be sure to put a <?php at the top of the file so that the webserver knows that it's PHP code! Then visit the Views tools page and clear the Views cache. Your views should now be listed as <b>Overridden</b> on the view list page. If you <b>revert</b> these views, they will be removed from the database, but will remain in code.
|
||||
|
||||
<h3>Theming your views in your module</h3>
|
||||
You can theme these views in the module and not need to rely on the theme to do this at all; and in fact, the theme can continue to override these just like it ordinarily would, even if your module provides a theme. This is very useful for distributing a module where the view needs to look "just so."
|
||||
|
||||
To do this, you need to implement <em>hook_theme()</em> in your module:
|
||||
<pre>function mymodule_theme($existing) {
|
||||
return array(
|
||||
'views_view__viewname__displayid' => array (
|
||||
'arguments' => array('view' => NULL),
|
||||
'template' => 'views-view--viewname--displayid',
|
||||
'base hook' => 'views_view',
|
||||
'path' => drupal_get_path('module', 'mymodule'),
|
||||
),
|
||||
);
|
||||
}
|
||||
</pre>
|
||||
|
||||
There are a small number of gotchas in doing this that you must be aware of.
|
||||
|
||||
<ol>
|
||||
<li>When referring to a template filename, you always use dashes in the name. i.e, <em>views-view--viewname--displayid.tpl.php</em>. However, when referring to the hook or function names, you use underscores instead of dashes. i.e, <em>views_view</em> and <em>views_view__viewname__displayid</em></li>
|
||||
|
||||
<li>The 'arguments' change based upon which of the 3 types you're overriding. There's the 'display', the 'style' and the 'row' style. The above code is assuming the display, which is usually just <em>views_view</em>. Here are the possibilities:
|
||||
|
||||
<pre>display: array('view_array' => array(), 'view' => NULL),
|
||||
style: array('view' => NULL, 'options' => NULL, 'rows' => NULL, 'title' => NULL),
|
||||
row: array('view' => NULL, 'options' => NULL, 'row' => NULL, 'field_alias' => NULL),
|
||||
field: array('view' => NULL, 'field' => NULL, 'row' => NULL),
|
||||
</pre>
|
||||
|
||||
Be sure to use the right arguments line or the theme system will not properly translate.
|
||||
</li>
|
||||
<li>The 'template' line should never include the extension, so drop the .tpl.php from it.</li>
|
||||
|
||||
<li>You need to make sure that the Views preprocess functions get registered. The 'base hook' line in the definition does that, but it can only do it if it comes after the Views registration, which actually happens very late in theme building. 99% of the time, your module will come before Views. You have two choices to deal with this:
|
||||
<ol>
|
||||
<li>Set your module's weight to 11 or higher in the database. Views' weight is 10. You can make this happen automatically when the module is first installed by creating a mymodule.install file and using this code:
|
||||
<pre>function mymodule_install() {
|
||||
db_query("UPDATE {system} SET weight = 11 WHERE name = 'mymodule'");
|
||||
}
|
||||
</pre>
|
||||
If you use this method, the <em>base hook</em> should be set to the name of the original template being used. i.e, if this is a variate of views-view-list.tpl.php, this should be 'views_view_list'.
|
||||
</li>
|
||||
<li>You can also just force it to list the preprocessors without actually having to detect them. This doesn't require modifying your module's weight, which is not always possible, you can insert this code into the array:
|
||||
<pre> 'preprocess functions' => array(
|
||||
'template_preprocess',
|
||||
'template_preprocess_views_view',
|
||||
'mymodule_preprocess_views_view__viewname_displayid',
|
||||
),
|
||||
</pre>
|
||||
|
||||
The first one is the global 'template_preprocess' function which all templates utilize. It does some basic things such as setting up $zebra and a few other items. See <a href="http://api.drupal.org/api/function/template_preprocess/6">api.drupal.org</a> for specifics.
|
||||
|
||||
The second one is the plugin specific preprocess. Like 'base hook' it should conform to the name used by the original template. i.e, if the original template was <em>views-view-list.tpl.php</em> then that preprocess function would be named <em>template_preprocess_views_view_list</em>.
|
||||
|
||||
The third one is your module's preprocess function, if it needs one. In general, you probably will not need one, and you should only attempt to use one if you are reasonably familiar with the concept of preprocess functions and Drupal's theme system in general. See Drupal's theme documentation for more information.
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li>
|
||||
If you leave the path blank the template file will be searched for in "./" which is the Drupal install base path.
|
||||
</li>
|
||||
</ol>
|
179
sites/all/modules/contrib/views/views/help/api-example.html
Normal file
179
sites/all/modules/contrib/views/views/help/api-example.html
Normal file
@ -0,0 +1,179 @@
|
||||
|
||||
For the new table defined by the Node example module to be understood by the views module you need to create a node_example.views.inc file that describes the table and its relationships to the rest of the database. In order for views to know that this file is to be loaded you need to implement hook_views_api. This is done by adding the following function into your node_example.module file
|
||||
|
||||
<pre>
|
||||
<?php
|
||||
/**
|
||||
* Implements hook_views_api().
|
||||
*
|
||||
* This tells drupal that there is Views integration file named
|
||||
* module-name.views.inc
|
||||
*/
|
||||
function node_example_views_api() {
|
||||
// Note that you can include 'path' in this array so that your views.inc
|
||||
// file can be stored in a different location.
|
||||
return array(
|
||||
'api' => 2.0
|
||||
);
|
||||
}
|
||||
?>
|
||||
</pre>
|
||||
|
||||
Below is the contents of a simple node_example.views.inc file that allows you to create views that include the new color and quantity information.
|
||||
|
||||
<pre>
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is used to tell the views module about the new node_example table.
|
||||
*
|
||||
* Database definition:
|
||||
* @code
|
||||
* CREATE TABLE node_example (
|
||||
* vid int(10) unsigned NOT NULL default '0',
|
||||
* nid int(10) unsigned NOT NULL default '0',
|
||||
* color varchar(255) NOT NULL default '',
|
||||
* quantity int(10) unsigned NOT NULL default '0',
|
||||
* PRIMARY KEY (vid, nid),
|
||||
* KEY `node_example_nid` (nid)
|
||||
* )
|
||||
* @endcode
|
||||
*/
|
||||
|
||||
function node_example_views_data() {
|
||||
// Basic table information.
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// node_example table
|
||||
// New group within Views called 'Example'
|
||||
// The group will appear in the UI in the dropdown tha allows you
|
||||
// to narrow down which fields and filters are available.
|
||||
|
||||
$data = array();
|
||||
$data['node_example']['table']['group'] = t('Example');
|
||||
|
||||
// Let Views know that our example table joins to the 'node'
|
||||
// base table. This means it will be available when listing
|
||||
// nodes and automatically make its fields appear.
|
||||
//
|
||||
// We also show up for node revisions.
|
||||
$data['node_example']['table']['join'] = array(
|
||||
'node_revisions' => array(
|
||||
'left_field' => 'vid',
|
||||
'field' => 'vid',
|
||||
),
|
||||
'node' => array(
|
||||
'left_field' => 'vid',
|
||||
'field' => 'vid',
|
||||
),
|
||||
);
|
||||
|
||||
// quantity
|
||||
$data['node_example']['quantity'] = array(
|
||||
'title' => t('Quantity'),
|
||||
'help' => t('Quantity of items.'),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_numeric',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_numeric',
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
);
|
||||
|
||||
// Color
|
||||
$data['node_example']['color'] = array(
|
||||
'title' => t('Color'),
|
||||
'help' => t('Color of item.'),
|
||||
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
?>
|
||||
</pre>
|
||||
|
||||
Some notes on usage:
|
||||
|
||||
Within Views, click on the Add tab. You have a number of type options here. Normally you would select either 'Node' (if you only want to display information on current nodes) or 'Node revision' (if you want to display information on all revisions of the nodes)
|
||||
|
||||
With this configuration you always pull out of the database, data for every single node, whether or not it has color and quantity information. To display information on just those nodes that have color and quantity information you can use a filter so that only nodes which don't have a NULL color or a NULL quantity are displayed.
|
||||
|
||||
<h3>Type/relationship extension</h3>
|
||||
|
||||
When your tables have first class data, you will often need to have own View types and View relationships defined. With the current node_example table this isn't required although I try to justify it below on an efficiency basis. See [[http://groups.drupal.org/node/17236#comment-58980|this discussion]] as to why it isn't justified.
|
||||
|
||||
Pulling data out of the database for every node when you only want data for the new Example node type is inefficient. To reduce the initial data extraction to just that relating to the new Example nodes requires that you make the node_example table the base table. This can be done by adding the following code into the node_example.views.inc file just before the 'return $data;'
|
||||
|
||||
<pre>
|
||||
<?php
|
||||
|
||||
// **** Begin optional extra for type and relationships ****
|
||||
|
||||
// Use node_example as a new base table
|
||||
// by creating a new views type called 'Node example'
|
||||
// This allows it to be selected as the 'view type'
|
||||
// when you initially add a new view.
|
||||
$data['node_example']['table']['base'] = array(
|
||||
'field' => 'vid',
|
||||
'title' => t('Node example'),
|
||||
'help' => t("Node example type with color and quantity information."),
|
||||
'weight' => -9,
|
||||
);
|
||||
|
||||
// When using the new 'Node example' type you need to use relationships
|
||||
// to access fields in other tables.
|
||||
|
||||
// Relationship to the 'Node revision' table
|
||||
$data['node_example']['vid'] = array(
|
||||
'title' => t('Node revision'),
|
||||
'help' => t('The particular node revision the color and quantity is attached to'),
|
||||
'relationship' => array(
|
||||
'label' => t('Node revision'),
|
||||
'base' => 'node_revisions',
|
||||
'base field' => 'vid',
|
||||
// This allows us to not show this relationship if the base is already
|
||||
// node_revisions so users won't create circular relationships.
|
||||
'skip base' => array('node', 'node_revisions'),
|
||||
),
|
||||
);
|
||||
|
||||
// Relationship to the 'Node' table
|
||||
$data['node_example']['nid'] = array(
|
||||
'title' => t('Node'),
|
||||
'help' => t('The particular node the color and quantity is attached to'),
|
||||
'relationship' => array(
|
||||
'label' => t('Node'),
|
||||
'base' => 'node',
|
||||
'base field' => 'nid',
|
||||
// This allows us to not show this relationship if the base is already
|
||||
// node so users won't create circular relationships.
|
||||
'skip base' => array('node', 'node_revisions'),
|
||||
),
|
||||
);
|
||||
|
||||
// **** End optional extra for type and relationships ****
|
||||
|
||||
?>
|
||||
</pre>
|
||||
|
||||
The above code adds a new 'Node example' to the view types that can be selected within the Add tab window of views. Selecting this sets the node_example table to be the base table.
|
||||
|
||||
If you select 'Node example' as view type, when you initially go into the edit window of views you will find the only fields available are the color and quantity fields. To get fields from other tables you need to add a relationship. Relationships may be found at the top in the same column as the fields.
|
88
sites/all/modules/contrib/views/views/help/api-forms.html
Normal file
88
sites/all/modules/contrib/views/views/help/api-forms.html
Normal file
@ -0,0 +1,88 @@
|
||||
Views allows handlers to output form elements, wrapping them automatically in a form, and handling validation / submission.
|
||||
The form is multistep by default, allowing other modules to add additional steps, such as confirmation screens.
|
||||
|
||||
<h2>Implementation</h2>
|
||||
A views handler outputs a special placeholder in render(), while the real form with matching structure gets added in views_form().
|
||||
When the View is being preprocessed for the theme file, all placeholders get replaced with the rendered form elements.
|
||||
|
||||
The views handler can also implement views_form_validate() and views_form_submit().
|
||||
<pre>
|
||||
function render($values) {
|
||||
return '<!--form-item-' . $this->options['id'] . '--' . $this->view->row_index . '-->';
|
||||
}
|
||||
|
||||
function form_element_name() {
|
||||
// Make sure this value is unique for all the view fields
|
||||
return $this->options['id'];
|
||||
}
|
||||
|
||||
function form_element_row_id($row_id) {
|
||||
// You could use values from $this->view->result[$row_id]
|
||||
// to provide complex row ids.
|
||||
return $row_id;
|
||||
}
|
||||
|
||||
function views_form(&$form, &$form_state) {
|
||||
// The view is empty, abort.
|
||||
if (empty($this->view->result)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$field_name = $this->form_element_name();
|
||||
$form[$field_name] = array(
|
||||
'#tree' => TRUE,
|
||||
);
|
||||
// At this point, the query has already been run, so we can access the results
|
||||
foreach ($this->view->result as $row_id => $row) {
|
||||
$form_element_row_id = $this->form_element_row_id($row_id);
|
||||
$form[$field_name][$form_element_row_id] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Your name'),
|
||||
'#default_value' => '',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Optional validate function.
|
||||
function views_form_validate($form, &$form_state) {
|
||||
$field_name = $this->form_element_name();
|
||||
foreach ($form_state['values'][$field_name] as $row_id => $value) {
|
||||
if ($value == 'Drupal') {
|
||||
form_set_error($field_name . '][' . $row_id, "You can't be named Drupal. That's my name.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Optional submit function.
|
||||
function views_form_submit($form, &$form_state) {
|
||||
// Do something here
|
||||
}
|
||||
</pre>
|
||||
|
||||
The form is multistep by default, with one step: 'views_form_views_form'.
|
||||
A "form_example" module could add a confirmation step by setting:
|
||||
<pre>
|
||||
$form_state['step'] = 'form_example_confirmation';
|
||||
</pre>
|
||||
in form_example_views_form_submit().
|
||||
Then, views_form would call form_example_confirmation($form, $form_state, $view, $output) to get that step.
|
||||
|
||||
<b>Important:</b> You can fetch the Views object in form_alter and validate / submit hooks from the form state:
|
||||
<pre>
|
||||
$view = $form_state['build_info']['args'][0];
|
||||
</pre>
|
||||
|
||||
<h2>Relevant Views functions</h2>
|
||||
<ul>
|
||||
<li>template_preprocess_views_view()</li>
|
||||
<li>views_form()</li>
|
||||
<li>views_form_views_form()</li>
|
||||
<li>views_form_views_form_validate()</li>
|
||||
<li>views_form_views_form_submit()</li>
|
||||
<li>theme_views_form_views_form()</li>
|
||||
</ul>
|
||||
|
||||
<h2>Hooks</h2>
|
||||
<ul>
|
||||
<li>hook_views_form_substitutions()</li>
|
||||
</ul>
|
@ -0,0 +1,45 @@
|
||||
In Views areas (header, footer, empty-text) are pluggable, this means you can write your own php logic to place whatever you want.
|
||||
|
||||
<h3>Requirements</h3>
|
||||
You should have read <a href="topic:views/api">API</a> and <a href="topic:views/api-tables">Tables API</a> to get a basic knowledge
|
||||
how to extend views.
|
||||
|
||||
<h3>Create your own area handler</h3>
|
||||
|
||||
The first step is to tell views: Hey i want to add a new area handler.
|
||||
Therefore you have to implement hook_views_data and add a new one. For example:
|
||||
|
||||
<pre>
|
||||
function yourmodule_views_data() {
|
||||
$data['views']['collapsible_area'] = array(
|
||||
'title' => t('Collabsible Text area'),
|
||||
'help' => t('Provide collabsible markup text for the area.'),
|
||||
'area' => array(
|
||||
'handler' => 'yourmodule_handler_collapsible_area_text',
|
||||
),
|
||||
);
|
||||
}
|
||||
</pre>
|
||||
|
||||
The second step is to write this handler. Therefore create a file called yourmodule_handler_collapsible_area_text.inc and
|
||||
add it to the .info file of your module.
|
||||
|
||||
Then add content to your area file like this:
|
||||
<pre>
|
||||
class yourmodule_handler_collapsible_area_text extends views_handler_area_text {
|
||||
function render($empty = FALSE) {
|
||||
// Here you just return a string of your content you want.
|
||||
if ($render = parent::render($empty)) {
|
||||
$element = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Title'),
|
||||
'#value' => $render,
|
||||
);
|
||||
$output = theme('fieldset', $element);
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
|
||||
As on every handler you can add options so you can configure the behavior. If the area isn't shown yet in the views interface, please clear the cache :)
|
262
sites/all/modules/contrib/views/views/help/api-tables.html
Normal file
262
sites/all/modules/contrib/views/views/help/api-tables.html
Normal file
@ -0,0 +1,262 @@
|
||||
Tables are described to Views by implementing hook_views_data(). This should be placed in MODULENAME.views.inc and it will be autoloaded (see <a href="topic:views/api">Views' API</a>). The hook implementation should return an array of table information, keyed by the name of the table. For example, if your module is describing three tables, 'foo', 'bar' and 'baz', your hook will look like this:
|
||||
<pre> /**
|
||||
* Implements hook_views_data().
|
||||
*/
|
||||
function MODULENAME_views_data() {
|
||||
$data = array(
|
||||
'foo' => array(
|
||||
// ...info about the table named 'foo'...
|
||||
),
|
||||
'bar' => array(
|
||||
// ...info about the table named 'bar'...
|
||||
),
|
||||
'baz' => array(
|
||||
// ...info about the table named 'baz'...
|
||||
),
|
||||
);
|
||||
return $data;
|
||||
}
|
||||
</pre>
|
||||
|
||||
The key should be the actual database name of the table (not including prefix), but it can be an alias as long as the join information (explained later) contains the real name of the table.
|
||||
|
||||
Each item in the array should be a field in the table, with the exception of a special information section called 'table'. Example:
|
||||
|
||||
<pre>$data['foo'] = array(
|
||||
'table' => array(
|
||||
// ... info about the table, described later ...
|
||||
),
|
||||
'bar' => array(
|
||||
// ... info about the field named 'bar', i.e, foo.bar,
|
||||
),
|
||||
'baz' => array(
|
||||
// ... info about the field named 'baz', i.e, foo.baz,
|
||||
),
|
||||
);
|
||||
</pre>
|
||||
|
||||
Once you get down to an array that contains actual data, that piece of the array will often be referred to as the definition.
|
||||
|
||||
<h2>The 'table' section</h2>
|
||||
Each table should have a 'table' section in it, which is used to set default information for the table, such as the group, as well as the very important joins and whether or not this is a base table.
|
||||
|
||||
First, there are several items that are actually for fields but can be placed here so that all fields within the table inherit them:
|
||||
<dl>
|
||||
<dt>group</dt>
|
||||
<dd>The name of the group this item will be with. In the UI, this is displayed as Group: Title. For example, "Node: Node ID", "Taxonomy: Term description", etc. It is important to be consistent with groups, because the UI sorts by group, and allows filtering by group to find fields as well.</dd>
|
||||
<dt>title</dt>
|
||||
<dd>The actual name of the field; it should be concise and descriptive.</dd>
|
||||
<dt>help</dt>
|
||||
<dd>A longer description to help describe what the field is or does. It should try to be only a line or two so as not to clutter the UI.</dd>
|
||||
</dl>
|
||||
|
||||
In general, having 'title' and 'help' at the table level doesn't make a lot of sense, but usually every item in a table is in the same group. Thus it is very common to define the 'group':
|
||||
|
||||
<pre>
|
||||
$data['foo']['table']['group'] = t('Foo');
|
||||
</pre>
|
||||
|
||||
The other items in the 'table' section are described in the following sections.
|
||||
|
||||
<h3>'base': Base table</h3>
|
||||
If your table is a base table -- meaning it can be the primary, central table for a View to use, you can declare it to be a base table. This primarily provides UI information so that it can be selected.
|
||||
For example:
|
||||
<pre>
|
||||
// Advertise this table as a possible base table
|
||||
$data['node']['table']['base'] = array(
|
||||
'field' => 'nid',
|
||||
'title' => t('Node'),
|
||||
'help' => t("Nodes are a Drupal site's primary content."),
|
||||
'weight' => -10,
|
||||
);
|
||||
</pre>
|
||||
|
||||
The following items are available in the base section:
|
||||
<dl>
|
||||
<dt>field</dt>
|
||||
<dd>The primary key field for this table. For Views to treat any table as a base table, it <b>must</b> have a primary field. For node this is the 'nid', for users this is the 'uid', etc. <strong>Without a single primary key field (i.e. not a composite key), Views will not be able to utilize the table as a base table.</strong> If your table does not have a primary key field, it is not too difficult to just add a serial field to it, usually.</dd>
|
||||
<dt>title</dt>
|
||||
<dd>The title of this table in the UI. It should be singular and describe the object that this table contains from the perspective of the user.</dd>
|
||||
<dt>help</dt>
|
||||
<dd>A short piece of text to describe what object this table contains.</dd>
|
||||
<dt>database</dt>
|
||||
<dd>If this table is held in a different database from your Drupal database, specify it as a string in the exact same format as the settings.php file. This is a special purpose variable that will probably be only used in site specific code, and <b>it must be the same database type as your Drupal database</b>. Also, don't try to join it to any table that isn't in the same database. That'll just create all kinds of silly errors. For example:
|
||||
<pre>
|
||||
// In settings.php for your site
|
||||
// Your drupal (site) database needs to be called 'default'
|
||||
$db_url['default'] = 'mysqli://user:pass@host/drupal_db';
|
||||
$db_url['budget'] = 'mysqli://user:pass@host/other_db';
|
||||
</pre>
|
||||
Then when you are describing the external database in your base table you would write something like this:
|
||||
<pre>
|
||||
$data[$table]['table']['base'] = array(
|
||||
'field' => 'Primary key',
|
||||
'title' => t('Field name'),
|
||||
'help' => t('Field description'),
|
||||
'database' => 'budget',
|
||||
'weight' => -10,
|
||||
);
|
||||
</pre>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h3>'join': Linking your table to existing base tables</h3>
|
||||
For Views to use your table, it has to either be a base table, or know how to link to an existing base table. Or sometimes both. Views uses this information to create a path to the base table; when the table is added to the query, Views will walk along this path, adding all tables required into the query.
|
||||
|
||||
<div class="help-box" style="text-align:center">
|
||||
<a href="path:images/node-term_node-term_data-large.png"><img src="path:images/node-term_node-term_data.png" /></a>
|
||||
<em>How taxonomy_term_data joins to node</em>
|
||||
</div>
|
||||
|
||||
In the above example, to use these with 'node' as the base table, both 'taxonomy_term_data' and 'term_node' need to be defined, and they each need a join handler for node:
|
||||
|
||||
<pre>
|
||||
$data['taxonomy_term_data']['table']['join']['node'] = array(
|
||||
'left_table' => 'term_node',
|
||||
'left_field' => 'tid',
|
||||
'field' => 'tid',
|
||||
);
|
||||
</pre>
|
||||
|
||||
The above can be read as "In order to join to the node table, the taxonomy_term_data table must first link to the term_node table, and they join on the 'tid' field.". When adding this table to the query for a node view, Views will look at this and then look for the term_node table.
|
||||
|
||||
<pre>
|
||||
$data['term_node']['table']['join']['node'] = array(
|
||||
'left_field' => 'nid',
|
||||
'field' => 'nid',
|
||||
);
|
||||
</pre>
|
||||
|
||||
Above, the fact that 'left_table' is left out lets us know that term_node links directly to the node table, using the 'nid' field on both sides of the join.
|
||||
|
||||
Quite a few more fields are available in this definition:
|
||||
<dl>
|
||||
<dt>handler</dt>
|
||||
<dd>The name of the handler object to use. Defaults to 'views_join'. You may create custom join handlers that may or may not use any of the data below, as they see fit.</dd>
|
||||
<dt>table</dt>
|
||||
<dd>Table to join. This is optional, and should only be used if the table being referenced is an alias.</dd>
|
||||
<dt>field</dt>
|
||||
<dd>Field to join on. This is required.</dd>
|
||||
<dt>left_table</dt>
|
||||
<dd>The next step toward the final destination. If this is the final destination it may be omitted.</dd>
|
||||
<dt>left_field</dt>
|
||||
<dd>The field to join to on the left side. This is required.</dd>
|
||||
<dt>type</dt>
|
||||
<dd>Either LEFT (default) or INNER.</dd>
|
||||
<dt>extra</dt>
|
||||
<dd>Either a string that's directly added, or an array of items. Each item is, itself, an array:
|
||||
<dl>
|
||||
<dt>table</dt>
|
||||
<dd>table should not be set in most cases, as it would be filled with the right table alias. Set it to NULL if you want to use a formular in "field"</dd>
|
||||
<dt>field</dt>
|
||||
<dd>Field or formula, therein "%alias" can be used to reference the right table.</dd>
|
||||
<dt>operator</dt>
|
||||
<dd>Similar to filters, this is the operator, such as >, <, =, etc. Defaults to = or IN.</dd>
|
||||
<dt>value</dt>
|
||||
<dd>Must be set. If an array, operator will be defaulted to IN.</dd>
|
||||
<dt>numeric</dt>
|
||||
<dd>If true, the value will not be surrounded in quotes, and %d will be used for its placeholder.</dd>
|
||||
</dl>
|
||||
</dd>
|
||||
<dt>extra type</dt>
|
||||
<dd> How all the extras will be combined. Either AND or OR. Defaults to AND.</dd>
|
||||
</dl>
|
||||
|
||||
<h2>Describing fields on tables</h2>
|
||||
Aside from the special table tag, each table can also have an unlimited number of field designations; these correspond roughly to fields on the table, though it is very common to use non-fields to display data that isn't directly in a field, such as data arrived from formulae, or special links related to the object the table is part of.
|
||||
|
||||
Each field is described in the view data with an array, keyed to the database name of the field. This array may contain some information fields, plus an entry in each of the five types of items Views has per field: argument, field, filter, relationship, sort. For example:
|
||||
|
||||
<pre>
|
||||
$data['node']['nid'] = array(
|
||||
'title' => t('Nid'),
|
||||
'help' => t('The node ID of the node.'), // The help that appears on the UI,
|
||||
// Information for displaying the nid
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_node',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
// Information for accepting a nid as an argument
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_node_nid',
|
||||
'name field' => 'title', // the field to display in the summary.
|
||||
'numeric' => TRUE,
|
||||
'validate type' => 'nid',
|
||||
),
|
||||
// Information for accepting a nid as a filter
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_numeric',
|
||||
),
|
||||
// Information for sorting on a nid.
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
);
|
||||
</pre>
|
||||
|
||||
The above example describes the 'nid' field on the 'node' table, providing 4 of the 5 handlers. Note that while field is normally expected to be the database name of the field, it doesn't have to be; you can use an alias (which is how you get multiple handlers per field) or something completely made up for items that aren't tied to the database. For example:
|
||||
|
||||
<pre>
|
||||
$data['node']['edit_node'] = array(
|
||||
'field' => array(
|
||||
'title' => t('Edit link'),
|
||||
'help' => t('Provide a simple link to edit the node.'),
|
||||
'handler' => 'views_handler_field_node_link_edit',
|
||||
),
|
||||
);
|
||||
</pre>
|
||||
|
||||
The above handler definition an edit link to a node, but this isn't a field in and of itself. For aliased fields, here is another example:
|
||||
|
||||
<pre>
|
||||
$data['users']['uid_current'] = array(
|
||||
'real field' => 'uid',
|
||||
'title' => t('Current'),
|
||||
'help' => t('Filter the view to the currently logged in user.'),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_user_current',
|
||||
),
|
||||
);
|
||||
</pre>
|
||||
|
||||
The above definition provides an alternate filter handler on the uid field for the current user.
|
||||
|
||||
The following items are allowed in the field definition:
|
||||
|
||||
<dl>
|
||||
<dt>group, title, help</dt>
|
||||
<dd>As above, these fields are for the UI. If placed here, any of these fields will override a setting on the base table.</dd>
|
||||
<dt>real field</dt>
|
||||
<dd>If this field is an alias, the "real field" may be placed here, and the handler will never know the difference.</dd>
|
||||
|
||||
<dt>field</dt>
|
||||
<dd>A handler definition for the "Field" section, which is a field that may be displayed in a view. The definition is an array; the contents of the array are completely up to the handler, other than the 'handler' definition. If omitted, handler will default to 'views_handler_field'.</dd>
|
||||
<dt>filter</dt>
|
||||
<dd>A handler definition for the "Filters" section, which will be used to apply WHERE clauses to the view. The definition is an array; the contents of the array are completely up to the handler, other than the 'handler' definition. If omitted, handler will default to 'views_handler_filter'.</dd>
|
||||
<dt>sort</dt>
|
||||
<dd>A handler definition for the "Sort criteria" section, which will be used to add an ORDER BY clause to the view. The definition is an array; the contents of the array are completely up to the handler, other than the 'handler' definition. If omitted, handler will default to 'views_handler_sort'.</dd>
|
||||
<dt>relationship</dt>
|
||||
<dd>A handler definition for the "Field" section, which is a way to bring in new or alternative base tables in the view. The definition is an array; the contents of the array are completely up to the handler, other than the 'handler' definition. If omitted, handler will default to 'views_handler_relationship'. All relationships need the 'base' to be set. The basic relationship handler also requires 'base field' to be set. 'base' and 'base field' represent the "right" half of the join that will use this field as the left side.</dd>
|
||||
<dt>argument</dt>
|
||||
<dd>A handler definition for the "Field" section, which is method of accepting user input from the URL or some other source. The definition is an array; the contents of the array are completely up to the handler, other than the 'handler' definition. If omitted, handler will default to 'views_handler_argument'.</dd>
|
||||
</dl>
|
||||
|
||||
For more information about what handlers need/use what data, visit <a href="http://views.doc.logrus.com">the Views API site</a> and check out the available handlers.
|
||||
|
||||
<h3>Support old tabledata</h3>
|
||||
If you need to rename some tables/fields you can create some references in the views data to be able to continue to work.
|
||||
Therefore you create the whole table structure of the current views data.
|
||||
|
||||
If you have to rename a single table you need to specify
|
||||
<pre>
|
||||
$data['oldtable']['moved to'] = 'newtable';
|
||||
</pre>
|
||||
|
||||
If you have to rename/move a single a field to another table you specify
|
||||
<pre>
|
||||
$data['oldtable']['oldfield']['field']['moved to'] = array('newtable', 'newfield');
|
||||
</pre>
|
||||
or
|
||||
<pre>
|
||||
$data['oldtable']['oldfield']['moved to'] = array('newtable', 'newfield');
|
||||
</pre>
|
224
sites/all/modules/contrib/views/views/help/api-upgrading.html
Normal file
224
sites/all/modules/contrib/views/views/help/api-upgrading.html
Normal file
@ -0,0 +1,224 @@
|
||||
In order to take advantage of the changes in Drupal 7, Views has gone through several API changes.
|
||||
Here's what you should know.
|
||||
|
||||
<h3>Handler registry</h3>
|
||||
|
||||
Views now uses Drupal's dynamic-loading code registry.
|
||||
You can safely remove your implementations of hook_views_handlers(), since they are no longer used.
|
||||
|
||||
Please remember to specify the handlers in your module's .info file. For example:
|
||||
<pre>
|
||||
name = Example module
|
||||
description = "Gives an example of a module."
|
||||
core = 7.x
|
||||
files[] = example.module
|
||||
files[] = example.install
|
||||
|
||||
; Views handlers
|
||||
files[] = includes/views/handlers/example_handler_argument_string.inc
|
||||
</pre>
|
||||
|
||||
<h3>Removed handlers</h3>
|
||||
|
||||
Note that views_handler_filter_float has been removed.
|
||||
This functionality is now handled by views_handler_filter_numeric.
|
||||
There's no need for having a special handler any more, thanks to the new DB layer in Drupal 7.
|
||||
|
||||
views_handler_sort_formula has been removed.
|
||||
Everyone who used it can extend from views_handler_sort, too.
|
||||
|
||||
<h3>Ctools dependency</h3>
|
||||
Views requires ctools now, so it can use the dependency system of ctools.
|
||||
The only thing you have to do is to remove views_process_dependency.
|
||||
|
||||
<h3>Changed add_where api</h3>
|
||||
If your field is a plain sql field:
|
||||
<pre>
|
||||
$this->query->add_where($this->options['group'], "$this->table_alias.$this->real_field " . $this->operator . " '%s'", $this->value);
|
||||
</pre>
|
||||
has to be converted to
|
||||
<pre>
|
||||
$this->query->add_where($this->options['group'], "$this->table_alias.$this->real_field", $this->value, $this->operator);
|
||||
</pre>
|
||||
If your field is a complex where condition:
|
||||
<pre>
|
||||
$this->query->add_where($this->options['group'], "$upper($field) NOT LIKE $upper('%%%s')", $this->value);
|
||||
</pre>
|
||||
has to be converted to
|
||||
<pre>
|
||||
$placeholder = $this->placeholder();
|
||||
$this->query->add_where_expression($this->options['group'], "$field LIKE $placeholder", array($placeholder => '%' . db_like($this->value)));
|
||||
</pre>
|
||||
placeholder() generates a automatic unique placeholder for you.
|
||||
|
||||
add_where with operator 'formula' can be converted to add_where_expression.
|
||||
add_having with operator 'formula' can be converted to add_having_expression.
|
||||
|
||||
<h3>Changed place for display specific settings</h3>
|
||||
In the new ui the new place for display settings is at the top of the second column.
|
||||
Therefore use something like this code in your display plugin:
|
||||
<pre>
|
||||
$categories['block'] = array(
|
||||
'title' => t('Block settings'),
|
||||
'column' => 'second',
|
||||
'build' => array(
|
||||
'#weight' => -10,
|
||||
),
|
||||
);
|
||||
</pre>
|
||||
|
||||
<h3>Changed filter settings and associated class variables</h3>
|
||||
'optional' and 'single' are now 'required' and 'multiple', the logic is now opposite.
|
||||
Also, the 'no_single' and 'no_optional' class variables (known as "object flags" in the API docs)
|
||||
are now 'always_multiple' and 'always_required'.
|
||||
|
||||
<h3>Changed argument settings</h3>
|
||||
See the init() function in views_handler_argument for an overview of everything
|
||||
that changed.
|
||||
|
||||
1. The default actions 'summary asc', 'summary desc', 'summary asc by count', 'summary asc by count'
|
||||
have been replaced by a single 'summary' action (which takes the sort order and type as options).
|
||||
2. Wildcards are now called exceptions.
|
||||
<pre>
|
||||
$this->options['exception']['value'] = $options['wildcard'];
|
||||
$this->options['exception']['title'] = $options['wildcard_substitution'];
|
||||
</pre>
|
||||
3. Summary plugin options are now stored in 'summary_options' instead of 'style_options'
|
||||
<pre>
|
||||
$this->options['summary_options'] = $options['style_options'];
|
||||
</pre>
|
||||
4. The selected summary plugin is no longer stored in 'style_plugin'.
|
||||
<pre>
|
||||
$this->options['summary']['format'] = $options['style_plugin'];
|
||||
</pre>
|
||||
5. The validator options have been moved.
|
||||
<pre>
|
||||
$options['validate']['type'] = $options['validate_type'];
|
||||
$options['validate']['fail'] = $options['validate_fail'];
|
||||
</pre>
|
||||
6. The validator settings have been moved from $form['argument_validate'] to ['validate_options']
|
||||
This means that dependent code in validate plugins needs to change.
|
||||
Example change for views_plugin_argument_validate_user:
|
||||
<pre>
|
||||
$form['roles'] = array(
|
||||
'#dependency' => array(
|
||||
- 'edit-options-argument-validate-user-restrict-roles' => array(1),
|
||||
+ 'edit-options-validate-options-user-restrict-roles' => array(1),
|
||||
),
|
||||
</pre>
|
||||
|
||||
<h3>The introduction of get_value() and sanitize_value()</h3>
|
||||
The views_handler class got two new functions:
|
||||
<pre>
|
||||
/**
|
||||
* Get the value that's supposed to be rendered.
|
||||
*
|
||||
* @param $values
|
||||
* An object containing all retrieved values.
|
||||
* @param $field
|
||||
* Optional name of the field where the value is stored.
|
||||
*/
|
||||
function get_value($values, $field = NULL) {
|
||||
$alias = isset($field) ? $this->aliases[$field] : $this->field_alias;
|
||||
if (isset($values->{$alias})) {
|
||||
return $values->{$alias};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize the value for output.
|
||||
*
|
||||
* @param $value
|
||||
* The value being rendered.
|
||||
* @param $type
|
||||
* The type of sanitization needed. If not provided, check_plain() is used.
|
||||
*/
|
||||
function sanitize_value($value, $type = NULL) {
|
||||
switch ($type) {
|
||||
case 'xss':
|
||||
$value = filter_xss($value);
|
||||
break;
|
||||
case 'url':
|
||||
$value = check_url($value);
|
||||
break;
|
||||
default:
|
||||
$value = check_plain($value);
|
||||
break;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
</pre>
|
||||
These functions are meant to be used in the render() functions of field handlers,
|
||||
for fetching data (usually by alias) from the $values object, and for sanitizing values.
|
||||
|
||||
The abstraction of fetching data from rendering data is important because
|
||||
different query backends have different ways of storing data in $values, and the field alias
|
||||
is a SQL specific thing. So instead of overriding the whole render() function and copying
|
||||
all of the logic there (as well as having to constantly keep up with upstream Views changes),
|
||||
the backend can just override get_values(), which is significantly less code.
|
||||
|
||||
Of course, different ways of fetching and displaying data might require different
|
||||
ways of sanitizing it, hence the usage of the sanitize_value() function.
|
||||
|
||||
Examples of converting render() field handler implementations:
|
||||
<pre>
|
||||
// This
|
||||
$value = $values->{$this->field_alias};
|
||||
// Becomes this
|
||||
$value = $this->get_value($values);
|
||||
|
||||
// And this
|
||||
$format = $values->{$this->aliases['format']};
|
||||
// Becomes this
|
||||
$format = $this->get_values($values, 'format');
|
||||
|
||||
// Instead of this:
|
||||
return check_plain($value);
|
||||
// We write:
|
||||
return $this->sanitize_value($value);
|
||||
|
||||
// Since sanitize_value() supports different sanitization functions, this:
|
||||
return filter_xss($value);
|
||||
// Can become:
|
||||
return $this->sanitize_value($value, 'xss');
|
||||
</pre>
|
||||
|
||||
|
||||
<h3>Changed views_get_page_view</h3>
|
||||
In contrast to 6.x views_get_page_view now does stores the current view, not the current page display.
|
||||
|
||||
<h3>Removed views-view-row-node</h3>
|
||||
Due to changes in comment.module there is no extra views-view-row-node template needed to display the comments. If you do some custom stuff there you should now be able to do everything in your node.tpl.php.
|
||||
|
||||
<h3>Entity type Key on Base tables</h3>
|
||||
During the development of the drupal7 version of views the entity type associated with a table got added to $data['name']['table']['base']['entity type']. It should be moved to $data['name']['table']['entity type'].
|
||||
|
||||
<h3>Changed views_plugin_style::render_grouping()</h3>
|
||||
The parameters as well as the structure of the methods return have changed.
|
||||
The method now accepts a third optional parameter called "$group_rendered".
|
||||
This parameter defines whether to use the rendered or the raw field value for grouping.
|
||||
Intention for adding the parameter was that the grouping could have been acted
|
||||
unexpected if the rendered field contained unique values e.g. by using drupal_html_id().
|
||||
<dl>
|
||||
<dt>New return structure</dt>
|
||||
<dd>
|
||||
{grouping value} is the value affected by the new parameter.
|
||||
<pre>
|
||||
array (
|
||||
{grouping value} => array(
|
||||
'group' => {rendered_value of the grouping field},
|
||||
'rows' => array({group rows}),
|
||||
),
|
||||
);
|
||||
</pre>
|
||||
</dd>
|
||||
<dt>Old return structure</dt>
|
||||
<dd>
|
||||
<strong>If the new parameter isn't explicitly set or its value is NULL the structure of the return will be the same as in D6!</strong>
|
||||
<pre>
|
||||
array (
|
||||
{rendered_value of the grouping field} => array({group rows}),
|
||||
);
|
||||
</pre>
|
||||
</dd>
|
||||
</dl>
|
24
sites/all/modules/contrib/views/views/help/api.html
Normal file
24
sites/all/modules/contrib/views/views/help/api.html
Normal file
@ -0,0 +1,24 @@
|
||||
Views allows modules to describe their tables relationships to each other, as well as fields, filters, sort criteria and arguments via <strong>hook_views_data()</strong>. Whenever Views deems it necessary, this hook is called, the data aggregated together and cached. <strong>hook_views_data_alter()</strong> may also be used to modify existing data, changing other module's handlers or adding handlers to other module's tables.
|
||||
|
||||
Views also allows modules to create new display types, style types, row styles, argument default handlers and argument validators via <strong>hook_views_handlers()</strong> and <strong>hook_views_plugins()</strong>.
|
||||
|
||||
These hooks are kept in a file named MODULENAME.views.inc. This file is automatically included upon need, so there is no need to try and include this in hook_init or any other method of including .inc files. This file should store hook_views_data, hook_views_data_alter(), hook_views_plugins(), hook_views_handlers(), as well as any other hooks and subsidiary data that will only be used by your module when Views is active. All handlers and plugins provided by your module should be in separate .inc files, and must be referenced in your module's .info file with the files[] directive.
|
||||
|
||||
There are two similar files, MODULENAME.views_default.inc and MODULENAME.views_convert.inc which contain default views and views 1 to views 2 convert helpers, respectively.
|
||||
|
||||
<h3>hook_views_api()</h3>
|
||||
<strong>In order for your files to be included, your module must first implement hook_views_api()</strong> in the main .module file. This module should return array of information. The following items may be returned:
|
||||
|
||||
<dl>
|
||||
<dt><strong>api</strong></dt>
|
||||
<dd>This must appear; it should be the oldest API version that your module can work with. If Views is currently running an older version of the API, it will ignore your module's views integration. This is a good thing, as it will prevent code crashes, at the expense of your module's functionality disappearing.
|
||||
<br />
|
||||
You may find the current Views API version by calling <strong>views_api_version()</strong> which is implemented at the top of views.module. This version numbering starts at 2.0. Every time changes are made to the Views handlers and plugins or other aspects of the Views API, the number will tick up (by either .001, .01 .1 or 1 depending upon how major the changes are). Note that <strong>views_api_version()</strong> was introduced in Views 2.0-rc2 and may not exist prior to that version. You may use drupal_function_exists() to test to see if this function is there.
|
||||
<br />
|
||||
Often these versions are basically compatible with each other and Views won't care if your module implements 2.000, 2.001, 2.002, etc. Your module can request that it won't work with any version older than a given version, however. Views will determine, itself, if a newer version will work.
|
||||
</dd>
|
||||
<dt><strong>path</strong></dt>
|
||||
<dd>If your *.views*.inc files are not in the same directory as the .module file, then return the full path here. You should probably use something like drupal_get_path('module', 'yourmodulename') . '/includepath'.</dd>
|
||||
<dt><strong>template path</strong></dt>
|
||||
<dd>A path where the module has stored it's views template files. When you have specificed this key views automatically uses the template files for the views. You can use the same naming conventions like for normal views template files.</dd>
|
||||
</dl>
|
106
sites/all/modules/contrib/views/views/help/argument.html
Normal file
106
sites/all/modules/contrib/views/views/help/argument.html
Normal file
@ -0,0 +1,106 @@
|
||||
Contextual Filters (known in previous versions of Views as "Arguments") are input. While they often come from the URL, they don't always. Don't be shocked when they don't. Each display type may have its own source for contextual filters. Block displays have no source of contextual filters at all; they cannot pull contextual filters from the URL, and often require use of PHP code as a default contextual filter. Various default values can be applied against contextual filters to use filters in a block view. See "Provide default value," under "When the filter value is NOT in the URL" below.
|
||||
|
||||
In general, contextual filters are used to filter the view, and in that sense they have a very close relationship to filters. However, this isn't necessarily true for every contextual filter. Contextual filters can be used for any purpose, really; the extent of what the contextual filter does is up to the developer of the contextual filter.
|
||||
|
||||
A typical use of an contextual filter might be to reduce a view to a single node, a single user, or nodes with a given taxonomy term.
|
||||
|
||||
<h3>When the filter value is NOT in the URL</h3>
|
||||
|
||||
<dl>
|
||||
<dt>Display all results for the specified field</dt>
|
||||
<dd>If this option is selected, the contextual filter is removed from the view as though it weren't there and all results will be displayed.</dd>
|
||||
<dt>Provide default value</dt>
|
||||
<dd>If no contextual filter is given, a default contextual filter can be selected. You may choose from a number of different default filter options. See "Default contextual filters" below.</dd>
|
||||
<dt>Hide view</dt>
|
||||
<dd>The view will remove itself entirely if the contextual filter is not present; for a block this means it simply won't appear. For page views the view will return a 404 and present a "Page not found" error. </dd>
|
||||
<dt>Display a summary</dt>
|
||||
<dd>The view will attempt to display a summary of contextual filters available, based upon the view, and provide links to the view with those contextual filters. Summaries have their own style handlers as well as options. The default summary style simply displays a list of contextual filters with a count of entries found per contextual filter. This special mode is a very powerful part of Views.</dd>
|
||||
<dt>Display contents of "No results found"</dt>
|
||||
<dd>If this option is selected, the value specified under "No results behavior" on the main view page will be displayed when there is no filter value in the URL.</dd>
|
||||
</dl>
|
||||
|
||||
An exception value can be set under the "Exceptions" menu. If this exception value is received, any filter value specified under "When the filter value is NOT in the URL" will be ignored. This is a literal value: if you enter the word "everything" here, the exception will apply only if the value "everything" is received.
|
||||
|
||||
<h3>Default contextual filters</h3>
|
||||
|
||||
The Default contextual filter selection is available <strong>only if the action to take is "Provide default value"</strong> under "When the filter value is NOT in the URL." When that option is selected, a new fieldset will appear that will allow you to choose default contextual filters. Views provides the following default selectors by default (but other modules may add more):
|
||||
|
||||
<dl>
|
||||
<dt>Content ID from URL</dt>
|
||||
<dd>This will attempt to find a Node ID from the URL, and is primarily useful for the Node: ID contextual filter (though other contextual filters that use Node IDs, such as the CCK Node Reference contextual filter, will find it useful, too). For example, when visiting the path "node/1" or "node/1/edit" it will know that the "1" in that path is a node ID and use it.</dd>
|
||||
<dt>Fixed value</dt>
|
||||
<dd>You may directly enter what the contextual filter will be. This is not a variable, it will always be the same contextual filter. </dd>
|
||||
<dt>PHP Code</dt>
|
||||
<dd>Arbitrary php code inserted here will run whenever a contextual filter is not present in the URL.</dd>
|
||||
<dt>Taxonomy term ID from URL</dt>
|
||||
<dd>This default filter will attempt to return a taxonomy term from the current path. Selecting this option gives you the choice to also load default filters from terms.</dd>
|
||||
<dt>User ID from URL</dt>
|
||||
<dd>Like Node ID and Taxonomy term ID from URL, this will attempt to find a user ID from the path. It also includes an option to look for a node and use the node author as the user ID.</dd>
|
||||
<dt>User ID from logged in user</dt>
|
||||
<dd>If a user is currently logged in and accessing this view, their user ID will be returned as the contextual filter.</dd>
|
||||
<dt>Current date</dt>
|
||||
<dd>This option simply returns today's date.</dd>
|
||||
<dt>Current node's creation time</dt>
|
||||
<dd>Select this to return a node's creation time as a contextual filter.</dd>
|
||||
<dt>Current node's update time</dt>
|
||||
<dd>Not surprisingly, this filter returns the current node's update time</dd>
|
||||
</dl>
|
||||
|
||||
Please bear in mind that the selection of a default contextual filter happens only if a contextual filter is not provided. If you are using a display that has no contextual filter source, such as a block, the contextual filter value selected here will always be used. However, if using a display that reads contextual filters from the URL, the options selected here will only be applied if the URL did not contain an contextual filter.
|
||||
|
||||
The "Skip default argument for view URL" option gives you the choice of ignoring the default argument totally. This is useful for certain applications, like the creation of feeds.
|
||||
|
||||
<h3>When the filter value IS in the URL or a default is provided</h3>
|
||||
|
||||
<dl>
|
||||
<dt>Override title</dt>
|
||||
<dd>Selecting this option will allow you to replace the default view title with a piece of arbitrary text. Argument substitutions in the form of %1, %2, etc. may be used here.</dd>
|
||||
<dt>Override breadcrumb</dt>
|
||||
<dd>This option will allow you to overwrite the view name in breadcrumbs. The same substitution values as in "Override title" may be used.</dd>
|
||||
<dt>Specify validation criteria</dt>
|
||||
<dd>Contextual filters can have validators, which are pluggable systems used to ensure that contextual filters fit within certain parameters. When a validator is chosen, it may provide some specific settings, including the action to take if an contextual filter is presented, but it fails to validate. These actions are generally the same as the default actions above, excluding the ability to provide another default filter. See "Contextual filter validation" below for a detailed description.</dd>
|
||||
</dl>
|
||||
|
||||
<h3>Contextual filter validation</h3>
|
||||
|
||||
Note: If a view provides a menu option, such as a tab, the tab will not appear if the contextual filter does not validate.
|
||||
|
||||
This sytem can have other validators plugged in; by default, Views provides:
|
||||
|
||||
<dl>
|
||||
<dt>Basic validation</dt>
|
||||
<dd>This validator ensures that the contextual filter is present. A PHP NULL value (from eg. PHP default contextual filter code) will invalidate.</dd>
|
||||
<dt>Content</dt>
|
||||
<dd>This validator ensures that the contextual filter is a valid Node ID. You may select which node types the validator will accept.</dd>
|
||||
<dt>Numeric</dt>
|
||||
<dd>This validator ensures that the contextual filter is a valid number.</dd>
|
||||
<dt>PHP Code</dt>
|
||||
<dd>You may enter arbitrary PHP code here, similar to the "PHP code" option under "Provide default value" in "When the filter value is NOT in the URL" above, to determine if the contextual filter is valid or not.</dd>
|
||||
<dt>Taxonomy term</dt>
|
||||
<dd>Ensures that the contextual filter is a valid taxonomy term. This includes options to limit to specific vocabularies and can transform the contextual filter to the right type depending upon the actual contextual filter. Set the contextual filter value type option to the actual type of data that the contextual filter being used is expecting.</dd>
|
||||
<dt>User</dt>
|
||||
<dd>Ensures that the contextual filter refers to a valid user. If you select this validator, additional options are available to accept numeric user IDs, usernames or both, as well as to consider a user's role when filtering the view.</dd>
|
||||
</dl>
|
||||
|
||||
If you select the "Specify validation criteria" option to select a specific validator, you will have the option to select an action to take if the filter value does not validate.
|
||||
|
||||
<dl>
|
||||
<dt>Display all results for the specified field</dt>
|
||||
<dd>Selecting this option will return all values if the filter value does not validate, similar to "Display all results for the specified field" under "When the filter value is not in the URL" above.</dd>
|
||||
<dt>Hide View</dt>
|
||||
<dd>Similar to "Hide view" under "When the filter value is NOT in the URL" above, if this option is selected and the selector does not validate, the view will hide itself. If the view is a block, nothing will appear. If it is a page, it will throw a 404 and present a "Page not found" error.</dd>
|
||||
<dt>Return Summary</dt>
|
||||
<dd>If you select this option and the filter does not validate, a summary of all values that are valid will be returned, as in the option of the same name under "When the filter value is NOT in the URL above."</dd>
|
||||
<dt>Display contents of "No results found"</dt>
|
||||
<dd>If this option is selected and the selector does not validate, the value specified under "No results behavior" on the main view page will be displayed.</dd>
|
||||
</dl>
|
||||
|
||||
<h3>Adminstrative title</h3>
|
||||
|
||||
Located under the "More" group at the bottom of the "Contextual filters" menu, this option allows you to specify a custom name for the contextual filter. This may be particularly useful if you use the same contextual filter twice and you'd like to distinguish between the two filters.
|
||||
|
||||
<h3>Grouping of contextual filters</h3>
|
||||
|
||||
Even though contextual filters do not appear in the "<em>and/or</em>" user interface for sorting and grouping regular filters, contextual filters are always added to the <em>first</em> group of filters. Thus the order of the groups can cause the contextual filter to have entirely different effects on the results of a view that has contextual filters. Even though differences might not be apparent through the user interface.
|
||||
|
||||
Multiple contextual filters are therefore always in the same "and/or" group of filters, and can not be placed in different groups. There is <a href="http://drupal.org/node/357082">an effort to add this feature</a>.
|
@ -0,0 +1,20 @@
|
||||
You choose the <strong>name</strong> of the current display.
|
||||
This <strong>title</strong> will be displayed with the view, wherever titles are normally displayed; i.e, as the page title, block title, etc.
|
||||
|
||||
When you use have many items to display, you have the choice to display them in different variants.
|
||||
<dl>
|
||||
<dt>Display a specified number of items</dt>
|
||||
<dd>Specify the number of items to display per page and an offset. The offset is the number of items to skip. For example, if this field is 3, the first 3 items will be skipped and not displayed.
|
||||
<dt>Display all items</dt>
|
||||
<dd>All items will display, but you can choose an offset. The number of items to skip. For example, if this field is 3, the first 3 items will be skipped and not displayed.</dd>
|
||||
<dt>Paged output, full pager</dt>
|
||||
<dd>A Pager can be used to display items, with the possibility to select the next page and also the first and last page. When you have many items the query is very <i>expensive</i>. To avoid this, you can choose the mini pager.
|
||||
You can also choose the number of items per page. If you enter 0, then there is no limit. Pagers also will respect an offset, if present. If multiple pagers are present on one page you may need to set this number to a higher value so as not to conflict within the ?page= array. Large values will add commas to your URLs, so avoid this if possible. Unless you're experiencing problems with pagers related to this view, you should leave this at 0. Enter the total number of pages to limit the number of values. When you leave the field empty all pages will show.
|
||||
The <strong>Exposed options</strong> allow users to define their values in a exposed form when view is displayed.
|
||||
You can choose "Expose items per page". With this option the user can determine how many items per page show in a view. Options for which label should display and what numberic options are also available.
|
||||
Furthermore, you can choose "Expose Offset". When checked, users can determine how many items should be skipped at the beginning. You can define a label.
|
||||
</dd>
|
||||
<dt>Paged output, mini pager</dt>
|
||||
<dd>The pager optiona are the same as for the "Paged output, full pager" but you have no possibility to jump to the last or first items. </dd>
|
||||
</dl>
|
||||
Normally, all views are created with <strong>unrestricted access</strong>. This means any site visitor can see the views. Please consider this when you make a view with a menu link and private data as output. You have by default two options: "Permission" and "Role". If you choose permission, you get a list of all permissions. Only users with the selected permission flag will be able to access this display. If you choose role, you get all roles as checkboxes. Only the checked roles will be able to access this display. Note that users with "access all views" can see any view, regardless of role.
|
@ -0,0 +1,5 @@
|
||||
<p>Here are some links to demonstration videos. It will get you started working with Views.</p>
|
||||
|
||||
<p><a href="http://drupal.org/node/248766">Views 2 (Drupal 6) Demonstration Video - Drupal Handbook</a></p>
|
||||
|
||||
<p><a href="http://nodeone.se/blogg/taming-the-beast-learn-views-with-nodeone">NodeOne's initial screencasts on the Views 3 UI.</a>
|
@ -0,0 +1 @@
|
||||
Attachment displays are 'attached' to another display in the same view. When the display is visited, the attached display will also be rendered and may be placed before, after or both before and after the original display. Attachment displays are often useful for displaying an argument summary view along with a page display that accepts arguments. This can be used to provide a kind of glossary.
|
@ -0,0 +1,11 @@
|
||||
Block displays will show up on your blocks administration page. Once a block display is created and saved, it can be enabled and positioned in your theme by visiting <strong>administer >> site building >> blocks</strong> and selecting it from the list.
|
||||
|
||||
Blocks <strong>do not</strong> accept arguments from any source; the only way to get arguments to a block is to provide defaults to it, possibly via the PHP Code default setting.
|
||||
|
||||
<ul>
|
||||
<li>Edit the argument in question; you may want to override this argument if you have multiple displays using it.</li>
|
||||
<li>Change the "Action to take if argument is not present" to "Provide default argument". This will bring up a new box called "Provide default argument options".</li>
|
||||
<li>The most common default argument type used for blocks is Node from URL, where it attempts to determine if the URL refers to a node, for example if visiting 'node/1' or 'node/1/edit'. User ID from URL is also very common.</li>
|
||||
<li>If you change the default argument type to 'PHP Code' (note: You must have permission to use PHP code on your site) you can enter PHP to define the argument needed. Simply return the argument.</li>
|
||||
<li>If you are using a <strong>more link</strong> with a block, you must have a page display for that more link to attach to. The more link will not print if there is no place (no display) for it to link to.</li>
|
||||
</ul>
|
@ -0,0 +1,3 @@
|
||||
The default display is primarily a display to store settings, and isn't actually used anywhere within the Views system. It is possible for external programs to use the default display, but if they do they will (hopefully) tell you which display they will be working with. The default display is also a convenient display to use to embed into your site using PHP snippets; this is useful, for example, in node content, but this is something that should generally only be done by administrators.
|
||||
|
||||
In general, you probably want to add either a <a href="topic:views/display-page">page display</a> or a <a href="topic:views/display-block">block display</a>.
|
@ -0,0 +1 @@
|
||||
A feed display allows you to attach an RSS feed to a view.
|
@ -0,0 +1,7 @@
|
||||
Page displays have a <a href="topic:views/path">path</a> and an optional <a href="topic:views/menu">menu</a> component. Page displays will be the primary content for the page, meaning they will be displayed in the main content area when you visit the URL that corresponds to the path.
|
||||
|
||||
Page displays take their arguments from the URL. You can embed arguments into the URL using %; in previous versions of Views, this was '$arg'. For example, 'node/%/foo' will accept URLs such as 'node/1/foo'.
|
||||
|
||||
Please remember that using a % placeholder makes the argument required. If you wish to have an optional argument, simply omit the % from the path. I.e. using "page/%" as the path requires an argument and visiting 'http://www.example.com/page' will not trigger the view.
|
||||
|
||||
If you intend to embed a view manually into another view, it is recommended that the page display not be used for embedding. Select a different display type to embed.
|
13
sites/all/modules/contrib/views/views/help/display.html
Normal file
13
sites/all/modules/contrib/views/views/help/display.html
Normal file
@ -0,0 +1,13 @@
|
||||
Displays tell Views where the output should go. By adding a display to a View, you can have your view appear as a page, or as a block, or even as an attachment to a different display on the view.
|
||||
|
||||
Displays tell Views where the output should go. By adding a display to a View, you can have your view appear as a page, or as a block, or even as an attachment to a different display on the view. You must create at least one display in order to place a View on your site.
|
||||
|
||||
Each display can have its own settings, but when created, a display will take all of its <em>basic settings</em> from the <strong>default display</strong> which all Views must have. For most settings, there is an <a href="topic:views/overrides">override</a> button that will override that single setting for the current display. Overridden settings will have a mark in the summary for that display. All 'default display settings' are shown in the other displays in '<i>italic</i>'. When you override a setting, then it is shown 'normal'.
|
||||
|
||||
Please keep in mind that when you are editing a setting on a display that is not overridden, then by default you are editing that for all displays.
|
||||
|
||||
Overriding <strong>fields</strong>, <strong>arguments</strong>, <strong>sorts</strong>, <strong>filters</strong> and <strong>relationships</strong>, can only be done by overriding the entire group or none of them. To do this, click on the header for the filters or the rearrange button. Once you override, the display will then have its own copies of the fields/filters/etc and changes to the defaults will not be reflected on your display.
|
||||
|
||||
With the <strong>Reorder</strong> button you can organize the order of your displays.
|
||||
With the <strong>Analysis</strong> button the system checks the view and may give you suggestions if something is wrong.
|
||||
You can <strong>clone a display</strong> by using the link in the header of the display.
|
13
sites/all/modules/contrib/views/views/help/drush.html
Normal file
13
sites/all/modules/contrib/views/views/help/drush.html
Normal file
@ -0,0 +1,13 @@
|
||||
There are some Drush commands available for Views, initially added in <a href="http://drupal.org/node/1079178">Drush command to revert views</a>:
|
||||
|
||||
<ul>
|
||||
<li>views-dev (vd) - Setup the views settings to a more developer oriented value</li>
|
||||
<li>views-revert (vr) - Revert overridden views to their default state. Make backups first!</li>
|
||||
</ul>
|
||||
|
||||
Examples:
|
||||
drush views-revert
|
||||
[prompts the user with a list of overridden views to choose from, or to revert all]
|
||||
|
||||
drush views-revert archive myview2
|
||||
[reverts the two specified views]
|
24
sites/all/modules/contrib/views/views/help/embed.html
Normal file
24
sites/all/modules/contrib/views/views/help/embed.html
Normal file
@ -0,0 +1,24 @@
|
||||
You can easily embed the results of a view into other parts of your site;
|
||||
either with code as a module, or in nodes or blocks as snippets. The
|
||||
easiest way is to use the function <strong>views_embed_view()</strong>:
|
||||
|
||||
<code>/**
|
||||
* Embed a view using a PHP snippet.
|
||||
*
|
||||
* This function is meant to be called from PHP snippets, should one wish to
|
||||
* embed a view in a node or something. It's meant to provide the simplest
|
||||
* solution and doesn't really offer a lot of options, but breaking the function
|
||||
* apart is pretty easy, and this provides a worthwhile guide to doing so.
|
||||
*
|
||||
* @param $name
|
||||
* The name of the view to embed.
|
||||
* @param $display_id
|
||||
* The display id to embed. If unsure, use 'default', as it will always be
|
||||
* valid. But things like 'page' or 'block' should work here.
|
||||
* @param ...
|
||||
* Any additional parameters will be passed as arguments.
|
||||
*/
|
||||
function views_embed_view($name, $display_id = 'default') {
|
||||
</code>
|
||||
|
||||
To figure out the id of a display, hover your mouse over the tab to select that display. Everything after the '#views-tab-' is the id of that display. This ID is guaranteed never to change unless you delete the display and create a new one.
|
@ -0,0 +1,3 @@
|
||||
The Emtpy Text content will be displayed when you choose the option <em>Display empty text</em> under the <strong>Arguments</strong> labelled <em>Action to take if argument is not present</em>.
|
||||
|
||||
By default you can choose one or more text areas.
|
@ -0,0 +1,77 @@
|
||||
<p>In this example you will create a context-sensitive block that shows the titles of recent blog entries by an author when viewing one of their posts. This will demonstrate using Views <em>arguments</em> to dynamically filter a view's contents at display time.</p>
|
||||
|
||||
<p>Before working through this example, enable the <strong>Blog</strong> module and populate some entries from a few different users.</p>
|
||||
|
||||
<h3>Creating the View</h3>
|
||||
<p>The first step is creating a view for our recent blog entries block. Because the block will show the titles of blog entries, this view is considered a "Node" type. Go to <a target="_blank" href="base_url:admin/structure/views/add">add new view</a>, enter the following properties, and click <strong>Next</strong>:</p>
|
||||
|
||||
<dl>
|
||||
<dt>View name</dt>
|
||||
<dd>recent_blog_entries</dd>
|
||||
<dt>View description</dt>
|
||||
<dd>List of recent blog entries for a given author.</dd>
|
||||
<dt>View tag</dt>
|
||||
<dd>blog</dd>
|
||||
<dt>View type</dt>
|
||||
<dd>Node</dd>
|
||||
</dl>
|
||||
|
||||
<h3>Generating a list of blog entries</h3>
|
||||
<p>It will be much easier to see the view progress if we can see it doing something. In this section, we will create a basic view displaying blog entry titles.</p>
|
||||
|
||||
<ol>
|
||||
<li>In the third column, locate the <strong>Fields</strong> area. Generally speaking, fields are the pieces of information that you want to display in the view (in this case, node title). Click the <strong>+</strong> icon to add a field.</li>
|
||||
<li>Scroll down to <strong>Defaults: Add fields</strong>, below the settings table. A large selection of fields will be available.</li>
|
||||
<li>In the <strong>Groups</strong> drop-down menu, select <em>Node</em>. This will limit the list to only the default fields exposed by Node module.</li>
|
||||
<li>Scroll down the list, select the <em>Node: Title</em> field, and click <strong>Add</strong>.</li>
|
||||
<li>You will now be presented with settings for the <em>Node: Title</em> field. Delete the label from the <strong>Label</strong> field, so that each individual node title is not prefixed with the word "Title." Additionally, check the <em>Link this field to its node</em> box so that visitors who see an interesting title can click directly on it to read the blog entry to which it belongs.</li>
|
||||
<li>When finished, click <strong>Update</strong>. If you scroll down to the <strong>Live Preview</strong> section, you should now see a list of several node titles; however both blog entries and other node types will be in the list. Let's fix that.</li>
|
||||
<li>In the fourth column, locate the <strong>Filters</strong> area. Filters limit the results displayed in the view, and we can use this to our advantage here by showing node titles only from blog entries and not every type of node. Click the <strong>+</strong> icon to add a filter.</li>
|
||||
<li>As before, scroll down to the <strong>Defaults: Add filters</strong> section, select <em>Node</em> from the <strong>Groups</strong> select box to limit the list of options to only those exposed by Node module.</li>
|
||||
<li>Scroll down and select the <em>Node: Type</em> field and click <strong>Add</strong>. In the settings page that appears, leave <strong>Operator</strong> as <em>Is one of</em> and select <em>Blog entry</em> under <strong>Node type</strong>. Click <strong>Update</strong> when finished.</li>
|
||||
<li>Now, by scrolling down to <strong>Live preview</strong>, you'll see that the list only shows blog entries.</li>
|
||||
</ol>
|
||||
|
||||
<h3>Adding context with arguments</h3>
|
||||
<p>While filters are very useful for limiting the results of a view when the condition is always consistent (for example, a view of blog entry nodes should <em>always</em> be filtered by the blog entry type), something filters can't do is smart decision-making based on the page context. In our case, we want the view to display a different list of blog entries when looking at a post by user 'admin' than we do when looking at a post by user 'member', and filters won't be able to help.</p>
|
||||
|
||||
<p>Luckily, there's another way to filter a view's content: <em>arguments</em>. Through arguments, Views are able to obtain additional context (typically via dynamic URLs with IDs in them) and can take this context into consideration when displaying the view.</p>
|
||||
|
||||
<p>Let's walk through adding and configuring an argument to our view so that we can change its contents based on post author.</p>
|
||||
|
||||
<ol>
|
||||
<li>In the third column, locate the <strong>Arguments</strong> area. Click the <strong>+</strong> icon to add an argument.</li>
|
||||
<li>Because we are basing the view around content <em>authors</em>, this time under <strong>Groups</strong> select <em>User</em>. Check <em>User: Uid</em> and click <strong>Add</strong>.</li>
|
||||
<li>The <strong>Defaults: Configure Argument User: Uid</strong> settings page has a lot going on, but only a few things that need our attention.</li>
|
||||
<li>The <strong>Title</strong> field here, unlike the Title field under <em>Basic Settings</em>, can be based upon the context that the view is being displayed in. Change the title to 'Recent entries by %1.' %1 will later be expanded to the user's name (based on the User: Uid argument) when the view is displayed.</li>
|
||||
<li>Under <strong>Action to take if argument is not present</strong>, there are a variety of options, ranging from displaying a 404 or a 403 page to simply displaying all values in the view. In our case, if an argument isn't specified (which it won't be, since this view will be displayed in a sidebar block, not as a page with its own URL), we want to give it a default one to act on. Select <em>Provide default argument</em>.</li>
|
||||
<li>Assuming JavaScript is enabled in your browser, you should now get another selection for <strong>Default argument type</strong>. Select <em>User ID from URL</em>, which will then provide a new option, <em>Also look for a node and use the node author</em>. Select it. This will cause Views to first see if it can figure out a user ID from the current URL (for example, user/1). If it can't, it will instead check to see if the current page is a node page (such as node/42) and, if so, take the user ID from the node's author field instead.</li>
|
||||
<li><strong>Validator options</strong> provide a useful way to control what kind of arguments your view will accept. Select <em>User</em> as the <strong>Validator</strong>. By default, changing this setting will check the incoming argument and ensure it's a valid user ID; if not, the view will be hidden from the page.</li>
|
||||
<li>Once you have changed the argument's title, default argument, and validator options, click <strong>Update</strong> to save your changes.</li>
|
||||
<li>You'll notice that now the Live preview no longer shows anything. Did we just break the view? Fortunately, no. It's merely abiding by our wishes to hide itself if there is no valid user ID given to it. Try entering a '1' in the <strong>Arguments</strong> box and clicking <strong>Preview</strong>. You should now see a list of only user 1's blog entries.</li>
|
||||
</ol>
|
||||
|
||||
<h3>Creating the block</h3>
|
||||
<p>So the live preview is now showing basically what we want. There's just one problem: we have no way to stick what we've done so far into a sidebar block! Let's fix that by adding a new <strong>Display</strong>.</p>
|
||||
|
||||
<ol>
|
||||
<li>In the first column, under <strong>Defaults</strong>, there is a select box containing entries such as <em>Page</em>, <em>Feed</em>, and, yes, <em>Block</em>! Select <em>Block</em> and click <strong>Add display</strong>.</li>
|
||||
<li>There's not much else to do here as far as Views is concerned. Under <strong>Block settings</strong>, click the <em>None</em> link next to <strong>Admin</strong> and fill in a description for the block in the administrative interface, such as: 'Recent blog entries by author.' and click <strong>Update</strong>.</li>
|
||||
<li>Save your work by clicking the <strong>Save</strong> button at the bottom of the Views interface. You should receive a message that the view has been saved.</li>
|
||||
<li>Next, navigate to the <a target="_blank" href="base_url:admin/structure/block">blocks interface</a> and drag the 'Recent blog entries by author' block to the right sidebar region (or similar) and click <strong>Save blocks</strong>.</li>
|
||||
<li>You'll notice this appeared to do nothing. No block shows in the sidebar. But remember, we are looking at an adminitrative page; we are not looking at a page that would provide a user ID context. Navigate to the <a target="_blank" href="base_url:blog">main blog listing</a> and click on an entry there. You should now see a sidebar block, titled something like "Recent entries by admin," with a list of blog entries beneath it.</li>
|
||||
</ol>
|
||||
|
||||
<h3>Finishing touches</h3>
|
||||
<p>There are still a few remaining things to do before our view is complete. For example, we said that the block was to show <em>recent</em> blog entries, but instead it's showing them in the order they were entered, with oldest on top. Additionally, even unpublished entries are showing in the list currently.</p>
|
||||
|
||||
<ol>
|
||||
<li>Return to the <a target="_blank" href="base_url:admin/structure/views/view/recent_blog_entries">recent_blog_entries view edit page</a>.</li>
|
||||
<li>Add an additional filter by clicking the <strong>+</strong> icon in the <strong>Filters</strong> section in the fourth column.</li>
|
||||
<li>Change <strong>Groups</strong> to <em>Node</em> and select <em>Node: Published</em>. Click <strong>Add</strong>.</li>
|
||||
<li>Under the <strong>Published</strong> selection, choose <em>Yes</em> and click <strong>Update</strong>.</li>
|
||||
<li>To handle sorting, locate the <strong>Sort criteria</strong> area, just above filters, and click the <strong>+</strong> icon there.</li>
|
||||
<li>Under <strong>Groups</strong>, again select <em>Node</em>. From the list of options, check <em>Node: Post date</em> and click <strong>Add</strong>.</li>
|
||||
<li>In the settings page, change <strong>Sort order</strong> to <em>Descending</em>. This will place the newer posts on top of the older ones. Click <strong>Update</strong> when finished.</li>
|
||||
<li>Finally, <strong>Save</strong> the view for your new settings to take effect.</li>
|
||||
</ol>
|
@ -0,0 +1,46 @@
|
||||
<p>In this example you will create a page that displays a list of the content authored by the current logged-in user. This will demonstrate using Views <em>filters</em> and <em>relationships</em> to dynamically filter the view's contents at display time.</p>
|
||||
|
||||
<p>For this example, we are assuming you have a content type "Blog Post".</p>
|
||||
|
||||
<h3>Creating the View</h3>
|
||||
<p>The first step is creating a view for our content list page. Because the page will show the titles of content, this view is considered a "Content" type. Go to <a target="_blank" href="base_url:admin/structure/views/add">add new view</a>, enter the following properties, and click <strong>Next</strong>:</p>
|
||||
|
||||
<dl>
|
||||
<dt>View name</dt>
|
||||
<dd>content_by_current_user</dd>
|
||||
<dt>Description</dt>
|
||||
<dd>List of content authored by the current user.</dd>
|
||||
</dl>
|
||||
|
||||
<p>Choose <strong>Show</strong> <em>Content</em> <strong>of type</strong> <em>Blog Post</em>. You can choose any way you wish to sort the content.</p>
|
||||
|
||||
<h3>Creating the page</h3>
|
||||
<p>Tick the box next to <strong>Create a page</strong>. Enter a page title and a path. For our purposes here, the default settings for the rest of this page are sufficient.</p>
|
||||
|
||||
<p>Click on <strong>Continue & edit</strong>.</p>
|
||||
|
||||
<h3>Creating the relationship</h3>
|
||||
<p>In order to have access to the author of the content, it is important to create a relationship between the current content type, and users.</p>
|
||||
|
||||
<p>Under <strong>Advanced</strong> in the right culumn, select <strong>add</strong> next to <strong>Relationships</strong>.</p>
|
||||
<p>Select <em>Content: Author</em> and click on <strong>Add and configure relationships</strong>. Leave the settings as they are and click on <strong>Apply (all displays)</strong>.</p>
|
||||
|
||||
<p>You now have access to the user data related to the content you are viewing.</p>
|
||||
|
||||
<h3>Filtering the view</h3>
|
||||
<p>Now you need to filter the view to display only content authored by the current user. This data is now available for the content because you have created the relationship in the step above.</p>
|
||||
|
||||
<p>Next to <strong>Filter criteria</strong> click on <strong>add</strong> to add a new filter to your view.</p>
|
||||
|
||||
<p>Filter the list of fields by selecting <em>User</em> next to <strong>Filter</strong> at the top. You now have more fields than before due to the relationship you created.</p>
|
||||
|
||||
<p>Select <em>User: Current</em> from the list and click on <strong>Add and configure filter criteria</strong>.</p>
|
||||
|
||||
<p>Since this field is only visible due to the relationship you created, <em>author</em> will already be selected under <strong>Relationship</strong>. This shows that the relationship you created is being used for the filter field.</p>
|
||||
<p>Select <em>Yes</em> under <strong>Is the logged in user</strong>, and click on <strong>Apply (all displays)</strong>.</p>
|
||||
|
||||
<p>If you have authored content of the type <em>Blog Post</em>, you should now see a list of those posts under the preview section at the bottom.</p>
|
||||
|
||||
<h3>Saving & testing the view</h3>
|
||||
<p>Click on <strong>Save</strong> to save the view.</p>
|
||||
<p>You can test the view by going to the path you entered in the first part of this example.</p>
|
@ -0,0 +1,57 @@
|
||||
In this example you will create a list of nodes of the content type "story", to be shown in a block. Through this step-by-step process, you will become familiar with some basic steps in creating a view, and familiarize yourself with the Views User Interface.
|
||||
|
||||
<ol>
|
||||
<li><h3>Creating a new view</h3>
|
||||
<p>Go to <a target="_blank" href="base_url:admin/structure/views/add">add new view</a>. Give your new view the name 'recent_stories', description 'Recent Stories', tag 'story', type 'Node' and click <strong>Next</strong>.</p></li>
|
||||
<li><h3>About the interface</h3>
|
||||
<p>You have been brought to Views User Interface. As you start, you are editing the "Default" options for the view. In the 1st column on the left you can see the drop-down menu offers 'block', for example, to select settings specific only to block views. In the remaining columns, you will be able to add or change options by clicking on links or icons. These options will then appear below this main area. Most likely, you will need to scroll a bit to see the options appear.</p></li>
|
||||
<li><h3>Selecting the fields to display</h3>
|
||||
<ol>
|
||||
<li>In 3rd column locate the <strong>Fields</strong> options. Click the <strong>+</strong> icon to add fields.</li>
|
||||
<li>Scroll down to <strong>Defaults: Add fields</strong>. In the <strong>Groups</strong> drop-down menu select 'Node', then check the following two fields: <em>Node: Post date</em>, <em>Node: Title</em>. Then click <strong>Add</strong>.</li>
|
||||
<li>You will be taken through the fields you added one at a time. Make the changes specified below.
|
||||
<ul>
|
||||
<li>For the <em>Post date</em> field: Delete the 'Post date' label. Change the <strong>Date format</strong> to <em>Custom</em>, and the <strong>Custom date format</strong> to 'F j, Y, g:i a' (do not type the single quotes; for the meaning of these letter codes, click on <em>the PHP docs</em> link under that box to arrive at the explanation). Click <strong>Update</strong>.</li>
|
||||
<li>For the <em>Title</em> field: Delete the 'Title' label. Select <em>Link this field to its node.</em> Click <strong>Update</strong>.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Scroll back up to <strong>Fields</strong> and click the <strong>↑↓</strong> icon to rearrange fields.</li>
|
||||
<li>Drag the four-sided arrow next to <em>Node: Title</em> so that it appears above <em>Node: Post date</em>. Click <strong>Update</strong> to save the new field order.</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li><h3>Filtering to <em>story</em> nodes only</h3>
|
||||
<ol>
|
||||
<li>Click the <strong>+</strong> icon next to <strong>Filters</strong>.</li>
|
||||
<li>In the <strong>Groups</strong> drop-down menu select 'Node', then check the <em>Node: Published</em> and <em>Node: Type</em> filters, and click <strong>Add</strong>.</li>
|
||||
<li>Select the <em>Published</em> checkbox. Click <strong>Update</strong></li>
|
||||
<li>Select <em>Is one of</em> and check <em>Story</em> in the <em>Node Type</em> field. Click <strong>Update</strong>.</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li><h3>Sorting to show most recent first</h3>
|
||||
<ol>
|
||||
<li>Scroll up to <strong>Sort criteria</strong> and click the <strong>+</strong> icon.</li>
|
||||
<li>In the <strong>Groups</strong> drop-down menu below, select 'Node', then check <em>Node: Post date</em>, and click <strong>Add</strong>. Alternatively, you may instead check <em>Node: Last comment time</em>, or <em>Node: Updated/commented date</em>, or <em>Node: Updated date</em>.</li>
|
||||
<li>Select <em>Descending</em> <strong>Sort order</strong>. Click <strong>Update</strong>.</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li><h3>Refining the basic settings</h3>
|
||||
<ul>
|
||||
<li>In 1st column under <strong>Basic settings</strong> locate these options:
|
||||
<ul>
|
||||
<li><em>Items to Display</em> setting, click <em>10</em>. Change the '10' to '4'. Click <strong>Update</strong></li>
|
||||
<li><em>Style</em> setting, click <em>Unformatted</em>. Change to <em>List</em>. Click <strong>Update</strong>.</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><h3>Adding a block display for custom options</h3>
|
||||
<ol>
|
||||
<li>In the dropdown on the left, ensure that <em>Block</em> is selected, and click <strong>Add Display</strong>.</li>
|
||||
<li>Under <strong>Block settings</strong>, click the <em>None</em> link next to the <em>Admin</em> setting. Change <strong>Block: Block admin description</strong> to 'Recent Stories'.</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li><h3>Saving the view</h3>
|
||||
<p>Click <strong>Save</strong> to save your work.</p></li>
|
||||
<li><h3>Instructing Drupal to show the block</h3>
|
||||
<p>Finally, you should tell Drupal to show this block. Configure your block by going to <a target="_blank" href="base_url:admin/structure/block">admin/structure/block</a>. Locate the block in the list: it is labeled <em>Recent Stories</em>. Place this block in a region and click <strong>Save</strong>. You may click <em>Configure</em> to set a different title, to determine which roles can view the block, and on which pages it appears; If you want your block on the front page only, enter '<front>'.</p></li>
|
||||
</ol>
|
@ -0,0 +1,54 @@
|
||||
<p>In this example you will create a views block that displays images in a slideshow using thumbnails of the images as a pager underneath the slideshow. This will demonstrate using <em>Views Slideshow </em>and <em>Image Styles</em> to display images.</p>
|
||||
|
||||
<p>For this example, we are going to display a single image from each content item of the type "Photos", which we assume you have already set up with an image field. We are also assuming that <em>Views Slideshow</em> and at least one plugin is installed and activated.</p>
|
||||
|
||||
<h3>Creating the image styles</h3>
|
||||
|
||||
<p>The first step is creating the right image styles to display the images from the node. We will create one for the slideshow image, and one for the pagers. Go to <a target="_blank" href="base_url:admin/structure/views/add">Image Styles</a> and create the following two styles:</p>
|
||||
|
||||
<dl>
|
||||
<dt>Style name</dt>
|
||||
<dd>slideshow_image</dd>
|
||||
<dt>Effects</dt>
|
||||
<dd>Scale and crop: 600px wide, 400px high</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt>Style name</dt>
|
||||
<dd>slideshow_thumbnail</dd>
|
||||
<dt>Effects</dt>
|
||||
<dd>Scale and crop: 30px wide, 20px high</dd>
|
||||
</dl>
|
||||
|
||||
<h3>Creating the View and block</h3>
|
||||
|
||||
<p>The next step is creating a view for the slideshow. Because the block will show the images in content, this view is considered a "Content" view. Go to <a target="_blank" href="base_url:admin/structure/views/add">add new view</a>, enter the following properties, and click <strong>Next</strong>:</p>
|
||||
<dl>
|
||||
<dt>View name</dt>
|
||||
<dd>Photo Slideshow</dd>
|
||||
<dt>Description</dt>
|
||||
<dd>Slideshow of images from Photos.</dd>
|
||||
</dl>
|
||||
|
||||
<p>Choose <strong>Show</strong> <em>Content</em> <strong>of type</strong> <em>Photos</em>. You can choose any way you wish to sort the content.</p>
|
||||
<p>Untick the box next to <strong>Create a page</strong> and tick the box next to <strong>Create a block</strong>. Enter a block title and choose Slideshow from the <strong>Display format</strong> select box. Select <em>fields</em> from the other select box. Leave the remaining settings as they are.</p>
|
||||
<p>Click on <strong>Continue & edit</strong>.</p>
|
||||
|
||||
<h3>Editing the view settings</h3>
|
||||
|
||||
<p>Turn off the pager by clicking on <strong>Display a specified number of items</strong> in the middle column and selecting <strong>Display all items</strong> in the next screen, and applying the settings.</p>
|
||||
<p>Enter a Block name by clicking on <strong>None</strong> at the top of the middle column.</p>
|
||||
<p>Next, remove the <em>Content: Title</em> field from the fields list in the left column by blicking on <strong>rearrage</strong> under the arrow.</p>
|
||||
<p>Next we have to add the thumbnail image field. Click on <strong>Add</strong> under the fields section and select your image field from the list. In the next screen, turn off the label, select <em>Exclude from display</em> and select <em>slideshow_thumbnail</em> from the Image Style select box. Under MORE, enter <em>Thumbnail</em> under Administrative Title.</p>
|
||||
<p>Click on <strong>Apply (all displays)</strong>.</p>
|
||||
<p>Now we have to add the image field to display in the slideshow. Clcik on <strong>Add</strong> under the fields section and select your image field from the list. In the next screen, turn off the label and select <em>slideshow_image</em> from the Image Style select box. Under MORE, enter <em>Display Image</em> under Administrative Title.</p>
|
||||
<p>Click on <strong>Apply (all displays)</strong>.</p>
|
||||
|
||||
<h3>Editing the slideshow settings</h3>
|
||||
|
||||
<p>Click on <strong>Settings</strong> next to Format: Slideshow in the first column. In the screen that opens we can choose the options for our slideshow.</p>
|
||||
<p>For the purpose of this example, we will only add the thumbnails as a pager, and leave the remaining slideshow settings as they are. Select the tick box next to <em>Pager</em> under Bottom Widgets. Select <em>Fields</em> from the Pager Type select box. Select the tick box next to <em>Thumbnail</em>.</p>
|
||||
<p>Click on <strong>Apply (all displays)</strong>.</p>
|
||||
|
||||
<h3>Saving & testing the view</h3>
|
||||
<p>Click on <strong>Save</strong> to save the view.</p>
|
||||
<p>You can test the view by adding the block you have created to your theme.</p>
|
@ -0,0 +1,73 @@
|
||||
<p>In this example you will create a <em>Feed display</em> to show nodes by individual users, dynamically selected through the URL. You will become familiar with the Views 2 interface, as well as learn how to use an argument to pull in a user name and use it in a dynamically created path.</p>
|
||||
<p>A <em>feed</em> is a data format that places your site's content into a file that can be read and displayed by news reader programs. When visiting a site, you may notice a small <a href="http://drupal.org/misc/feed.png">RSS transmission icon</a>, whereby clicking on it, you can subscribe to the site's most recent content. This makes it easier for your visitors to keep up to date with your website. You can also use this format to aggregate information into other sites. For more information, please watch a video from Common Craft about <a href="http://www.commoncraft.com/rss_plain_english">RSS in plain English</a>.</p>
|
||||
<p>Note, Drupal automatically creates a feed for your website, but you may want to create feeds with specific information. In this case, a list per user. </p>
|
||||
<ol>
|
||||
<li>
|
||||
<h3>Creating a new view </h3>
|
||||
<ol>
|
||||
<li>Go to <a target="_blank" href="base_url:admin/structure/views/add">add new view</a>. Give it the name 'user_feed', description 'A feed of user nodes.', tag 'users', type 'Node' and click Next.</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li><strong>About the Interface.</strong> You have been brought to the Views User Interface. As you start, you are editing the "Default" options for the view. In the 1st column on the left- you can see the pull-down menu offers 'Feed', for example, to select settings specific only to RSS views. In the remaining columns, you will be able to add or change options by clicking on links or icons. These options appear below this main area. Most likely, you will need to scroll to see the options appear. As you make changes, these options will appear in bold until you save your view.</li>
|
||||
<li>
|
||||
<h3>Change default display</h3>
|
||||
<ol>
|
||||
<li>Under <strong>Basic Settings</strong> in the 2nd column, click <em>Row style: Fields</em></li>
|
||||
<li>A menu loads below, <em>Defaults: How should each row in this view be styled</em>, check the <em>Node</em> option, and click <strong>Update</strong>.</li>
|
||||
<li>This loads another options menu, <em>Defaults: Row style options</em> click <strong>Update</strong>.</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li>
|
||||
<h3>Create the RSS view </h3>
|
||||
<ol>
|
||||
<li>In the 1st column, select 'Feed' in the drop-down menu, and click <strong>Add Display</strong>.</li>
|
||||
<li>Under <strong>Basic Settings </strong>in the 2nd column, click<em> Row style:Missing style plugin</em></li>
|
||||
<li>Note, options appear below the Views Interface, you may need to scroll to see <em>Feed: How should each row in this view be styled</em><br />
|
||||
tick <strong>Node</strong>, then <strong>Update</strong></li>
|
||||
<li>This loads the next options menu- <em>Display type: </em>select "Use default RSS settings", click <strong>Update</strong>.</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li>
|
||||
<h3>Set the path for accessing your feed</h3>
|
||||
<ol>
|
||||
<li> In the 2nd column under <strong>Feed settings</strong>, click <em>Path: None </em></li>
|
||||
<li>In options below <em>Feed: The menu path or URL of this view</em> enter in the path with an argument feeds/%/rss.xml</li>
|
||||
<li>Click <strong>Update</strong></li>
|
||||
</ol>
|
||||
</li>
|
||||
<li>
|
||||
<h3>Set up your arguments to say which user's nodes to display</h3>
|
||||
<ol>
|
||||
<li>To the right of <strong>Arguments</strong>, click the + sign to add and argument</li>
|
||||
<li>In the Feed: Add arguments menu that loads below, select User in the pull-down menu</li>
|
||||
<li>Check the box <em>User: Name</em>, click <strong>Add</strong></li>
|
||||
<li>Scroll down to options to find <strong>Case in path:</strong> select <em>Lower case</em></li>
|
||||
<li>Check the box <em>Transform spaces to dashes in URL</em></li>
|
||||
<li>Click <strong>Update default display</strong></li>
|
||||
</ol>
|
||||
</li>
|
||||
<li>
|
||||
<h3>Sort to show most recent at top of feed</h3>
|
||||
<ol>
|
||||
<li>Scroll up to <strong>Sort criteria</strong> in the right most column and click the + icon.</li>
|
||||
<li>In the <strong>Groups</strong> drop-down menu below, select 'Node', then check <em>Node: Post date</em>, and click <strong>Add</strong>. </li>
|
||||
<li>Select <em>Descending</em> <strong>Sort order</strong>. Click <strong>Update</strong>.</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li>
|
||||
<h3>Set filters to hide unpublished entries</h3>
|
||||
<ol>
|
||||
<li>Click the + icon next to <strong>Filters</strong>. In the options below, select <em>Node</em> under <strong>Groups</strong> drop-down menu, choose the <em>Node: Published</em> filter, and click <strong>Add</strong>.</li>
|
||||
<li>Check the box <em>Published</em>. Click <strong>Update default display</strong></li>
|
||||
</ol>
|
||||
</li>
|
||||
<li>
|
||||
<h3>Test</h3>
|
||||
<ol>
|
||||
<li>Click <strong>Save</strong></li>
|
||||
<li>Under <strong>Live preview</strong> type in the name of a user, in lowercase, replacing spaces with dashes, click <strong>Preview</strong>.</li>
|
||||
<li>You should test and find your feeds at URLs like http://yoursite.com/feeds/user-name/rss.xml</li>
|
||||
<li>You can use this path for aggregating on another site. You can also attach the RSS feed to another display of view to make the feed link appear on that display.</li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
@ -0,0 +1,47 @@
|
||||
In this example you will create a page view listing users on your site. Through this step-by-step process, you will become familiar with some basic steps in creating a view, and familiarize yourself with the Views User Interface.
|
||||
|
||||
<ol>
|
||||
<li><h3>Creating a new view</h3>
|
||||
<p>Go to <a target="_blank" href="base_url:admin/structure/views/add">add new view</a>. Give your new view the name 'user_list', description 'A simple user listing.', tag 'users', type 'User' and click <strong>Next</strong>.</p></li>
|
||||
<li><h3>About the Interface</h3>
|
||||
<p>You have been brought to the Views User Interface. As you start, you are editing the "Default" options for the view. In the 1st column on the left you can see the drop-down menu offers 'block', for example, to select settings specific only to block views. In the remaining columns, you will be able to add or change options by clicking on links or icons. These options will then appear below this main area. Most likely, you will need to scroll to see the options appear. As you make changes, these options will appear in bold until you save your view.</p></li>
|
||||
<li><h3>Creating a page display; choosing a URL and creating a menu link</h3>
|
||||
<ol>
|
||||
<li>In the 1st column, ensure that 'Page' is selected in the drop-down menu, and click <strong>Add Display</strong>.</li>
|
||||
<li>Next we'll define the path for this page. A page must have a path, and we define it early so that Views doesn't warn us "Display Page uses path but path is undefined." Locate the <strong>Page settings</strong> in the 2nd column, and click the <em>None</em> link next to the <em>Path</em> setting. In the options editing area that appears below, set the path to 'user_list' (or something Implement you prefer) and click <strong>Update</strong>.</li>
|
||||
<li>Next to <em>Menu</em> setting, Click the <em>No menu</em> link. In the options which appear below, select <em>Normal menu entry</em>, and set the title to 'User list' and click <strong>Update</strong>.</li>
|
||||
<li>Scroll up to <strong>Basic settings</strong>, in that same 2nd column, and click the <em>No</em> link next to <em>Use pager</em>. Below, in the options, select <em>Full pager</em> and click <strong>Update default display</strong>.</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li><h3>Selecting the fields to display</h3>
|
||||
<ol>
|
||||
<li>In 3rd column locate the <strong>Fields</strong> options. Click the <strong>+</strong> icon to add fields.</li>
|
||||
<li>Scroll down to <strong>Defaults: Add fields</strong>. In the <strong>Groups</strong> drop-down menu select 'User', then check the following fields: <em>User: Created date</em>, <em>User: Delete link</em>, <em>User: Edit link</em>, <em>User: Last access</em>, <em>User: Name</em> and <em>User: Picture</em>. Then click <strong>Add</strong>.</li>
|
||||
<li>You will be taken through the fields you added one at a time. Click <strong>Update default display</strong> to go to each next field. Leave the default options on all fields except <em>Delete link</em>; change that field's label to 'Operations'.</li>
|
||||
<li>Scroll back up to <strong>Fields</strong> and click the <strong>↑↓</strong> icon to rearrange fields. Down below, drag the <em>Name</em> field, by dragging its four-sided arrow, to the top. Drag the <em>Delete link (Operations)</em> field to the bottom, and the <em>Edit link</em> field just above it. Then click <strong>Update</strong>.</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li><h3>Seeing what we've done so far</h3>
|
||||
<p>At this point, you have done enough to create a valid view. If you scroll down, you will see a preview of your view. If it doesn't show already, click the <strong>Preview</strong> button; but generally this display updates automatically whenever you finish working in one of the mini forms.</p></li>
|
||||
<li><h3>Styling the view as a table; combining related fields into columns</h3>
|
||||
<ol>
|
||||
<li>Under <strong>Basic settings</strong>, in the 1st column, click the <em>Unformatted</em> link next to the <em>Style</em> setting. In the options below, under <strong>Page: How should this view be styled</strong>, choose <em>Table</em> and click <strong>Update default display</strong>.</li>
|
||||
<li>You will be taken to a <strong>Page: Style options</strong> form to edit the table settings. Locate our <em>Edit link</em> field in this mini form, and notice the <strong>Column</strong> drop-down. Change this drop-down to show <em>Operations</em>. In the <strong>Separator</strong> column next to the <em>Operations</em> field, type ' | ' (note the spaces around the <strong>|</strong> symbol). Check all of the <strong>Sortable</strong> checkboxes, and set <strong>Default sort</strong> to <em>Name</em>. When finished, click <strong>Update default display</strong>.</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li><h3>Filtering the user list to exclude unwanted entries</h3>
|
||||
<ol>
|
||||
<li>Click the <strong>+</strong> icon next to <strong>Filters</strong>.</li>
|
||||
<li>In the <strong>Groups</strong> drop-down menu select 'User', then check the <em>User: Name</em> filter, and click <strong>Add</strong>.</li>
|
||||
<li>Select <em>Is not one of</em> and enter 'Anonymous' in the <strong>Usernames</strong> box. Click <strong>Update default display</strong>.</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li><h3>Adding an argument to list users by role dynamically</h3>
|
||||
<ol>
|
||||
<li>Scroll up to <strong>Arguments</strong>, and click its <strong>+</strong> icon.</li>
|
||||
<li>Check the <em>User: Roles</em> argument, and click <strong>Add</strong>. Set the title to '%1' (don't type the quotes), and under <strong>Action to take if argument is not present</strong> select <em>Summary, sorted ascending</em>. Leave the other settings as they are. Click <strong>Update default display</strong>, and click <strong>Update</strong> through the prompts that follow to accept their default values.</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li><h3>Saving the view</h3>
|
||||
<p>Finally, click the <strong>Save</strong> button to save your work. At the very top, click <strong>View "Page"</strong> to go to your new view!</p></li>
|
||||
</ol>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user