本文整理汇总了PHP中OCP\Util::humanFileSize方法的典型用法代码示例。如果您正苦于以下问题:PHP Util::humanFileSize方法的具体用法?PHP Util::humanFileSize怎么用?PHP Util::humanFileSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCP\Util
的用法示例。
在下文中一共展示了Util::humanFileSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function index()
{
\OCP\Util::addscript('core', 'tags');
\OCP\Util::addStyle($this->appName, 'style');
\OCP\Util::addStyle($this->appName, 'jquery.Jcrop');
\OCP\Util::addStyle($this->appName, '3rdparty/fontello/css/animation');
\OCP\Util::addStyle($this->appName, '3rdparty/fontello/css/fontello');
\OCP\Util::addStyle($this->appName, '3rdparty/jquery.webui-popover');
\OCP\Util::addscript($this->appName, 'app');
\OCP\Util::addscript($this->appName, '3rdparty/jquery.webui-popover');
\OCP\Util::addscript($this->appName, 'settings');
\OCP\Util::addscript($this->appName, 'loader');
\OCP\Util::addscript($this->appName, 'jquery.scrollTo.min');
\OCP\Util::addscript($this->appName, 'jquery.nicescroll.min');
\OCP\Util::addscript('files', 'jquery.fileupload');
\OCP\Util::addscript($this->appName, 'jquery.Jcrop');
$iosSupport = $this->configInfo->getUserValue($this->userId, $this->appName, 'iossupport');
$maxUploadFilesize = \OCP\Util::maxUploadFilesize('/');
$addressbooks = Addressbook::all($this->userId);
if (count($addressbooks) == 0) {
Addressbook::addDefault($this->userId);
$addressbooks = Addressbook::all($this->userId);
}
//ContactsApp::addingDummyContacts(50);
$params = ['uploadMaxFilesize' => $maxUploadFilesize, 'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize), 'iossupport' => $iosSupport, 'addressbooks' => $addressbooks];
$csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
$csp->addAllowedImageDomain('*');
$csp->addAllowedFrameDomain('*');
$response = new TemplateResponse($this->appName, 'index');
$response->setContentSecurityPolicy($csp);
$response->setParams($params);
return $response;
}
示例2: index
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function index() {
\OC::$server->getNavigationManager()->setActiveEntry($this->appName);
$importManager = new ImportManager();
$imppTypes = Properties::getTypesForProperty('IMPP');
$adrTypes = Properties::getTypesForProperty('ADR');
$phoneTypes = Properties::getTypesForProperty('TEL');
$emailTypes = Properties::getTypesForProperty('EMAIL');
$ims = Properties::getIMOptions();
$imProtocols = array();
foreach($ims as $name => $values) {
$imProtocols[$name] = $values['displayname'];
}
$maxUploadFilesize = \OCP\Util::maxUploadFilesize('/');
$response = new TemplateResponse($this->appName, 'contacts');
$response->setParams(array(
'uploadMaxFilesize' => $maxUploadFilesize,
'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize),
'phoneTypes' => $phoneTypes,
'emailTypes' => $emailTypes,
'adrTypes' => $adrTypes,
'imppTypes' => $imppTypes,
'imProtocols' => $imProtocols,
'importManager' => $importManager,
));
return $response;
}
示例3: buildFileStorageStatistics
public static function buildFileStorageStatistics($dir)
{
// information about storage capacities
$storageInfo = \OC_Helper::getStorageInfo($dir);
$l = new \OC_L10N('files');
$maxUploadFileSize = \OCP\Util::maxUploadFilesize($dir, $storageInfo['free']);
$maxHumanFileSize = \OCP\Util::humanFileSize($maxUploadFileSize);
$maxHumanFileSize = $l->t('Upload (max. %s)', array($maxHumanFileSize));
return array('uploadMaxFilesize' => $maxUploadFileSize, 'maxHumanFilesize' => $maxHumanFileSize, 'freeSpace' => $storageInfo['free'], 'usedSpacePercent' => (int) $storageInfo['relative']);
}
示例4: upload
/**
* @NoAdminRequired
*/
public function upload()
{
$request = $this->request;
$params = $this->request->urlParams;
$response = new JSONResponse();
$view = \OCP\Files::getStorage('contacts');
if (!$view->file_exists('imports')) {
$view->mkdir('imports');
}
if (!isset($request->files['file'])) {
$response->bailOut(App::$l10n->t('No file was uploaded. Unknown error'));
return $response;
}
$file = $request->files['file'];
if ($file['error'] !== UPLOAD_ERR_OK) {
$error = $file['error'];
$errors = array(UPLOAD_ERR_OK => App::$l10n->t("There is no error, the file uploaded with success"), UPLOAD_ERR_INI_SIZE => App::$l10n->t("The uploaded file exceeds the upload_max_filesize directive in php.ini") . ini_get('upload_max_filesize'), UPLOAD_ERR_FORM_SIZE => App::$l10n->t("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"), UPLOAD_ERR_PARTIAL => App::$l10n->t("The uploaded file was only partially uploaded"), UPLOAD_ERR_NO_FILE => App::$l10n->t("No file was uploaded"), UPLOAD_ERR_NO_TMP_DIR => App::$l10n->t('Missing a temporary folder'), UPLOAD_ERR_CANT_WRITE => App::$l10n->t('Failed to write to disk'));
$response->bailOut($errors[$error]);
return $response;
}
$maxUploadFilesize = \OCP\Util::maxUploadFilesize('/');
$maxHumanFilesize = \OCP\Util::humanFileSize($maxUploadFilesize);
$totalSize = $file['size'];
if ($maxUploadFilesize >= 0 and $totalSize > $maxUploadFilesize) {
$response->bailOut(App::$l10n->t('Not enough storage available'));
return $response;
}
$tmpname = $file['tmp_name'];
$filename = strtr($file['name'], array('/' => '', "\\" => ''));
if (is_uploaded_file($tmpname)) {
if (\OC\Files\Filesystem::isFileBlacklisted($filename)) {
$response->bailOut(App::$l10n->t('Attempt to upload blacklisted file:') . $filename);
return $response;
}
$content = file_get_contents($tmpname);
$proxyStatus = \OC_FileProxy::$enabled;
\OC_FileProxy::$enabled = false;
if ($view->file_put_contents('/imports/' . $filename, $content)) {
\OC_FileProxy::$enabled = $proxyStatus;
$count = substr_count($content, 'BEGIN:');
$progresskey = 'contacts-import-' . rand();
$response->setParams(array('filename' => $filename, 'count' => $count, 'progresskey' => $progresskey, 'backend' => $params['backend'], 'addressBookId' => $params['addressBookId']));
\OC_Cache::set($progresskey, '10', 300);
} else {
\OC_FileProxy::$enabled = $proxyStatus;
$response->bailOut(App::$l10n->t('Error uploading contacts to storage.'));
return $response;
}
} else {
$response->bailOut('Temporary file: \'' . $tmpname . '\' has gone AWOL?');
return $response;
}
return $response;
}
示例5: index
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function index()
{
\OC::$server->getNavigationManager()->setActiveEntry('documents_index');
$maxUploadFilesize = \OCP\Util::maxUploadFilesize("/");
$response = new TemplateResponse('documents', 'documents', ['enable_previews' => $this->settings->getSystemValue('enable_previews', true), 'useUnstable' => $this->settings->getAppValue('documents', 'unstable', 'false'), 'savePath' => $this->settings->getUserValue($this->uid, 'documents', 'save_path', '/'), 'uploadMaxFilesize' => $maxUploadFilesize, 'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize), 'allowShareWithLink' => $this->settings->getAppValue('core', 'shareapi_allow_links', 'yes')]);
$policy = new ContentSecurityPolicy();
//$policy->addAllowedChildSrcDomain('\'self\' http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js http://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js \'unsafe-eval\'');
$policy->addAllowedScriptDomain('\'self\' http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js http://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js \'unsafe-eval\'');
$policy->addAllowedFrameDomain('\'self\' http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js http://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js \'unsafe-eval\'');
$policy->addAllowedConnectDomain('ws://' . $_SERVER['SERVER_NAME'] . ':9980');
$policy->addAllowedImageDomain('*');
$policy->allowInlineScript(true);
$policy->addAllowedFontDomain('data:');
$response->setContentSecurityPolicy($policy);
return $response;
}
示例6: index
public function index()
{
try {
$list = Helper::scandir($this->config->getBackupBase());
} catch (\Exception $e) {
$list = [];
}
clearstatcache();
$result = [];
foreach ($list as $item) {
if (in_array($item, ['.', '..'])) {
continue;
}
$result[] = ['title' => $item, 'date' => date("F d Y H:i:s", filectime($this->config->getBackupBase() . '/' . $item)), 'size' => \OCP\Util::humanFileSize(filesize($this->config->getBackupBase() . '/' . $item))];
}
return ['status' => 'success', 'data' => $result];
}
示例7: processImage
/**
* Load the image.
*/
protected function processImage()
{
// If image has already been read return
if ($this->image instanceof Image) {
return;
}
$this->image = new Image();
\OCP\Util::writeLog('contacts', __METHOD__ . ', Content-Type: ' . $this->request->getHeader('Content-Type'), \OCP\Util::DEBUG);
\OCP\Util::writeLog('contacts', __METHOD__ . ', Content-Length: ' . $this->request->getHeader('Content-Length'), \OCP\Util::DEBUG);
if (substr($this->request->getHeader('Content-Type'), 0, 6) !== 'image/') {
throw new \Exception('Only images can be used as contact photo', Http::STATUS_UNSUPPORTED_MEDIA_TYPE);
}
$maxSize = \OCP\Util::maxUploadFilesize('/');
if ($this->request->getHeader('Content-Length') > $maxSize) {
throw new \Exception(sprintf('The size of the file exceeds the maximum allowed %s', \OCP\Util::humanFileSize($maxSize)), Http::STATUS_REQUEST_ENTITY_TOO_LARGE);
}
$this->image->loadFromFileHandle($this->request->put);
}
示例8: index
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function index()
{
$iosSupport = $this->configInfo->getUserValue($this->userId, $this->appName, 'iossupport');
$activeView = $this->configInfo->getUserValue($this->userId, $this->appName, 'view', 'listview');
$lastSelectedBook = $this->configInfo->getUserValue($this->userId, $this->appName, 'currentbook', 0);
$maxUploadFilesize = \OCP\Util::maxUploadFilesize('/');
$addressbooks = Addressbook::all($this->userId);
if (count($addressbooks) == 0) {
Addressbook::addDefault($this->userId);
$addressbooks = Addressbook::all($this->userId);
}
//ContactsApp::addingDummyContacts(1000);
$params = ['uploadMaxFilesize' => $maxUploadFilesize, 'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize), 'iossupport' => $iosSupport, 'addressbooks' => $addressbooks, 'activeView' => $activeView, 'lastSelectedBook' => $lastSelectedBook];
$csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
$csp->addAllowedImageDomain('*');
$csp->addAllowedFrameDomain('*');
$response = new TemplateResponse($this->appName, 'index');
$response->setContentSecurityPolicy($csp);
$response->setParams($params);
return $response;
}
示例9: index
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function index()
{
\OC::$server->getNavigationManager()->setActiveEntry($this->appName);
$importManager = new ImportManager();
$imppTypes = Properties::getTypesForProperty('IMPP');
$adrTypes = Properties::getTypesForProperty('ADR');
$phoneTypes = Properties::getTypesForProperty('TEL');
$emailTypes = Properties::getTypesForProperty('EMAIL');
$ims = Properties::getIMOptions();
$imProtocols = array();
foreach ($ims as $name => $values) {
$imProtocols[$name] = $values['displayname'];
}
$maxUploadFilesize = \OCP\Util::maxUploadFilesize('/');
\OCP\Util::addScript('', 'jquery.multiselect');
\OCP\Util::addScript('', 'tags');
\OCP\Util::addScript('placeholder');
\OCP\Util::addScript('3rdparty', 'md5/md5.min');
\OCP\Util::addScript('jquery.avatar');
\OCP\Util::addScript('avatar');
\OCP\Util::addScript('contacts', 'jquery.combobox');
\OCP\Util::addScript('contacts', 'modernizr.custom');
\OCP\Util::addScript('contacts', 'app');
\OCP\Util::addScript('contacts', 'addressbooks');
\OCP\Util::addScript('contacts', 'contacts');
\OCP\Util::addScript('contacts', 'storage');
\OCP\Util::addScript('contacts', 'groups');
\OCP\Util::addScript('contacts', 'jquery.ocaddnew');
\OCP\Util::addScript('contacts', 'otherbackendconfig');
\OCP\Util::addScript('files', 'jquery.fileupload');
\OCP\Util::addScript('3rdparty/Jcrop', 'jquery.Jcrop');
\OCP\Util::addStyle('', 'jquery.multiselect');
\OCP\Util::addStyle('contacts', 'jquery.combobox');
\OCP\Util::addStyle('contacts', 'jquery.ocaddnew');
\OCP\Util::addStyle('3rdparty/Jcrop', 'jquery.Jcrop');
\OCP\Util::addStyle('contacts', 'contacts');
$response = new TemplateResponse($this->appName, 'contacts');
$response->setParams(array('uploadMaxFilesize' => $maxUploadFilesize, 'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize), 'phoneTypes' => $phoneTypes, 'emailTypes' => $emailTypes, 'adrTypes' => $adrTypes, 'imppTypes' => $imppTypes, 'imProtocols' => $imProtocols, 'importManager' => $importManager));
return $response;
}
示例10: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$toBeSet = [];
if ($input->getOption('enable')) {
$toBeSet['log_type'] = 'owncloud';
}
if ($file = $input->getOption('file')) {
$toBeSet['logfile'] = $file;
}
if (($rotateSize = $input->getOption('rotate-size')) !== null) {
$rotateSize = \OCP\Util::computerFileSize($rotateSize);
$this->validateRotateSize($rotateSize);
$toBeSet['log_rotate_size'] = $rotateSize;
}
// set config
foreach ($toBeSet as $option => $value) {
$this->config->setSystemValue($option, $value);
}
// display config
if ($this->config->getSystemValue('log_type', 'owncloud') === 'owncloud') {
$enabledText = 'enabled';
} else {
$enabledText = 'disabled';
}
$output->writeln('Log backend ownCloud: ' . $enabledText);
$dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
$defaultLogFile = rtrim($dataDir, '/') . '/owncloud.log';
$output->writeln('Log file: ' . $this->config->getSystemValue('logfile', $defaultLogFile));
$rotateSize = $this->config->getSystemValue('log_rotate_size', 0);
if ($rotateSize) {
$rotateString = \OCP\Util::humanFileSize($rotateSize);
} else {
$rotateString = 'disabled';
}
$output->writeln('Rotate at: ' . $rotateString);
}
示例11: showContact
/**
* @NoAdminRequired
*/
public function showContact()
{
$id = $this->params('id');
$vcard = ContactsApp::getContactVCard($id);
$oldaddressbookid = VCard::getAddressbookid($id);
$addressBookPerm = Addressbook::find($oldaddressbookid);
$editInfoCard = VCard::structureContact($vcard);
$TELTYPE = ContactsApp::getTypesOfProperty('TEL');
$EMAILTYPE = ContactsApp::getTypesOfProperty('EMAIL');
$URLTYPE = ContactsApp::getTypesOfProperty('URL');
$ADRTYPE = ContactsApp::getTypesOfProperty('ADR');
$aDefNArray = array('0' => 'lname', '1' => 'fname', '2' => 'anrede', '3' => 'title');
$aN = '';
if (isset($editInfoCard['N'][0]['value']) && count($editInfoCard['N'][0]['value']) > 0) {
foreach ($editInfoCard['N'][0]['value'] as $key => $val) {
if ($val != '') {
$aN[$aDefNArray[$key]] = $val;
}
}
}
$aOrgDef = array('0' => 'firm', '1' => 'department');
$aOrg = array();
if (isset($editInfoCard['ORG'][0]['value']) && count($editInfoCard['ORG'][0]['value']) > 0) {
foreach ($editInfoCard['ORG'][0]['value'] as $key => $val) {
if ($val != '') {
$aOrg[$aOrgDef[$key]] = $val;
}
}
}
$sBday = '';
if (isset($editInfoCard['BDAY'][0]['value']) && !empty($editInfoCard['BDAY'][0]['value'])) {
$sBday = $editInfoCard['BDAY'][0]['value'];
$date = new \DateTime($sBday);
$sBday = $date->format('d. M Y');
}
$sNotice = '';
if (isset($editInfoCard['NOTE'][0]['value']) && !empty($editInfoCard['NOTE'][0]['value'])) {
$sNotice = $editInfoCard['NOTE'][0]['value'];
}
$sNickname = '';
if (isset($editInfoCard['NICKNAME'][0]['value']) && !empty($editInfoCard['NICKNAME'][0]['value'])) {
$sNickname = $editInfoCard['NICKNAME'][0]['value'];
}
$sPosition = '';
if (isset($editInfoCard['TITLE'][0]['value']) && !empty($editInfoCard['TITLE'][0]['value'])) {
$sPosition = $editInfoCard['TITLE'][0]['value'];
}
$aAddr = '';
if (array_key_exists('ADR', $editInfoCard)) {
$aAddr = $this->getAddressInfo($editInfoCard['ADR'], $ADRTYPE);
}
$aTel = '';
if (array_key_exists('TEL', $editInfoCard)) {
$aTel = $this->getPhoneInfo($editInfoCard['TEL'], $TELTYPE);
}
$aEmail = '';
if (array_key_exists('EMAIL', $editInfoCard)) {
$aEmail = $this->getEmailInfo($editInfoCard['EMAIL'], $EMAILTYPE);
}
$aUrl = '';
if (array_key_exists('URL', $editInfoCard)) {
$aUrl = $this->getUrlInfo($editInfoCard['URL'], $URLTYPE);
}
$bPhoto = 0;
$imgSrc = '';
$imgMimeType = '';
$thumb = '<div id="noimage" class="ioc ioc-user"></div>';
if (isset($vcard->PHOTO)) {
$bPhoto = 1;
$thumb = '';
$image = new \OCP\Image();
$image->loadFromData((string) $vcard->PHOTO);
$imgSrc = $image->__toString();
$imgMimeType = $image->mimeType();
\OC::$server->getCache()->set('show-contacts-foto-' . $id, $image->data(), 600);
}
$maxUploadFilesize = \OCP\Util::maxUploadFilesize('/');
$params = ['id' => $id, 'tmpkey' => 'show-contacts-foto-' . $id, 'oldaddressbookid' => $oldaddressbookid, 'addressbooksPerm' => $addressBookPerm, 'isPhoto' => $bPhoto, 'thumbnail' => $thumb, 'imgsrc' => $imgSrc, 'imgMimeType' => $imgMimeType, 'anrede' => isset($aN['title']) ? $aN['title'] : '', 'fname' => isset($aN['fname']) ? $aN['fname'] : '', 'lname' => isset($aN['lname']) ? $aN['lname'] : '', 'firm' => isset($aOrg['firm']) ? $aOrg['firm'] : '', 'department' => isset($aOrg['department']) ? $aOrg['department'] : '', 'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize), 'aTel' => isset($aTel) ? $aTel : '', 'aEmail' => isset($aEmail) ? $aEmail : '', 'aAddr' => isset($aAddr) ? $aAddr : '', 'aUrl' => isset($aUrl) ? $aUrl : '', 'sBday' => isset($sBday) ? $sBday : '', 'nickname' => isset($sNickname) ? $sNickname : '', 'position' => isset($sPosition) ? $sPosition : '', 'sNotice' => isset($sNotice) ? $sNotice : ''];
$response = new TemplateResponse($this->appName, 'contact.show', $params, '');
return $response;
}
示例12: showContact
//.........这里部分代码省略.........
$aDefNArray = array('0' => 'lname', '1' => 'fname', '2' => 'anrede', '3' => 'title');
$aN = '';
if (isset($editInfoCard['N'][0]['value']) && count($editInfoCard['N'][0]['value']) > 0) {
foreach ($editInfoCard['N'][0]['value'] as $key => $val) {
if ($val != '') {
$aN[$aDefNArray[$key]] = $val;
}
}
}
//X-ABSHOWAS;
$bShowCompany = false;
if (isset($editInfoCard['ORG'][0]['SHOWAS']) && $editInfoCard['ORG'][0]['SHOWAS'] == 'COMPANY') {
$bShowCompany = true;
}
$aOrgDef = array('0' => 'firm', '1' => 'department');
$aOrg = array();
if (isset($editInfoCard['ORG'][0]['value']) && count($editInfoCard['ORG'][0]['value']) > 0) {
foreach ($editInfoCard['ORG'][0]['value'] as $key => $val) {
if ($val != '') {
$aOrg[$aOrgDef[$key]] = $val;
}
}
}
$sBday = '';
if (isset($editInfoCard['BDAY'][0]['value']) && !empty($editInfoCard['BDAY'][0]['value'])) {
$sBday = $editInfoCard['BDAY'][0]['value'];
$date = new \DateTime($sBday);
$sBday = $date->format('d. M Y');
}
$sNotice = '';
if (isset($editInfoCard['NOTE'][0]['value']) && !empty($editInfoCard['NOTE'][0]['value'])) {
$sNotice = stripcslashes($editInfoCard['NOTE'][0]['value']);
$sNotice = str_replace("\n", '<br />', $sNotice);
}
$sNickname = '';
if (isset($editInfoCard['NICKNAME'][0]['value']) && !empty($editInfoCard['NICKNAME'][0]['value'])) {
$sNickname = $editInfoCard['NICKNAME'][0]['value'];
}
$sPosition = '';
if (isset($editInfoCard['TITLE'][0]['value']) && !empty($editInfoCard['TITLE'][0]['value'])) {
$sPosition = $editInfoCard['TITLE'][0]['value'];
}
$aAddr = '';
if (array_key_exists('ADR', $editInfoCard)) {
$aAddr = $this->getAddressInfo($editInfoCard['ADR'], $ADRTYPE);
}
$aTel = '';
if (array_key_exists('TEL', $editInfoCard)) {
$aTel = $this->getPhoneInfo($editInfoCard['TEL'], $TELTYPE);
}
$aEmail = '';
if (array_key_exists('EMAIL', $editInfoCard)) {
$aEmail = $this->getEmailInfo($editInfoCard['EMAIL'], $EMAILTYPE);
}
$aUrl = '';
if (array_key_exists('URL', $editInfoCard)) {
$aUrl = $this->getUrlInfo($editInfoCard['URL'], $URLTYPE);
}
$aImpp = '';
if (array_key_exists('IMPP', $editInfoCard)) {
$aImpp = $this->getImppInfo($editInfoCard['IMPP'], $IMTYPE);
}
$aCloud = '';
if (array_key_exists('CLOUD', $editInfoCard)) {
$aCloud = $this->getCloudInfo($editInfoCard['CLOUD'], $ADRTYPE);
}
$bPhoto = 0;
$imgSrc = '';
$imgMimeType = '';
$tmpkey = 'editphoto';
$thumb = '<div id="noimage" class="ioc ioc-user"></div>';
if (isset($vcard->PHOTO)) {
$bPhoto = 1;
$thumb = '';
$image = new \OCP\Image();
$image->loadFromData((string) $vcard->PHOTO);
$imgSrc = $image->__toString();
$imgMimeType = $image->mimeType();
\OC::$server->getCache()->remove($tmpkey);
\OC::$server->getCache()->set($tmpkey, $image->data(), 600);
}
$catOutput = '';
if (isset($editInfoCard['CATEGORIES'][0]['value']) && count($editInfoCard['CATEGORIES'][0]['value']) > 0) {
foreach ($editInfoCard['CATEGORIES'] as $key => $catInfo) {
if ($key == 'value') {
$aCatInfo = explode(',', $catInfo['value']);
foreach ($aCatInfo as $key => $val) {
$backgroundColor = ContactsApp::genColorCodeFromText(trim($val), 80);
$color = ContactsApp::generateTextColor($backgroundColor);
$catOutput .= '<span class="colorgroup toolTip" data-category="' . $val . '" style="background-color:' . $backgroundColor . ';color:' . $color . ';" title="' . $val . '">' . mb_substr($val, 0, 1, "UTF-8") . '</span> ';
}
}
}
}
$addressBookName = $addressBookPerm['displayname'];
$maxUploadFilesize = \OCP\Util::maxUploadFilesize('/');
$params = ['id' => $id, 'tmpkey' => $tmpkey, 'oldaddressbookid' => $oldaddressbookid, 'addressbooksPerm' => $addressBookPerm, 'isPhoto' => $bPhoto, 'thumbnail' => $thumb, 'categories' => $catOutput, 'addressbookname' => $addressBookName, 'bShowCompany' => $bShowCompany, 'imgsrc' => $imgSrc, 'imgMimeType' => $imgMimeType, 'anrede' => isset($aN['title']) ? $aN['title'] : '', 'fname' => isset($aN['fname']) ? $aN['fname'] : '', 'lname' => isset($aN['lname']) ? $aN['lname'] : '', 'firm' => isset($aOrg['firm']) ? $aOrg['firm'] : '', 'department' => isset($aOrg['department']) ? $aOrg['department'] : '', 'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize), 'aTel' => isset($aTel) ? $aTel : '', 'aEmail' => isset($aEmail) ? $aEmail : '', 'aAddr' => isset($aAddr) ? $aAddr : '', 'aUrl' => isset($aUrl) ? $aUrl : '', 'aImpp' => isset($aImpp) ? $aImpp : '', 'aCloud' => isset($aCloud) ? $aCloud : '', 'sBday' => isset($sBday) ? $sBday : '', 'nickname' => isset($sNickname) ? $sNickname : '', 'position' => isset($sPosition) ? $sPosition : '', 'sNotice' => isset($sNotice) ? $sNotice : ''];
$response = new TemplateResponse($this->appName, 'contact.show', $params, '');
return $response;
}
示例13: foreach
<?php
// show toolbar
echo '<div id="controls">
<a href="' . \OCP\Util::linkToAbsolute('impress', 'documentation.php') . '" class="button docu">' . $l->t('Documentation') . '</a>
</div>
';
if (empty($_['list'])) {
echo '<div id="emptyfolder">' . $l->t('No Impress files are found in your ownCloud. Please upload a .impress file.') . '</div>';
} else {
echo '<table class="impresslist" >';
foreach ($_['list'] as $entry) {
echo '<tr><td width="1"><a target="_blank" href="' . \OCP\Util::linkToAbsolute('impress', 'player.php') . '&file=' . urlencode($entry['url']) . '&name=' . urlencode($entry['name']) . '"><img align="left" src="' . \OCP\Util::linkToAbsolute('impress', 'img/impressbig.png') . '"></a></td><td><a target="_blank" href="' . \OCP\Util::linkToAbsolute('impress', 'player.php') . '&file=' . urlencode($entry['url']) . '&name=' . urlencode($entry['name']) . '">' . $entry['name'] . '</a></td><td>' . \OCP\Util::formatDate($entry['mtime']) . '</td><td>' . \OCP\Util::humanFileSize($entry['size']) . '</td></tr>';
}
echo '</table>';
}
示例14: index
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function index()
{
$wopiRemote = $this->appConfig->getAppValue('wopi_url');
if (($parts = parse_url($wopiRemote)) && isset($parts['scheme']) && isset($parts['host'])) {
$webSocketProtocol = "ws://";
if ($parts['scheme'] == "https") {
$webSocketProtocol = "wss://";
}
$webSocket = sprintf("%s%s%s", $webSocketProtocol, $parts['host'], isset($parts['port']) ? ":" . $parts['port'] : "");
} else {
return $this->responseError($this->l10n->t('Collabora Online: Invalid URL "%s".', array($wopiRemote)), $this->l10n->t('Please ask your administrator to check the Collabora Online server setting.'));
}
\OC::$server->getNavigationManager()->setActiveEntry('richdocuments_index');
$maxUploadFilesize = \OCP\Util::maxUploadFilesize("/");
$response = new TemplateResponse('richdocuments', 'documents', ['enable_previews' => $this->settings->getSystemValue('enable_previews', true), 'uploadMaxFilesize' => $maxUploadFilesize, 'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize), 'allowShareWithLink' => $this->settings->getAppValue('core', 'shareapi_allow_links', 'yes'), 'wopi_url' => $webSocket]);
$policy = new ContentSecurityPolicy();
$policy->addAllowedScriptDomain('\'self\' http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js http://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js \'unsafe-eval\' ' . $wopiRemote);
/* frame-src is deprecated on Firefox, but Safari wants it! */
$policy->addAllowedFrameDomain('\'self\' http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js http://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js \'unsafe-eval\' ' . $wopiRemote);
$policy->addAllowedChildSrcDomain('\'self\' http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js http://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js \'unsafe-eval\' ' . $wopiRemote);
$policy->addAllowedConnectDomain($webSocket);
$policy->addAllowedImageDomain('*');
$policy->allowInlineScript(true);
$policy->addAllowedFontDomain('data:');
$response->setContentSecurityPolicy($policy);
return $response;
}
示例15: showShare
/**
* @PublicPage
* @NoCSRFRequired
*
* @param string $token
* @param string $path
* @return TemplateResponse|RedirectResponse
*/
public function showShare($token, $path = '')
{
\OC_User::setIncognitoMode(true);
// Check whether share exists
$linkItem = Share::getShareByToken($token, false);
if ($linkItem === false) {
return new NotFoundResponse();
}
$shareOwner = $linkItem['uid_owner'];
$originalSharePath = $this->getPath($token);
// Share is password protected - check whether the user is permitted to access the share
if (isset($linkItem['share_with']) && !Helper::authenticate($linkItem)) {
return new RedirectResponse($this->urlGenerator->linkToRoute('files_sharing.sharecontroller.authenticate', array('token' => $token)));
}
if (Filesystem::isReadable($originalSharePath . $path)) {
$getPath = Filesystem::normalizePath($path);
$originalSharePath .= $path;
} else {
throw new OCP\Files\NotFoundException();
}
$file = basename($originalSharePath);
$shareTmpl = [];
$shareTmpl['displayName'] = User::getDisplayName($shareOwner);
$shareTmpl['filename'] = $file;
$shareTmpl['directory_path'] = $linkItem['file_target'];
$shareTmpl['mimetype'] = Filesystem::getMimeType($originalSharePath);
$shareTmpl['previewSupported'] = \OC::$server->getPreviewManager()->isMimeSupported($shareTmpl['mimetype']);
$shareTmpl['dirToken'] = $linkItem['token'];
$shareTmpl['sharingToken'] = $token;
$shareTmpl['server2serversharing'] = Helper::isOutgoingServer2serverShareEnabled();
$shareTmpl['protected'] = isset($linkItem['share_with']) ? 'true' : 'false';
$shareTmpl['dir'] = '';
$nonHumanFileSize = \OC\Files\Filesystem::filesize($originalSharePath);
$shareTmpl['nonHumanFileSize'] = $nonHumanFileSize;
$shareTmpl['fileSize'] = \OCP\Util::humanFileSize($nonHumanFileSize);
// Show file list
if (Filesystem::is_dir($originalSharePath)) {
$shareTmpl['dir'] = $getPath;
$maxUploadFilesize = Util::maxUploadFilesize($originalSharePath);
$freeSpace = Util::freeSpace($originalSharePath);
$uploadLimit = Util::uploadLimit();
$folder = new Template('files', 'list', '');
$folder->assign('dir', $getPath);
$folder->assign('dirToken', $linkItem['token']);
$folder->assign('permissions', \OCP\Constants::PERMISSION_READ);
$folder->assign('isPublic', true);
$folder->assign('publicUploadEnabled', 'no');
$folder->assign('uploadMaxFilesize', $maxUploadFilesize);
$folder->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
$folder->assign('freeSpace', $freeSpace);
$folder->assign('uploadLimit', $uploadLimit);
// PHP upload limit
$folder->assign('usedSpacePercent', 0);
$folder->assign('trash', false);
$shareTmpl['folder'] = $folder->fetchPage();
}
$shareTmpl['downloadURL'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.downloadShare', array('token' => $token));
$shareTmpl['maxSizeAnimateGif'] = $this->config->getSystemValue('max_filesize_animated_gifs_public_sharing', 10);
$csp = new OCP\AppFramework\Http\ContentSecurityPolicy();
$csp->addAllowedFrameDomain('\'self\'');
$response = new TemplateResponse($this->appName, 'public', $shareTmpl, 'base');
$response->setContentSecurityPolicy($csp);
return $response;
}