forked from nuvoleweb/atrium_folders
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathatrium_folders.theme.inc
79 lines (70 loc) · 2.7 KB
/
atrium_folders.theme.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
function theme_folder_toolbar_fieldset($element) {
$output .= '<div class="left"><div class="inner">';
$output .= ' <div class="title">'. $element['#title'] .'</div>';
$output .= ' <div class="description">'. $element['#description'] .'</div>';
$output .= '</div></div>';
$output .= '<div class="right"><div class="inner">';
foreach (element_children($element) as $name) {
$output .= drupal_render($element[$name]);
}
$output .= '</div></div>';
return $output;
}
function theme_folder_toolbar_form($form) {
$output = '';
$links = array();
$buttons = array();
drupal_add_js(drupal_get_path('module', 'atrium_folders') .'/js/atrium_folders_toolbar.js');
$buttons = $form['buttons'];
$buttons['#weight'] = 1000;
unset($form['buttons']);
foreach (element_children($form) as $name) {
if ($form[$name]['#theme'] == 'folder_toolbar_fieldset') {
$links[$name]['title'] = $form[$name]['#title'];
$links[$name]['href'] = $_GET['q'];
$links[$name]['fragment'] = $name;
$links[$name]['attributes'] = array('class' => 'folder-toolbar-link');
$form[$name]['#attributes'] = array('id' => $name, 'class' => 'folder-toolbar-fieldset fieldset titled');
unset($buttons['preview']);
unset($buttons['preview_changes']);
$form[$name]['buttons'] = $buttons;
$form[$name]['buttons']['#prefix'] = '<div class="buttons" style="display: block;">';
$form[$name]['buttons']['#suffix'] = '</div>';
$output .= drupal_render($form[$name]);
}
else {
$form[$name]['#attributes'] = array('style' => 'display: none;');
$output .= drupal_render($form[$name]);
}
}
return '<div class="buttons">'. theme('links', $links) .'</div>' . $output;
}
/**
* Theme textfields element
*/
function theme_textfields($element) {
return $element['#children'];
}
/**
* Theme list of files
*
* $files: array of associative arrays, each including:
* filename, filepath, filemime, filesize, description
*/
function theme_folders_file_list($files = array()) {
$header = '';
$rows = array();
foreach ($files as $file) {
$row = array();
$extension = strtolower(substr(strrchr($file['filename'], '.'), 1));
$icon = '<div class="mime-' . $extension . '"><div class="fileview mime"></div></div>';
$row['icon'] = l($icon, file_create_url($file['filename']), array('html' => TRUE));
$row['file'] = l($file['filename'], file_create_url($file['filename']));
$rows[] = $row;
}
$table = theme('table', $header, $rows);
$description = '<p>Files uploaded to group folders and other group content.</p>';
$markup = '<div id="attach-wrapper">' . $description . $table . '</div>'; // So iTweak Uploads adds MIME icons
return $markup;
}