Révision 44d2e178
Ajouté par Assos Assos il y a presque 8 ans
drupal7/sites/all/modules/views/includes/handlers.inc | ||
---|---|---|
1547 | 1547 |
if (is_array($this->extra)) { |
1548 | 1548 |
$extras = array(); |
1549 | 1549 |
foreach ($this->extra as $info) { |
1550 |
$extra = ''; |
|
1551 | 1550 |
// Figure out the table name. Remember, only use aliases provided |
1552 | 1551 |
// if at all possible. |
1553 | 1552 |
$join_table = ''; |
... | ... | |
1565 | 1564 |
} |
1566 | 1565 |
} |
1567 | 1566 |
|
1568 |
// Convert a single-valued array of values to the single-value case, |
|
1569 |
// and transform from IN() notation to = notation |
|
1570 |
if (is_array($info['value']) && count($info['value']) == 1) { |
|
1571 |
if (empty($info['operator'])) { |
|
1572 |
$operator = '='; |
|
1567 |
// If left_field is set use it for a field-to-field condition. |
|
1568 |
if (!empty($info['left_field'])) { |
|
1569 |
$operator = !empty($info['operator']) ? $info['operator'] : '='; |
|
1570 |
$left_table = (isset($info['left_table'])) ? $info['left_table'] : $left['alias']; |
|
1571 |
$extras[] = "$join_table$info[field] $operator $left_table.$info[left_field]"; |
|
1572 |
} |
|
1573 |
// Else if formula is set, us it for a flexible on clause. |
|
1574 |
elseif (!empty($info['formula'])) { |
|
1575 |
// If a field is given, we build a "$field $op $formula". |
|
1576 |
// Without it would only be "$formula". |
|
1577 |
$extra = ''; |
|
1578 |
if (isset($info['field'])) { |
|
1579 |
// With a single value, the '=' operator is implicit. |
|
1580 |
$operator = !empty($info['operator']) ? $info['operator'] : '='; |
|
1581 |
$extra .= "$join_table$info[field] $operator "; |
|
1573 | 1582 |
} |
1574 |
else { |
|
1575 |
$operator = $info['operator'] == 'NOT IN' ? '!=' : '='; |
|
1583 |
$extra .= $info['formula']; |
|
1584 |
// Add placeholder arguments. |
|
1585 |
if (isset($info['formula_arguments']) && is_array($info['formula_arguments'])) { |
|
1586 |
$arguments = array_merge($arguments, $info['formula_arguments']); |
|
1576 | 1587 |
} |
1577 |
$info['value'] = array_shift($info['value']);
|
|
1588 |
$extras[] = $extra;
|
|
1578 | 1589 |
} |
1590 |
// Otherwise - and if we have a value - use it for a field-to-value condition. |
|
1591 |
elseif (!empty($info['value'])) { |
|
1592 |
// Convert a single-valued array of values to the single-value case, |
|
1593 |
// and transform from IN() notation to = notation |
|
1594 |
if (is_array($info['value']) && count($info['value']) == 1) { |
|
1595 |
if (empty($info['operator'])) { |
|
1596 |
$operator = '='; |
|
1597 |
} |
|
1598 |
else { |
|
1599 |
$operator = $info['operator'] == 'NOT IN' ? '!=' : '='; |
|
1600 |
} |
|
1601 |
$info['value'] = array_shift($info['value']); |
|
1602 |
} |
|
1579 | 1603 |
|
1580 |
if (is_array($info['value'])) { |
|
1581 |
// With an array of values, we need multiple placeholders and the |
|
1582 |
// 'IN' operator is implicit. |
|
1583 |
foreach ($info['value'] as $value) { |
|
1584 |
$placeholder_i = $view_query->placeholder('views_join_condition_'); |
|
1585 |
$arguments[$placeholder_i] = $value; |
|
1604 |
if (is_array($info['value'])) { |
|
1605 |
// With an array of values, we need multiple placeholders and the |
|
1606 |
// 'IN' operator is implicit. |
|
1607 |
foreach ($info['value'] as $value) { |
|
1608 |
$placeholder_i = ':views_join_condition_' . $select_query->nextPlaceholder(); |
|
1609 |
$arguments[$placeholder_i] = $value; |
|
1610 |
} |
|
1611 |
|
|
1612 |
$operator = !empty($info['operator']) ? $info['operator'] : 'IN'; |
|
1613 |
$placeholder = '( ' . implode(', ', array_keys($arguments)) . ' )'; |
|
1614 |
} |
|
1615 |
else { |
|
1616 |
// With a single value, the '=' operator is implicit. |
|
1617 |
$operator = !empty($info['operator']) ? $info['operator'] : '='; |
|
1618 |
$placeholder = ':views_join_condition_' . $select_query->nextPlaceholder(); |
|
1619 |
$arguments[$placeholder] = $info['value']; |
|
1586 | 1620 |
} |
1587 | 1621 |
|
1588 |
$operator = !empty($info['operator']) ? $info['operator'] : 'IN'; |
|
1589 |
$placeholder = '( ' . implode(', ', array_keys($arguments)) . ' )'; |
|
1622 |
$extras[] = "$join_table$info[field] $operator $placeholder"; |
|
1590 | 1623 |
} |
1591 |
else { |
|
1592 |
// With a single value, the '=' operator is implicit. |
|
1593 |
$operator = !empty($info['operator']) ? $info['operator'] : '='; |
|
1594 |
$placeholder = $view_query->placeholder('views_join_condition_'); |
|
1595 |
$arguments[$placeholder] = $info['value']; |
|
1596 |
} |
|
1597 |
$extras[] = "$join_table$info[field] $operator $placeholder"; |
|
1598 | 1624 |
} |
1599 | 1625 |
|
1600 | 1626 |
if ($extras) { |
... | ... | |
1660 | 1686 |
if (is_array($this->extra)) { |
1661 | 1687 |
$extras = array(); |
1662 | 1688 |
foreach ($this->extra as $info) { |
1663 |
$extra = ''; |
|
1664 | 1689 |
// Figure out the table name. Remember, only use aliases provided |
1665 | 1690 |
// if at all possible. |
1666 | 1691 |
$join_table = ''; |
Formats disponibles : Unified diff
Weekly update of contrib modules