Blame view

sources/apps/activity/lib/display.php 2.53 KB
6d9380f96   Cédric Dupont   Update sources OC...
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
  <?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
  {
  	/**
  	 * 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();
  	}
  }