deleted inigui, created features
This commit is contained in:
@@ -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.
|
||||
@@ -0,0 +1,36 @@
|
||||
|
||||
Field collection
|
||||
-----------------
|
||||
Provides a field collection field, to which any number of fields can be attached.
|
||||
|
||||
Each field collection item is internally represented as an entity, which is
|
||||
referenced via the field collection field in the host entity. While
|
||||
conceptually field collections are treated as part of the host entity, each
|
||||
field collection item may also be viewed and edited separately.
|
||||
|
||||
|
||||
Usage
|
||||
------
|
||||
|
||||
* Add a field collection field to any entity, e.g. to a node. For that use the
|
||||
the usual "Manage fields" interface provided by the "field ui" module of
|
||||
Drupal, e.g. "Admin -> Structure-> Content types -> Article -> Manage fields".
|
||||
|
||||
* Then go to "Admin -> Structure-> Field collection" to define some fields for
|
||||
the created field collection.
|
||||
|
||||
* By the default, the field collection is not shown during editing of the host
|
||||
entity. However, some links for adding, editing or deleting field collection
|
||||
items is shown when the host entity is viewed.
|
||||
|
||||
* Widgets for embedding the form for creating field collections in the
|
||||
host-entity can be provided by any module. In future the field collection
|
||||
module might provide such widgets itself too.
|
||||
|
||||
|
||||
Restrictions
|
||||
-------------
|
||||
|
||||
* As of now, the field collection field does not properly respect field
|
||||
translation. Thus, for now it is suggested to only use the field for
|
||||
entities that are not translatable.
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Plugin to provide a relationship handler for a field collection field.
|
||||
*/
|
||||
|
||||
// Plugin definition.
|
||||
$plugin = array(
|
||||
'title' => t('Field collection item'),
|
||||
'description' => t('Creates an entity context from a field collection field on a field.'),
|
||||
'context' => 'field_collection_field_collection_from_field_context',
|
||||
'edit form' => 'field_collection_field_collection_from_field_edit_form',
|
||||
'get child' => 'field_collection_field_collection_from_field_get_child',
|
||||
'get children' => 'field_collection_field_collection_from_field_get_children',
|
||||
'defaults' => array('delta' => 0),
|
||||
);
|
||||
|
||||
/**
|
||||
* Get child callback.
|
||||
*/
|
||||
function field_collection_field_collection_from_field_get_child($plugin, $parent, $child) {
|
||||
$plugins = field_collection_field_collection_from_field_get_children($plugin, $parent);
|
||||
return $plugins[$parent . ':' . $child];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get children callback.
|
||||
*/
|
||||
function field_collection_field_collection_from_field_get_children($plugin, $parent) {
|
||||
|
||||
$plugins = array();
|
||||
$instances_info = field_info_instances();
|
||||
if (isset($instances_info['field_collection_item'])) {
|
||||
$field_collection_items = $instances_info['field_collection_item'];
|
||||
|
||||
foreach (field_read_instances() as $instance) {
|
||||
if (isset($field_collection_items[$instance['field_name']])) {
|
||||
$child_plugin_id = $parent . ':' . $instance['entity_type'] . ':' . $instance['bundle'] . ':' . $instance['field_name'];
|
||||
|
||||
$child_plugin = $plugin;
|
||||
$child_plugin['context name'] = $instance['entity_type'] . ':' . $instance['bundle'] . ':' . $instance['field_name'];
|
||||
$child_plugin['title'] = t(
|
||||
'!label field collection (!field_name) from !entity_type (!bundle)',
|
||||
array(
|
||||
'!label' => $instance['label'],
|
||||
'!field_name' => $instance['field_name'],
|
||||
'!entity_type' => $instance['entity_type'],
|
||||
'!bundle' => $instance['bundle']
|
||||
)
|
||||
);
|
||||
$restrictions = array('type' => array($instance['bundle']));
|
||||
$child_plugin['required context'] = new ctools_context_required(ucfirst($instance['entity_type']), $instance['entity_type'], $restrictions);
|
||||
$child_plugin['parent'] = $parent;
|
||||
$child_plugin['keyword'] = 'Field collection';
|
||||
$child_plugin['entity_type'] = $instance['entity_type'];
|
||||
$child_plugin['field_name'] = $instance['field_name'];
|
||||
|
||||
$child_plugin['name'] = $child_plugin_id;
|
||||
$plugins[$child_plugin_id] = $child_plugin;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a new field collection context based on an existing context.
|
||||
*/
|
||||
function field_collection_field_collection_from_field_context($context, $conf) {
|
||||
|
||||
$plugin_info = ctools_get_relationship($conf['name']);
|
||||
$delta = (int) $conf['delta'];
|
||||
|
||||
$entity = $context->data;
|
||||
if (isset($entity->{$plugin_info['field_name']})) {
|
||||
|
||||
$items = field_get_items($plugin_info['entity_type'], $entity, $plugin_info['field_name']);
|
||||
if (isset($items[$delta]['value'])) {
|
||||
$field_collection_item = field_collection_item_load($items[$delta]['value']);
|
||||
}
|
||||
|
||||
return ctools_context_create('entity:field_collection_item', $items[$delta]['value']);
|
||||
}
|
||||
|
||||
return ctools_context_create_empty('entity:field_collection_item', NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings form.
|
||||
*/
|
||||
function field_collection_field_collection_from_field_edit_form($form, &$form_state) {
|
||||
$conf = $form_state['conf'];
|
||||
|
||||
$form['delta'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Delta'),
|
||||
'#size' => 3,
|
||||
'#description' => t('The relationship can only create one context, but multiple items can be related. Please type in the number you want. The first one will be 0.'),
|
||||
'#default_value' => empty($conf['delta']) ? 0 : $conf['delta'],
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Default theme implementation for field collection items.
|
||||
*
|
||||
* Available variables:
|
||||
* - $content: An array of comment items. Use render($content) to print them all, or
|
||||
* print a subset such as render($content['field_example']). Use
|
||||
* hide($content['field_example']) to temporarily suppress the printing of a
|
||||
* given element.
|
||||
* - $title: The (sanitized) field collection item label.
|
||||
* - $url: Direct url of the current entity if specified.
|
||||
* - $page: Flag for the full page state.
|
||||
* - $classes: String of classes that can be used to style contextually through
|
||||
* CSS. It can be manipulated through the variable $classes_array from
|
||||
* preprocess functions. By default the following classes are available, where
|
||||
* the parts enclosed by {} are replaced by the appropriate values:
|
||||
* - entity-field-collection-item
|
||||
* - field-collection-item-{field_name}
|
||||
*
|
||||
* Other variables:
|
||||
* - $classes_array: Array of html class attribute values. It is flattened
|
||||
* into a string within the variable $classes.
|
||||
*
|
||||
* @see template_preprocess()
|
||||
* @see template_preprocess_entity()
|
||||
* @see template_process()
|
||||
*/
|
||||
?>
|
||||
<div class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
|
||||
<div class="content"<?php print $content_attributes; ?>>
|
||||
<?php
|
||||
print render($content);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provides the field_collection module admin pages.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Menu callback; list all field collections on this site.
|
||||
*/
|
||||
function field_collections_overview() {
|
||||
$instances = field_info_instances();
|
||||
$field_types = field_info_field_types();
|
||||
$bundles = field_info_bundles();
|
||||
$header = array(t('Field name'), t('Used in'), array('data' => t('Operations'), 'colspan' => '2'));
|
||||
$rows = array();
|
||||
foreach ($instances as $entity_type => $type_bundles) {
|
||||
foreach ($type_bundles as $bundle => $bundle_instances) {
|
||||
foreach ($bundle_instances as $field_name => $instance) {
|
||||
$field = field_info_field($field_name);
|
||||
if ($field['type'] == 'field_collection') {
|
||||
$admin_path = _field_ui_bundle_admin_path($entity_type, $bundle);
|
||||
$rows[$field_name]['class'] = $field['locked'] ? array('menu-disabled') : array('');
|
||||
|
||||
$rows[$field_name]['data'][0] = $field['locked'] ? t('@field_name (Locked)', array('@field_name' => $field_name)) : $field_name;
|
||||
$rows[$field_name]['data'][1][] = l($bundles[$entity_type][$bundle]['label'], $admin_path . '/fields');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($rows as $field_name => $cell) {
|
||||
$rows[$field_name]['data'][1] = implode(', ', $cell['data'][1]);
|
||||
|
||||
$field_name_url_str = strtr($field_name, array('_' => '-'));
|
||||
$rows[$field_name]['data'][2] = l(t('manage fields'), 'admin/structure/field-collections/' . $field_name_url_str . '/fields');
|
||||
$rows[$field_name]['data'][3] = l(t('manage display'), 'admin/structure/field-collections/' . $field_name_url_str . '/display');
|
||||
}
|
||||
if (empty($rows)) {
|
||||
$output = t('No field collections have been defined yet. To do so attach a field collection field to any entity.');
|
||||
}
|
||||
else {
|
||||
// Sort rows by field name.
|
||||
ksort($rows);
|
||||
$output = theme('table', array('header' => $header, 'rows' => $rows));
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains API documentation and examples for the Field collection module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup hooks
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Alter whether a field collection item is considered empty.
|
||||
*
|
||||
* This hook allows modules to determine whether a field collection is empty
|
||||
* before it is saved.
|
||||
*
|
||||
* @param boolean $empty
|
||||
* Whether or not the field should be considered empty.
|
||||
* @param FieldCollectionItemEntity $item
|
||||
* The field collection we are currently operating on.
|
||||
*/
|
||||
function hook_field_collection_is_empty_alter(&$is_empty, FieldCollectionItemEntity $item) {
|
||||
if (isset($item->my_field) && empty($item->my_field)) {
|
||||
$is_empty = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Acts on field collections being loaded from the database.
|
||||
*
|
||||
* This hook is invoked during field collection item loading, which is handled
|
||||
* by entity_load(), via the EntityCRUDController.
|
||||
*
|
||||
* @param array $entities
|
||||
* An array of field collection item entities being loaded, keyed by id.
|
||||
*
|
||||
* @see hook_entity_load()
|
||||
*/
|
||||
function hook_field_collection_item_load(array $entities) {
|
||||
$result = db_query('SELECT pid, foo FROM {mytable} WHERE pid IN(:ids)', array(':ids' => array_keys($entities)));
|
||||
foreach ($result as $record) {
|
||||
$entities[$record->pid]->foo = $record->foo;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Responds when a field collection item is inserted.
|
||||
*
|
||||
* This hook is invoked after the field collection item is inserted into the
|
||||
* database.
|
||||
*
|
||||
* @param FieldCollectionItemEntity $field_collection_item
|
||||
* The field collection item that is being inserted.
|
||||
*
|
||||
* @see hook_entity_insert()
|
||||
*/
|
||||
function hook_field_collection_item_insert(FieldCollectionItemEntity $field_collection_item) {
|
||||
db_insert('mytable')->fields(array(
|
||||
'id' => entity_id('field_collection_item', $field_collection_item),
|
||||
'extra' => print_r($field_collection_item, TRUE),
|
||||
))->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Acts on a field collection item being inserted or updated.
|
||||
*
|
||||
* This hook is invoked before the field collection item is saved to the database.
|
||||
*
|
||||
* @param FieldCollectionItemEntity $field_collection_item
|
||||
* The field collection item that is being inserted or updated.
|
||||
*
|
||||
* @see hook_entity_presave()
|
||||
*/
|
||||
function hook_field_collection_item_presave(FieldCollectionItemEntity $field_collection_item) {
|
||||
$field_collection_item->name = 'foo';
|
||||
}
|
||||
|
||||
/**
|
||||
* Responds to a field collection item being updated.
|
||||
*
|
||||
* This hook is invoked after the field collection item has been updated in the
|
||||
* database.
|
||||
*
|
||||
* @param FieldCollectionItemEntity $field_collection_item
|
||||
* The field collection item that is being updated.
|
||||
*
|
||||
* @see hook_entity_update()
|
||||
*/
|
||||
function hook_field_collection_item_update(FieldCollectionItemEntity $field_collection_item) {
|
||||
db_update('mytable')
|
||||
->fields(array('extra' => print_r($field_collection_item, TRUE)))
|
||||
->condition('id', entity_id('field_collection_item', $field_collection_item))
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Responds to field collection item deletion.
|
||||
*
|
||||
* This hook is invoked after the field collection item has been removed from
|
||||
* the database.
|
||||
*
|
||||
* @param FieldCollectionItemEntity $field_collection_item
|
||||
* The field collection item that is being deleted.
|
||||
*
|
||||
* @see hook_entity_delete()
|
||||
*/
|
||||
function hook_field_collection_item_delete(FieldCollectionItemEntity $field_collection_item) {
|
||||
db_delete('mytable')
|
||||
->condition('pid', entity_id('field_collection_item', $field_collection_item))
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Act on a field collection item that is being assembled before rendering.
|
||||
*
|
||||
* @param $field_collection_item
|
||||
* The field collection item entity.
|
||||
* @param $view_mode
|
||||
* The view mode the field collection item is rendered in.
|
||||
* @param $langcode
|
||||
* The language code used for rendering.
|
||||
*
|
||||
* The module may add elements to $field_collection_item->content prior to
|
||||
* rendering. The structure of $field_collection_item->content is a renderable
|
||||
* array as expected by drupal_render().
|
||||
*
|
||||
* @see hook_entity_prepare_view()
|
||||
* @see hook_entity_view()
|
||||
*/
|
||||
function hook_field_collection_item_view($field_collection_item, $view_mode, $langcode) {
|
||||
$field_collection_item->content['my_additional_field'] = array(
|
||||
'#markup' => $additional_field,
|
||||
'#weight' => 10,
|
||||
'#theme' => 'mymodule_my_additional_field',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alter the results of entity_view() for field collection items.
|
||||
*
|
||||
* This hook is called after the content has been assembled in a structured
|
||||
* array and may be used for doing processing which requires that the complete
|
||||
* field collection item content structure has been built.
|
||||
*
|
||||
* If the module wishes to act on the rendered HTML of the field collection item
|
||||
* rather than the structured content array, it may use this hook to add a
|
||||
* #post_render callback. See drupal_render() and theme() documentation
|
||||
* respectively for details.
|
||||
*
|
||||
* @param $build
|
||||
* A renderable array representing the field collection item content.
|
||||
*
|
||||
* @see hook_entity_view_alter()
|
||||
*/
|
||||
function hook_field_collection_item_view_alter($build) {
|
||||
if ($build['#view_mode'] == 'full' && isset($build['an_additional_field'])) {
|
||||
// Change its weight.
|
||||
$build['an_additional_field']['#weight'] = -10;
|
||||
|
||||
// Add a #post_render callback to act on the rendered HTML of the entity.
|
||||
$build['#post_render'][] = 'my_module_post_render';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -0,0 +1,17 @@
|
||||
name = Field collection
|
||||
description = Provides a field collection field, to which any number of fields can be attached.
|
||||
core = 7.x
|
||||
dependencies[] = entity
|
||||
files[] = field_collection.test
|
||||
files[] = field_collection.info.inc
|
||||
files[] = views/field_collection_handler_relationship.inc
|
||||
files[] = field_collection.migrate.inc
|
||||
configure = admin/structure/field-collections
|
||||
package = Fields
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-11-04
|
||||
version = "7.x-1.0-beta8"
|
||||
core = "7.x"
|
||||
project = "field_collection"
|
||||
datestamp = "1415122384"
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provides entity property info for field collection items.
|
||||
*/
|
||||
|
||||
class FieldCollectionItemMetadataController extends EntityDefaultMetadataController {
|
||||
|
||||
public function entityPropertyInfo() {
|
||||
$info = parent::entityPropertyInfo();
|
||||
$properties = &$info['field_collection_item']['properties'];
|
||||
|
||||
$properties['field_name']['label'] = t('Field name');
|
||||
$properties['field_name']['description'] = t('The machine-readable name of the field collection field containing this item.');
|
||||
$properties['field_name']['required'] = TRUE;
|
||||
|
||||
$properties['host_entity'] = array(
|
||||
'label' => t('Host entity'),
|
||||
'type' => 'entity',
|
||||
'description' => t('The entity containing the field collection field.'),
|
||||
'getter callback' => 'field_collection_item_get_host_entity',
|
||||
'setter callback' => 'field_collection_item_set_host_entity',
|
||||
'required' => TRUE,
|
||||
);
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,330 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Install, update and uninstall functions for the field_collection module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_schema().
|
||||
*/
|
||||
function field_collection_schema() {
|
||||
|
||||
$schema['field_collection_item'] = array(
|
||||
'description' => 'Stores information about field collection items.',
|
||||
'fields' => array(
|
||||
'item_id' => array(
|
||||
'type' => 'serial',
|
||||
'not null' => TRUE,
|
||||
'description' => 'Primary Key: Unique field collection item ID.',
|
||||
),
|
||||
'revision_id' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'description' => 'Default revision ID.',
|
||||
),
|
||||
'field_name' => array(
|
||||
'description' => 'The name of the field on the host entity embedding this entity.',
|
||||
'type' => 'varchar',
|
||||
'length' => 32,
|
||||
'not null' => TRUE,
|
||||
),
|
||||
'archived' => array(
|
||||
'description' => 'Boolean indicating whether the field collection item is archived.',
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
),
|
||||
),
|
||||
'primary key' => array('item_id'),
|
||||
);
|
||||
$schema['field_collection_item_revision'] = array(
|
||||
'description' => 'Stores revision information about field collection items.',
|
||||
'fields' => array(
|
||||
'revision_id' => array(
|
||||
'type' => 'serial',
|
||||
'not null' => TRUE,
|
||||
'description' => 'Primary Key: Unique revision ID.',
|
||||
),
|
||||
'item_id' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'description' => 'Field collection item ID.',
|
||||
),
|
||||
),
|
||||
'primary key' => array('revision_id'),
|
||||
'indexes' => array(
|
||||
'item_id' => array('item_id'),
|
||||
),
|
||||
'foreign keys' => array(
|
||||
'versioned_field_collection_item' => array(
|
||||
'table' => 'field_collection_item',
|
||||
'columns' => array('item_id' => 'item_id'),
|
||||
),
|
||||
),
|
||||
);
|
||||
return $schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_schema().
|
||||
*/
|
||||
function field_collection_field_schema($field) {
|
||||
$columns = array(
|
||||
'value' => array(
|
||||
'type' => 'int',
|
||||
'not null' => FALSE,
|
||||
'description' => 'The field collection item id.',
|
||||
),
|
||||
'revision_id' => array(
|
||||
'type' => 'int',
|
||||
'not null' => FALSE,
|
||||
'description' => 'The field collection item revision id.',
|
||||
),
|
||||
);
|
||||
return array(
|
||||
'columns' => $columns,
|
||||
'indexes' => array(
|
||||
'revision_id' => array('revision_id'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the administer field collection permission machine name.
|
||||
*/
|
||||
function field_collection_update_7000() {
|
||||
db_update('role_permission')
|
||||
->fields(array('permission' => 'administer field collections'))
|
||||
->condition('permission', 'administer field-collections')
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add revision support.
|
||||
*/
|
||||
function field_collection_update_7001() {
|
||||
|
||||
// Add revision_id column to field_collection_item table.
|
||||
$revision_id_spec = array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'description' => 'Default revision ID.',
|
||||
// Set default to 0 temporarily.
|
||||
'initial' => 0,
|
||||
);
|
||||
// Field may already exist due to bug in 7.x-1.0-beta5.
|
||||
if (!db_field_exists('field_collection_item', 'revision_id')) {
|
||||
db_add_field('field_collection_item', 'revision_id', $revision_id_spec);
|
||||
}
|
||||
|
||||
// Initialize the revision_id to be the same as the item_id.
|
||||
db_update('field_collection_item')
|
||||
->expression('revision_id', 'item_id')
|
||||
->execute();
|
||||
|
||||
// Add the archived column
|
||||
$archived_spec = array(
|
||||
'description' => 'Boolean indicating whether the field collection item is archived.',
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
);
|
||||
// Field may already exist due to bug in 7.x-1.0-beta5.
|
||||
if (!db_field_exists('field_collection_item', 'archived')) {
|
||||
db_add_field('field_collection_item', 'archived', $archived_spec);
|
||||
}
|
||||
|
||||
// Create the new table. It is important to explicitly define the schema here
|
||||
// rather than use the hook_schema definition: http://drupal.org/node/150220.
|
||||
$schema['field_collection_item_revision'] = array(
|
||||
'description' => 'Stores revision information about field collection items.',
|
||||
'fields' => array(
|
||||
'revision_id' => array(
|
||||
'type' => 'serial',
|
||||
'not null' => TRUE,
|
||||
'description' => 'Primary Key: Unique revision ID.',
|
||||
),
|
||||
'item_id' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'description' => 'Field collection item ID.',
|
||||
),
|
||||
),
|
||||
'primary key' => array('revision_id'),
|
||||
'indexes' => array(
|
||||
'item_id' => array('item_id'),
|
||||
),
|
||||
'foreign keys' => array(
|
||||
'versioned_field_collection_item' => array(
|
||||
'table' => 'field_collection_item',
|
||||
'columns' => array('item_id' => 'item_id'),
|
||||
),
|
||||
),
|
||||
);
|
||||
// Table may already exist due to bug in 7.x-1.0-beta5.
|
||||
if (db_table_exists('field_collection_item_revision')) {
|
||||
db_drop_table('field_collection_item_revision');
|
||||
}
|
||||
db_create_table('field_collection_item_revision', $schema['field_collection_item_revision']);
|
||||
|
||||
// Fill the new table with the correct data.
|
||||
$items = db_select('field_collection_item', 'fci')
|
||||
->fields('fci')
|
||||
->execute();
|
||||
foreach ($items as $item) {
|
||||
// Update field_collection_item_revision table.
|
||||
db_insert('field_collection_item_revision')
|
||||
->fields(array(
|
||||
'revision_id' => $item->item_id,
|
||||
'item_id' => $item->item_id,
|
||||
))
|
||||
->execute();
|
||||
}
|
||||
|
||||
// Update the field_collection_field_schema columns for all tables.
|
||||
// Add a revision_id column.
|
||||
$revision_id_spec['description'] = 'The field collection item revision id.';
|
||||
// Because $value_column below can be null, so must $revision_id_column.
|
||||
$revision_id_spec['not null'] = FALSE;
|
||||
foreach (field_read_fields(array('type' => 'field_collection')) as $field_name => $field) {
|
||||
$table_prefixes = array('field_data', 'field_revision');
|
||||
foreach ($table_prefixes as $table_prefix) {
|
||||
|
||||
$table = sprintf('%s_%s', $table_prefix, $field_name);
|
||||
$value_column = sprintf('%s_value', $field_name);
|
||||
$revision_id_column = sprintf('%s_revision_id', $field_name);
|
||||
|
||||
// Field may already exist due to bug in 7.x-1.0-beta5.
|
||||
if (!db_field_exists($table, $revision_id_column)) {
|
||||
db_add_field($table, $revision_id_column, $revision_id_spec);
|
||||
}
|
||||
else {
|
||||
db_change_field($table, $revision_id_column, $revision_id_column, $revision_id_spec);
|
||||
}
|
||||
|
||||
// Initialize the revision_id to be the same as the item_id.
|
||||
db_update($table)
|
||||
->expression($revision_id_column, $value_column)
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
|
||||
// Need to get the system up-to-date so drupal_schema_fields_sql() will work.
|
||||
$schema = drupal_get_schema('field_collection_item_revision', TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove orphaned field collection item entities.
|
||||
*/
|
||||
function field_collection_update_7002() {
|
||||
// Loop over all fields and delete any orphaned field collection items.
|
||||
foreach (field_read_fields(array('type' => 'field_collection')) as $field_name => $field) {
|
||||
|
||||
$select = db_select('field_collection_item', 'fci')
|
||||
->fields('fci', array('item_id'))
|
||||
->condition('field_name', $field_name)
|
||||
->condition('archived', 0);
|
||||
$select->leftJoin('field_data_' . $field_name, 'field', "field.{$field_name}_value = fci.item_id ");
|
||||
$select->isNull('field.entity_id');
|
||||
$ids = $select->execute()->fetchCol(0);
|
||||
|
||||
entity_delete_multiple('field_collection_item', $ids);
|
||||
drupal_set_message(t('Deleted @count orphaned field collection items.', array('@count' => count($ids))));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update field_collection_field_schema columns for all tables.
|
||||
*/
|
||||
function field_collection_update_7003() {
|
||||
// Revision_id column.
|
||||
$revision_id_spec = array(
|
||||
'type' => 'int',
|
||||
'not null' => FALSE,
|
||||
'description' => 'The field collection item revision id.',
|
||||
'initial' => 0,
|
||||
);
|
||||
|
||||
// Update the field_collection_field_schema columns for all tables,
|
||||
// in case the buggy beta5 version of field_collection_update_7001()
|
||||
// completed without complaint.
|
||||
foreach (field_read_fields(array('type' => 'field_collection')) as $field_name => $field) {
|
||||
$table_prefixes = array('field_data', 'field_revision');
|
||||
foreach ($table_prefixes as $table_prefix) {
|
||||
$table = sprintf('%s_%s', $table_prefix, $field_name);
|
||||
$value_column = sprintf('%s_value', $field_name);
|
||||
$revision_id_column = sprintf('%s_revision_id', $field_name);
|
||||
db_change_field($table, $revision_id_column, $revision_id_column, $revision_id_spec);
|
||||
}
|
||||
}
|
||||
|
||||
// Need to get the system up-to-date so drupal_schema_fields_sql() will work.
|
||||
$schema = drupal_get_schema('field_collection_item_revision', TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add index on {$field_collection_field}_revision_id column for all tables.
|
||||
*/
|
||||
function field_collection_update_7004() {
|
||||
// Update the field_collection_field_schema columns for all tables.
|
||||
foreach (field_read_fields(array('type' => 'field_collection')) as $field_name => $field) {
|
||||
$table_prefixes = array('field_data', 'field_revision');
|
||||
foreach ($table_prefixes as $table_prefix) {
|
||||
|
||||
$table = sprintf('%s_%s', $table_prefix, $field_name);
|
||||
$revision_id_column = sprintf('%s_revision_id', $field_name);
|
||||
|
||||
// Add index on revision_id column.
|
||||
if (!db_index_exists($table, $revision_id_column)) {
|
||||
db_add_index($table, $revision_id_column, array($revision_id_column));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Force the creation of the table cache_entity_field_collection_item.
|
||||
*
|
||||
* entity_update_7003 will attempt to install entitycache tables for existing
|
||||
* modules, but it uses module_list() to get the list of available modules,
|
||||
* which, when called from a database update, may not return field_collection
|
||||
* since drupal is bootstrapped at a lower level.
|
||||
*/
|
||||
function field_collection_update_7005() {
|
||||
if (module_exists('entitycache')) {
|
||||
$entity_type = 'field_collection_item';
|
||||
$table = 'cache_entity_' . $entity_type;
|
||||
if (!db_table_exists($table)) {
|
||||
$schema = drupal_get_schema_unprocessed('system', 'cache');
|
||||
$schema['description'] = 'Cache table used to store' . $entity_type . ' entity records.';
|
||||
db_create_table($table, $schema);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures revision_id indexes are present at field_config table.
|
||||
*/
|
||||
function field_collection_update_7006() {
|
||||
$result = db_query("SELECT id, field_name, data FROM {field_config} WHERE type = 'field_collection'");
|
||||
foreach ($result as $field_config) {
|
||||
$data = unserialize($field_config->data);
|
||||
// Skip this record if the revision_id index is already present.
|
||||
if (isset($data['indexes']['revision_id'])) {
|
||||
continue;
|
||||
}
|
||||
// Otherwise, add the revision_id index and update the record.
|
||||
$data['indexes']['revision_id'] = array('revision_id');
|
||||
$data = serialize($data);
|
||||
$num_updated = db_update('field_config')
|
||||
->fields(array('data' => $data))
|
||||
->condition('id', $field_config->id)
|
||||
->execute();
|
||||
// If for some reason the update failed, throw an exception.
|
||||
if ($num_updated != 1) {
|
||||
$t_args['@field'] = $field_config->field_name;
|
||||
throw new DrupalUpdateException(t('An error was detected when attempting to update field configuration for field @field.', $t_args));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Support for the Migrate API.
|
||||
*
|
||||
* Your field collection migration should be run after the host entity
|
||||
* migration. For example, if the collection is attached to nodes via a field
|
||||
* named 'field_attached_data', and if the nodes are being imported by
|
||||
* ArticleMigration, your collection migration class constructor should look
|
||||
* like:
|
||||
*
|
||||
* @code
|
||||
* $this->dependencies = array('Article');
|
||||
*
|
||||
* $this->destination = new MigrateDestinationFieldCollection(
|
||||
* 'field_attached_data',
|
||||
* array('host_entity_type' => 'node')
|
||||
* );
|
||||
*
|
||||
* $this->addFieldMapping('host_entity_id', 'source_article_id')
|
||||
* ->sourceMigration('Article');
|
||||
* @endcode
|
||||
*
|
||||
* @see http://drupal.org/node/1900640
|
||||
*/
|
||||
|
||||
/**
|
||||
* Destination class implementing migration into field_collection.
|
||||
*/
|
||||
class MigrateDestinationFieldCollection extends MigrateDestinationEntity {
|
||||
/**
|
||||
* The type of entity hosting this collection field (e.g., node).
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $hostEntityType;
|
||||
|
||||
static public function getKeySchema() {
|
||||
return array(
|
||||
'item_id' => array(
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'description' => 'ID of field collection item',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic initialization.
|
||||
*
|
||||
* @param string $bundle
|
||||
* Bundle name.
|
||||
* @param array $options
|
||||
* (optional) Options applied to collections.
|
||||
*/
|
||||
public function __construct($bundle, array $options = array()) {
|
||||
parent::__construct('field_collection_item', $bundle, $options);
|
||||
$this->hostEntityType = $options['host_entity_type'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of fields available to be mapped for this collection
|
||||
* (bundle).
|
||||
*
|
||||
* @return array
|
||||
* Keys: machine names of the fields (to be passed to addFieldMapping).
|
||||
* Values: Human-friendly descriptions of the fields.
|
||||
*/
|
||||
public function fields() {
|
||||
$fields = migrate_handler_invoke_all('Entity', 'fields', $this->entityType, $this->bundle);
|
||||
$fields['item_id'] = t('Field collection entity ID');
|
||||
$fields['host_entity_id'] = t('Field collection host ID');
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Import a single field collection item.
|
||||
*
|
||||
* @param $collection
|
||||
* Collection object to build. Pre-filled with any fields mapped in the
|
||||
* migration.
|
||||
* @param $row
|
||||
* Raw source data object - passed through to prepare/complete handlers.
|
||||
*
|
||||
* @return array|false
|
||||
* Array of key fields (item_id only in this case) of the collection that
|
||||
* was saved or FALSE on failure.
|
||||
*/
|
||||
public function import(stdClass $collection, stdClass $row) {
|
||||
if (isset($row->migrate_map_destid1)) {
|
||||
// We're updated an existing entity - start from the previous data.
|
||||
// entity_load() returns an array, so we get the field collection entity
|
||||
// with array_shift().
|
||||
$entity = array_shift(entity_load('field_collection_item', array($row->migrate_map_destid1), array(), TRUE));
|
||||
$entity_old = clone $entity;
|
||||
$updating = TRUE;
|
||||
}
|
||||
else {
|
||||
// Skip the collection if it has no host.
|
||||
if (empty($collection->host_entity_id)) {
|
||||
throw new MigrateException('Could not find host entity of the field collection to import.');
|
||||
}
|
||||
$entity = entity_create('field_collection_item', array('field_name' => $this->bundle));
|
||||
$updating = FALSE;
|
||||
$host_entity = entity_load_single($this->hostEntityType, $collection->host_entity_id);
|
||||
entity_get_controller($this->hostEntityType)->resetCache();
|
||||
$entity->setHostEntity($this->hostEntityType, $host_entity);
|
||||
}
|
||||
|
||||
unset($collection->host_entity_id);
|
||||
|
||||
foreach ((array) $collection as $field => $value) {
|
||||
$entity->{$field} = $value;
|
||||
}
|
||||
|
||||
$this->prepare($entity, $row);
|
||||
|
||||
// Restore fields from original field_collection_item if updating
|
||||
if ($updating) {
|
||||
foreach ($entity as $field => $value) {
|
||||
if ('field_' != substr($field, 0, 6)) {
|
||||
continue;
|
||||
}
|
||||
elseif (property_exists($entity_old, $field) && !property_exists($collection, $field)) {
|
||||
$entity->$field = $entity_old->$field;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
migrate_instrument_start('field_collection_save');
|
||||
$status = entity_save('field_collection_item', $entity);
|
||||
migrate_instrument_stop('field_collection_save');
|
||||
|
||||
if (in_array($this->hostEntityType, array('node', 'field_collection_item')) || ($status !== FALSE)) {
|
||||
$this->complete($entity, $row);
|
||||
if ($updating) {
|
||||
$this->numUpdated++;
|
||||
}
|
||||
else {
|
||||
$this->numCreated++;
|
||||
}
|
||||
return array($entity->item_id);
|
||||
}
|
||||
else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a migrated collection.
|
||||
*
|
||||
* @param $key
|
||||
* Array of fields representing the key.
|
||||
*/
|
||||
public function rollback(array $key) {
|
||||
$item_id = reset($key);
|
||||
|
||||
$this->prepareRollback($item_id);
|
||||
$field_collection_item = field_collection_item_load($item_id);
|
||||
// If the collection wasn't imported then we can't roll it back, so check if
|
||||
// the loaded object is an instance of the FieldCollectionItemEntity class.
|
||||
if ($field_collection_item instanceof FieldCollectionItemEntity) {
|
||||
$field_collection_item->delete();
|
||||
}
|
||||
|
||||
$this->completeRollback($item_id);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements migrate hook_migrate_api().
|
||||
*/
|
||||
function field_collection_migrate_api() {
|
||||
$api = array(
|
||||
'api' => 2,
|
||||
);
|
||||
return $api;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provides the field collection item view / edit / delete pages.
|
||||
*/
|
||||
|
||||
// TODO: fix being embedded in a host with revisions.
|
||||
|
||||
/**
|
||||
* Field collection item view page.
|
||||
*/
|
||||
function field_collection_item_page_view($field_collection_item) {
|
||||
// @todo: Set breadcrumb including the host.
|
||||
drupal_set_title($field_collection_item->label());
|
||||
return $field_collection_item->view('full', NULL, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Form for editing a field collection item.
|
||||
* @todo implement hook_forms().
|
||||
*/
|
||||
function field_collection_item_form($form, &$form_state, $field_collection_item) {
|
||||
if (!isset($field_collection_item->is_new)) {
|
||||
drupal_set_title($field_collection_item->label());
|
||||
}
|
||||
$form_state += array('field_collection_item' => $field_collection_item);
|
||||
|
||||
// Hack: entity_form_field_validate() needs the bundle to be set.
|
||||
// @todo: Fix core and remove the hack.
|
||||
$form['field_name'] = array('#type' => 'value', '#value' => $field_collection_item->field_name);
|
||||
|
||||
field_attach_form('field_collection_item', $field_collection_item, $form, $form_state);
|
||||
|
||||
$form['actions'] = array('#type' => 'actions', '#weight' => 50);
|
||||
$form['actions']['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Save'),
|
||||
'#weight' => 5,
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validation callback.
|
||||
*/
|
||||
function field_collection_item_form_validate($form, &$form_state) {
|
||||
entity_form_field_validate('field_collection_item', $form, $form_state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit builder. Extracts the form values and updates the entity.
|
||||
*/
|
||||
function field_collection_item_form_submit_build_field_collection($form, $form_state) {
|
||||
entity_form_submit_build_entity('field_collection_item', $form_state['field_collection_item'], $form, $form_state);
|
||||
return $form_state['field_collection_item'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit callback that permanently saves the changes to the entity.
|
||||
*/
|
||||
function field_collection_item_form_submit($form, &$form_state) {
|
||||
$field_collection_item = field_collection_item_form_submit_build_field_collection($form, $form_state);
|
||||
$field_collection_item->save();
|
||||
drupal_set_message(t('The changes have been saved.'));
|
||||
$form_state['redirect'] = $field_collection_item->path();
|
||||
}
|
||||
|
||||
/**
|
||||
* Form for deleting a field collection item.
|
||||
*/
|
||||
function field_collection_item_delete_confirm($form, &$form_state, $field_collection_item) {
|
||||
$form_state += array('field_collection_item' => $field_collection_item);
|
||||
return confirm_form($form,
|
||||
t('Are you sure you want to delete %label?', array('%label' => $field_collection_item->label())),
|
||||
$field_collection_item->path(),
|
||||
t('This action cannot be undone.'),
|
||||
t('Delete'),
|
||||
t('Cancel')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit callback for deleting a field collection item.
|
||||
*/
|
||||
function field_collection_item_delete_confirm_submit($form, &$form_state) {
|
||||
$field_collection_item = $form_state['field_collection_item'];
|
||||
$field_collection_item->deleteRevision();
|
||||
drupal_set_message(t('%label has been deleted.', array('%label' => drupal_ucfirst($field_collection_item->label()))));
|
||||
$form_state['redirect'] = '<front>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new field collection item.
|
||||
*
|
||||
* @todo: Support optionally passing in the revision_id and langcode parameters.
|
||||
*/
|
||||
function field_collection_item_add($field_name, $entity_type, $entity_id, $revision_id = NULL, $langcode = NULL) {
|
||||
$info = entity_get_info();
|
||||
if (!isset($info[$entity_type])) {
|
||||
return MENU_NOT_FOUND;
|
||||
}
|
||||
$result = entity_load($entity_type, array($entity_id));
|
||||
$entity = reset($result);
|
||||
if (!$entity) {
|
||||
return MENU_NOT_FOUND;
|
||||
}
|
||||
// Ensure the given entity is of a bundle that has an instance of the field.
|
||||
list($id, $rev_id, $bundle) = entity_extract_ids($entity_type, $entity);
|
||||
$instance = field_info_instance($entity_type, $field_name, $bundle);
|
||||
if (!$instance) {
|
||||
return MENU_NOT_FOUND;
|
||||
}
|
||||
|
||||
// Check field cardinality.
|
||||
$field = field_info_field($field_name);
|
||||
$langcode = LANGUAGE_NONE;
|
||||
if (!($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED || !isset($entity->{$field_name}[$langcode]) || count($entity->{$field_name}[$langcode]) < $field['cardinality'])) {
|
||||
drupal_set_message(t('Too many items.'), 'error');
|
||||
return '';
|
||||
}
|
||||
|
||||
$field_collection_item = entity_create('field_collection_item', array('field_name' => $field_name));
|
||||
// Do not link the field collection item with the host entity at this point,
|
||||
// as during the form-workflow we have multiple field collection item entity
|
||||
// instances, which we don't want link all with the host.
|
||||
// That way the link is going to be created when the item is saved.
|
||||
$field_collection_item->setHostEntity($entity_type, $entity, LANGUAGE_NONE, FALSE);
|
||||
|
||||
$label = $field_collection_item->translatedInstanceLabel();
|
||||
$title = ($field['cardinality'] == 1) ? $label : t('Add new !instance_label', array('!instance_label' => $label));
|
||||
drupal_set_title($title);
|
||||
|
||||
// Make sure the current user has access to create a field collection item.
|
||||
if (!field_collection_item_access('create', $field_collection_item)) {
|
||||
return MENU_ACCESS_DENIED;
|
||||
}
|
||||
return drupal_get_form('field_collection_item_form', $field_collection_item);
|
||||
}
|
||||
@@ -0,0 +1,580 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* field_collections tests.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test basics.
|
||||
*/
|
||||
class FieldCollectionBasicTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Field collection',
|
||||
'description' => 'Tests creating and using field collections.',
|
||||
'group' => 'Field types',
|
||||
);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
parent::setUp('field_collection');
|
||||
|
||||
// Create a field_collection field to use for the tests.
|
||||
$this->field_name = 'field_test_collection';
|
||||
$this->field = array('field_name' => $this->field_name, 'type' => 'field_collection', 'cardinality' => 4);
|
||||
$this->field = field_create_field($this->field);
|
||||
$this->field_id = $this->field['id'];
|
||||
|
||||
$this->instance = array(
|
||||
'field_name' => $this->field_name,
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'article',
|
||||
'label' => $this->randomName() . '_label',
|
||||
'description' => $this->randomName() . '_description',
|
||||
'weight' => mt_rand(0, 127),
|
||||
'settings' => array(),
|
||||
'widget' => array(
|
||||
'type' => 'hidden',
|
||||
'label' => 'Test',
|
||||
'settings' => array(),
|
||||
),
|
||||
);
|
||||
$this->instance = field_create_instance($this->instance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper for creating a new node with a field collection item.
|
||||
*/
|
||||
protected function createNodeWithFieldCollection() {
|
||||
$node = $this->drupalCreateNode(array('type' => 'article'));
|
||||
// Manually create a field_collection.
|
||||
$entity = entity_create('field_collection_item', array('field_name' => $this->field_name));
|
||||
$entity->setHostEntity('node', $node);
|
||||
$entity->save();
|
||||
|
||||
return array($node, $entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests CRUD.
|
||||
*/
|
||||
function testCRUD() {
|
||||
list ($node, $entity) = $this->createNodeWithFieldCollection();
|
||||
$node = node_load($node->nid, NULL, TRUE);
|
||||
$this->assertEqual($entity->item_id, $node->{$this->field_name}[LANGUAGE_NONE][0]['value'], 'A field_collection has been successfully created and referenced.');
|
||||
$this->assertEqual($entity->revision_id, $node->{$this->field_name}[LANGUAGE_NONE][0]['revision_id'], 'A field_collection has been successfully created and referenced.');
|
||||
|
||||
// Test adding an additional field_collection during node edit.
|
||||
$entity2 = entity_create('field_collection_item', array('field_name' => $this->field_name));
|
||||
$node->{$this->field_name}[LANGUAGE_NONE][] = array('entity' => $entity2);
|
||||
node_save($node);
|
||||
|
||||
$node = node_load($node->nid, NULL, TRUE);
|
||||
$this->assertTrue(!empty($entity2->item_id) && !empty($entity2->revision_id), 'Field_collection has been saved.');
|
||||
$this->assertEqual($entity->item_id, $node->{$this->field_name}[LANGUAGE_NONE][0]['value'], 'Existing reference has been kept during update.');
|
||||
$this->assertEqual($entity->revision_id, $node->{$this->field_name}[LANGUAGE_NONE][0]['revision_id'], 'Existing reference has been kept during update (revision).');
|
||||
$this->assertEqual($entity2->item_id, $node->{$this->field_name}[LANGUAGE_NONE][1]['value'], 'New field_collection has been properly referenced');
|
||||
$this->assertEqual($entity2->revision_id, $node->{$this->field_name}[LANGUAGE_NONE][1]['revision_id'], 'New field_collection has been properly referenced (revision)');
|
||||
|
||||
// Make sure deleting the field_collection removes the reference.
|
||||
$entity2->delete();
|
||||
$node = node_load($node->nid, NULL, TRUE);
|
||||
$this->assertTrue(!isset($node->{$this->field_name}[LANGUAGE_NONE][1]), 'Reference correctly deleted.');
|
||||
|
||||
// Make sure field_collections are removed during deletion of the host.
|
||||
node_delete($node->nid);
|
||||
$this->assertTrue(entity_load('field_collection_item', FALSE) === array(), 'Field collections are deleted when the host is deleted.');
|
||||
|
||||
// Try deleting nodes with collections without any values.
|
||||
$node = $this->drupalCreateNode(array('type' => 'article'));
|
||||
node_delete($node->nid);
|
||||
$this->assertTrue(node_load($node->nid, NULL, TRUE) == FALSE, 'Node without collection values deleted.');
|
||||
|
||||
// Test creating a field collection entity with a not-yet saved host entity.
|
||||
$node = entity_create('node', array('type' => 'article'));
|
||||
$entity = entity_create('field_collection_item', array('field_name' => $this->field_name));
|
||||
$entity->setHostEntity('node', $node);
|
||||
$entity->save();
|
||||
// Now the node should have been saved with the collection and the link
|
||||
// should have been established.
|
||||
$this->assertTrue(!empty($node->nid), 'Node has been saved with the collection.');
|
||||
$this->assertTrue(count($node->{$this->field_name}[LANGUAGE_NONE]) == 1 && !empty($node->{$this->field_name}[LANGUAGE_NONE][0]['value']) && !empty($node->{$this->field_name}[LANGUAGE_NONE][0]['revision_id']), 'Link has been established.');
|
||||
|
||||
// Again, test creating a field collection with a not-yet saved host entity,
|
||||
// but this time save both entities via the host.
|
||||
$node = entity_create('node', array('type' => 'article'));
|
||||
$entity = entity_create('field_collection_item', array('field_name' => $this->field_name));
|
||||
$entity->setHostEntity('node', $node);
|
||||
node_save($node);
|
||||
$this->assertTrue(!empty($entity->item_id) && !empty($entity->revision_id), 'Collection has been saved with the host.');
|
||||
$this->assertTrue(count($node->{$this->field_name}[LANGUAGE_NONE]) == 1 && !empty($node->{$this->field_name}[LANGUAGE_NONE][0]['value']) && !empty($node->{$this->field_name}[LANGUAGE_NONE][0]['revision_id']), 'Link has been established.');
|
||||
|
||||
// Test Revisions.
|
||||
list ($node, $item) = $this->createNodeWithFieldCollection();
|
||||
$entity2 = entity_create('field_collection_item', array('field_name' => $this->field_name));
|
||||
$node->{$this->field_name}[LANGUAGE_NONE][] = array('entity' => $entity2);
|
||||
node_save($node);
|
||||
$this->assertEqual($entity2->archived, FALSE, 'New field collection item with new content revision is not archived.');
|
||||
|
||||
// Test saving a new revision of a node.
|
||||
$node->revision = TRUE;
|
||||
node_save($node);
|
||||
$item_updated = field_collection_item_load($node->{$this->field_name}[LANGUAGE_NONE][0]['value']);
|
||||
$this->assertNotEqual($item->revision_id, $item_updated->revision_id, 'Creating a new host entity revision creates a new field collection revision.');
|
||||
|
||||
// Test saving a new revision with a new field collection item.
|
||||
$node->revision = TRUE;
|
||||
|
||||
// Test saving the node without creating a new revision.
|
||||
$item = $item_updated;
|
||||
$node->revision = FALSE;
|
||||
node_save($node);
|
||||
$item_updated = field_collection_item_load($node->{$this->field_name}[LANGUAGE_NONE][0]['value']);
|
||||
$this->assertEqual($item->revision_id, $item_updated->revision_id, 'Updating a new host entity without creating a new revision does not create a new field collection revision.');
|
||||
|
||||
// Create a new revision of the node, such we have a non default node and
|
||||
// field collection revision. Then test using it.
|
||||
$vid = $node->vid;
|
||||
$item_revision_id = $item_updated->revision_id;
|
||||
$node->revision = TRUE;
|
||||
node_save($node);
|
||||
|
||||
$item_updated = field_collection_item_load($node->{$this->field_name}[LANGUAGE_NONE][0]['value']);
|
||||
$this->assertNotEqual($item_revision_id, $item_updated->revision_id, 'Creating a new host entity revision creates a new field collection revision.');
|
||||
$this->assertTrue($item_updated->isDefaultRevision(), 'Field collection of default host entity revision is default too.');
|
||||
$this->assertEqual($item_updated->hostEntityId(), $node->nid, 'Can access host entity ID of default field collection revision.');
|
||||
$this->assertEqual($item_updated->hostEntity()->vid, $node->vid, 'Loaded default host entity revision.');
|
||||
|
||||
$item = entity_revision_load('field_collection_item', $item_revision_id);
|
||||
$this->assertFalse($item->isDefaultRevision(), 'Field collection of non-default host entity is non-default too.');
|
||||
$this->assertEqual($item->hostEntityId(), $node->nid, 'Can access host entity ID of non-default field collection revision.');
|
||||
$this->assertEqual($item->hostEntity()->vid, $vid, 'Loaded non-default host entity revision.');
|
||||
|
||||
// Delete the non-default revision and make sure the field collection item
|
||||
// revision has been deleted too.
|
||||
entity_revision_delete('node', $vid);
|
||||
$this->assertFalse(entity_revision_load('node', $vid), 'Host entity revision deleted.');
|
||||
$this->assertFalse(entity_revision_load('field_collection_item', $item_revision_id), 'Field collection item revision deleted.');
|
||||
|
||||
// Test having archived field collections, i.e. collections referenced only
|
||||
// in non-default revisions.
|
||||
list ($node, $item) = $this->createNodeWithFieldCollection();
|
||||
// Create two revisions.
|
||||
$node_vid = $node->vid;
|
||||
$node->revision = TRUE;
|
||||
node_save($node);
|
||||
|
||||
$node_vid2 = $node->vid;
|
||||
$node->revision = TRUE;
|
||||
node_save($node);
|
||||
|
||||
// Now delete the field collection item for the default revision.
|
||||
$item = field_collection_item_load($node->{$this->field_name}[LANGUAGE_NONE][0]['value']);
|
||||
$item_revision_id = $item->revision_id;
|
||||
$item->deleteRevision();
|
||||
$node = node_load($node->nid);
|
||||
$this->assertTrue(!isset($node->{$this->field_name}[LANGUAGE_NONE][0]), 'Field collection item revision removed from host.');
|
||||
$this->assertFalse(field_collection_item_revision_load($item->revision_id), 'Field collection item default revision deleted.');
|
||||
|
||||
$item = field_collection_item_load($item->item_id);
|
||||
$this->assertNotEqual($item->revision_id, $item_revision_id, 'Field collection default revision has been updated.');
|
||||
$this->assertTrue($item->archived, 'Field collection item has been archived.');
|
||||
$this->assertFalse($item->isInUse(), 'Field collection item specified as not in use.');
|
||||
$this->assertTrue($item->isDefaultRevision(), 'Field collection of non-default host entity is default (but archived).');
|
||||
$this->assertEqual($item->hostEntityId(), $node->nid, 'Can access host entity ID of non-default field collection revision.');
|
||||
$this->assertEqual($item->hostEntity()->nid, $node->nid, 'Loaded non-default host entity revision.');
|
||||
|
||||
// Test deleting a revision of an archived field collection.
|
||||
$node_revision2 = node_load($node->nid, $node_vid2);
|
||||
$item = field_collection_item_revision_load($node_revision2->{$this->field_name}[LANGUAGE_NONE][0]['revision_id']);
|
||||
$item->deleteRevision();
|
||||
// There should be one revision left, so the item should still exist.
|
||||
$item = field_collection_item_load($item->item_id);
|
||||
$this->assertTrue($item->archived, 'Field collection item is still archived.');
|
||||
$this->assertFalse($item->isInUse(), 'Field collection item specified as not in use.');
|
||||
|
||||
// Test that deleting the first node revision deletes the whole field
|
||||
// collection item as it contains its last revision.
|
||||
node_revision_delete($node_vid);
|
||||
$this->assertFalse(field_collection_item_load($item->item_id), 'Archived field collection deleted when last revision deleted.');
|
||||
|
||||
// Test that removing a field-collection item also deletes it.
|
||||
list ($node, $item) = $this->createNodeWithFieldCollection();
|
||||
|
||||
$node->{$this->field_name}[LANGUAGE_NONE] = array();
|
||||
$node->revision = FALSE;
|
||||
node_save($node);
|
||||
$this->assertFalse(field_collection_item_load($item->item_id), 'Removed field collection item has been deleted.');
|
||||
|
||||
// Test removing a field-collection item while creating a new host revision.
|
||||
list ($node, $item) = $this->createNodeWithFieldCollection();
|
||||
$node->{$this->field_name}[LANGUAGE_NONE] = array();
|
||||
$node->revision = TRUE;
|
||||
node_save($node);
|
||||
// Item should not be deleted but archived now.
|
||||
$item = field_collection_item_load($item->item_id);
|
||||
$this->assertTrue($item, 'Removed field collection item still exists.');
|
||||
$this->assertTrue($item->archived, 'Removed field collection item is archived.');
|
||||
|
||||
// Test removing an old node revision. Make sure that the field collection
|
||||
// is not removed
|
||||
list ($node, $item) = $this->createNodeWithFieldCollection();
|
||||
$node_vid = $node->vid;
|
||||
$node->revision = TRUE;
|
||||
node_save($node);
|
||||
$node_vid2 = $node->vid;
|
||||
$item_vid2 = $node->{$this->field_name}[LANGUAGE_NONE][0]['revision_id'];
|
||||
node_revision_delete($node_vid);
|
||||
$item2 = field_collection_item_revision_load($item_vid2);
|
||||
$item_id2 = isset($item2->item_id) ? $item2->item_id : -1;
|
||||
$this->assertEqual($item_id2, $item->item_id, 'Removing an old node revision does not delete newer field collection revisions');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure the basic UI and access checks are working.
|
||||
*/
|
||||
function testBasicUI() {
|
||||
// Add a field to the collection.
|
||||
$field = array(
|
||||
'field_name' => 'field_text',
|
||||
'type' => 'text',
|
||||
'cardinality' => 1,
|
||||
'translatable' => FALSE,
|
||||
);
|
||||
field_create_field($field);
|
||||
$instance = array(
|
||||
'entity_type' => 'field_collection_item',
|
||||
'field_name' => 'field_text',
|
||||
'bundle' => $this->field_name,
|
||||
'label' => 'Test text field',
|
||||
'widget' => array(
|
||||
'type' => 'text_textfield',
|
||||
),
|
||||
);
|
||||
field_create_instance($instance);
|
||||
|
||||
$user = $this->drupalCreateUser();
|
||||
$node = $this->drupalCreateNode(array('type' => 'article'));
|
||||
|
||||
$this->drupalLogin($user);
|
||||
// Make sure access is denied.
|
||||
$path = 'field-collection/field-test-collection/add/node/' . $node->nid;
|
||||
$this->drupalGet($path);
|
||||
$this->assertText(t('Access denied'), 'Access has been denied.');
|
||||
|
||||
$user_privileged = $this->drupalCreateUser(array('access content', 'edit any article content'));
|
||||
$this->drupalLogin($user_privileged);
|
||||
$this->drupalGet("node/$node->nid");
|
||||
$this->assertLinkByHref($path, 0, 'Add link is shown.');
|
||||
$this->drupalGet($path);
|
||||
$this->assertText(t('Test text field'), 'Add form is shown.');
|
||||
|
||||
$edit['field_text[und][0][value]'] = $this->randomName();
|
||||
$this->drupalPost($path, $edit, t('Save'));
|
||||
$this->assertText(t('The changes have been saved.'), 'Field collection saved.');
|
||||
|
||||
$this->assertText($edit['field_text[und][0][value]'], "Added field value is shown.");
|
||||
|
||||
$edit['field_text[und][0][value]'] = $this->randomName();
|
||||
$this->drupalPost('field-collection/field-test-collection/1/edit', $edit, t('Save'));
|
||||
$this->assertText(t('The changes have been saved.'), 'Field collection saved.');
|
||||
$this->assertText($edit['field_text[und][0][value]'], "Field collection has been edited.");
|
||||
|
||||
$this->drupalGet('field-collection/field-test-collection/1');
|
||||
$this->assertText($edit['field_text[und][0][value]'], "Field collection can be viewed.");
|
||||
|
||||
// Add further 3 items, so we have reached 4 == maxium cardinality.
|
||||
$this->drupalPost($path, $edit, t('Save'));
|
||||
$this->drupalPost($path, $edit, t('Save'));
|
||||
$this->drupalPost($path, $edit, t('Save'));
|
||||
// Make sure adding doesn't work any more as we have restricted cardinality
|
||||
// to 1.
|
||||
$this->drupalGet($path);
|
||||
$this->assertText(t('Too many items.'), 'Maxium cardinality has been reached.');
|
||||
|
||||
$this->drupalPost('field-collection/field-test-collection/1/delete', array(), t('Delete'));
|
||||
$this->drupalGet($path);
|
||||
// Add form is shown again.
|
||||
$this->assertText(t('Test text field'), 'Field collection item has been deleted.');
|
||||
|
||||
// Test the viewing a revision. There should be no links to change it.
|
||||
$vid = $node->vid;
|
||||
$node = node_load($node->nid, NULL, TRUE);
|
||||
$node->revision = TRUE;
|
||||
node_save($node);
|
||||
|
||||
$this->drupalGet("node/$node->nid/revisions/$vid/view");
|
||||
$this->assertResponse(403, 'Access to view revision denied');
|
||||
// Login in as admin and try again.
|
||||
$user = $this->drupalCreateUser(array('administer nodes', 'bypass node access'));
|
||||
$this->drupalLogin($user);
|
||||
$this->drupalGet("node/$node->nid/revisions/$vid/view");
|
||||
$this->assertNoResponse(403, 'Access to view revision granted');
|
||||
|
||||
$this->assertNoLinkByHref($path, 'No links on revision view.');
|
||||
$this->assertNoLinkByHref('field-collection/field-test-collection/2/edit', 'No links on revision view.');
|
||||
$this->assertNoLinkByHref('field-collection/field-test-collection/2/delete', 'No links on revision view.');
|
||||
|
||||
$this->drupalGet("node/$node->nid/revisions");
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure that field_collection-entities are copied when host-entities do.
|
||||
*/
|
||||
public function testCopyingEntities() {
|
||||
list($node, $entity) = $this->createNodeWithFieldCollection();
|
||||
|
||||
// Create a copy of that node.
|
||||
$node->nid = NULL;
|
||||
$node->vid = NULL;
|
||||
$node->is_new = TRUE;
|
||||
|
||||
node_save($node);
|
||||
$item = $node->{$this->field_name}[LANGUAGE_NONE][0];
|
||||
$this->assertNotEqual($entity->item_id, $item['value']);
|
||||
|
||||
// Do a php clone to the $node object and save it.
|
||||
$node2 = clone $node;
|
||||
$node2->nid = NULL;
|
||||
$node2->is_new = TRUE;
|
||||
$node2->vid = NULL;
|
||||
node_save($node2);
|
||||
|
||||
$item2 = $node2->{$this->field_name}[LANGUAGE_NONE][0];
|
||||
$this->assertNotEqual($item2['value'], $item['value']);
|
||||
|
||||
// Create another copy this time (needlessly) forcing a new revision.
|
||||
$node->nid = NULL;
|
||||
$node->vid = NULL;
|
||||
$node->is_new = TRUE;
|
||||
$node->revision = TRUE;
|
||||
node_save($node);
|
||||
$item3 = $node->{$this->field_name}[LANGUAGE_NONE][0];
|
||||
$this->assertNotEqual($item['value'], $item3['value']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test using field collection with Rules.
|
||||
*/
|
||||
class FieldCollectionRulesIntegrationTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Field collection Rules integration',
|
||||
'description' => 'Tests using field collections with rules.',
|
||||
'group' => 'Field types',
|
||||
'dependencies' => array('rules'),
|
||||
);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
parent::setUp(array('field_collection', 'rules'));
|
||||
variable_set('rules_debug_log', 1);
|
||||
}
|
||||
|
||||
protected function createFields($cardinality = 4) {
|
||||
// Create a field_collection field to use for the tests.
|
||||
$this->field_name = 'field_test_collection';
|
||||
$this->field = array('field_name' => $this->field_name, 'type' => 'field_collection', 'cardinality' => $cardinality);
|
||||
$this->field = field_create_field($this->field);
|
||||
$this->field_id = $this->field['id'];
|
||||
|
||||
$this->instance = array(
|
||||
'field_name' => $this->field_name,
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'article',
|
||||
'label' => $this->randomName() . '_label',
|
||||
'description' => $this->randomName() . '_description',
|
||||
'weight' => mt_rand(0, 127),
|
||||
'settings' => array(),
|
||||
'widget' => array(
|
||||
'type' => 'hidden',
|
||||
'label' => 'Test',
|
||||
'settings' => array(),
|
||||
),
|
||||
);
|
||||
$this->instance = field_create_instance($this->instance);
|
||||
// Add a field to the collection.
|
||||
$field = array(
|
||||
'field_name' => 'field_text',
|
||||
'type' => 'text',
|
||||
'cardinality' => 1,
|
||||
'translatable' => FALSE,
|
||||
);
|
||||
field_create_field($field);
|
||||
$instance = array(
|
||||
'entity_type' => 'field_collection_item',
|
||||
'field_name' => 'field_text',
|
||||
'bundle' => $this->field_name,
|
||||
'label' => 'Test text field',
|
||||
'widget' => array(
|
||||
'type' => 'text_textfield',
|
||||
),
|
||||
);
|
||||
field_create_instance($instance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test creation field collection items.
|
||||
*/
|
||||
function testCreation() {
|
||||
$this->createFields();
|
||||
|
||||
$node = $this->drupalCreateNode(array('type' => 'article'));
|
||||
// Create a field collection.
|
||||
$action_set = rules_action_set(array('node' => array('type' => 'node', 'bundle' => 'article')));
|
||||
$action_set->action('entity_create', array(
|
||||
'type' => 'field_collection_item',
|
||||
'param_field_name' => $this->field_name,
|
||||
'param_host_entity:select' => 'node',
|
||||
));
|
||||
$action_set->action('data_set', array('data:select' => 'entity-created:field-text', 'value' => 'foo'));
|
||||
$action_set->execute($node);
|
||||
|
||||
$node = node_load($node->nid, NULL, TRUE);
|
||||
$this->assertTrue(!empty($node->{$this->field_name}[LANGUAGE_NONE][0]['value']), 'A field_collection has been successfully created.');
|
||||
$this->assertTrue(!empty($node->{$this->field_name}[LANGUAGE_NONE][0]['revision_id']), 'A field_collection has been successfully created (revision).');
|
||||
|
||||
// Now try making use of the field collection in rules.
|
||||
$action_set = rules_action_set(array('node' => array('type' => 'node', 'bundle' => 'article')));
|
||||
$action_set->action('drupal_message', array('message:select' => 'node:field-test-collection:0:field-text'));
|
||||
$action_set->execute($node);
|
||||
|
||||
$msg = drupal_get_messages();
|
||||
$this->assertEqual(array_pop($msg['status']), 'foo', 'Field collection can be used.');
|
||||
RulesLog::logger()->checkLog();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test using field collection items via the host while they are being created.
|
||||
*/
|
||||
function testUsageDuringCreation() {
|
||||
// Test using a single-cardinality field collection.
|
||||
$this->createFields(1);
|
||||
|
||||
$node = $this->drupalCreateNode(array('type' => 'article'));
|
||||
$entity = entity_create('field_collection_item', array('field_name' => $this->field_name));
|
||||
$entity->setHostEntity('node', $node);
|
||||
// Now the field collection is linked to the host, but not yet saved.
|
||||
|
||||
// Test using the wrapper on it.
|
||||
$wrapper = entity_metadata_wrapper('node', $node);
|
||||
$wrapper->get($this->field_name)->field_text->set('foo');
|
||||
$this->assertEqual($entity->field_text[LANGUAGE_NONE][0]['value'], 'foo', 'Field collection item used during creation via the wrapper.');
|
||||
|
||||
// Now test it via Rules, which should save our changes.
|
||||
$set = rules_action_set(array('node' => array('type' => 'node', 'bundle' => 'article')));
|
||||
$set->action('data_set', array('data:select' => 'node:' . $this->field_name . ':field-text', 'value' => 'bar'));
|
||||
$set->execute($node);
|
||||
$this->assertEqual($entity->field_text[LANGUAGE_NONE][0]['value'], 'bar', 'Field collection item used during creation via Rules.');
|
||||
$this->assertTrue(!empty($entity->item_id) && !empty($entity->revision_id), 'Field collection item has been saved by Rules and the host entity.');
|
||||
RulesLog::logger()->checkLog();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test using field collection with content that gets translated.
|
||||
*/
|
||||
class FieldCollectionContentTranslationTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Field collection content translation',
|
||||
'description' => 'Tests using content under translation.',
|
||||
'group' => 'Field types',
|
||||
'dependencies' => array('translation'),
|
||||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp(array('field_collection', 'translation'));
|
||||
// Create a field_collection field to use for the tests.
|
||||
$this->field_name = 'field_test_collection';
|
||||
$this->field = array('field_name' => $this->field_name, 'type' => 'field_collection', 'cardinality' => 4);
|
||||
$this->field = field_create_field($this->field);
|
||||
$this->field_id = $this->field['id'];
|
||||
|
||||
$this->instance = array(
|
||||
'field_name' => $this->field_name,
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'article',
|
||||
'label' => $this->randomName() . '_label',
|
||||
'description' => $this->randomName() . '_description',
|
||||
'weight' => mt_rand(0, 127),
|
||||
'settings' => array(),
|
||||
'widget' => array(
|
||||
'type' => 'field_collection_embed',
|
||||
'label' => 'Test',
|
||||
'settings' => array(),
|
||||
),
|
||||
);
|
||||
$this->instance = field_create_instance($this->instance);
|
||||
|
||||
// Add a field to the collection.
|
||||
$field = array(
|
||||
'field_name' => 'field_text',
|
||||
'type' => 'text',
|
||||
'cardinality' => 1,
|
||||
'translatable' => FALSE,
|
||||
);
|
||||
field_create_field($field);
|
||||
$instance = array(
|
||||
'entity_type' => 'field_collection_item',
|
||||
'field_name' => 'field_text',
|
||||
'bundle' => $this->field_name,
|
||||
'label' => 'Test text field',
|
||||
'widget' => array(
|
||||
'type' => 'text_textfield',
|
||||
),
|
||||
);
|
||||
field_create_instance($instance);
|
||||
|
||||
$admin_user = $this->drupalCreateUser(array('administer languages', 'administer content types', 'access administration pages', 'create article content', 'edit any article content', 'translate content'));
|
||||
|
||||
$this->drupalLogin($admin_user);
|
||||
// Add German language.
|
||||
locale_add_language('de');
|
||||
|
||||
// Set "Article" content type to use multilingual support.
|
||||
variable_set('language_content_type_article', TRANSLATION_ENABLED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure field collections are cloned to new entities on content translation.
|
||||
*/
|
||||
public function testContentTranslation() {
|
||||
// Create "Article" content.
|
||||
$edit['title'] = $this->randomName();
|
||||
$edit['body[' . LANGUAGE_NONE . '][0][value]'] = $this->randomName();
|
||||
$edit['language'] = 'en';
|
||||
$field_collection_name = 'field_test_collection[' . LANGUAGE_NONE . '][0][field_text][' . LANGUAGE_NONE . '][0][value]';
|
||||
$edit[$field_collection_name] = $this->randomName();
|
||||
|
||||
$this->drupalPost('node/add/article', $edit, t('Save'));
|
||||
$this->assertRaw(t('Article %title has been created.', array('%title' => $edit['title'])), 'Article created.');
|
||||
$node1 = $this->drupalGetNodeByTitle($edit['title']);
|
||||
|
||||
$this->drupalGet('node/' . $node1->nid . '/edit');
|
||||
$this->drupalGet('node/' . $node1->nid . '/translate');
|
||||
$this->drupalGet('node/add/article', array('query' => array('translation' => $node1->nid, 'target' => 'de')));
|
||||
|
||||
// Suffix translations with the langcode.
|
||||
unset($edit['language']);
|
||||
$edit['title'] .= 'DE';
|
||||
$edit[$field_collection_name] .= 'DE';
|
||||
$this->drupalPost('node/add/article', $edit, t('Save'), array('query' => array('translation' => $node1->nid, 'target' => 'de')));
|
||||
$node2 = $this->drupalGetNodeByTitle($edit['title']);
|
||||
|
||||
// Ensure that our new node is the translation of the first one.
|
||||
$this->assertEqual($node1->nid, $node2->tnid, 'Succesfully created translation.');
|
||||
// And check to see that their field collections are different.
|
||||
$this->assertNotEqual($node1->field_test_collection, $node2->field_test_collection, 'Field collections between translation source and translation differ.');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
@CHARSET "UTF-8";
|
||||
|
||||
.field-collection-container {
|
||||
border-bottom: 1px solid #D3D7D9;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.field-collection-container .field-items .field-item {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.field-collection-container .field-items .field-items .field-item {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.field-collection-view {
|
||||
padding: 1em 0 0.3em 0;
|
||||
margin: 0 1em 0 1em;
|
||||
border-bottom: 1px dotted #D3D7D9;
|
||||
}
|
||||
|
||||
/* If there is no add link, don't show the final border. */
|
||||
.field-collection-view-final {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.field-collection-view .entity-field-collection-item {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.field-collection-view ul.field-collection-view-links {
|
||||
float: right;
|
||||
font-size: 0.821em;
|
||||
list-style-type: none;
|
||||
width: auto;
|
||||
margin: 0 1em;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.field-collection-view .field-label {
|
||||
width: 25%;
|
||||
}
|
||||
|
||||
.field-collection-view .content {
|
||||
margin-top: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.field-collection-view .entity-field-collection-item {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
ul.field-collection-view-links li {
|
||||
float: left;
|
||||
}
|
||||
|
||||
ul.field-collection-view-links li a {
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
.field-collection-container ul.action-links-field-collection-add {
|
||||
float: right;
|
||||
padding: 0 0.5em 0 0;
|
||||
margin: 0 0 1em 2em;
|
||||
font-size: 0.821em;
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Views integration for field collection fields.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_field_views_data().
|
||||
*
|
||||
* Adds a relationship to the default field data.
|
||||
*
|
||||
* @see field_views_field_default_views_data()
|
||||
*/
|
||||
function field_collection_field_views_data($field) {
|
||||
$data = field_views_field_default_views_data($field);
|
||||
$field_name = $field['field_name'];
|
||||
|
||||
if (isset($data['field_data_' . $field_name])) {
|
||||
$data['field_data_' . $field_name][$field_name . '_value']['relationship'] = array(
|
||||
'handler' => 'field_collection_handler_relationship',
|
||||
'base' => 'field_collection_item',
|
||||
'base field' => 'item_id',
|
||||
'label' => t('field collection item from !field_name', array('!field_name' => $field['field_name'])),
|
||||
'field_name' => $field['field_name'],
|
||||
);
|
||||
$data['field_revision_' . $field_name][$field_name . '_revision_id']['relationship'] = array(
|
||||
'handler' => 'field_collection_handler_relationship',
|
||||
'base' => 'field_collection_item_revision',
|
||||
'base field' => 'revision_id',
|
||||
'label' => t('field collection item revision from !field_name', array('!field_name' => $field['field_name'])),
|
||||
'field_name' => $field['field_name'],
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($field['bundles'] as $entity_type => $bundles) {
|
||||
$entity_info = entity_get_info($entity_type);
|
||||
$pseudo_field_name = $field['field_name'] . '_' . $entity_type;
|
||||
|
||||
list($label, $all_labels) = field_views_field_label($field['field_name']);
|
||||
$entity = $entity_info['label'];
|
||||
if ($entity == t('Node')) {
|
||||
$entity = t('Content');
|
||||
}
|
||||
|
||||
$data['field_collection_item'][$pseudo_field_name]['relationship'] = array(
|
||||
'title' => t('Entity with the @field (@field_name)', array('@entity' => $entity, '@field' => $label, '@field_name' => $field['field_name'])),
|
||||
'help' => t('Relate each @entity using @field.', array('@entity' => $entity, '@field' => $label)),
|
||||
'handler' => 'views_handler_relationship_entity_reverse',
|
||||
'field_name' => $field['field_name'],
|
||||
'field table' => _field_sql_storage_tablename($field),
|
||||
'field field' => $field['field_name'] . '_value',
|
||||
'base' => $entity_info['base table'],
|
||||
'base field' => $entity_info['entity keys']['id'],
|
||||
'label' => t('!field_name', array('!field_name' => $field['field_name'])),
|
||||
);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provide relationship handler for field collection fields.
|
||||
*/
|
||||
class field_collection_handler_relationship extends views_handler_relationship {
|
||||
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['delta'] = array('default' => -1);
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a delta selector for multiple fields.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
$field = field_info_field($this->definition['field_name']);
|
||||
|
||||
// Only add the delta selector if the field is multiple.
|
||||
if ($field['cardinality']) {
|
||||
$max_delta = ($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED) ? 10 : $field['cardinality'];
|
||||
|
||||
$options = array('-1' => t('All'));
|
||||
for ($i = 0; $i < $max_delta; $i++) {
|
||||
$options[$i] = $i + 1;
|
||||
}
|
||||
$form['delta'] = array(
|
||||
'#type' => 'select',
|
||||
'#options' => $options,
|
||||
'#default_value' => $this->options['delta'],
|
||||
'#title' => t('Delta'),
|
||||
'#description' => t('The delta allows you to select which item in a multiple value field to key the relationship off of. Select "1" to use the first item, "2" for the second item, and so on. If you select "All", each item in the field will create a new row, which may appear to cause duplicates.'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function ensure_my_table() {
|
||||
$field = field_info_field($this->definition['field_name']);
|
||||
|
||||
if (!isset($this->table_alias)) {
|
||||
$join = $this->get_join();
|
||||
if ($this->options['delta'] != -1 && $field['cardinality']) {
|
||||
$join->extra[] = array(
|
||||
'field' => 'delta',
|
||||
'value' => $this->options['delta'],
|
||||
'numeric' => TRUE,
|
||||
);
|
||||
}
|
||||
$this->table_alias = $this->query->add_table($this->table, $this->relationship, $join);
|
||||
}
|
||||
return $this->table_alias;
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
sites/all/modules/contrib/fields/video_embed_field/plugins/export_ui/video_embed_field_export_ui.inc
Executable
+26
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Define this Export UI plugin.
|
||||
*/
|
||||
$plugin = array(
|
||||
'schema' => 'vef_video_styles', // As defined in hook_schema().
|
||||
'access' => 'administer video styles', // Define a permission users must have to access these pages.
|
||||
// Define the menu item.
|
||||
'menu' => array(
|
||||
'menu prefix' => 'admin/config/media',
|
||||
'menu item' => 'vef_video_styles',
|
||||
'menu title' => 'Configure Video Embed Styles',
|
||||
'menu description' => 'Administer Video Embed Field\'s video styles.',
|
||||
),
|
||||
// Define user interface texts.
|
||||
'title singular' => t('video style'),
|
||||
'title plural' => t('video styles'),
|
||||
'title singular proper' => t('Video Styles'),
|
||||
'title plural proper' => t('Video Styles'),
|
||||
// Define the names of the functions that provide the add/edit forms.
|
||||
'form' => array(
|
||||
'settings' => 'video_embed_field_video_style_form',
|
||||
// 'submit' and 'validate' are also valid callbacks.
|
||||
),
|
||||
);
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Default theme implementation to display a video embed field.
|
||||
*
|
||||
* Variables available:
|
||||
* - $url: The URL of the video to display embed code for
|
||||
* - $style: The style name of the embed code to use
|
||||
* - $style_settings: The style settings for the embed code
|
||||
* - $handler: The name of the video handler
|
||||
* - $embed_code: The embed code
|
||||
* - $data: Additional video data
|
||||
*
|
||||
* @see template_preprocess_video_embed()
|
||||
*/
|
||||
?>
|
||||
|
||||
<div class="embedded-video">
|
||||
<div class="player">
|
||||
<?php print $embed_code; ?>
|
||||
</div>
|
||||
</div>
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
name = "Video Embed Facebook"
|
||||
description = "Provides Facebook handler for Video Embed Fields. This module also serves as an example of how to add handlers to video embed field."
|
||||
core = 7.x
|
||||
package = Media
|
||||
configure = admin/config/media/vef_video_styles
|
||||
|
||||
dependencies[] = "video_embed_field"
|
||||
; Information added by drupal.org packaging script on 2012-10-17
|
||||
version = "7.x-2.0-beta5+11-dev"
|
||||
core = "7.x"
|
||||
project = "video_embed_field"
|
||||
datestamp = "1350438417"
|
||||
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
/**
|
||||
* @file Add a handler for facebook videos to Video Embed Field.
|
||||
* @see video_embed_field.api.php for more documentation
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_video_embed_handler_info().
|
||||
*
|
||||
* This function is used to tell video_embed_field which functions will be used to handle
|
||||
* different operations, along with a bit of metadata.
|
||||
* @return an associative array with the data
|
||||
* @see video_embed_field.api.php for specific details on the data to return.
|
||||
*/
|
||||
function video_embed_facebook_video_embed_handler_info() {
|
||||
$handlers = array();
|
||||
//the key here should be unique to our handler, normally the name of the service will suffice
|
||||
$handlers['facebook'] = array(
|
||||
'title' => 'Facebook Video', //The title is the name to show to users
|
||||
//function is a function to take the url and return the embed code
|
||||
'function' => 'video_embed_facebook_handle_video',
|
||||
//thumbnail_function is optional and takes the url and returns the thumbnail url
|
||||
'thumbnail_function' => 'video_embed_facebook_handle_thumbnail',
|
||||
//data_function is optional and returns an array of extra data for the given video url
|
||||
//because facebook requires oath to get this data, we'll leave it out for now
|
||||
//'data_function' => 'video_embed_facebook_handle_data',
|
||||
//form is the configure form to embed into video_embed styles - this is where all settings should go
|
||||
'form' => 'video_embed_facebook_form',
|
||||
//domains is how video embed determines which handler to use, its an array of domains to match
|
||||
//urls against. Don't include the scheme (like http://) or www.
|
||||
'domains' => array(
|
||||
'facebook.com',
|
||||
),
|
||||
//defaults are the defaults to provide to your form (as defined in your form callback)
|
||||
'defaults' => array(
|
||||
'width' => 640,
|
||||
'height' => 360,
|
||||
'allowfullscreen' => TRUE,
|
||||
),
|
||||
);
|
||||
|
||||
return $handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Our configuration form (the callback for the form key in info)
|
||||
* Provide a form to configure out video settings
|
||||
* @param $defaults - default/current values for your provider, the currently saved settings
|
||||
* with empty values filled with the defaults provided in info hook
|
||||
* @return a form as defined by forms api
|
||||
*/
|
||||
function video_embed_facebook_form($defaults) {
|
||||
$form = array();
|
||||
//form element for the width of the player - note we're using the default from defaults
|
||||
$form['height'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Player Width'),
|
||||
'#description' => t('The width of the player.'),
|
||||
'#default_value' => $defaults['height'],
|
||||
);
|
||||
//element for width
|
||||
$form['width'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Player Width'),
|
||||
'#description' => t('The width of the player.'),
|
||||
'#default_value' => $defaults['width'],
|
||||
);
|
||||
//allow configuration of fullscreen
|
||||
$form['allowfullscreen'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Allow Fullscreen'),
|
||||
'#desecription' => t('This will allow the video to be fullscreened.'),
|
||||
'#default_value' => $defaults['allowfullscreen'],
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This is the video handler (the 'function' key from handler_info)
|
||||
* @param $url - the full video url
|
||||
* @param $settings - an associative array of this handlers settings, from the settings form
|
||||
* @return - the embed code for the video
|
||||
*/
|
||||
function video_embed_facebook_handle_video($url, $settings) {
|
||||
$id = _video_embed_facebook_get_video_id($url);
|
||||
|
||||
if ($id) {
|
||||
//our embed code
|
||||
$embed = '<object>
|
||||
<param name="allowfullscreen" value="!fullscreen" />
|
||||
<param name="allowscriptaccess" value="always" />
|
||||
<param name="movie" value="https://www.facebook.com/v/!id" />
|
||||
<param name="wmode" value="opaque" />
|
||||
<embed src="https://www.facebook.com/v/!id" type="application/x-shockwave-flash" wmode="opaque"
|
||||
allowscriptaccess="always" allowfullscreen="!fullscreen" width="!width" height="!height">
|
||||
</embed>
|
||||
</object>';
|
||||
//use format_string to replace our placeholders with the values from the settings
|
||||
$embed = format_string($embed, array(
|
||||
'!id' => $id,
|
||||
'!fullscreen' => $settings['allowfullscreen'] ? 'true' : 'false',
|
||||
'!width' => $settings['width'],
|
||||
'!height' => $settings['height'],
|
||||
));
|
||||
//we want to return a render array
|
||||
$video = array(
|
||||
'#markup' => $embed,
|
||||
);
|
||||
return $video;
|
||||
}
|
||||
// just return an empty string if there is no id, so we don't have broken embeds showing up
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Retreive the thumbnail for the facebook video - note that based on a users permissions, this may be
|
||||
* the facebook unknown thumbnail: https://s-static.ak.facebook.com/rsrc.php/v1/y0/r/XsEg9L6Ie5_.jpg
|
||||
* @param $url - the url of the video as entered by the user
|
||||
* @return an array with the keys:
|
||||
* 'id' => an id for the video which is unique to your provider, used for naming the cached thumbnail file
|
||||
* 'url' => the url to retrieve the thumbnail from
|
||||
*/
|
||||
function video_embed_facebook_handle_thumbnail($url) {
|
||||
$id = _video_embed_facebook_get_video_id($url);
|
||||
// We're using a part of the graphs api to return the thumbnail. This only works for some videos
|
||||
return array(
|
||||
'id' => $id, //generally the id that the provider uses for the video
|
||||
'url' => 'https://graph.facebook.com/' . $id . '/picture', //the url of the thumbnail
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to take a facebook video url and return its id
|
||||
* @param $url - the full facebook video url
|
||||
* @return the id for the video
|
||||
*/
|
||||
function _video_embed_facebook_get_video_id($url) {
|
||||
//parse_url is an easy way to break a url into its components
|
||||
$matches = array();
|
||||
preg_match('/(.*)?v=([^&#]*)/', $url, $matches);
|
||||
//if the v get parameter is set, return it
|
||||
if ($matches && !empty($matches[2])) {
|
||||
return $matches[2];
|
||||
}
|
||||
//otherwise return false.
|
||||
return FALSE;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Form builder; Form for editing a video style.
|
||||
* Used by CTools export ui
|
||||
*
|
||||
* @ingroup forms
|
||||
* @see video_embed_field_video_style_form_submit()
|
||||
*/
|
||||
function video_embed_field_video_style_form(&$form, &$form_state) {
|
||||
if (isset($form_state['item'])) {
|
||||
$style = (array) $form_state['item'];
|
||||
}
|
||||
else {
|
||||
$style = array();
|
||||
}
|
||||
$form_state['video_style'] = $style;
|
||||
|
||||
//Grab the settings off the parser form
|
||||
$values = isset($style['data']) ? $style['data'] : array();
|
||||
$parser_form = video_embed_field_get_form($values);
|
||||
|
||||
//General settings for playback - formerly in the configuration section
|
||||
$form['data'] = array(
|
||||
'#type' => 'vertical_tabs',
|
||||
'#title' => t('Playback settings'),
|
||||
'#tree' => TRUE,
|
||||
) + $parser_form; //add in our extra settings
|
||||
|
||||
return $form;
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* API Info for video_embed_field module
|
||||
*/
|
||||
|
||||
/**
|
||||
* @function hook_video_embed_handler_info
|
||||
* Can be used to add more handlers for video_embed_field
|
||||
* @return an array of handlers, each handler is an array with the following keys
|
||||
* 'title' : required, the untranslated title of the provider, to show to the admin user
|
||||
* 'function' : required, the function used to generate the embed code
|
||||
* 'thumbnail_function' : optional, the function used to provide the thumbnail for a video
|
||||
* 'data_function' : optional, the function to return an array of video data.
|
||||
* 'form' : required, the function that returns the settings form for your provider
|
||||
* 'domains' : required, an array of domains to match against, this is used to know which provider to use
|
||||
* 'defaults' : default values for each setting made configurable in your form function
|
||||
*
|
||||
* @see below for function definitions
|
||||
*/
|
||||
function hook_video_embed_handler_info() {
|
||||
$handlers = array();
|
||||
|
||||
$handlers['ustream'] = array(
|
||||
'title' => 'UStream',
|
||||
'function' => 'your_module_handle_ustream',
|
||||
'thumbnail_function' => 'your_module_handle_ustream_thumbnail',
|
||||
'data_function' => 'your_module_handler_ustream_data',
|
||||
'form' => 'your_module_handler_ustream_form',
|
||||
'domains' => array(
|
||||
'ustream.com',
|
||||
),
|
||||
'defaults' => array(
|
||||
'width' => 640,
|
||||
'height' => 360,
|
||||
),
|
||||
);
|
||||
|
||||
return $handlers;
|
||||
}
|
||||
|
||||
// Example callbacks for a provider (in this case for ustream) - obviously, these functions are only for example
|
||||
// purposes
|
||||
|
||||
/**
|
||||
* Generate the embed code for a video
|
||||
* @param $url - the video url as entered by the user
|
||||
* @param $settings - the settings for this provider as defined in the form function,
|
||||
* defaulting to your provider's defaults
|
||||
* @return the embed code as a renderable array
|
||||
*/
|
||||
function your_module_handle_ustream($url, $settings) {
|
||||
return array(
|
||||
//this should be the full embed code for your provider, including each of the settings
|
||||
'#markup' => '<iframe src="ustream"></iframe>',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve information about the thumbnail for a given url
|
||||
* @param $url - the url of the video as entered by the user
|
||||
* @return an array with the keys:
|
||||
* 'id' => an id for the video which is unique to your provider, used for naming the cached thumbnail file
|
||||
* 'url' => the url to retrieve the thumbnail from
|
||||
*/
|
||||
function your_module_handle_ustream_thumbnail($url) {
|
||||
return array(
|
||||
'id' => '12332243242', //generally the id that the provider uses for the video
|
||||
'url' => 'http://something/thumbnail/somthing.jpg', //the url of the thumbnail
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* A forms api callback, returns the settings form for the provider
|
||||
* @param $defaults - default/current values for your provider, the currently saved settings
|
||||
* with empty values filled with the defaults provided in info hook
|
||||
* @return a form as defined by forms api
|
||||
*
|
||||
* @see http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7
|
||||
*/
|
||||
function your_module_handler_ustream_form($defaults) {
|
||||
$form = array();
|
||||
|
||||
$form['width'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Player Width'),
|
||||
'#description' => t('The width of the player in pixels'),
|
||||
'#default_value' => $defaults['width'],
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of extra data to be stored with the video, this data will be available for theming
|
||||
* @return an array
|
||||
*/
|
||||
function your_module_handler_ustream_data($url) {
|
||||
return array();
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* On behalf implementation of Feeds mapping API for video_embed_field.module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_feeds_processor_targets_alter().
|
||||
*
|
||||
* @see FeedsNodeProcessor::getMappingTargets().
|
||||
*/
|
||||
function video_embed_field_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_name) {
|
||||
foreach (field_info_instances($entity_type, $bundle_name) as $name => $instance) {
|
||||
$info = field_info_field($name);
|
||||
if ($info['type'] == 'video_embed_field') {
|
||||
$targets[$name] = array(
|
||||
'name' => $instance['label'],
|
||||
'callback' => 'video_embed_field_set_target',
|
||||
'description' => t('The @label field of the node.', array('@label' => $instance['label'])),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for mapping. Here is where the actual mapping happens.
|
||||
*
|
||||
* When the callback is invoked, $target contains the name of the field the
|
||||
* user has decided to map to and $value contains the value of the feed item
|
||||
* element the user has picked as a source.
|
||||
*/
|
||||
function video_embed_field_set_target($source, $entity, $target, $value) {
|
||||
if (empty($value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$field = isset($entity->$target) ? $entity->$target : array();
|
||||
if (!is_array($value) && !is_object($value)) {
|
||||
$field['und'][0]['video_url'] = $value;
|
||||
}
|
||||
$entity->{$target} = $field;
|
||||
|
||||
}
|
||||
+443
@@ -0,0 +1,443 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Implement a video field.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_field_info().
|
||||
*/
|
||||
function video_embed_field_field_info() {
|
||||
return array(
|
||||
'video_embed_field' => array(
|
||||
'label' => 'Video Embed',
|
||||
'description' => 'Embed videos from youtube or vimeo',
|
||||
'settings' => array(),
|
||||
'instance_settings' => array(
|
||||
'description_field' => 0,
|
||||
'description_length' => 128,
|
||||
),
|
||||
'default_widget' => 'video_embed_field_video',
|
||||
'default_formatter' => 'video_embed_field',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_instance_settings_form().
|
||||
*/
|
||||
function video_embed_field_field_instance_settings_form($field, $instance) {
|
||||
$settings = $instance['settings'];
|
||||
|
||||
$form['description_field'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Enable <em>Description</em> field'),
|
||||
'#default_value' => isset($settings['description_field']) ? $settings['description_field'] : '',
|
||||
'#description' => t('The description field allows users to enter a description about the video.'),
|
||||
'#parents' => array('instance', 'settings', 'description_field'),
|
||||
'#weight' => 11,
|
||||
);
|
||||
|
||||
$form['description_length'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Max description length'),
|
||||
'#default_value' => isset($settings['description_length']) ? $settings['description_length'] : 128,
|
||||
'#parents' => array('instance', 'settings', 'description_length'),
|
||||
'#weight' => 12,
|
||||
'#size' => 5,
|
||||
'#maxlength' => 5,
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_widget_info().
|
||||
*/
|
||||
function video_embed_field_field_widget_info() {
|
||||
return array(
|
||||
'video_embed_field_video' => array(
|
||||
'label' => 'Video',
|
||||
'description' => 'Provides a video embed field',
|
||||
'field types' => array('video_embed_field'),
|
||||
'settings' => array(),
|
||||
'behaviors' => array(
|
||||
'multiple values' => FIELD_BEHAVIOR_DEFAULT,
|
||||
'default value' => FIELD_BEHAVIOR_DEFAULT,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_widget_form().
|
||||
*/
|
||||
function video_embed_field_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
|
||||
// Don't need to check the type right now because we're only defining one
|
||||
$element += array(
|
||||
'#type' => 'fieldset',
|
||||
);
|
||||
|
||||
$element['video_url'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Video URL'),
|
||||
'#attributes' => array('class' => array('video_embed_url')),
|
||||
'#attached' => array(
|
||||
'css' => array(
|
||||
drupal_get_path('module', 'video_embed_field') . '/video_embed_field.form.css',
|
||||
),
|
||||
),
|
||||
'#default_value' => isset($items[$delta]['video_url']) ? $items[$delta]['video_url'] : '',
|
||||
'#required' => $element['#required'],
|
||||
);
|
||||
|
||||
// Add the description field if enabled.
|
||||
if (!empty($instance['settings']['description_field'])) {
|
||||
$element['description'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Description'),
|
||||
'#default_value' => isset($items[$delta]['description']) ? $items[$delta]['description'] : '',
|
||||
'#description' => t('The description which may be used as a label.'),
|
||||
'#maxlength' => $instance['settings']['description_length'],
|
||||
);
|
||||
}
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates video URL.
|
||||
*/
|
||||
function video_embed_field_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
|
||||
foreach ($items as $delta => $item) {
|
||||
if (!empty($item['video_url'])) {
|
||||
$item['video_url'] = trim($item['video_url']);
|
||||
if (stristr($item['video_url'], '.') && !stristr($item['video_url'], 'http://') && !stristr($item['video_url'], 'https://')) {
|
||||
$item['video_url'] = 'http://' . $item['video_url'];
|
||||
}
|
||||
|
||||
$parts = parse_url($item['video_url']);
|
||||
if (!$parts || !isset($parts['host'])) {
|
||||
$errors[$field['field_name']][$langcode][$delta][] = array(
|
||||
'error' => t('Invalid Url'),
|
||||
'message' => t('Video: Invalid Video URL.', array('%name' => $instance['label'])),
|
||||
);
|
||||
}
|
||||
else {
|
||||
$host = $parts['host'];
|
||||
if (stripos($host, 'www.') > -1) {
|
||||
$host = substr($host, 4);
|
||||
}
|
||||
$domains = _video_embed_field_get_provider_domains();
|
||||
if (!array_key_exists($host, $domains)) {
|
||||
$errors[$field['field_name']][$langcode][$delta][] = array(
|
||||
'error' => t('Unsupported Video Provider'),
|
||||
'message' => t('%name: This video provider is not currently supported.', array('%name' => $instance['label'])),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_field_presave().
|
||||
*
|
||||
* Download and save the thumbnail if it hasn't already been stored.
|
||||
* Get video data.
|
||||
*/
|
||||
function video_embed_field_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
|
||||
foreach ($items as $delta => $item) {
|
||||
//Trim whitespace from the video URL.
|
||||
$items[$delta]['video_url'] = trim($item['video_url']);
|
||||
|
||||
// Try to load thumbnail URL
|
||||
$info = video_embed_field_thumbnail_url($item['video_url']);
|
||||
if (isset($info['url']) && $info['url']) {
|
||||
$thumb_url = $info['url'];
|
||||
$local_path = 'public://video_embed_field_thumbnails/' . $info['handler'] . '/' . $info['id'] . '.jpg';
|
||||
|
||||
$dirname = drupal_dirname($local_path);
|
||||
file_prepare_directory($dirname, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
|
||||
|
||||
$response = drupal_http_request($thumb_url);
|
||||
if (!isset($response->error)) {
|
||||
file_save_data($response->data, $local_path, TRUE);
|
||||
}
|
||||
else {
|
||||
@copy($thumb_url, $local_path);
|
||||
}
|
||||
|
||||
|
||||
$items[$delta]['thumbnail_path'] = $local_path;
|
||||
} //couldn't get the thumbnail for whatever reason
|
||||
else {
|
||||
$items[$delta]['thumbnail_path'] = '';
|
||||
}
|
||||
|
||||
// Try to load video data
|
||||
$data = video_embed_field_get_video_data($item['video_url']);
|
||||
if (is_array($data) && !empty($data)) {
|
||||
$items[$delta]['video_data'] = serialize($data);
|
||||
}
|
||||
else {
|
||||
$items[$delta]['video_data'] = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_is_empty().
|
||||
*/
|
||||
function video_embed_field_field_is_empty($item, $field) {
|
||||
return empty($item) || empty($item['video_url']) || $item['video_url'] === '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_formatter_info().
|
||||
*/
|
||||
function video_embed_field_field_formatter_info() {
|
||||
$info = array(
|
||||
'video_embed_field' => array(
|
||||
'label' => t('Video Player'),
|
||||
'field types' => array('video_embed_field'),
|
||||
'settings' => array(
|
||||
'video_style' => 'normal',
|
||||
'description' => 1,
|
||||
'description_position' => 'bottom'
|
||||
),
|
||||
),
|
||||
'video_embed_field_thumbnail' => array(
|
||||
'label' => t('Thumbnail Preview'),
|
||||
'field types' => array('video_embed_field'),
|
||||
'settings' => array(
|
||||
'image_style' => 'none',
|
||||
'description' => 1,
|
||||
'description_position' => 'bottom',
|
||||
'image_link' => 'none',
|
||||
),
|
||||
),
|
||||
);
|
||||
if ( module_exists('colorbox') ) {
|
||||
$info['video_embed_field_thumbnail_colorbox'] = array(
|
||||
'label' => t('Thumbnail Preview w/Colorbox'),
|
||||
'field types' => array('video_embed_field'),
|
||||
'settings' => array(
|
||||
'video_style' => 'normal',
|
||||
'image_style' => 'none',
|
||||
'description' => 1,
|
||||
'description_position' => 'bottom',
|
||||
),
|
||||
);
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_formatter_settings_form().
|
||||
*/
|
||||
function video_embed_field_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
|
||||
$display = $instance['display'][$view_mode];
|
||||
$settings = $display['settings'];
|
||||
$element = array();
|
||||
|
||||
if ($display['type'] == 'video_embed_field' || $display['type'] == 'video_embed_field_thumbnail_colorbox') {
|
||||
$video_styles = video_embed_field_video_style_options(FALSE);
|
||||
$element['video_style'] = array(
|
||||
'#title' => t('Video style'),
|
||||
'#type' => 'select',
|
||||
'#default_value' => $settings['video_style'],
|
||||
'#options' => $video_styles,
|
||||
);
|
||||
}
|
||||
if ($display['type'] == 'video_embed_field_thumbnail' || $display['type'] == 'video_embed_field_thumbnail_colorbox') {
|
||||
$element['image_style'] = array(
|
||||
'#title' => t('Image style'),
|
||||
'#type' => 'select',
|
||||
'#options' => image_style_options(FALSE),
|
||||
'#default_value' => $settings['image_style'],
|
||||
'#empty_option' => t('None (original image)'),
|
||||
);
|
||||
}
|
||||
|
||||
if ($display['type'] == 'video_embed_field_thumbnail') {
|
||||
$link_types = array(
|
||||
'node' => t('Node'),
|
||||
'source' => t('Video Source'),
|
||||
);
|
||||
$element['image_link'] = array(
|
||||
'#title' => t('Link thumbnail to'),
|
||||
'#type' => 'select',
|
||||
'#default_value' => $settings['image_link'],
|
||||
'#empty_option' => t('Nothing'),
|
||||
'#options' => $link_types,
|
||||
);
|
||||
}
|
||||
|
||||
if ($instance['settings']['description_field']) {
|
||||
$element['description'] = array(
|
||||
'#title' => t('Show description'),
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => $settings['description'],
|
||||
);
|
||||
|
||||
$element['description_position'] = array(
|
||||
'#title' => t('Description Position'),
|
||||
'#type' => 'select',
|
||||
'#options' => array(
|
||||
'top' => t('Top'),
|
||||
'bottom' => t('Bottom')
|
||||
),
|
||||
'#default_value' => $settings['description_position'],
|
||||
);
|
||||
}
|
||||
return $element;
|
||||
}
|
||||
/**
|
||||
* Implements hook_field_formatter_settings_summary().
|
||||
*/
|
||||
function video_embed_field_field_formatter_settings_summary($field, $instance, $view_mode) {
|
||||
$display = $instance['display'][$view_mode];
|
||||
$settings = $display['settings'];
|
||||
|
||||
$summary = array();
|
||||
if ($display['type'] == 'video_embed_field' || $display['type'] == 'video_embed_field_thumbnail_colorbox') {
|
||||
$video_styles = video_embed_field_video_style_options(FALSE);
|
||||
// Styles could be lost because of enabled/disabled modules that defines
|
||||
// their styles in code.
|
||||
if (isset($video_styles[$settings['video_style']])) {
|
||||
$summary[] = t('Video style: @style', array('@style' => $video_styles[$settings['video_style']]));
|
||||
}
|
||||
}
|
||||
if ($display['type'] == 'video_embed_field_thumbnail' || $display['type'] == 'video_embed_field_thumbnail_colorbox') {
|
||||
$image_styles = image_style_options(FALSE);
|
||||
if (isset($image_styles[$settings['image_style']])) {
|
||||
$summary[] = t('Image style: @style', array('@style' => $image_styles[$settings['image_style']]));
|
||||
} //No Image style (original image)
|
||||
else {
|
||||
$summary[] = t('Original Image.');
|
||||
}
|
||||
if (isset($settings['image_link'])) {
|
||||
$summary[] = t('Image link: ' . $settings['image_link']);
|
||||
}
|
||||
else {
|
||||
$summary[] = t('Image link: none');
|
||||
}
|
||||
}
|
||||
|
||||
if ($settings['description'] && $instance['settings']['description_field']) {
|
||||
$summary[] = t('Show description');
|
||||
}
|
||||
elseif ($instance['settings']['description_field']) {
|
||||
$summary[] = t('Hide description');
|
||||
}
|
||||
|
||||
return implode('<br />', $summary);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_formatter_view().
|
||||
*/
|
||||
function video_embed_field_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
|
||||
$element = array();
|
||||
$settings = $display['settings'];
|
||||
|
||||
foreach ($items as $delta => $item) {
|
||||
//create the render array for the description
|
||||
if (isset($item['description']) && $item['description'] && $settings['description'] && $instance['settings']['description_field']) {
|
||||
$description = array(
|
||||
'#prefix' => '<div class="video-embed-description">',
|
||||
'#markup' => $item['description'],
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
}
|
||||
else {
|
||||
$description = array();
|
||||
}
|
||||
|
||||
//Render the field
|
||||
if ($display['type'] == 'video_embed_field') {
|
||||
$element[$delta] = array(
|
||||
array(
|
||||
'#theme' => 'video_embed_field_embed_code',
|
||||
'#url' => $item['video_url'],
|
||||
'#style' => $settings['video_style'],
|
||||
'#video_data' => !empty($item['video_data']) ? unserialize($item['video_data']) : array(),
|
||||
),
|
||||
);
|
||||
}
|
||||
elseif ($display['type'] == 'video_embed_field_thumbnail') {
|
||||
if (isset($item['thumbnail_path'])) {
|
||||
if (empty($settings['image_style']) || $settings['image_style'] == 'none') {
|
||||
$element[$delta] = array(
|
||||
array(
|
||||
'#theme' => 'image',
|
||||
'#path' => $item['thumbnail_path'],
|
||||
),
|
||||
);
|
||||
}
|
||||
else {
|
||||
$element[$delta] = array(
|
||||
array(
|
||||
'#theme' => 'image_style',
|
||||
'#path' => $item['thumbnail_path'],
|
||||
'#style_name' => $settings['image_style'],
|
||||
),
|
||||
);
|
||||
}
|
||||
if ($settings['image_link'] == 'source') {
|
||||
$link = explode('|||', l('|||', $item['video_url']));
|
||||
$element[$delta]['#prefix'] = $link[0];
|
||||
$element[$delta]['#suffix'] = $link[1];
|
||||
}
|
||||
elseif ($settings['image_link'] == 'node') {
|
||||
$nid = $entity->nid;
|
||||
$link = explode('|||', l('|||', 'node/' . $nid));
|
||||
$element[$delta]['#prefix'] = $link[0];
|
||||
$element[$delta]['#suffix'] = $link[1];
|
||||
}
|
||||
} //incase no thumbnail was downloaded / provider doesn't support thumbnails
|
||||
else {
|
||||
$element[$delta] = array(
|
||||
);
|
||||
}
|
||||
}
|
||||
elseif ($display['type'] == 'video_embed_field_thumbnail_colorbox') {
|
||||
if (isset($item['thumbnail_path'])) {
|
||||
$element[$delta] = array(
|
||||
array(
|
||||
'#theme' => 'video_embed_field_colorbox_code',
|
||||
'#image_url' => $item['thumbnail_path'],
|
||||
'#image_style' => $display['settings']['image_style'],
|
||||
'#video_url' => $item['video_url'],
|
||||
'#video_style' => $display['settings']['video_style'],
|
||||
'#video_data' => unserialize($item['video_data']),
|
||||
),
|
||||
);
|
||||
}
|
||||
//incase no thumbnail was downloaded / provider doesn't support thumbnails
|
||||
else {
|
||||
$element[$delta] = array(
|
||||
);
|
||||
}
|
||||
}
|
||||
//Get the HTML instead of the array, because we append it to the suffix.
|
||||
//This way, the thumbnail link wrapper doesn't make the description a link as well.
|
||||
$description_html = drupal_render($description);
|
||||
|
||||
$pos = isset($settings['description_position']) ? $settings['description_position'] : 'bottom';
|
||||
if ($pos == 'top') {
|
||||
$element[$delta]['#prefix'] = isset($element[$delta]['#prefix']) ? $element[$delta]['#prefix'] : '';
|
||||
$element[$delta]['#prefix'] = $description_html . $element[$delta]['#prefix'];
|
||||
}
|
||||
else {
|
||||
$element[$delta]['#suffix'] = isset($element[$delta]['#suffix']) ? $element[$delta]['#suffix'] : '';
|
||||
$element[$delta]['#suffix'] .= $description_html;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $element;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
/* Style to make sure the fields are the right way */
|
||||
table input.fluid.video_embed_url {
|
||||
width:100%;
|
||||
}
|
||||
+519
@@ -0,0 +1,519 @@
|
||||
<?php
|
||||
/**
|
||||
* Provide some handlers for video embed field
|
||||
* Other modules can implement the hook_video_embed_handler_info to provide more handlers
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_video_embed_handler_info().
|
||||
*/
|
||||
function video_embed_field_video_embed_handler_info() {
|
||||
$handlers = array();
|
||||
|
||||
$handlers['youtube'] = array(
|
||||
'title' => 'Youtube',
|
||||
'function' => 'video_embed_field_handle_youtube',
|
||||
'thumbnail_function' => 'video_embed_field_handle_youtube_thumbnail',
|
||||
'data_function' => 'video_embed_field_handle_youtube_data',
|
||||
'form' => 'video_embed_field_handler_youtube_form',
|
||||
'domains' => array(
|
||||
'youtube.com',
|
||||
'youtu.be',
|
||||
),
|
||||
'defaults' => array(
|
||||
'width' => '640px',
|
||||
'height' => '360px',
|
||||
'autoplay' => 0,
|
||||
'hd' => 1,
|
||||
'rel' => 0,
|
||||
'autohide' => 2,
|
||||
'showinfo' => 1,
|
||||
'modestbranding' => 0,
|
||||
'theme' => 'dark',
|
||||
'iv_load_policy' => 1,
|
||||
),
|
||||
);
|
||||
|
||||
$handlers['vimeo'] = array(
|
||||
'title' => 'Vimeo',
|
||||
'function' => 'video_embed_field_handle_vimeo',
|
||||
'thumbnail_function' => 'video_embed_field_handle_vimeo_thumbnail',
|
||||
'data_function' => 'video_embed_field_handle_vimeo_data',
|
||||
'form' => 'video_embed_field_handler_vimeo_form',
|
||||
'domains' => array(
|
||||
'vimeo.com',
|
||||
),
|
||||
'defaults' => array(
|
||||
'width' => '640px',
|
||||
'height' => '360px',
|
||||
'color' => '00adef',
|
||||
'portrait' => 1,
|
||||
'title' => 1,
|
||||
'byline' => 1,
|
||||
'autoplay' => 0,
|
||||
'loop' => 0,
|
||||
),
|
||||
);
|
||||
|
||||
return $handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to get the youtube video's id
|
||||
* Returns false if it doesn't parse for wahtever reason
|
||||
*/
|
||||
function _video_embed_field_get_youtube_id($url) {
|
||||
// Find the ID of the video they want to play from the url
|
||||
if (stristr($url, 'http://')) {
|
||||
$url = substr($url, 7);
|
||||
}
|
||||
elseif (stristr($url, 'https://')) {
|
||||
$url = substr($url, 8);
|
||||
}
|
||||
|
||||
if (stristr($url, 'playlist')) {
|
||||
//Playlists need the appended ampersand to take the options properly.
|
||||
$url = $url . '&';
|
||||
$pos = strripos($url, '?list=');
|
||||
if ($pos !== FALSE) {
|
||||
$pos2 = stripos($url, '&');
|
||||
$pos2++;
|
||||
}
|
||||
else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
//Alternate playlist link
|
||||
elseif (stristr($url, 'view_play_list')) {
|
||||
$url = $url . '&';
|
||||
//All playlist ID's are prepended with PL. view_play_list links allow you to not have that, though.
|
||||
if (!stristr($url, '?p=PL')) {
|
||||
$url = substr_replace($url, 'PL', strpos($url, '?p=') + 3, 0);
|
||||
}
|
||||
//Replace the links format with the embed format
|
||||
$url = str_ireplace('play_list?p=', 'videoseries?list=', $url);
|
||||
$pos = strripos($url, 'videoseries?list=');
|
||||
if ($pos !== FALSE) {
|
||||
$pos2 = stripos($url, '&');
|
||||
$pos2++;
|
||||
}
|
||||
else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$pos = strripos($url, 'v=');
|
||||
if ($pos !== FALSE) {
|
||||
$pos += 2;
|
||||
$pos2 = stripos($url, '&', $pos);
|
||||
$pos_hash = stripos($url, '#', $pos);
|
||||
|
||||
$pos2 = _video_embed_get_min($pos2, $pos_hash);
|
||||
}
|
||||
else {
|
||||
$pos = strripos($url, '/');
|
||||
if ($pos !== FALSE) {
|
||||
$pos++;
|
||||
$pos2 = stripos($url, '?', $pos);
|
||||
$pos_hash = stripos($url, '#', $pos);
|
||||
|
||||
$pos2 = _video_embed_get_min($pos2, $pos_hash);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($pos === FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
if ($pos2 > 0) {
|
||||
$id = substr($url, $pos, $pos2 - $pos);
|
||||
}
|
||||
else {
|
||||
$id = substr($url, $pos);
|
||||
}
|
||||
}
|
||||
return $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for Youtube videos.
|
||||
*/
|
||||
function video_embed_field_handle_youtube($url, $settings) {
|
||||
$output = array();
|
||||
|
||||
//Grab the minutes and seconds, and just convert it down to seconds
|
||||
preg_match('/#t=((?P<min>\d+)m)?((?P<sec>\d+)s)?/', $url, $matches);
|
||||
|
||||
//Give it some default data in case there is no #t=...
|
||||
$matches += array(
|
||||
"min" => 0,
|
||||
"sec" => 0,
|
||||
);
|
||||
$time = ($matches["min"] * 60) + $matches["sec"];
|
||||
$settings['start'] = $time;
|
||||
|
||||
$id = _video_embed_field_get_youtube_id($url);
|
||||
if (!$id) {
|
||||
// We can't decode the URL - just return the URL as a link
|
||||
$output['#markup'] = l($url, $url);
|
||||
return $output;
|
||||
}
|
||||
// Construct the embed code
|
||||
$settings['wmode'] = 'opaque';
|
||||
$settings_str = _video_embed_code_get_settings_str($settings);
|
||||
|
||||
$output['#markup'] = '<iframe width="' . $settings['width'] . '" height="' . $settings['height'] . '" src="//www.youtube.com/embed/' . $id . '?' . $settings_str . '" frameborder="0" allowfullscreen></iframe>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the thumbnail url for youtube videos
|
||||
*/
|
||||
function video_embed_field_handle_youtube_thumbnail($video_url) {
|
||||
$info = array();
|
||||
|
||||
$id = _video_embed_field_get_youtube_id($video_url);
|
||||
|
||||
//Playlist
|
||||
if (stristr($id, '?list=')) {
|
||||
//Strip out all but the ID, including the PL behind the ID.
|
||||
$start = strpos($id, '?list=PL') + 8;
|
||||
$length = strpos($id, '&') - $start;
|
||||
$id = substr($id, $start, $length);
|
||||
$info['id'] = $id;
|
||||
//Playlist info is stored in XML. The thumbnail is in there.
|
||||
$xml = drupal_http_request('http://gdata.youtube.com/feeds/api/playlists/' . $id);
|
||||
if (!isset($xml->error)) {
|
||||
$xml = new SimpleXMLElement($xml->data);
|
||||
$media = $xml->children('http://search.yahoo.com/mrss/');
|
||||
if ($media->group->thumbnail && $media->group->thumbnail[0]->attributes()) {
|
||||
$attrs = $media->group->thumbnail[0]->attributes();
|
||||
$info['url'] = (string) $attrs['url'];
|
||||
}
|
||||
}
|
||||
}
|
||||
//Regular video
|
||||
elseif ($id) {
|
||||
$info['id'] = $id;
|
||||
$info['url'] = 'http://img.youtube.com/vi/' . $id . '/0.jpg';
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get video data for a YouTube video URL
|
||||
*
|
||||
* @param string $url
|
||||
* A YouTube video URL to get data for
|
||||
*
|
||||
* @return array|false $data
|
||||
* An array of video data, or FALSE if unable to fetch data
|
||||
*/
|
||||
function video_embed_field_handle_youtube_data($url) {
|
||||
$data = array();
|
||||
|
||||
// Get YouTube video ID from URL
|
||||
$id = _video_embed_field_get_youtube_id($url);
|
||||
|
||||
if ($id) {
|
||||
$response = drupal_http_request('http://gdata.youtube.com/feeds/api/videos/' . $id . '?v=2&alt=json');
|
||||
if (!isset($response->error)) {
|
||||
$data = json_decode($response->data);
|
||||
$data = isset($data->entry) ? (array) $data->entry : (array) $data->feed;
|
||||
return _video_embed_field_clean_up_youtube_data($data);
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flatten out some unnecessary nesting in the youtube data
|
||||
*/
|
||||
function _video_embed_field_clean_up_youtube_data($data) {
|
||||
//make things a bit nicer for people trying to use the data
|
||||
foreach ($data as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$temp = (array) $value;
|
||||
if (isset($temp['$t'])) {
|
||||
$data[$key] = $temp['$t'];
|
||||
}
|
||||
else {
|
||||
$data[$key] = _video_embed_field_clean_up_youtube_data($temp);
|
||||
}
|
||||
}
|
||||
elseif (is_array($value)) {
|
||||
$data[$key] = _video_embed_field_clean_up_youtube_data($value);
|
||||
}
|
||||
|
||||
if ($key === 'category') {
|
||||
$terms = array();
|
||||
foreach ($data[$key] as $value) {
|
||||
if (isset($value['scheme']) && $value['scheme'] == 'http://schemas.google.com/g/2005#kind') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isset($value['term'])) {
|
||||
$terms[] = $value['term'];
|
||||
}
|
||||
}
|
||||
$data['terms'] = $terms;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the form elements for the Youtube configuration form.
|
||||
*/
|
||||
function video_embed_field_handler_youtube_form($defaults) {
|
||||
$form = array();
|
||||
|
||||
$form['width'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#size' => '5',
|
||||
'#title' => t('Player Width'),
|
||||
'#description' => t('The width of the youtube player.'),
|
||||
'#default_value' => $defaults['width'],
|
||||
);
|
||||
$form['height'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#size' => '5',
|
||||
'#title' => t('Player Height'),
|
||||
'#description' => t('The height of the youtube player.'),
|
||||
'#default_value' => $defaults['height'],
|
||||
);
|
||||
$form['theme'] = array(
|
||||
'#type' => 'select',
|
||||
'#options' => array(
|
||||
'dark' => t('Dark'),
|
||||
'light' => t('Light'),
|
||||
),
|
||||
'#title' => t('Player theme'),
|
||||
'#default_value' => $defaults['theme'],
|
||||
);
|
||||
$form['autoplay'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Autoplay'),
|
||||
'#description' => t('Play the video immediately.'),
|
||||
'#default_value' => $defaults['autoplay'],
|
||||
);
|
||||
$form['hd'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Use HD'),
|
||||
'#description' => t('Attempt to play the video in HD if available.'),
|
||||
'#default_value' => $defaults['hd'],
|
||||
);
|
||||
$form['rel'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Show related videos'),
|
||||
'#description' => t('Show related videos after the video is finished playing.'),
|
||||
'#default_value' => $defaults['rel'],
|
||||
);
|
||||
$form['showinfo'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Show info'),
|
||||
'#description' => t('Display information like the video title and rating before the video starts playing.'),
|
||||
'#default_value' => $defaults['showinfo'],
|
||||
);
|
||||
$form['modestbranding'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Hide Youtube logo'),
|
||||
'#description' => t('Hide the Youtube logo button on the player'),
|
||||
'#default_value' => $defaults['modestbranding'],
|
||||
);
|
||||
$form['iv_load_policy'] = array(
|
||||
'#type' => 'radios',
|
||||
'#options' => array(
|
||||
1 => t('Show video annotations.'),
|
||||
3 => t('Hide video annotations.'),
|
||||
),
|
||||
'#title' => t('Display annotations'),
|
||||
'#description' => t('Controls the display of annotations over the video content. Only works when using the flash player.'),
|
||||
'#default_value' => $defaults['iv_load_policy'],
|
||||
);
|
||||
$form['autohide'] = array(
|
||||
'#type' => 'radios',
|
||||
'#options' => array(
|
||||
0 => t('The video progress bar and player controls will be visible throughout the video.'),
|
||||
1 => t('Automatically slide the video progress bar and the player controls out of view a couple of seconds after the video starts playing. They will only reappear if the user moves her mouse over the video player or presses a keyboard key.'),
|
||||
2 => t('The video progress bar will fade out but the player controls (play button, volume control, etc.) remain visible.'),
|
||||
),
|
||||
'#title' => t('Autohide progress bar and the player controls'),
|
||||
'#description' => t('Controls the autohide behavior of the youtube player controls.'),
|
||||
'#default_value' => $defaults['autohide'],
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to get the Vimeo video's ID
|
||||
*
|
||||
* @param string $url
|
||||
* A Vimeo video URL to get the ID of
|
||||
*
|
||||
* @return integer|false $id
|
||||
* The video ID, or FALSE if unable to get the video ID
|
||||
*/
|
||||
function _video_embed_field_get_vimeo_id($url) {
|
||||
$pos = strripos($url, '/');
|
||||
if ($pos != FALSE) {
|
||||
$pos += 1;
|
||||
return (int) substr($url, $pos);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for Vimeo videos.
|
||||
*/
|
||||
function video_embed_field_handle_vimeo($url, $settings) {
|
||||
// Get ID of video from URL
|
||||
$id = _video_embed_field_get_vimeo_id($url);
|
||||
if (!$id) {
|
||||
return array(
|
||||
'#markup' => l($url, $url),
|
||||
);
|
||||
}
|
||||
|
||||
// Construct the embed code
|
||||
$settings['portrait'] = 0;
|
||||
$settings_str = _video_embed_code_get_settings_str($settings);
|
||||
|
||||
return array(
|
||||
'#markup' => '<iframe width="' . $settings['width'] . '" height="' . $settings['height'] . '" src="//player.vimeo.com/video/' . $id .
|
||||
'?' . $settings_str . '" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowfullscreen></iframe>',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the thumbnail url for youtube videos
|
||||
*/
|
||||
function video_embed_field_handle_vimeo_thumbnail($url) {
|
||||
// Get ID of video from URL
|
||||
$id = _video_embed_field_get_vimeo_id($url);
|
||||
$info = array(
|
||||
'id' => $id,
|
||||
);
|
||||
$response = drupal_http_request('http://vimeo.com/api/v2/video/' . $id . '.php');
|
||||
if (!isset($response->error)) {
|
||||
$response = unserialize($response->data);
|
||||
$video = current($response);
|
||||
|
||||
$image_url = $video['thumbnail_large'];
|
||||
$info['url'] = $image_url;
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get video data for a Vimeo video URL
|
||||
*
|
||||
* @param string $url
|
||||
* A Vimeo video URL to get data for
|
||||
*
|
||||
* @return array|false $data
|
||||
* An array of video data, or FALSE if unable to fetch data
|
||||
*/
|
||||
function video_embed_field_handle_vimeo_data($url) {
|
||||
// Get ID of video from URL
|
||||
$id = _video_embed_field_get_vimeo_id($url);
|
||||
if ($id) {
|
||||
$response = drupal_http_request('http://vimeo.com/api/v2/video/' . $id . '.php');
|
||||
if (!isset($response->error)) {
|
||||
$response = unserialize($response->data);
|
||||
return (array) current($response);
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the form elements for the Vimeo configuration form.
|
||||
*/
|
||||
function video_embed_field_handler_vimeo_form($defaults) {
|
||||
$form = array();
|
||||
|
||||
$form['width'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#size' => '5',
|
||||
'#title' => t('Player Width'),
|
||||
'#description' => t('The width of the vimeo player.'),
|
||||
'#default_value' => $defaults['width'],
|
||||
);
|
||||
$form['height'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#size' => '5',
|
||||
'#title' => t('Player Height'),
|
||||
'#description' => t('The height of the vimeo player.'),
|
||||
'#default_value' => $defaults['height'],
|
||||
);
|
||||
$form['color'] = array(
|
||||
'#type' => 'select',
|
||||
'#options' => array(
|
||||
'00adef' => t('Blue'),
|
||||
'ff9933' => t('Orange'),
|
||||
'c9ff23' => t('Lime'),
|
||||
'ff0179' => t('Fuschia'),
|
||||
'ffffff' => t('White'),
|
||||
),
|
||||
'#title' => t('Player Color'),
|
||||
'#description' => t('The color to use on the vimeo player.'),
|
||||
'#default_value' => $defaults['color'],
|
||||
);
|
||||
$form['portrait'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Overlay Author Thumbnail'),
|
||||
'#description' => t('Overlay the author\'s thumbnail before the video is played.'),
|
||||
'#default_value' => $defaults['portrait'],
|
||||
);
|
||||
$form['title'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Overlay Video\'s Title'),
|
||||
'#description' => t('Overlay the video\'s title before the video is played.'),
|
||||
'#default_value' => $defaults['title'],
|
||||
);
|
||||
$form['byline'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Overlay Video\'s Byline'),
|
||||
'#description' => t('Overlay the video\'s description before the video is played.'),
|
||||
'#default_value' => $defaults['byline'],
|
||||
);
|
||||
$form['overridable'] = array(
|
||||
'#prefix' => '<p class="note"><strong>' . t('Note') . ': </strong><em>',
|
||||
'#markup' => t('Color, portrait, title and byline can be restricted by Vimeo Plus videos.
|
||||
Such videos will ignore these settings.'),
|
||||
'#suffix' => '</em></p>',
|
||||
);
|
||||
$form['autoplay'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Autoplay'),
|
||||
'#description' => t('Play the video immediately.'),
|
||||
'#default_value' => $defaults['autoplay'],
|
||||
);
|
||||
$form['loop'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Loop'),
|
||||
'#description' => t('Loop the video\'s playback'),
|
||||
'#default_value' => $defaults['loop'],
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the min index for use in finding the id of a youtube video
|
||||
*/
|
||||
function _video_embed_get_min($pos1, $pos2) {
|
||||
if (!$pos1) {
|
||||
return $pos2;
|
||||
}
|
||||
elseif (!$pos2) {
|
||||
return $pos1;
|
||||
}
|
||||
else {
|
||||
return min($pos1, $pos2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
name = "Video Embed Field"
|
||||
description = "Expose a field type for embedding videos from youtube or vimeo."
|
||||
core = 7.x
|
||||
package = Media
|
||||
configure = admin/config/media/vef_video_styles
|
||||
|
||||
dependencies[] = ctools
|
||||
dependencies[] = image
|
||||
; Information added by drupal.org packaging script on 2012-10-17
|
||||
version = "7.x-2.0-beta5+11-dev"
|
||||
core = "7.x"
|
||||
project = "video_embed_field"
|
||||
datestamp = "1350438417"
|
||||
|
||||
+243
@@ -0,0 +1,243 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Install, update and uninstall functions for the video_embed_field module.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Install file for video_embed_field module
|
||||
* @author jcaldwell
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_field_schema().
|
||||
*/
|
||||
function video_embed_field_field_schema($field) {
|
||||
switch ($field['type']) {
|
||||
case 'video_embed_field':
|
||||
$columns = array(
|
||||
'video_url' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 512,
|
||||
'default' => '',
|
||||
),
|
||||
'thumbnail_path' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 512,
|
||||
'default' => '',
|
||||
),
|
||||
'video_data' => array(
|
||||
'type' => 'blob',
|
||||
'not null' => FALSE,
|
||||
'size' => 'big',
|
||||
'serialize' => TRUE,
|
||||
),
|
||||
'embed_code' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 1024,
|
||||
'default' => '',
|
||||
),
|
||||
'description' => array(
|
||||
'type' => 'text',
|
||||
'not null' => FALSE,
|
||||
),
|
||||
);
|
||||
$indexes = array();
|
||||
break;
|
||||
}
|
||||
|
||||
return array(
|
||||
'columns' => $columns,
|
||||
'indexes' => $indexes,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_schema().
|
||||
*/
|
||||
function video_embed_field_schema() {
|
||||
$schema['vef_video_styles'] = array(
|
||||
'description' => 'Stores video embed styles.',
|
||||
'export' => array(
|
||||
'key' => 'name',
|
||||
'primary key' => 'vsid',
|
||||
'identifier' => 'video_embed_style', // Exports will be as $video_style
|
||||
'default hook' => 'default_video_embed_styles', // Function hook name.
|
||||
'api' => array(
|
||||
'owner' => 'video_embed_field',
|
||||
'api' => 'default_video_embed_styles', // Base name for api include files.
|
||||
'minimum_version' => 1,
|
||||
'current_version' => 1,
|
||||
),
|
||||
),
|
||||
'fields' => array(
|
||||
'vsid' => array(
|
||||
'description' => 'The primary identifier for a video style.',
|
||||
'type' => 'serial',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'no export' => TRUE,
|
||||
),
|
||||
'name' => array(
|
||||
'description' => 'The style name.',
|
||||
'type' => 'varchar',
|
||||
'length' => '255',
|
||||
'not null' => TRUE,
|
||||
),
|
||||
'data' => array(
|
||||
'description' => 'The configuration data for the style.',
|
||||
'type' => 'blob',
|
||||
'size' => 'big',
|
||||
'not null' => TRUE,
|
||||
'serialize' => TRUE,
|
||||
),
|
||||
),
|
||||
'primary key' => array('vsid'),
|
||||
'unique keys' => array(
|
||||
'name' => array('name'),
|
||||
),
|
||||
);
|
||||
return $schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_uninstall().
|
||||
*/
|
||||
function video_embed_field_uninstall() {
|
||||
//do nothing right now - should eventually remove all the variables
|
||||
}
|
||||
|
||||
/**
|
||||
* Update 7000
|
||||
* Add an optional description form
|
||||
*/
|
||||
function video_embed_field_update_7000() {
|
||||
// Get the list of fields of type 'video_embed_field'.
|
||||
$video_embed_fields = array();
|
||||
foreach (field_info_fields() as $field_name => $field_info) {
|
||||
if ($field_info['type'] == 'video_embed_field') {
|
||||
$video_embed_fields[$field_name] = field_read_field($field_name);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($video_embed_fields as $field) {
|
||||
if ($field['deleted']) {
|
||||
$table = "field_deleted_data_{$field['id']}";
|
||||
$revision_table = "field_deleted_revision_{$field['id']}";
|
||||
}
|
||||
else {
|
||||
$table = "field_data_{$field['field_name']}";
|
||||
$revision_table = "field_revision_{$field['field_name']}";
|
||||
}
|
||||
$column = $field['field_name'] . '_' . 'description';
|
||||
db_add_field($table, $column, array('type' => 'text', 'not null' => FALSE));
|
||||
db_add_field($revision_table, $column, array('type' => 'text', 'not null' => FALSE));
|
||||
}
|
||||
|
||||
return t('Additional columns added.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update 7001
|
||||
* Add video style storage table
|
||||
*/
|
||||
function video_embed_field_update_7001() {
|
||||
if (!db_table_exists('vef_video_styles')) {
|
||||
$schema = video_embed_field_schema();
|
||||
db_create_table('vef_video_styles', $schema['vef_video_styles']);
|
||||
}
|
||||
|
||||
return t('Video styles storage table created.');
|
||||
}
|
||||
/**
|
||||
* Update 7002
|
||||
* Add field for storing the path to the video thumbnail
|
||||
*/
|
||||
function video_embed_field_update_7002() {
|
||||
// Get the list of fields of type 'video_embed_field'.
|
||||
$video_embed_fields = array();
|
||||
foreach (field_info_fields() as $field_name => $field_info) {
|
||||
if ($field_info['type'] == 'video_embed_field') {
|
||||
$video_embed_fields[$field_name] = field_read_field($field_name);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($video_embed_fields as $field) {
|
||||
if ($field['deleted']) {
|
||||
$table = "field_deleted_data_{$field['id']}";
|
||||
$revision_table = "field_deleted_revision_{$field['id']}";
|
||||
}
|
||||
else {
|
||||
$table = "field_data_{$field['field_name']}";
|
||||
$revision_table = "field_revision_{$field['field_name']}";
|
||||
}
|
||||
$column = $field['field_name'] . '_' . 'thumbnail_path';
|
||||
db_add_field($table, $column, array(
|
||||
'type' => 'varchar',
|
||||
'length' => 512,
|
||||
'default' => '',
|
||||
));
|
||||
db_add_field($revision_table, $column, array(
|
||||
'type' => 'varchar',
|
||||
'length' => 512,
|
||||
'default' => '',
|
||||
));
|
||||
}
|
||||
|
||||
return t('Thumbnail column added.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable inline colorbox support if colorbox is installed [NO LONGER NEEDED - This update hook does nothing]
|
||||
*/
|
||||
function video_embed_field_update_7003() {
|
||||
//this is no longer needed
|
||||
//variable_set('colorbox_inline', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable colorbox load support if colorbox is installed, we no longer need inline support
|
||||
*/
|
||||
function video_embed_field_update_7004() {
|
||||
variable_set('colorbox_load', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add data column to field database.
|
||||
*/
|
||||
function video_embed_field_update_7005() {
|
||||
// Get the list of fields of type 'video_embed_field'.
|
||||
$video_embed_fields = array();
|
||||
foreach (field_info_fields() as $field_name => $field_info) {
|
||||
if ($field_info['type'] == 'video_embed_field') {
|
||||
$video_embed_fields[$field_name] = field_read_field($field_name);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($video_embed_fields as $field) {
|
||||
if ($field['deleted']) {
|
||||
$table = "field_deleted_data_{$field['id']}";
|
||||
$revision_table = "field_deleted_revision_{$field['id']}";
|
||||
}
|
||||
else {
|
||||
$table = "field_data_{$field['field_name']}";
|
||||
$revision_table = "field_revision_{$field['field_name']}";
|
||||
}
|
||||
$column = $field['field_name'] . '_' . 'video_data';
|
||||
db_add_field($table, $column, array(
|
||||
'type' => 'blob',
|
||||
'not null' => FALSE,
|
||||
'size' => 'big',
|
||||
'serialize' => TRUE,
|
||||
));
|
||||
db_add_field($revision_table, $column, array(
|
||||
'type' => 'blob',
|
||||
'not null' => FALSE,
|
||||
'size' => 'big',
|
||||
'serialize' => TRUE,
|
||||
));
|
||||
}
|
||||
|
||||
return t('Data column added. Please clear cache.');
|
||||
}
|
||||
+570
@@ -0,0 +1,570 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Provides a simple field for easily embedding videos from youtube or vimeo
|
||||
*
|
||||
* This module is not intended to replace media or video - it does not allow for any local storage of videos, custom players or anything else
|
||||
* It simply allows users to embed videos from youtube and vimeo - and provides a hook to allow other modules to provide more providers.
|
||||
*
|
||||
* Uses CTools Export UI to manage settings. @see ./plugins/export_ui/video_embed_field_export_ui.inc
|
||||
*
|
||||
* @author jec006, jdelaune
|
||||
*/
|
||||
|
||||
// Load all Field module hooks.
|
||||
module_load_include('inc', 'video_embed_field', 'video_embed_field.field');
|
||||
// Load the admin forms
|
||||
module_load_include('inc', 'video_embed_field', 'video_embed_field.admin');
|
||||
// Load our default handlers
|
||||
module_load_include('inc', 'video_embed_field', 'video_embed_field.handlers');
|
||||
// Load feeds mapping hooks
|
||||
module_load_include('inc', 'video_embed_field', 'video_embed_field.feeds');
|
||||
|
||||
/**
|
||||
* Implements hook_ctools_plugin_directory().
|
||||
*/
|
||||
function video_embed_field_ctools_plugin_directory($module, $type) {
|
||||
// Load the export_ui plugin.
|
||||
if ($type == 'export_ui') {
|
||||
return 'plugins/export_ui';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_ctools_plugin_api().
|
||||
*
|
||||
* Tell CTools that we support the default_mymodule_presets API.
|
||||
*/
|
||||
function video_embed_field_ctools_plugin_api($owner, $api) {
|
||||
if ($owner == 'video_embed_field' && $api == 'default_video_embed_styles') {
|
||||
return array('version' => 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_default_video_styles().
|
||||
*/
|
||||
function video_embed_field_default_video_embed_styles() {
|
||||
$styles = array();
|
||||
|
||||
$handlers = video_embed_get_handlers();
|
||||
//create the normal handler
|
||||
$normal = new stdClass;
|
||||
$normal->disabled = FALSE; /* Edit this to true to make a default video_embed_style disabled initially */
|
||||
$normal->api_version = 1;
|
||||
$normal->name = 'normal';
|
||||
$normal->data = array();
|
||||
|
||||
$teaser = new stdClass;
|
||||
$teaser->disabled = FALSE; /* Edit this to true to make a default video_embed_style disabled initially */
|
||||
$teaser->api_version = 1;
|
||||
$teaser->name = 'teaser';
|
||||
$teaser->data = array();
|
||||
|
||||
//add in our settings for each of the handlers
|
||||
foreach ($handlers as $name => $handler) {
|
||||
$normal->data[$name] = $handler['defaults'];
|
||||
$teaser->data[$name] = $handler['defaults'];
|
||||
$teaser->data[$name]['width'] = 480;
|
||||
$teaser->data[$name]['height'] = 270;
|
||||
}
|
||||
|
||||
return array($normal, $teaser);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
function video_embed_field_menu() {
|
||||
$items = array();
|
||||
|
||||
$items['vef/load/%'] = array(
|
||||
'title' => 'Video Embed Field - Load Video',
|
||||
'page callback' => '_video_embed_field_show_video',
|
||||
'page arguments' => array(2),
|
||||
'access callback' => TRUE,
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of all styles and their settings.
|
||||
*
|
||||
* @return
|
||||
* An array of styles keyed by the video style ID (vsid).
|
||||
* @see video_embed_field_video_style_load()
|
||||
*/
|
||||
function video_embed_field_video_styles() {
|
||||
$styles = &drupal_static(__FUNCTION__);
|
||||
|
||||
// Grab from cache or build the array.
|
||||
if (!isset($styles)) {
|
||||
// load the style via ctools - which will handle all the caching for us -
|
||||
// however, because it does a bit more logic, lets still statically cache this function
|
||||
ctools_include('export');
|
||||
$styles = ctools_export_load_object('vef_video_styles');
|
||||
}
|
||||
|
||||
return $styles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a style by style name or ID. May be used as a loader for menu items.
|
||||
*
|
||||
* Note that you may also use ctools_export_load_object with the key being vef_video_styles
|
||||
*
|
||||
* @param $name
|
||||
* The name of the style.
|
||||
* @param $isid
|
||||
* Optional. The numeric id of a style if the name is not known.
|
||||
* @return
|
||||
* An video style array containing the following keys:
|
||||
* - "vsid": The unique image style ID.
|
||||
* - "name": The unique image style name.
|
||||
* - "data": An array of video settings within this video style.
|
||||
* If the video style name or ID is not valid, an empty array is returned.
|
||||
*/
|
||||
function video_embed_field_video_style_load($name = NULL, $vsid = NULL) {
|
||||
$styles = video_embed_field_video_styles();
|
||||
|
||||
// If retrieving by name.
|
||||
if (isset($name) && isset($styles[$name])) {
|
||||
$style = $styles[$name];
|
||||
} // If retrieving by image style id.
|
||||
elseif (!isset($name) && isset($vsid)) {
|
||||
foreach ($styles as $name => $database_style) {
|
||||
if (isset($database_style['vsid']) && $database_style['vsid'] == $vsid) {
|
||||
$style = $database_style;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if we found a style return it
|
||||
if (isset($style)) {
|
||||
return $style;
|
||||
}
|
||||
|
||||
// Otherwise the style was not found.
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_permission().
|
||||
*/
|
||||
function video_embed_field_permission() {
|
||||
return array(
|
||||
'administer video styles' => array(
|
||||
'title' => t('Administer video styles'),
|
||||
'description' => t('Create and modify styles for embedded videos.'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*/
|
||||
function video_embed_field_theme() {
|
||||
return array(
|
||||
// Theme functions in video_embed_field.admin.inc.
|
||||
'video_embed_field_video_style_list' => array(
|
||||
'variables' => array('styles' => NULL),
|
||||
),
|
||||
'video_embed_field_embed_code' => array(
|
||||
'template' => 'video-embed-field-embed-code',
|
||||
'variables' => array('url' => NULL, 'style' => 'normal', 'video_data' => array()),
|
||||
),
|
||||
'video_embed_field_colorbox_code' => array(
|
||||
'variables' => array('image_url' => NULL, 'image_style' => 'normal', 'video_url' => NULL, 'video_style' => NULL, 'video_data' => array()),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a hook that other modules can implement to get handlers - hook_video_embed_handler_info
|
||||
* Can be used to add more handlers if needed - from other modules and such
|
||||
* @see video_embed_field.api.php for more information
|
||||
*/
|
||||
function video_embed_get_handlers() {
|
||||
$handlers = cache_get('video_embed_field_handlers');
|
||||
|
||||
if ($handlers === FALSE) {
|
||||
$handlers = module_invoke_all('video_embed_handler_info');
|
||||
drupal_alter('video_embed_field_handlers', $handlers);
|
||||
cache_set('video_embed_field_handlers', $handlers);
|
||||
}
|
||||
else {
|
||||
$handlers = $handlers->data;
|
||||
}
|
||||
|
||||
return $handlers;
|
||||
}
|
||||
|
||||
function video_embed_get_handler($url) {
|
||||
// Process video URL
|
||||
if (!stristr($url, 'http://') && !stristr($url, 'https://')) {
|
||||
$url = 'http://' . $url;
|
||||
}
|
||||
$parts = parse_url($url);
|
||||
if (!isset($parts['host'])) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$host = $parts['host'];
|
||||
if (stripos($host, 'www.') > -1) {
|
||||
$host = substr($host, 4);
|
||||
}
|
||||
|
||||
$domains = _video_embed_field_get_provider_domains();
|
||||
$handlers = video_embed_get_handlers();
|
||||
if (isset($domains[$host])) {
|
||||
$handler_name = $domains[$host];
|
||||
$handler = $handlers[$handler_name];
|
||||
$handler['name'] = $handler_name;
|
||||
return $handler;
|
||||
}
|
||||
else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a form from the player configuration options
|
||||
* $defaults will be passed in with the default settings for the various fields
|
||||
*/
|
||||
function video_embed_field_get_form($defaults) {
|
||||
$form = array();
|
||||
|
||||
$handlers = video_embed_get_handlers();
|
||||
|
||||
foreach ($handlers as $name => $handler) {
|
||||
if (isset($handler['form']) && function_exists($handler['form'])) {
|
||||
$handler_defaults = isset($defaults[$name]) ? $defaults[$name] : array();
|
||||
$handler_defaults = array_merge($handler['defaults'], $handler_defaults);
|
||||
|
||||
$form[$name] = call_user_func($handler['form'], $handler_defaults);
|
||||
|
||||
$form[$name] += array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t($handler['title']),
|
||||
'#tree' => TRUE,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of image styles suitable for using as select list options.
|
||||
*
|
||||
* @param $include_empty
|
||||
* If TRUE a <none> option will be inserted in the options array.
|
||||
* @return
|
||||
* Array of image styles both key and value are set to style name.
|
||||
*/
|
||||
function video_embed_field_video_style_options($include_empty = TRUE) {
|
||||
$styles = video_embed_field_video_styles();
|
||||
$options = array();
|
||||
if ($include_empty && !empty($styles)) {
|
||||
$options[''] = t('<none>');
|
||||
}
|
||||
$options = array_merge($options, drupal_map_assoc(array_keys($styles)));
|
||||
if (empty($options)) {
|
||||
$options[''] = t('No defined styles');
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_filter_info().
|
||||
*/
|
||||
function video_embed_field_filter_info() {
|
||||
$filters['video_embed_field'] = array(
|
||||
'title' => t('Video Embedding'),
|
||||
'description' => t('Replaces [VIDEO::http://www.youtube.com/watch?v=someVideoID::aVideoStyle] tags with embedded videos.'),
|
||||
'process callback' => 'video_embed_field_filter_process',
|
||||
);
|
||||
|
||||
return $filters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Video Embed Field filter process callback.
|
||||
*/
|
||||
function video_embed_field_filter_process($text, $filter, $format) {
|
||||
preg_match_all('/ \[VIDEO:: ( [^\[\]]+ )* \] /x', $text, $matches);
|
||||
|
||||
$tag_match = (array) array_unique($matches[1]);
|
||||
$handlers = video_embed_get_handlers();
|
||||
|
||||
foreach ($tag_match as $tag) {
|
||||
$parts = explode('::', $tag);
|
||||
|
||||
// Get video style
|
||||
if (isset($parts[1])) {
|
||||
$style = $parts[1];
|
||||
}
|
||||
else {
|
||||
$style = 'normal';
|
||||
}
|
||||
|
||||
$embed_code = theme('video_embed_field_embed_code', array('url' => $parts[0], 'style' => $style));
|
||||
|
||||
$text = str_replace('[VIDEO::' . $tag . ']', $embed_code, $text);
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process variables to format a video player.
|
||||
*
|
||||
* $variables contains the following information:
|
||||
* - $url
|
||||
* - $style
|
||||
* - $video_data
|
||||
*
|
||||
* @see video-embed.tpl.php
|
||||
*/
|
||||
function template_preprocess_video_embed_field_embed_code(&$variables) {
|
||||
// Get the handler
|
||||
$handler = video_embed_get_handler($variables['url']);
|
||||
$variables['handler'] = $handler['name'];
|
||||
|
||||
// Load the style
|
||||
$style = video_embed_field_video_style_load($variables['style']);
|
||||
// If there was an issue load in the default style
|
||||
if ($style == FALSE) {
|
||||
$style = video_embed_field_video_style_load('normal');
|
||||
}
|
||||
if (isset($style->data[$variables['handler']])) {
|
||||
$variables['style_settings'] = $style->data[$variables['handler']];
|
||||
} //safety valve for when we add new handlers and there are styles in the database.
|
||||
else {
|
||||
$variables['style_settings'] = $handler['defaults'];
|
||||
}
|
||||
|
||||
|
||||
// Prepare the URL
|
||||
if (!stristr($variables['url'], 'http://') && !stristr($variables['url'], 'https://')) {
|
||||
$variables['url'] = 'http://' . $variables['url'];
|
||||
}
|
||||
|
||||
// Prepare embed code
|
||||
if ($handler && isset($handler['function']) && function_exists($handler['function'])) {
|
||||
$embed_code = call_user_func($handler['function'], $variables['url'], $variables['style_settings']);
|
||||
$variables['embed_code'] = drupal_render($embed_code);
|
||||
}
|
||||
else {
|
||||
$variables['embed_code'] = l($variables['url'], $variables['url']);
|
||||
}
|
||||
|
||||
// Prepare video data
|
||||
$variables['data'] = $variables['video_data'];
|
||||
unset($variables['video_data']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns image style image with a link to
|
||||
* an embedded video in colorbox.
|
||||
*
|
||||
* @param $variables
|
||||
* An associative array containing:
|
||||
* - image_url: The image URL.
|
||||
* - image_style: The image style to use.
|
||||
* - video_url: The video URL.
|
||||
* - video_style: The video style to use.
|
||||
* - video_data: An array of data about the video.
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
function theme_video_embed_field_colorbox_code($variables) {
|
||||
$style = video_embed_field_video_style_load($variables['video_style']);
|
||||
|
||||
// If there was an issue load in the default style
|
||||
if ($style == FALSE) {
|
||||
$style = video_embed_field_video_style_load('normal');
|
||||
}
|
||||
|
||||
$handler = video_embed_get_handler($variables['video_url']);
|
||||
|
||||
$data = $style->data[$handler['name']];
|
||||
|
||||
//Create a unique ID for colorbox inline
|
||||
$id = uniqid('video_embed_field-' . rand());
|
||||
|
||||
if ($variables['image_style'] == 'none') {
|
||||
$image = array(
|
||||
array(
|
||||
'#theme' => 'image',
|
||||
'#path' => $variables['image_url'],
|
||||
),
|
||||
);
|
||||
}
|
||||
else {
|
||||
$image = array(
|
||||
'#theme' => 'image_style',
|
||||
'#path' => $variables['image_url'],
|
||||
'#style_name' => $variables['image_style'],
|
||||
);
|
||||
}
|
||||
|
||||
$image = drupal_render($image);
|
||||
|
||||
// Write values for later AJAX load
|
||||
$hash = _video_embed_field_store_video($variables['video_url'], $variables['video_style']);
|
||||
|
||||
$output = l($image, base_path() . '?q=vef/load/' . $hash . '&width=' . ($data['width']) . '&height=' . ($data['height'] + 3), array('html' => TRUE, 'external' => TRUE, 'attributes' => array('class' => array('colorbox-load'))));
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the thumbnail url for a given video url
|
||||
* @param $url - the url of the video
|
||||
* @return a string representing the url of the thumbnail, or FALSE on error
|
||||
*/
|
||||
function video_embed_field_thumbnail_url($url) {
|
||||
$handler = video_embed_get_handler($url);
|
||||
if ($handler && isset($handler['thumbnail_function']) && function_exists($handler['thumbnail_function'])) {
|
||||
$info = call_user_func($handler['thumbnail_function'], $url);
|
||||
$info['handler'] = $handler['name'];
|
||||
return $info;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a video data array for a given video url
|
||||
*
|
||||
* @param string $url
|
||||
* A video URL of the data array you want returned
|
||||
*
|
||||
* @return array|false $data
|
||||
* An array of video data, or FALSE on error
|
||||
*/
|
||||
function video_embed_field_get_video_data($url) {
|
||||
$handler = video_embed_get_handler($url);
|
||||
if ($handler && isset($handler['data_function']) && function_exists($handler['data_function'])) {
|
||||
$data = call_user_func($handler['data_function'], $url);
|
||||
$data['handler'] = $handler['name'];
|
||||
return $data;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch all available provider domains.
|
||||
*/
|
||||
function _video_embed_field_get_provider_domains() {
|
||||
$domains = array();
|
||||
|
||||
$handlers = video_embed_get_handlers();
|
||||
foreach ($handlers as $name => $handler) {
|
||||
if (isset($handler['function']) && function_exists($handler['function'])) {
|
||||
foreach ($handler['domains'] as $domain) {
|
||||
$domains[$domain] = $name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $domains;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch settings string
|
||||
*/
|
||||
function _video_embed_code_get_settings_str($settings = array()) {
|
||||
$values = array();
|
||||
|
||||
foreach ($settings as $name => $value) {
|
||||
if (empty($value)) {
|
||||
$values[] = $name;
|
||||
}
|
||||
else {
|
||||
$values[] = $name . '=' . $value;
|
||||
}
|
||||
}
|
||||
|
||||
return implode('&', $values);
|
||||
}
|
||||
|
||||
//used to array filter in video_embed_field_requirements
|
||||
function _video_embed_field_array_filter($item) {
|
||||
return (isset($item['type']) && $item['type'] == 'video_embed_field');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a video to be loaded later from an _video_embed_field_load_video
|
||||
*/
|
||||
function _video_embed_field_store_video($video_url, $video_style) {
|
||||
//create a hash key
|
||||
$hash = _video_embed_field_hash($video_url, $video_style);
|
||||
|
||||
//check that is record doesn't already exist before saving it
|
||||
if (!_video_embed_field_load_video($hash)) {
|
||||
$record = array(
|
||||
'vhash' => $hash,
|
||||
'video_url' => $video_url,
|
||||
'video_style' => $video_style,
|
||||
);
|
||||
|
||||
cache_set('vef-store-' . $hash, $record);
|
||||
|
||||
//add it to our static cache so we won't have to go to the database
|
||||
$static_cache = &drupal_static('vef_video_store', array());
|
||||
$static_cache[$hash] = $record;
|
||||
}
|
||||
return $hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to render a video for an Ajax call
|
||||
*/
|
||||
function _video_embed_field_show_video($hash) {
|
||||
$data = _video_embed_field_load_video($hash);
|
||||
$video = array(
|
||||
'#theme' => 'video_embed_field_embed_code',
|
||||
'#style' => $data['video_style'],
|
||||
'#url' => $data['video_url'],
|
||||
);
|
||||
|
||||
print drupal_render($video);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a video from the video store given its hash
|
||||
* Returns either the data - an array with hash, video_url and video_style keys
|
||||
*/
|
||||
function _video_embed_field_load_video($hash) {
|
||||
$static_cache = &drupal_static('vef_video_store', array());
|
||||
//check if we've already loaded it
|
||||
if (isset($static_cache[$hash])) {
|
||||
return $static_cache[$hash];
|
||||
}
|
||||
else {
|
||||
|
||||
$result = cache_get('vef-store-' . $hash);
|
||||
if ($result) {
|
||||
//cache it before returning
|
||||
$data = $result->data;
|
||||
$static_cache[$hash] = $data;
|
||||
return $data;
|
||||
}
|
||||
else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a hash for storing or looking up a video in the store table
|
||||
*/
|
||||
function _video_embed_field_hash($video_url, $video_style) {
|
||||
return md5('vef' . $video_url . $video_style);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* admin.features.filter.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_filter_default_formats().
|
||||
*/
|
||||
function admin_filter_default_formats() {
|
||||
$formats = array();
|
||||
|
||||
// Exported format: Filtred html.
|
||||
$formats['filtred_html'] = array(
|
||||
'format' => 'filtred_html',
|
||||
'name' => 'Filtred html',
|
||||
'cache' => 1,
|
||||
'status' => 1,
|
||||
'weight' => 0,
|
||||
'filters' => array(
|
||||
'filter_html' => array(
|
||||
'weight' => -10,
|
||||
'status' => 1,
|
||||
'settings' => array(
|
||||
'allowed_html' => '<a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <p> <br> <img> <h6> <h5> <h4> <h3> <h2> <h1>',
|
||||
'filter_html_help' => 1,
|
||||
'filter_html_nofollow' => 0,
|
||||
),
|
||||
),
|
||||
'filter_url' => array(
|
||||
'weight' => 0,
|
||||
'status' => 1,
|
||||
'settings' => array(
|
||||
'filter_url_length' => 72,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Exported format: Plain text.
|
||||
$formats['plain_text'] = array(
|
||||
'format' => 'plain_text',
|
||||
'name' => 'Plain text',
|
||||
'cache' => 1,
|
||||
'status' => 1,
|
||||
'weight' => 10,
|
||||
'filters' => array(
|
||||
'filter_html_escape' => array(
|
||||
'weight' => 0,
|
||||
'status' => 1,
|
||||
'settings' => array(),
|
||||
),
|
||||
'filter_url' => array(
|
||||
'weight' => 1,
|
||||
'status' => 1,
|
||||
'settings' => array(
|
||||
'filter_url_length' => 72,
|
||||
),
|
||||
),
|
||||
'filter_autop' => array(
|
||||
'weight' => 2,
|
||||
'status' => 1,
|
||||
'settings' => array(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $formats;
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* admin.features.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_ctools_plugin_api().
|
||||
*/
|
||||
function admin_ctools_plugin_api($module = NULL, $api = NULL) {
|
||||
if ($module == "strongarm" && $api == "strongarm") {
|
||||
return array("version" => "1");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_views_api().
|
||||
*/
|
||||
function admin_views_api($module = NULL, $api = NULL) {
|
||||
return array("api" => "3.0");
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_workflow_default_workflows().
|
||||
*/
|
||||
function admin_workflow_default_workflows() {
|
||||
$workflows = array();
|
||||
|
||||
// Exported workflow: Affichage
|
||||
$workflows['Affichage'] = array(
|
||||
'name' => 'Affichage',
|
||||
'tab_roles' => 4,
|
||||
'options' => 'a:4:{s:16:"comment_log_node";s:1:"0";s:15:"comment_log_tab";s:1:"0";s:13:"name_as_title";s:1:"0";s:12:"watchdog_log";s:1:"0";}',
|
||||
'states' => array(
|
||||
0 => array(
|
||||
'state' => '(creation)',
|
||||
'weight' => -50,
|
||||
'sysid' => 1,
|
||||
'status' => 1,
|
||||
'name' => 'Affichage',
|
||||
),
|
||||
1 => array(
|
||||
'state' => 'Masqué',
|
||||
'weight' => -20,
|
||||
'sysid' => 0,
|
||||
'status' => 1,
|
||||
'name' => 'Affichage',
|
||||
),
|
||||
2 => array(
|
||||
'state' => 'Affiché',
|
||||
'weight' => -20,
|
||||
'sysid' => 0,
|
||||
'status' => 1,
|
||||
'name' => 'Affichage',
|
||||
),
|
||||
),
|
||||
'transitions' => array(
|
||||
0 => array(
|
||||
'roles' => 'workflow_features_author_name,administrator,root',
|
||||
'state' => '(creation)',
|
||||
'target_state' => 'Masqué',
|
||||
),
|
||||
1 => array(
|
||||
'roles' => 'workflow_features_author_name,administrator,root',
|
||||
'state' => '(creation)',
|
||||
'target_state' => 'Affiché',
|
||||
),
|
||||
2 => array(
|
||||
'roles' => 'workflow_features_author_name,administrator,root',
|
||||
'state' => 'Masqué',
|
||||
'target_state' => 'Affiché',
|
||||
),
|
||||
3 => array(
|
||||
'roles' => 'workflow_features_author_name,administrator,root',
|
||||
'state' => 'Affiché',
|
||||
'target_state' => 'Masqué',
|
||||
),
|
||||
),
|
||||
'node_types' => array(
|
||||
0 => 'chapitre',
|
||||
1 => 'page',
|
||||
),
|
||||
);
|
||||
|
||||
return $workflows;
|
||||
}
|
||||
@@ -0,0 +1,783 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* admin.features.user_permission.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_user_default_permissions().
|
||||
*/
|
||||
function admin_user_default_permissions() {
|
||||
$permissions = array();
|
||||
|
||||
// Exported permission: 'access admin theme'.
|
||||
$permissions['access admin theme'] = array(
|
||||
'name' => 'access admin theme',
|
||||
'roles' => array(
|
||||
'administrator' => 'administrator',
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'admin_theme',
|
||||
);
|
||||
|
||||
// Exported permission: 'access administration menu'.
|
||||
$permissions['access administration menu'] = array(
|
||||
'name' => 'access administration menu',
|
||||
'roles' => array(
|
||||
'administrator' => 'administrator',
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'admin_menu',
|
||||
);
|
||||
|
||||
// Exported permission: 'access administration pages'.
|
||||
$permissions['access administration pages'] = array(
|
||||
'name' => 'access administration pages',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'system',
|
||||
);
|
||||
|
||||
// Exported permission: 'access all views'.
|
||||
$permissions['access all views'] = array(
|
||||
'name' => 'access all views',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'views',
|
||||
);
|
||||
|
||||
// Exported permission: 'access backup and migrate'.
|
||||
$permissions['access backup and migrate'] = array(
|
||||
'name' => 'access backup and migrate',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'backup_migrate',
|
||||
);
|
||||
|
||||
// Exported permission: 'access backup files'.
|
||||
$permissions['access backup files'] = array(
|
||||
'name' => 'access backup files',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'backup_migrate',
|
||||
);
|
||||
|
||||
// Exported permission: 'access content'.
|
||||
$permissions['access content'] = array(
|
||||
'name' => 'access content',
|
||||
'roles' => array(
|
||||
'anonymous user' => 'anonymous user',
|
||||
'authenticated user' => 'authenticated user',
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'node',
|
||||
);
|
||||
|
||||
// Exported permission: 'access content overview'.
|
||||
$permissions['access content overview'] = array(
|
||||
'name' => 'access content overview',
|
||||
'roles' => array(
|
||||
'administrator' => 'administrator',
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'node',
|
||||
);
|
||||
|
||||
// Exported permission: 'access dashboard'.
|
||||
$permissions['access dashboard'] = array(
|
||||
'name' => 'access dashboard',
|
||||
'roles' => array(
|
||||
'administrator' => 'administrator',
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'dashboard',
|
||||
);
|
||||
|
||||
// Exported permission: 'access rules debug'.
|
||||
$permissions['access rules debug'] = array(
|
||||
'name' => 'access rules debug',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'rules',
|
||||
);
|
||||
|
||||
// Exported permission: 'access site in maintenance mode'.
|
||||
$permissions['access site in maintenance mode'] = array(
|
||||
'name' => 'access site in maintenance mode',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'system',
|
||||
);
|
||||
|
||||
// Exported permission: 'access site reports'.
|
||||
$permissions['access site reports'] = array(
|
||||
'name' => 'access site reports',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'system',
|
||||
);
|
||||
|
||||
// Exported permission: 'access user profiles'.
|
||||
$permissions['access user profiles'] = array(
|
||||
'name' => 'access user profiles',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'user',
|
||||
);
|
||||
|
||||
// Exported permission: 'access workflow summary views'.
|
||||
$permissions['access workflow summary views'] = array(
|
||||
'name' => 'access workflow summary views',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'workflow_views',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer actions'.
|
||||
$permissions['administer actions'] = array(
|
||||
'name' => 'administer actions',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'system',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer backup and migrate'.
|
||||
$permissions['administer backup and migrate'] = array(
|
||||
'name' => 'administer backup and migrate',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'backup_migrate',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer blocks'.
|
||||
$permissions['administer blocks'] = array(
|
||||
'name' => 'administer blocks',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'block',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer content type defaults'.
|
||||
$permissions['administer content type defaults'] = array(
|
||||
'name' => 'administer content type defaults',
|
||||
'roles' => array(),
|
||||
'module' => 'content_type_extras',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer content types'.
|
||||
$permissions['administer content types'] = array(
|
||||
'name' => 'administer content types',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'node',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer contexts'.
|
||||
$permissions['administer contexts'] = array(
|
||||
'name' => 'administer contexts',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'context_ui',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer devel menu items'.
|
||||
$permissions['administer devel menu items'] = array(
|
||||
'name' => 'administer devel menu items',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'menu_admin_per_menu',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer features'.
|
||||
$permissions['administer features'] = array(
|
||||
'name' => 'administer features',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'features',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer features menu items'.
|
||||
$permissions['administer features menu items'] = array(
|
||||
'name' => 'administer features menu items',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'menu_admin_per_menu',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer imce'.
|
||||
$permissions['administer imce'] = array(
|
||||
'name' => 'administer imce',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'imce',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer linkit'.
|
||||
$permissions['administer linkit'] = array(
|
||||
'name' => 'administer linkit',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'linkit',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer main-menu menu items'.
|
||||
$permissions['administer main-menu menu items'] = array(
|
||||
'name' => 'administer main-menu menu items',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'menu_admin_per_menu',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer management menu items'.
|
||||
$permissions['administer management menu items'] = array(
|
||||
'name' => 'administer management menu items',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'menu_admin_per_menu',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer menu'.
|
||||
$permissions['administer menu'] = array(
|
||||
'name' => 'administer menu',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'menu',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer module filter'.
|
||||
$permissions['administer module filter'] = array(
|
||||
'name' => 'administer module filter',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'module_filter',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer modules'.
|
||||
$permissions['administer modules'] = array(
|
||||
'name' => 'administer modules',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'system',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer navigation menu items'.
|
||||
$permissions['administer navigation menu items'] = array(
|
||||
'name' => 'administer navigation menu items',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'menu_admin_per_menu',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer nodes'.
|
||||
$permissions['administer nodes'] = array(
|
||||
'name' => 'administer nodes',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'node',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer pathauto'.
|
||||
$permissions['administer pathauto'] = array(
|
||||
'name' => 'administer pathauto',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'pathauto',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer permissions'.
|
||||
$permissions['administer permissions'] = array(
|
||||
'name' => 'administer permissions',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'user',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer redirects'.
|
||||
$permissions['administer redirects'] = array(
|
||||
'name' => 'administer redirects',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'redirect',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer rules'.
|
||||
$permissions['administer rules'] = array(
|
||||
'name' => 'administer rules',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'rules',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer shortcuts'.
|
||||
$permissions['administer shortcuts'] = array(
|
||||
'name' => 'administer shortcuts',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'shortcut',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer site configuration'.
|
||||
$permissions['administer site configuration'] = array(
|
||||
'name' => 'administer site configuration',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'system',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer software updates'.
|
||||
$permissions['administer software updates'] = array(
|
||||
'name' => 'administer software updates',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'system',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer styles ui'.
|
||||
$permissions['administer styles ui'] = array(
|
||||
'name' => 'administer styles ui',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'styles_ui',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer themes'.
|
||||
$permissions['administer themes'] = array(
|
||||
'name' => 'administer themes',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'system',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer url aliases'.
|
||||
$permissions['administer url aliases'] = array(
|
||||
'name' => 'administer url aliases',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'path',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer user-menu menu items'.
|
||||
$permissions['administer user-menu menu items'] = array(
|
||||
'name' => 'administer user-menu menu items',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'menu_admin_per_menu',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer users'.
|
||||
$permissions['administer users'] = array(
|
||||
'name' => 'administer users',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'user',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer views'.
|
||||
$permissions['administer views'] = array(
|
||||
'name' => 'administer views',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'views',
|
||||
);
|
||||
|
||||
// Exported permission: 'administer workflow'.
|
||||
$permissions['administer workflow'] = array(
|
||||
'name' => 'administer workflow',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'workflow_admin_ui',
|
||||
);
|
||||
|
||||
// Exported permission: 'block IP addresses'.
|
||||
$permissions['block IP addresses'] = array(
|
||||
'name' => 'block IP addresses',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'system',
|
||||
);
|
||||
|
||||
// Exported permission: 'bypass node access'.
|
||||
$permissions['bypass node access'] = array(
|
||||
'name' => 'bypass node access',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'node',
|
||||
);
|
||||
|
||||
// Exported permission: 'bypass rules access'.
|
||||
$permissions['bypass rules access'] = array(
|
||||
'name' => 'bypass rules access',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'rules',
|
||||
);
|
||||
|
||||
// Exported permission: 'cancel account'.
|
||||
$permissions['cancel account'] = array(
|
||||
'name' => 'cancel account',
|
||||
'roles' => array(
|
||||
'administrator' => 'administrator',
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'user',
|
||||
);
|
||||
|
||||
// Exported permission: 'change own username'.
|
||||
$permissions['change own username'] = array(
|
||||
'name' => 'change own username',
|
||||
'roles' => array(
|
||||
'administrator' => 'administrator',
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'user',
|
||||
);
|
||||
|
||||
// Exported permission: 'context ajax block access'.
|
||||
$permissions['context ajax block access'] = array(
|
||||
'name' => 'context ajax block access',
|
||||
'roles' => array(),
|
||||
'module' => 'context_ui',
|
||||
);
|
||||
|
||||
// Exported permission: 'create url aliases'.
|
||||
$permissions['create url aliases'] = array(
|
||||
'name' => 'create url aliases',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'path',
|
||||
);
|
||||
|
||||
// Exported permission: 'customize shortcut links'.
|
||||
$permissions['customize shortcut links'] = array(
|
||||
'name' => 'customize shortcut links',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'shortcut',
|
||||
);
|
||||
|
||||
// Exported permission: 'delete backup files'.
|
||||
$permissions['delete backup files'] = array(
|
||||
'name' => 'delete backup files',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'backup_migrate',
|
||||
);
|
||||
|
||||
// Exported permission: 'delete revisions'.
|
||||
$permissions['delete revisions'] = array(
|
||||
'name' => 'delete revisions',
|
||||
'roles' => array(
|
||||
'administrator' => 'administrator',
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'node',
|
||||
);
|
||||
|
||||
// Exported permission: 'display drupal links'.
|
||||
$permissions['display drupal links'] = array(
|
||||
'name' => 'display drupal links',
|
||||
'roles' => array(
|
||||
'administrator' => 'administrator',
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'admin_menu',
|
||||
);
|
||||
|
||||
// Exported permission: 'execute php code'.
|
||||
$permissions['execute php code'] = array(
|
||||
'name' => 'execute php code',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'devel',
|
||||
);
|
||||
|
||||
// Exported permission: 'flush caches'.
|
||||
$permissions['flush caches'] = array(
|
||||
'name' => 'flush caches',
|
||||
'roles' => array(
|
||||
'administrator' => 'administrator',
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'admin_menu',
|
||||
);
|
||||
|
||||
// Exported permission: 'generate features'.
|
||||
$permissions['generate features'] = array(
|
||||
'name' => 'generate features',
|
||||
'roles' => array(),
|
||||
'module' => 'features',
|
||||
);
|
||||
|
||||
// Exported permission: 'manage features'.
|
||||
$permissions['manage features'] = array(
|
||||
'name' => 'manage features',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'features',
|
||||
);
|
||||
|
||||
// Exported permission: 'menu edit devel'.
|
||||
$permissions['menu edit devel'] = array(
|
||||
'name' => 'menu edit devel',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'menu_editor',
|
||||
);
|
||||
|
||||
// Exported permission: 'menu edit features'.
|
||||
$permissions['menu edit features'] = array(
|
||||
'name' => 'menu edit features',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'menu_editor',
|
||||
);
|
||||
|
||||
// Exported permission: 'menu edit main-menu'.
|
||||
$permissions['menu edit main-menu'] = array(
|
||||
'name' => 'menu edit main-menu',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'menu_editor',
|
||||
);
|
||||
|
||||
// Exported permission: 'menu edit management'.
|
||||
$permissions['menu edit management'] = array(
|
||||
'name' => 'menu edit management',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'menu_editor',
|
||||
);
|
||||
|
||||
// Exported permission: 'menu edit navigation'.
|
||||
$permissions['menu edit navigation'] = array(
|
||||
'name' => 'menu edit navigation',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'menu_editor',
|
||||
);
|
||||
|
||||
// Exported permission: 'menu edit user-menu'.
|
||||
$permissions['menu edit user-menu'] = array(
|
||||
'name' => 'menu edit user-menu',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'menu_editor',
|
||||
);
|
||||
|
||||
// Exported permission: 'notify of path changes'.
|
||||
$permissions['notify of path changes'] = array(
|
||||
'name' => 'notify of path changes',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'pathauto',
|
||||
);
|
||||
|
||||
// Exported permission: 'override content type title display'.
|
||||
$permissions['override content type title display'] = array(
|
||||
'name' => 'override content type title display',
|
||||
'roles' => array(),
|
||||
'module' => 'content_type_extras',
|
||||
);
|
||||
|
||||
// Exported permission: 'participate in workflow'.
|
||||
$permissions['participate in workflow'] = array(
|
||||
'name' => 'participate in workflow',
|
||||
'roles' => array(
|
||||
'administrator' => 'administrator',
|
||||
'anonymous user' => 'anonymous user',
|
||||
'authenticated user' => 'authenticated user',
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'workflow_admin_ui',
|
||||
);
|
||||
|
||||
// Exported permission: 'perform backup'.
|
||||
$permissions['perform backup'] = array(
|
||||
'name' => 'perform backup',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'backup_migrate',
|
||||
);
|
||||
|
||||
// Exported permission: 'rename features'.
|
||||
$permissions['rename features'] = array(
|
||||
'name' => 'rename features',
|
||||
'roles' => array(),
|
||||
'module' => 'features',
|
||||
);
|
||||
|
||||
// Exported permission: 'restore from backup'.
|
||||
$permissions['restore from backup'] = array(
|
||||
'name' => 'restore from backup',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'backup_migrate',
|
||||
);
|
||||
|
||||
// Exported permission: 'revert revisions'.
|
||||
$permissions['revert revisions'] = array(
|
||||
'name' => 'revert revisions',
|
||||
'roles' => array(
|
||||
'administrator' => 'administrator',
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'node',
|
||||
);
|
||||
|
||||
// Exported permission: 'schedule workflow transitions'.
|
||||
$permissions['schedule workflow transitions'] = array(
|
||||
'name' => 'schedule workflow transitions',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'workflow',
|
||||
);
|
||||
|
||||
// Exported permission: 'select account cancellation method'.
|
||||
$permissions['select account cancellation method'] = array(
|
||||
'name' => 'select account cancellation method',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'user',
|
||||
);
|
||||
|
||||
// Exported permission: 'show workflow state form'.
|
||||
$permissions['show workflow state form'] = array(
|
||||
'name' => 'show workflow state form',
|
||||
'roles' => array(),
|
||||
'module' => 'workflow',
|
||||
);
|
||||
|
||||
// Exported permission: 'switch shortcut sets'.
|
||||
$permissions['switch shortcut sets'] = array(
|
||||
'name' => 'switch shortcut sets',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'shortcut',
|
||||
);
|
||||
|
||||
// Exported permission: 'switch users'.
|
||||
$permissions['switch users'] = array(
|
||||
'name' => 'switch users',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'devel',
|
||||
);
|
||||
|
||||
// Exported permission: 'translate content'.
|
||||
$permissions['translate content'] = array(
|
||||
'name' => 'translate content',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'translation',
|
||||
);
|
||||
|
||||
// Exported permission: 'use ctools import'.
|
||||
$permissions['use ctools import'] = array(
|
||||
'name' => 'use ctools import',
|
||||
'roles' => array(),
|
||||
'module' => 'ctools',
|
||||
);
|
||||
|
||||
// Exported permission: 'use text format filtred_html'.
|
||||
$permissions['use text format filtred_html'] = array(
|
||||
'name' => 'use text format filtred_html',
|
||||
'roles' => array(
|
||||
'administrator' => 'administrator',
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'filter',
|
||||
);
|
||||
|
||||
// Exported permission: 'view own unpublished content'.
|
||||
$permissions['view own unpublished content'] = array(
|
||||
'name' => 'view own unpublished content',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'node',
|
||||
);
|
||||
|
||||
// Exported permission: 'view revisions'.
|
||||
$permissions['view revisions'] = array(
|
||||
'name' => 'view revisions',
|
||||
'roles' => array(
|
||||
'administrator' => 'administrator',
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'node',
|
||||
);
|
||||
|
||||
// Exported permission: 'view the administration theme'.
|
||||
$permissions['view the administration theme'] = array(
|
||||
'name' => 'view the administration theme',
|
||||
'roles' => array(
|
||||
'administrator' => 'administrator',
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'system',
|
||||
);
|
||||
|
||||
return $permissions;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* admin.features.user_role.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_user_default_roles().
|
||||
*/
|
||||
function admin_user_default_roles() {
|
||||
$roles = array();
|
||||
|
||||
// Exported role: administrator.
|
||||
$roles['administrator'] = array(
|
||||
'name' => 'administrator',
|
||||
'weight' => 2,
|
||||
);
|
||||
|
||||
// Exported role: anonymous user.
|
||||
$roles['anonymous user'] = array(
|
||||
'name' => 'anonymous user',
|
||||
'weight' => 0,
|
||||
);
|
||||
|
||||
// Exported role: authenticated user.
|
||||
$roles['authenticated user'] = array(
|
||||
'name' => 'authenticated user',
|
||||
'weight' => 1,
|
||||
);
|
||||
|
||||
// Exported role: root.
|
||||
$roles['root'] = array(
|
||||
'name' => 'root',
|
||||
'weight' => 3,
|
||||
);
|
||||
|
||||
return $roles;
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* admin.features.workflow_access.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_workflow_access_features_default_settings().
|
||||
*/
|
||||
function admin_workflow_access_features_default_settings() {
|
||||
$workflows = array();
|
||||
|
||||
$workflows['Affichage'] = array();
|
||||
$workflows['Affichage']['Masqué'] = array();
|
||||
$workflows['Affichage']['Masqué']['administrator'] = array(
|
||||
'grant_view' => 1,
|
||||
'grant_update' => 1,
|
||||
'grant_delete' => 1,
|
||||
);
|
||||
$workflows['Affichage']['Masqué']['root'] = array(
|
||||
'grant_view' => 1,
|
||||
'grant_update' => 1,
|
||||
'grant_delete' => 1,
|
||||
);
|
||||
$workflows['Affichage']['Masqué']['anonymous user'] = array(
|
||||
'grant_view' => 0,
|
||||
'grant_update' => 0,
|
||||
'grant_delete' => 0,
|
||||
);
|
||||
$workflows['Affichage']['Masqué']['authenticated user'] = array(
|
||||
'grant_view' => 0,
|
||||
'grant_update' => 0,
|
||||
'grant_delete' => 0,
|
||||
);
|
||||
$workflows['Affichage']['Masqué']['workflow_features_author_name'] = array(
|
||||
'grant_view' => 0,
|
||||
'grant_update' => 0,
|
||||
'grant_delete' => 0,
|
||||
);
|
||||
$workflows['Affichage']['Affiché'] = array();
|
||||
$workflows['Affichage']['Affiché']['anonymous user'] = array(
|
||||
'grant_view' => 1,
|
||||
'grant_update' => 0,
|
||||
'grant_delete' => 0,
|
||||
);
|
||||
$workflows['Affichage']['Affiché']['authenticated user'] = array(
|
||||
'grant_view' => 1,
|
||||
'grant_update' => 0,
|
||||
'grant_delete' => 0,
|
||||
);
|
||||
$workflows['Affichage']['Affiché']['administrator'] = array(
|
||||
'grant_view' => 0,
|
||||
'grant_update' => 1,
|
||||
'grant_delete' => 1,
|
||||
);
|
||||
$workflows['Affichage']['Affiché']['root'] = array(
|
||||
'grant_view' => 0,
|
||||
'grant_update' => 1,
|
||||
'grant_delete' => 1,
|
||||
);
|
||||
$workflows['Affichage']['Affiché']['workflow_features_author_name'] = array(
|
||||
'grant_view' => 0,
|
||||
'grant_update' => 0,
|
||||
'grant_delete' => 0,
|
||||
);
|
||||
|
||||
return $workflows;
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* admin.features.wysiwyg.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_wysiwyg_default_profiles().
|
||||
*/
|
||||
function admin_wysiwyg_default_profiles() {
|
||||
$profiles = array();
|
||||
|
||||
// Exported profile: filtred_html
|
||||
$profiles['filtred_html'] = array(
|
||||
'format' => 'filtred_html',
|
||||
'editor' => 'tinymce',
|
||||
'settings' => array(
|
||||
'default' => 1,
|
||||
'user_choose' => 0,
|
||||
'show_toggle' => 1,
|
||||
'theme' => 'advanced',
|
||||
'language' => 'en',
|
||||
'buttons' => array(
|
||||
'default' => array(
|
||||
'bold' => 1,
|
||||
'italic' => 1,
|
||||
'underline' => 1,
|
||||
'bullist' => 1,
|
||||
'numlist' => 1,
|
||||
'undo' => 1,
|
||||
'redo' => 1,
|
||||
'link' => 1,
|
||||
'unlink' => 1,
|
||||
'image' => 1,
|
||||
'cut' => 1,
|
||||
'copy' => 1,
|
||||
'paste' => 1,
|
||||
),
|
||||
'advimage' => array(
|
||||
'advimage' => 1,
|
||||
),
|
||||
'advlink' => array(
|
||||
'advlink' => 1,
|
||||
),
|
||||
'font' => array(
|
||||
'formatselect' => 1,
|
||||
),
|
||||
'fullscreen' => array(
|
||||
'fullscreen' => 1,
|
||||
),
|
||||
'paste' => array(
|
||||
'pastetext' => 1,
|
||||
),
|
||||
'searchreplace' => array(
|
||||
'search' => 1,
|
||||
'replace' => 1,
|
||||
),
|
||||
'advlist' => array(
|
||||
'advlist' => 1,
|
||||
),
|
||||
'wordcount' => array(
|
||||
'wordcount' => 1,
|
||||
),
|
||||
'video_filter' => array(
|
||||
'video_filter' => 1,
|
||||
),
|
||||
'drupal' => array(
|
||||
'break' => 1,
|
||||
),
|
||||
),
|
||||
'toolbar_loc' => 'top',
|
||||
'toolbar_align' => 'left',
|
||||
'path_loc' => 'bottom',
|
||||
'resizing' => 1,
|
||||
'verify_html' => 1,
|
||||
'preformatted' => 0,
|
||||
'convert_fonts_to_spans' => 1,
|
||||
'remove_linebreaks' => 1,
|
||||
'apply_source_formatting' => 0,
|
||||
'paste_auto_cleanup_on_paste' => 1,
|
||||
'block_formats' => 'h2,h3,h4,h5,h6',
|
||||
'css_setting' => 'theme',
|
||||
'css_path' => '',
|
||||
'css_classes' => '',
|
||||
'buttonorder' => 'fullscreen,separator,bold,italic,underline,separator,formatselect,separator,bullist,numlist,advlist,separator,link,advlink,unlink,separator,image,advimage,video_filter,separator,cut,copy,paste,pastetext,search,replace,wordcount,separator,undo,redo,separator,break',
|
||||
),
|
||||
);
|
||||
|
||||
return $profiles;
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
name = Admin
|
||||
core = 7.x
|
||||
package = Gui
|
||||
dependencies[] = admin_menu
|
||||
dependencies[] = admin_menu_source
|
||||
dependencies[] = admin_theme
|
||||
dependencies[] = adminimal_admin_menu
|
||||
dependencies[] = auto_nodetitle
|
||||
dependencies[] = backup_migrate
|
||||
dependencies[] = content_type_extras
|
||||
dependencies[] = context_layouts
|
||||
dependencies[] = context_ui
|
||||
dependencies[] = ctools
|
||||
dependencies[] = dashboard
|
||||
dependencies[] = devel
|
||||
dependencies[] = extlink
|
||||
dependencies[] = fe_block
|
||||
dependencies[] = fe_profile
|
||||
dependencies[] = features
|
||||
dependencies[] = file
|
||||
dependencies[] = filter
|
||||
dependencies[] = filter_perms
|
||||
dependencies[] = footer_message
|
||||
dependencies[] = fpa
|
||||
dependencies[] = genpass
|
||||
dependencies[] = imce
|
||||
dependencies[] = linkit
|
||||
dependencies[] = login_destination
|
||||
dependencies[] = logintoboggan_rules
|
||||
dependencies[] = logintoboggan_variable
|
||||
dependencies[] = me_path_autocomplete
|
||||
dependencies[] = menu
|
||||
dependencies[] = menu_admin_per_menu
|
||||
dependencies[] = module_filter
|
||||
dependencies[] = node
|
||||
dependencies[] = nodeformcols
|
||||
dependencies[] = path
|
||||
dependencies[] = pathauto
|
||||
dependencies[] = redirect
|
||||
dependencies[] = rules_admin
|
||||
dependencies[] = shortcut
|
||||
dependencies[] = strongarm
|
||||
dependencies[] = styles_ui
|
||||
dependencies[] = syslog
|
||||
dependencies[] = system
|
||||
dependencies[] = translation
|
||||
dependencies[] = user
|
||||
dependencies[] = variable_admin
|
||||
dependencies[] = variable_realm
|
||||
dependencies[] = variable_store
|
||||
dependencies[] = views
|
||||
dependencies[] = views_ui
|
||||
dependencies[] = workflow
|
||||
dependencies[] = workflow_access
|
||||
dependencies[] = workflow_actions
|
||||
dependencies[] = workflow_admin_ui
|
||||
dependencies[] = workflow_rules
|
||||
dependencies[] = workflow_vbo
|
||||
dependencies[] = workflow_views
|
||||
dependencies[] = wysiwyg
|
||||
dependencies[] = wysiwyg_button_order
|
||||
dependencies[] = wysiwyg_filter
|
||||
features[ctools][] = strongarm:strongarm:1
|
||||
features[ctools][] = views:views_default:3.0
|
||||
features[features_api][] = api:2
|
||||
features[filter][] = filtred_html
|
||||
features[filter][] = plain_text
|
||||
features[user_permission][] = access admin theme
|
||||
features[user_permission][] = access administration menu
|
||||
features[user_permission][] = access administration pages
|
||||
features[user_permission][] = access all views
|
||||
features[user_permission][] = access backup and migrate
|
||||
features[user_permission][] = access backup files
|
||||
features[user_permission][] = access content
|
||||
features[user_permission][] = access content overview
|
||||
features[user_permission][] = access dashboard
|
||||
features[user_permission][] = access rules debug
|
||||
features[user_permission][] = access site in maintenance mode
|
||||
features[user_permission][] = access site reports
|
||||
features[user_permission][] = access user profiles
|
||||
features[user_permission][] = access workflow summary views
|
||||
features[user_permission][] = administer actions
|
||||
features[user_permission][] = administer backup and migrate
|
||||
features[user_permission][] = administer blocks
|
||||
features[user_permission][] = administer content type defaults
|
||||
features[user_permission][] = administer content types
|
||||
features[user_permission][] = administer contexts
|
||||
features[user_permission][] = administer devel menu items
|
||||
features[user_permission][] = administer features
|
||||
features[user_permission][] = administer features menu items
|
||||
features[user_permission][] = administer imce
|
||||
features[user_permission][] = administer linkit
|
||||
features[user_permission][] = administer main-menu menu items
|
||||
features[user_permission][] = administer management menu items
|
||||
features[user_permission][] = administer menu
|
||||
features[user_permission][] = administer module filter
|
||||
features[user_permission][] = administer modules
|
||||
features[user_permission][] = administer navigation menu items
|
||||
features[user_permission][] = administer nodes
|
||||
features[user_permission][] = administer pathauto
|
||||
features[user_permission][] = administer permissions
|
||||
features[user_permission][] = administer redirects
|
||||
features[user_permission][] = administer rules
|
||||
features[user_permission][] = administer shortcuts
|
||||
features[user_permission][] = administer site configuration
|
||||
features[user_permission][] = administer software updates
|
||||
features[user_permission][] = administer styles ui
|
||||
features[user_permission][] = administer themes
|
||||
features[user_permission][] = administer url aliases
|
||||
features[user_permission][] = administer user-menu menu items
|
||||
features[user_permission][] = administer users
|
||||
features[user_permission][] = administer views
|
||||
features[user_permission][] = administer workflow
|
||||
features[user_permission][] = block IP addresses
|
||||
features[user_permission][] = bypass node access
|
||||
features[user_permission][] = bypass rules access
|
||||
features[user_permission][] = cancel account
|
||||
features[user_permission][] = change own username
|
||||
features[user_permission][] = context ajax block access
|
||||
features[user_permission][] = create url aliases
|
||||
features[user_permission][] = customize shortcut links
|
||||
features[user_permission][] = delete backup files
|
||||
features[user_permission][] = delete revisions
|
||||
features[user_permission][] = display drupal links
|
||||
features[user_permission][] = execute php code
|
||||
features[user_permission][] = flush caches
|
||||
features[user_permission][] = generate features
|
||||
features[user_permission][] = manage features
|
||||
features[user_permission][] = menu edit devel
|
||||
features[user_permission][] = menu edit features
|
||||
features[user_permission][] = menu edit main-menu
|
||||
features[user_permission][] = menu edit management
|
||||
features[user_permission][] = menu edit navigation
|
||||
features[user_permission][] = menu edit user-menu
|
||||
features[user_permission][] = notify of path changes
|
||||
features[user_permission][] = override content type title display
|
||||
features[user_permission][] = participate in workflow
|
||||
features[user_permission][] = perform backup
|
||||
features[user_permission][] = rename features
|
||||
features[user_permission][] = restore from backup
|
||||
features[user_permission][] = revert revisions
|
||||
features[user_permission][] = schedule workflow transitions
|
||||
features[user_permission][] = select account cancellation method
|
||||
features[user_permission][] = show workflow state form
|
||||
features[user_permission][] = switch shortcut sets
|
||||
features[user_permission][] = switch users
|
||||
features[user_permission][] = translate content
|
||||
features[user_permission][] = use ctools import
|
||||
features[user_permission][] = use text format filtred_html
|
||||
features[user_permission][] = view own unpublished content
|
||||
features[user_permission][] = view revisions
|
||||
features[user_permission][] = view the administration theme
|
||||
features[user_role][] = administrator
|
||||
features[user_role][] = anonymous user
|
||||
features[user_role][] = authenticated user
|
||||
features[user_role][] = root
|
||||
features[variable][] = admin_menu_devel_modules_skip
|
||||
features[variable][] = admin_menu_display
|
||||
features[variable][] = admin_menu_margin_top
|
||||
features[variable][] = admin_menu_position_fixed
|
||||
features[variable][] = admin_menu_show_all
|
||||
features[variable][] = admin_menu_source_settings
|
||||
features[variable][] = admin_menu_tweak_modules
|
||||
features[variable][] = admin_menu_tweak_permissions
|
||||
features[variable][] = admin_menu_tweak_tabs
|
||||
features[variable][] = admin_theme
|
||||
features[variable][] = admin_theme_admin_theme_batch
|
||||
features[variable][] = admin_theme_admin_theme_devel
|
||||
features[variable][] = admin_theme_path
|
||||
features[variable][] = admin_theme_path_disallow
|
||||
features[variable][] = admin_toolbar
|
||||
features[variable][] = adminimal_admin_menu_toolbar-disabled
|
||||
features[variable][] = node_admin_theme
|
||||
features[variable][] = theme_adaptivetheme_admin_settings
|
||||
features[variable][] = theme_adaptivetheme_gui_admin_settings
|
||||
features[variable][] = user_admin_role
|
||||
features[variable][] = user_mail_register_admin_created_body
|
||||
features[variable][] = user_mail_register_admin_created_subject
|
||||
features[variable][] = workflow_access_priority
|
||||
features[variable][] = workflow_chapitre
|
||||
features[variable][] = workflow_page
|
||||
features[views_view][] = admin_contents
|
||||
features[workflow][] = Affichage
|
||||
features[workflow_access][] = Affichage
|
||||
features[wysiwyg][] = filtred_html
|
||||
project path = sites/all/modules/features
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Code for the Admin feature.
|
||||
*/
|
||||
|
||||
include_once 'admin.features.inc';
|
||||
@@ -0,0 +1,296 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* admin.strongarm.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_strongarm().
|
||||
*/
|
||||
function admin_strongarm() {
|
||||
$export = array();
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'adminimal_admin_menu_toolbar-disabled';
|
||||
$strongarm->value = TRUE;
|
||||
$export['adminimal_admin_menu_toolbar-disabled'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'admin_menu_devel_modules_skip';
|
||||
$strongarm->value = array(
|
||||
'devel' => 0,
|
||||
'devel_node_access' => 0,
|
||||
'views_ui' => 0,
|
||||
);
|
||||
$export['admin_menu_devel_modules_skip'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'admin_menu_display';
|
||||
$strongarm->value = 'plid';
|
||||
$export['admin_menu_display'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'admin_menu_margin_top';
|
||||
$strongarm->value = 1;
|
||||
$export['admin_menu_margin_top'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'admin_menu_position_fixed';
|
||||
$strongarm->value = 0;
|
||||
$export['admin_menu_position_fixed'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'admin_menu_show_all';
|
||||
$strongarm->value = 0;
|
||||
$export['admin_menu_show_all'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'admin_menu_source_settings';
|
||||
$strongarm->value = array(
|
||||
1 => array(
|
||||
'source' => '',
|
||||
),
|
||||
2 => array(
|
||||
'source' => '',
|
||||
),
|
||||
3 => array(
|
||||
'source' => 'navigation',
|
||||
),
|
||||
4 => array(
|
||||
'source' => '',
|
||||
),
|
||||
);
|
||||
$export['admin_menu_source_settings'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'admin_menu_tweak_modules';
|
||||
$strongarm->value = 0;
|
||||
$export['admin_menu_tweak_modules'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'admin_menu_tweak_permissions';
|
||||
$strongarm->value = 0;
|
||||
$export['admin_menu_tweak_permissions'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'admin_menu_tweak_tabs';
|
||||
$strongarm->value = 0;
|
||||
$export['admin_menu_tweak_tabs'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'admin_theme';
|
||||
$strongarm->value = 'adminimal';
|
||||
$export['admin_theme'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'admin_theme_admin_theme_batch';
|
||||
$strongarm->value = 1;
|
||||
$export['admin_theme_admin_theme_batch'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'admin_theme_admin_theme_devel';
|
||||
$strongarm->value = 1;
|
||||
$export['admin_theme_admin_theme_devel'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'admin_theme_path';
|
||||
$strongarm->value = '';
|
||||
$export['admin_theme_path'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'admin_theme_path_disallow';
|
||||
$strongarm->value = '';
|
||||
$export['admin_theme_path_disallow'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'admin_toolbar';
|
||||
$strongarm->value = array(
|
||||
'layout' => 'vertical',
|
||||
'position' => 'nw',
|
||||
'behavior' => 'df',
|
||||
'blocks' => array(
|
||||
'admin-devel' => -1,
|
||||
'locale-language' => -1,
|
||||
'user-online' => -1,
|
||||
),
|
||||
);
|
||||
$export['admin_toolbar'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'node_admin_theme';
|
||||
$strongarm->value = 1;
|
||||
$export['node_admin_theme'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'theme_adaptivetheme_admin_settings';
|
||||
$strongarm->value = array(
|
||||
'toggle_name' => 1,
|
||||
'toggle_favicon' => 1,
|
||||
'toggle_main_menu' => 1,
|
||||
'toggle_secondary_menu' => 1,
|
||||
'default_favicon' => 1,
|
||||
'favicon_path' => '',
|
||||
'favicon_upload' => '',
|
||||
'layout_width' => '1260px',
|
||||
'layout_sidebar_first_width' => '240',
|
||||
'layout_sidebar_last_width' => '240',
|
||||
'layout_method' => '2',
|
||||
'layout_enable_settings' => 'on',
|
||||
'breadcrumb_display' => 'yes',
|
||||
'breadcrumb_separator' => ' » ',
|
||||
'breadcrumb_home' => 1,
|
||||
'search_snippet' => 1,
|
||||
'search_info_type' => 1,
|
||||
'search_info_user' => 1,
|
||||
'search_info_date' => 1,
|
||||
'search_info_comment' => 1,
|
||||
'search_info_upload' => 1,
|
||||
'search_info_separator' => ' - ',
|
||||
'horizontal_login_block' => 1,
|
||||
'extra_page_classes' => 0,
|
||||
'extra_article_classes' => 0,
|
||||
'extra_comment_classes' => 0,
|
||||
'extra_block_classes' => 0,
|
||||
'extra_menu_classes' => 0,
|
||||
'extra_item_list_classes' => 0,
|
||||
'menu_item_span_elements' => 0,
|
||||
'at__active_tab' => 'edit-page-layout',
|
||||
);
|
||||
$export['theme_adaptivetheme_admin_settings'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'theme_adaptivetheme_gui_admin_settings';
|
||||
$strongarm->value = array(
|
||||
'toggle_name' => 1,
|
||||
'toggle_favicon' => 1,
|
||||
'toggle_main_menu' => 1,
|
||||
'toggle_secondary_menu' => 1,
|
||||
'default_favicon' => 1,
|
||||
'favicon_path' => '',
|
||||
'favicon_upload' => '',
|
||||
'layout_width' => '1260px',
|
||||
'layout_sidebar_first_width' => '240',
|
||||
'layout_sidebar_last_width' => '240',
|
||||
'layout_method' => '1',
|
||||
'layout_enable_settings' => 'on',
|
||||
'breadcrumb_display' => 'yes',
|
||||
'breadcrumb_separator' => ' » ',
|
||||
'breadcrumb_home' => 1,
|
||||
'search_snippet' => 1,
|
||||
'search_info_type' => 1,
|
||||
'search_info_user' => 1,
|
||||
'search_info_date' => 1,
|
||||
'search_info_comment' => 1,
|
||||
'search_info_upload' => 1,
|
||||
'search_info_separator' => ' - ',
|
||||
'horizontal_login_block' => 0,
|
||||
'extra_page_classes' => 0,
|
||||
'extra_article_classes' => 0,
|
||||
'extra_comment_classes' => 0,
|
||||
'extra_block_classes' => 0,
|
||||
'extra_menu_classes' => 0,
|
||||
'extra_item_list_classes' => 0,
|
||||
'menu_item_span_elements' => 0,
|
||||
'at__active_tab' => 'edit-page-layout',
|
||||
);
|
||||
$export['theme_adaptivetheme_gui_admin_settings'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'user_admin_role';
|
||||
$strongarm->value = '4';
|
||||
$export['user_admin_role'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'user_mail_register_admin_created_body';
|
||||
$strongarm->value = '[user:name],
|
||||
|
||||
A site administrator at [site:name] has created an account for you. You may now log in by clicking this link or copying and pasting it to your browser:
|
||||
|
||||
[user:one-time-login-url]
|
||||
|
||||
This link can only be used once to log in and will lead you to a page where you can set your password.
|
||||
|
||||
After setting your password, you will be able to log in at [site:login-url] in the future using:
|
||||
|
||||
username: [user:name]
|
||||
password: Your password
|
||||
|
||||
-- [site:name] team';
|
||||
$export['user_mail_register_admin_created_body'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'user_mail_register_admin_created_subject';
|
||||
$strongarm->value = 'An administrator created an account for you at [site:name]';
|
||||
$export['user_mail_register_admin_created_subject'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'workflow_access_priority';
|
||||
$strongarm->value = '0';
|
||||
$export['workflow_access_priority'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'workflow_chapitre';
|
||||
$strongarm->value = array(
|
||||
0 => 'node',
|
||||
);
|
||||
$export['workflow_chapitre'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'workflow_page';
|
||||
$strongarm->value = array(
|
||||
0 => 'node',
|
||||
);
|
||||
$export['workflow_page'] = $strongarm;
|
||||
|
||||
return $export;
|
||||
}
|
||||
@@ -0,0 +1,471 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* admin.views_default.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_views_default_views().
|
||||
*/
|
||||
function admin_views_default_views() {
|
||||
$export = array();
|
||||
|
||||
$view = new view();
|
||||
$view->name = 'admin_contents';
|
||||
$view->description = 'Administrative view for content';
|
||||
$view->tag = 'default';
|
||||
$view->base_table = 'node';
|
||||
$view->human_name = 'Admin Content';
|
||||
$view->core = 7;
|
||||
$view->api_version = '3.0';
|
||||
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
|
||||
|
||||
/* Display: Master */
|
||||
$handler = $view->new_display('default', 'Master', 'default');
|
||||
$handler->display->display_options['title'] = 'Contenu';
|
||||
$handler->display->display_options['use_more_always'] = FALSE;
|
||||
$handler->display->display_options['use_more_text'] = 'plus';
|
||||
$handler->display->display_options['access']['type'] = 'role';
|
||||
$handler->display->display_options['access']['role'] = array(
|
||||
3 => '3',
|
||||
4 => '4',
|
||||
);
|
||||
$handler->display->display_options['cache']['type'] = 'none';
|
||||
$handler->display->display_options['query']['type'] = 'views_query';
|
||||
$handler->display->display_options['query']['options']['distinct'] = TRUE;
|
||||
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
|
||||
$handler->display->display_options['exposed_form']['type'] = 'basic';
|
||||
$handler->display->display_options['exposed_form']['options']['submit_button'] = 'Filtrer';
|
||||
$handler->display->display_options['exposed_form']['options']['reset_button'] = TRUE;
|
||||
$handler->display->display_options['exposed_form']['options']['reset_button_label'] = 'réinitialiser';
|
||||
$handler->display->display_options['exposed_form']['options']['exposed_sorts_label'] = 'Trier par';
|
||||
$handler->display->display_options['exposed_form']['options']['autosubmit'] = TRUE;
|
||||
$handler->display->display_options['pager']['type'] = 'mini';
|
||||
$handler->display->display_options['pager']['options']['items_per_page'] = '20';
|
||||
$handler->display->display_options['pager']['options']['offset'] = '0';
|
||||
$handler->display->display_options['pager']['options']['id'] = '0';
|
||||
$handler->display->display_options['pager']['options']['expose']['items_per_page_label'] = 'Éléments par page';
|
||||
$handler->display->display_options['pager']['options']['expose']['items_per_page_options_all_label'] = '- Tout -';
|
||||
$handler->display->display_options['pager']['options']['expose']['offset_label'] = 'Décalage';
|
||||
$handler->display->display_options['pager']['options']['tags']['first'] = '« premier';
|
||||
$handler->display->display_options['pager']['options']['tags']['previous'] = '‹ précédent';
|
||||
$handler->display->display_options['pager']['options']['tags']['next'] = 'suivant ›';
|
||||
$handler->display->display_options['pager']['options']['tags']['last'] = 'dernier »';
|
||||
$handler->display->display_options['style_plugin'] = 'table';
|
||||
$handler->display->display_options['style_options']['columns'] = array(
|
||||
'views_bulk_operations' => 'views_bulk_operations',
|
||||
'type' => 'title',
|
||||
'title' => 'title',
|
||||
'edit_node' => 'title',
|
||||
'status' => 'status',
|
||||
'language' => 'language',
|
||||
'translate_node' => 'language',
|
||||
'changed' => 'changed',
|
||||
'delete_node' => 'delete_node',
|
||||
);
|
||||
$handler->display->display_options['style_options']['default'] = 'changed';
|
||||
$handler->display->display_options['style_options']['info'] = array(
|
||||
'views_bulk_operations' => array(
|
||||
'align' => '',
|
||||
'separator' => '',
|
||||
'empty_column' => 0,
|
||||
),
|
||||
'type' => array(
|
||||
'sortable' => 0,
|
||||
'default_sort_order' => 'asc',
|
||||
'align' => '',
|
||||
'separator' => '<br />',
|
||||
'empty_column' => 0,
|
||||
),
|
||||
'title' => array(
|
||||
'sortable' => 0,
|
||||
'default_sort_order' => 'asc',
|
||||
'align' => '',
|
||||
'separator' => '<br />',
|
||||
'empty_column' => 0,
|
||||
),
|
||||
'edit_node' => array(
|
||||
'align' => '',
|
||||
'separator' => '',
|
||||
'empty_column' => 0,
|
||||
),
|
||||
'status' => array(
|
||||
'sortable' => 0,
|
||||
'default_sort_order' => 'asc',
|
||||
'align' => '',
|
||||
'separator' => '<br />',
|
||||
'empty_column' => 0,
|
||||
),
|
||||
'language' => array(
|
||||
'sortable' => 0,
|
||||
'default_sort_order' => 'asc',
|
||||
'align' => '',
|
||||
'separator' => '<br />',
|
||||
'empty_column' => 0,
|
||||
),
|
||||
'translate_node' => array(
|
||||
'align' => '',
|
||||
'separator' => '',
|
||||
'empty_column' => 0,
|
||||
),
|
||||
'changed' => array(
|
||||
'sortable' => 0,
|
||||
'default_sort_order' => 'desc',
|
||||
'align' => '',
|
||||
'separator' => '',
|
||||
'empty_column' => 0,
|
||||
),
|
||||
'delete_node' => array(
|
||||
'align' => '',
|
||||
'separator' => '',
|
||||
'empty_column' => 0,
|
||||
),
|
||||
);
|
||||
$handler->display->display_options['style_options']['override'] = FALSE;
|
||||
/* En-tête: Global : Result summary */
|
||||
$handler->display->display_options['header']['result']['id'] = 'result';
|
||||
$handler->display->display_options['header']['result']['table'] = 'views';
|
||||
$handler->display->display_options['header']['result']['field'] = 'result';
|
||||
/* Champ: Opérations en masse : Contenu */
|
||||
$handler->display->display_options['fields']['views_bulk_operations']['id'] = 'views_bulk_operations';
|
||||
$handler->display->display_options['fields']['views_bulk_operations']['table'] = 'node';
|
||||
$handler->display->display_options['fields']['views_bulk_operations']['field'] = 'views_bulk_operations';
|
||||
$handler->display->display_options['fields']['views_bulk_operations']['label'] = '';
|
||||
$handler->display->display_options['fields']['views_bulk_operations']['element_label_colon'] = FALSE;
|
||||
$handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['display_type'] = '0';
|
||||
$handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['enable_select_all_pages'] = 1;
|
||||
$handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['force_single'] = 0;
|
||||
$handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['entity_load_capacity'] = '10';
|
||||
$handler->display->display_options['fields']['views_bulk_operations']['vbo_operations'] = array(
|
||||
'action::node_assign_owner_action' => array(
|
||||
'selected' => 0,
|
||||
'skip_confirmation' => 0,
|
||||
'override_label' => 0,
|
||||
'label' => '',
|
||||
'postpone_processing' => 0,
|
||||
),
|
||||
'action::node_unpublish_action' => array(
|
||||
'selected' => 1,
|
||||
'skip_confirmation' => 0,
|
||||
'override_label' => 0,
|
||||
'label' => '',
|
||||
'postpone_processing' => 0,
|
||||
),
|
||||
'action::node_unpublish_by_keyword_action' => array(
|
||||
'selected' => 0,
|
||||
'skip_confirmation' => 0,
|
||||
'override_label' => 0,
|
||||
'label' => '',
|
||||
'postpone_processing' => 0,
|
||||
),
|
||||
'action::node_save_action' => array(
|
||||
'selected' => 0,
|
||||
'skip_confirmation' => 0,
|
||||
'override_label' => 0,
|
||||
'label' => '',
|
||||
'postpone_processing' => 0,
|
||||
),
|
||||
'action::system_send_email_action' => array(
|
||||
'selected' => 0,
|
||||
'skip_confirmation' => 0,
|
||||
'override_label' => 0,
|
||||
'label' => '',
|
||||
'postpone_processing' => 0,
|
||||
),
|
||||
'action::views_bulk_operations_script_action' => array(
|
||||
'selected' => 0,
|
||||
'skip_confirmation' => 0,
|
||||
'override_label' => 0,
|
||||
'label' => '',
|
||||
'postpone_processing' => 0,
|
||||
),
|
||||
'action::views_bulk_operations_argument_selector_action' => array(
|
||||
'selected' => 0,
|
||||
'skip_confirmation' => 0,
|
||||
'override_label' => 0,
|
||||
'label' => '',
|
||||
'settings' => array(
|
||||
'url' => '',
|
||||
),
|
||||
),
|
||||
'action::node_promote_action' => array(
|
||||
'selected' => 0,
|
||||
'skip_confirmation' => 0,
|
||||
'override_label' => 0,
|
||||
'label' => '',
|
||||
'postpone_processing' => 0,
|
||||
),
|
||||
'action::node_publish_action' => array(
|
||||
'selected' => 1,
|
||||
'skip_confirmation' => 0,
|
||||
'override_label' => 0,
|
||||
'label' => '',
|
||||
'postpone_processing' => 0,
|
||||
),
|
||||
'action::node_unpromote_action' => array(
|
||||
'selected' => 0,
|
||||
'skip_confirmation' => 0,
|
||||
'override_label' => 0,
|
||||
'label' => '',
|
||||
'postpone_processing' => 0,
|
||||
),
|
||||
'action::node_make_unsticky_action' => array(
|
||||
'selected' => 0,
|
||||
'skip_confirmation' => 0,
|
||||
'override_label' => 0,
|
||||
'label' => '',
|
||||
'postpone_processing' => 0,
|
||||
),
|
||||
'action::views_bulk_operations_delete_item' => array(
|
||||
'selected' => 0,
|
||||
'skip_confirmation' => 0,
|
||||
'override_label' => 0,
|
||||
'label' => '',
|
||||
'postpone_processing' => 0,
|
||||
),
|
||||
'action::node_make_sticky_action' => array(
|
||||
'selected' => 0,
|
||||
'skip_confirmation' => 0,
|
||||
'override_label' => 0,
|
||||
'label' => '',
|
||||
'postpone_processing' => 0,
|
||||
),
|
||||
);
|
||||
/* Champ: Contenu : Type */
|
||||
$handler->display->display_options['fields']['type']['id'] = 'type';
|
||||
$handler->display->display_options['fields']['type']['table'] = 'node';
|
||||
$handler->display->display_options['fields']['type']['field'] = 'type';
|
||||
$handler->display->display_options['fields']['type']['hide_alter_empty'] = FALSE;
|
||||
/* Champ: Contenu : Titre */
|
||||
$handler->display->display_options['fields']['title']['id'] = 'title';
|
||||
$handler->display->display_options['fields']['title']['table'] = 'node';
|
||||
$handler->display->display_options['fields']['title']['field'] = 'title';
|
||||
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
|
||||
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
|
||||
$handler->display->display_options['fields']['title']['hide_alter_empty'] = FALSE;
|
||||
/* Champ: Contenu : Lien de modification */
|
||||
$handler->display->display_options['fields']['edit_node']['id'] = 'edit_node';
|
||||
$handler->display->display_options['fields']['edit_node']['table'] = 'views_entity_node';
|
||||
$handler->display->display_options['fields']['edit_node']['field'] = 'edit_node';
|
||||
$handler->display->display_options['fields']['edit_node']['label'] = '';
|
||||
$handler->display->display_options['fields']['edit_node']['alter']['alter_text'] = TRUE;
|
||||
$handler->display->display_options['fields']['edit_node']['alter']['text'] = '<span class="node-edit">[edit_node]</span>';
|
||||
$handler->display->display_options['fields']['edit_node']['element_label_colon'] = FALSE;
|
||||
$handler->display->display_options['fields']['edit_node']['hide_alter_empty'] = FALSE;
|
||||
/* Champ: Contenu : Publié */
|
||||
$handler->display->display_options['fields']['status']['id'] = 'status';
|
||||
$handler->display->display_options['fields']['status']['table'] = 'node';
|
||||
$handler->display->display_options['fields']['status']['field'] = 'status';
|
||||
$handler->display->display_options['fields']['status']['element_label_colon'] = FALSE;
|
||||
$handler->display->display_options['fields']['status']['hide_alter_empty'] = FALSE;
|
||||
$handler->display->display_options['fields']['status']['not'] = 0;
|
||||
/* Champ: Contenu : Langue */
|
||||
$handler->display->display_options['fields']['language']['id'] = 'language';
|
||||
$handler->display->display_options['fields']['language']['table'] = 'node';
|
||||
$handler->display->display_options['fields']['language']['field'] = 'language';
|
||||
$handler->display->display_options['fields']['language']['element_label_colon'] = FALSE;
|
||||
$handler->display->display_options['fields']['language']['hide_empty'] = TRUE;
|
||||
/* Champ: Traduction du contenu : Lien de traduction */
|
||||
$handler->display->display_options['fields']['translate_node']['id'] = 'translate_node';
|
||||
$handler->display->display_options['fields']['translate_node']['table'] = 'node';
|
||||
$handler->display->display_options['fields']['translate_node']['field'] = 'translate_node';
|
||||
$handler->display->display_options['fields']['translate_node']['alter']['alter_text'] = TRUE;
|
||||
$handler->display->display_options['fields']['translate_node']['alter']['text'] = '<span class="button">[translate_node]</span>';
|
||||
$handler->display->display_options['fields']['translate_node']['hide_empty'] = TRUE;
|
||||
$handler->display->display_options['fields']['translate_node']['text'] = 'traduire';
|
||||
/* Champ: Contenu : Date de mise à jour */
|
||||
$handler->display->display_options['fields']['changed']['id'] = 'changed';
|
||||
$handler->display->display_options['fields']['changed']['table'] = 'node';
|
||||
$handler->display->display_options['fields']['changed']['field'] = 'changed';
|
||||
$handler->display->display_options['fields']['changed']['date_format'] = 'short';
|
||||
/* Champ: Contenu : Lien de suppression */
|
||||
$handler->display->display_options['fields']['delete_node']['id'] = 'delete_node';
|
||||
$handler->display->display_options['fields']['delete_node']['table'] = 'views_entity_node';
|
||||
$handler->display->display_options['fields']['delete_node']['field'] = 'delete_node';
|
||||
$handler->display->display_options['fields']['delete_node']['alter']['alter_text'] = TRUE;
|
||||
$handler->display->display_options['fields']['delete_node']['alter']['text'] = '<span class="node-delete">[delete_node]</span>';
|
||||
$handler->display->display_options['fields']['delete_node']['element_label_colon'] = FALSE;
|
||||
$handler->display->display_options['fields']['delete_node']['hide_empty'] = TRUE;
|
||||
$handler->display->display_options['fields']['delete_node']['text'] = 'supprimer';
|
||||
$handler->display->display_options['filter_groups']['groups'] = array(
|
||||
1 => 'AND',
|
||||
2 => 'AND',
|
||||
);
|
||||
/* Critère de filtrage: Contenu : Type */
|
||||
$handler->display->display_options['filters']['type']['id'] = 'type';
|
||||
$handler->display->display_options['filters']['type']['table'] = 'node';
|
||||
$handler->display->display_options['filters']['type']['field'] = 'type';
|
||||
$handler->display->display_options['filters']['type']['value'] = array(
|
||||
'all' => 'all',
|
||||
'article' => 'article',
|
||||
'collection' => 'collection',
|
||||
'event' => 'event',
|
||||
'location' => 'location',
|
||||
'page' => 'page',
|
||||
'people' => 'people',
|
||||
'program' => 'program',
|
||||
'work' => 'work',
|
||||
);
|
||||
$handler->display->display_options['filters']['type']['group'] = 1;
|
||||
$handler->display->display_options['filters']['type']['exposed'] = TRUE;
|
||||
$handler->display->display_options['filters']['type']['expose']['operator_id'] = 'type_op';
|
||||
$handler->display->display_options['filters']['type']['expose']['label'] = 'Type';
|
||||
$handler->display->display_options['filters']['type']['expose']['operator'] = 'type_op';
|
||||
$handler->display->display_options['filters']['type']['expose']['identifier'] = 'type';
|
||||
$handler->display->display_options['filters']['type']['expose']['remember'] = TRUE;
|
||||
$handler->display->display_options['filters']['type']['expose']['reduce'] = TRUE;
|
||||
/* Critère de filtrage: Contenu : Publié */
|
||||
$handler->display->display_options['filters']['status']['id'] = 'status';
|
||||
$handler->display->display_options['filters']['status']['table'] = 'node';
|
||||
$handler->display->display_options['filters']['status']['field'] = 'status';
|
||||
$handler->display->display_options['filters']['status']['value'] = 'All';
|
||||
$handler->display->display_options['filters']['status']['group'] = 1;
|
||||
$handler->display->display_options['filters']['status']['exposed'] = TRUE;
|
||||
$handler->display->display_options['filters']['status']['expose']['operator_id'] = '';
|
||||
$handler->display->display_options['filters']['status']['expose']['label'] = 'Publié';
|
||||
$handler->display->display_options['filters']['status']['expose']['operator'] = 'status_op';
|
||||
$handler->display->display_options['filters']['status']['expose']['identifier'] = 'status';
|
||||
$handler->display->display_options['filters']['status']['expose']['remember'] = TRUE;
|
||||
/* Critère de filtrage: Contenu : Langue */
|
||||
$handler->display->display_options['filters']['language']['id'] = 'language';
|
||||
$handler->display->display_options['filters']['language']['table'] = 'node';
|
||||
$handler->display->display_options['filters']['language']['field'] = 'language';
|
||||
$handler->display->display_options['filters']['language']['value'] = array(
|
||||
'und' => 'und',
|
||||
'en' => 'en',
|
||||
'fr' => 'fr',
|
||||
);
|
||||
$handler->display->display_options['filters']['language']['group'] = 1;
|
||||
$handler->display->display_options['filters']['language']['exposed'] = TRUE;
|
||||
$handler->display->display_options['filters']['language']['expose']['operator_id'] = 'language_op';
|
||||
$handler->display->display_options['filters']['language']['expose']['label'] = 'Langue';
|
||||
$handler->display->display_options['filters']['language']['expose']['operator'] = 'language_op';
|
||||
$handler->display->display_options['filters']['language']['expose']['identifier'] = 'language';
|
||||
$handler->display->display_options['filters']['language']['expose']['remember'] = TRUE;
|
||||
$handler->display->display_options['filters']['language']['expose']['reduce'] = TRUE;
|
||||
/* Critère de filtrage: current user can update */
|
||||
$handler->display->display_options['filters']['php']['id'] = 'php';
|
||||
$handler->display->display_options['filters']['php']['table'] = 'views';
|
||||
$handler->display->display_options['filters']['php']['field'] = 'php';
|
||||
$handler->display->display_options['filters']['php']['ui_name'] = 'current user can update';
|
||||
$handler->display->display_options['filters']['php']['group'] = 1;
|
||||
$handler->display->display_options['filters']['php']['use_php_setup'] = 0;
|
||||
$handler->display->display_options['filters']['php']['php_filter'] = 'global $user;
|
||||
//dsm($data);
|
||||
return !(node_access(\'update\', node_load($data->nid), $user));
|
||||
';
|
||||
|
||||
/* Display: Page : all */
|
||||
$handler = $view->new_display('page', 'Page : all', 'page');
|
||||
$handler->display->display_options['defaults']['pager'] = FALSE;
|
||||
$handler->display->display_options['pager']['type'] = 'mini';
|
||||
$handler->display->display_options['pager']['options']['items_per_page'] = '30';
|
||||
$handler->display->display_options['pager']['options']['offset'] = '0';
|
||||
$handler->display->display_options['pager']['options']['id'] = '0';
|
||||
$handler->display->display_options['pager']['options']['expose']['items_per_page'] = TRUE;
|
||||
$handler->display->display_options['pager']['options']['expose']['items_per_page_label'] = 'Éléments par page';
|
||||
$handler->display->display_options['pager']['options']['expose']['items_per_page_options_all'] = TRUE;
|
||||
$handler->display->display_options['pager']['options']['expose']['items_per_page_options_all_label'] = '- Tout -';
|
||||
$handler->display->display_options['pager']['options']['expose']['offset_label'] = 'Décalage';
|
||||
$handler->display->display_options['pager']['options']['tags']['first'] = '« premier';
|
||||
$handler->display->display_options['pager']['options']['tags']['previous'] = '‹ précédent';
|
||||
$handler->display->display_options['pager']['options']['tags']['next'] = 'suivant ›';
|
||||
$handler->display->display_options['pager']['options']['tags']['last'] = 'dernier »';
|
||||
$handler->display->display_options['path'] = 'admin/content/nodes';
|
||||
$handler->display->display_options['menu']['type'] = 'tab';
|
||||
$handler->display->display_options['menu']['title'] = 'Content';
|
||||
$handler->display->display_options['menu']['weight'] = '-100';
|
||||
$handler->display->display_options['menu']['context'] = 0;
|
||||
$handler->display->display_options['tab_options']['type'] = 'normal';
|
||||
$handler->display->display_options['tab_options']['title'] = 'dashboard';
|
||||
$handler->display->display_options['tab_options']['weight'] = '0';
|
||||
|
||||
/* Display: Block */
|
||||
$handler = $view->new_display('block', 'Block', 'block_1');
|
||||
$handler->display->display_options['defaults']['title'] = FALSE;
|
||||
$handler->display->display_options['title'] = 'Recent Content';
|
||||
$handler->display->display_options['defaults']['pager'] = FALSE;
|
||||
$handler->display->display_options['pager']['type'] = 'some';
|
||||
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
|
||||
$handler->display->display_options['pager']['options']['offset'] = '0';
|
||||
$handler->display->display_options['defaults']['fields'] = FALSE;
|
||||
/* Champ: Contenu : Type */
|
||||
$handler->display->display_options['fields']['type']['id'] = 'type';
|
||||
$handler->display->display_options['fields']['type']['table'] = 'node';
|
||||
$handler->display->display_options['fields']['type']['field'] = 'type';
|
||||
$handler->display->display_options['fields']['type']['hide_alter_empty'] = FALSE;
|
||||
/* Champ: Contenu : Titre */
|
||||
$handler->display->display_options['fields']['title']['id'] = 'title';
|
||||
$handler->display->display_options['fields']['title']['table'] = 'node';
|
||||
$handler->display->display_options['fields']['title']['field'] = 'title';
|
||||
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
|
||||
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
|
||||
$handler->display->display_options['fields']['title']['hide_alter_empty'] = FALSE;
|
||||
/* Champ: Contenu : Lien de modification */
|
||||
$handler->display->display_options['fields']['edit_node']['id'] = 'edit_node';
|
||||
$handler->display->display_options['fields']['edit_node']['table'] = 'views_entity_node';
|
||||
$handler->display->display_options['fields']['edit_node']['field'] = 'edit_node';
|
||||
$handler->display->display_options['fields']['edit_node']['label'] = 'Modifier';
|
||||
$handler->display->display_options['fields']['edit_node']['alter']['alter_text'] = TRUE;
|
||||
$handler->display->display_options['fields']['edit_node']['alter']['text'] = '<span class="node-edit">[edit_node]</span>';
|
||||
$handler->display->display_options['fields']['edit_node']['hide_alter_empty'] = FALSE;
|
||||
/* Champ: Contenu : Publié */
|
||||
$handler->display->display_options['fields']['status']['id'] = 'status';
|
||||
$handler->display->display_options['fields']['status']['table'] = 'node';
|
||||
$handler->display->display_options['fields']['status']['field'] = 'status';
|
||||
$handler->display->display_options['fields']['status']['element_label_colon'] = FALSE;
|
||||
$handler->display->display_options['fields']['status']['hide_alter_empty'] = FALSE;
|
||||
$handler->display->display_options['fields']['status']['not'] = 0;
|
||||
/* Champ: Contenu : Langue */
|
||||
$handler->display->display_options['fields']['language']['id'] = 'language';
|
||||
$handler->display->display_options['fields']['language']['table'] = 'node';
|
||||
$handler->display->display_options['fields']['language']['field'] = 'language';
|
||||
$handler->display->display_options['fields']['language']['element_label_colon'] = FALSE;
|
||||
$handler->display->display_options['fields']['language']['hide_alter_empty'] = FALSE;
|
||||
/* Champ: Traduction du contenu : Lien de traduction */
|
||||
$handler->display->display_options['fields']['translate_node']['id'] = 'translate_node';
|
||||
$handler->display->display_options['fields']['translate_node']['table'] = 'node';
|
||||
$handler->display->display_options['fields']['translate_node']['field'] = 'translate_node';
|
||||
$handler->display->display_options['fields']['translate_node']['element_label_colon'] = FALSE;
|
||||
$handler->display->display_options['fields']['translate_node']['hide_alter_empty'] = FALSE;
|
||||
$handler->display->display_options['fields']['translate_node']['text'] = 'Traduire';
|
||||
$translatables['admin_contents'] = array(
|
||||
t('Master'),
|
||||
t('Contenu'),
|
||||
t('plus'),
|
||||
t('Filtrer'),
|
||||
t('réinitialiser'),
|
||||
t('Trier par'),
|
||||
t('Asc'),
|
||||
t('Desc'),
|
||||
t('Éléments par page'),
|
||||
t('- Tout -'),
|
||||
t('Décalage'),
|
||||
t('« premier'),
|
||||
t('‹ précédent'),
|
||||
t('suivant ›'),
|
||||
t('dernier »'),
|
||||
t('Displaying @start - @end of @total'),
|
||||
t('- Choisir une opération -'),
|
||||
t('Type'),
|
||||
t('Titre'),
|
||||
t('<span class="node-edit">[edit_node]</span>'),
|
||||
t('Publié'),
|
||||
t('Langue'),
|
||||
t('Lien de traduction'),
|
||||
t('<span class="button">[translate_node]</span>'),
|
||||
t('traduire'),
|
||||
t('Date de mise à jour'),
|
||||
t('Lien de suppression'),
|
||||
t('<span class="node-delete">[delete_node]</span>'),
|
||||
t('supprimer'),
|
||||
t('Page : all'),
|
||||
t('Block'),
|
||||
t('Recent Content'),
|
||||
t('Modifier'),
|
||||
t('Traduire'),
|
||||
);
|
||||
$export['admin_contents'] = $view;
|
||||
|
||||
return $export;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* page.features.field_base.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_field_default_field_bases().
|
||||
*/
|
||||
function page_field_default_field_bases() {
|
||||
$field_bases = array();
|
||||
|
||||
// Exported field_base: 'body'
|
||||
$field_bases['body'] = array(
|
||||
'active' => 1,
|
||||
'cardinality' => 1,
|
||||
'deleted' => 0,
|
||||
'entity_types' => array(
|
||||
0 => 'node',
|
||||
),
|
||||
'field_name' => 'body',
|
||||
'field_permissions' => array(
|
||||
'type' => 0,
|
||||
),
|
||||
'foreign keys' => array(
|
||||
'format' => array(
|
||||
'columns' => array(
|
||||
'format' => 'format',
|
||||
),
|
||||
'table' => 'filter_format',
|
||||
),
|
||||
),
|
||||
'indexes' => array(
|
||||
'format' => array(
|
||||
0 => 'format',
|
||||
),
|
||||
),
|
||||
'locked' => 0,
|
||||
'module' => 'text',
|
||||
'settings' => array(),
|
||||
'translatable' => 0,
|
||||
'type' => 'text_with_summary',
|
||||
);
|
||||
|
||||
return $field_bases;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* page.features.field_instance.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_field_default_field_instances().
|
||||
*/
|
||||
function page_field_default_field_instances() {
|
||||
$field_instances = array();
|
||||
|
||||
// Exported field_instance: 'node-page-body'
|
||||
$field_instances['node-page-body'] = array(
|
||||
'bundle' => 'page',
|
||||
'default_value' => NULL,
|
||||
'deleted' => 0,
|
||||
'description' => '',
|
||||
'display' => array(
|
||||
'default' => array(
|
||||
'label' => 'hidden',
|
||||
'module' => 'text',
|
||||
'settings' => array(),
|
||||
'type' => 'text_default',
|
||||
'weight' => 0,
|
||||
),
|
||||
'teaser' => array(
|
||||
'label' => 'hidden',
|
||||
'module' => 'text',
|
||||
'settings' => array(
|
||||
'trim_length' => 600,
|
||||
),
|
||||
'type' => 'text_summary_or_trimmed',
|
||||
'weight' => 0,
|
||||
),
|
||||
),
|
||||
'entity_type' => 'node',
|
||||
'field_name' => 'body',
|
||||
'label' => 'Body',
|
||||
'required' => FALSE,
|
||||
'settings' => array(
|
||||
'display_summary' => TRUE,
|
||||
'text_processing' => 1,
|
||||
'user_register_form' => FALSE,
|
||||
),
|
||||
'widget' => array(
|
||||
'module' => 'text',
|
||||
'settings' => array(
|
||||
'rows' => 20,
|
||||
'summary_rows' => 5,
|
||||
),
|
||||
'type' => 'text_textarea_with_summary',
|
||||
'weight' => -4,
|
||||
),
|
||||
);
|
||||
|
||||
// Translatables
|
||||
// Included for use with string extractors like potx.
|
||||
t('Body');
|
||||
|
||||
return $field_instances;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* page.features.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_ctools_plugin_api().
|
||||
*/
|
||||
function page_ctools_plugin_api($module = NULL, $api = NULL) {
|
||||
if ($module == "strongarm" && $api == "strongarm") {
|
||||
return array("version" => "1");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_node_info().
|
||||
*/
|
||||
function page_node_info() {
|
||||
$items = array(
|
||||
'page' => array(
|
||||
'name' => t('Page'),
|
||||
'base' => 'node_content',
|
||||
'description' => t('Use this content type to add static pages like "about" "contact" etc'),
|
||||
'has_title' => '1',
|
||||
'title_label' => t('Title'),
|
||||
'help' => '',
|
||||
),
|
||||
);
|
||||
drupal_alter('node_info', $items);
|
||||
return $items;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* page.features.user_permission.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_user_default_permissions().
|
||||
*/
|
||||
function page_user_default_permissions() {
|
||||
$permissions = array();
|
||||
|
||||
// Exported permission: 'create page content'.
|
||||
$permissions['create page content'] = array(
|
||||
'name' => 'create page content',
|
||||
'roles' => array(
|
||||
'administrator' => 'administrator',
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'node',
|
||||
);
|
||||
|
||||
// Exported permission: 'delete any page content'.
|
||||
$permissions['delete any page content'] = array(
|
||||
'name' => 'delete any page content',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'node',
|
||||
);
|
||||
|
||||
// Exported permission: 'delete own page content'.
|
||||
$permissions['delete own page content'] = array(
|
||||
'name' => 'delete own page content',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'node',
|
||||
);
|
||||
|
||||
// Exported permission: 'edit any page content'.
|
||||
$permissions['edit any page content'] = array(
|
||||
'name' => 'edit any page content',
|
||||
'roles' => array(
|
||||
'administrator' => 'administrator',
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'node',
|
||||
);
|
||||
|
||||
// Exported permission: 'edit own page content'.
|
||||
$permissions['edit own page content'] = array(
|
||||
'name' => 'edit own page content',
|
||||
'roles' => array(
|
||||
'root' => 'root',
|
||||
),
|
||||
'module' => 'node',
|
||||
);
|
||||
|
||||
return $permissions;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
name = Page
|
||||
description = page content type
|
||||
core = 7.x
|
||||
package = Gui
|
||||
dependencies[] = ctools
|
||||
dependencies[] = features
|
||||
dependencies[] = node
|
||||
dependencies[] = strongarm
|
||||
dependencies[] = text
|
||||
features[ctools][] = strongarm:strongarm:1
|
||||
features[features_api][] = api:2
|
||||
features[field_base][] = body
|
||||
features[field_instance][] = node-page-body
|
||||
features[node][] = page
|
||||
features[user_permission][] = create page content
|
||||
features[user_permission][] = delete any page content
|
||||
features[user_permission][] = delete own page content
|
||||
features[user_permission][] = edit any page content
|
||||
features[user_permission][] = edit own page content
|
||||
features[variable][] = menu_options_page
|
||||
features[variable][] = menu_parent_page
|
||||
features[variable][] = node_options_page
|
||||
features[variable][] = node_preview_page
|
||||
features[variable][] = node_submitted_page
|
||||
features[variable][] = pathauto_node_page_pattern
|
||||
project path = sites/all/modules/features
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Code for the Page feature.
|
||||
*/
|
||||
|
||||
include_once 'page.features.inc';
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* page.strongarm.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_strongarm().
|
||||
*/
|
||||
function page_strongarm() {
|
||||
$export = array();
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'menu_options_page';
|
||||
$strongarm->value = array();
|
||||
$export['menu_options_page'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'menu_parent_page';
|
||||
$strongarm->value = 'main-menu:0';
|
||||
$export['menu_parent_page'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'node_options_page';
|
||||
$strongarm->value = array(
|
||||
0 => 'status',
|
||||
);
|
||||
$export['node_options_page'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'node_preview_page';
|
||||
$strongarm->value = '1';
|
||||
$export['node_preview_page'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'node_submitted_page';
|
||||
$strongarm->value = 0;
|
||||
$export['node_submitted_page'] = $strongarm;
|
||||
|
||||
$strongarm = new stdClass();
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'pathauto_node_page_pattern';
|
||||
$strongarm->value = '';
|
||||
$export['pathauto_node_page_pattern'] = $strongarm;
|
||||
|
||||
return $export;
|
||||
}
|
||||
Reference in New Issue
Block a user