Revize 2237
Přidáno uživatelem Ondřej Fibich před asi 11 roky(ů)
freenetis/branches/1.1/application/controllers/search.php | ||
---|---|---|
{
|
||
// trim and remove unrequired cars from keyword
|
||
$keyword = trim($keyword);
|
||
$mkeyword = preg_replace("/[\[\]!\"#$%&'()*+,\/:;<=>?@\^`{|}~]/", ' ', $keyword);
|
||
$mkeyword = preg_replace("/[\[\]!\"#$%&'()*+,\/:;<=>?@\^`{|}~-]/", ' ', $keyword);
|
||
|
||
// separate keywords
|
||
$keywords = explode(' ', preg_replace("/\s+/", ' ', $mkeyword));
|
||
|
||
// variations - if keyword contains many words (>= 3) then only create
|
||
// variations - if keyword contains many words (> 3) then only create
|
||
// variations that contains all words of keyword but only sorted in many
|
||
// ways. If keyword do not contain many words then make all variations.
|
||
// If keyword contains more then 5 words then disable variations at all.
|
||
$variation_keys = array();
|
||
|
||
if (count($keywords) < 3) // all
|
||
if (count($keywords) <= 3) // all
|
||
{
|
||
for ($i = count($keywords); $i > 0; $i--)
|
||
{
|
freenetis/branches/1.1/application/models/search.php | ||
---|---|---|
LEFT JOIN membership_interrupts mi ON m.id = mi.member_id
|
||
LEFT JOIN members_fees mf ON mi.members_fee_id = mf.id AND (mf.activation_date < CURDATE() AND mf.deactivation_date > CURDATE())
|
||
WHERE m.name LIKE ? COLLATE utf8_general_ci
|
||
|
||
ORDER BY ABS(LENGTH(value) - " . mb_strlen($keyword) . ")
|
||
".$sql_limit, array
|
||
(
|
||
" (" . __('I') . ")",
|
||
... | ... | |
LEFT JOIN membership_interrupts mi ON m.id = mi.member_id
|
||
LEFT JOIN members_fees mf ON mi.members_fee_id = mf.id AND (mf.activation_date < CURDATE() AND mf.deactivation_date > CURDATE())
|
||
WHERE m.id LIKE ? COLLATE utf8_general_ci
|
||
|
||
ORDER BY ABS(LENGTH(value) - " . mb_strlen($keyword) . ")
|
||
".$sql_limit, array
|
||
(
|
||
" (" . __('I') . ")",
|
||
... | ... | |
LEFT JOIN membership_interrupts mi ON m.id = mi.member_id
|
||
LEFT JOIN members_fees mf ON mi.members_fee_id = mf.id AND (mf.activation_date < CURDATE() AND mf.deactivation_date > CURDATE())
|
||
WHERE vs.variable_symbol LIKE ? COLLATE utf8_general_ci
|
||
|
||
ORDER BY ABS(LENGTH(value) - " . mb_strlen($keyword) . ")
|
||
".$sql_limit, array
|
||
(
|
||
__('Variable symbol') . ": ",
|
||
... | ... | |
LEFT JOIN membership_interrupts mi ON m.id = mi.member_id
|
||
LEFT JOIN members_fees mf ON mi.members_fee_id = mf.id AND (mf.activation_date < CURDATE() AND mf.deactivation_date > CURDATE())
|
||
WHERE m.comment LIKE ? COLLATE utf8_general_ci
|
||
|
||
ORDER BY ABS(LENGTH(value) - " . mb_strlen($keyword) . ")
|
||
".$sql_limit, array
|
||
(
|
||
__('Comment') . ": ",
|
||
... | ... | |
LEFT JOIN membership_interrupts mi ON m.id = mi.member_id
|
||
LEFT JOIN members_fees mf ON mi.members_fee_id = mf.id AND (mf.activation_date < CURDATE() AND mf.deactivation_date > CURDATE())
|
||
WHERE CONCAT(tw.town, IF(tw.quarter IS NOT NULL, CONCAT(' ', tw.quarter), '')) LIKE ? COLLATE utf8_general_ci
|
||
|
||
ORDER BY ABS(LENGTH(value) - " . mb_strlen($keyword) . ")
|
||
".$sql_limit, " (" . __('I') . ")", "%$keyword%");
|
||
}
|
||
|
||
... | ... | |
LEFT JOIN membership_interrupts mi ON m.id = mi.member_id
|
||
LEFT JOIN members_fees mf ON mi.members_fee_id = mf.id AND (mf.activation_date < CURDATE() AND mf.deactivation_date > CURDATE())
|
||
WHERE CONCAT(s.street, ' ',ap.street_number) LIKE ? COLLATE utf8_general_ci
|
||
|
||
ORDER BY ABS(LENGTH(value) - " . mb_strlen($keyword) . ")
|
||
".$sql_limit, " (" . __('I') . ")", "%$keyword%");
|
||
}
|
||
|
||
... | ... | |
LEFT JOIN membership_interrupts mi ON m.id = mi.member_id
|
||
LEFT JOIN members_fees mf ON mi.members_fee_id = mf.id AND (mf.activation_date < CURDATE() AND mf.deactivation_date > CURDATE())
|
||
WHERE ap.street_number LIKE ? COLLATE utf8_general_ci
|
||
|
||
ORDER BY ABS(LENGTH(value) - " . mb_strlen($keyword) . ")
|
||
".$sql_limit, " (" . __('I') . ")", "$keyword%");
|
||
}
|
||
|
||
... | ... | |
LEFT JOIN membership_interrupts mi ON m.id = mi.member_id
|
||
LEFT JOIN members_fees mf ON mi.members_fee_id = mf.id AND (mf.activation_date < CURDATE() AND mf.deactivation_date > CURDATE())
|
||
WHERE m.organization_identifier LIKE ? COLLATE utf8_general_ci
|
||
|
||
ORDER BY ABS(LENGTH(value) - " . mb_strlen($keyword) . ")
|
||
".$sql_limit, array
|
||
(
|
||
" (" . __('I') . ")",
|
||
... | ... | |
LEFT JOIN membership_interrupts mi ON m.id = mi.member_id
|
||
LEFT JOIN members_fees mf ON mi.members_fee_id = mf.id AND (mf.activation_date < CURDATE() AND mf.deactivation_date > CURDATE())
|
||
WHERE m.vat_organization_identifier LIKE ? COLLATE utf8_general_ci
|
||
|
||
ORDER BY ABS(LENGTH(value) - " . mb_strlen($keyword) . ")
|
||
".$sql_limit, array
|
||
(
|
||
" (" . __('I') . ")",
|
||
... | ... | |
CONCAT(?, u.name, ' ',u.surname) AS return_value, 'users/show/' AS link
|
||
FROM users u
|
||
WHERE CONCAT(u.name,' ',u.surname) LIKE ? COLLATE utf8_general_ci
|
||
|
||
ORDER BY ABS(LENGTH(value) - " . mb_strlen($keyword) . ")
|
||
".$sql_limit, array
|
||
(
|
||
__('Username') . ": ",
|
||
... | ... | |
CONCAT(?, u.name, ' ',u.surname) AS return_value,
|
||
'users/show/' AS link
|
||
FROM users u WHERE u.login LIKE ? COLLATE utf8_general_ci
|
||
|
||
ORDER BY ABS(LENGTH(value) - " . mb_strlen($keyword) . ")
|
||
".$sql_limit, array
|
||
(
|
||
__('Username') . ": ",
|
||
... | ... | |
'towns/show/' AS link
|
||
FROM towns t
|
||
WHERE CONCAT(t.town, IF(t.quarter IS NOT NULL, CONCAT(' ', t.quarter), '')) LIKE ? COLLATE utf8_general_ci
|
||
|
||
ORDER BY ABS(LENGTH(value) - " . mb_strlen($keyword) . ")
|
||
".$sql_limit, array
|
||
(
|
||
__('ZIP code') . ": ",
|
||
... | ... | |
FROM devices d
|
||
JOIN users u ON d.user_id = u.id
|
||
WHERE d.name LIKE ? COLLATE utf8_general_ci
|
||
|
||
ORDER BY ABS(LENGTH(value) - " . mb_strlen($keyword) . ")
|
||
".$sql_limit, array
|
||
(
|
||
__('User') . ": ",
|
||
... | ... | |
FROM devices d
|
||
JOIN ifaces ic ON ic.device_id = d.id
|
||
WHERE ic.mac LIKE ? COLLATE utf8_general_ci
|
||
|
||
ORDER BY ABS(LENGTH(value) - " . mb_strlen($keyword) . ")
|
||
".$sql_limit, array
|
||
(
|
||
__('MAC address') . ": ",
|
||
... | ... | |
JOIN ifaces ic ON ic.device_id = d.id
|
||
LEFT JOIN ip_addresses ip ON ip.iface_id = ic.id
|
||
WHERE ip.ip_address LIKE ? COLLATE utf8_general_ci
|
||
|
||
ORDER BY ABS(LENGTH(value) - " . mb_strlen($keyword) . ")
|
||
".$sql_limit, array
|
||
(
|
||
__('IP address') . ": ",
|
||
... | ... | |
JOIN links s ON i.link_id = s.id
|
||
WHERE i.wireless_mode = ? AND s.medium = ? AND
|
||
s.wireless_ssid LIKE ? COLLATE utf8_general_ci
|
||
|
||
ORDER BY ABS(LENGTH(value) - " . mb_strlen($keyword) . ")
|
||
".$sql_limit, array
|
||
(
|
||
__('SSID') . ": ",
|
||
... | ... | |
'subnets/show/' AS link
|
||
FROM subnets s
|
||
WHERE s.name LIKE ? COLLATE utf8_general_ci
|
||
|
||
ORDER BY ABS(LENGTH(value) - " . mb_strlen($keyword) . ")
|
||
".$sql_limit, array
|
||
(
|
||
__('Address') . ": ",
|
||
... | ... | |
'subnets/show/' AS link
|
||
FROM subnets s
|
||
WHERE CONCAT(s.network_address,'/',32-log2((~inet_aton(s.netmask) & 0xffffffff) + 1)) LIKE ? COLLATE utf8_general_ci
|
||
|
||
ORDER BY ABS(LENGTH(value) - " . mb_strlen($keyword) . ")
|
||
".$sql_limit, array
|
||
(
|
||
__('Address') . ": ",
|
||
... | ... | |
'links/show/' AS link
|
||
FROM links s
|
||
WHERE s.name LIKE ? COLLATE utf8_general_ci
|
||
|
||
ORDER BY ABS(LENGTH(value) - " . mb_strlen($keyword) . ")
|
||
".$sql_limit, array
|
||
(
|
||
__('Link') . ' ',
|
Také k dispozici: Unified diff
Novinky:
- refs #811: Drobne upravy v prepracovani fulltextu