Skip to content
Snippets Groups Projects
Commit 0e2284dc authored by Chris Gross's avatar Chris Gross
Browse files

daily build

parent 921ba33c
No related branches found
No related tags found
No related merge requests found
Showing
with 1567 additions and 12 deletions
WCM Base 7.x-1.x, 2015-11-09
----------------------------
- OCIO URL Aliases: Add and enable Pathologic module.
- OCIO WYSIWYG: Add Pathologic to Filtered HTML text format.
- OCIO Omega Base: Re-aligned contact and leadership pages.
WCM Base 7.x-1.x, 2015-11-06 WCM Base 7.x-1.x, 2015-11-06
---------------------------- ----------------------------
- OCIO Web Form: - OCIO Web Form:
......
...@@ -7,9 +7,9 @@ dependencies[] = views ...@@ -7,9 +7,9 @@ dependencies[] = views
files[] = better_exposed_filters_exposed_form_plugin.inc files[] = better_exposed_filters_exposed_form_plugin.inc
files[] = tests/better_exposed_filters.test files[] = tests/better_exposed_filters.test
; Information added by Drupal.org packaging script on 2015-08-16 ; Information added by Drupal.org packaging script on 2015-11-08
version = "7.x-3.2+36-dev" version = "7.x-3.2+37-dev"
core = "7.x" core = "7.x"
project = "better_exposed_filters" project = "better_exposed_filters"
datestamp = "1439736843" datestamp = "1446999846"
...@@ -121,7 +121,7 @@ function bef_test_content_field_default_field_bases() { ...@@ -121,7 +121,7 @@ function bef_test_content_field_default_field_bases() {
'settings' => array( 'settings' => array(
'allowed_values' => array( 'allowed_values' => array(
0 => array( 0 => array(
'vocabulary' => 'location', 'vocabulary' => 'taxonomy-bef_test-location',
'parent' => 0, 'parent' => 0,
), ),
), ),
......
...@@ -9,9 +9,9 @@ ...@@ -9,9 +9,9 @@
*/ */
function bef_test_content_taxonomy_default_vocabularies() { function bef_test_content_taxonomy_default_vocabularies() {
return array( return array(
'location' => array( 'taxonomy-bef_test-location' => array(
'name' => 'Location', 'name' => 'Location',
'machine_name' => 'location', 'machine_name' => 'taxonomy-bef_test-location',
'description' => '', 'description' => '',
'hierarchy' => 1, 'hierarchy' => 1,
'module' => 'taxonomy', 'module' => 'taxonomy',
......
...@@ -28,7 +28,7 @@ features[field_instance][] = node-bef_test-field_bef_test_location ...@@ -28,7 +28,7 @@ features[field_instance][] = node-bef_test-field_bef_test_location
features[field_instance][] = node-bef_test-field_bef_test_numbers features[field_instance][] = node-bef_test-field_bef_test_numbers
features[field_instance][] = node-bef_test-field_bef_test_price features[field_instance][] = node-bef_test-field_bef_test_price
features[node][] = bef_test features[node][] = bef_test
features[taxonomy][] = location features[taxonomy][] = taxonomy-bef_test-location
features[views_view][] = bef_test_view features[views_view][] = bef_test_view
features_exclude[dependencies][ctools] = ctools features_exclude[dependencies][ctools] = ctools
features_exclude[dependencies][options] = options features_exclude[dependencies][options] = options
...@@ -41,9 +41,9 @@ features_exclude[field][node-bef_test-field_price] = node-bef_test-field_price ...@@ -41,9 +41,9 @@ features_exclude[field][node-bef_test-field_price] = node-bef_test-field_price
features_exclude[field][node-bef_test-field_date] = node-bef_test-field_date features_exclude[field][node-bef_test-field_date] = node-bef_test-field_date
hidden = 1 hidden = 1
; Information added by Drupal.org packaging script on 2015-08-16 ; Information added by Drupal.org packaging script on 2015-11-08
version = "7.x-3.2+36-dev" version = "7.x-3.2+37-dev"
core = "7.x" core = "7.x"
project = "better_exposed_filters" project = "better_exposed_filters"
datestamp = "1439736843" datestamp = "1446999846"
...@@ -253,7 +253,7 @@ function bef_test_content_views_default_views() { ...@@ -253,7 +253,7 @@ function bef_test_content_views_default_views() {
3 => 0, 3 => 0,
); );
$handler->display->display_options['filters']['field_bef_test_location_tid']['type'] = 'select'; $handler->display->display_options['filters']['field_bef_test_location_tid']['type'] = 'select';
$handler->display->display_options['filters']['field_bef_test_location_tid']['vocabulary'] = 'location'; $handler->display->display_options['filters']['field_bef_test_location_tid']['vocabulary'] = 'taxonomy-bef_test-location';
$handler->display->display_options['filters']['field_bef_test_location_tid']['hierarchy'] = 1; $handler->display->display_options['filters']['field_bef_test_location_tid']['hierarchy'] = 1;
/* Display: Page */ /* Display: Page */
......
...@@ -316,7 +316,7 @@ class BEF_TestTaxonomyFilters extends BEF_TestBase { ...@@ -316,7 +316,7 @@ class BEF_TestTaxonomyFilters extends BEF_TestBase {
// Add three terms with two children each to the vocab defined in // Add three terms with two children each to the vocab defined in
// bef_test_content. // bef_test_content.
$vocab = taxonomy_vocabulary_machine_name_load('location'); $vocab = taxonomy_vocabulary_machine_name_load('taxonomy-bef_test-location');
$parents = array(); $parents = array();
foreach (array('parent1', 'parent2', 'parent3') as $name) { foreach (array('parent1', 'parent2', 'parent3') as $name) {
$term = new stdClass(); $term = new stdClass();
......
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.
Pathologic
----------
Project Page:
http://drupal.org/project/pathologic
By Garrett Albright
http://drupal.org/user/191212
Originally sponsored by Precision Intermedia
http://www.precisionintermedia.com/
Thanks to all who have used this module over the years and provided bug reports
and suggestions via email and the issue queue! I love you all.
Installation & Configuration
----------------------------
For full installation and configuration instructions, please see this page in
the Drupal online manual:
http://drupal.org/node/257026
<?php
/**
* @file
* Configuration form for Pathologic.
*/
/**
* Form callback for the Pathologic configuration form.
*/
function pathologic_configuration_form($form, $form_state) {
$form['reminder'] = array(
'#type' => 'markup',
'#markup' => '<p>' . t('Reminder: The settings on this form only affect text formats for which Pathologic is configured to use the global Pathologic settings; if it&rsquo;s configured to use per-format settings, these settings will have no effect. If you have upgraded to the current 7.x-3.x version of Pathologic from version 7.x-2.x, all of your current formats will use their existing per-format settings by default, so that behavior will be the same as the 7.x-2.x version until they are configured to use the global settings instead. Please <a href="!docs">consult Pathologic&rsquo;s documentation</a> for a step-by-step guide to configuring Pathologic.', array('!docs' => 'http://drupal.org/node/257026')) . '</p>',
'#weight' => 0,
);
$config_form = _pathologic_configuration_form(array(
'protocol_style' => variable_get('pathologic_protocol_style', 'full'),
'local_paths' => variable_get('pathologic_local_paths', ''),
));
$form['pathologic_protocol_style'] = $config_form['protocol_style'];
$form['pathologic_local_paths'] = $config_form['local_paths'];
return system_settings_form($form);
}
/**
* Common elements for the Pathologic configuration form.
*
* This reduces redundancy in code for form elements that will appear on both
* the global settings form and the per-format filter settings form.
*
* @param $defaults
* An array of default values for the configuration form fields.
* @return
* The common form elements
*/
function _pathologic_configuration_form($defaults) {
return array(
'protocol_style' => array(
'#type' => 'radios',
'#title' => t('Processed URL format'),
'#default_value' => $defaults['protocol_style'],
'#options' => array(
'full' => t('Full URL (<code>http://example.com/foo/bar</code>)'),
'proto-rel' => t('Protocol relative URL (<code>//example.com/foo/bar</code>)'),
'path' => t('Path relative to server root (<code>/foo/bar</code>)'),
),
'#description' => t('The <em>Full URL</em> option is best for stopping broken images and links in syndicated content (such as in RSS feeds), but will likely lead to problems if your site is accessible by both HTTP and HTTPS. Paths output with the <em>Protocol relative URL</em> option will avoid such problems, but feed readers and other software not using up-to-date standards may be confused by the paths. The <em>Path relative to server root</em> option will avoid problems with sites accessible by both HTTP and HTTPS with no compatibility concerns, but will absolutely not fix broken images and links in syndicated content.'),
'#weight' => 10,
),
'local_paths' => array(
'#type' => 'textarea',
'#title' => t('All base paths for this site'),
'#default_value' => $defaults['local_paths'],
'#description' => t('If this site is or was available at more than one base path or URL, enter them here, separated by line breaks. For example, if this site is live at <code>http://example.com/</code> but has a staging version at <code>http://dev.example.org/staging/</code>, you would enter both those URLs here. If confused, please read <a href="!docs">Pathologic&rsquo;s documentation</a> for more information about this option and what it affects.', array('!docs' => 'http://drupal.org/node/257026')),
'#weight' => 20,
),
);
}
<?php
/**
* @file
* Hooks provided by Pathologic.
*
* @ingroup pathologic
*/
/**
* @addtogroup hooks
* @{
*/
/**
* Allow modules to alter a URL Pathologic is about to create.
*
* This hook is invoked after Pathologic has torn apart a URL it thinks it can
* alter properly and is just about to call the url() function to construct the
* new URL. Modules can alter the values that Pathologic is about to send to
* url(), or even stop Pathologic from altering a URL entirely.
*
* @param $url_params
* An array with 'path' and 'options' values, which correspond to the $path
* and $options parameters of the url() function. The 'options' array has an
* extra parameter labeled 'use_original' which is set to FALSE by default.
* This parameter is ignored by url(), but if its value is set to TRUE after
* all alter hook invocations, Pathologic will return the original, unaltered
* path it found in the content instead of calling url() and generating a new
* one. Thus, it provides a way for modules to halt the alteration of paths
* which Pathologic has incorrectly decided should be altered.
* @param $parts
* This array contains the result of running parse_url() on the path that
* Pathologic found in content, though Pathologic likely altered some of the
* values in this array since. It contains another parameter, 'original',
* which contains the original URL Pathologic found in the content, unaltered.
* You should not alter this value in any way; to alter how Pathologic
* constructs the new URL, alter $url_params instead.
* @param $settings
* This contains the settings Pathologic is using to decide how to alter the
* URL; some settings are from the graphical filter form and alterable by the
* user, while others are determined programmatically. If you're looking for
* the filter settings which Pathologic is currently using (if you've altered
* your own field onto the filter settings form, for example), try looking in
* $settings['current_settings'].
*
* @see url()
* @see parse_url()
* @see pathologic_replace()
* @see http://drupal.org/node/1762022
*/
function hook_pathologic_alter(&$url_params, $parts, $settings) {
// If we're linking to the "bananas" subdirectory or something under it, then
// have Pathologic pass through the original URL, without altering it.
if (preg_match('~^bananas(/.*)?$~', $url_params['path'])) {
$url_params['options']['use_original'] = TRUE;
}
// If we're linking to a path like "article/something.html", then prepend
// "magazine" to the path, but remove the ".html". The end result will look
// like "magazine/article/something".
if (preg_match('~^article/(.+)\.html$~', $url_params['path'], $matches)) {
$url_params['path'] = 'magazine/article/' . $matches[1];
}
// If the URL doesn't have a "foo" query parameter, then add one.
if (!is_array($url_params['options']['query'])) {
$url_params['options']['query'] = array();
}
if (empty($url_params['options']['query']['foo'])) {
$url_params['options']['query']['foo'] = 'bar';
}
// If it's a path to a local image, make sure it's using our CDN server.
if (preg_match('~\.(png|gif|jpe?g)$~', $url_params['path'])) {
$url_params['path'] = 'http://cdn.example.com/' . $url_params['path'];
$url_params['options']['external'] = TRUE;
}
}
/**
* @} End of "addtogroup hooks".
*/
name = Pathologic
description = Helps avoid broken links and incorrect paths in content.
package = "Input filters"
dependencies[] = filter
core = 7.x
configure = admin/config/content/pathologic
files[] = tests/pathologic.test
; Information added by Drupal.org packaging script on 2015-11-04
version = "7.x-3.0"
core = "7.x"
project = "pathologic"
datestamp = "1446668979"
<?php
/**
* @file
* .install file for Pathologic.
*/
/**
* Re-enable Pathologic under Drupal 7, preserving settings from Drupal 6.
*/
function pathologic_update_7000($sandbox) {
// Make sure {d6_upgrade_filter} exists. It won't exist for people upgrading
// from beta versions of the D7 version of Pathologic on native D7 sites (not
// upgraded from D6).
if (db_table_exists('d6_upgrade_filter')) {
// Get all Pathologic data from {d6_upgrade_filter}.
$rez = db_select('d6_upgrade_filter', 'dup')
->fields('dup')
->condition('module', 'pathologic')
->execute();
while ($instance = $rez->fetchObject()) {
// Load the format
if ($format = filter_format_load($instance->format)) {
// Load filters.
$format->filters = array();
// Add the filters
foreach (filter_list_format($instance->format) as $filter_name => $filter) {
$format->filters[$filter_name] = (array)$filter;
}
// Add Pathologic
$format->filters['pathologic'] = array(
'weight' => $instance->weight,
'status' => 1,
'settings' => array(
'absolute' => variable_get('filter_pathologic_absolute_' . $instance->format, TRUE),
'local_paths' => variable_get('filter_pathologic_local_paths_' . $instance->format, ''),
),
);
// Save the format
filter_format_save($format);
// Unset old variables
variable_del('filter_pathologic_absolute_' . $instance->format);
variable_del('filter_pathologic_local_paths_' . $instance->format);
}
}
// Delete Pathologic data from {d6_upgrade_filter}…?
// No, maybe we don't want to actually do that…?
}
}
/**
* Convert obsolete "absolute" setting to modern "protocol_style" setting for
* each filter instance.
*/
function pathologic_update_7200(&$sandbox) {
foreach (filter_formats() as $format) {
// @see http://drupal.org/node/1304930
if (empty($format->filters)) {
$format->filters = array();
// Add the filters
foreach (filter_list_format($format->format) as $filter_name => $filter) {
$format->filters[$filter_name] = (array)$filter;
}
}
if (isset($format->filters['pathologic'])) {
$format->filters['pathologic']['settings']['protocol_style'] = $format->filters['pathologic']['settings']['absolute'] ? 'full' : 'path';
unset($format->filters['pathologic']['settings']['absolute']);
filter_format_save($format);
}
}
}
<?php
/**
* @file
* Pathologic text filter for Drupal.
*
* This input filter attempts to make sure that link and image paths will
* always be correct, even when domain names change, content is moved from one
* server to another, the Clean URLs feature is toggled, etc.
*/
/**
* Implements hook_menu().
*/
function pathologic_menu() {
return array(
'admin/config/content/pathologic' => array(
'title' => 'Pathologic',
'description' => 'Configure how Pathologic adjusts link and image paths in content.',
'page callback' => 'drupal_get_form',
'page arguments' => array('pathologic_configuration_form'),
'file' => 'pathologic.admin.inc',
'access arguments' => array('administer filters'),
),
);
}
/**
* Implements hook_filter_info().
*/
function pathologic_filter_info() {
return array(
'pathologic' => array(
'title' => t('Correct URLs with Pathologic'),
'process callback' => '_pathologic_filter',
'settings callback' => '_pathologic_settings',
'default settings' => array(
'settings_source' => 'global',
'local_paths' => '',
'protocol_style' => 'full',
),
// Set weight to 50 so that it will hopefully appear at the bottom of
// filter lists by default. 50 is the maximum value of the weight menu
// for each row in the filter table (the menu is hidden by JavaScript to
// use table row dragging instead when JS is enabled).
'weight' => 50,
)
);
}
/**
* Settings callback for Pathologic.
*/
function _pathologic_settings($form, &$form_state, $filter, $format, $defaults, $filters) {
// Puzzlingly, though we have a $form parameter, it has everything else's form
// elements in it; we can't just modify it in place or return it modified. We
// need to start a new form.
$our_form = array();
$our_form['reminder'] = array(
'#type' => 'item',
'#title' => t('In most cases, Pathologic should be the <em>last</em> filter in the &ldquo;Filter processing order&rdquo; list.'),
'#weight' => 0,
);
$our_form['settings_source'] = array(
'#type' => 'radios',
'#title' => t('Settings source'),
'#description' => t('Select whether Pathologic should use the <a href="!config">global Pathologic settings</a> or custom &ldquo;local&rdquo; settings when filtering text in this text format.', array('!config' => url('admin/config/content/pathologic'))),
'#weight' => 10,
'#default_value' => _pathologic_get_real_settings_source($format->format),
'#options' => array(
'global' => t('Use global Pathologic settings'),
'local' => t('Use custom settings for this text format'),
),
);
$our_form['local_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Custom settings for this text format'),
'#weight' => 20,
'#collapsible' => FALSE,
'#collapsed' => FALSE,
'#description' => t('These settings are ignored if &ldquo;Use global Pathologic settings&rdquo; is selected above.'),
'#states' => array(
'visible' => array(
':input[name="filters[pathologic][settings][settings_source]"]' => array('value' => 'local'),
),
),
);
module_load_include('inc', 'pathologic', 'pathologic.admin');
$our_form['local_settings'] += _pathologic_configuration_form(array(
'protocol_style' => isset($filter->settings['protocol_style']) ? $filter->settings['protocol_style'] : $defaults['protocol_style'],
'local_paths' => isset($filter->settings['local_paths']) ? $filter->settings['local_paths'] : $defaults['local_paths'],
));
return $our_form;
}
/**
* Pathologic filter callback.
*
* Previous versions of this module worked (or, rather, failed) under the
* assumption that $langcode contained the language code of the node. Sadly,
* this isn't the case.
* @see http://drupal.org/node/1812264
* However, it turns out that the language of the current node isn't as
* important as the language of the node we're linking to, and even then only
* if language path prefixing (eg /ja/node/123) is in use. REMEMBER THIS IN THE
* FUTURE, ALBRIGHT.
*
* The below code uses the @ operator before parse_url() calls because in PHP
* 5.3.2 and earlier, parse_url() causes a warning of parsing fails. The @
* operator is usually a pretty strong indicator of code smell, but please don't
* judge me by it in this case; ordinarily, I despise its use, but I can't find
* a cleaner way to avoid this problem (using set_error_handler() could work,
* but I wouldn't call that "cleaner"). Fortunately, Drupal 8 will require at
* least PHP 5.3.5, so this mess doesn't have to spread into the D8 branch of
* Pathologic.
* @see https://drupal.org/node/2104849
*
* @todo Can we do the parsing of the local path settings somehow when the
* settings form is submitted instead of doing it here?
*/
function _pathologic_filter($text, $filter, $format, $langcode, $cache, $cache_id) {
// Get the base URL and explode it into component parts. We add these parts
// to the exploded local paths settings later.
global $base_url;
$base_url_parts = @parse_url($base_url . '/');
// Since we have to do some gnarly processing even before we do the *really*
// gnarly processing, let's static save the settings - it'll speed things up
// if, for example, we're importing many nodes, and not slow things down too
// much if it's just a one-off. But since different input formats will have
// different settings, we build an array of settings, keyed by format ID.
$cached_settings = &drupal_static(__FUNCTION__, array());
if (!isset($cached_settings[$filter->format])) {
$filter_settings = $filter->settings;
// Overwrite local settings with the global defaults if necessary
if (_pathologic_get_real_settings_source($filter->format) === 'global') {
$filter_settings['protocol_style'] = variable_get('pathologic_protocol_style', 'full');
$filter_settings['local_paths'] = variable_get('pathologic_local_paths', '');
}
$filter_settings['local_paths_exploded'] = array();
if ($filter_settings['local_paths'] !== '') {
// Build an array of the exploded local paths for this format's settings.
// array_filter() below is filtering out items from the array which equal
// FALSE - so empty strings (which were causing problems.
// @see http://drupal.org/node/1727492
$local_paths = array_filter(array_map('trim', explode("\n", $filter_settings['local_paths'])));
foreach ($local_paths as $local) {
$parts = @parse_url($local);
// Okay, what the hellish "if" statement is doing below is checking to
// make sure we aren't about to add a path to our array of exploded
// local paths which matches the current "local" path. We consider it
// not a match, if…
// @todo: This is pretty horrible. Can this be simplified?
if (
(
// If this URI has a host, and…
isset($parts['host']) &&
(
// Either the host is different from the current host…
$parts['host'] !== $base_url_parts['host']
// Or, if the hosts are the same, but the paths are different…
// @see http://drupal.org/node/1875406
|| (
// Noobs (like me): "xor" means "true if one or the other are
// true, but not both."
(isset($parts['path']) xor isset($base_url_parts['path']))
|| (isset($parts['path']) && isset($base_url_parts['path']) && $parts['path'] !== $base_url_parts['path'])
)
)
) ||
// Or…
(
// The URI doesn't have a host…
!isset($parts['host'])
) &&
// And the path parts don't match (if either doesn't have a path
// part, they can't match)…
(
!isset($parts['path']) ||
!isset($base_url_parts['path']) ||
$parts['path'] !== $base_url_parts['path']
)
) {
// Add it to the list.
$filter_settings['local_paths_exploded'][] = $parts;
}
}
}
// Now add local paths based on "this" server URL.
$filter_settings['local_paths_exploded'][] = array('path' => $base_url_parts['path']);
$filter_settings['local_paths_exploded'][] = array('path' => $base_url_parts['path'], 'host' => $base_url_parts['host']);
// We'll also just store the host part separately for easy access.
$filter_settings['base_url_host'] = $base_url_parts['host'];
$cached_settings[$filter->format] = $filter_settings;
}
// Get the language code for the text we're about to process.
$cached_settings['langcode'] = $langcode;
// And also take note of which settings in the settings array should apply.
$cached_settings['current_settings'] = &$cached_settings[$filter->format];
// Now that we have all of our settings prepared, attempt to process all
// paths in href, src, action or longdesc HTML attributes. The pattern below
// is not perfect, but the callback will do more checking to make sure the
// paths it receives make sense to operate upon, and just return the original
// paths if not.
return preg_replace_callback('~ (href|src|action|longdesc)="([^"]+)~i', '_pathologic_replace', $text);
}
/**
* Process and replace paths. preg_replace_callback() callback.
*/
function _pathologic_replace($matches) {
// Get the base path.
global $base_path;
// Get the settings for the filter. Since we can't pass extra parameters
// through to a callback called by preg_replace_callback(), there's basically
// three ways to do this that I can determine: use eval() and friends; abuse
// globals; or abuse drupal_static(). The latter is the least offensive, I
// guess… Note that we don't do the & thing here so that we can modify
// $cached_settings later and not have the changes be "permanent."
$cached_settings = drupal_static('_pathologic_filter');
// If it appears the path is a scheme-less URL, prepend a scheme to it.
// parse_url() cannot properly parse scheme-less URLs. Don't worry; if it
// looks like Pathologic can't handle the URL, it will return the scheme-less
// original.
// @see https://drupal.org/node/1617944
// @see https://drupal.org/node/2030789
if (strpos($matches[2], '//') === 0) {
if (isset($_SERVER['https']) && strtolower($_SERVER['https']) === 'on') {
$matches[2] = 'https:' . $matches[2];
}
else {
$matches[2] = 'http:' . $matches[2];
}
}
// Now parse the URL after reverting HTML character encoding.
// @see http://drupal.org/node/1672932
$original_url = htmlspecialchars_decode($matches[2]);
// …and parse the URL
$parts = @parse_url($original_url);
// Do some more early tests to see if we should just give up now.
if (
// If parse_url() failed, $parts = FALSE. If the href was just "#", $parts
// is an empty array. Give up in both cases.
empty($parts)
|| (
// If there's a scheme part and it doesn't look useful, bail out.
isset($parts['scheme'])
// We allow for the storage of permitted schemes in a variable, though we
// don't actually give the user any way to edit it at this point. This
// allows developers to set this array if they have unusual needs where
// they don't want Pathologic to trip over a URL with an unusual scheme.
// @see http://drupal.org/node/1834308
// "files" and "internal" are for Path Filter compatibility.
&& !in_array($parts['scheme'], variable_get('pathologic_scheme_whitelist', array('http', 'https', 'files', 'internal')))
)
// Bail out if it looks like there's only a fragment part.
|| (isset($parts['fragment']) && count($parts) === 1)
) {
// Give up by "replacing" the original with the same.
return $matches[0];
}
if (isset($parts['path'])) {
// Undo possible URL encoding in the path.
// @see http://drupal.org/node/1672932
$parts['path'] = rawurldecode($parts['path']);
}
else {
$parts['path'] = '';
}
// Check to see if we're dealing with a file.
// @todo Should we still try to do path correction on these files too?
if (isset($parts['scheme']) && $parts['scheme'] === 'files') {
// Path Filter "files:" support. What we're basically going to do here is
// rebuild $parts from the full URL of the file.
$new_parts = @parse_url(file_create_url(file_default_scheme() . '://' . $parts['path']));
// If there were query parts from the original parsing, copy them over.
if (!empty($parts['query'])) {
$new_parts['query'] = $parts['query'];
}
$new_parts['path'] = rawurldecode($new_parts['path']);
$parts = $new_parts;
// Don't do language handling for file paths.
$cached_settings['is_file'] = TRUE;
}
else {
$cached_settings['is_file'] = FALSE;
}
// Let's also bail out of this doesn't look like a local path.
$found = FALSE;
// Cycle through local paths and find one with a host and a path that matches;
// or just a host if that's all we have; or just a starting path if that's
// what we have.
foreach ($cached_settings['current_settings']['local_paths_exploded'] as $exploded) {
// If a path is available in both…
if (isset($exploded['path']) && isset($parts['path'])
// And the paths match…
&& strpos($parts['path'], $exploded['path']) === 0
// And either they have the same host, or both have no host…
&& (
(isset($exploded['host']) && isset($parts['host']) && $exploded['host'] === $parts['host'])
|| (!isset($exploded['host']) && !isset($parts['host']))
)
) {
// Remove the shared path from the path. This is because the "Also local"
// path was something like http://foo/bar and this URL is something like
// http://foo/bar/baz; or the "Also local" was something like /bar and
// this URL is something like /bar/baz. And we only care about the /baz
// part.
$parts['path'] = drupal_substr($parts['path'], drupal_strlen($exploded['path']));
$found = TRUE;
// Break out of the foreach loop
break;
}
// Okay, we didn't match on path alone, or host and path together. Can we
// match on just host? Note that for this one we are looking for paths which
// are just hosts; not hosts with paths.
elseif ((isset($parts['host']) && !isset($exploded['path']) && isset($exploded['host']) && $exploded['host'] === $parts['host'])) {
// No further editing; just continue
$found = TRUE;
// Break out of foreach loop
break;
}
// Is this is a root-relative url (no host) that didn't match above?
// Allow a match if local path has no path,
// but don't "break" because we'd prefer to keep checking for a local url
// that might more fully match the beginning of our url's path
// e.g.: if our url is /foo/bar we'll mark this as a match for
// http://example.com but want to keep searching and would prefer a match
// to http://example.com/foo if that's configured as a local path
elseif (!isset($parts['host']) && (!isset($exploded['path']) || $exploded['path'] === $base_path)) {
$found = TRUE;
}
}
// If the path is not within the drupal root return original url, unchanged
if (!$found) {
return $matches[0];
}
// Okay, format the URL.
// If there's still a slash lingering at the start of the path, chop it off.
$parts['path'] = ltrim($parts['path'],'/');
// Examine the query part of the URL. Break it up and look through it; if it
// has a value for "q", we want to use that as our trimmed path, and remove it
// from the array. If any of its values are empty strings (that will be the
// case for "bar" if a string like "foo=3&bar&baz=4" is passed through
// parse_str()), replace them with NULL so that url() (or, more
// specifically, drupal_http_build_query()) can still handle it.
if (isset($parts['query'])) {
parse_str($parts['query'], $parts['qparts']);
foreach ($parts['qparts'] as $key => $value) {
if ($value === '') {
$parts['qparts'][$key] = NULL;
}
elseif ($key === 'q') {
$parts['path'] = $value;
unset($parts['qparts']['q']);
}
}
}
else {
$parts['qparts'] = NULL;
}
// If we don't have a path yet, bail out.
if (!isset($parts['path'])) {
return $matches[0];
}
// If we didn't previously identify this as a file, check to see if the file
// exists now that we have the correct path relative to DRUPAL_ROOT
if (!$cached_settings['is_file']) {
$cached_settings['is_file'] = !empty($parts['path']) && is_file(DRUPAL_ROOT . '/'. $parts['path']);
}
// Okay, deal with language stuff.
$language_list = language_list();
if ($cached_settings['is_file']) {
// If we're linking to a file, use a fake LANGUAGE_NONE language object.
// Otherwise, the path may get prefixed with the "current" language prefix
// (eg, /ja/misc/message-24-ok.png)
$parts['language_obj'] = (object) array('language' => LANGUAGE_NONE, 'prefix' => '');
}
else if(!empty($cached_settings['langcode']) && !empty($language_list[$cached_settings['langcode']])) {
$parts['language_obj'] = $language_list[$cached_settings['langcode']];
}
else {
// Let's see if we can split off a language prefix from the path.
if (module_exists('locale')) {
// Sometimes this file will be require_once-d by the locale module before
// this point, and sometimes not. We require_once it ourselves to be sure.
require_once DRUPAL_ROOT . '/includes/language.inc';
list($language_obj, $path) = language_url_split_prefix($parts['path'], $language_list);
if ($language_obj) {
$parts['path'] = $path;
$parts['language_obj'] = $language_obj;
}
}
}
// If we get to this point and $parts['path'] is now an empty string (which
// will be the case if the path was originally just "/"), then we
// want to link to <front>.
if ($parts['path'] === '') {
$parts['path'] = '<front>';
}
// Build the parameters we will send to url()
$url_params = array(
'path' => $parts['path'],
'options' => array(
'query' => $parts['qparts'],
'fragment' => isset($parts['fragment']) ? $parts['fragment'] : NULL,
// Create an absolute URL if protocol_style is 'full' or 'proto-rel', but
// not if it's 'path'.
'absolute' => $cached_settings['current_settings']['protocol_style'] !== 'path',
// If we seem to have found a language for the path, pass it along to
// url(). Otherwise, ignore the 'language' parameter.
'language' => isset($parts['language_obj']) ? $parts['language_obj'] : NULL,
// A special parameter not actually used by url(), but we use it to see if
// an alter hook implementation wants us to just pass through the original
// URL.
'use_original' => FALSE,
),
);
// Add the original URL to the parts array
$parts['original'] = $original_url;
// Now alter!
// @see http://drupal.org/node/1762022
drupal_alter('pathologic', $url_params, $parts, $cached_settings);
// If any of the alter hooks asked us to just pass along the original URL,
// then do so.
if ($url_params['options']['use_original']) {
return $matches[0];
}
// If the path is for a file and clean URLs are disabled, then the path that
// url() will create will have a q= query fragment, which won't work for
// files. To avoid that, we use this trick to temporarily turn clean URLs on.
// This is horrible, but it seems to be the sanest way to do this.
// @see http://drupal.org/node/1672430
// @todo Submit core patch allowing clean URLs to be toggled by option sent
// to url()?
if (!empty($cached_settings['is_file'])) {
$cached_settings['orig_clean_url'] = !empty($GLOBALS['conf']['clean_url']);
if (!$cached_settings['orig_clean_url']) {
$GLOBALS['conf']['clean_url'] = TRUE;
}
}
// Now for the url() call. Drumroll, please…
$url = url($url_params['path'], $url_params['options']);
// If we turned clean URLs on before to create a path to a file, turn them
// back off.
if ($cached_settings['is_file'] && !$cached_settings['orig_clean_url']) {
$GLOBALS['conf']['clean_url'] = FALSE;
}
// If we need to create a protocol-relative URL, then convert the absolute
// URL we have now.
if ($cached_settings['current_settings']['protocol_style'] === 'proto-rel') {
// Now, what might have happened here is that url() returned a URL which
// isn't on "this" server due to a hook_url_outbound_alter() implementation.
// We don't want to convert the URL in that case. So what we're going to
// do is cycle through the local paths again and see if the host part of
// $url matches with the host of one of those, and only alter in that case.
$url_parts = @parse_url($url);
if (!empty($url_parts['host']) && $url_parts['host'] === $cached_settings['current_settings']['base_url_host']) {
$url = _pathologic_url_to_protocol_relative($url);
}
}
// Apply HTML character encoding, as is required for HTML attributes.
// @see http://drupal.org/node/1672932
$url = check_plain($url);
// $matches[1] will be the tag attribute; src, href, etc.
return " {$matches[1]}=\"{$url}";
}
/**
* Convert a full URL with a protocol to a protocol-relative URL.
*
* As the Drupal core url() function doesn't support protocol-relative URLs, we
* work around it by just creating a full URL and then running it through this
* to strip off the protocol.
*
* Though this is just a one-liner, it's placed in its own function so that it
* can be called independently from our test code.
*/
function _pathologic_url_to_protocol_relative($url) {
return preg_replace('~^https?://~', '//', $url);
}
/**
* Get the "real" settings_source value for a format.
*
* We can't trust the settings_source setting because, on existing formats, it
* will be set to 'global' (the default value) when actually we want it to use
* the pre-existing settings, which we now call the 'local' settings. So let's
* get the settings as they are in {filter} without pre-processing. AFAICT,
* there's no API function to do this.
*
* @param $format_name
* The machine name of the format.
* @return
* Either "global" or "local" as appropriate.
*/
function _pathologic_get_real_settings_source($format_name) {
$orig_settings = db_select('filter', 'f')
->fields('f', array('settings'))
->condition('format', $format_name)
->condition('name', 'pathologic')
->execute()
->fetchField();
if ($orig_settings) {
$orig_settings = unserialize($orig_settings);
return isset($orig_settings['settings_source']) ? $orig_settings['settings_source'] : 'local';
}
else {
return 'global';
}
}
<?php
/**
* @file
* Pathologic behavior testing.
*/
/**
* Tests that Pathologic ain't broke.
*
* We extend FilterUnitTestCase because it has some nice methods that we also
* want to be able to use.
*
* Note to self: The method to pass bits of text through are fail() or pass().
*/
class PathologicTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Pathologic path filtering',
'description' => 'Test Pathologic&rsquo;s path translation and conversion.',
'group' => 'Filter',
);
}
public function setUp() {
parent::setUp('pathologic');
}
public function testPathologic() {
// Start by testing our function to build protocol-relative URLs.
$this->assertEqual(
_pathologic_url_to_protocol_relative('http://example.com/foo/bar'),
'//example.com/foo/bar',
t('Protocol-relative URL creation with http:// URL')
);
$this->assertEqual(
_pathologic_url_to_protocol_relative('https://example.org/baz'),
'//example.org/baz',
t('Protocol-relative URL creation with https:// URL')
);
// Build some paths to check against.
$test_paths = array(
'foo' => array(
'path' => 'foo',
'opts' => array(),
),
'foo/bar' => array(
'path' => 'foo/bar',
'opts' => array(),
),
'foo/bar?baz' => array(
'path' => 'foo/bar',
'opts' => array('query' => array('baz' => NULL)),
),
'foo/bar?baz=qux' => array(
'path' => 'foo/bar',
'opts' => array('query' => array('baz' => 'qux')),
),
'foo/bar#baz' => array(
'path' => 'foo/bar',
'opts' => array('fragment' => 'baz'),
),
'foo/bar?baz=qux&amp;quux=quuux#quuuux' => array(
'path' => 'foo/bar',
'opts' => array(
'query' => array('baz' => 'qux', 'quux' => 'quuux'),
'fragment' => 'quuuux',
),
),
'foo%20bar?baz=qux%26quux' => array(
'path' => 'foo bar',
'opts' => array(
'query' => array('baz' => 'qux&quux'),
),
),
'/' => array(
'path' => '<front>',
'opts' => array(),
),
);
// Run tests with clean URLs both enabled and disabled.
foreach (array(TRUE, FALSE) as $clean_url) {
variable_set('clean_url', $clean_url);
// Run tests with absoulte filtering enabled and disabled.
foreach (array('full', 'proto-rel', 'path') as $protocol_style) {
$format_id = _pathologic_build_format(array('protocol_style' => $protocol_style, 'settings_source' => 'local'));
$paths = array();
foreach ($test_paths as $path => $args) {
$args['opts']['absolute'] = $protocol_style !== 'path';
$paths[$path] = _pathologic_content_url($args['path'], $args['opts']);
if ($protocol_style === 'proto-rel') {
$paths[$path] = _pathologic_url_to_protocol_relative($paths[$path]);
}
}
$t10ns = array(
'!clean' => $clean_url ? t('Yes') : t('No'),
'!ps' => $protocol_style,
);
$this->assertEqual(
check_markup('<a href="foo"><img src="foo/bar" /></a>', $format_id),
'<a href="' . $paths['foo'] . '"><img src="' . $paths['foo/bar'] . '" /></a>',
t('Simple paths. Clean URLs: !clean; protocol style: !ps.', $t10ns)
);
$this->assertEqual(
check_markup('<form action="foo/bar?baz"><IMG LONGDESC="foo/bar?baz=qux" /></a>', $format_id),
'<form action="' . $paths['foo/bar?baz'] . '"><IMG LONGDESC="' . $paths['foo/bar?baz=qux'] . '" /></a>',
t('Paths with query string. Clean URLs: !clean; protocol style: !ps.', $t10ns)
);
$this->assertEqual(
check_markup('<a href="foo/bar#baz">', $format_id),
'<a href="' . $paths['foo/bar#baz'] . '">',
t('Path with fragment. Clean URLs: !clean; protocol style: !ps.', $t10ns)
);
$this->assertEqual(
check_markup('<a href="#foo">', $format_id),
'<a href="#foo">',
t('Fragment-only href. Clean URLs: !clean; protocol style: !ps.', $t10ns)
);
// @see https://drupal.org/node/2208223
$this->assertEqual(
check_markup('<a href="#">', $format_id),
'<a href="#">',
t('Hash-only href. Clean URLs: !clean; protocol style: !ps.', $t10ns)
);
$this->assertEqual(
check_markup('<a href="foo/bar?baz=qux&amp;quux=quuux#quuuux">', $format_id),
'<a href="' . $paths['foo/bar?baz=qux&amp;quux=quuux#quuuux'] . '">',
t('Path with query string and fragment. Clean URLs: !clean; protocol style: !ps.', $t10ns)
);
$this->assertEqual(
check_markup('<a href="foo%20bar?baz=qux%26quux">', $format_id),
'<a href="' . $paths['foo%20bar?baz=qux%26quux'] . '">',
t('Path with URL encoded parts')
);
$this->assertEqual(
check_markup('<a href="/"></a>', $format_id),
'<a href="' . $paths['/'] . '"></a>',
t('Path with just slash. Clean URLs: !clean; protocol style: !ps', $t10ns)
);
}
}
global $base_path;
$this->assertEqual(
check_markup('<a href="' . $base_path . 'foo">bar</a>', $format_id),
'<a href="' . _pathologic_content_url('foo', array('absolute' => FALSE)) . '">bar</a>',
t('Paths beginning with $base_path (like WYSIWYG editors like to make)')
);
global $base_url;
$this->assertEqual(
check_markup('<a href="' . $base_url . '/foo">bar</a>', $format_id),
'<a href="' . _pathologic_content_url('foo', array('absolute' => FALSE)) . '">bar</a>',
t('Paths beginning with $base_url')
);
// @see http://drupal.org/node/1617944
$this->assertEqual(
check_markup('<a href="//example.com/foo">bar</a>', $format_id),
'<a href="//example.com/foo">bar</a>',
t('Off-site schemeless URLs (//example.com/foo) ignored')
);
// Test internal: and all base paths.
$format_id = _pathologic_build_format(array(
'protocol_style' => 'full',
'local_paths' => "http://example.com/qux\nhttp://example.org\n/bananas",
'settings_source' => 'local',
));
// @see https://drupal.org/node/2030789
$this->assertEqual(
check_markup('<a href="//example.org/foo">bar</a>', $format_id),
'<a href="' . _pathologic_content_url('foo', array('absolute' => TRUE)) . '">bar</a>',
t('On-site schemeless URLs processed')
);
$this->assertEqual(
check_markup('<a href="internal:foo">', $format_id),
'<a href="' . _pathologic_content_url('foo', array('absolute' => TRUE)) . '">',
t('Path Filter compatibility (internal:)')
);
$this->assertEqual(
check_markup('<a href="files:image.jpeg">', $format_id),
'<a href="' . _pathologic_content_url(file_create_url('public://image.jpeg'), array('absolute' => TRUE, 'is_file' => TRUE)) . '">',
t('Path Filter compatibility (files:)')
);
$this->assertEqual(
check_markup('<a href="http://example.com/qux/foo"><img src="http://example.org/bar.jpeg" longdesc="/bananas/baz" /></a>', $format_id),
'<a href="' . _pathologic_content_url('foo', array('absolute' => TRUE)) . '"><img src="' . _pathologic_content_url('bar.jpeg', array('absolute' => TRUE)) . '" longdesc="' . _pathologic_content_url('baz', array('absolute' => TRUE)) . '" /></a>',
t('"All base paths for this site" functionality')
);
$this->assertEqual(
check_markup('<a href="webcal:foo">bar</a>', $format_id),
'<a href="webcal:foo">bar</a>',
t('URLs with likely protocols are ignored')
);
// Test hook_pathologic_alter() implementation.
$this->assertEqual(
check_markup('<a href="foo?test=add_foo_qpart">', $format_id),
'<a href="' . _pathologic_content_url('foo', array('absolute' => TRUE, 'query' => array('test' => 'add_foo_qpart', 'foo' => 'bar'))) . '">',
t('hook_pathologic_alter(): Alter $url_params')
);
$this->assertEqual(
check_markup('<a href="bar?test=use_original">', $format_id),
'<a href="bar?test=use_original">',
t('hook_pathologic_alter(): Passthrough with use_original option')
);
// Test paths to existing files when clean URLs are disabled.
// @see http://drupal.org/node/1672430
variable_set('clean_url', FALSE);
$filtered_tag = check_markup('<img src="misc/druplicon.png" />', $format_id);
$this->assertTrue(
strpos($filtered_tag, 'q=') === FALSE,
t("Paths to files don't have ?q= when clean URLs are off")
);
$format_id = _pathologic_build_format(array(
'protocol_style' => 'rel',
'settings_source' => 'global',
));
variable_set('pathologic_protocol_style', 'proto-rel');
variable_set('pathologic_local_paths', 'http://example.com/');
$this->assertEqual(
check_markup('<img src="http://example.com/foo.jpeg" />', $format_id),
'<img src="' . _pathologic_url_to_protocol_relative(_pathologic_content_url('foo.jpeg', array('absolute' => TRUE))) . '" />',
t('Use global settings when so configured on the format')
);
}
}
/**
* Wrapper around url() which does HTML entity decoding and encoding.
*
* Since Pathologic works with paths in content, it needs to decode paths which
* have been HTML-encoded, and re-encode them when done. This is a wrapper
* around url() which does the same thing so that we can expect the results
* from it and from Pathologic to still match in our tests.
*
* @see url()
* @see http://drupal.org/node/1672932
* @see http://www.w3.org/TR/xhtml1/guidelines.html#C_12
*/
function _pathologic_content_url($path, $options) {
// If we should pretend this is a path to a file, temporarily enable clean
// URLs if necessary.
// @see _pathologic_replace()
// @see http://drupal.org/node/1672430
if (!empty($options['is_file'])) {
$options['orig_clean_url'] = !empty($GLOBALS['conf']['clean_url']);
if (!$options['orig_clean_url']) {
$GLOBALS['conf']['clean_url'] = TRUE;
}
}
$url = check_plain(url(htmlspecialchars_decode($path), $options));
if (!empty($options['is_file']) && !$options['orig_clean_url']) {
$GLOBALS['conf']['clean_url'] = FALSE;
}
return $url;
}
/**
* Build a text format with Pathologic configured a certain way.
*
* @param $settings
* An array of settings for the Pathologic instance on the format.
* @return
* A format machine name (consisting of random characters) for the format.
*/
function _pathologic_build_format($settings) {
$format_id = user_password();
$format = (object) array(
'format' => $format_id,
'name' => $format_id,
'filters' => array(
'pathologic' => array(
'status' => 1,
'settings' => $settings,
),
),
);
filter_format_save($format);
return $format_id;
}
/**
* Implements hook_pathologic_alter() for testing that functionality.
*/
function pathologic_pathologic_alter(&$url_params, $parts, $settings) {
if (is_array($parts['qparts']) && isset($parts['qparts']['test'])) {
if ($parts['qparts']['test'] === 'add_foo_qpart') {
// Add a "foo" query part.
if (empty($url_params['options']['query'])) {
$url_params['options']['query'] = array();
}
$url_params['options']['query']['foo'] = 'bar';
}
elseif ($parts['qparts']['test'] === 'use_original') {
$url_params['options']['use_original'] = TRUE;
}
}
}
/**
* Tests with entity translation and language path prefixes.
*/
if (class_exists('EntityTranslationTestCase')) {
class PathologicEntityTranslationTestCase extends EntityTranslationTestCase {
public static function getInfo() {
return array(
'name' => 'Pathologic & Entity Translation',
'description' => 'Tests with entity translation and language prefixes.',
'group' => 'Filter',
);
}
public function setUp() {
parent::setUp('pathologic_test');
$this->login($this->getAdminUser(array('administer filters')));
$this->enableCleanUrls();
$this->addLanguage('en');
$this->addLanguage('es');
$this->enableUrlLanguageDetection();
$this->configureContentType();
$this->enablePathologicForTextFormat('filtered_html', array(
'filters[pathologic][settings][local_settings][protocol_style]' => 'path',
));
$this->login($this->getTranslatorUser());
}
public function addLanguage($langcode) {
parent::addLanguage($langcode);
// Check to make sure that language has a prefix.
$this->drupalGet('admin/config/regional/language/edit/' . $langcode);
if ($this->xpath('//input[@type="text" and @name="prefix" and @value=""]')) {
$this->drupalPost(NULL, array('prefix' => $langcode), t('Save language'));
}
}
public function enablePathologicForTextFormat($format, $edit) {
$this->drupalGet('admin/config/content/formats/' . $format);
$edit['filters[pathologic][status]'] = 1;
$edit['filters[pathologic][weight]'] = 50;
$edit['filters[pathologic][settings][settings_source]'] = 'local';
$this->drupalPost(NULL, $edit, t('Save configuration'));
}
public function testEntityTranslation() {
// Create Basic page in English.
$node_title = $this->randomName();
$node_body = 'EN: ' . $this->randomName();
$node_one = $this->createPage($node_title, $node_body, 'en');
// Submit translation in Spanish.
$node_translation_title = $this->randomName();
$node_translation_body = 'ES: ' . $this->randomName();
$node_translation_one = $this->createTranslation($node_one, $node_translation_title, $node_translation_body, 'es', 'en');
$this->drupalGet('en/node/' . $node_one->nid);
$this->drupalGet('es/node/' . $node_one->nid);
// Create Basic page in English.
$node_title = $this->randomName();
$node_body = 'EN: ' . $this->randomName() . '<a href="node/' . $node_one->nid . '">FixMe</a>';
$node_two = $this->createPage($node_title, $node_body, 'en');
// Submit translation in Spanish.
$node_translation_title = $this->randomName();
$node_translation_body = 'ES: ' . $this->randomName() . '<a href="node/' . $node_one->nid . '">FixMe</a>';
$node_translation_two = $this->createTranslation($node_two, $node_translation_title, $node_translation_body, 'es', 'en');
// Check that the english translation points to the english version of node
// one.
$this->drupalGet('en/node/' . $node_two->nid);
$this->assertLinkByHref('en/node/' . $node_one->nid);
// Check that the spanish translation points to the spanish version of node
// one.
$this->drupalGet('es/node/' . $node_two->nid);
$this->assertLinkByHref('es/node/' . $node_one->nid);
}
}
}
name = Pathologic testing
description = Tests Pathologic module functionality. Do not enable.
core = 7.x
package = Testing
hidden = TRUE
dependencies[] = entity_translation
dependencies[] = pathologic
; Information added by Drupal.org packaging script on 2015-11-04
version = "7.x-3.0"
core = "7.x"
project = "pathologic"
datestamp = "1446668979"
<?php
/**
* @file
* Installation functionality for Pathologic testing module.
*/
<?php
/**
* @file
* Testing functionality for Pathologic module.
*/
...@@ -8,6 +8,7 @@ dependencies[] = ctools ...@@ -8,6 +8,7 @@ dependencies[] = ctools
dependencies[] = features dependencies[] = features
dependencies[] = path dependencies[] = path
dependencies[] = pathauto dependencies[] = pathauto
dependencies[] = pathologic
dependencies[] = redirect dependencies[] = redirect
dependencies[] = strongarm dependencies[] = strongarm
features[ctools][] = strongarm:strongarm:1 features[ctools][] = strongarm:strongarm:1
......
<?php
/**
* @file
* Install, uninstall, and updates for OCIO URL Aliases.
*/
/**
* Enable Pathologic module.
*/
function ocio_url_aliases_update_7001() {
module_enable(array('pathologic'));
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment