views_handler_field_alpha_pagination_group.inc in Views Alpha Pagination 7.2
File
src/views_handler_field_alpha_pagination_group.inc
View source
<?php
class views_handler_field_alpha_pagination_group extends \views_handler_field {
private $alphaPagination;
public function construct() {
$this->alphaPagination = new AlphaPagination($this);
parent::construct();
}
function option_definition() {
$options = parent::option_definition();
$options['label'] = '';
$options['element_label_colon'] = FALSE;
$options['exclude']['default'] = TRUE;
return $options;
}
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
foreach (element_children($form) as $child) {
if ($child === 'more' || $child === 'ui_name') {
continue;
}
$form[$child]['#access'] = FALSE;
}
}
function query() {
}
function render($values) {
$areas = $this->alphaPagination
->getAreaHandlers();
if (!$areas) {
return '';
}
$alpha_pagination = new AlphaPagination($areas[0]);
$path = $alpha_pagination
->getOption('paginate_link_path');
$field_name = $alpha_pagination
->getOption('paginate_view_field');
if (!isset($this->view->field[$field_name])) {
return '';
}
$field = $this->view->field[$field_name];
if (empty($field->last_render_text)) {
$field
->render($values);
}
$value = $alpha_pagination
->getValue(!empty($field->last_render_text) ? drupal_ucfirst(substr(strip_tags($field->last_render_text), 0, 1)) : '');
$label = $alpha_pagination
->getLabel($value);
if ($value && $path && $path[0] === '#') {
$name = token_replace(substr($path, 1), $alpha_pagination
->getTokens($value));
$label = [
'#type' => 'html_tag',
'#theme' => 'html_tag__alpha_pagination__anchor',
'#tag' => 'a',
'#value' => '',
'#attributes' => [
'name' => $name,
],
'#suffix' => $label,
];
}
return $label;
}
public function ui_name($short = FALSE) {
return $this->alphaPagination
->ui_name();
}
public function validate() {
return $this->alphaPagination
->validate();
}
}