removed front-page module

This commit is contained in:
Bachir Soussi Chiadmi 2015-07-03 10:31:06 +02:00
parent 408251fd28
commit 459335fee1
7 changed files with 0 additions and 1188 deletions

View File

@ -1,339 +0,0 @@
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

@ -1,52 +0,0 @@
Introduction
================
This module is for people who want a custom front page to their Drupal sites.
For all bugs, feature requests or support requests please use the
Front Page issue queue at http://drupal.org/project/issues/front
Key Functionality
=====================
1. Allows you to specify a custom front page based on role type.
2. Allows 4 different override types:
1. Themed - Allows you to add content that will display as a standard
themed Drupal page.
2. Full - Allows you to add content that will be displayed on the screen
as is. This method is the same as declaring a whole HTML page.
3. Redirect - Allows you to 301 redirect the user to another path.
4. Alias - Allows you to specify a local path which will then display as
the home page without redirecting the user.
4. Allow Themed and Full display types to be passed through Drupals input filters.
5. Override Home Links to go to another local path. This could be to stop users
going back to a splash screen.
Installation
===============
1. Upload and install the Front Page module.
2. Go to Administer -> Config -> Front Page.
3. Expand any of the roles that you want to override the default front page and
select the appropriate method of override as well as filling in the variables
required for that method. Once the settings are correct save the form.
4. Go to Administer -> Config -> Front Page -> Arrange.
5. Arrange the roles in the order in which you want them to process. Roles at
the top will process first and then work down the list. Once the order is
correct save the form.
5. Go back to Administer -> Config -> Front Page.
6. Enable the 'Front Page Override' checkbox and then save the form. The front
page module should now be working correctly.

View File

@ -1,16 +0,0 @@
Upgrading to 7.x-2.x
----- IMPORTANT -----
If you are using the php option for themed or full pages you need to make
sure there is a filter called "php_code" otherwise the system will use
the default filter instead and the php will not evaluate.
You should set the site front page to something other than "front_page".
The front page module no longer directs everything to "front_page" before
passing the user onto the appropriate option, it now catches the request at
the init stage and only sends the user to the "front_page" if it needs to
produce themed or full responses. The site default front page should be a local
page on the site and is usually the page that anonymous users should see.
Once you are happy with all your settings you need to enable the front page
module in /admin/config/front otherwise it will not work.

View File

@ -1,340 +0,0 @@
<?php
/**
* @file
* Admin page callbacks for the front page module.
*/
/**
* Form for configuring front page settings.
*/
function front_page_admin($form, &$form_state) {
$form['front_page_enable'] = array(
'#type' => 'checkbox',
'#title' => t('Front Page Override'),
'#description' => t('Enable this if you want the front page module to manage the home page.'),
'#default_value' => variable_get('front_page_enable', 0),
);
// Load any existing settings and build the by redirect by role form
$form['roles'] = array(
'#tree' => TRUE,
'#type' => 'fieldset',
'#title' => t('Roles'),
'#description' => t('These are the settings for each role. If Front Page Override is enabled when a user reaches the home page the site will iterate through the roles below from top to bottom until firstly the user has the role and secondly the role is not set to SKIP. If no roles get selected the site front page will be shown. To rearrange the order in which the roles are processed you may do this at the !link.', array('!link' => l(t('Arrange tab'), 'admin/config/front/arrange'))),
'#collapsible' => FALSE,
);
// build the form for roles
$roles = user_roles();
$front_page_data = front_page_get_all();
// Map the available modes common for all roles.
$modes = array(
'' => t('Skip'),
'themed' => t('Themed'),
'full' => t('Full'),
'redirect' => t('Redirect'),
'alias' => t('Alias'),
);
// Set the description common for all roles.
$descriptions = array(
'' => t('Disable functionality for this role.'),
'themed' => t('Means your default layout, theme and stylesheet will be loaded with your custom front_page.'),
'full' => t('Allows you to have a completely different layout, style sheet etc.'),
'redirect' => t('Will automatically redirect visitors to a specific page specified in the REDIRECT TO box.'),
'alias' => t('Will display the page listed in path as if it were the home page. This option does not redirect.'),
);
// Format the options to use as radio buttons
$options = array();
foreach ($modes as $key => $mode) {
$options[$key] = "<strong>{$mode}:</strong> {$descriptions[$key]}";
}
// Iterate each role
foreach ($roles as $rid => $role) {
// Determine the mode for this role
$mode = isset($front_page_data[$rid]['mode']) ? $front_page_data[$rid]['mode'] : '';
$form['roles'][$rid] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Front Page for !rolename (%mode)', array('!rolename' => $role, '%mode' => $modes[$mode])),
'#weight' => isset($front_page_data[$rid]['weight']) ? $front_page_data[$rid]['weight'] : 0,
);
$form['roles'][$rid]['mode'] = array(
'#type' => 'radios',
'#title' => t('Select mode'),
'#default_value' => $mode,
'#options' => $options,
);
// We need a wrapper because of a core bug that prevents the visible
// #state from properly hiding text_format widgets:
// @see: https://drupal.org/node/997826
$form['roles'][$rid]['data_wrapper'] = array(
'#type' => 'container',
'#states' => array(
'visible' => array(
':input[name="roles[' . $rid . '][mode]"]' => array(
array('value' => 'full'),
array('value' => 'themed')
),
),
),
);
$form['roles'][$rid]['data_wrapper']['data'] = array(
'#type' => 'text_format',
'#title' => t('Data'),
'#default_value' => (isset($front_page_data[$rid]['data']) && isset($front_page_data[$rid]['mode']) && ($front_page_data[$rid]['mode'] == 'themed' || $front_page_data[$rid]['mode'] == 'full')) ? $front_page_data[$rid]['data'] : NULL,
'#format' => !empty($front_page_data[$rid]['filter_format']) ? $front_page_data[$rid]['filter_format'] : NULL,
'#description' => t('Paste your HTML or TEXT here.') . '<br /><br />' . t('You can paste in the full HTML code for a complete page and include a different style sheet in the HEAD of the document if you want a completely different layout and style to the rest of your site.'),
);
$form['roles'][$rid]['path'] = array(
'#type' => 'textfield',
'#title' => t('Path'),
'#default_value' => (isset($front_page_data[$rid]['data']) && isset($front_page_data[$rid]['mode']) && ($front_page_data[$rid]['mode'] == 'redirect' || $front_page_data[$rid]['mode'] == 'alias')) ? $front_page_data[$rid]['data'] : NULL,
'#cols' => 20,
'#rows' => 1,
'#description' => t('If you are using <strong>Redirect</strong> or <strong>Alias</strong> you need to specify the path. An alias path should only include the URL part of a URL (eg "node/51"). A redirect path can contain a full URL including get parameters and fragment string (eg "node/51?page=5#anchor").'),
'#states' => array(
'visible' => array(
':input[name="roles[' . $rid . '][mode]"]' => array(
array('value' => 'redirect'),
array('value' => 'alias')
),
),
),
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save Settings'),
);
return $form;
}
/**
* Validation hook for front_page_admin.
*/
function front_page_admin_validate($form, &$form_state) {
if (is_array($form_state['values']['roles'])) {
foreach ($form_state['values']['roles'] as $rid => $role) {
switch ($role['mode']) {
case 'themed':
case 'full':
if (empty($role['data_wrapper']['data']['value'])) {
form_set_error('roles][' . $rid . '][data][value', 'You must set the data field for ' . $role['mode'] . ' mode.');
}
break;
case 'redirect':
if (empty($role['path'])) {
form_set_error('roles][' . $rid . '][path', 'You must set the path field for redirect mode.');
}
break;
case 'alias':
if (empty($role['path'])) {
form_set_error('roles][' . $rid . '][path', 'You must set the path field for alias mode.');
}
elseif (!preg_match('@^[^?#]+$@', $role['path'])) {
form_set_error('roles][' . $rid . '][path', 'You must set only the URI part of a URL in alias mode.');
}
break;
}
}
}
}
/**
* Submit hook for front_page_admin.
*/
function front_page_admin_submit($form, &$form_state) {
variable_set('front_page_enable', $form_state['values']['front_page_enable']);
db_query("UPDATE {front_page} SET mode=''");
if (is_array($form_state['values']['roles'])) {
foreach ($form_state['values']['roles'] as $rid => $role) {
switch ($role['mode']) {
case 'themed':
case 'full':
db_merge('front_page')
->key(array('rid' => $rid))
->fields(array(
'mode' => $role['mode'],
'data' => $role['data_wrapper']['data']['value'],
'filter_format' => $role['data_wrapper']['data']['format'],
))
->execute();
break;
case 'redirect':
case 'alias':
db_merge('front_page')
->key(array('rid' => $rid))
->fields(array(
'mode' => $role['mode'],
'data' => $role['path'],
'filter_format' => '',
))
->execute();
break;
default:
db_merge('front_page')
->key(array('rid' => $rid))
->fields(array(
'mode' => '',
'data' => '',
'filter_format' => '',
))
->execute();
break;
}
}
}
drupal_set_message(t('Your settings have been saved.'));
}
/**
* Form for arranging the roles according to what order the roles should be processed.
*/
function front_page_admin_arrange_form($form, &$form_state) {
$roles = user_roles();
$front_page_data = front_page_get_all();
foreach ($roles as $rid => $role) {
$front_page_data[$rid]['name'] = $role;
}
$form['roles'] = array(
'#tree' => TRUE,
);
foreach ($front_page_data as $role_id => $role) {
$form['roles'][$role_id]['title']['#markup'] = $role['name'];
$form['roles'][$role_id]['mode']['#markup'] = !empty($role['mode']) ? $role['mode'] : 'skip';
$form['roles'][$role_id]['preview']['#markup'] = !empty($role['mode']) ? l(t('preview'), 'front_page/preview/' . $role_id, array('attributes' => array('target' => '_blank'))) : '';
if (!empty($role['mode'])) {
$form['roles'][$role_id]['enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Enable'),
'#title_display' => 'invisible',
'#default_value' => TRUE,
);
}
else {
$form['roles'][$role_id]['enabled']['#markup'] = 'disabled';
}
$form['roles'][$role_id]['weight'] = array(
'#type' => 'weight',
'#title' => t('Weight'),
'#title_display' => 'invisible',
'#delta' => 10,
'#default_value' => isset($role['weight']) ? $role['weight'] : 0,
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save Order'),
);
return $form;
}
/**
* Submit hook for front_page_admin_arrange_form.
*/
function front_page_admin_arrange_form_submit($form, &$form_state) {
$front_page_data = front_page_get_all();
foreach ($form_state['values']['roles'] as $rid => $role) {
if (isset($role['mode']) && !$role['mode'] || !isset($front_page_data[$rid])) {
db_merge('front_page')
->key(array('rid' => $rid))
->fields(array(
'mode' => '',
'data' => '',
'filter_format' => '',
'weight' => $role['weight'],
))
->execute();
}
else {
db_merge('front_page')
->key(array('rid' => $rid))
->fields(array(
'weight' => $role['weight'],
))
->execute();
}
}
}
/**
* Form for setting the <front> placeholder to another path.
*/
function front_page_admin_home_links($form, &$form_state) {
$form['front_page_home_link_path'] = array(
'#type' => 'textfield',
'#title' => t('Redirect your site HOME links to'),
'#default_value' => variable_get('front_page_home_link_path', ''),
'#cols' => 20, '#rows' => 1,
'#description' => t('Specify where the user should be redirected to. An example would be <em>node/12</em>. Leave blank when you\'re not using HOME redirect.'),
'#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q=')
);
return system_settings_form($form);
}
/**
* Returns HTML for the front page arrange form into a table.
*
* @param $variables
* An associative array containing:
* - form: A render element representing the form.
*/
function theme_front_page_admin_arrange_form($variables) {
$form = $variables['form'];
drupal_add_tabledrag('front-page-arrange', 'order', 'sibling', 'front-page-weight');
$header = array(
t('Role'),
t('Mode'),
t('Preview'),
t('Enabled'),
t('Weight'),
);
$rows = array();
foreach (element_children($form['roles']) as $rid) {
$element = &$form['roles'][$rid];
// Add special classes to be used for tabledrag.js.
$element['weight']['#attributes']['class'] = array('front-page-weight');
$row = array();
$row[] = drupal_render($element['title']);
$row[] = drupal_render($element['mode']);
$row[] = drupal_render($element['preview']);
$row[] = drupal_render($element['enabled']);
$row[] = drupal_render($element['weight']);
$row = array_merge(array('data' => $row), $element['#attributes']);
$row['class'][] = 'draggable';
$rows[] = $row;
}
$output = '';
if (empty($rows)) {
$rows[] = array(array('data' => 'no roles', 'colspan' => '5'));
}
$output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'front-page-arrange')));
$output .= drupal_render_children($form);
return $output;
}

View File

@ -1,12 +0,0 @@
name = Front Page
description = Allows site admins setup custom front pages for the site.
package = Administration
core = 7.x
configure = admin/config/front/settings
; Information added by drupal.org packaging script on 2013-06-07
version = "7.x-2.4"
core = "7.x"
project = "front"
datestamp = "1370619956"

View File

@ -1,146 +0,0 @@
<?php
/**
* @file
* Install, update and uninstall functions for the front page module.
*/
/**
* Implements hook_install().
*/
function front_page_install() {
}
/**
* Implements hook_uninstall().
*/
function front_page_uninstall() {
variable_del('front_page_enable');
variable_del('front_page_breadcrumb');
variable_del('front_page_breadcrumb_redirect');
variable_del('special_notice_time');
variable_del('special_notice_text');
}
/**
* Implements hook_schema().
*/
function front_page_schema() {
$schema['front_page'] = array(
'description' => 'Stores Front Page settings.',
'fields' => array(
'rid' => array(
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'description' => 'Primary Key: Role ID.',
),
'mode' => array(
'type' => 'varchar',
'length' => 10,
'not null' => TRUE,
'default' => '',
'description' => 'The mode the front page will operate in for the selected role.',
),
'data' => array(
'type' => 'text',
'not null' => TRUE,
'size' => 'big',
'description' => 'Contains the data for the selected mode. This could be a path or html to display.',
),
'filter_format' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'The filter format to apply to the data.',
),
'weight' => array(
'type' => 'int',
'default' => 0,
'description' => 'The weight of the front page setting.',
)
),
'primary key' => array('rid'),
'indexes' => array(
'weight' => array('weight'),
),
);
return $schema;
}
/**
* Update 7200 - Add table if not already added, transfer data into the table and correct special notice times.
*/
function front_page_update_7200() {
if (!db_table_exists('front_page')) {
$schema = drupal_get_schema_unprocessed('front_page');
_drupal_schema_initialize($schema, 'front_page', FALSE);
if (isset($schema['front_page'])) {
db_create_table('front_page', $schema['front_page']);
}
// need to add front page data from variables table to new table.
$formats = filter_formats();
$formats = drupal_map_assoc(array_keys($formats));
$default_format = array_shift($formats);
$php_format = isset($formats['php_code']) ? 'php_code' : $default_format;
$roles = user_roles();
foreach ($roles as $rid => $role_name) {
$mode = variable_get('front_' . $rid . '_type', '');
if (!empty($mode)) {
switch ($mode) {
case 'themed':
case 'full':
$data = variable_get('front_' . $rid . '_text', '');
$format = $default_format;
if (variable_get('front_' . $rid . '_php', 0)) {
$format = $php_format;
}
break;
case 'redirect':
case 'alias':
$data = variable_get('front_' . $rid . '_redirect', '');
$format = '';
break;
default:
$mode = '';
$format = '';
$data = '';
break;
}
$weight = $rid * -1;
db_merge('front_page')
->key(array('rid' => $rid))
->fields(array(
'mode' => $mode,
'data' => $data,
'filter_format' => $format,
'weight' => $weight,
))
->execute();
variable_del('front_' . $rid . '_type');
variable_del('front_' . $rid . '_text');
variable_del('front_' . $rid . '_php');
variable_del('front_' . $rid . '_redirect');
}
}
}
if (variable_get('site_frontpage', 'node') == 'front_page') {
variable_set('site_frontpage', 'node');
}
}
function front_page_update_7201() {
variable_del('special_notice_time');
variable_del('special_notice_text');
variable_del('front_page_breadcrumb');
$path = variable_get('front_page_breadcrumb_redirect', '');
variable_set('front_page_home_link_path', $path);
variable_del('front_page_breadcrumb_redirect');
}

View File

@ -1,283 +0,0 @@
<?php
/**
*
* This module allows the site admin to set advanced front page settings.
*
* This version is for Drupal 7. Earlier versions can be found at http://drupal.org/project/front.
*
* This module version was developed by timhilliard and various members of the drupal community.
*
* If you have any ideas/patches or requests, please post them at http://drupal.org/project/issues/front.
*
*/
/**
* Implements hook_help().
*/
function front_page_help($section) {
switch ($section) {
case 'admin/config/front/settings':
return t('<p>Setup custom front pages for your site.</p>');
case 'admin/config/front/arrange':
return t('<p>Arrange the order in which roles will be checked for custom front page settings. Roles will be processed from top to bottom. To enable other roles you must first enable them in the !link.</p>', array('!link' => l(t('Settings tab'), 'admin/config/front/settings')));
case 'admin/config/front/home-links':
return t('<p>If a HOME link is set, the &lt;front&gt; placeholder will be replaced with this value instead of the standard front page.</p>');
}
}
/**
* Implements hook_menu().
*/
function front_page_menu() {
// Front page settings.
$items['admin/config/front'] = array(
'title' => 'Front Page',
'description' => 'Configure front page.',
'position' => 'right',
'weight' => -15,
'page callback' => 'system_admin_menu_block_page',
'access arguments' => array('administer front page'),
'file' => 'system.admin.inc',
'file path' => drupal_get_path('module', 'system'),
);
$items['admin/config/front/settings'] = array(
'title' => 'Settings',
'description' => 'Administer custom front page settings.',
'weight' => 0,
'page callback' => 'drupal_get_form',
'page arguments' => array('front_page_admin'),
'access arguments' => array('administer front page'),
'type' => MENU_LOCAL_TASK | MENU_NORMAL_ITEM,
'file' => 'front_page.admin.inc',
);
$items['admin/config/front/arrange'] = array(
'title' => 'Arrange',
'description' => 'Ability to re-arrange what order front page roles are processed.',
'page callback' => 'drupal_get_form',
'page arguments' => array('front_page_admin_arrange_form'),
'access arguments' => array('administer front page'),
'type' => MENU_LOCAL_TASK | MENU_NORMAL_ITEM,
'file' => 'front_page.admin.inc',
'weight' => 1,
);
$items['admin/config/front/home-links'] = array(
'title' => 'Home links',
'description' => 'Allows you to change the location of the &lt;front&gt; placeholder.',
'page callback' => 'drupal_get_form',
'page arguments' => array('front_page_admin_home_links'),
'access arguments' => array('administer front page'),
'type' => MENU_LOCAL_TASK | MENU_NORMAL_ITEM,
'file' => 'front_page.admin.inc',
'weight' => 2,
);
$items['front_page'] = array(
'title' => '',
'page callback' => 'front_page',
'access callback' => TRUE,
'type' => MENU_SUGGESTED_ITEM,
);
return $items;
}
/**
* Implements hook_permission().
*/
function front_page_permission() {
return array(
'administer front page' => array(
'title' => t('Administer front page'),
'description' => t('Allow users to make changes to the front page settings.'),
),
);
}
/**
* Implements hook_init().
*/
function front_page_init() {
// Make sure front page module is not run when using cli (drush).
// Make sur front page module does not run when installing Drupal either.
if (drupal_is_cli() || drupal_installation_attempted()) {
return;
}
// Don't run when site is in maintenance mode
if (variable_get('maintenance_mode', 0)) {
return;
}
// Ignore non index.php requests (like cron)
if (!empty($_SERVER['SCRIPT_FILENAME']) && realpath(DRUPAL_ROOT . '/index.php') != realpath($_SERVER['SCRIPT_FILENAME'])) {
return;
}
global $_front_page, $conf;
// let administrator know that there is a config error.
if (variable_get('site_frontpage', '') == 'front_page' && user_access('administer menu')) {
drupal_set_message(t('There is a configuration error. The home page should not be set to the path "front_page". Please change this !link', array('!link' => l(t('here'), 'admin/config/system/site-information'))), 'error');
}
if (variable_get('front_page_enable', 0) && drupal_is_front_page()) {
$_front_page = front_page_get_by_role();
}
if (user_access('administer menu') && preg_match('@^front_page/preview/([0-9]+)$@', $_GET['q'], $match)) {
$_front_page = front_page_get_by_rid($match[1]);
}
if ($_front_page) {
switch ($_front_page['mode']) {
case 'themed':
case 'full':
$_GET['q'] = 'front_page';
// need to set variable site_frontpage to current path so that it thinks it is the front page.
$conf['site_frontpage'] = $_GET['q'];
break;
case 'redirect':
$url = front_page_parse_url($_front_page['data']);
drupal_goto($url['path'], $url['options']);
break;
case 'alias':
$url = front_page_parse_url($_front_page['data']);
$_GET['q'] = drupal_get_normal_path($url['path']);
// need to set variable site_frontpage to current path so that it thinks it is the front page.
$conf['site_frontpage'] = $_GET['q'];
break;
}
// turn caching off for this page as it is dependant on role.
$GLOBALS['conf']['cache'] = FALSE;
}
}
/**
* Function to handle the display of the front page themed and full types.
*/
function front_page() {
// $_front_page variable should already have been loaded in front_page_init() function.
global $_front_page;
if ($_front_page) {
switch ($_front_page['mode']) {
case 'themed':
return check_markup($_front_page['data'], $_front_page['filter_format']);
case 'full':
print check_markup($_front_page['data'], $_front_page['filter_format']);
exit;
}
}
// set page not found as there was no themed or full option set for the front page.
drupal_not_found();
exit;
}
/**
* Function to parse a full URL including GET variables and fragment
* to an array ready for drupal_goto(), url(), or l() functions.
*/
function front_page_parse_url($path) {
$url['path'] = $path;
$url['options'] = array();
if (preg_match('@^(?P<path>[^?#]+)(\?(?P<query>[^#]*))?(#(?P<fragment>.*))?$@', $path, $match)) {
$url['path'] = $match['path'];
if (!empty($match['query'])) {
foreach (explode('&', $match['query']) as $query_part) {
list($key, $value) = explode('=', $query_part);
$url['options']['query'][$key] = $value;
}
}
if (!empty($match['fragment'])) {
$url['options']['fragment'] = $match['fragment'];
}
}
return $url;
}
/**
* Function to return the first role enabled in front page, ordered by weight.
*/
function front_page_get_by_role($index = 0, $number = 1) {
global $user;
$result = db_select('front_page', 'fp')
->fields('fp')
->condition('rid', array_keys($user->roles))
->condition('mode', '', '<>')
->orderBy('weight', 'ASC')
->orderBy('rid', 'DESC')
->range($index, $number)
->execute()
->fetchAssoc();
return $result;
}
/**
* Function to return the first role enabled in front page, ordered by weight.
*/
function front_page_get_by_rid($rid) {
$result = db_select('front_page', 'fp')
->fields('fp')
->condition('rid', $rid)
->condition('mode', '', '<>')
->execute()
->fetchAssoc();
return $result;
}
/**
* Function to return all the roles in front page, ordered by weight.
*/
function front_page_get_all() {
global $user;
$result = db_select('front_page', 'fp')
->fields('fp')
->orderBy('weight', 'ASC')
->orderBy('rid', 'DESC')
->execute()
->fetchAllAssoc('rid', PDO::FETCH_ASSOC);
return $result;
}
/**
* Implements hook_page_url_outbound_alter().
*
* This alters anything parsed through the url() function to replace the <front> string
* with an alternative string instead of the site_frontpage setting.
*/
function front_page_url_outbound_alter(&$path, &$options, &$original_path) {
// check if path is set to 'front_page' as this is our virtual home
// page and doesn't work properly unless used from home page.
if ($path == 'front_page') {
$original_path = $path = '';
}
$newpath = variable_get('front_page_home_link_path', '');
if (($path == '<front>' || empty($path)) && !empty($newpath)) {
$original_path = $path = $newpath;
}
}
/**
* Implements hook_theme().
*/
function front_page_theme() {
return array(
'front_page_admin_arrange_form' => array(
'file' => 'front_page.admin.inc',
'render element' => 'form',
),
);
}
/**
* Implements hook_user_role_delete().
*/
function front_page_user_role_delete($role) {
// Delete Front configuration for the role being deleted.
db_delete('front_page')
->condition('rid', $role->rid)
->execute();
}