function template_preprocess_filedepot_filelisting in filedepot 7
Same name and namespace in other branches
- 6 lib-theme.php \template_preprocess_filedepot_filelisting()
File
- ./
lib-theme.php, line 305 - lib-theme.php Theme support functions for the module
Code
function template_preprocess_filedepot_filelisting(&$variables) {
global $user;
$filedepot = filedepot_filedepot();
$nexcloud = filedepot_nexcloud();
/* listing rec format
file.fid as fid,file.cid,file.title,file.fname,file.date,file.version,file.submitter,file.status,
detail.description,category.name as foldername,category.pid,category.last_modified_date,status_changedby_uid as changedby_uid, size
*/
$rec = $variables['listingrec'];
$level = $variables['level'];
$variables['subfolder_id'] = $rec['cid'];
$variables['show_submitter'] = 'none';
$variables['padding_left'] = $level * $filedepot->listingpadding + $filedepot->listingpadding;
$variables['file_desc_padding_left'] = $filedepot->filedescriptionOffset + $level * $filedepot->listingpadding;
$variables['locked_icon'] = base_path() . drupal_get_path('module', 'filedepot') . '/css/images/' . $filedepot
->getFileIcon('locked');
$variables['submitter'] = '';
$variables['favorite_status_image'] = '';
$variables['filesize'] = '';
if ($rec['status'] == 2) {
$variables['show_lock'] = '';
}
else {
$variables['show_lock'] = 'none';
}
$variables['details_link_parms'] = "?fid={$rec['fid']}";
$variables['fid'] = $rec['fid'];
if (isset($rec['size'])) {
$variables['filesize'] = filedepot_formatFileSize($rec['size']);
}
$variables['file_name'] = filter_xss($rec['title']);
if (isset($rec['date']) and $rec['date'] > 0) {
$variables['modified_date'] = strftime($filedepot->shortdate, $rec['date']);
}
else {
$variables['modified_date'] = '';
}
$variables['folder_link'] = url('filedepot', array(
'query' => array(
'cid' => $rec['cid'],
),
'absolute' => true,
));
$variables['folder_name'] = filter_xss($rec['foldername']);
$filenum = $rec['fileorder'] / 10;
if (variable_get('filedepot_show_index_enabled', 1) == 1) {
// Check admin config setting
$variables['file_number'] = "{$rec['folderprefix']}.{$filenum}";
}
else {
$variables['file_number'] = '';
}
$variables['file_description'] = nl2br(filter_xss($rec['description']));
$variables['actionclass'] = 'twoactions';
$tags = $nexcloud
->get_itemtags($variables['fid']);
$variables['tags'] = filedepot_formatfiletags($tags);
$variables['show_favorite'] = FALSE;
if ($rec['status'] > 0 and user_is_logged_in()) {
$variables['show_favorite'] = TRUE;
if (db_query("SELECT count(fid) FROM {filedepot_favorites} WHERE uid=:uid AND fid=:fid", array(
':uid' => $user->uid,
':fid' => $variables['fid'],
))
->fetchField() > 0) {
$variables['favorite_status_image'] = "{$variables['layout_url']}/css/images/{$filedepot->iconmap['favorite-on']}";
$variables['LANG_favorite_status'] = t('Click to clear favorite');
}
else {
$variables['favorite_status_image'] = "{$variables['layout_url']}/css/images/{$filedepot->iconmap['favorite-off']}";
$variables['LANG_favorite_status'] = t('Click to mark item as a favorite');
}
}
$variables['show_approvalsubmitter'] = 'none';
$variables['show_foldername'] = '';
if ($filedepot->activeview == 'approvals') {
$variables['show_approvalsubmitter'] = '';
$variables['show_submitter'] = 'none';
$variables['submitter'] = db_query("SELECT name FROM {users} WHERE uid=:uid", array(
':uid' => $rec['submitter'],
))
->fetchField();
}
elseif ($filedepot->activeview == 'incoming') {
$movelink = "<a class=\"moveincoming\" href=\"?fid={$rec['fid']}\" onClick=\"return false;\">" . t('Move') . '</a>';
$deletelink = "<a class=\"deleteincoming\" href=\"?fid={$rec['fid']}\" onClick=\"return false;\">" . t('Delete') . '</a>';
$variables['action1_link'] = $movelink;
$variables['action2_link'] = $deletelink;
$variables['submitter'] = db_query("SELECT name FROM {users} WHERE uid=:uid", array(
':uid' => $rec['submitter'],
))
->fetchField();
$variables['show_submitter'] = '';
$variables['show_foldername'] = 'none';
}
else {
$folder_admin = $filedepot
->checkPermission($rec['cid'], 'admin');
if ($filedepot->cid > 0 or empty($filedepot->activeview)) {
$variables['show_foldername'] = 'none';
}
$variables['action1_link'] = ' ';
$variables['action2_link'] = ' ';
$variables['actionclass'] = 'noactions';
$allowLockedFileDownloads = variable_get('filedepot_locked_file_download_enabled', 0);
// Check admin config setting
if ($rec['status'] == FILEDEPOT_LOCKED_STATUS) {
if ($folder_admin or $rec['changedby_uid'] == $user->uid) {
// File locked and folder admin or file owner
$path = drupal_get_path('module', 'filedepot') . '/css/images/' . $filedepot
->getFileIcon('download');
$downloadlinkimage = theme('image', array(
'path' => $path,
));
$variables['action1_link'] = l($downloadlinkimage, "filedepot_download/{$rec['nid']}/{$rec['fid']}", array(
'html' => TRUE,
'attributes' => array(
'title' => t('Download File'),
),
));
if (FILEDEPOT_CLIENT_SUPPORT and $user->uid > 0 and $filedepot
->checkPermission($rec['cid'], array(
'upload_dir',
), $user->uid)) {
$variables['actionclass'] = 'twoactions';
$path = drupal_get_path('module', 'filedepot') . '/css/images/' . $filedepot
->getFileIcon('editfile');
$editlinkimage = theme('image', array(
'path' => $path,
));
$variables['action2_link'] = l($editlinkimage, "filedepot_download/{$rec['nid']}/{$rec['fid']}/0/edit", array(
'html' => TRUE,
'attributes' => array(
'title' => t('Download for Editing'),
),
));
}
else {
$variables['action2_link'] = '';
$variables['actionclass'] = 'oneaction';
}
}
elseif ($allowLockedFileDownloads == 1) {
// File locked and downloads allowed
$path = drupal_get_path('module', 'filedepot') . '/css/images/' . $filedepot
->getFileIcon('download');
$downloadlinkimage = theme('image', array(
'path' => $path,
));
$variables['action1_link'] = l($downloadlinkimage, "filedepot_download/{$rec['nid']}/{$rec['fid']}", array(
'html' => TRUE,
'attributes' => array(
'title' => t('Download File'),
),
));
$variables['action2_link'] = '';
$variables['actionclass'] = 'oneaction';
}
}
else {
if ($folder_admin or $rec['changedby_uid'] == $user->uid) {
$path = drupal_get_path('module', 'filedepot') . '/css/images/' . $filedepot
->getFileIcon('download');
$downloadlinkimage = theme('image', array(
'path' => $path,
));
$variables['action1_link'] = l($downloadlinkimage, "filedepot_download/{$rec['nid']}/{$rec['fid']}", array(
'html' => TRUE,
'attributes' => array(
'title' => t('Download File'),
),
));
if (FILEDEPOT_CLIENT_SUPPORT and $user->uid > 0 and $filedepot
->checkPermission($rec['cid'], array(
'upload_dir',
), $user->uid)) {
$variables['actionclass'] = 'twoactions';
$path = drupal_get_path('module', 'filedepot') . '/css/images/' . $filedepot
->getFileIcon('editfile');
$editlinkimage = theme('image', array(
'path' => $path,
));
$variables['action2_link'] = l($editlinkimage, "filedepot_download/{$rec['nid']}/{$rec['fid']}/0/edit", array(
'html' => TRUE,
'attributes' => array(
'title' => t('Download for Editing'),
),
));
}
else {
$variables['action2_link'] = '';
$variables['actionclass'] = 'oneaction';
}
}
else {
$path = drupal_get_path('module', 'filedepot') . '/css/images/' . $filedepot
->getFileIcon('download');
$downloadlinkimage = theme('image', array(
'path' => $path,
));
$variables['action1_link'] = l($downloadlinkimage, "filedepot_download/{$rec['nid']}/{$rec['fid']}", array(
'html' => TRUE,
'attributes' => array(
'title' => t('Download File'),
),
));
$variables['action2_link'] = '';
$variables['actionclass'] = 'oneaction';
}
}
}
$icon = $filedepot
->getFileIcon($rec['fname']);
$variables['extension_icon'] = "{$variables['layout_url']}/css/images/{$icon}";
if ($variables['morerecords'] == 'loadfolder_msg') {
$variables['more_records_message'] = theme('filedepot_filelisting_loadfolder', array(
'cid' => $rec['cid'],
'fid' => $variables['fid'],
'foldernumber' => $variables['file_number'],
'level' => $level,
));
}
elseif ($variables['morerecords'] != '') {
$variables['more_records_message'] = theme('filedepot_filelisting_moredata', array(
'cid' => $rec['cid'],
'fid' => $variables['fid'],
'foldernumber' => $variables['file_number'],
'level' => $level,
));
}
else {
$variables['more_records_message'] = '';
}
}