Save attachments as ...

This commit is contained in:
RainLoop Team 2015-04-25 02:15:11 +04:00
parent f5f067f1f3
commit 48b91fb957
20 changed files with 687 additions and 76 deletions

View file

@ -34,4 +34,5 @@ class Charset
const ISO_8859_8 = 'iso-8859-8';
const ISO_8859_8_I = 'iso-8859-8-i';
const ISO_2022_JP = 'iso-2022-jp';
const CP858 = 'cp858';
}

View file

@ -567,6 +567,12 @@ class Http
return false;
}
$sUrl = \trim($sUrl);
if ('//' === substr($sUrl, 0, 2))
{
$sUrl = 'http:'.$sUrl;
}
$aOptions = array(
CURLOPT_URL => $sUrl,
CURLOPT_HEADER => false,

View file

@ -235,6 +235,56 @@ END;
return $sCharset;
}
/**
* @param string $sFilePath
* @param function $fFileExistsCallback = null
*
* @return string
*/
public static function SmartFileExists($sFilePath, $fFileExistsCallback = null)
{
$sFilePath = \str_replace('\\', '/', \trim($sFilePath));
if (!$fFileExistsCallback)
{
$fFileExistsCallback = function ($sPath) {
return \file_exists($sPath);
};
}
if (!\call_user_func($fFileExistsCallback, $sFilePath))
{
return $sFilePath;
}
$aFileInfo = \pathinfo($sFilePath);
$iIndex = 0;
do
{
$iIndex++;
$sFilePathNew = $aFileInfo['dirname'].'/'.
\preg_replace('/\(\d{1,2}\)$/', '', $aFileInfo['filename']).
' ('.$iIndex.')'.
(empty($aFileInfo['extension']) ? '' : '.'.$aFileInfo['extension'])
;
if (!\call_user_func($fFileExistsCallback, $sFilePathNew))
{
$sFilePath = $sFilePathNew;
break;
}
else if (10 < $iIndex)
{
break;
}
}
while (true);
return $sFilePath;
}
/**
* @return bool
*/