Example #1
0
 /**
  * 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();
 }
Example #2
0
 /**
  * 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();
 }
Example #3
0
 private function getRelativeTime($timeString)
 {
     // ToDo what about relative time?
     $datetime = new \DateTime($timeString);
     $time = $datetime->getTimestamp() + $datetime->getOffset();
     if (function_exists('\\OCP\\relative_modified_date')) {
         $time = \OCP\relative_modified_date($time);
     } else {
         $time = $this->l10n->l('datetime', $time);
     }
     return $time;
 }
Example #4
0
<div class="ocDashboard calendar items">

	<?php 
foreach ($additionalparams['activitys'] as $activity) {
    print_unescaped("<div class='priority" . $activity['priority'] . " activity-entry'>\n                <a href='" . $activity["link"] . "' title='" . $activity['subject'] . "'>" . \OC_Util::sanitizeHTML(getNiceSmallText($activity['subject'])) . "</a><br /><span> " . \OCP\relative_modified_date(date("U", strtotime($activity['date']))) . "</span>\n            </div>\n        ");
}
?>
		
		
</div>


<?php 
function getNiceSmallText($string)
{
    $maxStringLen = 40;
    $startStringLen = 5;
    $return = "";
    if (strlen($string) >= $maxStringLen) {
        $lastCharacter = -1 * ($maxStringLen - $startStringLen);
        $return = substr($string, 0, $startStringLen);
        $return .= "...";
        $return .= substr($string, $lastCharacter);
    } else {
        $return = $string;
    }
    return $return;
}
Example #5
0
 /**
  * @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="******"></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
 }
Example #6
0
foreach ($items as $item) {
    if ($item->isRead()) {
        $newsItemClass = "read";
    } else {
        $newsItemClass = "";
    }
    if ($item->isImportant()) {
        $starClass = 'important';
        $startTitle = $l->t('Mark as unimportant');
    } else {
        $starClass = '';
        $startTitle = $l->t('Mark as important');
    }
    echo '<li class="feed_item ' . $newsItemClass . '" data-id="' . $item->getId() . '" data-feedid="' . $item->getFeedId() . '">';
    echo '<span class="timestamp">' . $item->getDate() . '</span>';
    $relative_modified_date = OCP\relative_modified_date($item->getDate());
    echo '<h2 class="item_date"><time class="timeago" datetime="' . date('c', $item->getDate()) . '">' . $relative_modified_date . '</time>' . '</h2>';
    echo '<div class="utils">';
    echo '<ul class="primary_item_utils">';
    echo '<li class="star ' . $starClass . '" title="' . $startTitle . '"></li>';
    echo '</ul>';
    echo '</div>';
    echo '<h1 class="item_title"><a target="_blank" href="' . $item->getUrl() . '">' . htmlspecialchars($item->getTitle(), ENT_QUOTES, 'UTF-8') . '</a></h1>';
    if ((int) $lastViewedFeedType !== OCA\News\FeedType::FEED) {
        $feedTitle = $l->t('from') . ' ' . '<a href="#" class="from_feed"> ' . $item->getFeedTitle() . '</a> ';
    } else {
        $feedTitle = '';
    }
    if ($item->getAuthor() !== null && trim($item->getAuthor()) !== '') {
        $author = $l->t('by') . ' ' . htmlspecialchars($item->getAuthor(), ENT_QUOTES, 'UTF-8');
    } else {
Example #7
0
<input type="hidden" id="disableSharing" data-status="<?php 
p($_['disableSharing']);
?>
">

<?php 
foreach ($_['files'] as $file) {
    $simple_file_size = OCP\simple_file_size($file['size']);
    // the bigger the file, the darker the shade of grey; megabytes*2
    $simple_size_color = intval(200 - $file['size'] / (1024 * 1024) * 2);
    if ($simple_size_color < 0) {
        $simple_size_color = 0;
    }
    $relative_modified_date = OCP\relative_modified_date($file['mtime']);
    // the older the file, the brighter the shade of grey; days*14
    $relative_date_color = round((time() - $file['mtime']) / 60 / 60 / 24 * 14);
    if ($relative_date_color > 200) {
        $relative_date_color = 200;
    }
    $name = str_replace('+', '%20', urlencode($file['name']));
    $name = str_replace('%2F', '/', $name);
    $directory = str_replace('+', '%20', urlencode($file['directory']));
    $directory = str_replace('%2F', '/', $directory);
    ?>
	<tr data-id="<?php 
    p($file['fileid']);
    ?>
"
		data-file="<?php 
    p($name);
    ?>
Example #8
0
<input type="hidden" id="disableSharing" data-status="<?php 
p($_['disableSharing']);
?>
">
<?php 
foreach ($_['files'] as $file) {
    $relative_deleted_date = OCP\relative_modified_date($file['timestamp']);
    // the older the file, the brighter the shade of grey; days*14
    $relative_date_color = round((time() - $file['date']) / 60 / 60 / 24 * 14);
    if ($relative_date_color > 200) {
        $relative_date_color = 200;
    }
    $name = str_replace('+', '%20', urlencode($file['name']));
    $name = str_replace('%2F', '/', $name);
    $directory = str_replace('+', '%20', urlencode($file['directory']));
    $directory = str_replace('%2F', '/', $directory);
    ?>
	<tr data-filename="<?php 
    p($file['name']);
    ?>
"
		data-type="<?php 
    $file['type'] == 'dir' ? p('dir') : p('file');
    ?>
"
		data-mime="<?php 
    p($file['mimetype']);
    ?>
"
		data-permissions='<?php 
    p($file['permissions']);
Example #9
0
 * 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 Affero General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
/** @var $l OC_L10N */
/** @var $theme OC_Defaults */
/** @var $_ array */
$lastDate = null;
foreach ($_['activity'] as $event) {
    // group by date
    // TODO: use more efficient way to group by date (don't group by localized string...)
    $currentDate = (string) \OCP\relative_modified_date($event['timestamp'], true);
    // new date group
    if ($currentDate !== $lastDate) {
        // not first date group ?
        if ($lastDate !== null) {
            ?>
	</div>
</div>

<?php 
        }
        $lastDate = $currentDate;
        ?>
<div class="section activity-section group" data-date="<?php 
        p($currentDate);
        ?>