yf_make_alphabet classGenerate alphabet for search names.
| File | plugins/common/classes/common/yf_make_alphabet.class.php |
|---|---|
| Use | _class('make_alphabet', 'classes/common/') |
| Property | Default | Description |
|---|---|---|
| None declared in this class. | ||
public function go($url, &$chars, $get_var_name = 'id', $q_var = 'id')
Create Alphabet search criteria.Make alphabet html and query limit for selected chars.
$url : default URL for all link$chars : current selected first and second chars for limit$get_var_name : variable name for $_GET requert. Default: 'id'$q_var : name variable for queryReturns array($html, , $char2): $html - variable contain html text for show in browser, $char1 - first char $char2 - second char
public function go($url, &$chars, $get_var_name = 'id', $q_var = 'id')
{
$nUrl = $url . '&' . $get_var_name . '=';
$chars = strtolower(substr($chars . '11', 0, 2));
$sel_style = ' style="background-color:#ccc;"';
$html = '<a href="' . $nUrl . '1"' . (($chars[0] == '1') ? $sel_style : '') . '> # </a> ';
for ($i = 'a'; $i <= 'z'; $i = chr(ord($i) + 1)) {
$html .= '<a href="' . $nUrl . $i . '"' . (($chars[0] == $i) ? $sel_style : '') . '> ' . _ucfirst($i) . ' </a> ';
}
$html .= '<br /><span class="small_alphabet">';
$html .= '<a href="' . $nUrl . $chars[0] . '1"' . (($chars[1] == '1') ? $sel_style : '') . '>' . (($chars[0] == '1') ? '#' : $chars[0]) . '#</a> ';
for ($i = 'a'; $i <= 'z'; $i = chr(ord($i) + 1)) {
$html .= '<a href="' . $nUrl . $chars[0] . $i . '"' . (($i == $chars[1]) ? $sel_style : '') . '>' . (($chars[0] == '1') ? '#' : $chars[0]) . $i . '</a> ';
}
$html .= '</span>';
if ($chars[0] == '1' && $chars[1] == '1') {
$like = '';
} elseif ($chars[0] != '1' && $chars[1] == '1') {
$like = ' AND ' . $q_var . " LIKE '" . $chars[0] . "%' ";
} elseif ($chars[0] == '1' && $chars[1] != '1') {
$like = ' AND ' . $q_var . " REGEXP '^[a-zA-Z0-9\_\-\s]{1}" . $chars[1] . ".*' ";
} else {
$like = ' AND ' . $q_var . " LIKE '" . $chars[0] . $chars[1] . "%' ";
}
return [$html, $like];
}