Ejemplo n.º 1
0
 /**
  * @param string $path
  * @param bool $isDir
  * @return string
  */
 protected function getPreviewLink($path, $isDir)
 {
     if ($isDir) {
         return $this->urlGenerator->linkTo('files', 'index.php', array('dir' => $path));
     } else {
         $parentDir = substr_count($path, '/') === 1 ? '/' : dirname($path);
         $fileName = basename($path);
         return $this->urlGenerator->linkTo('files', 'index.php', array('dir' => $parentDir, 'scrollto' => $fileName));
     }
 }
 /**
  * Prepares a file parameter for usage
  *
  * Removes the path from filenames and adds highlights
  *
  * @param string $param
  * @param bool $stripPath Shall we remove the path from the filename
  * @param bool $highlightParams
  * @return string
  */
 protected function prepareFileParam($param, $stripPath, $highlightParams)
 {
     $param = $this->fixLegacyFilename($param);
     $is_dir = $this->rootView->is_dir('/' . $this->user . '/files' . $param);
     if ($is_dir) {
         $linkData = ['dir' => $param];
     } else {
         $parentDir = substr_count($param, '/') === 1 ? '/' : dirname($param);
         $fileName = basename($param);
         $linkData = ['dir' => $parentDir, 'scrollto' => $fileName];
     }
     $fileLink = $this->urlGenerator->linkTo('files', 'index.php', $linkData);
     $param = trim($param, '/');
     list($path, $name) = $this->splitPathFromFilename($param);
     if (!$stripPath || $path === '') {
         if (!$highlightParams) {
             return $param;
         }
         return '<a class="filename" href="' . $fileLink . '">' . Util::sanitizeHTML($param) . '</a>';
     }
     if (!$highlightParams) {
         return $name;
     }
     $title = ' title="' . $this->l->t('in %s', array(Util::sanitizeHTML($path))) . '"';
     return '<a class="filename has-tooltip" href="' . $fileLink . '"' . $title . '>' . Util::sanitizeHTML($name) . '</a>';
 }
Ejemplo n.º 3
0
 /**
  * @param IEvent $event
  * @param string $parameter The parameter to be formatted
  * @param bool $allowHtml   Should HTML be used to format the parameter?
  * @param bool $verbose     Should paths, names, etc be shortened or full length
  * @return string The formatted parameter
  */
 public function format(IEvent $event, $parameter, $allowHtml, $verbose = false)
 {
     $param = $this->fixLegacyFilename($parameter);
     // If the activity is about the very same file, we use the current path
     // for the link generation instead of the one that was saved.
     $fileId = '';
     if ($event->getObjectType() === 'files' && $event->getObjectName() === $param) {
         $fileId = $event->getObjectId();
         $info = $this->infoCache->getInfoById($this->user, $fileId, $param);
     } else {
         $info = $this->infoCache->getInfoByPath($this->user, $param);
     }
     if ($info['is_dir']) {
         $linkData = ['dir' => $info['path']];
     } else {
         $parentDir = substr_count($info['path'], '/') === 1 ? '/' : dirname($info['path']);
         $fileName = basename($info['path']);
         $linkData = ['dir' => $parentDir, 'scrollto' => $fileName];
     }
     if ($info['view'] !== '') {
         $linkData['view'] = $info['view'];
     }
     $param = trim($param, '/');
     list($path, $name) = $this->splitPathFromFilename($param);
     $fileLink = $this->urlGenerator->linkTo('files', 'index.php', $linkData);
     if ($allowHtml === null) {
         return '<file link="' . $fileLink . '" id="' . Util::sanitizeHTML($fileId) . '">' . Util::sanitizeHTML($param) . '</file>';
     }
     if ($verbose || $path === '') {
         if (!$allowHtml) {
             return $param;
         }
         return '<a class="filename" href="' . $fileLink . '">' . Util::sanitizeHTML($param) . '</a>';
     }
     if (!$allowHtml) {
         return $name;
     }
     $title = ' title="' . $this->l->t('in %s', array(Util::sanitizeHTML($path))) . '"';
     return '<a class="filename has-tooltip" href="' . $fileLink . '"' . $title . '>' . Util::sanitizeHTML($name) . '</a>';
 }
Ejemplo n.º 4
0
 /**
  * create array with all vCard properties
  *
  * @param string $uri
  * @param VCard $vCard
  * @return array
  */
 protected function vCard2Array($uri, VCard $vCard)
 {
     $result = ['URI' => $uri];
     foreach ($vCard->children as $property) {
         $result[$property->name] = $property->getValue();
         if ($property->name === 'PHOTO' && $property->getValueType() === 'BINARY') {
             $url = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'remote.php') . '/dav/');
             $url .= implode('/', ['addressbooks', substr($this->addressBookInfo['principaluri'], 11), $this->addressBookInfo['uri'], $uri]) . '?photo';
             $result['PHOTO'] = 'VALUE=uri:' . $url;
         } else {
             $result[$property->name] = $property->getValue();
         }
     }
     if ($this->addressBookInfo['principaluri'] === 'principals/system/system' && $this->addressBookInfo['uri'] === 'system') {
         $result['isLocalSystemBook'] = true;
     }
     return $result;
 }
Ejemplo n.º 5
0
 /**
  * Returns the parameters to be used in the index function
  *
  * @param $appName
  *
  * @return array<string,string>
  */
 private function getIndexParameters($appName)
 {
     // Parameters sent to the index function
     $params = ['appName' => $appName, 'uploadUrl' => $this->urlGenerator->linkTo('files', 'ajax/upload.php'), 'publicUploadEnabled' => $this->appConfig->getAppValue('core', 'shareapi_allow_public_upload', 'yes'), 'mailNotificationEnabled' => $this->appConfig->getAppValue('core', 'shareapi_allow_mail_notification', 'no'), 'mailPublicNotificationEnabled' => $this->appConfig->getAppValue('core', 'shareapi_allow_public_notification', 'no')];
     return $params;
 }