updated contrib modules
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
// @codingStandardsIgnoreFile
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains functions handling views integration.
|
||||
|
@@ -7,20 +7,26 @@
|
||||
|
||||
/**
|
||||
* Argument handler to filter results by target.
|
||||
*
|
||||
* @codingStandardsIgnoreStart
|
||||
*/
|
||||
class link_views_handler_argument_target extends views_handler_argument {
|
||||
|
||||
/**
|
||||
* Provide defaults for the argument when a new one is created.
|
||||
*/
|
||||
function options(&$options) {
|
||||
parent::options($options);
|
||||
}
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
return $options;
|
||||
}
|
||||
/**
|
||||
* Provide a default options form for the argument.
|
||||
*
|
||||
* @codingStandardsIgnoreStart
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
public function options_form(&$form, &$form_state) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
$defaults = $this->default_actions();
|
||||
|
||||
$form['title'] = array(
|
||||
@@ -52,7 +58,7 @@ class link_views_handler_argument_target extends views_handler_argument {
|
||||
|
||||
$form['wildcard'] = array(
|
||||
'#prefix' => '<div class="views-right-50">',
|
||||
// prefix and no suffix means these two items will be grouped together.
|
||||
// Prefix and no suffix means these two items will be grouped together.
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Wildcard'),
|
||||
'#size' => 20,
|
||||
@@ -93,7 +99,7 @@ class link_views_handler_argument_target extends views_handler_argument {
|
||||
'#default_value' => $this->options['validate_type'],
|
||||
);
|
||||
|
||||
$validate_types = array('none' => t('<Basic validation>'));
|
||||
$validate_types = array('none' => t('- Basic validation -'));
|
||||
$plugins = views_fetch_plugin_data('argument validator');
|
||||
foreach ($plugins as $id => $info) {
|
||||
$valid = TRUE;
|
||||
@@ -125,8 +131,8 @@ class link_views_handler_argument_target extends views_handler_argument {
|
||||
|
||||
asort($validate_types);
|
||||
$form['validate_type']['#options'] = $validate_types;
|
||||
// Show this gadget if *anything* but 'none' is selected
|
||||
|
||||
// Show this gadget if *anything* but 'none' is selected.
|
||||
$form['validate_fail'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Action to take if argument does not validate'),
|
||||
@@ -140,10 +146,11 @@ class link_views_handler_argument_target extends views_handler_argument {
|
||||
*
|
||||
* The argument sent may be found at $this->argument.
|
||||
*/
|
||||
function query() {
|
||||
public function query($group_by = FALSE) {
|
||||
$this->ensure_my_table();
|
||||
// Because attributes are stored serialized, our only option is to also
|
||||
// serialize the data we're searching for and use LIKE to find similar data.
|
||||
$this->query->add_where(0, $this->table_alias .'.'. $this->real_field ." LIKE '%%%s%'", serialize(array('target' => $this->argument)));
|
||||
$this->query->add_where(0, $this->table_alias . ' . ' . $this->real_field . " LIKE '%%%s%'", serialize(array('target' => $this->argument)));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -7,22 +7,30 @@
|
||||
|
||||
/**
|
||||
* Filter handler for limiting a view to URLs of a certain protocol.
|
||||
*
|
||||
* @codingStandardsIgnoreStart
|
||||
*/
|
||||
class link_views_handler_filter_protocol extends views_handler_filter_string {
|
||||
|
||||
/**
|
||||
* Set defaults for the filter options.
|
||||
*
|
||||
* @codingStandardsIgnoreEnd
|
||||
*/
|
||||
function options(&$options) {
|
||||
parent::options($options);
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['operator'] = 'OR';
|
||||
$options['value'] = 'http';
|
||||
$options['case'] = 0;
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the operators supported for protocols.
|
||||
*/
|
||||
function operators() {
|
||||
public function operators() {
|
||||
$operators = array(
|
||||
'OR' => array(
|
||||
'title' => t('Is one of'),
|
||||
@@ -35,7 +43,13 @@ class link_views_handler_filter_protocol extends views_handler_filter_string {
|
||||
return $operators;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
/**
|
||||
* Options form.
|
||||
*
|
||||
* @codingStandardsIgnoreStart
|
||||
*/
|
||||
public function options_form(&$form, &$form_state) {
|
||||
//@codingStandardsIgnoreEnd
|
||||
parent::options_form($form, $form_state);
|
||||
$form['case'] = array(
|
||||
'#type' => 'value',
|
||||
@@ -45,8 +59,11 @@ class link_views_handler_filter_protocol extends views_handler_filter_string {
|
||||
|
||||
/**
|
||||
* Provide a select list to choose the desired protocols.
|
||||
*
|
||||
* @codingStandardsIgnoreStart
|
||||
*/
|
||||
function value_form(&$form, &$form_state) {
|
||||
public function value_form(&$form, &$form_state) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
// We have to make some choices when creating this as an exposed
|
||||
// filter form. For example, if the operator is locked and thus
|
||||
// not rendered, we can't render dependencies; instead we only
|
||||
@@ -61,7 +78,19 @@ class link_views_handler_filter_protocol extends views_handler_filter_string {
|
||||
'#type' => 'select',
|
||||
'#title' => t('Protocol'),
|
||||
'#default_value' => $this->value,
|
||||
'#options' => drupal_map_assoc(variable_get('filter_allowed_protocols', array('http', 'https', 'ftp', 'news', 'nntp', 'telnet', 'mailto', 'irc', 'ssh', 'sftp', 'webcal'))),
|
||||
'#options' => drupal_map_assoc(variable_get('filter_allowed_protocols', array(
|
||||
'http',
|
||||
'https',
|
||||
'ftp',
|
||||
'news',
|
||||
'nntp',
|
||||
'telnet',
|
||||
'mailto',
|
||||
'irc',
|
||||
'ssh',
|
||||
'sftp',
|
||||
'webcal',
|
||||
))),
|
||||
'#multiple' => 1,
|
||||
'#size' => 4,
|
||||
'#description' => t('The protocols displayed here are those globally available. You may add more protocols by modifying the <em>filter_allowed_protocols</em> variable in your installation.'),
|
||||
@@ -71,8 +100,11 @@ class link_views_handler_filter_protocol extends views_handler_filter_string {
|
||||
|
||||
/**
|
||||
* Filter down the query to include only the selected protocols.
|
||||
*
|
||||
* @codingStandardsIgnoreStart
|
||||
*/
|
||||
function op_protocol($field, $upper) {
|
||||
public function op_protocol($field, $upper) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
$db_type = db_driver();
|
||||
|
||||
$protocols = $this->value;
|
||||
@@ -80,27 +112,34 @@ class link_views_handler_filter_protocol extends views_handler_filter_string {
|
||||
$where_conditions = array();
|
||||
foreach ($protocols as $protocol) {
|
||||
// Simple case, the URL begins with the specified protocol.
|
||||
$condition = $field .' LIKE \''. $protocol .'%\'';
|
||||
$condition = $field . ' LIKE \'' . $protocol . '%\'';
|
||||
|
||||
// More complex case, no protocol specified but is automatically cleaned up
|
||||
// by link_cleanup_url(). RegEx is required for this search operation.
|
||||
// More complex case, no protocol specified but is automatically cleaned
|
||||
// up by link_cleanup_url(). RegEx is required for this search operation.
|
||||
if ($protocol == 'http') {
|
||||
$link_domains = _link_domains();
|
||||
if ($db_type == 'pgsql') {
|
||||
// PostGreSQL code has NOT been tested. Please report any problems to the link issue queue.
|
||||
// pgSQL requires all slashes to be double escaped in regular expressions.
|
||||
// PostGreSQL code has NOT been tested. Please report any problems to
|
||||
// the link issue queue.
|
||||
// pgSQL requires all slashes to be double escaped in regular
|
||||
// expressions.
|
||||
// @codingStandardsIgnoreLine
|
||||
// See http://www.postgresql.org/docs/8.1/static/functions-matching.html#FUNCTIONS-POSIX-REGEXP
|
||||
$condition .= ' OR '. $field .' ~* \''.'^(([a-z0-9]([a-z0-9\\-_]*\\.)+)('. LINK_DOMAINS .'|[a-z][a-z]))'.'\'';
|
||||
$condition .= ' OR ' . $field . ' ~* \'' . '^(([a-z0-9]([a-z0-9\\-_]*\\.)+)(' . $link_domains . '|[a-z][a-z]))' . '\'';
|
||||
}
|
||||
else {
|
||||
// mySQL requires backslashes to be double (triple?) escaped within character classes.
|
||||
// mySQL requires backslashes to be double (triple?) escaped within
|
||||
// character classes.
|
||||
// @codingStandardsIgnoreLine
|
||||
// See http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html#operator_regexp
|
||||
$condition .= ' OR '. $field .' REGEXP \''.'^(([a-z0-9]([a-z0-9\\\-_]*\.)+)('. LINK_DOMAINS .'|[a-z][a-z]))'.'\'';
|
||||
$condition .= ' OR ' . $field . ' REGEXP \'' . '^(([a-z0-9]([a-z0-9\\\-_]*\.)+)(' . $link_domains . '|[a-z][a-z]))' . '\'';
|
||||
}
|
||||
}
|
||||
|
||||
$where_conditions[] = $condition;
|
||||
}
|
||||
|
||||
$this->query->add_where($this->options['group'], implode(' '. $this->operator .' ', $where_conditions));
|
||||
$this->query->add_where($this->options['group'], implode(' ' . $this->operator . ' ', $where_conditions));
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user