2013-08-18 19:02:48 +03:00
|
|
|
<?php
|
|
|
|
/**
|
2015-12-16 17:57:44 +03:00
|
|
|
* ownCloud - Richdocuments App
|
2013-08-18 19:02:48 +03:00
|
|
|
*
|
|
|
|
* @author Victor Dubiniuk
|
|
|
|
* @copyright 2013 Victor Dubiniuk victor.dubiniuk@gmail.com
|
|
|
|
*
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later.
|
|
|
|
*/
|
|
|
|
|
2015-12-16 17:57:44 +03:00
|
|
|
namespace OCA\Richdocuments;
|
2013-08-18 19:02:48 +03:00
|
|
|
|
2014-02-12 15:46:53 +03:00
|
|
|
class Helper {
|
2015-12-16 17:57:44 +03:00
|
|
|
const APP_ID = 'richdocuments';
|
2014-02-12 15:46:53 +03:00
|
|
|
|
2013-09-21 00:01:11 +03:00
|
|
|
public static function getNewFileName($view, $path, $prepend = ' '){
|
2013-10-29 16:27:09 +03:00
|
|
|
$fileNum = 1;
|
2014-02-12 15:46:53 +03:00
|
|
|
|
2013-09-20 09:57:10 +03:00
|
|
|
while ($view->file_exists($path)){
|
|
|
|
$fileNum += 1;
|
2015-11-04 21:49:23 +01:00
|
|
|
$path = preg_replace('/(\.|' . $prepend . '\(\d+\)\.)([^.]*)$/', $prepend . '(' . $fileNum . ').$2', $path);
|
2013-09-20 09:57:10 +03:00
|
|
|
};
|
2014-02-12 15:46:53 +03:00
|
|
|
|
2013-09-20 09:57:10 +03:00
|
|
|
return $path;
|
|
|
|
}
|
2014-02-12 15:46:53 +03:00
|
|
|
}
|