first import

This commit is contained in:
Bachir Soussi Chiadmi
2015-04-08 11:40:19 +02:00
commit 1bc61b12ad
8435 changed files with 1582817 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
##########################################################################################
_ _ _ _
__| | _____ _____| | ___ _ __ _ __ ___ ___ _ __ | |_ __ _ ___ ___| | _____
/ _` |/ _ \ \ / / _ \ |/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __| / _` |/ _ \/ _ \ |/ / __|
| (_| | __/\ V / __/ | (_) | |_) | | | | | | __/ | | | |_ | (_| | __/ __/ <\__ \
\__,_|\___| \_/ \___|_|\___/| .__/|_| |_| |_|\___|_| |_|\__| \__, |\___|\___|_|\_\___/
|_| |___/
##########################################################################################
##########################################################################################
##### Delta Module
##########################################################################################
Project Page: http://drupal.org/project/delta
Issue Queue: http://drupal.org/project/issues/delta
Usage Stats: http://drupal.org/project/usage/delta
Maintainer(s): Jake Strawn
http://himerus.com
http://developmentgeeks.com
http://facebook.com/developmentgeeks
http://drupal.org/user/159141
http://twitter.com/himerus
##########################################################################################
##### CHANGELOG.txt
##########################################################################################

View 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.

View File

@@ -0,0 +1,57 @@
##########################################################################################
_ _ _ _
__| | _____ _____| | ___ _ __ _ __ ___ ___ _ __ | |_ __ _ ___ ___| | _____
/ _` |/ _ \ \ / / _ \ |/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __| / _` |/ _ \/ _ \ |/ / __|
| (_| | __/\ V / __/ | (_) | |_) | | | | | | __/ | | | |_ | (_| | __/ __/ <\__ \
\__,_|\___| \_/ \___|_|\___/| .__/|_| |_| |_|\___|_| |_|\__| \__, |\___|\___|_|\_\___/
|_| |___/
##########################################################################################
##########################################################################################
##### Delta Module
##########################################################################################
Project Page: http://drupal.org/project/delta
Issue Queue: http://drupal.org/project/issues/delta
Usage Stats: http://drupal.org/project/usage/delta
Maintainer(s):
Jake Strawn
http://himerus.com
http://developmentgeeks.com
http://facebook.com/developmentgeeks
http://drupal.org/user/159141
http://twitter.com/himerus
Sebastian Siemssen
http://twitter.com/thefubhy
http://drupal.org/user/761344
##########################################################################################
Delta Module Information
========================
The Delta module enables contextual theme settings for Omega (drupal.org/project/omega)
subthemes. The combination of Delta, Omega and Context will give you the ability to create
duplicates of theme settings and via Context assign them as a reaction to any context you
can create.
Usage
=====
1.) Download and install the Delta & Context modules
2.) Download and enable an Omega Subtheme
a.) http://drupal.org/project/omega (Omega Base theme & Starterkit)
b.) http://drupal.org/project/gamma (Gamma subtheme)
3.) Visit /admin/appearance and configure the defaults for your Omega subtheme
4.) Visit /admin/appearance/delta and select the checkbox for the appropriate subtheme
on the default settings tab
5.) Visit /admin/appearance/delta/templates/add and create your first template.
a.) Give it a pretty name
b.) Select your theme from the dropdown & save
6.) Automatically directed to /admin/appearance/delta/templates/configure/your-template,
you will be able to customize the settings for this special copy of the theme settings.
7.) Visit /admin/structure/context, and add or edit a context with your conditions
8.) Select Delta from the reactions box, and select the appropriate Delta template you
just created.
9.) Save and Enjoy...
Related Information
===================
* http://himerus.com/blog/himerus/omega-intro-2-delta-module-contextual-theme-settings

View File

@@ -0,0 +1,22 @@
name = Delta API
description = The Delta module is an advanced manipulation of the Theme Settings API to allow for customization/configuration of theme settings based on node types, context, or groups of paths.
package = Theme Tools
core = 7.x
version = 7.x-3.x-dev
dependencies[] = ctools
; Information added by drupal.org packaging script on 2011-11-12
version = "7.x-3.x-dev"
core = "7.x"
project = "delta"
datestamp = "1321099837"
; Information added by drupal.org packaging script on 2012-07-25
version = "7.x-3.0-beta11+0-dev"
core = "7.x"
project = "delta"
datestamp = "1343175072"

View File

@@ -0,0 +1,231 @@
<?php
/**
* @file
* Contains install, update, and uninstall functions for Skinr.
*/
/**
* Implementats hook_schema().
*/
function delta_schema() {
$schema['delta'] = array(
'description' => t('Stores theme-settings templates that allow overriding the theme settings used based on various contexts.'),
'export' => array(
'key' => 'machine_name',
'key name' => 'name',
'primary key' => 'machine_name',
'identifier' => 'delta',
'default hook' => 'delta_default_templates',
'status' => 'delta_status',
'api' => array(
'owner' => 'delta',
'api' => 'delta',
'minimum_version' => 3,
'current_version' => 3,
),
'export callback' => 'delta_export',
),
'fields' => array(
'machine_name' => array(
'description' => 'The system name of this theme settings template.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
),
'name' => array(
'description' => 'The friendly name of this theme settings template.',
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
),
'description' => array(
'description' => 'A brief description of this theme settings template.',
'type' => 'text',
'size' => 'medium',
'not null' => TRUE,
),
'theme' => array(
'description' => 'The theme for which this theme settings template is relevant.',
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
),
'mode' => array(
'description' => 'The mode that this template operrates in.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
),
'parent' => array(
'description' => 'The system name of the parent of this theme settings template.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
),
'settings' => array(
'description' => 'Serialized data which is a copy of the theme settings array stored in the system table based on these overrides',
'type' => 'blob',
'size' => 'big',
'not null' => FALSE,
'serialize' => TRUE,
),
),
'primary key' => array('machine_name'),
);
return $schema;
}
/**
* Rename the delta_theme_settings table to delta only and adjust it to be compatible with Delta 3.x.
*/
function delta_update_7301(&$sandbox) {
if (!isset($sandbox['progress'])) {
$sandbox['#finished'] = 0;
$sandbox['progress'] = 0;
$sandbox['max'] = db_select('delta_theme_settings', 'dt')->countQuery()->execute()->fetchField();
foreach (array('tid', 'theme', 'system_name') as $item) {
db_drop_index('delta_theme_settings', $item);
}
db_drop_field('delta_theme_settings', 'tid');
db_change_field('delta_theme_settings', 'data', 'settings', array(
'description' => 'Serialized data which is a copy of the theme settings array stored in the system table based on these overrides',
'type' => 'blob',
'size' => 'big',
'not null' => FALSE,
'serialize' => TRUE,
));
db_change_field('delta_theme_settings', 'system_name', 'machine_name', array(
'description' => 'The system name of this theme settings template.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
), array(
'primary key' => array('machine_name'),
));
db_change_field('delta_theme_settings', 'theme', 'theme', array(
'description' => 'The theme for which this theme settings template is relevant.',
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
));
db_change_field('delta_theme_settings', 'name', 'name', array(
'description' => 'The friendly name of this theme settings template.',
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
));
db_add_field('delta_theme_settings', 'mode', array(
'description' => 'The mode that this template operrates in.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'initial' => 'override',
));
db_rename_table('delta_theme_settings', 'delta');
}
$templates = db_select('delta', 'd')
->fields('d', array('machine_name'))
->orderBy('machine_name')
->range($sandbox['progress'], 10)
->execute()
->fetchCol();
foreach ($templates as $name) {
$key = 'theme_delta_' . $name . '_settings';
$settings = variable_get($key, array());
variable_del($key);
unset($settings['delta_template']);
db_update('delta')
->fields(array('settings' => serialize($settings)))
->condition('machine_name', $name)
->execute();
$sandbox['progress']++;
}
$sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']);
if ($sandbox['#finished'] >= 1) {
return t("The Delta module's database table has been updated successfully and can now be used with Delta 3.x.");
}
}
/**
* Add a description field to the Delta database table.
*/
function delta_update_7302(&$sandbox) {
db_add_field('delta', 'description', array(
'description' => 'A brief description of this theme settings template.',
'type' => 'text',
'size' => 'medium',
'not null' => TRUE,
'initial' => '',
));
return t("Successfully added a description field to the Delta database table.");
}
/**
* Add a parent field to the Delta database table.
*/
function delta_update_7303(&$sandbox) {
db_add_field('delta', 'parent', array(
'description' => 'The system name of the parent of this theme settings template.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'initial' => '',
));
return t("Successfully added a parent field to the Delta database table.");
}
/**
* Add keys to the settings arrays.
*/
function delta_update_7304(&$sandbox) {
if (!isset($sandbox['progress'])) {
$sandbox['#finished'] = 0;
$sandbox['progress'] = 0;
$sandbox['max'] = db_select('delta', 'dt')->countQuery()->execute()->fetchField();
}
$templates = db_select('delta', 'd')
->fields('d', array('machine_name', 'settings', 'theme'))
->orderBy('machine_name')
->range($sandbox['progress'], 10)
->execute();
foreach ($templates as $item) {
$settings = array('theme_' . $item->theme . '_settings' => unserialize($item->settings));
db_update('delta')
->fields(array('settings' => serialize($settings)))
->condition('machine_name', $item->machine_name)
->execute();
$sandbox['progress']++;
}
$sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']);
if ($sandbox['#finished'] >= 1) {
cache_clear_all();
return t("The Delta template settings have been successfully updated.");
}
}

View File

@@ -0,0 +1,278 @@
<?php
/**
* @file Provide contextual theme settings via context module
*/
define('DELTA_PRESERVE', 'preserve');
define('DELTA_OVERRIDE', 'override');
/**
* Implements hook_menu_alter().
*/
function delta_menu_alter(&$items) {
foreach (list_themes() as $theme) {
$items['admin/appearance/settings/' . $theme->name]['page arguments'] = array($theme->name);
$items['admin/appearance/settings/' . $theme->name]['page callback'] = 'delta_theme_settings';
}
}
/**
* Implements hook_ctools_plugin_type().
*/
function delta_ctools_plugin_type() {
return array(
'plugins' => array(
'cache' => TRUE,
'use hooks' => TRUE,
'classes' => array('handler'),
'load themes' => TRUE,
),
);
}
/**
* Implements hook_delta_plugins().
*/
function delta_delta_plugins() {
return array(
'delta_injection' => array(
'handler' => array(
'path' => drupal_get_path('module', 'delta') . '/plugins/delta',
'file' => 'delta_injection.inc',
'class' => 'delta_injection',
),
),
'delta_injection_theme_settings' => array(
'handler' => array(
'path' => drupal_get_path('module', 'delta') . '/plugins/delta',
'file' => 'delta_injection_theme_settings.inc',
'class' => 'delta_injection_theme_settings',
'parent' => 'delta_injection',
),
),
);
}
/**
* Implements hook_context_plugins().
*/
function delta_context_plugins() {
return array(
'context_reaction_delta' => array(
'handler' => array(
'path' => drupal_get_path('module', 'delta') . '/plugins/context',
'file' => 'context_reaction_delta.inc',
'class' => 'context_reaction_delta',
'parent' => 'context_reaction',
),
),
);
}
/**
* Implements hook_context_regiswaittry().
*/
function delta_context_registry() {
return array(
'reactions' => array(
'delta' => array(
'title' => t('Delta'),
'description' => t('Apply contextual theme settings via the Delta module.'),
'plugin' => 'context_reaction_delta',
),
),
);
}
/**
* Implements hook_context_page_reaction().
*/
function delta_context_page_reaction(){
if ($plugin = context_get_plugin('reaction', 'delta')) {
$plugin->execute();
}
}
/**
* Implements hook_load().
*/
function delta_load($name) {
ctools_include('export');
if ($template = ctools_export_crud_load('delta', $name)) {
return $template;
}
}
/**
* @todo
*/
function delta_load_all($reset = FALSE) {
return ctools_export_crud_load_all('delta', $reset);
}
/**
* @todo
*/
function delta_enabled($name) {
$template = delta_load($name);
return $template && (!isset($template->disabled) || !$template->disabled);
}
/**
* @todo
*/
function delta_reset($theme) {
if ($current = delta_get_current($theme)) {
foreach (delta_get_plugins($current) as $plugin) {
$plugin->revoke();
}
$pointer = &drupal_static('delta_inject');
$pointer[$theme] = NULL;
module_invoke_all('delta_reset', $theme, $current);
return $current;
}
}
/**
* @todo
*/
function delta_get_current($theme) {
$pointer = drupal_static('delta_inject');
if (isset($pointer[$theme])) {
return $pointer[$theme];
}
}
/**
* @todos
*/
function delta_inject($name) {
if ($name && $delta = delta_load($name)) {
$pointer = &drupal_static(__FUNCTION__);
$before = delta_reset($delta->theme);
foreach (delta_get_plugins($name) as $plugin) {
$plugin->inject();
}
$pointer[$delta->theme] = $name;
module_invoke_all('delta_inject', $delta->theme, $name);
return $before;
}
}
/**
* @todo
*/
function delta_get_plugin($name, $plugin) {
if ($plugins = delta_get_plugins($name)) {
if (isset($plugins[$plugin])) {
return $plugins[$plugin];
}
}
return FALSE;
}
/**
* @todo
*/
function delta_get_plugins($name) {
$cache = &drupal_static(__FUNCTION__);
if (!isset($cache[$name])) {
$cache[$name] = array();
ctools_include('plugins');
foreach (ctools_get_plugins('delta', 'plugins') as $plugin) {
if ($plugin['name'] != 'delta_injection') {
if ($class = ctools_plugin_get_class($plugin, 'handler')) {
$cache[$name][$plugin['name']] = new $class($plugin, $name);
}
}
}
drupal_alter('delta_plugins', $cache[$name], $name);
}
return $cache[$name];
}
/**
* @todo
*/
function delta_variable_set($name, $value) {
$original = isset($GLOBALS['conf'][$name]) ? $GLOBALS['conf'][$name] : NULL;
$GLOBALS['conf'][$name] = $value;
return $original;
}
/**
* @todo
*/
function delta_ancestors($name) {
$ancestors = array();
if ($template = delta_load($name)) {
$ancestors[$template->machine_name] = $template;
if (!empty($template->parent)) {
$ancestors = array_merge($ancestors, delta_ancestors($template->parent));
}
}
return $ancestors;
}
/**
* @todo
*/
function delta_merge($first, $second) {
if (is_array($first) && is_array($second)) {
return array_merge($first, $second);
}
if (is_object($first) && is_object($second)) {
return (object) array_merge((array) $first, (array) $second);
}
return $second;
}
/**
* @todo
*/
function delta_reduce(array $first, array $second) {
if ($first === $second) {
return NULL;
}
foreach ($first as $name => $value) {
if (($first[$name] === NULL && !isset($second[$name])) || (isset($second[$name]) && $value === $second[$name])) {
unset($first[$name]);
}
}
return $first;
}
/**
* @todo
*/
function delta_theme_settings($key) {
$backup = delta_reset($key);
$form = drupal_get_form('system_theme_settings', $key);
delta_inject($backup);
return $form;
}

View File

@@ -0,0 +1,20 @@
name = Delta Blocks
description = Exposes a number of core Drupal elements as blocks.
core = 7.x
version = 7.x-3.x-dev
package = Theme Tools
; Information added by drupal.org packaging script on 2011-11-12
version = "7.x-3.x-dev"
core = "7.x"
project = "delta"
datestamp = "1321099837"
; Information added by drupal.org packaging script on 2012-07-25
version = "7.x-3.0-beta11+0-dev"
core = "7.x"
project = "delta"
datestamp = "1343175072"

View File

@@ -0,0 +1,42 @@
<?php
/**
* @file
* Install/uninstall functions for the Delta blocks module.
*/
/**
* Implements hook_uninstall().
*/
function delta_blocks_uninstall() {
variable_del('delta_blocks_blocks');
variable_del('delta_blocks_logo_linked');
variable_del('delta_blocks_page_title_hidden');
variable_del('delta_blocks_site_name_linked');
variable_del('delta_blocks_site_name_hidden');
variable_del('delta_blocks_site_slogan_hidden');
variable_del('delta_blocks_branding_logo_linked');
variable_del('delta_blocks_branding_logo_render');
variable_del('delta_blocks_branding_site_name_linked');
variable_del('delta_blocks_branding_site_name_hidden');
variable_del('delta_blocks_branding_site_slogan_hidden');
variable_del('delta_blocks_breadcrumb_title_hidden');
variable_del('delta_blocks_breadcrumb_current');
}
/**
* Implements hook_install().
*/
function delta_blocks_install() {
variable_set('delta_blocks_logo_linked', TRUE);
variable_set('delta_blocks_page_title_hidden', FALSE);
variable_set('delta_blocks_site_name_linked', TRUE);
variable_set('delta_blocks_site_name_hidden', FALSE);
variable_set('delta_blocks_site_slogan_hidden', FALSE);
variable_set('delta_blocks_branding_logo_linked', TRUE);
variable_set('delta_blocks_branding_logo_render', TRUE);
variable_set('delta_blocks_branding_site_name_linked', TRUE);
variable_set('delta_blocks_branding_site_name_hidden', FALSE);
variable_set('delta_blocks_branding_site_slogan_hidden', FALSE);
variable_set('delta_blocks_breadcrumb_title_hidden', TRUE);
variable_set('delta_blocks_breadcrumb_current', TRUE);
}

View File

@@ -0,0 +1,449 @@
<?php
/**
* @file
* Exposes a number of core Drupal elements as blocks.
*/
/**
* Implements hook_help().
*/
function delta_blocks_help($path, $arg) {
if ($path == 'admin/help#delta_blocks') {
return '<p>' . t('This module exposes a number of core Drupal elements as blocks.') . '</p>';
}
}
/**
* Implements hook_menu()
*/
function delta_blocks_menu() {
$items = array();
$items['admin/config/user-interface/delta-blocks'] = array(
'title' => 'Delta blocks',
'description' => 'Settings for the Delta blocks module.',
'page callback' => 'drupal_get_form',
'page arguments' => array('delta_blocks_admin_settings'),
'access arguments' => array('administer delta blocks'),
'type' => MENU_NORMAL_ITEM,
'file' => 'includes/delta_blocks.admin.inc',
);
return $items;
}
/**
* Implements hook_permission().
*/
function delta_blocks_permission() {
return array(
'administer delta blocks' => array(
'title' => t('Administer Delta blocks'),
'description' => t('Manage settings for Delta blocks module'),
),
);
}
/**
* Implements hook_block_info().
*/
function delta_blocks_block_info() {
$blocks = array();
foreach (_delta_blocks_get_blocks() as $delta => $info) {
if (_delta_blocks_is_enabled($delta)) {
$blocks[$delta] = array(
'info' => $info['title'],
'cache' => $info['cache'],
);
}
}
return $blocks;
}
/**
* Implements hook_block_view().
*/
function delta_blocks_block_view($delta = '') {
$blocks = _delta_blocks_get_blocks();
if (isset($blocks[$delta]) && _delta_blocks_is_enabled($delta)) {
return array(
'subject' => '',
'content' => delta_blocks_get_content($delta),
);
}
}
/**
* Implements hook_block_save().
*/
function delta_blocks_block_save($delta = '', $edit = array()) {
switch ($delta) {
case 'branding':
variable_set('delta_blocks_branding_site_name_hidden', $edit['delta_blocks_branding_site_slogan_hidden']);
variable_set('delta_blocks_branding_site_slogan_hidden', $edit['delta_blocks_branding_site_slogan_hidden']);
variable_set('delta_blocks_branding_logo_linked', $edit['delta_blocks_branding_logo_linked']);
variable_set('delta_blocks_branding_logo_render', $edit['delta_blocks_branding_logo_render']);
variable_set('delta_blocks_branding_site_name_linked', $edit['delta_blocks_branding_site_name_linked']);
break;
case 'site-name':
variable_set('delta_blocks_site_name_linked', $edit['delta_blocks_site_name_linked']);
variable_set('delta_blocks_site_name_hidden', $edit['delta_blocks_site_name_hidden']);
break;
case 'site-slogan':
variable_set('delta_blocks_site_slogan_hidden', $edit['delta_blocks_site_slogan_hidden']);
break;
case 'page-title':
variable_set('delta_blocks_page_title_hidden', $edit['delta_blocks_page_title_hidden']);
break;
case 'logo':
variable_set('delta_blocks_logo_linked', $edit['delta_blocks_logo_linked']);
break;
case 'breadcrumb':
variable_set('delta_blocks_breadcrumb_title_hidden', $edit['delta_blocks_breadcrumb_title_hidden']);
variable_set('delta_blocks_breadcrumb_current', $edit['delta_blocks_breadcrumb_current']);
break;
}
}
/**
* Implements hook_block_configure().
*/
function delta_blocks_block_configure($delta = '') {
$form = array();
switch ($delta) {
case 'branding':
$form['delta_blocks_settings']['delta_blocks_branding_site_name_linked'] = array(
'#type' => 'checkbox',
'#title' => t('Link the site name to your front page'),
'#default_value' => variable_get('delta_blocks_branding_site_name_linked', TRUE),
);
$form['delta_blocks_settings']['delta_blocks_branding_site_name_hidden'] = array(
'#type' => 'checkbox',
'#title' => t('Hide the site name via CSS'),
'#default_value' => variable_get('delta_blocks_branding_site_name_hidden', FALSE),
);
$form['delta_blocks_settings']['delta_blocks_branding_site_slogan_hidden'] = array(
'#type' => 'checkbox',
'#title' => t('Hide site slogan via CSS'),
'#default_value' => variable_get('delta_blocks_branding_site_slogan_hidden', FALSE),
);
$form['delta_blocks_settings']['delta_blocks_branding_logo_render'] = array(
'#type' => 'checkbox',
'#title' => t('Show the logo'),
'#default_value' => variable_get('delta_blocks_branding_logo_render', TRUE),
);
$form['delta_blocks_settings']['delta_blocks_branding_logo_linked'] = array(
'#type' => 'checkbox',
'#title' => t('Link the logo to your front page'),
'#default_value' => variable_get('delta_blocks_branding_logo_linked', TRUE),
'#states' => array(
'visible' => array(
':input[name="delta_blocks_branding_logo_render"]' => array('checked' => TRUE),
),
),
);
break;
case 'site-name':
$form['delta_blocks_settings']['delta_blocks_site_name_linked'] = array(
'#type' => 'checkbox',
'#title' => t('Link the site name to your front page'),
'#default_value' => variable_get('delta_blocks_site_name_linked', TRUE),
);
$form['delta_blocks_settings']['delta_blocks_site_name_hidden'] = array(
'#type' => 'checkbox',
'#title' => t('Hide the site name via CSS'),
'#default_value' => variable_get('delta_blocks_site_name_hidden', TRUE),
);
break;
case 'site-slogan':
$form['delta_blocks_settings']['delta_blocks_site_slogan_hidden'] = array(
'#type' => 'checkbox',
'#title' => t('Hide the site slogan via CSS'),
'#default_value' => variable_get('delta_blocks_site_slogan_hidden', TRUE),
);
break;
case 'page-title':
$form['delta_blocks_settings']['delta_blocks_page_title_hidden'] = array(
'#type' => 'checkbox',
'#title' => t('Hide page title via CSS'),
'#default_value' => variable_get('delta_blocks_page_title_hidden', FALSE),
);
break;
case 'logo':
$form['delta_blocks_settings']['delta_blocks_logo_linked'] = array(
'#type' => 'checkbox',
'#title' => t('Link the logo to your front page'),
'#default_value' => variable_get('delta_blocks_logo_linked', TRUE),
);
break;
case 'breadcrumb':
$form['delta_blocks_settings']['delta_blocks_breadcrumb_title_hidden'] = array(
'#type' => 'checkbox',
'#title' => t('Hide the block title via CSS'),
'#default_value' => variable_get('delta_blocks_breadcrumb_title_hidden', TRUE),
);
$form['delta_blocks_settings']['delta_blocks_breadcrumb_current'] = array(
'#type' => 'checkbox',
'#title' => t('Append the current page to the breadcrumb navigation'),
'#default_value' => variable_get('delta_blocks_breadcrumb_current', TRUE),
);
break;
}
if (!empty($form)) {
$form['delta_blocks_settings'] += array(
'#type' => 'fieldset',
'#title' => t('Block settings'),
);
}
return $form;
}
/**
* Implements hook_theme().
*/
function delta_blocks_theme() {
return array(
'delta_blocks_logo' => array(
'variables' => array('logo' => NULL, 'logo_link' => NULL, 'site_name' => NULL),
'file' => 'includes/delta_blocks.theme.inc',
),
'delta_blocks_site_name' => array(
'variables' => array('site_name' => NULL),
'file' => 'includes/delta_blocks.theme.inc',
),
'delta_blocks_site_slogan' => array(
'variables' => array('site_slogan' => NULL),
'file' => 'includes/delta_blocks.theme.inc',
),
'delta_blocks_branding' => array(
'variables' => array('site_name' => NULL, 'site_slogan' => NULL, 'logo' => NULL, 'logo_link' => NULL, 'site_name_hidden' => NULL, 'site_slogan_hidden' => NULL),
'file' => 'includes/delta_blocks.theme.inc',
),
'delta_blocks_page_title' => array(
'variables' => array('page_title' => NULL),
'file' => 'includes/delta_blocks.theme.inc',
),
'delta_blocks_breadcrumb' => array(
'variables' => array('breadcrumb' => NULL),
'file' => 'includes/delta_blocks.theme.inc',
),
'delta_blocks_action_links' => array(
'variables' => array('action_links' => NULL),
'file' => 'includes/delta_blocks.theme.inc',
),
'delta_blocks_feed_icons' => array(
'variables' => array('feed_icons' => NULL),
'file' => 'includes/delta_blocks.theme.inc',
),
'delta_blocks_tabs' => array(
'variables' => array('primary' => NULL, 'secondary' => NULL),
'file' => 'includes/delta_blocks.theme.inc',
),
);
}
/**
* Implements hook_menu_contextual_links_alter().
*/
function delta_blocks_menu_contextual_links_alter(&$links, $router_item, $root_path) {
$block = array_pop($router_item['map']);
if (in_array($block, array('site-slogan', 'site-name', 'branding'))) {
$links['site-information'] = array(
'title' => t('Site information'),
'href' => 'admin/config/system/site-information',
'localized_options' => array(),
);
}
if (in_array($block, array('logo', 'branding'))) {
$links['logo-settings'] = array(
'title' => t('Logo settings'),
'href' => module_exists('delta_ui') && !empty($GLOBALS['delta']) ? 'admin/appearance/delta/layouts/configure/' . $GLOBALS['delta']->machine_name : 'admin/appearance/settings/' . $GLOBALS['theme_key'],
'localized_options' => array('fragment' => 'edit-logo'),
);
}
}
/**
* Implements hook_preprocess_block().
*/
function delta_blocks_preprocess_block(&$vars) {
if ($vars['block']->delta == 'breadcrumb') {
if(variable_get('delta_blocks_breadcrumb_title_hidden', TRUE)) {
$vars['title_attributes_array']['class'][] = 'element-invisible';
}
}
}
/**
* Provides individual block content.
*/
function delta_blocks_get_content($delta) {
$variables = array();
switch ($delta) {
case 'logo':
$variables['logo'] = delta_blocks_logo();
$variables['logo_linked'] = variable_get('delta_blocks_logo_linked', TRUE);
$variables['site_name'] = filter_xss_admin(variable_get('site_name', 'Drupal'));
return theme('delta_blocks_logo', $variables);
case 'site-name':
$variables['site_name'] = filter_xss_admin(variable_get('site_name'));
$variables['site_name_linked'] = variable_get('delta_blocks_site_name_linked', TRUE);
$variables['site_name_hidden'] = variable_get('delta_blocks_site_name_hidden', FALSE);
return theme('delta_blocks_site_name', $variables);
case 'site-slogan':
$variables['site_slogan'] = filter_xss_admin(variable_get('site_slogan'));
$variables['site_slogan_hidden'] = variable_get('delta_blocks_site_slogan_hidden', FALSE);
return theme('delta_blocks_site_slogan', $variables);
case 'branding':
$variables['site_name'] = filter_xss_admin(variable_get('site_name', 'Drupal'));
$variables['site_name_linked'] = variable_get('delta_blocks_branding_site_name_linked', TRUE);
$variables['site_name_hidden'] = variable_get('delta_blocks_branding_site_name_hidden', FALSE);
$variables['site_slogan'] = filter_xss_admin(variable_get('site_slogan', ''));
$variables['site_slogan_hidden'] = variable_get('delta_blocks_branding_site_slogan_hidden', FALSE);
$variables['logo'] = variable_get('delta_blocks_branding_logo_render', TRUE) ? delta_blocks_logo() : NULL;
$variables['logo_linked'] = variable_get('delta_blocks_branding_logo_linked', TRUE);
return theme('delta_blocks_branding', $variables);
case 'page-title':
$variables['page_title'] = drupal_get_title();
$variables['page_title_hidden'] = variable_get('delta_blocks_page_title_hidden', FALSE);
return theme('delta_blocks_page_title', $variables);
case 'breadcrumb':
$variables['breadcrumb_title_hidden'] = variable_get('delta_blocks_breadcrumb_title_hidden', TRUE);
$variables['breadcrumb_current'] = variable_get('delta_blocks_breadcrumb_current', TRUE);
$variables['breadcrumb'] = drupal_get_breadcrumb();
return theme('delta_blocks_breadcrumb', $variables);
case 'messages':
return theme('status_messages');
case 'tabs':
$variables['primary'] = menu_primary_local_tasks();
$variables['secondary'] = menu_secondary_local_tasks();
return theme('delta_blocks_tabs', $variables);
case 'action-links':
$variables['action_links'] = menu_local_actions();
return theme('delta_blocks_action_links', $variables);
case 'feed-icons':
$variables['feed_icons'] = drupal_get_feeds();
return theme('delta_blocks_feed_icons', $variables);
}
}
/**
* @todo
*/
function delta_blocks_options() {
$output = array();
foreach (_delta_blocks_get_blocks() as $block => $info) {
$output[$block] = $info['title'];
}
return $output;
}
/**
* @todo
*/
function delta_blocks_logo() {
$theme = $GLOBALS['theme_key'];
if (theme_get_setting('default_logo', $theme)) {
$themes = list_themes();
$theme_object = $themes[$theme];
return file_create_url(dirname($theme_object->filename) . '/logo.png');
}
else if ($path = theme_get_setting('logo_path', $theme)) {
return file_create_url($path);
}
}
/**
* Returns a list of delta_blocks blocks.
*/
function _delta_blocks_get_blocks() {
return array(
'logo' => array(
'title' => t('Logo'),
'cache' => DRUPAL_CACHE_GLOBAL,
),
'site-name' => array(
'title' => t('Site name'),
'cache' => DRUPAL_CACHE_GLOBAL,
),
'site-slogan' => array(
'title' => t('Site slogan'),
'cache' => DRUPAL_CACHE_GLOBAL,
),
'branding' => array(
'title' => t('Branding'),
'cache' => DRUPAL_CACHE_GLOBAL,
),
'page-title' => array(
'title' => t('Page title'),
'cache' => DRUPAL_CACHE_PER_PAGE,
),
'breadcrumb' => array(
'title' => t('Breadcrumb'),
'cache' => DRUPAL_CACHE_PER_PAGE,
),
'tabs' => array(
'title' => t('Tabs'),
'cache' => DRUPAL_CACHE_PER_PAGE,
),
'messages' => array(
'title' => t('Messages'),
'cache' => DRUPAL_NO_CACHE,
),
'action-links' => array(
'title' => t('Action links'),
'cache' => DRUPAL_CACHE_GLOBAL,
),
'feed-icons' => array(
'title' => t('Feed icons'),
'cache' => DRUPAL_CACHE_GLOBAL,
),
);
}
/**
* Verify if a given block is enabled in the admin settings.
*/
function _delta_blocks_is_enabled($delta) {
$blocks = variable_get('delta_blocks_toggle', array());
if (!empty($blocks[$delta]) || !isset($blocks[$delta])) {
return TRUE;
}
return FALSE;
}

View File

@@ -0,0 +1,22 @@
<?php
/**
* @file
* Admin functions for the Delta blocks module.
*/
function delta_blocks_admin_settings($form, &$form_state) {
$form['delta_blocks'] = array(
'#type' => 'fieldset',
'#title' => t('Delta blocks configuration'),
);
$form['delta_blocks']['delta_blocks_toggle'] = array(
'#type' => 'checkboxes',
'#title' => t('Toggle Delta blocks'),
'#options' => delta_blocks_options(),
'#default_value' => variable_get('delta_blocks_toggle', array()),
'#description' => t('The selected items will be available as blocks.'),
);
return system_settings_form($form);
}

View File

@@ -0,0 +1,193 @@
<?php
/**
* @file
* Theme functions for the Delta blocks module.
*/
/**
* Returns the rendered branding.
*
* @ingroup themeable
*/
function theme_delta_blocks_branding($variables) {
$logo = theme('delta_blocks_logo', $variables);
$site_name = theme('delta_blocks_site_name', $variables);
$site_slogan = theme('delta_blocks_site_slogan', $variables);
$attributes['class'] = array('site-name-slogan');
if ($variables['site_name_hidden'] && $variables['site_slogan_hidden']) {
$attributes['class'][] = 'element-invisible';
}
return $logo . '<hgroup' . drupal_attributes($attributes) . '>' . $site_name . $site_slogan . '</hgroup>';
}
/**
* Returns the rendered logo.
*
* @ingroup themeable
*/
function theme_delta_blocks_logo($variables) {
if ($variables['logo']) {
$image = array(
'#theme' => 'image',
'#path' => $variables['logo'],
'#alt' => $variables['site_name'],
);
$image = render($image);
if ($variables['logo_linked']) {
$options['html'] = TRUE;
$options['attributes']['id'] = 'logo';
$options['attributes']['title'] = t('Return to the @name home page', array('@name' => $variables['site_name']));
$image = l($image, '<front>', $options);
}
return '<div class="logo-img">' . $image . '</div>';
}
}
/**
* Returns the rendered site name.
*
* @ingroup themeable
*/
function theme_delta_blocks_site_name($variables) {
// If there is no page title set for this page, use a h1 for the site name.
$tag = drupal_get_title() !== '' ? 'h2' : 'h1';
$site_name = $variables['site_name'];
if ($variables['site_name_linked']) {
$options['html'] = TRUE;
$options['attributes']['title'] = t('Return to the @name home page', array('@name' => $variables['site_name']));
$link = array(
'#theme' => 'link',
'#path' => '<front>',
'#text' => '<span>' . $site_name . '</span>',
'#options' => $options,
);
$site_name = render($link);
}
$attributes['class'] = array('site-name');
if ($variables['site_name_hidden']) {
$attributes['class'][] = 'element-invisible';
}
return '<' . $tag . drupal_attributes($attributes) . '>' . $site_name . '</' . $tag . '>';
}
/**
* Returns the rendered site slogan.
*
* @ingroup themeable
*/
function theme_delta_blocks_site_slogan($variables) {
if ($variables['site_slogan'] !== '') {
$attributes['class'] = array('site-slogan');
if ($variables['site_slogan_hidden']) {
$attributes['class'][] = 'element-invisible';
}
return '<h6' . drupal_attributes($attributes) . '>' . $variables['site_slogan'] . '</h6>';
}
}
/**
* Returns the rendered page title.
*
* @ingroup themeable
*/
function theme_delta_blocks_page_title($variables) {
if ($variables['page_title'] !== '') {
$attributes['id'] = 'page-title';
$attributes['class'][] = 'title';
if ($variables['page_title_hidden']) {
$attributes['class'][] = 'element-invisible';
}
return '<h1' . drupal_attributes($attributes) . '>' . $variables['page_title'] . '</h1>';
}
}
/**
* Returns the rendered breadcrumb.
*
* @ingroup themeable
*/
function theme_delta_blocks_breadcrumb($variables) {
$output = '';
if (!empty($variables['breadcrumb'])) {
if ($variables['breadcrumb_current']) {
$variables['breadcrumb'][] = l(drupal_get_title(), current_path(), array('html' => TRUE));
}
$output = '<div id="breadcrumb" class="clearfix"><ul class="breadcrumb">';
$switch = array('odd' => 'even', 'even' => 'odd');
$zebra = 'even';
$last = count($variables['breadcrumb']) - 1;
foreach ($variables['breadcrumb'] as $key => $item) {
$zebra = $switch[$zebra];
$attributes['class'] = array('depth-' . ($key + 1), $zebra);
if ($key == 0) {
$attributes['class'][] = 'first';
}
if ($key == $last) {
$attributes['class'][] = 'last';
}
$output .= '<li' . drupal_attributes($attributes) . '>' . $item . '</li>';
}
$output .= '</ul></div>';
}
return $output;
}
/**
* Returns the rendered action items.
*
* @ingroup themeable
*/
function theme_delta_blocks_action_links($variables) {
$actions = render($variables['action_links']);
if (!empty($actions)) {
return '<div id="action-links" class="clearfix"><ul class="action-links">' . $actions . '</ul></div>';
}
}
/**
* Returns the rendered feed icons.
*
* @ingroup themeable
*/
function theme_delta_blocks_feed_icons($variables) {
return $variables['feed_icons'];
}
/**
* Returns the rendered menu local tasks.
*
* @ingroup themeable
*/
function theme_delta_blocks_tabs($variables) {
$tabs = theme('menu_local_tasks', $variables);
if (!empty($tabs)) {
return '<div id="tabs" class="clearfix">' . $tabs . '</div>';
}
}

View File

@@ -0,0 +1,23 @@
name = Delta Color
description = Makes the color module available for Delta templates.
core = 7.x
version = 7.x-3.x-dev
package = Theme Tools
dependencies[] = delta
dependencies[] = color
; Information added by drupal.org packaging script on 2011-11-12
version = "7.x-3.x-dev"
core = "7.x"
project = "delta"
datestamp = "1321099837"
; Information added by drupal.org packaging script on 2012-07-25
version = "7.x-3.0-beta11+0-dev"
core = "7.x"
project = "delta"
datestamp = "1343175072"

View File

@@ -0,0 +1,17 @@
<?php
/**
* Implements hook_delta_plugins().
*/
function delta_color_delta_plugins() {
return array(
'delta_injection_color' => array(
'handler' => array(
'path' => drupal_get_path('module', 'delta_color') . '/plugins',
'file' => 'delta_injection_color.inc',
'class' => 'delta_injection_color',
'parent' => 'delta_injection',
),
),
);
}

View File

@@ -0,0 +1,59 @@
<?php
class delta_injection_color extends delta_injection {
/**
* @todo
*/
function variables() {
return array(
'color_' . $this->delta->theme . '_files',
'color_' . $this->delta->theme . '_logo',
'color_' . $this->delta->theme . '_palette',
'color_' . $this->delta->theme . '_stylesheets',
'color_' . $this->delta->theme . '_screenshot',
);
}
/**
* @todo
*/
function form_alter(&$form, &$form_state) {
color_form_system_theme_settings_alter($form, $form_state);
}
/**
* @todo
*/
function form_validate($form, &$form_state) {
parent::form_validate($form, $form_state);
$files = $this->backup('color_' . $this->delta->theme . '_files');
if (!empty($files) && $directory = dirname(reset($files))) {
@rename($directory, $directory . '-delta');
}
}
/**
* @todo
*/
function form_submit($form, &$form_state) {
// Delete old files.
if (!empty($this->delta->settings['color_' . $this->delta->theme . '_files'])) {
foreach ($this->delta->settings['color_' . $this->delta->theme . '_files'] as $file) {
@drupal_unlink($file);
}
if (isset($file) && $file = dirname($file)) {
@drupal_rmdir($file);
}
}
parent::form_submit($form, $form_state);
$files = $this->backup('color_' . $this->delta->theme . '_files');
if (!empty($files) && $directory = dirname(reset($files))) {
@rename($directory . '-delta', $directory);
}
}
}

View File

@@ -0,0 +1,64 @@
<?php
/**
* @file
* Delta UI functionality
*/
/**
* @todo
*/
function delta_ui_layout_configure($form, &$form_state, $delta) {
module_load_include('inc', 'system', 'system.admin');
$backup = delta_inject($delta->machine_name);
$form_state['delta'] = $delta->machine_name;
$form_state['build_info']['args'][0] = $delta->theme;
$form = system_theme_settings($form, $form_state, $delta->theme);
foreach (delta_get_plugins($delta->machine_name) as $plugin) {
$plugin->form_alter($form, $form_state);
}
$form['delta'] = array(
'#type' => 'markup',
'#markup' => '<div class="messages warning">' . t('You are currently editing the Delta template %name. This template operates in %mode mode.', array('%name' => $delta->name, '%mode' => ($delta->mode == DELTA_PRESERVE ? t('Preserve') : t('Override')))) . '</div>',
'#weight' => -999,
);
$form['#validate'][] = 'delta_ui_layout_configure_validate';
$form['#submit'][] = 'delta_ui_layout_configure_submit';
$form['#attributes']['id'] = 'system-theme-settings';
delta_reset($delta->theme);
delta_inject($backup);
return $form;
}
/**
* @todo
*/
function delta_ui_layout_configure_validate($form, &$form_state) {
foreach (delta_get_plugins($form_state['delta']) as $plugin) {
$plugin->form_validate($form, $form_state);
}
}
/**
* @todo
*/
function delta_ui_layout_configure_submit($form, &$form_state) {
foreach (delta_get_plugins($form_state['delta']) as $plugin) {
$plugin->form_submit($form, $form_state);
}
foreach (delta_get_plugins($form_state['delta']) as $plugin) {
$plugin->presave($form, $form_state);
}
$delta = delta_load($form_state['delta']);
ctools_export_crud_save('delta', $delta);
}

View File

@@ -0,0 +1,21 @@
name = Delta UI
description = The Delta UI provides a user interface to build and edit the contextual theme settings provided by the Delta module.
package = Theme Tools
core = 7.x
version = 7.x-3.x-dev
dependencies[] = delta
; Information added by drupal.org packaging script on 2011-11-12
version = "7.x-3.x-dev"
core = "7.x"
project = "delta"
datestamp = "1321099837"
; Information added by drupal.org packaging script on 2012-07-25
version = "7.x-3.0-beta11+0-dev"
core = "7.x"
project = "delta"
datestamp = "1343175072"

View File

@@ -0,0 +1,46 @@
<?php
/**
* Implements hook_permission().
*/
function delta_ui_permission() {
return array(
'administer delta' => array(
'title' => t('Administer Delta'),
'description' => t('Administer settings for the Delta module.'),
),
);
}
/**
* Implements of hook_menu().
*/
function delta_ui_menu() {
$items['admin/appearance/delta/list/%delta/configure'] = array(
'title' => 'Settings',
'description' => 'Override settings for a layout.',
'page callback' => 'drupal_get_form',
'page arguments' => array('delta_ui_layout_configure', 4),
'access arguments' => array('administer delta'),
'file' => 'delta_ui.admin.inc',
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
/**
* Implements of hook_menu_alter().
*/
function delta_ui_menu_alter(&$items) {
$items['admin/appearance/delta']['type'] = MENU_LOCAL_TASK;
}
/**
* Implements hook_ctools_plugin_directory().
*/
function delta_ui_ctools_plugin_directory($module, $plugin) {
if ($module == 'ctools' && $plugin == 'export_ui') {
return 'export_ui';
}
}

View File

@@ -0,0 +1,40 @@
<?php
/**
* @file
* Plugin definition for CTools Export UI integration.
*/
$plugin = array(
'schema' => 'delta',
'access' => 'administer delta',
'menu' => array(
'menu prefix' => 'admin/appearance',
'menu item' => 'delta',
'menu title' => 'Delta',
'menu description' => 'Create additional instances of your theme settings.',
),
'title singular' => t('template'),
'title singular proper' => t('Template'),
'title plural' => t('templates'),
'title plural proper' => t('Templates'),
'handler' => array(
'class' => 'delta_export_ui',
'parent' => 'ctools_export_ui',
),
'form' => array(
'settings' => 'delta_ui_form',
),
'strings' => array(
'confirmation' => array(
'revert' => array(
'information' => t('This action will permanently remove any customizations made to this templates.'),
'success' => t('The template has been reverted.'),
),
'delete' => array(
'information' => t('This action will permanently remove the template from your database.'),
'success' => t('The template has been deleted.'),
),
),
),
);

View File

@@ -0,0 +1,330 @@
<?php
/**
* @todo
*/
class delta_export_ui extends ctools_export_ui {
/**
* @todo
*/
function list_form(&$form, &$form_state) {
parent::list_form($form, $form_state);
$form['top row']['theme'] = array(
'#type' => 'select',
'#title' => t('Theme'),
'#options' => array('all' => t('- All -')) + _delta_ui_options_themes(),
'#default_value' => 'all',
'#weight' => -10,
);
$form['top row']['submit'] = $form['bottom row']['submit'];
$form['top row']['reset'] = $form['bottom row']['reset'];
$form['bottom row']['#access'] = FALSE;
}
/**
* @todo
*/
function list_filter($form_state, $item) {
if (parent::list_filter($form_state, $item)) {
return TRUE;
}
if ($form_state['values']['theme'] != 'all' && $form_state['values']['theme'] != $item->theme) {
return TRUE;
}
}
/**
* @todo
*/
function set_item_state($state, $js, $input, $item) {
ctools_export_set_object_status($item, $state);
if (!$js) {
drupal_goto(ctools_export_ui_plugin_base_path($this->plugin));
}
else {
return $this->list_page($js, $input);
}
}
/**
* @todo
*/
function edit_form_validate(&$form, &$form_state) {
parent::edit_form_validate($form, $form_state);
$values = $form_state['values'];
if ($values['parent'] == '_none') {
form_set_value(array('#parents' => array('parent')), '', $form_state);
}
else {
form_set_value(array('#parents' => array('mode')), DELTA_PRESERVE, $form_state);
}
}
/**
* @todo
*
* This function can be removed once the core CTools one
* works properly and uses the right field for the machine
* name validation error.
*/
function edit_finish_validate(&$form, &$form_state) {
if ($form_state['op'] != 'edit') {
$element = array(
'#value' => $form_state['item']->{$this->plugin['export']['key']},
'#parents' => array($this->plugin['export']['key']),
);
$form_state['plugin'] = $this->plugin;
ctools_export_ui_edit_name_validate($element, $form_state);
}
}
/**
* @todo
*/
function list_table_header() {
$header = array();
$header[] = array('data' => t('Name'), 'class' => array('ctools-export-ui-name'));
$header[] = array('data' => t('Theme'), 'class' => array('ctools-export-ui-theme'));
$header[] = array('data' => t('Ancestors'), 'class' => array('ctools-export-ui-ancestors'));
$header[] = array('data' => t('Mode'), 'class' => array('ctools-export-ui-Mode'));
$header[] = array('data' => t('Storage'), 'class' => array('ctools-export-ui-storage'));
$header[] = array('data' => t('Operations'), 'class' => array('ctools-export-ui-operations'));
return $header;
}
/**
* @todo
*/
function list_build_row($item, &$form_state, $operations) {
$name = $item->machine_name;
$theme = _delta_ui_theme_name($item->theme);
$modes = array(DELTA_PRESERVE => t('Preserve'), DELTA_OVERRIDE => t('Override'));
$ancestors = _delta_ui_ancestors_names($name);
array_shift($ancestors);
$operations = array(
'configure' => array(
'title' => t('Configure'),
'href' => 'admin/appearance/delta/list/' . $name . '/configure',
)) + $operations;
$this->rows[$name]['data'] = array();
$this->rows[$name]['class'] = !empty($item->disabled) ? array('ctools-export-ui-disabled') : array('ctools-export-ui-enabled');
$this->rows[$name]['data'][] = array(
'data' => check_plain($item->name) . '<div class="description">' . check_plain($item->description) . "</div>",
'class' => array('ctools-export-ui-name')
);
$this->rows[$name]['data'][] = array(
'data' => $theme,
'class' => array('ctools-export-ui-theme')
);
$this->rows[$name]['data'][] = array(
'data' => implode(', ', $ancestors),
'class' => array('ctools-export-ui-ancestors')
);
$this->rows[$name]['data'][] = array(
'data' => $modes[$item->mode],
'class' => array('ctools-export-ui-mode')
);
$this->rows[$name]['data'][] = array(
'data' => check_plain($item->type),
'class' => array('ctools-export-ui-storage')
);
$this->rows[$name]['data'][] = array(
'data' => theme('links', array(
'links' => $operations,
'attributes' => array('class' => array('links inline'))
)),
'class' => array('ctools-export-ui-operations'),
);
$this->sorts[$name] = $name;
}
function hook_menu(&$items) {
if (empty($this->plugin['schema'])) {
return;
}
parent::hook_menu($items);
$prefix = ctools_export_ui_plugin_base_path($this->plugin);
}
}
/**
* @todo
*/
function delta_ui_form(&$form, &$form_state) {
$delta = $form_state['item'];
$themes = _delta_ui_options_themes();
if (isset($form_state['input']['theme'])) {
$theme = $form_state['input']['theme'];
}
else if (isset($delta->theme)) {
$theme = $delta->theme;
}
else {
$theme = key($themes);
}
$parents = _delta_ui_options_parents($theme, $delta->machine_name);
$form['info']['#type'] = 'fieldset';
$form['info']['#title'] = delta_load($delta->machine_name) ? t('Edit an existing Delta template') : t('Add a new Delta template');
$form['info']['#tree'] = FALSE;
$form['info']['name'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#description' => t('The human readable name for this template.'),
'#default_value' => isset($delta->name) ? $delta->name : '',
'#id' => 'edit-delta-name',
'#required' => TRUE,
);
$form['info']['machine_name'] = array(
'#type' => 'machine_name',
'#title' => t('Machine name'),
'#description' => t('A unique machine-readable name for this theme settings template. It must only contain lowercase letters, numbers, and underscores.'),
'#default_value' => isset($delta->machine_name) ? $delta->machine_name : '',
'#required' => TRUE,
'#maxlength' => 32,
'#access' => !delta_load($delta->machine_name),
'#machine_name' => array(
'source' => array('info', 'name'),
'exists' => 'delta_load',
),
);
$form['info']['description'] = array(
'#type' => 'textfield',
'#title' => t('Description'),
'#description' => t('A brief description of this theme settings template.'),
'#default_value' => isset($delta->description) ? $delta->description : '',
);
$form['info']['theme'] = array(
'#type' => 'select',
'#title' => t('Theme'),
'#required' => TRUE,
'#description' => t('The theme that you want to create this template for.'),
'#default_value' => $theme,
'#options' => $themes,
'#access' => !isset($delta->machine_name),
'#ajax' => array(
'callback' => '_delta_ui_parent_options_callback',
'wrapper' => 'parent-options-wrapper',
'method' => 'replace',
'effect' => 'fade',
),
);
$form['info']['parent'] = array(
'#type' => 'select',
'#title' => t('Parent template'),
'#description' => t('This option allows you to build hierarchical theme settings. Delta templates that have a parent will always operate in preserve ("Only override different values") mode.'),
'#default_value' => isset($delta->parent) ? $delta->parent : array(),
'#options' => array('_none' => t('- None -')) + $parents,
'#prefix' => '<div id="parent-options-wrapper">',
'#suffix' => '</div>',
);
$form['info']['mode'] = array(
'#type' => 'radios',
'#title' => t('Operation mode'),
'#description' => t('This setting controls the way that settings are being stored and overriden.'),
'#default_value' => isset($delta->mode) ? $delta->mode : DELTA_PRESERVE,
'#options' => array(
DELTA_PRESERVE => t('Only override different values'),
DELTA_OVERRIDE => t('Override all values'),
),
'#states' => array(
'visible' => array(
':input[name="parent"]' => array('value' => '_none'),
),
),
);
$form['info']['settings'] = array(
'#type' => 'value',
'#value' => isset($delta->settings) ? $delta->settings : array(),
);
}
/**
* @todo
*/
function _delta_ui_parent_options_callback($form, $form_state) {
return $form['info']['parent'];
}
/**
* @todo
*/
function _delta_ui_ancestors_names($delta) {
$output = array();
foreach (delta_ancestors($delta) as $ancestor) {
$output[$ancestor->machine_name] = $ancestor->name;
}
return $output;
}
/**
* @todo
*/
function _delta_ui_theme_name($theme) {
$themes = list_themes();
return isset($themes[$theme]) ? $themes[$theme]->info['name'] : t('<span class="marker">Theme not found</span>');
}
/**
* @todo
*/
function _delta_ui_options_themes() {
$themes = list_themes();
$options = array();
foreach ($themes as $theme => $info) {
if ($info->status) {
$options[$theme] = $info->info['name'];
}
}
return $options;
}
/**
* @todo
*/
function _delta_ui_options_parents($key, $delta) {
$options = array();
foreach (delta_load_all() as $item) {
if ($item->theme == $key && (!isset($delta) || ($item->machine_name != $delta && !in_array($delta, array_keys(delta_ancestors($item->parent)))))) {
$options[$item->machine_name] = $item->name;
}
}
return $options;
}

View File

@@ -0,0 +1,58 @@
<?php
/**
* Expose themes as context reactions.
*/
class context_reaction_delta extends context_reaction {
/**
* @todo
*/
function options_form($context) {
$values = $this->fetch_from_context($context);
$options = _delta_options();
$form = array(
'#tree' => TRUE,
'#title' => t('Delta Override Template'),
);
$form['delta_template'] = array(
'#type' => count($options) > 10 ? 'select' : 'radios',
'#title' => t('Select Custom theme settings template.'),
'#description' => empty($options) ? t('There are no valid (enabled) Delta templates available.') : t('The theme settings of the selected Delta template will override the default theme settings for all pages that match this context.'),
'#default_value' => isset($values['delta_template']) ? $values['delta_template'] : NULL,
'#options' => $options,
);
return $form;
}
/**
* @todo
*/
function execute() {
foreach (context_active_contexts() as $context) {
if (!empty($context->reactions['delta']['delta_template'])) {
$template = $context->reactions['delta']['delta_template'];
if (delta_enabled($template)) {
delta_inject($template);
}
}
}
}
}
/**
* @todo
*/
function _delta_options() {
$options = array();
foreach (delta_load_all() as $item) {
if (delta_enabled($item->machine_name)) {
$options[$item->machine_name] = $item->name;
}
}
return $options;
}

View File

@@ -0,0 +1,134 @@
<?php
class delta_injection {
var $plugin;
var $delta;
var $original;
var $settings;
/**
* Constructor. Do not override.
*/
function __construct($plugin, $delta) {
$this->plugin = $plugin;
$this->delta = delta_load($delta);
}
/**
* @todo
*/
function variables() {
return array();
}
/**
* @todo
*/
function config($name) {
if (isset($this->settings[$name])) {
return $this->settings[$name];
}
if (!empty($this->delta->parent)) {
if ($plugin = delta_get_plugin($this->delta->parent, $this->plugin['name'])) {
$this->settings[$name] = isset($this->delta->settings[$name]) ? delta_merge($plugin->config($name), $this->delta->settings[$name]) : $plugin->config($name);
}
}
if (!isset($this->settings[$name])) {
$this->settings[$name] = isset($this->delta->settings[$name]) ? delta_merge(variable_get($name), $this->delta->settings[$name]) : variable_get($name);
}
return $this->settings[$name];
}
/**
* @todo
*/
function inject() {
foreach ($this->variables() as $name) {
$settings = $this->config($name);
if (isset($settings)) {
$this->backup($name, delta_variable_set($name, $settings));
}
}
}
/**
* @todo
*/
function revoke() {
foreach ($this->variables() as $name) {
delta_variable_set($name, $this->backup($name));
}
}
/**
* @todo
*/
function backup($name, $value = NULL) {
if (isset($value) && !isset($this->original[$name])) {
$this->original[$name] = $value;
}
if (isset($this->original[$name])) {
return $this->original[$name];
}
}
/**
* @todo
*/
function presave($form, &$form_state) {
if ($this->delta->mode == DELTA_PRESERVE) {
$base = array();
if (!empty($this->delta->parent)) {
if ($plugin = delta_get_plugin($this->delta->parent, $this->plugin['name'])) {
foreach ($this->variables() as $variable) {
$base[$variable] = $plugin->config($variable);
}
}
}
foreach ($this->variables() as $variable) {
if (isset($base[$variable])) {
$this->delta->settings[$variable] = delta_reduce($this->delta->settings[$variable], $base[$variable]);
}
else {
$this->delta->settings[$variable] = delta_reduce(
is_array($this->delta->settings[$variable]) ? $this->delta->settings[$variable] : array(),
is_array(variable_get($variable)) ? variable_get($variable) : array());
}
}
}
}
/**
* @todo
*/
function form_alter(&$form, &$form_state) {
// Nothing to do here.
}
/**
* @todo
*/
function form_validate($form, &$form_state) {
foreach ($this->variables() as $name) {
$this->backup($name, variable_get($name));
}
}
/**
* @todo
*/
function form_submit($form, &$form_state) {
foreach ($this->variables() as $name) {
$this->delta->settings[$name] = variable_get($name);
variable_set($name, $this->backup($name));
}
}
}

View File

@@ -0,0 +1,30 @@
<?php
class delta_injection_theme_settings extends delta_injection {
/**
* @todo
*/
function variables() {
return array('theme_' . $this->delta->theme . '_settings');
}
/**
* @todo
*/
function inject() {
$cache = &drupal_static('theme_get_setting');
$cache[$this->delta->theme] = NULL;
parent::inject();
}
/**
* @todo
*/
function revoke() {
$cache = &drupal_static('theme_get_setting');
$cache[$this->delta->theme] = NULL;
parent::revoke();
}
}