本文整理汇总了PHP中OCP\Util::formatDate方法的典型用法代码示例。如果您正苦于以下问题:PHP Util::formatDate方法的具体用法?PHP Util::formatDate怎么用?PHP Util::formatDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCP\Util
的用法示例。
在下文中一共展示了Util::formatDate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
/**
* Get the template for a specific activity-event in the activities
*
* @param array $activity An array with all the activity data in it
* @return string
*/
public static function show($activity)
{
$tmpl = new Template('activity', 'activity.box');
$tmpl->assign('formattedDate', Util::formatDate($activity['timestamp']));
$tmpl->assign('formattedTimestamp', \OCP\relative_modified_date($activity['timestamp']));
$tmpl->assign('user', $activity['user']);
$tmpl->assign('displayName', User::getDisplayName($activity['user']));
if (strpos($activity['subjectformatted']['markup']['trimmed'], '<a ') !== false) {
// We do not link the subject as we create links for the parameters instead
$activity['link'] = '';
}
$tmpl->assign('event', $activity);
if ($activity['file']) {
$rootView = new View('/' . $activity['affecteduser'] . '/files');
$exist = $rootView->file_exists($activity['file']);
$is_dir = $rootView->is_dir($activity['file']);
unset($rootView);
// show a preview image if the file still exists
$mimetype = \OC_Helper::getFileNameMimeType($activity['file']);
if (!$is_dir && \OC::$server->getPreviewManager()->isMimeSupported($mimetype) && $exist) {
$tmpl->assign('previewLink', Util::linkTo('files', 'index.php', array('dir' => dirname($activity['file']))));
$tmpl->assign('previewImageLink', Util::linkToRoute('core_ajax_preview', array('file' => $activity['file'], 'x' => 150, 'y' => 150)));
} else {
$tmpl->assign('previewLink', Util::linkTo('files', 'index.php', array('dir' => $activity['file'])));
$tmpl->assign('previewImageLink', \OC_Helper::mimetypeIcon($is_dir ? 'dir' : $mimetype));
$tmpl->assign('previewLinkIsDir', true);
}
}
return $tmpl->fetchPage();
}
示例2: show
/**
* Get the template for a specific activity-event in the activities
*
* @param array $activity An array with all the activity data in it
* @param return string
*/
public static function show($activity)
{
$tmpl = new \OCP\Template('activity', 'activity.box');
$tmpl->assign('formattedDate', \OCP\Util::formatDate($activity['timestamp']));
$tmpl->assign('formattedTimestamp', \OCP\relative_modified_date($activity['timestamp']));
$tmpl->assign('user', $activity['user']);
$tmpl->assign('displayName', \OCP\User::getDisplayName($activity['user']));
if ($activity['app'] === 'files') {
// We do not link the subject as we create links for the parameters instead
$activity['link'] = '';
}
$tmpl->assign('event', $activity);
if ($activity['file']) {
$rootView = new \OC\Files\View('');
$exist = $rootView->file_exists('/' . $activity['user'] . '/files' . $activity['file']);
$is_dir = $rootView->is_dir('/' . $activity['user'] . '/files' . $activity['file']);
unset($rootView);
// show a preview image if the file still exists
if (!$is_dir && $exist) {
$tmpl->assign('previewLink', \OCP\Util::linkTo('files', 'index.php', array('dir' => dirname($activity['file']))));
$tmpl->assign('previewImageLink', \OCP\Util::linkToRoute('core_ajax_preview', array('file' => $activity['file'], 'x' => 150, 'y' => 150)));
} else {
if ($exist) {
$tmpl->assign('previewLink', \OCP\Util::linkTo('files', 'index.php', array('dir' => $activity['file'])));
$tmpl->assign('previewImageLink', \OC_Helper::mimetypeIcon('dir'));
$tmpl->assign('previewLinkIsDir', true);
}
}
}
return $tmpl->fetchPage();
}
示例3: testGetFilesByTagMultiple
public function testGetFilesByTagMultiple()
{
$tagName = 'MyTagName';
$fileInfo1 = new FileInfo('/root.txt', $this->getMockBuilder('\\OC\\Files\\Storage\\Storage')->disableOriginalConstructor()->getMock(), '/var/www/root.txt', ['mtime' => 55, 'mimetype' => 'application/pdf', 'size' => 1234, 'etag' => 'MyEtag'], $this->getMockBuilder('\\OCP\\Files\\Mount\\IMountPoint')->disableOriginalConstructor()->getMock());
$fileInfo2 = new FileInfo('/root.txt', $this->getMockBuilder('\\OC\\Files\\Storage\\Storage')->disableOriginalConstructor()->getMock(), '/var/www/some/sub.txt', ['mtime' => 999, 'mimetype' => 'application/binary', 'size' => 9876, 'etag' => 'SubEtag'], $this->getMockBuilder('\\OCP\\Files\\Mount\\IMountPoint')->disableOriginalConstructor()->getMock());
$this->tagService->expects($this->once())->method('getFilesByTag')->with($this->equalTo([$tagName]))->will($this->returnValue([$fileInfo1, $fileInfo2]));
$expected = new DataResponse(['files' => [['id' => null, 'parentId' => null, 'date' => \OCP\Util::formatDate(55), 'mtime' => 55000, 'icon' => \OCA\Files\Helper::determineIcon($fileInfo1), 'name' => 'root.txt', 'permissions' => null, 'mimetype' => 'application/pdf', 'size' => 1234, 'type' => 'file', 'etag' => 'MyEtag', 'path' => '/', 'tags' => [['MyTagName']]], ['id' => null, 'parentId' => null, 'date' => \OCP\Util::formatDate(999), 'mtime' => 999000, 'icon' => \OCA\Files\Helper::determineIcon($fileInfo2), 'name' => 'root.txt', 'permissions' => null, 'mimetype' => 'application/binary', 'size' => 9876, 'type' => 'file', 'etag' => 'SubEtag', 'path' => '/', 'tags' => [['MyTagName']]]]]);
$this->assertEquals($expected, $this->apiController->getFilesByTag([$tagName]));
}
示例4: search
/**
* @brief Search in the activities and return search results
* @param $query
* @return search results
*/
function search($query)
{
$data = Data::search($query, 100);
$results = array();
foreach ($data as $d) {
$file = $d['file'];
$results[] = new \OC_Search_Result(basename($file), $d['subject'] . ' (' . \OCP\Util::formatDate($d['timestamp']) . ')', \OC_Helper::linkTo('activity', 'index.php'), 'Activity');
}
return $results;
}
示例5: getTrashFiles
/**
* Retrieves the contents of a trash bin directory.
* @param string $dir path to the directory inside the trashbin
* or empty to retrieve the root of the trashbin
* @return array of files
*/
public static function getTrashFiles($dir)
{
$result = array();
$user = \OCP\User::getUser();
if ($dir && $dir !== '/') {
$view = new \OC_Filesystemview('/' . $user . '/files_trashbin/files');
$dirContent = $view->opendir($dir);
if ($dirContent === false) {
return null;
}
if (is_resource($dirContent)) {
while (($entryName = readdir($dirContent)) !== false) {
if (!\OC\Files\Filesystem::isIgnoredDir($entryName)) {
$pos = strpos($dir . '/', '/', 1);
$tmp = substr($dir, 0, $pos);
$pos = strrpos($tmp, '.d');
$timestamp = substr($tmp, $pos + 2);
$result[] = array('id' => $entryName, 'timestamp' => $timestamp, 'mime' => $view->getMimeType($dir . '/' . $entryName), 'type' => $view->is_dir($dir . '/' . $entryName) ? 'dir' : 'file', 'location' => $dir);
}
}
closedir($dirContent);
}
} else {
$query = \OC_DB::prepare('SELECT `id`,`location`,`timestamp`,`type`,`mime` FROM `*PREFIX*files_trash` WHERE `user` = ?');
$result = $query->execute(array($user))->fetchAll();
}
$files = array();
$id = 0;
foreach ($result as $r) {
$i = array();
$i['id'] = $id++;
$i['name'] = $r['id'];
$i['date'] = \OCP\Util::formatDate($r['timestamp']);
$i['timestamp'] = $r['timestamp'];
$i['etag'] = $i['timestamp'];
// dummy etag
$i['mimetype'] = $r['mime'];
$i['type'] = $r['type'];
if ($i['type'] === 'file') {
$fileinfo = pathinfo($r['id']);
$i['basename'] = $fileinfo['filename'];
$i['extension'] = isset($fileinfo['extension']) ? '.' . $fileinfo['extension'] : '';
}
$i['directory'] = $r['location'];
if ($i['directory'] === '/') {
$i['directory'] = '';
}
$i['permissions'] = \OCP\PERMISSION_READ;
$i['isPreviewAvailable'] = \OC::$server->getPreviewManager()->isMimeSupported($r['mime']);
$i['icon'] = \OCA\Files\Helper::determineIcon($i);
$files[] = $i;
}
usort($files, array('\\OCA\\Files\\Helper', 'fileCmp'));
return $files;
}
示例6: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$dui = new DeletedUsersIndex(new \OC\Preferences(\OC_DB::getConnection()), \OC::$server->getDatabaseConnection(), $this->getAccess());
/** @var \Symfony\Component\Console\Helper\Table $table */
$table = $this->getHelperSet()->get('table');
$table->setHeaders(array('ownCloud name', 'Display Name', 'LDAP UID', 'LDAP DN', 'Last Login', 'Dir', 'Sharer'));
$rows = array();
$offset = 0;
do {
$resultSet = $dui->getUsers($offset);
$offset += count($resultSet);
foreach ($resultSet as $user) {
$hAS = $user->getHasActiveShares() ? 'Y' : 'N';
$lastLogin = $user->getLastLogin() > 0 ? \OCP\Util::formatDate($user->getLastLogin()) : '-';
$rows[] = array($user->getOCName(), $user->getDisplayName(), $user->getUid(), $user->getDN(), $lastLogin, $user->getHomePath(), $hAS);
}
} while (count($resultSet) === 10);
$table->setRows($rows);
$table->render($output);
}
示例7: getFiles
/**
* Retrieves the contents of the given directory and
* returns it as a sorted array.
* @param string $dir path to the directory
* @return array of files
*/
public static function getFiles($dir)
{
$content = \OC\Files\Filesystem::getDirectoryContent($dir);
$files = array();
foreach ($content as $i) {
$i['date'] = \OCP\Util::formatDate($i['mtime']);
if ($i['type'] === 'file') {
$fileinfo = pathinfo($i['name']);
$i['basename'] = $fileinfo['filename'];
if (!empty($fileinfo['extension'])) {
$i['extension'] = '.' . $fileinfo['extension'];
} else {
$i['extension'] = '';
}
}
$i['directory'] = $dir;
$i['isPreviewAvailable'] = \OC::$server->getPreviewManager()->isMimeSupported($i['mimetype']);
$i['icon'] = \OCA\Files\Helper::determineIcon($i);
$files[] = $i;
}
usort($files, array('\\OCA\\Files\\Helper', 'fileCmp'));
return $files;
}
示例8: show
/**
* @brief Show a specific event in the activities
* @param array $event An array with all the event data in it
*/
public static function show($event)
{
$l = \OC_L10N::get('lib');
$user = $event['user'];
if (!isset($event['isGrouped'])) {
$event['isGrouped'] = false;
}
$formattedDate = \OCP\Util::formatDate($event['timestamp']);
$formattedTimestamp = \OCP\relative_modified_date($event['timestamp']);
$displayName = \OCP\User::getDisplayName($user);
// TODO: move into template?
echo '<div class="box">';
echo '<div class="header">';
echo '<span class="avatar" data-user="' . \OC_Util::sanitizeHTML($user) . '"></span>';
echo '<span>';
echo '<span class="user">' . \OC_Util::sanitizeHTML($displayName) . '</span>';
echo '<span class="activitytime tooltip" title="' . \OC_Util::sanitizeHTML($formattedDate) . '">' . \OC_Util::sanitizeHTML($formattedTimestamp) . '</span>';
echo '<span class="appname">' . \OC_Util::sanitizeHTML($event['app']) . '</span>';
echo '</span>';
echo '</div>';
echo '<div class="messagecontainer">';
if ($event['isGrouped']) {
$count = 0;
echo '<ul class="activitysubject grouped">';
foreach ($event['events'] as $subEvent) {
echo '<li>';
if ($subEvent['link'] != '') {
echo '<a href="' . $subEvent['link'] . '">';
}
echo \OC_Util::sanitizeHTML($subEvent['subject']);
if ($subEvent['link'] != '') {
echo '</a>';
}
echo '</li>';
$count++;
if ($count > 5) {
echo '<li class="more">' . $l->n('%n more...', '%n more...', count($event['events']) - $count) . '</li>';
break;
}
}
echo '</ul>';
} else {
if ($event['link'] != '') {
echo '<a href="' . $event['link'] . '">';
}
echo '<div class="activitysubject">' . \OC_Util::sanitizeHTML($event['subject']) . '</div>';
echo '<div class="activitymessage">' . \OC_Util::sanitizeHTML($event['message']) . '</div>';
}
$rootView = new \OC\Files\View('');
if ($event['file'] !== null) {
$exist = $rootView->file_exists('/' . $user . '/files' . $event['file']);
unset($rootView);
// show a preview image if the file still exists
if ($exist) {
echo '<img class="preview" src="' . \OCP\Util::linkToRoute('core_ajax_preview', array('file' => $event['file'], 'x' => 150, 'y' => 150)) . '" />';
}
}
if (!$event['isGrouped'] && $event['link'] != '') {
echo '</a>';
}
echo '</div>';
// end messagecontainer
echo '</div>';
// end box
}
示例9: foreach
} else {
foreach ($mounts as $mountkey => $mount) {
if ($file['storage'] == $mount['storage_id']) {
$newdir = substr($mountkey, strrpos($mountkey, '/'));
if (substr($file['path'], 0, strrpos($file['path'], '/')) != "") {
$files[$key]['path'] = $newdir . '/' . substr($file['path'], 0, strrpos($file['path'], '/'));
} else {
$files[$key]['path'] = $newdir;
}
}
}
}
unset($files[$key]['storage']);
//unset($files[$key]['fileid']);
$files[$key]['type'] = 'file';
$files[$key]['date'] = \OCP\Util::formatDate($file['storage_mtime']);
unset($files[$key]['storage_mtime']);
$files[$key]['mtime'] = $file['mtime'] * 1000;
$files[$key]['parentId'] = $file['parent'];
unset($files[$key]['parent']);
$files[$key]['permissions'] = (int) $file['permissions'];
}
}
if (empty($files)) {
$data['directory'] = $dir;
$data['files'] = $files;
//\OCA\Files\Helper::formatFileInfos($files);
$data['permissions'] = (int) $permissions;
OCP\JSON::success(array('data' => $data));
die("所查询文件类型不存在");
}
示例10: getListArray
public function getListArray()
{
$data = [];
$data['id'] = $this->getUid();
$data['from'] = $this->getFrom();
$data['fromEmail'] = $this->getFromEmail();
$data['fromList'] = $this->getFromList();
$data['to'] = $this->getTo();
$data['toEmail'] = $this->getToEmail();
$data['toList'] = $this->getToList();
$data['subject'] = $this->getSubject();
$data['date'] = Util::formatDate($this->getSentDate()->format('U'));
$data['size'] = Util::humanFileSize($this->getSize());
$data['flags'] = $this->getFlags();
$data['dateInt'] = $this->getSentDate()->getTimestamp();
$data['dateIso'] = $this->getSentDate()->format('c');
$data['ccList'] = $this->getCCList();
return $data;
}
示例11: array
* [size] => 3981786
* [mtime] => 1388521137
* [storage_mtime] => 1388521137
* [encrypted] => 1
* [unencrypted_size] => 3981786
* [etag] => 52c326b169ba4
* [permissions] => 27 )
*/
$fileInfos = \OC\Files\Filesystem::getFileInfo($filePath);
$thumbPath = OCP\Util::linkToAbsolute('oclife', 'getThumbnail.php', array('filePath' => $filePath));
$preview = '<img style="border: 1px solid black; display: block;" src="' . $thumbPath . '" />';
$infos = array();
$infos[] = '<strong>' . $l->t('File name') . ': </strong>' . $fileInfos['name'];
$infos[] = '<strong>MIME: </strong>' . $fileInfos['mimetype'];
$infos[] = '<strong>' . $l->t('Size') . ': </strong>' . \OCA\OCLife\utilities::formatBytes($fileInfos['size'], 2, TRUE);
$infos[] = '<strong>' . $l->t('When added') . ': </strong>' . \OCP\Util::formatDate($fileInfos['storage_mtime']);
$infos[] = '<strong>' . $l->t('Encrypted? ') . '</strong>' . ($fileInfos['encrypted'] === TRUE ? $l->t('Yes') : $l->t('No'));
if ($fileInfos['encrypted']) {
$infos[] = '<strong>' . $l->t('Unencrypted size') . ': </strong>' . \OCA\OCLife\utilities::formatBytes($fileInfos['unencrypted_size'], 2, TRUE);
}
// Output basic infos
$htmlInfos = implode('<br />', $infos);
// Check for EXIF data
// Get current user
$user = \OCP\User::getUser();
$viewPath = '/' . $user . '/files';
$view = new \OC\Files\View($viewPath);
$imageLocalPath = $view->getLocalFile($filePath);
$exifHandler = new OCA\OCLife\exifHandler($imageLocalPath);
$allInfos = $exifHandler->getExifData();
$ifd0Infos = isset($allInfos['IFD0']) ? $allInfos['IFD0'] : array();
示例12: array
if ($lastDate !== null) {
// output box group
if (count($eventsInGroup) > 0) {
\OCA\Activity\Data::show(makeEventGroup($eventsInGroup));
}
$eventsInGroup = array();
$lastGroup = null;
// close previous date group
echo '</div>';
// boxcontainer
echo '</div>';
// date group
}
$lastDate = $currentDate;
echo '<div class="group" data-date="' . $currentDate . '">';
echo '<div class="groupheader"><span class="tooltip" title="' . \OCP\Util::formatDate(strip_time($event['timestamp']), true) . '">' . ucfirst($currentDate) . '</span></div>';
echo '<div class="boxcontainer">';
}
$currentGroup = makeGroupKey($event);
// new box group
if ($lastGroup !== $currentGroup) {
if ($lastGroup !== null) {
// create meta event and add it to the list
\OCA\Activity\Data::show(makeEventGroup($eventsInGroup));
$eventsInGroup = array();
}
$lastGroup = $currentGroup;
}
$eventsInGroup[] = $event;
}
// show last group
示例13: formatFileInfo
/**
* Formats the file info to be returned as JSON to the client.
*
* @param \OCP\Files\FileInfo $i
* @return array formatted file info
*/
public static function formatFileInfo(FileInfo $i)
{
$entry = array();
$entry['id'] = $i['fileid'];
$entry['parentId'] = $i['parent'];
$entry['date'] = \OCP\Util::formatDate($i['mtime']);
$entry['mtime'] = $i['mtime'] * 1000;
// only pick out the needed attributes
$entry['icon'] = \OCA\Files\Helper::determineIcon($i);
if (\OC::$server->getPreviewManager()->isAvailable($i)) {
$entry['isPreviewAvailable'] = true;
}
$entry['name'] = $i->getName();
$entry['permissions'] = $i['permissions'];
$entry['mimetype'] = $i['mimetype'];
$entry['size'] = $i['size'];
$entry['type'] = $i['type'];
$entry['etag'] = $i['etag'];
//$entry['mount'] = $i->getStorage()->getId();
$query = \OC_DB::prepare('SELECT `uid_owner`
FROM
`*PREFIX*share`
WHERE
`item_source` = ?');
$result = $query->execute(array($entry['id']));
if (\OCP\DB::isError($result)) {
\OCP\Util::writeLog('OCP\\Share', \OC_DB::getErrorMessage(), \OC_Log::ERROR);
} else {
while ($row = $result->fetchRow()) {
$entry['owner'] = $row['uid_owner'];
}
}
if (isset($i['tags'])) {
$entry['tags'] = $i['tags'];
}
if (isset($i['displayname_owner'])) {
$entry['shareOwner'] = $i['displayname_owner'];
$query = \OC_DB::prepare('SELECT `directory_uuid`
FROM
`*PREFIX*ldap_user_mapping`
WHERE
`ldap_dn` LIKE LOWER("cn="?"%")');
$result = $query->execute(array($entry['shareOwner']));
if (\OCP\DB::isError($result)) {
\OCP\Util::writeLog('OCP\\Share', \OC_DB::getErrorMessage(), \OC_Log::ERROR);
if ($entry['shareOwner'] == 'admin') {
$entry['storage'] = 'admin';
}
} else {
while ($row = $result->fetchRow()) {
$entry['storage'] = $row['directory_uuid'];
}
if ($entry['shareOwner'] == 'admin') {
$entry['storage'] = 'admin';
}
}
}
if (isset($i['is_share_mount_point'])) {
$entry['isShareMountPoint'] = $i['is_share_mount_point'];
}
$mountType = null;
if ($i->isShared()) {
$mountType = 'shared';
} else {
if ($i->isMounted()) {
$mountType = 'external';
}
}
if ($mountType !== null) {
if ($i->getInternalPath() === '') {
$mountType .= '-root';
}
$entry['mountType'] = $mountType;
}
if (isset($i['extraData'])) {
$entry['extraData'] = $i['extraData'];
}
return $entry;
}
示例14: isset
<?php
/**
* ownCloud - Updater plugin
*
* @author Victor Dubiniuk
* @copyright 2015 Victor Dubiniuk victor.dubiniuk@gmail.com
*
* This file is licensed under the Affero General Public License version 3 or
* later.
*/
namespace OCA\Updater;
\OCP\JSON::checkAdminUser();
\OCP\JSON::callCheck();
$newChannel = isset($_POST['newChannel']) ? $_POST['newChannel'] : false;
if ($newChannel) {
App::flushCache();
$channel = Channel::setCurrentChannel($newChannel);
if ($channel) {
$data = App::getFeed();
$lastCheck = \OC_Appconfig::getValue('core', 'lastupdatedat');
$data['checkedAt'] = \OCP\Util::formatDate($lastCheck);
$data['channel'] = $channel;
$data['data']['message'] = '';
\OCP\JSON::success($data);
} else {
\OCP\JSON::error(['data' => ['message' => App::$l10n->t('Unable to switch channel.')]]);
}
}
示例15: 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>';
}