added social links block
339
sites/all/modules/contrib/social/social_media_links/LICENSE.txt
Normal file
@@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
@@ -0,0 +1,32 @@
|
||||
DESCRIPTION
|
||||
===========
|
||||
The modules provides a configurable block that display links (icons) to your
|
||||
profiles on various popular networking sites.
|
||||
|
||||
INSTALLATION
|
||||
============
|
||||
1. Install as usual, see http://drupal.org/node/70151 for further information.
|
||||
2. The module has no special configuration. All settings are available in the
|
||||
block settings:
|
||||
/admin/structure/block/manage/social_media_links/social-media-links/configure
|
||||
|
||||
INCLUDED ICON SETS
|
||||
==================
|
||||
The module contains a icon set, that the module is ready for use immediately
|
||||
after the installation.
|
||||
Currently, the Elegant Themes set [1] is included. This icon set is licensed
|
||||
under MIT and GPL 2.0. Thank, you guys!
|
||||
|
||||
[1] http://www.elegantthemes.com/blog/resources/beautiful-free-social-media-icons
|
||||
|
||||
TODOS
|
||||
=====
|
||||
* Add documentation for the hooks to register new platforms and icon sets
|
||||
* Add more predefined icon sets.
|
||||
* Add libraries integration to include (external) icon sets.
|
||||
* Add tool to change the order of the platforms.
|
||||
* Add validation to check the entered usernames (404 return code status check)
|
||||
|
||||
MAINTAINER
|
||||
==========
|
||||
- cbeier (Christian Beier)
|
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 1.8 KiB |
@@ -0,0 +1,6 @@
|
||||
Copyright Elegant Themes, Inc. 2012
|
||||
|
||||
Dual licensed under MIT and GPL 2.0:
|
||||
|
||||
http://www.gnu.org/licenses/gpl-2.0.html
|
||||
http://www.opensource.org/licenses/mit-license.html
|
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Defines the social media links widget for panels.
|
||||
*/
|
||||
|
||||
$plugin = array(
|
||||
'title' => t('Social Media Links'),
|
||||
'description' => t('Create a Social Media Links widget.'),
|
||||
'category' => array('widgets', 0),
|
||||
'single' => FALSE,
|
||||
'admin info' => 'social_media_links_widget_admin_info',
|
||||
'edit form' => 'social_media_links_widget_form',
|
||||
'render callback' => 'social_media_links_widget_render',
|
||||
);
|
||||
|
||||
/**
|
||||
* Callback to provide administrative info (the preview in panels when building a panel).
|
||||
*/
|
||||
function social_media_links_widget_admin_info($subtype, $conf, $context = NULL) {
|
||||
if (!empty($conf)) {
|
||||
$platform_infos = social_media_links_platforms();
|
||||
|
||||
$active_platforms = array();
|
||||
foreach ($conf['platforms'] as $name => $platform) {
|
||||
if (!empty($platform['platform_value'])) {
|
||||
$active_platforms[] = $platform_infos[$name]['title'];
|
||||
}
|
||||
}
|
||||
|
||||
$content = t('Activated Platforms: @platforms', array('@platforms' => implode(', ', $active_platforms)));
|
||||
$content .= '<br />' . t('Iconset: @iconset', array('@iconset' => $conf['icon_style']));
|
||||
|
||||
$block = new stdClass();
|
||||
$block->title = $conf['override_title'] ? $conf['override_title_text'] : t('Follow Us');
|
||||
$block->content = $content;
|
||||
|
||||
return $block;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for the edit form.
|
||||
*/
|
||||
function social_media_links_widget_form($form, &$form_state) {
|
||||
$form += social_media_links_form($form_state['conf']);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit callback for the edit form.
|
||||
*/
|
||||
function social_media_links_widget_form_submit($form, &$form_state) {
|
||||
foreach (element_children($form) as $key) {
|
||||
if (isset($form_state['values'][$key])) {
|
||||
$form_state['conf'][$key] = $form_state['values'][$key];
|
||||
}
|
||||
}
|
||||
if (isset($form_state['values']['icon_style'])) {
|
||||
$form_state['conf']['icon_style'] = $form_state['values']['icon_style'];
|
||||
}
|
||||
}
|
||||
|
||||
function social_media_links_widget_render($subtype, $conf, $panel_args) {
|
||||
$block = new stdClass();
|
||||
|
||||
$platforms = _social_media_links_cleanup_platforms($conf['platforms']);
|
||||
|
||||
$content = array(
|
||||
'#theme' => 'social_media_links_platforms',
|
||||
'#platform_values' => $platforms,
|
||||
'#icon_style' => $conf['icon_style'],
|
||||
'#appearance' => $conf['appearance'],
|
||||
'#link_attributes' => $conf['link_attributes'],
|
||||
'#attributes' => array(
|
||||
'class' => array('social-media-links', 'platforms'),
|
||||
),
|
||||
);
|
||||
|
||||
// Add css to the block.
|
||||
$content['#attached']['css'][] = drupal_get_path('module', 'social_media_links') . '/social_media_links.css';
|
||||
|
||||
$block->title = $conf['override_title'] ? $conf['override_title_text'] : t('Follow Us');
|
||||
$block->content = $content;
|
||||
|
||||
return $block;
|
||||
}
|
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* API documentation for Social Media Links Block module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Defines all platforms by the module.
|
||||
*
|
||||
* @return array
|
||||
* An associative array whose keys define the key for the platform
|
||||
* (social network) and contains information about the platform. Each
|
||||
* platform description is itself an associative array, with the following
|
||||
* key-value pairs:
|
||||
* - title: (required) The name of the platform / social network.
|
||||
* - base url: (required) The base url for the platform (prefix) to
|
||||
* build the link:
|
||||
* {base url} + {user value} = link url
|
||||
* The base url will be shown on the configuration page before the
|
||||
* input field.
|
||||
* - link attributes:
|
||||
* - image alt: A optional alternativ text that will be used for the icon
|
||||
* alt attribute.
|
||||
*/
|
||||
function hook_social_media_links_platform_info() {
|
||||
$platforms = array();
|
||||
|
||||
// A simple example for twitter.
|
||||
$platforms['twitter'] = array(
|
||||
'title' => t('Twitter'),
|
||||
'base url' => 'http://www.twitter.com/',
|
||||
);
|
||||
|
||||
// A expample for Google+ with an alternative alt text.
|
||||
$platforms['googleplus'] = array(
|
||||
'title' => t('Google+'),
|
||||
'base url' => 'https://plus.google.com/',
|
||||
'image alt' => 'Google+ icon',
|
||||
);
|
||||
|
||||
return $platforms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the platforms.
|
||||
*
|
||||
* @param array $platforms
|
||||
* A associative array with the defined platforms.
|
||||
*/
|
||||
function hook_social_media_links_platform_info_alter(&$platforms) {
|
||||
// Change the title for Google Plus.
|
||||
$platforms['googleplus']['title'] = t('Google Plus');
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the available iconsets.
|
||||
*
|
||||
* @return array
|
||||
* An associative array whose keys define the key for the iconset
|
||||
* and contains information about the icons for the platforms. Each
|
||||
* iconset deinition is itself an associative array, with the
|
||||
* following key-value pairs:
|
||||
* - name: The name of the iconset.
|
||||
* - publisher: The name of the publisher.
|
||||
* - publisher url: The url for further informations about the iconset.
|
||||
* - styles: The available sizes/styles for the iconset.
|
||||
* - path callback: The name of the callback function that returns the
|
||||
* image urls.
|
||||
* - download url: The url to download the iconset.
|
||||
*/
|
||||
function hook_social_media_links_iconset_info() {
|
||||
// Simple example for a iconset definition.
|
||||
$icons['elegantthemes'] = array(
|
||||
'name' => 'Elegant Themes Icons',
|
||||
'publisher' => 'Elegant Themes',
|
||||
'publisher url' => 'http://www.elegantthemes.com/',
|
||||
'styles' => array(
|
||||
'32' => '32x32',
|
||||
),
|
||||
'path callback' => 'social_media_links_path_elegantthemes',
|
||||
'download url' => 'http://www.elegantthemes.com/blog/resources/beautiful-free-social-media-icons',
|
||||
);
|
||||
|
||||
return $icons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the iconset definitions.
|
||||
*
|
||||
* @param array $iconsets
|
||||
* A associative array with the defined iconsets.
|
||||
*/
|
||||
function hook_social_media_links_iconset_info_alter(&$iconsets) {
|
||||
// Change the path callback for the elegantthemes.
|
||||
$iconsets['elegantthemes']['path callback'] = 'social_media_links_path_elegantthemes';
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
.block-social-media-links ul.platforms,
|
||||
.pane-social-media-link-widget ul.platforms {
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.block-social-media-links .horizontal li,
|
||||
.pane-social-media-link-widget .horizontal li {
|
||||
display: inline-block;
|
||||
text-align: center;
|
||||
padding: .2em .35em;
|
||||
}
|
||||
|
||||
.block-social-media-links .vertical li,
|
||||
.pane-social-media-link-widget .vertical li {
|
||||
list-style-type: none;
|
||||
margin: 0 0 .5em 0
|
||||
}
|
||||
|
||||
.block-social-media-links .vertical li a img,
|
||||
.pane-social-media-link-widget .vertical li a img {
|
||||
vertical-align: middle;
|
||||
margin-right: .5em;
|
||||
}
|
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Callbacks for the icon sets.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Register the default icon sets.
|
||||
*
|
||||
* @return array
|
||||
* Array of icon sets.
|
||||
*/
|
||||
function social_media_links_social_media_links_iconset_info() {
|
||||
$icons['elegantthemes'] = array(
|
||||
'name' => 'Elegant Themes Icons',
|
||||
'publisher' => 'Elegant Themes',
|
||||
'publisher url' => 'http://www.elegantthemes.com/',
|
||||
'styles' => array(
|
||||
'32' => '32x32',
|
||||
),
|
||||
'path callback' => 'social_media_links_path_elegantthemes',
|
||||
'download url' => 'http://www.elegantthemes.com/blog/resources/beautiful-free-social-media-icons',
|
||||
);
|
||||
|
||||
$icons['nouveller'] = array(
|
||||
'name' => 'Social Meida Bookmark Icon +',
|
||||
'publisher' => 'nouveller',
|
||||
'publisher url' => 'http://www.nouveller.com/',
|
||||
'path callback' => 'social_media_links_path_nouveller',
|
||||
'download url' => 'http://www.nouveller.com/general/free-social-media-bookmark-icon-pack-the-ever-growing-icon-set/',
|
||||
'styles' => array(
|
||||
'16' => '16x16',
|
||||
'32' => '32x32',
|
||||
'buttons' => '122x42',
|
||||
),
|
||||
);
|
||||
|
||||
$icons['themeid'] = array(
|
||||
'name' => 'themeiD 26 Social Media Icon Sets',
|
||||
'publisher' => 'themeiD',
|
||||
'publisher url' => 'http://themeid.com/',
|
||||
'download url' => 'http://themeid.com/26-free-social-media-icon-sets/',
|
||||
'path callback' => 'social_media_links_path_themeid',
|
||||
'styles' => array(
|
||||
'32' => '32x32',
|
||||
),
|
||||
);
|
||||
|
||||
$icons['webtoolkit'] = array(
|
||||
'name' => 'webtoolkit Icon Set',
|
||||
'publisher' => 'webtoolkit4.me',
|
||||
'publisher url' => 'http://webtoolkit4.me/',
|
||||
'download url' => 'http://webtoolkit4.me/2008/09/05/webtoolkit4me-releases-the-first-icon-set/',
|
||||
'path callback' => 'social_media_links_path_webtoolkit',
|
||||
'styles' => array(
|
||||
'24' => '24x24',
|
||||
'32' => '32x32',
|
||||
'48' => '48x48',
|
||||
'62' => '62x62',
|
||||
),
|
||||
);
|
||||
|
||||
return $icons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback with the informations about the elegantthemes icon set.
|
||||
*
|
||||
* @param string $platform
|
||||
* Name of the platform for which the path is returned.
|
||||
*
|
||||
* @param string $style
|
||||
* Size of the icons.
|
||||
*
|
||||
* @return string
|
||||
* The image path.
|
||||
*/
|
||||
function social_media_links_path_elegantthemes($platform = 'twitter', $style = NULL) {
|
||||
$info = social_media_links_iconset('elegantthemes');
|
||||
|
||||
switch ($platform) {
|
||||
case 'contact':
|
||||
$platform = 'email';
|
||||
break;
|
||||
|
||||
case 'youtube_channel':
|
||||
$platform = 'youtube';
|
||||
break;
|
||||
}
|
||||
|
||||
$path = isset($info['path']) ? $info['path'] . '/PNG/' . $platform . '.png' : '';
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback with the informations about the nouveller icon set.
|
||||
*
|
||||
* @param string $platform
|
||||
* Name of the platform for which the path is returned.
|
||||
*
|
||||
* @param string $style
|
||||
* Size of the icons.
|
||||
*
|
||||
* @return string
|
||||
* The image path.
|
||||
*/
|
||||
function social_media_links_path_nouveller($platform = 'twitter', $style = '32') {
|
||||
$info = social_media_links_iconset('nouveller');
|
||||
|
||||
switch ($platform) {
|
||||
case 'contact':
|
||||
$platform = 'email';
|
||||
break;
|
||||
case 'googleplus':
|
||||
$platform = 'google';
|
||||
break;
|
||||
case 'youtube_channel':
|
||||
$platform = 'youtube';
|
||||
break;
|
||||
}
|
||||
|
||||
$path = isset($info['path']) ? $info['path'] . '/' . $style . '/' . $platform . '.png' : '';
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback with the informations about the themeiD icon set.
|
||||
*
|
||||
* @param string $platform
|
||||
* Name of the platform for which the path is returned.
|
||||
*
|
||||
* @param string $style
|
||||
* Size of the icons.
|
||||
*
|
||||
* @return string
|
||||
* The image path.
|
||||
*/
|
||||
function social_media_links_path_themeid($platform = 'twitter', $style = '32') {
|
||||
$info = social_media_links_iconset('themeid');
|
||||
|
||||
switch ($platform) {
|
||||
case 'contact':
|
||||
$platform = 'email';
|
||||
break;
|
||||
|
||||
case 'googleplus':
|
||||
$platform = 'google';
|
||||
break;
|
||||
|
||||
case 'youtube_channel':
|
||||
$platform = 'youtube';
|
||||
break;
|
||||
}
|
||||
|
||||
$path = isset($info['path']) ? $info['path'] . '/' . $platform . '-icon.png' : '';
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback with the informations about the themeiD icon set.
|
||||
*
|
||||
* @param string $platform
|
||||
* Name of the platform for which the path is returned.
|
||||
*
|
||||
* @param string $style
|
||||
* Size of the icons.
|
||||
*
|
||||
* @return string
|
||||
* The image path.
|
||||
*/
|
||||
function social_media_links_path_webtoolkit($platform = 'twitter', $style = '32') {
|
||||
$info = social_media_links_iconset('webtoolkit');
|
||||
|
||||
switch ($platform) {
|
||||
case 'googleplus':
|
||||
$platform = 'google';
|
||||
break;
|
||||
|
||||
case 'youtube_channel':
|
||||
$platform = 'youtube';
|
||||
break;
|
||||
}
|
||||
|
||||
$path = isset($info['path']) ? $info['path'] . '/' . $style . 'x' . $style . '/' . $platform . '.png' : '';
|
||||
|
||||
return $path;
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
name = Social Media Links Block
|
||||
description = The Module provides a block that display links (icons) to your profiles on various social networking sites.
|
||||
core = 7.x
|
||||
php = 5.2.4
|
||||
configure = admin/structure/block/manage/social_media_links/social-media-links/configure
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-08-29
|
||||
version = "7.x-1.5+1-dev"
|
||||
core = "7.x"
|
||||
project = "social_media_links"
|
||||
datestamp = "1440837482"
|
||||
|
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Social Media Link module's install and uninstall code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_uninstall().
|
||||
*/
|
||||
function social_media_links_uninstall() {
|
||||
variable_del('social_media_links_platforms');
|
||||
variable_del('social_media_links_appearance');
|
||||
variable_del('social_media_links_link_attributes');
|
||||
variable_del('social_media_links_icon_style');
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate the platform data to the new structure.
|
||||
*/
|
||||
function social_media_links_update_7101() {
|
||||
$platforms = variable_get('social_media_links_platforms', array());
|
||||
foreach ($platforms as $key => $value) {
|
||||
if (!is_array($value)) {
|
||||
$platform_new = array(
|
||||
'platform_value' => $value,
|
||||
'weight' => 0,
|
||||
);
|
||||
$platforms[$key] = $platform_new;
|
||||
}
|
||||
}
|
||||
variable_set('social_media_links_platforms', $platforms);
|
||||
}
|
@@ -0,0 +1,773 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Functions for the Social Media Links module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*/
|
||||
function social_media_links_theme($existing, $type, $theme, $path) {
|
||||
return array(
|
||||
'social_media_links_platforms_table' => array(
|
||||
'render element' => 'form',
|
||||
),
|
||||
'social_media_links_platforms' => array(
|
||||
'variables' => array(
|
||||
'platform_values' => array(),
|
||||
'icon_style' => array(),
|
||||
'appearance' => array(),
|
||||
'link_attributes' => array(),
|
||||
'attributes' => array(),
|
||||
),
|
||||
),
|
||||
'social_media_links_platform' => array(
|
||||
'variables' => array(
|
||||
'info' => array(),
|
||||
'name' => NULL,
|
||||
'value' => NULL,
|
||||
'icon_style' => array(),
|
||||
'appearance' => array(),
|
||||
'attributes' => array(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_ctools_plugin_directory().
|
||||
*/
|
||||
function social_media_links_ctools_plugin_directory($module, $plugin) {
|
||||
if ($module == 'ctools' && $plugin == 'content_types') {
|
||||
return 'plugins/' . $plugin;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_block_info().
|
||||
*/
|
||||
function social_media_links_block_info() {
|
||||
$blocks['social-media-links'] = array(
|
||||
'info' => t('Social Media Links'),
|
||||
// We cache per role, so that the edit/configure links display only if the
|
||||
// user has access.
|
||||
'cache' => DRUPAL_CACHE_PER_ROLE,
|
||||
);
|
||||
|
||||
return $blocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_block_configure().
|
||||
*/
|
||||
function social_media_links_block_configure($delta = '') {
|
||||
if ($delta === 'social-media-links') {
|
||||
$values = array(
|
||||
'platforms' => variable_get('social_media_links_platforms', array()),
|
||||
'appearance' => variable_get('social_media_links_appearance', array()),
|
||||
'icon_style' => variable_get('social_media_links_icon_style', ''),
|
||||
'link_attributes' => variable_get('social_media_links_link_attributes', array()),
|
||||
);
|
||||
|
||||
$form = social_media_links_form($values);
|
||||
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
|
||||
function social_media_links_form($values) {
|
||||
$form = array();
|
||||
|
||||
// Platforms.
|
||||
$form['platforms'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Platforms'),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => FALSE,
|
||||
'#tree' => TRUE,
|
||||
'#theme' => 'social_media_links_platforms_table',
|
||||
);
|
||||
|
||||
$platform_values = isset($values['platforms']) ? $values['platforms'] : array();
|
||||
$platforms = social_media_links_platforms();
|
||||
|
||||
if (!empty($platform_values)) {
|
||||
// Combine the platforms with the weight value for sorting.
|
||||
foreach ($platforms as $key => $value) {
|
||||
if (isset($platform_values[$key]['weight'])) {
|
||||
$platforms[$key]['weight'] = $platform_values[$key]['weight'];
|
||||
}
|
||||
}
|
||||
|
||||
uasort($platforms, 'drupal_sort_weight');
|
||||
}
|
||||
|
||||
$i = -10;
|
||||
foreach ($platforms as $key => $value) {
|
||||
$form['platforms'][$key] = array(
|
||||
'platform_value' => array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => $value['title'],
|
||||
'#title_display' => 'invisible',
|
||||
'#size' => 40,
|
||||
'#field_prefix' => $value['base url'],
|
||||
'#default_value' => isset($platform_values[$key]['platform_value']) ? $platform_values[$key]['platform_value'] : '',
|
||||
),
|
||||
'weight' => array(
|
||||
'#type' => 'weight',
|
||||
'#title' => t('Weight'),
|
||||
'#title_display' => 'invisible',
|
||||
'#delta' => 10,
|
||||
'#default_value' => isset($platform_values[$key]['weight']) ? $platform_values[$key]['weight'] : $i + 1,
|
||||
'#attributes' => array('class' => array('weight')),
|
||||
),
|
||||
);
|
||||
$i++;
|
||||
}
|
||||
|
||||
// Appearance.
|
||||
$form['appearance'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Appearance'),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
'#tree' => TRUE,
|
||||
);
|
||||
$appearance_values = isset($values['appearance']) ? $values['appearance'] : array();
|
||||
$form['appearance']['orientation'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Orientation'),
|
||||
'#default_value' => isset($appearance_values['orientation']) ? $appearance_values['orientation'] : 'h',
|
||||
'#options' => array(
|
||||
'v' => t('vertical'),
|
||||
'h' => t('horizontal'),
|
||||
),
|
||||
);
|
||||
$form['appearance']['show_name'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Show name'),
|
||||
'#description' => t('Show the platform name next to the icon.'),
|
||||
'#default_value' => isset($appearance_values['show_name']) ? $appearance_values['show_name'] : 0,
|
||||
);
|
||||
|
||||
// Link Attributes.
|
||||
$form['link_attributes'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Link attributes'),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
'#tree' => TRUE,
|
||||
);
|
||||
$link_values = isset($values['link_attributes']) ? $values['link_attributes'] : array();
|
||||
$form['link_attributes']['target'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Default target'),
|
||||
'#default_value' => isset($link_values['target']) ? $link_values['target'] : '<none>',
|
||||
'#options' => array(
|
||||
'<none>' => t('Remove target attribute'),
|
||||
'_blank' => t('Open in a new browser window or tab (_blank)'),
|
||||
'_self' => t('Open in the current window (_self)'),
|
||||
'_parent' => t('Open in the frame that is superior to the frame the link is in (_parent)'),
|
||||
'_top' => t('Cancel all frames and open in full browser window (_top)'),
|
||||
),
|
||||
);
|
||||
$form['link_attributes']['rel'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Default rel'),
|
||||
'#default_value' => isset($link_values['rel']) ? $link_values['rel'] : '<none>',
|
||||
'#options' => array(
|
||||
'<none>' => t('Remove rel attribute'),
|
||||
'nofollow' => t('Set nofollow'),
|
||||
),
|
||||
);
|
||||
|
||||
// Icon Sets.
|
||||
$form['icons'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Icon Sets'),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => FALSE,
|
||||
);
|
||||
|
||||
$options = social_media_links_iconsets_options();
|
||||
$form['icons']['icon_style'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Icon Style'),
|
||||
'#default_value' => $values['icon_style'],
|
||||
'#options' => $options,
|
||||
);
|
||||
|
||||
// Generate the icon set table.
|
||||
$header = array(
|
||||
array(
|
||||
'data' => t('Name'),
|
||||
'style' => 'width: 150px;',
|
||||
),
|
||||
t('Sizes'),
|
||||
t('Icon examples and download instructions'),
|
||||
);
|
||||
|
||||
$rows = array();
|
||||
$icons = social_media_links_iconsets();
|
||||
foreach ($icons as $iconset_name => $iconset) {
|
||||
if (isset($iconset['download url'])) {
|
||||
$name = '<strong>' . l($iconset['name'], $iconset['download url'], array('attributes' => array('target' => '_blank'))) . '</strong>';
|
||||
}
|
||||
else {
|
||||
$name = '<strong>' . $iconset['name'] . '</strong>';
|
||||
}
|
||||
|
||||
if (isset($iconset['publisher'])) {
|
||||
$name .= '<br />' . t('by') . ' ';
|
||||
if (isset($iconset['publisher url'])) {
|
||||
$name .= l($iconset['publisher'], $iconset['publisher url'], array('attributes' => array('target' => '_blank')));
|
||||
}
|
||||
else {
|
||||
$name .= $iconset['publisher'];
|
||||
}
|
||||
}
|
||||
|
||||
$row = array(
|
||||
$name,
|
||||
implode('<br />', $iconset['styles']),
|
||||
);
|
||||
|
||||
if (!empty($iconset['path'])) {
|
||||
$row[] = _social_media_links_generate_example_table($platforms, $iconset);
|
||||
}
|
||||
else {
|
||||
$searchdirs = social_media_links_searchdirs($iconset_name);
|
||||
|
||||
$str = '<strong>' . t('Not installed.') . '</strong><br />';
|
||||
$str .= t('To install: !download and install it into',
|
||||
array(
|
||||
'!download' => l(t('Download'), $iconset['download url'], array('attributes' => array('target' => '_blank'))),
|
||||
)
|
||||
);
|
||||
$str .= ' <code> DRUPAL_ROOT/' . preg_replace('/,([^,]+) ?$/', " " . t('or') . " $1", implode(', ', $searchdirs), 1) . '</code>.';
|
||||
|
||||
if (isset($iconset['additional instructions'])) {
|
||||
$str .= ' ' . $iconset['additional instructions'];
|
||||
}
|
||||
$row[] = $str;
|
||||
}
|
||||
|
||||
$rows[] = $row;
|
||||
$vars = array(
|
||||
'header' => $header,
|
||||
'rows' => $rows,
|
||||
'attributes' => array(
|
||||
'id' => 'social-media-links-iconsets',
|
||||
),
|
||||
);
|
||||
|
||||
$form['icons']['installed'] = array(
|
||||
'#markup' => theme('table', $vars),
|
||||
);
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_block_save().
|
||||
*/
|
||||
function social_media_links_block_save($delta = '', $edit = array()) {
|
||||
if ($delta === 'social-media-links') {
|
||||
variable_set('social_media_links_platforms', $edit['platforms']);
|
||||
variable_set('social_media_links_appearance', $edit['appearance']);
|
||||
variable_set('social_media_links_link_attributes', $edit['link_attributes']);
|
||||
variable_set('social_media_links_icon_style', $edit['icon_style']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_block_view().
|
||||
*/
|
||||
function social_media_links_block_view($delta = '') {
|
||||
$block = array();
|
||||
switch ($delta) {
|
||||
case 'social-media-links':
|
||||
$platforms = variable_get('social_media_links_platforms', array());
|
||||
$platforms = _social_media_links_cleanup_platforms($platforms);
|
||||
|
||||
if (count($platforms) > 0) {
|
||||
$block['subject'] = t('Follow Us');
|
||||
$block['content'] = array(
|
||||
'#theme' => 'social_media_links_platforms',
|
||||
'#platform_values' => $platforms,
|
||||
'#icon_style' => variable_get('social_media_links_icon_style'),
|
||||
'#appearance' => variable_get('social_media_links_appearance'),
|
||||
'#link_attributes' => variable_get('social_media_links_link_attributes'),
|
||||
'#attributes' => array(
|
||||
'class' => array('social-media-links', 'platforms'),
|
||||
),
|
||||
);
|
||||
|
||||
// Add css to the block.
|
||||
$block['content']['#attached']['css'][] = drupal_get_path('module', 'social_media_links') . '/social_media_links.css';
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return $block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Preprocesses variables for social media links platforms.
|
||||
*
|
||||
* @see theme_social_media_links_platforms()
|
||||
*/
|
||||
function template_preprocess_social_media_links_platforms(&$variables) {
|
||||
$platform_infos = social_media_links_platforms();
|
||||
$icon_style = explode(':', $variables['icon_style']);
|
||||
|
||||
// Apply the link settings to the render array.
|
||||
foreach ($variables['link_attributes'] as $key => $value) {
|
||||
if ($value == '<none>') {
|
||||
unset($variables['link_attributes'][$key]);
|
||||
}
|
||||
}
|
||||
|
||||
// Sort and loop over the platforms.
|
||||
uasort($variables['platform_values'], 'drupal_sort_weight');
|
||||
foreach ($variables['platform_values'] as $platform_name => $platform_value) {
|
||||
// Build the platform data array.
|
||||
$variables['platforms'][$platform_name] = array(
|
||||
'#theme' => 'social_media_links_platform',
|
||||
'#name' => $platform_name,
|
||||
'#info' => $platform_infos[$platform_name],
|
||||
'#value' => $platform_value['platform_value'],
|
||||
'#icon_style' => $icon_style,
|
||||
'#appearance' => $variables['appearance'],
|
||||
'#attributes' => $variables['link_attributes'],
|
||||
);
|
||||
}
|
||||
|
||||
if ($variables['appearance']['orientation'] == 'h') {
|
||||
$variables['attributes']['class'][] = 'inline horizontal';
|
||||
}
|
||||
else {
|
||||
$variables['attributes']['class'][] = 'vertical';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes variables for social-media-links-platform.tpl.php.
|
||||
*
|
||||
* @see theme_social_media_links_platform()
|
||||
*/
|
||||
function template_preprocess_social_media_links_platform(&$variables) {
|
||||
$info = $variables['info'];
|
||||
$name = $variables['name'];
|
||||
$value = $variables['value'];
|
||||
$icon_style = $variables['icon_style'];
|
||||
|
||||
// Call the url callback of the platform to create the link url.
|
||||
$variables['link'] = $info['base url'] . $value;
|
||||
if (isset($info['url callback'])) {
|
||||
$platform_url_changed = call_user_func($info['url callback'], $info['base url'], $value);
|
||||
if ($platform_url_changed) {
|
||||
$variables['link'] = $platform_url_changed;
|
||||
}
|
||||
}
|
||||
|
||||
$variables['attributes']['title'] = check_plain($info['title']);
|
||||
$variables['icon_path'] = social_media_links_icon($icon_style[0], $name, $icon_style[1]);
|
||||
$variables['icon_alt'] = isset($info['image alt']) ? $info['image alt'] : $info['title'] . ' ' . t('icon');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the available platforms.
|
||||
*
|
||||
* @return array
|
||||
* Returns a list of platforms.
|
||||
*/
|
||||
function social_media_links_platforms() {
|
||||
$platforms = &drupal_static(__FUNCTION__);
|
||||
|
||||
// Grab from cache or build the array.
|
||||
if (isset($platforms)) {
|
||||
return $platforms;
|
||||
}
|
||||
|
||||
include_once 'social_media_links.platforms.inc';
|
||||
|
||||
$platforms = array();
|
||||
$platforms = module_invoke_all('social_media_links_platform_info');
|
||||
|
||||
drupal_alter('social_media_links_platform_info', $platforms);
|
||||
|
||||
return $platforms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all registered icon sets.
|
||||
*
|
||||
* @return array
|
||||
* Return a list of all registered platforms.
|
||||
*/
|
||||
function social_media_links_iconsets() {
|
||||
$sets = &drupal_static(__FUNCTION__);
|
||||
|
||||
// Grab from cache or build the array.
|
||||
if (isset($sets)) {
|
||||
return $sets;
|
||||
}
|
||||
|
||||
include_once 'social_media_links.iconsets.inc';
|
||||
|
||||
$sets = array();
|
||||
$sets = module_invoke_all('social_media_links_iconset_info');
|
||||
|
||||
foreach ($sets as $key => $set) {
|
||||
if ($path = social_media_links_iconset_path($key)) {
|
||||
$sets[$key]['path'] = $path;
|
||||
}
|
||||
}
|
||||
|
||||
drupal_alter('social_media_links_iconset_info', $sets);
|
||||
|
||||
return $sets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get informations about a specific icon set.
|
||||
*
|
||||
* @param string $iconset
|
||||
* Name of the icon set.
|
||||
*
|
||||
* @return array
|
||||
* Informations about the icon set.
|
||||
*/
|
||||
function social_media_links_iconset($iconset) {
|
||||
$sets = social_media_links_iconsets();
|
||||
return isset($sets[$iconset]) ? $sets[$iconset] : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path of a platform icon.
|
||||
*
|
||||
* @param string $iconset
|
||||
* Name of the icon set.
|
||||
* @param string $platform
|
||||
* Name of the platform.
|
||||
* @param string $style
|
||||
* Icon size.
|
||||
*
|
||||
* @return string
|
||||
* Path to the icon image.
|
||||
*/
|
||||
function social_media_links_icon($iconset, $platform, $style) {
|
||||
$iconset = social_media_links_iconset($iconset);
|
||||
return call_user_func($iconset['path callback'], $platform, $style);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with the possible locations of the installed iconsets.
|
||||
*
|
||||
* @param string $iconset
|
||||
* Optional: Name of the iconset.
|
||||
*
|
||||
* @return array
|
||||
* Possible path locations of the iconsets.
|
||||
*/
|
||||
function social_media_links_searchdirs($iconset = '') {
|
||||
$searchdirs = array();
|
||||
|
||||
$profile = drupal_get_path('profile', drupal_get_profile());
|
||||
$config = conf_path();
|
||||
|
||||
// Similar to 'modules' and 'themes' directories in the root directory,
|
||||
// certain distributions may want to place libraries into a 'libraries'
|
||||
// directory in Drupal's root directory.
|
||||
$searchdirs[] = 'libraries';
|
||||
|
||||
// Similar to 'modules' and 'themes' directories inside an installation
|
||||
// profile, installation profiles may want to place libraries into a
|
||||
// 'libraries' directory. But exclude/ignore the standard drupal profiles.
|
||||
if (!in_array($profile, array('minimal', 'standard', 'testing'))) {
|
||||
$searchdirs[] = "$profile/libraries";
|
||||
}
|
||||
|
||||
// Always search sites/all/libraries.
|
||||
$searchdirs[] = 'sites/all/libraries';
|
||||
|
||||
// Also search sites/<domain>/libraries.
|
||||
$searchdirs[] = "$config/libraries";
|
||||
|
||||
if (!empty($iconset)) {
|
||||
foreach ($searchdirs as $key => $dir) {
|
||||
$searchdirs[$key] = $dir . '/' . $iconset;
|
||||
}
|
||||
}
|
||||
|
||||
return $searchdirs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of library directories.
|
||||
*
|
||||
* @return array
|
||||
* A list of library directories.
|
||||
*/
|
||||
function social_media_links_libraries() {
|
||||
$directories = &drupal_static(__FUNCTION__);
|
||||
|
||||
// Grab from cache or build the array.
|
||||
if (isset($directories)) {
|
||||
return $directories;
|
||||
}
|
||||
|
||||
$searchdirs = social_media_links_searchdirs();
|
||||
|
||||
// Add the social_media_links module directory.
|
||||
$searchdirs[] = drupal_get_path('module', 'social_media_links') . '/libraries';
|
||||
|
||||
$directories = array();
|
||||
$nomask = array('CVS');
|
||||
foreach ($searchdirs as $dir) {
|
||||
if (is_dir($dir) && $handle = opendir($dir)) {
|
||||
while (FALSE !== ($file = readdir($handle))) {
|
||||
if (!in_array($file, $nomask) && $file[0] != '.') {
|
||||
if (is_dir("$dir/$file")) {
|
||||
$directories[$file] = "$dir/$file";
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
}
|
||||
|
||||
return $directories;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the library path of an icon set.
|
||||
*
|
||||
* @param string $iconset
|
||||
* Name of the icon set.
|
||||
*
|
||||
* @return string
|
||||
* Path of the icon set.
|
||||
*/
|
||||
function social_media_links_iconset_path($iconset) {
|
||||
$path = FALSE;
|
||||
$libraries = social_media_links_libraries();
|
||||
if (array_key_exists($iconset, $libraries)) {
|
||||
$path = $libraries[$iconset];
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list options for the icon set style select.
|
||||
*
|
||||
* @return array
|
||||
* Array with the select options.
|
||||
*/
|
||||
function social_media_links_iconsets_options() {
|
||||
$iconsets = social_media_links_iconsets();
|
||||
$options = array();
|
||||
|
||||
foreach ($iconsets as $iconset_name => $iconset) {
|
||||
if (!empty($iconset['path'])) {
|
||||
foreach ($iconset['styles'] as $sid => $style) {
|
||||
$options[$iconset['name']][$iconset_name . ':' . $sid] = $style;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme function for the platforms.
|
||||
*/
|
||||
function theme_social_media_links_platforms(&$variables) {
|
||||
$output = '';
|
||||
|
||||
$platforms = $variables['platforms'];
|
||||
$attributes = $variables['attributes'];
|
||||
|
||||
// Open the ul element.
|
||||
$output .= '<ul' . drupal_attributes($attributes) . '>';
|
||||
|
||||
$num_platforms = count($platforms);
|
||||
$i = 1;
|
||||
|
||||
foreach ($platforms as $name => $platform) {
|
||||
$class = array($name);
|
||||
|
||||
// Add first and last classes to the list of platforms to help out themers.
|
||||
if ($i == 1) {
|
||||
$class[] = 'first';
|
||||
}
|
||||
if ($i == $num_platforms) {
|
||||
$class[] = 'last';
|
||||
}
|
||||
|
||||
$output .= '<li ' . drupal_attributes(array('class' => $class)) . '>';
|
||||
// Render the platform item.
|
||||
$output .= drupal_render($platform);
|
||||
$output .= '</li>';
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
// Close the ul element.
|
||||
$output .= '</ul>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme function for a single platform element.
|
||||
*/
|
||||
function theme_social_media_links_platform(&$variables) {
|
||||
$output = '';
|
||||
|
||||
$icon = theme_image(array(
|
||||
'path' => $variables['icon_path'],
|
||||
'alt' => $variables['icon_alt'],
|
||||
'attributes' => array(),
|
||||
));
|
||||
|
||||
$options = array();
|
||||
$options['attributes'] = $variables['attributes'];
|
||||
$options['html'] = TRUE;
|
||||
|
||||
$output .= l($icon, $variables['link'], $options);
|
||||
|
||||
if (!empty($variables['appearance']['show_name'])) {
|
||||
if ($variables['appearance']['orientation'] == 'h') {
|
||||
$output .= '<br />';
|
||||
}
|
||||
|
||||
$title = check_plain($variables['attributes']['title']);
|
||||
$output .= '<span>' . l($title, $variables['link'], $options) . '</span>';
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for the platform table with tabledrag.
|
||||
*/
|
||||
function theme_social_media_links_platforms_table(&$variables) {
|
||||
$form = $variables['form'];
|
||||
|
||||
$rows = array();
|
||||
foreach (element_children($form) as $platform) {
|
||||
$form[$platform]['weight']['#attributes']['class'] = array('platforms-order-weight');
|
||||
$rows[] = array(
|
||||
'data' => array(
|
||||
'<strong>' . $form[$platform]['platform_value']['#title'] . '<strong>',
|
||||
array('class' => array('platform-cross'), 'data' => drupal_render($form[$platform]['platform_value'])),
|
||||
array('class' => array('tabledrag-hide'), 'data' => drupal_render($form[$platform]['weight'])),
|
||||
),
|
||||
'class' => array('draggable'),
|
||||
);
|
||||
}
|
||||
|
||||
$header = array(
|
||||
t('Platform'),
|
||||
'',
|
||||
array(
|
||||
'class' => array('tabledrag-hide'),
|
||||
'data' => t('Weight'),
|
||||
),
|
||||
);
|
||||
|
||||
$output = theme('table', array(
|
||||
'header' => $header,
|
||||
'rows' => $rows,
|
||||
'attributes' => array('id' => 'platforms-order'),
|
||||
));
|
||||
|
||||
drupal_add_tabledrag('platforms-order', 'order', 'silbing', 'platforms-order-weight');
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to clean up the platforms array from the empty
|
||||
* values.
|
||||
*
|
||||
* @param array $platforms
|
||||
* The array with the platforms.
|
||||
*
|
||||
* @return array
|
||||
* The cleaned platforms array.
|
||||
*/
|
||||
function _social_media_links_cleanup_platforms($platforms) {
|
||||
foreach ((array) $platforms as $key => $platform) {
|
||||
if (empty($platform['platform_value'])) {
|
||||
unset($platforms[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
return $platforms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to generate the icon set example table.
|
||||
*
|
||||
* @param array $platforms
|
||||
* Keyed array with all available platforms.
|
||||
* @param array $iconset
|
||||
* Array with the information about the icon set.
|
||||
*
|
||||
* @return string
|
||||
* The generated table markup.
|
||||
*/
|
||||
function _social_media_links_generate_example_table($platforms, $iconset) {
|
||||
if (!is_array($platforms) && count($platforms) == 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$groups = array_chunk($platforms, 10, TRUE);
|
||||
$output = '';
|
||||
|
||||
// Use the first iconset style for the sample table.
|
||||
$style = key($iconset['styles']);
|
||||
|
||||
foreach ($groups as $group) {
|
||||
$header = array();
|
||||
$row = array();
|
||||
|
||||
foreach ($group as $platform_name => $platform) {
|
||||
$header[] = array(
|
||||
'data' => $platform['title'],
|
||||
'style' => 'text-align: center; ',
|
||||
);
|
||||
|
||||
$vars = array('path' => call_user_func($iconset['path callback'], $platform_name, $style));
|
||||
|
||||
if (file_exists($vars['path'])) {
|
||||
$row[] = array(
|
||||
'data' => theme('image', $vars) . ' ',
|
||||
'style' => 'text-align: center;',
|
||||
);
|
||||
}
|
||||
else {
|
||||
$row[] = array(
|
||||
'data' => '–',
|
||||
'style' => 'text-align: center;',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$vars = array(
|
||||
'header' => $header,
|
||||
'rows' => array('data' => $row),
|
||||
);
|
||||
$output .= theme('table', $vars);
|
||||
$output .= '<br />';
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Callbacks for the platforms.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Register the default platforms.
|
||||
*
|
||||
* @return array
|
||||
* List with the default supported platforms.
|
||||
*/
|
||||
function social_media_links_social_media_links_platform_info() {
|
||||
$platforms['facebook'] = array(
|
||||
'title' => t('Facebook'),
|
||||
'base url' => 'https://www.facebook.com/',
|
||||
);
|
||||
|
||||
$platforms['twitter'] = array(
|
||||
'title' => t('Twitter'),
|
||||
'base url' => 'http://www.twitter.com/',
|
||||
);
|
||||
|
||||
$platforms['googleplus'] = array(
|
||||
'title' => t('Google+'),
|
||||
'base url' => 'https://plus.google.com/',
|
||||
'image alt' => 'Google+ icon',
|
||||
);
|
||||
|
||||
$platforms['tumblr'] = array(
|
||||
'title' => t('Tumblr'),
|
||||
'base url' => '',
|
||||
'image alt' => 'Tumblr',
|
||||
);
|
||||
|
||||
$platforms['instagram'] = array(
|
||||
'title' => t('Instagram'),
|
||||
'base url' => 'http://www.instagram.com/',
|
||||
);
|
||||
|
||||
$platforms['linkedin'] = array(
|
||||
'title' => t('LinkedIn'),
|
||||
'base url' => 'http://www.linkedin.com/',
|
||||
);
|
||||
|
||||
$platforms['pinterest'] = array(
|
||||
'title' => t('Pinterest'),
|
||||
'base url' => 'http://www.pinterest.com/',
|
||||
);
|
||||
|
||||
$platforms['vimeo'] = array(
|
||||
'title' => t('Vimeo'),
|
||||
'base url' => 'http://www.vimeo.com/',
|
||||
);
|
||||
|
||||
$platforms['youtube'] = array(
|
||||
'title' => t('YouTube'),
|
||||
'base url' => 'http://www.youtube.com/user/',
|
||||
);
|
||||
|
||||
$platforms['youtube_channel'] = array(
|
||||
'title' => t('Youtube (Channel)'),
|
||||
'base url' => 'http://www.youtube.com/channel/',
|
||||
);
|
||||
|
||||
$platforms['rss'] = array(
|
||||
'title' => t('RSS'),
|
||||
'base url' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
|
||||
);
|
||||
|
||||
$platforms['contact'] = array(
|
||||
'title' => t('Contact'),
|
||||
'base url' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
|
||||
'link attributes' => FALSE,
|
||||
);
|
||||
|
||||
$platforms['email'] = array(
|
||||
'title' => t('E-Mail'),
|
||||
'base url' => '',
|
||||
'url callback' => 'social_media_links_email_url',
|
||||
'link attributes' => FALSE,
|
||||
);
|
||||
|
||||
return $platforms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback function to generate the correct url for e-mail links.
|
||||
*/
|
||||
function social_media_links_email_url($base_url, $platform_value) {
|
||||
if (valid_email_address($platform_value)) {
|
||||
return 'mailto:' . $platform_value;
|
||||
}
|
||||
return FALSE;
|
||||
}
|