alphabetQuery();
}
if (!$result) {
return NULL;
}
$dynamicAlphabets = array();
while ($result->fetch()) {
$dynamicAlphabets[] = $result->sort_name;
}
return $dynamicAlphabets;
}
/**
* Create the links.
*
* @param array $query
* The form values for search.
* @param string $sortByCharacter
* The character that we are potentially sorting on.
*
* @param $isDAO
*
* @return array
* with links
*/
public static function createLinks(&$query, $sortByCharacter, $isDAO) {
$AToZBar = self::getStaticCharacters();
$dynamicAlphabets = self::getDynamicCharacters($query, $isDAO);
if (!$dynamicAlphabets) {
return NULL;
}
$AToZBar = array_merge($AToZBar, $dynamicAlphabets);
sort($AToZBar, SORT_STRING);
$AToZBar = array_unique($AToZBar);
// get the current path
$path = CRM_Utils_System::currentPath();
$qfKey = NULL;
if (isset($query->_formValues)) {
$qfKey = CRM_Utils_Array::value('qfKey', $query->_formValues);
}
if (empty($qfKey)) {
// CRM-20943 Can only pass variables by reference and also cannot use $this so using $empty setting to NULL which is default.
$emptyVariable = NULL;
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $emptyVariable, FALSE, NULL, $_REQUEST);
}
$aToZBar = array();
foreach ($AToZBar as $key => $link) {
if ($link === NULL) {
continue;
}
$element = array();
if (in_array($link, $dynamicAlphabets)) {
$klass = '';
if ($link == $sortByCharacter) {
$element['class'] = "active";
$klass = 'class="active"';
}
$url = CRM_Utils_System::url($path, "force=1&qfKey=$qfKey&sortByCharacter=");
// we do it this way since we want the url to be encoded but not the link character
// since that seems to mess up drupal utf-8 encoding etc
$url .= urlencode($link);
$element['item'] = sprintf('%s',
$url,
$klass,
$link
);
}
else {
$element['item'] = $link;
}
$aToZBar[] = $element;
}
$url = sprintf(
'%s',
CRM_Utils_System::url(
$path,
"force=1&qfKey=$qfKey&sortByCharacter=all"
),
ts('All')
);
$aToZBar[] = array('item' => $url);
return $aToZBar;
}
}