2014-06-04 14:29:42 +04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ownCloud - Activity App
|
|
|
|
*
|
|
|
|
* @author Joas Schilling
|
|
|
|
* @copyright 2014 Joas Schilling nickvergessen@owncloud.com
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 3 of the License, or any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OCA\Activity;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class Display
|
|
|
|
*
|
|
|
|
* @package OCA\Activity
|
|
|
|
*/
|
|
|
|
class Display
|
|
|
|
{
|
|
|
|
/**
|
2014-06-04 14:37:57 +04:00
|
|
|
* 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
|
2014-06-04 14:29:42 +04:00
|
|
|
*/
|
2014-06-04 14:37:57 +04:00
|
|
|
public static function show($activity) {
|
2014-06-04 14:29:42 +04:00
|
|
|
$tmpl = new \OCP\Template('activity', 'activity.box');
|
2014-06-04 14:37:57 +04:00
|
|
|
$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']));
|
2014-06-11 15:02:22 +04:00
|
|
|
|
|
|
|
if ($activity['app'] === 'files') {
|
|
|
|
// We do not link the subject as we create links for the parameters instead
|
|
|
|
$activity['link'] = '';
|
|
|
|
}
|
|
|
|
|
2014-06-04 14:37:57 +04:00
|
|
|
$tmpl->assign('event', $activity);
|
2014-06-04 14:29:42 +04:00
|
|
|
|
2014-07-02 17:16:40 +04:00
|
|
|
if ($activity['file']) {
|
|
|
|
$rootView = new \OC\Files\View('');
|
2014-06-04 14:37:57 +04:00
|
|
|
$exist = $rootView->file_exists('/' . $activity['user'] . '/files' . $activity['file']);
|
|
|
|
$is_dir = $rootView->is_dir('/' . $activity['user'] . '/files' . $activity['file']);
|
2014-06-04 14:29:42 +04:00
|
|
|
unset($rootView);
|
|
|
|
|
|
|
|
// show a preview image if the file still exists
|
|
|
|
if (!$is_dir && $exist) {
|
2014-06-04 14:37:57 +04:00
|
|
|
$tmpl->assign('previewLink', \OCP\Util::linkTo('files', 'index.php', array('dir' => dirname($activity['file']))));
|
2014-06-04 14:29:42 +04:00
|
|
|
$tmpl->assign('previewImageLink',
|
|
|
|
\OCP\Util::linkToRoute('core_ajax_preview', array(
|
2014-06-04 14:37:57 +04:00
|
|
|
'file' => $activity['file'],
|
2014-06-04 14:29:42 +04:00
|
|
|
'x' => 150,
|
|
|
|
'y' => 150,
|
|
|
|
))
|
|
|
|
);
|
|
|
|
} else if ($exist) {
|
2014-07-13 10:55:35 +04:00
|
|
|
$tmpl->assign('previewLink', \OCP\Util::linkTo('files', 'index.php', array('dir' => $activity['file'])));
|
2014-06-04 14:29:42 +04:00
|
|
|
$tmpl->assign('previewImageLink', \OC_Helper::mimetypeIcon('dir'));
|
|
|
|
$tmpl->assign('previewLinkIsDir', true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-04 14:37:57 +04:00
|
|
|
return $tmpl->fetchPage();
|
2014-06-04 14:29:42 +04:00
|
|
|
}
|
|
|
|
}
|