protected function TFTController::get_folder_operation_links in Taxonomy File Tree 3.x
Same name and namespace in other branches
- 8 src/Controller/TFTController.php \Drupal\tft\Controller\TFTController::get_folder_operation_links()
Return an <ul> with links for the current folder.
Return value
array The render array.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
1 call to TFTController::get_folder_operation_links()
- TFTController::content_table in src/
Controller/ TFTController.php - Get the folder content in HTML table form.
File
- src/
Controller/ TFTController.php, line 367
Class
- TFTController
- Class TFTController.
Namespace
Drupal\tft\ControllerCode
protected function get_folder_operation_links($tid, $gid = NULL) {
$items = [];
// First link: got to parent.
$parent_tid = _tft_get_parent_tid($tid);
/** @var \Drupal\Core\TempStore\PrivateTempStore $tempstore */
$tempstore = \Drupal::service('tempstore.private')
->get('tft');
$root_tid = $tempstore
->get('root_tid');
$query = 'destination=' . $tempstore
->get('q');
$disabled = FALSE;
if ($parent_tid > -1 && $tid != $root_tid) {
if (!_tft_term_access($parent_tid)) {
$disabled = TRUE;
}
}
else {
$disabled = TRUE;
}
$class = $disabled ? 'disabled' : '';
$fragment = $disabled ? '#' : "#term/{$parent_tid}";
$items[] = [
'#wrapper_attributes' => [
'id' => 'tft-back',
'class' => 'folder-menu-ops-link first',
],
'#type' => 'link',
'#title' => Markup::create('<i class="fi fi-rr-undo"></i>' . $this
->t("Parent folder")),
'#url' => Url::fromUri("internal:{$fragment}"),
'#attributes' => [
'class' => $class,
'id' => 'tft-back-link',
],
];
// Third link: reorder child terms.
$uri = "/tft/terms/reorder/{$tid}?{$query}";
$group = Group::load($gid);
$user = $this
->currentUser();
if ($user
->hasPermission(TFT_REORDER_TERMS) || $group && $group
->hasPermission(TFT_REORDER_TERMS, $user)) {
$items[] = [
'#wrapper_attributes' => [
'id' => 'manage-folders',
'class' => 'folder-menu-ops-link',
],
'#type' => 'link',
'#title' => $this
->t("reorder elements"),
'#url' => Url::fromUri('internal:' . $uri),
];
}
return [
'#theme' => 'item_list',
'#list_type' => 'ul',
'#attributes' => [
'class' => 'tabs primary',
'id' => 'folder-menu-container',
],
'#items' => $items,
];
}