Exemplo n.º 1
0
	/**
	 * Returns a list of all files tagged with the given tag.
	 *
	 * @NoAdminRequired
	 * @CORS
	 *
	 * @param array $tagName tag name to filter by
	 * @return DataResponse
	 */
	public function getFilesByTag($tagName) {
		$files = array();
		$fileInfos = $this->tagService->getFilesByTag($tagName);
		foreach ($fileInfos as &$fileInfo) {
			$file = \OCA\Files\Helper::formatFileInfo($fileInfo);
			$parts = explode('/', dirname($fileInfo->getPath()), 4);
			$file['path'] = '/' . $parts[3];
			$file['tags'] = array($tagName);
			$files[] = $file;
		}
		return new DataResponse(array('files' => $files), Http::STATUS_OK);
	}
Exemplo n.º 2
0
 /**
  * Returns a list of all files tagged with the given tag.
  *
  * @NoAdminRequired
  *
  * @param array|string $tagName tag name to filter by
  * @return DataResponse
  */
 public function getFilesByTag($tagName)
 {
     $files = array();
     $fileInfos = $this->tagService->getFilesByTag($tagName);
     foreach ($fileInfos as &$fileInfo) {
         $file = \OCA\Files\Helper::formatFileInfo($fileInfo);
         $parts = explode('/', dirname($fileInfo->getPath()), 4);
         if (isset($parts[3])) {
             $file['path'] = '/' . $parts[3];
         } else {
             $file['path'] = '/';
         }
         $file['tags'] = [$tagName];
         $files[] = $file;
     }
     return new DataResponse(['files' => $files]);
 }