Blame view
sources/apps/documents/lib/helper.php
1.17 KB
|
923852aa1
|
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 |
<?php
/**
* ownCloud - Documents App
*
* @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.
*/
namespace OCA\Documents;
class Helper{
const APP_ID = 'documents';
public static function getNewFileName($view, $path, $prepend = ' '){
$fileNum = 1;
while ($view->file_exists($path)){
$fileNum += 1;
$path = preg_replace('/(\.odt|' . $prepend . '\(\d+\)\.odt)$/', $prepend . '(' .$fileNum . ').odt', $path);
};
return $path;
}
public static function isVersionsEnabled(){
return \OCP\App::isEnabled('files_versions');
}
public static function getRandomColor(){
$str = dechex(floor(rand(0, 16777215)));
return '#' . str_pad($str, 6, "0", STR_PAD_LEFT);
}
public static function debugLog($message){
self::log($message, \OCP\Util::DEBUG);
}
public static function warnLog($message){
self::log($message, \OCP\Util::WARN);
}
public static function errorLog($message){
self::log($message, \OCP\Util::ERROR);
}
public static function log($message, $level){
\OCP\Util::writeLog(self::APP_ID, $message, $level);
}
}
|