first import
This commit is contained in:
339
sites/all/modules/views_boxes/LICENSE.txt
Normal file
339
sites/all/modules/views_boxes/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.
|
||||
80
sites/all/modules/views_boxes/README.txt
Normal file
80
sites/all/modules/views_boxes/README.txt
Normal file
@@ -0,0 +1,80 @@
|
||||
Using Views Boxes
|
||||
--------------------------------------
|
||||
|
||||
I. Basic use:
|
||||
--------------------------------------
|
||||
* Enter a couple of article nodes (just set the titles for now).
|
||||
|
||||
* Make sure you have Views UI enabled and then create a new view
|
||||
(called list_articles) with a block display that returns the titles
|
||||
of your published articles.
|
||||
|
||||
* Go back to your test page and reclick 'Configure Layout'.
|
||||
|
||||
* Select Boxes in the editor's dropdown, and then drag and drop
|
||||
'Add custom view box' into a region.
|
||||
|
||||
* You'll be prompted to set the box's description (which is used
|
||||
for admin UI purposes) and its title (which is actually rendered
|
||||
and shown to end users). Set the title to <none> and the description
|
||||
to 'Views Box - Articles' and then click Continue.
|
||||
|
||||
* The 'View' dropdown shown then allows you to pick the block display
|
||||
you want this box instance to use. For now, we just have list_articles
|
||||
which doesn't have any exposed or contextual filters, so we can go
|
||||
ahead and save our settings.
|
||||
|
||||
* You'll now see your list of articles.
|
||||
|
||||
II. Exposed and contextual filters:
|
||||
--------------------------------------
|
||||
Views Boxes ships with some filters that are particularly useful for
|
||||
allowing extra levels of control over your view while still storing
|
||||
the configuration data in the box itself. We're going to cover the ability
|
||||
to curate this list_articles so that we can manually sort the article nodes
|
||||
through the box. For this, we're going to install the Views Arguments Extras
|
||||
module as it provides some filters that we'll need.
|
||||
|
||||
* Go edit the list_articles view.
|
||||
|
||||
* Add a contextual filter and select 'Content: Nid'. Before you save it,
|
||||
scroll down and open up the 'More' options.
|
||||
|
||||
* The administrative title can be used for two purposes: displaying what it
|
||||
is that we'll be selecting (Article nodes) to the admin when using the box,
|
||||
and to limit the autocomplete fields we'll have to specific entities and
|
||||
bundles. By default the autocomplete field will display all nodes, but if
|
||||
we want to restrict it to articles, we'd enter:
|
||||
Article nodes [node] {bundles:article} here
|
||||
|
||||
[ENTITY_TYPE] will tell the autocomplete which entity type to look up
|
||||
{bundles:COMMASEPERATEDLISTOFBUNDLES} will limit the auto complete by bundle
|
||||
|
||||
* Check the 'Allow multiple values' option and save your changes.
|
||||
|
||||
* Add a sort criteria and select 'Arguments: Multi-item Argument Order'.
|
||||
This insures that we're actually sorting using the nodes we'll be selecting
|
||||
through the contextual filter in the box. Make sure that this sort criteria
|
||||
comes before the existing 'Content: Post date' and it's set to
|
||||
'sort descending'. Save your changes to the view and go back to your page
|
||||
node with the list_articles view block.
|
||||
|
||||
* Edit the box by clicking the gear icon that appears when you hover over it
|
||||
and then selecting 'Edit Box'. Notice that you don't necessarily need to be
|
||||
in Context Editor mode to edit existing boxes.
|
||||
|
||||
* You'll notice that you now get 'Article Nodes' under settings for the box,
|
||||
which allows you to pick article nodes using the autocomplete fields and to
|
||||
order them as you'd like. Once you're done with this, save the changes and
|
||||
you'll get your manually reordered list.
|
||||
|
||||
* You can reuse the same box instance or another page if you want to keep the
|
||||
same ordered list, but you can also create a new custom view box that reuses
|
||||
the same view display but with a different selection of nodes. This allows
|
||||
for a pretty powerful way to make views configurable through the box interface
|
||||
while still keeping the benefits of reusing the same displays (templates
|
||||
for examples). Other filters can be exposed too and used through the box
|
||||
interface, and having a view box filter on a specific taxonomy term can be
|
||||
achieved in a similar manner.
|
||||
|
||||
Documentation written by tirdadc - http://drupal.org/user/383630
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
// $Id: views_handler_argument_count.inc,v 1.1 2008/09/03 19:21:28 merlinofchaos Exp $
|
||||
/**
|
||||
* Argument handler that ignores the argument.
|
||||
*/
|
||||
class views_boxes_handler_argument_limit extends views_handler_argument {
|
||||
|
||||
/**
|
||||
* Override options_form()
|
||||
*
|
||||
* We are just adding markup to warn that a pager acts after we do.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$form['must_not_be'] = array(
|
||||
'#markup' => t('This argument will have no effect if a pager is in use.'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override default_actions() to remove actions that don't
|
||||
* make sense for a count argument.
|
||||
* @todo need to see if this is necessary
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the behavior of query() to prevent the query
|
||||
* from being changed in any way.
|
||||
*/
|
||||
function query( $group_by = FALSE ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Override pre_query()
|
||||
*
|
||||
* We set the limit on the queue if we have a non wildcard value
|
||||
*/
|
||||
function pre_query() {
|
||||
if (isset($this->view->args[$this->position])) {
|
||||
$limit = $this->view->args[$this->position];
|
||||
if ($limit != $this->options['exception']['value']) {
|
||||
$this->view->query->set_limit($limit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
class views_boxes_handler_filter_sort extends views_handler_filter_in_operator {
|
||||
function get_value_options() {
|
||||
if (!isset($this->value_options)) {
|
||||
$this->value_title = t('Sort Plugins');
|
||||
$this->view->display_handler->get_handlers('sort');
|
||||
$options = array();
|
||||
foreach ($this->view->display_handler->handlers['sort'] as $key => $handler) {
|
||||
// Only show items that have been exposed
|
||||
// using the exposed filters means that the exposed form gets involved
|
||||
// and we do not like the way it does it.
|
||||
$name = $handler->options['ui_name'] ? $handler->options['ui_name'] : $key;
|
||||
$options[$key] = $name;
|
||||
}
|
||||
$this->value_options = $options;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function query() {
|
||||
// This should not be necessary but for some reason when we use
|
||||
// $view->set_exposed_input() it is not making it to value
|
||||
if (isset($this->view->exposed_input[$this->options['id']])) {
|
||||
$this->value = $this->view->exposed_input[$this->options['id']];
|
||||
}
|
||||
|
||||
if (!is_array($this->value)) {
|
||||
$this->value = array($this->value => $this->value);
|
||||
}
|
||||
|
||||
// Run though each value and grab the sort handler that we already have
|
||||
// then reset the sort array on the view
|
||||
// note this method lets us also change the order of the sort if
|
||||
// it is set correctly on the way in.
|
||||
if (!empty($this->value)) {
|
||||
$pre_sort = array();
|
||||
$sort_canidates = array();
|
||||
$hit_sort = FALSE;
|
||||
foreach ($this->view->sort as $key => $handle) {
|
||||
if (in_array($key, $this->options['value'])) {
|
||||
$sort_canidates[$key] = $handle;
|
||||
$hit_sort = TRUE;
|
||||
unset($this->view->sort[$key]);
|
||||
}
|
||||
elseif (!$hit_sort) {
|
||||
$pre_sort[$key] = $handle;
|
||||
unset($this->view->sort[$key]);
|
||||
}
|
||||
}
|
||||
$sort_ordered = array();
|
||||
foreach ($this->value as $key) {
|
||||
$sort_ordered[$key] = $sort_canidates[$key];
|
||||
}
|
||||
$this->view->sort = $pre_sort + $sort_ordered + $this->view->sort;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
19
sites/all/modules/views_boxes/plugins/views_boxes_view.css
Normal file
19
sites/all/modules/views_boxes/plugins/views_boxes_view.css
Normal file
@@ -0,0 +1,19 @@
|
||||
.form-item-view .description {
|
||||
clear:both;
|
||||
}
|
||||
.id-item {
|
||||
padding: 0px 0px 0px 13px;
|
||||
position:relative
|
||||
}
|
||||
.id-item .handle {
|
||||
height: 20px;
|
||||
left: -5px;
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
width: 20px;
|
||||
background: url("/misc/draggable.png") no-repeat scroll 0 0 transparent;
|
||||
}
|
||||
.id-item .handle:hover {
|
||||
background-position : 0 -20px;
|
||||
cursor:pointer;
|
||||
}
|
||||
525
sites/all/modules/views_boxes/plugins/views_boxes_view.inc
Normal file
525
sites/all/modules/views_boxes/plugins/views_boxes_view.inc
Normal file
@@ -0,0 +1,525 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provides a new box-type that provides Views as boxes.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Views content listing box.
|
||||
*/
|
||||
class views_boxes_view extends boxes_box {
|
||||
/**
|
||||
* Implementation of boxes_box::options_defaults().
|
||||
*/
|
||||
public function options_defaults() {
|
||||
return array(
|
||||
'view' => '',
|
||||
'settings' => array(),
|
||||
'view_object' => NULL,
|
||||
'view_more_text' => '',
|
||||
'view_more_link' => '',
|
||||
'expose_filters' => FALSE,
|
||||
);
|
||||
}
|
||||
/**
|
||||
* implements boxes_box::option_submit()
|
||||
* This needs a boxes patch
|
||||
*/
|
||||
public function options_submit($form, &$form_state) {
|
||||
|
||||
//$settings_form = $form['options']['settings'];
|
||||
//views_exposed_form_submit($settings_form, $form_state);
|
||||
foreach ($form['options']['settings'] as $key => $element) {
|
||||
if (isset($form_state['input'][$key])) {
|
||||
$this->options['settings'][$key] = $form_state['input'][$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* we use fancy ajax on our options form and this breaks with the context ui
|
||||
*/
|
||||
function use_multistep_create() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides boxes_box::cache_setting().
|
||||
*
|
||||
* This delegates each Views Box instance's cache setting to the value on the
|
||||
* View's Block display 'Block cache' value.
|
||||
*/
|
||||
public function cache_setting() {
|
||||
|
||||
$view_info = explode('--', $this->options['view']);
|
||||
// We are getting this from the cached views
|
||||
if ($view_info && count($view_info) == 2 && $view = views_get_view($view_info[0])) {
|
||||
foreach ($view->display as $id => $display) {
|
||||
if (($id == $view_info[1]) && (isset($display->display_options['block_caching']))) {
|
||||
return $display->display_options['block_caching'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return DRUPAL_CACHE_CUSTOM;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of boxes_box::options_form().
|
||||
*
|
||||
* We are presenting a form element for the view to use
|
||||
* and then a field set of elements based on that views exposed form and arguments
|
||||
*/
|
||||
public function options_form(&$form_state) {
|
||||
|
||||
drupal_add_css(drupal_get_path('module', 'views_boxes') . '/plugins/views_boxes_view.css');
|
||||
drupal_add_js(drupal_get_path('module', 'views_boxes') . '/plugins/views_boxes_view.js');
|
||||
$form = array();
|
||||
$view_options = array();
|
||||
|
||||
// Find all view displays that are blocks
|
||||
foreach (views_get_enabled_views() as $view) {
|
||||
$name = $view->name;
|
||||
foreach ($view->display as $display_name => $display) {
|
||||
// Only show block displays
|
||||
if ($display->display_plugin == 'block') {
|
||||
$view_options[$view->human_name]["$name--$display_name"] = "{$view->human_name} - {$display->display_title}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// form element for the view, change this set off an ajax call on the settings
|
||||
$form['view'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('View'),
|
||||
'#description' => t('Select the View and Display to use.'),
|
||||
'#options' => $view_options,
|
||||
'#default_value' => $this->options['view'],
|
||||
'#ajax' => array(
|
||||
'callback' => 'views_boxes_view_settings_callback',
|
||||
'wrapper' => 'view_settings',
|
||||
'method' => 'replace',
|
||||
'effect' => 'fade',
|
||||
),
|
||||
);
|
||||
|
||||
// wrapper for exposed form and arguments
|
||||
$form['settings'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Settings',
|
||||
'#prefix' => '<div id="view_settings">',
|
||||
'#suffix' => '</div>'
|
||||
);
|
||||
|
||||
// EXPOSED FILTERS
|
||||
$view_string = !empty($form_state['values']['view']) ? $form_state['values']['view'] : $this->options['view'];
|
||||
list($view_name, $display_name) = (preg_match('/--/', $view_string)) ? explode('--', $view_string) : array('', '');
|
||||
if ($view_name) {
|
||||
|
||||
// Insure that we use values that have been set in the form
|
||||
// on ajax calls
|
||||
$view = views_get_view($view_name, TRUE);
|
||||
$view->set_display($display_name);
|
||||
$view->set_exposed_input($this->options['settings']);
|
||||
$view->execute();
|
||||
|
||||
// Get the exposed form and use it to build the settings_form
|
||||
$exposed_form = $view->display_handler->get_plugin('exposed_form');
|
||||
$settings_form_state = array();
|
||||
list($settings_form, $settings_form_state) = $this->render_exposed_form($exposed_form, $settings_form_state);
|
||||
$form_state['settings_form_state'] = $settings_form_state;
|
||||
$temp_form_state = $form_state;
|
||||
$this->options_submit(array("options" => array("settings" => $settings_form)), $temp_form_state);
|
||||
|
||||
// Iterate over each item and make sure it has a title and add back
|
||||
// our default values
|
||||
foreach ($settings_form as $id => $element) {
|
||||
if (isset($view->filter[$id])) {
|
||||
$handler = $view->filter[$id];
|
||||
$title = $handler->options['ui_name'] ? $handler->options['ui_name'] : $id;
|
||||
$title = $handler->options['expose']['label'] ? $handler->options['expose']['label'] : $title;
|
||||
$settings_form[$id]['#title'] = $title;
|
||||
}
|
||||
if (isset($this->options['settings'][$id])) {
|
||||
// if we have an options array we want to make sure our default value
|
||||
// is in the options before we set it as the value
|
||||
$default_value = $this->options['settings'][$id];
|
||||
if (isset($settings_form[$id]['#options'])) {
|
||||
if (is_array($default_value)) {
|
||||
foreach ($default_value as $key => $value) {
|
||||
if (!in_array($value, array_keys($settings_form[$id]['#options']))) {
|
||||
unset($default_value[$key]);
|
||||
}
|
||||
}
|
||||
if (empty($default_value)) {
|
||||
unset($default_value);
|
||||
}
|
||||
else {
|
||||
if (!($settings_form[$id]['#multiple'])) {
|
||||
$default_value = $default_value[0];
|
||||
unset($default_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!in_array($default_value, array_keys($settings_form[$id]['#options']))) {
|
||||
unset($default_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($default_value)) {
|
||||
$settings_form[$id]['#default_value'] = $default_value;
|
||||
}
|
||||
}
|
||||
/*
|
||||
// we want to reorder the options to the same order as our stored values
|
||||
// incase the order matters
|
||||
if (is_array($this->options['settings'][$id])) {
|
||||
$options = array();
|
||||
foreach ($this->options['settings'][$id] as $key => $on) {
|
||||
$options[$key] = $settings_form[$id]['#options'][$key];
|
||||
}
|
||||
$settings_form[$id]['#options'] = $options + $settings_form[$id]['#options'];
|
||||
}
|
||||
// Make checkboxes instead of multi select for the sort options
|
||||
// This really should be part of the filter settings
|
||||
if ($settings_form[$id]['#type'] =='select' && $settings_form[$id]['#multiple'] == TRUE && $id == 'sort') {
|
||||
$settings_form[$id]['#type'] ='checkboxes';
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// ARGUMENTS
|
||||
// foreach argument let's make a element in the settings_form
|
||||
foreach ($view->argument as $key => $arg) {
|
||||
|
||||
// We are doing some custom handling on the id argument type
|
||||
// basically we are hiding the field that holds all of the ids
|
||||
// and making autocomplete fields for node selection.
|
||||
// We then update the original field with JS.
|
||||
$re = "/\[(.*)\]/";
|
||||
$entity_type = FALSE;
|
||||
unset($bundles);
|
||||
|
||||
// Check for the following format of the admin title
|
||||
// [entity type]
|
||||
// if we have it remove it from the name and set the entity type
|
||||
if (preg_match($re, $arg->options['ui_name'], $matches)) {
|
||||
$entity_type = $matches[1];
|
||||
$arg->options['ui_name'] = preg_replace($re, '', $arg->options['ui_name']);
|
||||
}
|
||||
|
||||
// See if we're going to filters on specific bundles
|
||||
$re = "/\{bundles:(.*)\}/";
|
||||
if (preg_match($re, $arg->options['ui_name'], $matches)) {
|
||||
$bundles = $matches[1];
|
||||
$arg->options['ui_name'] = preg_replace($re, '', $arg->options['ui_name']);
|
||||
}
|
||||
|
||||
if ((get_class($arg) == 'views_handler_argument_null') ||
|
||||
($arg->field == 'tid') ||
|
||||
($arg->field == 'nid') ||
|
||||
$entity_type) {
|
||||
// we need to get info about our entity
|
||||
// for now we are only looking at nodes and taxonomy_terms
|
||||
if (isset($form_state['values'][$key])) {
|
||||
$this->options['settings'][$key] = $form_state['values'][$key];
|
||||
}
|
||||
|
||||
$entity_type_array = array(
|
||||
'nid' => 'node',
|
||||
'tid' => 'taxonomy_term',
|
||||
);
|
||||
$entity_type = $entity_type ? $entity_type : (isset($entity_type_array[$arg->field]) ? $entity_type_array[$arg->field] : 'node');
|
||||
$entity_info = entity_get_info($entity_type);
|
||||
// Grab the name of the label and id field so that we can build the
|
||||
// autocomplete field values later
|
||||
$id_field = $entity_info['entity keys']['id'];
|
||||
$label_field = $entity_info['entity keys']['label'];
|
||||
|
||||
// Build the field group to put all of our widgets in
|
||||
$title = $arg->options['ui_name'] ? $arg->options['ui_name'] : $key;
|
||||
$settings_form["{$key}_group"] = array(
|
||||
'#title' => $title,
|
||||
'#type' => "fieldset",
|
||||
'#prefix' => "<div id = '$key-group' class='id-group'>",
|
||||
'#suffix' => "</div>",
|
||||
);
|
||||
|
||||
// Build the actual value field (this is what gets sent to the view)
|
||||
$settings_form[$key] = array(
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => $this->options['settings'][$key],
|
||||
'#attributes' => array('class' => array('id-value'), 'group' => "$key-group", 'style' => 'display:none'),
|
||||
);
|
||||
|
||||
// Wrap the sortable items
|
||||
$settings_form["{$key}_group"]["{$key}_container_start"] = array(
|
||||
'#markup' => "<div class='id-sortable' key='$key' id='$key-wrapper'>",
|
||||
'#weight' => -1,
|
||||
);
|
||||
|
||||
// Find the current values and build auto complete fields that are populated
|
||||
$ids = explode("+", $this->options['settings'][$key]);
|
||||
$entities = entity_load($entity_type, $ids);
|
||||
$count = 0;
|
||||
|
||||
// Restrict autocomplete to specific entity or bundle(s)
|
||||
if (!isset($bundles)) {
|
||||
$autocomplete_path = "entity-autocomplete/{$entity_type}";
|
||||
}
|
||||
else {
|
||||
$autocomplete_path = "entity-autocomplete/bundle/{$entity_type}/" . $bundles;
|
||||
}
|
||||
|
||||
foreach ($entities as $index => $entity) {
|
||||
$id = $index;
|
||||
|
||||
// Adding a rand to the key so the value does not get cached
|
||||
$settings_form["{$key}_group"][$key . "_$id-" . rand(0, 10000)] = array(
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => "{$entity->{$label_field}} [id:$id]",
|
||||
'#autocomplete_path' => $autocomplete_path,
|
||||
'#prefix' => '<div class = "id-item"><div class= handle></div>',
|
||||
'#attributes' => array('class' => array('id-field'), 'key' => $key),
|
||||
'#suffix' => '</div>',
|
||||
'#weight' => $count,
|
||||
);
|
||||
$count ++;
|
||||
}
|
||||
|
||||
// if the use asked for a new field or we have no fields add a empty field
|
||||
if ($form_state['clicked_button']['#key'] == $key || ($count == 0)) {
|
||||
$settings_form["{$key}_group"][$key . "new-" . rand(0, 10000)] = array(
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => "",
|
||||
'#autocomplete_path' => $autocomplete_path,
|
||||
'#prefix' => '<div class = "id-item"><div class= handle></div>',
|
||||
'#attributes' => array('class' => array('id-field'), 'key' => $key),
|
||||
'#suffix' => '</div>',
|
||||
'#weight' => 1000,
|
||||
);
|
||||
}
|
||||
// End the sortable group
|
||||
$settings_form["{$key}_group"]["{$key}_container_end"] = array(
|
||||
'#markup' => '</div>',
|
||||
'#weight' => 1001,
|
||||
);
|
||||
// Add a button to add a new item
|
||||
$settings_form["{$key}_group"]["{$key}_add"] = array(
|
||||
'#type' => 'button',
|
||||
'#value' => "Add New $title",
|
||||
'#key' => $key,
|
||||
'#weight' => 1002,
|
||||
'#attributes' => array('key' => $key),
|
||||
'#ajax' => array(
|
||||
'callback' => 'views_boxes_view_id_callback',
|
||||
'wrapper' => "{$key}-group",
|
||||
'method' => 'replace',
|
||||
'effect' => 'fade',
|
||||
),
|
||||
|
||||
);
|
||||
}
|
||||
else {
|
||||
$settings_form[$key] = array(
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => $this->options['settings'][$key],
|
||||
'#title' => $arg->options['ui_name'] ? $arg->options['ui_name'] : $key,
|
||||
);
|
||||
}
|
||||
}
|
||||
// if there are no settings we want to keep the field set
|
||||
// but make it clear that it is empty
|
||||
if (empty($settings_form)) {
|
||||
$form['settings']['empty'] = array(
|
||||
'#markup' => t('This view has no settings'),
|
||||
);
|
||||
}
|
||||
else {
|
||||
$form['settings'] = $form['settings'] + $settings_form;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
// Leave the setting fieldset but make it clear that we do not yet have a view
|
||||
$form['settings']['empty'] = array(
|
||||
'#markup' => t('No view selected'),
|
||||
);
|
||||
}
|
||||
$form['view_more_text'] = array(
|
||||
'#title' => t('More link text'),
|
||||
'#description' => t('Optional text for a custom link that follows the listing.'),
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => $this->options['view_more_text'],
|
||||
);
|
||||
$form['view_more_link'] = array(
|
||||
'#title' => t('More link URL'),
|
||||
'#description' => t('Optional URL for a custom link that follows the listing. Need to be a valid URL.'),
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => $this->options['view_more_link'],
|
||||
);
|
||||
$form['expose_filters'] = array(
|
||||
'#title' => t('Expose filters in render'),
|
||||
'#description' => t('By default in Views Boxes, exposed filters are meant to be used for editing the box settings for the view and are not rendered in the output. Checking this box will show them in the rendered view.'),
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => $this->options['expose_filters'],
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of boxes_box::render().
|
||||
*/
|
||||
public function render() {
|
||||
$content = '';
|
||||
// Only build a view if we have one
|
||||
if (
|
||||
($view_info = explode('--', $this->options['view'])) &&
|
||||
($view = views_get_view($view_info[0], TRUE))
|
||||
) {
|
||||
$display_name = $view_info[1];
|
||||
|
||||
$view->set_exposed_input($this->options['settings']);
|
||||
$view->exposed_data = $this->options['settings'];
|
||||
$view->set_display($display_name);
|
||||
|
||||
// Set arguments
|
||||
$args = array();
|
||||
$view->display_handler->get_handlers('argument');
|
||||
|
||||
// Run though the arguments and set values if we have them, set wildcard otherwise
|
||||
foreach ($view->display_handler->handlers['argument'] as $key => $arg) {
|
||||
if (!empty($this->options['settings'][$key])) {
|
||||
$args[] = $this->options['settings'][$key];
|
||||
}
|
||||
else {
|
||||
$args[] = $arg->options['exception']['value'];
|
||||
}
|
||||
}
|
||||
if (!empty($args)) {
|
||||
$view->set_arguments($args);
|
||||
}
|
||||
|
||||
// we need to execute before we remove the exposed widgets
|
||||
// but this is not an issue because render will not re-execute
|
||||
$view->pre_execute($args);
|
||||
$view->execute($display_name);
|
||||
$view->post_execute();
|
||||
|
||||
// We want to remove the filters by default
|
||||
if (!isset($this->options['expose_filters']) || !$this->options['expose_filters']) {
|
||||
unset($view->exposed_widgets);
|
||||
}
|
||||
|
||||
$content = $view->render($display_name);
|
||||
|
||||
// Let's use the box title first,
|
||||
// if it is not set, let's use the views
|
||||
// if it is set to <none>, let's not have a title
|
||||
$title = $this->title;
|
||||
if (!$title) {
|
||||
$options = $view->display_handler->options;
|
||||
if ($options['defaults']['title']) {
|
||||
$title = isset($view->display['default']->display_options['title']) ? check_plain($view->display['default']->display_options['title']) : NULL;
|
||||
}
|
||||
else {
|
||||
$title = isset($view->display_handler->options['title']) ? check_plain($view->display_handler->options['title']) : NULL;
|
||||
}
|
||||
}
|
||||
elseif ($title == '<none>') {
|
||||
$title = NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$content = t("No view selected");
|
||||
$title = $this->title;
|
||||
}
|
||||
// More link
|
||||
if ($this->options['view_more_text']) {
|
||||
if (valid_url($this->options['view_more_link'])) {
|
||||
$content .= '<div class="box-more-link">' .
|
||||
l($this->options['view_more_text'], $this->options['view_more_link']) . '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
$box = array(
|
||||
'delta' => $this->delta, // Crucial.
|
||||
'title' => $title,
|
||||
'subject' => $title,
|
||||
'content' => $content,
|
||||
'is_empty' => FALSE,
|
||||
'view_more_text' => $this->options['view_more_text'],
|
||||
'view_more_link' => $this->options['view_more_link'],
|
||||
);
|
||||
|
||||
if ((isset($view)) && (count($view->result) == 0) && !boxes_access_edit()) {
|
||||
$box['is_empty'] = TRUE;
|
||||
}
|
||||
|
||||
if ($display_name) {
|
||||
$box['current_display'] = $display_name;
|
||||
}
|
||||
if ($view->name) {
|
||||
$box['current_view'] = $view->name;
|
||||
}
|
||||
return $box;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is mostly a copy of exposed_form::render_exposed_form()
|
||||
*
|
||||
* But we do not do the render step and instead pass on the form and form_state
|
||||
*/
|
||||
function render_exposed_form($that, &$form_state, $block = FALSE) {
|
||||
// Deal with any exposed filters we may have, before building.
|
||||
$e = $this->options['settings']['exposed_input'];
|
||||
//$_SESSION['views'][$that->view->name][]
|
||||
//$that->view->exposed_data = $e;
|
||||
//$that->view->set_exposed_input($e);
|
||||
$form_state = $form_state + array(
|
||||
'view' => &$that->view,
|
||||
'display' => &$that->display,
|
||||
'method' => 'get',
|
||||
'rerender' => TRUE,
|
||||
'no_redirect' => TRUE,
|
||||
'always_process' => TRUE,
|
||||
'input' => $e
|
||||
);
|
||||
|
||||
// Some types of displays (eg. attachments) may wish to use the exposed
|
||||
// filters of their parent displays instead of showing an additional
|
||||
// exposed filter form for the attachment as well as that for the parent.
|
||||
if (!$that->view->display_handler->displays_exposed() || (!$block && $that->view->display_handler->get_option('exposed_block'))) {
|
||||
unset($form_state['rerender']);
|
||||
}
|
||||
|
||||
if (!empty($that->ajax)) {
|
||||
$form_state['ajax'] = TRUE;
|
||||
}
|
||||
|
||||
$form_state['exposed_form_plugin'] = $that;
|
||||
$form = drupal_build_form('views_exposed_form', $form_state);
|
||||
foreach ($form as $key => $item) {
|
||||
if (preg_match("/(^#|^form|submit)/", $key)) {
|
||||
unset($form[$key]);
|
||||
}
|
||||
}
|
||||
$output = array($form, $form_state);
|
||||
if (!empty($form_state['js settings'])) {
|
||||
$that->view->js_settings = $form_state['js settings'];
|
||||
}
|
||||
|
||||
if (!$that->view->display_handler->displays_exposed() || (!$block && $that->view->display_handler->get_option('exposed_block'))) {
|
||||
return "";
|
||||
}
|
||||
else {
|
||||
return $output;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
drupal_add_js(drupal_get_path('module', 'views_boxes') . '/plugins/views_boxes_view.js');
|
||||
drupal_add_css(drupal_get_path('module', 'views_boxes') . '/plugins/views_boxes_view.css');
|
||||
53
sites/all/modules/views_boxes/plugins/views_boxes_view.js
Normal file
53
sites/all/modules/views_boxes/plugins/views_boxes_view.js
Normal file
@@ -0,0 +1,53 @@
|
||||
|
||||
(function ($) {
|
||||
Drupal.behaviors.view_boxes = {
|
||||
attach: function(context) {
|
||||
//All of this code is for the custom id field
|
||||
|
||||
// Bind an update event to all of our id-value fields
|
||||
// this takes the values from all of the corresponding
|
||||
// id-fields parse and update our value
|
||||
$(".id-value").bind("update", function(e) {
|
||||
values = [];
|
||||
groupid = $(this).attr('group');
|
||||
$("#" + groupid).find(".id-field").each(function(i) {
|
||||
value = $(this).val();
|
||||
re = /.*id:(.*)\]/;
|
||||
if(value.match(re)) {
|
||||
id = value.replace(re, "$1");
|
||||
values.push(id);
|
||||
}
|
||||
});
|
||||
$(this).val(values.join("+"));
|
||||
});
|
||||
// make all wrappers sortable
|
||||
// and set up an update whenever a field is left
|
||||
$(".id-group", context).each(function () {
|
||||
$(this, context).find(".id-field").focusout(function (e){
|
||||
valueid = $(this).attr("key").replace(/_/g,"-");
|
||||
$("#edit-" + valueid).trigger("update");
|
||||
});
|
||||
$(this, context).find("input.form-submit").click(function (e){
|
||||
valueid = $(this).attr("key").replace(/_/g,"-");
|
||||
$("#edit-" + valueid).trigger("update");
|
||||
});
|
||||
$(this, context).find(".id-sortable", context).sortable({
|
||||
stop: function(event, ui) {
|
||||
valueid = $(this).attr("key").replace(/_/g,"-");
|
||||
$("#edit-" + valueid).trigger("update");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Redefining this here as the popup wasn't hiding properly following a click
|
||||
if (Drupal.jsAC != null) {
|
||||
Drupal.jsAC.prototype.select = function (node) {
|
||||
this.input.value = $(node).data('autocompleteValue');
|
||||
$(this.popup).css({ visibility: 'hidden' });
|
||||
valueid = $(this.input).attr("key").replace(/_/g,"-");
|
||||
$("#edit-" + valueid).trigger("update");
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
})(jQuery);
|
||||
19
sites/all/modules/views_boxes/views_boxes.info
Normal file
19
sites/all/modules/views_boxes/views_boxes.info
Normal file
@@ -0,0 +1,19 @@
|
||||
name = "Views Boxes"
|
||||
description = "Provides configurable views through boxes."
|
||||
core = 7.x
|
||||
dependencies[] = "ctools"
|
||||
dependencies[] = "boxes"
|
||||
dependencies[] = "views"
|
||||
dependencies[] = "entity_autocomplete"
|
||||
|
||||
files[] = views_boxes.module
|
||||
files[] = plugins/views_boxes_context_list.inc
|
||||
files[] = handlers/views_boxes_handler_argument_limit.inc
|
||||
files[] = handlers/views_boxes_handler_filter_sort.inc
|
||||
|
||||
; Information added by drupal.org packaging script on 2012-02-13
|
||||
version = "7.x-1.0-beta8"
|
||||
core = "7.x"
|
||||
project = "views_boxes"
|
||||
datestamp = "1329171345"
|
||||
|
||||
57
sites/all/modules/views_boxes/views_boxes.module
Normal file
57
sites/all/modules/views_boxes/views_boxes.module
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Implements hook_ctools_plugin_api().
|
||||
*/
|
||||
function views_boxes_ctools_plugin_api($module, $api) {
|
||||
if ($module == 'boxes' && $api == 'plugins') {
|
||||
return array('version' => 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_boxes_plugins().
|
||||
*/
|
||||
function views_boxes_boxes_plugins() {
|
||||
$info = array();
|
||||
$path = drupal_get_path('module', 'views_boxes') . '/plugins';
|
||||
$info['view'] = array(
|
||||
'title' => 'View Box',
|
||||
'handler' => array(
|
||||
'parent' => 'box',
|
||||
'class' => 'views_boxes_view',
|
||||
'file' => 'views_boxes_view.inc',
|
||||
'path' => $path,
|
||||
),
|
||||
);
|
||||
return $info;
|
||||
}
|
||||
|
||||
function views_boxes_view_id_callback($form, $form_state) {
|
||||
$key = $form_state['clicked_button']['#key'];
|
||||
$return['settings'] = $form['options']['settings']["{$key}_group"];
|
||||
return $return;
|
||||
}
|
||||
|
||||
function views_boxes_view_settings_callback($form, $form_state) {
|
||||
$return['settings'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Settings',
|
||||
'#prefix' => '<div id="view_settings">',
|
||||
'#suffix' => '</div>',
|
||||
'reload' => array(
|
||||
'#markup' => t('Please save and edit again to select settings'),
|
||||
),
|
||||
);
|
||||
$return['settings'] = $form['options']['settings'];
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_views_api().
|
||||
*/
|
||||
function views_boxes_views_api() {
|
||||
return array(
|
||||
'api' => views_api_version(), //should not be using this
|
||||
);
|
||||
}
|
||||
32
sites/all/modules/views_boxes/views_boxes.views.inc
Normal file
32
sites/all/modules/views_boxes/views_boxes.views.inc
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_views_data().
|
||||
*
|
||||
* Describes the two custom handlers to Views.
|
||||
*/
|
||||
function views_boxes_views_data() {
|
||||
$data['views_boxes']['table']['group'] = t('Boxes');
|
||||
$data['views_boxes']['table']['join'] = array(
|
||||
'#boxes' => array(),
|
||||
);
|
||||
$data['views']['limit'] = array(
|
||||
'title' => t('Limit'),
|
||||
'help' => t('Limit the number of records returned.'),
|
||||
'argument' => array(
|
||||
'handler' => 'views_boxes_handler_argument_limit',
|
||||
),
|
||||
);
|
||||
$data['views']['sort'] = array(
|
||||
'title' => t('Sort'),
|
||||
'help' => t('Limit which items can but used for sort.'),
|
||||
'filter' => array(
|
||||
'handler' => 'views_boxes_handler_filter_sort',
|
||||
),
|
||||
);
|
||||
|
||||
return $data;
|
||||
}
|
||||
Reference in New Issue
Block a user