function tft_l in Taxonomy File Tree 7.2
Same name and namespace in other branches
- 7 tft.module \tft_l()
Format a folder or file link.
Parameters
string $title: The link title
int $id: Either the taxonomy term tid or the node nid
string $mime: The mime type of the file (for a folder, use 'folder')
Return value
string HTML string with the formatted link
Related topics
1 call to tft_l()
- tft_get_content in ./
tft.module - Get the folder content and return it in an array form for the theme_table call.
File
- ./
tft.module, line 552 - Hook implementations and module logic for TFT.
Code
function tft_l($title, $id, $mime) {
if ($mime == 'folder') {
return '<a href="#tft/' . $id . '" class="folder-folder-link" id="tid-' . $id . '">' . $title . '</a>';
}
else {
$class = 'file';
$settings = tft_get_file_setting();
switch ($mime) {
case 'image/png':
case 'image/jpeg':
case 'image/gif':
if (module_exists('image')) {
$node = node_load($id);
$icon = image_style_url('tft_thumb', $node->{$settings['field']}[LANGUAGE_NONE][0]['uri']);
$class .= ' thumbnail';
$href = file_create_url($node->{$settings['field']}[LANGUAGE_NONE][0]['uri']);
if (module_exists('lightbox2')) {
$class .= ' enable-lightbox lightbox';
}
break;
}
// Fall through to default if the image module is not available.
default:
// Get the filefield icon
$file = (object) array(
'filemime' => $mime,
);
$icon = base_path() . file_icon_path($file);
$class .= ' generic';
$href = "tft/download/file/{$id}";
break;
}
return l($title, $href, array(
'attributes' => array(
'class' => $class,
'style' => "background-image: url({$icon})",
'target' => '_blank',
),
));
}
}