• R/O
  • SSH
  • HTTPS

xoonips: Commit


Commit MetaInfo

Revision652 (tree)
Time2017-09-25 20:55:08
Authororrisroot

Log Message

removed thubnail image migration. prepared static thumbnail images does not need any more.

Change Summary

Incremental Difference

--- trunk/xoonips/xoops_trust_path/modules/xdbmigrate/class/migrate/Item.class.php (revision 651)
+++ trunk/xoonips/xoops_trust_path/modules/xdbmigrate/class/migrate/Item.class.php (revision 652)
@@ -151,14 +151,11 @@
151151 if (file_exists($file)) {
152152 $dbFile = false;
153153 rename($file, $moveFile);
154- } else if (!$this->_checkThumbnailFile($itemFile['file_id'])) {
154+ } else {
155155 $logmsg = sprintf("item file %s not found ", $itemFile['file_id']);
156156 Xdbmigrate_Logger::addLog($logmsg);
157157 continue;
158158 }
159- //create thumbnail
160- if (!$this->_createThumbnail($itemFile, $moveFile, $dbFile))
161- return false;
162159 }
163160 return true;
164161 }
@@ -182,86 +179,4 @@
182179 $this->mDB->freeRecordSet($res);
183180 return $ret;
184181 }
185-
186- /*
187- * check thumbnail file
188- *
189- * @param file id
190- *
191- * @return bool
192- */
193- protected function _checkThumbnailFile($fileId) {
194- $ret = array();
195- $table = $this->mWorkingTable->getTable($this->mTargetDirname . '_file');
196- $sql = sprintf('SELECT * FROM `%s` WHERE `file_id`=%u', $table, $fileId);
197- if (!($res = $this->mDB->query($sql)))
198- return false;
199- $row = $this->mDB->fetchArray($res);
200- $this->mDB->freeRecordSet($res);
201- if (is_null($row['thumbnail_file']))
202- return false;
203- return true;
204- }
205-
206- /*
207- * create thumbnail
208- *
209- * @param item file
210- * @param img file
211- * @param db
212- *
213- * @return bool
214- *
215- */
216- protected function _createThumbnail($itemFile, $imgFile, $db) {
217- $thumbnailFile = $imgFile . '_thumbnail';
218- if ($db) {
219- // thumbnail from db
220- $table = $this->mWorkingTable->getTable($this->mTargetDirname . '_file');
221- $sql = sprintf('SELECT `thumbnail_file` FROM `%s` WHERE `file_id`=%u', $table, $itemFile['file_id']);
222- if (!($res = $this->mDB->query($sql)))
223- return false;
224- $row = $this->mDB->fetchRow($res);
225- $this->mDB->freeRecordSet($res);
226- $fp = fopen($imgFile, 'w');
227- if ($fp === false) {
228- return false;
229- }
230- fwrite($fp, $row[0]);
231- fclose($fp);
232- copy($imgFile, $thumbnailFile);
233- //unlink($imgFile); // Order to perform the same operation as the XooNIps NG file upload
234- } else {
235- if ($this->_isViewType($itemFile['item_field_detail_id'])) {
236- $xoonipsFile = new Xoonips_File($this->mTargetDirname, $this->mTargetDirname);
237- $thumbnail = $xoonipsFile->getThumbnail($imgFile, $itemFile['mime_type']);
238- if ($thumbnail != '') {
239- if (file_exists($thumbnail)) {
240- copy($thumbnail, $thumbnailFile);
241- unlink($thumbnail);
242- }
243- }
244- unset($xoonipsFile);
245- }
246- }
247- return true;
248- }
249-
250- /*
251- * check view type
252- *
253- * @return bool
254- */
255- protected function _isViewType($itemFieldDetailId) {
256- $itemTable = $this->mDB->prefix($this->mTargetDirname . '_item_field_detail');
257- $viewTypeTable = $this->mDB->prefix($this->mTargetDirname . '_view_type');
258- $sql = sprintf('SELECT * FROM `%s` WHERE `item_field_detail_id`=%u AND `view_type_id` = (SELECT `view_type_id` FROM `%s` WHERE `name`="preview")', $itemTable, $itemFieldDetailId, $viewTypeTable);
259- if (!($res = $this->mDB->query($sql)))
260- return false;
261- $row = $this->mDB->getRowsNum($res);
262- $this->mDB->freeRecordSet($res);
263- if ($row == 0)
264- return false;
265- return true;
266- }
267182 }
Show on old repository browser