public static function drupalchatController::_drupalchat_chat in DrupalChat 8
1 call to drupalchatController::_drupalchat_chat()
File
- src/
Controller/ drupalchatController.php, line 1070 - Contains Drupal\drupalchat\Controller\drupalchatController
Class
Namespace
Drupal\drupalchat\ControllerCode
public static function _drupalchat_chat() {
$user = \Drupal::currentUser();
$chat = array();
$chat['name'] = 'chat';
$chat['header'] = t('Chat')
->__toString();
$buddylist = drupalchatController::_drupalchat_buddylist($user
->id());
$buddylist_online = drupalchatController::_drupalchat_buddylist_online($buddylist);
//JON COMMENTS
$chat['contents'] = '<div class="chat_options">' . '<a class="chat_loading" href="#"></a>' . '</div>';
$items = array();
foreach ($buddylist_online as $key => $value) {
if ($key != 'total') {
$items[] = array(
'#markup' => '<a class="' . $key . '" href="#">' . $value['name'] . '</a>',
'#wrapper_attributes' => array(
'class' => 'status-' . $value['status'],
),
);
}
}
if ($items) {
$item_list = array(
'#theme' => 'item_list',
'#items' => $items,
'#list_type' => 'ul',
);
$chat['footer'] = $item_list;
}
else {
$no_user_item = array();
$no_user_item[] = array(
'#markup' => \Drupal::l(t('No users online')
->__toString(), Url::fromRoute('drupalchat.user')),
'#wrapper_attributes' => array(
'class' => 'link',
),
);
$render_array = array(
'#theme' => 'item_list',
'#items' => $no_user_item,
'#list_type' => 'ul',
);
$chat['footer'] = $render_array;
}
$chat['text'] = t('Chat')
->__toString() . ' (<span class="online-count">' . count($items) . '</span>)';
//$chat['text'] = t('Chat') . ' (<span class="online-count">' . count($items) . '</span>)';
$theme = \Drupal::config('drupalchat.settings')
->get('drupalchat_theme') ?: 'light';
$image = [
'#theme' => 'image',
'#uri' => drupal_get_path('module', 'drupalchat') . '/css/themes/' . $theme . '/images/loading.gif',
'#width' => NULL,
'#height' => NULL,
'#alt' => t('chat')
->__toString(),
'#attributes' => array(
'class' => 'icon',
),
];
$chat['icon'] = $image;
$drupalchat_subpanel = array(
'#theme' => 'drupalchat_subpanel',
'#subpanel' => $chat,
);
return $drupalchat_subpanel;
}