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,4 @@
This directory should be used to place downloaded and custom modules
which are common to all sites. This will allow you to more easily
update Drupal core files.

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,20 @@
// $Id;
CONTENTS
---------
* Introduction
* Installation
* Custom themes
Introduction
------------
This module will display blocks in a accordion widget.
It will apply accordion widget for sidebar_first(left), sidebar_right(right) regions
Installation
------------
The drupal7 is having jquery 1.3.2 version and jquery UI is also available with the drupal core.
Install accordion_blocks module and enable.
Clear your cache, then block on left side and right side(if you have blocks both sides) will appear in accordion widget.

View File

@@ -0,0 +1,22 @@
<?php
/**
* @file
* Main accordion block template
*
* Variables available:
* - $content: An array of block content with block content and block title
*/
?>
<div class="accordion_blocks_container">
<?php foreach ($content as $block_key => $block) : ?>
<h2><a href="#">
<?php if($block->title) : ?>
<?php print check_plain($block->title); ?>
<?php endif; ?>
</a></h2>
<div>
<?php print render($block->content);?>
</div>
<?php endforeach; ?>
</div>

View File

@@ -0,0 +1,75 @@
<?php
/**
* @file
* Add, Update and Delete block functions for the accordion blocks module.
*/
/**
* Menu callback for displaying the list of
* accordion blocks created.
*/
function accordion_block_list() {
$result = db_select('accordion_blocks', 'sd')
->fields('sd', array('title', 'id'))
->orderBy('title', 'ASC')
->execute();
$header = array(
array('data' => t('Accordion Blocks')),
array('data' => t('Operations'), 'colspan' => 3),
);
$rows = array();
foreach ($result as $row) {
$tablerow = array(
array('data' => $row->title),
array('data' => l(t('Edit'), 'admin/structure/accordion_block/manage/' . $row->id . '/edit')),
array('data' => l(t('Delete'), 'admin/structure/accordion_block/manage/' . $row->id . '/delete')),
);
$rows[] = $tablerow;
}
if (!$rows) {
$rows[] = array(array('data' => t('No Accordion blocks available.'), 'colspan' => 4));
}
$build = array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
'#attributes' => array('id' => 'accordion_blocks'),
);
return $build;
}
/**
* Deletion of accordion block.
*/
function accordion_block_delete($form, $form_state, $accordion_block) {
$form['id'] = array('#type' => 'hidden', '#value' => $accordion_block['id']);
$form['sd_name'] = array('#type' => 'hidden', '#value' => $accordion_block['title']);
return confirm_form($form, t('Are you sure you want to delete the accordion block %name?', array('%name' => $accordion_block['title'])), 'admin/structure/accordion_block', '', t('Delete'), t('Cancel'));
}
/**
* Submit handler for accordion block deletion.
*/
function accordion_block_delete_submit($form, &$form_state) {
$delta = $form_state['values']['sd_name'] . "_" . $form_state['values']['id'];
db_delete('accordion_blocks')
->condition('id', $form_state['values']['id'])
->execute();
db_delete('block')
->condition('module', 'accordion_blocks')
->condition('delta', $delta)
->execute();
drupal_set_message(t('The accordion block %name has been removed.', array('%name' => $form_state['values']['sd_name'])));
cache_clear_all();
$form_state['redirect'] = 'admin/structure/accordion_block';
}

View File

@@ -0,0 +1,11 @@
name = Blocks in accordion
description = Displays blocks in jquery accordion widget
core = 7.x
configure = admin/config/user-interface/accordion-blocks
; Information added by drupal.org packaging script on 2012-04-11
version = "7.x-3.1"
core = "7.x"
project = "accordion_blocks"
datestamp = "1334126142"

View File

@@ -0,0 +1,47 @@
<?php
/**
* @file
* Install and uninstall functions for the accordion blocks module.
*/
/**
* Implements hook_install().
*/
function accordion_blocks_install() {
$t = get_t();
drupal_set_message($t('Accordion Blocks module is successfully installed. Create accordion widgets through <a href="@url">Structure > Accordion Blocks</a> .', array('@url' => url('admin/structure/accordion_blocks'))));
}
/**
* Implements hook_schema().
*/
function accordion_blocks_schema() {
$schema['accordion_blocks'] = array(
'fields' => array(
'id' => array(
'description' => 'id of the accordion widget',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'title' => array(
'description' => 'Title of the accordion widget',
'type' => 'varchar',
'length' => 150,
'not null' => TRUE,
'default' => '',
),
'content' => array(
'description' => 'serailized content used in the accordion widget',
'type' => 'text',
'size' => 'big',
'not null' => FALSE,
'serialize' => TRUE,
),
),
'primary key' => array('id'),
);
return $schema;
}

View File

@@ -0,0 +1,396 @@
<?php
/*
*@file
* This module privide the accordion widget for the blocks on left and right side
*/
/**
* Implements hook_permission().
*/
function accordion_blocks_permission() {
return array(
'administer accordion blocks configuration' => array(
'title' => t('Administer accordion blocks'),
'description' => t('Administer accordion blocks configurations.'),
),
);
}
/*
* Implements hook_init()
*/
function accordion_blocks_init() {
// including accordion related javascript and css files
drupal_add_library('system', 'ui.accordion');
drupal_add_js(drupal_get_path('module', 'accordion_blocks') .'/accordion_init.js');
drupal_add_css(drupal_get_path('module', 'accordion_blocks') .'/accordion_init.css');
}
/**
* Implements hook_menu()
*/
function accordion_blocks_menu() {
//settings page
$items['admin/structure/accordion_block'] = array(
'title' => 'Accordion Blocks',
'description' => 'Create blocks of accordion content.',
'page callback' => 'accordion_block_list',
'access arguments' => array('administer accordion blocks configuration'),
'type' => MENU_NORMAL_ITEM,
'file' => 'accordion_blocks.admin.inc',
'weight' => -10,
);
$items['admin/structure/accordion_block/list'] = array(
'title' => 'List Accordion Blocks',
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['admin/structure/accordion_block/add'] = array(
'title' => 'Add Accordion Block',
'description' => 'Configuring the Accordion Block Settings.',
'page callback' => 'drupal_get_form',
'page arguments' => array('accordion_block_config_settings', 'add'),
'access arguments' => array('administer accordion block configuration'),
'type' => MENU_LOCAL_ACTION,
'weight' => 1,
);
$items['admin/structure/accordion_block/manage/%accordion_block'] = array(
'title' => 'Edit Accordion Block',
'page callback' => 'drupal_get_form',
'page arguments' => array('accordion_block_config_settings', 'edit', 4),
'access arguments' => array('administer accordion block configuration'),
);
$items['admin/structure/accordion_block/manage/%accordion_block/edit'] = array(
'title' => 'Edit Accordion Block',
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['admin/structure/accordion_block/manage/%accordion_block/delete'] = array(
'title' => 'Delete accordion block',
'page callback' => 'drupal_get_form',
'page arguments' => array('accordion_block_delete', 4),
'access arguments' => array('administer accordion block configuration'),
'type' => MENU_LOCAL_TASK,
'file' => 'accordion_blocks.admin.inc',
);
return $items;
}
/**
* Load the accordion block data.
*
* @param integer $id
* Integer id of the accordion block.
*
* @returns
* array of the block content,
* skin and title of the accordion block.
*/
function accordion_block_load($id) {
$content = array();
$query = db_select('accordion_blocks', 'sd')
->fields('sd', array('title', 'content'))
->condition('sd.id', $id, '=');
$accordion_block = $query->execute()->fetchAssoc();
if (!$accordion_block) {
return FALSE;
}
$accordion_block['id'] = $id;
return $accordion_block;
}
/**
* Implements hook_block_info().
*/
function accordion_blocks_block_info() {
$blocks = array();
$query = db_select("accordion_blocks", 'sd')
->fields('sd', array('id', 'title'))
->execute();
foreach ($query as $accordion_block) {
$blocks[$accordion_block->title . "_" . $accordion_block->id] = array('info' => t($accordion_block->title));
}
return $blocks;
}
/**
* Implements hook_block_view().
*/
function accordion_blocks_block_view($delta = '') {
$block = array();
$block_title_info = explode('_', $delta);
$id = array_pop($block_title_info);
$title = implode("_", $block_title_info);
$scripts = array();
$style = array();
$accordion_block_data = accordion_block_load($id);
// Building the content for the accordion block.
$content = accordion_block_content($delta, $id);
$block['subject'] = t($title);
$block['content']['#markup'] = theme("accordion_block", $content);
return $block;
}
/**
* accordion block data
*
* @returns
* the block content for the accordion block.
*/
function accordion_block_content($delta, $id) {
$accordion_data = accordion_block_load($id);
if ($delta == $accordion_data['title'] . "_" . $accordion_data['id']) {
$data = unserialize($accordion_data['content']);
$blocks_content = array();
if (isset($data)) {
foreach ($data as $key => $block) {
if (!empty($block)) {
$blocks_info = explode('_delta_', $block);
$block_data = block_load($blocks_info[0], $blocks_info[1]);
$blocks_content[$key] = new stdClass();
$blocks_content[$key]->title = $block_data->title;
$block_content = module_invoke($blocks_info[0], "block_view", $blocks_info[1]);
$blocks_content[$key]->content = $block_content['content'];
}
}
}
$accordion_block_content = array('content' => $blocks_content);
return $accordion_block_content;
}
}
/**
* Implements hook_theme().
*/
function accordion_blocks_theme() {
return array(
'accordion_block' => array(
'variables' => array('content' => NULL,),
'template' => 'accordion_block',
),
);
}
/**
* Implements menu callback for the
* admin settings form for accordion_block
*/
function accordion_block_config_settings($form, &$form_state, $formtype, $accordion_block = NULL) {
$default_values = $accordion_block;
$form = array();
if ($formtype == 'edit') {
$form['id'] = array(
'#type' => 'value',
'#value' => isset($accordion_block['id']) ? $accordion_block['id'] : 0,
);
}
$form['accordion_block_title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#default_value' => $default_values['title'],
'#description' => t('Title of the accordion block.'),
'#required' => TRUE,
);
$data = unserialize($default_values['content']);
$form['accordion_block_content'] = array(
'#type' => 'fieldset',
'#title' => t('Accordion Block Content'),
'#prefix' => '<div id="accordion_block_wrapper">',
'#suffix' => '</div>',
);
$blocks = accordion_block_get_all_blocks();
if (empty($form_state['accordion_blocks'])) {
$form_state['accordion_blocks'] = count($data);
}
for ($block_count = 0; $block_count < $form_state['accordion_blocks']; $block_count++) {
$form['accordion_block_content']['type']["block_" . $block_count] = array(
'#type' => 'select',
'#title' => t('Block content'),
'#default_value' => $data["block_" . $block_count],
'#description' => t('Add type of accordion block content.'),
'#options' => $blocks,
);
}
$form['accordion_block_content']['add_name'] = array(
'#type' => 'submit',
'#value' => t('Add one more'),
'#submit' => array('accordion_block_add_more_blocks'),
'#ajax' => array(
'callback' => 'accordion_block_add_more_blocks_callback',
'wrapper' => 'accordion_block_wrapper',
),
);
if ($form_state['accordion_blocks'] > 1) {
$form['accordion_block_content']['remove_name'] = array(
'#type' => 'submit',
'#value' => t('Remove one'),
'#submit' => array('accordion_block_add_more_remove_one'),
'#ajax' => array(
'callback' => 'accordion_block_add_more_blocks_callback',
'wrapper' => 'accordion_block_wrapper',
),
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Accordion Block Submit'),
);
$form['#validate'][] = 'accordion_block_validate';
return $form;
}
/**
* Form validate handler for the accordion_block_config_settings().
*
* @params $form
* form varibale of drupal.
* @params $form_state
* form state values.
*/
function accordion_block_validate(&$form, &$form_state) {
$pattern = '/^[a-zA-Z0-9_ ]+$/';
if (!preg_match($pattern, $form['accordion_block_title']['#value'])) {
form_set_error('accordion_block_title', 'Title Should contain only letters,numbers and underscores');
}
}
/**
* From submit handler for accordion_block_config_settings().
*/
function accordion_block_config_settings_submit($form, $form_state) {
$values = $form_state['values'];
$block_values = array();
$count = 0;
foreach ($values as $key => $form_value) {
if ($key == 'block_' . $count) {
$block_values['block_' . $count] = $form_value;
$count++;
}
}
$content = serialize($block_values);
$title = $values['accordion_block_title'];
$id = '';
if (array_key_exists('id', $values)) {
$id = $values['id'];
}
if (!$id) {
$insert = db_insert('accordion_blocks')
->fields(array('title', 'content'))
->values(array(
'title' => $title,
'content' => $content,
))
->execute();
if ($insert) {
drupal_set_message(t("Added accordion block sucessfully"));
drupal_goto('admin/structure/accordion_block');
}
}
else {
$update = db_update('accordion_blocks')
->fields(array(
'title' => $title,
'content' => $content,
))
->condition('id', $id, '=')
->execute();
if ($update) {
drupal_set_message(t("Updated accordion block sucessfully"));
drupal_goto('admin/structure/accordion_block');
}
}
}
/**
* Ajax callback for adding more blocks to the accordion block content.
*/
function accordion_block_add_more_blocks_callback($form, &$form_state) {
return $form['accordion_block_content'];
}
/**
* Submit handler for the "Add One More" button of a field form.
*
* This handler makes changes to the form state.
* If the button was clicked with JS disabled, then
* the page is reloaded with the complete rebuilt form. If the button was
* clicked with JS enabled, then ajax_form_callback(),
* accordion_block_add_more_blocks_callback()
* to return just the changed part of the form.
*/
function accordion_block_add_more_blocks($form, &$form_state) {
$form_state['accordion_blocks']++;
$form_state['rebuild'] = TRUE;
}
/**
* Submit handler for the "Remove One" button of a accordion block settings form.
* This handler removes the last block added to the settings form.
*/
function accordion_block_add_more_remove_one($form, &$form_state) {
if ($form_state['accordion_blocks'] > 1) {
$form_state['accordion_blocks']--;
}
$form_state['rebuild'] = TRUE;
}
/**
* Retriving all system blocks
*
* @returns
* array of all blocks created data.
*/
function accordion_block_get_all_blocks() {
module_load_include('inc', 'block', 'block.admin');
static $blocksarray;
static $theme;
if (empty($blocksarray)) {
global $theme_key;
drupal_theme_initialize();
if (!isset($theme)) {
// If theme is not specifically set, rehash for the current theme.
$theme = $theme_key;
}
// Fetch and sort blocks.
$blocks = _block_rehash($theme);
$compare_theme = &drupal_static('_block_compare:theme');
$compare_theme = $theme;
usort($blocks, '_block_compare');
$blocksarray = array();
foreach ($blocks as $id => $block) {
if ($block['module'] != 'accordion_blocks') {
$key = $block['module'] . '_delta_' . $block['delta'];
$blocksarray[$key] = $block['info'];
}
}
}
return $blocksarray;
}

View File

@@ -0,0 +1,28 @@
.ui-accordion li {
display:list-item;
}
.accordion_blocks_container .block-title {
font-size: 1em;
padding: 10px 0 4px 30px;
}
.accordion_blocks_container .block {
margin-bottom: 0px;
}
.ui-accordion .ui-accordion-content {
padding: 0.5em 0.2em 0.5em 0;
}
.ui-widget {
font-size: inherit;
font-family: inherit;
color: inherit;
}
.ui-widget-content {
color: inherit;
}
.ui-widget-content a {
color: inherit;
}
.ui-accordion-header {
margin-bottom: 0px;
}

View File

@@ -0,0 +1,9 @@
(function($) {
Drupal.behaviors.accordion_blocks = {
attach: function() {
$('.accordion_blocks_container').accordion({header: "h2", autoHeight: false});
}
};
})(jQuery);

View File

@@ -0,0 +1,7 @@
<div id="block-<?php print $block->module . '-' . $block->delta; ?>" <?php print $attributes; ?>>
<?php if (!empty($block->subject)): ?>
<h2 <?php print $title_attributes; ?>><a href="#"><?php print $block->subject ?></a></h2>
<?php endif;?>
<div <?php print $content_attributes; ?>><?php print $content ?></div>
</div>

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,53 @@
Adaptive Image
http://drupal.org/project/adaptive_image
====================================
DESCRIPTION
-----------
The Adaptive image module provides device-appropriate versions of images from your fields.
You can activate adaptive images by adding an adaptive effect to any of your image styles.
The used technique is derived from http://adaptive-images.com/ by Matt Wilcox.
The hard work is done by Drupal core no need for any additional rewrites.
If image styles work on your website, this module will too.
REQUIREMENTS
------------
Drupal 7.x
CLIENTSIDE REQUIREMENTS
------------------------
JavaScript enabled
INSTALLING
----------
1. To install the module copy the 'adaptive_image' folder to your sites/all/modules directory.
2. Read more about installing modules at http://drupal.org/node/70151
CONFIGURING AND USING
---------------------
1. Go to admin/config/media/image-styles
Edit an existing or add a new style. Add the Adaptive image effect.
Click on 'Update style' button.
2. Go to admin/structure/types
Click on "manage display".
Choose a "image" field and click on the edit button.
Choose the previously updated style as image style.
Click on "Update".
REPORTING ISSUE. REQUESTING SUPPORT. REQUESTING NEW FEATURE
-----------------------------------------------------------
1. Go to the module issue queue at http://drupal.org/project/issues/adaptive_image?status=All&categories=All
2. Click on CREATE A NEW ISSUE link.
3. Fill the form.
4. To get a status report on your request go to http://drupal.org/project/issues/user
UPGRADING
---------
Read more at http://drupal.org/node/250790

View File

@@ -0,0 +1,127 @@
<?php
/**
* @file
* Adaptive Image - Adaptive images for Drupal
* @see http://adaptive-images.com/
*
* @author
* Stefan Auditor <stefan.auditor@erdfisch.de>
*/
/**
* Copy of image_style_deliver() for use with adaptive images.
*/
function adaptive_image_style_deliver($style, $scheme) {
$settings = $resolutions = array();
$settings = adaptive_image_effect_settings($style);
$mobile_first = (boolean) $settings['mobile_first'];
$resolutions = explode(',', $settings['resolutions']);
/* Do we need to switch mobile first off? */
if (adaptive_image_browser_detect()) {
$mobile_first = FALSE;
}
$resolution = adaptive_image_resolution($resolutions);
/* No resolution was found (no cookie or invalid cookie) */
if (!$resolution && count($resolutions)) {
// We send the lowest resolution for mobile-first approach, and highest otherwise
$resolution = $mobile_first ? min($resolutions) : max($resolutions);
}
// Check that the style is defined and the scheme is valid.
if (!$style || !file_stream_wrapper_valid_scheme($scheme)) {
drupal_exit();
}
foreach ($style['effects'] as $id => $effect) {
if ($effect['name'] == 'adaptive_image') {
$style['effects'][$id]['data']['width'] = $resolution;
$style['effects'][$id]['data']['height'] = NULL;
break;
}
}
$args = func_get_args();
array_shift($args);
array_shift($args);
$target = implode('/', $args);
$image_uri = $scheme . '://' . $target;
$derivative_uri = image_style_path($style['name'], $image_uri);
if ($resolution) {
$path_parts = pathinfo($derivative_uri);
$derivative_uri = $path_parts['dirname'] . '/' . $resolution . '/' . $path_parts['basename'];
}
// If using the private scheme, let other modules provide headers and
// control access to the file.
if ($scheme == 'private') {
if (file_exists($derivative_uri)) {
file_download($scheme, file_uri_target($derivative_uri));
}
else {
$headers = module_invoke_all('file_download', $image_uri);
if (in_array(-1, $headers) || empty($headers)) {
return drupal_access_denied();
}
if (count($headers)) {
foreach ($headers as $name => $value) {
drupal_add_http_header($name, $value);
}
}
}
}
// Don't start generating the image if the derivative already exists or if
// generation is in progress in another thread.
$lock_name = 'image_style_deliver:' . $style['name'] . ':' . drupal_hash_base64($image_uri);
if (!file_exists($derivative_uri)) {
$lock_acquired = lock_acquire($lock_name);
if (!$lock_acquired) {
// Tell client to retry again in 3 seconds. Currently no browsers are known
// to support Retry-After.
drupal_add_http_header('Status', '503 Service Unavailable');
drupal_add_http_header('Retry-After', 3);
print t('Image generation in progress. Try again shortly.');
drupal_exit();
}
}
// Try to generate the image, unless another thread just did it while we were
// acquiring the lock.
$success = file_exists($derivative_uri) || image_style_create_derivative($style, $image_uri, $derivative_uri);
if (!empty($lock_acquired)) {
lock_release($lock_name);
}
if ($success) {
$image = image_load($derivative_uri);
file_transfer($image->source, array('Content-Type' => $image->info['mime_type'], 'Content-Length' => $image->info['file_size']));
}
else {
watchdog('image', 'Unable to generate the derived image located at %path.', array('%path' => $derivative_uri));
drupal_add_http_header('Status', '500 Internal Server Error');
print t('Error generating image.');
drupal_exit();
}
}
/**
* Check for common desktop patterns in the user agent
*/
function adaptive_image_browser_detect() {
$userAgent = strtolower($_SERVER['HTTP_USER_AGENT']);
// Identify the OS platform. Match only desktop OSs
if (strpos($userAgent,'macintosh') ||
strpos($userAgent,'windows nt') ||
strpos($userAgent,'x11')) {
return TRUE;
}
}

View File

@@ -0,0 +1,13 @@
name = Adaptive Image
description = Support for adaptive images.
core = 7.x
dependencies[] = image
stylesheets[all][] = css/adaptive-image.css
; Information added by drupal.org packaging script on 2012-02-24
version = "7.x-1.4"
core = "7.x"
project = "adaptive_image"
datestamp = "1330097138"

View File

@@ -0,0 +1,237 @@
<?php
/**
* @file
* Adaptive Image - Adaptive images for Drupal
* @see http://adaptive-images.com/
*
* @author
* Stefan Auditor <stefan.auditor@erdfisch.de>
*/
/**
* Implements hook_init().
*/
function adaptive_image_init() {
// According to the documentation of hook_init() it should not be used to
// load JS or CSS. The CSS case has been moved to the info file. But the JS is
// here by intention, as we want it inline to prevent wait time while loading
// the script
// No need for drupal behaviours, jquery compatibility wrapper nor ready event
$js = "document.cookie = 'adaptive_image=' + Math.max(screen.width, screen.height) + '; path=/';";
drupal_add_js($js,
// First-come, first-served
array(
'type' => 'inline',
'scope' => 'header',
'group' => JS_LIBRARY,
'every_page' => TRUE,
'weight' => -500,
)
);
}
/**
* Implements hook_menu().
*/
function adaptive_image_menu() {
$items = array();
// Add image style generation paths adaptive URLs.
if (module_exists('image')) {
// Generate and deliver image derivatives of public files.
$directory_path = file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath();
$items[$directory_path . '/styles/%image_style/adaptive-image'] = array(
'title' => 'Generate image style',
'page callback' => 'adaptive_image_style_deliver',
'page arguments' => array(count(explode('/', $directory_path)) + 1),
'access callback' => TRUE,
'type' => MENU_CALLBACK,
'file' => 'adaptive_image.image.inc',
);
// Generate and deliver image derivatives of private files.
$items['system/files/styles/%image_style/adaptive-image'] = array(
'title' => 'Generate adaptive image style',
'page callback' => 'adaptive_image_style_deliver',
'page arguments' => array(3),
'access callback' => TRUE,
'type' => MENU_CALLBACK,
'file' => 'adaptive_image.image.inc',
);
}
return $items;
}
/**
* Implements hook_image_effect_info().
*/
function adaptive_image_image_effect_info() {
$effects = array();
$effects['adaptive_image'] = array(
'label' => t('Adaptive'),
'help' => t('Adaptive image scale according to client resolution.'),
'effect callback' => 'image_scale_effect',
'dimensions callback' => 'image_scale_dimensions',
'form callback' => 'adaptive_image_scale_form',
'summary theme' => 'adaptive_image_scale_summary',
);
return $effects;
}
/**
* Form structure for the image scale form.
*
* Note that this is not a complete form, it only contains the portion of the
* form for configuring the scale options. Therefore it does not not need to
* include metadata about the effect, nor a submit button.
*
* @param $data
* The current configuration for this scale effect.
*/
function adaptive_image_scale_form($data) {
$form['resolutions'] = array(
'#type' => 'textfield',
'#title' => t('Resolutions'),
'#default_value' => isset($data['resolutions']) ? $data['resolutions'] : '1382, 992, 768, 480',
'#required' => TRUE,
'#description' => t('The resolution break-points to use (screen widths, in pixels).'),
);
$form['mobile_first'] = array(
'#type' => 'checkbox',
'#title' => t('Mobile first'),
'#default_value' => isset($data['mobile_first']) ? $data['mobile_first'] : TRUE,
'#description' => t("Check this to send the smallest version when the resolution can not be determined."),
);
$resolutions = explode(',', str_replace(' ', '', $form['resolutions']['#default_value']));
$resolution = adaptive_image_resolution($resolutions);
// Provide needed defaults
$form['height'] = array('#type' => 'hidden','#default_value' => NULL);
$form['width'] = array('#type' => 'hidden','#default_value' => $resolution);
$form['upscale'] = array('#type' => 'hidden','#default_value' => NULL);
return $form;
}
/**
* Implements hook_theme().
*/
function adaptive_image_theme() {
return array(
'adaptive_image_scale_summary' => array(
'variables' => array('data' => NULL),
),
);
}
/**
* Returns HTML for a summary of an image scale effect.
*
* @param $variables
* An associative array containing:
* - data: The current configuration for this scale effect.
*
* @ingroup themeable
*/
function theme_adaptive_image_scale_summary($variables) {
$data = $variables['data'];
if ($data['resolutions']) {
return check_plain($data['resolutions']);
}
}
/**
* Implements template_preprocess_image().
*
* Adds a class to adaptive images for max-width.
*/
function adaptive_image_preprocess_image(&$variables) {
global $base_url;
if (isset($variables['style_name'])) {
// Get image style settings
$style = image_style_load($variables['style_name']);
// Check if style contains the adaptive image effect
if ($style && adaptive_image_contains_effect($style)) {
$settings = adaptive_image_effect_settings($style);
$resolutions = explode(',', $settings['resolutions']);
$resolution = adaptive_image_resolution($resolutions);
// Only construct direct path if not private
if (!strpos($variables['path'], '/system/') && is_numeric($resolution)) {
$path_parts = pathinfo($variables['path']);
$derivative_uri = $path_parts['dirname'] . '/' . $resolution . '/' . $path_parts['basename'];
}
if (isset($derivative_uri) && file_exists(str_replace($base_url, '.', $derivative_uri))) {
// Deliver existing path to bypass menu callback
$variables['path'] = $derivative_uri;
}
else {
// Reconstruct the image path to %/%style_name/adaptive-image/% to
// trigger image generation or file access check
$variables['path'] = str_replace('styles/' . $variables['style_name'], 'styles/' . $variables['style_name'] . '/adaptive-image', $variables['path']);
}
// Add class for styling
$variables['attributes']['class'] = 'adaptive-image';
// Remove fixed image dimensions
unset($variables['height']);
unset($variables['width']);
}
}
}
/**
* Check for adaptive image effect from style
*/
function adaptive_image_contains_effect($style) {
foreach ($style['effects'] as $effect) {
if ($effect['name'] == 'adaptive_image') {
return TRUE;
}
}
return FALSE;
}
/**
* Get adaptive image effect from style settings
*/
function adaptive_image_effect_settings($style) {
$settings = array();
foreach ($style['effects'] as $effect) {
if ($effect['name'] == 'adaptive_image') {
$settings = $effect['data'];
}
}
return $settings;
}
/**
* Determine current resolution
*/
function adaptive_image_resolution($resolutions) {
$resolution = '';
/* Check to see if a valid cookie exists */
if (count($resolutions) && isset($_COOKIE['adaptive_image'])) {
if (is_numeric($_COOKIE['adaptive_image'])) {
$client_width = (int) $_COOKIE['adaptive_image']; // store the cookie value in a variable
/* the client width in the cookie is valid, now fit that number into the correct resolution break point */
rsort($resolutions); // make sure the supplied break-points are in reverse size order
$resolution = $resolutions[0]; // by default it's the largest supported break-point
foreach ($resolutions as $break_point) { // filter down
if ($client_width <= $break_point) {
$resolution = $break_point;
}
}
} else {
setcookie("adaptive_image", "", time() -1); // delete the mangled cookie
}
}
return $resolution;
}

View File

@@ -0,0 +1,3 @@
img.adaptive-image {
max-width: 100%;
}

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,29 @@
<?php
/**
* @file
* API documentation for Addressfield.
*/
/**
* Format generation callback.
*
* @param $format
* The address format being generated.
* @param $address
* The address this format is generated for.
* @param $context
* An array of context arguments:
* - 'mode': can be either 'form' or 'render'
* - (optional) 'field': when generated for a field, the field
* - (optional) 'instance': when generated for a field, the field instance
* - (optional) 'langcode': when generated for a field, the langcode
* this field is being rendered in.
* - (optional) 'delta': when generated for a field, the delta of the
* currently handled address.
*
* @ingroup addressfield_format
*/
function CALLBACK_addressfield_format_callback(&$format, $address, $context = array()) {
}

View File

@@ -0,0 +1,26 @@
.addressfield-container-inline > div.form-item {
float: left;
margin-right: 1em;
}
.addressfield-container-inline.country-GB > div.form-item {
float: none;
margin-right: auto;
}
/* Clear-fix markup for the inline container */
.addressfield-container-inline:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
/* IE6 */
* html .addressfield-container-inline {
height: 1%;
}
/* IE7 */
*:first-child + html .addressfield-container-inline {
min-height: 1%;
}

View File

@@ -0,0 +1,55 @@
<?php
/**
* @file
* Integration with the Feeds module.
*/
/**
* Implements hook_feeds_node_processor_targets_alter().
*/
function addressfield_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_name) {
foreach (field_info_instances($entity_type, $bundle_name) as $name => $instance) {
$info = field_info_field($name);
if ($info['type'] == 'addressfield') {
foreach ($info['columns'] as $sub_field => $schema_info) {
$name_label = $instance['label'] . ': ' . drupal_ucfirst(str_replace('_', ' ', $sub_field));
$targets[$name . ':' . $sub_field] = array(
'name' => $name_label,
'callback' => 'addressfield_set_target',
'real_target' => $info['field_name'],
'description' => $schema_info['description'],
);
}
}
}
}
/**
* Callback for hook_feeds_processor_targets_alter().
*
* @param $source
* Field mapper source settings.
* @param $entity
* An entity object, for instance a node object.
* @param $target
* A string identifying the target on the node.
* @param $value
* The value to populate the target with.
*/
function addressfield_set_target($source, $entity, $target, $value) {
list($field_name, $sub_field) = explode(':', $target, 2);
// Handle non-multiple value fields.
if (!is_array($value)) {
$value = array($value);
}
$field = isset($entity->$field_name) ? $entity->$field_name : array();
foreach ($value as $i => $v) {
$field['und'][$i][$sub_field] = $v;
}
$entity->$field_name = $field;
}

View File

@@ -0,0 +1,15 @@
name = Address Field
description = Manage a flexible address field, implementing the xNAL standard.
core = 7.x
package = Fields
dependencies[] = ctools
files[] = views/addressfield_views_handler_filter_country.inc
; Information added by drupal.org packaging script on 2012-05-29
version = "7.x-1.0-beta3"
core = "7.x"
project = "addressfield"
datestamp = "1338304248"

View File

@@ -0,0 +1,186 @@
<?php
/**
* Implements hook_field_schema()
*/
function addressfield_field_schema() {
$columns = array(
'country' => array(
'description' => 'Two letter ISO country code of this address.',
'type' => 'varchar',
'length' => 2,
'not null' => FALSE,
'default' => '',
),
'administrative_area' => array(
'description' => 'The administrative area of this address. (i.e. State/Province)',
'type' => 'varchar',
'length' => 255,
'default' => '',
'not null' => FALSE,
),
'sub_administrative_area' => array(
'description' => 'The sub administrative area of this address.',
'type' => 'varchar',
'length' => 255,
'default' => '',
'not null' => FALSE,
),
'locality' => array(
'description' => 'The locality of this address. (i.e. City)',
'type' => 'varchar',
'length' => 255,
'default' => '',
'not null' => FALSE,
),
'dependent_locality' => array(
'description' => 'The dependent locality of this address.',
'type' => 'varchar',
'length' => 255,
'default' => '',
'not null' => FALSE,
),
'postal_code' => array(
'description' => 'The postal code of this address.',
'type' => 'varchar',
'length' => 255,
'default' => '',
'not null' => FALSE,
),
'thoroughfare' => array(
'description' => 'The thoroughfare of this address. (i.e. Street address)',
'type' => 'varchar',
'length' => 255,
'default' => '',
'not null' => FALSE,
),
'premise' => array(
'description' => 'The premise of this address. (i.e. Apartment / Suite number)',
'type' => 'varchar',
'length' => 255,
'default' => '',
'not null' => FALSE,
),
'sub_premise' => array(
'description' => 'The sub_premise of this address.',
'type' => 'varchar',
'length' => 255,
'default' => '',
'not null' => FALSE,
),
'organisation_name' => array(
'description' => 'Contents of a primary OrganisationName element in the xNL XML.',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'default' => '',
),
'name_line' => array(
'description' => 'Contents of a primary NameLine element in the xNL XML.',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'default' => '',
),
'first_name' => array(
'description' => 'Contents of the FirstName element of a primary PersonName element in the xNL XML.',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'default' => '',
),
'last_name' => array(
'description' => 'Contents of the LastName element of a primary PersonName element in the xNL XML.',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'default' => '',
),
'data' => array(
'description' => 'Additional data for this address.',
'type' => 'text',
'size' => 'big',
'not null' => FALSE,
'serialize' => TRUE,
),
);
return array(
'columns' => $columns,
// TODO Add indexes.
);
}
/**
* Update the field configuration to the new plugin structure.
*/
function addressfield_update_7000() {
// Enable ctools.
if (!module_enable(array('ctools'))) {
throw new Exception('This version of addressfield requires ctools, but it could not be enabled.');
}
// Get the list of fields of type 'addressfield'.
$address_fields = array();
foreach (field_info_fields() as $field_name => $field_info) {
if ($field_info['type'] == 'addressfield') {
$address_fields[$field_name] = $field_name;
}
}
foreach (field_info_instances() as $entity_type => $bundles) {
foreach ($bundles as $bundle_name => $instances) {
foreach (array_intersect_key($instances, $address_fields) as $field_name => $instance) {
$widget_settings = &$instance['widget']['settings'];
if ($instance['widget']['type'] == 'addressfield_standard') {
// Default to use the country-based address widget.
$format_handlers = array('address');
// Map the old 'name_format' setting to the name and organization widgets.
if (in_array($widget_settings['name_format'], array('name_line_organisation', 'first_last_organisation'))) {
$format_handlers[] = 'organisation';
}
if (in_array($widget_settings['name_format'], array('name_line', 'name_line_organisation'))) {
$format_handlers[] = 'name-oneline';
}
else {
$format_handlers[] = 'name-full';
}
unset($widget_settings['name_format']);
$widget_settings['format_handlers'] = $format_handlers;
}
// Update displays.
foreach ($instance['display'] as $view_mode => &$view_mode_info) {
$display_settings = &$view_mode_info['settings'];
if ($view_mode_info['type'] == 'addressfield_default') {
if (isset($widget_settings['format_handlers'])) {
$display_settings['use_widget_handlers'] = 1;
}
else {
// If the widget is non-standard, just use a sane default.
$display_settings['use_widget_handlers'] = 0;
$display_settings['format_handlers'] = array('address', 'name-oneline');
}
}
else if ($view_mode_info['type'] == 'addressfield_name') {
// Migrate the 'addressfield_name' formatter to the new framework.
$view_mode_info['type'] = 'addressfield_default';
// Start from the widget configuration.
$display_settings['use_widget_handlers'] = 0;
$display_settings['format_handlers'] = isset($widget_settings['format_handlers']) ? $widget_settings['format_handlers'] : array('address', 'name-oneline');
if (empty($display_settings['organisation'])) {
$display_settings['format_handlers'] = array_diff( $display_settings['format_handlers'], array('organisation'));
}
unset($display_settings['organisation']);
}
}
field_update_instance($instance);
}
}
}
}

View File

@@ -0,0 +1,747 @@
<?php
/**
* @file
* Defines a field for attaching country-specific addresses to entities.
*/
/**
* Implements hook_ctools_plugin_directory().
*/
function addressfield_ctools_plugin_directory($module, $plugin) {
if ($module == 'addressfield') {
return 'plugins/' . $plugin;
}
}
/**
* Implements hook_ctools_plugin_type().
*/
function addressfield_ctools_plugin_type() {
$plugins['format'] = array(
'load themes' => TRUE,
);
return $plugins;
}
/**
* Implements hook_views_api().
*/
function addressfield_views_api() {
return array(
'api' => 3,
'path' => drupal_get_path('module', 'addressfield') . '/views',
);
}
/**
* Get the list of format plugins.
*/
function addressfield_format_plugins() {
ctools_include('plugins');
$plugins = ctools_get_plugins('addressfield', 'format');
uasort($plugins, 'ctools_plugin_sort');
return $plugins;
}
/**
* Get the list of format plugins in a format suitable for #options.
*/
function addressfield_format_plugins_options() {
$options = array();
foreach (addressfield_format_plugins() as $widget => $info) {
$options[$widget] = check_plain($info['title']);
}
return $options;
}
/**
* @defgroup addressfield_format Address format API
* @{
* API for generating address forms and display formats.
*
* Addresses forms and display formats are collaboratively generated by one or
* more format handler plugins. An address with a name and a company, for example,
* will be generated by three handlers:
* - 'address' that will generate the country, locality, street blocks
* - 'organisation' that will add the organisation block to the address
* - 'name-full' that will add a first name and last name block to the address
*
* A format handler is a CTools plugin of type 'addressfield' / 'format'. Each
* handler is passed the format in turn, and can add to or modify the format.
*
* The format itself is a renderable array stub. This stub will be transformed
* into either a Form API array suitable for use as part of a form or into a
* renderable array suitable for use with drupal_render(). The following
* modifications are done:
* - when rendering as a form, every element which name (its key in the array)
* is a valid addressfield column (see addressfield_field_schema()), will
* be transformed into a form element, either using a type explicitly
* defined in '#widget_type' or using 'select' if '#options' is set or
* 'textfield' if it is not. In addition, the '#default_value' of every
* field will be populated from the address being edited.
* - when rendering as a formatter, every element which name (its key in the array)
* is a valid addressfield column (see addressfield_field_schema()), will
* be transformed into a renderable element, either using a type explicitly
* defined in '#render_type' or else using 'addressfield_container'. When
* the type is 'addressfield_container' the element will be rendered as
* an HTML element set by '#tag' (default: span).
*/
/**
* Generate a format for a given address.
*
* @param $address
* The address format being generated.
* @param $handlers
* The format handlers to use to generate the format.
* @param $context
* An array of context arguments:
* - 'mode': can be either 'form' or 'render'
* - (optional) 'field': when generated for a field, the field
* - (optional) 'instance': when generated for a field, the field instance
* - (optional) 'langcode': when generated for a field, the langcode
* this field is being rendered in.
* - (optional) 'delta': when generated for a field, the delta of the
* currently handled address.
*
* @return
* A rendered array suitable for use as part of a form (if 'mode' is 'form'),
* or suitable to pass to drupal_render().
*/
function addressfield_generate($address, array $handlers, array $context = array()) {
ctools_include('plugins');
$format = array();
$format['#handlers'] = $handlers;
foreach ($format['#handlers'] as $handler) {
if ($callback = ctools_plugin_load_function('addressfield', 'format', $handler, 'format callback')) {
$callback($format, $address, $context);
}
}
// Store the address in the format, for processing.
$format['#address'] = $address;
// Post-process the format stub, depending on the rendering mode.
if ($context['mode'] == 'form') {
$format['#addressfield'] = TRUE;
$format['#process'][] = 'addressfield_process_format_form';
$format['#required'] = FALSE;
}
else {
$format['#pre_render'][] = 'addressfield_render_address';
}
return $format;
}
/**
* Generate a full-fledged form from a format snippet, as returned by addressfield_formats().
*/
function addressfield_process_format_form($format, &$form_state, $complete_form) {
// Make sure to load all the plugins that participated in this format.
ctools_include('plugins');
foreach ($format['#handlers'] as $handler) {
ctools_plugin_load_function('addressfield', 'format', $handler, 'format callback');
}
_addressfield_process_format_form($format, $format['#address'], $format['#required']);
return $format;
}
function _addressfield_process_format_form(&$format, $address, $required) {
foreach (element_children($format) as $key) {
$child = &$format[$key];
// Automatically expand elements that matches one of the field of the
// address structure.
if (in_array($key, array('name_line', 'first_name', 'last_name', 'organisation_name', 'country', 'administrative_area', 'sub_administrative_area', 'locality', 'dependent_locality', 'postal_code', 'thoroughfare', 'premise', 'sub_premise'))) {
// Set the type.
if (isset($child['#widget_type'])) {
$child['#type'] = $child['#widget_type'];
}
else {
if (isset($child['#options'])) {
$child['#type'] = 'select';
$child['#size'] = 0;
}
else {
$child['#type'] = 'textfield';
}
}
if (!$required) {
unset($child['#required']);
}
$child['#default_value'] = $address[$key];
}
// Recurse through the child.
_addressfield_process_format_form($child, $address, $required);
}
}
/**
* Render an address in a given format.
*/
function addressfield_render_address($format) {
_addressfield_render_address($format, $format['#address']);
return $format;
}
function _addressfield_render_address(&$format, $address) {
foreach (element_children($format) as $key) {
$child = &$format[$key];
// Automatically expand elements that matches one of the field of the
// address structure.
if (in_array($key, array('name_line', 'first_name', 'last_name', 'organisation_name', 'country', 'administrative_area', 'sub_administrative_area', 'locality', 'dependent_locality', 'postal_code', 'thoroughfare', 'premise', 'sub_premise'))) {
if (isset($child['#render_type'])) {
$child['#type'] = $child['#render_type'];
}
else {
$child['#type'] = 'addressfield_container';
if (!isset($child['#tag'])) {
$child['#tag'] = 'span';
}
}
if (isset($child['#options'])) {
// Expand options if necessary.
$child['#children'] = isset($child['#options'][$address[$key]]) ? check_plain($child['#options'][$address[$key]]) : '';
}
else {
$child['#children'] = check_plain($address[$key]);
}
// Skip empty elements.
if ((string) $child['#children'] === '') {
$child['#access'] = FALSE;
}
// Add #prefix and #field_suffix to the prefixes and suffixes.
if (isset($child['#prefix'])) {
$child['#prefix'] = (isset($child['#prefix']) ? $child['#prefix'] : '') . $child['#prefix'];
}
if (isset($child['#field_suffix'])) {
$child['#suffix'] = (isset($child['#suffix']) ? $child['#suffix'] : '') . $child['#field_suffix'];
}
}
// Recurse through the child.
_addressfield_render_address($child, $address);
}
}
/**
* @} End of "ingroup addressfield_format"
*/
/**
* Implementation of hook_theme().
*/
function addressfield_theme() {
$hooks['addressfield_container'] = array(
'render element' => 'element',
);
return $hooks;
}
/**
* Render a container for a set of address fields.
*/
function theme_addressfield_container($variables) {
$element = $variables['element'];
$element['#children'] = trim($element['#children']);
if (strlen($element['#children']) > 0) {
$output = '<' . $element['#tag'] . drupal_attributes($element['#attributes']) . '>';
$output .= $element['#children'];
$output .= '</' . $element['#tag'] . ">";
return $output;
}
else {
return '';
}
}
/**
* Implementation of hook_element_info().
*/
function addressfield_element_info() {
$types['addressfield_container'] = array(
'#theme_wrappers' => array('addressfield_container'),
'#process' => array('addressfield_widget_process'),
'#attributes' => array(),
'#tag' => 'div',
);
return $types;
}
/**
* Form API process function: set the #parents of the children of this element so they appear at the same level as the parent.
*/
function addressfield_widget_process($element) {
foreach (element_children($element) as $key) {
$element[$key]['#parents'] = $element['#parents'];
$element[$key]['#parents'][count($element[$key]['#parents']) - 1] = $key;
}
return $element;
}
/**
* Implements hook_field_info()
*/
function addressfield_field_info() {
$fields = array();
$fields['addressfield'] = array(
'label' => t('Postal address'),
'description' => t('A field type used for storing postal addresses according the xNAL standard.'),
'settings' => array(),
'instance_settings' => array(),
'default_widget' => 'addressfield_standard',
'default_formatter' => 'addressfield_default',
'property_type' => 'addressfield',
'property_callbacks' => array('addressfield_property_info_callback'),
);
return $fields;
}
/**
* Returns an array of default values for the addressfield form elements.
*/
function addressfield_default_values($available_countries = NULL) {
if (!isset($available_countries)) {
$available_countries = _addressfield_country_options_list();
}
// Use the default country of the site if possible.
$default_country = variable_get('site_default_country', NULL);
// If the default country is undefined or not in the list of available countries,
// just fallback to the first country in the list.
if (!$default_country || !isset($available_countries[$default_country])) {
$default_country = key($available_countries);
}
return array(
'country' => $default_country,
'name_line' => '',
'first_name' => '',
'last_name' => '',
'organisation_name' => '',
'administrative_area' => '',
'sub_administrative_area' => '',
'locality' => '',
'dependent_locality' => '',
'postal_code' => '',
'thoroughfare' => '',
'premise' => '',
'sub_premise' => '',
'data' => '',
);
}
/**
* Implements hook_field_is_empty().
*/
function addressfield_field_is_empty($item, $field) {
// Every address field must have at least a country value or it is considered
// empty, even if it has name information.
return empty($item['country']);
}
/**
* Implements hook_field_widget_info()
*/
function addressfield_field_widget_info() {
$widgets = array();
$widgets['addressfield_standard'] = array(
'label' => t('Dynamic address form'),
'field types' => array('addressfield'),
'settings' => array(
'available_countries' => array(),
'format_handlers' => array('address'),
),
);
return $widgets;
}
/**
* Implements hook_field_widget_settings_form()
*/
function addressfield_field_widget_settings_form($field, $instance) {
$widget = $instance['widget'];
$defaults = field_info_widget_settings($widget['type']);
$settings = array_merge($defaults, $widget['settings']);
if ($widget['type'] == 'addressfield_standard') {
$form['available_countries'] = array(
'#type' => 'select',
'#multiple' => TRUE,
'#title' => t('Available countries'),
'#description' => t('If no countries are selected, all countries will be available.'),
'#options' => _addressfield_country_options_list(),
'#default_value' => $settings['available_countries'],
);
$form['format_handlers'] = array(
'#type' => 'checkboxes',
'#title' => t('Format handlers'),
'#options' => addressfield_format_plugins_options(),
'#default_value' => $settings['format_handlers'],
);
}
return $form;
}
/**
* Implements hook_field_widget_form()
*/
function addressfield_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
$settings = $instance['widget']['settings'];
// Generate a specific key used to identify this element to restore a default
// value upon AJAX submission regardless of where this element is in the
// $form array.
$element_key = implode('|', array($element['#entity_type'], $element['#bundle'], $element['#field_name'], $element['#language'], $element['#delta']));
// Store the key in the element array as a value so it can be easily retrieved
// in context in the $form_state['values'] array in the element validator.
$element['element_key'] = array(
'#type' => 'value',
'#value' => $element_key,
);
// Get the default address used to build the widget form elements, looking
// first in the form state, then in the stored value for the field, and then
// in the default values of the instance.
$address = array();
if (!empty($form_state['addressfield'][$element_key])) {
// Use the value from the form_state if available.
$address = $form_state['addressfield'][$element_key];
}
elseif (!empty($items[$delta]['country'])) {
// Else use the saved value for the field.
$address = $items[$delta];
}
else {
// Otherwise use the instance default.
$address = (array) $instance['default_value'][0];
}
// Merge in default values to provide a value for every expected array key.
$countries = _addressfield_country_options_list($field, $instance);
$address += addressfield_default_values($countries);
// Add the form elements for the standard widget, which includes a country
// select list at the top that reloads the available address elements when the
// country is changed.
if ($instance['widget']['type'] == 'addressfield_standard') {
// Wrap everything in a fieldset. This is not the best looking element,
// but it's the only wrapper available in Drupal we can properly use
// in that context, and it is overridable if necessary.
$element['#type'] = 'fieldset';
// Generate the address form.
$context = array(
'mode' => 'form',
'field' => $field,
'instance' => $instance,
'langcode' => $langcode,
'delta' => $delta,
);
$element += addressfield_generate($address, $settings['format_handlers'], $context);
// Mark the form element as required if necessary.
$element['#required'] = $delta == 0 && $instance['required'];
}
return $element;
}
/**
* Element validate callback: rebuilds the form on country change and stores the current address value in the $form_state for retrieval on rebuild.
*/
function addressfield_standard_country_validate($element, &$form_state) {
// If the country was changed, rebuild the form.
if ($element['#default_value'] != $element['#value']) {
$form_state['rebuild'] = TRUE;
}
$parents = $element['#parents'];
array_pop($parents);
// Search through the form values to find the current address.
$address = drupal_array_get_nested_value($form_state['values'], $parents);
// Store the present address values in the form state for retrieval by the
// widget form regardless of where the widget sits in the $form array.
$form_state['addressfield'][$address['element_key']] = array_diff_key($address, array('element_key' => ''));
}
/**
* Ajax callback in response to a change of country in an address field.
*
* The only thing we have to do is to find the proper element to render.
*/
function addressfield_standard_widget_refresh($form, $form_state) {
// The target element is one element below the triggering country selector.
$array_parents = $form_state['triggering_element']['#array_parents'];
array_pop($array_parents);
// Iterate over the form parents to find the element.
$element = $form;
foreach ($array_parents as $name) {
$element = &$element[$name];
if (!empty($element['#addressfield'])) {
break;
}
}
// Return the address block, but remove the '_weight' element inserted
// by the field API.
unset($element['_weight']);
return $element;
}
/**
* Implements hook_field_formatter_info().
*/
function addressfield_field_formatter_info() {
return array(
'addressfield_default' => array(
'label' => t('Default'),
'field types' => array('addressfield'),
'settings' => array(
'use_widget_handlers' => 1,
'format_handlers' => array('address'),
),
),
);
}
/**
* Implements hook_field_formatter_settings_form().
*/
function addressfield_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
$display = $instance['display'][$view_mode];
$settings = $display['settings'];
$element['use_widget_handlers'] = array(
'#type' => 'checkbox',
'#title' => t('Use the same configuration as the widget'),
'#default_value' => !empty($settings['use_widget_handlers']),
);
$element['format_handlers'] = array(
'#type' => 'checkboxes',
'#title' => t('Format handlers'),
'#options' => addressfield_format_plugins_options(),
'#default_value' => $settings['format_handlers'],
'#process' => array('form_process_checkboxes', '_addressfield_field_formatter_settings_form_process_add_state'),
'#element_validate' => array('_addressfield_field_formatter_settings_form_validate')
);
return $element;
}
/**
* Helper function: set the proper #states to the use widget handlers checkbox.
*/
function _addressfield_field_formatter_settings_form_process_add_state($element, $form_state) {
// Build a #parents based on the current checkbox.
$target_parents = array_slice($element['#parents'], 0, -1);
$target_parents[] = 'use_widget_handlers';
$target_parents = array_shift($target_parents) . ($target_parents ? '[' . implode('][', $target_parents) . ']' : '');
$element['#states']['visible'] = array(
':input[name="' . $target_parents . '"]' => array('checked' => FALSE),
);
return $element;
}
/**
* Helper function: filter the results of the checkboxes form element.
*/
function _addressfield_field_formatter_settings_form_validate($element, &$element_state) {
form_set_value($element, array_filter($element['#value']), $element_state);
}
/**
* Implements hook_field_formatter_settings_summary().
*/
function addressfield_field_formatter_settings_summary($field, $instance, $view_mode) {
$display = $instance['display'][$view_mode];
$settings = $display['settings'];
$summary = '';
if ($settings['use_widget_handlers']) {
return t('Use widget configuration');
}
else {
$summary = array();
$plugins = addressfield_format_plugins();
foreach ($settings['format_handlers'] as $handler) {
$summary[] = $plugins[$handler]['title'];
}
return $summary ? implode(', ', $summary) : t('No handler');
}
}
/**
* Implements hook_field_formatter_view().
*/
function addressfield_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$settings = $display['settings'];
$element = array();
switch ($display['type']) {
case 'addressfield_default':
if (!empty($settings['use_widget_handlers'])) {
$handlers = $instance['widget']['settings']['format_handlers'];
}
else {
$handlers = $settings['format_handlers'];
}
foreach ($items as $delta => $address) {
// Generate the address format.
$context = array(
'mode' => 'render',
'field' => $field,
'instance' => $instance,
'langcode' => $langcode,
'delta' => $delta,
);
$element[$delta] = addressfield_generate($address, $handlers, $context);
}
break;
}
return $element;
}
/**
* Callback to alter the property info of address fields.
*
* @see addressfield_field_info().
*/
function addressfield_property_info_callback(&$info, $entity_type, $field, $instance, $field_type) {
$name = $field['field_name'];
$property = &$info[$entity_type]['bundles'][$instance['bundle']]['properties'][$name];
$property['type'] = ($field['cardinality'] != 1) ? 'list<addressfield>' : 'addressfield';
$property['getter callback'] = 'entity_metadata_field_verbatim_get';
$property['setter callback'] = 'entity_metadata_field_verbatim_set';
$property['auto creation'] = 'addressfield_default_values';
$property['property info'] = addressfield_data_property_info();
unset($property['query callback']);
}
/**
* Defines info for the properties of the address field data structure.
*/
function addressfield_data_property_info($name = NULL) {
// Build an array of basic property information for the address field.
$properties = array(
'country' => array(
'label' => t('Country'),
'options list' => '_addressfield_country_options_list',
),
'name_line' => array(
'label' => t('Full name'),
),
'first_name' => array(
'label' => t('First name'),
),
'last_name' => array(
'label' => t('Last name'),
),
'organisation_name' => array(
'label' => t('Company'),
),
'administrative_area' => array(
'label' => t('Administrative area (i.e. State / Province)'),
),
'sub_administrative_area' => array(
'label' => t('Sub administrative area'),
),
'locality' => array(
'label' => t('Locality (i.e. City)'),
),
'dependent_locality' => array(
'label' => t('Dependent locality'),
),
'postal_code' => array(
'label' => t('Postal code'),
),
'thoroughfare' => array(
'label' => t('Thoroughfare (i.e. Street address)'),
),
'premise' => array(
'label' => t('Premise (i.e. Apartment / Suite number)'),
),
'name_line' => array(
'label' => t('Sub premise'),
),
);
// Add the default values for each of the address field properties.
foreach ($properties as $key => &$value) {
$value += array(
'description' => !empty($name) ? t('!label of field %name', array('!label' => $value['label'], '%name' => $name)) : '',
'type' => 'text',
'getter callback' => 'entity_property_verbatim_get',
'setter callback' => 'entity_property_verbatim_set',
);
}
return $properties;
}
/**
* Wraps country_get_list() for use as an Entity API options list.
*/
function _addressfield_country_options_list($field = NULL, $instance = NULL) {
// Necessary for country_get_list().
require_once DRUPAL_ROOT . '/includes/locale.inc';
$countries = country_get_list();
if (isset($field)) {
// If the instance is not specified, loop against all the instances of the field.
if (!isset($instance)) {
$instances = array();
foreach ($field['bundles'] as $entity_type => $bundles) {
foreach ($bundles as $bundle_name) {
$instances[] = field_info_instance($entity_type, $field['field_name'], $bundle_name);
}
}
}
else {
$instances = array($instance);
}
foreach ($instances as $instance) {
if (!empty($instance['widget']['settings']['available_countries'])) {
$countries = array_intersect_key($countries, $instance['widget']['settings']['available_countries']);
}
else {
// This instance allow all the countries.
$countries = country_get_list();
break;
}
}
}
return $countries;
}

View File

@@ -0,0 +1,15 @@
name = Address Field Example
description = Example module for how to implement an addressfield format handler.
core = 7.x
package = Fields
hidden = TRUE
dependencies[] = ctools
dependencies[] = addressfield
; Information added by drupal.org packaging script on 2012-05-29
version = "7.x-1.0-beta3"
core = "7.x"
project = "addressfield"
datestamp = "1338304248"

View File

@@ -0,0 +1,10 @@
<?php
/**
* Implements hook_ctools_plugin_directory().
*/
function addressfield_example_ctools_plugin_directory($module, $plugin) {
if ($module == 'addressfield') {
return 'plugins/' . $plugin;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,22 @@
<?php
/**
* @file
* Hide then country when only one country is available.
*/
$plugin = array(
'title' => t('Hide the country when only one is available'),
'format callback' => 'addressfield_format_address_hide_country',
'type' => 'address',
'weight' => -80,
);
/**
* Format callback.
*
* @see CALLBACK_addressfield_format_callback()
*/
function addressfield_format_address_hide_country(&$format, $address, $context = array()) {
$format['country']['#access'] = (count($format['country']['#options']) > 1);
}

View File

@@ -0,0 +1,429 @@
<?php
/**
* @file
* The default format for adresses.
*/
$plugin = array(
'title' => t('Address form (country-specific)'),
'format callback' => 'addressfield_format_address_generate',
'type' => 'address',
'weight' => -100,
);
/**
* Format callback.
*
* @see CALLBACK_addressfield_format_callback()
*/
function addressfield_format_address_generate(&$format, $address, $context = array()) {
// We start with a reasonable default: a simple block format suitable
// for international shipping. We extend it with country-specific heuristics
// below.
// The street block.
$format['street_block'] = array(
'#type' => 'addressfield_container',
'#attributes' => array('class' => array('street-block')),
'#weight' => 0,
);
$format['street_block']['thoroughfare'] = array(
'#title' => t('Address 1'),
'#tag' => 'div',
'#attributes' => array('class' => array('thoroughfare')),
'#size' => 30,
// The #required will be automatically set to FALSE when processing.
'#required' => TRUE,
);
$format['street_block']['premise'] = array(
'#title' => t('Address 2'),
'#tag' => 'div',
'#attributes' => array('class' => array('premise')),
'#size' => 30,
);
$format['locality_block'] = array(
'#type' => 'addressfield_container',
'#attributes' => array('class' => array('addressfield-container-inline', 'locality-block', 'country-' . $address['country'])),
'#weight' => 50,
);
$format['locality_block']['#attached']['css'][] = drupal_get_path('module', 'addressfield') . '/addressfield.css';
$format['locality_block']['postal_code'] = array(
'#title' => t('Postal Code'),
'#size' => 10,
'#required' => TRUE,
'#attributes' => array('class' => array('postal-code')),
);
$format['locality_block']['locality'] = array(
'#title' => t('City'),
'#size' => 30,
'#required' => TRUE,
'#prefix' => ' ',
'#attributes' => array('class' => array('locality')),
);
$format['country'] = array(
'#title' => t('Country'),
'#options' => _addressfield_country_options_list(),
'#required' => TRUE,
'#attributes' => array('class' => array('country')),
'#weight' => 100,
);
// Those countries do not seem to have a relevant postal code.
if (in_array($address['country'], array('AF', 'AG', 'AL', 'AO', 'BB', 'BI', 'BJ', 'BO', 'BS', 'BW', 'BZ', 'CF', 'CG', 'CM', 'CO', 'DJ', 'DM', 'EG', 'ER', 'FJ', 'GD', 'GH', 'GM', 'GQ', 'GY', 'IE', 'KI', 'KM', 'KP', 'KY', 'LC', 'LY', 'ML', 'MR', 'NA', 'NR', 'RW', 'SB', 'SC', 'SL', 'SR', 'ST', 'TD', 'TG', 'TL', 'TO', 'TT', 'TV', 'TZ', 'UG', 'VC', 'VU', 'WS', 'ZW'))) {
unset($format['locality_block']['postal_code']);
// Remove the prefix from the first widget of the block.
$element_children = element_children($format['locality_block']);
$first_child = reset($element_children);
unset($format['locality_block'][$first_child]['#prefix']);
}
// Those countries generally use their administrative division in postal addresses.
if (in_array($address['country'], array('AR', 'AU', 'BR', 'BS', 'BY', 'BZ', 'CA', 'CN', 'DO', 'EG', 'ES', 'FJ', 'FM', 'GB', 'HN', 'ID', 'IE', 'IN', 'IT', 'JO', 'JP', 'KI', 'KN', 'KR', 'KW', 'KY', 'KZ', 'MX', 'MY', 'MZ', 'NG', 'NI', 'NR', 'NZ', 'OM', 'PA', 'PF', 'PG', 'PH', 'PR', 'PW', 'RU', 'SM', 'SO', 'SR', 'SV', 'TH', 'TW', 'UA', 'US', 'UY', 'VE', 'VI', 'VN', 'YU', 'ZA'))) {
$format['locality_block']['administrative_area'] = array(
'#title' => t('State'),
'#size' => 10,
'#required' => TRUE,
'#prefix' => ' ',
'#attributes' => array('class' => array('state')),
);
}
// A few contries have a well-known list of administrative divisions.
if ($address['country'] == 'US') {
$format['locality_block']['administrative_area']['#options'] = array(
'' => t('--'),
'AL' => t('Alabama'),
'AK' => t('Alaska'),
'AZ' => t('Arizona'),
'AR' => t('Arkansas'),
'CA' => t('California'),
'CO' => t('Colorado'),
'CT' => t('Connecticut'),
'DE' => t('Delaware'),
'DC' => t('District Of Columbia'),
'FL' => t('Florida'),
'GA' => t('Georgia'),
'HI' => t('Hawaii'),
'ID' => t('Idaho'),
'IL' => t('Illinois'),
'IN' => t('Indiana'),
'IA' => t('Iowa'),
'KS' => t('Kansas'),
'KY' => t('Kentucky'),
'LA' => t('Louisiana'),
'ME' => t('Maine'),
'MD' => t('Maryland'),
'MA' => t('Massachusetts'),
'MI' => t('Michigan'),
'MN' => t('Minnesota'),
'MS' => t('Mississippi'),
'MO' => t('Missouri'),
'MT' => t('Montana'),
'NE' => t('Nebraska'),
'NV' => t('Nevada'),
'NH' => t('New Hampshire'),
'NJ' => t('New Jersey'),
'NM' => t('New Mexico'),
'NY' => t('New York'),
'NC' => t('North Carolina'),
'ND' => t('North Dakota'),
'OH' => t('Ohio'),
'OK' => t('Oklahoma'),
'OR' => t('Oregon'),
'PA' => t('Pennsylvania'),
'RI' => t('Rhode Island'),
'SC' => t('South Carolina'),
'SD' => t('South Dakota'),
'TN' => t('Tennessee'),
'TX' => t('Texas'),
'UT' => t('Utah'),
'VT' => t('Vermont'),
'VA' => t('Virginia'),
'WA' => t('Washington'),
'WV' => t('West Virginia'),
'WI' => t('Wisconsin'),
'WY' => t('Wyoming'),
' ' => t('--'),
'AS' => t('American Samoa'),
'FM' => t('Federated States of Micronesia'),
'GU' => t('Guam'),
'MH' => t('Marshall Islands'),
'MP' => t('Northern Mariana Islands'),
'PW' => t('Palau'),
'PR' => t('Puerto Rico'),
'VI' => t('Virgin Islands'),
);
$format['locality_block']['postal_code']['#title'] = t('ZIP Code');
}
else if ($address['country'] == 'IT') {
$format['locality_block']['administrative_area']['#options'] = array(
'' => t('--'),
'AG' => 'Agrigento',
'AL' => 'Alessandria',
'AN' => 'Ancona',
'AO' => 'Valle d\'Aosta/Vallée d\'Aoste',
'AP' => 'Ascoli Piceno',
'AQ' => 'L\'Aquila',
'AR' => 'Arezzo',
'AT' => 'Asti',
'AV' => 'Avellino',
'BA' => 'Bari',
'BG' => 'Bergamo',
'BI' => 'Biella',
'BL' => 'Belluno',
'BN' => 'Benevento',
'BO' => 'Bologna',
'BR' => 'Brindisi',
'BS' => 'Brescia',
'BT' => 'Barletta-Andria-Trani',
'BZ' => 'Bolzano/Bozen',
'CA' => 'Cagliari',
'CB' => 'Campobasso',
'CE' => 'Caserta',
'CH' => 'Chieti',
'CI' => 'Carbonia-Iglesias',
'CL' => 'Caltanissetta',
'CN' => 'Cuneo',
'CO' => 'Como',
'CR' => 'Cremona',
'CS' => 'Cosenza',
'CT' => 'Catania',
'CZ' => 'Catanzaro',
'EN' => 'Enna',
'FC' => 'Forlì-Cesena',
'FE' => 'Ferrara',
'FG' => 'Foggia',
'FI' => 'Firenze',
'FM' => 'Fermo',
'FR' => 'Frosinone',
'GE' => 'Genova',
'GO' => 'Gorizia',
'GR' => 'Grosseto',
'IM' => 'Imperia',
'IS' => 'Isernia',
'KR' => 'Crotone',
'LC' => 'Lecco',
'LE' => 'Lecce',
'LI' => 'Livorno',
'LO' => 'Lodi',
'LT' => 'Latina',
'LU' => 'Lucca',
'MB' => 'Monza e Brianza',
'MC' => 'Macerata',
'ME' => 'Messina',
'MI' => 'Milano',
'MN' => 'Mantova',
'MO' => 'Modena',
'MS' => 'Massa-Carrara',
'MT' => 'Matera',
'NA' => 'Napoli',
'NO' => 'Novara',
'NU' => 'Nuoro',
'OG' => 'Ogliastra',
'OR' => 'Oristano',
'OT' => 'Olbia-Tempio',
'PA' => 'Palermo',
'PC' => 'Piacenza',
'PD' => 'Padova',
'PE' => 'Pescara',
'PG' => 'Perugia',
'PI' => 'Pisa',
'PN' => 'Pordenone',
'PO' => 'Prato',
'PR' => 'Parma',
'PT' => 'Pistoia',
'PU' => 'Pesaro e Urbino',
'PV' => 'Pavia',
'PZ' => 'Potenza',
'RA' => 'Ravenna',
'RC' => 'Reggio di Calabria',
'RE' => 'Reggio nell\'Emilia',
'RG' => 'Ragusa',
'RI' => 'Rieti',
'RM' => 'Roma',
'RN' => 'Rimini',
'RO' => 'Rovigo',
'SA' => 'Salerno',
'SI' => 'Siena',
'SO' => 'Sondrio',
'SP' => 'La Spezia',
'SR' => 'Siracusa',
'SS' => 'Sassari',
'SV' => 'Savona',
'TA' => 'Taranto',
'TE' => 'Teramo',
'TN' => 'Trento',
'TO' => 'Torino',
'TP' => 'Trapani',
'TR' => 'Terni',
'TS' => 'Trieste',
'TV' => 'Treviso',
'UD' => 'Udine',
'VA' => 'Varese',
'VB' => 'Verbano-Cusio-Ossola',
'VC' => 'Vercelli',
'VE' => 'Venezia',
'VI' => 'Vicenza',
'VR' => 'Verona',
'VS' => 'Medio Campidano',
'VT' => 'Viterbo',
'VV' => 'Vibo Valentia',
);
$format['locality_block']['administrative_area']['#title'] = t('Province');
}
else if ($address['country'] == 'BR') {
$format['locality_block']['administrative_area']['#options'] = array(
'' => t('--'),
'AC' => t('Acre'),
'AL' => t('Alagoas'),
'AM' => t('Amazonas'),
'AP' => t('Amapa'),
'BA' => t('Bahia'),
'CE' => t('Ceara'),
'DF' => t('Distrito Federal'),
'ES' => t('Espirito Santo'),
'GO' => t('Goias'),
'MA' => t('Maranhao'),
'MG' => t('Minas Gerais'),
'MS' => t('Mato Grosso do Sul'),
'MT' => t('Mato Grosso'),
'PA' => t('Para'),
'PB' => t('Paraiba'),
'PE' => t('Pernambuco'),
'PI' => t('Piaui'),
'PR' => t('Parana'),
'RJ' => t('Rio de Janeiro'),
'RN' => t('Rio Grande do Norte'),
'RO' => t('Rondonia'),
'RR' => t('Roraima'),
'RS' => t('Rio Grande do Sul'),
'SC' => t('Santa Catarina'),
'SE' => t('Sergipe'),
'SP' => t('Sao Paulo'),
'TO' => t('Tocantins'),
);
}
else if ($address['country'] == 'CA') {
$format['locality_block']['administrative_area']['#options'] = array(
'' => t('--'),
'AB' => t('Alberta'),
'BC' => t('British Columbia'),
'MB' => t('Manitoba'),
'NB' => t('New Brunswick'),
'NL' => t('Newfoundland'),
'NT' => t('Northwest Territories'),
'NS' => t('Nova Scotia'),
'NU' => t('Nunavut'),
'ON' => t('Ontario'),
'PE' => t('Prince Edward Island'),
'QC' => t('Quebec'),
'SK' => t('Saskatchewan'),
'YT' => t('Yukon Territory'),
);
$format['locality_block']['administrative_area']['#title'] = t('Province');
}
else if ($address['country'] == 'AU') {
$format['locality_block']['administrative_area']['#options'] = array(
'' => t('--'),
'ACT' => t('Australian Capital Territory'),
'NSW' => t('New South Wales'),
'NT' => t('Northern Territory'),
'QLD' => t('Queensland'),
'SA' => t('South Australia'),
'TAS' => t('Tasmania'),
'VIC' => t('Victoria'),
'WA' => t('Western Australia'),
);
}
// Those countries tend to put the postal code after the locality.
if (in_array($address['country'], array('AU', 'BD', 'BF', 'BH', 'BM', 'BN', 'BT', 'CA', 'FM', 'GB', 'ID', 'IN', 'JM', 'JO', 'KH', 'LB', 'LS', 'LV', 'MM', 'MN', 'MV', 'MW', 'NG', 'NP', 'NZ', 'PE', 'PK', 'PR', 'PW', 'SA', 'SG', 'SO', 'TH', 'US', 'VI', 'VG', 'VN'))) {
// Take the widget out of the array.
$postal_code_widget = $format['locality_block']['postal_code'];
$postal_code_widget['#prefix'] = ' ';
unset($format['locality_block']['postal_code']);
// Add it back.
$format['locality_block']['postal_code'] = $postal_code_widget;
// Remove the prefix from the first widget of the block.
$element_children = element_children($format['locality_block']);
$first_child = reset($element_children);
unset($format['locality_block'][$first_child]['#prefix']);
}
// GB-specific tweaks
if ($address['country'] == 'GB') {
// Locality
$format['locality_block']['locality'] = array_merge(
$format['locality_block']['locality'],
array(
'#title' => t('Town/City'),
'#weight' => 40,
'#prefix' => '',
'#tag' => 'div',
)
);
// Administrative
$format['locality_block']['administrative_area'] = array_merge(
$format['locality_block']['administrative_area'],
array(
'#title' => t('County'),
'#required' => FALSE,
'#weight' => 50,
'#size' => 30,
'#prefix' => '',
'#tag' => 'div',
)
);
// Postal code
$format['locality_block']['postal_code'] = array_merge(
$format['locality_block']['postal_code'],
array(
'#title' => t('Postcode'),
'#weight' => 60,
'#prefix' => '',
'#tag' => 'div',
)
);
}
if ($context['mode'] == 'form') {
// Provide a wrapper ID for AJAX replacement based on country selection.
if (!isset($format['#wrapper_id'])) {
$format['#wrapper_id'] = drupal_html_id('addressfield-wrapper');
$format['#prefix'] = '<div id="' . $format['#wrapper_id'] . '">';
$format['#suffix'] = '</div>';
}
// Form mode, move the country selector to the top of the form.
$format['country']['#weight'] = -10;
// Limit it to the countries supported by the widget.
if (isset($context['field'])) {
$format['country']['#options'] = _addressfield_country_options_list($context['field'], $context['instance']);
}
// AJAX enable it.
$format['country']['#ajax'] = array(
'callback' => 'addressfield_standard_widget_refresh',
'wrapper' => $format['#wrapper_id'],
'method' => 'replace',
);
$format['country']['#element_validate'] = array('addressfield_standard_country_validate');
// Don't validate any element when the country is changed.
$format['country']['#limit_validation_errors'] = array();
if (isset($context['delta']) && $context['delta'] > 0) {
// On subsequent elements of a field, we make the country field non
// required and add a ' - None - ' option to it, so as to allow the
// user to remove the address by clearing the country field.
$format['country']['#required'] = FALSE;
$format['country']['#empty_value'] = '';
}
}
}

View File

@@ -0,0 +1,39 @@
<?php
/**
* @file
* Generates a first name + last name format.
*/
$plugin = array(
'title' => t('Name (First name, Last name)'),
'format callback' => 'addressfield_format_name_full_generate',
'type' => 'name',
'weight' => 0,
);
/**
* Format callback.
*
* @see CALLBACK_addressfield_format_callback()
*/
function addressfield_format_name_full_generate(&$format, $address) {
$format['name_block'] = array(
'#type' => 'addressfield_container',
'#attributes' => array('class' => array('addressfield-container-inline', 'name-block')),
'#weight' => -100,
);
$format['name_block']['first_name'] = array(
'#title' => t('First name'),
'#size' => 30,
'#required' => TRUE,
'#attributes' => array('class' => array('first-name')),
);
$format['name_block']['last_name'] = array(
'#title' => t('Last name'),
'#size' => 30,
'#required' => TRUE,
'#prefix' => ' ',
'#attributes' => array('class' => array('last-name')),
);
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* @file
* Generates a first name + last name format.
*/
$plugin = array(
'title' => t('Name (single line)'),
'format callback' => 'addressfield_format_name_oneline_generate',
'type' => 'name',
'weight' => 0,
);
/**
* Format callback.
*
* @see CALLBACK_addressfield_format_callback()
*/
function addressfield_format_name_oneline_generate(&$format, $address) {
$format['name_block'] = array(
'#type' => 'addressfield_container',
'#attributes' => array('class' => array('addressfield-container-inline', 'name-block')),
'#weight' => -100,
);
$format['name_block']['name_line'] = array(
'#title' => t('Full name'),
'#tag' => 'div',
'#attributes' => array('class' => array('name-block')),
'#size' => 30,
'#required' => TRUE,
);
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* @file
* Generates a first name + last name format.
*/
$plugin = array(
'title' => t('Organisation (single line)'),
'format callback' => 'addressfield_format_organisation_generate',
'type' => 'organisation',
'weight' => -10,
);
/**
* Format callback.
*
* @see CALLBACK_addressfield_format_callback()
*/
function addressfield_format_organisation_generate(&$format, $address) {
$format['organisation_block'] = array(
'#type' => 'addressfield_container',
'#attributes' => array('class' => array('addressfield-container-inline', 'name-block')),
'#weight' => -50,
);
$format['organisation_block']['organisation_name'] = array(
'#title' => t('Company'),
'#size' => 30,
'#attributes' => array('class' => array('organisation-name')),
);
}

View File

@@ -0,0 +1,26 @@
<?php
/**
* Implements hook_field_views_data().
*/
function addressfield_field_views_data($field) {
$data = field_views_field_default_views_data($field);
// Add a handler for countries.
foreach ($field['storage']['details']['sql'] as $type => $tables) {
foreach ($tables as $table_name => $columns) {
if (!isset($columns['country'])) {
continue;
}
$column_real_name = $columns['country'];
if (!isset($data[$table_name][$column_real_name]['filter'])) {
continue;
}
$data[$table_name][$column_real_name]['filter']['handler'] = 'addressfield_views_handler_filter_country';
}
}
return $data;
}

View File

@@ -0,0 +1,9 @@
<?php
class addressfield_views_handler_filter_country extends views_handler_filter_in_operator {
function get_value_options() {
$this->value_title = t('Country');
$field = field_info_field($this->definition['field_name']);
$this->value_options = _addressfield_country_options_list($field);
}
}

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,108 @@
Admin 2.x
=========
The admin module provides UI improvements to the standard Drupal admin interface. The 2.x branch focuses on the following goals:
1. Sustainability - avoid excessive overrides of code, markup, and
interface strings to ensure the module keeps the workload overhead
on the maintainers and community to a minimum.
2. Pluggable/extensible architecture - ensure that admin serves as a
starting point for other modules in contrib to implement admin
interfaces.
3. Expose Drupal's strengths and downplay its weaknesses where possible.
An honest approach to the underlying framework and architecture
of Drupal will be less confusing to the user down the road.
Admin is not an original work - many of its decisions have had direct
influences from other work in the community:
- [Administration menu](http://drupal.org/project/admin_menu)
Daniel Kudwien (sun)
- [Navigate](http://drupal.org/project/navigate)
Chris Shattuck (chrisshattuck)
- [d7ux](http://www.d7ux.org)
Mark Boulton & Leisa Reichelt
Installation
============
1. Install & enable the module.
2. Admin makes a permission available that allows only properly
permissioned users to make use of the admin toolbar. Users with the
'use admin toolbar' permission will be able to use the toolbar.
3. You can configure the layout, position, and enabled tools for the
admin toolbar on `admin/config/user-interface/admin`, or by navigating
to `Administration > Configuration > User interface > Administration tools`
Implementing your own Admin "plugins"
=====================================
Admin's "plugins" are simply Drupal blocks. In order to expose one of your
module's blocks as one suitable for use in the admin toolbar you can set the `admin` key in your `hook_block()` to `TRUE`. Note that users can add any blocks to the admin toolbar if they wish at `admin/settings/admin`, though not all will work well in the context of the admin toolbar.
/**
* Implementation of hook_block().
*/
function my_module_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) {
case 'list':
$blocks = array();
$blocks['example'] = array(
'info' => t('Example block'),
'admin' => TRUE
);
return $blocks;
}
}
Theming your block and other tips
=================================
Your block should provide general rules for either of the admin toolbar
layouts (horizontal or vertical). You can specify CSS rules using the
following selectors:
#admin-toolbar.horizontal {}
#admin-toolbar.vertical {}
Admin provides fairly decent defaults for the following Drupal core
theme functions:
- `theme('item_list')`
- menu output (e.g. `menu_tree_output()`).
- most form elements (with the exception of fieldsets)
- admin panes (see below)
Admin provides an additional FormAPI element type `admin_panes`. Admin
panes allow you to fit multiple elements of content into a togglable
interface. The panes will automatically adjust to the layout to the toolbar
and display as either vertical tabs (horizontal layout) or accordian boxes
(vertical layout).
Here is an example of using admin panes in a form API array:
$form['panes'] = array(
'#tree' => FALSE,
'#type' => 'admin_panes',
'foo' => array(
'#title' => t('Pane 1'),
...
),
'bar' => array(
'#title' => t('Pane 2'),
...
),
);
Note that each child element must have a #title attribute to be labeled
properly.
Contributors
============
- yhahn (Young Hahn)
- ajashton (AJ Ashton)

View File

@@ -0,0 +1,204 @@
<?php
/**
* System settings form for admin toolbar.
*/
function admin_settings_form($form, &$form_state) {
$form['admin_toolbar'] = array(
'#tree' => TRUE,
'#theme' => 'admin_settings_form',
);
$form['admin_toolbar']['layout'] = array(
'#type' => 'select',
'#title' => t('Layout'),
'#description' => t('Choose a layout for the admin toolbar. Vertical works well with large, wide screens. Horizontal works well on screens with limited real estate.'),
'#options' => array(
'horizontal' => t('Horizontal'),
'vertical' => t('Vertical'),
),
'#default_value' => admin_get_settings('layout'),
);
$form['admin_toolbar']['position'] = array(
'#type' => 'select',
'#title' => t('Position'),
'#description' => t('Choose a position for the admin toolbar that will not collide with other elements in your current theme.'),
'#options' => array(
'ne' => t('Top right'),
'nw' => t('Top left'),
'se' => t('Bottom right'),
'sw' => t('Bottom left'),
),
'#default_value' => admin_get_settings('position'),
);
$form['admin_toolbar']['behavior'] = array(
'#type' => 'select',
'#title' => t('State on new pages'),
'#description' => t('Choose toolbar behavior on new page loads.'),
'#options' => array(
'df' => t('Remember from previous page'),
'ah' => t('Collapsed'),
),
'#default_value' => admin_get_settings('behavior'),
);
$block_info = array();
foreach (module_implements('block_info') as $module) {
$module_blocks = module_invoke($module, 'block_info');
if ($module_blocks) {
foreach ($module_blocks as $delta => $info) {
$block_info["{$module}-{$delta}"] = $info;
}
}
}
// Store block info for use in form processing.
$form['#block_info'] = $block_info;
// Get default block options.
$options = array();
$enabled = array_filter(admin_get_settings('blocks')) + admin_get_default_blocks(TRUE);
foreach ($block_info as $bid => $info) {
if (!empty($enabled[$bid])) {
$options[$bid] = $info['info'];
}
}
asort($options);
$form['admin_toolbar']['blocks'] = array(
'#type' => 'checkboxes',
'#options' => $options,
'#default_value' => drupal_map_assoc(array_keys(array_filter(admin_get_settings('blocks')))),
);
// Grab an array of human-readable module names. It hurts that we need to do this.
$result = db_query("SELECT name,type,info FROM {system} WHERE type = :type AND status = :status", array(':type' => 'module', ':status' => 1));
$modules = array();
while ($row = $result->fetchObject()) {
$info = unserialize($row->info);
$modules[$row->name] = isset($info['name']) ? $info['name'] : $row->name;
}
$custom_options = array();
foreach (array_diff_key($block_info, $options) as $bid => $info) {
$block_parts = (explode('-', $bid));
$module = array_shift($block_parts);
$module = isset($modules[$module]) ? $modules[$module] : $module;
$custom_options[$module][$bid] = $info['info'];
}
$custom_options = $custom_options + array(-1 => '<' . t('Choose a block') . '>');
ksort($custom_options);
$form['admin_toolbar']['custom'] = array(
'#type' => 'select',
'#options' => $custom_options,
'#default_value' => -1,
'#element_validate' => array('admin_settings_form_custom_validate'),
'#description' => t('Enable other blocks for use in the admin toolbar.'),
);
$form['admin_toolbar']['add'] = array(
'#type' => 'submit',
'#value' => t('Add block'),
);
$form = system_settings_form($form);
// Add a submit handler for expanding block information.
array_unshift($form['#submit'], 'admin_settings_form_submit');
return $form;
}
/**
* Submit handler for admin_settings_form().
*
* Retrieves cache type for each block and saves that instead of `1` for each
* enabled block.
*/
function admin_settings_form_submit($form, &$form_state) {
if (isset($form['#block_info'], $form_state['values']['admin_toolbar']['blocks'])) {
$blocks = array();
foreach (array_keys(array_filter($form_state['values']['admin_toolbar']['blocks'])) as $bid) {
$blocks[$bid] = isset($form['#block_info'][$bid]['cache']) ? $form['#block_info'][$bid]['cache'] : DRUPAL_NO_CACHE;
}
$form_state['values']['admin_toolbar']['blocks'] = $blocks;
}
}
/**
* Element validator for custom block adder. Moves values within
* $form_state['values'] and prevents additional variables from being saved.
*/
function admin_settings_form_custom_validate($element, &$form_state) {
if ($form_state['values']['admin_toolbar']['custom'] != -1) {
$bid = $form_state['values']['admin_toolbar']['custom'];
$form_state['values']['admin_toolbar']['blocks'][$bid] = $bid;
}
unset($form_state['values']['admin_toolbar']['custom']);
unset($form_state['values']['admin_toolbar']['add']);
}
/**
* Theme function for the admin settings form.
*/
function theme_admin_settings_form($variables) {
$form = $variables['element'];
$rows = array();
// Admin blocks
$header = array(array(
'data' => t('Administrative blocks'),
'colspan' => 2,
));
foreach (array_keys(admin_get_default_blocks(TRUE)) as $block) {
$rows[] = array(array(
'data' => drupal_render($form['blocks'][$block]),
'colspan' => 2,
));
}
// "Custom" blocks
$rows[] = array(array(
'data' => t('Other blocks'),
'colspan' => 2,
'header' => TRUE,
));
foreach (element_children($form['blocks']) as $block) {
if (empty($form['blocks'][$block]['#printed'])) {
$rows[] = array(array(
'data' => drupal_render($form['blocks'][$block]),
'colspan' => 2,
));
}
}
$rows[] = array(drupal_render($form['custom']), drupal_render($form['add']));
$form['blocks']['#children'] = theme('table', array('header' => $header, 'rows' => $rows));
return drupal_render_children($form);
}
/**
* Rebuild form.
*/
function admin_settings_rebuild($form_state) {
$form = array();
$form['rebuild'] = array(
'#type' => 'fieldset',
'#title' => t('Wipe and rebuild'),
'#description' => t('If the administrative menu is not working properly, you may need to wipe and rebuild it from scratch. <strong>This option will reset any customizations made to your administrative menu items.</strong>'),
);
$form['rebuild']['submit'] = array(
'#type' => 'submit',
'#value' => t('Rebuild'),
'#submit' => array('admin_settings_rebuild_submit'),
);
return $form;
}
/**
* Wipe and rebuild the admin menu.
*/
function admin_settings_rebuild_submit($form, &$form_state) {
db_delete('menu_links')
->condition('menu_name', 'management')
->execute();
menu_rebuild();
if (module_exists('block')) {
cache_clear_all('admin', 'cache_block', TRUE);
}
}

View File

@@ -0,0 +1,21 @@
name = Admin
description = UI helpers for Drupal admins and managers.
package = Administration
core = 7.x
configure = admin/config/user-interface/admin
files[] = admin.admin.inc
files[] = admin.install
files[] = admin.module
files[] = includes/admin.devel.inc
files[] = includes/admin.theme.inc
files[] = theme/admin-panes.tpl.php
files[] = theme/admin-toolbar.tpl.php
files[] = theme/theme.inc
; Information added by drupal.org packaging script on 2011-09-30
version = "7.x-2.x-dev"
core = "7.x"
project = "admin"
datestamp = "1317340920"

View File

@@ -0,0 +1,25 @@
<?php
/**
* @file
* Install, update and uninstall functions for the admin module.
*/
/**
* Implements hook_uninstall().
*/
function admin_uninstall() {
variable_del('admin_toolbar');
}
/**
* Implements hook_enable().
*/
function admin_enable() {
// Weight admin to come after other modules -- in particular, admin_theme().
db_update('system')
->fields(array('weight' => 1))
->condition('name', 'admin')
->condition('type', 'module')
->execute();
}

View File

@@ -0,0 +1,450 @@
<?php
/**
* Implements hook_block_info().
*/
function admin_block_info() {
$blocks = array();
$blocks['create'] = array(
'info' => t('Create content'),
'cache' => DRUPAL_NO_CACHE,
'admin' => TRUE,
);
$blocks['theme'] = array(
'info' => t('Theme switcher'),
'cache' => DRUPAL_CACHE_PER_ROLE,
'admin' => TRUE,
);
$blocks['account'] = array(
'info' => t('My Account'),
'cache' => DRUPAL_NO_CACHE,
'admin' => TRUE,
);
if (module_exists('menu')) {
$blocks['menu'] = array(
'info' => t('Administration menu'),
'cache' => DRUPAL_CACHE_PER_ROLE,
'admin' => TRUE,
);
}
if (module_exists('devel')) {
$blocks['devel'] = array(
'info' => t('Devel'),
'cache' => DRUPAL_NO_CACHE,
'admin' => TRUE,
);
}
return $blocks;
}
/**
* Implements hook_block_view().
*/
function admin_block_view($delta) {
switch ($delta) {
case 'create':
$item = menu_get_item('node/add');
$links = system_admin_menu_block($item);
if (!empty($links)) {
$menu = array();
foreach ($links as $key => $link) {
$menu[$key] = array(
'link' => $link + array('in_active_trail' => FALSE),
'below' => FALSE,
);
}
return array(
'subject' => !empty($item['title']) ? $item['title'] : t('Create content'),
'content' => menu_tree_output($menu),
);
}
break;
case 'theme':
if (user_access('select different theme')) {
module_load_include('inc', 'admin', 'includes/admin.theme');
return admin_block_theme();
}
return NULL;
case 'account':
return admin_account_block();
case 'menu':
$item = menu_get_item('admin');
if ($item && $item['access']) {
$tree = menu_tree_all_data('management');
foreach ($tree as $key => $branch) {
if ($branch['link']['link_path'] !== 'admin') {
unset($tree[$key]);
}
}
return array(
'subject' => !empty($item['title']) ? $item['title'] : t('Administer'),
'content' => menu_tree_output($tree),
);
}
break;
case 'devel':
module_load_include('inc', 'admin', 'includes/admin.devel');
return admin_block_devel();
}
}
/**
* Implements hook_element_info().
*/
function admin_element_info() {
return array(
'admin_panes' => array(
'#value' => '',
'#theme_wrappers' => array('admin_panes'),
),
);
}
/**
* Implements hook_menu().
*/
function admin_menu() {
$items = array();
$items['admin/config/user-interface/admin'] =
$items['admin/config/user-interface/admin/settings'] = array(
'title' => 'Administration tools',
'description' => 'Settings for site administration tools.',
'page callback' => 'drupal_get_form',
'page arguments' => array('admin_settings_form'),
'access callback' => 'user_access',
'access arguments' => array('administer site configuration'),
'type' => MENU_NORMAL_ITEM,
'file' => 'admin.admin.inc',
'module' => 'admin',
);
$items['admin/config/user-interface/admin/settings']['title'] = 'Settings';
$items['admin/config/user-interface/admin/settings']['type'] = MENU_DEFAULT_LOCAL_TASK;
$items['admin/config/user-interface/admin/rebuild'] = array(
'title' => 'Rebuild',
'description' => 'Wipe and rebuild the administrative menu.',
'page callback' => 'drupal_get_form',
'page arguments' => array('admin_settings_rebuild'),
'access callback' => 'user_access',
'access arguments' => array('administer site configuration'),
'type' => MENU_LOCAL_TASK,
'file' => 'admin.admin.inc',
'module' => 'admin',
'weight' => 10,
);
return $items;
}
/**
* Implements hook_menu_alter().
*/
function admin_menu_alter(&$items) {
foreach ($items as $path => $item) {
// Smarter access callback for poorly checked landing pages
if (!empty($item['access arguments']) && !empty($item['page callback']) && $item['access arguments'] === array('access administration pages') && in_array($item['page callback'], array('system_admin_menu_block_page', 'system_settings_overview'))) {
$items[$path]['access callback'] = 'admin_landing_page_access';
$items[$path]['access arguments'] = array($path);
}
}
}
/**
* Menu access callback for admin landing pages.
*
* For a given landing page, grant access if the current user has access
* to any of its child menu items.
*/
function admin_landing_page_access($path) {
static $paths;
if (!isset($paths[$path])) {
$paths[$path] = FALSE;
// Retrieve menu item but without menu_get_item()
$item = db_select('menu_links')
->fields('menu_links')
->condition('module', 'system')
->condition('router_path', $path)
->execute()
->fetchAssoc();
if ($item) {
$query = db_select('menu_links', 'ml');
$query->leftJoin('menu_router', 'm', 'm.path = ml.router_path');
$query->fields('ml');
$query->fields('m', array_diff(drupal_schema_fields_sql('menu_router'), array('weight')));
$query->condition('ml.plid', $item['mlid']);
$result = $query->execute();
while ($item = $result->fetchAssoc()) {
_menu_link_translate($item);
if ($item['access']) {
$paths[$path] = TRUE;
break;
}
}
}
}
return $paths[$path];
}
/**
* Implements hook_permission().
*/
function admin_permission() {
return array(
'use admin toolbar' => array(
'title' => t('use admin toolbar'),
'description' => t('Use the admin toolbar'),
),
'select different theme' => array(
'title' => t('select different theme'),
'description' => t("Select different theme for the current user's session."),
),
);
}
/**
* Implements hook_theme().
*/
function admin_theme($cache, $type, $theme, $path) {
$path = drupal_get_path('module', 'admin');
$items['admin_tab'] = array(
'variables' => array(
'tab' => array(),
'class' => '',
),
'path' => $path . '/theme',
'file' => 'theme.inc',
);
$items['admin_toolbar'] = array(
'variables' => array(
'blocks' => array(),
'position' => 'ne',
'layout' => 'horizontal',
'behavior' => 'df',
),
'template' => 'admin-toolbar',
'path' => $path . '/theme',
'file' => 'theme.inc',
);
$items['admin_drilldown_menu_tree_output'] = array(
'variables' => array('menu' => array()),
'path' => $path . '/theme',
'file' => 'theme.inc',
);
$items['admin_drilldown_menu_tree'] = array(
'variables' => array('menu' => array()),
'path' => $path . '/theme',
'file' => 'theme.inc',
);
$items['admin_drilldown_menu_item'] = array(
'variables' => array(
'link' => NULL,
'has_children' => NULL,
'menu' => '',
'in_active_trail' => FALSE,
'extra_class' => NULL,
),
'path' => $path . '/theme',
'file' => 'theme.inc',
);
$items['admin_drilldown_menu_item_link'] = array(
'variables' => array('item' => array()),
'path' => $path . '/theme',
'file' => 'theme.inc',
);
$items['admin_panes'] = array(
'render element' => 'element',
'template' => 'admin-panes',
'path' => $path . '/theme',
'file' => 'theme.inc',
);
$items['admin_settings_form'] = array(
'render element' => 'element',
'path' => $path,
'file' => 'admin.admin.inc',
);
return $items;
}
/**
* Get variable settings or fallback to defaults.
*/
function admin_get_settings($key = NULL) {
static $settings;
if (!isset($settings)) {
// Try to gather what information we can from the cookie.
// Note that this information should not be trusted in any
// way for affecting *anything* but trivial changes to the site.
$cookie = array();
if (isset($_REQUEST['DrupalAdminToolbar'])) {
parse_str($_REQUEST['DrupalAdminToolbar'], $cookie);
}
$settings = variable_get('admin_toolbar', array()) + array(
'layout' => 'vertical',
'position' => 'nw',
'behavior' => 'df',
'blocks' => admin_get_default_blocks(),
'expanded' => isset($cookie['expanded']) ? check_plain($cookie['expanded']) : 0,
'active_tab' => isset($cookie['activeTab']) ? check_plain($cookie['activeTab']) : 0,
);
// Ensure that if behavior is set to autohide the toolbar is collapsed.
if ($settings['behavior'] === 'ah') {
$settings['expanded'] = 0;
}
}
if (isset($key)) {
return isset($settings[$key]) ? $settings[$key] : FALSE;
}
return $settings;
}
/**
* Get all blocks that have declared themselves visible in the admin toolbar by default.
*/
function admin_get_default_blocks($reset = FALSE) {
static $defaults;
if (!isset($defaults) || $reset) {
$cache = cache_get('admin_default_blocks');
if ($cache && !$reset) {
$defaults = $cache->data;
}
else {
$defaults = array();
foreach (module_implements('block_info') as $module) {
$module_blocks = module_invoke($module, 'block_info');
if ($module_blocks) {
foreach ($module_blocks as $delta => $info) {
if (isset($info['admin'])) {
$defaults["{$module}-{$delta}"] = isset($info['cache']) ? $info['cache'] : DRUPAL_NO_CACHE;
}
}
}
}
cache_set('admin_default_blocks', $defaults);
}
}
return $defaults;
}
/**
* Get blocks enabled for the admin toolbar.
*/
function admin_get_admin_blocks() {
$blocks = array();
if (user_access('use admin toolbar') && $enabled_blocks = admin_get_settings('blocks')) {
module_load_include('module', 'block', 'block');
foreach ($enabled_blocks as $bid => $cache) {
$block = NULL;
$split = explode('-', $bid, 2);
if (count($split) === 2) {
list($module, $delta) = $split;
$block = new stdClass();
$block->module = $module;
$block->delta = $delta;
$block->bid = $bid;
$block->title = NULL;
$block->cache = is_numeric($cache) ? $cache : DRUPAL_NO_CACHE;
$block->region = 'admin_toolbar'; // Fake the block region.
$blocks[$bid] = $block;
}
}
$blocks = _block_render_blocks($blocks);
}
return $blocks;
}
/**
* Preprocessor that runs *before* template_preprocess_page().
*/
function admin_page_build(&$page) {
if (user_access('use admin toolbar') && $trail = menu_get_active_trail()) {
do {
$last = array_pop($trail);
} while (count($trail) && !($last['type'] & MENU_VISIBLE_IN_TREE));
if ($last) {
drupal_add_js(array('activePath' => url($last['href'])), array('type' => 'setting', 'scope' => JS_DEFAULT));
}
}
if (!admin_suppress(FALSE) && $blocks = admin_get_admin_blocks()) {
$path = drupal_get_path('module', 'admin');
drupal_add_js("misc/jquery.cookie.js");
drupal_add_js("{$path}/includes/jquery.drilldown.js");
drupal_add_js("{$path}/includes/admin.toolbar.js");
drupal_add_js("{$path}/includes/admin.menu.js");
drupal_add_css("{$path}/includes/admin.toolbar.base.css");
drupal_add_css("{$path}/includes/admin.toolbar.css");
drupal_add_css("{$path}/includes/admin.menu.css");
$position = admin_get_settings('position');
$layout = admin_get_settings('layout');
$behavior = admin_get_settings('behavior');
$class = admin_get_settings('expanded') ? 'admin-expanded' : '';
$page['page_bottom']['admin_toolbar'] = array(
'#type' => 'markup',
'#markup' => theme('admin_toolbar', array('blocks' => $blocks, 'position' => $position, 'layout' => $layout, 'behavior' => $behavior)),
);
}
}
/**
* Implements hook_preprocess_html().
*/
function admin_preprocess_html(&$vars) {
if (!admin_suppress(FALSE) && $blocks = admin_get_admin_blocks()) {
$position = admin_get_settings('position');
$layout = admin_get_settings('layout');
$behavior = admin_get_settings('behavior');
$class = admin_get_settings('expanded') ? 'admin-expanded' : '';
$vars['classes_array'][] = " admin-{$position} admin-{$layout} admin-{$behavior} {$class} ";
}
}
/**
* Implements hook_suppress().
*
* Suppress display of administration toolbar.
*
* This function should be called from within another module's page callback
* preferably using module_invoke_all('suppress') when the menu should not be
* displayed. This is useful for modules that implement popup pages or other
* special pages where the menu would be distracting or break the layout.
*
* @param $set
* Defaults to TRUE. If called before hook_footer(), the menu will not be
* displayed. If FALSE is passed, the suppression state is returned.
*/
function admin_suppress($set = TRUE) {
static $suppress = FALSE;
if (!empty($set) && $suppress === FALSE) {
$suppress = TRUE;
}
return $suppress;
}
/**
* My Account block.
*/
function admin_account_block() {
$block = array(
'subject' => t('My Account'),
'content' => '',
);
global $user;
if ($user->uid > 0) {
$menu = array();
$menu[] = array(
'data' => l(t('View my account'), 'user/' . $user->uid),
'class' => array('leaf'),
);
$menu[] = array(
'data' => l(t('Edit my account'), 'user/' . $user->uid . '/edit'),
'class' => array('leaf'),
);
$menu[] = array(
'data' => l(t('Logout'), 'user/logout'),
'class' => array('leaf'),
);
$block['content'] = theme('item_list', array('items' => $menu, 'attributes' => array('class' => array('menu'))));
}
return $block;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 934 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 612 B

View File

@@ -0,0 +1,192 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="40"
height="400"
id="svg2657"
sodipodi:version="0.32"
inkscape:version="0.46"
version="1.0"
sodipodi:docname="bleeds.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape">
<defs
id="defs2659">
<linearGradient
inkscape:collect="always"
id="linearGradient3410">
<stop
style="stop-color:#ffffff;stop-opacity:1"
offset="0"
id="stop3412" />
<stop
style="stop-color:#dddddd;stop-opacity:1"
offset="1"
id="stop3414" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3410"
id="linearGradient2637"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1,0,0,0.75,240,-240)"
x1="0"
y1="360"
x2="0"
y2="400" />
<linearGradient
id="linearGradient3418"
inkscape:collect="always">
<stop
id="stop3420"
offset="0"
style="stop-color:#444444;stop-opacity:1" />
<stop
id="stop3422"
offset="1"
style="stop-color:#222222;stop-opacity:1" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3418"
id="linearGradient3416"
gradientUnits="userSpaceOnUse"
x1="0"
y1="360"
x2="0"
y2="400"
gradientTransform="matrix(1,0,0,0.75,240,-270)" />
<linearGradient
inkscape:collect="always"
id="linearGradient3397">
<stop
style="stop-color:#222222;stop-opacity:1"
offset="0"
id="stop3400" />
<stop
style="stop-color:#111111;stop-opacity:1"
offset="1"
id="stop3402" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3397"
id="linearGradient3407"
x1="0"
y1="360"
x2="0"
y2="400"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1,0,0,0.75,240,100)" />
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 526.18109 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="744.09448 : 526.18109 : 1"
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
id="perspective2665" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
gridtolerance="10000"
guidetolerance="10"
objecttolerance="10"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1"
inkscape:cx="-33.318742"
inkscape:cy="141.59317"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false">
<inkscape:grid
type="xygrid"
id="grid2685"
visible="true"
enabled="true" />
</sodipodi:namedview>
<metadata
id="metadata2662">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<g
style="display:inline"
id="g3449"
inkscape:export-filename="/home/yh/Private/www/d6/sites/all/modules/admin/images/bleeds.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
transform="matrix(0.1666667,0,0,1,-40.000016,0)">
<rect
inkscape:export-ydpi="90"
inkscape:export-xdpi="90"
inkscape:export-filename="/home/yh/d6/sites/all/modules/admin/toolbar/bleeds.png"
y="370"
x="240"
height="30"
width="240"
id="rect2624"
style="opacity:1;fill:url(#linearGradient3407);fill-opacity:1;stroke:none;stroke-width:1.7854991;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<rect
inkscape:export-ydpi="90"
inkscape:export-xdpi="90"
inkscape:export-filename="/home/yh/d6/sites/all/modules/admin/toolbar/bleeds.png"
style="opacity:1;fill:#222222;fill-opacity:1;stroke:none;stroke-width:1.7854991;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect3409"
width="240"
height="1"
x="240"
y="399" />
<rect
inkscape:export-ydpi="90"
inkscape:export-xdpi="90"
inkscape:export-filename="/home/yh/d6/sites/all/modules/admin/toolbar/bleeds.png"
style="opacity:1;fill:url(#linearGradient3416);fill-opacity:1;stroke:none;stroke-width:1.7854991;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect3413"
width="240"
height="30"
x="240"
y="0" />
<rect
y="30"
x="240"
height="30"
width="240"
id="rect2635"
style="opacity:1;fill:url(#linearGradient2637);fill-opacity:1;stroke:none;stroke-width:1.7854991;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
inkscape:export-filename="/home/yh/d6/sites/all/modules/admin/toolbar/bleeds.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
<rect
y="-6.8212105e-14"
x="240"
height="1"
width="240"
id="rect2675"
style="opacity:1;fill:#555555;fill-opacity:1;stroke:none;stroke-width:1.7854991;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
inkscape:export-filename="/home/yh/d6/sites/all/modules/admin/toolbar/bleeds.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 55 KiB

View File

@@ -0,0 +1,54 @@
div.dev-query,
div.dev-timer,
div.dev-memory-usage,
div.devel-querylog { display:none; }
.devel-hide { display:none !important; }
/**
* Admin devel block ==================================================
*/
#block-admin-devel div.dev-info strong {
color:#fff;
font-weight:bold;
}
#block-admin-devel input.dev-querylog-show,
#block-admin-devel input.dev-querylog-hide { margin-top:5px; }
#block-admin-devel input.dev-querylog-hide { display:none; }
#block-admin-devel .marker {
color:#f40;
font-weight:bold;
}
/* Override menu styling */
#admin-toolbar #block-admin-devel { padding-bottom:10px; }
/**
* Query list =========================================================
*/
div.devel-querylog {
border-bottom:1px solid #181818;
background:#080808;
color:#999;
font-size:11px;
line-height:15px;
position:relative;
display:none;
}
div.devel-querylog-header {
border:0px;
font-weight:bold;
}
div.devel-querylog .marker {
color:#f40;
font-weight: bold;
}
div.devel-querylog a { color:#fff; }
div.devel-querylog-even { background:#0c0c0c; }
div.devel-querylog-odd { background:#101010; }

View File

@@ -0,0 +1,79 @@
<?php
/**
* Devel admin block.
*/
function admin_block_devel() {
if (module_exists('devel') && (user_access('access devel information') || user_access('switch users') || user_access('execute php code'))) {
drupal_add_css(drupal_get_path('module', 'admin') . '/includes/admin.devel.css');
drupal_add_js(drupal_get_path('module', 'admin') . '/includes/admin.devel.js');
return array('subject' => t('Devel'), 'content' => drupal_get_form('admin_block_devel_form'));
}
}
/**
* Devel admin block form.
*/
function admin_block_devel_form($form, $form_state) {
$panes = array();
if (user_access('access devel information')) {
$panes['performance'] = admin_devel_performance_form();
}
if (user_access('switch users')) {
$panes['switch_user'] = array(
'#title' => t('Switch user'),
'list' => array('#markup' => theme('links', array(
'links' => devel_switch_user_list(),
'attributes' => array('class' => 'links clearfix'),
))),
'user' => devel_switch_user_form(),
);
$panes['switch_user']['user']['#submit'] = array('devel_switch_user_form_submit');
}
if (user_access('execute php code')) {
$panes['execute'] = devel_execute_form() + array('#title' => t('Execute PHP'));
$panes['execute']['op']['#submit'] = array('devel_execute_form_submit');
}
if (user_access('access devel information')) {
$panes['menu'] = menu_tree_output(menu_tree_all_data('devel'));
$panes['menu']['#title'] = t('Other tools');
}
if (!empty($panes)) {
$panes['#type'] = 'admin_panes';
return array('panes' => $panes);
}
return array();
}
/**
* Performance "form". Actually renders placeholders that are populated post-exit via javascript.
*/
function admin_devel_performance_form() {
$items = array();
if (variable_get('dev_timer', 0) && !variable_get('devel_query_display', FALSE)) {
$items[] = array(
'data' => "<div class='dev-info'></div>",
'class' => array('dev-timer'),
);
}
if (variable_get('dev_mem', FALSE) && function_exists('memory_get_usage')) {
$items[] = array(
'data' => "<div class='dev-info'></div>",
'class' => array('dev-memory-usage'),
);
}
if (variable_get('devel_query_display', FALSE)) {
$show = "<input type='button' class='form-submit dev-querylog-show' value='" . t('Show querylog') . "'/>";
$hide = "<input type='button' class='form-submit dev-querylog-hide' value='" . t('Hide querylog') . "'/>";
$items[] = array(
'data' => "<div class='dev-info'></div>{$show}{$hide}",
'class' => array('dev-query'),
);
}
if ($items) {
return array(
'#title' => t('Performance'),
'#markup' => theme('item_list', array('items' => $items)),
);
}
}

View File

@@ -0,0 +1,36 @@
(function($) {
Drupal.behaviors.adminDevel = {};
Drupal.behaviors.adminDevel.attach = function(context) {
$('#block-admin-devel:not(.admin-processed)').each(function() {
var devel = $(this);
devel.addClass('admin-processed');
// Pull logged values from footer output into the block.
$('li', devel).each(function() {
var key = $(this).attr('class').split(' ')[0];
if (key && $('body > .'+key).size() > 0) {
var value = $('body > .'+key).html();
$('div.dev-info', this).html(value);
}
});
// Query list show handler.
$('input.dev-querylog-show', devel).click(function() {
$(this).hide().siblings('input.dev-querylog-hide').show();
$('body > *:not(#admin-toolbar, .region-page-bottom, .devel-querylog)').addClass('devel-hide');
$('body > .devel-querylog').show();
return false;
});
// Query list hide handler.
$('input.dev-querylog-hide').click(function() {
$(this).hide().siblings('input.dev-querylog-show').show();
$('body > *:not(#admin-toolbar, .region-page-bottom, .devel-querylog)').removeClass('devel-hide');
$('body > .devel-querylog').hide();
return false;
});
});
};
})(jQuery);

View File

@@ -0,0 +1,38 @@
/**
* Breadcrumb
*/
div#admin-toolbar div.admin-tab.admin-menu a {
background-image:url(../images/sprite-rtl.png);
background-position:0% -70px;
padding-left:20px;
padding-right:0px;
}
/**
* Tooltips
*/
div#admin-toolbar.horizontal span.menu-description {
left:auto;
right:60%;
padding-left:0;
padding-right:20px;
}
/**
* Menu
*/
#admin-toolbar ul.drilldown-active-menu li {
background-image:url(../images/sprite-rtl.png);
background-position:100% -85px;
}
#admin-toolbar ul.drilldown-active-menu li.leaf { background-position:100% -110px; }
#admin-toolbar ul.menu li a {
margin-left:0;
margin-right:25px;
}
#admin-toolbar.horizontal ul.drilldown-active-menu { float:right; }
#admin-toolbar.horizontal ul.drilldown-active-menu li { float:right; }

View File

@@ -0,0 +1,127 @@
/**
* Breadcrumb
*/
div#admin-toolbar div.admin-tab.admin-menu #admin-tab-admin-menu {
display:block;
height:20px;
overflow:hidden;
position:relative;
}
div#admin-toolbar div.admin-tab a {
background:url(../images/sprite.png) 100% -70px no-repeat;
padding-right:20px;
}
div#admin-toolbar div.admin-tab a:last-child {
background:transparent;
padding:0px;
}
/**
* Tooltips
*/
div#admin-toolbar.vertical div.admin-toolbar-menu-hover div.block-content { bottom:100px; }
div#admin-toolbar span.menu-description { display:none; }
div#admin-toolbar a.menu-hover span.menu-description {
color:#ccc;
display:block;
}
div#admin-toolbar.vertical a.menu-hover span.menu-description {
position:absolute;
overflow:hidden;
left:0px;
right:0px;
bottom:0px;
padding:0px 20px;
height:90px;
}
div#admin-toolbar.horizontal a.menu-hover span.menu-description {
position:absolute;
top:0px;
left:60%;
width:35%;
padding-left:20px;
}
/**
* Menu
*/
#admin-toolbar ul.menu,
#admin-toolbar ul.menu ul,
#admin-toolbar ul.menu li,
#admin-toolbar ul.menu li a {
list-style:none;
background:transparent;
padding:0px;
margin:0px;
border:0px;
}
/* IE7 */
*:first-child+html #admin-toolbar ul.menu,
*:first-child+html #admin-toolbar ul.menu ul,
*:first-child+html #admin-toolbar ul.menu li,
*:first-child+html #admin-toolbar ul.menu li a { overflow:hidden; }
#admin-toolbar.horizontal ul.drilldown-active-menu {
float:left;
width:60%;
}
#admin-toolbar.horizontal div.admin-pane ul.drilldown-active-menu {
float:none;
width:auto;
}
#admin-toolbar.horizontal ul.drilldown-active-menu li {
float:left;
width:49.9%;
}
#admin-toolbar ul.drilldown-active-menu li { background:url(../images/sprite.png) 0% -85px no-repeat; }
#admin-toolbar ul.menu li.leaf,
#admin-toolbar ul.drilldown-active-menu li.leaf { background:url(../images/sprite.png) 0% -110px no-repeat; }
#admin-toolbar ul.menu li a {
-moz-border-radius:5px;
-webkit-border-radius:5px;
display:block;
margin-left:25px;
height:15px;
padding:5px 10px 4px;
border-bottom:1px solid #222;
white-space:nowrap;
overflow:hidden;
}
#admin-toolbar ul.menu li a span.menu-description { white-space:normal; }
/* IE7 requires height to be explicitly set. */
#admin-toolbar ul.menu li.leaf,
#admin-toolbar ul.drilldown-active-menu li { height:25px; }
#admin-toolbar ul.menu li a.active { background:#222; }
#admin-toolbar ul.menu li a:hover {
color:#000;
background:url(../images/bleeds.png) 0px -30px repeat-x;
}
/* Drilldown generic styles */
.drilldown ul.menu li { display:none !important; }
.drilldown ul.menu li a { display:none !important; }
.drilldown ul.menu li.drilldown-active-trail { display:block !important; }
.drilldown ul.drilldown-active-menu li { display:block !important; }
.drilldown ul.drilldown-active-menu li a { display:block !important; }
.drilldown ul.drilldown-active-menu li ul { display:none !important; }
.drilldown ul.drilldown-active-menu li.expanded { cursor:pointer; }
.drilldown ul.drilldown-active-menu ul.menu li a { display:none !important; }

View File

@@ -0,0 +1,65 @@
(function($) {
Drupal.behaviors.adminToolbarMenu = {};
Drupal.behaviors.adminToolbarMenu.attach = function(context) {
if (jQuery().drilldown) {
$('#admin-toolbar div.admin-block:has(ul.menu):not(.admin-toolbar-menu)')
.addClass('admin-toolbar-menu')
.each(function() {
var menu = $(this);
var trail = '#admin-toolbar div.admin-tab.' + $(this).attr('id').split('block-')[1] + ' span';
var rootTitle = $(trail).text();
if ($('a:has(span.menu-description)', menu).size() > 0) {
menu.addClass('admin-toolbar-menu-hover');
$('a:has(span.menu-description)', menu).hover(
function() {
$('<a></a>')
.attr('class', $(this).attr('class'))
.addClass('menu-hover')
.addClass('overlay-exclude')
.append($('span.menu-description', this).clone())
.appendTo(menu)
.show();
},
function() {
$(menu)
.children('a.menu-hover')
.remove();
}
);
}
// Replace the standard trail click handler with one that only
// adjusts menu if the admin tab is active. Otherwise, switch
// to that admin tab.
menu.bind('refresh.drilldown', function() {
$(trail + ' a').unbind('click').click(function() {
if ($(this).parents('div.admin-tab').is('.admin-tab-active')) {
var settings = {'activeLink': $(this).data('original'), 'trail': trail};
// If the clicked link does not reference the current
// active menu, set it to be active.
if (settings.activeLink.siblings('ul.drilldown-active-menu').size() === 0) {
menu.drilldown('setActive', settings);
return false;
}
// Otherwise, pass-through and allow the link to be clicked.
return menu.drilldown('goTo', settings);
}
$(this).parents('div.admin-tab').click();
return false;
});
});
// Init drilldown plugin.
menu.drilldown('init', {
activePath: Drupal.settings.activePath,
trail: trail,
rootTitle: rootTitle
});
});
}
};
})(jQuery);

View File

@@ -0,0 +1,38 @@
<?php
/**
* Theme switcher admin block.
*/
function admin_block_theme() {
$themes = list_themes();
if (count($themes) > 2) {
return array(
'subject' => t('Switch theme'),
'content' => drupal_get_form('admin_block_theme_form', $themes),
);
}
}
/**
* Devel admin block form.
*/
function admin_block_theme_form($form, $form_state, $themes) {
$options = array();
foreach ($themes as $theme) {
if ($theme->status) {
$options[$theme->name] = isset($theme->info['name']) ? check_plain($theme->info['name']) : $theme->name;
}
}
$form = array();
$form['theme_default'] = array(
'#type' => 'radios',
'#options' => $options,
'#default_value' => variable_get('theme_default', 'garland'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save configuration'),
);
$form['#submit'] = array('system_settings_form_submit');
return $form;
}

View File

@@ -0,0 +1,3 @@
/**
* @TODO: Update RTL support.
*/

View File

@@ -0,0 +1,35 @@
div#admin-toolbar.horizontal div.admin-tab {
float:right;
margin-left:5px;
margin-right:0;
}
div#admin-toolbar div.admin-tab-active {
-moz-border-radius:5px 0px 0px 5px;
}
/**
* Horizontal layout.
*/
#admin-toolbar.horizontal div.admin-panes {
padding-left:0;
padding-right:25%;
}
#admin-toolbar.horizontal div.admin-panes div.admin-pane-tabs {
left:auto;
right:0px;
}
#admin-toolbar.horizontal div.admin-panes div.admin-pane-tabs a {
-moz-border-radius:3px 3px 0px 0px;
-webkit-border-top-right-radius:3px;
-webkit-border-bottom-right-radius:3px;
}
#admin-toolbar.horizontal div.admin-panes div.admin-pane-tabs a.admin-pane-active {
border-width:1px 1px 1px 0px;
margin-left:-1px;
margin-right:0;
}

View File

@@ -0,0 +1,472 @@
/**
* Admin toolbar CSS resets ===========================================
*/
/* Text */
#admin-toolbar,
#admin-toolbar h1,
#admin-toolbar h2,
#admin-toolbar h3,
#admin-toolbar h4,
#admin-toolbar h5,
#admin-toolbar h6,
#admin-toolbar p,
#admin-toolbar blockquote,
#admin-toolbar pre,
#admin-toolbar a,
#admin-toolbar abbr,
#admin-toolbar acronym,
#admin-toolbar address,
#admin-toolbar big,
#admin-toolbar cite,
#admin-toolbar code,
#admin-toolbar del,
#admin-toolbar dfn,
#admin-toolbar em,
#admin-toolbar font,
#admin-toolbar img,
#admin-toolbar ins,
#admin-toolbar kbd,
#admin-toolbar q,
#admin-toolbar s,
#admin-toolbar samp,
#admin-toolbar small,
#admin-toolbar strike,
#admin-toolbar strong,
#admin-toolbar sub,
#admin-toolbar sup,
#admin-toolbar tt,
#admin-toolbar var,
#admin-toolbar b,
#admin-toolbar u,
#admin-toolbar i,
#admin-toolbar center,
/* Common classes */
#admin-toolbar .buttons,
/* Lists */
#admin-toolbar dl,
#admin-toolbar dt,
#admin-toolbar dd,
#admin-toolbar ol,
#admin-toolbar ul,
#admin-toolbar li,
/* Forms */
#admin-toolbar fieldset,
#admin-toolbar form,
#admin-toolbar input,
#admin-toolbar select,
#admin-toolbar textarea,
#admin-toolbar label,
#admin-toolbar legend,
/* Tables */
#admin-toolbar table,
#admin-toolbar caption,
#admin-toolbar tbody,
#admin-toolbar tfoot,
#admin-toolbar thead,
#admin-toolbar tr,
#admin-toolbar th,
#admin-toolbar td,
/* Drupal: system.css */
#admin-toolbar tr.even,
#admin-toolbar tr.odd,
#admin-toolbar tr.drag,
#admin-toolbar tbody,
#admin-toolbar tbody th,
#admin-toolbar thead th,
#admin-toolbar .breadcrumb,
#admin-toolbar .error,
#admin-toolbar div.error,
#admin-toolbar tr.error,
#admin-toolbar .warning,
#admin-toolbar div.warning,
#admin-toolbar tr.warning,
#admin-toolbar .ok,
#admin-toolbar div.ok,
#admin-toolbar tr.ok,
#admin-toolbar .item-list,
#admin-toolbar .item-list .icon,
#admin-toolbar .item-list .title,
#admin-toolbar .item-list ul,
#admin-toolbar .item-list ul li,
#admin-toolbar ol.task-list li.active,
#admin-toolbar .form-item,
#admin-toolbar tr.odd .form-item,
#admin-toolbar tr.even .form-item,
#admin-toolbar tr.merge-down,
#admin-toolbar tr.merge-up,
#admin-toolbar .form-item .description,
#admin-toolbar .form-item label,
#admin-toolbar .form-item label.option,
#admin-toolbar .form-checkboxes,
#admin-toolbar .form-radios,
#admin-toolbar .form-checkboxes .form-item,
#admin-toolbar .form-radios .form-item,
#admin-toolbar .marker,
#admin-toolbar .form-required,
#admin-toolbar .more-link,
#admin-toolbar .more-help-link,
#admin-toolbar .item-list .pager,
#admin-toolbar .item-list .pager li,
#admin-toolbar .pager-current,
#admin-toolbar .tips,
#admin-toolbar html.js fieldset.collapsible legend a,
#admin-toolbar html.js fieldset.collapsed legend a,
#admin-toolbar .resizable-textarea {
margin:0px;
padding:0px;
border:0px;
outline:0px;
font-size:100%;
vertical-align:baseline;
background:transparent;
line-height:inherit;
position:static;
-moz-box-shadow:none;
-webkit-box-shadow:none;
-moz-border-radius:none;
-webkit-border-radius:none;
}
/**
* Base styles ========================================================
*/
div#admin-toolbar {
z-index:100;
position:fixed;
}
html.overlay-open div#admin-toolbar { z-index:600; }
/**
* Toggling ===========================================================
*/
div#admin-toolbar div.admin-blocks {
overflow:hidden;
display:none;
}
body.admin-expanded div#admin-toolbar div.admin-blocks { display:block; }
div#admin-toolbar.ne,
div#admin-toolbar.nw { top:0px; }
div#admin-toolbar.se,
div#admin-toolbar.sw { bottom:0px; }
div#admin-toolbar.nw,
div#admin-toolbar.sw,
div#admin-toolbar.nw span.admin-toggle,
div#admin-toolbar.sw span.admin-toggle { left:0px; }
div#admin-toolbar.ne,
div#admin-toolbar.se,
div#admin-toolbar.ne span.admin-toggle,
div#admin-toolbar.se span.admin-toggle { right:0px; }
/**
* Vertical =========================================================
*/
div#admin-toolbar.vertical {
position:fixed;
bottom:0px;
top:0px;
}
div#admin-toolbar.vertical div.admin-blocks { width:0px; }
body.admin-expanded div#admin-toolbar.vertical div.admin-blocks { width:260px; }
div#admin-toolbar.vertical div.admin-block { width:240px; }
div#admin-toolbar.vertical div.admin-tabs { width:215px; }
body div#admin-toolbar.vertical div.admin-blocks { position:absolute; top:0px; bottom:0px; }
body.admin-expanded div#admin-toolbar.vertical.ne div.admin-blocks,
body.admin-expanded div#admin-toolbar.vertical.se div.admin-blocks { right:0px; }
body.admin-expanded div#admin-toolbar.vertical.nw div.admin-blocks,
body.admin-expanded div#admin-toolbar.vertical.sw div.admin-blocks { left:0px; }
body.admin-expanded.admin-vertical.admin-ne,
body.admin-expanded.admin-vertical.admin-se { margin-right:260px; }
body.admin-expanded.admin-vertical.admin-nw,
body.admin-expanded.admin-vertical.admin-sw { margin-left:260px; }
/**
* Horizontal =======================================================
*/
div#admin-toolbar.horizontal { left:0px; right:0px; }
body.admin-expanded div#admin-toolbar.horizontal div.admin-blocks { height:260px; }
body.admin-expanded.admin-horizontal.admin-ne,
body.admin-expanded.admin-horizontal.admin-nw { margin-top:260px; }
body.admin-expanded.admin-horizontal.admin-sw,
body.admin-expanded.admin-horizontal.admin-se { margin-bottom:260px; }
/**
* Toggler ============================================================
*/
div#admin-toolbar span.admin-toggle {
display:block;
width:35px;
height:35px;
cursor:pointer;
overflow:hidden;
text-indent:-999px;
position:absolute;
top:0px;
z-index:1000;
}
div#admin-toolbar.se span.admin-toggle,
div#admin-toolbar.sw span.admin-toggle {
position:fixed;
bottom:0px;
top:auto;
}
body.admin-expanded div#admin-toolbar span.admin-toggle {
position:absolute;
top:0px;
}
/**
* Admin tabs =========================================================
*/
div#admin-toolbar.horizontal div.admin-tabs {
height:30px;
padding:5px 10px 0px;
overflow:hidden;
}
div#admin-toolbar.vertical div.admin-tabs {
position:relative;
padding:5px 10px 25px;
}
div#admin-toolbar.ne div.admin-tabs,
div#admin-toolbar.se div.admin-tabs { padding-right:35px !important; }
div#admin-toolbar.nw div.admin-tabs,
div#admin-toolbar.sw div.admin-tabs { padding-left:35px !important; }
div#admin-toolbar div.admin-tab,
div#admin-toolbar div.admin-tab span,
div#admin-toolbar div.admin-tab a {
list-style:none;
background:transparent;
padding:0px;
margin:0px;
}
div#admin-toolbar div.admin-tab {
cursor:pointer;
padding:4px 19px;
height:15px;
border-width:1px;
border-style:solid;
}
div#admin-toolbar.vertical div.admin-tab {
overflow:hidden;
white-space:nowrap;
margin-bottom:5px;
padding-left:9px;
padding-right:9px;
width:195px;
}
div#admin-toolbar.horizontal div.admin-tab {
float:left;
margin-right:5px;
}
div#admin-toolbar div.admin-tab-active {
border-width:1px 1px 0px;
padding-bottom:10px;
}
div#admin-toolbar.vertical div.admin-tab-active {
padding-bottom:5px;
position:absolute;
bottom:0px;
margin:0px;
}
/**
* Admin blocks =======================================================
*/
div#admin-toolbar div.admin-block {
position:relative;
padding:10px;
display:none;
}
div#admin-toolbar div.block-content {
overflow-x:hidden;
overflow-y:auto;
position:absolute;
top:10px;
left:10px;
right:10px;
bottom:10px;
}
div#admin-toolbar div.admin-active { display:block; }
/**
* Horizontal =======================================================
*/
div#admin-toolbar.horizontal div.block-content { height:200px; }
/**
* Vertical =========================================================
*/
div#admin-toolbar.vertical div.admin-block { position:absolute; bottom:0px; left:0px; right:0px; }
div#admin-toolbar.vertical div.admin-blocks-1 div.admin-block { top:30px; }
div#admin-toolbar.vertical div.admin-blocks-2 div.admin-block { top:60px; }
div#admin-toolbar.vertical div.admin-blocks-3 div.admin-block { top:90px; }
div#admin-toolbar.vertical div.admin-blocks-4 div.admin-block { top:120px; }
div#admin-toolbar.vertical div.admin-blocks-5 div.admin-block { top:150px; }
div#admin-toolbar.vertical div.admin-blocks-6 div.admin-block { top:180px; }
div#admin-toolbar.vertical div.admin-blocks-7 div.admin-block { top:210px; }
div#admin-toolbar.vertical div.admin-blocks-8 div.admin-block { top:240px; }
div#admin-toolbar.vertical div.admin-blocks-9 div.admin-block { top:270px; }
div#admin-toolbar.vertical div.admin-blocks-10 div.admin-block { top:300px; }
/**
* Lists ==============================================================
*/
#admin-toolbar div.item-list li {
padding:5px 0px 4px;
border-style:solid;
border-width:0px 0px 1px;
}
/**
* Reasonable inline links
*/
#admin-toolbar ul.links {
-moz-border-radius:5px;
-webkit-border-radius:5px;
padding:5px;
}
#admin-toolbar ul.links li a { padding:2px 10px; }
/**
* Form elements ======================================================
*/
#admin-toolbar input.form-autocomplete,
#admin-toolbar input.form-text,
#admin-toolbar textarea.form-textarea,
#admin-toolbar select.form-select {
padding:2px;
border-width:2px;
border-style:solid;
width:90%;
}
#admin-toolbar input.form-submit {
cursor:pointer;
padding:2px 5px;
text-align:center;
font-weight:normal;
border-width:1px;
border-style:solid;
}
#admin-toolbar.vertical div.admin-panes div.admin-pane,
#admin-toolbar div.admin-panes div.admin-pane-active,
#admin-toolbar div.fieldset,
#admin-toolbar div.form-item {
position:relative;
margin:0px 0px 5px;
border-width:1px;
border-style:solid;
}
#admin-toolbar div.form-item { padding:4px; }
#admin-toolbar div.form-item label {
margin:0px;
padding:0px;
font-weight:bold;
font-size:10px;
text-transform:uppercase;
}
#admin-toolbar div.form-item label.option {
text-transform:none;
font-size:11px;
}
#admin-toolbar div.form-item label.option input { vertical-align:middle; }
#admin-toolbar.vertical div.form-item div.description { font-size:10px; }
/**
* Admin panes ========================================================
*/
#admin-toolbar div.admin-panes h2.admin-pane-title a {
display:block;
padding:4px;
}
#admin-toolbar div.admin-panes div.admin-pane-content {
padding:4px;
display:none;
}
#admin-toolbar div.admin-panes div.admin-pane-active div.admin-pane-content { display:block; }
#admin-toolbar div.admin-pane div.form-item {
border:0px;
-moz-border-radius:0px;
-webkit-border-radius:0px;
padding:5px 0px;
margin:0px;
background:transparent;
}
/**
* Horizontal layout.
*/
#admin-toolbar.horizontal div.admin-panes {
position:relative;
padding-left:200px;
}
#admin-toolbar.horizontal div.admin-panes div.admin-pane {
-moz-border-radius:0px;
-webkit-border-radius:0px;
}
#admin-toolbar.horizontal div.admin-panes div.admin-pane-content { padding:4px 9px; }
#admin-toolbar.horizontal div.admin-panes div.admin-pane-tabs {
z-index:500;
position:absolute;
left:0px;
width:200px;
}
#admin-toolbar.horizontal div.admin-panes div.admin-pane-tabs a { padding:5px; }
#admin-toolbar.horizontal div.admin-panes div.admin-pane-tabs a.admin-pane-active {
padding:4px;
border-width:1px 0px 1px 1px;
border-style:solid;
margin-right:-1px;
}
body.toolbar.admin-nw #admin-toolbar,
body.toolbar.admin-ne #admin-toolbar {
margin-top: 65px;
}

View File

@@ -0,0 +1,188 @@
/**
* Base styles ========================================================
*/
div#admin-toolbar,
div#admin-toolbar * {
font:normal 11px/15px "Lucida Grande",Tahoma,Verdana,sans-serif;
color:#ccc;
}
div#admin-toolbar a {
text-decoration:none;
color:#fff;
font-weight:normal;
}
/**
* Toolbar background =================================================
*/
div#admin-toolbar div.admin-blocks { background:url(../images/black.png) 0px 35px repeat-x; }
div#admin-toolbar.vertical div.admin-blocks { background-color:#000; }
/**
* Toggle =============================================================
*/
div#admin-toolbar span.admin-toggle { background:url(../images/sprite.png) 0px 0px no-repeat; }
/* Positions */
div#admin-toolbar.nw span.admin-toggle { background-position:0px 0px; }
div#admin-toolbar.ne span.admin-toggle { background-position:-35px 0px; }
div#admin-toolbar.se span.admin-toggle { background-position:-70px 0px; }
div#admin-toolbar.sw span.admin-toggle { background-position:-105px 0px; }
/* Expanded */
body.admin-expanded div#admin-toolbar span.admin-toggle { background-position:0px -35px; }
/**
* Tabs ===============================================================
*/
div#admin-toolbar div.admin-tabs { background:#222 url(../images/bleeds.png) 0px 100% repeat-x; }
div#admin-toolbar div.admin-tab {
-moz-border-radius:5px;
-moz-box-shadow: #333 0px 1px 0px;
-webkit-border-radius:5px;
-webkit-box-shadow: #333 0px 1px 0px;
text-shadow: #222 0px 1px 0px;
background:url(../images/bleeds.png) 0px 0px repeat-x;
cursor:pointer;
border-color:#111;
}
div#admin-toolbar div.admin-tab,
div#admin-toolbar div.admin-tab a { color:#999; }
div#admin-toolbar div.admin-tab-active {
-moz-border-radius:5px 5px 0px 0px;
-moz-box-shadow: none;
-webkit-border-radius:0px;
-webkit-border-top-left-radius:5px;
-webkit-border-top-right-radius:5px;
-webkit-box-shadow: none;
background:#000;
border-color:#555 #333;
}
div#admin-toolbar div.admin-tab:hover,
div#admin-toolbar div.admin-tab-active,
div#admin-toolbar div.admin-tab-active a { color:#fff; }
/**
* Drupal elements ====================================================
*/
/* Lists */
#admin-toolbar div.item-list li { border-color:#222; }
/* Links */
#admin-toolbar ul.links { background:#111; }
#admin-toolbar ul.links li a {
-moz-border-radius:3px;
-webkit-border-radius:3px;
background:#333;
}
#admin-toolbar ul.links li a:hover {
background:#eee;
color:#333;
}
/**
* Form elements ======================================================
*/
#admin-toolbar input.form-autocomplete,
#admin-toolbar input.form-text,
#admin-toolbar textarea.form-textarea,
#admin-toolbar select.form-select {
border-color:#000;
background:#000;
color:#999;
}
#admin-toolbar input.form-autocomplete:hover,
#admin-toolbar input.form-text:hover,
#admin-toolbar textarea.form-textarea:hover,
#admin-toolbar select.form-select:hover,
#admin-toolbar div.form-item:hover input.form-autocomplete,
#admin-toolbar div.form-item:hover input.form-text,
#admin-toolbar div.form-item:hover textarea.form-textarea,
#admin-toolbar div.form-item:hover select.form-select,
#admin-toolbar input.form-autocomplete:focus,
#admin-toolbar input.form-text:focus,
#admin-toolbar textarea.form-textarea:focus,
#admin-toolbar select.form-select:focus {
color:#fff;
border-color:#333;
}
#admin-toolbar input.form-submit {
color:#999;
border-color:#555 #444 #333;
background:#222 url(../images/bleeds.png) 0px 100% repeat-x;
-moz-border-radius:3px;
-webkit-border-radius:3px;
}
#admin-toolbar input.form-submit:hover {
border-color:#aaa #888 #666;
background:#444 url(../images/bleeds.png) 0px 0px repeat-x;
color:#fff;
}
#admin-toolbar input.form-submit:active {
border-color:#333;
background:#111;
color:#fff;
}
#admin-toolbar.vertical div.admin-panes div.admin-pane,
#admin-toolbar div.admin-panes div.admin-pane-active,
#admin-toolbar div.fieldset,
#admin-toolbar div.form-item {
background:#111;
border-color:#222;
-moz-border-radius:3px;
-webkit-border-radius:3px;
}
#admin-toolbar div.form-item { padding:4px; }
#admin-toolbar div.form-item div.description,
#admin-toolbar div.form-item label { color:#999; }
/**
* Admin panes ========================================================
*/
#admin-toolbar div.admin-panes div.admin-pane:hover,
#admin-toolbar div.admin-panes div.admin-pane-active,
#admin-toolbar.vertical div.admin-panes div.admin-pane-active {
background:#222;
border-color:#333;
}
#admin-toolbar div.admin-panes h2.admin-pane-title a { color:#666; }
#admin-toolbar div.admin-panes h2.admin-pane-title a:hover,
#admin-toolbar div.admin-panes h2.admin-pane-title a.admin-pane-active { color:#fff; }
#admin-toolbar div.admin-pane div.item-list li { border-color:#333; }
/* Horizontal */
#admin-toolbar.horizontal div.admin-panes div.admin-pane-tabs a {
-moz-border-radius:3px 0px 0px 3px;
-webkit-border-top-left-radius:3px;
-webkit-border-bottom-left-radius:3px;
}
#admin-toolbar.horizontal div.admin-panes div.admin-pane-tabs a.admin-pane-active {
background:#222;
border-color:#333;
}
body.toolbar #admin-toolbar.vertical {
margin-top: 65px;
}

View File

@@ -0,0 +1,257 @@
(function($) {
Drupal.behaviors.adminToolbar = {};
Drupal.behaviors.adminToolbar.attach = function(context) {
$('#admin-toolbar:not(.processed)').each(function() {
var toolbar = $(this);
toolbar.addClass('processed');
// Set initial toolbar state.
Drupal.adminToolbar.init(toolbar);
// Admin toggle.
$('.admin-toggle', this).click(function() { Drupal.adminToolbar.toggle(toolbar); });
// Admin tabs.
$('div.admin-tab', this).click(function() { Drupal.adminToolbar.tab(toolbar, $(this), true); });
$(document).bind('drupalOverlayLoad', {adminToolbar: Drupal.adminToolbar, toolbar: toolbar}, function(event) {
var body = $(document.body);
var adminToolbar = event.data.adminToolbar;
var expand = parseInt(adminToolbar.getState('expanded'));
if (!expand) {
return;
}
var toolbar = event.data.toolbar;
var size = adminToolbar.SIZE + 'px';
adminToolbar.setOverlayState(toolbar, toolbar.is('.vertical'), expand);
});
});
$('div.admin-panes:not(.processed)').each(function() {
var panes = $(this);
panes.addClass('processed');
$('h2.admin-pane-title a').click(function() {
var target = $(this).attr('href').split('#')[1];
var panes = $(this).parents('div.admin-panes')[0];
$('.admin-pane-active', panes).removeClass('admin-pane-active');
$('div.admin-pane.' + target, panes).addClass('admin-pane-active');
$(this).addClass('admin-pane-active');
return false;
});
});
};
/**
* Admin toolbar methods.
*/
Drupal.adminToolbar = {};
/**
* The width or height of the toolbar, depending on orientation.
*/
Drupal.adminToolbar.SIZE = 260;
/**
* Set the initial state of the toolbar.
*/
Drupal.adminToolbar.init = function (toolbar) {
// Set expanded state.
var expanded = this.getState('expanded');
if (!$(document.body).hasClass('admin-ah')) {
if (expanded == 1) {
$(document.body).addClass('admin-expanded');
}
}
// Set default tab state.
var target = this.getState('activeTab');
if (target) {
if ($('div.admin-tab.'+target).size() > 0) {
var tab = $('div.admin-tab.'+target);
this.tab(toolbar, tab, false);
}
}
// Add layout class to body.
var classes = toolbar.attr('class').split(' ');
if (classes[0] === 'nw' || classes[0] === 'ne' || classes[0] === 'se' || classes[0] === 'sw' ) {
$(document.body).addClass('admin-'+classes[0]);
}
if (classes[1] === 'horizontal' || classes[1] === 'vertical') {
$(document.body).addClass('admin-'+classes[1]);
}
if (classes[2] === 'df' || classes[2] === 'ah') {
$(document.body).addClass('admin-'+classes[2]);
}
var vertical = true;
if(classes[1] === 'horizontal') {
vertical = false;
}
};
/**
* Set the active tab.
*/
Drupal.adminToolbar.tab = function(toolbar, tab, animate) {
if (!tab.is('.admin-tab-active')) {
var target = $('span', tab).attr('id').split('admin-tab-')[1];
// Vertical
// Use animations to make the vertical tab transition a bit smoother.
if (toolbar.is('.vertical') && animate) {
$('.admin-tab-active', toolbar).fadeOut('fast');
$(tab).fadeOut('fast', function() {
$('.admin-tab-active', toolbar).fadeIn('fast').removeClass('admin-tab-active');
$(tab).slideDown('fast').addClass('admin-tab-active');
Drupal.adminToolbar.setState('activeTab', target);
});
}
// Horizontal
// Tabs don't need animation assistance.
else {
$('div.admin-tab', toolbar).removeClass('admin-tab-active');
$(tab, toolbar).addClass('admin-tab-active');
Drupal.adminToolbar.setState('activeTab', target);
}
// Blocks
$('div.admin-block.admin-active', toolbar).removeClass('admin-active');
$('#block-'+target, toolbar).addClass('admin-active');
}
return false;
};
/**
* Set the width/height of the of the overlay body based on the state admin toolbar.
*
* @param vertical
* A boolean indicating if the toolbar is vertical.
* @param expanded
* A boolean indicating if the toolbar is expanded.
*/
Drupal.adminToolbar.setOverlayState = function(toolbar, vertical, expanded) {
var margin,
size = this.SIZE + 65;
if (!expanded) {
size = 0;
}
margin = {marginLeft: size+'px'};
if (vertical) {
if (toolbar.is('.ne') || toolbar.is('.se')) {
margin = {marginRight: size+'px'}
}
}
else {
if (toolbar.is('.ne') || toolbar.is('.nw')) {
margin = {marginTop: size+'px'};
}
else {
margin = {marginBottom: size+'px'};
}
}
$('iframe.overlay-element').contents().find('body').animate(margin, 'fast');
};
/**
* Toggle the toolbar open or closed.
*/
Drupal.adminToolbar.toggle = function (toolbar) {
var size = '0px';
if ($(document.body).is('.admin-expanded')) {
if ($(toolbar).is('.vertical')) {
$('div.admin-blocks', toolbar).animate({width:size}, 'fast');
if ($(toolbar).is('.nw') || $(toolbar).is('.sw')) {
$(document.body).animate({marginLeft:size}, 'fast', function() { $(this).toggleClass('admin-expanded'); });
}
else {
$(document.body).animate({marginRight:size}, 'fast', function() { $(this).toggleClass('admin-expanded'); });
}
this.setOverlayState(toolbar, true, false);
}
else {
$('div.admin-blocks', toolbar).animate({height:size}, 'fast');
if ($(toolbar).is('.nw') || $(toolbar).is('.ne')) {
$(document.body).animate({marginTop:size}, 'fast', function() { $(this).toggleClass('admin-expanded'); });
}
else {
$(document.body).animate({marginBottom:size}, 'fast', function() { $(this).toggleClass('admin-expanded'); });
}
this.setOverlayState(toolbar, false, false);
}
this.setState('expanded', 0);
}
else {
size = this.SIZE + 'px';
if ($(toolbar).is('.vertical')) {
$('div.admin-blocks', toolbar).animate({width:size}, 'fast');
if ($(toolbar).is('.nw') || $(toolbar).is('.sw')) {
$(document.body).animate({marginLeft:size}, 'fast', function() { $(this).toggleClass('admin-expanded'); });
}
else {
$(document.body).animate({marginRight:size}, 'fast', function() { $(this).toggleClass('admin-expanded'); });
}
this.setOverlayState(toolbar, true, true);
}
else {
$('div.admin-blocks', toolbar).animate({height:size}, 'fast');
if ($(toolbar).is('.nw') || $(toolbar).is('.ne')) {
$(document.body).animate({marginTop:size}, 'fast', function() { $(this).toggleClass('admin-expanded'); });
}
else {
$(document.body).animate({marginBottom:size}, 'fast', function() { $(this).toggleClass('admin-expanded'); });
}
this.setOverlayState(toolbar, false, true);
}
if ($(document.body).hasClass('admin-ah')) {
this.setState('expanded', 0);
}
else {
this.setState('expanded', 1);
}
}
};
/**
* Get the value of a cookie variable.
*/
Drupal.adminToolbar.getState = function(key) {
if (!Drupal.adminToolbar.state) {
Drupal.adminToolbar.state = {};
var cookie = $.cookie('DrupalAdminToolbar');
var query = cookie ? cookie.split('&') : [];
if (query) {
for (var i in query) {
// Extra check to avoid js errors in Chrome, IE and Safari when
// combined with JS like twitter's widget.js.
// See http://drupal.org/node/798764.
if (typeof(query[i]) == 'string' && query[i].indexOf('=') != -1) {
var values = query[i].split('=');
if (values.length === 2) {
Drupal.adminToolbar.state[values[0]] = values[1];
}
}
}
}
}
return Drupal.adminToolbar.state[key] ? Drupal.adminToolbar.state[key] : false;
};
/**
* Set the value of a cookie variable.
*/
Drupal.adminToolbar.setState = function(key, value) {
var existing = Drupal.adminToolbar.getState(key);
if (existing != value) {
Drupal.adminToolbar.state[key] = value;
var query = [];
for (var i in Drupal.adminToolbar.state) {
query.push(i + '=' + Drupal.adminToolbar.state[i]);
}
$.cookie('DrupalAdminToolbar', query.join('&'), {expires: 7, path: '/'});
}
};
})(jQuery);

View File

@@ -0,0 +1,165 @@
/**
* Generic menu drilldown plugin for standard Drupal menu tree markup.
* The plugin should be inited against a DOM element that *contains*
* a Drupal ul.menu tree. Example:
*
* $('div.block-menu').drilldown('init', params);
*
* You must provide the following parameters as settings:
*
* var params = {
* activePath : A drupal menu path that is currently active including the basePath e.g. "/mysite/node"
* trail : A jquery selector to the DOM element that should act as the trail container, e.g. "div.my-menu-breadcrumb-trail"
* rootTitle : The title to use for the root menu item if the menu does not already possess one. Optional.
* }
*
*/
(function($) {
$.fn.drilldown = function(method, settings) {
var menu = this;
var activePath;
var rootTitle = settings.rootTitle || 'Home';
switch (method) {
case 'goTo':
// If the passed link refers to the current page, don't follow through
// the link.
if (this.activePath && this.activePath === $(settings.activeLink).attr('href')) {
return false;
}
return true;
case 'setActive':
var breadcrumb = [];
var activeMenu;
$(settings.activeLink).each(function() {
// Traverse backwards through menu parents and build breadcrumb array.
$(this).parents('ul.menu').each(function() {
if ($(this).parents('ul.menu').size() > 0) {
$(this).siblings('a').each(function() {
breadcrumb.unshift($(this));
});
}
// If this is a root menu with no root link to accompany it,
// generate one such that the breadcrumb may reference it.
else if ($(this).children('li').size() > 1) {
var root;
if ($(this).siblings('a.drilldown-root').size() > 0) {
root = $(this).siblings('a.drilldown-root');
}
else {
root = $('<a href="#" class="drilldown-root" style="display:none">'+rootTitle+'</a>');
$(this).before(root);
}
breadcrumb.unshift(root);
}
});
// If we have a child menu (actually a sibling in the DOM), use it
// as the active menu. Otherwise treat our direct parent as the
// active menu.
if ($(this).next().is('ul.menu')) {
activeMenu = $(this).next();
breadcrumb.push($(this));
}
else {
activeMenu = $(this).parents('ul.menu').eq(0);
}
if (activeMenu) {
$('.drilldown-active-trail', menu).removeClass('drilldown-active-trail');
$('ul.menu', menu).removeClass('drilldown-active-menu').removeClass('clearfix');
$(activeMenu)
.addClass('drilldown-active-menu').addClass('clearfix')
.parents('li').addClass('drilldown-active-trail').show();
}
});
// Render the breadcrumb to the target DOM object
if (breadcrumb.length > 0) {
var trail = $(settings.trail);
trail.empty();
for (var key in breadcrumb) {
if (breadcrumb[key]) {
// We don't use the $().clone() method here because of an
// IE & jQuery 1.2 bug.
var clone = $('<a></a>')
.attr('href', $(breadcrumb[key]).attr('href'))
.attr('class', $(breadcrumb[key]).attr('class'))
.html($(breadcrumb[key]).html())
.addClass('depth-'+key)
.appendTo(trail);
// We add a reference to the original link and a click handler
// that traces back to that instance to set as the active link.
$('a.depth-'+key, trail)
.data('original', $(breadcrumb[key]))
.click(function() {
settings.activeLink = $(this).data('original');
// If the clicked link does not reference the current
// active menu, set it to be active.
if (settings.activeLink.siblings('ul.drilldown-active-menu').size() === 0) {
menu.drilldown('setActive', settings);
return false;
}
// Otherwise, pass-through and allow the link to be clicked.
return menu.drilldown('goTo', settings);
});
}
}
}
// Event in case others need to update themselves when a new active
// link is set.
$(menu).trigger('refresh.drilldown');
break;
case 'init':
if ($('ul.menu ul.menu', menu).size() > 0) {
$(menu).addClass('drilldown');
$(settings.trail).addClass('drilldown-trail');
// Set initial active menu state.
var activeLink;
$('ul.menu a', menu).removeClass('active');
if (settings.activePath && $('ul.menu a[href="'+settings.activePath+'"]', menu).size() > 0) {
this.activePath = settings.activePath;
activeLink = $('ul.menu a[href="'+settings.activePath+'"]', menu).addClass('active');
}
if (!activeLink) {
activeLink = $('ul.menu a.active', menu).size() ? $('ul.menu a.active', menu) : $('ul.menu > li > a', menu);
}
if (activeLink) {
menu.drilldown('setActive', {
activeLink: $(activeLink[0]),
trail: settings.trail,
rootTitle: rootTitle
});
}
// Attach click handlers to menu items
$('ul.menu li:has(ul.menu)', this).click(function() {
if ($(this).parent().is('.drilldown-active-menu')) {
if (menu.data('disableMenu')) {
return true;
}
else {
var url = $(this).children('a').attr('href');
var activeLink = $('ul.menu a[href="'+url+'"]', menu);
menu.drilldown('setActive', {
activeLink: activeLink,
trail: settings.trail,
rootTitle: rootTitle
});
return false;
}
}
});
$('ul.menu li:has(ul.menu) a', menu).click(function() {
menu.data('disableMenu', true);
});
}
break;
}
return this;
};
})(jQuery);

View File

@@ -0,0 +1,30 @@
<div class='admin-panes clearfix '>
<?php if ($layout == 'vertical'): ?>
<?php foreach ($panels as $key => $panel): ?>
<div class='admin-pane <?php if (!isset($first)) print 'admin-pane-active' ?> admin-pane-<?php print $key ?>'>
<h2 class='admin-pane-title'><?php print $labels[$key] ?></h2>
<div class='admin-pane-content clearfix'><?php print render($panel) ?></div>
</div>
<?php $first = TRUE ?>
<?php endforeach; ?>
<?php else: ?>
<div class='admin-pane-tabs'>
<?php foreach ($panels as $key => $panel): ?>
<h2 class='admin-pane-title'><?php print $labels[$key] ?></h2>
<?php endforeach; ?>
</div>
<?php foreach ($panels as $key => $panel): ?>
<div class='admin-pane <?php if (!isset($first)) print 'admin-pane-active' ?> admin-pane-<?php print $key ?>'>
<div class='admin-pane-content clearfix'><?php print render($panel) ?></div>
</div>
<?php $first = TRUE ?>
<?php endforeach; ?>
<?php endif; ?>
<?php print render($others) ?>
</div>

View File

@@ -0,0 +1,18 @@
<div id='admin-toolbar' class='<?php print $position ?> <?php print $layout ?> <?php print $behavior ?>'>
<span class='admin-toggle'><?php print t('Admin') ?></span>
<div class='admin-blocks admin-blocks-<?php print count($blocks) ?>'>
<div class='admin-tabs clearfix'>
<?php foreach ($tabs as $bid => $tab): ?>
<?php print theme('admin_tab', array('tab' => $tab, 'class' => $bid)); ?>
<?php endforeach; ?>
</div>
<?php foreach ($blocks as $block): ?>
<div class='admin-block <?php if (isset($block->class)) print $block->class ?>' id='block-<?php print $block->bid ?>'>
<div class='block-content clearfix'><?php print render($block->content) ?></div>
</div>
<?php endforeach; ?>
</div>
</div>

View File

@@ -0,0 +1,144 @@
<?php
/**
* Preprocessor for theme('admin_toolbar').
*/
function template_preprocess_admin_toolbar(&$vars) {
// Set the active block.
$active = admin_get_settings('active_tab') ? admin_get_settings('active_tab') : key($vars['blocks']);
if (!empty($vars['blocks'])) {
$blocks = $vars['blocks'];
$vars['tabs'] = array();
$vars['blocks'] = array();
foreach ($blocks as $block) {
$bid = $block->bid;
$vars['tabs'][$bid] = array(
'title' => $block->subject,
'attributes' => array('id' => 'admin-tab-' . $bid),
);
$vars['blocks'][$bid] = $block;
// Mark active tab, block.
if ($bid == $active) {
$vars['blocks'][$bid]->class = 'admin-active';
$vars['tabs'][$bid]['active'] = TRUE;
}
}
}
}
/**
* Theme function for form API element '#type' => 'admin_panes'.
*/
function template_preprocess_admin_panes(&$vars) {
drupal_add_js(drupal_get_path('module', 'admin') . '/includes/admin.toolbar.js');
$vars['layout'] = admin_get_settings('layout');
$vars['labels'] = $vars['panels'] = $vars['others'] = array();
$first = TRUE;
foreach (element_children($vars['element']) as $key) {
if (!isset($vars['element'][$key]['#access']) || $vars['element'][$key]['#access']) {
if (!empty($vars['element'][$key]['#title'])) {
$vars['labels'][$key] = l($vars['element'][$key]['#title'], $_GET['q'], array(
'fragment' => 'admin-pane-' . $key,
'attributes' => array(
'class' => array($first ? 'admin-pane-active' : '')
)
));
$vars['panels'][$key] = $vars['element'][$key];
$first = FALSE;
}
else {
$vars['others'][] = $vars['element'][$key];
}
}
}
}
/**
* Generate markup for an admin tab.
*/
function theme_admin_tab($variables) {
$tab = $variables['tab'];
$class = $variables['class'];
$attr = isset($tab['attributes']) ? drupal_attributes($tab['attributes']) : '';
$class .= !empty($tab['active']) ? ' admin-tab-active' : '';
$title = filter_xss_admin($tab['title']);
return "<div class='admin-tab {$class}'><span {$attr}>{$title}</span></div>";
}
/**
* Alternative to menu_tree_output() which uses admin implementations of the
* core menu theme functions.
*/
function theme_admin_drilldown_menu_tree_output($variables) {
$tree = $variables['menu'];
$output = '';
$items = array();
// Pull out just the menu items we are going to render so that we
// get an accurate count for the first/last classes.
foreach ($tree as $data) {
if (!$data['link']['hidden']) {
$items[] = $data;
}
}
$num_items = count($items);
foreach ($items as $i => $data) {
$extra_class = NULL;
if ($i == 0) {
$extra_class = 'first';
}
if ($i == $num_items - 1) {
$extra_class = 'last';
}
$link = theme('admin_drilldown_menu_item_link', array('item' => $data['link']));
$in_active_trail = isset($data['link']['in_active_trail']) ? $data['link']['in_active_trail'] : FALSE;
if ($data['below']) {
$output .= theme('admin_drilldown_menu_item', array('link' => $link, 'has_children' => $data['link']['has_children'], 'menu' => theme('admin_drilldown_menu_tree_output', array('menu' => $data['below'])), 'in_active_trail' => $in_active_trail, 'extra_class' => $extra_class));
}
else {
$output .= theme('admin_drilldown_menu_item', array('link' => $link, 'has_children' => $data['link']['has_children'], 'menu' => '', 'in_active_trail' => $in_active_trail, 'extra_class' => $extra_class));
}
}
return $output ? theme('admin_drilldown_menu_tree', array('menu' => $output)) : '';
}
/**
* Alternative to theme_menu_tree().
* Ensures custom theme-level overrides of theme_menu_tree() do not break
* markup expected by admin.
*/
function theme_admin_drilldown_menu_tree($variables) {
$tree = $variables['menu'];
return theme_menu_tree($tree);
}
/**
* Alternative to theme_menu_item().
* Ensures custom theme-level overrides of theme_menu_item() do not break
* markup expected by admin.
*/
function theme_admin_drilldown_menu_item($variables) {
$link = $variables['link'];
$has_children = $variables['has_children'];
$menu = $variables['menu'];
$in_active_trail = $variables['in_active_trail'];
$extra_class = $variables['extra_class'];
return theme_menu_item($link, $has_children, $menu, $in_active_trail, $extra_class);
}
/**
* Alternative to theme_menu_item_link().
*/
function theme_admin_drilldown_menu_item_link($variables) {
$link = $variables['item'];
$link['localized_options'] = empty($link['localized_options']) ? array() : $link['localized_options'];
$link['localized_options']['html'] = TRUE;
$link['localized_options']['purl'] = array('disabled' => TRUE);
$link['description'] = check_plain(truncate_utf8(strip_tags($link['description']), 150, TRUE, TRUE));
$link['title'] .= !empty($link['description']) ? "<span class='menu-description'>{$link['description']}</span>" : '';
$link['title'] = filter_xss_admin($link['title']);
return l($link['title'], $link['href'], $link['localized_options']);
}

View File

@@ -0,0 +1,366 @@
Admin Menu 7.x-3.x, xxxx-xx-xx
------------------------------
#1177202 by das-peter, dereine, sun: Fixed copying and re-injection of child
router items breaks badly. Change them by reference instead.
Requires latest Views 3.x code.
#1212064 by sun: Updated admin_views default views for VBO 3.x.
#1196590 by sun: Fixed errors and notices for admin_views with Views 3.
#1144768 by idlewilder, sun: Fixed devel modules to skip are not displayed.
#1079374 by WillHall: Fixed JS Error: unrecognized expression: [href=/].
#1114132 by joelstein, sun: Added Field UI to list of developer modules.
#1008380 by bdragon, sun: Updated admin_views for D7.
#1146644 by sun: Fixed PHP 5.3 compability in tests.
#442560 by sun: Fixed 'defer' script attribute breaks Drupal.behaviors in FF3.6.
#1022902 by matglas86, sun: Updated for changed core Toolbar styles.
Admin Menu 7.x-3.0-RC1, 2010-01-07
----------------------------------
#990774 by sun: Updated for $closure renamed to $page_bottom.
#991906 by johnv, sun: Added configure to .info file.
#947198 by sun: Added hint about disabling Toolbar.
by sun: Updated administrative settings form for D7 UX guidelines.
by sun: Disabled "Rebuild system links" button on settings form.
#420816 by sun, smk-ka: Improved on-demand loading of dynamic paths.
#420816 by tim.plunkett: Fixed dynamic Field UI paths for vocabularies.
#871774 by swentel: Fixed developer modules toggle still uses referer_uri().
#671760 by sun: Updated for new preprocess defaults.
#731462 by sun: Updated for system_rebuild_theme_data().
by sun: Re-added a "Rebuild system links" button to settings form.
#420816 by tim.plunkett: Updated taxonomy path map for machine names.
#857688 by sun: Updated for reverted system_settings_form().
#420816 by smk-ka, sun: Added merging of menu trees containing dynamic paths.
by sun: Fixed tests and minor admin_menu_toolbar styling issues.
by sun: Fixed various styling issues for admin_menu and admin_menu_toolbar.
by sun: Updated for Schema API, DBTNG, coding standards.
by sun: Updated for new admin/modules path.
#701424 by hutch: Updated for new admin/people/people path.
by sun: Removed orphan menu rewrite function.
#667858 by sun: Don't remove the current user from the switch user list.
#631550 by sun: Updated for fixed MENU_VISIBLE_IN_BREADCRUMB behavior.
#658344 by dereine, sun: Updated for removed drupal_session_count().
by sun: Added separate permission to flush cashes.
by sun: Updated for changed Devel settings form.
by sun: Updated for new {system}.info module data.
#614730 by azriprajwala, sun: Updated for hook_theme() key changes.
by sun: Updated for all theme functions should take a single argument.
by sun: Reverted removal of registry cache flushing option.
#578520 by sun: Fixed destination query parameter is processed wrongly.
#578520 by sun: Updated for $query in url() should always be an array.
by Dave Reid: Updated for PHP 5 date constants.
by sun: Updated for new database API.
by smk-ka: Removed remnants of the registry. Fixed flush admin menu cache
command.
#567618 by smk-ka: Revised test cases. Abstracted out base web test class.
by sun: Updated for removed registry, new admin paths.
#326539 by sun: Updated for class attribute array.
#519782 by sun: Updated for hook_footer() replaced by hook_page_alter().
#525638 by Razorraser: Updated for admin/build renamed to admin/structure.
by Dave Reid: Updated for hook_permission().
#482314 by Dave Reid: Updated for node_type_get_types().
#437506 by yched, Dave Reid: Updated for menu_router_build().
#376816 by sun: Updated for compatibility for other JavaScript libraries.
#337820 by Dave Reid: Updated for new user/logout path.
#340546 by Dave Reid: Updated for drupal_add_js().
#340531 by Dave Reid: Updated for module_list().
#266358 by sun: Updated for drupal_add_css().
#320526 by yettyn, sun: Updated to UNSTABLE-2 (DBTNG queries, permissions, etc).
by sun: Changed admin_menu_wipe() to admin_menu_flush_caches().
by sun: Updated content-type edit menu item locations.
by sun: Fixed sess_count() changed to drupal_session_count().
Admin Menu 6.x-3.x, xxxx-xx-xx
------------------------------
#588936 by fenstrat: Fixed Toolbar shortcuts not visible.
#860390 by Kevin Rogers: Fixed .info file parsing error on uncertain platform.
#551484 by sun: Fixed stale hook_admin_menu_output_alter() docs.
Admin Menu 6.x-3.0-ALPHA4, 2010-03-11
-------------------------------------
#730156 by sun: Fixed Administration views.
by sun: Fixed missing .element-hidden style in D6 for permissions tweak.
#645526 by TravisCarden: Fixed stale local tasks markup after moving them.
#366442 by sun: Added tweak to collapse modules on permissions page.
#655926 by donquixote, sun: Improved performance of delayed mouseout.
#557062 by sun: Fixed admin_menu_toolbar JS/CSS loaded before admin_menu's.
#599462 by sun, koyama: Added background-color to avoid unintentional override.
#601918 by BWPanda: Fixed admin_menu.css overrides admin_menu_toolbar.css.
#586228 by Island Usurper: Fixed for PHP 5.3.
#554124 by Dave Reid: Added missing toolbar.png.
#557062 by Dave Reid: Fixed undefined Drupal.admin error when including
admin_menu_toolbar.js before admin_menu.js.
#511744 by smk-ka, sun: Fixed /admin page links are broken.
by smk-ka: Added missing variables to hook_uninstall().
#571038 by smk-ka: Removed call to admin_menu_wipe() and cleaned install file.
#552190 by Bartezz: Fixed missing t() for user logout link.
Admin Menu 6.x-3.0-ALPHA3, 2009-08-16
-------------------------------------
#502500 by sun: Added "Create content" menu.
#538714 by sun: Fixed wrong re-parenting in Drupal's menu system.
#550132 by sun: Fixed (temporarily) admin_views menu items.
by sun: Added Administration views sub-module, converting all administrative
listing pages in Drupal core into real, ajaxified, and alterable views.
#547206 by sun: Fixed menu link descriptions lead to mouseover clashes.
#540954 by Rob Loach: Added String Overrides to list of developer modules.
#540762 by Deslack: Added Malay translation.
Admin Menu 6.x-3.0-ALPHA2, 2009-08-02
-------------------------------------
#527908 by sun: Changed theme_admin_menu_links() to use $element['#children'].
#527908 by markus_petrux, sun: Changed admin menu into a renderable array.
#420812 by sun, smk-ka: Added support for hook_js().
by sun: Fixed destination query string of current page not applied to links.
by sun: Changed Drupal.admin.attachBehaviors() to accept local JS settings.
#276751 by sun: Revamped rendering of menu additions/widgets.
#500866 by sun: Updated for removed t() from getInfo() in tests.
#402058 by sun: Added Administration menu toolbar module.
by markus_petrux, sun: Added API documentation.
#461264 by sun: Added site/domain as CSS class.
#451270 by smk-ka, sun: Changed visual indication for uid1.
by sun: Minor code clean-up.
#490670 by sun: Fixed missing menu after installation/upgrade.
#515718 by joelstein, sun: Added rules_admin module to developer modules list.
#352065 by sun: Added setting to select developer modules to keep enabled.
#511854 by psynaptic: Fixed logout link.
#424960 by markus_petrux, sun: Fixed gzip compression for cached output.
by sun: Fixed opacity of links in sub-menus.
#479922 by sun: Fixed fieldsets not collapsed on admin/build/modules/list*.
#495148 by sun: Fixed MENU_NORMAL_ITEMs do not appear in administration menu.
by sun: Fixed tests for new content-type locations.
#345984 by markus_petrux, sun: Fixed old menu links not removed on upgrade.
#276751 by sun: Major rewrite. Fixed menu items cannot be moved, altered, or
added as well as various performance issues.
by sun: Added variable to allow to disable caching (rewrite).
Admin Menu 6.x-3.0-ALPHA1, 2009-06-10
-------------------------------------
#236657 by sun: Updated for corrected arguments of system_clear_cache_submit().
#483870 by sun: Fixed compatibility with new Admin module.
#483152 by sun: Fixed admin_menu caches not flushed when clean URLs are toggled.
#479922 by danep: Fixed fieldsets not collapsed on admin/build/modules/list.
#469716 by sun: Fixed wrong AJAX callback URL under various conditions.
#471504 by wulff: Updated Danish translation.
by sun: Fixed admin_menu_suppress() does not suppress margin-top.
#451270 by sun: Added visual indication when working as uid 1.
by Dave Reid: Updated for getInfo() in tests.
#420828 by sun: Added dynamic replacements for cached administration menu.
#420840 by sun: Fixed Drupal.behaviors.adminMenu must be only executed once.
#345984 by markus_petrux, sun: Added client-side caching of administration menu.
Attention: A new era of Drupal user experience starts here. This is the very
first issue of a series of improvements targeting plain awesomeness.
#349169 by sun: Fixed Devel switch user links contain multiple path prefixes.
#345984 by sun: Code clean-up in preparation for client-side caching.
#415196 by psynaptic: Updated for CSS coding standards.
#406672 by mr.j, sun: Fixed "Move local tasks" option leaves stale UL.
by sun: Major code clean-up and sync across 3.x branches.
#349505 by smk-ka, sun: Performance: Added caching of entire menu output.
#315342 by wulff: Added "My account" link (by splitting the "Log out" item).
#384100 by kepol, sun: Fixed content-type items displayed in wrong place.
#373339 by sun: Fixed double-escaped 'Edit <content-type>' link titles.
#373372 by sun: Turned procedural JavaScript into admin menu behaviors.
by sun: Fixed admin menu tests (and updated to 6.x for SimpleTest 2.x).
#359158 by nitrospectide, sun: Fixed Devel Themer breaks admin menu.
#365335 by sun: Fixed not all variables removed after uninstall.
Admin Menu 6.x-1.3, 2009-01-24
------------------------------
#362454 by sun: Fixed Drupal.settings.admin_menu is undefined JS error in some
browsers.
Admin Menu 6.x-1.2, 2009-01-20
------------------------------
#358697 by sun: Added docs about admin_menu_suppress() to README.txt.
#342684 by darumaki, sun: Added notice about Opera configuration to README.txt.
#350932 by sun: Fixed "Run updates" link repeated per language/site.
#342298 by gustz: Updated Spanish translation.
#346106 by sun: Fixed XHTML-Strict validation for admin menu icon.
#287448 by sun: Fixed unnecessary menu rebuild for users without permission to
use admin menu.
#342002 by AltaVida: Fixed improper test for node/add paths.
#272920 by keith.smith: Changed all text strings throughout the module.
#322731 by sun: Fixed improper use of t() in module install file.
#282030 by sun: Fixed "Run updates" item visible for unprivileged users.
#322877 by sun: Added tweak to move page tabs into administration menu.
#287468 by sun: Fixed module paths directly below "admin" get the wrong parent.
#310423 by sun: Added optional position: fixed configuration setting.
#292657 by smk-ka: Improved rendering performance.
#234149 by yhager, sun: Fixed RTL support for IE.
#323726 by danez1972: Added Spanish translation.
#325057 by sun: Updated README.txt.
#234149 by yhager, levavie, sun: Added RTL support.
#325057 by sun: Added links to flush specific caches.
#324334 by AltaVida: Fixed usernames with spaces not in Devel user switch links.
#319382 by betz: Added Dutch translation.
Admin Menu 6.x-1.1, 2008-09-12
------------------------------
#295476 by pwolanin, use <front> for icon path to fix front-page path-change
bug and pathauto conflict, add wipe button to admin form.
#301370 by sun: Disabled module fieldset collapsing behavior by default.
#288672 by sun: Fixed JS hover behavior not working in IE.
#290803 by sun: Fixed missing devel_themer in devel modules; added some others.
#286636 by sun: Fixed menus do not drop down in IE6.
#249537 by pwolanin, sun: Added admin_menu_suppress() to allow other modules to
disable the display of admin_menu on certain pages (f.e. popups).
#268211 by sun: Fixed invalid issue queue links for custom modules and
sub-modules of projects.
#261461 by sun: Added FAQ entry for displaying other menus like admin_menu.
#264067 by sun: Added FAQ entry for huge amount of anonymous users displayed.
#280002 by pwolanin: Clean up .test setUp function.
#242377 by sun: Fixed sub-level menu items exceed total document height.
Admin Menu 6.x-1.0, 2008-06-26
------------------------------
#266308 by sun: Fixed jQuery 1.0.x incompatible selector for collapsing modules.
#268373 by sun: Added hook_update to cleanup for alpha/beta testers.
#268373 by sun: Added menu callback to disable/enable developer modules.
#132524 by pwolanin: Fixed admin_menu links are re-inserted each time menu links
are rebuilt.
by smk-ka: Performance: Use 'defer' attribute for JavaScript to delay execution.
#266099 by sun: Fixed description of "Apply margin-top" configuration setting.
#266308 by sun: Usability: Added Utility module features to collapse module
fieldsets on Modules page.
#251341 by sun: Added docs about display drupal links permission.
Admin Menu 6.x-1.0-BETA, 2008-06-08
-----------------------------------
#132524 by sun: Fixed support for sub-content-types below node/add.
#132524 by pwolanin: Added support for localizable menu links.
#132524 by pwolanin, sun: Fixed menu links adjustments.
#132524 by pwolanin: Added simpletest.
#132524 by pwolanin: Major rewrite to better use Drupal 6 menu system.
#132524 by sun: Moved gettext translation files into translations.
#132524 by sun: Committing pre-alpha code for D6 due to public demand.
Admin Menu 5.x-2.x, xxxx-xx-xx
------------------------------
#246221 by sun: Fixed user counter displays different values than Who's online
block.
#239022 by mikl: Added Danish translation.
#234444 by smk-ka: Fixed admin_menu icon does not respect theme settings.
#198240 by sun: Fixed admin_menu displayed in print output.
Admin Menu 5.x-2.4, 2008-02-24
------------------------------
#214740 by sun: Regression: Fixed directly applied marginTop not supported by IE.
#214725 by sun: Fixed wrong CSS id in admin_menu.js (missed in 5.x-2.3).
Admin Menu 5.x-2.3, 2008-02-24
------------------------------
#214725 by sun: Fixed CSS id and classes should not contain underscores.
#209390 by sun: Added note about interaction with user role permissions.
#214740 by jjeff, sun: Added module settings to configure margin-top CSS.
#200737 by sun: Changed admin_menu (fav)icon to use theme setting, if defined.
#203116 by smk-ka: Improved performance of non-cached admin_menu by storing
already processed URLs in the cache.
#224605 by sun: 'Add <content_type>' items do not appear without 'administer
nodes' permission.
#210615 by robertgarrigos: Fixed Mozilla Mac: Collapsible fieldsets display
error.
Admin Menu 5.x-2.2, 2007-01-08
------------------------------
#204884 by jjeff: Usability: Override theme font family declaration.
#204935 by jjeff: Added mouseout delay for hovered menus (yay!).
#193941 by downgang: Fixed margin in IE6 using Garland theme.
#197306 by sun: Fixed 'Run updates' leads to wrong url with clean URLs disabled.
Moved images into sub-folder.
by smk-ka: Fixed icon title for user counter not displayed & coding style.
Fixed user count not displayed without 'administer users' permission.
Admin Menu 5.x-2.1, 2007-12-02
------------------------------
Fixed adding menu items with negative weight not always working.
Fixed admin_menu_copy_items() is overwriting already existing items.
Fixed display menu item ids in devel settings does not work.
Admin Menu 5.x-2.0, 2007-12-02
------------------------------
Added devel_admin_menu() for fast access to clear-cache, variable editor and
switch_user.
Added username to logout button.
Added hook_admin_menu() to allow other modules to alter admin_menu.
#194189 by sun: Added counter for current anonymous/authenticated users.
Added Drupal.org project issue queue links for all enabled contrib modules.
#189701 by sun: Changed admin_menu icon to be a menu.
#193925 by sun: Removed obsolete menu slicing code.
#193669 by smk-ka: Moved admin_menu builder functions into include file.
Admin Menu 5.x-1.2, 2007-11-18
------------------------------
#176969 by smk-ka: Fixed performance issues with path(auto) module by
introducing a menu cache for admin_menu.
#179648 by sun: Inject admin_menu into theme.
Fixes several CSS bugs in various themes and also activation of admin_menu
immediately after installation.
#191213 by Standard: Fixed block info shouldn't contain the word "block".
#187816 by sun: Fixed "Add" not translatable.
#186218 by sun: Fixed admin menu icon too big in Safari.
#182563 by sun: Fixed wrong datatype for array_search in _admin_menu_get_children().
#183496 by sun: Fixed invalid argument supplied for foreach in admin_menu_copy_items().
Admin Menu 5.x-1.1, 2007-10-10
------------------------------
#178876 by sun: Fixed 3rd-level submenus expand without hover over.
#153455 by sun: Fixed add product node sub-elements are empty.
Fixed path_to_theme() call breaking blocks page.
#177582 by sun: Fixed bluebreeze theme compatibility.
Admin Menu 5.x-1.0, 2007-09-06
------------------------------
#156952 by sun: Fixed admin menu inaccessible due to margins.
#149229 by sun: Fixed admin menu not expanding in IE7.
#172545 by sun: Use opacity instead of -moz-opacity.
#132867 Fixed z-index too low.
- Fixed admin menu block selectors to override any other theme styles.
#155589 by sun: Added permission to access administration menu.
- Fixed a PHP warning when there are no content types defined in the system, as
node/add then has no child menu items.
#155312 by sun: Fixed menu item tooltip clashes.
Added support for custom stylesheets per theme.
Removed 4.7.x compatibility.
Admin Menu 4.7-1.3, 2007-03-30
------------------------------
#126601 Fixed Users can see inaccessible items.
#121027 Fixed Page not found entries for menu-collapsed.png.
Admin Menu 4.7-1.2, 2007-03-04
------------------------------
- Fixed menu item adjustments
- Fixed IE / Safari support
- Fixed base_path for IE support
- Added create content options to content management menu
Admin Menu 4.7-1.1, 2007-01-24
------------------------------
First stable release, compatible to Drupal 4.7.x and 5.x.
Admin Menu 4.7-1.0, 2007-01-16
------------------------------
Initial release of admin_menu module. Already supporting Drupal 5.0.

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,188 @@
-- SUMMARY --
The Administration menu module displays the entire administrative menu tree (and
most local tasks) in a drop-down menu, providing administrators one- or
two-click access to most pages. Other modules may also add menu links to the
menu using hook_admin_menu_output_alter().
For a full description of the module, visit the project page:
http://drupal.org/project/admin_menu
To submit bug reports and feature suggestions, or to track changes:
http://drupal.org/project/issues/admin_menu
-- REQUIREMENTS --
None.
-- INSTALLATION --
* Install as usual, see http://drupal.org/node/70151 for further information.
* You likely want to disable Toolbar module, since its output clashes with
Administration menu.
-- CONFIGURATION --
* Configure user permissions in Administration » People » Permissions:
- Use the administration pages and help (System module)
The top-level administration categories require this permission to be
accessible. The administration menu will be empty unless this permission is
granted.
- Access administration menu
Users in roles with the "Access administration menu" permission will see
the administration menu at the top of each page.
- Display Drupal links
Users in roles with the "Display drupal links" permission will receive
links to drupal.org issue queues for all enabled contributed modules. The
issue queue links appear under the administration menu icon.
Note that the menu items displayed in the administration menu depend on the
actual permissions of the viewing user. For example, the "People" menu item
is not displayed to a user who is not a member of a role with the "Administer
users" permission.
* Customize the menu settings in Administration » Configuration and modules »
Administration » Administration menu.
* To prevent administrative menu items from appearing twice, you may hide the
"Management" menu block.
-- CUSTOMIZATION --
* To override the default administration menu icon, you may:
1) Disable it via CSS in your theme:
body #admin-menu-icon { display: none; }
2) Alter the image by overriding the theme function:
Copy the entire theme_admin_menu_icon() function into your template.php,
rename it to phptemplate_admin_menu_icon() or THEMENAME_admin_menu_icon(),
and customize the output according to your needs.
Remember that the output of the administration menu is cached. To see changes
from your theme override function, you must clear your site cache (via
the "Flush all caches" link on the menu).
* To override the font size, add the following line to your theme's stylesheet:
body #admin-menu { font-size: 10px; }
-- TROUBLESHOOTING --
* If the menu does not display, check the following:
- Are the "Access administration menu" and "Use the administration pages and help"
permissions enabled for the appropriate roles?
- Does html.tpl.php of your theme output the $page_bottom variable?
* If the menu is rendered behind a Flash movie object, add this property to your
Flash object(s):
<param name="wmode" value="transparent" />
See http://drupal.org/node/195386 for further information.
-- FAQ --
Q: When the administration menu module is enabled, blank space is added to the
bottom of my theme. Why?
A: This is caused by a long list of links to module issue queues at Drupal.org.
Use Administer >> User management >> Permissions to disable the "display
drupal links" permission for all appropriate roles. Note that since UID 1
automatically receives all permissions, the list of issue queue links cannot
be disabled for UID 1.
Q: After upgrading to 6.x-1.x, the menu disappeared. Why?
A: You may need to regenerate your menu. Visit
http://example.com/admin/build/modules to regenerate your menu (substitute
your site name for example.com).
Q: Can I configure the administration menu module to display another menu (like
the Navigation menu, for instance)?
A: No. As the name implies, administration menu module is for administrative
menu links only. However, you can copy and paste the contents of
admin_menu.css into your theme's stylesheet and replace #admin-menu with any
other menu block id (#block-menu-1, for example).
Q: Sometimes, the user counter displays a lot of anonymous users, but no spike
of users or requests appear in Google Analytics or other tracking tools.
A: If your site was concurrently spidered by search-engine robots, it may have
a significant number of anonymous users for a short time. Most web tracking
tools like Google Analytics automatically filter out these requests.
Q: I enabled "Aggregate and compress CSS files", but admin_menu.css is still
there. Is this normal?
A: Yes, this is the intended behavior. the administration menu module only loads
its stylesheet as needed (i.e., on page requests by logged-on, administrative
users).
Q: Why are sub-menus not visible in Opera?
A: In the Opera browser preferences under "web pages" there is an option to fit
to width. By disabling this option, sub-menus in the administration menu
should appear.
Q: How can the administration menu be hidden on certain pages?
A: You can suppress it by simply calling the following function in PHP:
module_invoke('admin_menu', 'suppress');
However, this needs to happen as early as possible in the page request, so
placing it in the theming layer (resp. a page template file) is too late.
Ideally, the function is called in hook_init() in a custom module. If you do
not have a custom module, placing it into some conditional code at the top of
template.php may work out, too.
-- CONTACT --
Current maintainers:
* Daniel F. Kudwien (sun) - http://drupal.org/user/54136
* Peter Wolanin (pwolanin) - http://drupal.org/user/49851
* Stefan M. Kudwien (smk-ka) - http://drupal.org/user/48898
* Dave Reid (Dave Reid) - http://drupal.org/user/53892
Major rewrite for Drupal 6 by Peter Wolanin (pwolanin).
This project has been sponsored by:
* UNLEASHED MIND
Specialized in consulting and planning of Drupal powered sites, UNLEASHED
MIND offers installation, development, theming, customization, and hosting
to get you started. Visit http://www.unleashedmind.com for more information.
* Lullabot
Friendly Drupal experts providing professional consulting & education
services. Visit http://www.lullabot.com for more information.
* Acquia
Commercially Supported Drupal. Visit http://acquia.com for more information.

View File

@@ -0,0 +1,12 @@
name = Administration Development tools
description = Administration and debugging functionality for developers and site builders.
package = Administration
core = 7.x
scripts[] = admin_devel.js
; Information added by drupal.org packaging script on 2013-01-31
version = "7.x-3.0-rc4"
core = "7.x"
project = "admin_menu"
datestamp = "1359651687"

View File

@@ -0,0 +1,40 @@
(function($) {
/**
* jQuery debugging helper.
*
* Invented for Dreditor.
*
* @usage
* $.debug(var [, name]);
* $variable.debug( [name] );
*/
jQuery.extend({
debug: function () {
// Setup debug storage in global window. We want to look into it.
window.debug = window.debug || [];
args = jQuery.makeArray(arguments);
// Determine data source; this is an object for $variable.debug().
// Also determine the identifier to store data with.
if (typeof this == 'object') {
var name = (args.length ? args[0] : window.debug.length);
var data = this;
}
else {
var name = (args.length > 1 ? args.pop() : window.debug.length);
var data = args[0];
}
// Store data.
window.debug[name] = data;
// Dump data into Firebug console.
if (typeof console != 'undefined') {
console.log(name, data);
}
return this;
}
});
// @todo Is this the right way?
jQuery.fn.debug = jQuery.debug;
})(jQuery);

View File

@@ -0,0 +1,33 @@
<?php
/**
* @file
* Administration and debugging functionality for developers and site builders.
*/
/**
* Implements hook_form_FORMID_alter().
*/
function admin_devel_form_admin_menu_theme_settings_alter(&$form, &$form_state) {
$form['actions']['wipe_rebuild'] = array(
'#type' => 'submit',
'#value' => t('Rebuild system links'),
'#submit' => array('admin_devel_form_admin_menu_theme_settings_alter_rebuild_submit'),
// @todo Not necessarily ready for mass-consumption yet.
'#access' => FALSE,
);
}
/**
* Form submit handler to wipe and rebuild all 'module' = 'system' menu links.
*/
function admin_devel_form_admin_menu_theme_settings_alter_rebuild_submit($form, &$form_state) {
// Delete all auto-generated menu links derived from menu router items.
db_delete('menu_links')
->condition('module', 'system')
->execute();
// Rebuild menu links from current menu router items.
menu_rebuild();
drupal_set_message(t('System links derived from menu router paths have been rebuilt.'));
}

View File

@@ -0,0 +1,64 @@
#admin-menu {
text-align: right;
}
#admin-menu .dropdown .admin-menu-users a {
background-position: 10% center;
padding-left: 22px;
padding-right: 0;
}
#admin-menu .dropdown .admin-menu-action,
#admin-menu .dropdown .admin-menu-search {
float: left;
}
#admin-menu .dropdown .admin-menu-action a {
border-left: none;
border-right: 1px solid #323232;
}
/* All lists */
#admin-menu a {
text-align: right;
}
#admin-menu .dropdown a {
border-left: 1px solid #323232;
border-right: 0;
}
#admin-menu .dropdown .admin-menu-tab a {
border-left: 1px solid #52565E;
border-right: 0;
}
#admin-menu .dropdown li li a {
border-left: 0;
}
/* All list items */
#admin-menu .dropdown li {
float: right;
}
#admin-menu .dropdown li li {
}
/* Second-level lists */
#admin-menu .dropdown li ul {
left: auto;
right: -999em;
}
/* Third-and-above-level lists */
#admin-menu .dropdown li li.expandable ul {
margin-left: 0;
margin-right: 160px;
}
/* Lists nested under hovered list items */
#admin-menu .dropdown li.admin-menu-action:hover ul {
left: 0 !important;
right: auto;
}
/* Second-and-more-level hovering */
#admin-menu .dropdown li li.expandable {
background-image: url(images/arrow-rtl.png);
background-position: 5px 6px;
}

View File

@@ -0,0 +1,62 @@
(function($) {
/**
* Live preview of Administration menu components.
*/
Drupal.behaviors.adminMenuLivePreview = {
attach: function (context, settings) {
$('input[name^="admin_menu_components"]', context).once('admin-menu-live-preview')
.change(function () {
var target = $(this).attr('rel');
$(target).toggle(this.checked);
})
.trigger('change');
}
};
/**
* Automatically enables required permissions on demand.
*
* Many users do not understand that two permissions are required for the
* administration menu to appear. Since Drupal core provides no facility for
* this, we implement a simple manual confirmation for automatically enabling
* the "other" permission.
*/
Drupal.behaviors.adminMenuPermissionsSetupHelp = {
attach: function (context, settings) {
$('#permissions', context).once('admin-menu-permissions-setup', function () {
// Retrieve matrix/mapping - these need to use the same indexes for the
// same permissions and roles.
var $roles = $(this).find('th:not(:first)');
var $admin = $(this).find('input[name$="[access administration pages]"]');
var $menu = $(this).find('input[name$="[access administration menu]"]');
// Retrieve the permission label - without description.
var adminPermission = $.trim($admin.eq(0).parents('td').prev().children().get(0).firstChild.textContent);
var menuPermission = $.trim($menu.eq(0).parents('td').prev().children().get(0).firstChild.textContent);
$admin.each(function (index) {
// Only proceed if both are not enabled already.
if (!(this.checked && $menu[index].checked)) {
// Stack both checkboxes and attach a click event handler to both.
$(this).add($menu[index]).click(function () {
// Do nothing when disabling a permission.
if (this.checked) {
// Figure out which is the other, check whether it still disabled,
// and if so, ask whether to auto-enable it.
var other = (this == $admin[index] ? $menu[index] : $admin[index]);
if (!other.checked && confirm(Drupal.t('Also allow !name role to !permission?', {
'!name': $roles[index].textContent,
'!permission': (this == $admin[index] ? menuPermission : adminPermission)
}))) {
other.checked = 'checked';
}
}
});
}
});
});
}
};
})(jQuery);

View File

@@ -0,0 +1,164 @@
<?php
/**
* @file
* API documentation for Administration menu.
*/
/**
* Provide expansion arguments for dynamic menu items.
*
* The map items must be keyed by the dynamic path to expand, i.e. a menu path
* containing one or more '%' placeholders. Each map item may have the following
* properties:
* - parent: The parent menu path to link the expanded items to.
* - arguments: An array of argument sets that will be used in the expansion.
* Each set consists of an array of one or more placeholders, which again is
* an array of possible expansion values. Upon expansion, each argument is
* combined with every other argument from the set (technically, the cartesian
* product of all arguments). The expansion values may be empty; that is, you
* do not need to insert logic to skip map items for which no values exist,
* since Administration menu will take care of that.
*
* @see admin_menu.map.inc
*/
function hook_admin_menu_map() {
// Expand content types below Structure > Content types.
// The key denotes the dynamic path to expand to multiple menu items.
$map['admin/structure/types/manage/%node_type'] = array(
// Link generated items directly to the "Content types" item.
'parent' => 'admin/structure/types',
// Create expansion arguments for the '%node_type' placeholder.
'arguments' => array(
array(
'%node_type' => array_keys(node_type_get_types()),
),
),
);
return $map;
}
/**
* Add to the administration menu content before it is rendered.
*
* Only use this hook to add new data to the menu structure. Use
* hook_admin_menu_output_alter() to *alter* existing data.
*
* @param array $content
* A structured array suitable for drupal_render(), potentially containing:
* - menu: The administrative menu of links below the path 'admin/*'.
* - icon: The icon menu.
* - account: The user account name and log out link.
* - users: The user counter.
* Additionally, these special properties:
* - #components: The actual components contained in $content are configurable
* and depend on the 'admin_menu_components' configuration value. #components
* holds a copy of that for convenience.
* - #complete: A Boolean indicating whether the complete menu should be built,
* ignoring the current configuration in #components.
* Passed by reference.
*
* @see hook_admin_menu_output_alter()
* @see admin_menu_links_menu()
* @see admin_menu_links_icon()
* @see admin_menu_links_user()
* @see theme_admin_menu_links()
*/
function hook_admin_menu_output_build(&$content) {
// In case your implementation provides a configurable component, check
// whether the component should be displayed:
if (empty($content['#components']['shortcut.links']) && !$content['#complete']) {
return;
}
// Add new top-level item to the menu.
if (isset($content['menu'])) {
$content['menu']['myitem'] = array(
'#title' => t('My item'),
// #attributes are used for list items (LI).
'#attributes' => array('class' => array('mymodule-myitem')),
'#href' => 'mymodule/path',
// #options are passed to l().
'#options' => array(
'query' => drupal_get_destination(),
// Apply a class on the link (anchor).
'attributes' => array('class' => array('myitem-link-anchor')),
),
// #weight controls the order of links in the resulting item list.
'#weight' => 50,
);
}
// Add link to the icon menu to manually run cron.
if (isset($content['icon'])) {
$content['icon']['myitem']['cron'] = array(
'#title' => t('Run cron'),
'#access' => user_access('administer site configuration'),
'#href' => 'admin/reports/status/run-cron',
);
}
}
/**
* Change the administration menu content before it is rendered.
*
* Only use this hook to alter existing data in the menu structure. Use
* hook_admin_menu_output_build() to *add* new data.
*
* @param array $content
* A structured array suitable for drupal_render(). Passed by reference.
*
* @see hook_admin_menu_output_build()
*/
function hook_admin_menu_output_alter(&$content) {
}
/**
* Return content to be replace via JS in the cached menu output.
*
* @param bool $complete
* A Boolean indicating whether all available components of the menu will be
* output and the cache will be skipped.
*
* @return array
* An associative array whose keys are jQuery selectors and whose values are
* strings containing the replacement content.
*/
function hook_admin_menu_replacements($complete) {
$items = array();
// If the complete menu is output, then it is uncached and will contain the
// current counts already.
if (!$complete) {
// Check whether the users count component is enabled.
$components = variable_get('admin_menu_components', array());
if (!empty($components['admin_menu.users']) && ($user_count = admin_menu_get_user_count())) {
// Replace the counters in the cached menu output with current counts.
$items['.admin-menu-users a'] = $user_count;
}
}
return $items;
}
/**
* Inform about additional module-specific caches that can be cleared.
*
* Administration menu uses this hook to gather information about available
* caches that can be flushed individually. Each returned item forms a separate
* menu link below the "Flush all caches" link in the icon menu.
*
* @return array
* An associative array whose keys denote internal identifiers for a
* particular caches (which can be freely defined, but should be in a module's
* namespace) and whose values are associative arrays containing:
* - title: The name of the cache, without "cache" suffix. This label is
* output as link text, but also for the "!title cache cleared."
* confirmation message after flushing the cache; make sure it works and
* makes sense to users in both locations.
* - callback: The name of a function to invoke to flush the individual cache.
*/
function hook_admin_menu_cache_info() {
$caches['update'] = array(
'title' => t('Update data'),
'callback' => '_update_cache_clear',
);
return $caches;
}

View File

@@ -0,0 +1,46 @@
/**
* @file
* Administration menu color override.
*/
#admin-menu {
background-color: #911;
background-image: url(images/bkg-red.png);
}
#admin-menu li.admin-menu-action a {
border-left-color: #a91f1f;
}
/* All lists */
#admin-menu ul a {
border-right-color: #a91f1f;
}
#admin-menu ul li.admin-menu-tab a {
border-right-color: #52565E;
}
#admin-menu li li a {
border-top-color: #801f1f;
}
/* All list items */
#admin-menu li li {
background-color: #991f1f;
}
/* Second-and-more-level hovering */
#admin-menu li li.expandable {
background-color: #b93f3f;
}
#admin-menu li li:hover,
#admin-menu li li.iehover {
background-color: #690f0f;
}
#admin-menu li li.expandable:hover a,
#admin-menu li li.expandable:hover li.expandable:hover a {
border-color: #801f1f;
}
#admin-menu li li.expandable:hover li a,
#admin-menu li li.expandable:hover li.expandable:hover li a {
border-color: #801f1f;
}

View File

@@ -0,0 +1,250 @@
/**
* @file
* Administration menu.
*
* Implementation of Sons of Suckerfish Dropdowns.
*
* @see www.htmldog.com/articles/suckerfish
*/
#admin-menu {
background: #101010 url(images/bkg.png) bottom left repeat-x;
font-size: 9px;
font-family: "lucida grande", tahoma, verdana, arial, sans-serif;
left: 0;
position: absolute;
text-align: left;
top: 0;
width: 100%;
}
#admin-menu-wrapper {
overflow: hidden;
}
#admin-menu .dropdown .admin-menu-icon a {
padding: 1px 8px 4px;
}
#admin-menu .dropdown .admin-menu-icon ul a {
padding: 4px 8px;
}
#admin-menu .dropdown .admin-menu-icon img {
vertical-align: bottom;
}
#admin-menu .dropdown .admin-menu-users a {
background: transparent url(images/icon_users.png) 90% center no-repeat;
padding-right: 22px;
}
#admin-menu .dropdown .admin-menu-action,
#admin-menu .dropdown .admin-menu-search {
float: right;
}
#admin-menu .dropdown .admin-menu-action a {
border-left: 1px solid #323232;
border-right: none;
}
body.admin-menu {
margin-top: 20px !important;
}
/* All lists */
#admin-menu,
#admin-menu .dropdown {
line-height: 1.4em;
list-style: none;
margin: 0;
padding: 0;
z-index: 999;
}
#admin-menu .dropdown {
position: static;
}
#admin-menu a,
#admin-menu li > span {
background: transparent none;
border: none;
color: #EEE;
font-weight: normal;
text-align: left; /* LTR */
text-decoration: none;
}
#admin-menu .dropdown a,
#admin-menu .dropdown li > span {
border-right: 1px solid #323232; /* LTR */
display: block;
padding: 4px 8px;
}
#admin-menu .dropdown .admin-menu-tab a {
border-right: 1px solid #52565E; /* LTR */
}
#admin-menu .dropdown li li a {
border-right: none; /* LTR */
border-top: 1px solid #323232;
}
/* All list items */
#admin-menu .dropdown li {
background-image: none;
float: left; /* LTR */
height: 100%;
list-style-image: none;
list-style-type: none;
margin: 0 !important;
padding: 0;
}
#admin-menu .dropdown .admin-menu-tab {
background: url(images/bkg_tab.png) repeat-x left bottom;
padding-bottom: 1px;
}
#admin-menu .dropdown li li {
background: #202020;
filter: Alpha(opacity=88);
opacity: 0.88;
width: 160px; /* Required for Opera */
}
#admin-menu .dropdown li li li {
filter: Alpha(opacity=100);
opacity: 1;
}
/* Second-level lists */
/* Note: We must hide sub-lists or scrollbars might appear (display: none is not read by screen readers). */
#admin-menu .dropdown li ul {
background: none;
display: none;
left: -999em; /* LTR */
line-height: 1.2em;
margin: 0;
position: absolute;
width: 160px;
}
/* Third-and-above-level lists */
#admin-menu .dropdown li li.expandable ul {
margin: -20px 0 0 160px; /* LTR */
}
#admin-menu .dropdown li:hover ul ul,
#admin-menu .dropdown li:hover ul ul ul,
#admin-menu .dropdown li:hover ul ul ul ul,
#admin-menu .dropdown li:hover ul ul ul ul ul,
#admin-menu .dropdown li.iehover ul ul,
#admin-menu .dropdown li.iehover ul ul ul,
#admin-menu .dropdown li.iehover ul ul ul ul,
#admin-menu .dropdown li.iehover ul ul ul ul ul {
display: none;
left: -999em; /* LTR */
}
/* Lists nested under hovered list items */
#admin-menu .dropdown li:hover ul,
#admin-menu .dropdown li li:hover ul,
#admin-menu .dropdown li li li:hover ul,
#admin-menu .dropdown li li li li:hover ul,
#admin-menu .dropdown li li li li li:hover ul,
#admin-menu .dropdown li.iehover ul,
#admin-menu .dropdown li li.iehover ul,
#admin-menu .dropdown li li li.iehover ul,
#admin-menu .dropdown li li li li.iehover ul,
#admin-menu .dropdown li li li li li.iehover ul {
display: block;
left: auto; /* LTR */
}
#admin-menu .dropdown li.admin-menu-action:hover ul {
right: 0; /* LTR */
}
/* Second-and-more-level hovering */
#admin-menu .dropdown li li.expandable {
background: #45454A url(images/arrow.png) no-repeat 145px 6px;
}
#admin-menu .dropdown li li:hover,
#admin-menu .dropdown li li.iehover {
background-color: #111;
}
#admin-menu .dropdown li li:hover a,
#admin-menu .dropdown li li:hover li:hover a,
#admin-menu .dropdown li li:hover li:hover li:hover a {
color: #FFF;
}
#admin-menu .dropdown li li.expandable:hover a,
#admin-menu .dropdown li li.expandable:hover li.expandable:hover a {
border-color: #444;
color: #EEE;
}
#admin-menu .dropdown li li.expandable:hover li a,
#admin-menu .dropdown li li.expandable:hover li.expandable:hover li a {
border-color: #323232;
}
#admin-menu .dropdown li li:hover li a,
#admin-menu .dropdown li li.iehover li a,
#admin-menu .dropdown li li.iehover li.iehover li a {
color: #EEE;
}
#admin-menu .dropdown li li.iehover a,
#admin-menu .dropdown li li.iehover li.iehover a,
#admin-menu .dropdown li li.iehover li.iehover li.iehover a {
color: #FFF;
width: 90%; /* IE */
}
/* Search form */
#admin-menu .admin-menu-search .form-item {
margin: 0;
padding: 0;
}
#admin-menu .admin-menu-search input {
background: #fff none center right no-repeat;
border: none;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
font-size: 10px;
margin: 1px 0;
outline: none;
padding: 2px 22px 2px 4px;
width: 158px;
}
#admin-menu .dropdown .admin-menu-search-results {
display: block !important;
left: auto !important;
top: 100%;
}
#admin-menu .admin-menu-search-results,
#admin-menu .admin-menu-search-results li {
width: 186px;
}
#admin-menu li.highlight {
background-color: #eee !important;
}
#admin-menu li.highlight > a {
border-color: #ccc !important;
color: #111 !important;
}
/* #210615: Mozilla on Mac fix */
html.js fieldset.collapsible div.fieldset-wrapper {
overflow: visible;
}
/* Hide the menu on print output. */
@media print {
#admin-menu {
display: none !important;
}
body.admin-menu {
margin-top: 0 !important;
}
}
/**
* Tweaks permissions, if enabled.
*/
tr.admin-menu-tweak-permissions-processed {
cursor: pointer;
cursor: hand;
}
tr.admin-menu-tweak-permissions-processed td.module {
border-top: 0;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,16 @@
name = Administration menu
description = "Provides a dropdown menu to most administrative tasks and other common destinations (to users with the proper permissions)."
package = Administration
core = 7.x
configure = admin/config/administration/admin_menu
; Requires menu_build_tree() conditions; available after 7.10.
; @see http://drupal.org/node/1025582
dependencies[] = system (>7.10)
files[] = tests/admin_menu.test
; Information added by drupal.org packaging script on 2013-01-31
version = "7.x-3.0-rc4"
core = "7.x"
project = "admin_menu"
datestamp = "1359651687"

View File

@@ -0,0 +1,122 @@
<?php
/**
* @file
* Install, update, and uninstall functions for the admin menu module.
*/
/**
* Implements hook_schema().
*/
function admin_menu_schema() {
$schema['cache_admin_menu'] = drupal_get_schema_unprocessed('system', 'cache');
$schema['cache_admin_menu']['description'] = 'Cache table for Administration menu to store client-side caching hashes.';
return $schema;
}
/**
* Implements hook_install().
*/
function admin_menu_install() {
// Increase the module weight, so admin_menu catches any alterations made by
// other modules in hook_menu_alter().
db_update('system')
->fields(array('weight' => 100))
->condition('type', 'module')
->condition('name', 'admin_menu')
->execute();
}
/**
* Implements hook_uninstall().
*/
function admin_menu_uninstall() {
// Delete variables.
variable_del('admin_menu_components');
variable_del('admin_menu_devel_modules');
variable_del('admin_menu_devel_modules_enabled');
variable_del('admin_menu_devel_modules_skip');
variable_del('admin_menu_margin_top');
variable_del('admin_menu_position_fixed');
variable_del('admin_menu_tweak_modules');
variable_del('admin_menu_tweak_tabs');
variable_del('admin_menu_show_all');
variable_del('admin_menu_display');
variable_del('admin_menu_cache_server');
variable_del('admin_menu_cache_client');
}
/**
* Ensure that admin_menu is rebuilt after upgrading to D6.
*/
function admin_menu_update_6000() {
// Drop the {admin_menu} table in admin_menu_update_6000() on sites that used
// one of the later patches in #132524.
if (db_table_exists('admin_menu')) {
db_drop_table('admin_menu');
}
}
/**
* Wipe and rebuild so we can switch the icon path to <front>.
*/
function admin_menu_update_6001() {
db_delete('menu_links')->condition('module', 'admin_menu')->execute();
menu_cache_clear('admin_menu');
}
/**
* Add {cache_admin_menu} table.
*/
function admin_menu_update_7300() {
if (!db_table_exists('cache_admin_menu')) {
$schema = drupal_get_schema_unprocessed('system', 'cache');
db_create_table('cache_admin_menu', $schema);
}
}
/**
* Increase the module weight.
*
* @see admin_menu_install()
*/
function admin_menu_update_7302() {
db_update('system')
->fields(array('weight' => 100))
->condition('type', 'module')
->condition('name', 'admin_menu')
->execute();
}
/**
* Remove local tasks from {menu_links} table.
*/
function admin_menu_update_7303() {
db_delete('menu_router')
->condition('path', 'admin/%', 'LIKE')
->condition('type', MENU_IS_LOCAL_TASK, '&')
->execute();
}
/**
* Remove obsolete 'admin_menu' menu and all orphan links in it.
*/
function admin_menu_update_7304() {
// Remove the custom menu used by 6.x-1.x.
if (db_table_exists('menu_custom')) {
db_delete('menu_custom')->condition('menu_name', 'admin_menu')->execute();
}
// 6.x-1.x cloned the entire link structure below the path 'admin' into a
// separate 'menu_name' "admin_menu" with 'module' "admin_menu". 6.x-3.x and
// early alpha versions of 7.x-3.x still did something similar. All of these
// records are obsolete. Removal of the 'module' records (without different
// menu_name) is particularly important, since they would otherwise appear
// as duplicate links.
db_delete('menu_links')
->condition(db_or()
->condition('module', 'admin_menu')
->condition('menu_name', 'admin_menu')
)
->execute();
}

View File

@@ -0,0 +1,397 @@
(function($) {
Drupal.admin = Drupal.admin || {};
Drupal.admin.behaviors = Drupal.admin.behaviors || {};
Drupal.admin.hashes = Drupal.admin.hashes || {};
/**
* Core behavior for Administration menu.
*
* Test whether there is an administration menu is in the output and execute all
* registered behaviors.
*/
Drupal.behaviors.adminMenu = {
attach: function (context, settings) {
// Initialize settings.
settings.admin_menu = $.extend({
suppress: false,
margin_top: false,
position_fixed: false,
tweak_modules: false,
tweak_permissions: false,
tweak_tabs: false,
destination: '',
basePath: settings.basePath,
hash: 0,
replacements: {}
}, settings.admin_menu || {});
// Check whether administration menu should be suppressed.
if (settings.admin_menu.suppress) {
return;
}
var $adminMenu = $('#admin-menu:not(.admin-menu-processed)', context);
// Client-side caching; if administration menu is not in the output, it is
// fetched from the server and cached in the browser.
if (!$adminMenu.length && settings.admin_menu.hash) {
Drupal.admin.getCache(settings.admin_menu.hash, function (response) {
if (typeof response == 'string' && response.length > 0) {
$('body', context).append(response);
}
var $adminMenu = $('#admin-menu:not(.admin-menu-processed)', context);
// Apply our behaviors.
Drupal.admin.attachBehaviors(context, settings, $adminMenu);
// Allow resize event handlers to recalculate sizes/positions.
$(window).triggerHandler('resize');
});
}
// If the menu is in the output already, this means there is a new version.
else {
// Apply our behaviors.
Drupal.admin.attachBehaviors(context, settings, $adminMenu);
}
}
};
/**
* Collapse fieldsets on Modules page.
*/
Drupal.behaviors.adminMenuCollapseModules = {
attach: function (context, settings) {
if (settings.admin_menu.tweak_modules) {
$('#system-modules fieldset:not(.collapsed)', context).addClass('collapsed');
}
}
};
/**
* Collapse modules on Permissions page.
*/
Drupal.behaviors.adminMenuCollapsePermissions = {
attach: function (context, settings) {
if (settings.admin_menu.tweak_permissions) {
// Freeze width of first column to prevent jumping.
$('#permissions th:first', context).css({ width: $('#permissions th:first', context).width() });
// Attach click handler.
$modules = $('#permissions tr:has(td.module)', context).once('admin-menu-tweak-permissions', function () {
var $module = $(this);
$module.bind('click.admin-menu', function () {
// @todo Replace with .nextUntil() in jQuery 1.4.
$module.nextAll().each(function () {
var $row = $(this);
if ($row.is(':has(td.module)')) {
return false;
}
$row.toggleClass('element-hidden');
});
});
});
// Collapse all but the targeted permission rows set.
if (window.location.hash.length) {
$modules = $modules.not(':has(' + window.location.hash + ')');
}
$modules.trigger('click.admin-menu');
}
}
};
/**
* Apply margin to page.
*
* Note that directly applying marginTop does not work in IE. To prevent
* flickering/jumping page content with client-side caching, this is a regular
* Drupal behavior.
*/
Drupal.behaviors.adminMenuMarginTop = {
attach: function (context, settings) {
if (!settings.admin_menu.suppress && settings.admin_menu.margin_top) {
$('body:not(.admin-menu)', context).addClass('admin-menu');
}
}
};
/**
* Retrieve content from client-side cache.
*
* @param hash
* The md5 hash of the content to retrieve.
* @param onSuccess
* A callback function invoked when the cache request was successful.
*/
Drupal.admin.getCache = function (hash, onSuccess) {
if (Drupal.admin.hashes.hash !== undefined) {
return Drupal.admin.hashes.hash;
}
$.ajax({
cache: true,
type: 'GET',
dataType: 'text', // Prevent auto-evaluation of response.
global: false, // Do not trigger global AJAX events.
url: Drupal.settings.admin_menu.basePath.replace(/admin_menu/, 'js/admin_menu/cache/' + hash),
success: onSuccess,
complete: function (XMLHttpRequest, status) {
Drupal.admin.hashes.hash = status;
}
});
};
/**
* TableHeader callback to determine top viewport offset.
*
* @see toolbar.js
*/
Drupal.admin.height = function() {
var $adminMenu = $('#admin-menu');
var height = $adminMenu.outerHeight();
// In IE, Shadow filter adds some extra height, so we need to remove it from
// the returned height.
if ($adminMenu.css('filter') && $adminMenu.css('filter').match(/DXImageTransform\.Microsoft\.Shadow/)) {
height -= $adminMenu.get(0).filters.item("DXImageTransform.Microsoft.Shadow").strength;
}
return height;
};
/**
* @defgroup admin_behaviors Administration behaviors.
* @{
*/
/**
* Attach administrative behaviors.
*/
Drupal.admin.attachBehaviors = function (context, settings, $adminMenu) {
if ($adminMenu.length) {
$adminMenu.addClass('admin-menu-processed');
$.each(Drupal.admin.behaviors, function() {
this(context, settings, $adminMenu);
});
}
};
/**
* Apply 'position: fixed'.
*/
Drupal.admin.behaviors.positionFixed = function (context, settings, $adminMenu) {
if (settings.admin_menu.position_fixed) {
$adminMenu.addClass('admin-menu-position-fixed');
$adminMenu.css('position', 'fixed');
}
};
/**
* Move page tabs into administration menu.
*/
Drupal.admin.behaviors.pageTabs = function (context, settings, $adminMenu) {
if (settings.admin_menu.tweak_tabs) {
var $tabs = $(context).find('ul.tabs.primary');
$adminMenu.find('#admin-menu-wrapper > ul').eq(1)
.append($tabs.find('li').addClass('admin-menu-tab'));
$(context).find('ul.tabs.secondary')
.appendTo('#admin-menu-wrapper > ul > li.admin-menu-tab.active')
.removeClass('secondary');
$tabs.remove();
}
};
/**
* Perform dynamic replacements in cached menu.
*/
Drupal.admin.behaviors.replacements = function (context, settings, $adminMenu) {
for (var item in settings.admin_menu.replacements) {
$(item, $adminMenu).html(settings.admin_menu.replacements[item]);
}
};
/**
* Inject destination query strings for current page.
*/
Drupal.admin.behaviors.destination = function (context, settings, $adminMenu) {
if (settings.admin_menu.destination) {
$('a.admin-menu-destination', $adminMenu).each(function() {
this.search += (!this.search.length ? '?' : '&') + Drupal.settings.admin_menu.destination;
});
}
};
/**
* Apply JavaScript-based hovering behaviors.
*
* @todo This has to run last. If another script registers additional behaviors
* it will not run last.
*/
Drupal.admin.behaviors.hover = function (context, settings, $adminMenu) {
// Hover emulation for IE 6.
if ($.browser.msie && parseInt(jQuery.browser.version) == 6) {
$('li', $adminMenu).hover(
function () {
$(this).addClass('iehover');
},
function () {
$(this).removeClass('iehover');
}
);
}
// Delayed mouseout.
$('li.expandable', $adminMenu).hover(
function () {
// Stop the timer.
clearTimeout(this.sfTimer);
// Display child lists.
$('> ul', this)
.css({left: 'auto', display: 'block'})
// Immediately hide nephew lists.
.parent().siblings('li').children('ul').css({left: '-999em', display: 'none'});
},
function () {
// Start the timer.
var uls = $('> ul', this);
this.sfTimer = setTimeout(function () {
uls.css({left: '-999em', display: 'none'});
}, 400);
}
);
};
/**
* Apply the search bar functionality.
*/
Drupal.admin.behaviors.search = function (context, settings, $adminMenu) {
// @todo Add a HTML ID.
var $input = $('input.admin-menu-search', $adminMenu);
// Initialize the current search needle.
var needle = $input.val();
// Cache of all links that can be matched in the menu.
var links;
// Minimum search needle length.
var needleMinLength = 2;
// Append the results container.
var $results = $('<div />').insertAfter($input);
/**
* Executes the search upon user input.
*/
function keyupHandler() {
var matches, $html, value = $(this).val();
// Only proceed if the search needle has changed.
if (value !== needle) {
needle = value;
// Initialize the cache of menu links upon first search.
if (!links && needle.length >= needleMinLength) {
// @todo Limit to links in dropdown menus; i.e., skip menu additions.
links = buildSearchIndex($adminMenu.find('li:not(.admin-menu-action, .admin-menu-action li) > a'));
}
// Empty results container when deleting search text.
if (needle.length < needleMinLength) {
$results.empty();
}
// Only search if the needle is long enough.
if (needle.length >= needleMinLength && links) {
matches = findMatches(needle, links);
// Build the list in a detached DOM node.
$html = buildResultsList(matches);
// Display results.
$results.empty().append($html);
}
}
}
/**
* Builds the search index.
*/
function buildSearchIndex($links) {
return $links
.map(function () {
var text = (this.textContent || this.innerText);
// Skip menu entries that do not contain any text (e.g., the icon).
if (typeof text === 'undefined') {
return;
}
return {
text: text,
textMatch: text.toLowerCase(),
element: this
};
});
}
/**
* Searches the index for a given needle and returns matching entries.
*/
function findMatches(needle, links) {
var needleMatch = needle.toLowerCase();
// Select matching links from the cache.
return $.grep(links, function (link) {
return link.textMatch.indexOf(needleMatch) !== -1;
});
}
/**
* Builds the search result list in a detached DOM node.
*/
function buildResultsList(matches) {
var $html = $('<ul class="dropdown admin-menu-search-results" />');
$.each(matches, function () {
var result = this.text;
var $element = $(this.element);
// Check whether there is a top-level category that can be prepended.
var $category = $element.closest('#admin-menu-wrapper > ul > li');
var categoryText = $category.find('> a').text()
if ($category.length && categoryText) {
result = categoryText + ': ' + result;
}
var $result = $('<li><a href="' + $element.attr('href') + '">' + result + '</a></li>');
$result.data('original-link', $(this.element).parent());
$html.append($result);
});
return $html;
}
/**
* Highlights selected result.
*/
function resultsHandler(e) {
var $this = $(this);
var show = e.type === 'mouseenter' || e.type === 'focusin';
$this.trigger(show ? 'showPath' : 'hidePath', [this]);
}
/**
* Closes the search results and clears the search input.
*/
function resultsClickHandler(e, link) {
var $original = $(this).data('original-link');
$original.trigger('mouseleave');
$input.val('').trigger('keyup');
}
/**
* Shows the link in the menu that corresponds to a search result.
*/
function highlightPathHandler(e, link) {
if (link) {
var $original = $(link).data('original-link');
var show = e.type === 'showPath';
// Toggle an additional CSS class to visually highlight the matching link.
// @todo Consider using same visual appearance as regular hover.
$original.toggleClass('highlight', show);
$original.trigger(show ? 'mouseenter' : 'mouseleave');
}
}
// Attach showPath/hidePath handler to search result entries.
$results.delegate('li', 'mouseenter mouseleave focus blur', resultsHandler);
// Hide the result list after a link has been clicked, useful for overlay.
$results.delegate('li', 'click', resultsClickHandler);
// Attach hover/active highlight behavior to search result entries.
$adminMenu.delegate('.admin-menu-search-results li', 'showPath hidePath', highlightPathHandler);
// Attach the search input event handler.
$input.bind('keyup search', keyupHandler);
};
/**
* @} End of "defgroup admin_behaviors".
*/
})(jQuery);

View File

@@ -0,0 +1,164 @@
<?php
/**
* @file
* Implements hook_admin_menu_map() on behalf of core modules.
*
* @todo Replace all/most of those API functions with direct DB queries;
* we only need the menu arguments (keys), not fully loaded objects.
*/
/**
* Implements hook_admin_menu_map() on behalf of Filter module.
*/
function filter_admin_menu_map() {
if (!user_access('administer filters')) {
return;
}
$map['admin/config/content/formats/%filter_format'] = array(
'parent' => 'admin/config/content/formats',
'arguments' => array(
array('%filter_format' => array_keys(filter_formats())),
),
);
return $map;
}
/**
* Implements hook_admin_menu_map() on behalf of Menu module.
*/
function menu_admin_menu_map() {
if (!user_access('administer menu')) {
return;
}
$map['admin/structure/menu/manage/%menu'] = array(
'parent' => 'admin/structure/menu',
'arguments' => array(
array('%menu' => array_keys(menu_get_menus())),
),
);
return $map;
}
/**
* Implements hook_admin_menu_map() on behalf of Node module.
*/
function node_admin_menu_map() {
if (!user_access('administer content types')) {
return;
}
$map['admin/structure/types/manage/%node_type'] = array(
'parent' => 'admin/structure/types',
'arguments' => array(
array('%node_type' => array_keys(node_type_get_types())),
),
);
return $map;
}
/**
* Implements hook_admin_menu_map() on behalf of Field UI module.
*/
function field_ui_admin_menu_map() {
$map = array();
foreach (entity_get_info() as $obj_type => $info) {
foreach ($info['bundles'] as $bundle_name => $bundle_info) {
if (isset($bundle_info['admin'])) {
$arguments = array();
switch ($obj_type) {
case 'comment':
$fields = array();
foreach (field_info_instances($obj_type, $bundle_name) as $field) {
$fields[] = $field['field_name'];
}
// @todo Make Comment module expose the original node type bundle,
// pretty please.
if (drupal_substr($bundle_name, 0, 13) == 'comment_node_') {
$bundle_name = drupal_substr($bundle_name, 13);
}
// @todo Doesn't work yet. Why?
$arguments = array(
'%comment_node_type' => array($bundle_name),
'%field_ui_menu' => $fields,
);
break;
case 'node':
$fields = array();
foreach (field_info_instances($obj_type, $bundle_name) as $field) {
$fields[] = $field['field_name'];
}
$arguments = array(
'%node_type' => array($bundle_name),
'%field_ui_menu' => $fields,
);
break;
case 'taxonomy_term':
$fields = array();
foreach (field_info_instances($obj_type, $bundle_name) as $field) {
$fields[] = $field['field_name'];
}
// Map machine_name to vid.
$arguments = array(
'%taxonomy_vocabulary_machine_name' => array($bundle_name),
'%field_ui_menu' => $fields,
);
break;
case 'user':
$arguments = array(
'%field_ui_menu' => array_keys(field_info_fields('user')),
);
break;
}
if (!empty($arguments)) {
$path = $bundle_info['admin']['path'];
$map["$path/fields/%field_ui_menu"]['parent'] = "$path/fields";
$map["$path/fields/%field_ui_menu"]['arguments'][] = $arguments;
}
}
}
}
return $map;
}
/**
* Implements hook_admin_menu_map() on behalf of Taxonomy module.
*/
function taxonomy_admin_menu_map() {
if (!user_access('administer taxonomy')) {
return;
}
$map['admin/structure/taxonomy/%taxonomy_vocabulary_machine_name'] = array(
'parent' => 'admin/structure/taxonomy',
'arguments' => array(
array('%taxonomy_vocabulary_machine_name' => array_keys(taxonomy_vocabulary_get_names())),
),
);
return $map;
}
/**
* Implements hook_admin_menu_map() on behalf of Views UI module.
*/
function views_ui_admin_menu_map() {
if (!user_access('administer views')) {
return;
}
$views = array();
foreach (views_get_enabled_views() as $name => $view) {
$views[] = $name;
}
if (empty($views)) {
return;
}
$map['admin/structure/views/view/%views_ui_cache'] = array(
'parent' => 'admin/structure/views',
'arguments' => array(
array('%views_ui_cache' => $views),
),
);
return $map;
}

View File

@@ -0,0 +1,858 @@
<?php
/**
* @file
* Render an administrative menu as a dropdown menu at the top of the window.
*/
/**
* Implements hook_help().
*/
function admin_menu_help($path, $arg) {
switch ($path) {
case 'admin/config/administration/admin_menu':
return '<p>' . t('The administration menu module provides a dropdown menu arranged for one- or two-click access to most administrative tasks and other common destinations (to users with the proper permissions). Use the settings below to customize the appearance of the menu.') . '</p>';
case 'admin/help#admin_menu':
$output = '';
$output .= '<p>' . t('The administration menu module provides a dropdown menu arranged for one- or two-click access to most administrative tasks and other common destinations (to users with the proper permissions). Administration menu also displays the number of anonymous and authenticated users, and allows modules to add their own custom menu items. Integration with the menu varies from module to module; the contributed module <a href="@drupal">Devel</a>, for instance, makes strong use of the administration menu module to provide quick access to development tools.', array('@drupal' => 'http://drupal.org/project/devel')) . '</p>';
$output .= '<p>' . t('The administration menu <a href="@settings">settings page</a> allows you to modify some elements of the menu\'s behavior and appearance. Since the appearance of the menu is dependent on your site theme, substantial customizations require modifications to your site\'s theme and CSS files. See the advanced module README.txt file for more information on theme and CSS customizations.', array('@settings' => url('admin/config/administration/admin_menu'))) . '</p>';
$output .= '<p>' . t('The menu items displayed in the administration menu depend upon the actual permissions of the viewer. First, the administration menu is only displayed to users in roles with the <em>Access administration menu</em> (admin_menu module) permission. Second, a user must be a member of a role with the <em>Access administration pages</em> (system module) permission to view administrative links. And, third, only currently permitted links are displayed; for example, if a user is not a member of a role with the permissions <em>Administer permissions</em> (user module) and <em>Administer users</em> (user module), the <em>User management</em> menu item is not displayed.') . '</p>';
return $output;
}
}
/**
* Implements hook_permission().
*/
function admin_menu_permission() {
return array(
'access administration menu' => array(
'title' => t('Access administration menu'),
'description' => t('Display the administration menu at the top of each page.'),
),
'flush caches' => array(
'title' => t('Flush caches'),
'description' => t('Access links to flush caches in the administration menu.'),
),
'display drupal links' => array(
'title' => t('Display Drupal links'),
'description' => t('Provide Drupal.org links in the administration menu.'),
),
);
}
/**
* Implements hook_theme().
*/
function admin_menu_theme() {
return array(
'admin_menu_links' => array(
'render element' => 'elements',
),
'admin_menu_icon' => array(
'variables' => array('src' => NULL, 'alt' => NULL),
'file' => 'admin_menu.inc',
),
);
}
/**
* Implements hook_menu().
*/
function admin_menu_menu() {
// AJAX callback.
// @see http://drupal.org/project/js
$items['js/admin_menu/cache'] = array(
'page callback' => 'admin_menu_js_cache',
'delivery callback' => 'admin_menu_deliver',
'access arguments' => array('access administration menu'),
'type' => MENU_CALLBACK,
);
// Module settings.
$items['admin/config/administration'] = array(
'title' => 'Administration',
'description' => 'Administration tools.',
'page callback' => 'system_admin_menu_block_page',
'access arguments' => array('access administration pages'),
'file' => 'system.admin.inc',
'file path' => drupal_get_path('module', 'system'),
);
$items['admin/config/administration/admin_menu'] = array(
'title' => 'Administration menu',
'description' => 'Adjust administration menu settings.',
'page callback' => 'drupal_get_form',
'page arguments' => array('admin_menu_theme_settings'),
'access arguments' => array('administer site configuration'),
'file' => 'admin_menu.inc',
);
// Menu link callbacks.
$items['admin_menu/toggle-modules'] = array(
'page callback' => 'admin_menu_toggle_modules',
'access arguments' => array('administer modules'),
'type' => MENU_CALLBACK,
'file' => 'admin_menu.inc',
);
$items['admin_menu/flush-cache'] = array(
'page callback' => 'admin_menu_flush_cache',
'access arguments' => array('flush caches'),
'type' => MENU_CALLBACK,
'file' => 'admin_menu.inc',
);
return $items;
}
/**
* Implements hook_menu_alter().
*/
function admin_menu_menu_alter(&$items) {
// Flush client-side caches whenever the menu is rebuilt.
admin_menu_flush_caches();
}
/**
* Implements hook_menu_link_insert().
*/
function admin_menu_menu_link_insert($link) {
// Flush all of our caches to pick up the link.
admin_menu_flush_caches();
}
/**
* Implements hook_menu_link_update().
*/
function admin_menu_menu_link_update($link) {
// Flush all of our caches to pick up the link.
admin_menu_flush_caches();
}
/**
* Implements hook_menu_link_delete().
*/
function admin_menu_menu_link_delete($link) {
// Flush all of our caches to pick up the link.
admin_menu_flush_caches();
}
/**
* Implements hook_system_info_alter().
*
* Indicate that the 'page_bottom' region (in which the administration menu
* is displayed) is an overlay supplemental region that should be refreshed
* whenever its content is updated.
*
* @see toolbar_system_info_alter()
*/
function admin_menu_system_info_alter(&$info, $file, $type) {
if ($type == 'theme') {
$info['overlay_supplemental_regions'][] = 'page_bottom';
}
}
/**
* Implements hook_page_build().
*/
function admin_menu_page_build(&$page) {
if (!user_access('access administration menu') || admin_menu_suppress(FALSE)) {
return;
}
// Performance: Skip this entirely for AJAX requests.
if (strpos($_GET['q'], 'js/') === 0) {
return;
}
global $user, $language;
$path = drupal_get_path('module', 'admin_menu');
$page['page_bottom']['admin_menu'] = array(
'#attached' => array(),
);
$attached = &$page['page_bottom']['admin_menu']['#attached'];
$options = array('every_page' => TRUE);
$attached['css'][$path . '/admin_menu.css'] = $options;
if ($user->uid == 1) {
$attached['css'][$path . '/admin_menu.uid1.css'] = $options;
}
// Previous versions used the 'defer' attribute to increase browser rendering
// performance. At least starting with Firefox 3.6, deferred .js files are
// loaded, but Drupal.behaviors are not contained in the DOM when drupal.js
// executes Drupal.attachBehaviors().
$attached['js'][$path . '/admin_menu.js'] = $options;
// Destination query strings are applied via JS.
$settings['destination'] = drupal_http_build_query(drupal_get_destination());
// Determine whether we need to show all components and disable all caches.
$complete = FALSE;
if (current_path() == 'admin/config/administration/admin_menu' && $_SERVER['REQUEST_METHOD'] == 'GET') {
$complete = TRUE;
}
// If the client supports JavaScript and we have a cached menu for the current
// user, only output the hash for the client-side HTTP cache callback URL.
$cid = 'admin_menu:' . $user->uid . ':' . session_id() . ':' . $language->language;
if (!$complete && !empty($_COOKIE['has_js']) && ($hash = admin_menu_cache_get($cid))) {
$settings['hash'] = $hash;
// The base path to use for cache requests depends on whether clean URLs
// are enabled, whether Drupal runs in a sub-directory, and on the language
// system configuration. url() already provides us the proper path and also
// invokes potentially existing custom_url_rewrite() functions, which may
// add further required components to the URL to provide context. Due to
// those components, and since url('') returns only base_path() when clean
// URLs are disabled, we need to use a replacement token as path. Yuck.
$settings['basePath'] = url('admin_menu');
}
// Otherwise, add the full menu to the page.
else {
$page['page_bottom']['admin_menu']['#markup'] = admin_menu_output($complete);
}
$replacements = module_invoke_all('admin_menu_replacements', $complete);
if (!empty($replacements)) {
$settings['replacements'] = $replacements;
}
if ($setting = variable_get('admin_menu_margin_top', 1)) {
$settings['margin_top'] = $setting;
// @todo Drupal.behaviors.adminMenuMarginTop is obsolete, but
// hook_page_build() does not allow to set a CSS class on the body yet.
// @see http://drupal.org/node/1473548, http://drupal.org/node/1194528
//$page['#attributes']['class'][] = 'admin-menu';
}
if ($setting = variable_get('admin_menu_position_fixed', 1)) {
$settings['position_fixed'] = $setting;
// In fixed positioning, supply a callback function for tableheader.js to
// allow it to determine the top viewport offset.
// @see admin_menu.js, toolbar.js
$attached['js'][] = array(
'data' => array('tableHeaderOffset' => 'Drupal.admin.height'),
'type' => 'setting',
);
}
if ($setting = variable_get('admin_menu_tweak_tabs', 0)) {
$settings['tweak_tabs'] = $setting;
}
if ($_GET['q'] == 'admin/modules' || strpos($_GET['q'], 'admin/modules/list') === 0) {
$settings['tweak_modules'] = variable_get('admin_menu_tweak_modules', 0);
}
if ($_GET['q'] == 'admin/people/permissions' || $_GET['q'] == 'admin/people/permissions/list') {
$settings['tweak_permissions'] = variable_get('admin_menu_tweak_permissions', 0);
}
$attached['js'][] = array(
'data' => array('admin_menu' => $settings),
'type' => 'setting',
);
}
/**
* Suppress display of administration menu.
*
* This function should be called from within another module's page callback
* (preferably using module_invoke()) when the menu should not be displayed.
* This is useful for modules that implement popup pages or other special
* pages where the menu would be distracting or break the layout.
*
* @param $set
* Defaults to TRUE. If called before hook_footer(), the menu will not be
* displayed. If FALSE is passed, the suppression state is returned.
*/
function admin_menu_suppress($set = TRUE) {
static $suppress = FALSE;
// drupal_add_js() must only be invoked once.
if (!empty($set) && $suppress === FALSE) {
$suppress = TRUE;
drupal_add_js(array('admin_menu' => array('suppress' => 1)), 'setting');
}
return $suppress;
}
/**
* Implements hook_js().
*/
function admin_menu_js() {
return array(
'cache' => array(
'callback' => 'admin_menu_js_cache',
'includes' => array('common', 'theme', 'unicode'),
'dependencies' => array('devel', 'filter', 'user'),
),
);
}
/**
* Retrieve a client-side cache hash from cache.
*
* The hash cache is consulted more than once per request; we therefore cache
* the results statically to avoid multiple database requests.
*
* This should only be used for client-side cache hashes. Use cache_menu for
* administration menu content.
*
* @param $cid
* The cache ID of the data to retrieve.
*/
function admin_menu_cache_get($cid) {
$cache = &drupal_static(__FUNCTION__, array());
if (!variable_get('admin_menu_cache_client', TRUE)) {
return FALSE;
}
if (!array_key_exists($cid, $cache)) {
$cache[$cid] = cache_get($cid, 'cache_admin_menu');
if ($cache[$cid] && isset($cache[$cid]->data)) {
$cache[$cid] = $cache[$cid]->data;
}
}
return $cache[$cid];
}
/**
* Store a client-side cache hash in persistent cache.
*
* This should only be used for client-side cache hashes. Use cache_menu for
* administration menu content.
*
* @param $cid
* The cache ID of the data to retrieve.
*/
function admin_menu_cache_set($cid, $data) {
if (variable_get('admin_menu_cache_client', TRUE)) {
cache_set($cid, $data, 'cache_admin_menu');
}
}
/**
* Menu callback; Output administration menu for HTTP caching via AJAX request.
*
* @see admin_menu_deliver()
*/
function admin_menu_js_cache() {
global $conf;
// Suppress Devel module.
$GLOBALS['devel_shutdown'] = FALSE;
// Enforce page caching.
$conf['cache'] = 1;
drupal_page_is_cacheable(TRUE);
// If we have a cache, serve it.
// @see _drupal_bootstrap_page_cache()
$cache = drupal_page_get_cache();
if (is_object($cache)) {
header('X-Drupal-Cache: HIT');
// Restore the metadata cached with the page.
$_GET['q'] = $cache->data['path'];
date_default_timezone_set(drupal_get_user_timezone());
drupal_serve_page_from_cache($cache);
// We are done.
exit;
}
// Otherwise, create a new page response (that will be cached).
header('X-Drupal-Cache: MISS');
// The Expires HTTP header is the heart of the client-side HTTP caching. The
// additional server-side page cache only takes effect when the client
// accesses the callback URL again (e.g., after clearing the browser cache or
// when force-reloading a Drupal page).
$max_age = 3600 * 24 * 365;
drupal_add_http_header('Expires', gmdate(DATE_RFC1123, REQUEST_TIME + $max_age));
drupal_add_http_header('Cache-Control', 'private, max-age=' . $max_age);
// Retrieve and return the rendered menu.
return admin_menu_output();
}
/**
* Delivery callback for client-side HTTP caching.
*
* @see admin_menu_js_cache()
*/
function admin_menu_deliver($page_callback_result) {
drupal_add_http_header('Content-Type', 'text/html; charset=utf-8');
// Send appropriate language header for browsers.
global $language;
drupal_add_http_header('Content-Language', $language->language);
// The page callback is always admin_menu_js_cache(), which always returns a
// string, and is only accessed when the user actually has access to it.
// Therefore, we do not care for the other possible page callback results.
print $page_callback_result;
// Perform end-of-request tasks. The page cache is created here.
drupal_page_footer();
}
/**
* Implements hook_admin_menu_replacements().
*/
function admin_menu_admin_menu_replacements($complete) {
$items = array();
// If the complete menu is output, then it is uncached and will contain the
// current counts already.
if (!$complete) {
// Check whether the users count component is enabled.
$components = variable_get('admin_menu_components', array());
if (!empty($components['admin_menu.users']) && ($user_count = admin_menu_get_user_count())) {
// Replace the counters in the cached menu output with current counts.
$items['.admin-menu-users a'] = $user_count;
}
}
return $items;
}
/**
* Return count of online anonymous/authenticated users.
*
* @see user_block(), user.module
*/
function admin_menu_get_user_count() {
$interval = REQUEST_TIME - variable_get('user_block_seconds_online', 900);
$count_anon = admin_menu_session_count($interval, TRUE);
$count_auth = admin_menu_session_count($interval, FALSE);
return t('@count-anon / @count-auth', array('@count-anon' => $count_anon, '@count-auth' => $count_auth));
}
/**
* Counts how many users are active on the site.
*
* Counts how many users have sessions which have been active since the
* specified time. Can count either anonymous sessions or authenticated
* sessions.
*
* @param $timestamp
* A Unix timestamp. Users who have been active since this time will be
* counted. The default is 0, which counts all existing sessions.
* @param $anonymous
* TRUE counts only anonymous users. FALSE counts only authenticated users.
*
* @return
* The number of users with sessions.
*
* @todo There are mostly no anonymous sessions anymore. Split this into a
* separate module providing proper user statistics.
*/
function admin_menu_session_count($timestamp = 0, $anonymous = TRUE) {
$query = db_select('sessions');
$query->addExpression('COUNT(sid)', 'count');
$query->condition('timestamp', $timestamp, '>=');
$query->condition('uid', 0, $anonymous ? '=' : '>');
return $query->execute()->fetchField();
}
/**
* Build the administration menu output.
*
* @param bool $complete
* (optional) Whether to build to the complete menu including all components
* and ignore the cache. Defaults to FALSE. Internally used for the settings
* page.
*/
function admin_menu_output($complete = FALSE) {
global $user, $language;
$cache_server_enabled = !$complete && variable_get('admin_menu_cache_server', TRUE);
$cid = 'admin_menu:' . $user->uid . ':' . session_id() . ':' . $language->language;
// Try to load and output administration menu from server-side cache.
// @todo Duplicates the page cache? Page cache ID contains the hash that is
// generated at the bottom of this function, which is based on $content,
// but logically identical to the $cid. Investigate whether not only the
// cache_menu but also the cache_admin_menu could be dropped; the
// client-side HTTP cache hash check could be based on a cid lookup in
// cache_page instead? (i.e., one cache to rule them all) However,
// cache_page is cleared very often.
if ($cache_server_enabled) {
$cache = cache_get($cid, 'cache_menu');
if ($cache && isset($cache->data)) {
$content = $cache->data;
}
}
// Rebuild the output.
if (!isset($content)) {
// Retrieve enabled components to display and make them available for others.
$components = variable_get('admin_menu_components', array());
$components += array(
'admin_menu.menu' => TRUE,
'admin_menu.icon' => TRUE,
'admin_menu.account' => TRUE,
);
$content['#components'] = $components;
$content['#complete'] = $complete;
// Add site name as CSS class for development/staging theming purposes. We
// leverage the cookie domain instead of HTTP_HOST to account for many (but
// not all) multi-domain setups (e.g. language-based sub-domains).
$classes = 'admin-menu-site' . drupal_strtolower(preg_replace('/[^a-zA-Z0-9-]/', '-', $GLOBALS['cookie_domain']));
// Displace overlay.
// @see Drupal.overlay.create
// @see toolbar_preprocess_toolbar()
if (module_exists('overlay')) {
$classes .= ' overlay-displace-top';
}
// @todo Always output container to harden JS-less support.
$content['#prefix'] = '<div id="admin-menu" class="' . $classes . '"><div id="admin-menu-wrapper">';
$content['#suffix'] = '</div></div>';
// Load menu builder functions.
module_load_include('inc', 'admin_menu');
// @todo Move the below callbacks into hook_admin_menu_build()
// implementations (and $module.admin_menu.inc).
// Add administration menu.
if (!empty($components['admin_menu.menu']) || $complete) {
$content['menu'] = admin_menu_links_menu(admin_menu_tree('management'));
$content['menu']['#theme'] = 'admin_menu_links';
$content['menu']['#wrapper_attributes']['id'] = 'admin-menu-menu';
// Ensure the menu tree is rendered between the icon and user links.
$content['menu']['#weight'] = 0;
}
// Add menu additions.
if (!empty($components['admin_menu.icon']) || $complete) {
$content['icon'] = admin_menu_links_icon();
}
if (!empty($components['admin_menu.account']) || $complete) {
$content['account'] = admin_menu_links_account();
}
if (!empty($components['admin_menu.users']) || $complete) {
$content['users'] = admin_menu_links_users();
}
if (!empty($components['admin_menu.search']) || $complete) {
$content['search'] = admin_menu_links_search();
}
// Allow modules to enhance the menu.
// Uses '_output' suffix for consistency with the alter hook (see below).
foreach (module_implements('admin_menu_output_build') as $module) {
$function = $module . '_admin_menu_output_build';
$function($content);
}
// Allow modules to alter the output.
// The '_output' suffix is required to prevent hook implementation function
// name clashes with the contributed Admin module.
drupal_alter('admin_menu_output', $content);
$content = drupal_render($content);
// Cache the menu for this user.
if ($cache_server_enabled) {
cache_set($cid, $content, 'cache_menu');
}
}
// Store the new hash for this user.
if (!empty($_COOKIE['has_js']) && !$complete) {
admin_menu_cache_set($cid, md5($content));
}
return $content;
}
/**
* Implements hook_admin_menu_output_build().
*/
function admin_menu_admin_menu_output_build(&$content) {
if (!isset($content['menu'])) {
return;
}
// Unassign weights for categories below Configuration.
// An alphabetical order is more natural for a dropdown menu.
if (isset($content['menu']['admin/config'])) {
foreach (element_children($content['menu']['admin/config']) as $key) {
$content['menu']['admin/config'][$key]['#weight_original'] = $content['menu']['admin/config'][$key]['#weight'];
unset($content['menu']['admin/config'][$key]['#weight']);
}
}
// Retrieve the "Add content" link tree.
$link = db_query("SELECT * FROM {menu_links} WHERE router_path = 'node/add' AND module = 'system'")->fetchAssoc();
$conditions = array();
for ($i = 1; $i < MENU_MAX_DEPTH; $i++) {
if (!empty($link["p$i"])) {
$conditions["p$i"] = $link["p$i"];
}
}
$tree = menu_build_tree($link['menu_name'], array(
'conditions' => $conditions,
'min_depth' => $link['depth'],
));
$links = admin_menu_links_menu($tree);
if (!empty($links)) {
// If the user has access to the top-level "Content" category, insert the
// "Add content" link tree there.
if (isset($content['menu']['admin/content'])) {
$content['menu']['admin/content'] += $links;
}
// Otherwise make insert "Add content" as top-level category.
else {
$key = key($links);
$links[$key]['#weight'] = -100;
$content['menu'] += $links;
}
}
}
/**
* Implements hook_admin_menu_output_alter().
*/
function admin_menu_admin_menu_output_alter(&$content) {
foreach ($content['menu'] as $key => $link) {
// Move local tasks on 'admin' into icon menu.
if ($key == 'admin/tasks' || $key == 'admin/index') {
$content['icon']['icon'][$key] = $link;
unset($content['menu'][$key]);
}
}
}
/**
* Render a themed list of links.
*
* @param $variables
* - elements: A renderable array of links using the following keys:
* - #attributes: Optional array of attributes for the list item, processed
* via drupal_attributes().
* - #title: Title of the link, passed to l().
* - #href: Optional path of the link, passed to l(). When omitted, the
* element's '#title' is rendered without link.
* - #description: Optional alternative text for the link, passed to l().
* - #options: Optional alternative text for the link, passed to l().
* The array key of each child element itself is passed as path for l().
*/
function theme_admin_menu_links($variables) {
$destination = &drupal_static('admin_menu_destination');
$elements = $variables['elements'];
if (!isset($destination)) {
$destination = drupal_get_destination();
$destination = $destination['destination'];
}
// The majority of items in the menu are sorted already, but since modules
// may add or change arbitrary items anywhere, there is no way around sorting
// everything again. element_sort() is not sufficient here, as it
// intentionally retains the order of elements having the same #weight,
// whereas menu links are supposed to be ordered by #weight and #title.
uasort($elements, 'admin_menu_element_sort');
$elements['#sorted'] = TRUE;
$output = '';
foreach (element_children($elements) as $path) {
// Early-return nothing if user does not have access.
if (isset($elements[$path]['#access']) && !$elements[$path]['#access']) {
continue;
}
$elements[$path] += array(
'#attributes' => array(),
'#options' => array(),
);
// Render children to determine whether this link is expandable.
if (isset($elements[$path]['#type']) || isset($elements[$path]['#theme']) || isset($elements[$path]['#pre_render'])) {
$elements[$path]['#children'] = drupal_render($elements[$path]);
}
else {
$elements[$path]['#children'] = theme('admin_menu_links', array('elements' => $elements[$path]));
if (!empty($elements[$path]['#children'])) {
$elements[$path]['#attributes']['class'][] = 'expandable';
}
if (isset($elements[$path]['#attributes']['class'])) {
$elements[$path]['#attributes']['class'] = $elements[$path]['#attributes']['class'];
}
}
$link = '';
// Handle menu links.
if (isset($elements[$path]['#href'])) {
// Strip destination query string from href attribute and apply a CSS class
// for our JavaScript behavior instead.
if (isset($elements[$path]['#options']['query']['destination']) && $elements[$path]['#options']['query']['destination'] == $destination) {
unset($elements[$path]['#options']['query']['destination']);
$elements[$path]['#options']['attributes']['class'][] = 'admin-menu-destination';
}
$link = l($elements[$path]['#title'], $elements[$path]['#href'], $elements[$path]['#options']);
}
// Handle plain text items, but do not interfere with menu additions.
elseif (!isset($elements[$path]['#type']) && isset($elements[$path]['#title'])) {
if (!empty($elements[$path]['#options']['html'])) {
$title = $elements[$path]['#title'];
}
else {
$title = check_plain($elements[$path]['#title']);
}
$attributes = '';
if (isset($elements[$path]['#options']['attributes'])) {
$attributes = drupal_attributes($elements[$path]['#options']['attributes']);
}
$link = '<span' . $attributes . '>' . $title . '</span>';
}
$output .= '<li' . drupal_attributes($elements[$path]['#attributes']) . '>';
$output .= $link . $elements[$path]['#children'];
$output .= '</li>';
}
// @todo #attributes probably required for UL, but already used for LI.
// @todo Use $element['#children'] here instead.
if ($output) {
$elements['#wrapper_attributes']['class'][] = 'dropdown';
$attributes = drupal_attributes($elements['#wrapper_attributes']);
$output = "\n" . '<ul' . $attributes . '>' . $output . '</ul>';
}
return $output;
}
/**
* Function used by uasort to sort structured arrays by #weight AND #title.
*/
function admin_menu_element_sort($a, $b) {
// @see element_sort()
$a_weight = isset($a['#weight']) ? $a['#weight'] : 0;
$b_weight = isset($b['#weight']) ? $b['#weight'] : 0;
if ($a_weight == $b_weight) {
// @see element_sort_by_title()
$a_title = isset($a['#title']) ? $a['#title'] : '';
$b_title = isset($b['#title']) ? $b['#title'] : '';
return strnatcasecmp($a_title, $b_title);
}
return ($a_weight < $b_weight) ? -1 : 1;
}
/**
* Implements hook_translated_menu_link_alter().
*
* Here is where we make changes to links that need dynamic information such
* as the current page path or the number of users.
*/
function admin_menu_translated_menu_link_alter(&$item, $map) {
global $user, $base_url;
static $access_all;
if ($item['menu_name'] != 'admin_menu') {
return;
}
// Check whether additional development output is enabled.
if (!isset($access_all)) {
$access_all = variable_get('admin_menu_show_all', 0) && module_exists('devel');
}
// Prepare links that would not be displayed normally.
if ($access_all && !$item['access']) {
$item['access'] = TRUE;
// Prepare for http://drupal.org/node/266596
if (!isset($item['localized_options'])) {
_menu_item_localize($item, $map, TRUE);
}
}
// Don't waste cycles altering items that are not visible
if (!$item['access']) {
return;
}
// Add developer information to all links, if enabled.
if ($extra = variable_get('admin_menu_display', 0)) {
$item['title'] .= ' ' . $extra[0] . ': ' . $item[$extra];
}
}
/**
* Implements hook_flush_caches().
*
* Flushes client-side caches.
*
* @param int $uid
* (optional) A user ID to limit the cache flush to.
*/
function admin_menu_flush_caches($uid = NULL) {
// A call to menu_rebuild() will trigger potentially thousands of calls into
// menu_link_save(), for which admin_menu has to implement the corresponding
// CRUD hooks, in order to take up any menu link changes, since any menu link
// change could affect the admin menu (which essentially is an aggregate) and
// since there is no other way to get notified about stale caches. The cache
// only needs to be flushed once though, so we prevent a ton of needless
// subsequent calls with this static.
// @see http://drupal.org/node/918538
$was_flushed = &drupal_static(__FUNCTION__, array());
// $uid can be NULL. PHP automatically converts that into '' (empty string),
// which is different to uid 0 (zero).
if (isset($was_flushed[$uid])) {
return;
}
$was_flushed[$uid] = TRUE;
$cid = 'admin_menu:';
if (isset($uid)) {
$cid .= $uid . ':';
}
// Flush cached output of admin_menu.
cache_clear_all($cid, 'cache_menu', TRUE);
// Flush client-side cache hashes.
drupal_static_reset('admin_menu_cache_get');
// db_table_exists() required for SimpleTest.
if (db_table_exists('cache_admin_menu')) {
cache_clear_all(isset($uid) ? $cid : '*', 'cache_admin_menu', TRUE);
}
}
/**
* Implements hook_form_alter().
*/
function admin_menu_form_alter(&$form, &$form_state, $form_id) {
$global_flush_ids = array(
'admin_menu_theme_settings' => 1,
// Update links for clean/non-clean URLs.
'system_clean_url_settings' => 1,
// Incorporate changed user permissions.
'user_admin_permissions' => 1,
// Removing a role potentially means less permissions.
'user_admin_role_delete_confirm' => 1,
// User name and roles may be changed on the user account form.
'user_profile_form' => 1,
);
if (isset($global_flush_ids[$form_id])) {
$form['#submit'][] = 'admin_menu_form_alter_flush_cache_submit';
// Optionally limit the cache flush to a certain user ID.
$form_state['admin_menu_uid'] = NULL;
if ($form_id == 'user_profile_form') {
$form_state['admin_menu_uid'] = $form_state['user']->uid;
}
}
// UX: Add a confirmation to the permissions form to ask the user whether to
// auto-enable the 'access administration menu' permission along with
// 'access administration pages'.
if ($form_id == 'user_admin_permissions') {
$form['#attached']['js'][] = drupal_get_path('module', 'admin_menu') . '/admin_menu.admin.js';
}
}
/**
* Form submission handler to flush Administration menu caches.
*/
function admin_menu_form_alter_flush_cache_submit($form, &$form_state) {
admin_menu_flush_caches($form_state['admin_menu_uid']);
}
/**
* Implements hook_form_FORM_ID_alter().
*
* Extends Devel module with Administration menu developer settings.
*/
function admin_menu_form_devel_admin_settings_alter(&$form, &$form_state) {
form_load_include($form_state, 'inc', 'admin_menu');
_admin_menu_form_devel_admin_settings_alter($form, $form_state);
}

View File

@@ -0,0 +1,9 @@
/**
* @file
* Administration menu color override for uid1.
*/
#admin-menu li.admin-menu-account > a {
background: #911 url(images/bkg-red.png) bottom left repeat-x;
}

View File

@@ -0,0 +1,145 @@
/**
* @file
* Toolbar style for Administration menu.
*
* Important: We cannot re-use toolbar.png from Toolbar module, since we cannot
* reliably determine the path to it.
*
* @todo Separate shortcut functionality into own module/widget.
*/
/* Adjust margin/height */
html body.admin-menu {
margin-top: 29px !important;
}
html body.admin-menu-with-shortcuts {
margin-top: 65px !important;
}
/* Displace the core Toolbar, if concurrently output. */
body div#toolbar.toolbar {
top: 30px;
}
/**
* Base styles.
*
* We use a keyword for the toolbar font size to make it display consistently
* across different themes, while still allowing browsers to resize the text.
*/
#admin-menu {
font: normal small "Lucida Grande", Verdana, sans-serif;
-moz-box-shadow: 0 -10px 20px 13px #000;
-webkit-box-shadow: 0 -10px 20px 13px #000;
box-shadow: 0 -10px 20px 13px #000;
right: 0;
width: auto;
}
#admin-menu-wrapper {
font-size: .846em;
padding: 5px 10px 0;
}
#admin-menu .dropdown a {
color: #fafafa;
}
/* Remove border from all lists and actions */
#admin-menu .dropdown .admin-menu-action a {
border-left: 0;
}
#admin-menu .dropdown .admin-menu-icon > a {
padding: 2px 10px 3px;
}
/**
* Administration menu.
*/
#admin-menu .dropdown .admin-menu-icon > a span {
vertical-align: text-bottom;
width: 11px;
height: 14px;
display: block;
background: url(toolbar.png) no-repeat 0 -45px;
text-indent: -9999px;
}
#admin-menu > div > .dropdown > li > a {
border-right: 0;
margin-bottom: 4px;
padding: 2px 10px 3px;
}
#admin-menu .dropdown .admin-menu-toolbar-category > a,
#admin-menu .dropdown .admin-menu-action > a {
border-radius: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
}
#admin-menu .dropdown .admin-menu-toolbar-category > a.active-trail {
text-shadow: #333 0 1px 0;
background: url(toolbar.png) 0 0 repeat-x;
}
#admin-menu .dropdown .admin-menu-toolbar-category > a:hover {
background-color: #444;
}
#admin-menu .dropdown .admin-menu-tab a {
border-right: 0;
}
#admin-menu .dropdown li li.expandable ul {
margin: -22px 0 0 160px;
}
/**
* Shortcuts toggle.
*/
#admin-menu .shortcut-toggle {
cursor: pointer;
background: url(toolbar.png) 0 -20px no-repeat;
display: block;
float: right;
margin: 0 0 0 1.3em;
text-indent: -9999px;
overflow: hidden;
width: 25px;
height: 25px;
}
#admin-menu .shortcut-toggle:focus,
#admin-menu .shortcut-toggle:hover {
background-position: -50px -20px;
}
#admin-menu .shortcut-toggle.active {
background-position: -25px -20px;
}
#admin-menu .shortcut-toggle.active:focus,
#admin-menu .shortcut-toggle.active:hover {
background-position: -75px -20px;
}
/**
* Shortcuts widget.
*/
#admin-menu .shortcut-toolbar {
background-color: #666;
clear: both;
display: none;
margin: 0 -10px;
overflow: hidden;
/* Align with icon; @see shortcut.css */
padding-left: 5px;
}
#admin-menu .shortcut-toolbar.active {
display: block;
}
/* Override theme list style; @see shortcut.css */
#admin-menu .shortcut-toolbar ul {
margin: 0;
}
/* @see toolbar.css */
#admin-menu .shortcut-toolbar li {
float: left;
list-style-image: none;
list-style-type: none;
}
#admin-menu .shortcut-toolbar a {
display: block;
}

View File

@@ -0,0 +1,12 @@
name = Administration menu Toolbar style
description = A better Toolbar.
package = Administration
core = 7.x
dependencies[] = admin_menu
; Information added by drupal.org packaging script on 2013-01-31
version = "7.x-3.0-rc4"
core = "7.x"
project = "admin_menu"
datestamp = "1359651687"

View File

@@ -0,0 +1,37 @@
<?php
/**
* @file
* Installation functionality for Administration menu toolbar module.
*/
/**
* Implements hook_install().
*/
function admin_menu_toolbar_install() {
// Required to load JS/CSS in hook_init() after admin_menu.
db_update('system')
->fields(array('weight' => 101))
->condition('type', 'module')
->condition('name', 'admin_menu_toolbar')
->execute();
}
/**
* Set module weight to a value higher than admin_menu.
*
* At this point, admin_menu should have a weight of 100. To account for
* customized weights, we increase the weight relatively.
*
* @see admin_menu_toolbar_install()
*/
function admin_menu_toolbar_update_6300() {
$weight = db_query("SELECT weight FROM {system} WHERE type = 'module' AND name = 'admin_menu'")->fetchField();
$weight++;
db_update('system')
->fields(array('weight' => $weight))
->condition('type', 'module')
->condition('name', 'admin_menu_toolbar')
->execute();
}

View File

@@ -0,0 +1,56 @@
(function($) {
Drupal.admin = Drupal.admin || {};
Drupal.admin.behaviors = Drupal.admin.behaviors || {};
/**
* @ingroup admin_behaviors
* @{
*/
/**
* Apply active trail highlighting based on current path.
*
* @todo Not limited to toolbar; move into core?
*/
Drupal.admin.behaviors.toolbarActiveTrail = function (context, settings, $adminMenu) {
if (settings.admin_menu.toolbar && settings.admin_menu.toolbar.activeTrail) {
$adminMenu.find('> div > ul > li > a[href="' + settings.admin_menu.toolbar.activeTrail + '"]').addClass('active-trail');
}
};
/**
* Toggles the shortcuts bar.
*/
Drupal.admin.behaviors.shortcutToggle = function (context, settings, $adminMenu) {
var $shortcuts = $adminMenu.find('.shortcut-toolbar');
if (!$shortcuts.length) {
return;
}
var storage = window.localStorage || false;
var storageKey = 'Drupal.admin_menu.shortcut';
var $body = $(context).find('body');
var $toggle = $adminMenu.find('.shortcut-toggle');
$toggle.click(function () {
var enable = !$shortcuts.hasClass('active');
$shortcuts.toggleClass('active', enable);
$toggle.toggleClass('active', enable);
if (settings.admin_menu.margin_top) {
$body.toggleClass('admin-menu-with-shortcuts', enable);
}
// Persist toggle state across requests.
storage && enable ? storage.setItem(storageKey, 1) : storage.removeItem(storageKey);
this.blur();
return false;
});
if (!storage || storage.getItem(storageKey)) {
$toggle.trigger('click');
}
};
/**
* @} End of "ingroup admin_behaviors".
*/
})(jQuery);

View File

@@ -0,0 +1,118 @@
<?php
/**
* @file
* Renders Administration menu like Toolbar (core) module.
*
* @todo Separate shortcut functionality into own module/widget.
*/
/**
* Implements hook_form_FORMID_alter().
*/
function admin_menu_toolbar_form_admin_menu_theme_settings_alter(&$form) {
// Add the shortcut links as component on behalf of Shortcut module.
$form['plugins']['admin_menu_components']['#options']['shortcut.links'] = t('Shortcuts');
// The shortcut bar consists of two elements, so we target their class names
// instead of cluttering the markup with additional IDs.
$form['plugins']['admin_menu_components']['shortcut.links']['#attributes']['rel'] = '.shortcut-toggle, .shortcut-toolbar';
}
/**
* Implementation of hook_page_build().
*/
function admin_menu_toolbar_page_build(&$page) {
if (!isset($page['page_bottom']['admin_menu'])) {
return;
}
$path = drupal_get_path('module', 'admin_menu_toolbar');
$attached = &$page['page_bottom']['admin_menu']['#attached'];
$options = array('every_page' => TRUE);
$attached['css'][$path . '/admin_menu_toolbar.css'] = $options;
$attached['js'][$path . '/admin_menu_toolbar.js'] = $options;
// @todo Stop-gap fix until cached rendering is resolved.
// @see http://drupal.org/node/1567622
if (module_exists('shortcut')) {
$attached['css'][drupal_get_path('module', 'shortcut') . '/shortcut.css'] = $options;
}
$settings = array();
// Add current path to support menu item highlighting.
// @todo Compile real active trail here?
$args = explode('/', $_GET['q']);
if ($args[0] == 'admin' && !empty($args[1])) {
$settings['activeTrail'] = url($args[0] . '/' . $args[1]);
}
elseif (drupal_is_front_page()) {
$settings['activeTrail'] = url('<front>');
}
$attached['js'][] = array(
'data' => array('admin_menu' => array('toolbar' => $settings)),
'type' => 'setting',
);
}
/**
* Implements hook_admin_menu_output_build().
*/
function admin_menu_toolbar_admin_menu_output_build(&$content) {
if (empty($content['#components']['shortcut.links']) && !$content['#complete']) {
return;
}
// Add shortcuts toggle.
$content['shortcut-toggle'] = array(
'#access' => module_exists('shortcut'),
'#weight' => -200,
'#type' => 'link',
'#title' => t('Show shortcuts'),
'#href' => '',
'#options' => array(
'attributes' => array('class' => 'shortcut-toggle'),
),
);
// Add shortcuts bar.
$content['shortcut'] = array(
'#access' => module_exists('shortcut'),
'#weight' => 200,
'#prefix' => '<div class="shortcut-toolbar">',
'#suffix' => '</div>',
);
$content['shortcut']['shortcuts'] = array(
// Shortcut module's CSS relies on Toolbar module's markup.
// @see http://drupal.org/node/1217038
'#prefix' => '<div id="toolbar">',
'#suffix' => '</div>',
// @todo Links may contain .active-trail classes.
'#pre_render' => array('shortcut_toolbar_pre_render'),
);
}
/**
* Implements hook_admin_menu_output_alter().
*/
function admin_menu_toolbar_admin_menu_output_alter(&$content) {
// Add a class to top-level items for styling.
if (isset($content['menu'])) {
foreach (element_children($content['menu']) as $link) {
$content['menu'][$link]['#attributes']['class'][] = 'admin-menu-toolbar-category';
}
}
// Alter icon.
if (isset($content['icon'])) {
unset($content['icon']['icon']['#theme']);
$content['icon']['icon']['#title'] = '<span>' . t('Home') . '</span>';
$content['icon']['icon']['#attributes']['class'][] = 'admin-menu-toolbar-category';
}
// Alter user account link.
if (isset($content['account'])) {
$content['account']['account']['#title'] = t('Hello <strong>@username</strong>', array('@username' => $content['account']['account']['#title']));
$content['account']['account']['#options']['html'] = TRUE;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 558 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 629 B

View File

@@ -0,0 +1,520 @@
<?php
/**
* @file
* Tests for the Administration menu module.
*/
/**
* Base class for all administration menu web test cases.
*/
class AdminMenuWebTestCase extends DrupalWebTestCase {
protected $profile = 'testing';
protected $basePermissions = array(
'system' => 'access administration pages',
'admin_menu' => 'access administration menu',
);
function setUp() {
// Enable admin menu module and any other modules.
$modules = func_get_args();
$modules = isset($modules[0]) ? $modules[0] : $modules;
$modules[] = 'admin_menu';
parent::setUp($modules);
// Disable client-side caching.
variable_set('admin_menu_cache_client', FALSE);
// Disable Clean URLs to ensure drupal.org testbot compatibility.
variable_set('clean_url', 0);
}
/**
* Check that an element exists in HTML markup.
*
* @param $xpath
* An XPath expression.
* @param array $arguments
* (optional) An associative array of XPath replacement tokens to pass to
* DrupalWebTestCase::buildXPathQuery().
* @param $message
* The message to display along with the assertion.
* @param $group
* The type of assertion - examples are "Browser", "PHP".
*
* @return
* TRUE if the assertion succeeded, FALSE otherwise.
*/
protected function assertElementByXPath($xpath, array $arguments = array(), $message, $group = 'Other') {
$elements = $this->xpath($xpath, $arguments);
return $this->assertTrue(!empty($elements[0]), $message, $group);
}
/**
* Check that an element does not exist in HTML markup.
*
* @param $xpath
* An XPath expression.
* @param array $arguments
* (optional) An associative array of XPath replacement tokens to pass to
* DrupalWebTestCase::buildXPathQuery().
* @param $message
* The message to display along with the assertion.
* @param $group
* The type of assertion - examples are "Browser", "PHP".
*
* @return
* TRUE if the assertion succeeded, FALSE otherwise.
*/
protected function assertNoElementByXPath($xpath, array $arguments = array(), $message, $group = 'Other') {
$elements = $this->xpath($xpath, $arguments);
return $this->assertTrue(empty($elements), $message, $group);
}
/**
* Asserts that links appear in the menu in a specified trail.
*
* @param array $trail
* A list of menu link titles to assert in the menu.
*/
protected function assertLinkTrailByTitle(array $trail) {
$xpath = array();
$args = array();
$message = '';
foreach ($trail as $i => $title) {
$xpath[] = '/li/a[text()=:title' . $i . ']';
$args[':title' . $i] = $title;
$message .= ($i ? ' » ' : '') . check_plain($title);
}
$xpath = '//div[@id="admin-menu"]/div/ul' . implode('/parent::li/ul', $xpath);
$this->assertElementByXPath($xpath, $args, $message . ' link found.');
}
/**
* Asserts that no link appears in the menu for a specified trail.
*
* @param array $trail
* A list of menu link titles to assert in the menu.
*/
protected function assertNoLinkTrailByTitle(array $trail) {
$xpath = array();
$args = array();
$message = '';
foreach ($trail as $i => $title) {
$xpath[] = '/li/a[text()=:title' . $i . ']';
$args[':title' . $i] = $title;
$message .= ($i ? ' » ' : '') . check_plain($title);
}
$xpath = '//div[@id="admin-menu"]/div/ul' . implode('/parent::li/ul', $xpath);
$this->assertNoElementByXPath($xpath, $args, $message . ' link not found.');
}
}
/**
* Tests menu links depending on user permissions.
*/
class AdminMenuPermissionsTestCase extends AdminMenuWebTestCase {
public static function getInfo() {
return array(
'name' => 'Menu link access permissions',
'description' => 'Tests appearance of menu links depending on user permissions.',
'group' => 'Administration menu',
);
}
function setUp() {
parent::setUp(array('node'));
}
/**
* Test that the links are added to the page (no JS testing).
*/
function testPermissions() {
module_enable(array('contact'));
$this->resetAll();
// Anonymous users should not see the menu.
$this->drupalGet('');
$this->assertNoElementByXPath('//div[@id="admin-menu"]', array(), t('Administration menu not found.'));
// Create a user who
// - can access content overview
// - cannot access drupal.org links
// - cannot administer Contact module
$permissions = $this->basePermissions + array(
'access content overview',
);
$admin_user = $this->drupalCreateUser($permissions);
$this->drupalLogin($admin_user);
// Check that the user can see the admin links, but not the drupal links.
$this->assertElementByXPath('//div[@id="admin-menu"]', array(), 'Administration menu found.');
$this->assertElementByXPath('//div[@id="admin-menu"]//a[contains(@href, :path)]', array(':path' => 'admin/content'), 'Content link found.');
$this->assertNoElementByXPath('//div[@id="admin-menu"]//a[@href=:path]', array(':path' => 'http://drupal.org'), 'Icon » Drupal.org link not found.');
$this->assertNoElementByXPath('//div[@id="admin-menu"]//a[contains(@href, :path)]', array(':path' => 'admin/structure/contact'), 'Structure » Contact link not found.');
// Create a user "reversed" to the above; i.e., who
// - cannot access content overview
// - can access drupal.org links
// - can administer Contact module
$permissions = $this->basePermissions + array(
'display drupal links',
'administer contact forms',
);
$admin_user2 = $this->drupalCreateUser($permissions);
$this->drupalLogin($admin_user2);
$this->assertElementByXPath('//div[@id="admin-menu"]', array(), 'Administration menu found.');
$this->assertNoElementByXPath('//div[@id="admin-menu"]//a[contains(@href, :path)]', array(':path' => 'admin/content'), 'Content link not found.');
$this->assertElementByXPath('//div[@id="admin-menu"]//a[@href=:path]', array(':path' => 'http://drupal.org'), 'Icon » Drupal.org link found.');
$this->assertElementByXPath('//div[@id="admin-menu"]//a[contains(@href, :path)]', array(':path' => 'admin/structure/contact'), 'Structure » Contact link found.');
}
/**
* Tests handling of links pointing to category/overview pages.
*/
function testCategories() {
// Create a user with minimum permissions.
$admin_user = $this->drupalCreateUser($this->basePermissions);
$this->drupalLogin($admin_user);
// Verify that no category links appear.
$this->assertNoLinkTrailByTitle(array(t('Structure')));
$this->assertNoLinkTrailByTitle(array(t('Configuration')));
// Create a user with access to one configuration category.
$permissions = $this->basePermissions + array(
'administer users',
);
$admin_user = $this->drupalCreateUser($permissions);
$this->drupalLogin($admin_user);
// Verify that only expected category links appear.
$this->assertNoLinkTrailByTitle(array(t('Structure')));
$this->assertLinkTrailByTitle(array(t('People')));
$this->assertLinkTrailByTitle(array(t('Configuration')));
$this->assertLinkTrailByTitle(array(t('Configuration'), t('People')));
// Random picks are sufficient.
$this->assertNoLinkTrailByTitle(array(t('Configuration'), t('Media')));
$this->assertNoLinkTrailByTitle(array(t('Configuration'), t('System')));
}
/**
* Tests that user role and permission changes are properly taken up.
*/
function testPermissionChanges() {
// Create a user who is able to change permissions.
$permissions = $this->basePermissions + array(
'administer permissions',
);
$admin_user = $this->drupalCreateUser($permissions);
$this->drupalLogin($admin_user);
// Extract the user role ID that was created for above permissions.
$rid = key(array_diff_key($admin_user->roles, array(DRUPAL_AUTHENTICATED_RID => 0)));
// Verify that Configuration does not appear.
$this->assertNoLinkTrailByTitle(array(t('Configuration')));
// Grant the 'administer site configuration' permission to ourselves.
$edit = array(
$rid . '[administer site configuration]' => TRUE,
);
$this->drupalPost('admin/people/permissions', $edit, t('Save permissions'));
// Verify that Configuration appears.
$this->assertLinkTrailByTitle(array(t('Configuration')));
// Verify that Structure » Content types does not appear.
$this->assertNoLinkTrailByTitle(array(t('Structure'), t('Content types')));
// Create a new role.
$edit = array(
'name' => 'test',
);
$this->drupalPost('admin/people/permissions/roles', $edit, t('Add role'));
// It should be safe to assume that the new role gets the next ID.
$test_rid = $rid + 1;
// Grant the 'administer content types' permission for the role.
$edit = array(
$test_rid . '[administer content types]' => TRUE,
);
$this->drupalPost('admin/people/permissions/' . $test_rid, $edit, t('Save permissions'));
// Verify that Structure » Content types does not appear.
$this->assertNoLinkTrailByTitle(array(t('Structure'), t('Content types')));
// Assign the role to ourselves.
$edit = array(
'roles[' . $test_rid . ']' => TRUE,
);
$this->drupalPost('user/' . $admin_user->uid . '/edit', $edit, t('Save'));
// Verify that Structure » Content types appears.
$this->assertLinkTrailByTitle(array(t('Structure'), t('Content types')));
// Delete the role.
$this->drupalPost('admin/people/permissions/roles/edit/' . $test_rid, array(), t('Delete role'));
$this->drupalPost(NULL, array(), t('Delete'));
// Verify that Structure » Content types does not appear.
$this->assertNoLinkTrailByTitle(array(t('Structure'), t('Content types')));
}
}
/**
* Tests appearance, localization, and escaping of dynamic links.
*/
class AdminMenuDynamicLinksTestCase extends AdminMenuWebTestCase {
public static function getInfo() {
return array(
'name' => 'Dynamic links',
'description' => 'Tests appearance, localization, and escaping of dynamic links.',
'group' => 'Administration menu',
);
}
function setUp() {
parent::setUp(array('node'));
}
/**
* Tests node type links.
*/
function testNode() {
$type = $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
// Create a content-type with special characters.
$type = $this->drupalCreateContentType(array('type' => 'special', 'name' => 'Cool & Special'));
$permissions = $this->basePermissions + array(
'administer content types',
'create article content',
'create special content',
);
$this->admin_user = $this->drupalCreateUser($permissions);
$this->drupalLogin($this->admin_user);
// Verify that dynamic links are displayed.
$this->drupalGet('');
$this->assertElementByXPath('//div[@id="admin-menu"]', array(), t('Administration menu found.'));
$this->assertElementByXPath('//div[@id="admin-menu"]//a[contains(@href, :path)]', array(':path' => 'admin/structure/types'), "Structure » Content types link found.");
// Verify link title output escaping.
$this->assertNoRaw('Cool & Special');
$this->assertRaw(check_plain('Cool & Special'));
// Verify Manage content type links.
$links = array(
'admin/structure/types/manage/article' => 'Article',
'admin/structure/types/manage/special' => 'Cool & Special',
);
foreach ($links as $path => $title) {
$this->assertElementByXPath('//div[@id="admin-menu"]//a[contains(@href, :path) and text()=:title]', array(
':path' => $path,
':title' => $title,
), "Structure » Content types » $title link found.");
}
// Verify Add content links.
$links = array(
'node/add/article' => 'Article',
'node/add/special' => 'Cool & Special',
);
foreach ($links as $path => $title) {
$this->assertElementByXPath('//div[@id="admin-menu"]//a[contains(@href, :path) and text()=:title]', array(
':path' => $path,
':title' => $title,
), "Add content » $title link found.");
}
}
/**
* Tests Add content links.
*/
function testNodeAdd() {
$type = $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
// Verify that "Add content" does not appear for unprivileged users.
$permissions = $this->basePermissions + array(
'access content',
);
$this->web_user = $this->drupalCreateUser($permissions);
$this->drupalLogin($this->web_user);
$this->assertNoText(t('Add content'));
// Verify "Add content" appears below "Content" for administrative users.
$permissions = $this->basePermissions + array(
'access content overview',
'access content',
'create article content',
);
$this->admin_user = $this->drupalCreateUser($permissions);
$this->drupalLogin($this->admin_user);
$this->assertLinkTrailByTitle(array(
t('Content'),
t('Add content'),
));
// Verify "Add content" appears on the top-level for regular users.
$permissions = $this->basePermissions + array(
'access content',
'create article content',
);
$this->web_user = $this->drupalCreateUser($permissions);
$this->drupalLogin($this->web_user);
$this->assertLinkTrailByTitle(array(
t('Add content'),
));
}
}
/**
* Tests appearance of different types of links.
*/
class AdminMenuLinkTypesTestCase extends AdminMenuWebTestCase {
public static function getInfo() {
return array(
'name' => 'Link types',
'description' => 'Tests appearance of different types of links.',
'group' => 'Administration menu',
);
}
function setUp() {
parent::setUp(array('help'));
$permissions = module_invoke_all('permission');
$permissions = array_keys($permissions);
$this->admin_user = $this->drupalCreateUser($permissions);
$this->drupalLogin($this->admin_user);
}
/**
* Tests appearance of different router item link types.
*/
function testLinkTypes() {
// Verify that MENU_NORMAL_ITEMs appear.
$this->assertLinkTrailByTitle(array(
t('Configuration'),
t('System'),
t('Site information'),
));
// Verify that MENU_LOCAL_TASKs appear.
$this->assertLinkTrailByTitle(array(t('People'), t('Permissions')));
$this->assertLinkTrailByTitle(array(t('Appearance'), t('Settings')));
$this->assertLinkTrailByTitle(array(t('Modules'), t('Uninstall')));
// Verify that MENU_LOCAL_ACTIONs appear.
$this->assertLinkTrailByTitle(array(
t('People'),
t('Add user'),
));
// Verify that MENU_DEFAULT_LOCAL_TASKs do NOT appear.
$this->assertNoLinkTrailByTitle(array(t('Modules'), t('List')));
$this->assertNoLinkTrailByTitle(array(t('People'), t('List')));
$this->assertNoLinkTrailByTitle(array(t('People'), t('Permissions'), t('Permissions')));
$this->assertNoLinkTrailByTitle(array(t('Appearance'), t('List')));
// Verify that MENU_VISIBLE_IN_BREADCRUMB items (exact type) do NOT appear.
$this->assertNoLinkTrailByTitle(array(t('Modules'), t('Uninstall'), t('Uninstall')));
$this->assertNoLinkTrailByTitle(array(t('Help'), 'admin_menu'));
// Verify that special "Index" link appears below icon.
$this->assertElementByXPath('//div[@id="admin-menu"]//a[contains(@href, :path) and text()=:title]', array(
':path' => 'admin/index',
':title' => t('Index'),
), "Icon » Index link found.");
}
}
/**
* Tests customized menu links.
*/
class AdminMenuCustomizedTestCase extends AdminMenuWebTestCase {
public static function getInfo() {
return array(
'name' => 'Customized links',
'description' => 'Tests customized menu links.',
'group' => 'Administration menu',
);
}
function setUp() {
parent::setUp(array('menu'));
$this->admin_user = $this->drupalCreateUser($this->basePermissions + array(
'administer menu',
));
$this->drupalLogin($this->admin_user);
}
/**
* Test disabled custom links.
*/
function testCustomDisabled() {
$type = $this->drupalCreateContentType();
$node = $this->drupalCreateNode(array('type' => $type->type));
$text = $this->randomName();
$xpath = $this->buildXPathQuery('//div[@id=:id]//a[contains(text(), :text)]', array(
':id' => 'admin-menu',
':text' => $text,
));
// Verify that the link does not appear in the menu.
$this->drupalGet('node');
$elements = $this->xpath($xpath);
$this->assertFalse($elements, 'Custom link not found.');
// Add a custom link to the node to the menu.
$edit = array(
'link_path' => 'node/' . $node->nid,
'link_title' => $text,
'parent' => 'management:' . $this->queryMlidByPath('admin'),
);
$this->drupalPost('admin/structure/menu/manage/management/add', $edit, t('Save'));
// Verify that the link appears in the menu.
$this->drupalGet('node');
$elements = $this->xpath($xpath);
$this->assertTrue($elements, 'Custom link found.');
// Disable the link.
$edit = array(
'enabled' => FALSE,
);
$this->drupalPost('admin/structure/menu/item/' . $this->queryMlidByPath('node/' . $node->nid) . '/edit', $edit, t('Save'));
// Verify that the disabled link does not appear in the menu.
$this->drupalGet('node');
$elements = $this->xpath($xpath);
$this->assertFalse($elements, 'Disabled custom link not found.');
}
/**
* Tests external links.
*/
function testCustomExternal() {
// Add a custom link to the node to the menu.
$edit = array(
'link_path' => 'http://example.com',
'link_title' => 'Example',
'parent' => 'management:' . $this->queryMlidByPath('admin'),
);
$this->drupalPost('admin/structure/menu/manage/management/add', $edit, t('Save'));
// Verify that the link appears in the menu.
$this->drupalGet('');
$elements = $this->xpath('//div[@id=:id]//a[@href=:href and contains(text(), :text)]', array(
':id' => 'admin-menu',
':href' => $edit['link_path'],
':text' => $edit['link_title'],
));
$this->assertTrue($elements, 'External link found.');
}
/**
* Returns the menu link ID for a given link path in the management menu.
*/
protected function queryMlidByPath($path) {
return db_query('SELECT mlid FROM {menu_links} WHERE menu_name = :menu AND link_path = :path', array(
':menu' => 'management',
':path' => $path,
))->fetchField();
}
}

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,11 @@
name = Aggregate cache
description = imagecache style generation of css and javascript aggregates.
core = 7.x
; Information added by drupal.org packaging script on 2012-01-31
version = "7.x-1.1"
core = "7.x"
project = "agrcache"
datestamp = "1328018142"

View File

@@ -0,0 +1,22 @@
<?php
/**
* @file
* Schema, install and update functions for agrcache module.
*/
/**
* Implements hook_requirements().
*/
function agrcache_requirements($phase) {
$t = get_t();
$requirements = array();
if (!variable_get('clean_url', 0)) {
$requirements['agrcache_clean_url'] = array(
'title' => $t('Clean urls'),
'value' => $t('Aggregate cache requires clean URLs to be enabled in order to serve aggregates.'),
'severity' => REQUIREMENT_WARNING,
);
}
return $requirements;
}

View File

@@ -0,0 +1,483 @@
<?php
/**
* @file
* Provides imagecache style generation of css/js aggregates.
*/
/**
* Implements hook_menu().
*/
function agrcache_menu() {
$directory_path = variable_get('file_public_path', conf_path() . '/files');
foreach (array('css', 'js') as $type) {
$items[$directory_path . "/$type/%"] = array(
'title' => "Generate $type aggregate",
'page callback' => 'agrcache_generate_aggregate',
'page arguments' => array(count(explode('/', $directory_path)) + 1, $type),
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
}
return $items;
}
/**
* Implements hook_element_info_alter().
*/
function agrcache_element_info_alter(&$type) {
// Swap in our own aggregation callback.
if (isset($type['styles']['#aggregate_callback'])) {
$type['styles']['#aggregate_callback'] = 'agrcache_aggregate_css';
}
}
/**
* Implements hook_theme_registry_alter().
*/
function agrcache_theme_registry_alter(&$theme_registry) {
// For JavaScript there is no nice hook_elements() implementation to hook
// into, aggregation is done inline in drupal_get_js(). So instead take over
// template_preprocess_html.
// @see http://drupal.org/node/330082
// @see http://drupal.org/node/352951
$index = array_search('template_process_html', $theme_registry['html']['process functions']);
$theme_registry['html']['process functions'][$index] = '_agrcache_process_html';
}
/**
* Replacement for template_process_html().
*/
function _agrcache_process_html(&$variables) {
// Render page_top and page_bottom into top level variables.
$variables['page_top'] = drupal_render($variables['page']['page_top']);
$variables['page_bottom'] = drupal_render($variables['page']['page_bottom']);
// Place the rendered HTML for the page body into a top level variable.
$variables['page'] = $variables['page']['#children'];
$variables['page_bottom'] .= agrcache_get_js('footer');
$variables['head'] = drupal_get_html_head();
$variables['css'] = drupal_add_css();
$variables['styles'] = drupal_get_css();
$variables['scripts'] = agrcache_get_js();
}
/**
* Replacement for drupal_get_js().
*/
function agrcache_get_js($scope = 'header', $javascript = NULL, $skip_alter = FALSE) {
if (!isset($javascript)) {
$javascript = drupal_add_js();
}
if (empty($javascript)) {
return '';
}
// Allow modules to alter the JavaScript.
if (!$skip_alter) {
drupal_alter('js', $javascript);
}
// Filter out elements of the given scope.
$items = array();
foreach ($javascript as $key => $item) {
if ($item['scope'] == $scope) {
$items[$key] = $item;
}
}
$output = '';
// The index counter is used to keep aggregated and non-aggregated files in
// order by weight.
$index = 1;
$processed = array();
$files = array();
$preprocess_js = (variable_get('preprocess_js', FALSE) && (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update'));
// A dummy query-string is added to filenames, to gain control over
// browser-caching. The string changes on every update or full cache
// flush, forcing browsers to load a new copy of the files, as the
// URL changed. Files that should not be cached (see drupal_add_js())
// get REQUEST_TIME as query-string instead, to enforce reload on every
// page request.
$default_query_string = variable_get('css_js_query_string', '0');
// For inline Javascript to validate as XHTML, all Javascript containing
// XHTML needs to be wrapped in CDATA. To make that backwards compatible
// with HTML 4, we need to comment out the CDATA-tag.
$embed_prefix = "\n<!--//--><![CDATA[//><!--\n";
$embed_suffix = "\n//--><!]]>\n";
// Since Javascript may look for arguments in the url and act on them, some
// third-party code might require the use of a different query string.
$js_version_string = variable_get('drupal_js_version_query_string', 'v=');
// Sort the JavaScript so that it appears in the correct order.
uasort($items, 'drupal_sort_css_js');
// Provide the page with information about the individual JavaScript files
// used, information not otherwise available when aggregation is enabled.
$setting['ajaxPageState']['js'] = array_fill_keys(array_keys($items), 1);
unset($setting['ajaxPageState']['js']['settings']);
drupal_add_js($setting, 'setting');
// If we're outputting the header scope, then this might be the final time
// that drupal_get_js() is running, so add the setting to this output as well
// as to the drupal_add_js() cache. If $items['settings'] doesn't exist, it's
// because drupal_get_js() was intentionally passed a $javascript argument
// stripped off settings, potentially in order to override how settings get
// output, so in this case, do not add the setting to this output.
if ($scope == 'header' && isset($items['settings'])) {
$items['settings']['data'][] = $setting;
}
// Loop through the JavaScript to construct the rendered output.
$element = array(
'#tag' => 'script',
'#value' => '',
'#attributes' => array(
'type' => 'text/javascript',
),
);
foreach ($items as $item) {
$query_string = empty($item['version']) ? $default_query_string : $js_version_string . $item['version'];
switch ($item['type']) {
case 'setting':
$js_element = $element;
$js_element['#value_prefix'] = $embed_prefix;
$js_element['#value'] = 'jQuery.extend(Drupal.settings, ' . drupal_json_encode(drupal_array_merge_deep_array($item['data'])) . ");";
$js_element['#value_suffix'] = $embed_suffix;
$output .= theme('html_tag', array('element' => $js_element));
break;
case 'inline':
$js_element = $element;
if ($item['defer']) {
$js_element['#attributes']['defer'] = 'defer';
}
$js_element['#value_prefix'] = $embed_prefix;
$js_element['#value'] = $item['data'];
$js_element['#value_suffix'] = $embed_suffix;
$processed[$index++] = theme('html_tag', array('element' => $js_element));
break;
case 'file':
$js_element = $element;
if (!$item['preprocess'] || !$preprocess_js) {
if ($item['defer']) {
$js_element['#attributes']['defer'] = 'defer';
}
$query_string_separator = (strpos($item['data'], '?') !== FALSE) ? '&' : '?';
$js_element['#attributes']['src'] = file_create_url($item['data']) . $query_string_separator . ($item['cache'] ? $query_string : REQUEST_TIME);
$processed[$index++] = theme('html_tag', array('element' => $js_element));
}
else {
// By increasing the index for each aggregated file, we maintain
// the relative ordering of JS by weight. We also set the key such
// that groups are split by items sharing the same 'group' value and
// 'every_page' flag. While this potentially results in more aggregate
// files, it helps make each one more reusable across a site visit,
// leading to better front-end performance of a website as a whole.
// See drupal_add_js() for details.
$key = 'aggregate_' . $item['group'] . '_' . $item['every_page'] . '_' . $index;
$processed[$key] = '';
$files[$key][$item['data']] = $item;
}
break;
case 'external':
$js_element = $element;
// Preprocessing for external JavaScript files is ignored.
if ($item['defer']) {
$js_element['#attributes']['defer'] = 'defer';
}
$js_element['#attributes']['src'] = $item['data'];
$processed[$index++] = theme('html_tag', array('element' => $js_element));
break;
}
}
// Aggregate any remaining JS files that haven't already been output.
// This is the only hunk of code change from drupal_get_js().
if ($preprocess_js && count($files) > 0) {
$map = array();
foreach ($files as $key => $file_set) {
$data = agrcache_build_aggregate_cache($file_set, 'js');
$uri = $data['uri'];
if (!empty($data['#write_cache'])) {
$map['files'][$data['key']] = $data['uri'];
$map['callbacks'][$data['uri']] = $file_set;
}
// Only include the file if was written successfully. Errors are logged
// using watchdog.
if ($uri) {
$preprocess_file = file_create_url($uri);
$js_element = $element;
$js_element['#attributes']['src'] = $preprocess_file;
$processed[$key] = theme('html_tag', array('element' => $js_element));
}
}
}
if (!empty($map)) {
agrcache_add_to_variable('agrcache_js_cache_files', $map);
}
// Keep the order of JS files consistent as some are preprocessed and others are not.
// Make sure any inline or JS setting variables appear last after libraries have loaded.
return implode('', $processed) . $output;
}
/**
* Replacement for drupal_aggregate_css().
*/
function agrcache_aggregate_css(&$css_groups) {
$preprocess_css = (variable_get('preprocess_css', FALSE) && (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update'));
$map = array();
// For each group that needs aggregation, aggregate its items.
foreach ($css_groups as $key => $group) {
switch ($group['type']) {
// If a file group can be aggregated into a single file, do so, and set
// the group's data property to the file path of the aggregate file.
case 'file':
if ($group['preprocess'] && $preprocess_css) {
$data = agrcache_build_aggregate_cache($group['items'], 'css');
if ($data) {
$css_groups[$key]['data'] = $data['uri'];
if (!empty($data['#write_cache'])) {
$map['files'][$data['key']] = $data['uri'];
$map['callbacks'][$data['uri']] = $group['items'];
}
}
}
break;
// Aggregate all inline CSS content into the group's data property.
case 'inline':
$css_groups[$key]['data'] = '';
foreach ($group['items'] as $item) {
$css_groups[$key]['data'] .= drupal_load_stylesheet_content($item['data'], $item['preprocess']);
}
break;
}
}
if (!empty($map)) {
agrcache_add_to_variable('agrcache_css_cache_files', $map);
}
}
/**
* Replacement for drupal_build_css_cache() and drupal_build_js_cache().
*/
function agrcache_build_aggregate_cache($files, $type) {
$data = '';
$uri = '';
$map = variable_get('agrcache_' . $type . '_cache_files', array());
$key = hash('sha256', serialize($files));
if (isset($map['files'][$key])) {
return array('uri' => $map['files'][$key]);
}
else {
// To ensure a new filenames are created only when the contents of the
// hashed files changes, use a hash of the contents for the filename.
$function = 'agrcache_collect_' . $type . '_group';
$data = $function($files);
if ($data) {
// Prefix filename to prevent blocking by firewalls which reject files
// starting with "ad*".
$filename = $type . '_' . drupal_hash_base64($data) . ".$type";
// Create the aggregate directory within the files folder.
$path = "public://$type";
$uri = $path . '/' . $filename;
return array(
'key' => $key,
'uri' => $uri,
'#write_cache' => TRUE,
);
}
else {
return FALSE;
}
}
}
/**
* Collect javascript files.
*/
function agrcache_collect_js_group($js) {
// JavaScript aggregation currently only collects the files together, so
// re-use agrcache_process_js_group();
return agrcache_process_js_group($js);
}
/**
* College CSS files.
*/
function agrcache_collect_css_group($css) {
$contents = '';
foreach ($css as $stylesheet) {
if ($stylesheet['type'] == 'file' && file_exists($stylesheet['data'])) {
$contents .= file_get_contents($stylesheet['data']);
}
}
return $contents;
}
/**
* Process a js group for aggregation.
*/
function agrcache_process_js_group($js) {
$data = '';
foreach ($js as $path => $info) {
if ($info['preprocess']) {
// Append a ';' and a newline after each JS file to prevent them from running together.
$data .= file_get_contents($path) . ";\n";
}
}
return $data;
}
/**
* Aggregate and compress css groups.
*/
function agrcache_process_css_group($css) {
// Build aggregate CSS file.
$data = '';
foreach ($css as $stylesheet) {
// Only 'file' stylesheets can be aggregated.
if ($stylesheet['type'] == 'file') {
$contents = drupal_load_stylesheet($stylesheet['data'], TRUE);
// Build the base URL of this CSS file: start with the full URL.
$css_base_url = file_create_url($stylesheet['data']);
// Move to the parent.
$css_base_url = substr($css_base_url, 0, strrpos($css_base_url, '/'));
// Simplify to a relative URL if the stylesheet URL starts with the
// base URL of the website.
if (substr($css_base_url, 0, strlen($GLOBALS['base_root'])) == $GLOBALS['base_root']) {
$css_base_url = substr($css_base_url, strlen($GLOBALS['base_root']));
}
_drupal_build_css_path(NULL, $css_base_url . '/');
// Anchor all paths in the CSS with its base URL, ignoring external and absolute paths.
$data .= preg_replace_callback('/url\(\s*[\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\s*\)/i', '_drupal_build_css_path', $contents);
}
}
// Per the W3C specification at http://www.w3.org/TR/REC-CSS2/cascade.html#at-import,
// @import rules must proceed any other style, so we move those to the top.
$regexp = '/@import[^;]+;/i';
preg_match_all($regexp, $data, $matches);
$data = preg_replace($regexp, '', $data);
$data = implode('', $matches[0]) . $data;
return $data;
}
/**
* Menu callback to generate a css aggregate.
*/
function agrcache_generate_aggregate($filename, $type) {
// Recreate the full uri from the filename.
$path = "public://$type";
$uri = $path . '/' . $filename;
$map = variable_get('agrcache_' . $type . '_cache_files', array());
$compression = variable_get($type . '_gzip_compression', TRUE) && variable_get('clean_url', 0) && extension_loaded('zlib');
// This callback should only be called if the file does not already exist on
// disk since the webserver will serve the file directly, bypassing PHP when it does.
// However it is possible that the file was created during bootstrap by another request.
if (file_exists($uri)) {
$data = file_get_contents($uri);
if ($compression) {
$compressed = gzencode($data, 9, FORCE_GZIP);
}
}
elseif (isset($map['callbacks'][$uri])) {
// @todo: consider adding locking here.
// @see drupal.org/node/886488
$function = 'agrcache_process_' . $type . '_group';
$data = $function($map['callbacks'][$uri]);
// Check file_exists() again, in case the file was built during processing.
if (!file_exists($uri)) {
// Create the file.
file_prepare_directory($path, FILE_CREATE_DIRECTORY);
if (!file_exists($uri) && !file_unmanaged_save_data($data, $uri, FILE_EXISTS_REPLACE)) {
drupal_add_http_header('Status', '503 Service Unavailable');
print t('Error generating aggregate');
drupal_exit();
}
// If gzip compression is enabled, clean URLs are enabled (which means
// that rewrite rules are working) and the zlib extension is available then
// create a gzipped version of this file. This file is served conditionally
// to browsers that accept gzip using .htaccess rules.
if ($compression) {
$compressed = gzencode($data, 9, FORCE_GZIP);
if (!file_exists($uri . '.gz') && !file_unmanaged_save_data($compressed, $uri . '.gz', FILE_EXISTS_REPLACE)) {
drupal_add_http_header('Status', '503 Service Unavailable');
print t('Error generating aggregate');
drupal_exit();
}
}
}
$content_type = $type == 'css' ? 'text/css' : 'application/javascript';
$headers = array();
$headers['Content-Type'] = $content_type;
// Ensure this file can be cached by browsers and reverse proxies.
$headers['Cache-Control'] = 'public, max-age=1209600';
// Since the file name is based on a hash of file contents, there is no
// problem allowing the browser to cache it for as long as possible.
// Set this to two weeks since that's what .htaccess does if mod_expires
// is enabled.
$headers['Expires'] = gmdate(DATE_RFC1123, REQUEST_TIME + 1209600);
// When possible, serve the gzip version of the file via PHP.
if (!empty($compressed) && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE) {
$headers['Content-Encoding'] = 'gzip';
$data = $compressed;
ini_set('zlib.output_compression', '0');
}
foreach ($headers as $key => $value) {
drupal_add_http_header($key, $value);
}
print $data;
drupal_exit();
}
else {
watchdog('agrcache', 'Received request for a non-existent css aggregate @uri', array('@uri' => $uri));
}
}
/**
* Merge the existing value of a variable from the database with new values.
*
* @param $name
* The name of the variable.
* @param $values
* An array of values to add.
* @param $default
* The default value of the variable, as passed to variable_get().
* This defaults to an empty array().
*/
function agrcache_add_to_variable($name, $values, $default = array()) {
// This function bypasses variable_get() on purpose. Since when dealing with
// 'volatile' variables such as css and javascript maps that may be updated
// by multiple threads, it is necessary to minimize the potential race
// condition where threads may overwrite the value of the variable with a
// version missing values that were just added by a previous process.
// This approach lowers the window for that race condition to the time
// between the database query and variable_set(), which should be only a
// couple of milliseconds compared to up to over a second between
// variable_initialize() and reaching this function.
$original = $default;
$result = db_query('SELECT value FROM {variable} WHERE name = :name', array(':name' => $name))->fetchField();
if ($result) {
$original = unserialize($result);
}
variable_set($name, array_merge_recursive($original, $values));
}

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,94 @@
-------------------------------------------------------------------------------
Backup and Migrate 2 for Drupal 7.x
by Ronan Dowling, Gorton Studios - ronan (at) gortonstudios (dot) com
-------------------------------------------------------------------------------
DESCRIPTION:
This module makes the task of backing up your Drupal database and migrating data
from one Drupal install to another easier. It provides a function to backup the
entire database to file or download, and to restore from a previous backup. You
can also schedule the backup operation. Compression of backup files is also
supported.
There are options to exclude the data from certain tables (such as cache or
search index tables) to increase efficiency by ignoring data that does not need
to be backed up or migrated.
The backup files are a list of SQL statements which can be executed with a tool
such as phpMyAdmin or the command-line mysql client.
-------------------------------------------------------------------------------
INSTALLATION:
* Put the module in your drupal modules directory and enable it in
admin/modules.
* Go to admin/people/permissions and grant permission to any roles that need to be
able to backup or restore the databse.
* Configure and use the module at admin/config/system/backup_migrate
OPTIONAL:
* Enable token.module to allow token replacement in backup file names.
* To Backup to Amazon S3:
- Download the S3 library from http://undesigned.org.za/2007/10/22/amazon-s3-php-class
and place the file 'S3.php' in the includes directory in this module.
The stable version (0.4.0 20th Jul 2009) works best with Backup and Migrate.
LIGHTTPD USERS:
Add the following code to your lighttp.conf to secure your backup directories:
$HTTP["url"] =~ "^/sites/default/files/backup_migrate/" {
url.access-deny = ( "" )
}
You may need to adjust the path to reflect the actual path to the files.
IIS 7 USERS:
Add the following code to your web.config code to secire your backup directories:
<rule name="postinst-redirect" stopProcessing="true">
<match url="sites/default/files/backup_migrate" />
<action type="Rewrite" url=""/>
</rule>
You may need to adjust the path to reflect the actual path to the files.
-------------------------------------------------------------------------------
VERY IMPORTANT SECURITY NOTE:
Backup files may contain sensitive data and by default, are saved to your web
server in a directory normally accessible by the public. This could lead to a
very serious security vulnerability. Backup and Migrate attempts to protect
backup files using a .htaccess file, but this is not guaranteed to work on all
environments (and is guaranteed to fail on web servers that are not apache). You
should test to see if your backup files are publicly accessible, and if in doubt
do not save backups to the server, or use the destinations feature to save to a
folder outside of your webroot.
OTHER WARNINGS:
A failed restore can destroy your database and therefore your entire Drupal
installation. ALWAYS TEST BACKUP FILES ON A TEST ENVIRONMENT FIRST. If in doubt
do not use this module.
This module has only be tested with MySQL and does not work with anyother dbms.
If you have experiences with Postres or any other dbms and are willing to help
test and modify the module to work with it, please contact the developer at
ronan (at) gortonstudios (dot) com.
Make sure your php timeout is set high enough to complete a backup or restore
operation. Larger databases require more time. Also, while the module attempts
to keep memory needs to a minimum, a backup or restore will require
significantly more memory then most Drupal operations.
If your backup file contains the 'sessions' table all other users will be logged
out after you run a restore. To avoid this, exclude the sessions table when
creating your backups. Be aware though that you will need to recreate the
sessions table if you use this backup on an empty database.
Do not change the file extension of backup files or the restore function will be
unable to determine the compression type the file and will not function
correctly.
IF A RESTORE FAILS:
Don't panic, the restore file should work with phpMyAdmin's import function, or
with the mysql command line tool. If it does not, then it is likely corrupt; you
may panic now. MAKE SURE THAT THIS MODULE IS NOT YOUR ONLY FORM OF BACKUP.
-------------------------------------------------------------------------------

View File

@@ -0,0 +1,39 @@
.schedule-list-disabled {
filter:alpha(opacity=50);
-moz-opacity: .50;
opacity: .50;
}
.backup-migrate-cache-time {
font-size: 0.85em;
}
.backup-migrate-tables-checkboxes .form-item label {
width: 15em;
float: left;
overflow: hidden;
white-space: nowrap;
height: 1.75em;
margin: .25em .25em 0 0;
}
.backup-migrate-tables-checkboxes .form-item label.checked {
background-color: #eee;
}
.backup-migrate-tables-checkboxes .form-item label input {
margin-right: .25em;
}
div.backup-migrate-tables-checkboxes {
max-height: 40em;
overflow: auto;
}
div.backup-migrate-description {
font-size: smaller;
}
div.row-error {
color: #FF0000;
font-weight: bold;
}

Some files were not shown because too many files have changed in this diff Show More