@@ -32,8 +32,9 @@ public function init()
32
32
$ this ->addCallBack ('CALLBACK_CORE_GET_COMMUNITY_MANAGE_TABS ' , 'getCommunityTab ' );
33
33
$ this ->addCallBack ('CALLBACK_CORE_GET_USER_TABS ' , 'getUserTab ' );
34
34
$ this ->addCallBack ('CALLBACK_CORE_GET_FOOTER_LAYOUT ' , 'getScript ' );
35
- $ this ->addCallBack ('CALLBACK_CORE_GET_SIMPLEUPLOAD_EXTRA_HTML ' , 'getExtraHtml ' );
36
- $ this ->addCallBack ('CALLBACK_CORE_GET_JAVAUPLOAD_EXTRA_HTML ' , 'getExtraHtml ' );
35
+ $ this ->addCallBack ('CALLBACK_CORE_GET_SIMPLEUPLOAD_EXTRA_HTML ' , 'getExtraHtmlSimple ' );
36
+ $ this ->addCallBack ('CALLBACK_CORE_GET_JAVAUPLOAD_EXTRA_HTML ' , 'getExtraHtmlSimple ' );
37
+ $ this ->addCallBack ('CALLBACK_CORE_GET_REVISIONUPLOAD_EXTRA_HTML ' , 'getExtraHtmlRevision ' );
37
38
$ this ->addCallBack ('CALLBACK_CORE_VALIDATE_UPLOAD ' , 'validateUpload ' );
38
39
39
40
$ this ->enableWebAPI ($ this ->moduleName );
@@ -72,8 +73,11 @@ public function getScript()
72
73
return '<script type="text/javascript" src=" ' .$ modulePublicWebroot .'/public/js/common/common.notify.js"></script> ' ;
73
74
}
74
75
75
- /** Add free space information to the dom on the simple upload page */
76
- public function getExtraHtml ($ args )
76
+ /**
77
+ * Add free space information to the dom on the simple upload & java upload pages
78
+ * @param folder The folder dao that you are uploading into
79
+ */
80
+ public function getExtraHtmlSimple ($ args )
77
81
{
78
82
$ modelLoader = new MIDAS_ModelLoader ();
79
83
$ folderModel = $ modelLoader ->loadModel ('Folder ' );
@@ -97,6 +101,44 @@ public function getExtraHtml($args)
97
101
}
98
102
}
99
103
104
+ /**
105
+ * Add free space information to the dom on the revision uploader page
106
+ * @param item The item dao that you are uploading a new revision into
107
+ */
108
+ public function getExtraHtmlRevision ($ args )
109
+ {
110
+ $ modelLoader = new MIDAS_ModelLoader ();
111
+ $ folderModel = $ modelLoader ->loadModel ('Folder ' );
112
+ $ folderQuotaModel = $ modelLoader ->loadModel ('FolderQuota ' , $ this ->moduleName );
113
+
114
+ $ item = $ args ['item ' ];
115
+ $ folders = $ item ->getFolders ();
116
+ if (count ($ folders ) == 0 )
117
+ {
118
+ //don't allow any more uploading into an orphaned item
119
+ return '<div id="sizequotaFreeSpace" style="display:none;">0</div> ' .
120
+ '<div id="sizequotaHFreeSpace" style="display:none;"> ' .$ this ->t ('None ' ).'</div> ' ;
121
+ }
122
+ else
123
+ {
124
+ $ rootFolder = $ folderModel ->getRoot ($ folders [0 ]);
125
+ $ quota = $ folderQuotaModel ->getFolderQuota ($ rootFolder );
126
+ if ($ quota == '' )
127
+ {
128
+ return '<div id="sizequotaFreeSpace" style="display:none;"></div> ' .
129
+ '<div id="sizequotaHFreeSpace" style="display:none;"> ' .$ this ->t ('Unlimited ' ).'</div> ' ;
130
+ }
131
+ else
132
+ {
133
+ $ used = $ folderModel ->getSize ($ rootFolder );
134
+ $ freeSpace = number_format ($ quota - $ used , 0 , '. ' , '' );
135
+ $ hFreeSpace = UtilityComponent::formatSize ($ quota - $ used );
136
+ return '<div id="sizequotaFreeSpace" style="display:none;"> ' .$ freeSpace .'</div> ' .
137
+ '<div id="sizequotaHFreeSpace" style="display:none;"> ' .$ hFreeSpace .'</div> ' ;
138
+ }
139
+ }
140
+ }
141
+
100
142
/**
101
143
* Return whether or not the upload is allowed. If uploading the file
102
144
* will cause the size to surpass the quota, it will be rejected.
0 commit comments