richdocuments/lib/helper.php

28 lines
589 B
PHP
Raw Normal View History

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
public static function getNewFileName($view, $path, $prepend = ' '){
$fileNum = 1;
2014-02-12 15:46:53 +03:00
while ($view->file_exists($path)){
$fileNum += 1;
$path = preg_replace('/(\.|' . $prepend . '\(\d+\)\.)([^.]*)$/', $prepend . '(' . $fileNum . ').$2', $path);
};
2014-02-12 15:46:53 +03:00
return $path;
}
2014-02-12 15:46:53 +03:00
}