示例#1
0
	function listFiles($username, $password, $tags, $workspaces, $name, $offset=0, $limit=1000, $type="") {
		$result = '';
		if ($this->loginUser($username, $password)) {
			$wspaces = Projects::findByCSVIds($workspaces);
			$ws = count($wspaces) > 0 ? $wspaces[0] : null; //TODO hay que buscar por todos los workspaces, por ahora solo funciona con el primero
			$alltags = explode(',', $tags);
			$tags = $alltags[0]; //TODO tambien falta hacer la b�squeda por varios tags, por ahora solo va a tomar el primero
			if (trim($tags) == '') $tags = null;
			
			if ($ws == null) {
				$files = ProjectFiles::getUserFiles(logged_user(), null, $tags, $type, ProjectFiles::ORDER_BY_NAME, 'ASC', $offset, $limit);
			} else {
				$listfiles = ProjectFiles::getProjectFiles($ws, null,
					false, ProjectFiles::ORDER_BY_NAME, 'ASC', ($offset/$limit), $limit, false, $tags,$type);
				if (is_array($listfiles) && count($listfiles))
					$files = $listfiles[0];
				else $files = array();
			}
			
			$name = trim($name);
			if (isset($files) && is_array($files)) {
				$this->initXml('files');
				foreach ($files as $f) {
					if ($name == '' || stristr($f->getFilename(), $name)) {
						$this->file_toxml($f);
					}
				}
				$result = $this->endXml();
			} else $result = '';
		}

		return $result;
	}
 /**
  * Loads the logged user's mp3 files
  *
  */
 function get_mp3()
 {
     ajx_current("empty");
     /* get arguments */
     $project = active_project();
     $tag = array_var($_GET, 'tag');
     $type = 'audio/mpeg';
     /* query */
     $files = ProjectFiles::getUserFiles(logged_user(), $project, $tag, $type, ProjectFiles::ORDER_BY_NAME, 'ASC');
     if (!is_array($files)) {
         $files = array();
     }
     /* prepare response object */
     $mp3 = array('mp3' => array());
     foreach ($files as $f) {
         $songname = $f->getProperty("songname");
         $artist = $f->getProperty("songartist");
         $album = $f->getProperty("songalbum");
         $track = $f->getProperty("songtrack");
         $year = $f->getProperty("songyear");
         $duration = $f->getProperty("songduration");
         $mp3["mp3"][] = array($songname, $artist, $album, $track, $year, $duration, $f->getDownloadUrl(), $f->getFilename(), $f->getId());
     }
     ajx_extra_data($mp3);
 }